diff --git a/Dockerfile b/Dockerfile index 6e099c8..6e7f0c3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -43,6 +43,7 @@ COPY netscan/ ./netscan/ COPY nginxmon/ ./nginxmon/ COPY routermon/ ./routermon/ COPY pricemon/ ./pricemon/ +COPY jbot/ ./jbot/ COPY new_theme/ ./new_theme/ COPY templates/ ./templates/ COPY locale/ ./locale/ @@ -149,10 +150,12 @@ COPY --chown=appuser:appuser netscan/ ./netscan/ COPY --chown=appuser:appuser nginxmon/ ./nginxmon/ COPY --chown=appuser:appuser routermon/ ./routermon/ COPY --chown=appuser:appuser pricemon/ ./pricemon/ +COPY --chown=appuser:appuser jbot/ ./jbot/ COPY --chown=appuser:appuser new_theme/ ./new_theme/ COPY --chown=appuser:appuser templates/ ./templates/ COPY --chown=appuser:appuser static/ ./static/ COPY --chown=appuser:appuser qdrant_sync.py ./ +COPY --chown=appuser:appuser entrypoint.sh ./ # Final cleanup RUN find /app -name "*.pyc" -delete \ @@ -168,5 +171,5 @@ EXPOSE 8000 HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 \ CMD curl -f http://localhost:8000/ || exit 1 -# Run the application -CMD ["gunicorn", "--chdir", "/app", "core.wsgi:application", "--bind", "0.0.0.0:8000", "--workers", "2", "--threads", "4"] +# Run migrations then start gunicorn +CMD ["/bin/sh", "/app/entrypoint.sh"] diff --git a/entrypoint.sh b/entrypoint.sh new file mode 100644 index 0000000..a4abedf --- /dev/null +++ b/entrypoint.sh @@ -0,0 +1,10 @@ +#!/bin/sh +set -e + +# Run DB migrations on startup (idempotent — safe to run every time) +uv run manage.py migrate --noinput + +exec gunicorn --chdir /app core.wsgi:application \ + --bind 0.0.0.0:8000 \ + --workers 2 \ + --threads 4 diff --git a/jbot/admin.py b/jbot/admin.py new file mode 100644 index 0000000..a4de763 --- /dev/null +++ b/jbot/admin.py @@ -0,0 +1,8 @@ +from django.contrib import admin +from .models import JbotApiConfig + + +@admin.register(JbotApiConfig) +class JbotApiConfigAdmin(admin.ModelAdmin): + list_display = ('volc_app_id', 'llm_model', 'volc_tts_voice', 'updated_at') + readonly_fields = ('updated_at',) diff --git a/jbot/api_urls.py b/jbot/api_urls.py index a998b2c..9707f21 100644 --- a/jbot/api_urls.py +++ b/jbot/api_urls.py @@ -7,4 +7,5 @@ urlpatterns = [ path('asr/', views.asr_view, name='jbot-api-asr'), path('memory/extract/', views.memory_extract_view, name='jbot-api-memory-extract'), path('config/', views.config_view, name='jbot-api-config'), + path('api-config/', views.api_config_view, name='jbot-api-api-config'), ] diff --git a/jbot/migrations/0001_initial.py b/jbot/migrations/0001_initial.py new file mode 100644 index 0000000..eab1f54 --- /dev/null +++ b/jbot/migrations/0001_initial.py @@ -0,0 +1,27 @@ +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [] + + operations = [ + migrations.CreateModel( + name='JbotApiConfig', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('volc_app_id', models.CharField(blank=True, default='', max_length=200)), + ('volc_access_token', models.CharField(blank=True, default='', max_length=500)), + ('openrouter_api_key', models.CharField(blank=True, default='', max_length=200)), + ('llm_model', models.CharField(blank=True, default='deepseek/deepseek-chat', max_length=200)), + ('volc_tts_voice', models.CharField(blank=True, default='zh_female_vv_uranus_bigtts', max_length=200)), + ('volc_asr_resource', models.CharField(blank=True, default='volc.bigasr.sauc.duration', max_length=200)), + ('updated_at', models.DateTimeField(auto_now=True)), + ], + options={ + 'verbose_name': 'JBOT API Config', + }, + ), + ] diff --git a/jbot/migrations/__init__.py b/jbot/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/jbot/models.py b/jbot/models.py new file mode 100644 index 0000000..8a6c6cc --- /dev/null +++ b/jbot/models.py @@ -0,0 +1,27 @@ +from django.db import models + + +class JbotApiConfig(models.Model): + """Singleton model storing JBOT API credentials and runtime defaults. + Configured via the Settings UI at /jbot/settings — env vars are fallback only. + """ + volc_app_id = models.CharField(max_length=200, blank=True, default='') + volc_access_token = models.CharField(max_length=500, blank=True, default='') + openrouter_api_key = models.CharField(max_length=200, blank=True, default='') + llm_model = models.CharField(max_length=200, blank=True, default='deepseek/deepseek-chat') + volc_tts_voice = models.CharField(max_length=200, blank=True, default='zh_female_vv_uranus_bigtts') + volc_asr_resource = models.CharField(max_length=200, blank=True, default='volc.bigasr.sauc.duration') + updated_at = models.DateTimeField(auto_now=True) + + class Meta: + verbose_name = 'JBOT API Config' + + @classmethod + def load(cls): + """Return the singleton row, creating it if needed.""" + obj, _ = cls.objects.get_or_create(pk=1) + return obj + + def save(self, *args, **kwargs): + self.pk = 1 + super().save(*args, **kwargs) diff --git a/jbot/views.py b/jbot/views.py index 7ddc3ba..d5b1f35 100644 --- a/jbot/views.py +++ b/jbot/views.py @@ -1,12 +1,14 @@ """ JBOT backend views — Python port of the Node.js server/index.js Endpoints: - GET /jbot/ → SPA shell (index.html) - POST /api/jbot/chat/ → OpenRouter LLM proxy - POST /api/jbot/tts/ → Volcengine seed-tts-2.0 - POST /api/jbot/asr/ → Volcengine BigASR 1.0 (WebSocket binary protocol) + GET /jbot/ → SPA shell (index.html) + POST /api/jbot/chat/ → OpenRouter LLM proxy + POST /api/jbot/tts/ → Volcengine seed-tts-2.0 + POST /api/jbot/asr/ → Volcengine BigASR 1.0 (WebSocket binary protocol) POST /api/jbot/memory/extract/ → background memory extraction via LLM - GET /api/jbot/config/ → public config flags + GET /api/jbot/config/ → public config flags + GET /api/jbot/api-config/ → read API credentials/settings (tokens masked) + POST /api/jbot/api-config/ → save API credentials/settings to DB """ import base64 import gzip @@ -20,8 +22,6 @@ import uuid import requests from django.http import JsonResponse -from django.utils.decorators import method_decorator -from django.views import View from django.views.decorators.csrf import csrf_exempt from django.views.generic import TemplateView @@ -43,16 +43,100 @@ def _json_body(request): return {} +# ── Config helper: DB values override env vars ──────────────────────────────── + +def _get_cfg(): + """Return merged config: DB row first, env vars as fallback.""" + defaults = { + 'volc_app_id': os.environ.get('VOLC_APP_ID', ''), + 'volc_access_token': os.environ.get('VOLC_ACCESS_TOKEN', ''), + 'openrouter_api_key': os.environ.get('OPENROUTER_API_KEY', ''), + 'llm_model': os.environ.get('LLM_MODEL', 'deepseek/deepseek-chat'), + 'volc_tts_voice': os.environ.get('VOLC_TTS_VOICE', 'zh_female_vv_uranus_bigtts'), + 'volc_asr_resource': os.environ.get('VOLC_ASR_RESOURCE', 'volc.bigasr.sauc.duration'), + } + try: + from .models import JbotApiConfig + db = JbotApiConfig.load() + for k in defaults: + db_val = getattr(db, k, '') + if db_val: + defaults[k] = db_val + except Exception: + pass + return defaults + + +# ── API Config CRUD (read/write credentials via UI) ────────────────────────── + +@csrf_exempt +def api_config_view(request): + if request.method == 'GET': + try: + from .models import JbotApiConfig + db = JbotApiConfig.load() + env = { + 'volc_app_id': os.environ.get('VOLC_APP_ID', ''), + 'volc_access_token': os.environ.get('VOLC_ACCESS_TOKEN', ''), + 'openrouter_api_key': os.environ.get('OPENROUTER_API_KEY', ''), + } + def _masked(db_val, env_val): + return '***' if (db_val or env_val) else '' + + return JsonResponse({ + 'volcAppId': db.volc_app_id or env['volc_app_id'], + 'volcAccessToken': _masked(db.volc_access_token, env['volc_access_token']), + 'openrouterApiKey': _masked(db.openrouter_api_key, env['openrouter_api_key']), + 'llmModel': db.llm_model or os.environ.get('LLM_MODEL', 'deepseek/deepseek-chat'), + 'volcTtsVoice': db.volc_tts_voice or os.environ.get('VOLC_TTS_VOICE', 'zh_female_vv_uranus_bigtts'), + 'volcAsrResource': db.volc_asr_resource or os.environ.get('VOLC_ASR_RESOURCE', 'volc.bigasr.sauc.duration'), + 'hasVolc': bool(db.volc_app_id or env['volc_app_id']), + 'hasLlm': bool(db.openrouter_api_key or env['openrouter_api_key']), + }) + except Exception as e: + return JsonResponse({'error': str(e)}, status=500) + + if request.method == 'POST': + data = _json_body(request) + try: + from .models import JbotApiConfig + db = JbotApiConfig.load() + # Only update fields that are present and not the masked placeholder + mapping = { + 'volcAppId': 'volc_app_id', + 'llmModel': 'llm_model', + 'volcTtsVoice': 'volc_tts_voice', + 'volcAsrResource': 'volc_asr_resource', + } + for json_key, db_field in mapping.items(): + if json_key in data: + setattr(db, db_field, data[json_key]) + # Secret fields: only update if non-empty and not the placeholder + for json_key, db_field in [('volcAccessToken', 'volc_access_token'), + ('openrouterApiKey', 'openrouter_api_key')]: + val = data.get(json_key, '') + if val and val != '***': + setattr(db, db_field, val) + db.save() + return JsonResponse({'ok': True}) + except Exception as e: + logger.error('[API-CONFIG] save failed: %s', e) + return JsonResponse({'error': str(e)}, status=500) + + return JsonResponse({'error': 'GET or POST required'}, status=405) + + # ── TTS 2.0 (Volcengine seed-tts-2.0 HTTP streaming NDJSON) ───────────────── def _do_tts(text, voice=None): - app_id = os.environ.get('VOLC_APP_ID', '') - token = os.environ.get('VOLC_ACCESS_TOKEN', '') - speaker = voice or os.environ.get('VOLC_TTS_VOICE', 'zh_female_vv_uranus_bigtts') + cfg = _get_cfg() + app_id = cfg['volc_app_id'] + token = cfg['volc_access_token'] + speaker = voice or cfg['volc_tts_voice'] resource_id = os.environ.get('VOLC_TTS_RESOURCE', 'seed-tts-2.0') if not app_id or not token: - raise ValueError('Volcengine credentials not configured (VOLC_APP_ID / VOLC_ACCESS_TOKEN)') + raise ValueError('Volcengine credentials not configured — set them in JBOT Settings → API 配置') resp = requests.post( 'https://openspeech.bytedance.com/api/v3/tts/unidirectional', @@ -121,19 +205,16 @@ def tts_view(request): # ── ASR 1.0 (Volcengine BigASR WebSocket binary protocol) ──────────────────── -# Message type constants _ASR_MT_FULL_CLIENT = 1 _ASR_MT_AUDIO_ONLY = 2 _ASR_MT_FULL_SERVER = 9 _ASR_MT_ERROR = 15 -# Flag constants _FLAG_NO_SEQ = 0 _FLAG_POS_SEQ = 1 _FLAG_LAST_NO = 2 _FLAG_NEG_SEQ = 3 -# Serialization / compression _SER_NONE = 0 _SER_JSON = 1 _CMP_NONE = 0 @@ -183,7 +264,6 @@ def _asr_unpack(data: bytes): def _to_pcm(audio_bytes: bytes, mime_type: str = 'audio/webm') -> bytes: - """Convert browser audio (webm/ogg/mp4) to PCM 16kHz 16-bit mono via ffmpeg.""" fmt = mime_type.split('/')[1].split(';')[0].strip() if '/' in mime_type else 'webm' result = subprocess.run( ['ffmpeg', '-loglevel', 'error', @@ -198,18 +278,18 @@ def _to_pcm(audio_bytes: bytes, mime_type: str = 'audio/webm') -> bytes: def _do_asr(audio_bytes: bytes, mime_type: str = 'audio/webm') -> str: - """Transcribe audio using Volcengine BigASR 1.0 WebSocket binary protocol.""" try: import websocket as ws_module except ImportError: raise RuntimeError('websocket-client not installed — run: uv add websocket-client') - app_id = os.environ.get('VOLC_APP_ID', '') - token = os.environ.get('VOLC_ACCESS_TOKEN', '') - resource_id = os.environ.get('VOLC_ASR_RESOURCE', 'volc.bigasr.sauc.duration') + cfg = _get_cfg() + app_id = cfg['volc_app_id'] + token = cfg['volc_access_token'] + resource_id = cfg['volc_asr_resource'] if not app_id or not token: - raise ValueError('Volcengine credentials not configured') + raise ValueError('Volcengine credentials not configured — set them in JBOT Settings → API 配置') pcm = _to_pcm(audio_bytes, mime_type) if not pcm: @@ -234,8 +314,8 @@ def _do_asr(audio_bytes: bytes, mime_type: str = 'audio/webm') -> str: ws.send_binary(_asr_pack(_ASR_MT_FULL_CLIENT, _FLAG_NO_SEQ, _SER_JSON, _CMP_GZIP, gzip.compress(config))) - CHUNK = 6400 - pcm_data = pcm # captured from outer scope + CHUNK = 6400 + pcm_data = pcm for off in range(0, len(pcm_data), CHUNK): chunk = pcm_data[off:off + CHUNK] is_last = (off + CHUNK >= len(pcm_data)) @@ -295,9 +375,9 @@ def _do_asr(audio_bytes: bytes, mime_type: str = 'audio/webm') -> str: def asr_view(request): if request.method != 'POST': return JsonResponse({'error': 'POST required'}, status=405) - data = _json_body(request) - audio_b64 = data.get('audioBase64', '') - mime_type = data.get('format', 'audio/webm') + data = _json_body(request) + audio_b64 = data.get('audioBase64', '') + mime_type = data.get('format', 'audio/webm') if not audio_b64: return JsonResponse({'error': 'audioBase64 required'}, status=400) try: @@ -316,21 +396,22 @@ def chat_view(request): if request.method != 'POST': return JsonResponse({'error': 'POST required'}, status=405) - api_key = os.environ.get('OPENROUTER_API_KEY', '') + cfg = _get_cfg() + api_key = cfg['openrouter_api_key'] if not api_key: - return JsonResponse({'error': 'OPENROUTER_API_KEY not configured'}, status=503) + return JsonResponse({'error': 'OPENROUTER_API_KEY not configured — set it in JBOT Settings → API 配置'}, status=503) data = _json_body(request) messages = data.get('messages', []) memories = data.get('memories', []) settings = data.get('settings', {}) - model = os.environ.get('LLM_MODEL', 'deepseek/deepseek-chat') + model = cfg['llm_model'] - robot_name = settings.get('robotName', 'JBOT') - personality = settings.get('robotPersonality', - '你是一个友好、简洁、偶尔幽默的AI机器人助手。回复控制在80字以内。') - lang = settings.get('language', 'auto') - lang_hint = '' + robot_name = settings.get('robotName', 'JBOT') + personality = settings.get('robotPersonality', + '你是一个友好、简洁、偶尔幽默的AI机器人助手。回复控制在80字以内。') + lang = settings.get('language', 'auto') + lang_hint = '' if lang == 'zh-CN': lang_hint = '\n请用中文回复。' elif lang == 'en-US': @@ -379,7 +460,8 @@ def memory_extract_view(request): if request.method != 'POST': return JsonResponse({'error': 'POST required'}, status=405) - api_key = os.environ.get('OPENROUTER_API_KEY', '') + cfg = _get_cfg() + api_key = cfg['openrouter_api_key'] if not api_key: return JsonResponse({'facts': []}) @@ -389,7 +471,7 @@ def memory_extract_view(request): if not user_text or not bot_text: return JsonResponse({'facts': []}) - model = os.environ.get('LLM_MODEL', 'deepseek/deepseek-chat') + model = cfg['llm_model'] prompt = ( 'You are a memory extraction assistant for an AI robot named JBOT.\n\n' f'Conversation exchange:\nUser: "{user_text}"\nJBOT: "{bot_text}"\n\n' @@ -416,9 +498,7 @@ def memory_extract_view(request): timeout=15, ) resp.raise_for_status() - raw = resp.json().get('choices', [{}])[0].get('message', {}).get('content', '[]') - raw = raw.strip() - # strip ```json fences if present + raw = resp.json().get('choices', [{}])[0].get('message', {}).get('content', '[]').strip() if raw.startswith('```'): raw = raw.split('\n', 1)[-1].rsplit('```', 1)[0].strip() facts = json.loads(raw) @@ -430,13 +510,12 @@ def memory_extract_view(request): return JsonResponse({'facts': []}) -# ── Config ──────────────────────────────────────────────────────────────────── +# ── Public config flags ──────────────────────────────────────────────────────── def config_view(request): - has_volc = bool(os.environ.get('VOLC_APP_ID') and os.environ.get('VOLC_ACCESS_TOKEN')) - has_llm = bool(os.environ.get('OPENROUTER_API_KEY')) + cfg = _get_cfg() return JsonResponse({ - 'volcengine': has_volc, - 'llm': has_llm, - 'ttsVoice': os.environ.get('VOLC_TTS_VOICE', 'zh_female_vv_uranus_bigtts'), + 'volcengine': bool(cfg['volc_app_id'] and cfg['volc_access_token']), + 'llm': bool(cfg['openrouter_api_key']), + 'ttsVoice': cfg['volc_tts_voice'], }) diff --git a/k8s/manifest.yaml b/k8s/manifest.yaml index fc83d8e..941d07a 100644 --- a/k8s/manifest.yaml +++ b/k8s/manifest.yaml @@ -173,22 +173,7 @@ spec: value: "192.168.1.2" - name: OLLAMA_URL value: "http://ollama-service.ollama.svc.cluster.local:11434" - # JBOT — AI Robot Face env vars - - name: VOLC_APP_ID - valueFrom: - secretKeyRef: - name: jbot-credentials - key: app_id - - name: VOLC_ACCESS_TOKEN - valueFrom: - secretKeyRef: - name: jbot-credentials - key: access_token - - name: OPENROUTER_API_KEY - valueFrom: - secretKeyRef: - name: jbot-credentials - key: openrouter_api_key + # JBOT — AI Robot Face env var defaults (API keys configured via UI at /jbot/settings) - name: LLM_MODEL value: "deepseek/deepseek-chat" - name: VOLC_TTS_VOICE diff --git a/static/dist/jbot.css b/static/dist/jbot.css index 0ba038a..3e11493 100644 --- a/static/dist/jbot.css +++ b/static/dist/jbot.css @@ -1 +1 @@ -*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}body{background:#f1f5f9;color:#0f172a;font-family:system-ui,Segoe UI,sans-serif;-webkit-font-smoothing:antialiased}#root{height:100dvh;height:-webkit-fill-available;display:flex;flex-direction:column}:root{--bg: #F1F5F9;--surface: #FFFFFF;--border: #E2E8F0;--text: #0F172A;--text2: #475569;--text3: #94A3B8;--accent: #0EA5E9;--accent-bg: #E0F7FE;--face-bg: #080C14}.app{height:100dvh;height:-webkit-fill-available;display:flex;flex-direction:column;background:var(--bg);color:var(--text);overflow:hidden}.hdr{flex:0 0 auto;display:flex;align-items:center;gap:12px;padding:10px 20px;background:var(--surface);border-bottom:1px solid var(--border)}.hdr h1{font-size:1.5rem;font-weight:800;letter-spacing:.1em;color:var(--text);margin:0}.accent{color:var(--accent)}.subtitle{font-size:.72rem;color:var(--text3);letter-spacing:.05em}.hdr-nav{margin-left:auto;display:flex;gap:8px}.hdr-link{background:none;border:1px solid var(--border);border-radius:6px;color:var(--text2);font-size:.78rem;padding:4px 10px;cursor:pointer;transition:background .15s,color .15s}.hdr-link:hover{background:var(--bg);color:var(--accent)}.page-body{flex:1;min-height:0;display:flex;overflow:hidden}.left-col{flex:0 0 auto;width:296px;display:flex;flex-direction:column;overflow-y:auto;background:var(--surface);border-right:1px solid var(--border);padding:14px 14px 20px;gap:14px}.right-col{flex:1;min-width:0;display:flex;flex-direction:column;overflow:hidden;background:var(--bg)}.screen-wrap{display:flex;flex-direction:column;align-items:center;gap:8px}.bezel{background:var(--face-bg);border-radius:18px;padding:12px;box-shadow:0 4px 28px #00000038,0 0 0 1px #ffffff0f}.expr-label{font-size:.85rem;color:var(--text2);height:1.4em;text-align:center}.scale-controls{display:flex;gap:6px}.scale-btn{background:var(--bg);border:1px solid var(--border);border-radius:6px;color:var(--text2);padding:3px 12px;font-size:.78rem;cursor:pointer;transition:all .15s}.scale-btn:hover{border-color:var(--accent);color:var(--accent)}.scale-btn.active{background:var(--accent-bg);border-color:var(--accent);color:var(--accent);font-weight:600}.panel{display:flex;flex-direction:column;gap:12px}.panel-section h3{font-size:.67rem;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--text3);margin:0 0 7px}.key-hint{font-weight:400;opacity:.7}.btn-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:5px}.btn-grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.btn-grid-4 .ebtn{font-size:.62rem;padding:5px 3px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ebtn{background:var(--bg);border:1px solid var(--border);border-radius:7px;color:var(--text2);padding:6px 9px;font-size:.78rem;cursor:pointer;transition:all .15s;text-align:left}.ebtn:hover{border-color:var(--c);color:var(--c);background:color-mix(in srgb,var(--c) 6%,var(--surface))}.ebtn.active{background:color-mix(in srgb,var(--c) 12%,var(--surface));border-color:var(--c);color:var(--c);font-weight:600}.toggle{display:flex;align-items:center;gap:7px;font-size:.8rem;color:var(--text2);cursor:pointer;-webkit-user-select:none;user-select:none}.toggle input[type=checkbox]{accent-color:var(--accent);width:14px;height:14px}.switch-interval{display:flex;flex-direction:column;gap:5px}.switch-interval-label{display:flex;justify-content:space-between;font-size:.75rem;color:var(--text2)}.interval-val{color:var(--accent);font-weight:700}.switch-interval input[type=range]{width:100%;accent-color:var(--accent);cursor:pointer}.interval-ticks{display:flex;justify-content:space-between;font-size:.65rem;color:var(--text3)}.hint{font-size:.72rem;color:var(--text3);line-height:1.7}kbd{background:var(--bg);border:1px solid var(--border);border-radius:4px;padding:1px 5px;font-size:.68rem;font-family:inherit;color:var(--text2)}.hist-inline-link{background:none;border:none;color:var(--accent);font-size:.72rem;padding:0;cursor:pointer;text-decoration:underline}.chat-panel{display:flex;flex-direction:column;height:100%;padding:14px 18px;gap:10px;overflow:hidden}.chat-header{flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;padding-bottom:8px;border-bottom:1px solid var(--border)}.chat-title{font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--text3)}.history-link{background:none;border:none;color:var(--accent);font-size:.75rem;cursor:pointer;padding:0}.history-link:hover{text-decoration:underline}.voice-status{flex:0 0 auto;font-size:.8rem;letter-spacing:.04em;padding:6px 12px;border-radius:8px;width:fit-content}.voice-status-listening{color:#0369a1;background:#e0f2fe;animation:pulse .9s ease-in-out infinite}.voice-status-thinking{color:#92400e;background:#fef3c7;animation:pulse 1.2s ease-in-out infinite}.voice-status-speaking{color:#065f46;background:#d1fae5}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.chat-messages{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:4px 2px;scrollbar-width:thin;scrollbar-color:var(--border) transparent}.chat-messages::-webkit-scrollbar{width:4px}.chat-messages::-webkit-scrollbar-thumb{background:var(--border);border-radius:2px}.chat-empty{font-size:.82rem;color:var(--text3);text-align:center;padding:40px 0;margin:auto}.bubble{display:flex;flex-direction:column;gap:3px;max-width:82%}.bubble-user{align-self:flex-end;align-items:flex-end}.bubble-bot{align-self:flex-start;align-items:flex-start}.bubble-label{font-size:.62rem;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--text3)}.bubble-text{border-radius:12px;padding:9px 13px;font-size:.9rem;line-height:1.55}.bubble-user .bubble-text{background:#dbeafe;color:#1e3a8a;border-bottom-right-radius:3px}.bubble-bot .bubble-text{background:var(--surface);border:1px solid var(--border);color:var(--text);border-bottom-left-radius:3px}.audio-btn{width:100%;max-width:220px;height:28px;margin-top:3px;border-radius:6px;opacity:.8}.audio-btn:hover{opacity:1}.hist-page{min-height:100vh;background:var(--bg)}.hist-toolbar{display:flex;align-items:center;justify-content:space-between;padding:12px 24px;border-bottom:1px solid var(--border);position:sticky;top:0;background:var(--surface);z-index:10}.hist-heading{font-size:1rem;font-weight:700;color:var(--text);margin:0}.hist-back{background:none;border:1px solid var(--border);border-radius:6px;color:var(--text2);padding:5px 12px;font-size:.78rem;cursor:pointer}.hist-back:hover{border-color:var(--accent);color:var(--accent)}.hist-clear{background:none;border:1px solid #FECACA;border-radius:6px;color:#dc2626;padding:5px 12px;font-size:.78rem;cursor:pointer}.hist-clear:hover:not(:disabled){border-color:#dc2626}.hist-clear:disabled{opacity:.3;cursor:default}.hist-empty{text-align:center;color:var(--text3);padding:64px 32px;font-size:.9rem}.hist-list{display:flex;flex-direction:column;max-width:680px;margin:0 auto;padding:16px 24px}.hist-entry{border:1px solid var(--border);border-radius:12px;padding:14px 16px;margin-bottom:12px;background:var(--surface)}.hist-meta{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.hist-time{font-size:.68rem;color:var(--text3)}.hist-del{background:none;border:none;color:var(--text3);cursor:pointer;font-size:.8rem;padding:0 4px}.hist-del:hover{color:#dc2626}.hist-row{display:flex;gap:10px;margin-bottom:8px}.hist-role{font-size:.62rem;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--text3);min-width:36px;padding-top:2px}.hist-row-user .hist-role{color:#2563eb}.hist-row-bot .hist-role{color:#059669}.hist-body{flex:1}.hist-text{font-size:.86rem;color:var(--text);line-height:1.5;margin:0 0 6px}.hist-audio{width:100%;max-width:260px;height:26px;opacity:.75;border-radius:6px}.hist-audio:hover{opacity:1}@media(max-width:700px){.app{height:100dvh;height:-webkit-fill-available}.hdr{padding:8px 14px}.hdr h1{font-size:1.2rem}.subtitle{display:none}.page-body{flex-direction:column}.left-col{width:100%;flex:0 0 auto;border-right:none;border-bottom:1px solid var(--border);padding:10px 12px;gap:8px;flex-direction:row;align-items:flex-start;overflow-x:hidden;overflow-y:visible}.screen-wrap{flex:0 0 auto}.bezel{padding:8px}.panel{flex:1;min-width:0;gap:8px;overflow-y:auto;max-height:272px}.btn-grid{grid-template-columns:repeat(2,1fr);gap:4px}.btn-grid-4{grid-template-columns:repeat(4,1fr);gap:3px}.ebtn{font-size:.7rem;padding:5px 6px}.btn-grid-4 .ebtn{font-size:.58rem;padding:4px 2px}.scale-controls{display:none}.right-col{flex:1;min-height:0}.chat-panel{padding:10px 12px}}.memory-panel{border:1px solid var(--border);border-radius:8px;overflow:hidden}.memory-toggle{width:100%;display:flex;align-items:center;gap:6px;padding:7px 10px;background:var(--bg);border:none;cursor:pointer;font-size:.78rem;color:var(--text2);text-align:left}.memory-toggle:hover{background:#e8eef6}.memory-badge{margin-left:auto;background:var(--accent-bg);color:var(--accent);border-radius:10px;font-size:.65rem;font-weight:700;padding:1px 6px;min-width:18px;text-align:center}.memory-arrow{font-size:.6rem;color:var(--text3)}.memory-body{padding:8px 10px;background:var(--surface);border-top:1px solid var(--border)}.memory-empty{font-size:.72rem;color:var(--text3);text-align:center;padding:6px 0;margin:0}.memory-list{list-style:none;display:flex;flex-direction:column;gap:5px;margin:0 0 8px;padding:0;max-height:160px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--border) transparent}.memory-item{display:flex;align-items:flex-start;gap:6px;font-size:.75rem;color:var(--text2);line-height:1.4}.memory-text{flex:1}.memory-del{flex:0 0 auto;background:none;border:none;color:var(--text3);cursor:pointer;font-size:.9rem;line-height:1;padding:0 2px}.memory-del:hover{color:#dc2626}.memory-clear{width:100%;background:none;border:1px solid #FECACA;border-radius:5px;color:#dc2626;font-size:.72rem;padding:4px 0;cursor:pointer}.memory-clear:hover{background:#fef2f2}.voice-hint{margin-top:4px;display:flex;align-items:center;gap:4px;flex-wrap:wrap}.settings-page{min-height:100dvh;background:var(--bg);color:var(--text)}.settings-toolbar{display:flex;align-items:center;gap:14px;padding:12px 20px;background:var(--surface);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:10}.settings-back{background:none;border:1px solid var(--border);border-radius:6px;color:var(--text2);font-size:.85rem;padding:5px 12px;cursor:pointer;transition:background .15s}.settings-back:hover{background:var(--bg);color:var(--accent)}.settings-heading{font-size:1.1rem;font-weight:700;margin:0;flex:1}.settings-save{background:var(--accent);border:none;border-radius:7px;color:#fff;font-size:.85rem;font-weight:600;padding:6px 16px;cursor:pointer;transition:opacity .15s}.settings-save:hover{opacity:.85}.settings-body{max-width:600px;margin:0 auto;padding:20px 18px 40px;display:flex;flex-direction:column;gap:20px}.settings-section{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:16px;display:flex;flex-direction:column;gap:12px}.settings-section-title{font-size:.85rem;font-weight:700;color:var(--text2);margin:0 0 4px;letter-spacing:.02em}.settings-label{display:flex;flex-direction:column;gap:5px;font-size:.82rem;font-weight:600;color:var(--text2)}.settings-label-mt{margin-top:6px}.settings-hint{font-size:.73rem;font-weight:400;color:var(--text3);margin-left:4px}.settings-hint-block{font-size:.75rem;color:var(--text3);margin:0}.settings-hint-block a{color:var(--accent)}.settings-input{border:1px solid var(--border);border-radius:6px;padding:7px 10px;font-size:.85rem;color:var(--text);background:var(--bg);outline:none;transition:border-color .15s;font-family:inherit}.settings-input:focus{border-color:var(--accent)}.settings-textarea{border:1px solid var(--border);border-radius:6px;padding:7px 10px;font-size:.85rem;color:var(--text);background:var(--bg);outline:none;resize:vertical;min-height:60px;transition:border-color .15s;font-family:inherit;line-height:1.5}.settings-textarea:focus{border-color:var(--accent)}.settings-radio-group{display:flex;flex-direction:column;gap:8px}.settings-radio-label{display:flex;align-items:center;gap:8px;font-size:.85rem;color:var(--text2);cursor:pointer}.settings-radio-label input{accent-color:var(--accent)}.settings-voice-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px}.settings-voice-btn{display:flex;flex-direction:column;gap:3px;padding:10px 10px 8px;background:var(--bg);border:1.5px solid var(--border);border-radius:8px;cursor:pointer;text-align:left;transition:border-color .15s,background .15s}.settings-voice-btn:hover,.settings-voice-btn.active{border-color:var(--accent);background:var(--accent-bg)}.voice-btn-label{font-size:.88rem;font-weight:700;color:var(--text)}.voice-btn-meta{font-size:.68rem;color:var(--text3);line-height:1.3}.settings-section-danger{border-color:#fecaca}.settings-reset-btn{background:none;border:1px solid #FECACA;border-radius:6px;color:#dc2626;font-size:.82rem;padding:7px 14px;cursor:pointer;transition:background .15s}.settings-reset-btn:hover{background:#fef2f2} +*,*:before,*:after{box-sizing:border-box;margin:0;padding:0}body{background:#f1f5f9;color:#0f172a;font-family:system-ui,Segoe UI,sans-serif;-webkit-font-smoothing:antialiased}#root{height:100dvh;height:-webkit-fill-available;display:flex;flex-direction:column}:root{--bg: #F1F5F9;--surface: #FFFFFF;--border: #E2E8F0;--text: #0F172A;--text2: #475569;--text3: #94A3B8;--accent: #0EA5E9;--accent-bg: #E0F7FE;--face-bg: #080C14}.app{height:100dvh;height:-webkit-fill-available;display:flex;flex-direction:column;background:var(--bg);color:var(--text);overflow:hidden}.hdr{flex:0 0 auto;display:flex;align-items:center;gap:12px;padding:10px 20px;background:var(--surface);border-bottom:1px solid var(--border)}.hdr h1{font-size:1.5rem;font-weight:800;letter-spacing:.1em;color:var(--text);margin:0}.accent{color:var(--accent)}.subtitle{font-size:.72rem;color:var(--text3);letter-spacing:.05em}.hdr-nav{margin-left:auto;display:flex;gap:8px}.hdr-link{background:none;border:1px solid var(--border);border-radius:6px;color:var(--text2);font-size:.78rem;padding:4px 10px;cursor:pointer;transition:background .15s,color .15s}.hdr-link:hover{background:var(--bg);color:var(--accent)}.page-body{flex:1;min-height:0;display:flex;overflow:hidden}.left-col{flex:0 0 auto;width:296px;display:flex;flex-direction:column;overflow-y:auto;background:var(--surface);border-right:1px solid var(--border);padding:14px 14px 20px;gap:14px}.right-col{flex:1;min-width:0;display:flex;flex-direction:column;overflow:hidden;background:var(--bg)}.screen-wrap{display:flex;flex-direction:column;align-items:center;gap:8px}.bezel{background:var(--face-bg);border-radius:18px;padding:12px;box-shadow:0 4px 28px #00000038,0 0 0 1px #ffffff0f}.expr-label{font-size:.85rem;color:var(--text2);height:1.4em;text-align:center}.scale-controls{display:flex;gap:6px}.scale-btn{background:var(--bg);border:1px solid var(--border);border-radius:6px;color:var(--text2);padding:3px 12px;font-size:.78rem;cursor:pointer;transition:all .15s}.scale-btn:hover{border-color:var(--accent);color:var(--accent)}.scale-btn.active{background:var(--accent-bg);border-color:var(--accent);color:var(--accent);font-weight:600}.panel{display:flex;flex-direction:column;gap:12px}.panel-section h3{font-size:.67rem;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--text3);margin:0 0 7px}.key-hint{font-weight:400;opacity:.7}.btn-grid{display:grid;grid-template-columns:repeat(2,1fr);gap:5px}.btn-grid-4{display:grid;grid-template-columns:repeat(4,1fr);gap:4px}.btn-grid-4 .ebtn{font-size:.62rem;padding:5px 3px;text-align:center;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.ebtn{background:var(--bg);border:1px solid var(--border);border-radius:7px;color:var(--text2);padding:6px 9px;font-size:.78rem;cursor:pointer;transition:all .15s;text-align:left}.ebtn:hover{border-color:var(--c);color:var(--c);background:color-mix(in srgb,var(--c) 6%,var(--surface))}.ebtn.active{background:color-mix(in srgb,var(--c) 12%,var(--surface));border-color:var(--c);color:var(--c);font-weight:600}.toggle{display:flex;align-items:center;gap:7px;font-size:.8rem;color:var(--text2);cursor:pointer;-webkit-user-select:none;user-select:none}.toggle input[type=checkbox]{accent-color:var(--accent);width:14px;height:14px}.switch-interval{display:flex;flex-direction:column;gap:5px}.switch-interval-label{display:flex;justify-content:space-between;font-size:.75rem;color:var(--text2)}.interval-val{color:var(--accent);font-weight:700}.switch-interval input[type=range]{width:100%;accent-color:var(--accent);cursor:pointer}.interval-ticks{display:flex;justify-content:space-between;font-size:.65rem;color:var(--text3)}.hint{font-size:.72rem;color:var(--text3);line-height:1.7}kbd{background:var(--bg);border:1px solid var(--border);border-radius:4px;padding:1px 5px;font-size:.68rem;font-family:inherit;color:var(--text2)}.hist-inline-link{background:none;border:none;color:var(--accent);font-size:.72rem;padding:0;cursor:pointer;text-decoration:underline}.chat-panel{display:flex;flex-direction:column;height:100%;padding:14px 18px;gap:10px;overflow:hidden}.chat-header{flex:0 0 auto;display:flex;align-items:center;justify-content:space-between;padding-bottom:8px;border-bottom:1px solid var(--border)}.chat-title{font-size:.7rem;font-weight:700;text-transform:uppercase;letter-spacing:.1em;color:var(--text3)}.history-link{background:none;border:none;color:var(--accent);font-size:.75rem;cursor:pointer;padding:0}.history-link:hover{text-decoration:underline}.voice-status{flex:0 0 auto;font-size:.8rem;letter-spacing:.04em;padding:6px 12px;border-radius:8px;width:fit-content}.voice-status-listening{color:#0369a1;background:#e0f2fe;animation:pulse .9s ease-in-out infinite}.voice-status-thinking{color:#92400e;background:#fef3c7;animation:pulse 1.2s ease-in-out infinite}.voice-status-speaking{color:#065f46;background:#d1fae5}@keyframes pulse{0%,to{opacity:1}50%{opacity:.5}}.chat-messages{flex:1;min-height:0;overflow-y:auto;display:flex;flex-direction:column;gap:10px;padding:4px 2px;scrollbar-width:thin;scrollbar-color:var(--border) transparent}.chat-messages::-webkit-scrollbar{width:4px}.chat-messages::-webkit-scrollbar-thumb{background:var(--border);border-radius:2px}.chat-empty{font-size:.82rem;color:var(--text3);text-align:center;padding:40px 0;margin:auto}.bubble{display:flex;flex-direction:column;gap:3px;max-width:82%}.bubble-user{align-self:flex-end;align-items:flex-end}.bubble-bot{align-self:flex-start;align-items:flex-start}.bubble-label{font-size:.62rem;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--text3)}.bubble-text{border-radius:12px;padding:9px 13px;font-size:.9rem;line-height:1.55}.bubble-user .bubble-text{background:#dbeafe;color:#1e3a8a;border-bottom-right-radius:3px}.bubble-bot .bubble-text{background:var(--surface);border:1px solid var(--border);color:var(--text);border-bottom-left-radius:3px}.audio-btn{width:100%;max-width:220px;height:28px;margin-top:3px;border-radius:6px;opacity:.8}.audio-btn:hover{opacity:1}.hist-page{min-height:100vh;background:var(--bg)}.hist-toolbar{display:flex;align-items:center;justify-content:space-between;padding:12px 24px;border-bottom:1px solid var(--border);position:sticky;top:0;background:var(--surface);z-index:10}.hist-heading{font-size:1rem;font-weight:700;color:var(--text);margin:0}.hist-back{background:none;border:1px solid var(--border);border-radius:6px;color:var(--text2);padding:5px 12px;font-size:.78rem;cursor:pointer}.hist-back:hover{border-color:var(--accent);color:var(--accent)}.hist-clear{background:none;border:1px solid #FECACA;border-radius:6px;color:#dc2626;padding:5px 12px;font-size:.78rem;cursor:pointer}.hist-clear:hover:not(:disabled){border-color:#dc2626}.hist-clear:disabled{opacity:.3;cursor:default}.hist-empty{text-align:center;color:var(--text3);padding:64px 32px;font-size:.9rem}.hist-list{display:flex;flex-direction:column;max-width:680px;margin:0 auto;padding:16px 24px}.hist-entry{border:1px solid var(--border);border-radius:12px;padding:14px 16px;margin-bottom:12px;background:var(--surface)}.hist-meta{display:flex;align-items:center;justify-content:space-between;margin-bottom:10px}.hist-time{font-size:.68rem;color:var(--text3)}.hist-del{background:none;border:none;color:var(--text3);cursor:pointer;font-size:.8rem;padding:0 4px}.hist-del:hover{color:#dc2626}.hist-row{display:flex;gap:10px;margin-bottom:8px}.hist-role{font-size:.62rem;font-weight:700;text-transform:uppercase;letter-spacing:.07em;color:var(--text3);min-width:36px;padding-top:2px}.hist-row-user .hist-role{color:#2563eb}.hist-row-bot .hist-role{color:#059669}.hist-body{flex:1}.hist-text{font-size:.86rem;color:var(--text);line-height:1.5;margin:0 0 6px}.hist-audio{width:100%;max-width:260px;height:26px;opacity:.75;border-radius:6px}.hist-audio:hover{opacity:1}@media(max-width:700px){.app{height:100dvh;height:-webkit-fill-available}.hdr{padding:8px 14px}.hdr h1{font-size:1.2rem}.subtitle{display:none}.page-body{flex-direction:column}.left-col{width:100%;flex:0 0 auto;border-right:none;border-bottom:1px solid var(--border);padding:10px 12px;gap:8px;flex-direction:row;align-items:flex-start;overflow-x:hidden;overflow-y:visible}.screen-wrap{flex:0 0 auto}.bezel{padding:8px}.panel{flex:1;min-width:0;gap:8px;overflow-y:auto;max-height:272px}.btn-grid{grid-template-columns:repeat(2,1fr);gap:4px}.btn-grid-4{grid-template-columns:repeat(4,1fr);gap:3px}.ebtn{font-size:.7rem;padding:5px 6px}.btn-grid-4 .ebtn{font-size:.58rem;padding:4px 2px}.scale-controls{display:none}.right-col{flex:1;min-height:0}.chat-panel{padding:10px 12px}}.memory-panel{border:1px solid var(--border);border-radius:8px;overflow:hidden}.memory-toggle{width:100%;display:flex;align-items:center;gap:6px;padding:7px 10px;background:var(--bg);border:none;cursor:pointer;font-size:.78rem;color:var(--text2);text-align:left}.memory-toggle:hover{background:#e8eef6}.memory-badge{margin-left:auto;background:var(--accent-bg);color:var(--accent);border-radius:10px;font-size:.65rem;font-weight:700;padding:1px 6px;min-width:18px;text-align:center}.memory-arrow{font-size:.6rem;color:var(--text3)}.memory-body{padding:8px 10px;background:var(--surface);border-top:1px solid var(--border)}.memory-empty{font-size:.72rem;color:var(--text3);text-align:center;padding:6px 0;margin:0}.memory-list{list-style:none;display:flex;flex-direction:column;gap:5px;margin:0 0 8px;padding:0;max-height:160px;overflow-y:auto;scrollbar-width:thin;scrollbar-color:var(--border) transparent}.memory-item{display:flex;align-items:flex-start;gap:6px;font-size:.75rem;color:var(--text2);line-height:1.4}.memory-text{flex:1}.memory-del{flex:0 0 auto;background:none;border:none;color:var(--text3);cursor:pointer;font-size:.9rem;line-height:1;padding:0 2px}.memory-del:hover{color:#dc2626}.memory-clear{width:100%;background:none;border:1px solid #FECACA;border-radius:5px;color:#dc2626;font-size:.72rem;padding:4px 0;cursor:pointer}.memory-clear:hover{background:#fef2f2}.voice-hint{margin-top:4px;display:flex;align-items:center;gap:4px;flex-wrap:wrap}.settings-page{min-height:100dvh;background:var(--bg);color:var(--text)}.settings-toolbar{display:flex;align-items:center;gap:14px;padding:12px 20px;background:var(--surface);border-bottom:1px solid var(--border);position:sticky;top:0;z-index:10}.settings-back{background:none;border:1px solid var(--border);border-radius:6px;color:var(--text2);font-size:.85rem;padding:5px 12px;cursor:pointer;transition:background .15s}.settings-back:hover{background:var(--bg);color:var(--accent)}.settings-heading{font-size:1.1rem;font-weight:700;margin:0;flex:1}.settings-save{background:var(--accent);border:none;border-radius:7px;color:#fff;font-size:.85rem;font-weight:600;padding:6px 16px;cursor:pointer;transition:opacity .15s}.settings-save:hover{opacity:.85}.settings-body{max-width:600px;margin:0 auto;padding:20px 18px 40px;display:flex;flex-direction:column;gap:20px}.settings-section{background:var(--surface);border:1px solid var(--border);border-radius:10px;padding:16px;display:flex;flex-direction:column;gap:12px}.settings-section-title{font-size:.85rem;font-weight:700;color:var(--text2);margin:0 0 4px;letter-spacing:.02em}.settings-label{display:flex;flex-direction:column;gap:5px;font-size:.82rem;font-weight:600;color:var(--text2)}.settings-label-mt{margin-top:6px}.settings-hint{font-size:.73rem;font-weight:400;color:var(--text3);margin-left:4px}.settings-hint-block{font-size:.75rem;color:var(--text3);margin:0}.settings-hint-block a{color:var(--accent)}.settings-input{border:1px solid var(--border);border-radius:6px;padding:7px 10px;font-size:.85rem;color:var(--text);background:var(--bg);outline:none;transition:border-color .15s;font-family:inherit}.settings-input:focus{border-color:var(--accent)}.settings-textarea{border:1px solid var(--border);border-radius:6px;padding:7px 10px;font-size:.85rem;color:var(--text);background:var(--bg);outline:none;resize:vertical;min-height:60px;transition:border-color .15s;font-family:inherit;line-height:1.5}.settings-textarea:focus{border-color:var(--accent)}.settings-radio-group{display:flex;flex-direction:column;gap:8px}.settings-radio-label{display:flex;align-items:center;gap:8px;font-size:.85rem;color:var(--text2);cursor:pointer}.settings-radio-label input{accent-color:var(--accent)}.settings-voice-grid{display:grid;grid-template-columns:repeat(auto-fill,minmax(130px,1fr));gap:8px}.settings-voice-btn{display:flex;flex-direction:column;gap:3px;padding:10px 10px 8px;background:var(--bg);border:1.5px solid var(--border);border-radius:8px;cursor:pointer;text-align:left;transition:border-color .15s,background .15s}.settings-voice-btn:hover,.settings-voice-btn.active{border-color:var(--accent);background:var(--accent-bg)}.voice-btn-label{font-size:.88rem;font-weight:700;color:var(--text)}.voice-btn-meta{font-size:.68rem;color:var(--text3);line-height:1.3}.settings-section-danger{border-color:#fecaca}.settings-reset-btn{background:none;border:1px solid #FECACA;border-radius:6px;color:#dc2626;font-size:.82rem;padding:7px 14px;cursor:pointer;transition:background .15s}.settings-reset-btn:hover{background:#fef2f2}.settings-secret-row{display:flex;gap:.5rem;align-items:stretch}.settings-secret-row .settings-input{flex:1}.settings-show-btn{padding:.45rem .75rem;font-size:.78rem;background:#e2e8f0;border:1px solid #cbd5e1;border-radius:6px;cursor:pointer;white-space:nowrap;color:#475569}.settings-show-btn:hover{background:#cbd5e1} diff --git a/static/dist/jbot.js b/static/dist/jbot.js index 6208d37..0d54e8e 100644 --- a/static/dist/jbot.js +++ b/static/dist/jbot.js @@ -1,4 +1,4 @@ -import{r as l,j as d,c as tn}from"./client-DS0SU7Jy.js";/** +import{r as i,j as l,c as nn}from"./client-DS0SU7Jy.js";/** * react-router v7.15.1 * * Copyright (c) Remix Software Inc. @@ -7,6 +7,6 @@ import{r as l,j as d,c as tn}from"./client-DS0SU7Jy.js";/** * LICENSE.md file in the root directory of this source tree. * * @license MIT - */var mt="popstate";function pt(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function nn(e={}){function t(r,a){var c;let o=(c=a.state)==null?void 0:c.masked,{pathname:s,search:u,hash:i}=o||r.location;return qe("",{pathname:s,search:u,hash:i},a.state&&a.state.usr||null,a.state&&a.state.key||"default",o?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:ve(a)}return an(t,n,null,e)}function T(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function K(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function rn(){return Math.random().toString(36).substring(2,10)}function gt(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function qe(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?ue(t):t,state:n,key:t&&t.key||r||rn(),mask:a}}function ve({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function ue(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function an(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:o=!1}=r,s=a.history,u="POP",i=null,c=h();c==null&&(c=0,s.replaceState({...s.state,idx:c},""));function h(){return(s.state||{idx:null}).idx}function f(){u="POP";let g=h(),v=g==null?null:g-c;c=g,i&&i({action:u,location:p.location,delta:v})}function m(g,v){u="PUSH";let w=pt(g)?g:qe(p.location,g,v);c=h()+1;let E=gt(w,c),N=p.createHref(w.mask||w);try{s.pushState(E,"",N)}catch($){if($ instanceof DOMException&&$.name==="DataCloneError")throw $;a.location.assign(N)}o&&i&&i({action:u,location:p.location,delta:1})}function b(g,v){u="REPLACE";let w=pt(g)?g:qe(p.location,g,v);c=h();let E=gt(w,c),N=p.createHref(w.mask||w);s.replaceState(E,"",N),o&&i&&i({action:u,location:p.location,delta:0})}function y(g){return on(g)}let p={get action(){return u},get location(){return e(a,s)},listen(g){if(i)throw new Error("A history only accepts one active listener");return a.addEventListener(mt,f),i=g,()=>{a.removeEventListener(mt,f),i=null}},createHref(g){return t(a,g)},createURL:y,encodeLocation(g){let v=y(g);return{pathname:v.pathname,search:v.search,hash:v.hash}},push:m,replace:b,go(g){return s.go(g)}};return p}function on(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),T(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:ve(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function jt(e,t,n="/"){return sn(e,t,n,!1)}function sn(e,t,n,r,a){let o=typeof t=="string"?ue(t):t,s=Z(o.pathname||"/",n);if(s==null)return null;let u=ln(e),i=null,c=wn(s);for(let h=0;i==null&&h{let h={relativePath:c===void 0?s.path||"":c,caseSensitive:s.caseSensitive===!0,childrenIndex:u,route:s};if(h.relativePath.startsWith("/")){if(!h.relativePath.startsWith(r)&&i)return;T(h.relativePath.startsWith(r),`Absolute route path "${h.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),h.relativePath=h.relativePath.slice(r.length)}let f=V([r,h.relativePath]),m=n.concat(h);s.children&&s.children.length>0&&(T(s.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${f}".`),Pt(s.children,t,m,f,i)),!(s.path==null&&!s.index)&&t.push({path:f,score:gn(f,s.index),routesMeta:m})};return e.forEach((s,u)=>{var i;if(s.path===""||!((i=s.path)!=null&&i.includes("?")))o(s,u);else for(let c of Mt(s.path))o(s,u,!0,c)}),t}function Mt(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),o=n.replace(/\?$/,"");if(r.length===0)return a?[o,""]:[o];let s=Mt(r.join("/")),u=[];return u.push(...s.map(i=>i===""?o:[o,i].join("/"))),a&&u.push(...s),u.map(i=>e.startsWith("/")&&i===""?"/":i)}function un(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:yn(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var cn=/^:[\w-]+$/,dn=3,hn=2,fn=1,mn=10,pn=-2,yt=e=>e==="*";function gn(e,t){let n=e.split("/"),r=n.length;return n.some(yt)&&(r+=pn),t&&(r+=hn),n.filter(a=>!yt(a)).reduce((a,o)=>a+(cn.test(o)?dn:o===""?fn:mn),r)}function yn(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function vn(e,t,n=!1){let{routesMeta:r}=e,a={},o="/",s=[];for(let u=0;u{if(h==="*"){let y=u[m]||"";s=o.slice(0,o.length-y.length).replace(/(.)\/+$/,"$1")}const b=u[m];return f&&!b?c[h]=void 0:c[h]=(b||"").replace(/%2F/g,"/"),c},{}),pathname:o,pathnameBase:s,pattern:e}}function bn(e,t=!1,n=!0){K(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(s,u,i,c,h)=>{if(r.push({paramName:u,isOptional:i!=null}),i){let f=h.charAt(c+s.length);return f&&f!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function wn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return K(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Z(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var En=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function xn(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?ue(e):e,o;return n?(n=$t(n),n.startsWith("/")?o=vt(n.substring(1),"/"):o=vt(n,t)):o=t,{pathname:o,search:kn(r),hash:Cn(a)}}function vt(e,t){let n=$e(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function He(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Rn(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function Tt(e){let t=Rn(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ze(e,t,n,r=!1){let a;typeof e=="string"?a=ue(e):(a={...e},T(!a.pathname||!a.pathname.includes("?"),He("?","pathname","search",a)),T(!a.pathname||!a.pathname.includes("#"),He("#","pathname","hash",a)),T(!a.search||!a.search.includes("#"),He("#","search","hash",a)));let o=e===""||a.pathname==="",s=o?"/":a.pathname,u;if(s==null)u=n;else{let f=t.length-1;if(!r&&s.startsWith("..")){let m=s.split("/");for(;m[0]==="..";)m.shift(),f-=1;a.pathname=m.join("/")}u=f>=0?t[f]:"/"}let i=xn(a,u),c=s&&s!=="/"&&s.endsWith("/"),h=(o||s===".")&&n.endsWith("/");return!i.pathname.endsWith("/")&&(c||h)&&(i.pathname+="/"),i}var $t=e=>e.replace(/\/\/+/g,"/"),V=e=>$t(e.join("/")),$e=e=>e.replace(/\/+$/,""),Sn=e=>$e(e).replace(/^\/*/,"/"),kn=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Cn=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,Nn=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function jn(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Pn(e){let t=e.map(n=>n.route.path).filter(Boolean);return V(t)||"/"}var Lt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function It(e,t){let n=e;if(typeof n!="string"||!En.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Lt)try{let o=new URL(window.location.href),s=n.startsWith("//")?new URL(o.protocol+n):new URL(n),u=Z(s.pathname,t);s.origin===o.origin&&u!=null?n=u+s.search+s.hash:a=!0}catch{K(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var _t=["POST","PUT","PATCH","DELETE"];new Set(_t);var Mn=["GET",..._t];new Set(Mn);var ce=l.createContext(null);ce.displayName="DataRouter";var Ie=l.createContext(null);Ie.displayName="DataRouterState";var Bt=l.createContext(!1);function Tn(){return l.useContext(Bt)}var Ft=l.createContext({isTransitioning:!1});Ft.displayName="ViewTransition";var $n=l.createContext(new Map);$n.displayName="Fetchers";var Ln=l.createContext(null);Ln.displayName="Await";var H=l.createContext(null);H.displayName="Navigation";var be=l.createContext(null);be.displayName="Location";var ee=l.createContext({outlet:null,matches:[],isDataRoute:!1});ee.displayName="Route";var et=l.createContext(null);et.displayName="RouteError";var At="REACT_ROUTER_ERROR",In="REDIRECT",_n="ROUTE_ERROR_RESPONSE";function Bn(e){if(e.startsWith(`${At}:${In}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Fn(e){if(e.startsWith(`${At}:${_n}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new Nn(t.status,t.statusText,t.data)}catch{}}function An(e,{relative:t}={}){T(we(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=l.useContext(H),{hash:a,pathname:o,search:s}=xe(e,{relative:t}),u=o;return n!=="/"&&(u=o==="/"?n:V([n,o])),r.createHref({pathname:u,search:s,hash:a})}function we(){return l.useContext(be)!=null}function te(){return T(we(),"useLocation() may be used only in the context of a component."),l.useContext(be).location}var Ot="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ut(e){l.useContext(H).static||l.useLayoutEffect(e)}function Ee(){let{isDataRoute:e}=l.useContext(ee);return e?Xn():On()}function On(){T(we(),"useNavigate() may be used only in the context of a component.");let e=l.useContext(ce),{basename:t,navigator:n}=l.useContext(H),{matches:r}=l.useContext(ee),{pathname:a}=te(),o=JSON.stringify(Tt(r)),s=l.useRef(!1);return Ut(()=>{s.current=!0}),l.useCallback((i,c={})=>{if(K(s.current,Ot),!s.current)return;if(typeof i=="number"){n.go(i);return}let h=Ze(i,JSON.parse(o),a,c.relative==="path");e==null&&t!=="/"&&(h.pathname=h.pathname==="/"?t:V([t,h.pathname])),(c.replace?n.replace:n.push)(h,c.state,c)},[t,n,o,a,e])}l.createContext(null);function xe(e,{relative:t}={}){let{matches:n}=l.useContext(ee),{pathname:r}=te(),a=JSON.stringify(Tt(n));return l.useMemo(()=>Ze(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Un(e,t){return Dt(e,t)}function Dt(e,t,n){var g;T(we(),"useRoutes() may be used only in the context of a component.");let{navigator:r}=l.useContext(H),{matches:a}=l.useContext(ee),o=a[a.length-1],s=o?o.params:{},u=o?o.pathname:"/",i=o?o.pathnameBase:"/",c=o&&o.route;{let v=c&&c.path||"";Ht(u,!c||v.endsWith("*")||v.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${u}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. + */var mt="popstate";function pt(e){return typeof e=="object"&&e!=null&&"pathname"in e&&"search"in e&&"hash"in e&&"state"in e&&"key"in e}function rn(e={}){function t(r,a){var d;let s=(d=a.state)==null?void 0:d.masked,{pathname:o,search:u,hash:c}=s||r.location;return Ke("",{pathname:o,search:u,hash:c},a.state&&a.state.usr||null,a.state&&a.state.key||"default",s?{pathname:r.location.pathname,search:r.location.search,hash:r.location.hash}:void 0)}function n(r,a){return typeof a=="string"?a:be(a)}return sn(t,n,null,e)}function M(e,t){if(e===!1||e===null||typeof e>"u")throw new Error(t)}function q(e,t){if(!e){typeof console<"u"&&console.warn(t);try{throw new Error(t)}catch{}}}function an(){return Math.random().toString(36).substring(2,10)}function gt(e,t){return{usr:e.state,key:e.key,idx:t,masked:e.mask?{pathname:e.pathname,search:e.search,hash:e.hash}:void 0}}function Ke(e,t,n=null,r,a){return{pathname:typeof e=="string"?e:e.pathname,search:"",hash:"",...typeof t=="string"?ue(t):t,state:n,key:t&&t.key||r||an(),mask:a}}function be({pathname:e="/",search:t="",hash:n=""}){return t&&t!=="?"&&(e+=t.charAt(0)==="?"?t:"?"+t),n&&n!=="#"&&(e+=n.charAt(0)==="#"?n:"#"+n),e}function ue(e){let t={};if(e){let n=e.indexOf("#");n>=0&&(t.hash=e.substring(n),e=e.substring(0,n));let r=e.indexOf("?");r>=0&&(t.search=e.substring(r),e=e.substring(0,r)),e&&(t.pathname=e)}return t}function sn(e,t,n,r={}){let{window:a=document.defaultView,v5Compat:s=!1}=r,o=a.history,u="POP",c=null,d=f();d==null&&(d=0,o.replaceState({...o.state,idx:d},""));function f(){return(o.state||{idx:null}).idx}function h(){u="POP";let m=f(),y=m==null?null:m-d;d=m,c&&c({action:u,location:g.location,delta:y})}function p(m,y){u="PUSH";let w=pt(m)?m:Ke(g.location,m,y);d=f()+1;let x=gt(w,d),N=g.createHref(w.mask||w);try{o.pushState(x,"",N)}catch(I){if(I instanceof DOMException&&I.name==="DataCloneError")throw I;a.location.assign(N)}s&&c&&c({action:u,location:g.location,delta:1})}function b(m,y){u="REPLACE";let w=pt(m)?m:Ke(g.location,m,y);d=f();let x=gt(w,d),N=g.createHref(w.mask||w);o.replaceState(x,"",N),s&&c&&c({action:u,location:g.location,delta:0})}function v(m){return on(m)}let g={get action(){return u},get location(){return e(a,o)},listen(m){if(c)throw new Error("A history only accepts one active listener");return a.addEventListener(mt,h),c=m,()=>{a.removeEventListener(mt,h),c=null}},createHref(m){return t(a,m)},createURL:v,encodeLocation(m){let y=v(m);return{pathname:y.pathname,search:y.search,hash:y.hash}},push:p,replace:b,go(m){return o.go(m)}};return g}function on(e,t=!1){let n="http://localhost";typeof window<"u"&&(n=window.location.origin!=="null"?window.location.origin:window.location.href),M(n,"No window.location.(origin|href) available to create URL");let r=typeof e=="string"?e:be(e);return r=r.replace(/ $/,"%20"),!t&&r.startsWith("//")&&(r=n+r),new URL(r,n)}function Tt(e,t,n="/"){return ln(e,t,n,!1)}function ln(e,t,n,r,a){let s=typeof t=="string"?ue(t):t,o=Z(s.pathname||"/",n);if(o==null)return null;let u=un(e),c=null,d=xn(o);for(let f=0;c==null&&f{let f={relativePath:d===void 0?o.path||"":d,caseSensitive:o.caseSensitive===!0,childrenIndex:u,route:o};if(f.relativePath.startsWith("/")){if(!f.relativePath.startsWith(r)&&c)return;M(f.relativePath.startsWith(r),`Absolute route path "${f.relativePath}" nested under path "${r}" is not valid. An absolute child route path must start with the combined path of all its parent routes.`),f.relativePath=f.relativePath.slice(r.length)}let h=V([r,f.relativePath]),p=n.concat(f);o.children&&o.children.length>0&&(M(o.index!==!0,`Index routes must not have child routes. Please remove all child routes from route path "${h}".`),Pt(o.children,t,p,h,c)),!(o.path==null&&!o.index)&&t.push({path:h,score:yn(h,o.index),routesMeta:p})};return e.forEach((o,u)=>{var c;if(o.path===""||!((c=o.path)!=null&&c.includes("?")))s(o,u);else for(let d of Mt(o.path))s(o,u,!0,d)}),t}function Mt(e){let t=e.split("/");if(t.length===0)return[];let[n,...r]=t,a=n.endsWith("?"),s=n.replace(/\?$/,"");if(r.length===0)return a?[s,""]:[s];let o=Mt(r.join("/")),u=[];return u.push(...o.map(c=>c===""?s:[s,c].join("/"))),a&&u.push(...o),u.map(c=>e.startsWith("/")&&c===""?"/":c)}function cn(e){e.sort((t,n)=>t.score!==n.score?n.score-t.score:vn(t.routesMeta.map(r=>r.childrenIndex),n.routesMeta.map(r=>r.childrenIndex)))}var dn=/^:[\w-]+$/,hn=3,fn=2,mn=1,pn=10,gn=-2,yt=e=>e==="*";function yn(e,t){let n=e.split("/"),r=n.length;return n.some(yt)&&(r+=gn),t&&(r+=fn),n.filter(a=>!yt(a)).reduce((a,s)=>a+(dn.test(s)?hn:s===""?mn:pn),r)}function vn(e,t){return e.length===t.length&&e.slice(0,-1).every((r,a)=>r===t[a])?e[e.length-1]-t[t.length-1]:0}function bn(e,t,n=!1){let{routesMeta:r}=e,a={},s="/",o=[];for(let u=0;u{if(f==="*"){let v=u[p]||"";o=s.slice(0,s.length-v.length).replace(/(.)\/+$/,"$1")}const b=u[p];return h&&!b?d[f]=void 0:d[f]=(b||"").replace(/%2F/g,"/"),d},{}),pathname:s,pathnameBase:o,pattern:e}}function wn(e,t=!1,n=!0){q(e==="*"||!e.endsWith("*")||e.endsWith("/*"),`Route path "${e}" will be treated as if it were "${e.replace(/\*$/,"/*")}" because the \`*\` character must always follow a \`/\` in the pattern. To get rid of this warning, please change the route path to "${e.replace(/\*$/,"/*")}".`);let r=[],a="^"+e.replace(/\/*\*?$/,"").replace(/^\/*/,"/").replace(/[\\.*+^${}|()[\]]/g,"\\$&").replace(/\/:([\w-]+)(\?)?/g,(o,u,c,d,f)=>{if(r.push({paramName:u,isOptional:c!=null}),c){let h=f.charAt(d+o.length);return h&&h!=="/"?"/([^\\/]*)":"(?:/([^\\/]*))?"}return"/([^\\/]+)"}).replace(/\/([\w-]+)\?(\/|$)/g,"(/$1)?$2");return e.endsWith("*")?(r.push({paramName:"*"}),a+=e==="*"||e==="/*"?"(.*)$":"(?:\\/(.+)|\\/*)$"):n?a+="\\/*$":e!==""&&e!=="/"&&(a+="(?:(?=\\/|$))"),[new RegExp(a,t?void 0:"i"),r]}function xn(e){try{return e.split("/").map(t=>decodeURIComponent(t).replace(/\//g,"%2F")).join("/")}catch(t){return q(!1,`The URL path "${e}" could not be decoded because it is a malformed URL segment. This is probably due to a bad percent encoding (${t}).`),e}}function Z(e,t){if(t==="/")return e;if(!e.toLowerCase().startsWith(t.toLowerCase()))return null;let n=t.endsWith("/")?t.length-1:t.length,r=e.charAt(n);return r&&r!=="/"?null:e.slice(n)||"/"}var En=/^(?:[a-z][a-z0-9+.-]*:|\/\/)/i;function Rn(e,t="/"){let{pathname:n,search:r="",hash:a=""}=typeof e=="string"?ue(e):e,s;return n?(n=At(n),n.startsWith("/")?s=vt(n.substring(1),"/"):s=vt(n,t)):s=t,{pathname:s,search:Cn(r),hash:Nn(a)}}function vt(e,t){let n=Ae(t).split("/");return e.split("/").forEach(a=>{a===".."?n.length>1&&n.pop():a!=="."&&n.push(a)}),n.length>1?n.join("/"):"/"}function He(e,t,n,r){return`Cannot include a '${e}' character in a manually specified \`to.${t}\` field [${JSON.stringify(r)}]. Please separate it out to the \`to.${n}\` field. Alternatively you may provide the full path as a string in and the router will parse it for you.`}function Sn(e){return e.filter((t,n)=>n===0||t.route.path&&t.route.path.length>0)}function It(e){let t=Sn(e);return t.map((n,r)=>r===t.length-1?n.pathname:n.pathnameBase)}function Ze(e,t,n,r=!1){let a;typeof e=="string"?a=ue(e):(a={...e},M(!a.pathname||!a.pathname.includes("?"),He("?","pathname","search",a)),M(!a.pathname||!a.pathname.includes("#"),He("#","pathname","hash",a)),M(!a.search||!a.search.includes("#"),He("#","search","hash",a)));let s=e===""||a.pathname==="",o=s?"/":a.pathname,u;if(o==null)u=n;else{let h=t.length-1;if(!r&&o.startsWith("..")){let p=o.split("/");for(;p[0]==="..";)p.shift(),h-=1;a.pathname=p.join("/")}u=h>=0?t[h]:"/"}let c=Rn(a,u),d=o&&o!=="/"&&o.endsWith("/"),f=(s||o===".")&&n.endsWith("/");return!c.pathname.endsWith("/")&&(d||f)&&(c.pathname+="/"),c}var At=e=>e.replace(/\/\/+/g,"/"),V=e=>At(e.join("/")),Ae=e=>e.replace(/\/+$/,""),kn=e=>Ae(e).replace(/^\/*/,"/"),Cn=e=>!e||e==="?"?"":e.startsWith("?")?e:"?"+e,Nn=e=>!e||e==="#"?"":e.startsWith("#")?e:"#"+e,jn=class{constructor(e,t,n,r=!1){this.status=e,this.statusText=t||"",this.internal=r,n instanceof Error?(this.data=n.toString(),this.error=n):this.data=n}};function Tn(e){return e!=null&&typeof e.status=="number"&&typeof e.statusText=="string"&&typeof e.internal=="boolean"&&"data"in e}function Pn(e){let t=e.map(n=>n.route.path).filter(Boolean);return V(t)||"/"}var Lt=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function $t(e,t){let n=e;if(typeof n!="string"||!En.test(n))return{absoluteURL:void 0,isExternal:!1,to:n};let r=n,a=!1;if(Lt)try{let s=new URL(window.location.href),o=n.startsWith("//")?new URL(s.protocol+n):new URL(n),u=Z(o.pathname,t);o.origin===s.origin&&u!=null?n=u+o.search+o.hash:a=!0}catch{q(!1,` contains an invalid URL which will probably break when clicked - please update to a valid URL path.`)}return{absoluteURL:r,isExternal:a,to:n}}Object.getOwnPropertyNames(Object.prototype).sort().join("\0");var _t=["POST","PUT","PATCH","DELETE"];new Set(_t);var Mn=["GET",..._t];new Set(Mn);var ce=i.createContext(null);ce.displayName="DataRouter";var $e=i.createContext(null);$e.displayName="DataRouterState";var Bt=i.createContext(!1);function In(){return i.useContext(Bt)}var Ft=i.createContext({isTransitioning:!1});Ft.displayName="ViewTransition";var An=i.createContext(new Map);An.displayName="Fetchers";var Ln=i.createContext(null);Ln.displayName="Await";var H=i.createContext(null);H.displayName="Navigation";var we=i.createContext(null);we.displayName="Location";var ee=i.createContext({outlet:null,matches:[],isDataRoute:!1});ee.displayName="Route";var et=i.createContext(null);et.displayName="RouteError";var Ot="REACT_ROUTER_ERROR",$n="REDIRECT",_n="ROUTE_ERROR_RESPONSE";function Bn(e){if(e.startsWith(`${Ot}:${$n}:{`))try{let t=JSON.parse(e.slice(28));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string"&&typeof t.location=="string"&&typeof t.reloadDocument=="boolean"&&typeof t.replace=="boolean")return t}catch{}}function Fn(e){if(e.startsWith(`${Ot}:${_n}:{`))try{let t=JSON.parse(e.slice(40));if(typeof t=="object"&&t&&typeof t.status=="number"&&typeof t.statusText=="string")return new jn(t.status,t.statusText,t.data)}catch{}}function On(e,{relative:t}={}){M(xe(),"useHref() may be used only in the context of a component.");let{basename:n,navigator:r}=i.useContext(H),{hash:a,pathname:s,search:o}=Re(e,{relative:t}),u=s;return n!=="/"&&(u=s==="/"?n:V([n,s])),r.createHref({pathname:u,search:o,hash:a})}function xe(){return i.useContext(we)!=null}function te(){return M(xe(),"useLocation() may be used only in the context of a component."),i.useContext(we).location}var Dt="You should call navigate() in a React.useEffect(), not when your component is first rendered.";function Ut(e){i.useContext(H).static||i.useLayoutEffect(e)}function Ee(){let{isDataRoute:e}=i.useContext(ee);return e?Qn():Dn()}function Dn(){M(xe(),"useNavigate() may be used only in the context of a component.");let e=i.useContext(ce),{basename:t,navigator:n}=i.useContext(H),{matches:r}=i.useContext(ee),{pathname:a}=te(),s=JSON.stringify(It(r)),o=i.useRef(!1);return Ut(()=>{o.current=!0}),i.useCallback((c,d={})=>{if(q(o.current,Dt),!o.current)return;if(typeof c=="number"){n.go(c);return}let f=Ze(c,JSON.parse(s),a,d.relative==="path");e==null&&t!=="/"&&(f.pathname=f.pathname==="/"?t:V([t,f.pathname])),(d.replace?n.replace:n.push)(f,d.state,d)},[t,n,s,a,e])}i.createContext(null);function Re(e,{relative:t}={}){let{matches:n}=i.useContext(ee),{pathname:r}=te(),a=JSON.stringify(It(n));return i.useMemo(()=>Ze(e,JSON.parse(a),r,t==="path"),[e,a,r,t])}function Un(e,t){return zt(e,t)}function zt(e,t,n){var m;M(xe(),"useRoutes() may be used only in the context of a component.");let{navigator:r}=i.useContext(H),{matches:a}=i.useContext(ee),s=a[a.length-1],o=s?s.params:{},u=s?s.pathname:"/",c=s?s.pathnameBase:"/",d=s&&s.route;{let y=d&&d.path||"";Wt(u,!d||y.endsWith("*")||y.endsWith("*?"),`You rendered descendant (or called \`useRoutes()\`) at "${u}" (under ) but the parent route path has no trailing "*". This means if you navigate deeper, the parent won't match anymore and therefore the child routes will never render. -Please change the parent to .`)}let h=te(),f;if(t){let v=typeof t=="string"?ue(t):t;T(i==="/"||((g=v.pathname)==null?void 0:g.startsWith(i)),`When overriding the location using \`\` or \`useRoutes(routes, location)\`, the location pathname must begin with the portion of the URL pathname that was matched by all parent routes. The current pathname base is "${i}" but pathname "${v.pathname}" was given in the \`location\` prop.`),f=v}else f=h;let m=f.pathname||"/",b=m;if(i!=="/"){let v=i.replace(/^\//,"").split("/");b="/"+m.replace(/^\//,"").split("/").slice(v.length).join("/")}let y=n&&n.state.matches.length?n.state.matches.map(v=>Object.assign(v,{route:n.manifest[v.route.id]||v.route})):jt(e,{pathname:b});K(c||y!=null,`No routes matched location "${f.pathname}${f.search}${f.hash}" `),K(y==null||y[y.length-1].route.element!==void 0||y[y.length-1].route.Component!==void 0||y[y.length-1].route.lazy!==void 0,`Matched leaf route at location "${f.pathname}${f.search}${f.hash}" does not have an element or Component. This means it will render an with a null value by default resulting in an "empty" page.`);let p=Vn(y&&y.map(v=>Object.assign({},v,{params:Object.assign({},s,v.params),pathname:V([i,r.encodeLocation?r.encodeLocation(v.pathname.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:v.pathname]),pathnameBase:v.pathnameBase==="/"?i:V([i,r.encodeLocation?r.encodeLocation(v.pathnameBase.replace(/%/g,"%25").replace(/\?/g,"%3F").replace(/#/g,"%23")).pathname:v.pathnameBase])})),a,n);return t&&p?l.createElement(be.Provider,{value:{location:{pathname:"/",search:"",hash:"",state:null,key:"default",mask:void 0,...f},navigationType:"POP"}},p):p}function Dn(){let e=Gn(),t=jn(e)?`${e.status} ${e.statusText}`:e instanceof Error?e.message:JSON.stringify(e),n=e instanceof Error?e.stack:null,r="rgba(200,200,200, 0.5)",a={padding:"0.5rem",backgroundColor:r},o={padding:"2px 4px",backgroundColor:r},s=null;return console.error("Error handled by React Router default ErrorBoundary:",e),s=l.createElement(l.Fragment,null,l.createElement("p",null,"💿 Hey developer 👋"),l.createElement("p",null,"You can provide a way better UX than this when your app throws errors by providing your own ",l.createElement("code",{style:o},"ErrorBoundary")," or"," ",l.createElement("code",{style:o},"errorElement")," prop on your route.")),l.createElement(l.Fragment,null,l.createElement("h2",null,"Unexpected Application Error!"),l.createElement("h3",{style:{fontStyle:"italic"}},t),n?l.createElement("pre",{style:a},n):null,s)}var zn=l.createElement(Dn,null),zt=class extends l.Component{constructor(e){super(e),this.state={location:e.location,revalidation:e.revalidation,error:e.error}}static getDerivedStateFromError(e){return{error:e}}static getDerivedStateFromProps(e,t){return t.location!==e.location||t.revalidation!=="idle"&&e.revalidation==="idle"?{error:e.error,location:e.location,revalidation:e.revalidation}:{error:e.error!==void 0?e.error:t.error,location:t.location,revalidation:e.revalidation||t.revalidation}}componentDidCatch(e,t){this.props.onError?this.props.onError(e,t):console.error("React Router caught the following error during render",e)}render(){let e=this.state.error;if(this.context&&typeof e=="object"&&e&&"digest"in e&&typeof e.digest=="string"){const n=Fn(e.digest);n&&(e=n)}let t=e!==void 0?l.createElement(ee.Provider,{value:this.props.routeContext},l.createElement(et.Provider,{value:e,children:this.props.component})):this.props.children;return this.context?l.createElement(Hn,{error:e},t):t}};zt.contextType=Bt;var We=new WeakMap;function Hn({children:e,error:t}){let{basename:n}=l.useContext(H);if(typeof t=="object"&&t&&"digest"in t&&typeof t.digest=="string"){let r=Bn(t.digest);if(r){let a=We.get(t);if(a)throw a;let o=It(r.location,n);if(Lt&&!We.get(t))if(o.isExternal||r.reloadDocument)window.location.href=o.absoluteURL||o.to;else{const s=Promise.resolve().then(()=>window.__reactRouterDataRouter.navigate(o.to,{replace:r.replace}));throw We.set(t,s),s}return l.createElement("meta",{httpEquiv:"refresh",content:`0;url=${o.absoluteURL||o.to}`})}}return e}function Wn({routeContext:e,match:t,children:n}){let r=l.useContext(ce);return r&&r.static&&r.staticContext&&(t.route.errorElement||t.route.ErrorBoundary)&&(r.staticContext._deepestRenderedBoundaryId=t.route.id),l.createElement(ee.Provider,{value:e},n)}function Vn(e,t=[],n){let r=n==null?void 0:n.state;if(e==null){if(!r)return null;if(r.errors)e=r.matches;else if(t.length===0&&!r.initialized&&r.matches.length>0)e=r.matches;else return null}let a=e,o=r==null?void 0:r.errors;if(o!=null){let h=a.findIndex(f=>f.route.id&&(o==null?void 0:o[f.route.id])!==void 0);T(h>=0,`Could not find a matching route for errors on route IDs: ${Object.keys(o).join(",")}`),a=a.slice(0,Math.min(a.length,h+1))}let s=!1,u=-1;if(n&&r){s=r.renderFallback;for(let h=0;h=0?a=a.slice(0,u+1):a=[a[0]];break}}}}let i=n==null?void 0:n.onError,c=r&&i?(h,f)=>{var m,b;i(h,{location:r.location,params:((b=(m=r.matches)==null?void 0:m[0])==null?void 0:b.params)??{},pattern:Pn(r.matches),errorInfo:f})}:void 0;return a.reduceRight((h,f,m)=>{let b,y=!1,p=null,g=null;r&&(b=o&&f.route.id?o[f.route.id]:void 0,p=f.route.errorElement||zn,s&&(u<0&&m===0?(Ht("route-fallback",!1,"No `HydrateFallback` element provided to render during initial hydration"),y=!0,g=null):u===m&&(y=!0,g=f.route.hydrateFallbackElement||null)));let v=t.concat(a.slice(0,m+1)),w=()=>{let E;return b?E=p:y?E=g:f.route.Component?E=l.createElement(f.route.Component,null):f.route.element?E=f.route.element:E=h,l.createElement(Wn,{match:f,routeContext:{outlet:h,matches:v,isDataRoute:r!=null},children:E})};return r&&(f.route.ErrorBoundary||f.route.errorElement||m===0)?l.createElement(zt,{location:r.location,revalidation:r.revalidation,component:p,error:b,children:w(),routeContext:{outlet:null,matches:v,isDataRoute:!0},onError:c}):w()},null)}function tt(e){return`${e} must be used within a data router. See https://reactrouter.com/en/main/routers/picking-a-router.`}function Jn(e){let t=l.useContext(ce);return T(t,tt(e)),t}function qn(e){let t=l.useContext(Ie);return T(t,tt(e)),t}function Kn(e){let t=l.useContext(ee);return T(t,tt(e)),t}function nt(e){let t=Kn(e),n=t.matches[t.matches.length-1];return T(n.route.id,`${e} can only be used on routes that contain a unique "id"`),n.route.id}function Yn(){return nt("useRouteId")}function Gn(){var r;let e=l.useContext(et),t=qn("useRouteError"),n=nt("useRouteError");return e!==void 0?e:(r=t.errors)==null?void 0:r[n]}function Xn(){let{router:e}=Jn("useNavigate"),t=nt("useNavigate"),n=l.useRef(!1);return Ut(()=>{n.current=!0}),l.useCallback(async(a,o={})=>{K(n.current,Ot),n.current&&(typeof a=="number"?await e.navigate(a):await e.navigate(a,{fromRouteId:t,...o}))},[e,t])}var bt={};function Ht(e,t,n){!t&&!bt[e]&&(bt[e]=!0,K(!1,n))}l.memo(Qn);function Qn({routes:e,manifest:t,future:n,state:r,isStatic:a,onError:o}){return Dt(e,void 0,{manifest:t,state:r,isStatic:a,onError:o})}function je(e){T(!1,"A is only ever to be used as the child of element, never rendered directly. Please wrap your in a .")}function Zn({basename:e="/",children:t=null,location:n,navigationType:r="POP",navigator:a,static:o=!1,useTransitions:s}){T(!we(),"You cannot render a inside another . You should never have more than one in your app.");let u=e.replace(/^\/*/,"/"),i=l.useMemo(()=>({basename:u,navigator:a,static:o,useTransitions:s,future:{}}),[u,a,o,s]);typeof n=="string"&&(n=ue(n));let{pathname:c="/",search:h="",hash:f="",state:m=null,key:b="default",mask:y}=n,p=l.useMemo(()=>{let g=Z(c,u);return g==null?null:{location:{pathname:g,search:h,hash:f,state:m,key:b,mask:y},navigationType:r}},[u,c,h,f,m,b,r,y]);return K(p!=null,` is not able to match the URL "${c}${h}${f}" because it does not start with the basename, so the won't render anything.`),p==null?null:l.createElement(H.Provider,{value:i},l.createElement(be.Provider,{children:t,value:p}))}function er({children:e,location:t}){return Un(Ke(e),t)}function Ke(e,t=[]){let n=[];return l.Children.forEach(e,(r,a)=>{if(!l.isValidElement(r))return;let o=[...t,a];if(r.type===l.Fragment){n.push.apply(n,Ke(r.props.children,o));return}T(r.type===je,`[${typeof r.type=="string"?r.type:r.type.name}] is not a component. All component children of must be a or `),T(!r.props.index||!r.props.children,"An index route cannot have child routes.");let s={id:r.props.id||o.join("-"),caseSensitive:r.props.caseSensitive,element:r.props.element,Component:r.props.Component,index:r.props.index,path:r.props.path,middleware:r.props.middleware,loader:r.props.loader,action:r.props.action,hydrateFallbackElement:r.props.hydrateFallbackElement,HydrateFallback:r.props.HydrateFallback,errorElement:r.props.errorElement,ErrorBoundary:r.props.ErrorBoundary,hasErrorBoundary:r.props.hasErrorBoundary===!0||r.props.ErrorBoundary!=null||r.props.errorElement!=null,shouldRevalidate:r.props.shouldRevalidate,handle:r.props.handle,lazy:r.props.lazy};r.props.children&&(s.children=Ke(r.props.children,o)),n.push(s)}),n}var Pe="get",Me="application/x-www-form-urlencoded";function _e(e){return typeof HTMLElement<"u"&&e instanceof HTMLElement}function tr(e){return _e(e)&&e.tagName.toLowerCase()==="button"}function nr(e){return _e(e)&&e.tagName.toLowerCase()==="form"}function rr(e){return _e(e)&&e.tagName.toLowerCase()==="input"}function ar(e){return!!(e.metaKey||e.altKey||e.ctrlKey||e.shiftKey)}function or(e,t){return e.button===0&&(!t||t==="_self")&&!ar(e)}var ke=null;function sr(){if(ke===null)try{new FormData(document.createElement("form"),0),ke=!1}catch{ke=!0}return ke}var ir=new Set(["application/x-www-form-urlencoded","multipart/form-data","text/plain"]);function Ve(e){return e!=null&&!ir.has(e)?(K(!1,`"${e}" is not a valid \`encType\` for \`
\`/\`\` and will default to "${Me}"`),null):e}function lr(e,t){let n,r,a,o,s;if(nr(e)){let u=e.getAttribute("action");r=u?Z(u,t):null,n=e.getAttribute("method")||Pe,a=Ve(e.getAttribute("enctype"))||Me,o=new FormData(e)}else if(tr(e)||rr(e)&&(e.type==="submit"||e.type==="image")){let u=e.form;if(u==null)throw new Error('Cannot submit a + + + + + + + + + )} + + {/* ── Robot identity ── */}

🤖 机器人身份

diff --git a/static_src/jbot/services/api.js b/static_src/jbot/services/api.js index ba14e1d..9c1b2da 100644 --- a/static_src/jbot/services/api.js +++ b/static_src/jbot/services/api.js @@ -64,3 +64,29 @@ export async function apiExtractMemory(userText, botText) { return []; } } + +// Read JBOT API credentials/settings from server (tokens are masked as '***') +export async function apiGetApiConfig() { + try { + const r = await fetch(`${BASE}/api-config/`); + if (!r.ok) return {}; + return r.json(); + } catch { + return {}; + } +} + +// Save JBOT API credentials/settings to server DB +// Pass '***' for secret fields to leave them unchanged +export async function apiSaveApiConfig(config) { + const r = await fetch(`${BASE}/api-config/`, { + method: 'POST', + headers: { 'Content-Type': 'application/json' }, + body: JSON.stringify(config), + }); + if (!r.ok) { + const e = await r.json().catch(() => ({})); + throw new Error(e.error || `HTTP ${r.status}`); + } + return r.json(); +}