<!DOCTYPE html>
<html lang="ru">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}TelePush{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap" rel="stylesheet">
    <link href="{{ url_for('static', filename='style.css') }}?v={{ config.TELEPUSH_VERSION }}" rel="stylesheet">
    {% block extra_css %}{% endblock %}
    <script>
        // Применяем тему до рендера body — без вспышки.
        (function() {
            try {
                var t = localStorage.getItem('tp_theme') || 'calm';
                if (t === 'amoled' || t === 'light') {
                    document.documentElement.classList.add('theme-' + t);
                }
            } catch(e) {}
        })();
    </script>
</head>
<body>
    <div class="app-layout">
        <!-- Sidebar -->
        <aside class="sidebar" id="sidebar">
            <button id="sidebar-toggle" class="sidebar-toggle-btn" onclick="toggleSidebar()" title="Свернуть/развернуть боковое меню">
                <i class="bi bi-layout-sidebar-inset"></i>
            </button>
            <div class="sidebar-brand">
                <img src="{{ url_for('static', filename='logo.svg') }}" alt="TelePush" style="width:36px;height:36px;">
                <div class="brand-text">
                    <h1>TelePush</h1>
                    <span class="version">v{{ config.TELEPUSH_VERSION }}</span>
                </div>
            </div>

            <nav class="sidebar-nav">
                <ul style="list-style:none;padding:0;">
                    <li class="nav-section">Обзор</li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="dashboard" onclick="showTab('dashboard')">
                            <i class="bi bi-speedometer2"></i> Главная
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="analytics" onclick="showTab('analytics')">
                            <i class="bi bi-graph-up"></i> Аналитика
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="history" onclick="showTab('history')">
                            <i class="bi bi-clock-history"></i> История
                        </a>
                    </li>

                    <li class="nav-section">Аккаунты</li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="accounts" onclick="showTab('accounts')">
                            <i class="bi bi-phone"></i> Аккаунты
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="proxy" onclick="showTab('proxy')">
                            <i class="bi bi-shield-lock"></i> Прокси
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="profiles" onclick="showTab('profiles')">
                            <i class="bi bi-person-badge"></i> Заполнение профилей
                            <span class="badge-beta">BETA</span>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="reauth" onclick="showTab('reauth')">
                            <i class="bi bi-arrow-repeat"></i> Переавторизация
                        </a>
                    </li>

                    <li class="nav-section">Рассылка</li>
                    <li class="nav-item">
                        <a class="nav-link active" data-tab="spam" onclick="showTab('spam')">
                            <i class="bi bi-megaphone"></i> По чатам
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="dm" onclick="showTab('dm')">
                            <i class="bi bi-person-lines-fill"></i> По ЛС
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="templates" onclick="showTab('templates')">
                            <i class="bi bi-file-text"></i> Шаблоны
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="autoreply" onclick="showTab('autoreply')">
                            <i class="bi bi-reply"></i> Автоответчик
                        </a>
                    </li>

                    <li class="nav-section">Подписка / инвайт</li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="join" onclick="showTab('join')">
                            <i class="bi bi-box-arrow-in-right"></i> Вступление
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="invite" onclick="showTab('invite')">
                            <i class="bi bi-person-plus"></i> Инвайт
                            <span class="badge-beta">BETA</span>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="multi" onclick="showTab('multi')">
                            <i class="bi bi-stack"></i> Мульти-режим
                            <span class="badge-beta">BETA</span>
                        </a>
                    </li>

                    <li class="nav-section">Парсинг и мониторинг</li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="parser" onclick="showTab('parser')">
                            <i class="bi bi-search"></i> Парсинг
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="monitor" onclick="showTab('monitor')">
                            <i class="bi bi-broadcast"></i> Мониторинг
                        </a>
                    </li>

                    <li class="nav-section">AI-инструменты</li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="warmup" onclick="showTab('warmup')">
                            <i class="bi bi-fire"></i> Прогрев
                            <span class="badge-beta">BETA</span>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="neuro-comments" onclick="showTab('neuro-comments')">
                            <i class="bi bi-chat-quote"></i> Нейрокомменты
                            <span class="badge-beta">BETA</span>
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="imitation" onclick="showTab('imitation')">
                            <i class="bi bi-person-walking"></i> Имитация активности
                            <span class="badge-beta">BETA</span>
                        </a>
                    </li>

                    <li class="nav-section">Накрутка</li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="boost" onclick="showTab('boost')">
                            <i class="bi bi-graph-up-arrow"></i> Накрутка
                            <span class="badge-beta">BETA</span>
                        </a>
                    </li>

                    <li class="nav-section">Чекер</li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="checker" onclick="showTab('checker')">
                            <i class="bi bi-shield-check"></i> Чекер аккаунтов
                        </a>
                    </li>

                    <li class="nav-section">Конвертеры</li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="conv-t2s" onclick="showTab('conv-t2s')">
                            <i class="bi bi-file-earmark-arrow-down"></i> tdata → session
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="conv-s2t" onclick="showTab('conv-s2t')">
                            <i class="bi bi-file-earmark-arrow-up"></i> session → tdata
                        </a>
                    </li>

                    <li class="nav-section">Настройки</li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="settings" onclick="showTab('settings')">
                            <i class="bi bi-gear"></i> Настройки
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="guide" onclick="showTab('guide')">
                            <i class="bi bi-book"></i> Инструкция
                        </a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" data-tab="profile" onclick="showTab('profile')">
                            <i class="bi bi-person-badge"></i> Профиль
                        </a>
                    </li>

                </ul>
            </nav>

            <!-- Sidebar footer -->
            <div style="padding:16px 20px;border-top:1px solid var(--border);font-size:0.75rem;color:var(--text-muted);">
                <div class="d-flex align-center justify-between">
                    <span><span class="pulse-dot"></span> Онлайн</span>
                    <a onclick="showTab('support')" style="color:var(--accent-light);cursor:pointer;text-decoration:none;">
                        <i class="bi bi-headset"></i> Поддержка
                    </a>
                </div>
            </div>
        </aside>

        <!-- Main -->
        <main class="main-content">
            <!-- Broadcast announcement баннер от админа -->
            <div id="broadcast-banner" style="display:none;border-radius:12px;padding:14px 18px;margin:0 0 16px;border:1px solid;">
                <div style="display:flex;align-items:flex-start;gap:12px;">
                    <i id="broadcast-icon" class="bi" style="font-size:1.4rem;flex-shrink:0;"></i>
                    <div style="flex:1;">
                        <div id="broadcast-title" style="font-size:0.92rem;font-weight:700;margin-bottom:4px;"></div>
                        <div id="broadcast-text" style="font-size:0.82rem;line-height:1.55;white-space:pre-wrap;"></div>
                    </div>
                    <button onclick="dismissBroadcast()" style="background:transparent;border:none;color:inherit;font-size:1.1rem;cursor:pointer;opacity:0.7;flex-shrink:0;" title="Скрыть до следующего сообщения">×</button>
                </div>
            </div>

            <!-- Temp launch warning (только если exe реально из архива) -->
            <div id="temp-launch-banner" style="display:none;background:linear-gradient(135deg,#2a0d14,#3b1c1c);border:2px solid #ef4444;border-radius:12px;padding:16px 20px;margin:0 0 16px;">
                <div style="display:flex;align-items:flex-start;gap:12px;">
                    <i class="bi bi-exclamation-triangle-fill" style="color:#ef4444;font-size:1.6rem;flex-shrink:0;"></i>
                    <div style="flex:1;">
                        <div style="font-size:0.95rem;font-weight:700;color:#fca5a5;margin-bottom:6px;">
                            Программа запущена из временной папки архива!
                        </div>
                        <div style="font-size:0.78rem;color:#fecaca;line-height:1.55;margin-bottom:8px;">
                            Текущая папка: <code id="temp-launch-path" style="background:rgba(0,0,0,0.3);padding:2px 6px;border-radius:4px;font-size:0.72rem;word-break:break-all;"></code>
                        </div>
                        <div style="font-size:0.82rem;color:#fff;line-height:1.7;">
                            Распакуй архив в постоянную папку (например <code style="background:rgba(0,0,0,0.3);padding:1px 4px;border-radius:3px;">C:\TelePush\</code>) и запусти TelePush.exe оттуда — иначе при закрытии архива все данные пропадут.
                        </div>
                    </div>
                </div>
            </div>

            <!-- Update banner (hidden by default) -->
            <div class="update-banner" id="update-banner" style="display:none;">
                <div>
                    <i class="bi bi-arrow-up-circle" style="color:var(--success);margin-right:6px;"></i>
                    <strong>Доступно обновление</strong> <span id="update-version" style="color:var(--success);font-weight:700;"></span>
                    <span id="update-changelog" style="font-size:0.75rem;color:var(--text-muted);margin-left:8px;"></span>
                </div>
                <div style="display:flex;gap:8px;align-items:center;flex-wrap:nowrap;">
                    <button class="btn btn-success btn-sm" onclick="installUpdate()">
                        <i class="bi bi-download"></i> Обновить
                    </button>
                    <a href="https://telepush.org/api/download?v=latest" target="_blank" rel="noopener"
                       title="Если автообновление не работает — скачай zip вручную и распакуй поверх папки TelePush (папку data/ не трогай)"
                       style="font-size:0.72rem;color:var(--text-muted);text-decoration:underline;white-space:nowrap;">
                        или скачать вручную
                    </a>
                </div>
            </div>

            <!-- Expired license banner (hidden by default) -->
            <div id="expired-banner" style="display:none;background:linear-gradient(135deg,#1c0f0f,#2a1010);border:1px solid #3b1c1c;border-radius:12px;padding:20px 24px;margin:0 0 16px;text-align:center;">
                <div style="font-size:1.8rem;margin-bottom:8px;color:#ff7b7b;"><i class="bi bi-lock-fill"></i></div>
                <div style="font-size:1.05rem;font-weight:700;color:#f87171;margin-bottom:6px;">Срок лицензии истёк</div>
                <div style="font-size:0.82rem;color:#9ca3af;margin-bottom:16px;">Модули заблокированы. Продлите ключ для продолжения работы.</div>
                <div style="margin-bottom:12px;">
                    <input type="text" id="renew-tg-username" class="form-control" placeholder="Ваш @username в Telegram" style="max-width:280px;margin:0 auto;text-align:center;font-size:0.82rem;">
                </div>
                <div style="display:flex;gap:10px;justify-content:center;flex-wrap:wrap;">
                    <button class="btn btn-accent btn-sm" onclick="requestRenewal()" id="btn-renew">
                        <i class="bi bi-key"></i> Запросить продление
                    </button>
                    <a href="https://t.me/boberkurvateh" target="_blank" class="btn btn-outline btn-sm" style="text-decoration:none;">
                        <i class="bi bi-telegram"></i> Написать в поддержку
                    </a>
                </div>
                <div id="renew-result" style="margin-top:10px;font-size:0.82rem;display:none;"></div>
            </div>

            {% block content %}{% endblock %}
        </main>
            <!-- Console Log Panel -->
            <div id="console-panel" class="console-panel">
                <!-- Drag handle -->
                <div id="console-drag" class="console-panel__drag" onmousedown="startConsoleDrag(event)"></div>
                <div style="padding:0 8px 0 12px;display:flex;align-items:center;gap:2px;border-bottom:1px solid var(--border);overflow-x:auto;">
                    <span style="font-size:0.7rem;font-weight:600;color:var(--text-muted);margin-right:8px;flex-shrink:0;"><i class="bi bi-terminal"></i></span>
                    <button class="con-tab active" data-mod="all" onclick="setConsoleFilter(this,'all')">Все <span class="con-badge"></span></button>
                    <button class="con-tab" data-mod="spam" onclick="setConsoleFilter(this,'spam')">Рассылка <span class="con-badge"></span></button>
                    <button class="con-tab" data-mod="dm" onclick="setConsoleFilter(this,'dm')">ЛС <span class="con-badge"></span></button>
                    <button class="con-tab" data-mod="join" onclick="setConsoleFilter(this,'join')">Подписка <span class="con-badge"></span></button>
                    <button class="con-tab" data-mod="parser" onclick="setConsoleFilter(this,'parser')">Парсер <span class="con-badge"></span></button>
                    <button class="con-tab" data-mod="monitor" onclick="setConsoleFilter(this,'monitor')">Мониторинг <span class="con-badge"></span></button>
                    <button class="con-tab" data-mod="warmup" onclick="setConsoleFilter(this,'warmup')">Прогрев <span class="con-badge"></span></button>
                    <button class="con-tab" data-mod="autoreply" onclick="setConsoleFilter(this,'autoreply')">Авто-ответ <span class="con-badge"></span></button>
                    <button class="con-tab" data-mod="system" onclick="setConsoleFilter(this,'system')">Системные <span class="con-badge"></span></button>
                    <div style="flex:1"></div>
                    <button onclick="clearConsole()" title="Очистить" style="background:none;border:none;color:var(--text-muted);cursor:pointer;font-size:0.7rem;padding:4px 6px;"><i class="bi bi-trash"></i></button>
                    <button onclick="toggleConsole()" title="Свернуть" style="background:none;border:none;color:var(--text-muted);cursor:pointer;font-size:0.7rem;padding:4px 6px;"><i class="bi bi-chevron-down"></i></button>
                </div>
                <div id="console-log" style="flex:1;overflow-y:auto;padding:8px 16px;font-family:monospace;font-size:0.75rem;color:var(--text-muted);line-height:1.6;"></div>
            </div>

    </div>

    
        <!-- Onboarding Overlay -->
        <div id="onboarding-overlay" class="onboarding-overlay hidden">
            <div class="onboarding-overlay__card">
                <div id="onboarding-content"></div>
            </div>
        </div>

        <!-- Telegram Messenger Panel -->
        <div id="tg-panel" style="position:fixed;top:0;right:-420px;width:420px;height:100vh;background:var(--bg-card);border-left:1px solid var(--border);z-index:200;transition:right 0.3s ease;display:flex;flex-direction:column;">
            <!-- Header -->
            <div id="tg-header" style="padding:10px 16px;border-bottom:1px solid var(--border);display:flex;align-items:center;gap:10px;min-height:48px;">
                <button id="tg-back-btn" onclick="loadTgDialogs()" style="display:none;background:none;border:none;color:var(--accent-light);cursor:pointer;font-size:1rem;padding:4px;"><i class="bi bi-arrow-left"></i></button>
                <i class="bi bi-telegram" id="tg-header-icon" style="color:#229ED9;font-size:1.1rem;"></i>
                <div style="flex:1;min-width:0;">
                    <div id="tg-header-title" style="font-weight:600;font-size:0.85rem;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;">Telegram</div>
                    <div id="tg-header-sub" style="font-size:0.65rem;color:var(--text-muted);display:none;"></div>
                </div>
                <button id="tg-info-btn" onclick="showTgUserInfo()" style="display:none;background:none;border:none;color:var(--accent-light);cursor:pointer;font-size:1rem;padding:4px;" title="Информация"><i class="bi bi-info-circle"></i></button>
                <button onclick="toggleTgPanel()" style="background:none;border:none;color:#64748b;cursor:pointer;font-size:1rem;"><i class="bi bi-x-lg"></i></button>
            </div>
            <!-- Tabs -->
            <div id="tg-tabs" style="display:flex;border-bottom:1px solid var(--border);">
                <button class="tg-tab active" onclick="tgShowTab(this,'chats')" style="flex:1;padding:8px;background:none;border:none;color:#a78bfa;font-size:0.78rem;font-weight:600;cursor:pointer;border-bottom:2px solid #7c3aed;">Чаты</button>
                <button class="tg-tab" onclick="tgShowTab(this,'replies')" style="flex:1;padding:8px;background:none;border:none;color:#64748b;font-size:0.78rem;font-weight:600;cursor:pointer;border-bottom:2px solid transparent;">Входящие</button>
                <button class="tg-tab" onclick="tgShowTab(this,'log')" style="flex:1;padding:8px;background:none;border:none;color:#64748b;font-size:0.78rem;font-weight:600;cursor:pointer;border-bottom:2px solid transparent;">Лог</button>
            </div>
            <!-- Warning -->
            <div style="padding:8px 12px;background:var(--surface-warning-bg);border-bottom:1px solid var(--surface-warning-border);font-size:0.68rem;color:var(--warning);line-height:1.4;">
                <i class="bi bi-exclamation-triangle" style="margin-right:4px;"></i>
                Не открывайте Telegram на этом же аккаунте (ни на телефоне, ни в десктопе) пока идёт работа — сессия может быть разорвана.
            </div>
            <!-- Content -->
            <div id="tg-chats" style="flex:1;overflow-y:auto;display:flex;flex-direction:column;"></div>
            <div id="tg-replies" style="flex:1;overflow-y:auto;padding:8px;display:none;"></div>
            <div id="tg-log" style="flex:1;overflow-y:auto;padding:8px;font-family:monospace;font-size:0.72rem;color:#64748b;display:none;"></div>
        </div>

    <!-- Show console button (when hidden) -->
    <div id="console-show-btn" style="display:none;position:fixed;bottom:8px;left:268px;z-index:51;">
        <button onclick="toggleConsole()" style="background:#7c3aed;color:white;border:none;border-radius:8px;padding:6px 14px;font-size:0.75rem;cursor:pointer;font-weight:600;">
            <i class="bi bi-terminal"></i> Показать консоль
        </button>
    </div>

    <div class="toast-container" id="toast-container"></div>

    <script src="{{ url_for('static', filename='app.js') }}?v={{ config.TELEPUSH_VERSION }}"></script>
    
<script>
var _consoleVisible = true;
function _consolePanelHeight() {
    var p = document.getElementById('console-panel');
    return parseInt(p.style.height) || parseInt(getComputedStyle(p).height) || 90;
}
function toggleConsole() {
    _consoleVisible = !_consoleVisible;
    document.getElementById('console-panel').classList.toggle('hidden', !_consoleVisible);
    document.getElementById('console-show-btn').style.display = _consoleVisible ? 'none' : 'block';
    var h = _consolePanelHeight();
    document.querySelector('.main-content').style.paddingBottom = _consoleVisible ? (h + 20) + 'px' : '24px';
}
// Console drag resize
function startConsoleDrag(e) {
    e.preventDefault();
    var panel = document.getElementById('console-panel');
    var startY = e.clientY;
    var startH = _consolePanelHeight();
    function onMove(ev) {
        var newH = Math.max(80, Math.min(500, startH + (startY - ev.clientY)));
        panel.style.height = newH + 'px';
        document.querySelector('.main-content').style.paddingBottom = (newH + 20) + 'px';
    }
    function onUp() {
        document.removeEventListener('mousemove', onMove);
        document.removeEventListener('mouseup', onUp);
    }
    document.addEventListener('mousemove', onMove);
    document.addEventListener('mouseup', onUp);
}
function clearConsole() {
    document.getElementById('console-log').innerHTML = '';
    document.querySelectorAll('.con-tab .con-badge').forEach(function(b){b.textContent='';b.classList.remove('has-err','has-warn');});
}

var _consoleFilter = 'all';
function setConsoleFilter(btn, mod) {
    _consoleFilter = mod;
    document.querySelectorAll('.con-tab').forEach(function(t){t.classList.remove('active');});
    if (btn) btn.classList.add('active');
    var el = document.getElementById('console-log');
    if (!el) return;
    Array.from(el.children).forEach(function(line){
        var lm = line.getAttribute('data-mod') || 'system';
        line.style.display = (mod === 'all' || lm === mod) ? '' : 'none';
    });
    el.scrollTop = el.scrollHeight;
    // обнуляем счётчик активного таба
    if (btn) {
        var b = btn.querySelector('.con-badge');
        if (b) { b.textContent = ''; b.classList.remove('has-err','has-warn'); }
    }
}

function _bumpTabBadge(mod, level) {
    if (mod === _consoleFilter) return;  // не считаем то, что и так видно
    var btn = document.querySelector('.con-tab[data-mod="' + mod + '"]');
    if (!btn) return;
    var b = btn.querySelector('.con-badge');
    if (!b) return;
    var n = parseInt(b.textContent || '0') + 1;
    b.textContent = n > 99 ? '99+' : n;
    if (level === 'ERROR') b.classList.add('has-err');
    else if (level === 'WARNING' && !b.classList.contains('has-err')) b.classList.add('has-warn');
}

function addLog(msg, level, module) {
    var el = document.getElementById('console-log');
    if (!el) return;
    var mod = module || 'system';
    var colors = {INFO: '#94a3b8', WARNING: '#f59e0b', ERROR: '#ef4444', SUCCESS: '#22c55e', DEBUG: '#64748b'};
    var icons = {
        INFO:    '<i class="bi bi-info-circle-fill"></i>',
        WARNING: '<i class="bi bi-exclamation-triangle-fill"></i>',
        ERROR:   '<i class="bi bi-x-circle-fill"></i>',
        SUCCESS: '<i class="bi bi-check-circle-fill"></i>',
        DEBUG:   '<i class="bi bi-dot"></i>'
    };
    var bgColors = {ERROR: '#2a0d0d', WARNING: '#2a1f0d', SUCCESS: '#0d2418'};
    var modBadgeColors = {spam:'#a78bfa',dm:'#22c55e',join:'#3b82f6',parser:'#ec4899',monitor:'#f97316',warmup:'#eab308',autoreply:'#06b6d4',system:'#64748b'};
    var modLabels = {spam:'РАС',dm:'ЛС',join:'ПОД',parser:'ПАР',monitor:'МОН',warmup:'ПРГ',autoreply:'АО',system:'СИС'};
    var time = new Date().toLocaleTimeString();
    var line = document.createElement('div');
    line.setAttribute('data-mod', mod);
    line.style.color = colors[level] || '#94a3b8';
    line.style.padding = '2px 4px';
    line.style.borderRadius = '3px';
    if (bgColors[level]) line.style.background = bgColors[level];
    if (_consoleFilter !== 'all' && _consoleFilter !== mod) line.style.display = 'none';
    var icon = icons[level] || '';
    var modBadge = '<span style="display:inline-block;background:'+modBadgeColors[mod]+'22;color:'+modBadgeColors[mod]+';padding:0 5px;border-radius:3px;font-size:.62rem;font-weight:700;margin-right:6px;">'+modLabels[mod]+'</span>';
    line.innerHTML = '<span style="color:#5a6178">[' + time + ']</span> ' + modBadge + icon + ' ' + (msg||'').replace(/[<>]/g, function(c){return c==='<'?'&lt;':'&gt;'});
    el.appendChild(line);
    el.scrollTop = el.scrollHeight;
    _bumpTabBadge(mod, level);
    // Лимит строк
    while (el.children.length > 2000) el.removeChild(el.firstChild);
}
// Override console.log for app
var _origLog = console.log;
console.log = function() {
    _origLog.apply(console, arguments);
    addLog(Array.from(arguments).join(' '), 'INFO');
};
// Initial padding
document.querySelector('.main-content').style.paddingBottom = '200px';
addLog('TelePush ' + (document.querySelector('.version')?.textContent || 'v1.0') + ' запущен', 'SUCCESS');
</script>

{% block extra_js %}{% endblock %}
</body>
</html>
