mirror of
https://github.com/danog/telegram-tt.git
synced 2024-11-26 12:24:46 +01:00
1 line
105 KiB
Plaintext
1 line
105 KiB
Plaintext
{"version":3,"file":"8422.cfa7884f5b7ee933b6c3.js","mappings":"8TAmDA,MAGMA,EAA2C,CAC/CC,GAAIC,EAAAA,GACJC,WAAY,IACZC,KAAM,kBACNC,OAAO,EACPC,SAAU,GACVC,YAAa,IAGTC,GAA8BC,EAAAA,EAAAA,KAAUC,GAAOA,KAAM,KAAM,GAC3DC,GAA8BC,EAAAA,EAAAA,KAAUF,GAAOA,KAAM,KAAK,GAAO,GAulCvEG,eAAeC,EACbC,EAAiCC,EAAmBC,GACpD,UADyEC,EACzE,wDACIC,GAASC,EAAAA,EAAAA,MACb,MAAMC,EAAuB,WAAGC,EAAAA,EAAAA,IAA8BH,UAAjC,aAAG,EAAuCI,QACjEC,QAAeC,EAAAA,EAAAA,IAAQ,aAAc,CACzCC,MAAOC,EAAAA,GACPV,WAAAA,EACAW,SAAuB,aAAbb,EACVc,WAAYX,EACZY,iBAAkBX,EAAOW,iBACzBT,wBAAAA,IAGF,IAAKG,EACH,OAGF,MAAM,QAAEO,GAAYP,EAQpB,GANIO,EAAQC,OAAS,GAAKD,EAAQ,KAAOf,GACvCe,EAAQE,QAGVd,GAASC,EAAAA,EAAAA,MAELF,GAA8B,WAAbH,EAAuB,CAE1C,IAAKgB,EAAQG,SAAShC,EAAAA,IAAgC,CACpD,MAAMiC,QAAgBV,EAAAA,EAAAA,IAAQ,YAAa,CACzCrB,KAAM,OACNgC,KAAMpC,IAGRmB,GAASC,EAAAA,EAAAA,MAET,MAAMiB,EAAoBF,IAAWG,EAAAA,EAAAA,IAAWnB,EAAQgB,EAAQI,QAC5DF,IACFN,EAAQS,QAAQH,EAAkBpC,IAClCuB,EAAOiB,MAAMD,QAAQH,GACjBhB,IACFgB,EAAkBK,YAAcrB,IAKtC,MAAMsB,GAAcC,EAAAA,EAAAA,IAAkBzB,GAChC0B,EAAeF,EAAc,CAACA,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OG,eAAe,cAAgBH,EAAOG,eAAe,cACrE1B,EAAoB,CAClBjO,SAAUua,EACVhK,WAAYC,GAAaC,IAElB+J,EACT3M,EAAsB,CAAE2M,MAAAA,EAAOnU,YAAAA,EAAaD,OAAAA,IAE5CgI,EAAmB,CACjBpO,SAAUua,EACVhS,UAAW2H,OAAOuK,GAClBtK,UAAWD,OAAOE,GAClB1J,WAAYkK,EACZvK,YAAAA,EACAD,OAAAA,KAIN,MAEF,IAAK,cAAe,CAClB,MAAM,KACJqU,EADI,QACE5H,GACJrD,EAEJhH,EAAa,CACXvG,OAAS,IAAG4Q,IACZlT,GAAI8a,IAEN,MAEF,IAAK,KA8BL,IAAK,QAUL,QAGE,MArCF,IAAK,OAAQ,CACX,MAAM,OAAEC,GAAWlL,EAEnB1B,EAAiB,CAAER,KAAMoN,IACzB,MAEF,IAAK,WACL,IAAK,cAAe,CAClB,MAAM,IAAEC,GAAQnL,EAEhBzB,EAAe,CACb7I,eAAgB,CACd8K,UAAW2K,KAGf,MAEF,IAAK,QACL,IAAK,MACL,IAAK,UAAW,CACd,MAAQ/M,IAAKgN,EAAP,KAAiBvK,GAASb,EAChCxB,EAAkB,CAAEqC,KAAMC,EAAgBsK,EAAUvK,KACpD,MAOF,IAAK,UAAW,CACd,MAAM,KAAEK,GAASlB,EACjBtB,EAAY,CAAEwC,KAAAA,IACd,SASC,SAASZ,EAAqBD,GACnC,GAAKA,EAEL,OADcA,EAAOgL,cAAc3L,MAAM,KAC5B3F,QAAQzJ,GAA8Bgb,EAAAA,GAAAA,SAAwBhb,KAGtE,SAASwQ,EAAgB1C,EAAcyC,GAC5C,MAAO,CAACzC,EAAKyC,GAAM9G,OAAOC,SAAS2L,KAAK","sources":["webpack://telegram-t/./src/global/actions/api/chats.ts","webpack://telegram-t/./src/global/actions/ui/calls.ts","webpack://telegram-t/./src/global/reducers/calls.ts","webpack://telegram-t/./src/global/selectors/calls.ts","webpack://telegram-t/./src/util/deeplink.ts"],"sourcesContent":["import {\n addActionHandler, getActions, getGlobal, setGlobal,\n} from '../../index';\n\nimport type {\n ApiChat, ApiUser, ApiChatFolder, ApiError,\n} from '../../../api/types';\nimport { MAIN_THREAD_ID } from '../../../api/types';\nimport { NewChatMembersProgress, ChatCreationProgress, ManagementProgress } from '../../../types';\nimport type { GlobalActions, GlobalState } from '../../types';\n\nimport {\n ARCHIVED_FOLDER_ID,\n TOP_CHAT_MESSAGES_PRELOAD_LIMIT,\n CHAT_LIST_LOAD_SLICE,\n RE_TG_LINK,\n SERVICE_NOTIFICATIONS_USER_ID,\n TMP_CHAT_ID,\n ALL_FOLDER_ID,\n DEBUG,\n} from '../../../config';\nimport { callApi } from '../../../api/gramjs';\nimport {\n addChats, addUsers, addUserStatuses, replaceThreadParam,\n updateChatListIds, updateChats, updateChat, updateChatListSecondaryInfo,\n updateManagementProgress, leaveChat, replaceUsers, replaceUserStatuses,\n replaceChats, replaceChatListIds, addChatMembers,\n} from '../../reducers';\nimport {\n selectChat, selectUser, selectChatListType, selectIsChatPinned,\n selectChatFolder, selectSupportChat, selectChatByUsername, selectThreadTopMessageId,\n selectCurrentMessageList, selectThreadInfo, selectCurrentChat, selectLastServiceNotification,\n selectVisibleUsers, selectUserByPhoneNumber,\n} from '../../selectors';\nimport { buildCollectionByKey, omit } from '../../../util/iteratees';\nimport { debounce, pause, throttle } from '../../../util/schedulers';\nimport {\n isChatSummaryOnly,\n isChatArchived,\n isChatBasicGroup,\n isChatChannel,\n isChatSuperGroup,\n isUserBot,\n} from '../../helpers';\nimport { formatShareText, parseChooseParameter, processDeepLink } from '../../../util/deeplink';\nimport { updateGroupCall } from '../../reducers/calls';\nimport { selectGroupCall } from '../../selectors/calls';\nimport { getOrderedIds } from '../../../util/folderManager';\nimport * as langProvider from '../../../util/langProvider';\nimport { selectCurrentLimit } from '../../selectors/limits';\n\nconst TOP_CHAT_MESSAGES_PRELOAD_INTERVAL = 100;\nconst INFINITE_LOOP_MARKER = 100;\n\nconst SERVICE_NOTIFICATIONS_USER_MOCK: ApiUser = {\n id: SERVICE_NOTIFICATIONS_USER_ID,\n accessHash: '0',\n type: 'userTypeRegular',\n isMin: true,\n username: '',\n phoneNumber: '',\n};\n\nconst runThrottledForLoadTopChats = throttle((cb) => cb(), 3000, true);\nconst runDebouncedForLoadFullChat = debounce((cb) => cb(), 500, false, true);\n\naddActionHandler('preloadTopChatMessages', async (global, actions) => {\n const preloadedChatIds = new Set<string>();\n\n for (let i = 0; i < TOP_CHAT_MESSAGES_PRELOAD_LIMIT; i++) {\n await pause(TOP_CHAT_MESSAGES_PRELOAD_INTERVAL);\n\n const { chatId: currentChatId } = selectCurrentMessageList(global) || {};\n const folderAllOrderedIds = getOrderedIds(ALL_FOLDER_ID);\n const nextChatId = folderAllOrderedIds?.find((id) => id !== currentChatId && !preloadedChatIds.has(id));\n if (!nextChatId) {\n return;\n }\n\n preloadedChatIds.add(nextChatId);\n\n actions.loadViewportMessages({ chatId: nextChatId, threadId: MAIN_THREAD_ID });\n }\n});\n\naddActionHandler('openChat', (global, actions, payload) => {\n const { id, threadId = MAIN_THREAD_ID } = payload;\n if (!id) {\n return;\n }\n\n const { currentUserId } = global;\n const chat = selectChat(global, id);\n\n if (chat?.hasUnreadMark) {\n actions.toggleChatUnread({ id });\n }\n\n // Please telegram send us some updates about linked chat 🙏\n if (chat?.lastMessage?.threadInfo) {\n actions.requestThreadInfoUpdate({\n chatId: chat.lastMessage.threadInfo.chatId,\n threadId: chat.lastMessage.threadInfo.threadId,\n });\n }\n\n if (!chat) {\n if (id === currentUserId) {\n void callApi('fetchChat', { type: 'self' });\n } else {\n const user = selectUser(global, id);\n if (user) {\n void callApi('fetchChat', { type: 'user', user });\n }\n }\n } else if (isChatSummaryOnly(chat) && !chat.isMin) {\n actions.requestChatUpdate({ chatId: id });\n }\n\n if (threadId !== MAIN_THREAD_ID) {\n const topMessageId = selectThreadTopMessageId(global, id, threadId);\n if (!topMessageId) {\n actions.requestThreadInfoUpdate({ chatId: id, threadId });\n }\n }\n});\n\naddActionHandler('openLinkedChat', async (global, actions, payload) => {\n const { id } = payload!;\n const chat = selectChat(global, id);\n if (!chat) {\n return;\n }\n\n const chatFullInfo = await callApi('fetchFullChat', chat);\n\n if (chatFullInfo?.fullInfo?.linkedChatId) {\n actions.openChat({ id: chatFullInfo.fullInfo.linkedChatId });\n }\n});\n\naddActionHandler('focusMessageInComments', async (global, actions, payload) => {\n const { chatId, threadId, messageId } = payload!;\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n const result = await callApi('requestThreadInfoUpdate', { chat, threadId });\n if (!result) {\n return;\n }\n\n actions.focusMessage({ chatId, threadId, messageId });\n});\n\naddActionHandler('openSupportChat', async (global, actions) => {\n const chat = selectSupportChat(global);\n if (chat) {\n actions.openChat({ id: chat.id, shouldReplaceHistory: true });\n return;\n }\n\n actions.openChat({ id: TMP_CHAT_ID, shouldReplaceHistory: true });\n\n const result = await callApi('fetchChat', { type: 'support' });\n if (result) {\n actions.openChat({ id: result.chatId, shouldReplaceHistory: true });\n }\n});\n\naddActionHandler('loadAllChats', async (global, actions, payload) => {\n const listType = payload.listType as 'active' | 'archived';\n const { onReplace } = payload;\n let { shouldReplace } = payload;\n let i = 0;\n\n const getOrderDate = (chat: ApiChat) => {\n return chat.lastMessage?.date || chat.joinDate;\n };\n\n while (shouldReplace || !getGlobal().chats.isFullyLoaded[listType]) {\n if (i++ >= INFINITE_LOOP_MARKER) {\n if (DEBUG) {\n // eslint-disable-next-line no-console\n console.error('`actions/loadAllChats`: Infinite loop detected');\n }\n\n return;\n }\n\n global = getGlobal();\n\n if (global.connectionState !== 'connectionStateReady' || global.authState !== 'authorizationStateReady') {\n return;\n }\n\n const listIds = !shouldReplace && global.chats.listIds[listType];\n const oldestChat = listIds\n ? listIds\n /* eslint-disable @typescript-eslint/no-loop-func */\n .map((id) => global.chats.byId[id])\n .filter((chat) => (\n Boolean(chat && getOrderDate(chat))\n && chat.id !== SERVICE_NOTIFICATIONS_USER_ID\n && !selectIsChatPinned(global, chat.id)\n ))\n /* eslint-enable @typescript-eslint/no-loop-func */\n .sort((chat1, chat2) => getOrderDate(chat1)! - getOrderDate(chat2)!)[0]\n : undefined;\n\n await loadChats(listType, oldestChat?.id, oldestChat ? getOrderDate(oldestChat) : undefined, shouldReplace);\n\n if (shouldReplace) {\n onReplace?.();\n shouldReplace = false;\n }\n }\n});\n\naddActionHandler('loadFullChat', (global, actions, payload) => {\n const { chatId, force } = payload!;\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n if (force) {\n loadFullChat(chat);\n } else {\n runDebouncedForLoadFullChat(() => loadFullChat(chat));\n }\n});\n\naddActionHandler('loadTopChats', () => {\n runThrottledForLoadTopChats(() => loadChats('active'));\n});\n\naddActionHandler('requestChatUpdate', (global, actions, payload) => {\n const { serverTimeOffset } = global;\n const { chatId } = payload!;\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n void callApi('requestChatUpdate', {\n chat,\n serverTimeOffset,\n ...(chatId === SERVICE_NOTIFICATIONS_USER_ID && {\n lastLocalMessage: selectLastServiceNotification(global)?.message,\n }),\n });\n});\n\naddActionHandler('updateChatMutedState', (global, actions, payload) => {\n const { serverTimeOffset } = global;\n const { chatId, isMuted } = payload!;\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n setGlobal(updateChat(global, chatId, { isMuted }));\n void callApi('updateChatMutedState', { chat, isMuted, serverTimeOffset });\n});\n\naddActionHandler('createChannel', (global, actions, payload) => {\n const {\n title, about, photo, memberIds,\n } = payload!;\n\n const members = (memberIds as string[])\n .map((id) => selectUser(global, id))\n .filter<ApiUser>(Boolean as any);\n\n void createChannel(title, members, about, photo);\n});\n\naddActionHandler('joinChannel', (global, actions, payload) => {\n const { chatId } = payload!;\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n const { id: channelId, accessHash } = chat;\n\n if (!(channelId && accessHash)) {\n return;\n }\n\n void joinChannel(channelId, accessHash);\n});\n\naddActionHandler('deleteChatUser', (global, actions, payload) => {\n const { chatId, userId }: { chatId: string; userId: string } = payload!;\n const chat = selectChat(global, chatId);\n const user = selectUser(global, userId);\n if (!chat || !user) {\n return;\n }\n\n global = leaveChat(global, chatId);\n setGlobal(global);\n\n if (selectCurrentMessageList(global)?.chatId === chatId) {\n actions.openChat({ id: undefined });\n }\n\n void callApi('deleteChatUser', { chat, user });\n});\n\naddActionHandler('deleteChat', (global, actions, payload) => {\n const { chatId }: { chatId: string } = payload!;\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n global = leaveChat(global, chatId);\n setGlobal(global);\n\n if (selectCurrentMessageList(global)?.chatId === chatId) {\n actions.openChat({ id: undefined });\n }\n\n void callApi('deleteChat', { chatId: chat.id });\n});\n\naddActionHandler('leaveChannel', (global, actions, payload) => {\n const { chatId } = payload!;\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n global = leaveChat(global, chatId);\n setGlobal(global);\n\n if (selectCurrentMessageList(global)?.chatId === chatId) {\n actions.openChat({ id: undefined });\n }\n\n const { id: channelId, accessHash } = chat;\n if (channelId && accessHash) {\n void callApi('leaveChannel', { channelId, accessHash });\n }\n});\n\naddActionHandler('deleteChannel', (global, actions, payload) => {\n const { chatId } = payload!;\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n global = leaveChat(global, chatId);\n setGlobal(global);\n\n if (selectCurrentMessageList(global)?.chatId === chatId) {\n actions.openChat({ id: undefined });\n }\n\n const { id: channelId, accessHash } = chat;\n if (channelId && accessHash) {\n void callApi('deleteChannel', { channelId, accessHash });\n }\n});\n\naddActionHandler('createGroupChat', (global, actions, payload) => {\n const { title, memberIds, photo } = payload!;\n const members = (memberIds as string[])\n .map((id) => selectUser(global, id))\n .filter<ApiUser>(Boolean as any);\n\n void createGroupChat(title, members, photo);\n});\n\naddActionHandler('toggleChatPinned', (global, actions, payload) => {\n const { id, folderId } = payload!;\n const chat = selectChat(global, id);\n if (!chat) {\n return;\n }\n\n const limit = selectCurrentLimit(global, 'dialogFolderPinned');\n\n if (folderId) {\n const folder = selectChatFolder(global, folderId);\n if (folder) {\n const shouldBePinned = !selectIsChatPinned(global, id, folderId);\n\n const { pinnedChatIds, includedChatIds } = folder;\n const newPinnedIds = shouldBePinned\n ? [id, ...(pinnedChatIds || [])]\n : (pinnedChatIds || []).filter((pinnedId) => pinnedId !== id);\n\n // With both Pin and Unpin we need to re-add a user to the included group\n const newIncludedChatIds = [id, ...includedChatIds];\n\n void callApi('editChatFolder', {\n id: folderId,\n folderUpdate: {\n ...folder,\n pinnedChatIds: newPinnedIds,\n includedChatIds: newIncludedChatIds,\n },\n });\n }\n } else {\n const listType = selectChatListType(global, id);\n const isPinned = selectIsChatPinned(global, id, listType === 'archived' ? ARCHIVED_FOLDER_ID : undefined);\n\n const ids = global.chats.orderedPinnedIds[listType === 'archived' ? 'archived' : 'active'];\n if ((ids?.length || 0) >= limit && !isPinned) {\n actions.openLimitReachedModal({\n limit: 'dialogFolderPinned',\n });\n return;\n }\n void callApi('toggleChatPinned', { chat, shouldBePinned: !isPinned });\n }\n});\n\naddActionHandler('toggleChatArchived', (global, actions, payload) => {\n const { id } = payload!;\n const chat = selectChat(global, id);\n if (chat) {\n void callApi('toggleChatArchived', {\n chat,\n folderId: isChatArchived(chat) ? 0 : ARCHIVED_FOLDER_ID,\n });\n }\n});\n\naddActionHandler('loadChatFolders', () => {\n void loadChatFolders();\n});\n\naddActionHandler('loadRecommendedChatFolders', () => {\n void loadRecommendedChatFolders();\n});\n\naddActionHandler('editChatFolders', (global, actions, payload) => {\n const { chatId, idsToRemove, idsToAdd } = payload!;\n const limit = selectCurrentLimit(global, 'dialogFiltersChats');\n\n const isLimitReached = (idsToAdd as number[])\n .some((id) => selectChatFolder(global, id)!.includedChatIds.length >= limit);\n if (isLimitReached) {\n actions.openLimitReachedModal({ limit: 'dialogFiltersChats' });\n return;\n }\n\n (idsToRemove as number[]).forEach(async (id) => {\n const folder = selectChatFolder(global, id);\n if (folder) {\n await callApi('editChatFolder', {\n id,\n folderUpdate: {\n ...folder,\n pinnedChatIds: folder.pinnedChatIds?.filter((pinnedId) => pinnedId !== chatId),\n includedChatIds: folder.includedChatIds.filter((includedId) => includedId !== chatId),\n },\n });\n }\n });\n\n (idsToAdd as number[]).forEach(async (id) => {\n const folder = selectChatFolder(global, id);\n if (folder) {\n await callApi('editChatFolder', {\n id,\n folderUpdate: {\n ...folder,\n includedChatIds: folder.includedChatIds.concat(chatId),\n },\n });\n }\n });\n});\n\naddActionHandler('editChatFolder', (global, actions, payload) => {\n const { id, folderUpdate } = payload!;\n const folder = selectChatFolder(global, id);\n\n if (folder) {\n void callApi('editChatFolder', {\n id,\n folderUpdate: {\n id,\n emoticon: folder.emoticon,\n pinnedChatIds: folder.pinnedChatIds,\n ...folderUpdate,\n },\n });\n }\n});\n\naddActionHandler('addChatFolder', (global, actions, payload) => {\n const { folder } = payload!;\n const { orderedIds, byId } = global.chatFolders;\n\n const limit = selectCurrentLimit(global, 'dialogFilters');\n if (Object.keys(byId).length >= limit) {\n actions.openLimitReachedModal({\n limit: 'dialogFilters',\n });\n return;\n }\n\n const maxId = Math.max(...(orderedIds || []), ARCHIVED_FOLDER_ID);\n\n void createChatFolder(folder, maxId);\n});\n\naddActionHandler('sortChatFolders', async (global, actions, payload) => {\n const { folderIds } = payload!;\n\n const result = await callApi('sortChatFolders', folderIds);\n if (result) {\n global = getGlobal();\n setGlobal({\n ...global,\n chatFolders: {\n ...global.chatFolders,\n orderedIds: folderIds,\n },\n });\n }\n});\n\naddActionHandler('deleteChatFolder', (global, actions, payload) => {\n const { id } = payload!;\n const folder = selectChatFolder(global, id);\n\n if (folder) {\n void deleteChatFolder(id);\n }\n});\n\naddActionHandler('toggleChatUnread', (global, actions, payload) => {\n const { id } = payload!;\n const { serverTimeOffset } = global;\n const chat = selectChat(global, id);\n if (chat) {\n if (chat.unreadCount) {\n void callApi('markMessageListRead', { serverTimeOffset, chat, threadId: MAIN_THREAD_ID });\n } else {\n void callApi('toggleDialogUnread', {\n chat,\n hasUnreadMark: !chat.hasUnreadMark,\n });\n }\n }\n});\n\naddActionHandler('openChatByInvite', async (global, actions, payload) => {\n const { hash } = payload!;\n\n const result = await callApi('openChatByInvite', hash);\n if (!result) {\n return;\n }\n\n actions.openChat({ id: result.chatId });\n});\n\naddActionHandler('openChatByPhoneNumber', async (global, actions, payload) => {\n const { phoneNumber, startAttach, attach } = payload!;\n\n // Open temporary empty chat to make the click response feel faster\n actions.openChat({ id: TMP_CHAT_ID });\n\n const chat = await fetchChatByPhoneNumber(phoneNumber);\n if (!chat) {\n actions.openPreviousChat();\n actions.showNotification({\n message: langProvider.getTranslation('lng_username_by_phone_not_found').replace('{phone}', phoneNumber),\n });\n return;\n }\n\n actions.openChat({ id: chat.id });\n\n if (attach) {\n openAttachMenuFromLink(actions, chat.id, attach, startAttach);\n }\n});\n\naddActionHandler('openTelegramLink', (global, actions, payload) => {\n const { url } = payload!;\n const {\n openChatByPhoneNumber,\n openChatByInvite,\n openStickerSet,\n openChatWithDraft,\n joinVoiceChatByLink,\n showNotification,\n focusMessage,\n openInvoice,\n processAttachBotParameters,\n openChatByUsername: openChatByUsernameAction,\n } = actions;\n\n if (url.match(RE_TG_LINK)) {\n processDeepLink(url);\n return;\n }\n\n const uri = new URL(url.startsWith('http') ? url : `https://${url}`);\n if (uri.hostname === 't.me' && uri.pathname === '/') {\n window.open(uri.toString(), '_blank', 'noopener');\n return;\n }\n\n const hostParts = uri.hostname.split('.');\n if (hostParts.length > 3) return;\n const pathname = hostParts.length === 3 ? `${hostParts[0]}/${uri.pathname}` : uri.pathname;\n const [part1, part2, part3] = pathname.split('/').filter(Boolean).map((l) => decodeURI(l));\n const params = Object.fromEntries(uri.searchParams);\n\n let hash: string | undefined;\n if (part1 === 'joinchat') {\n hash = part2;\n }\n\n const startAttach = params.hasOwnProperty('startattach') && !params.startattach ? true : params.startattach;\n const choose = parseChooseParameter(params.choose);\n\n if (part1.match(/^\\+([0-9]+)(\\?|$)/)) {\n openChatByPhoneNumber({\n phoneNumber: part1.substr(1, part1.length - 1),\n startAttach,\n attach: params.attach,\n });\n return;\n }\n\n if (part1.startsWith(' ') || part1.startsWith('+')) {\n hash = part1.substr(1, part1.length - 1);\n }\n\n if (hash) {\n openChatByInvite({ hash });\n return;\n }\n\n if (part1 === 'addstickers' || part1 === 'addemoji') {\n openStickerSet({\n stickerSetInfo: {\n shortName: part2,\n },\n });\n return;\n }\n\n const chatOrChannelPostId = part2 || undefined;\n const messageId = part3 ? Number(part3) : undefined;\n const commentId = params.comment ? Number(params.comment) : undefined;\n\n if (part1 === 'share') {\n const text = formatShareText(params.url, params.text);\n openChatWithDraft({ text });\n } else if (params.hasOwnProperty('voicechat') || params.hasOwnProperty('livestream')) {\n joinVoiceChatByLink({\n username: part1,\n inviteHash: params.voicechat || params.livestream,\n });\n } else if (part1 === 'c' && chatOrChannelPostId && messageId) {\n const chatId = `-${chatOrChannelPostId}`;\n const chat = selectChat(global, chatId);\n if (!chat) {\n showNotification({ message: 'Chat does not exist' });\n return;\n }\n\n focusMessage({\n chatId,\n messageId,\n });\n } else if (part1.startsWith('$')) {\n openInvoice({\n slug: part1.substring(1),\n });\n } else if (part1 === 'invoice') {\n openInvoice({\n slug: part2,\n });\n } else if (startAttach && choose) {\n processAttachBotParameters({\n username: part1,\n filter: choose,\n ...(typeof startAttach === 'string' && { startParam: startAttach }),\n });\n } else {\n openChatByUsernameAction({\n username: part1,\n messageId: messageId || Number(chatOrChannelPostId),\n commentId,\n startParam: params.start,\n startAttach,\n attach: params.attach,\n });\n }\n});\n\naddActionHandler('acceptInviteConfirmation', async (global, actions, payload) => {\n const { hash } = payload!;\n const result = await callApi('importChatInvite', { hash });\n if (!result) {\n return;\n }\n\n actions.openChat({ id: result.id });\n});\n\naddActionHandler('openChatByUsername', async (global, actions, payload) => {\n const {\n username, messageId, commentId, startParam, startAttach, attach,\n } = payload!;\n\n const chat = selectCurrentChat(global);\n\n if (!commentId) {\n if (chat && chat.username === username && !startAttach && !startParam) {\n actions.focusMessage({ chatId: chat.id, messageId });\n return;\n }\n await openChatByUsername(actions, username, messageId, startParam, startAttach, attach);\n return;\n }\n\n const { chatId, type } = selectCurrentMessageList(global) || {};\n const usernameChat = selectChatByUsername(global, username);\n if (chatId && usernameChat && type === 'thread') {\n const threadInfo = selectThreadInfo(global, chatId, messageId);\n\n if (threadInfo && threadInfo.chatId === chatId) {\n actions.focusMessage({\n chatId: threadInfo.chatId,\n threadId: threadInfo.threadId,\n messageId: commentId,\n });\n return;\n }\n }\n\n if (!messageId) return;\n\n void openCommentsByUsername(actions, username, messageId, commentId);\n});\n\naddActionHandler('togglePreHistoryHidden', async (global, actions, payload) => {\n const { chatId, isEnabled } = payload!;\n\n let chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n if (isChatBasicGroup(chat)) {\n chat = await migrateChat(chat);\n\n if (!chat) {\n return;\n }\n\n actions.openChat({ id: chat.id });\n }\n\n void callApi('togglePreHistoryHidden', { chat, isEnabled });\n});\n\naddActionHandler('updateChatDefaultBannedRights', (global, actions, payload) => {\n const { chatId, bannedRights } = payload!;\n const chat = selectChat(global, chatId);\n\n if (!chat) {\n return;\n }\n\n void callApi('updateChatDefaultBannedRights', { chat, bannedRights });\n});\n\naddActionHandler('updateChatMemberBannedRights', async (global, actions, payload) => {\n const { chatId, userId, bannedRights } = payload!;\n let chat = selectChat(global, chatId);\n const user = selectUser(global, userId);\n\n if (!chat || !user) {\n return;\n }\n\n if (isChatBasicGroup(chat)) {\n chat = await migrateChat(chat);\n\n if (!chat) {\n return;\n }\n\n actions.openChat({ id: chat.id });\n }\n\n await callApi('updateChatMemberBannedRights', { chat, user, bannedRights });\n\n global = getGlobal();\n\n const chatAfterUpdate = selectChat(global, chatId);\n\n if (!chatAfterUpdate || !chatAfterUpdate.fullInfo) {\n return;\n }\n\n const { members, kickedMembers } = chatAfterUpdate.fullInfo;\n\n const isBanned = Boolean(bannedRights.viewMessages);\n const isUnblocked = !Object.keys(bannedRights).length;\n\n setGlobal(updateChat(global, chatId, {\n fullInfo: {\n ...chatAfterUpdate.fullInfo,\n ...(members && isBanned && {\n members: members.filter((m) => m.userId !== userId),\n }),\n ...(members && !isBanned && {\n members: members.map((m) => (\n m.userId === userId\n ? { ...m, bannedRights }\n : m\n )),\n }),\n ...(isUnblocked && kickedMembers && {\n kickedMembers: kickedMembers.filter((m) => m.userId !== userId),\n }),\n },\n }));\n});\n\naddActionHandler('updateChatAdmin', async (global, actions, payload) => {\n const {\n chatId, userId, adminRights, customTitle,\n } = payload!;\n\n let chat = selectChat(global, chatId);\n const user = selectUser(global, userId);\n if (!chat || !user) {\n return;\n }\n\n if (isChatBasicGroup(chat)) {\n chat = await migrateChat(chat);\n if (!chat) {\n return;\n }\n\n actions.openChat({ id: chat.id });\n }\n\n await callApi('updateChatAdmin', {\n chat, user, adminRights, customTitle,\n });\n\n const chatAfterUpdate = await callApi('fetchFullChat', chat);\n if (!chatAfterUpdate?.fullInfo) {\n return;\n }\n\n const { adminMembers } = chatAfterUpdate.fullInfo;\n const isDismissed = !Object.keys(adminRights).length;\n\n global = getGlobal();\n\n setGlobal(updateChat(global, chatId, {\n fullInfo: {\n ...chatAfterUpdate.fullInfo,\n ...(adminMembers && isDismissed && {\n adminMembers: adminMembers.filter((m) => m.userId !== userId),\n }),\n ...(adminMembers && !isDismissed && {\n adminMembers: adminMembers.map((m) => (\n m.userId === userId\n ? { ...m, adminRights, customTitle }\n : m\n )),\n }),\n },\n }));\n});\n\naddActionHandler('updateChat', async (global, actions, payload) => {\n const {\n chatId, title, about, photo,\n } = payload!;\n\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n setGlobal(updateManagementProgress(getGlobal(), ManagementProgress.InProgress));\n\n await Promise.all([\n chat.title !== title\n ? callApi('updateChatTitle', chat, title)\n : undefined,\n chat.fullInfo && chat.fullInfo.about !== about\n ? callApi('updateChatAbout', chat, about)\n : undefined,\n photo\n ? callApi('editChatPhoto', { chatId, accessHash: chat.accessHash, photo })\n : undefined,\n ]);\n\n setGlobal(updateManagementProgress(getGlobal(), ManagementProgress.Complete));\n});\n\naddActionHandler('toggleSignatures', (global, actions, payload) => {\n const { chatId, isEnabled } = payload!;\n const chat = selectChat(global, chatId);\n\n if (!chat) {\n return;\n }\n\n void callApi('toggleSignatures', { chat, isEnabled });\n});\n\naddActionHandler('loadGroupsForDiscussion', async (global) => {\n const groups = await callApi('fetchGroupsForDiscussion');\n if (!groups) {\n return;\n }\n\n const addedById = groups.reduce((result, group) => {\n if (group) {\n result[group.id] = group;\n }\n\n return result;\n }, {} as Record<string, ApiChat>);\n\n global = getGlobal();\n global = addChats(global, addedById);\n setGlobal({\n ...global,\n chats: {\n ...global.chats,\n forDiscussionIds: Object.keys(addedById),\n },\n });\n});\n\naddActionHandler('linkDiscussionGroup', async (global, actions, payload) => {\n const { channelId, chatId } = payload!;\n\n const channel = selectChat(global, channelId);\n let chat = selectChat(global, chatId);\n if (!channel || !chat) {\n return;\n }\n\n if (isChatBasicGroup(chat)) {\n chat = await migrateChat(chat);\n\n if (!chat) {\n return;\n }\n\n actions.openChat({ id: chat.id });\n }\n\n let { fullInfo } = chat;\n if (!fullInfo) {\n const fullChat = await callApi('fetchFullChat', chat);\n if (!fullChat) {\n return;\n }\n\n fullInfo = fullChat.fullInfo;\n }\n\n if (fullInfo!.isPreHistoryHidden) {\n await callApi('togglePreHistoryHidden', { chat, isEnabled: false });\n }\n\n void callApi('setDiscussionGroup', { channel, chat });\n});\n\naddActionHandler('unlinkDiscussionGroup', async (global, actions, payload) => {\n const { channelId } = payload!;\n\n const channel = selectChat(global, channelId);\n if (!channel) {\n return;\n }\n\n let chat: ApiChat | undefined;\n if (channel.fullInfo?.linkedChatId) {\n chat = selectChat(global, channel.fullInfo.linkedChatId);\n }\n\n await callApi('setDiscussionGroup', { channel });\n if (chat) {\n loadFullChat(chat);\n }\n});\n\naddActionHandler('setActiveChatFolder', (global, actions, payload) => {\n const maxFolders = selectCurrentLimit(global, 'dialogFilters');\n\n const isBlocked = payload + 1 > maxFolders;\n\n if (isBlocked) {\n actions.openLimitReachedModal({\n limit: 'dialogFilters',\n });\n return undefined;\n }\n\n return {\n ...global,\n chatFolders: {\n ...global.chatFolders,\n activeChatFolder: payload,\n },\n };\n});\n\naddActionHandler('resetOpenChatWithDraft', (global) => {\n return {\n ...global,\n requestedDraft: undefined,\n };\n});\n\naddActionHandler('loadMoreMembers', async (global) => {\n const { chatId } = selectCurrentMessageList(global) || {};\n const chat = chatId ? selectChat(global, chatId) : undefined;\n if (!chat || isChatBasicGroup(chat)) {\n return;\n }\n\n const offset = (chat.fullInfo?.members?.length) || undefined;\n const result = await callApi('fetchMembers', chat.id, chat.accessHash!, 'recent', offset);\n if (!result) {\n return;\n }\n\n const { members, users, userStatusesById } = result;\n if (!members || !members.length) {\n return;\n }\n\n global = getGlobal();\n global = addUsers(global, buildCollectionByKey(users, 'id'));\n global = addUserStatuses(global, userStatusesById);\n global = addChatMembers(global, chat, members);\n setGlobal(global);\n});\n\naddActionHandler('addChatMembers', async (global, actions, payload) => {\n const { chatId, memberIds } = payload;\n const chat = selectChat(global, chatId);\n const users = (memberIds as string[]).map((userId) => selectUser(global, userId)).filter<ApiUser>(Boolean as any);\n\n if (!chat || !users.length) {\n return;\n }\n\n actions.setNewChatMembersDialogState(NewChatMembersProgress.Loading);\n await callApi('addChatMembers', chat, users);\n actions.setNewChatMembersDialogState(NewChatMembersProgress.Closed);\n loadFullChat(chat);\n});\n\naddActionHandler('deleteChatMember', async (global, actions, payload) => {\n const { chatId, userId } = payload;\n const chat = selectChat(global, chatId);\n const user = selectUser(global, userId);\n\n if (!chat || !user) {\n return;\n }\n\n await callApi('deleteChatMember', chat, user);\n loadFullChat(chat);\n});\n\naddActionHandler('toggleIsProtected', (global, actions, payload) => {\n const { chatId, isProtected } = payload;\n const chat = selectChat(global, chatId);\n\n if (!chat) {\n return;\n }\n\n void callApi('toggleIsProtected', { chat, isProtected });\n});\n\naddActionHandler('setChatEnabledReactions', async (global, actions, payload) => {\n const { chatId, enabledReactions } = payload;\n const chat = selectChat(global, chatId);\n if (!chat) return;\n\n await callApi('setChatEnabledReactions', {\n chat,\n enabledReactions,\n });\n\n void loadFullChat(chat);\n});\n\naddActionHandler('loadChatSettings', async (global, actions, payload) => {\n const { chatId } = payload!;\n const chat = selectChat(global, chatId);\n if (!chat) return;\n\n const settings = await callApi('fetchChatSettings', chat);\n if (!settings) return;\n\n setGlobal(updateChat(getGlobal(), chat.id, { settings }));\n});\n\naddActionHandler('toggleJoinToSend', async (global, actions, payload) => {\n const { chatId, isEnabled } = payload;\n const chat = selectChat(global, chatId);\n if (!chat) return;\n if (!isChatSuperGroup(chat) && !isChatChannel(chat)) return;\n\n await callApi('toggleJoinToSend', chat, isEnabled);\n});\n\naddActionHandler('toggleJoinRequest', async (global, actions, payload) => {\n const { chatId, isEnabled } = payload;\n const chat = selectChat(global, chatId);\n if (!chat) return;\n if (!isChatSuperGroup(chat) && !isChatChannel(chat)) return;\n\n await callApi('toggleJoinRequest', chat, isEnabled);\n});\n\naddActionHandler('processAttachBotParameters', async (global, actions, payload) => {\n const { username, filter, startParam } = payload;\n const bot = await getAttachBotOrNotify(global, username);\n if (!bot) return;\n\n global = getGlobal();\n const { attachMenu: { bots } } = global;\n if (!bots[bot.id]) {\n setGlobal({\n ...global,\n requestedAttachBotInstall: {\n botId: bot.id,\n onConfirm: {\n action: 'requestAttachBotInChat',\n payload: {\n botId: bot.id,\n filter,\n startParam,\n },\n },\n },\n });\n return;\n }\n\n getActions().requestAttachBotInChat({\n botId: bot.id,\n filter,\n startParam,\n });\n});\n\nasync function loadChats(\n listType: 'active' | 'archived', offsetId?: string, offsetDate?: number, shouldReplace = false,\n) {\n let global = getGlobal();\n const lastLocalServiceMessage = selectLastServiceNotification(global)?.message;\n const result = await callApi('fetchChats', {\n limit: CHAT_LIST_LOAD_SLICE,\n offsetDate,\n archived: listType === 'archived',\n withPinned: shouldReplace,\n serverTimeOffset: global.serverTimeOffset,\n lastLocalServiceMessage,\n });\n\n if (!result) {\n return;\n }\n\n const { chatIds } = result;\n\n if (chatIds.length > 0 && chatIds[0] === offsetId) {\n chatIds.shift();\n }\n\n global = getGlobal();\n\n if (shouldReplace && listType === 'active') {\n // Always include service notifications chat\n if (!chatIds.includes(SERVICE_NOTIFICATIONS_USER_ID)) {\n const result2 = await callApi('fetchChat', {\n type: 'user',\n user: SERVICE_NOTIFICATIONS_USER_MOCK,\n });\n\n global = getGlobal();\n\n const notificationsChat = result2 && selectChat(global, result2.chatId);\n if (notificationsChat) {\n chatIds.unshift(notificationsChat.id);\n result.chats.unshift(notificationsChat);\n if (lastLocalServiceMessage) {\n notificationsChat.lastMessage = lastLocalServiceMessage;\n }\n }\n }\n\n const currentChat = selectCurrentChat(global);\n const visibleChats = currentChat ? [currentChat] : [];\n\n const visibleUsers = selectVisibleUsers(global) || [];\n if (global.currentUserId && global.users.byId[global.currentUserId]) {\n visibleUsers.push(global.users.byId[global.currentUserId]);\n }\n\n global = replaceUsers(global, buildCollectionByKey(visibleUsers.concat(result.users), 'id'));\n global = replaceUserStatuses(global, result.userStatusesById);\n global = replaceChats(global, buildCollectionByKey(visibleChats.concat(result.chats), 'id'));\n global = replaceChatListIds(global, listType, chatIds);\n } else if (shouldReplace && listType === 'archived') {\n global = addUsers(global, buildCollectionByKey(result.users, 'id'));\n global = addUserStatuses(global, result.userStatusesById);\n global = updateChats(global, buildCollectionByKey(result.chats, 'id'));\n global = replaceChatListIds(global, listType, chatIds);\n } else {\n global = addUsers(global, buildCollectionByKey(result.users, 'id'));\n global = addUserStatuses(global, result.userStatusesById);\n global = updateChats(global, buildCollectionByKey(result.chats, 'id'));\n global = updateChatListIds(global, listType, chatIds);\n }\n\n global = updateChatListSecondaryInfo(global, listType, result);\n\n Object.keys(result.draftsById).forEach((chatId) => {\n global = replaceThreadParam(\n global, chatId, MAIN_THREAD_ID, 'draft', result.draftsById[chatId],\n );\n });\n\n Object.keys(result.replyingToById).forEach((chatId) => {\n global = replaceThreadParam(\n global, chatId, MAIN_THREAD_ID, 'replyingToId', result.replyingToById[chatId],\n );\n });\n\n if (chatIds.length === 0 && !global.chats.isFullyLoaded[listType]) {\n global = {\n ...global,\n chats: {\n ...global.chats,\n isFullyLoaded: {\n ...global.chats.isFullyLoaded,\n [listType]: true,\n },\n },\n };\n }\n\n setGlobal(global);\n}\n\nexport async function loadFullChat(chat: ApiChat) {\n const result = await callApi('fetchFullChat', chat);\n if (!result) {\n return undefined;\n }\n\n const {\n users, userStatusesById, fullInfo, groupCall, membersCount,\n } = result;\n\n let global = getGlobal();\n if (users) {\n global = addUsers(global, buildCollectionByKey(users, 'id'));\n }\n\n if (userStatusesById) {\n global = addUserStatuses(global, userStatusesById);\n }\n\n if (groupCall) {\n const existingGroupCall = selectGroupCall(global, groupCall.id!);\n global = updateGroupCall(\n global,\n groupCall.id!,\n omit(groupCall, ['connectionState']),\n undefined,\n existingGroupCall ? undefined : groupCall.participantsCount,\n );\n }\n\n global = updateChat(global, chat.id, {\n fullInfo,\n ...(membersCount && { membersCount }),\n });\n\n setGlobal(global);\n\n const stickerSet = fullInfo.stickerSet;\n if (stickerSet) {\n getActions().loadStickers({\n stickerSetInfo: {\n id: stickerSet.id,\n accessHash: stickerSet.accessHash,\n },\n });\n }\n\n return result;\n}\n\nasync function createChannel(title: string, users: ApiUser[], about?: string, photo?: File) {\n setGlobal({\n ...getGlobal(),\n chatCreation: {\n progress: ChatCreationProgress.InProgress,\n },\n });\n\n let createdChannel: ApiChat | undefined;\n\n try {\n createdChannel = await callApi('createChannel', { title, about, users });\n } catch (error) {\n const global = getGlobal();\n\n setGlobal({\n ...global,\n chatCreation: {\n progress: ChatCreationProgress.Error,\n },\n });\n\n if ((error as ApiError).message === 'CHANNELS_TOO_MUCH') {\n getActions().openLimitReachedModal({ limit: 'channels' });\n } else {\n getActions().showDialog({ data: { ...(error as ApiError), hasErrorKey: true } });\n }\n }\n\n if (!createdChannel) {\n return;\n }\n\n const { id: channelId, accessHash } = createdChannel;\n\n let global = getGlobal();\n global = updateChat(global, channelId, createdChannel);\n global = {\n ...global,\n chatCreation: {\n ...global.chatCreation,\n progress: createdChannel ? ChatCreationProgress.Complete : ChatCreationProgress.Error,\n },\n };\n setGlobal(global);\n getActions().openChat({ id: channelId, shouldReplaceHistory: true });\n\n if (channelId && accessHash && photo) {\n await callApi('editChatPhoto', { chatId: channelId, accessHash, photo });\n }\n}\n\nasync function joinChannel(channelId: string, accessHash: string) {\n try {\n await callApi('joinChannel', { channelId, accessHash });\n } catch (error) {\n if ((error as ApiError).message === 'CHANNELS_TOO_MUCH') {\n getActions().openLimitReachedModal({ limit: 'channels' });\n } else {\n getActions().showDialog({ data: { ...(error as ApiError), hasErrorKey: true } });\n }\n }\n}\n\nasync function createGroupChat(title: string, users: ApiUser[], photo?: File) {\n setGlobal({\n ...getGlobal(),\n chatCreation: {\n progress: ChatCreationProgress.InProgress,\n },\n });\n\n try {\n const createdChat = await callApi('createGroupChat', {\n title,\n users,\n });\n\n if (!createdChat) {\n return;\n }\n\n const { id: chatId } = createdChat;\n\n let global = getGlobal();\n global = updateChat(global, chatId, createdChat);\n global = {\n ...global,\n chatCreation: {\n ...global.chatCreation,\n progress: createdChat ? ChatCreationProgress.Complete : ChatCreationProgress.Error,\n },\n };\n setGlobal(global);\n getActions()\n .openChat({\n id: chatId,\n shouldReplaceHistory: true,\n });\n\n if (chatId && photo) {\n await callApi('editChatPhoto', {\n chatId,\n photo,\n });\n }\n } catch (e: any) {\n if (e.message === 'USERS_TOO_FEW') {\n const global = getGlobal();\n setGlobal({\n ...global,\n chatCreation: {\n ...global.chatCreation,\n progress: ChatCreationProgress.Error,\n error: 'CreateGroupError',\n },\n });\n }\n }\n}\n\nexport async function migrateChat(chat: ApiChat): Promise<ApiChat | undefined> {\n try {\n const supergroup = await callApi('migrateChat', chat);\n\n return supergroup;\n } catch (error) {\n if ((error as ApiError).message === 'CHANNELS_TOO_MUCH') {\n getActions().openLimitReachedModal({ limit: 'channels' });\n } else {\n getActions().showDialog({ data: { ...(error as ApiError), hasErrorKey: true } });\n }\n\n return undefined;\n }\n}\n\nasync function loadChatFolders() {\n const chatFolders = await callApi('fetchChatFolders');\n\n if (chatFolders) {\n const global = getGlobal();\n\n setGlobal({\n ...global,\n chatFolders: {\n ...global.chatFolders,\n ...chatFolders,\n },\n });\n }\n}\n\nasync function loadRecommendedChatFolders() {\n const recommendedChatFolders = await callApi('fetchRecommendedChatFolders');\n\n if (recommendedChatFolders) {\n const global = getGlobal();\n\n setGlobal({\n ...global,\n chatFolders: {\n ...global.chatFolders,\n recommended: recommendedChatFolders,\n },\n });\n }\n}\n\nasync function createChatFolder(folder: ApiChatFolder, maxId: number) {\n // Clear fields from recommended folders\n const { id: recommendedId, description, ...newFolder } = folder;\n\n await callApi('editChatFolder', {\n id: maxId + 1,\n folderUpdate: {\n id: maxId + 1,\n ...newFolder,\n },\n });\n\n if (!description) {\n return;\n }\n\n const global = getGlobal();\n const { recommended } = global.chatFolders;\n\n if (recommended) {\n setGlobal({\n ...global,\n chatFolders: {\n ...global.chatFolders,\n recommended: recommended.filter(({ id }) => id !== recommendedId),\n },\n });\n }\n}\n\nasync function deleteChatFolder(id: number) {\n await callApi('deleteChatFolder', id);\n}\n\nexport async function fetchChatByUsername(\n username: string,\n) {\n const global = getGlobal();\n const localChat = selectChatByUsername(global, username);\n if (localChat && !localChat.isMin) {\n return localChat;\n }\n\n const chat = await callApi('getChatByUsername', username);\n if (!chat) {\n return undefined;\n }\n\n setGlobal(updateChat(getGlobal(), chat.id, chat));\n\n return chat;\n}\n\nexport async function fetchChatByPhoneNumber(phoneNumber: string) {\n const global = getGlobal();\n const localUser = selectUserByPhoneNumber(global, phoneNumber);\n if (localUser && !localUser.isMin) {\n return selectChat(global, localUser.id);\n }\n\n const chat = await callApi('getChatByPhoneNumber', phoneNumber);\n if (!chat) {\n return undefined;\n }\n\n setGlobal(updateChat(getGlobal(), chat.id, chat));\n\n return chat;\n}\n\nasync function getAttachBotOrNotify(global: GlobalState, username: string) {\n const chat = await fetchChatByUsername(username);\n if (!chat) return undefined;\n\n const user = selectUser(global, chat.id);\n if (!user) return undefined;\n\n const isBot = isUserBot(user);\n if (!isBot || !user.isAttachBot) {\n getActions().showNotification({ message: langProvider.getTranslation('WebApp.AddToAttachmentUnavailableError') });\n\n return undefined;\n }\n return user;\n}\n\nasync function openChatByUsername(\n actions: GlobalActions,\n username: string,\n channelPostId?: number,\n startParam?: string,\n startAttach?: string | boolean,\n attach?: string,\n) {\n const global = getGlobal();\n const currentChat = selectCurrentChat(global);\n\n // Attach in the current chat\n if (startAttach && !attach) {\n const user = await getAttachBotOrNotify(global, username);\n\n if (!currentChat || !user) return;\n\n actions.callAttachBot({\n botId: user.id,\n chatId: currentChat.id,\n ...(typeof startAttach === 'string' && { startParam: startAttach }),\n });\n\n return;\n }\n\n const isCurrentChat = currentChat?.username === username;\n\n if (!isCurrentChat) {\n // Open temporary empty chat to make the click response feel faster\n actions.openChat({ id: TMP_CHAT_ID });\n }\n\n const chat = await fetchChatByUsername(username);\n if (!chat) {\n if (!isCurrentChat) {\n actions.openPreviousChat();\n actions.showNotification({ message: 'User does not exist' });\n }\n\n return;\n }\n\n if (channelPostId) {\n actions.focusMessage({ chatId: chat.id, messageId: channelPostId });\n } else if (!isCurrentChat) {\n actions.openChat({ id: chat.id });\n }\n\n if (startParam) {\n actions.startBot({ botId: chat.id, param: startParam });\n }\n\n if (attach) {\n openAttachMenuFromLink(actions, chat.id, attach, startAttach);\n }\n}\n\nasync function openAttachMenuFromLink(\n actions: GlobalActions,\n chatId: string, attach: string, startAttach?: string | boolean,\n) {\n const botChat = await fetchChatByUsername(attach);\n if (!botChat) return;\n const botUser = selectUser(getGlobal(), botChat.id);\n if (!botUser || !botUser.isAttachBot) {\n actions.showNotification({ message: langProvider.getTranslation('WebApp.AddToAttachmentUnavailableError') });\n return;\n }\n\n actions.callAttachBot({\n botId: botUser.id,\n chatId,\n ...(typeof startAttach === 'string' && { startParam: startAttach }),\n });\n}\n\nasync function openCommentsByUsername(\n actions: GlobalActions,\n username: string,\n messageId: number,\n commentId: number,\n) {\n actions.openChat({ id: TMP_CHAT_ID });\n\n const chat = await fetchChatByUsername(username);\n\n if (!chat) return;\n\n const global = getGlobal();\n\n const threadInfo = selectThreadInfo(global, chat.id, messageId);\n let discussionChatId: string | undefined;\n\n if (!threadInfo) {\n const result = await callApi('requestThreadInfoUpdate', { chat, threadId: messageId });\n if (!result) return;\n\n discussionChatId = result.discussionChatId;\n } else {\n discussionChatId = threadInfo.chatId;\n }\n\n if (!discussionChatId) return;\n\n actions.focusMessage({\n chatId: discussionChatId,\n threadId: messageId,\n messageId: Number(commentId),\n });\n}\n","import { addActionHandler, getGlobal, setGlobal } from '../../index';\nimport { selectActiveGroupCall, selectChatGroupCall, selectGroupCall } from '../../selectors/calls';\nimport { callApi } from '../../../api/gramjs';\nimport { selectChat, selectUser } from '../../selectors';\nimport { copyTextToClipboard } from '../../../util/clipboard';\nimport type { ApiGroupCall } from '../../../api/types';\nimport { updateGroupCall } from '../../reducers/calls';\nimport { buildCollectionByKey, omit } from '../../../util/iteratees';\nimport { addChats, addUsers } from '../../reducers';\nimport { fetchChatByUsername, loadFullChat } from '../api/chats';\nimport safePlay from '../../../util/safePlay';\nimport { ARE_CALLS_SUPPORTED } from '../../../util/environment';\nimport * as langProvider from '../../../util/langProvider';\nimport type { CallSound } from '../../types';\n\n// Workaround for Safari not playing audio without user interaction\nlet audioElement: HTMLAudioElement | undefined;\nlet audioContext: AudioContext | undefined;\n\nlet sounds: Record<CallSound, HTMLAudioElement>;\nlet initializationPromise: Promise<void> | undefined = Promise.resolve();\n\nexport const initializeSoundsForSafari = () => {\n if (!initializationPromise) return Promise.resolve();\n\n const joinAudio = new Audio('./voicechat_join.mp3');\n const connectingAudio = new Audio('./voicechat_connecting.mp3');\n connectingAudio.loop = true;\n const leaveAudio = new Audio('./voicechat_leave.mp3');\n const allowTalkAudio = new Audio('./voicechat_onallowtalk.mp3');\n const busyAudio = new Audio('./call_busy.mp3');\n const connectAudio = new Audio('./call_connect.mp3');\n const endAudio = new Audio('./call_end.mp3');\n const incomingAudio = new Audio('./call_incoming.mp3');\n incomingAudio.loop = true;\n const ringingAudio = new Audio('./call_ringing.mp3');\n ringingAudio.loop = true;\n\n sounds = {\n join: joinAudio,\n allowTalk: allowTalkAudio,\n leave: leaveAudio,\n connecting: connectingAudio,\n incoming: incomingAudio,\n end: endAudio,\n connect: connectAudio,\n busy: busyAudio,\n ringing: ringingAudio,\n };\n\n initializationPromise = Promise.all(Object.values(sounds).map((l) => {\n l.muted = true;\n l.volume = 0.0001;\n return l.play().then(() => {\n l.pause();\n l.volume = 1;\n l.currentTime = 0;\n l.muted = false;\n });\n })).then(() => {\n initializationPromise = undefined;\n });\n\n return initializationPromise;\n};\n\nasync function fetchGroupCall(groupCall: Partial<ApiGroupCall>) {\n const result = await callApi('getGroupCall', {\n call: groupCall,\n });\n\n if (!result) return undefined;\n\n let global = getGlobal();\n\n const existingGroupCall = selectGroupCall(global, groupCall.id!);\n\n global = updateGroupCall(\n global,\n groupCall.id!,\n omit(result.groupCall, ['connectionState']),\n undefined,\n existingGroupCall?.isLoaded ? undefined : result.groupCall.participantsCount,\n );\n global = addUsers(global, buildCollectionByKey(result.users, 'id'));\n global = addChats(global, buildCollectionByKey(result.chats, 'id'));\n\n setGlobal(global);\n\n return result.groupCall;\n}\n\nasync function fetchGroupCallParticipants(groupCall: Partial<ApiGroupCall>, nextOffset?: string) {\n const result = await callApi('fetchGroupCallParticipants', {\n call: groupCall as ApiGroupCall,\n offset: nextOffset,\n });\n\n if (!result) return;\n\n let global = getGlobal();\n\n global = addUsers(global, buildCollectionByKey(result.users, 'id'));\n global = addChats(global, buildCollectionByKey(result.chats, 'id'));\n\n setGlobal(global);\n}\n\naddActionHandler('toggleGroupCallPanel', (global) => {\n return {\n ...global,\n isCallPanelVisible: !global.isCallPanelVisible,\n };\n});\n\naddActionHandler('subscribeToGroupCallUpdates', async (global, actions, payload) => {\n const { subscribed, id } = payload!;\n const groupCall = selectGroupCall(global, id);\n\n if (!groupCall) return;\n\n if (subscribed) {\n await fetchGroupCall(groupCall);\n await fetchGroupCallParticipants(groupCall);\n }\n\n await callApi('toggleGroupCallStartSubscription', {\n subscribed,\n call: groupCall,\n });\n});\n\naddActionHandler('createGroupCall', async (global, actions, payload) => {\n const { chatId } = payload;\n\n const chat = selectChat(global, chatId);\n if (!chat) {\n return;\n }\n\n const result = await callApi('createGroupCall', {\n peer: chat,\n });\n\n if (!result) return;\n\n global = getGlobal();\n setGlobal(updateGroupCall(global, result.id, {\n ...result,\n chatId,\n }));\n\n actions.joinGroupCall({ id: result.id, accessHash: result.accessHash });\n});\n\naddActionHandler('createGroupCallInviteLink', async (global, actions) => {\n const groupCall = selectActiveGroupCall(global);\n\n if (!groupCall || !groupCall.chatId) {\n return;\n }\n\n const chat = selectChat(global, groupCall.chatId);\n if (!chat) {\n return;\n }\n\n const canInvite = Boolean(chat.username);\n\n let { inviteLink } = chat.fullInfo!;\n if (canInvite) {\n inviteLink = await callApi('exportGroupCallInvite', {\n call: groupCall,\n canSelfUnmute: false,\n });\n }\n\n if (!inviteLink) {\n return;\n }\n\n copyTextToClipboard(inviteLink);\n actions.showNotification({\n message: 'Link copied to clipboard',\n });\n});\n\naddActionHandler('joinVoiceChatByLink', async (global, actions, payload) => {\n const { username, inviteHash } = payload!;\n\n const chat = await fetchChatByUsername(username);\n\n if (!chat) {\n actions.showNotification({ message: langProvider.getTranslation('NoUsernameFound') });\n return;\n }\n\n const full = await loadFullChat(chat);\n\n if (full?.groupCall) {\n actions.joinGroupCall({ id: full.groupCall.id, accessHash: full.groupCall.accessHash, inviteHash });\n }\n});\n\naddActionHandler('joinGroupCall', async (global, actions, payload) => {\n if (!ARE_CALLS_SUPPORTED) return;\n\n if (global.phoneCall) {\n actions.toggleGroupCallPanel();\n return;\n }\n\n const {\n chatId, id, accessHash, inviteHash,\n } = payload;\n\n createAudioElement();\n\n await initializeSoundsForSafari();\n const { groupCalls: { activeGroupCallId } } = global;\n let groupCall = id ? selectGroupCall(global, id) : selectChatGroupCall(global, chatId);\n\n if (groupCall?.id === activeGroupCallId) {\n actions.toggleGroupCallPanel();\n return;\n }\n\n if (activeGroupCallId) {\n actions.leaveGroupCall({\n rejoin: payload,\n });\n return;\n }\n\n if (groupCall && activeGroupCallId === groupCall.id) {\n actions.toggleGroupCallPanel();\n return;\n }\n\n if (!groupCall && (!id || !accessHash)) {\n groupCall = await fetchGroupCall({\n id,\n accessHash,\n });\n }\n\n if (!groupCall) return;\n\n global = getGlobal();\n global = updateGroupCall(\n global,\n groupCall.id,\n {\n ...groupCall,\n inviteHash,\n },\n undefined,\n groupCall.participantsCount + 1,\n );\n global = {\n ...global,\n groupCalls: {\n ...global.groupCalls,\n activeGroupCallId: groupCall.id,\n },\n isCallPanelVisible: false,\n };\n setGlobal(global);\n});\n\naddActionHandler('playGroupCallSound', (global, actions, payload) => {\n const { sound } = payload!;\n\n if (!sounds[sound]) {\n return;\n }\n\n const doPlay = () => {\n if (sound !== 'connecting') {\n sounds.connecting.pause();\n }\n if (sound !== 'incoming') {\n sounds.incoming.pause();\n }\n if (sound !== 'ringing') {\n sounds.ringing.pause();\n }\n safePlay(sounds[sound]);\n };\n\n if (initializationPromise) {\n initializationPromise.then(doPlay);\n } else {\n doPlay();\n }\n});\n\naddActionHandler('loadMoreGroupCallParticipants', (global) => {\n const groupCall = selectActiveGroupCall(global);\n if (!groupCall) {\n return;\n }\n\n void fetchGroupCallParticipants(groupCall, groupCall.nextOffset);\n});\n\naddActionHandler('requestCall', async (global, actions, payload) => {\n const { userId, isVideo } = payload;\n\n if (global.phoneCall) {\n actions.toggleGroupCallPanel();\n return;\n }\n\n const user = selectUser(global, userId);\n\n if (!user) {\n return;\n }\n\n await initializeSoundsForSafari();\n\n setGlobal({\n ...getGlobal(),\n phoneCall: {\n id: '',\n state: 'requesting',\n participantId: userId,\n isVideo,\n adminId: global.currentUserId,\n },\n isCallPanelVisible: false,\n });\n});\n\nfunction createAudioContext() {\n return (new (window.AudioContext || (window as any).webkitAudioContext)());\n}\n\nconst silence = (ctx: AudioContext) => {\n const oscillator = ctx.createOscillator();\n const dst = oscillator.connect(ctx.createMediaStreamDestination());\n oscillator.start();\n return new MediaStream([Object.assign((dst as any).stream.getAudioTracks()[0], { enabled: false })]);\n};\n\nfunction createAudioElement() {\n const ctx = createAudioContext();\n audioElement = new Audio();\n audioContext = ctx;\n audioElement.srcObject = silence(ctx);\n safePlay(audioElement);\n}\n\nexport function getGroupCallAudioElement() {\n return audioElement;\n}\n\nexport function getGroupCallAudioContext() {\n return audioContext;\n}\n\nexport function removeGroupCallAudioElement() {\n audioElement?.pause();\n audioContext = undefined;\n audioElement = undefined;\n}\n","import type { GroupCallParticipant } from '../../lib/secret-sauce';\nimport type { GlobalState } from '../types';\nimport type { ApiGroupCall } from '../../api/types';\nimport { selectGroupCall } from '../selectors/calls';\nimport { omit } from '../../util/iteratees';\nimport { updateChat } from './chats';\nimport { selectChat } from '../selectors';\n\nexport function updateGroupCall(\n global: GlobalState,\n groupCallId: string,\n groupCallUpdate: Partial<ApiGroupCall>,\n addToParticipantCount?: number,\n resetParticipantCount?: number,\n): GlobalState {\n const unfiltered = Object.values({\n ...global.groupCalls.byId[groupCallId]?.participants,\n ...groupCallUpdate.participants,\n });\n const filtered = unfiltered.filter((l) => !l.isLeft);\n const participants = filtered.reduce((acc: Record<string, GroupCallParticipant>, el) => {\n acc[el.id] = el;\n return acc;\n }, {});\n\n return {\n ...global,\n groupCalls: {\n ...global.groupCalls,\n byId: {\n ...global.groupCalls.byId,\n [groupCallId]: {\n ...global.groupCalls.byId[groupCallId],\n ...omit(groupCallUpdate, ['participantsCount']),\n ...(addToParticipantCount && {\n participantsCount: global.groupCalls.byId[groupCallId].participantsCount + addToParticipantCount,\n }),\n ...(resetParticipantCount !== undefined && {\n participantsCount: resetParticipantCount,\n }),\n participants,\n },\n },\n },\n };\n}\n\nexport function removeGroupCall(\n global: GlobalState,\n groupCallId: string,\n): GlobalState {\n const groupCall = selectGroupCall(global, groupCallId);\n if (groupCall && groupCall.chatId) {\n const chat = selectChat(global, groupCall.chatId);\n if (chat) {\n global = updateChat(global, groupCall.chatId, {\n fullInfo: {\n ...chat.fullInfo,\n groupCallId: undefined,\n },\n });\n }\n }\n\n return {\n ...global,\n groupCalls: {\n ...global.groupCalls,\n byId: {\n ...omit(global.groupCalls.byId, [groupCallId.toString()]),\n },\n },\n };\n}\n\nexport function updateActiveGroupCall(\n global: GlobalState,\n groupCallUpdate: Partial<ApiGroupCall>,\n resetParticipantCount?: number,\n): GlobalState {\n if (!global.groupCalls.activeGroupCallId) {\n return global;\n }\n\n return updateGroupCall(global,\n global.groupCalls.activeGroupCallId,\n groupCallUpdate,\n undefined,\n resetParticipantCount);\n}\n\nexport function updateGroupCallParticipant(\n global: GlobalState,\n groupCallId: string,\n userId: string,\n participantUpdate: Partial<GroupCallParticipant>,\n noUpdateCount = false,\n) {\n const groupCall = selectGroupCall(global, groupCallId);\n if (!groupCall) {\n return global;\n }\n\n return updateGroupCall(global, groupCallId, {\n participants: {\n ...groupCall.participants,\n [userId]: {\n ...groupCall.participants[userId],\n ...participantUpdate,\n },\n },\n }, participantUpdate.isLeft\n ? (noUpdateCount ? 0 : -1)\n : (groupCall.participants[userId] || noUpdateCount ? 0 : 1));\n}\n","import type { GlobalState } from '../types';\nimport { selectChat } from './chats';\nimport { isChatBasicGroup } from '../helpers';\nimport { selectUser } from './users';\n\nexport function selectChatGroupCall(global: GlobalState, chatId: string) {\n const chat = selectChat(global, chatId);\n if (!chat || !chat.fullInfo || !chat.fullInfo.groupCallId) return undefined;\n\n return selectGroupCall(global, chat.fullInfo.groupCallId);\n}\n\nexport function selectGroupCall(global: GlobalState, groupCallId: string) {\n return global.groupCalls.byId[groupCallId];\n}\n\nexport function selectGroupCallParticipant(global: GlobalState, groupCallId: string, participantId: string) {\n return selectGroupCall(global, groupCallId)?.participants[participantId];\n}\n\nexport function selectIsAdminInActiveGroupCall(global: GlobalState): boolean {\n const chatId = selectActiveGroupCall(global)?.chatId;\n\n if (!chatId) return false;\n\n const chat = selectChat(global, chatId);\n if (!chat) return false;\n\n return (isChatBasicGroup(chat) && chat.isCreator) || Boolean(chat.adminRights?.manageCall);\n}\n\nexport function selectActiveGroupCall(global: GlobalState) {\n const { groupCalls: { activeGroupCallId } } = global;\n if (!activeGroupCallId) {\n return undefined;\n }\n\n return selectGroupCall(global, activeGroupCallId);\n}\n\nexport function selectPhoneCallUser(global: GlobalState) {\n const { phoneCall, currentUserId } = global;\n if (!phoneCall || !phoneCall.participantId || !phoneCall.adminId) {\n return undefined;\n }\n\n const id = phoneCall.adminId === currentUserId ? phoneCall.participantId : phoneCall.adminId;\n return selectUser(global, id);\n}\n","import { getActions } from '../global';\n\nimport type { ApiChatType } from '../api/types';\n\nimport { API_CHAT_TYPES } from '../config';\nimport { IS_SAFARI } from './environment';\n\ntype DeepLinkMethod = 'resolve' | 'login' | 'passport' | 'settings' | 'join' | 'addstickers' | 'addemoji' |\n'setlanguage' | 'addtheme' | 'confirmphone' | 'socks' | 'proxy' | 'privatepost' | 'bg' | 'share' | 'msg' | 'msg_url' |\n'invoice';\n\nexport const processDeepLink = (url: string) => {\n const {\n protocol, searchParams, pathname, hostname,\n } = new URL(url);\n\n if (protocol !== 'tg:') return;\n\n const {\n openChatByInvite,\n openChatByUsername,\n openChatByPhoneNumber,\n openStickerSet,\n focusMessage,\n joinVoiceChatByLink,\n openInvoice,\n processAttachBotParameters,\n openChatWithDraft,\n } = getActions();\n\n // Safari thinks the path in tg://path links is hostname for some reason\n const method = (IS_SAFARI ? hostname : pathname).replace(/^\\/\\//, '') as DeepLinkMethod;\n const params = Object.fromEntries(searchParams);\n\n switch (method) {\n case 'resolve': {\n const {\n domain, phone, post, comment, voicechat, livestream, start, startattach, attach,\n } = params;\n\n const startAttach = params.hasOwnProperty('startattach') && !startattach ? true : startattach;\n const choose = parseChooseParameter(params.choose);\n\n if (domain !== 'telegrampassport') {\n if (startAttach && choose) {\n processAttachBotParameters({\n username: domain,\n filter: choose,\n ...(typeof startAttach === 'string' && { startParam: startAttach }),\n });\n } else if (params.hasOwnProperty('voicechat') || params.hasOwnProperty('livestream')) {\n joinVoiceChatByLink({\n username: domain,\n inviteHash: voicechat || livestream,\n });\n } else if (phone) {\n openChatByPhoneNumber({ phone, startAttach, attach });\n } else {\n openChatByUsername({\n username: domain,\n messageId: Number(post),\n commentId: Number(comment),\n startParam: start,\n startAttach,\n attach,\n });\n }\n }\n break;\n }\n case 'privatepost': {\n const {\n post, channel,\n } = params;\n\n focusMessage({\n chatId: `-${channel}`,\n id: post,\n });\n break;\n }\n case 'bg': {\n // const {\n // slug, color, rotation, mode, intensity, bg_color: bgColor, gradient,\n // } = params;\n break;\n }\n case 'join': {\n const { invite } = params;\n\n openChatByInvite({ hash: invite });\n break;\n }\n case 'addemoji':\n case 'addstickers': {\n const { set } = params;\n\n openStickerSet({\n stickerSetInfo: {\n shortName: set,\n },\n });\n break;\n }\n case 'share':\n case 'msg':\n case 'msg_url': {\n const { url: urlParam, text } = params;\n openChatWithDraft({ text: formatShareText(urlParam, text) });\n break;\n }\n case 'login': {\n // const { code, token } = params;\n break;\n }\n\n case 'invoice': {\n const { slug } = params;\n openInvoice({ slug });\n break;\n }\n default:\n // Unsupported deeplink\n\n break;\n }\n};\n\nexport function parseChooseParameter(choose?: string) {\n if (!choose) return undefined;\n const types = choose.toLowerCase().split(' ');\n return types.filter((type): type is ApiChatType => API_CHAT_TYPES.includes(type as ApiChatType));\n}\n\nexport function formatShareText(url?: string, text?: string) {\n return [url, text].filter(Boolean).join('\\n');\n}\n"],"names":["SERVICE_NOTIFICATIONS_USER_MOCK","id","SERVICE_NOTIFICATIONS_USER_ID","accessHash","type","isMin","username","phoneNumber","runThrottledForLoadTopChats","throttle","cb","runDebouncedForLoadFullChat","debounce","async","loadChats","listType","offsetId","offsetDate","shouldReplace","global","getGlobal","lastLocalServiceMessage","selectLastServiceNotification","message","result","callApi","limit","CHAT_LIST_LOAD_SLICE","archived","withPinned","serverTimeOffset","chatIds","length","shift","includes","result2","user","notificationsChat","selectChat","chatId","unshift","chats","lastMessage","currentChat","selectCurrentChat","visibleChats","visibleUsers","selectVisibleUsers","currentUserId","users","byId","push","replaceUsers","buildCollectionByKey","concat","replaceUserStatuses","userStatusesById","replaceChats","replaceChatListIds","addUsers","addUserStatuses","updateChats","updateChatListIds","updateChatListSecondaryInfo","Object","keys","draftsById","forEach","replaceThreadParam","MAIN_THREAD_ID","replyingToById","isFullyLoaded","setGlobal","loadFullChat","chat","fullInfo","groupCall","membersCount","existingGroupCall","selectGroupCall","updateGroupCall","omit","undefined","participantsCount","updateChat","stickerSet","getActions","loadStickers","stickerSetInfo","migrateChat","error","openLimitReachedModal","showDialog","data","hasErrorKey","fetchChatByUsername","localChat","selectChatByUsername","getAttachBotOrNotify","selectUser","isUserBot","isAttachBot","showNotification","langProvider","openAttachMenuFromLink","actions","attach","startAttach","botChat","botUser","callAttachBot","botId","startParam","addActionHandler","preloadedChatIds","Set","i","TOP_CHAT_MESSAGES_PRELOAD_LIMIT","pause","currentChatId","selectCurrentMessageList","folderAllOrderedIds","getOrderedIds","ALL_FOLDER_ID","nextChatId","find","has","add","loadViewportMessages","threadId","payload","hasUnreadMark","toggleChatUnread","threadInfo","requestThreadInfoUpdate","isChatSummaryOnly","requestChatUpdate","selectThreadTopMessageId","chatFullInfo","linkedChatId","openChat","messageId","focusMessage","selectSupportChat","shouldReplaceHistory","TMP_CHAT_ID","onReplace","getOrderDate","date","joinDate","DEBUG","console","connectionState","authState","listIds","oldestChat","map","filter","Boolean","selectIsChatPinned","sort","chat1","chat2","force","lastLocalMessage","isMuted","title","about","photo","memberIds","createdChannel","chatCreation","progress","ChatCreationProgress","channelId","createChannel","joinChannel","userId","leaveChat","createdChat","e","createGroupChat","folderId","selectCurrentLimit","folder","selectChatFolder","shouldBePinned","pinnedChatIds","includedChatIds","newPinnedIds","pinnedId","newIncludedChatIds","folderUpdate","selectChatListType","isPinned","ARCHIVED_FOLDER_ID","ids","orderedPinnedIds","isChatArchived","chatFolders","loadChatFolders","recommendedChatFolders","recommended","loadRecommendedChatFolders","idsToRemove","idsToAdd","some","includedId","emoticon","orderedIds","maxId","recommendedId","description","newFolder","createChatFolder","Math","max","folderIds","deleteChatFolder","unreadCount","hash","localUser","selectUserByPhoneNumber","fetchChatByPhoneNumber","openPreviousChat","replace","url","openChatByPhoneNumber","openChatByInvite","openStickerSet","openChatWithDraft","joinVoiceChatByLink","openInvoice","processAttachBotParameters","openChatByUsername","openChatByUsernameAction","match","RE_TG_LINK","processDeepLink","uri","URL","startsWith","hostname","pathname","window","open","toString","hostParts","split","part1","part2","part3","l","decodeURI","params","fromEntries","searchParams","hasOwnProperty","startattach","choose","parseChooseParameter","substr","shortName","chatOrChannelPostId","Number","commentId","comment","text","formatShareText","inviteHash","voicechat","livestream","slug","substring","start","channelPostId","isCurrentChat","startBot","param","usernameChat","selectThreadInfo","discussionChatId","openCommentsByUsername","isEnabled","isChatBasicGroup","bannedRights","chatAfterUpdate","members","kickedMembers","isBanned","viewMessages","isUnblocked","m","adminRights","customTitle","adminMembers","isDismissed","updateManagementProgress","ManagementProgress","Promise","all","groups","addedById","reduce","group","addChats","forDiscussionIds","channel","fullChat","isPreHistoryHidden","activeChatFolder","requestedDraft","offset","addChatMembers","setNewChatMembersDialogState","NewChatMembersProgress","isProtected","enabledReactions","settings","isChatSuperGroup","isChatChannel","bot","attachMenu","bots","requestAttachBotInChat","requestedAttachBotInstall","onConfirm","action","audioElement","audioContext","sounds","initializationPromise","resolve","initializeSoundsForSafari","joinAudio","Audio","connectingAudio","loop","leaveAudio","allowTalkAudio","busyAudio","connectAudio","endAudio","incomingAudio","ringingAudio","join","allowTalk","leave","connecting","incoming","end","connect","busy","ringing","values","muted","volume","play","then","currentTime","fetchGroupCall","call","isLoaded","fetchGroupCallParticipants","nextOffset","getGroupCallAudioElement","getGroupCallAudioContext","removeGroupCallAudioElement","isCallPanelVisible","subscribed","peer","joinGroupCall","selectActiveGroupCall","canInvite","inviteLink","canSelfUnmute","copyTextToClipboard","full","ARE_CALLS_SUPPORTED","phoneCall","toggleGroupCallPanel","ctx","AudioContext","webkitAudioContext","srcObject","oscillator","createOscillator","dst","createMediaStreamDestination","MediaStream","assign","stream","getAudioTracks","enabled","silence","safePlay","createAudioElement","groupCalls","activeGroupCallId","selectChatGroupCall","leaveGroupCall","rejoin","sound","doPlay","isVideo","state","participantId","adminId","groupCallId","groupCallUpdate","addToParticipantCount","resetParticipantCount","participants","isLeft","acc","el","removeGroupCall","updateActiveGroupCall","updateGroupCallParticipant","participantUpdate","noUpdateCount","selectGroupCallParticipant","selectIsAdminInActiveGroupCall","isCreator","manageCall","selectPhoneCallUser","protocol","method","IS_SAFARI","domain","phone","post","invite","set","urlParam","toLowerCase","API_CHAT_TYPES"],"sourceRoot":""} |