diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 00000000..c10f7c72 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,36 @@ +# Node modules +InfoGenie-frontend/node_modules +InfoGenie-frontend/build + +# Python cache +InfoGenie-backend/__pycache__ +InfoGenie-backend/**/__pycache__ +InfoGenie-backend/*.pyc +InfoGenie-backend/**/*.pyc + +# Git +.git +.gitignore + +# IDE +.vscode +.idea +*.swp +*.swo + +# Logs +*.log + +# OS +.DS_Store +Thumbs.db + +# Test files +InfoGenie-backend/test + +# Documentation +*.md + +# Backup files +*.backup +*.bak diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..ea2b41a4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,57 @@ +# InfoGenie 统一 Docker 镜像 +# 多阶段构建:前端构建 + 后端 + Nginx + +# 阶段1: 前端构建 +FROM node:18-alpine AS frontend-builder + +WORKDIR /frontend +COPY InfoGenie-frontend/package*.json ./ +RUN npm install --legacy-peer-deps +COPY InfoGenie-frontend/ ./ +RUN npm run build + +# 阶段2: 最终镜像 +FROM python:3.10-slim + +# 安装 Nginx 和必要的工具 +RUN apt-get update && apt-get install -y \ + nginx \ + supervisor \ + && rm -rf /var/lib/apt/lists/* + +# 设置工作目录 +WORKDIR /app + +# 复制后端代码 +COPY InfoGenie-backend/ ./backend/ + +# 安装 Python 依赖 +RUN pip install --no-cache-dir -r ./backend/requirements.txt gunicorn + +# 复制前端构建产物到 Nginx 目录 +COPY --from=frontend-builder /frontend/build /usr/share/nginx/html + +# 创建持久化数据目录 +RUN mkdir -p /app/data/logs + +# 复制 Nginx 配置 +COPY docker/nginx.conf /etc/nginx/nginx.conf +COPY docker/default.conf /etc/nginx/conf.d/default.conf + +# 复制 Supervisor 配置 +COPY docker/supervisord.conf /etc/supervisor/conf.d/supervisord.conf + +# 复制启动脚本 +COPY docker/entrypoint.sh /entrypoint.sh +RUN chmod +x /entrypoint.sh + +# 暴露端口 +EXPOSE 2323 + +# 设置环境变量 +ENV FLASK_APP=app.py +ENV FLASK_ENV=production +ENV PYTHONUNBUFFERED=1 + +# 使用 supervisor 管理多进程 +ENTRYPOINT ["/entrypoint.sh"] diff --git a/InfoGenie-backend/modules/__pycache__/aimodelapp.cpython-313.pyc b/InfoGenie-backend/modules/__pycache__/aimodelapp.cpython-313.pyc index fff27464..68c49b55 100755 Binary files a/InfoGenie-backend/modules/__pycache__/aimodelapp.cpython-313.pyc and b/InfoGenie-backend/modules/__pycache__/aimodelapp.cpython-313.pyc differ diff --git a/InfoGenie-backend/modules/__pycache__/auth.cpython-313.pyc b/InfoGenie-backend/modules/__pycache__/auth.cpython-313.pyc index d34a4a37..71487c3c 100755 Binary files a/InfoGenie-backend/modules/__pycache__/auth.cpython-313.pyc and b/InfoGenie-backend/modules/__pycache__/auth.cpython-313.pyc differ diff --git a/InfoGenie-backend/modules/__pycache__/email_service.cpython-313.pyc b/InfoGenie-backend/modules/__pycache__/email_service.cpython-313.pyc index e992185e..8c30c86a 100755 Binary files a/InfoGenie-backend/modules/__pycache__/email_service.cpython-313.pyc and b/InfoGenie-backend/modules/__pycache__/email_service.cpython-313.pyc differ diff --git a/InfoGenie-backend/modules/__pycache__/user_management.cpython-313.pyc b/InfoGenie-backend/modules/__pycache__/user_management.cpython-313.pyc index 1ad337d1..7d164dd7 100755 Binary files a/InfoGenie-backend/modules/__pycache__/user_management.cpython-313.pyc and b/InfoGenie-backend/modules/__pycache__/user_management.cpython-313.pyc differ diff --git a/InfoGenie-backend/modules/aimodelapp.py b/InfoGenie-backend/modules/aimodelapp.py index 5b52d554..7de7c36c 100755 --- a/InfoGenie-backend/modules/aimodelapp.py +++ b/InfoGenie-backend/modules/aimodelapp.py @@ -855,6 +855,56 @@ def linux_command_generator(): except Exception as e: return jsonify({'error': f'Linux命令生成失败: {str(e)}'}), 500 +#AI文章排版(Markdown格式化)接口 +@aimodelapp_bp.route('/markdown_formatting', methods=['POST']) +@verify_user_coins +def markdown_formatting(): + """AI文章排版(Markdown格式化)接口""" + try: + data = request.get_json() + article_text = data.get('article_text', '').strip() + emoji_style = data.get('emoji_style', 'balanced').strip() + markdown_option = data.get('markdown_option', 'standard').strip() + + if not article_text: + return jsonify({'error': '文章内容不能为空'}), 400 + + # 构建Markdown排版的提示词 + prompt = f"""你是一位专业的文档排版助手。请将用户提供的全文按“标准Markdown格式”进行排版,并在不改变任何原文内容的前提下进行结构化呈现。严格遵守以下规则: + +1) 保留所有原始内容,严禁改写、删减或添加新内容。 +2) 使用合理的Markdown结构(标题、分节、段落、列表、引用、表格如有必要、代码块仅当原文包含)。 +3) 智能添加适量Emoji以增强可读性({emoji_style}),在标题、关键句、列表项等处点缀;避免过度使用,保持专业。 +4) 保持语言与语气不变,只优化排版和表现形式。 +5) 输出“纯Markdown文本”,不要包含任何JSON、HTML、XML、解释文字、或代码块围栏标记(例如不要在最外层使用```)。 + +如果原文本较长,可在开头自动生成简洁的“目录”以便阅读。 + +原文如下: +{article_text} +""" + + messages = [{"role": "user", "content": prompt}] + + # 使用DeepSeek进行排版生成 + content, error = call_deepseek_api(messages) + + if error: + return jsonify({'error': error}), 500 + + # 返回AI生成的Markdown文本 + return jsonify({ + 'success': True, + 'formatted_markdown': content, + 'source_text': article_text, + 'emoji_style': emoji_style, + 'markdown_option': markdown_option, + 'timestamp': datetime.now().isoformat() + }) + + except Exception as e: + return jsonify({'error': f'文章排版失败: {str(e)}'}), 500 + #获取用户萌芽币余额 @aimodelapp_bp.route('/coins', methods=['GET']) def get_user_coins(): @@ -951,4 +1001,87 @@ def get_available_models(): }) except Exception as e: - return jsonify({'error': f'获取模型列表失败: {str(e)}'}), 500 \ No newline at end of file + return jsonify({'error': f'获取模型列表失败: {str(e)}'}), 500 + +#中国亲戚称呼计算器接口(普通话版 + 方言) +@aimodelapp_bp.route('/kinship-calculator', methods=['POST']) +@verify_user_coins +def kinship_calculator(): + """中国亲戚称呼计算器接口""" + try: + data = request.get_json() or {} + relation_chain = (data.get('relation_chain') or '').strip() + dialects = data.get('dialects') # 可选,指定方言列表 + + if not relation_chain: + return jsonify({'error': '亲属关系链不能为空'}), 400 + + # 组装提示词:要求严格JSON输出 + requested_dialects = dialects if isinstance(dialects, list) and dialects else [ + '粤语', '闽南语', '上海话', '四川话', '东北话', '客家话' + ] + + prompt = f"""你是一位中国亲属称呼专家。请解析下面的亲属关系链,给出最终的亲属称呼。 +输入的关系链会用“的”连接,如“妈妈的爸爸”“爸爸的姐姐的儿子”。 + +请遵循: +1) 以中国大陆通行的标准普通话称呼为准,给出最常用、规范的最终称呼。 +2) 同时给出若干方言的对应称呼:{', '.join(requested_dialects)}。 +3) 如存在地区差异或性别歧义,请在notes中说明,但最终给出一个最常用称呼。 +4) 不要展示推理过程;只输出JSON。 + +严格按以下JSON结构输出: +{{ + "mandarin_title": "标准普通话称呼", + "dialect_titles": {{ + "粤语": {{"title": "称呼", "romanization": "粤拼或发音", "notes": "可选说明"}}, + "闽南语": {{"title": "称呼", "romanization": "白话字或发音", "notes": "可选说明"}}, + "上海话": {{"title": "称呼", "romanization": "拟音或IPA", "notes": "可选说明"}}, + "四川话": {{"title": "称呼", "romanization": "拟音或IPA", "notes": "可选说明"}}, + "东北话": {{"title": "称呼", "romanization": "拟音或IPA", "notes": "可选说明"}}, + "客家话": {{"title": "称呼", "romanization": "客家话拟音", "notes": "可选说明"}} + }}, + "notes": "总体说明(如地区差异、辈分方向、父系/母系等提示)" +}} + +关系链: +{relation_chain} +""" + + messages = [{"role": "user", "content": prompt}] + content, error = call_deepseek_api(messages) + + if error: + return jsonify({'error': error}), 500 + + # 解析AI返回的JSON + try: + result = json.loads(content) + except json.JSONDecodeError: + import re + m = re.search(r'\{[\s\S]*\}', content) + if not m: + return jsonify({'error': 'AI返回的数据中未找到有效JSON'}), 500 + try: + result = json.loads(m.group()) + except Exception: + return jsonify({'error': 'AI返回的JSON格式无法解析'}), 500 + + mandarin_title = result.get('mandarin_title') + dialect_titles = result.get('dialect_titles', {}) + notes = result.get('notes', '') + + if not mandarin_title: + return jsonify({'error': '未获得标准普通话称呼'}), 500 + + return jsonify({ + 'success': True, + 'relation_chain': relation_chain, + 'mandarin_title': mandarin_title, + 'dialect_titles': dialect_titles, + 'notes': notes, + 'timestamp': datetime.now().isoformat() + }) + + except Exception as e: + return jsonify({'error': f'亲戚称呼计算失败: {str(e)}'}), 500 \ No newline at end of file diff --git a/InfoGenie-backend/modules/auth.py b/InfoGenie-backend/modules/auth.py index 2e074970..a62f99c7 100755 --- a/InfoGenie-backend/modules/auth.py +++ b/InfoGenie-backend/modules/auth.py @@ -70,6 +70,8 @@ def validate_password(password): """验证密码格式(6-20位)""" return 6 <= len(password) <= 20 + +#==========================对外暴露的HTTP接口========================== #发送验证码邮件 @auth_bp.route('/send-verification', methods=['POST']) def send_verification(): @@ -450,3 +452,4 @@ def check_login(): 'success': False, 'message': f'服务器错误: {str(e)}' }), 500 +#==========================对外暴露的HTTP接口========================== \ No newline at end of file diff --git a/InfoGenie-backend/modules/user_management.py b/InfoGenie-backend/modules/user_management.py index 4d4af285..db252c48 100755 --- a/InfoGenie-backend/modules/user_management.py +++ b/InfoGenie-backend/modules/user_management.py @@ -51,6 +51,8 @@ def login_required(f): return decorated_function return decorated_function + +#==========================对外暴露的HTTP接口========================== # 获取用户资料 @user_bp.route('/profile', methods=['GET']) @login_required @@ -102,6 +104,127 @@ def get_profile(): 'message': f'服务器错误: {str(e)}' }), 500 +# 为指定账号增加萌芽币 +@user_bp.route('/add-coins', methods=['POST']) +@login_required +def add_coins(): + """为指定账号增加萌芽币(支持email或username指定账号,amount为正整数)""" + try: + data = request.get_json() or {} + email = (data.get('email') or '').strip() + username = (data.get('username') or '').strip() + amount = data.get('amount') + + # 参数校验 + if not email and not username: + return jsonify({ + 'success': False, + 'message': '请提供email或username其中之一' + }), 400 + + if amount is None: + return jsonify({ + 'success': False, + 'message': 'amount不能为空' + }), 400 + + try: + amount_int = int(amount) + except Exception: + return jsonify({ + 'success': False, + 'message': 'amount必须为整数' + }), 400 + + if amount_int <= 0: + return jsonify({ + 'success': False, + 'message': 'amount必须为正整数' + }), 400 + + users_collection = current_app.mongo.db.userdata + query = {'邮箱': email} if email else {'用户名': username} + user = users_collection.find_one(query) + if not user: + return jsonify({ + 'success': False, + 'message': '用户不存在' + }), 404 + + before_coins = user.get('萌芽币', 0) + update_result = users_collection.update_one(query, {'$inc': {'萌芽币': amount_int}}) + + if update_result.modified_count == 0: + return jsonify({ + 'success': False, + 'message': '更新失败,请稍后重试' + }), 500 + + updated = users_collection.find_one({'_id': user['_id']}) + new_coins = updated.get('萌芽币', before_coins) + + return jsonify({ + 'success': True, + 'message': f"已为账户{email or username}增加{amount_int}萌芽币", + 'data': { + 'before_coins': before_coins, + 'added': amount_int, + 'new_coins': new_coins, + 'user': { + 'id': str(updated.get('_id')), + 'email': updated.get('邮箱'), + 'username': updated.get('用户名'), + 'avatar': updated.get('头像'), + 'register_time': updated.get('注册时间'), + 'last_login': updated.get('最后登录'), + 'login_count': updated.get('登录次数', 0), + 'status': updated.get('用户状态', 'active'), + 'level': updated.get('等级', 0), + 'experience': updated.get('经验', 0), + 'coins': new_coins + } + } + }), 200 + except Exception as e: + return jsonify({ + 'success': False, + 'message': f'服务器错误: {str(e)}' + }), 500 + +# 列出所有用户 +@user_bp.route('/list', methods=['GET']) +@login_required +def list_users(): + """列出所有用户(不返回密码)""" + try: + users_collection = current_app.mongo.db.userdata + cursor = users_collection.find({}, {'密码': 0}) + users = [] + for u in cursor: + users.append({ + 'id': str(u.get('_id')), + 'email': u.get('邮箱'), + 'username': u.get('用户名'), + 'avatar': u.get('头像'), + 'register_time': u.get('注册时间'), + 'last_login': u.get('最后登录'), + 'login_count': u.get('登录次数', 0), + 'status': u.get('用户状态', 'active'), + 'level': u.get('等级', 0), + 'experience': u.get('经验', 0), + 'coins': u.get('萌芽币', 0) + }) + return jsonify({ + 'success': True, + 'count': len(users), + 'data': users + }), 200 + except Exception as e: + return jsonify({ + 'success': False, + 'message': f'服务器错误: {str(e)}' + }), 500 + # 修改密码 @user_bp.route('/change-password', methods=['POST']) @login_required @@ -424,3 +547,4 @@ def delete_account(): 'success': False, 'message': f'服务器错误: {str(e)}' }), 500 +#==========================对外暴露的HTTP接口========================== \ No newline at end of file diff --git a/InfoGenie-backend/test/test_add_coins.py b/InfoGenie-backend/test/test_add_coins.py new file mode 100644 index 00000000..aa3c51e6 --- /dev/null +++ b/InfoGenie-backend/test/test_add_coins.py @@ -0,0 +1,100 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +测试为指定账号增加萌芽币接口 (/api/user/add-coins) +""" + +import os +import sys +import json +from datetime import datetime + +# 加入后端根目录到路径,导入create_app +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from app import create_app +from modules.auth import generate_token +from werkzeug.security import generate_password_hash + + +def run_test(): + """运行加币接口测试,打印真实响应并断言结果""" + app = create_app() + + with app.app_context(): + db = app.mongo.db + users = db.userdata + + # 构造一个临时测试用户(真实写库,测试结束删除) + test_email = "infogenie.test.addcoins@foxmail.com" + users.delete_many({'邮箱': test_email}) + test_user = { + '邮箱': test_email, + '用户名': '测试用户_加币', + '密码': generate_password_hash('AddCoins123!'), + '头像': None, + '注册时间': datetime.now().isoformat(), + '最后登录': None, + '登录次数': 0, + '用户状态': 'active', + '等级': 0, + '经验': 0, + '萌芽币': 0, + '签到系统': { + '连续签到天数': 0, + '今日是否已签到': False, + '签到时间': datetime.now().strftime('%Y-%m-%d') + } + } + insert_result = users.insert_one(test_user) + test_user_id = str(insert_result.inserted_id) + + # 生成有效JWT用于认证 + token = generate_token({ + 'user_id': test_user_id, + 'email': test_email, + 'username': test_user['用户名'] + }) + + client = app.test_client() + + # 第一次加币: +500 + resp1 = client.post( + '/api/user/add-coins', + headers={'Authorization': f'Bearer {token}'}, + json={'email': test_email, 'amount': 500} + ) + print('第一次加币 状态码:', resp1.status_code) + data1 = resp1.get_json() + print('第一次加币 响应:') + print(json.dumps(data1, ensure_ascii=False, indent=2)) + assert resp1.status_code == 200 + assert data1.get('success') is True + assert data1['data']['before_coins'] == 0 + assert data1['data']['added'] == 500 + assert data1['data']['new_coins'] == 500 + + # 第二次加币: +200 + resp2 = client.post( + '/api/user/add-coins', + headers={'Authorization': f'Bearer {token}'}, + json={'email': test_email, 'amount': 200} + ) + print('第二次加币 状态码:', resp2.status_code) + data2 = resp2.get_json() + print('第二次加币 响应:') + print(json.dumps(data2, ensure_ascii=False, indent=2)) + assert resp2.status_code == 200 + assert data2.get('success') is True + assert data2['data']['before_coins'] == 500 + assert data2['data']['added'] == 200 + assert data2['data']['new_coins'] == 700 + + # 清理临时测试用户 + users.delete_many({'邮箱': test_email}) + + +if __name__ == '__main__': + print('🔧 开始测试 /api/user/add-coins 接口...') + run_test() + print('✅ 测试完成!') \ No newline at end of file diff --git a/InfoGenie-backend/test/test_user_list.py b/InfoGenie-backend/test/test_user_list.py new file mode 100644 index 00000000..26df9d80 --- /dev/null +++ b/InfoGenie-backend/test/test_user_list.py @@ -0,0 +1,81 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +""" +测试列出所有用户的HTTP接口 (/api/user/list) +""" + +import os +import sys +import json +from datetime import datetime + +# 将后端根目录加入路径,便于导入app +sys.path.append(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + +from app import create_app +from modules.auth import generate_token +from werkzeug.security import generate_password_hash + + +def run_test(): + """运行用户列表接口测试,输出真实数据""" + # 使用.env中的真实Mongo配置,不造假 + app = create_app() + + with app.app_context(): + db = app.mongo.db + users = db.userdata + + # 插入一个测试用户(真实写入后再删除),确保可验证接口输出 + test_email = "infogenie.test.user@foxmail.com" + users.delete_many({'邮箱': test_email}) + test_user = { + '邮箱': test_email, + '用户名': '测试用户_列表', + '密码': generate_password_hash('TestPass123!'), + '头像': None, + '注册时间': datetime.now().isoformat(), + '最后登录': None, + '登录次数': 0, + '用户状态': 'active', + '等级': 0, + '经验': 0, + '萌芽币': 0, + '签到系统': { + '连续签到天数': 0, + '今日是否已签到': False, + '签到时间': datetime.now().strftime('%Y-%m-%d') + } + } + insert_result = users.insert_one(test_user) + test_user_id = str(insert_result.inserted_id) + + # 生成有效JWT,满足认证要求 + token = generate_token({ + 'user_id': test_user_id, + 'email': test_email, + 'username': test_user['用户名'] + }) + + client = app.test_client() + resp = client.get('/api/user/list', headers={'Authorization': f'Bearer {token}'}) + + print("状态码:", resp.status_code) + data = resp.get_json() + print("响应内容:") + print(json.dumps(data, ensure_ascii=False, indent=2)) + + # 基本断言,确保返回真实列表数据且包含刚插入的测试用户 + assert resp.status_code == 200 + assert data.get('success') is True + assert isinstance(data.get('data'), list) + assert any(u.get('email') == test_email for u in data['data']) + + # 清理测试数据 + users.delete_many({'邮箱': test_email}) + + +if __name__ == '__main__': + print('🔎 开始测试 /api/user/list 接口...') + run_test() + print('✅ 测试完成!') \ No newline at end of file diff --git a/InfoGenie-frontend/.env.development b/InfoGenie-frontend/.env.development new file mode 100644 index 00000000..bf4bf9b4 --- /dev/null +++ b/InfoGenie-frontend/.env.development @@ -0,0 +1,11 @@ +# React 开发环境变量 + +# API URL - 开发环境使用本地后端 +REACT_APP_API_URL=http://127.0.0.1:5002 + +# 应用信息 +REACT_APP_NAME=InfoGenie +REACT_APP_VERSION=1.0.0 + +# 调试模式 +REACT_APP_DEBUG=true diff --git a/InfoGenie-frontend/.env.production b/InfoGenie-frontend/.env.production new file mode 100644 index 00000000..41a7dfa9 --- /dev/null +++ b/InfoGenie-frontend/.env.production @@ -0,0 +1,13 @@ +# React 构建时环境变量 +# 用于 Docker 构建 + +# API URL - 在 Docker 环境下,前端和后端在同一个容器 +# 使用相对路径,这样前端会自动使用当前域名 +REACT_APP_API_URL= + +# 应用信息 +REACT_APP_NAME=InfoGenie +REACT_APP_VERSION=1.0.0 + +# 调试模式(生产环境关闭) +REACT_APP_DEBUG=false diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机一言/css/background.css b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机一言/css/background.css index 3a10cfda..7bdb6f75 100755 --- a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机一言/css/background.css +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机一言/css/background.css @@ -4,11 +4,11 @@ body { background: linear-gradient( 135deg, - #fff8dc 0%, - #ffeaa7 25%, - #fdcb6e 50%, - #e17055 75%, - #d63031 100% + #f1f8e9 0%, + #dcedc8 25%, + #c8e6c8 50%, + #a5d6a7 75%, + #81c784 100% ); background-size: 400% 400%; animation: gradientShift 15s ease infinite; @@ -24,9 +24,9 @@ body::before { width: 100%; height: 100%; background: - radial-gradient(circle at 20% 80%, rgba(255, 215, 0, 0.1) 0%, transparent 50%), - radial-gradient(circle at 80% 20%, rgba(255, 223, 0, 0.1) 0%, transparent 50%), - radial-gradient(circle at 40% 40%, rgba(212, 175, 55, 0.05) 0%, transparent 50%); + radial-gradient(circle at 20% 80%, rgba(129, 199, 132, 0.1) 0%, transparent 50%), + radial-gradient(circle at 80% 20%, rgba(165, 214, 167, 0.1) 0%, transparent 50%), + radial-gradient(circle at 40% 40%, rgba(102, 187, 106, 0.05) 0%, transparent 50%); pointer-events: none; z-index: 1; } @@ -40,11 +40,11 @@ body::after { width: 100%; height: 100%; background-image: - radial-gradient(2px 2px at 20px 30px, rgba(255, 215, 0, 0.3), transparent), - radial-gradient(2px 2px at 40px 70px, rgba(255, 223, 0, 0.2), transparent), - radial-gradient(1px 1px at 90px 40px, rgba(212, 175, 55, 0.4), transparent), - radial-gradient(1px 1px at 130px 80px, rgba(255, 215, 0, 0.2), transparent), - radial-gradient(2px 2px at 160px 30px, rgba(255, 223, 0, 0.3), transparent); + radial-gradient(2px 2px at 20px 30px, rgba(129, 199, 132, 0.3), transparent), + radial-gradient(2px 2px at 40px 70px, rgba(165, 214, 167, 0.2), transparent), + radial-gradient(1px 1px at 90px 40px, rgba(102, 187, 106, 0.4), transparent), + radial-gradient(1px 1px at 130px 80px, rgba(129, 199, 132, 0.2), transparent), + radial-gradient(2px 2px at 160px 30px, rgba(165, 214, 167, 0.3), transparent); background-repeat: repeat; background-size: 200px 100px; animation: sparkle 20s linear infinite; @@ -106,8 +106,8 @@ body::after { body::before { background: - radial-gradient(circle at 30% 70%, rgba(255, 215, 0, 0.08) 0%, transparent 40%), - radial-gradient(circle at 70% 30%, rgba(255, 223, 0, 0.08) 0%, transparent 40%); + radial-gradient(circle at 30% 70%, rgba(129, 199, 132, 0.08) 0%, transparent 40%), + radial-gradient(circle at 70% 30%, rgba(165, 214, 167, 0.08) 0%, transparent 40%); } body::after { @@ -121,9 +121,9 @@ body::after { body { background: linear-gradient( 135deg, - #fff8dc 0%, - #ffeaa7 50%, - #fdcb6e 100% + #f1f8e9 0%, + #dcedc8 50%, + #c8e6c8 100% ); background-size: 150% 150%; } @@ -138,18 +138,18 @@ body::after { body { background: linear-gradient( 135deg, - #2c1810 0%, - #3d2914 25%, - #4a3319 50%, - #5c3e1f 75%, - #6b4423 100% + #1b2e1b 0%, + #2e4a2e 25%, + #3e5e3e 50%, + #4e6e4e 75%, + #5e7e5e 100% ); } body::before { background: - radial-gradient(circle at 20% 80%, rgba(255, 215, 0, 0.05) 0%, transparent 50%), - radial-gradient(circle at 80% 20%, rgba(255, 223, 0, 0.05) 0%, transparent 50%); + radial-gradient(circle at 20% 80%, rgba(129, 199, 132, 0.05) 0%, transparent 50%), + radial-gradient(circle at 80% 20%, rgba(165, 214, 167, 0.05) 0%, transparent 50%); } } @@ -162,6 +162,6 @@ body::after { } body { - background: linear-gradient(135deg, #fff8dc 0%, #ffeaa7 50%, #fdcb6e 100%); + background: linear-gradient(135deg, #f1f8e9 0%, #dcedc8 50%, #c8e6c8 100%); } } \ No newline at end of file diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机一言/css/style.css b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机一言/css/style.css index b84b1125..618808d2 100755 --- a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机一言/css/style.css +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机一言/css/style.css @@ -8,7 +8,7 @@ body { font-family: 'Microsoft YaHei', 'PingFang SC', 'Helvetica Neue', Arial, sans-serif; line-height: 1.6; - color: #2c1810; + color: #2e7d32; overflow-x: hidden; } @@ -33,20 +33,20 @@ body { .title { font-size: 3rem; font-weight: 700; - color: #d4af37; + color: #2e7d32; text-shadow: - 0 0 10px rgba(212, 175, 55, 0.8), - 0 0 20px rgba(212, 175, 55, 0.6), - 0 0 30px rgba(212, 175, 55, 0.4); + 0 0 10px rgba(129, 199, 132, 0.8), + 0 0 20px rgba(129, 199, 132, 0.6), + 0 0 30px rgba(129, 199, 132, 0.4); margin-bottom: 10px; animation: titleGlow 3s ease-in-out infinite alternate; } .subtitle { font-size: 1.2rem; - color: #b8860b; + color: #388e3c; opacity: 0.9; - text-shadow: 0 0 5px rgba(184, 134, 11, 0.5); + text-shadow: 0 0 5px rgba(102, 187, 106, 0.5); } /* 主内容区域 */ @@ -58,14 +58,14 @@ body { /* 一言容器 */ .quote-container { - background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 223, 0, 0.05)); - border: 2px solid rgba(212, 175, 55, 0.3); + background: linear-gradient(135deg, rgba(129, 199, 132, 0.1), rgba(165, 214, 167, 0.05)); + border: 2px solid rgba(102, 187, 106, 0.3); border-radius: 20px; padding: 40px; margin-bottom: 30px; backdrop-filter: blur(10px); box-shadow: - 0 8px 32px rgba(212, 175, 55, 0.2), + 0 8px 32px rgba(102, 187, 106, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1); position: relative; overflow: hidden; @@ -78,7 +78,7 @@ body { left: -2px; right: -2px; bottom: -2px; - background: linear-gradient(45deg, #ffd700, #ffed4e, #ffd700, #ffed4e); + background: linear-gradient(45deg, #81c784, #a5d6a7, #81c784, #a5d6a7); border-radius: 22px; z-index: -1; animation: borderGlow 4s linear infinite; @@ -88,7 +88,7 @@ body { .loading { display: none; text-align: center; - color: #d4af37; + color: #2e7d32; } .loading.show { @@ -98,8 +98,8 @@ body { .loading-spinner { width: 40px; height: 40px; - border: 4px solid rgba(212, 175, 55, 0.3); - border-top: 4px solid #d4af37; + border: 4px solid rgba(102, 187, 106, 0.3); + border-top: 4px solid #2e7d32; border-radius: 50%; margin: 0 auto 15px; animation: spin 1s linear infinite; @@ -118,15 +118,15 @@ body { .quote-text { font-size: 1.8rem; line-height: 1.8; - color: #2c1810; + color: #2e7d32; margin-bottom: 20px; - text-shadow: 0 1px 2px rgba(212, 175, 55, 0.1); + text-shadow: 0 1px 2px rgba(102, 187, 106, 0.1); font-weight: 500; } .quote-index { font-size: 0.9rem; - color: #b8860b; + color: #388e3c; opacity: 0.8; } @@ -134,7 +134,7 @@ body { .error-message { display: none; text-align: center; - color: #cd853f; + color: #66bb6a; } .error-message.show { @@ -157,20 +157,20 @@ body { } .refresh-btn { - background: linear-gradient(135deg, #ffd700, #ffed4e); + background: linear-gradient(135deg, #81c784, #a5d6a7); border: none; border-radius: 50px; padding: 15px 30px; font-size: 1.1rem; font-weight: 600; - color: #2c1810; + color: #2e7d32; cursor: pointer; display: inline-flex; align-items: center; gap: 10px; transition: all 0.3s ease; box-shadow: - 0 4px 15px rgba(212, 175, 55, 0.3), + 0 4px 15px rgba(102, 187, 106, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.3); position: relative; overflow: hidden; @@ -179,7 +179,7 @@ body { .refresh-btn:hover { transform: translateY(-2px); box-shadow: - 0 6px 20px rgba(212, 175, 55, 0.4), + 0 6px 20px rgba(102, 187, 106, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.3); } @@ -206,7 +206,7 @@ body { .footer { margin-top: 40px; text-align: center; - color: #b8860b; + color: #388e3c; opacity: 0.8; font-size: 0.9rem; } @@ -215,15 +215,15 @@ body { @keyframes titleGlow { 0% { text-shadow: - 0 0 10px rgba(212, 175, 55, 0.8), - 0 0 20px rgba(212, 175, 55, 0.6), - 0 0 30px rgba(212, 175, 55, 0.4); + 0 0 10px rgba(129, 199, 132, 0.8), + 0 0 20px rgba(129, 199, 132, 0.6), + 0 0 30px rgba(129, 199, 132, 0.4); } 100% { text-shadow: - 0 0 15px rgba(212, 175, 55, 1), - 0 0 25px rgba(212, 175, 55, 0.8), - 0 0 35px rgba(212, 175, 55, 0.6); + 0 0 15px rgba(129, 199, 132, 1), + 0 0 25px rgba(129, 199, 132, 0.8), + 0 0 35px rgba(129, 199, 132, 0.6); } } diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/css/background.css b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/css/background.css index 7f1aa01c..38d40031 100755 --- a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/css/background.css +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/css/background.css @@ -6,9 +6,9 @@ body { transition: background 0.5s ease; } -/* Hand-drawn Comic Theme Background - NEW VIBRANT VERSION */ +/* Hand-drawn Comic Theme Background - FRESH GREEN VERSION */ body.theme-comic { - background: linear-gradient(-45deg, #ff7e5f, #feb47b, #ffcc80, #ffecb3); + background: linear-gradient(-45deg, #c8e6c9, #dcedc8, #f1f8e9, #e8f5e8); background-size: 400% 400%; animation: gradientBG 15s ease infinite; } diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/css/style.css b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/css/style.css index 5dccdee4..d8e4fa1e 100755 --- a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/css/style.css +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/css/style.css @@ -33,7 +33,7 @@ border: 2px solid transparent; } .theme-icon.active { - border-color: #ff7043; + border-color: #66bb6a; transform: scale(1.1); } @@ -41,26 +41,26 @@ .theme-comic header h1 { font-family: 'Zhi Mang Xing', cursive; font-size: 4em; - color: #d84315; /* Deep Orange */ + color: #2e7d32; /* Fresh Green */ text-shadow: 2px 2px 0 #fff; margin: 0.2em 0; } .theme-comic .divider { height: 3px; - background: linear-gradient(90deg, #ffca28, #ff7043, #29b6f6, #66bb6a); + background: linear-gradient(90deg, #81c784, #a5d6a7, #c8e6c9, #66bb6a); border-radius: 3px; margin: 20px auto; width: 80%; } .theme-comic .joke-card { - background: rgba(255, 255, 255, 0.85); /* White with transparency */ + background: rgba(248, 255, 248, 0.9); /* Light green tinted white */ backdrop-filter: blur(5px); border-radius: 15px; padding: 40px; min-height: 200px; - box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); + box-shadow: 0 8px 25px rgba(102, 187, 106, 0.15); display: flex; justify-content: center; align-items: center; @@ -68,6 +68,7 @@ margin-bottom: 20px; transform: rotate(-1deg); transition: transform 0.2s ease; + border: 1px solid rgba(129, 199, 132, 0.3); } .theme-comic .joke-card:hover { transform: rotate(1deg) scale(1.02); @@ -77,11 +78,11 @@ font-family: 'Zhi Mang Xing', cursive; font-size: 2em; line-height: 1.6; - color: #5d4037; + color: #1b5e20; } .theme-comic .new-joke-btn { - background: #1e88e5; /* Vibrant Blue */ + background: linear-gradient(135deg, #66bb6a, #81c784); /* Fresh Green Gradient */ color: white; font-family: 'Zhi Mang Xing', cursive; font-size: 2.5em; @@ -89,7 +90,7 @@ border-radius: 50px; padding: 10px 30px; cursor: pointer; - box-shadow: 0 5px 0 #1565c0; /* Darker Blue */ + box-shadow: 0 5px 0 #388e3c; /* Darker Green */ transition: all 0.1s ease-in-out; } .theme-comic .new-joke-btn:active { @@ -120,8 +121,8 @@ margin-top: -27.5px; } .book-page { - background: #ffca28; - border: 1px solid #ff7043; + background: #a5d6a7; + border: 1px solid #66bb6a; border-radius: 3px; transform-origin: left; } diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/index.html b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/index.html index e443b252..833f79da 100755 --- a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/index.html +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机搞笑段子/index.html @@ -11,8 +11,6 @@
✏️
-
😂
-
📺
diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/css/style.css b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/css/style.css new file mode 100644 index 00000000..c218a495 --- /dev/null +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/css/style.css @@ -0,0 +1,163 @@ +/* 随机答案之书 - 淡绿色清新风格样式(与随机唱歌音频一致) */ + +/* 重置样式 */ +* { + margin: 0; + padding: 0; + box-sizing: border-box; +} + +body { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background: linear-gradient(135deg, #a8e6cf 0%, #dcedc1 50%, #ffd3a5 100%); + min-height: 100vh; + color: #2d5016; + line-height: 1.6; + overflow-x: hidden; +} + +.container { + max-width: 900px; + margin: 0 auto; + padding: 20px; +} + +/* 头部 */ +.header { + text-align: center; + margin-bottom: 20px; + background: rgba(255, 255, 255, 0.85); + border-radius: 20px; + padding: 24px; + box-shadow: 0 8px 25px rgba(45, 80, 22, 0.08); + backdrop-filter: blur(10px); +} + +.header h1 { + font-size: 2rem; + color: #2d5016; + margin-bottom: 10px; + font-weight: 700; + display: flex; + align-items: center; + justify-content: center; + gap: 12px; +} + +.header p { + color: #5a7c65; + font-size: 1rem; +} + +/* 按钮 */ +.btn { + background: linear-gradient(135deg, #81c784 0%, #66bb6a 100%); + color: white; + border: none; + padding: 10px 18px; + border-radius: 10px; + font-size: 0.95rem; + font-weight: 600; + cursor: pointer; + transition: all 0.25s ease; + box-shadow: 0 4px 12px rgba(129, 199, 132, 0.35); + text-decoration: none; +} + +.btn:hover { + transform: translateY(-2px); + box-shadow: 0 6px 18px rgba(129, 199, 132, 0.45); +} + +/* 加载与错误 */ +.loading, .error { + text-align: center; + padding: 30px; + background: rgba(255, 255, 255, 0.85); + border-radius: 15px; + box-shadow: 0 5px 20px rgba(45, 80, 22, 0.08); +} + +.spinner { + width: 36px; + height: 36px; + border: 4px solid #e8f5e8; + border-top: 4px solid #81c784; + border-radius: 50%; + animation: spin 1s linear infinite; + margin: 0 auto 18px; +} + +@keyframes spin { + 0% { transform: rotate(0deg); } + 100% { transform: rotate(360deg); } +} + +/* 动画 */ +.fade-in { + animation: fadeIn 0.5s ease-in-out; +} + +@keyframes fadeIn { + from { opacity: 0; transform: translateY(10px); } + to { opacity: 1; transform: translateY(0); } +} + +/* 答案卡片 */ +.answer-card { + background: rgba(255, 255, 255, 0.9); + padding: 16px; + border-radius: 15px; + box-shadow: 0 4px 18px rgba(45, 80, 22, 0.08); + margin-bottom: 15px; + text-align: center; +} + +.answer-text { + font-size: 1.4rem; + font-weight: 700; + margin-bottom: 8px; + color: #1b5e20; + word-break: break-word; +} + +.answer-en { + color: #5a7c65; + font-size: 1rem; + margin-bottom: 10px; +} + +.meta { + color: #5a7c65; + font-size: 0.95rem; +} + +.actions { + display: flex; + gap: 12px; + align-items: center; + justify-content: center; + margin-top: 12px; +} + +/* 手机端优先优化 */ +@media (max-width: 767px) { + .container { padding: 12px; } + .header { padding: 18px; } + .header h1 { font-size: 1.6rem; gap: 8px; } + + .answer-card { padding: 16px; } + .answer-text { font-size: 1.3rem; } + .answer-en { font-size: 0.95rem; } + + .actions { + flex-direction: column; + gap: 15px; + } + + .btn { + width: 100%; + max-width: 220px; + text-align: center; + } +} \ No newline at end of file diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/index.html b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/index.html new file mode 100644 index 00000000..aedfd38c --- /dev/null +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/index.html @@ -0,0 +1,45 @@ + + + + + + + 📘真理之道 + + + + + +
+
+

📘真理之道

+

当你踌躇不定,犹豫不决时,不妨来这里看看吧

+
+ + +
+
+

正在加载中,请稍候…

+
+ + + + +
+
+
-
+ +
编号:-
+
+ + +
+
+
+
+ + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/js/script.js b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/js/script.js new file mode 100644 index 00000000..3f27cd9f --- /dev/null +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/js/script.js @@ -0,0 +1,224 @@ +// 随机答案之书 页面脚本 +(function () { + 'use strict'; + + const API = { + endpoints: [], + currentIndex: 0, + params: { + encoding: 'json' + }, + localFallback: '返回接口.json', + // 初始化API接口列表 + async init() { + try { + const res = await fetch('./接口集合.json'); + const endpoints = await res.json(); + this.endpoints = endpoints.map(endpoint => `${endpoint}/v2/answer`); + } catch (e) { + // 如果无法加载接口集合,使用默认接口 + this.endpoints = ['https://60s.api.shumengya.top/v2/answer']; + } + }, + // 获取当前接口URL + getCurrentUrl() { + if (this.endpoints.length === 0) return null; + const url = new URL(this.endpoints[this.currentIndex]); + Object.entries(this.params).forEach(([k, v]) => url.searchParams.append(k, v)); + return url.toString(); + }, + // 切换到下一个接口 + switchToNext() { + this.currentIndex = (this.currentIndex + 1) % this.endpoints.length; + return this.currentIndex < this.endpoints.length; + }, + // 重置到第一个接口 + reset() { + this.currentIndex = 0; + } + }; + + // DOM 元素引用 + const els = { + loading: null, + error: null, + container: null, + answer: null, + answerEn: null, + indexEl: null, + refreshBtn: null, + copyBtn: null, + }; + + function initDom() { + els.loading = document.getElementById('loading'); + els.error = document.getElementById('error'); + els.container = document.getElementById('content'); + + els.answer = document.getElementById('answer'); + els.answerEn = document.getElementById('answer-en'); + els.indexEl = document.getElementById('index'); + els.refreshBtn = document.getElementById('refresh-btn'); + els.copyBtn = document.getElementById('copy-btn'); + } + + function showLoading() { + els.loading.style.display = 'block'; + els.error.style.display = 'none'; + els.container.style.display = 'none'; + } + + function showError(msg) { + els.loading.style.display = 'none'; + els.error.style.display = 'block'; + els.container.style.display = 'none'; + els.error.querySelector('p').textContent = msg || '获取数据失败,请稍后重试'; + } + + function showContent() { + els.loading.style.display = 'none'; + els.error.style.display = 'none'; + els.container.style.display = 'block'; + } + + function safeText(text) { + const div = document.createElement('div'); + div.textContent = text == null ? '' : String(text); + return div.innerHTML; + } + + async function fetchFromAPI() { + // 初始化API接口列表 + await API.init(); + + // 重置API索引到第一个接口 + API.reset(); + + // 尝试所有API接口 + for (let i = 0; i < API.endpoints.length; i++) { + try { + const url = API.getCurrentUrl(); + console.log(`尝试接口 ${i + 1}/${API.endpoints.length}: ${url}`); + + const resp = await fetch(url, { + cache: 'no-store', + timeout: 10000 // 10秒超时(兼容同目录页面风格) + }); + + if (!resp.ok) { + throw new Error(`HTTP ${resp.status}: ${resp.statusText}`); + } + + const data = await resp.json(); + + if (data && data.code === 200) { + console.log(`接口 ${i + 1} 请求成功`); + return data; + } + + throw new Error(data && data.message ? data.message : '接口返回异常'); + + } catch (e) { + console.warn(`接口 ${i + 1} 失败:`, e.message); + + // 如果不是最后一个接口,切换到下一个 + if (i < API.endpoints.length - 1) { + API.switchToNext(); + continue; + } + + // 所有接口都失败了 + console.warn('所有远程接口都失败,尝试本地数据'); + return null; + } + } + } + + async function fetchFromLocal() { + try { + const resp = await fetch(API.localFallback + `?t=${Date.now()}`); + if (!resp.ok) throw new Error(`本地文件HTTP ${resp.status}`); + const data = await resp.json(); + return data; + } catch (e) { + console.error('读取本地返回接口.json失败:', e); + return null; + } + } + + function render(data) { + const d = data?.data || {}; + + const cn = d.answer || ''; + const en = d.answer_en || ''; + const idx = d.index != null ? d.index : d.id != null ? d.id : '-'; + + els.answer.innerHTML = safeText(cn || '-'); + + if (en) { + els.answerEn.style.display = 'block'; + els.answerEn.innerHTML = safeText(en); + } else { + els.answerEn.style.display = 'none'; + els.answerEn.innerHTML = ''; + } + + els.indexEl.textContent = idx; + showContent(); + } + + async function load() { + showLoading(); + try { + // 先尝试远程API + const data = await fetchFromAPI(); + if (data) { + render(data); + return; + } + + // 远程API失败,尝试本地数据 + const localData = await fetchFromLocal(); + if (localData) { + render(localData); + return; + } + + // 都失败了 + showError('获取数据失败,请稍后重试'); + } catch (e) { + console.error('加载数据时发生错误:', e); + showError('获取数据失败,请稍后重试'); + } + } + + function bindEvents() { + if (els.refreshBtn) { + els.refreshBtn.addEventListener('click', load); + } + if (els.copyBtn) { + els.copyBtn.addEventListener('click', async () => { + const textParts = []; + const cn = els.answer?.textContent?.trim(); + const en = els.answerEn?.textContent?.trim(); + if (cn) textParts.push(cn); + if (en) textParts.push(en); + const finalText = textParts.join('\n'); + try { + await navigator.clipboard.writeText(finalText); + const old = els.copyBtn.textContent; + els.copyBtn.textContent = '已复制'; + setTimeout(() => { els.copyBtn.textContent = old; }, 1200); + } catch (e) { + alert('复制失败,请手动选择文本复制'); + } + }); + } + } + + document.addEventListener('DOMContentLoaded', () => { + initDom(); + bindEvents(); + load(); + }); +})(); \ No newline at end of file diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/接口集合.json b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/接口集合.json new file mode 100644 index 00000000..8ec2d2ec --- /dev/null +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/接口集合.json @@ -0,0 +1,3 @@ +[ + "https://60s.api.shumengya.top" +] \ No newline at end of file diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/返回接口.json b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/返回接口.json new file mode 100644 index 00000000..73cbc640 --- /dev/null +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机答案之书/返回接口.json @@ -0,0 +1,10 @@ +{ + "code": 200, + "message": "获取成功。数据来自官方/权威源头,以确保稳定与实时。开源地址 https://github.com/vikiboss/60s,反馈群 595941841", + "data": { + "id": "63", + "answer": "那不值得纠结", + "answer_en": "It's not worth worrying about", + "index": 62 + } +} \ No newline at end of file diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机运势/css/background.css b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机运势/css/background.css index d18a8699..92d35e3c 100755 --- a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机运势/css/background.css +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机运势/css/background.css @@ -1,8 +1,8 @@ body { - background: linear-gradient(-45deg, #0a021a, #2a0d3f, #4a1a6c, #7b2f8f); + background: linear-gradient(-45deg, #f1f8e9, #e8f5e8, #c8e6c9, #dcedc8); background-size: 400% 400%; animation: gradientBG 20s ease infinite; - color: #ffffff; + color: #2e7d32; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; margin: 0; padding: 0; diff --git a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机运势/css/style.css b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机运势/css/style.css index 7792be02..c3bec4c0 100755 --- a/InfoGenie-frontend/public/60sapi/娱乐消遣/随机运势/css/style.css +++ b/InfoGenie-frontend/public/60sapi/娱乐消遣/随机运势/css/style.css @@ -8,14 +8,14 @@ header h1 { font-size: 2.8em; - color: #f0e6ff; - text-shadow: 0 0 10px #d1a9ff, 0 0 20px #d1a9ff; + color: #2e7d32; + text-shadow: 0 0 10px #81c784, 0 0 20px #a5d6a7; margin-bottom: 0.2em; } header p { font-size: 1.2em; - color: #e0c8ff; + color: #388e3c; margin-bottom: 40px; } @@ -27,11 +27,11 @@ header p { .crystal-ball { width: 200px; height: 200px; - background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.6), rgba(200, 180, 255, 0.1)); + background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.6), rgba(200, 230, 201, 0.3)); border-radius: 50%; margin: 0 auto; position: relative; - box-shadow: 0 0 30px #c390ff, 0 0 60px #a060e0, inset 0 0 20px rgba(255, 220, 255, 0.3); + box-shadow: 0 0 30px #81c784, 0 0 60px #66bb6a, inset 0 0 20px rgba(220, 255, 220, 0.3); animation: float 6s ease-in-out infinite; transform-style: preserve-3d; } @@ -54,7 +54,7 @@ header p { left: 50%; width: 120%; height: 120%; - background: linear-gradient(45deg, rgba(255, 192, 203, 0.1), rgba(128, 0, 128, 0.2)); + background: linear-gradient(45deg, rgba(200, 230, 201, 0.2), rgba(129, 199, 132, 0.3)); border-radius: 50%; animation: swirl 10s linear infinite; transform: translate(-50%, -50%); @@ -71,7 +71,7 @@ header p { } .fortune-card { - background: rgba(255, 255, 255, 0.05); + background: rgba(248, 255, 248, 0.8); border-radius: 15px; padding: 30px; margin-bottom: 30px; @@ -80,8 +80,8 @@ header p { justify-content: center; align-items: center; backdrop-filter: blur(10px); - border: 1px solid rgba(255, 255, 255, 0.1); - box-shadow: 0 8px 32px 0 rgba(31, 38, 135, 0.37); + border: 1px solid rgba(129, 199, 132, 0.3); + box-shadow: 0 8px 32px 0 rgba(102, 187, 106, 0.2); transition: opacity 0.5s ease-in-out; } @@ -96,13 +96,13 @@ header p { #luck-desc { font-size: 2em; - color: #ffc0cb; + color: #2e7d32; margin: 0 0 10px; } #luck-tip { font-size: 1.1em; - color: #e0e0e0; + color: #388e3c; margin: 0; padding-bottom: 20px; /* Add some space before the new details */ } @@ -121,7 +121,7 @@ header p { .detail-item h3 { font-size: 0.9em; - color: #ffc0cb; + color: #66bb6a; margin: 0 0 5px; font-weight: normal; } @@ -151,8 +151,8 @@ header p { .tarot-container h2 { font-size: 1.5em; - color: #f0e6ff; - text-shadow: 0 0 8px #d1a9ff; + color: #2e7d32; + text-shadow: 0 0 8px #81c784; margin-bottom: 20px; } @@ -188,23 +188,23 @@ header p { } .tarot-card-back { - background: linear-gradient(135deg, #4a1a6c, #2a0d3f); - border: 2px solid #d1a9ff; + background: linear-gradient(135deg, #66bb6a, #388e3c); + border: 2px solid #81c784; display: flex; justify-content: center; align-items: center; font-size: 3em; - color: #d1a9ff; + color: #c8e6c9; } .tarot-card-back::after { content: '✧'; /* A simple star symbol */ - text-shadow: 0 0 10px #f0e6ff; + text-shadow: 0 0 10px #e8f5e8; } .tarot-card-front { - background: linear-gradient(135deg, #3e165b, #592883); - border: 2px solid #d1a9ff; + background: linear-gradient(135deg, #4caf50, #66bb6a); + border: 2px solid #81c784; color: white; transform: rotateY(180deg); padding: 20px; @@ -217,7 +217,7 @@ header p { #tarot-name { font-size: 1.4em; - color: #ffc0cb; + color: #e8f5e8; margin: 0 0 10px; } @@ -248,8 +248,8 @@ header p { .decor-symbol { position: absolute; - color: rgba(209, 169, 255, 0.5); - text-shadow: 0 0 10px rgba(240, 230, 255, 0.7); + color: rgba(129, 199, 132, 0.5); + text-shadow: 0 0 10px rgba(200, 230, 201, 0.7); animation: floatSymbol 20s infinite ease-in-out; } @@ -268,7 +268,7 @@ header p { } #get-fortune-btn { - background: linear-gradient(45deg, #da70d6, #8a2be2); + background: linear-gradient(45deg, #66bb6a, #4caf50); color: white; border: none; border-radius: 50px; @@ -276,12 +276,12 @@ header p { font-size: 1.1em; cursor: pointer; transition: transform 0.2s, box-shadow 0.2s; - box-shadow: 0 0 15px #c390ff; + box-shadow: 0 0 15px #81c784; } #get-fortune-btn:hover { transform: scale(1.05); - box-shadow: 0 0 25px #d1a9ff; + box-shadow: 0 0 25px #a5d6a7; } #get-fortune-btn:active { @@ -289,8 +289,8 @@ header p { } .loading-spinner { - border: 4px solid rgba(255, 255, 255, 0.2); - border-left-color: #ffc0cb; + border: 4px solid rgba(129, 199, 132, 0.3); + border-left-color: #66bb6a; border-radius: 50%; width: 40px; height: 40px; @@ -308,7 +308,7 @@ header p { footer { margin-top: 40px; - color: rgba(255, 255, 255, 0.6); + color: rgba(46, 125, 50, 0.7); } /* Responsive Design */ diff --git a/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/css/background.css b/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/css/background.css index 74f65ebc..0da5d4ac 100755 --- a/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/css/background.css +++ b/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/css/background.css @@ -6,7 +6,7 @@ body::before { left: 0; width: 100%; height: 100%; - background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + background: linear-gradient(135deg, #f0f8e8 0%, #e8f5e8 50%, #d4f4dd 100%); z-index: -2; } @@ -18,9 +18,9 @@ body::after { width: 100%; height: 100%; background: - radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.3) 0%, transparent 50%); + radial-gradient(circle at 20% 80%, rgba(144, 238, 144, 0.2) 0%, transparent 50%), + radial-gradient(circle at 80% 20%, rgba(173, 255, 173, 0.2) 0%, transparent 50%), + radial-gradient(circle at 40% 40%, rgba(152, 251, 152, 0.2) 0%, transparent 50%); z-index: -1; animation: backgroundMove 20s ease-in-out infinite; } @@ -28,27 +28,27 @@ body::after { @keyframes backgroundMove { 0%, 100% { background: - radial-gradient(circle at 20% 80%, rgba(120, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 80% 20%, rgba(255, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 40% 40%, rgba(120, 219, 255, 0.3) 0%, transparent 50%); + radial-gradient(circle at 20% 80%, rgba(144, 238, 144, 0.2) 0%, transparent 50%), + radial-gradient(circle at 80% 20%, rgba(173, 255, 173, 0.2) 0%, transparent 50%), + radial-gradient(circle at 40% 40%, rgba(152, 251, 152, 0.2) 0%, transparent 50%); } 25% { background: - radial-gradient(circle at 60% 30%, rgba(120, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 30% 70%, rgba(255, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 80% 80%, rgba(120, 219, 255, 0.3) 0%, transparent 50%); + radial-gradient(circle at 60% 30%, rgba(144, 238, 144, 0.2) 0%, transparent 50%), + radial-gradient(circle at 30% 70%, rgba(173, 255, 173, 0.2) 0%, transparent 50%), + radial-gradient(circle at 80% 80%, rgba(152, 251, 152, 0.2) 0%, transparent 50%); } 50% { background: - radial-gradient(circle at 80% 60%, rgba(120, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 20% 30%, rgba(255, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 60% 70%, rgba(120, 219, 255, 0.3) 0%, transparent 50%); + radial-gradient(circle at 80% 60%, rgba(144, 238, 144, 0.2) 0%, transparent 50%), + radial-gradient(circle at 20% 30%, rgba(173, 255, 173, 0.2) 0%, transparent 50%), + radial-gradient(circle at 60% 70%, rgba(152, 251, 152, 0.2) 0%, transparent 50%); } 75% { background: - radial-gradient(circle at 40% 90%, rgba(120, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 70% 10%, rgba(255, 119, 198, 0.3) 0%, transparent 50%), - radial-gradient(circle at 20% 60%, rgba(120, 219, 255, 0.3) 0%, transparent 50%); + radial-gradient(circle at 40% 90%, rgba(144, 238, 144, 0.2) 0%, transparent 50%), + radial-gradient(circle at 70% 10%, rgba(173, 255, 173, 0.2) 0%, transparent 50%), + radial-gradient(circle at 20% 60%, rgba(152, 251, 152, 0.2) 0%, transparent 50%); } } diff --git a/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/css/style.css b/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/css/style.css index 30d4768f..4ef98078 100755 --- a/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/css/style.css +++ b/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/css/style.css @@ -11,6 +11,22 @@ body { color: #333; min-height: 100vh; overflow-x: hidden; + /* 隐藏滚动条但保留滚动功能 */ + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE and Edge */ +} + +/* 隐藏 Webkit 浏览器的滚动条 */ +body::-webkit-scrollbar, +html::-webkit-scrollbar, +*::-webkit-scrollbar { + display: none; +} + +/* 全局隐藏滚动条但保留滚动功能 */ +html { + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE and Edge */ } /* 容器样式 */ @@ -26,7 +42,7 @@ body { .header { text-align: center; padding: 3rem 2rem 2rem; - background: linear-gradient(135deg, rgba(74, 144, 226, 0.1), rgba(80, 200, 120, 0.1)); + background: linear-gradient(135deg, rgba(144, 238, 144, 0.15), rgba(152, 251, 152, 0.15)); backdrop-filter: blur(10px); border-bottom: 1px solid rgba(255, 255, 255, 0.2); } @@ -34,7 +50,7 @@ body { .header h1 { font-size: 2.5rem; font-weight: 700; - background: linear-gradient(135deg, #4a90e2, #50c878); + background: linear-gradient(135deg, #228B22, #32CD32); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; @@ -44,7 +60,7 @@ body { .header h1 i { margin-right: 0.5rem; - background: linear-gradient(135deg, #4a90e2, #50c878); + background: linear-gradient(135deg, #228B22, #32CD32); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; @@ -72,7 +88,7 @@ body { } .query-btn { - background: linear-gradient(135deg, #4a90e2, #50c878); + background: linear-gradient(135deg, #228B22, #32CD32); color: white; border: none; padding: 1rem 2rem; @@ -81,7 +97,7 @@ body { border-radius: 50px; cursor: pointer; transition: all 0.3s ease; - box-shadow: 0 4px 15px rgba(74, 144, 226, 0.3); + box-shadow: 0 4px 15px rgba(34, 139, 34, 0.3); display: inline-flex; align-items: center; gap: 0.5rem; @@ -91,8 +107,8 @@ body { .query-btn:hover { transform: translateY(-2px); - box-shadow: 0 6px 20px rgba(74, 144, 226, 0.4); - background: linear-gradient(135deg, #3a7bc8, #40a868); + box-shadow: 0 6px 20px rgba(34, 139, 34, 0.4); + background: linear-gradient(135deg, #1e7e1e, #2eb82e); } .query-btn:active { diff --git a/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/index.html b/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/index.html index 875fb9f0..88d7ae88 100755 --- a/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/index.html +++ b/InfoGenie-frontend/public/60sapi/实用功能/公网IP地址/index.html @@ -51,11 +51,6 @@ 查询时间: --
-
- - 数据来源: - 60s.viki.moe -
位置信息: @@ -129,9 +124,6 @@ -
diff --git a/InfoGenie-frontend/public/60sapi/实用功能/农历信息/css/background.css b/InfoGenie-frontend/public/60sapi/实用功能/农历信息/css/background.css index 3454ea71..4b346b4f 100755 --- a/InfoGenie-frontend/public/60sapi/实用功能/农历信息/css/background.css +++ b/InfoGenie-frontend/public/60sapi/实用功能/农历信息/css/background.css @@ -1,18 +1,33 @@ -/* 农历主题背景样式 - 柔和版本 */ +/* 全局滚动条隐藏样式 */ +html, body { + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE/Edge */ +} + +html::-webkit-scrollbar, +body::-webkit-scrollbar, +*::-webkit-scrollbar { + display: none; /* Webkit浏览器 */ +} + +/* 农历主题背景样式 - 淡黄绿色到淡绿色清新渐变 */ body { background: linear-gradient(135deg, - #f8f9fa 0%, /* 浅灰白 */ - #fff3e0 20%, /* 淡橙色 */ - #fef7e0 40%, /* 极淡黄 */ - #f3e5ab 60%, /* 柔和金色 */ - #e8dcc6 80%, /* 米色 */ - #f8f9fa 100% /* 浅灰白 */ + #f0f8e8 0%, /* 淡黄绿色 */ + #e8f5e8 20%, /* 浅绿色 */ + #d4f4dd 40%, /* 淡绿色 */ + #c8f2d4 60%, /* 清新绿色 */ + #b8f0c8 80%, /* 柔和绿色 */ + #e8f5e8 100% /* 浅绿色 */ ); background-size: 400% 400%; animation: gentleShift 30s ease infinite; background-attachment: fixed; min-height: 100vh; position: relative; + /* 隐藏滚动条但保留滚动功能 */ + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE/Edge */ } @keyframes gentleShift { @@ -23,7 +38,7 @@ body { 100% { background-position: 0% 50%; } } -/* 动态颜色调节系统 - 柔和版本 */ +/* 动态颜色调节系统 - 绿色主题版本 */ .adaptive-overlay { position: fixed; top: 0; @@ -31,9 +46,9 @@ body { width: 100%; height: 100%; background: - radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.3) 0%, transparent 50%), - radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.25) 0%, transparent 50%), - linear-gradient(45deg, rgba(255, 255, 255, 0.2) 0%, rgba(255, 255, 255, 0.3) 100%); + radial-gradient(circle at 20% 30%, rgba(200, 242, 212, 0.3) 0%, transparent 50%), + radial-gradient(circle at 80% 70%, rgba(184, 240, 200, 0.25) 0%, transparent 50%), + linear-gradient(45deg, rgba(232, 245, 232, 0.2) 0%, rgba(212, 244, 221, 0.3) 100%); pointer-events: none; z-index: 1; animation: adaptiveShift 60s ease infinite; @@ -42,33 +57,33 @@ body { @keyframes adaptiveShift { 0% { background: - radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%), - radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 50%), - linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.2) 100%); + radial-gradient(circle at 20% 30%, rgba(232, 245, 232, 0.1) 0%, transparent 50%), + radial-gradient(circle at 80% 70%, rgba(212, 244, 221, 0.15) 0%, transparent 50%), + linear-gradient(45deg, rgba(240, 248, 232, 0.1) 0%, rgba(232, 245, 232, 0.2) 100%); } 25% { background: - radial-gradient(circle at 70% 20%, rgba(255, 255, 255, 0.2) 0%, transparent 50%), - radial-gradient(circle at 30% 80%, rgba(255, 255, 255, 0.1) 0%, transparent 50%), - linear-gradient(135deg, rgba(255, 255, 255, 0.15) 0%, rgba(255, 255, 255, 0.25) 100%); + radial-gradient(circle at 70% 20%, rgba(200, 242, 212, 0.2) 0%, transparent 50%), + radial-gradient(circle at 30% 80%, rgba(184, 240, 200, 0.1) 0%, transparent 50%), + linear-gradient(135deg, rgba(212, 244, 221, 0.15) 0%, rgba(200, 242, 212, 0.25) 100%); } 50% { background: - radial-gradient(circle at 50% 50%, rgba(255, 255, 255, 0.15) 0%, transparent 50%), - radial-gradient(circle at 10% 90%, rgba(255, 255, 255, 0.12) 0%, transparent 50%), - linear-gradient(225deg, rgba(255, 255, 255, 0.12) 0%, rgba(255, 255, 255, 0.22) 100%); + radial-gradient(circle at 50% 50%, rgba(220, 246, 228, 0.15) 0%, transparent 50%), + radial-gradient(circle at 10% 90%, rgba(232, 245, 232, 0.12) 0%, transparent 50%), + linear-gradient(225deg, rgba(240, 248, 232, 0.12) 0%, rgba(212, 244, 221, 0.22) 100%); } 75% { background: - radial-gradient(circle at 90% 60%, rgba(255, 255, 255, 0.18) 0%, transparent 50%), - radial-gradient(circle at 40% 10%, rgba(255, 255, 255, 0.08) 0%, transparent 50%), - linear-gradient(315deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.2) 100%); + radial-gradient(circle at 90% 60%, rgba(184, 240, 200, 0.18) 0%, transparent 50%), + radial-gradient(circle at 40% 10%, rgba(240, 248, 232, 0.08) 0%, transparent 50%), + linear-gradient(315deg, rgba(232, 245, 232, 0.1) 0%, rgba(200, 242, 212, 0.2) 100%); } 100% { background: - radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.1) 0%, transparent 50%), - radial-gradient(circle at 80% 70%, rgba(255, 255, 255, 0.15) 0%, transparent 50%), - linear-gradient(45deg, rgba(255, 255, 255, 0.1) 0%, rgba(255, 255, 255, 0.2) 100%); + radial-gradient(circle at 20% 30%, rgba(232, 245, 232, 0.1) 0%, transparent 50%), + radial-gradient(circle at 80% 70%, rgba(212, 244, 221, 0.15) 0%, transparent 50%), + linear-gradient(45deg, rgba(240, 248, 232, 0.1) 0%, rgba(232, 245, 232, 0.2) 100%); } } diff --git a/InfoGenie-frontend/public/60sapi/实用功能/农历信息/css/style.css b/InfoGenie-frontend/public/60sapi/实用功能/农历信息/css/style.css index 38abe022..4004990d 100755 --- a/InfoGenie-frontend/public/60sapi/实用功能/农历信息/css/style.css +++ b/InfoGenie-frontend/public/60sapi/实用功能/农历信息/css/style.css @@ -266,12 +266,12 @@ body { .date-input:focus { outline: none; - border-color: rgba(255, 255, 255, 0.5); - background: rgba(255, 255, 255, 0.15); + border-color: #228B22; + background: rgba(255, 255, 255, 0.95); box-shadow: - 0 6px 20px rgba(31, 38, 135, 0.2), - inset 0 1px 0 rgba(255, 255, 255, 0.3), - 0 0 0 3px rgba(255, 255, 255, 0.1); + 0 6px 20px rgba(34, 139, 34, 0.2), + inset 0 1px 0 rgba(255, 255, 255, 0.8), + 0 0 0 3px rgba(34, 139, 34, 0.1); transform: translateY(-2px); } @@ -282,11 +282,11 @@ body { } .query-btn { - background: linear-gradient(135deg, #f0f0f0, #e0e0e0); + background: linear-gradient(135deg, #228B22 0%, #32CD32 100%); backdrop-filter: blur(15px); -webkit-backdrop-filter: blur(15px); - color: #1a1a1a; - border: 1px solid rgba(0, 0, 0, 0.2); + color: #ffffff; + border: 1px solid rgba(34, 139, 34, 0.3); padding: 12px 28px; border-radius: 20px; cursor: pointer; @@ -298,10 +298,10 @@ body { gap: 8px; position: relative; overflow: hidden; - text-shadow: 0 1px 3px rgba(255, 255, 255, 0.8); + text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3); box-shadow: - 0 4px 15px rgba(0, 0, 0, 0.1), - inset 0 1px 0 rgba(255, 255, 255, 0.8); + 0 4px 15px rgba(34, 139, 34, 0.3), + inset 0 1px 0 rgba(255, 255, 255, 0.2); } /* 移除按钮颜色动画,保持稳定的可读性 */ @@ -326,12 +326,12 @@ body { } .query-btn:hover { - background: linear-gradient(135deg, #e8e8e8, #d8d8d8); - border-color: rgba(0, 0, 0, 0.3); + background: linear-gradient(135deg, #1e7e1e, #2eb82e); + border-color: rgba(34, 139, 34, 0.5); transform: translateY(-2px); box-shadow: - 0 8px 25px rgba(0, 0, 0, 0.15), - inset 0 1px 0 rgba(255, 255, 255, 0.9); + 0 8px 25px rgba(34, 139, 34, 0.4), + inset 0 1px 0 rgba(255, 255, 255, 0.3); } .btn-icon { diff --git a/InfoGenie-frontend/public/60sapi/实用功能/农历信息/index.html b/InfoGenie-frontend/public/60sapi/实用功能/农历信息/index.html index 6744ddec..d66d4d7c 100755 --- a/InfoGenie-frontend/public/60sapi/实用功能/农历信息/index.html +++ b/InfoGenie-frontend/public/60sapi/实用功能/农历信息/index.html @@ -3,7 +3,7 @@ - 🌙 农历信息查询 + 🌙农历信息查询 @@ -48,8 +48,7 @@
-
🏮
-

🌙 农历信息查询 📅

+

🌙农历信息查询

传统文化 · 时光转换 · 节气查询

diff --git a/InfoGenie-frontend/public/60sapi/实用功能/农历信息/js/script.js b/InfoGenie-frontend/public/60sapi/实用功能/农历信息/js/script.js index ac8c595b..248b8928 100755 --- a/InfoGenie-frontend/public/60sapi/实用功能/农历信息/js/script.js +++ b/InfoGenie-frontend/public/60sapi/实用功能/农历信息/js/script.js @@ -287,15 +287,9 @@ function displayLunarInfo(lunarData) {
本月进度
${lunarData.stats.percents_formatted.month}
-
-
🗓️
-
本周第几天
-
第${lunarData.stats.week_of_month}周
+
-
-
-
今日进度
-
${lunarData.stats.percents_formatted.day}
+
diff --git a/InfoGenie-frontend/public/60sapi/实用功能/哈希解压压缩/css/style.css b/InfoGenie-frontend/public/60sapi/实用功能/哈希解压压缩/css/style.css index 4b94a03d..98183afc 100755 --- a/InfoGenie-frontend/public/60sapi/实用功能/哈希解压压缩/css/style.css +++ b/InfoGenie-frontend/public/60sapi/实用功能/哈希解压压缩/css/style.css @@ -7,10 +7,26 @@ body { font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; - background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + background: linear-gradient(135deg, #f0f8e8 0%, #e8f5e8 50%, #d4f4dd 100%); min-height: 100vh; color: #333; overflow-x: hidden; + /* 隐藏滚动条但保留滚动功能 */ + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE and Edge */ +} + +/* 隐藏 Webkit 浏览器的滚动条 */ +body::-webkit-scrollbar, +html::-webkit-scrollbar, +*::-webkit-scrollbar { + display: none; +} + +/* 全局隐藏滚动条但保留滚动功能 */ +html { + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE and Edge */ } .container { @@ -65,7 +81,7 @@ body { .logo i { font-size: 48px; - background: linear-gradient(45deg, #ff6b6b, #4ecdc4); + background: linear-gradient(45deg, #228B22, #32CD32); -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; @@ -174,7 +190,7 @@ body { .card-header i { font-size: 24px; - color: #667eea; + color: #228B22; } .card-header h2 { @@ -202,8 +218,8 @@ body { #inputText:focus { outline: none; - border-color: #667eea; - box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1); + border-color: #228B22; + box-shadow: 0 0 0 3px rgba(34, 139, 34, 0.1); background: rgba(255, 255, 255, 0.95); } @@ -247,14 +263,14 @@ body { } .btn-primary { - background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + background: linear-gradient(135deg, #228B22 0%, #32CD32 100%); color: white; - box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3); + box-shadow: 0 4px 15px rgba(34, 139, 34, 0.3); } .btn-primary:hover { transform: translateY(-2px); - box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4); + box-shadow: 0 8px 25px rgba(34, 139, 34, 0.4); } .btn-secondary { @@ -306,7 +322,7 @@ body { left: 0; right: 0; height: 4px; - background: linear-gradient(90deg, #ff6b6b, #4ecdc4, #45b7d1, #96ceb4); + background: linear-gradient(90deg, #228B22, #32CD32, #90EE90, #98FB98); } .result-card:hover { @@ -356,7 +372,7 @@ body { .result-value:hover { background: rgba(248, 250, 252, 0.95); - border-color: #667eea; + border-color: #228B22; } .result-value .placeholder { @@ -367,7 +383,7 @@ body { .copy-btn { background: none; border: none; - color: #667eea; + color: #228B22; cursor: pointer; padding: 8px; border-radius: 6px; @@ -377,8 +393,8 @@ body { } .copy-btn:hover { - background: rgba(102, 126, 234, 0.1); - color: #5a67d8; + background: rgba(34, 139, 34, 0.1); + color: #1e7e1e; } /* Loading Overlay */ @@ -429,7 +445,7 @@ body { position: fixed; bottom: 30px; right: 30px; - background: linear-gradient(135deg, #4ecdc4, #44a08d); + background: linear-gradient(135deg, #228B22, #32CD32); color: white; padding: 16px 24px; border-radius: 12px; diff --git a/InfoGenie-frontend/public/60sapi/实用功能/密码强度检测/css/style.css b/InfoGenie-frontend/public/60sapi/实用功能/密码强度检测/css/style.css index 858e4bea..563b0930 100755 --- a/InfoGenie-frontend/public/60sapi/实用功能/密码强度检测/css/style.css +++ b/InfoGenie-frontend/public/60sapi/实用功能/密码强度检测/css/style.css @@ -5,12 +5,27 @@ box-sizing: border-box; } +/* 隐藏滚动条但保留滚动功能 */ +html { + scrollbar-width: none; + -ms-overflow-style: none; +} + +body::-webkit-scrollbar, +html::-webkit-scrollbar, +*::-webkit-scrollbar { + display: none; +} + body { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif; line-height: 1.6; color: #2c3e50; min-height: 100vh; overflow-x: hidden; + background: linear-gradient(135deg, #f0f8e8 0%, #e8f5e8 50%, #d4f4dd 100%); + scrollbar-width: none; + -ms-overflow-style: none; } /* 容器布局 */ @@ -28,9 +43,9 @@ body { text-align: center; margin-bottom: 40px; padding: 40px 20px; - background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + background: linear-gradient(135deg, #228B22 0%, #32CD32 100%); border-radius: 20px; - box-shadow: 0 10px 30px rgba(102, 126, 234, 0.3); + box-shadow: 0 10px 30px rgba(34, 139, 34, 0.3); color: white; } @@ -95,9 +110,9 @@ body { .password-input:focus { outline: none; - border-color: #667eea; + border-color: #228B22; background: #ffffff; - box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1); + box-shadow: 0 0 0 4px rgba(34, 139, 34, 0.1); } .password-input::placeholder { @@ -140,7 +155,7 @@ body { /* 检测按钮 */ .check-btn { width: 100%; - background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); + background: linear-gradient(135deg, #228B22 0%, #32CD32 100%); color: white; border: none; padding: 18px 32px; @@ -149,7 +164,7 @@ body { font-weight: 600; cursor: pointer; transition: all 0.3s ease; - box-shadow: 0 4px 20px rgba(102, 126, 234, 0.3); + box-shadow: 0 4px 20px rgba(34, 139, 34, 0.3); display: flex; align-items: center; justify-content: center; @@ -160,7 +175,7 @@ body { .check-btn:hover { transform: translateY(-2px); - box-shadow: 0 6px 25px rgba(102, 126, 234, 0.4); + box-shadow: 0 6px 25px rgba(34, 139, 34, 0.4); } .check-btn:active { @@ -284,7 +299,7 @@ body { .bar-fill { height: 100%; - background: linear-gradient(90deg, #ef4444, #f97316, #eab308, #22c55e); + background: linear-gradient(90deg, #90EE90, #98FB98, #32CD32, #228B22); border-radius: 6px; width: 0%; transition: width 0.8s ease; @@ -383,13 +398,13 @@ body { } .char-type.has-type { - background: #dcfce7; - border-color: #bbf7d0; - color: #166534; + background: #f0f8e8; + border-color: #d4f4dd; + color: #1e7e1e; } .char-type.has-type .type-icon { - color: #22c55e; + color: #228B22; } .type-icon { @@ -555,11 +570,11 @@ body { position: fixed; top: 20px; right: 20px; - background: #22c55e; + background: #228B22; color: white; padding: 16px 24px; border-radius: 10px; - box-shadow: 0 4px 20px rgba(34, 197, 94, 0.3); + box-shadow: 0 4px 20px rgba(34, 139, 34, 0.3); z-index: 1000; animation: toastSlide 0.3s ease-out; font-weight: 500; @@ -586,11 +601,11 @@ body { } .strength-strong { - color: #059669 !important; + color: #228B22 !important; } .strength-very-strong { - color: #047857 !important; + color: #1e7e1e !important; } /* 分数圆圈颜色 */ @@ -603,11 +618,11 @@ body { } .score-strong { - background: conic-gradient(from 0deg, #059669 0deg, #059669 var(--score-deg), #e2e8f0 var(--score-deg), #e2e8f0 360deg) !important; + background: conic-gradient(from 0deg, #228B22 0deg, #228B22 var(--score-deg), #e2e8f0 var(--score-deg), #e2e8f0 360deg) !important; } .score-very-strong { - background: conic-gradient(from 0deg, #047857 0deg, #047857 var(--score-deg), #e2e8f0 var(--score-deg), #e2e8f0 360deg) !important; + background: conic-gradient(from 0deg, #1e7e1e 0deg, #1e7e1e var(--score-deg), #e2e8f0 var(--score-deg), #e2e8f0 360deg) !important; } /* 平板端适配 (768px - 1024px) */ diff --git a/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/env.js b/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/env.js new file mode 100644 index 00000000..95bfb73d --- /dev/null +++ b/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/env.js @@ -0,0 +1,25 @@ +// 环境配置文件 - AI中国亲戚称呼计算器 +// 复用 InfoGenie 的全局 ENV_CONFIG,支持独立打开的回退地址 + +const DEFAULT_API = (window.ENV_CONFIG && window.ENV_CONFIG.API_URL) || 'http://127.0.0.1:5002'; + +window.API_CONFIG = { + baseUrl: window.parent?.ENV_CONFIG?.API_URL || DEFAULT_API, + endpoints: { + kinshipCalculator: '/api/aimodelapp/kinship-calculator' + } +}; + +window.AUTH_CONFIG = { + tokenKey: 'token', + getToken: () => localStorage.getItem('token'), + isAuthenticated: () => !!localStorage.getItem('token') +}; + +window.APP_CONFIG = { + name: 'InfoGenie 中国亲戚称呼计算器', + version: '1.0.0', + debug: false +}; + +console.log('中国亲戚称呼计算器 环境配置已加载'); \ No newline at end of file diff --git a/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/index.html b/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/index.html new file mode 100644 index 00000000..9e7bf811 --- /dev/null +++ b/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/index.html @@ -0,0 +1,59 @@ + + + + + + 中国亲戚称呼计算器 + + + +
+
+

中国亲戚称呼计算器

+

输入亲属关系链(如“妈妈的爸爸”、“爸爸的姐姐的儿子”),快速得到标准普通话称呼与各地方言称呼

+
+ +
+
+ + + +
+ · 使用“的”连接每一层关系,例如: + 妈妈的爸爸 + 爸爸的姐姐的儿子 + 妈妈的弟弟的女儿 +
+ + + + +
+ + +
+
+ + + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/script.js b/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/script.js new file mode 100644 index 00000000..a71c1bd4 --- /dev/null +++ b/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/script.js @@ -0,0 +1,135 @@ +// 环境与认证在 env.js 中定义 + +const relationInput = document.getElementById('relationInput'); +const calcBtn = document.getElementById('calcBtn'); +const loadingDiv = document.getElementById('loading'); +const errorDiv = document.getElementById('error'); +const resultSection = document.getElementById('resultSection'); +const mandarinTitleEl = document.getElementById('mandarinTitle'); +const dialectListEl = document.getElementById('dialectList'); +const copyMandarinBtn = document.getElementById('copyMandarinBtn'); +const notesBlock = document.getElementById('notesBlock'); +const notesEl = document.getElementById('notes'); + +function setExample(text) { + relationInput.value = text; +} +window.setExample = setExample; + +function showLoading(show) { + loadingDiv.style.display = show ? 'block' : 'none'; + calcBtn.disabled = show; +} + +function showError(msg) { + errorDiv.textContent = msg || ''; + errorDiv.style.display = msg ? 'block' : 'none'; +} + +function clearResults() { + resultSection.style.display = 'none'; + mandarinTitleEl.textContent = ''; + dialectListEl.innerHTML = ''; + notesBlock.style.display = 'none'; + notesEl.textContent = ''; +} + +async function callKinshipAPI(relationChain) { + const token = window.AUTH_CONFIG.getToken(); + if (!token) throw new Error('未登录,请先登录后使用AI功能'); + + const url = `${window.API_CONFIG.baseUrl}${window.API_CONFIG.endpoints.kinshipCalculator}`; + const resp = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify({ relation_chain: relationChain }) + }); + + if (!resp.ok) { + if (resp.status === 402) throw new Error('您的萌芽币余额不足,无法使用此功能'); + const err = await resp.json().catch(() => ({})); + throw new Error(err.error || `API请求失败: ${resp.status} ${resp.statusText}`); + } + + const data = await resp.json(); + if (!data.success) throw new Error(data.error || 'API响应异常'); + return data; +} + +function renderDialects(dialectTitles) { + dialectListEl.innerHTML = ''; + const order = ['粤语','闽南语','上海话','四川话','东北话','客家话']; + const names = order.concat(Object.keys(dialectTitles || {}).filter(k => !order.includes(k))); + + names.forEach(name => { + const info = dialectTitles?.[name]; + if (!info || (!info.title && !info.romanization && !info.notes)) return; + const item = document.createElement('div'); + item.className = 'dialect-item'; + const title = (info.title || '').toString(); + const roman = (info.romanization || '').toString(); + const notes = (info.notes || '').toString(); + item.innerHTML = ` +
${name}
+
${title}
+ ${roman ? `
${roman}
` : ''} + ${notes ? `
${notes}
` : ''} + `; + dialectListEl.appendChild(item); + }); +} + +async function doCalculate() { + const relation = (relationInput.value || '').trim(); + if (!relation) { + showError('请输入亲属关系链'); + return; + } + showError(''); + showLoading(true); + clearResults(); + + try { + const data = await callKinshipAPI(relation); + mandarinTitleEl.textContent = data.mandarin_title || ''; + renderDialects(data.dialect_titles || {}); + if (data.notes) { + notesEl.textContent = data.notes; + notesBlock.style.display = 'block'; + } + resultSection.style.display = 'block'; + } catch (e) { + console.error('计算失败:', e); + showError(`计算失败: ${e.message}`); + } finally { + showLoading(false); + } +} + +function copyText(text) { + try { + navigator.clipboard.writeText(text); + } catch (e) { + const ta = document.createElement('textarea'); + ta.value = text; + document.body.appendChild(ta); + ta.select(); + document.execCommand('copy'); + document.body.removeChild(ta); + } +} + +copyMandarinBtn.addEventListener('click', () => { + const t = mandarinTitleEl.textContent || ''; + if (!t) return; + copyText(t); +}); + +calcBtn.addEventListener('click', doCalculate); + +document.addEventListener('DOMContentLoaded', () => { + showError(''); +}); \ No newline at end of file diff --git a/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/styles.css b/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/styles.css new file mode 100644 index 00000000..c63f012e --- /dev/null +++ b/InfoGenie-frontend/public/aimodelapp/AI中国亲戚称呼计算器/styles.css @@ -0,0 +1,189 @@ +/* 渐变背景与毛玻璃风格,参考 AI文章排版 */ +:root { + --green: #a8e6cf; + --lime: #dcedc1; + --dark: #2e7d32; + --text: #1b5e20; + --muted: #558b2f; + --white: #ffffff; + --shadow: rgba(0, 0, 0, 0.08); +} + +html, body { + height: 100%; +} + +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif; + color: var(--text); + background: linear-gradient(135deg, var(--green) 0%, var(--lime) 100%); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.app-container { + min-height: 100vh; + display: flex; + flex-direction: column; + align-items: center; + padding: 16px; +} + +.app-header { + text-align: center; + margin: 8px 0 16px; +} + +.app-header h1 { + font-size: 22px; + margin: 0; + color: var(--dark); +} + +.subtitle { + margin-top: 8px; + font-size: 13px; + color: var(--muted); +} + +.card { + width: 100%; + max-width: 720px; + background: rgba(255,255,255,0.75); + backdrop-filter: blur(10px); + border-radius: 14px; + box-shadow: 0 8px 24px var(--shadow); + padding: 16px; +} + +.label { + display: block; + font-size: 13px; + color: var(--muted); + margin-bottom: 6px; +} + +.textarea { + width: 100%; + box-sizing: border-box; + border: 1px solid rgba(0,0,0,0.05); + border-radius: 10px; + padding: 10px 12px; + font-size: 14px; + color: var(--text); + outline: none; +} +.textarea:focus { + border-color: rgba(46,125,50,0.35); + box-shadow: 0 0 0 3px rgba(46,125,50,0.12); +} + +.hint { + margin: 10px 0 12px; + font-size: 12px; + color: var(--muted); +} +.chip { + display: inline-block; + background: rgba(255,255,255,0.9); + border: 1px solid rgba(46,125,50,0.2); + color: var(--dark); + border-radius: 999px; + padding: 4px 10px; + margin-right: 6px; + cursor: pointer; + user-select: none; +} +.chip:hover { filter: brightness(0.98); } + +.button { + display: inline-flex; + align-items: center; + justify-content: center; + border: none; + border-radius: 12px; + padding: 10px 14px; + font-size: 14px; + cursor: pointer; + background: rgba(46,125,50,0.15); + color: var(--dark); +} +.button.primary { + background: linear-gradient(135deg, #81c784, #aed581); + color: #fff; +} +.button:disabled { opacity: 0.6; cursor: not-allowed; } + +.loading { + margin-top: 10px; + font-size: 13px; + color: var(--muted); +} +.error { + margin-top: 8px; + padding: 8px 10px; + border-left: 3px solid #e53935; + background: rgba(229,57,53,0.08); + border-radius: 8px; + color: #c62828; + font-size: 13px; +} + +.result-section { margin-top: 14px; } +.result-section h2 { + font-size: 16px; + margin: 0 0 8px; + color: var(--dark); +} + +.result-block { + background: rgba(255,255,255,0.9); + border: 1px solid rgba(0,0,0,0.05); + border-radius: 12px; + padding: 10px; + margin-bottom: 10px; +} +.result-title { + font-size: 13px; + color: var(--muted); + margin-bottom: 6px; +} +.result-value { + font-size: 18px; + color: var(--text); +} +.actions { margin-top: 8px; } + +.dialect-list { + display: grid; + grid-template-columns: 1fr; + gap: 8px; +} +@media (min-width: 540px) { + .dialect-list { grid-template-columns: 1fr 1fr; } +} + +.dialect-item { + border: 1px solid rgba(46,125,50,0.18); + border-radius: 10px; + padding: 8px; + background: rgba(255,255,255,0.95); +} +.dialect-item .dialect-name { + font-weight: 600; + color: var(--dark); + margin-bottom: 4px; +} +.dialect-item .dialect-title { font-size: 15px; } +.dialect-item .dialect-roman { font-size: 12px; color: var(--muted); } +.dialect-item .dialect-notes { font-size: 12px; color: var(--muted); margin-top: 4px; } + +.notes { font-size: 13px; color: var(--muted); } + +.app-footer { + margin-top: 12px; + font-size: 12px; + color: var(--muted); + text-align: center; +} \ No newline at end of file diff --git a/InfoGenie-frontend/public/aimodelapp/AI变量命名助手/styles.css b/InfoGenie-frontend/public/aimodelapp/AI变量命名助手/styles.css index c6d4bd14..ce1673ca 100755 --- a/InfoGenie-frontend/public/aimodelapp/AI变量命名助手/styles.css +++ b/InfoGenie-frontend/public/aimodelapp/AI变量命名助手/styles.css @@ -8,13 +8,31 @@ /* 主体样式 - iOS风格 */ body { font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif; - background: linear-gradient(135deg, #87CEEB 0%, #98FB98 100%); + background: linear-gradient(135deg, #F0FFF0 0%, #98FB98 50%, #90EE90 100%); min-height: 100vh; padding: 20px; color: #1D1D1F; line-height: 1.47; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; + /* 隐藏滚动条但保留滚动功能 */ + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE/Edge */ +} + +/* 隐藏Webkit浏览器的滚动条 */ +body::-webkit-scrollbar { + display: none; +} + +/* 全局滚动条隐藏 */ +* { + scrollbar-width: none; /* Firefox */ + -ms-overflow-style: none; /* IE/Edge */ +} + +*::-webkit-scrollbar { + display: none; /* Chrome, Safari, Opera */ } /* 容器样式 - iOS毛玻璃效果 */ @@ -81,9 +99,9 @@ body { .form-input:focus { outline: none; - border-color: #007AFF; + border-color: #32CD32; background: rgba(255, 255, 255, 0.95); - box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.1); + box-shadow: 0 0 0 4px rgba(50, 205, 50, 0.1); } .textarea { @@ -105,7 +123,7 @@ body { .btn { width: 100%; padding: 16px; - background: #007AFF; + background: #32CD32; color: white; border: none; border-radius: 12px; @@ -114,18 +132,18 @@ body { cursor: pointer; transition: all 0.2s ease; margin-bottom: 24px; - box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25); + box-shadow: 0 2px 8px rgba(50, 205, 50, 0.25); } .btn:hover { - background: #0056CC; + background: #228B22; transform: translateY(-1px); - box-shadow: 0 4px 16px rgba(0, 122, 255, 0.35); + box-shadow: 0 4px 16px rgba(50, 205, 50, 0.35); } .btn:active { transform: translateY(0); - background: #004499; + background: #006400; } .btn:disabled { @@ -151,7 +169,7 @@ body { .loading { display: none; text-align: center; - color: #007AFF; + color: #32CD32; font-style: normal; padding: 24px; font-weight: 500; @@ -161,9 +179,12 @@ body { background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 16px; - padding: 24px; + padding: 20px; min-height: 150px; backdrop-filter: blur(10px); + display: grid; + gap: 16px; + grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); } .placeholder { @@ -176,15 +197,16 @@ body { /* 分组标题样式 - iOS风格 */ .convention-group-title { - font-size: 1.0625rem; + font-size: 1rem; font-weight: 600; color: white; - margin: 20px 0 12px 0; - padding: 12px 16px; - background: #007AFF; + margin: 16px 0 12px 0; + padding: 10px 16px; + background: #32CD32; border-radius: 12px; text-align: center; - box-shadow: 0 2px 8px rgba(0, 122, 255, 0.25); + box-shadow: 0 2px 8px rgba(50, 205, 50, 0.25); + grid-column: 1 / -1; } .convention-group-title:first-child { @@ -196,17 +218,21 @@ body { background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(0, 0, 0, 0.06); border-radius: 12px; - padding: 16px; - margin-bottom: 12px; + padding: 12px; + margin-bottom: 0; transition: all 0.2s ease; cursor: pointer; position: relative; backdrop-filter: blur(10px); + min-height: 80px; + display: flex; + flex-direction: column; + justify-content: space-between; } .suggestion-item:hover { - border-color: rgba(0, 122, 255, 0.3); - box-shadow: 0 4px 16px rgba(0, 122, 255, 0.1); + border-color: rgba(50, 205, 50, 0.3); + box-shadow: 0 4px 16px rgba(50, 205, 50, 0.1); background: rgba(255, 255, 255, 0.95); } @@ -216,33 +242,35 @@ body { .variable-name { font-family: 'SF Mono', 'Monaco', 'Consolas', 'Courier New', monospace; - font-size: 1.0625rem; + font-size: 1rem; font-weight: 600; color: #1D1D1F; - margin-bottom: 6px; + margin-bottom: 4px; + word-break: break-all; } .variable-description { - font-size: 0.9375rem; + font-size: 0.875rem; color: #86868B; - line-height: 1.47; + line-height: 1.4; + flex-grow: 1; } .copy-btn { position: absolute; - top: 12px; - right: 12px; - background: #007AFF; + top: 8px; + right: 8px; + background: #32CD32; color: white; border: none; - border-radius: 8px; - padding: 6px 12px; - font-size: 0.8125rem; + border-radius: 6px; + padding: 4px 8px; + font-size: 0.75rem; font-weight: 600; cursor: pointer; opacity: 0; transition: all 0.2s ease; - box-shadow: 0 2px 4px rgba(0, 122, 255, 0.25); + box-shadow: 0 1px 3px rgba(50, 205, 50, 0.25); } .suggestion-item:hover .copy-btn { @@ -250,7 +278,7 @@ body { } .copy-btn:hover { - background: #0056CC; + background: #228B22; transform: translateY(-1px); } @@ -314,17 +342,30 @@ body { .suggestions-container { padding: 15px; + grid-template-columns: 1fr; + gap: 12px; } .suggestion-item { - padding: 12px; + padding: 10px; + min-height: 70px; } .copy-btn { position: static; opacity: 1; - margin-top: 8px; + margin-top: 6px; width: 100%; + padding: 6px 8px; + font-size: 0.75rem; + } + + .variable-name { + font-size: 0.9rem; + } + + .variable-description { + font-size: 0.8rem; } } @@ -342,16 +383,30 @@ body { padding: 10px; } + .suggestions-container { + padding: 12px; + gap: 10px; + } + .suggestion-item { - padding: 10px; + padding: 8px; + min-height: 60px; } .variable-name { - font-size: 1rem; + font-size: 0.85rem; + margin-bottom: 3px; } .variable-description { - font-size: 0.85rem; + font-size: 0.75rem; + line-height: 1.3; + } + + .convention-group-title { + font-size: 0.9rem; + padding: 8px 12px; + margin: 12px 0 8px 0; } } diff --git a/InfoGenie-frontend/public/aimodelapp/AI文章排版/env.js b/InfoGenie-frontend/public/aimodelapp/AI文章排版/env.js new file mode 100644 index 00000000..277c8d07 --- /dev/null +++ b/InfoGenie-frontend/public/aimodelapp/AI文章排版/env.js @@ -0,0 +1,29 @@ +// 环境配置文件 - AI文章排版 +// 复用 InfoGenie 的全局 ENV_CONFIG + +// 本地/独立打开页面的API回退地址(优先使用父窗口ENV_CONFIG) +const DEFAULT_API = (window.ENV_CONFIG && window.ENV_CONFIG.API_URL) || 'http://127.0.0.1:5002'; + +// API配置 +window.API_CONFIG = { + baseUrl: window.parent?.ENV_CONFIG?.API_URL || DEFAULT_API, + endpoints: { + markdownFormatting: '/api/aimodelapp/markdown_formatting' + } +}; + +// 认证配置 +window.AUTH_CONFIG = { + tokenKey: 'token', + getToken: () => localStorage.getItem('token'), + isAuthenticated: () => !!localStorage.getItem('token') +}; + +// 应用配置 +window.APP_CONFIG = { + name: 'InfoGenie AI文章排版', + version: '1.0.0', + debug: false +}; + +console.log('AI文章排版 环境配置已加载'); \ No newline at end of file diff --git a/InfoGenie-frontend/public/aimodelapp/AI文章排版/index.html b/InfoGenie-frontend/public/aimodelapp/AI文章排版/index.html new file mode 100644 index 00000000..6118e10d --- /dev/null +++ b/InfoGenie-frontend/public/aimodelapp/AI文章排版/index.html @@ -0,0 +1,92 @@ + + + + + + AI文章排版助手 + + + +
+
+

AI文章排版助手

+

保持原文不变 · 智能转为Markdown并点缀Emoji

+
+ +
+
+ + +
+ +
+
+ + +
+
+ + +
+
+ + +
+ +
+

排版结果

+
正在排版中,请稍候...
+
+
输入文章后点击“开始排版”,AI将把原文转换为规范的Markdown,并智能添加合适的Emoji
+
+ + + + +
+
+ + + + + + + + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/aimodelapp/AI文章排版/script.js b/InfoGenie-frontend/public/aimodelapp/AI文章排版/script.js new file mode 100644 index 00000000..5a144a42 --- /dev/null +++ b/InfoGenie-frontend/public/aimodelapp/AI文章排版/script.js @@ -0,0 +1,152 @@ +// 配置已在 env.js 中定义 + +// DOM元素 +const articleTextInput = document.getElementById('articleText'); +const emojiStyleSelect = document.getElementById('emojiStyle'); +const markdownOptionSelect = document.getElementById('markdownOption'); +const formatBtn = document.getElementById('formatBtn'); +const loadingDiv = document.getElementById('loading'); +const resultContainer = document.getElementById('resultContainer'); +const previewSection = document.getElementById('previewSection'); +const markdownPreview = document.getElementById('markdownPreview'); +const rawSection = document.getElementById('rawSection'); +const markdownRaw = document.getElementById('markdownRaw'); +const copyMdBtn = document.getElementById('copyMdBtn'); +const copyHtmlBtn = document.getElementById('copyHtmlBtn'); + +// 加载器控制 +function showLoading(show) { + loadingDiv.style.display = show ? 'block' : 'none'; + formatBtn.disabled = show; +} + +// 错误提示 +function showErrorMessage(msg) { + resultContainer.innerHTML = `
${msg}
`; +} + +// 调用后端API +async function callBackendAPI(articleText, emojiStyle, markdownOption) { + try { + const token = window.AUTH_CONFIG.getToken(); + if (!token) throw new Error('未登录,请先登录后使用AI功能'); + + const url = `${window.API_CONFIG.baseUrl}${window.API_CONFIG.endpoints.markdownFormatting}`; + const response = await fetch(url, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify({ + article_text: articleText, + emoji_style: emojiStyle, + markdown_option: markdownOption + }) + }); + + if (!response.ok) { + if (response.status === 402) throw new Error('您的萌芽币余额不足,无法使用此功能'); + const errorData = await response.json().catch(() => ({})); + throw new Error(errorData.error || `API请求失败: ${response.status} ${response.statusText}`); + } + + const data = await response.json(); + if (data.success && data.formatted_markdown) return data.formatted_markdown; + throw new Error(data.error || 'API响应格式异常'); + } catch (error) { + console.error('API调用错误:', error); + throw error; + } +} + +// 显示结果 +function displayFormattingResult(markdownText) { + // 源Markdown + markdownRaw.textContent = markdownText || ''; + rawSection.style.display = markdownText ? 'block' : 'none'; + + // 预览渲染(使用marked + DOMPurify) + let html = ''; + try { + // 兼容新旧版本的marked库 + if (typeof marked === 'function') { + // 旧版本marked直接调用 + html = marked(markdownText || ''); + } else if (marked && typeof marked.parse === 'function') { + // 新版本marked使用parse方法 + html = marked.parse(markdownText || ''); + } else { + throw new Error('marked库未正确加载'); + } + + // 使用DOMPurify清理HTML(如果可用) + const safeHtml = typeof DOMPurify !== 'undefined' ? DOMPurify.sanitize(html) : html; + markdownPreview.innerHTML = safeHtml; + } catch (error) { + console.error('Markdown渲染失败:', error); + markdownPreview.innerHTML = `
Markdown渲染失败: ${error.message}
`; + } + + previewSection.style.display = markdownText ? 'block' : 'none'; + + // 顶部结果容器状态 + resultContainer.innerHTML = ''; + resultContainer.classList.add('conversion-result'); +} + +// 复制功能 +function copyToClipboard(text) { + try { + navigator.clipboard.writeText(text); + } catch (e) { + const textarea = document.createElement('textarea'); + textarea.value = text; + document.body.appendChild(textarea); + textarea.select(); + document.execCommand('copy'); + document.body.removeChild(textarea); + } +} + +copyMdBtn.addEventListener('click', () => copyToClipboard(markdownRaw.textContent || '')); +copyHtmlBtn.addEventListener('click', () => copyToClipboard(markdownPreview.innerHTML || '')); + +// 执行排版 +async function performFormatting() { + const articleText = articleTextInput.value.trim(); + const emojiStyle = emojiStyleSelect.value; + const markdownOption = markdownOptionSelect.value; + + if (!articleText) { + showErrorMessage('请输入需要排版的文章内容'); + return; + } + + showLoading(true); + resultContainer.innerHTML = ''; + previewSection.style.display = 'none'; + rawSection.style.display = 'none'; + + try { + const markdown = await callBackendAPI(articleText, emojiStyle, markdownOption); + displayFormattingResult(markdown); + } catch (error) { + console.error('排版失败:', error); + showErrorMessage(`排版失败: ${error.message}`); + } finally { + showLoading(false); + } +} + +// 事件绑定 +formatBtn.addEventListener('click', performFormatting); + +// 页面初始化 +document.addEventListener('DOMContentLoaded', () => { + resultContainer.innerHTML = '
请输入文章内容,选择Emoji风格与排版偏好,然后点击开始排版
'; +}); + +// 导出函数供HTML调用 +window.performFormatting = performFormatting; +window.copyToClipboard = copyToClipboard; \ No newline at end of file diff --git a/InfoGenie-frontend/public/aimodelapp/AI文章排版/styles.css b/InfoGenie-frontend/public/aimodelapp/AI文章排版/styles.css new file mode 100644 index 00000000..83442a33 --- /dev/null +++ b/InfoGenie-frontend/public/aimodelapp/AI文章排版/styles.css @@ -0,0 +1,84 @@ +/* 全局样式重置 */ +* { margin: 0; padding: 0; box-sizing: border-box; } + +/* 主体样式 - 清新渐变 */ +body { + font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', Arial, sans-serif; + background: linear-gradient(135deg, #a8e6cf 0%, #dcedc8 50%, #f1f8e9 100%); + min-height: 100vh; + padding: 20px; + color: #2e7d32; + line-height: 1.47; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* 容器样式 - 毛玻璃效果 */ +.container { + max-width: 900px; + margin: 0 auto; + background: rgba(255, 255, 255, 0.85); + border-radius: 24px; + padding: 32px; + box-shadow: 0 8px 32px rgba(76, 175, 80, 0.15), 0 2px 8px rgba(76, 175, 80, 0.1); + backdrop-filter: blur(20px) saturate(180%); + border: 1px solid rgba(76, 175, 80, 0.2); +} + +/* 头部样式 */ +.header { text-align: center; margin-bottom: 32px; } +.title { font-size: 2.25rem; color: #1b5e20; margin-bottom: 8px; font-weight: 600; letter-spacing: -0.02em; } +.subtitle { color: #4caf50; font-size: 1.0625rem; margin-bottom: 24px; font-weight: 400; } + +/* 表单区域 */ +.form-section { margin-bottom: 32px; } +.form-group { margin-bottom: 24px; } +.form-row { display: flex; gap: 16px; margin-bottom: 24px; } +.half-width { flex: 1; } +.form-label { display: block; margin-bottom: 8px; font-weight: 600; color: #2e7d32; } +.form-input { width: 100%; border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 12px; padding: 12px 14px; outline: none; background: rgba(255, 255, 255, 0.75); color: #1b5e20; font-size: 1rem; transition: all 0.2s ease; } +.form-input:focus { border-color: rgba(76, 175, 80, 0.4); box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.15); } +.textarea { min-height: 160px; resize: vertical; line-height: 1.6; } +.select { appearance: none; background-image: linear-gradient(135deg, #f1f8e9 0%, #e8f5e9 100%); } + +/* 操作按钮 */ +.btn { width: 100%; padding: 14px 18px; border: none; border-radius: 14px; font-weight: 600; font-size: 1.0625rem; color: #fff; background: linear-gradient(135deg, #43a047 0%, #66bb6a 50%, #81c784 100%); box-shadow: 0 4px 16px rgba(76, 175, 80, 0.3), 0 2px 8px rgba(76, 175, 80, 0.2); cursor: pointer; transition: all 0.2s ease; } +.btn:hover { transform: translateY(-1px); box-shadow: 0 6px 20px rgba(76, 175, 80, 0.35); } +.btn:active { transform: translateY(0); background: linear-gradient(135deg, #2e7d32 0%, #388e3c 100%); } +.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; background: #86868B; } + +/* 结果区域 */ +.result-section { margin-top: 32px; } +.result-title { font-size: 1.25rem; color: #1b5e20; margin-bottom: 16px; text-align: center; font-weight: 600; } +.loading { display: none; text-align: center; color: #4caf50; padding: 24px; font-weight: 500; } +.conversion-container { background: rgba(255, 255, 255, 0.6); border: 1px solid rgba(0, 0, 0, 0.08); border-radius: 16px; padding: 24px; min-height: 140px; backdrop-filter: blur(10px); } +.placeholder { text-align: center; color: #86868B; padding: 32px 20px; font-weight: 400; } +.placeholder.error { color: #d32f2f; background: rgba(244, 67, 54, 0.1); border: 1px solid rgba(244, 67, 54, 0.2); border-radius: 8px; } +.error { color: #d32f2f; background: rgba(244, 67, 54, 0.1); padding: 12px; border-radius: 8px; border: 1px solid rgba(244, 67, 54, 0.2); } + +/* 预览与原文区域 */ +.preview-section, .raw-section { margin-top: 24px; } +.preview-header, .raw-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; } +.preview-header .label, .raw-header .label { font-weight: 600; color: #2e7d32; font-size: 1rem; } +.copy-btn { padding: 6px 10px; border: none; border-radius: 10px; font-weight: 600; font-size: 0.9375rem; color: #fff; background: linear-gradient(135deg, #4caf50 0%, #81c784 100%); box-shadow: 0 2px 8px rgba(76, 175, 80, 0.25); cursor: pointer; } +.copy-btn:hover { filter: brightness(1.05); } + +.markdown-preview { background: rgba(255, 255, 255, 0.9); border: 1px solid rgba(0, 0, 0, 0.06); border-radius: 12px; padding: 20px; color: #2e7d32; line-height: 1.8; } +.markdown-raw { background: rgba(255, 255, 255, 0.85); border: 1px solid rgba(0, 0, 0, 0.06); border-radius: 12px; padding: 16px; color: #1b5e20; font-family: 'SF Mono', 'Monaco', 'Consolas', 'Courier New', monospace; font-size: 0.9375rem; white-space: pre-wrap; word-break: break-word; } + +/* Markdown渲染细节 */ +.markdown-preview h1, .markdown-preview h2, .markdown-preview h3 { color: #1b5e20; margin: 10px 0; } +.markdown-preview p { margin: 10px 0; } +.markdown-preview ul, .markdown-preview ol { padding-left: 24px; margin: 10px 0; } +.markdown-preview blockquote { border-left: 4px solid rgba(76, 175, 80, 0.4); padding-left: 12px; color: #4caf50; background: rgba(76, 175, 80, 0.08); border-radius: 6px; } +.markdown-preview code { background: rgba(0, 0, 0, 0.06); padding: 2px 6px; border-radius: 6px; font-family: 'SF Mono', 'Monaco', 'Consolas', 'Courier New', monospace; } + +/* 移动端优化 */ +@media (max-width: 480px) { + .container { padding: 18px; border-radius: 18px; } + .title { font-size: 1.75rem; } + .subtitle { font-size: 0.95rem; } + .form-row { flex-direction: column; gap: 12px; } + .textarea { min-height: 200px; } + .btn { font-size: 1rem; padding: 12px 16px; } +} \ No newline at end of file diff --git a/InfoGenie-frontend/public/assets/fonts/kaiti1.ttf b/InfoGenie-frontend/public/assets/fonts/kaiti1.ttf new file mode 100644 index 00000000..e3c7007c Binary files /dev/null and b/InfoGenie-frontend/public/assets/fonts/kaiti1.ttf differ diff --git a/InfoGenie-frontend/public/assets/圆角-logo.png b/InfoGenie-frontend/public/assets/圆角-logo.png new file mode 100644 index 00000000..ef7d5fc2 Binary files /dev/null and b/InfoGenie-frontend/public/assets/圆角-logo.png differ diff --git a/InfoGenie-frontend/public/index.html b/InfoGenie-frontend/public/index.html index effd9954..45050624 100755 --- a/InfoGenie-frontend/public/index.html +++ b/InfoGenie-frontend/public/index.html @@ -323,9 +323,9 @@
-
万象口袋
+ 万象口袋
-
🎨 一个跨平台的多功能聚合应用(´。• ω •。`) 💬
+ 🎨 一个跨平台的多功能聚合应用(´。• ω •。`) 💬
diff --git a/InfoGenie-frontend/public/smallgame/2048/game-logic.js b/InfoGenie-frontend/public/smallgame/2048/game-logic.js index 910dce86..e68ffd92 100755 --- a/InfoGenie-frontend/public/smallgame/2048/game-logic.js +++ b/InfoGenie-frontend/public/smallgame/2048/game-logic.js @@ -30,6 +30,122 @@ class Game2048 { // 开始计时 this.startTimer(); } + + // 依据分数计算权重(0.1 ~ 0.95) + calculateWeightByScore(score) { + const w = score / 4000; // 4000分约接近满权重 + return Math.max(0.1, Math.min(0.95, w)); + } + + // 按权重偏向生成0~10的随机整数,权重越高越偏向更大值 + biasedRandomInt(maxInclusive, weight) { + const rand = Math.random(); + const biased = Math.pow(rand, 1 - weight); // weight越大,biased越接近1 + const val = Math.floor(biased * (maxInclusive + 1)); + return Math.max(0, Math.min(maxInclusive, val)); + } + + // 附加结束信息到界面 + appendEndInfo(text, type = 'info') { + const message = document.getElementById('game-message'); + if (!message) return; + const info = document.createElement('div'); + info.style.marginTop = '10px'; + info.style.fontSize = '16px'; + info.style.color = type === 'error' ? '#d9534f' : (type === 'success' ? '#28a745' : '#776e65'); + info.textContent = text; + message.appendChild(info); + } + + // 游戏结束时尝试给当前登录账户加“萌芽币” + async tryAwardCoinsOnGameOver() { + try { + const token = localStorage.getItem('token'); + if (!token) { + this.appendEndInfo('未登录,无法获得萌芽币'); + return; + } + + let email = null; + try { + const userStr = localStorage.getItem('user'); + if (userStr) { + const userObj = JSON.parse(userStr); + email = userObj && (userObj.email || userObj['邮箱']); + } + } catch (e) { + // 忽略解析错误 + } + + if (!email) { + this.appendEndInfo('未找到账户信息(email),无法加币', 'error'); + return; + } + + // 根据分数计算权重与概率 + const weight = this.calculateWeightByScore(this.score); + let awardProbability = weight; // 默认用权重作为概率 + let guaranteed = false; + + // 分数≥500时必定触发奖励 + if (this.score >= 500) { + awardProbability = 1; + guaranteed = true; + } + + const roll = Math.random(); + if (roll > awardProbability) { + this.appendEndInfo('本局未获得萌芽币'); + return; + } + + // 生成0~10随机萌芽币数量,权重越高越偏向更大值 + let coins = this.biasedRandomInt(5, weight); + // 保底至少 1 个(仅当分数≥500时) + if (guaranteed) { + coins = Math.max(1, coins); + } + coins = Math.max(0, Math.min(10, coins)); + + if (coins <= 0) { + this.appendEndInfo('本局未获得萌芽币'); + return; + } + + // 后端 API base URL(从父窗口ENV_CONFIG获取,回退到本地默认) + const apiBase = (window.parent && window.parent.ENV_CONFIG && window.parent.ENV_CONFIG.API_URL) + ? window.parent.ENV_CONFIG.API_URL + : ((window.ENV_CONFIG && window.ENV_CONFIG.API_URL) ? window.ENV_CONFIG.API_URL : 'http://127.0.0.1:5002'); + + const resp = await fetch(`${apiBase}/api/user/add-coins`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify({ email, amount: coins }) + }); + + if (!resp.ok) { + const err = await resp.json().catch(() => ({})); + const msg = err && (err.message || err.error) ? (err.message || err.error) : `请求失败(${resp.status})`; + this.appendEndInfo(`加币失败:${msg}`, 'error'); + return; + } + + const data = await resp.json(); + if (data && data.success) { + const newCoins = data.data && data.data.new_coins; + this.appendEndInfo(`恭喜获得 ${coins} 个萌芽币!当前余额:${newCoins}`, 'success'); + } else { + const msg = (data && (data.message || data.error)) || '未知错误'; + this.appendEndInfo(`加币失败:${msg}`, 'error'); + } + } catch (e) { + console.error('加币流程发生错误:', e); + this.appendEndInfo('加币失败:网络或系统错误', 'error'); + } + } initializeGrid() { this.grid = []; @@ -315,6 +431,16 @@ class Game2048 { message.className = 'game-message game-won'; message.style.display = 'flex'; message.querySelector('p').textContent = '你赢了!'; + + // 胜利也尝试加币(异步,不阻塞UI) + this.tryAwardCoinsOnGameOver(); + + // 显示最终统计 + setTimeout(() => { + if (window.gameStats) { + window.gameStats.showFinalStats(); + } + }, 1000); } showGameOver() { @@ -323,6 +449,16 @@ class Game2048 { message.style.display = 'flex'; message.querySelector('p').textContent = '游戏结束!'; + // 渲染排行榜 + try { + this.renderLeaderboard(); + } catch (e) { + console.error('渲染排行榜时发生错误:', e); + } + + // 尝试加币(异步,不阻塞UI) + this.tryAwardCoinsOnGameOver(); + // 显示最终统计 setTimeout(() => { if (window.gameStats) { @@ -377,6 +513,92 @@ class Game2048 { }, 1000); } + // 构建并渲染排行榜 + renderLeaderboard() { + const container = document.getElementById('leaderboard'); + if (!container) return; + + // 生成当前玩家数据 + const today = this.formatDate(new Date()); + const currentPlayer = { + "名称": "我", + "账号": "guest-local", + "分数": this.score, + "时间": today, + _current: true + }; + + // 合并并排序数据(分数由高到低) + const baseData = (typeof playerdata !== 'undefined' && Array.isArray(playerdata)) ? playerdata : []; + const merged = [...baseData.map(d => ({...d})), currentPlayer] + .sort((a, b) => (b["分数"] || 0) - (a["分数"] || 0)); + + // 计算当前玩家排名 + const currentIndex = merged.findIndex(d => d._current); + const rank = currentIndex >= 0 ? currentIndex + 1 : '-'; + + // 仅展示前10条 + const topN = merged.slice(0, 10); + + // 生成 HTML + const summaryHtml = ` +
+ 本局分数:${this.score} + 用时:${this.stats.gameTime} + 你的排名:${rank} +
+ `; + + const headerHtml = ` +
+
排名
+
名称
+
分数
+
日期
+
+ `; + + const rowsHtml = topN.map((d, i) => { + const isCurrent = !!d._current; + const rowClass = `leaderboard-row${isCurrent ? ' current' : ''}`; + return ` +
+
${i + 1}
+
${this.escapeHtml(d["名称"] || '未知')}
+
${d["分数"] ?? 0}
+
${this.escapeHtml(d["时间"] || '-')}
+
+ `; + }).join(''); + + container.innerHTML = ` +
排行榜
+ ${summaryHtml} +
+ ${headerHtml} +
${rowsHtml}
+
+ `; + } + + // 工具:日期格式化 YYYY-MM-DD + formatDate(date) { + const y = date.getFullYear(); + const m = String(date.getMonth() + 1).padStart(2, '0'); + const d = String(date.getDate()).padStart(2, '0'); + return `${y}-${m}-${d}`; + } + + // 工具:简单转义以避免 XSS + escapeHtml(str) { + return String(str) + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/\"/g, '"') + .replace(/'/g, '''); + } + bindEvents() { // 重试按钮 document.getElementById('retry-btn').addEventListener('click', () => { diff --git a/InfoGenie-frontend/public/smallgame/2048/index.html b/InfoGenie-frontend/public/smallgame/2048/index.html index 41e1a707..11a8f6c0 100755 --- a/InfoGenie-frontend/public/smallgame/2048/index.html +++ b/InfoGenie-frontend/public/smallgame/2048/index.html @@ -22,6 +22,8 @@

+ +
@@ -64,6 +66,7 @@ + diff --git a/InfoGenie-frontend/public/smallgame/2048/styles.css b/InfoGenie-frontend/public/smallgame/2048/styles.css index 0fb12299..f3c76763 100755 --- a/InfoGenie-frontend/public/smallgame/2048/styles.css +++ b/InfoGenie-frontend/public/smallgame/2048/styles.css @@ -237,6 +237,91 @@ body { transition: all 0.3s ease; } +/* 排行榜样式(与 2048 主题一致) */ +.leaderboard { + width: 100%; + max-width: 440px; + background: rgba(250, 248, 239, 0.95); /* #faf8ef */ + border-radius: 12px; + padding: 12px; + box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); + color: #776e65; +} + +.leaderboard-title { + font-size: 22px; + font-weight: 700; + color: #8f7a66; + margin-bottom: 8px; + letter-spacing: 0.5px; +} + +.leaderboard-summary { + display: flex; + flex-wrap: wrap; + gap: 10px; + font-size: 14px; + color: #8f7a66; + margin-bottom: 10px; +} +.leaderboard-summary strong { + color: #8f7a66; +} + +.leaderboard-table { + border: 1px solid rgba(187, 173, 160, 0.3); /* #bbada0 */ + border-radius: 10px; + overflow: hidden; + background: rgba(238, 228, 218, 0.4); /* #eee4da */ +} + +.leaderboard-header, +.leaderboard-row { + display: grid; + grid-template-columns: 64px 1fr 90px 120px; /* 排名/名称/分数/日期 */ + align-items: center; +} + +.leaderboard-header { + background: #eee4da; + color: #776e65; + font-weight: 700; + padding: 8px 10px; + border-bottom: 1px solid rgba(187, 173, 160, 0.3); +} + +.leaderboard-body { + max-height: 220px; + overflow-y: auto; + background: rgba(238, 228, 218, 0.25); +} + +.leaderboard-row { + padding: 8px 10px; + border-top: 1px solid rgba(187, 173, 160, 0.15); +} +.leaderboard-row:nth-child(odd) { + background: rgba(238, 228, 218, 0.22); +} +.leaderboard-row.current { + background: #f3e9d4; + box-shadow: inset 0 0 0 2px rgba(143, 122, 102, 0.35); +} + +.leaderboard-col.rank { + text-align: center; + font-weight: 700; + color: #8f7a66; +} +.leaderboard-col.score { + text-align: right; + font-weight: 700; +} +.leaderboard-col.time { + text-align: right; + color: #776e65; +} + .retry-button:hover { background: #9f8a76; transform: translateY(-2px); diff --git a/InfoGenie-frontend/public/smallgame/俄罗斯方块/game-stats.js b/InfoGenie-frontend/public/smallgame/俄罗斯方块/game-stats.js index 87d9ffd0..f3bd8958 100755 --- a/InfoGenie-frontend/public/smallgame/俄罗斯方块/game-stats.js +++ b/InfoGenie-frontend/public/smallgame/俄罗斯方块/game-stats.js @@ -1,338 +1,96 @@ -// 游戏统计和成就系统 -class GameStats { - constructor() { - this.achievements = [ - { - id: 'first_game', - name: '初次体验', - description: '完成第一次游戏', - condition: (stats) => true - }, - { - id: 'score_1000', - name: '小试牛刀', - description: '单局得分达到1000分', - condition: (stats) => stats.score >= 1000 - }, - { - id: 'score_5000', - name: '游戏达人', - description: '单局得分达到5000分', - condition: (stats) => stats.score >= 5000 - }, - { - id: 'score_10000', - name: '方块大师', - description: '单局得分达到10000分', - condition: (stats) => stats.score >= 10000 - }, - { - id: 'level_5', - name: '步步高升', - description: '达到第5级', - condition: (stats) => stats.level >= 5 - }, - { - id: 'level_10', - name: '速度之王', - description: '达到第10级', - condition: (stats) => stats.level >= 10 - }, - { - id: 'lines_50', - name: '消除专家', - description: '累计消除50行', - condition: (stats) => stats.lines >= 50 - }, - { - id: 'lines_100', - name: '清理大师', - description: '累计消除100行', - condition: (stats) => stats.lines >= 100 - }, - { - id: 'tetris', - name: 'Tetris!', - description: '一次消除4行', - condition: (stats) => stats.maxCombo >= 4 - }, - { - id: 'time_10min', - name: '持久战士', - description: '单局游戏时间超过10分钟', - condition: (stats) => stats.playTime >= 600000 - }, - { - id: 'efficiency', - name: '效率专家', - description: '平均每分钟得分超过500', - condition: (stats) => stats.avgScore >= 500 - } - ]; - - this.init(); - } - - init() { - this.setupEventListeners(); - } - - setupEventListeners() { - const playAgainBtn = document.getElementById('playAgainBtn'); - playAgainBtn.addEventListener('click', () => { - this.hideStats(); - game.restart(); - }); - } - - showStats(gameData) { - const playTimeMinutes = gameData.playTime / 60000; - const avgScore = playTimeMinutes > 0 ? Math.round(gameData.score / playTimeMinutes) : 0; - - const stats = { - ...gameData, - avgScore: avgScore - }; - - // 更新统计显示 - document.getElementById('finalScore').textContent = stats.score.toLocaleString(); - document.getElementById('finalLevel').textContent = stats.level; - document.getElementById('finalLines').textContent = stats.lines; - document.getElementById('playTime').textContent = this.formatTime(stats.playTime); - document.getElementById('maxCombo').textContent = stats.maxCombo; - document.getElementById('avgScore').textContent = stats.avgScore; - - // 检查成就 - const achievement = this.checkAchievements(stats); - this.displayAchievement(achievement); - - // 显示统计界面 - document.getElementById('gameStats').style.display = 'flex'; - document.getElementById('gameStats').classList.add('fade-in'); - } - - hideStats() { - document.getElementById('gameStats').style.display = 'none'; - document.getElementById('gameStats').classList.remove('fade-in'); - } - - formatTime(milliseconds) { - const seconds = Math.floor(milliseconds / 1000); - const minutes = Math.floor(seconds / 60); - const remainingSeconds = seconds % 60; - - return `${minutes.toString().padStart(2, '0')}:${remainingSeconds.toString().padStart(2, '0')}`; - } - - checkAchievements(stats) { - // 获取已获得的成就 - const earnedAchievements = this.getEarnedAchievements(); - - // 检查新成就 - for (let achievement of this.achievements) { - if (!earnedAchievements.includes(achievement.id) && - achievement.condition(stats)) { - - // 保存新成就 - this.saveAchievement(achievement.id); - return achievement; - } - } - - return null; - } - - displayAchievement(achievement) { - const achievementEl = document.getElementById('achievement'); - - if (achievement) { - achievementEl.innerHTML = ` - 🏆 成就解锁!
- ${achievement.name}
- ${achievement.description} - `; - achievementEl.classList.add('pulse'); - } else { - // 显示随机鼓励话语 - const encouragements = [ - '继续努力,你会变得更强!', - '每一次游戏都是进步的机会!', - '方块世界需要你的智慧!', - '熟能生巧,加油!', - '下一局一定会更好!', - '坚持就是胜利!', - '你的反应速度在提升!', - '策略思维正在增强!' - ]; - - const randomEncouragement = encouragements[Math.floor(Math.random() * encouragements.length)]; - achievementEl.innerHTML = `💪 ${randomEncouragement}`; - achievementEl.classList.remove('pulse'); - } - } - - getEarnedAchievements() { - const saved = localStorage.getItem('tetris_achievements'); - return saved ? JSON.parse(saved) : []; - } - - saveAchievement(achievementId) { - const earned = this.getEarnedAchievements(); - if (!earned.includes(achievementId)) { - earned.push(achievementId); - localStorage.setItem('tetris_achievements', JSON.stringify(earned)); - } - } - - // 获取历史最佳记录 - getBestStats() { - const saved = localStorage.getItem('tetris_best_stats'); - return saved ? JSON.parse(saved) : { - score: 0, - level: 0, - lines: 0, - maxCombo: 0 - }; - } - - // 保存最佳记录 - saveBestStats(stats) { - const best = this.getBestStats(); - let updated = false; - - if (stats.score > best.score) { - best.score = stats.score; - updated = true; - } - - if (stats.level > best.level) { - best.level = stats.level; - updated = true; - } - - if (stats.lines > best.lines) { - best.lines = stats.lines; - updated = true; - } - - if (stats.maxCombo > best.maxCombo) { - best.maxCombo = stats.maxCombo; - updated = true; - } - - if (updated) { - localStorage.setItem('tetris_best_stats', JSON.stringify(best)); - } - - return updated; - } - - // 显示排行榜 - showLeaderboard() { - const best = this.getBestStats(); - const earned = this.getEarnedAchievements(); - - console.log('最佳记录:', best); - console.log('已获得成就:', earned.length + '/' + this.achievements.length); - } -} +// 游戏结束排行榜展示 +const gameStats = { + showStats({ score, playTime }) { + // 将毫秒转为 mm:ss + const formatDuration = (ms) => { + const totalSec = Math.max(0, Math.floor(ms / 1000)); + const m = String(Math.floor(totalSec / 60)).padStart(2, '0'); + const s = String(totalSec % 60).padStart(2, '0'); + return `${m}:${s}`; + }; -// 高级特效系统 -class GameEffects { - constructor(game) { - this.game = game; - this.particles = []; - this.effects = []; - - this.init(); - } - - init() { - // 创建特效canvas - this.effectsCanvas = document.createElement('canvas'); - this.effectsCanvas.width = this.game.canvas.width; - this.effectsCanvas.height = this.game.canvas.height; - this.effectsCanvas.style.position = 'absolute'; - this.effectsCanvas.style.top = '0'; - this.effectsCanvas.style.left = '0'; - this.effectsCanvas.style.pointerEvents = 'none'; - this.effectsCanvas.style.zIndex = '10'; - - this.effectsCtx = this.effectsCanvas.getContext('2d'); - - // 将特效canvas添加到游戏板容器中 - this.game.canvas.parentElement.style.position = 'relative'; - this.game.canvas.parentElement.appendChild(this.effectsCanvas); - } - - // 行消除特效 - lineCleared(row) { - for (let i = 0; i < 20; i++) { - this.particles.push({ - x: Math.random() * this.game.canvas.width, - y: row * this.game.CELL_SIZE + this.game.CELL_SIZE / 2, - vx: (Math.random() - 0.5) * 10, - vy: (Math.random() - 0.5) * 10, - life: 1, - decay: 0.02, - color: `hsl(${Math.random() * 360}, 100%, 50%)` - }); - } - } - - // 方块锁定特效 - pieceLocked(piece) { - const centerX = (piece.x + piece.matrix[0].length / 2) * this.game.CELL_SIZE; - const centerY = (piece.y + piece.matrix.length / 2) * this.game.CELL_SIZE; - - for (let i = 0; i < 10; i++) { - this.particles.push({ - x: centerX, - y: centerY, - vx: (Math.random() - 0.5) * 8, - vy: (Math.random() - 0.5) * 8, - life: 0.8, - decay: 0.03, - color: piece.color - }); - } - } - - // 更新特效 - update() { - // 更新粒子 - for (let i = this.particles.length - 1; i >= 0; i--) { - const particle = this.particles[i]; - - particle.x += particle.vx; - particle.y += particle.vy; - particle.life -= particle.decay; - - if (particle.life <= 0) { - this.particles.splice(i, 1); - } - } - } - - // 绘制特效 - draw() { - this.effectsCtx.clearRect(0, 0, this.effectsCanvas.width, this.effectsCanvas.height); - - // 绘制粒子 - for (let particle of this.particles) { - this.effectsCtx.save(); - this.effectsCtx.globalAlpha = particle.life; - this.effectsCtx.fillStyle = particle.color; - this.effectsCtx.beginPath(); - this.effectsCtx.arc(particle.x, particle.y, 3, 0, Math.PI * 2); - this.effectsCtx.fill(); - this.effectsCtx.restore(); - } - } -} + // 构造排行榜数据(模拟),将当前成绩与 gamedata.js 合并 + const todayStr = (() => { + const d = new Date(); + const y = d.getFullYear(); + const m = String(d.getMonth() + 1).padStart(2, '0'); + const day = String(d.getDate()).padStart(2, '0'); + return `${y}-${m}-${day}`; + })(); -// 创建统计系统实例 -const gameStats = new GameStats(); + // 当前玩家信息(可根据实际项目替换为真实用户) + const currentEntry = { + 名称: localStorage.getItem('tetris_player_name') || '我', + 账号: localStorage.getItem('tetris_player_account') || 'guest@local', + 分数: score, + 时间: formatDuration(playTime), // 排行榜展示“游戏时长” + isCurrent: true, + }; -// 在适当的地方创建特效系统 -// const gameEffects = new GameEffects(game); + // 注意:在浏览器中,使用 const 声明的全局变量不会挂载到 window 上 + // 因此这里直接使用 playerdata,而不是 window.playerdata + const baseData = (typeof playerdata !== 'undefined' && Array.isArray(playerdata)) ? playerdata : []; + + // 为基础数据模拟“游戏时长”(mm:ss),以满足展示需求 + const simulateDuration = (scoreVal) => { + const sec = Math.max(30, Math.min(30 * 60, Math.round((Number(scoreVal) || 0) * 1.2))); + return formatDuration(sec * 1000); + }; + + const merged = [...baseData.map((d) => ({ + ...d, + // 使用已有分数推导一个模拟时长 + 时间: simulateDuration(d.分数), + isCurrent: false, + })), currentEntry] + .sort((a, b) => (b.分数 || 0) - (a.分数 || 0)); + + // 3) 渲染排行榜(取前10) + const tbody = document.getElementById('leaderboardBody'); + tbody.innerHTML = ''; + const topN = merged.slice(0, 10); + topN.forEach((item, idx) => { + const tr = document.createElement('tr'); + if (item.isCurrent) { + tr.classList.add('current-row'); + } + const rankCell = document.createElement('td'); + const nameCell = document.createElement('td'); + const scoreCell = document.createElement('td'); + const timeCell = document.createElement('td'); + + const rankBadge = document.createElement('span'); + rankBadge.className = 'rank-badge'; + rankBadge.textContent = String(idx + 1); + rankCell.appendChild(rankBadge); + + nameCell.textContent = item.名称 || '未知'; + scoreCell.textContent = item.分数 || 0; + timeCell.textContent = item.时间 || formatDuration(playTime); + + tr.appendChild(rankCell); + tr.appendChild(nameCell); + tr.appendChild(scoreCell); + tr.appendChild(timeCell); + tbody.appendChild(tr); + }); + + // 4) 展示排行榜界面 + const statsEl = document.getElementById('gameStats'); + statsEl.style.display = 'flex'; + + // 5) 再玩一次按钮 + const playAgainBtn = document.getElementById('playAgainBtn'); + if (playAgainBtn) { + playAgainBtn.onclick = () => { + statsEl.style.display = 'none'; + if (window.game && typeof window.game.restart === 'function') { + window.game.restart(); + } + }; + } + }, +}; + +// 暴露到全局 +window.gameStats = gameStats; \ No newline at end of file diff --git a/InfoGenie-frontend/public/smallgame/俄罗斯方块/index.html b/InfoGenie-frontend/public/smallgame/俄罗斯方块/index.html index 76caa7cb..8345de3a 100755 --- a/InfoGenie-frontend/public/smallgame/俄罗斯方块/index.html +++ b/InfoGenie-frontend/public/smallgame/俄罗斯方块/index.html @@ -61,40 +61,32 @@
-

游戏结束

-
-
- 最终分数 - 0 -
-
- 达到等级 - 1 -
-
- 消除行数 - 0 -
-
- 游戏时长 - 00:00 -
-
- 单次消除最大行数 - 0 -
-
- 平均每分钟分数 - 0 +

游戏结束排行榜

+ +
+
本局排行榜
+
+ + + + + + + + + + +
排名名称分数游戏时长
+
仅显示前10名;“游戏时长”为模拟数据,已与您的成绩合并
-
+ diff --git a/InfoGenie-frontend/public/smallgame/俄罗斯方块/styles.css b/InfoGenie-frontend/public/smallgame/俄罗斯方块/styles.css index cd9ff0e4..fc09551a 100755 --- a/InfoGenie-frontend/public/smallgame/俄罗斯方块/styles.css +++ b/InfoGenie-frontend/public/smallgame/俄罗斯方块/styles.css @@ -319,6 +319,84 @@ body { box-shadow: 0 4px 8px rgba(46, 125, 50, 0.3); } +/* 排行榜样式 */ +.leaderboard { + background: linear-gradient(135deg, #e8f5e8 0%, #f1f8e9 100%); + color: #2e7d32; + border: 1px solid rgba(46, 125, 50, 0.3); + border-radius: 16px; + box-shadow: 0 6px 18px rgba(46, 125, 50, 0.25); + padding: 16px; + margin-bottom: 20px; +} + +.leaderboard-title { + font-weight: 700; + font-size: 1.2rem; + margin-bottom: 12px; + background: linear-gradient(135deg, #4caf50 0%, #8bc34a 50%, #cddc39 100%); + -webkit-background-clip: text; + -webkit-text-fill-color: transparent; + background-clip: text; +} + +.leaderboard-wrap { + max-height: 260px; + overflow: auto; + border-radius: 12px; +} + +.leaderboard-table { + width: 100%; + border-collapse: collapse; +} + +.leaderboard-table thead tr { + background: linear-gradient(135deg, #66bb6a 0%, #8bc34a 100%); + color: #fff; +} + +.leaderboard-table th, +.leaderboard-table td { + text-align: left; + padding: 10px 12px; + border-bottom: 1px solid rgba(46, 125, 50, 0.15); + font-size: 0.95rem; +} + +.leaderboard-table tbody tr { + background: linear-gradient(135deg, rgba(46,125,50,0.08) 0%, rgba(46,125,50,0.03) 100%); + transition: background 0.2s ease, transform 0.2s ease; +} + +.leaderboard-table tbody tr:hover { + background: linear-gradient(135deg, rgba(46,125,50,0.12) 0%, rgba(46,125,50,0.06) 100%); + transform: translateY(-1px); +} + +.rank-badge { + display: inline-block; + min-width: 32px; + text-align: center; + padding: 4px 8px; + border-radius: 12px; + background: linear-gradient(45deg, #66bb6a, #8bc34a); + color: #fff; + font-weight: 700; +} + +.current-row { + outline: 2px solid rgba(76, 175, 80, 0.7); + box-shadow: 0 0 0 4px rgba(76, 175, 80, 0.15) inset; +} + +.leaderboard-tip { + margin-top: 10px; + font-size: 0.85rem; + color: #388e3c; + opacity: 0.85; +} + /* 响应式设计 */ @media (max-width: 768px) { .game-container { @@ -378,6 +456,15 @@ body { padding: 20px; width: 95%; } + + .leaderboard-wrap { + max-height: 200px; + } + .leaderboard-table th, + .leaderboard-table td { + padding: 8px 10px; + font-size: 0.9rem; + } } @media (max-width: 480px) { @@ -449,3 +536,39 @@ body { .pulse { animation: pulse 2s infinite; } +/* 摘要卡片 */ +.leaderboard-summary { + display: grid; + grid-template-columns: repeat(3, 1fr); + gap: 12px; + margin-bottom: 16px; +} + +.summary-item { + background: linear-gradient(135deg, #2e7d32 0%, #388e3c 100%); + color: #fff; + padding: 12px; + border-radius: 10px; + border: 1px solid rgba(46, 125, 50, 0.3); + box-shadow: 0 4px 8px rgba(46, 125, 50, 0.2); +} + +.summary-label { + display: block; + font-size: 0.9rem; + opacity: 0.9; +} + +.summary-value { + display: block; + font-size: 1.3rem; + font-weight: 700; + margin-top: 4px; +} + +@media (max-width: 768px) { + .leaderboard-summary { + grid-template-columns: 1fr; + gap: 10px; + } +} diff --git a/InfoGenie-frontend/public/smallgame/别踩白方块/game.js b/InfoGenie-frontend/public/smallgame/别踩白方块/game.js index b8e1adff..2326862f 100755 --- a/InfoGenie-frontend/public/smallgame/别踩白方块/game.js +++ b/InfoGenie-frontend/public/smallgame/别踩白方块/game.js @@ -84,6 +84,8 @@ function gameOver(){ // 显示最终得分和达到的最高速度 document.getElementById('final-score-value').innerHTML = myScore; document.getElementById('final-speed-value').innerHTML = gameSpeed.toFixed(1); + // 渲染排行榜 + renderLeaderboard(); // 显示游戏结束弹窗 document.getElementById('game-over-modal').style.display = 'flex'; @@ -250,6 +252,78 @@ function handleClick(e) { checkHit(x, y); } + +// ===== 排行榜逻辑 ===== +function formatDateYYYYMMDD() { + var d = new Date(); + var y = d.getFullYear(); + var m = String(d.getMonth() + 1).padStart(2, '0'); + var day = String(d.getDate()).padStart(2, '0'); + return y + '-' + m + '-' + day; +} + +function escapeHtml(str) { + if (typeof str !== 'string') return str; + return str + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); +} + +function renderLeaderboard(){ + var nowStr = formatDateYYYYMMDD(); + // 当前玩家数据(模拟) + var me = { + "名称": "我", + "账号": "guest", + "分数": myScore, + "时间": nowStr, + "__isMe": true + }; + + // 合并现有数据与当前玩家 + var data = (typeof playerdata !== 'undefined' && Array.isArray(playerdata)) + ? playerdata.slice() : []; + data.push(me); + + // 按分数降序排序 + data.sort(function(a, b){ + return (b["分数"] || 0) - (a["分数"] || 0); + }); + + var tbody = document.getElementById('leaderboard-body'); + if (!tbody) return; + tbody.innerHTML = ''; + + var myRank = -1; + for (var i = 0; i < data.length; i++){ + var row = data[i]; + var tr = document.createElement('tr'); + if (row.__isMe){ + myRank = i + 1; + tr.className = 'leaderboard-row-me'; + } + + tr.innerHTML = + '' + (i + 1) + '' + + '' + escapeHtml(row["名称"] || '') + '' + + '' + (row["分数"] || 0) + '' + + '' + escapeHtml(row["时间"] || '') + ''; + + // 只展示前10名 + if (i < 10) tbody.appendChild(tr); + } + + // 更新我的数据摘要 + var rankEl = document.getElementById('my-rank'); + var scoreEl = document.getElementById('my-score'); + var timeEl = document.getElementById('my-time'); + if (rankEl) rankEl.textContent = myRank > 0 ? myRank : '-'; + if (scoreEl) scoreEl.textContent = myScore; + if (timeEl) timeEl.textContent = nowStr; +} // 处理触摸事件 function handleTouch(e) { diff --git a/InfoGenie-frontend/public/smallgame/别踩白方块/index.html b/InfoGenie-frontend/public/smallgame/别踩白方块/index.html index 494c1b37..4d42635c 100755 --- a/InfoGenie-frontend/public/smallgame/别踩白方块/index.html +++ b/InfoGenie-frontend/public/smallgame/别踩白方块/index.html @@ -182,6 +182,56 @@ background: linear-gradient(45deg, #4caf50, #388e3c); box-shadow: 0 6px 16px rgba(76,175,80,0.4); } + /* 排行榜样式 */ + .leaderboard { + margin-top: 15px; + background: rgba(255,255,255,0.6); + border: 1px solid rgba(129,199,132,0.3); + border-radius: 10px; + overflow: hidden; + } + .leaderboard-title { + background: linear-gradient(45deg, #66bb6a, #4caf50); + color: white; + font-weight: bold; + font-size: 16px; + padding: 8px 12px; + text-align: left; + box-shadow: inset 0 -1px 0 rgba(255,255,255,0.2); + } + .leaderboard-meta { + color: #2e7d32; + font-size: 13px; + padding: 8px 12px; + border-bottom: 1px solid rgba(129,199,132,0.2); + display: flex; + justify-content: space-between; + gap: 8px; + flex-wrap: wrap; + } + .leaderboard-table { + width: 100%; + border-collapse: collapse; + } + .leaderboard-table th, .leaderboard-table td { + padding: 8px 6px; + font-size: 13px; + border-bottom: 1px solid rgba(129,199,132,0.2); + color: #1b5e20; + text-align: center; + } + .leaderboard-table th { + background: rgba(129,199,132,0.2); + font-weight: bold; + color: #1b5e20; + } + .leaderboard-row-me { + background: rgba(198,40,40,0.08); + border-left: 3px solid #c62828; + } + .leaderboard-table tr:nth-child(even) { + background: rgba(129,199,132,0.1); + } /* 移动端适配 */ @media (max-width: 768px) { @@ -253,11 +303,32 @@
最终得分: 0
最高速度: 1.0x
+ +
+
排行榜
+
+ 我的排名:第 - + 我的分数:0 + 时间:-- +
+ + + + + + + + + + +
排名名称分数时间
+
+ \ No newline at end of file diff --git a/InfoGenie-frontend/public/smallgame/打飞机/game.js b/InfoGenie-frontend/public/smallgame/打飞机/game.js new file mode 100644 index 00000000..58981296 --- /dev/null +++ b/InfoGenie-frontend/public/smallgame/打飞机/game.js @@ -0,0 +1,309 @@ +const canvas = document.getElementById('game'); +const ctx = canvas.getContext('2d'); +const scoreEl = document.getElementById('scoreVal'); +const pauseBtn = document.getElementById('pauseBtn'); +const restartBtn = document.getElementById('restartBtn'); +const startOverlay = document.getElementById('startOverlay'); +const startBtn = document.getElementById('startBtn'); +const overOverlay = document.getElementById('overOverlay'); +const againBtn = document.getElementById('againBtn'); +const finalScoreEl = document.getElementById('finalScore'); + +let width = 0, height = 0; +let running = false, paused = false, gameOver = false; +let player, bullets = [], enemies = [], particles = []; +let score = 0, elapsed = 0, spawnTimer = 0, fireTimer = 0; + +function fitCanvas(){ + const w = canvas.clientWidth | 0; + const h = canvas.clientHeight | 0; + if (canvas.width !== w || canvas.height !== h){ + canvas.width = w; + canvas.height = h; + } + width = canvas.width; height = canvas.height; +} + +function clamp(v,min,max){ return v < min ? min : (v > max ? max : v); } +function rand(min,max){ return Math.random()*(max-min)+min; } + +function initGame(){ + fitCanvas(); + score = 0; + elapsed = 0; + spawnTimer = 0; + fireTimer = 0; + bullets.length = 0; + enemies.length = 0; + particles.length = 0; + gameOver = false; + paused = false; + player = { + x: width/2, + y: height*0.82, + r: Math.max(14, Math.min(width,height)*0.02), + speed: Math.max(350, Math.min(width,height)*0.9), + alive: true + }; + scoreEl.textContent = '0'; + pauseBtn.textContent = '暂停'; +} + +function startGame(){ + running = true; + startOverlay.classList.add('hide'); + overOverlay.classList.add('hide'); + initGame(); + requestAnimationFrame(loop); +} + +function restartGame(){ + startOverlay.classList.add('hide'); + startGame(); +} + +pauseBtn.addEventListener('click', ()=>{ + if (!running) return; + paused = !paused; + pauseBtn.textContent = paused ? '继续' : '暂停'; +}); +restartBtn.addEventListener('click', ()=>{ initGame(); }); +startBtn.addEventListener('click', startGame); +againBtn.addEventListener('click', ()=>{ startOverlay.classList.add('hide'); startGame(); }); +window.addEventListener('resize', fitCanvas); + +let pointerActive = false; +canvas.addEventListener('pointerdown', (e)=>{ + pointerActive = true; + if (!running) startGame(); + movePlayer(e); + canvas.setPointerCapture && canvas.setPointerCapture(e.pointerId); +}); +canvas.addEventListener('pointermove', (e)=>{ if (pointerActive) movePlayer(e); }); +canvas.addEventListener('pointerup', ()=>{ pointerActive = false; }); + +function movePlayer(e){ + const rect = canvas.getBoundingClientRect(); + const x = (e.clientX - rect.left); + const y = (e.clientY - rect.top); + const minY = height * 0.45; + player.x = clamp(x, player.r, width - player.r); + player.y = clamp(y, minY, height - player.r); +} + +function spawnEnemy(){ + const d = Math.min(6, 1 + elapsed/10); + let r, x, speed, hp, color, type; + const roll = Math.random(); + + if (roll < 0.5 - Math.min(0.2, elapsed*0.02)) { // 普通 + type = 'normal'; + r = rand(12, 18 + d*1.8); + x = rand(r, width - r); + speed = rand(60 + d*20, 110 + d*30); + hp = 1; color = 'rgba(70,160,80,0.9)'; + enemies.push({x, y: -r, r, speed, hp, color, type}); + } else if (roll < 0.75) { // 快速 + type = 'fast'; + r = rand(10, 14 + d); + x = rand(r, width - r); + speed = rand(130 + d*35, 220 + d*40); + hp = 1; color = 'rgba(120,200,90,0.95)'; + enemies.push({x, y: -r, r, speed, hp, color, type}); + } else if (roll < 0.92) { // 之字形 + type = 'zigzag'; + r = rand(12, 18 + d*1.5); + x = rand(r, width - r); + speed = rand(90 + d*20, 140 + d*25); + hp = 1; color = 'rgba(90,180,110,0.95)'; + const vxAmp = rand(40, 80); + const freq = rand(2, 4); + const phase = rand(0, Math.PI*2); + enemies.push({x, y: -r, r, speed, hp, color, type, vxAmp, freq, phase}); + } else if (roll < 0.98) { // 坦克型(耐久) + type = 'tough'; + r = rand(20, 26 + d); + x = rand(r, width - r); + speed = rand(60, 100 + d*10); + hp = 3; color = 'rgba(50,140,70,0.9)'; + enemies.push({x, y: -r, r, speed, hp, color, type}); + } else { // 分裂型 + type = 'splitter'; + r = rand(22, 28 + d); + x = rand(r, width - r); + speed = rand(70 + d*15, 100 + d*20); + hp = 2; color = 'rgba(80,170,90,0.95)'; + enemies.push({x, y: -r, r, speed, hp, color, type}); + } +} + +function spawnChildren(parent){ + const count = 2; + for (let k=0; k=0; i--){ + const b = bullets[i]; + b.y += b.vy * dt; + if (b.y + b.r < 0){ bullets.splice(i,1); } + } + // enemies + const speedBoost = Math.min(2.2, 1 + elapsed*0.015); + for (let i=enemies.length-1; i>=0; i--){ + const e = enemies[i]; + // 不同类型的移动方式 + if (e.type === 'zigzag'){ + e.y += e.speed * speedBoost * dt; + e.phase += (e.freq || 3) * dt; + e.x += Math.sin(e.phase) * (e.vxAmp || 60) * dt; + e.x = clamp(e.x, e.r, width - e.r); + } else if (e.type === 'mini'){ + e.y += e.speed * speedBoost * dt; + e.x += (e.vx || 0) * dt; + e.x = clamp(e.x, e.r, width - e.r); + } else { + e.y += e.speed * speedBoost * dt; + } + // 与玩家碰撞 + const dx = e.x - player.x, dy = e.y - player.y; + const rr = e.r + player.r; + if (dx*dx + dy*dy < rr*rr){ endGame(); break; } + if (e.y - e.r > height){ enemies.splice(i,1); } + } + // bullet-enemy collisions + for (let i=enemies.length-1; i>=0; i--){ + const e = enemies[i]; + for (let j=bullets.length-1; j>=0; j--){ + const b = bullets[j]; + const dx = e.x - b.x, dy = e.y - b.y; + const rr = e.r + b.r; + if (dx*dx + dy*dy <= rr*rr){ + bullets.splice(j,1); + e.hp -= 1; + addBurst(e.x, e.y, e.r); + if (e.hp <= 0){ + if (e.type === 'splitter'){ spawnChildren(e); } + enemies.splice(i,1); + score += (e.type === 'tough' ? 2 : 1); + scoreEl.textContent = score; + } + break; + } + } + } + // particles + for (let i=particles.length-1; i>=0; i--){ + const p = particles[i]; + p.x += p.vx * dt; p.y += p.vy * dt; p.life -= dt; + if (p.life <= 0) particles.splice(i,1); + } +} + +function addBurst(x,y,r){ + for (let i=0; i<6; i++){ + const a = Math.random() * Math.PI * 2; + const speed = rand(40, 140); + particles.push({ x, y, vx: Math.cos(a)*speed, vy: Math.sin(a)*speed, life: rand(0.15, 0.4) }); + } +} + +function draw(){ + fitCanvas(); + ctx.clearRect(0,0,width,height); + // soft overlay for depth + const grd = ctx.createLinearGradient(0,0,0,height); + grd.addColorStop(0, 'rgba(255,255,255,0.0)'); + grd.addColorStop(1, 'rgba(255,255,255,0.05)'); + ctx.fillStyle = grd; ctx.fillRect(0,0,width,height); + + // player + drawPlayer(); + // bullets + ctx.fillStyle = 'rgba(80,180,90,0.9)'; + for (let i=0; i + + + + + + + 打飞机 · 清新休闲 + + + +
+
打飞机
+
得分:0
+
+ + +
+
+ +
+ + +
+
+

打飞机

+

轻触屏幕开始,无尽模式。

+

操作:手指拖动战机移动。

+ +
+
+ +
+
+

游戏结束

+

本次得分:0

+ +
+
+
+ + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/smallgame/打飞机/style.css b/InfoGenie-frontend/public/smallgame/打飞机/style.css new file mode 100644 index 00000000..03a479b0 --- /dev/null +++ b/InfoGenie-frontend/public/smallgame/打飞机/style.css @@ -0,0 +1,65 @@ +:root { + --header-h: 56px; + --bg-start: #d7f6d2; + --bg-end: #ecf7c8; + --accent: #6bb86f; + --accent2: #a5d67e; + --text: #274b2f; +} + +* { box-sizing: border-box; } +html, body { height: 100%; } +body { + margin: 0; + height: 100dvh; + width: 100vw; + color: var(--text); + background: linear-gradient(180deg, var(--bg-start), var(--bg-end)); + font-family: system-ui, -apple-system, Segoe UI, Roboto, "Noto Sans SC", Arial, sans-serif; + -webkit-tap-highlight-color: transparent; +} + +.topbar { + position: fixed; top:0; left:0; right:0; height: var(--header-h); + display: flex; align-items: center; justify-content: space-between; + padding: 0 12px; + background: rgba(255,255,255,0.35); + border-bottom: 1px solid rgba(0,0,0,0.06); + backdrop-filter: saturate(120%) blur(10px); +} +.brand { font-weight: 700; letter-spacing: .5px; } +.score { font-weight: 600; } +.actions button { + background: var(--accent2); border: none; color: #1e3c27; + border-radius: 999px; padding: 6px 12px; margin-left: 8px; + font-weight: 600; box-shadow: 0 2px 6px rgba(0,0,0,0.08); +} +.actions button:active { transform: translateY(1px); } + +.game-wrap { position: absolute; inset: var(--header-h) 0 0 0; } +#game { + width: 100vw; height: calc(100dvh - var(--header-h)); + display: block; touch-action: none; cursor: crosshair; +} + +.overlay { + position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; + background: rgba(240, 250, 236, 0.6); + backdrop-filter: blur(6px); +} +.overlay.hide { display: none; } +.panel { + background: rgba(255,255,255,0.75); + border: 1px solid rgba(0,0,0,0.05); + border-radius: 16px; padding: 16px; + width: min(420px, 92vw); text-align: center; + box-shadow: 0 10px 30px rgba(0,0,0,0.06); +} +.panel h1, .panel h2 { margin: 6px 0 8px; } +.panel p { margin: 4px 0; } +.panel button { + background: var(--accent); color: #fff; border: none; + border-radius: 12px; padding: 10px 16px; font-size: 16px; margin-top: 8px; + box-shadow: 0 3px 10px rgba(0,0,0,0.1); +} +.panel button:active { transform: translateY(1px); } \ No newline at end of file diff --git a/InfoGenie-frontend/public/smallgame/贪吃蛇/game-core.js b/InfoGenie-frontend/public/smallgame/贪吃蛇/game-core.js index faad209c..2b2f31e0 100755 --- a/InfoGenie-frontend/public/smallgame/贪吃蛇/game-core.js +++ b/InfoGenie-frontend/public/smallgame/贪吃蛇/game-core.js @@ -35,6 +35,114 @@ class SnakeGame { this.init(); } + + // 根据分数计算权重(权重越高,越容易触发且数量偏大) + calculateWeightByScore(score) { + const w = score / 100; // 1000分趋近高权重 + return Math.max(0.1, Math.min(0.95, w)); + } + + // 权重偏向的随机整数,weight越大越偏向更大值 + biasedRandomInt(maxInclusive, weight) { + const r = Math.random(); + const biased = Math.pow(r, 1 - weight); + const val = Math.floor(biased * (maxInclusive + 1)); + return Math.max(0, Math.min(maxInclusive, val)); + } + + // 在排行榜弹层追加结束信息 + appendEndInfo(text, type = 'info') { + const summary = document.getElementById('leaderboardSummary'); + if (!summary) return; + const info = document.createElement('div'); + info.style.marginTop = '8px'; + info.style.fontSize = '14px'; + info.style.color = type === 'error' ? '#d9534f' : (type === 'success' ? '#28a745' : '#333'); + info.textContent = text; + summary.appendChild(info); + } + + // 游戏结束后尝试加“萌芽币” + async tryAwardCoinsOnGameOver() { + try { + const token = localStorage.getItem('token'); + if (!token) { + this.appendEndInfo('未登录,无法获得萌芽币'); + return; + } + + let email = null; + try { + const userStr = localStorage.getItem('user'); + if (userStr) { + const userObj = JSON.parse(userStr); + email = userObj && (userObj.email || userObj['邮箱']); + } + } catch (_) {} + + if (!email) { + this.appendEndInfo('未找到账户信息(email),无法加币', 'error'); + return; + } + + const weight = this.calculateWeightByScore(this.score); + let coins = 0; + let guaranteed = false; + + // 得分大于400必定触发获得1-5个萌芽币 + if (this.score > 5) { + guaranteed = true; + coins = Math.floor(Math.random() * 5) + 1; // 1~5 + } else { + // 使用权重作为概率 + const roll = Math.random(); + if (roll > weight) { + this.appendEndInfo('本局未获得萌芽币'); + return; + } + // 生成0~10随机数量(权重越高越偏向更大) + coins = this.biasedRandomInt(10, weight); + coins = Math.max(0, Math.min(10, coins)); + if (coins <= 0) { + this.appendEndInfo('本局未获得萌芽币'); + return; + } + } + + // 后端 API base(优先父窗口ENV_CONFIG) + const apiBase = (window.parent && window.parent.ENV_CONFIG && window.parent.ENV_CONFIG.API_URL) + ? window.parent.ENV_CONFIG.API_URL + : ((window.ENV_CONFIG && window.ENV_CONFIG.API_URL) ? window.ENV_CONFIG.API_URL : 'http://127.0.0.1:5002'); + + const resp = await fetch(`${apiBase}/api/user/add-coins`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${token}` + }, + body: JSON.stringify({ email, amount: coins }) + }); + + if (!resp.ok) { + const err = await resp.json().catch(() => ({})); + const msg = err && (err.message || err.error) ? (err.message || err.error) : `请求失败(${resp.status})`; + this.appendEndInfo(`加币失败:${msg}`, 'error'); + return; + } + + const data = await resp.json(); + if (data && data.success) { + const newCoins = data.data && data.data.new_coins; + this.appendEndInfo(`恭喜获得 ${coins} 个萌芽币!当前余额:${newCoins}`, 'success'); + } else { + const msg = (data && (data.message || data.error)) || '未知错误'; + this.appendEndInfo(`加币失败:${msg}`, 'error'); + } + } catch (e) { + console.error('加币流程发生错误:', e); + this.appendEndInfo('加币失败:网络或系统错误', 'error'); + } + } init() { this.generateFood(); @@ -310,10 +418,94 @@ class SnakeGame { this.dy = dy; } + // 工具:格式化日期为 YYYY-MM-DD + formatDate(date = new Date()) { + const y = date.getFullYear(); + const m = String(date.getMonth() + 1).padStart(2, '0'); + const d = String(date.getDate()).padStart(2, '0'); + return `${y}-${m}-${d}`; + } + showGameOver() { - // 游戏结束时只记录最终状态,不显示弹窗 + // 构建并展示排行榜弹层 const gameTime = Math.floor((Date.now() - this.startTime) / 1000); - console.log(`游戏结束! 分数: ${this.score}, 长度: ${this.snake.length}, 等级: ${this.level}, 时间: ${gameTime}秒`); + const overlay = document.getElementById('leaderboardOverlay'); + const listEl = document.getElementById('leaderboardList'); + const lbScore = document.getElementById('lbScore'); + const lbLength = document.getElementById('lbLength'); + const lbLevel = document.getElementById('lbLevel'); + const lbGameTime = document.getElementById('lbGameTime'); + const lbRank = document.getElementById('lbRank'); + + if (!overlay || !listEl) { + console.warn('排行榜容器不存在'); + return; + } + + // 汇总当前玩家数据 + lbScore.textContent = this.score; + lbLength.textContent = this.snake.length; + lbLevel.textContent = this.level; + lbGameTime.textContent = `${gameTime}秒`; + + const currentEntry = { + "名称": localStorage.getItem('snakePlayerName') || '我', + "账号": localStorage.getItem('snakePlayerAccount') || 'guest@local', + "分数": this.score, + "时间": this.formatDate(new Date()), + __isCurrent: true, + __duration: gameTime + }; + + // 合并并排序数据(使用 gamedata.js 中的 playerdata) + const baseData = (typeof playerdata !== 'undefined' && Array.isArray(playerdata)) ? playerdata : []; + const merged = [...baseData, currentEntry]; + merged.sort((a, b) => (b["分数"] || 0) - (a["分数"] || 0)); + const playerIndex = merged.findIndex(e => e.__isCurrent); + lbRank.textContent = playerIndex >= 0 ? `#${playerIndex + 1}` : '—'; + + // 生成排行榜(TOP 10) + const topList = merged.slice(0, 10).map((entry, idx) => { + const isCurrent = !!entry.__isCurrent; + const name = entry["名称"] ?? '未知玩家'; + const score = entry["分数"] ?? 0; + const dateStr = entry["时间"] ?? ''; + const timeStr = isCurrent ? `时长:${entry.__duration}秒` : `时间:${dateStr}`; + return ` +
+ #${idx + 1} + ${name} + ${score}分 + ${timeStr} +
+ `; + }).join(''); + listEl.innerHTML = topList; + + overlay.style.display = 'flex'; + // 结束时尝试加币(异步,不阻塞UI) + this.tryAwardCoinsOnGameOver(); + + // 触发游戏结束事件(供统计模块使用) + const gameOverEvent = new CustomEvent('gameOver', { + detail: { + score: this.score, + length: this.snake.length, + level: this.level, + gameTime: gameTime, + foodEaten: this.foodEaten + } + }); + document.dispatchEvent(gameOverEvent); + + // 绑定重新开始按钮 + const restartBtn = document.getElementById('leaderboardRestartBtn'); + if (restartBtn) { + restartBtn.onclick = () => { + overlay.style.display = 'none'; + this.restart(); + }; + } } @@ -334,6 +526,10 @@ class SnakeGame { this.foodEaten = 0; this.specialFood = null; + // 隐藏排行榜弹层(若可见) + const overlay = document.getElementById('leaderboardOverlay'); + if (overlay) overlay.style.display = 'none'; + this.generateFood(); this.updateUI(); diff --git a/InfoGenie-frontend/public/smallgame/贪吃蛇/game-stats.js b/InfoGenie-frontend/public/smallgame/贪吃蛇/game-stats.js index 2df9484d..7842b2a3 100755 --- a/InfoGenie-frontend/public/smallgame/贪吃蛇/game-stats.js +++ b/InfoGenie-frontend/public/smallgame/贪吃蛇/game-stats.js @@ -86,9 +86,6 @@ class GameStatistics { // 保存到本地存储 localStorage.setItem('snakeHighScores', JSON.stringify(this.highScores)); - - // 显示高分榜 - this.displayHighScores(); } displaySessionStats() { @@ -175,31 +172,7 @@ class GameStatistics { } } -// 扩展游戏核心类,添加统计事件触发 -SnakeGame.prototype.showGameOver = function() { - const modal = document.getElementById('gameOverModal'); - const gameTime = Math.floor((Date.now() - this.startTime) / 1000); - - document.getElementById('finalScore').textContent = this.score; - document.getElementById('finalLength').textContent = this.snake.length; - document.getElementById('finalLevel').textContent = this.level; - document.getElementById('gameTime').textContent = gameTime; - document.getElementById('foodEaten').textContent = this.foodEaten; - - // 触发游戏结束事件 - const gameOverEvent = new CustomEvent('gameOver', { - detail: { - score: this.score, - length: this.snake.length, - level: this.level, - gameTime: gameTime, - foodEaten: this.foodEaten - } - }); - document.dispatchEvent(gameOverEvent); - - modal.style.display = 'flex'; -}; +// 原游戏结束界面已移除,保留统计模块以便响应 'gameOver' 事件 // 初始化统计模块 let gameStats; diff --git a/InfoGenie-frontend/public/smallgame/贪吃蛇/gamedata.js b/InfoGenie-frontend/public/smallgame/贪吃蛇/gamedata.js index a00d422c..e96f2c4f 100644 --- a/InfoGenie-frontend/public/smallgame/贪吃蛇/gamedata.js +++ b/InfoGenie-frontend/public/smallgame/贪吃蛇/gamedata.js @@ -5,18 +5,6 @@ const playerdata = [ "分数":1568, "时间":"2025-09-08" }, - { - "名称":"柚大青", - "账号":"2143323382@qq.com", - "分数":245, - "时间":"2025-09-21" - }, - { - "名称":"牛马", - "账号":"2973419538@qq.com", - "分数":1123, - "时间":"2025-09-25" - }, { "名称":"风行者", "账号":"4456723190@qq.com", diff --git a/InfoGenie-frontend/public/smallgame/贪吃蛇/index.html b/InfoGenie-frontend/public/smallgame/贪吃蛇/index.html index 4b1f20a0..ef50d739 100755 --- a/InfoGenie-frontend/public/smallgame/贪吃蛇/index.html +++ b/InfoGenie-frontend/public/smallgame/贪吃蛇/index.html @@ -27,12 +27,32 @@
-
-

使用方向键或拖动手势控制蛇的方向

+ +
+ + + - diff --git a/InfoGenie-frontend/public/smallgame/贪吃蛇/styles.css b/InfoGenie-frontend/public/smallgame/贪吃蛇/styles.css index 217e45a3..fd975ee3 100755 --- a/InfoGenie-frontend/public/smallgame/贪吃蛇/styles.css +++ b/InfoGenie-frontend/public/smallgame/贪吃蛇/styles.css @@ -184,6 +184,20 @@ body { border: 1px solid rgba(46, 125, 50, 0.2); } +.leaderboard-summary { + margin: 10px 0 15px; + padding: 10px 12px; + background: rgba(255, 255, 255, 0.5); + border-radius: 12px; + color: #1b5e20; + text-align: center; + border: 1px solid rgba(46, 125, 50, 0.2); +} + +.leaderboard-summary p { + margin: 6px 0; +} + .leaderboard h3 { color: #1b5e20; margin-bottom: 15px; @@ -234,6 +248,13 @@ body { text-align: right; } +.leaderboard-item .player-time { + color: #4a5568; + font-size: 0.8rem; + min-width: 80px; + text-align: right; +} + /* 手机端优化 */ @media (max-width: 768px) { .game-container { diff --git a/InfoGenie-frontend/public/smallgame/跑酷/game.js b/InfoGenie-frontend/public/smallgame/跑酷/game.js new file mode 100644 index 00000000..67769ea8 --- /dev/null +++ b/InfoGenie-frontend/public/smallgame/跑酷/game.js @@ -0,0 +1,314 @@ +// 清新跑酷 - Endless Runner (Mobile Portrait, Touch-friendly) +(() => { + const canvas = document.getElementById('gameCanvas'); + const ctx = canvas.getContext('2d'); + const scoreEl = document.getElementById('score'); + const restartBtn = document.getElementById('restartBtn'); + const overlay = document.getElementById('overlay'); + const overlayRestart = document.getElementById('overlayRestart'); + const finalScoreEl = document.getElementById('finalScore'); + + let dpr = Math.max(1, Math.floor(window.devicePixelRatio || 1)); + let running = true; + let gameOver = false; + let lastTime = performance.now(); + let elapsed = 0; // seconds + let score = 0; + + const world = { + width: 360, + height: 640, + groundH: 90, // 地面高度(CSS像素) + baseSpeed: 240, // 初始速度(px/s) + speed: 240, // 当前速度(随难度提升) + gravity: 1800, // 重力(px/s^2) + jumpV: -864, // 跳跃初速度(px/s) + }; + + const player = { + x: 72, + y: 0, // 通过 resetPlayer 设置 + w: 44, + h: 54, + vy: 0, + grounded: false, + color: '#2f7d5f' + }; + + const obstacles = []; + const coins = []; + let obstacleTimer = 0; // ms 到下一个障碍 + let coinTimer = 0; // ms 到下一个道具 + + function clamp(v, a, b) { return Math.max(a, Math.min(b, v)); } + function rand(min, max) { return Math.random() * (max - min) + min; } + + function resizeCanvas() { + dpr = Math.max(1, Math.floor(window.devicePixelRatio || 1)); + const cssWidth = Math.min(480, document.documentElement.clientWidth); + const cssHeight = document.documentElement.clientHeight; + + canvas.style.width = cssWidth + 'px'; + canvas.style.height = cssHeight + 'px'; + canvas.width = Math.floor(cssWidth * dpr); + canvas.height = Math.floor(cssHeight * dpr); + ctx.setTransform(dpr, 0, 0, dpr, 0, 0); // 使用CSS像素绘制 + + world.width = cssWidth; + world.height = cssHeight; + world.groundH = Math.max(64, Math.floor(world.height * 0.14)); + + resetPlayer(); + } + + function resetPlayer() { + player.y = world.height - world.groundH - player.h; + player.vy = 0; + player.grounded = true; + } + + function spawnObstacle() { + const w = rand(28, 56); + const h = rand(40, clamp(world.height * 0.28, 80, 140)); + const y = world.height - world.groundH - h; + obstacles.push({ x: world.width + w, y, w, h, color: '#3ea573' }); + + // 以一定概率在障碍上方生成一个金币 + if (Math.random() < 0.6) { + const cx = world.width + w + rand(10, 40); + const cy = y - rand(28, 56); + coins.push({ x: cx, y: cy, r: 10, color: '#f6c453' }); + } + } + + function spawnCoin() { + const r = 10; + const yTop = world.height * 0.35; // 道具浮在中上区域 + const y = rand(yTop, world.height - world.groundH - 80); + coins.push({ x: world.width + 60, y, r, color: '#f6c453' }); + } + + function rectsOverlap(ax, ay, aw, ah, bx, by, bw, bh) { + return ax < bx + bw && ax + aw > bx && ay < by + bh && ay + ah > by; + } + + function circleRectOverlap(cx, cy, r, rx, ry, rw, rh) { + const closestX = clamp(cx, rx, rx + rw); + const closestY = clamp(cy, ry, ry + rh); + const dx = cx - closestX; + const dy = cy - closestY; + return (dx * dx + dy * dy) <= r * r; + } + + function jump() { + if (gameOver) return; + if (player.grounded) { + player.vy = world.jumpV; + player.grounded = false; + } + } + + function update(dt) { + // 难度递增:速度随时间上涨,生成间隔缩短 + elapsed += dt; + world.speed = world.baseSpeed + elapsed * 22; // 每秒加速 + + obstacleTimer -= dt * 1000; + coinTimer -= dt * 1000; + + const minInterval = clamp(1400 - elapsed * 20, 700, 1600); // 障碍间隔(更远) + const coinInterval = clamp(1200 - elapsed * 25, 500, 1200); // 金币间隔 + + if (obstacleTimer <= 0) { + spawnObstacle(); + obstacleTimer = rand(minInterval, minInterval * 1.35); + } + if (coinTimer <= 0) { + spawnCoin(); + coinTimer = rand(coinInterval * 0.6, coinInterval); + } + + // 玩家物理 + player.vy += world.gravity * dt; + player.y += player.vy * dt; + const groundY = world.height - world.groundH - player.h; + if (player.y >= groundY) { + player.y = groundY; + player.vy = 0; + player.grounded = true; + } + + // 移动障碍与金币 + const dx = world.speed * dt; + for (let i = obstacles.length - 1; i >= 0; i--) { + const ob = obstacles[i]; + ob.x -= dx; + if (ob.x + ob.w < 0) obstacles.splice(i, 1); + } + for (let i = coins.length - 1; i >= 0; i--) { + const c = coins[i]; + c.x -= dx; + if (c.x + c.r < 0) coins.splice(i, 1); + } + + // 碰撞检测:障碍 + for (const ob of obstacles) { + if (rectsOverlap(player.x, player.y, player.w, player.h, ob.x, ob.y, ob.w, ob.h)) { + endGame(); + return; + } + } + + // 拾取金币 + for (let i = coins.length - 1; i >= 0; i--) { + const c = coins[i]; + if (circleRectOverlap(c.x, c.y, c.r, player.x, player.y, player.w, player.h)) { + score += 100; // 金币加分 + coins.splice(i, 1); + } + } + + // 距离积分(随速度) + score += Math.floor(world.speed * dt * 0.2); + scoreEl.textContent = String(score); + } + + function drawGround() { + const y = world.height - world.groundH; + // 地面阴影渐变 + const grad = ctx.createLinearGradient(0, y, 0, world.height); + grad.addColorStop(0, 'rgba(60, 150, 110, 0.35)'); + grad.addColorStop(1, 'rgba(60, 150, 110, 0.05)'); + ctx.fillStyle = grad; + ctx.fillRect(0, y, world.width, world.groundH); + + // 地面纹理线 + ctx.strokeStyle = 'rgba(47, 79, 63, 0.25)'; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(0, y); + ctx.lineTo(world.width, y); + ctx.stroke(); + } + + function drawPlayer() { + ctx.fillStyle = player.color; + const r = 8; // 圆角 + const x = player.x, y = player.y, w = player.w, h = player.h; + ctx.beginPath(); + ctx.moveTo(x + r, y); + ctx.arcTo(x + w, y, x + w, y + h, r); + ctx.arcTo(x + w, y + h, x, y + h, r); + ctx.arcTo(x, y + h, x, y, r); + ctx.arcTo(x, y, x + w, y, r); + ctx.closePath(); + ctx.fill(); + + // 前进指示条 + ctx.fillStyle = 'rgba(255, 255, 255, 0.5)'; + ctx.fillRect(x + 6, y + 10, 6, 12); + ctx.fillRect(x + 18, y + 10, 6, 12); + } + + function drawObstacles() { + for (const ob of obstacles) { + // 渐变柱体 + const g = ctx.createLinearGradient(ob.x, ob.y, ob.x, ob.y + ob.h); + g.addColorStop(0, '#52b985'); + g.addColorStop(1, '#3ea573'); + ctx.fillStyle = g; + ctx.fillRect(ob.x, ob.y, ob.w, ob.h); + // 顶部高亮 + ctx.fillStyle = 'rgba(255,255,255,0.35)'; + ctx.fillRect(ob.x, ob.y, ob.w, 4); + } + } + + function drawCoins() { + for (const c of coins) { + ctx.beginPath(); + ctx.arc(c.x, c.y, c.r, 0, Math.PI * 2); + ctx.fillStyle = c.color; + ctx.fill(); + // 外圈高光 + ctx.strokeStyle = 'rgba(255,255,255,0.6)'; + ctx.lineWidth = 2; + ctx.stroke(); + } + } + + function draw(now) { + // 清屏(CSS负责背景渐变,这里仅清理) + ctx.clearRect(0, 0, world.width, world.height); + + drawGround(); + drawPlayer(); + drawObstacles(); + drawCoins(); + + // 速度指示(右上角小提示) + ctx.fillStyle = 'rgba(47,79,63,0.35)'; + ctx.font = '12px system-ui'; + ctx.textAlign = 'right'; + ctx.fillText(`速度 ${Math.round(world.speed)}px/s`, world.width - 8, 18); + } + + function endGame() { + running = false; + gameOver = true; + finalScoreEl.textContent = String(score); + overlay.hidden = false; + } + + function resetGame() { + running = true; + gameOver = false; + obstacles.length = 0; + coins.length = 0; + obstacleTimer = 0; + coinTimer = rand(400, 900); + score = 0; + elapsed = 0; + resetPlayer(); + overlay.hidden = true; + lastTime = performance.now(); + } + + function loop(now) { + const dt = Math.min(0.033, (now - lastTime) / 1000); // 限制最大步长 + lastTime = now; + + if (running) { + update(dt); + draw(now); + } + requestAnimationFrame(loop); + } + + // 输入事件 + function onKey(e) { + if (e.code === 'Space' || e.code === 'ArrowUp') { + e.preventDefault(); + jump(); + } + } + function onPointer() { jump(); } + + restartBtn.addEventListener('click', () => { + resetGame(); + }); + overlayRestart.addEventListener('click', () => { + resetGame(); + }); + + window.addEventListener('keydown', onKey, { passive: false }); + window.addEventListener('mousedown', onPointer); + window.addEventListener('touchstart', onPointer, { passive: true }); + window.addEventListener('resize', () => { + resizeCanvas(); + }); + + // 初始化并启动 + resizeCanvas(); + requestAnimationFrame(loop); +})(); \ No newline at end of file diff --git a/InfoGenie-frontend/public/smallgame/跑酷/index.html b/InfoGenie-frontend/public/smallgame/跑酷/index.html new file mode 100644 index 00000000..b4bc2386 --- /dev/null +++ b/InfoGenie-frontend/public/smallgame/跑酷/index.html @@ -0,0 +1,33 @@ + + + + + + 清新跑酷 - InfoGenie + + + + +
+
+
分数 0
+ +
+ +
+ +
轻触屏幕或按空格跳跃
+ + +
+
+ + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/smallgame/跑酷/style.css b/InfoGenie-frontend/public/smallgame/跑酷/style.css new file mode 100644 index 00000000..f95fe023 --- /dev/null +++ b/InfoGenie-frontend/public/smallgame/跑酷/style.css @@ -0,0 +1,130 @@ +/* 清新淡绿色渐变风格与移动端适配 */ +:root { + --green-1: #a8e6cf; /* 淡绿色 */ + --green-2: #dcedc1; /* 淡黄绿色 */ + --accent: #58c48b; /* 按钮主色 */ + --accent-dark: #3ca16c; + --text: #2f4f3f; /* 深绿文字 */ + --card: #ffffffd9; /* 半透明卡片 */ +} +* { box-sizing: border-box; } +html, body { height: 100%; } +body { + margin: 0; + font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Microsoft Yahei", sans-serif; + color: var(--text); + background: linear-gradient(180deg, var(--green-1) 0%, var(--green-2) 100%); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +.game-shell { + min-height: 100vh; + display: flex; + flex-direction: column; +} + +.hud { + position: sticky; + top: 0; + width: 100%; + display: flex; + align-items: center; + justify-content: space-between; + padding: 10px 14px; + background: color-mix(in oklab, var(--green-2) 65%, white 35%); + backdrop-filter: saturate(1.4) blur(6px); + box-shadow: 0 2px 10px rgb(0 0 0 / 6%); +} +.score { + font-weight: 700; + font-size: 18px; + letter-spacing: 0.5px; +} + +.restart { + appearance: none; + border: none; + outline: none; + background: var(--accent); + color: #fff; + font-weight: 600; + font-size: 14px; + padding: 8px 12px; + border-radius: 999px; + box-shadow: 0 4px 12px rgb(88 196 139 / 30%); + transition: transform .05s ease, background .2s ease; +} +.restart:active { transform: scale(0.98); } +.restart:hover { background: var(--accent-dark); } + +.stage { + position: relative; + flex: 1; + width: 100%; + display: flex; + align-items: center; + justify-content: center; +} +canvas { + width: 100%; + height: 100%; + display: block; +} + +.hint { + position: absolute; + bottom: max(10px, env(safe-area-inset-bottom)); + left: 0; + right: 0; + text-align: center; + font-size: 12px; + color: color-mix(in oklab, var(--text), white 35%); + opacity: 0.85; + pointer-events: none; +} + +.overlay { + position: absolute; + inset: 0; + display: flex; + align-items: center; + justify-content: center; + background: rgb(0 0 0 / 10%); +} +.overlay[hidden] { display: none; } + +.overlay-card { + width: min(88vw, 420px); + background: var(--card); + border-radius: 16px; + box-shadow: 0 10px 30px rgb(0 0 0 / 15%); + padding: 18px 18px 16px; + text-align: center; +} +.gameover-title { + font-size: 20px; + font-weight: 800; +} +.summary { + margin: 12px 0 16px; + font-size: 16px; +} +.overlay-restart { + appearance: none; + border: none; + outline: none; + background: var(--accent); + color: #fff; + font-weight: 700; + font-size: 16px; + padding: 10px 16px; + border-radius: 12px; + box-shadow: 0 6px 16px rgb(88 196 139 / 38%); +} +.overlay-restart:active { transform: scale(0.98); } +.overlay-restart:hover { background: var(--accent-dark); } + +@media (prefers-reduced-motion: reduce) { + .restart, .overlay-restart { transition: none; } +} \ No newline at end of file diff --git a/InfoGenie-frontend/public/smallgame/躲树叶/index.html b/InfoGenie-frontend/public/smallgame/躲树叶/index.html new file mode 100644 index 00000000..74ae8e42 --- /dev/null +++ b/InfoGenie-frontend/public/smallgame/躲树叶/index.html @@ -0,0 +1,39 @@ + + + + + + 清新躲避 · 无尽模式 + + + + +
+
分数 0
+ +
+ + + + + + + +
请将手机竖屏以获得最佳体验
+ + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/smallgame/躲树叶/script.js b/InfoGenie-frontend/public/smallgame/躲树叶/script.js new file mode 100644 index 00000000..0e4e4c20 --- /dev/null +++ b/InfoGenie-frontend/public/smallgame/躲树叶/script.js @@ -0,0 +1,261 @@ +(() => { + const canvas = document.getElementById('game'); + const ctx = canvas.getContext('2d'); + const hudScoreEl = document.getElementById('score'); + const pauseBtn = document.getElementById('pauseBtn'); + const startOverlay = document.getElementById('startOverlay'); + const startBtn = document.getElementById('startBtn'); + const gameOverOverlay = document.getElementById('gameOverOverlay'); + const finalScoreEl = document.getElementById('finalScore'); + const restartBtn = document.getElementById('restartBtn'); + const rotateOverlay = document.getElementById('rotateOverlay'); + + let width = 0, height = 0, DPR = 1; + let running = false, paused = false; + let lastTime = 0, timeElapsed = 0, score = 0, spawnTimer = 0; + + const player = { x: 0, y: 0, r: 18, vx: 0, targetX: null }; + const obstacles = []; + let pointerActive = false; + + function clamp(v, min, max){ return Math.max(min, Math.min(max, v)); } + function rand(min, max){ return Math.random()*(max-min)+min; } + + function updateOrientationOverlay(){ + const landscape = window.innerWidth > window.innerHeight; + rotateOverlay.style.display = landscape ? 'flex' : 'none'; + } + + function resize(){ + updateOrientationOverlay(); + DPR = Math.min(2, window.devicePixelRatio || 1); + width = window.innerWidth; + height = window.innerHeight; + canvas.width = Math.floor(width * DPR); + canvas.height = Math.floor(height * DPR); + ctx.setTransform(DPR, 0, 0, DPR, 0, 0); + if (!running){ + player.x = width * 0.5; + player.y = height - Math.max(80, height * 0.12); + } else { + player.y = height - Math.max(80, height * 0.12); + player.x = clamp(player.x, player.r + 8, width - player.r - 8); + } + } + window.addEventListener('resize', resize); + resize(); + + function drawBackground(){ + // 轻微的顶部高光,让画面更通透 + const g = ctx.createLinearGradient(0,0,0,height); + g.addColorStop(0,'rgba(255,255,255,0.10)'); + g.addColorStop(1,'rgba(255,255,255,0.00)'); + ctx.fillStyle = g; + ctx.fillRect(0,0,width,height); + } + + function drawPlayer(){ + ctx.save(); + ctx.translate(player.x, player.y); + const r = player.r; + const grad = ctx.createRadialGradient(-r*0.3, -r*0.3, r*0.2, 0, 0, r); + grad.addColorStop(0, '#5fca7e'); + grad.addColorStop(1, '#3a9e5a'); + ctx.fillStyle = grad; + // 圆形带小叶柄的简化“叶子”角色 + ctx.beginPath(); + ctx.arc(0,0,r,0,Math.PI*2); + ctx.fill(); + ctx.strokeStyle = 'rgba(58,158,90,0.7)'; + ctx.lineWidth = 2; + ctx.beginPath(); + ctx.moveTo(0, -r*0.9); + ctx.quadraticCurveTo(r*0.2, -r*1.3, r*0.5, -r*1.0); + ctx.stroke(); + ctx.restore(); + } + + function spawnObstacle(){ + const difficulty = 1 + timeElapsed * 0.08; // 随时间慢慢提升 + const r = rand(10, 22); + const x = rand(r+8, width - r - 8); + const speed = rand(90, 140) * (0.9 + difficulty * 0.5); + const rot = rand(-Math.PI*0.5, Math.PI*0.5); + obstacles.push({ x, y: -r - 20, r, speed, rot, swayPhase: Math.random()*Math.PI*2, swayAmp: rand(6,12) }); + } + + function drawObstacle(o){ + ctx.save(); + ctx.translate(o.x, o.y); + ctx.rotate(o.rot); + const r = o.r; + ctx.beginPath(); + ctx.ellipse(0, 0, r*0.9, r*0.6, 0, 0, Math.PI*2); + const grad = ctx.createLinearGradient(-r, -r, r, r); + grad.addColorStop(0, '#d8f7c2'); + grad.addColorStop(0.5, '#b9ef9f'); + grad.addColorStop(1, '#9edf77'); + ctx.fillStyle = grad; + ctx.fill(); + ctx.strokeStyle = 'rgba(90,150,90,0.5)'; + ctx.lineWidth = 1.5; + ctx.beginPath(); + ctx.moveTo(-r*0.5, 0); + ctx.quadraticCurveTo(0, -r*0.3, r*0.5, 0); + ctx.stroke(); + ctx.restore(); + } + + function update(dt){ + const difficulty = 1 + timeElapsed * 0.08; + const spawnInterval = Math.max(0.12, 0.9 / difficulty); + spawnTimer -= dt; + if (spawnTimer <= 0){ + spawnObstacle(); + spawnTimer = spawnInterval; + } + + // 障碍移动 + 轻微左右摆动 + for (let i = 0; i < obstacles.length; i++){ + const o = obstacles[i]; + o.y += o.speed * dt; + o.x += Math.sin(o.swayPhase + timeElapsed * 1.6) * (o.swayAmp * dt); + } + + // 清除离开屏幕的障碍 + for (let i = obstacles.length - 1; i >= 0; i--){ + const o = obstacles[i]; + if (o.y > height + o.r + 60){ + obstacles.splice(i, 1); + } + } + + // 键盘轻推(桌面端备用) + if (player.targetX != null){ + const dir = player.targetX - player.x; + player.vx = clamp(dir, -500, 500); + player.x += player.vx * dt; + if (Math.abs(dir) < 2){ + player.targetX = null; + player.vx = 0; + } + } + + // 限制玩家范围 + player.x = clamp(player.x, player.r + 8, width - player.r - 8); + + // 碰撞检测(近似圆形) + for (const o of obstacles){ + const dx = o.x - player.x; + const dy = o.y - player.y; + const dist = Math.hypot(dx, dy); + if (dist < player.r + o.r * 0.65){ + endGame(); + return; + } + } + + // 计分:按生存时间累计 + score += dt * 10; // 每秒约10分 + hudScoreEl.textContent = Math.floor(score); + } + + function render(){ + ctx.clearRect(0,0,width,height); + drawBackground(); + for (const o of obstacles) drawObstacle(o); + drawPlayer(); + } + + function loop(t){ + if (!running){ return; } + if (paused){ + lastTime = t; + requestAnimationFrame(loop); + return; + } + if (!lastTime) lastTime = t; + const dt = Math.min(0.033, (t - lastTime)/1000); + lastTime = t; + timeElapsed += dt; + update(dt); + render(); + requestAnimationFrame(loop); + } + + function startGame(){ + obstacles.length = 0; + score = 0; + timeElapsed = 0; + spawnTimer = 0; + running = true; + paused = false; + lastTime = 0; + startOverlay.classList.remove('show'); + gameOverOverlay.classList.remove('show'); + resize(); + requestAnimationFrame(loop); + } + + function endGame(){ + running = false; + paused = false; + finalScoreEl.textContent = Math.floor(score); + gameOverOverlay.classList.add('show'); + } + + function pointerToCanvasX(e){ + const rect = canvas.getBoundingClientRect(); + return clamp(e.clientX - rect.left, 0, rect.width); + } + + // 触控与指针事件:按住并左右拖动 + canvas.addEventListener('pointerdown', e => { + pointerActive = true; + player.targetX = null; + player.x = pointerToCanvasX(e); + }); + canvas.addEventListener('pointermove', e => { + if (!pointerActive) return; + player.x = pointerToCanvasX(e); + }); + canvas.addEventListener('pointerup', () => { pointerActive = false; }); + canvas.addEventListener('pointercancel', () => { pointerActive = false; }); + + // 轻点屏幕:向左/右轻推一段距离 + canvas.addEventListener('click', e => { + const x = pointerToCanvasX(e); + const center = width / 2; + const dir = x < center ? -1 : 1; + player.targetX = clamp(player.x + dir * Math.max(50, width * 0.12), player.r + 8, width - player.r - 8); + }); + + // 键盘备用控制(桌面端) + window.addEventListener('keydown', e => { + if (e.key === 'ArrowLeft' || e.key === 'a'){ + player.targetX = clamp(player.x - Math.max(50, width * 0.12), player.r + 8, width - player.r - 8); + } else if (e.key === 'ArrowRight' || e.key === 'd'){ + player.targetX = clamp(player.x + Math.max(50, width * 0.12), player.r + 8, width - player.r - 8); + } else if (e.key === ' ') { + togglePause(); + } else if (e.key === 'Enter' && !running){ + startGame(); + } + }); + + // 按钮 + pauseBtn.addEventListener('click', togglePause); + startBtn.addEventListener('click', startGame); + restartBtn.addEventListener('click', startGame); + + function togglePause(){ + if (!running) return; + paused = !paused; + pauseBtn.textContent = paused ? '▶' : 'Ⅱ'; + } + + // 避免滚动与系统手势干扰 + ['touchstart','touchmove','touchend'].forEach(type => { + window.addEventListener(type, e => { if (pointerActive) e.preventDefault(); }, { passive: false }); + }); +})(); \ No newline at end of file diff --git a/InfoGenie-frontend/public/smallgame/躲树叶/style.css b/InfoGenie-frontend/public/smallgame/躲树叶/style.css new file mode 100644 index 00000000..44e7122b --- /dev/null +++ b/InfoGenie-frontend/public/smallgame/躲树叶/style.css @@ -0,0 +1,106 @@ +/* 主题色:淡绿色到淡黄绿色的清新渐变 */ +:root { + --bg-start: #dff9d3; + --bg-mid: #eaffd1; + --bg-end: #e9fbb5; + --accent: #4fb66d; + --accent-dark: #3a9e5a; + --text: #2f4f3f; + --hud-bg: rgba(255, 255, 255, 0.65); + --overlay-bg: rgba(255, 255, 255, 0.55); +} + +* { box-sizing: border-box; } +html, body { height: 100%; } +body { + margin: 0; + font-family: system-ui, -apple-system, Segoe UI, Roboto, Noto Sans, PingFang SC, Microsoft YaHei, sans-serif; + color: var(--text); + background: linear-gradient(180deg, var(--bg-start), var(--bg-mid), var(--bg-end)); + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + touch-action: none; +} + +/* 顶部HUD */ +#hud { + position: fixed; + top: env(safe-area-inset-top, 12px); + left: env(safe-area-inset-left, 12px); + right: env(safe-area-inset-right, 12px); + display: flex; + align-items: center; + justify-content: space-between; + gap: 12px; + padding: 12px 14px; + margin: 8px; + border-radius: 14px; + background: var(--hud-bg); + backdrop-filter: blur(8px); + box-shadow: 0 6px 16px rgba(0,0,0,0.08); +} +#hud .score { font-weight: 600; letter-spacing: 0.5px; } + +/* 画布填充屏幕,适配竖屏 */ +#game { + position: fixed; + inset: 0; + width: 100vw; + height: 100vh; + display: block; + touch-action: none; + -webkit-tap-highlight-color: transparent; +} + +/* 通用按钮样式 */ +.btn { + appearance: none; + border: none; + outline: none; + padding: 8px 12px; + border-radius: 12px; + color: #fff; + background: linear-gradient(180deg, var(--accent), var(--accent-dark)); + box-shadow: 0 6px 14px rgba(79,182,109,0.35); + cursor: pointer; +} +.btn:active { transform: translateY(1px); } +.btn.primary { font-weight: 600; } + +/* 覆盖层样式 */ +.overlay { + position: fixed; + inset: 0; + display: none; + align-items: center; + justify-content: center; + padding: 24px; +} +.overlay.show { display: flex; } + +.card { + width: min(520px, 92vw); + padding: 20px 18px; + border-radius: 16px; + background: var(--overlay-bg); + backdrop-filter: blur(8px); + box-shadow: 0 10px 22px rgba(0,0,0,0.12); + text-align: center; +} +.card h1, .card h2 { margin: 8px 0 12px; } +.card p { margin: 6px 0 12px; } + +/* 横屏提示覆盖层 */ +#rotateOverlay { + position: fixed; + inset: 0; + display: none; + align-items: center; + justify-content: center; + text-align: center; + padding: 24px; + font-weight: 600; + color: var(--accent-dark); + background: rgba(255,255,255,0.6); + backdrop-filter: blur(6px); +} \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/AI聊天/index.html b/InfoGenie-frontend/public/toolbox/AI聊天/index.html new file mode 100644 index 00000000..ea2daf66 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/AI聊天/index.html @@ -0,0 +1,42 @@ + + + + + + AI 聊天 + + + +
+ +
+

AI 聊天

+
+ + +
+
+
+
+ +
+
+ + +
+
+ + + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/AI聊天/marked.min.js b/InfoGenie-frontend/public/toolbox/AI聊天/marked.min.js new file mode 100644 index 00000000..b4e0d73b --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/AI聊天/marked.min.js @@ -0,0 +1,69 @@ +/** + * marked v15.0.12 - a markdown parser + * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed) + * https://github.com/markedjs/marked + */ + +/** + * DO NOT EDIT THIS FILE + * The code in this file is generated from files in ./src/ + */ +(function(g,f){if(typeof exports=="object"&&typeof module<"u"){module.exports=f()}else if("function"==typeof define && define.amd){define("marked",f)}else {g["marked"]=f()}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports}; +"use strict";var H=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var ye=(l,e)=>{for(var t in e)H(l,t,{get:e[t],enumerable:!0})},Re=(l,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Te(e))!we.call(l,s)&&s!==t&&H(l,s,{get:()=>e[s],enumerable:!(n=be(e,s))||n.enumerable});return l};var Se=l=>Re(H({},"__esModule",{value:!0}),l);var kt={};ye(kt,{Hooks:()=>L,Lexer:()=>x,Marked:()=>E,Parser:()=>b,Renderer:()=>$,TextRenderer:()=>_,Tokenizer:()=>S,defaults:()=>w,getDefaults:()=>z,lexer:()=>ht,marked:()=>k,options:()=>it,parse:()=>pt,parseInline:()=>ct,parser:()=>ut,setOptions:()=>ot,use:()=>lt,walkTokens:()=>at});module.exports=Se(kt);function z(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var w=z();function N(l){w=l}var I={exec:()=>null};function h(l,e=""){let t=typeof l=="string"?l:l.source,n={replace:(s,i)=>{let r=typeof i=="string"?i:i.source;return r=r.replace(m.caret,"$1"),t=t.replace(s,r),n},getRegex:()=>new RegExp(t,e)};return n}var m={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^/i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:l=>new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}#`),htmlBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}<(?:[a-z].*>|!--)`,"i")},$e=/^(?:[ \t]*(?:\n|$))+/,_e=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Le=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,O=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ze=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,F=/(?:[*+-]|\d{1,9}[.)])/,ie=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oe=h(ie).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Me=h(ie).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Q=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Pe=/^[^\n]+/,U=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ae=h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",U).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ee=h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,F).getRegex(),v="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",K=/|$))/,Ce=h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",K).replace("tag",v).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),le=h(Q).replace("hr",O).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),Ie=h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",le).getRegex(),X={blockquote:Ie,code:_e,def:Ae,fences:Le,heading:ze,hr:O,html:Ce,lheading:oe,list:Ee,newline:$e,paragraph:le,table:I,text:Pe},re=h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",O).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),Oe={...X,lheading:Me,table:re,paragraph:h(Q).replace("hr",O).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",re).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex()},Be={...X,html:h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",K).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:I,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:h(Q).replace("hr",O).replace("heading",` *#{1,6} *[^ +]`).replace("lheading",oe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},qe=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ve=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ae=/^( {2,}|\\)\n(?!\s*$)/,De=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\]*?>/g,ue=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,je=h(ue,"u").replace(/punct/g,D).getRegex(),Fe=h(ue,"u").replace(/punct/g,pe).getRegex(),he="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Qe=h(he,"gu").replace(/notPunctSpace/g,ce).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ue=h(he,"gu").replace(/notPunctSpace/g,He).replace(/punctSpace/g,Ge).replace(/punct/g,pe).getRegex(),Ke=h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ce).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Xe=h(/\\(punct)/,"gu").replace(/punct/g,D).getRegex(),We=h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Je=h(K).replace("(?:-->|$)","-->").getRegex(),Ve=h("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",Je).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Ye=h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ke=h(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",U).getRegex(),ge=h(/^!?\[(ref)\](?:\[\])?/).replace("ref",U).getRegex(),et=h("reflink|nolink(?!\\()","g").replace("reflink",ke).replace("nolink",ge).getRegex(),J={_backpedal:I,anyPunctuation:Xe,autolink:We,blockSkip:Ne,br:ae,code:ve,del:I,emStrongLDelim:je,emStrongRDelimAst:Qe,emStrongRDelimUnd:Ke,escape:qe,link:Ye,nolink:ge,punctuation:Ze,reflink:ke,reflinkSearch:et,tag:Ve,text:De,url:I},tt={...J,link:h(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},j={...J,emStrongRDelimAst:Ue,emStrongLDelim:Fe,url:h(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":">",'"':""","'":"'"},fe=l=>st[l];function R(l,e){if(e){if(m.escapeTest.test(l))return l.replace(m.escapeReplace,fe)}else if(m.escapeTestNoEncode.test(l))return l.replace(m.escapeReplaceNoEncode,fe);return l}function V(l){try{l=encodeURI(l).replace(m.percentDecode,"%")}catch{return null}return l}function Y(l,e){let t=l.replace(m.findPipe,(i,r,o)=>{let a=!1,c=r;for(;--c>=0&&o[c]==="\\";)a=!a;return a?"|":" |"}),n=t.split(m.splitPipe),s=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length0?-2:-1}function me(l,e,t,n,s){let i=e.href,r=e.title||null,o=l[1].replace(s.other.outputLinkReplace,"$1");n.state.inLink=!0;let a={type:l[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:r,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=!1,a}function rt(l,e,t){let n=l.match(t.other.indentCodeCompensation);if(n===null)return e;let s=n[1];return e.split(` +`).map(i=>{let r=i.match(t.other.beginningSpace);if(r===null)return i;let[o]=r;return o.length>=s.length?i.slice(s.length):i}).join(` +`)}var S=class{options;rules;lexer;constructor(e){this.options=e||w}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:A(n,` +`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=rt(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=A(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:A(t[0],` +`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=A(t[0],` +`).split(` +`),s="",i="",r=[];for(;n.length>0;){let o=!1,a=[],c;for(c=0;c1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let r=this.rules.other.listItemRegex(n),o=!1;for(;e;){let c=!1,p="",u="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let d=t[2].split(` +`,1)[0].replace(this.rules.other.listReplaceTabs,Z=>" ".repeat(3*Z.length)),g=e.split(` +`,1)[0],T=!d.trim(),f=0;if(this.options.pedantic?(f=2,u=d.trimStart()):T?f=t[1].length+1:(f=t[2].search(this.rules.other.nonSpaceChar),f=f>4?1:f,u=d.slice(f),f+=t[1].length),T&&this.rules.other.blankLine.test(g)&&(p+=g+` +`,e=e.substring(g.length+1),c=!0),!c){let Z=this.rules.other.nextBulletRegex(f),te=this.rules.other.hrRegex(f),ne=this.rules.other.fencesBeginRegex(f),se=this.rules.other.headingBeginRegex(f),xe=this.rules.other.htmlBeginRegex(f);for(;e;){let G=e.split(` +`,1)[0],C;if(g=G,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),C=g):C=g.replace(this.rules.other.tabCharGlobal," "),ne.test(g)||se.test(g)||xe.test(g)||Z.test(g)||te.test(g))break;if(C.search(this.rules.other.nonSpaceChar)>=f||!g.trim())u+=` +`+C.slice(f);else{if(T||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ne.test(d)||se.test(d)||te.test(d))break;u+=` +`+g}!T&&!g.trim()&&(T=!0),p+=G+` +`,e=e.substring(G.length+1),d=C.slice(f)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(o=!0));let y=null,ee;this.options.gfm&&(y=this.rules.other.listIsTask.exec(u),y&&(ee=y[0]!=="[ ] ",u=u.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:p,task:!!y,checked:ee,loose:!1,text:u,tokens:[]}),i.raw+=p}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let c=0;cd.type==="space"),u=p.length>0&&p.some(d=>this.rules.other.anyLine.test(d.raw));i.loose=u}if(i.loose)for(let c=0;c({text:a,tokens:this.lexer.inline(a),header:!1,align:r.align[c]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===` +`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let r=A(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{let r=de(t[2],"()");if(r===-2)return;if(r>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let r=this.rules.other.pedanticHrefTitle.exec(s);r&&(s=r[1],i=r[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),me(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return me(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let r=[...s[0]].length-1,o,a,c=r,p=0,u=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+r);(s=u.exec(t))!=null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(a=[...o].length,s[3]||s[4]){c+=a;continue}else if((s[5]||s[6])&&r%3&&!((r+a)%3)){p+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+p);let d=[...s[0]][0].length,g=e.slice(0,r+s.index+d+a);if(Math.min(r,a)%2){let f=g.slice(1,-1);return{type:"em",raw:g,text:f,tokens:this.lexer.inlineTokens(f)}}let T=g.slice(2,-2);return{type:"strong",raw:g,text:T,tokens:this.lexer.inlineTokens(T)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}};var x=class l{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||w,this.options.tokenizer=this.options.tokenizer||new S,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:m,block:B.normal,inline:P.normal};this.options.pedantic?(t.block=B.pedantic,t.inline=P.pedantic):this.options.gfm&&(t.block=B.gfm,this.options.breaks?t.inline=P.breaks:t.inline=P.gfm),this.tokenizer.rules=t}static get rules(){return{block:B,inline:P}}static lex(e,t){return new l(t).lex(e)}static lexInline(e,t){return new l(t).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,` +`),this.blockTokens(e,this.tokens);for(let t=0;t(s=r.call({lexer:this},e,t))?(e=e.substring(s.raw.length),t.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let r=t.at(-1);s.raw.length===1&&r!==void 0?r.raw+=` +`:t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=` +`+s.raw,r.text+=` +`+s.text,this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=` +`+s.raw,r.text+=` +`+s.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let i=e;if(this.options.extensions?.startBlock){let r=1/0,o=e.slice(1),a;this.options.extensions.startBlock.forEach(c=>{a=c.call({lexer:this},o),typeof a=="number"&&a>=0&&(r=Math.min(r,a))}),r<1/0&&r>=0&&(i=e.substring(0,r+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){let r=t.at(-1);n&&r?.type==="paragraph"?(r.raw+=` +`+s.raw,r.text+=` +`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s),n=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="text"?(r.raw+=` +`+s.raw,r.text+=` +`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(e){let r="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(r);break}else throw new Error(r)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,s=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)o.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,s.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(s=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,r="";for(;e;){i||(r=""),i=!1;let o;if(this.options.extensions?.inline?.some(c=>(o=c.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let c=t.at(-1);o.type==="text"&&c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,r)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let c=1/0,p=e.slice(1),u;this.options.extensions.startInline.forEach(d=>{u=d.call({lexer:this},p),typeof u=="number"&&u>=0&&(c=Math.min(c,u))}),c<1/0&&c>=0&&(a=e.substring(0,c+1))}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(r=o.raw.slice(-1)),i=!0;let c=t.at(-1);c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):t.push(o);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return t}};var $=class{options;parser;constructor(e){this.options=e||w}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(m.notSpaceStart)?.[0],i=e.replace(m.endingNewline,"")+` +`;return s?'
'+(n?i:R(i,!0))+`
+`:"
"+(n?i:R(i,!0))+`
+`}blockquote({tokens:e}){return`
+${this.parser.parse(e)}
+`}html({text:e}){return e}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)} +`}hr(e){return`
+`}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o +`+s+" +`}listitem(e){let t="";if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type==="paragraph"?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=n+" "+R(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):t+=n+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`
  • ${t}
  • +`}checkbox({checked:e}){return"'}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    +`}table(e){let t="",n="";for(let i=0;i${s}`),` + +`+t+` +`+s+`
    +`}tablerow({text:e}){return` +${e} +`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+` +`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${R(e,!0)}`}br(e){return"
    "}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=V(e);if(i===null)return s;e=i;let r='
    ",r}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=V(e);if(i===null)return R(n);e=i;let r=`${n}{let o=i[r].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let r=t.renderers[i.name];r?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=r.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=t[i.level];r?r.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new $(this.defaults);for(let r in n.renderer){if(!(r in i))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let o=r,a=n.renderer[o],c=i[o];i[o]=(...p)=>{let u=a.apply(i,p);return u===!1&&(u=c.apply(i,p)),u||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new S(this.defaults);for(let r in n.tokenizer){if(!(r in i))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let o=r,a=n.tokenizer[o],c=i[o];i[o]=(...p)=>{let u=a.apply(i,p);return u===!1&&(u=c.apply(i,p)),u}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new L;for(let r in n.hooks){if(!(r in i))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let o=r,a=n.hooks[o],c=i[o];L.passThroughHooks.has(r)?i[o]=p=>{if(this.defaults.async)return Promise.resolve(a.call(i,p)).then(d=>c.call(i,d));let u=a.call(i,p);return c.call(i,u)}:i[o]=(...p)=>{let u=a.apply(i,p);return u===!1&&(u=c.apply(i,p)),u}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,r=n.walkTokens;s.walkTokens=function(o){let a=[];return a.push(r.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return x.lex(e,t??this.defaults)}parser(e,t){return b.parse(e,t??this.defaults)}parseMarkdown(e){return(n,s)=>{let i={...s},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));r.hooks&&(r.hooks.options=r,r.hooks.block=e);let a=r.hooks?r.hooks.provideLexer():e?x.lex:x.lexInline,c=r.hooks?r.hooks.provideParser():e?b.parse:b.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(p=>a(p,r)).then(p=>r.hooks?r.hooks.processAllTokens(p):p).then(p=>r.walkTokens?Promise.all(this.walkTokens(p,r.walkTokens)).then(()=>p):p).then(p=>c(p,r)).then(p=>r.hooks?r.hooks.postprocess(p):p).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));let p=a(n,r);r.hooks&&(p=r.hooks.processAllTokens(p)),r.walkTokens&&this.walkTokens(p,r.walkTokens);let u=c(p,r);return r.hooks&&(u=r.hooks.postprocess(u)),u}catch(p){return o(p)}}}onError(e,t){return n=>{if(n.message+=` +Please report this to https://github.com/markedjs/marked.`,e){let s="

    An error occurred:

    "+R(n.message+"",!0)+"
    ";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}};var M=new E;function k(l,e){return M.parse(l,e)}k.options=k.setOptions=function(l){return M.setOptions(l),k.defaults=M.defaults,N(k.defaults),k};k.getDefaults=z;k.defaults=w;k.use=function(...l){return M.use(...l),k.defaults=M.defaults,N(k.defaults),k};k.walkTokens=function(l,e){return M.walkTokens(l,e)};k.parseInline=M.parseInline;k.Parser=b;k.parser=b.parse;k.Renderer=$;k.TextRenderer=_;k.Lexer=x;k.lexer=x.lex;k.Tokenizer=S;k.Hooks=L;k.parse=k;var it=k.options,ot=k.setOptions,lt=k.use,at=k.walkTokens,ct=k.parseInline,pt=k,ut=b.parse,ht=x.lex; + +if(__exports != exports)module.exports = exports;return module.exports})); diff --git a/InfoGenie-frontend/public/toolbox/AI聊天/purify.min.js b/InfoGenie-frontend/public/toolbox/AI聊天/purify.min.js new file mode 100644 index 00000000..7a4da768 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/AI聊天/purify.min.js @@ -0,0 +1,3 @@ +/*! @license DOMPurify 3.0.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.6/LICENSE */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:o,getOwnPropertyDescriptor:r}=Object;let{freeze:i,seal:a,create:l}=Object,{apply:c,construct:s}="undefined"!=typeof Reflect&&Reflect;i||(i=function(e){return e}),a||(a=function(e){return e}),c||(c=function(e,t,n){return e.apply(t,n)}),s||(s=function(e,t){return new e(...t)});const u=N(Array.prototype.forEach),m=N(Array.prototype.pop),f=N(Array.prototype.push),p=N(String.prototype.toLowerCase),d=N(String.prototype.toString),h=N(String.prototype.match),g=N(String.prototype.replace),T=N(String.prototype.indexOf),y=N(String.prototype.trim),E=N(RegExp.prototype.test),A=(_=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n1?n-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:p;t&&t(e,null);let i=o.length;for(;i--;){let t=o[i];if("string"==typeof t){const e=r(t);e!==t&&(n(o)||(o[i]=e),t=e)}e[t]=!0}return e}function S(t){const n=l(null);for(const[o,i]of e(t))void 0!==r(t,o)&&(n[o]=i);return n}function R(e,t){for(;null!==e;){const n=r(e,t);if(n){if(n.get)return N(n.get);if("function"==typeof n.value)return N(n.value)}e=o(e)}return function(e){return console.warn("fallback value for",e),null}}const w=i(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),D=i(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),L=i(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),v=i(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),x=i(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),k=i(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),C=i(["#text"]),O=i(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),I=i(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),M=i(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),U=i(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),P=a(/\{\{[\w\W]*|[\w\W]*\}\}/gm),F=a(/<%[\w\W]*|[\w\W]*%>/gm),H=a(/\${[\w\W]*}/gm),z=a(/^data-[\-\w.\u00B7-\uFFFF]/),B=a(/^aria-[\-\w]+$/),W=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),G=a(/^(?:\w+script|data):/i),Y=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),j=a(/^html$/i);var q=Object.freeze({__proto__:null,MUSTACHE_EXPR:P,ERB_EXPR:F,TMPLIT_EXPR:H,DATA_ATTR:z,ARIA_ATTR:B,IS_ALLOWED_URI:W,IS_SCRIPT_OR_DATA:G,ATTR_WHITESPACE:Y,DOCTYPE_NAME:j});const X=function(){return"undefined"==typeof window?null:window},K=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}};var V=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:X();const o=e=>t(e);if(o.version="3.0.6",o.removed=[],!n||!n.document||9!==n.document.nodeType)return o.isSupported=!1,o;let{document:r}=n;const a=r,c=a.currentScript,{DocumentFragment:s,HTMLTemplateElement:_,Node:N,Element:P,NodeFilter:F,NamedNodeMap:H=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:z,DOMParser:B,trustedTypes:G}=n,Y=P.prototype,V=R(Y,"cloneNode"),$=R(Y,"nextSibling"),Z=R(Y,"childNodes"),J=R(Y,"parentNode");if("function"==typeof _){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let Q,ee="";const{implementation:te,createNodeIterator:ne,createDocumentFragment:oe,getElementsByTagName:re}=r,{importNode:ie}=a;let ae={};o.isSupported="function"==typeof e&&"function"==typeof J&&te&&void 0!==te.createHTMLDocument;const{MUSTACHE_EXPR:le,ERB_EXPR:ce,TMPLIT_EXPR:se,DATA_ATTR:ue,ARIA_ATTR:me,IS_SCRIPT_OR_DATA:fe,ATTR_WHITESPACE:pe}=q;let{IS_ALLOWED_URI:de}=q,he=null;const ge=b({},[...w,...D,...L,...x,...C]);let Te=null;const ye=b({},[...O,...I,...M,...U]);let Ee=Object.seal(l(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,_e=null,Ne=!0,be=!0,Se=!1,Re=!0,we=!1,De=!1,Le=!1,ve=!1,xe=!1,ke=!1,Ce=!1,Oe=!0,Ie=!1;const Me="user-content-";let Ue=!0,Pe=!1,Fe={},He=null;const ze=b({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Be=null;const We=b({},["audio","video","img","source","image","track"]);let Ge=null;const Ye=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),je="http://www.w3.org/1998/Math/MathML",qe="http://www.w3.org/2000/svg",Xe="http://www.w3.org/1999/xhtml";let Ke=Xe,Ve=!1,$e=null;const Ze=b({},[je,qe,Xe],d);let Je=null;const Qe=["application/xhtml+xml","text/html"],et="text/html";let tt=null,nt=null;const ot=r.createElement("form"),rt=function(e){return e instanceof RegExp||e instanceof Function},it=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!nt||nt!==e){if(e&&"object"==typeof e||(e={}),e=S(e),Je=Je=-1===Qe.indexOf(e.PARSER_MEDIA_TYPE)?et:e.PARSER_MEDIA_TYPE,tt="application/xhtml+xml"===Je?d:p,he="ALLOWED_TAGS"in e?b({},e.ALLOWED_TAGS,tt):ge,Te="ALLOWED_ATTR"in e?b({},e.ALLOWED_ATTR,tt):ye,$e="ALLOWED_NAMESPACES"in e?b({},e.ALLOWED_NAMESPACES,d):Ze,Ge="ADD_URI_SAFE_ATTR"in e?b(S(Ye),e.ADD_URI_SAFE_ATTR,tt):Ye,Be="ADD_DATA_URI_TAGS"in e?b(S(We),e.ADD_DATA_URI_TAGS,tt):We,He="FORBID_CONTENTS"in e?b({},e.FORBID_CONTENTS,tt):ze,Ae="FORBID_TAGS"in e?b({},e.FORBID_TAGS,tt):{},_e="FORBID_ATTR"in e?b({},e.FORBID_ATTR,tt):{},Fe="USE_PROFILES"in e&&e.USE_PROFILES,Ne=!1!==e.ALLOW_ARIA_ATTR,be=!1!==e.ALLOW_DATA_ATTR,Se=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Re=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,we=e.SAFE_FOR_TEMPLATES||!1,De=e.WHOLE_DOCUMENT||!1,xe=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,Ce=e.RETURN_TRUSTED_TYPE||!1,ve=e.FORCE_BODY||!1,Oe=!1!==e.SANITIZE_DOM,Ie=e.SANITIZE_NAMED_PROPS||!1,Ue=!1!==e.KEEP_CONTENT,Pe=e.IN_PLACE||!1,de=e.ALLOWED_URI_REGEXP||W,Ke=e.NAMESPACE||Xe,Ee=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&rt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ee.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&rt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ee.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ee.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),we&&(be=!1),ke&&(xe=!0),Fe&&(he=b({},[...C]),Te=[],!0===Fe.html&&(b(he,w),b(Te,O)),!0===Fe.svg&&(b(he,D),b(Te,I),b(Te,U)),!0===Fe.svgFilters&&(b(he,L),b(Te,I),b(Te,U)),!0===Fe.mathMl&&(b(he,x),b(Te,M),b(Te,U))),e.ADD_TAGS&&(he===ge&&(he=S(he)),b(he,e.ADD_TAGS,tt)),e.ADD_ATTR&&(Te===ye&&(Te=S(Te)),b(Te,e.ADD_ATTR,tt)),e.ADD_URI_SAFE_ATTR&&b(Ge,e.ADD_URI_SAFE_ATTR,tt),e.FORBID_CONTENTS&&(He===ze&&(He=S(He)),b(He,e.FORBID_CONTENTS,tt)),Ue&&(he["#text"]=!0),De&&b(he,["html","head","body"]),he.table&&(b(he,["tbody"]),delete Ae.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');Q=e.TRUSTED_TYPES_POLICY,ee=Q.createHTML("")}else void 0===Q&&(Q=K(G,c)),null!==Q&&"string"==typeof ee&&(ee=Q.createHTML(""));i&&i(e),nt=e}},at=b({},["mi","mo","mn","ms","mtext"]),lt=b({},["foreignobject","desc","title","annotation-xml"]),ct=b({},["title","style","font","a","script"]),st=b({},D);b(st,L),b(st,v);const ut=b({},x);b(ut,k);const mt=function(e){let t=J(e);t&&t.tagName||(t={namespaceURI:Ke,tagName:"template"});const n=p(e.tagName),o=p(t.tagName);return!!$e[e.namespaceURI]&&(e.namespaceURI===qe?t.namespaceURI===Xe?"svg"===n:t.namespaceURI===je?"svg"===n&&("annotation-xml"===o||at[o]):Boolean(st[n]):e.namespaceURI===je?t.namespaceURI===Xe?"math"===n:t.namespaceURI===qe?"math"===n&<[o]:Boolean(ut[n]):e.namespaceURI===Xe?!(t.namespaceURI===qe&&!lt[o])&&(!(t.namespaceURI===je&&!at[o])&&(!ut[n]&&(ct[n]||!st[n]))):!("application/xhtml+xml"!==Je||!$e[e.namespaceURI]))},ft=function(e){f(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},pt=function(e,t){try{f(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){f(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Te[e])if(xe||ke)try{ft(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},dt=function(e){let t=null,n=null;if(ve)e=""+e;else{const t=h(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Je&&Ke===Xe&&(e=''+e+"");const o=Q?Q.createHTML(e):e;if(Ke===Xe)try{t=(new B).parseFromString(o,Je)}catch(e){}if(!t||!t.documentElement){t=te.createDocument(Ke,"template",null);try{t.documentElement.innerHTML=Ve?ee:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),Ke===Xe?re.call(t,De?"html":"body")[0]:De?t.documentElement:i},ht=function(e){return ne.call(e.ownerDocument||e,e,F.SHOW_ELEMENT|F.SHOW_COMMENT|F.SHOW_TEXT,null)},gt=function(e){return e instanceof z&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof H)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Tt=function(e){return"function"==typeof N&&e instanceof N},yt=function(e,t,n){ae[e]&&u(ae[e],(e=>{e.call(o,t,n,nt)}))},Et=function(e){let t=null;if(yt("beforeSanitizeElements",e,null),gt(e))return ft(e),!0;const n=tt(e.nodeName);if(yt("uponSanitizeElement",e,{tagName:n,allowedTags:he}),e.hasChildNodes()&&!Tt(e.firstElementChild)&&E(/<[/\w]/g,e.innerHTML)&&E(/<[/\w]/g,e.textContent))return ft(e),!0;if(!he[n]||Ae[n]){if(!Ae[n]&&_t(n)){if(Ee.tagNameCheck instanceof RegExp&&E(Ee.tagNameCheck,n))return!1;if(Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(n))return!1}if(Ue&&!He[n]){const t=J(e)||e.parentNode,n=Z(e)||e.childNodes;if(n&&t){for(let o=n.length-1;o>=0;--o)t.insertBefore(V(n[o],!0),$(e))}}return ft(e),!0}return e instanceof P&&!mt(e)?(ft(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!E(/<\/no(script|embed|frames)/i,e.innerHTML)?(we&&3===e.nodeType&&(t=e.textContent,u([le,ce,se],(e=>{t=g(t,e," ")})),e.textContent!==t&&(f(o.removed,{element:e.cloneNode()}),e.textContent=t)),yt("afterSanitizeElements",e,null),!1):(ft(e),!0)},At=function(e,t,n){if(Oe&&("id"===t||"name"===t)&&(n in r||n in ot))return!1;if(be&&!_e[t]&&E(ue,t));else if(Ne&&E(me,t));else if(!Te[t]||_e[t]){if(!(_t(e)&&(Ee.tagNameCheck instanceof RegExp&&E(Ee.tagNameCheck,e)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(e))&&(Ee.attributeNameCheck instanceof RegExp&&E(Ee.attributeNameCheck,t)||Ee.attributeNameCheck instanceof Function&&Ee.attributeNameCheck(t))||"is"===t&&Ee.allowCustomizedBuiltInElements&&(Ee.tagNameCheck instanceof RegExp&&E(Ee.tagNameCheck,n)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(n))))return!1}else if(Ge[t]);else if(E(de,g(n,pe,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==T(n,"data:")||!Be[e]){if(Se&&!E(fe,g(n,pe,"")));else if(n)return!1}else;return!0},_t=function(e){return e.indexOf("-")>0},Nt=function(e){yt("beforeSanitizeAttributes",e,null);const{attributes:t}=e;if(!t)return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Te};let r=t.length;for(;r--;){const i=t[r],{name:a,namespaceURI:l,value:c}=i,s=tt(a);let f="value"===a?c:y(c);if(n.attrName=s,n.attrValue=f,n.keepAttr=!0,n.forceKeepAttr=void 0,yt("uponSanitizeAttribute",e,n),f=n.attrValue,n.forceKeepAttr)continue;if(pt(a,e),!n.keepAttr)continue;if(!Re&&E(/\/>/i,f)){pt(a,e);continue}we&&u([le,ce,se],(e=>{f=g(f,e," ")}));const p=tt(e.nodeName);if(At(p,s,f)){if(!Ie||"id"!==s&&"name"!==s||(pt(a,e),f=Me+f),Q&&"object"==typeof G&&"function"==typeof G.getAttributeType)if(l);else switch(G.getAttributeType(p,s)){case"TrustedHTML":f=Q.createHTML(f);break;case"TrustedScriptURL":f=Q.createScriptURL(f)}try{l?e.setAttributeNS(l,a,f):e.setAttribute(a,f),m(o.removed)}catch(e){}}}yt("afterSanitizeAttributes",e,null)},bt=function e(t){let n=null;const o=ht(t);for(yt("beforeSanitizeShadowDOM",t,null);n=o.nextNode();)yt("uponSanitizeShadowNode",n,null),Et(n)||(n.content instanceof s&&e(n.content),Nt(n));yt("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,i=null,l=null;if(Ve=!e,Ve&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Tt(e)){if("function"!=typeof e.toString)throw A("toString is not a function");if("string"!=typeof(e=e.toString()))throw A("dirty is not a string, aborting")}if(!o.isSupported)return e;if(Le||it(t),o.removed=[],"string"==typeof e&&(Pe=!1),Pe){if(e.nodeName){const t=tt(e.nodeName);if(!he[t]||Ae[t])throw A("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof N)n=dt("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r);else{if(!xe&&!we&&!De&&-1===e.indexOf("<"))return Q&&Ce?Q.createHTML(e):e;if(n=dt(e),!n)return xe?null:Ce?ee:""}n&&ve&&ft(n.firstChild);const c=ht(Pe?e:n);for(;i=c.nextNode();)Et(i)||(i.content instanceof s&&bt(i.content),Nt(i));if(Pe)return e;if(xe){if(ke)for(l=oe.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(Te.shadowroot||Te.shadowrootmode)&&(l=ie.call(a,l,!0)),l}let m=De?n.outerHTML:n.innerHTML;return De&&he["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&E(j,n.ownerDocument.doctype.name)&&(m="\n"+m),we&&u([le,ce,se],(e=>{m=g(m,e," ")})),Q&&Ce?Q.createHTML(m):m},o.setConfig=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};it(e),Le=!0},o.clearConfig=function(){nt=null,Le=!1},o.isValidAttribute=function(e,t,n){nt||it({});const o=tt(e),r=tt(t);return At(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&(ae[e]=ae[e]||[],f(ae[e],t))},o.removeHook=function(e){if(ae[e])return m(ae[e])},o.removeHooks=function(e){ae[e]&&(ae[e]=[])},o.removeAllHooks=function(){ae={}},o}();return V})); +//# sourceMappingURL=purify.min.js.map diff --git a/InfoGenie-frontend/public/toolbox/AI聊天/script.js b/InfoGenie-frontend/public/toolbox/AI聊天/script.js new file mode 100644 index 00000000..ba03f3c7 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/AI聊天/script.js @@ -0,0 +1,223 @@ +// 简单的静态网页调用 GitHub Models API 进行聊天 +// 注意:将 token 暴露在前端存在安全风险,仅用于本地演示 + +const endpoint = "https://models.github.ai/inference"; +let apiKey = "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"; // 注意:已硬编码,仅用于本地演示 + +const chatBox = document.getElementById("chat-box"); +const userInput = document.getElementById("user-input"); +const sendBtn = document.getElementById("send-btn"); +const modelSelect = document.getElementById("model"); + +// 模型信息映射(中文描述与上下文上限) +const MODEL_INFO = { + "openai/gpt-4.1": { + name: "gpt-4.1", + inputTokens: "1049k", + outputTokens: "33k", + about: "在各方面优于 gpt-4o,编码、指令跟随与长上下文理解均有显著提升" + }, + "openai/gpt-4.1-mini": { + name: "gpt-4.1-mini", + inputTokens: "1049k", + outputTokens: "33k", + about: "在各方面优于 gpt-4o-mini,在编码、指令跟随与长上下文处理上有显著提升" + }, + "openai/gpt-4.1-nano": { + name: "gpt-4.1-nano", + inputTokens: "1049k", + outputTokens: "33k", + about: "在编码、指令跟随与长上下文处理上有所提升,同时具备更低延迟与成本" + }, + "openai/gpt-4o": { + name: "gpt-4o", + inputTokens: "131k", + outputTokens: "16k", + about: "OpenAI 最先进的多模态 gpt-4o 家族模型,可处理文本与图像输入" + }, + "openai/gpt-5": { + name: "gpt-5", + inputTokens: "200k", + outputTokens: "100k", + about: "针对逻辑密集与多步骤任务设计" + }, + "deepseek-r1": { + name: "deepseek-r1", + inputTokens: "128k", + outputTokens: "4k", + about: "通过逐步训练过程在推理任务上表现出色,适用于语言、科学推理与代码生成等" + }, + "deepseek-v3-0324": { + name: "deepseek-v3-0324", + inputTokens: "128k", + outputTokens: "4k", + about: "相较于 DeepSeek-V3 在关键方面显著提升,包括更强的推理能力、函数调用与代码生成表现" + }, + "xai/grok-3": { + name: "grok-3", + inputTokens: "131k", + outputTokens: "4k", + about: "Grok 3 是 xAI 的首发模型,由 Colossus 在超大规模上进行预训练,在金融、医疗和法律等专业领域表现突出。" + }, + "xai/grok-3-mini": { + name: "grok-3-mini", + inputTokens: "131k", + outputTokens: "4k", + about: "Grok 3 Mini 是一款轻量级模型,会在答复前进行思考。它针对数学与科学问题进行训练,特别适合逻辑类任务。" + } +}; + +function renderModelInfo() { + const m = MODEL_INFO[modelSelect.value]; + const infoEl = document.getElementById('model-info'); + if (!infoEl) return; + if (m) { + infoEl.innerHTML = `
    ${m.name} 上下文 ${m.inputTokens} 输入 · ${m.outputTokens} 输出
    简介:${m.about}
    `; + } else { + infoEl.innerHTML = `
    未配置该模型的上下文限制信息
    `; + } +} + + + +// Markdown 解析配置(若库已加载) +if (window.marked) { + marked.setOptions({ gfm: true, breaks: true, headerIds: true, mangle: false }); +} + +function renderMarkdown(text) { + try { + if (window.marked && window.DOMPurify) { + const html = marked.parse(text || ''); + return DOMPurify.sanitize(html); + } + } catch (_) {} + return text || ''; +} + +function appendMessage(role, text){ + const message = document.createElement('div'); + message.className = `message ${role}`; + const bubble = document.createElement('div'); + bubble.className = 'bubble'; + // Markdown 渲染 + bubble.innerHTML = renderMarkdown(text); + message.appendChild(bubble); + chatBox.appendChild(message); + chatBox.scrollTop = chatBox.scrollHeight; +} + +function appendStreamingMessage(role){ + const message = document.createElement('div'); + message.className = `message ${role}`; + const bubble = document.createElement('div'); + bubble.className = 'bubble'; + bubble._mdBuffer = ''; + bubble.innerHTML = ''; + message.appendChild(bubble); + chatBox.appendChild(message); + chatBox.scrollTop = chatBox.scrollHeight; + return bubble; +} + +async function sendMessage(){ + const content = userInput.value.trim(); + if (!content) return; + appendMessage('user', content); + userInput.value = ''; + + const model = modelSelect.value; + + // 令牌已硬编码(本地演示),如未配置则提示 + if (!apiKey) { + appendMessage('assistant', '未配置令牌'); + return; + } + + sendBtn.disabled = true; + const assistantBubble = appendStreamingMessage('assistant'); + + try { + const res = await fetch(`${endpoint}/chat/completions`, { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + 'Authorization': `Bearer ${apiKey}` + }, + body: JSON.stringify({ + model, + temperature: 1, + top_p: 1, + stream: true, + messages: [ + { role: 'system', content: '' }, + { role: 'user', content } + ] + }) + }); + + if (!res.ok) { + const errText = await res.text(); + throw new Error(`HTTP ${res.status}: ${errText}`); + } + + const reader = res.body.getReader(); + const decoder = new TextDecoder('utf-8'); + let buffer = ''; + let doneStream = false; + + while (!doneStream) { + const { value, done } = await reader.read(); + if (done) break; + buffer += decoder.decode(value, { stream: true }); + + const parts = buffer.split(/\r?\n/); + buffer = parts.pop(); + for (const part of parts) { + const line = part.trim(); + if (line === '') continue; + if (line.startsWith('data:')) { + const payload = line.slice(5).trim(); + if (payload === '[DONE]') { + doneStream = true; + break; + } + try { + const json = JSON.parse(payload); + const delta = json?.choices?.[0]?.delta?.content ?? json?.choices?.[0]?.message?.content ?? ''; + if (delta) { + // 累计流式文本并增量渲染 Markdown + assistantBubble._mdBuffer = (assistantBubble._mdBuffer || '') + delta; + const safeHtml = renderMarkdown(assistantBubble._mdBuffer); + assistantBubble.innerHTML = safeHtml; + chatBox.scrollTop = chatBox.scrollHeight; + } + } catch (e) { + // 忽略无法解析的行 + } + } + } + } + + if (!assistantBubble._mdBuffer || !assistantBubble.textContent) { + assistantBubble.textContent = '(无内容返回)'; + } + } catch (err) { + //assistantBubble.textContent = `出错了:${err.message}`; + assistantBubble.textContent = `调用次数过多或者使用人数过多,请稍后再试!`; + } finally { + sendBtn.disabled = false; + } +} + +sendBtn.addEventListener('click', sendMessage); +userInput.addEventListener('keydown', (e) => { + if (e.key === 'Enter' && !e.shiftKey) { + e.preventDefault(); + sendMessage(); + } +}); + +// 切换模型时更新信息面板,初次渲染一次 +modelSelect.addEventListener('change', renderModelInfo); +renderModelInfo(); \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/AI聊天/style.css b/InfoGenie-frontend/public/toolbox/AI聊天/style.css new file mode 100644 index 00000000..7e897bc9 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/AI聊天/style.css @@ -0,0 +1,172 @@ +/* 淡绿色淡黄绿色渐变清新柔和风格,移动端适配 */ +:root { + --bg-start: #d9f7be; /* 淡绿 */ + --bg-end: #f4f9d2; /* 淡黄绿 */ + --primary: #4caf50; /* 绿色强调 */ + --secondary: #8bc34a; + --text: #2f3b2f; + --muted: #6b7a6b; + --white: #ffffff; + --shadow: rgba(76, 175, 80, 0.2); +} + +* { box-sizing: border-box; } +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", "PingFang SC", "Microsoft YaHei", sans-serif; + background: linear-gradient(135deg, var(--bg-start), var(--bg-end)); + color: var(--text); + min-height: 100vh; + display: flex; + align-items: center; + justify-content: center; + padding: 16px; +} + +.chat-container { + width: 100%; + max-width: 720px; + background: var(--white); + border-radius: 16px; + box-shadow: 0 10px 30px var(--shadow); + overflow: hidden; +} + +/* 顶部警示通知样式 */ +.warning-banner { + padding: 10px 16px; + background: #fff8d6; /* 柔和黄色背景 */ + border: 1px solid #ffec99; /* 黄色边框 */ + border-left: 4px solid #faad14; /* 左侧强调条 */ + color: #5c4a00; /* 深色文字保证可读性 */ + font-size: 14px; + line-height: 1.6; +} + +@media (max-width: 480px) { + .warning-banner { font-size: 13px; padding: 8px 12px; } +} + +.chat-header { + display: flex; + align-items: center; + justify-content: space-between; + padding: 12px 16px; + background: linear-gradient(135deg, #eafbe6, #f9ffe6); + border-bottom: 1px solid #e1f3d8; +} + +.chat-header h2 { + margin: 0; + font-size: 18px; + color: var(--primary); +} + +.model-selector { + display: flex; + align-items: center; + gap: 8px; +} + +.model-selector select { + padding: 6px 8px; + border: 1px solid #cfe8c9; + border-radius: 8px; + background: #f7fff2; + color: var(--text); +} + +.chat-box { + height: 60vh; + padding: 16px; + overflow-y: auto; + background: #fbfff5; +} + +.message { display: flex; margin-bottom: 12px; gap: 8px; } +.message .bubble { + padding: 10px 12px; + border-radius: 12px; + max-width: 85%; + box-shadow: 0 2px 10px var(--shadow); +} +.message.user .bubble { + background: #e2f7d8; + align-self: flex-end; +} +.message.assistant .bubble { + background: #fffef0; +} +.message.user { justify-content: flex-end; } +.message.assistant { justify-content: flex-start; } + +.chat-input { + display: flex; + gap: 8px; + padding: 12px; + border-top: 1px solid #e1f3d8; + background: #fafff0; +} + +#user-input { + flex: 1; + padding: 10px 12px; + border: 1px solid #cfe8c9; + border-radius: 12px; + font-size: 16px; + background: #ffffff; +} + +#send-btn { + padding: 10px 16px; + border: none; + border-radius: 12px; + background: linear-gradient(135deg, var(--secondary), var(--primary)); + color: var(--white); + font-weight: 600; + cursor: pointer; +} +#send-btn:disabled { opacity: 0.6; cursor: not-allowed; } + +/* 模型信息面板样式 */ +.model-info { + padding: 10px 16px; + background: #f9fff0; + border-bottom: 1px solid #e1f3d8; + color: var(--muted); + font-size: 14px; +} +.model-info .name { color: var(--primary); font-weight: 600; } +.model-info .tokens { color: var(--text); font-weight: 600; margin-left: 8px; } +.model-info .about { margin-top: 6px; line-height: 1.5; } + +/* 移动端优化 */ +@media (max-width: 480px) { + .chat-box { height: 62vh; } + #user-input { font-size: 15px; } + #send-btn { padding: 10px 14px; } + .model-info { font-size: 13px; padding: 8px 12px; } +} + +/* 全局隐藏滚动条,保留滚动效果 */ +html, body { + -ms-overflow-style: none; /* IE/旧版 Edge */ + scrollbar-width: none; /* Firefox */ +} +html::-webkit-scrollbar, +body::-webkit-scrollbar { display: none; } /* Chrome/Safari/新 Edge */ + +/* 隐藏所有元素滚动条(覆盖常见浏览器) */ +* { + -ms-overflow-style: none; + scrollbar-width: none; +} +*::-webkit-scrollbar { display: none; } + +/* 保持聊天框可滚动并优化移动端滚动体验 */ +.chat-box { -webkit-overflow-scrolling: touch; } + +/* 代码块允许横向滚动但隐藏滚动条 */ +.message .bubble pre { overflow-x: auto; } +.message .bubble pre { scrollbar-width: none; -ms-overflow-style: none; } +.message .bubble pre::-webkit-scrollbar { display: none; } \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/Json编辑器/index.html b/InfoGenie-frontend/public/toolbox/Json编辑器/index.html new file mode 100644 index 00000000..c811a96d --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/Json编辑器/index.html @@ -0,0 +1,339 @@ + + + + + + 📒JSON编辑器 + + + + + + + + + + + + + + + + + +
    +
    +
    + + 📒JSON 编辑器 +
    +
    + + + + + +
    +
    + +
    + +
    + + 就绪 +
    +
    +
    + + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/Markdown解析器/index.html b/InfoGenie-frontend/public/toolbox/Markdown解析器/index.html new file mode 100644 index 00000000..bdd9525b --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/Markdown解析器/index.html @@ -0,0 +1,337 @@ + + + + + + + + Markdown解析器 + + + + + + +
    +
    + +
    +

    Markdown解析器

    +
    +
    +
    +
    +
    +
    Markdown 输入
    + +
    + + +
    +
    +
    实时预览
    +
    +
    +
    + +
    + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/Markdown解析器/marked.min.js b/InfoGenie-frontend/public/toolbox/Markdown解析器/marked.min.js new file mode 100644 index 00000000..b4e0d73b --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/Markdown解析器/marked.min.js @@ -0,0 +1,69 @@ +/** + * marked v15.0.12 - a markdown parser + * Copyright (c) 2011-2025, Christopher Jeffrey. (MIT Licensed) + * https://github.com/markedjs/marked + */ + +/** + * DO NOT EDIT THIS FILE + * The code in this file is generated from files in ./src/ + */ +(function(g,f){if(typeof exports=="object"&&typeof module<"u"){module.exports=f()}else if("function"==typeof define && define.amd){define("marked",f)}else {g["marked"]=f()}}(typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : this,function(){var exports={};var __exports=exports;var module={exports}; +"use strict";var H=Object.defineProperty;var be=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var we=Object.prototype.hasOwnProperty;var ye=(l,e)=>{for(var t in e)H(l,t,{get:e[t],enumerable:!0})},Re=(l,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of Te(e))!we.call(l,s)&&s!==t&&H(l,s,{get:()=>e[s],enumerable:!(n=be(e,s))||n.enumerable});return l};var Se=l=>Re(H({},"__esModule",{value:!0}),l);var kt={};ye(kt,{Hooks:()=>L,Lexer:()=>x,Marked:()=>E,Parser:()=>b,Renderer:()=>$,TextRenderer:()=>_,Tokenizer:()=>S,defaults:()=>w,getDefaults:()=>z,lexer:()=>ht,marked:()=>k,options:()=>it,parse:()=>pt,parseInline:()=>ct,parser:()=>ut,setOptions:()=>ot,use:()=>lt,walkTokens:()=>at});module.exports=Se(kt);function z(){return{async:!1,breaks:!1,extensions:null,gfm:!0,hooks:null,pedantic:!1,renderer:null,silent:!1,tokenizer:null,walkTokens:null}}var w=z();function N(l){w=l}var I={exec:()=>null};function h(l,e=""){let t=typeof l=="string"?l:l.source,n={replace:(s,i)=>{let r=typeof i=="string"?i:i.source;return r=r.replace(m.caret,"$1"),t=t.replace(s,r),n},getRegex:()=>new RegExp(t,e)};return n}var m={codeRemoveIndent:/^(?: {1,4}| {0,3}\t)/gm,outputLinkReplace:/\\([\[\]])/g,indentCodeCompensation:/^(\s+)(?:```)/,beginningSpace:/^\s+/,endingHash:/#$/,startingSpaceChar:/^ /,endingSpaceChar:/ $/,nonSpaceChar:/[^ ]/,newLineCharGlobal:/\n/g,tabCharGlobal:/\t/g,multipleSpaceGlobal:/\s+/g,blankLine:/^[ \t]*$/,doubleBlankLine:/\n[ \t]*\n[ \t]*$/,blockquoteStart:/^ {0,3}>/,blockquoteSetextReplace:/\n {0,3}((?:=+|-+) *)(?=\n|$)/g,blockquoteSetextReplace2:/^ {0,3}>[ \t]?/gm,listReplaceTabs:/^\t+/,listReplaceNesting:/^ {1,4}(?=( {4})*[^ ])/g,listIsTask:/^\[[ xX]\] /,listReplaceTask:/^\[[ xX]\] +/,anyLine:/\n.*\n/,hrefBrackets:/^<(.*)>$/,tableDelimiter:/[:|]/,tableAlignChars:/^\||\| *$/g,tableRowBlankLine:/\n[ \t]*$/,tableAlignRight:/^ *-+: *$/,tableAlignCenter:/^ *:-+: *$/,tableAlignLeft:/^ *:-+ *$/,startATag:/^
    /i,startPreScriptTag:/^<(pre|code|kbd|script)(\s|>)/i,endPreScriptTag:/^<\/(pre|code|kbd|script)(\s|>)/i,startAngleBracket:/^$/,pedanticHrefTitle:/^([^'"]*[^\s])\s+(['"])(.*)\2/,unicodeAlphaNumeric:/[\p{L}\p{N}]/u,escapeTest:/[&<>"']/,escapeReplace:/[&<>"']/g,escapeTestNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/,escapeReplaceNoEncode:/[<>"']|&(?!(#\d{1,7}|#[Xx][a-fA-F0-9]{1,6}|\w+);)/g,unescapeTest:/&(#(?:\d+)|(?:#x[0-9A-Fa-f]+)|(?:\w+));?/ig,caret:/(^|[^\[])\^/g,percentDecode:/%25/g,findPipe:/\|/g,splitPipe:/ \|/,slashPipe:/\\\|/g,carriageReturn:/\r\n|\r/g,spaceLine:/^ +$/gm,notSpaceStart:/^\S*/,endingNewline:/\n$/,listItemRegex:l=>new RegExp(`^( {0,3}${l})((?:[ ][^\\n]*)?(?:\\n|$))`),nextBulletRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:[*+-]|\\d{1,9}[.)])((?:[ ][^\\n]*)?(?:\\n|$))`),hrRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}((?:- *){3,}|(?:_ *){3,}|(?:\\* *){3,})(?:\\n+|$)`),fencesBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}(?:\`\`\`|~~~)`),headingBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}#`),htmlBeginRegex:l=>new RegExp(`^ {0,${Math.min(3,l-1)}}<(?:[a-z].*>|!--)`,"i")},$e=/^(?:[ \t]*(?:\n|$))+/,_e=/^((?: {4}| {0,3}\t)[^\n]+(?:\n(?:[ \t]*(?:\n|$))*)?)+/,Le=/^ {0,3}(`{3,}(?=[^`\n]*(?:\n|$))|~{3,})([^\n]*)(?:\n|$)(?:|([\s\S]*?)(?:\n|$))(?: {0,3}\1[~`]* *(?=\n|$)|$)/,O=/^ {0,3}((?:-[\t ]*){3,}|(?:_[ \t]*){3,}|(?:\*[ \t]*){3,})(?:\n+|$)/,ze=/^ {0,3}(#{1,6})(?=\s|$)(.*)(?:\n+|$)/,F=/(?:[*+-]|\d{1,9}[.)])/,ie=/^(?!bull |blockCode|fences|blockquote|heading|html|table)((?:.|\n(?!\s*?\n|bull |blockCode|fences|blockquote|heading|html|table))+?)\n {0,3}(=+|-+) *(?:\n+|$)/,oe=h(ie).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/\|table/g,"").getRegex(),Me=h(ie).replace(/bull/g,F).replace(/blockCode/g,/(?: {4}| {0,3}\t)/).replace(/fences/g,/ {0,3}(?:`{3,}|~{3,})/).replace(/blockquote/g,/ {0,3}>/).replace(/heading/g,/ {0,3}#{1,6}/).replace(/html/g,/ {0,3}<[^\n>]+>\n/).replace(/table/g,/ {0,3}\|?(?:[:\- ]*\|)+[\:\- ]*\n/).getRegex(),Q=/^([^\n]+(?:\n(?!hr|heading|lheading|blockquote|fences|list|html|table| +\n)[^\n]+)*)/,Pe=/^[^\n]+/,U=/(?!\s*\])(?:\\.|[^\[\]\\])+/,Ae=h(/^ {0,3}\[(label)\]: *(?:\n[ \t]*)?([^<\s][^\s]*|<.*?>)(?:(?: +(?:\n[ \t]*)?| *\n[ \t]*)(title))? *(?:\n+|$)/).replace("label",U).replace("title",/(?:"(?:\\"?|[^"\\])*"|'[^'\n]*(?:\n[^'\n]+)*\n?'|\([^()]*\))/).getRegex(),Ee=h(/^( {0,3}bull)([ \t][^\n]+?)?(?:\n|$)/).replace(/bull/g,F).getRegex(),v="address|article|aside|base|basefont|blockquote|body|caption|center|col|colgroup|dd|details|dialog|dir|div|dl|dt|fieldset|figcaption|figure|footer|form|frame|frameset|h[1-6]|head|header|hr|html|iframe|legend|li|link|main|menu|menuitem|meta|nav|noframes|ol|optgroup|option|p|param|search|section|summary|table|tbody|td|tfoot|th|thead|title|tr|track|ul",K=/|$))/,Ce=h("^ {0,3}(?:<(script|pre|style|textarea)[\\s>][\\s\\S]*?(?:[^\\n]*\\n+|$)|comment[^\\n]*(\\n+|$)|<\\?[\\s\\S]*?(?:\\?>\\n*|$)|\\n*|$)|\\n*|$)|)[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|<(?!script|pre|style|textarea)([a-z][\\w-]*)(?:attribute)*? */?>(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$)|(?=[ \\t]*(?:\\n|$))[\\s\\S]*?(?:(?:\\n[ ]*)+\\n|$))","i").replace("comment",K).replace("tag",v).replace("attribute",/ +[a-zA-Z:_][\w.:-]*(?: *= *"[^"\n]*"| *= *'[^'\n]*'| *= *[^\s"'=<>`]+)?/).getRegex(),le=h(Q).replace("hr",O).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("|table","").replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),Ie=h(/^( {0,3}> ?(paragraph|[^\n]*)(?:\n|$))+/).replace("paragraph",le).getRegex(),X={blockquote:Ie,code:_e,def:Ae,fences:Le,heading:ze,hr:O,html:Ce,lheading:oe,list:Ee,newline:$e,paragraph:le,table:I,text:Pe},re=h("^ *([^\\n ].*)\\n {0,3}((?:\\| *)?:?-+:? *(?:\\| *:?-+:? *)*(?:\\| *)?)(?:\\n((?:(?! *\\n|hr|heading|blockquote|code|fences|list|html).*(?:\\n|$))*)\\n*|$)").replace("hr",O).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("blockquote"," {0,3}>").replace("code","(?: {4}| {0,3} )[^\\n]").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex(),Oe={...X,lheading:Me,table:re,paragraph:h(Q).replace("hr",O).replace("heading"," {0,3}#{1,6}(?:\\s|$)").replace("|lheading","").replace("table",re).replace("blockquote"," {0,3}>").replace("fences"," {0,3}(?:`{3,}(?=[^`\\n]*\\n)|~{3,})[^\\n]*\\n").replace("list"," {0,3}(?:[*+-]|1[.)]) ").replace("html",")|<(?:script|pre|style|textarea|!--)").replace("tag",v).getRegex()},Be={...X,html:h(`^ *(?:comment *(?:\\n|\\s*$)|<(tag)[\\s\\S]+? *(?:\\n{2,}|\\s*$)|\\s]*)*?/?> *(?:\\n{2,}|\\s*$))`).replace("comment",K).replace(/tag/g,"(?!(?:a|em|strong|small|s|cite|q|dfn|abbr|data|time|code|var|samp|kbd|sub|sup|i|b|u|mark|ruby|rt|rp|bdi|bdo|span|br|wbr|ins|del|img)\\b)\\w+(?!:|[^\\w\\s@]*@)\\b").getRegex(),def:/^ *\[([^\]]+)\]: *]+)>?(?: +(["(][^\n]+[")]))? *(?:\n+|$)/,heading:/^(#{1,6})(.*)(?:\n+|$)/,fences:I,lheading:/^(.+?)\n {0,3}(=+|-+) *(?:\n+|$)/,paragraph:h(Q).replace("hr",O).replace("heading",` *#{1,6} *[^ +]`).replace("lheading",oe).replace("|table","").replace("blockquote"," {0,3}>").replace("|fences","").replace("|list","").replace("|html","").replace("|tag","").getRegex()},qe=/^\\([!"#$%&'()*+,\-./:;<=>?@\[\]\\^_`{|}~])/,ve=/^(`+)([^`]|[^`][\s\S]*?[^`])\1(?!`)/,ae=/^( {2,}|\\)\n(?!\s*$)/,De=/^(`+|[^`])(?:(?= {2,}\n)|[\s\S]*?(?:(?=[\\]*?>/g,ue=/^(?:\*+(?:((?!\*)punct)|[^\s*]))|^_+(?:((?!_)punct)|([^\s_]))/,je=h(ue,"u").replace(/punct/g,D).getRegex(),Fe=h(ue,"u").replace(/punct/g,pe).getRegex(),he="^[^_*]*?__[^_*]*?\\*[^_*]*?(?=__)|[^*]+(?=[^*])|(?!\\*)punct(\\*+)(?=[\\s]|$)|notPunctSpace(\\*+)(?!\\*)(?=punctSpace|$)|(?!\\*)punctSpace(\\*+)(?=notPunctSpace)|[\\s](\\*+)(?!\\*)(?=punct)|(?!\\*)punct(\\*+)(?!\\*)(?=punct)|notPunctSpace(\\*+)(?=notPunctSpace)",Qe=h(he,"gu").replace(/notPunctSpace/g,ce).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Ue=h(he,"gu").replace(/notPunctSpace/g,He).replace(/punctSpace/g,Ge).replace(/punct/g,pe).getRegex(),Ke=h("^[^_*]*?\\*\\*[^_*]*?_[^_*]*?(?=\\*\\*)|[^_]+(?=[^_])|(?!_)punct(_+)(?=[\\s]|$)|notPunctSpace(_+)(?!_)(?=punctSpace|$)|(?!_)punctSpace(_+)(?=notPunctSpace)|[\\s](_+)(?!_)(?=punct)|(?!_)punct(_+)(?!_)(?=punct)","gu").replace(/notPunctSpace/g,ce).replace(/punctSpace/g,W).replace(/punct/g,D).getRegex(),Xe=h(/\\(punct)/,"gu").replace(/punct/g,D).getRegex(),We=h(/^<(scheme:[^\s\x00-\x1f<>]*|email)>/).replace("scheme",/[a-zA-Z][a-zA-Z0-9+.-]{1,31}/).replace("email",/[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+(@)[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)+(?![-_])/).getRegex(),Je=h(K).replace("(?:-->|$)","-->").getRegex(),Ve=h("^comment|^|^<[a-zA-Z][\\w-]*(?:attribute)*?\\s*/?>|^<\\?[\\s\\S]*?\\?>|^|^").replace("comment",Je).replace("attribute",/\s+[a-zA-Z:_][\w.:-]*(?:\s*=\s*"[^"]*"|\s*=\s*'[^']*'|\s*=\s*[^\s"'=<>`]+)?/).getRegex(),q=/(?:\[(?:\\.|[^\[\]\\])*\]|\\.|`[^`]*`|[^\[\]\\`])*?/,Ye=h(/^!?\[(label)\]\(\s*(href)(?:(?:[ \t]*(?:\n[ \t]*)?)(title))?\s*\)/).replace("label",q).replace("href",/<(?:\\.|[^\n<>\\])+>|[^ \t\n\x00-\x1f]*/).replace("title",/"(?:\\"?|[^"\\])*"|'(?:\\'?|[^'\\])*'|\((?:\\\)?|[^)\\])*\)/).getRegex(),ke=h(/^!?\[(label)\]\[(ref)\]/).replace("label",q).replace("ref",U).getRegex(),ge=h(/^!?\[(ref)\](?:\[\])?/).replace("ref",U).getRegex(),et=h("reflink|nolink(?!\\()","g").replace("reflink",ke).replace("nolink",ge).getRegex(),J={_backpedal:I,anyPunctuation:Xe,autolink:We,blockSkip:Ne,br:ae,code:ve,del:I,emStrongLDelim:je,emStrongRDelimAst:Qe,emStrongRDelimUnd:Ke,escape:qe,link:Ye,nolink:ge,punctuation:Ze,reflink:ke,reflinkSearch:et,tag:Ve,text:De,url:I},tt={...J,link:h(/^!?\[(label)\]\((.*?)\)/).replace("label",q).getRegex(),reflink:h(/^!?\[(label)\]\s*\[([^\]]*)\]/).replace("label",q).getRegex()},j={...J,emStrongRDelimAst:Ue,emStrongLDelim:Fe,url:h(/^((?:ftp|https?):\/\/|www\.)(?:[a-zA-Z0-9\-]+\.?)+[^\s<]*|^email/,"i").replace("email",/[A-Za-z0-9._+-]+(@)[a-zA-Z0-9-_]+(?:\.[a-zA-Z0-9-_]*[a-zA-Z0-9])+(?![-_])/).getRegex(),_backpedal:/(?:[^?!.,:;*_'"~()&]+|\([^)]*\)|&(?![a-zA-Z0-9]+;$)|[?!.,:;*_'"~)]+(?!$))+/,del:/^(~~?)(?=[^\s~])((?:\\.|[^\\])*?(?:\\.|[^\s~\\]))\1(?=[^~]|$)/,text:/^([`~]+|[^`~])(?:(?= {2,}\n)|(?=[a-zA-Z0-9.!#$%&'*+\/=?_`{\|}~-]+@)|[\s\S]*?(?:(?=[\\":">",'"':""","'":"'"},fe=l=>st[l];function R(l,e){if(e){if(m.escapeTest.test(l))return l.replace(m.escapeReplace,fe)}else if(m.escapeTestNoEncode.test(l))return l.replace(m.escapeReplaceNoEncode,fe);return l}function V(l){try{l=encodeURI(l).replace(m.percentDecode,"%")}catch{return null}return l}function Y(l,e){let t=l.replace(m.findPipe,(i,r,o)=>{let a=!1,c=r;for(;--c>=0&&o[c]==="\\";)a=!a;return a?"|":" |"}),n=t.split(m.splitPipe),s=0;if(n[0].trim()||n.shift(),n.length>0&&!n.at(-1)?.trim()&&n.pop(),e)if(n.length>e)n.splice(e);else for(;n.length0?-2:-1}function me(l,e,t,n,s){let i=e.href,r=e.title||null,o=l[1].replace(s.other.outputLinkReplace,"$1");n.state.inLink=!0;let a={type:l[0].charAt(0)==="!"?"image":"link",raw:t,href:i,title:r,text:o,tokens:n.inlineTokens(o)};return n.state.inLink=!1,a}function rt(l,e,t){let n=l.match(t.other.indentCodeCompensation);if(n===null)return e;let s=n[1];return e.split(` +`).map(i=>{let r=i.match(t.other.beginningSpace);if(r===null)return i;let[o]=r;return o.length>=s.length?i.slice(s.length):i}).join(` +`)}var S=class{options;rules;lexer;constructor(e){this.options=e||w}space(e){let t=this.rules.block.newline.exec(e);if(t&&t[0].length>0)return{type:"space",raw:t[0]}}code(e){let t=this.rules.block.code.exec(e);if(t){let n=t[0].replace(this.rules.other.codeRemoveIndent,"");return{type:"code",raw:t[0],codeBlockStyle:"indented",text:this.options.pedantic?n:A(n,` +`)}}}fences(e){let t=this.rules.block.fences.exec(e);if(t){let n=t[0],s=rt(n,t[3]||"",this.rules);return{type:"code",raw:n,lang:t[2]?t[2].trim().replace(this.rules.inline.anyPunctuation,"$1"):t[2],text:s}}}heading(e){let t=this.rules.block.heading.exec(e);if(t){let n=t[2].trim();if(this.rules.other.endingHash.test(n)){let s=A(n,"#");(this.options.pedantic||!s||this.rules.other.endingSpaceChar.test(s))&&(n=s.trim())}return{type:"heading",raw:t[0],depth:t[1].length,text:n,tokens:this.lexer.inline(n)}}}hr(e){let t=this.rules.block.hr.exec(e);if(t)return{type:"hr",raw:A(t[0],` +`)}}blockquote(e){let t=this.rules.block.blockquote.exec(e);if(t){let n=A(t[0],` +`).split(` +`),s="",i="",r=[];for(;n.length>0;){let o=!1,a=[],c;for(c=0;c1,i={type:"list",raw:"",ordered:s,start:s?+n.slice(0,-1):"",loose:!1,items:[]};n=s?`\\d{1,9}\\${n.slice(-1)}`:`\\${n}`,this.options.pedantic&&(n=s?n:"[*+-]");let r=this.rules.other.listItemRegex(n),o=!1;for(;e;){let c=!1,p="",u="";if(!(t=r.exec(e))||this.rules.block.hr.test(e))break;p=t[0],e=e.substring(p.length);let d=t[2].split(` +`,1)[0].replace(this.rules.other.listReplaceTabs,Z=>" ".repeat(3*Z.length)),g=e.split(` +`,1)[0],T=!d.trim(),f=0;if(this.options.pedantic?(f=2,u=d.trimStart()):T?f=t[1].length+1:(f=t[2].search(this.rules.other.nonSpaceChar),f=f>4?1:f,u=d.slice(f),f+=t[1].length),T&&this.rules.other.blankLine.test(g)&&(p+=g+` +`,e=e.substring(g.length+1),c=!0),!c){let Z=this.rules.other.nextBulletRegex(f),te=this.rules.other.hrRegex(f),ne=this.rules.other.fencesBeginRegex(f),se=this.rules.other.headingBeginRegex(f),xe=this.rules.other.htmlBeginRegex(f);for(;e;){let G=e.split(` +`,1)[0],C;if(g=G,this.options.pedantic?(g=g.replace(this.rules.other.listReplaceNesting," "),C=g):C=g.replace(this.rules.other.tabCharGlobal," "),ne.test(g)||se.test(g)||xe.test(g)||Z.test(g)||te.test(g))break;if(C.search(this.rules.other.nonSpaceChar)>=f||!g.trim())u+=` +`+C.slice(f);else{if(T||d.replace(this.rules.other.tabCharGlobal," ").search(this.rules.other.nonSpaceChar)>=4||ne.test(d)||se.test(d)||te.test(d))break;u+=` +`+g}!T&&!g.trim()&&(T=!0),p+=G+` +`,e=e.substring(G.length+1),d=C.slice(f)}}i.loose||(o?i.loose=!0:this.rules.other.doubleBlankLine.test(p)&&(o=!0));let y=null,ee;this.options.gfm&&(y=this.rules.other.listIsTask.exec(u),y&&(ee=y[0]!=="[ ] ",u=u.replace(this.rules.other.listReplaceTask,""))),i.items.push({type:"list_item",raw:p,task:!!y,checked:ee,loose:!1,text:u,tokens:[]}),i.raw+=p}let a=i.items.at(-1);if(a)a.raw=a.raw.trimEnd(),a.text=a.text.trimEnd();else return;i.raw=i.raw.trimEnd();for(let c=0;cd.type==="space"),u=p.length>0&&p.some(d=>this.rules.other.anyLine.test(d.raw));i.loose=u}if(i.loose)for(let c=0;c({text:a,tokens:this.lexer.inline(a),header:!1,align:r.align[c]})));return r}}lheading(e){let t=this.rules.block.lheading.exec(e);if(t)return{type:"heading",raw:t[0],depth:t[2].charAt(0)==="="?1:2,text:t[1],tokens:this.lexer.inline(t[1])}}paragraph(e){let t=this.rules.block.paragraph.exec(e);if(t){let n=t[1].charAt(t[1].length-1)===` +`?t[1].slice(0,-1):t[1];return{type:"paragraph",raw:t[0],text:n,tokens:this.lexer.inline(n)}}}text(e){let t=this.rules.block.text.exec(e);if(t)return{type:"text",raw:t[0],text:t[0],tokens:this.lexer.inline(t[0])}}escape(e){let t=this.rules.inline.escape.exec(e);if(t)return{type:"escape",raw:t[0],text:t[1]}}tag(e){let t=this.rules.inline.tag.exec(e);if(t)return!this.lexer.state.inLink&&this.rules.other.startATag.test(t[0])?this.lexer.state.inLink=!0:this.lexer.state.inLink&&this.rules.other.endATag.test(t[0])&&(this.lexer.state.inLink=!1),!this.lexer.state.inRawBlock&&this.rules.other.startPreScriptTag.test(t[0])?this.lexer.state.inRawBlock=!0:this.lexer.state.inRawBlock&&this.rules.other.endPreScriptTag.test(t[0])&&(this.lexer.state.inRawBlock=!1),{type:"html",raw:t[0],inLink:this.lexer.state.inLink,inRawBlock:this.lexer.state.inRawBlock,block:!1,text:t[0]}}link(e){let t=this.rules.inline.link.exec(e);if(t){let n=t[2].trim();if(!this.options.pedantic&&this.rules.other.startAngleBracket.test(n)){if(!this.rules.other.endAngleBracket.test(n))return;let r=A(n.slice(0,-1),"\\");if((n.length-r.length)%2===0)return}else{let r=de(t[2],"()");if(r===-2)return;if(r>-1){let a=(t[0].indexOf("!")===0?5:4)+t[1].length+r;t[2]=t[2].substring(0,r),t[0]=t[0].substring(0,a).trim(),t[3]=""}}let s=t[2],i="";if(this.options.pedantic){let r=this.rules.other.pedanticHrefTitle.exec(s);r&&(s=r[1],i=r[3])}else i=t[3]?t[3].slice(1,-1):"";return s=s.trim(),this.rules.other.startAngleBracket.test(s)&&(this.options.pedantic&&!this.rules.other.endAngleBracket.test(n)?s=s.slice(1):s=s.slice(1,-1)),me(t,{href:s&&s.replace(this.rules.inline.anyPunctuation,"$1"),title:i&&i.replace(this.rules.inline.anyPunctuation,"$1")},t[0],this.lexer,this.rules)}}reflink(e,t){let n;if((n=this.rules.inline.reflink.exec(e))||(n=this.rules.inline.nolink.exec(e))){let s=(n[2]||n[1]).replace(this.rules.other.multipleSpaceGlobal," "),i=t[s.toLowerCase()];if(!i){let r=n[0].charAt(0);return{type:"text",raw:r,text:r}}return me(n,i,n[0],this.lexer,this.rules)}}emStrong(e,t,n=""){let s=this.rules.inline.emStrongLDelim.exec(e);if(!s||s[3]&&n.match(this.rules.other.unicodeAlphaNumeric))return;if(!(s[1]||s[2]||"")||!n||this.rules.inline.punctuation.exec(n)){let r=[...s[0]].length-1,o,a,c=r,p=0,u=s[0][0]==="*"?this.rules.inline.emStrongRDelimAst:this.rules.inline.emStrongRDelimUnd;for(u.lastIndex=0,t=t.slice(-1*e.length+r);(s=u.exec(t))!=null;){if(o=s[1]||s[2]||s[3]||s[4]||s[5]||s[6],!o)continue;if(a=[...o].length,s[3]||s[4]){c+=a;continue}else if((s[5]||s[6])&&r%3&&!((r+a)%3)){p+=a;continue}if(c-=a,c>0)continue;a=Math.min(a,a+c+p);let d=[...s[0]][0].length,g=e.slice(0,r+s.index+d+a);if(Math.min(r,a)%2){let f=g.slice(1,-1);return{type:"em",raw:g,text:f,tokens:this.lexer.inlineTokens(f)}}let T=g.slice(2,-2);return{type:"strong",raw:g,text:T,tokens:this.lexer.inlineTokens(T)}}}}codespan(e){let t=this.rules.inline.code.exec(e);if(t){let n=t[2].replace(this.rules.other.newLineCharGlobal," "),s=this.rules.other.nonSpaceChar.test(n),i=this.rules.other.startingSpaceChar.test(n)&&this.rules.other.endingSpaceChar.test(n);return s&&i&&(n=n.substring(1,n.length-1)),{type:"codespan",raw:t[0],text:n}}}br(e){let t=this.rules.inline.br.exec(e);if(t)return{type:"br",raw:t[0]}}del(e){let t=this.rules.inline.del.exec(e);if(t)return{type:"del",raw:t[0],text:t[2],tokens:this.lexer.inlineTokens(t[2])}}autolink(e){let t=this.rules.inline.autolink.exec(e);if(t){let n,s;return t[2]==="@"?(n=t[1],s="mailto:"+n):(n=t[1],s=n),{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}url(e){let t;if(t=this.rules.inline.url.exec(e)){let n,s;if(t[2]==="@")n=t[0],s="mailto:"+n;else{let i;do i=t[0],t[0]=this.rules.inline._backpedal.exec(t[0])?.[0]??"";while(i!==t[0]);n=t[0],t[1]==="www."?s="http://"+t[0]:s=t[0]}return{type:"link",raw:t[0],text:n,href:s,tokens:[{type:"text",raw:n,text:n}]}}}inlineText(e){let t=this.rules.inline.text.exec(e);if(t){let n=this.lexer.state.inRawBlock;return{type:"text",raw:t[0],text:t[0],escaped:n}}}};var x=class l{tokens;options;state;tokenizer;inlineQueue;constructor(e){this.tokens=[],this.tokens.links=Object.create(null),this.options=e||w,this.options.tokenizer=this.options.tokenizer||new S,this.tokenizer=this.options.tokenizer,this.tokenizer.options=this.options,this.tokenizer.lexer=this,this.inlineQueue=[],this.state={inLink:!1,inRawBlock:!1,top:!0};let t={other:m,block:B.normal,inline:P.normal};this.options.pedantic?(t.block=B.pedantic,t.inline=P.pedantic):this.options.gfm&&(t.block=B.gfm,this.options.breaks?t.inline=P.breaks:t.inline=P.gfm),this.tokenizer.rules=t}static get rules(){return{block:B,inline:P}}static lex(e,t){return new l(t).lex(e)}static lexInline(e,t){return new l(t).inlineTokens(e)}lex(e){e=e.replace(m.carriageReturn,` +`),this.blockTokens(e,this.tokens);for(let t=0;t(s=r.call({lexer:this},e,t))?(e=e.substring(s.raw.length),t.push(s),!0):!1))continue;if(s=this.tokenizer.space(e)){e=e.substring(s.raw.length);let r=t.at(-1);s.raw.length===1&&r!==void 0?r.raw+=` +`:t.push(s);continue}if(s=this.tokenizer.code(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=` +`+s.raw,r.text+=` +`+s.text,this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(s=this.tokenizer.fences(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.heading(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.hr(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.blockquote(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.list(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.html(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.def(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="paragraph"||r?.type==="text"?(r.raw+=` +`+s.raw,r.text+=` +`+s.raw,this.inlineQueue.at(-1).src=r.text):this.tokens.links[s.tag]||(this.tokens.links[s.tag]={href:s.href,title:s.title});continue}if(s=this.tokenizer.table(e)){e=e.substring(s.raw.length),t.push(s);continue}if(s=this.tokenizer.lheading(e)){e=e.substring(s.raw.length),t.push(s);continue}let i=e;if(this.options.extensions?.startBlock){let r=1/0,o=e.slice(1),a;this.options.extensions.startBlock.forEach(c=>{a=c.call({lexer:this},o),typeof a=="number"&&a>=0&&(r=Math.min(r,a))}),r<1/0&&r>=0&&(i=e.substring(0,r+1))}if(this.state.top&&(s=this.tokenizer.paragraph(i))){let r=t.at(-1);n&&r?.type==="paragraph"?(r.raw+=` +`+s.raw,r.text+=` +`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s),n=i.length!==e.length,e=e.substring(s.raw.length);continue}if(s=this.tokenizer.text(e)){e=e.substring(s.raw.length);let r=t.at(-1);r?.type==="text"?(r.raw+=` +`+s.raw,r.text+=` +`+s.text,this.inlineQueue.pop(),this.inlineQueue.at(-1).src=r.text):t.push(s);continue}if(e){let r="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(r);break}else throw new Error(r)}}return this.state.top=!0,t}inline(e,t=[]){return this.inlineQueue.push({src:e,tokens:t}),t}inlineTokens(e,t=[]){let n=e,s=null;if(this.tokens.links){let o=Object.keys(this.tokens.links);if(o.length>0)for(;(s=this.tokenizer.rules.inline.reflinkSearch.exec(n))!=null;)o.includes(s[0].slice(s[0].lastIndexOf("[")+1,-1))&&(n=n.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.reflinkSearch.lastIndex))}for(;(s=this.tokenizer.rules.inline.anyPunctuation.exec(n))!=null;)n=n.slice(0,s.index)+"++"+n.slice(this.tokenizer.rules.inline.anyPunctuation.lastIndex);for(;(s=this.tokenizer.rules.inline.blockSkip.exec(n))!=null;)n=n.slice(0,s.index)+"["+"a".repeat(s[0].length-2)+"]"+n.slice(this.tokenizer.rules.inline.blockSkip.lastIndex);let i=!1,r="";for(;e;){i||(r=""),i=!1;let o;if(this.options.extensions?.inline?.some(c=>(o=c.call({lexer:this},e,t))?(e=e.substring(o.raw.length),t.push(o),!0):!1))continue;if(o=this.tokenizer.escape(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.tag(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.link(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.reflink(e,this.tokens.links)){e=e.substring(o.raw.length);let c=t.at(-1);o.type==="text"&&c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):t.push(o);continue}if(o=this.tokenizer.emStrong(e,n,r)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.codespan(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.br(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.del(e)){e=e.substring(o.raw.length),t.push(o);continue}if(o=this.tokenizer.autolink(e)){e=e.substring(o.raw.length),t.push(o);continue}if(!this.state.inLink&&(o=this.tokenizer.url(e))){e=e.substring(o.raw.length),t.push(o);continue}let a=e;if(this.options.extensions?.startInline){let c=1/0,p=e.slice(1),u;this.options.extensions.startInline.forEach(d=>{u=d.call({lexer:this},p),typeof u=="number"&&u>=0&&(c=Math.min(c,u))}),c<1/0&&c>=0&&(a=e.substring(0,c+1))}if(o=this.tokenizer.inlineText(a)){e=e.substring(o.raw.length),o.raw.slice(-1)!=="_"&&(r=o.raw.slice(-1)),i=!0;let c=t.at(-1);c?.type==="text"?(c.raw+=o.raw,c.text+=o.text):t.push(o);continue}if(e){let c="Infinite loop on byte: "+e.charCodeAt(0);if(this.options.silent){console.error(c);break}else throw new Error(c)}}return t}};var $=class{options;parser;constructor(e){this.options=e||w}space(e){return""}code({text:e,lang:t,escaped:n}){let s=(t||"").match(m.notSpaceStart)?.[0],i=e.replace(m.endingNewline,"")+` +`;return s?'
    '+(n?i:R(i,!0))+`
    +`:"
    "+(n?i:R(i,!0))+`
    +`}blockquote({tokens:e}){return`
    +${this.parser.parse(e)}
    +`}html({text:e}){return e}heading({tokens:e,depth:t}){return`${this.parser.parseInline(e)} +`}hr(e){return`
    +`}list(e){let t=e.ordered,n=e.start,s="";for(let o=0;o +`+s+" +`}listitem(e){let t="";if(e.task){let n=this.checkbox({checked:!!e.checked});e.loose?e.tokens[0]?.type==="paragraph"?(e.tokens[0].text=n+" "+e.tokens[0].text,e.tokens[0].tokens&&e.tokens[0].tokens.length>0&&e.tokens[0].tokens[0].type==="text"&&(e.tokens[0].tokens[0].text=n+" "+R(e.tokens[0].tokens[0].text),e.tokens[0].tokens[0].escaped=!0)):e.tokens.unshift({type:"text",raw:n+" ",text:n+" ",escaped:!0}):t+=n+" "}return t+=this.parser.parse(e.tokens,!!e.loose),`
  • ${t}
  • +`}checkbox({checked:e}){return"'}paragraph({tokens:e}){return`

    ${this.parser.parseInline(e)}

    +`}table(e){let t="",n="";for(let i=0;i${s}`),` + +`+t+` +`+s+`
    +`}tablerow({text:e}){return` +${e} +`}tablecell(e){let t=this.parser.parseInline(e.tokens),n=e.header?"th":"td";return(e.align?`<${n} align="${e.align}">`:`<${n}>`)+t+` +`}strong({tokens:e}){return`${this.parser.parseInline(e)}`}em({tokens:e}){return`${this.parser.parseInline(e)}`}codespan({text:e}){return`${R(e,!0)}`}br(e){return"
    "}del({tokens:e}){return`${this.parser.parseInline(e)}`}link({href:e,title:t,tokens:n}){let s=this.parser.parseInline(n),i=V(e);if(i===null)return s;e=i;let r='
    ",r}image({href:e,title:t,text:n,tokens:s}){s&&(n=this.parser.parseInline(s,this.parser.textRenderer));let i=V(e);if(i===null)return R(n);e=i;let r=`${n}{let o=i[r].flat(1/0);n=n.concat(this.walkTokens(o,t))}):i.tokens&&(n=n.concat(this.walkTokens(i.tokens,t)))}}return n}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(n=>{let s={...n};if(s.async=this.defaults.async||s.async||!1,n.extensions&&(n.extensions.forEach(i=>{if(!i.name)throw new Error("extension name required");if("renderer"in i){let r=t.renderers[i.name];r?t.renderers[i.name]=function(...o){let a=i.renderer.apply(this,o);return a===!1&&(a=r.apply(this,o)),a}:t.renderers[i.name]=i.renderer}if("tokenizer"in i){if(!i.level||i.level!=="block"&&i.level!=="inline")throw new Error("extension level must be 'block' or 'inline'");let r=t[i.level];r?r.unshift(i.tokenizer):t[i.level]=[i.tokenizer],i.start&&(i.level==="block"?t.startBlock?t.startBlock.push(i.start):t.startBlock=[i.start]:i.level==="inline"&&(t.startInline?t.startInline.push(i.start):t.startInline=[i.start]))}"childTokens"in i&&i.childTokens&&(t.childTokens[i.name]=i.childTokens)}),s.extensions=t),n.renderer){let i=this.defaults.renderer||new $(this.defaults);for(let r in n.renderer){if(!(r in i))throw new Error(`renderer '${r}' does not exist`);if(["options","parser"].includes(r))continue;let o=r,a=n.renderer[o],c=i[o];i[o]=(...p)=>{let u=a.apply(i,p);return u===!1&&(u=c.apply(i,p)),u||""}}s.renderer=i}if(n.tokenizer){let i=this.defaults.tokenizer||new S(this.defaults);for(let r in n.tokenizer){if(!(r in i))throw new Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let o=r,a=n.tokenizer[o],c=i[o];i[o]=(...p)=>{let u=a.apply(i,p);return u===!1&&(u=c.apply(i,p)),u}}s.tokenizer=i}if(n.hooks){let i=this.defaults.hooks||new L;for(let r in n.hooks){if(!(r in i))throw new Error(`hook '${r}' does not exist`);if(["options","block"].includes(r))continue;let o=r,a=n.hooks[o],c=i[o];L.passThroughHooks.has(r)?i[o]=p=>{if(this.defaults.async)return Promise.resolve(a.call(i,p)).then(d=>c.call(i,d));let u=a.call(i,p);return c.call(i,u)}:i[o]=(...p)=>{let u=a.apply(i,p);return u===!1&&(u=c.apply(i,p)),u}}s.hooks=i}if(n.walkTokens){let i=this.defaults.walkTokens,r=n.walkTokens;s.walkTokens=function(o){let a=[];return a.push(r.call(this,o)),i&&(a=a.concat(i.call(this,o))),a}}this.defaults={...this.defaults,...s}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return x.lex(e,t??this.defaults)}parser(e,t){return b.parse(e,t??this.defaults)}parseMarkdown(e){return(n,s)=>{let i={...s},r={...this.defaults,...i},o=this.onError(!!r.silent,!!r.async);if(this.defaults.async===!0&&i.async===!1)return o(new Error("marked(): The async option was set to true by an extension. Remove async: false from the parse options object to return a Promise."));if(typeof n>"u"||n===null)return o(new Error("marked(): input parameter is undefined or null"));if(typeof n!="string")return o(new Error("marked(): input parameter is of type "+Object.prototype.toString.call(n)+", string expected"));r.hooks&&(r.hooks.options=r,r.hooks.block=e);let a=r.hooks?r.hooks.provideLexer():e?x.lex:x.lexInline,c=r.hooks?r.hooks.provideParser():e?b.parse:b.parseInline;if(r.async)return Promise.resolve(r.hooks?r.hooks.preprocess(n):n).then(p=>a(p,r)).then(p=>r.hooks?r.hooks.processAllTokens(p):p).then(p=>r.walkTokens?Promise.all(this.walkTokens(p,r.walkTokens)).then(()=>p):p).then(p=>c(p,r)).then(p=>r.hooks?r.hooks.postprocess(p):p).catch(o);try{r.hooks&&(n=r.hooks.preprocess(n));let p=a(n,r);r.hooks&&(p=r.hooks.processAllTokens(p)),r.walkTokens&&this.walkTokens(p,r.walkTokens);let u=c(p,r);return r.hooks&&(u=r.hooks.postprocess(u)),u}catch(p){return o(p)}}}onError(e,t){return n=>{if(n.message+=` +Please report this to https://github.com/markedjs/marked.`,e){let s="

    An error occurred:

    "+R(n.message+"",!0)+"
    ";return t?Promise.resolve(s):s}if(t)return Promise.reject(n);throw n}}};var M=new E;function k(l,e){return M.parse(l,e)}k.options=k.setOptions=function(l){return M.setOptions(l),k.defaults=M.defaults,N(k.defaults),k};k.getDefaults=z;k.defaults=w;k.use=function(...l){return M.use(...l),k.defaults=M.defaults,N(k.defaults),k};k.walkTokens=function(l,e){return M.walkTokens(l,e)};k.parseInline=M.parseInline;k.Parser=b;k.parser=b.parse;k.Renderer=$;k.TextRenderer=_;k.Lexer=x;k.lexer=x.lex;k.Tokenizer=S;k.Hooks=L;k.parse=k;var it=k.options,ot=k.setOptions,lt=k.use,at=k.walkTokens,ct=k.parseInline,pt=k,ut=b.parse,ht=x.lex; + +if(__exports != exports)module.exports = exports;return module.exports})); diff --git a/InfoGenie-frontend/public/toolbox/Markdown解析器/purify.min.js b/InfoGenie-frontend/public/toolbox/Markdown解析器/purify.min.js new file mode 100644 index 00000000..7a4da768 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/Markdown解析器/purify.min.js @@ -0,0 +1,3 @@ +/*! @license DOMPurify 3.0.6 | (c) Cure53 and other contributors | Released under the Apache license 2.0 and Mozilla Public License 2.0 | github.com/cure53/DOMPurify/blob/3.0.6/LICENSE */ +!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).DOMPurify=t()}(this,(function(){"use strict";const{entries:e,setPrototypeOf:t,isFrozen:n,getPrototypeOf:o,getOwnPropertyDescriptor:r}=Object;let{freeze:i,seal:a,create:l}=Object,{apply:c,construct:s}="undefined"!=typeof Reflect&&Reflect;i||(i=function(e){return e}),a||(a=function(e){return e}),c||(c=function(e,t,n){return e.apply(t,n)}),s||(s=function(e,t){return new e(...t)});const u=N(Array.prototype.forEach),m=N(Array.prototype.pop),f=N(Array.prototype.push),p=N(String.prototype.toLowerCase),d=N(String.prototype.toString),h=N(String.prototype.match),g=N(String.prototype.replace),T=N(String.prototype.indexOf),y=N(String.prototype.trim),E=N(RegExp.prototype.test),A=(_=TypeError,function(){for(var e=arguments.length,t=new Array(e),n=0;n1?n-1:0),r=1;r2&&void 0!==arguments[2]?arguments[2]:p;t&&t(e,null);let i=o.length;for(;i--;){let t=o[i];if("string"==typeof t){const e=r(t);e!==t&&(n(o)||(o[i]=e),t=e)}e[t]=!0}return e}function S(t){const n=l(null);for(const[o,i]of e(t))void 0!==r(t,o)&&(n[o]=i);return n}function R(e,t){for(;null!==e;){const n=r(e,t);if(n){if(n.get)return N(n.get);if("function"==typeof n.value)return N(n.value)}e=o(e)}return function(e){return console.warn("fallback value for",e),null}}const w=i(["a","abbr","acronym","address","area","article","aside","audio","b","bdi","bdo","big","blink","blockquote","body","br","button","canvas","caption","center","cite","code","col","colgroup","content","data","datalist","dd","decorator","del","details","dfn","dialog","dir","div","dl","dt","element","em","fieldset","figcaption","figure","font","footer","form","h1","h2","h3","h4","h5","h6","head","header","hgroup","hr","html","i","img","input","ins","kbd","label","legend","li","main","map","mark","marquee","menu","menuitem","meter","nav","nobr","ol","optgroup","option","output","p","picture","pre","progress","q","rp","rt","ruby","s","samp","section","select","shadow","small","source","spacer","span","strike","strong","style","sub","summary","sup","table","tbody","td","template","textarea","tfoot","th","thead","time","tr","track","tt","u","ul","var","video","wbr"]),D=i(["svg","a","altglyph","altglyphdef","altglyphitem","animatecolor","animatemotion","animatetransform","circle","clippath","defs","desc","ellipse","filter","font","g","glyph","glyphref","hkern","image","line","lineargradient","marker","mask","metadata","mpath","path","pattern","polygon","polyline","radialgradient","rect","stop","style","switch","symbol","text","textpath","title","tref","tspan","view","vkern"]),L=i(["feBlend","feColorMatrix","feComponentTransfer","feComposite","feConvolveMatrix","feDiffuseLighting","feDisplacementMap","feDistantLight","feDropShadow","feFlood","feFuncA","feFuncB","feFuncG","feFuncR","feGaussianBlur","feImage","feMerge","feMergeNode","feMorphology","feOffset","fePointLight","feSpecularLighting","feSpotLight","feTile","feTurbulence"]),v=i(["animate","color-profile","cursor","discard","font-face","font-face-format","font-face-name","font-face-src","font-face-uri","foreignobject","hatch","hatchpath","mesh","meshgradient","meshpatch","meshrow","missing-glyph","script","set","solidcolor","unknown","use"]),x=i(["math","menclose","merror","mfenced","mfrac","mglyph","mi","mlabeledtr","mmultiscripts","mn","mo","mover","mpadded","mphantom","mroot","mrow","ms","mspace","msqrt","mstyle","msub","msup","msubsup","mtable","mtd","mtext","mtr","munder","munderover","mprescripts"]),k=i(["maction","maligngroup","malignmark","mlongdiv","mscarries","mscarry","msgroup","mstack","msline","msrow","semantics","annotation","annotation-xml","mprescripts","none"]),C=i(["#text"]),O=i(["accept","action","align","alt","autocapitalize","autocomplete","autopictureinpicture","autoplay","background","bgcolor","border","capture","cellpadding","cellspacing","checked","cite","class","clear","color","cols","colspan","controls","controlslist","coords","crossorigin","datetime","decoding","default","dir","disabled","disablepictureinpicture","disableremoteplayback","download","draggable","enctype","enterkeyhint","face","for","headers","height","hidden","high","href","hreflang","id","inputmode","integrity","ismap","kind","label","lang","list","loading","loop","low","max","maxlength","media","method","min","minlength","multiple","muted","name","nonce","noshade","novalidate","nowrap","open","optimum","pattern","placeholder","playsinline","poster","preload","pubdate","radiogroup","readonly","rel","required","rev","reversed","role","rows","rowspan","spellcheck","scope","selected","shape","size","sizes","span","srclang","start","src","srcset","step","style","summary","tabindex","title","translate","type","usemap","valign","value","width","xmlns","slot"]),I=i(["accent-height","accumulate","additive","alignment-baseline","ascent","attributename","attributetype","azimuth","basefrequency","baseline-shift","begin","bias","by","class","clip","clippathunits","clip-path","clip-rule","color","color-interpolation","color-interpolation-filters","color-profile","color-rendering","cx","cy","d","dx","dy","diffuseconstant","direction","display","divisor","dur","edgemode","elevation","end","fill","fill-opacity","fill-rule","filter","filterunits","flood-color","flood-opacity","font-family","font-size","font-size-adjust","font-stretch","font-style","font-variant","font-weight","fx","fy","g1","g2","glyph-name","glyphref","gradientunits","gradienttransform","height","href","id","image-rendering","in","in2","k","k1","k2","k3","k4","kerning","keypoints","keysplines","keytimes","lang","lengthadjust","letter-spacing","kernelmatrix","kernelunitlength","lighting-color","local","marker-end","marker-mid","marker-start","markerheight","markerunits","markerwidth","maskcontentunits","maskunits","max","mask","media","method","mode","min","name","numoctaves","offset","operator","opacity","order","orient","orientation","origin","overflow","paint-order","path","pathlength","patterncontentunits","patterntransform","patternunits","points","preservealpha","preserveaspectratio","primitiveunits","r","rx","ry","radius","refx","refy","repeatcount","repeatdur","restart","result","rotate","scale","seed","shape-rendering","specularconstant","specularexponent","spreadmethod","startoffset","stddeviation","stitchtiles","stop-color","stop-opacity","stroke-dasharray","stroke-dashoffset","stroke-linecap","stroke-linejoin","stroke-miterlimit","stroke-opacity","stroke","stroke-width","style","surfacescale","systemlanguage","tabindex","targetx","targety","transform","transform-origin","text-anchor","text-decoration","text-rendering","textlength","type","u1","u2","unicode","values","viewbox","visibility","version","vert-adv-y","vert-origin-x","vert-origin-y","width","word-spacing","wrap","writing-mode","xchannelselector","ychannelselector","x","x1","x2","xmlns","y","y1","y2","z","zoomandpan"]),M=i(["accent","accentunder","align","bevelled","close","columnsalign","columnlines","columnspan","denomalign","depth","dir","display","displaystyle","encoding","fence","frame","height","href","id","largeop","length","linethickness","lspace","lquote","mathbackground","mathcolor","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","numalign","open","rowalign","rowlines","rowspacing","rowspan","rspace","rquote","scriptlevel","scriptminsize","scriptsizemultiplier","selection","separator","separators","stretchy","subscriptshift","supscriptshift","symmetric","voffset","width","xmlns"]),U=i(["xlink:href","xml:id","xlink:title","xml:space","xmlns:xlink"]),P=a(/\{\{[\w\W]*|[\w\W]*\}\}/gm),F=a(/<%[\w\W]*|[\w\W]*%>/gm),H=a(/\${[\w\W]*}/gm),z=a(/^data-[\-\w.\u00B7-\uFFFF]/),B=a(/^aria-[\-\w]+$/),W=a(/^(?:(?:(?:f|ht)tps?|mailto|tel|callto|sms|cid|xmpp):|[^a-z]|[a-z+.\-]+(?:[^a-z+.\-:]|$))/i),G=a(/^(?:\w+script|data):/i),Y=a(/[\u0000-\u0020\u00A0\u1680\u180E\u2000-\u2029\u205F\u3000]/g),j=a(/^html$/i);var q=Object.freeze({__proto__:null,MUSTACHE_EXPR:P,ERB_EXPR:F,TMPLIT_EXPR:H,DATA_ATTR:z,ARIA_ATTR:B,IS_ALLOWED_URI:W,IS_SCRIPT_OR_DATA:G,ATTR_WHITESPACE:Y,DOCTYPE_NAME:j});const X=function(){return"undefined"==typeof window?null:window},K=function(e,t){if("object"!=typeof e||"function"!=typeof e.createPolicy)return null;let n=null;const o="data-tt-policy-suffix";t&&t.hasAttribute(o)&&(n=t.getAttribute(o));const r="dompurify"+(n?"#"+n:"");try{return e.createPolicy(r,{createHTML:e=>e,createScriptURL:e=>e})}catch(e){return console.warn("TrustedTypes policy "+r+" could not be created."),null}};var V=function t(){let n=arguments.length>0&&void 0!==arguments[0]?arguments[0]:X();const o=e=>t(e);if(o.version="3.0.6",o.removed=[],!n||!n.document||9!==n.document.nodeType)return o.isSupported=!1,o;let{document:r}=n;const a=r,c=a.currentScript,{DocumentFragment:s,HTMLTemplateElement:_,Node:N,Element:P,NodeFilter:F,NamedNodeMap:H=n.NamedNodeMap||n.MozNamedAttrMap,HTMLFormElement:z,DOMParser:B,trustedTypes:G}=n,Y=P.prototype,V=R(Y,"cloneNode"),$=R(Y,"nextSibling"),Z=R(Y,"childNodes"),J=R(Y,"parentNode");if("function"==typeof _){const e=r.createElement("template");e.content&&e.content.ownerDocument&&(r=e.content.ownerDocument)}let Q,ee="";const{implementation:te,createNodeIterator:ne,createDocumentFragment:oe,getElementsByTagName:re}=r,{importNode:ie}=a;let ae={};o.isSupported="function"==typeof e&&"function"==typeof J&&te&&void 0!==te.createHTMLDocument;const{MUSTACHE_EXPR:le,ERB_EXPR:ce,TMPLIT_EXPR:se,DATA_ATTR:ue,ARIA_ATTR:me,IS_SCRIPT_OR_DATA:fe,ATTR_WHITESPACE:pe}=q;let{IS_ALLOWED_URI:de}=q,he=null;const ge=b({},[...w,...D,...L,...x,...C]);let Te=null;const ye=b({},[...O,...I,...M,...U]);let Ee=Object.seal(l(null,{tagNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},attributeNameCheck:{writable:!0,configurable:!1,enumerable:!0,value:null},allowCustomizedBuiltInElements:{writable:!0,configurable:!1,enumerable:!0,value:!1}})),Ae=null,_e=null,Ne=!0,be=!0,Se=!1,Re=!0,we=!1,De=!1,Le=!1,ve=!1,xe=!1,ke=!1,Ce=!1,Oe=!0,Ie=!1;const Me="user-content-";let Ue=!0,Pe=!1,Fe={},He=null;const ze=b({},["annotation-xml","audio","colgroup","desc","foreignobject","head","iframe","math","mi","mn","mo","ms","mtext","noembed","noframes","noscript","plaintext","script","style","svg","template","thead","title","video","xmp"]);let Be=null;const We=b({},["audio","video","img","source","image","track"]);let Ge=null;const Ye=b({},["alt","class","for","id","label","name","pattern","placeholder","role","summary","title","value","style","xmlns"]),je="http://www.w3.org/1998/Math/MathML",qe="http://www.w3.org/2000/svg",Xe="http://www.w3.org/1999/xhtml";let Ke=Xe,Ve=!1,$e=null;const Ze=b({},[je,qe,Xe],d);let Je=null;const Qe=["application/xhtml+xml","text/html"],et="text/html";let tt=null,nt=null;const ot=r.createElement("form"),rt=function(e){return e instanceof RegExp||e instanceof Function},it=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};if(!nt||nt!==e){if(e&&"object"==typeof e||(e={}),e=S(e),Je=Je=-1===Qe.indexOf(e.PARSER_MEDIA_TYPE)?et:e.PARSER_MEDIA_TYPE,tt="application/xhtml+xml"===Je?d:p,he="ALLOWED_TAGS"in e?b({},e.ALLOWED_TAGS,tt):ge,Te="ALLOWED_ATTR"in e?b({},e.ALLOWED_ATTR,tt):ye,$e="ALLOWED_NAMESPACES"in e?b({},e.ALLOWED_NAMESPACES,d):Ze,Ge="ADD_URI_SAFE_ATTR"in e?b(S(Ye),e.ADD_URI_SAFE_ATTR,tt):Ye,Be="ADD_DATA_URI_TAGS"in e?b(S(We),e.ADD_DATA_URI_TAGS,tt):We,He="FORBID_CONTENTS"in e?b({},e.FORBID_CONTENTS,tt):ze,Ae="FORBID_TAGS"in e?b({},e.FORBID_TAGS,tt):{},_e="FORBID_ATTR"in e?b({},e.FORBID_ATTR,tt):{},Fe="USE_PROFILES"in e&&e.USE_PROFILES,Ne=!1!==e.ALLOW_ARIA_ATTR,be=!1!==e.ALLOW_DATA_ATTR,Se=e.ALLOW_UNKNOWN_PROTOCOLS||!1,Re=!1!==e.ALLOW_SELF_CLOSE_IN_ATTR,we=e.SAFE_FOR_TEMPLATES||!1,De=e.WHOLE_DOCUMENT||!1,xe=e.RETURN_DOM||!1,ke=e.RETURN_DOM_FRAGMENT||!1,Ce=e.RETURN_TRUSTED_TYPE||!1,ve=e.FORCE_BODY||!1,Oe=!1!==e.SANITIZE_DOM,Ie=e.SANITIZE_NAMED_PROPS||!1,Ue=!1!==e.KEEP_CONTENT,Pe=e.IN_PLACE||!1,de=e.ALLOWED_URI_REGEXP||W,Ke=e.NAMESPACE||Xe,Ee=e.CUSTOM_ELEMENT_HANDLING||{},e.CUSTOM_ELEMENT_HANDLING&&rt(e.CUSTOM_ELEMENT_HANDLING.tagNameCheck)&&(Ee.tagNameCheck=e.CUSTOM_ELEMENT_HANDLING.tagNameCheck),e.CUSTOM_ELEMENT_HANDLING&&rt(e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck)&&(Ee.attributeNameCheck=e.CUSTOM_ELEMENT_HANDLING.attributeNameCheck),e.CUSTOM_ELEMENT_HANDLING&&"boolean"==typeof e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements&&(Ee.allowCustomizedBuiltInElements=e.CUSTOM_ELEMENT_HANDLING.allowCustomizedBuiltInElements),we&&(be=!1),ke&&(xe=!0),Fe&&(he=b({},[...C]),Te=[],!0===Fe.html&&(b(he,w),b(Te,O)),!0===Fe.svg&&(b(he,D),b(Te,I),b(Te,U)),!0===Fe.svgFilters&&(b(he,L),b(Te,I),b(Te,U)),!0===Fe.mathMl&&(b(he,x),b(Te,M),b(Te,U))),e.ADD_TAGS&&(he===ge&&(he=S(he)),b(he,e.ADD_TAGS,tt)),e.ADD_ATTR&&(Te===ye&&(Te=S(Te)),b(Te,e.ADD_ATTR,tt)),e.ADD_URI_SAFE_ATTR&&b(Ge,e.ADD_URI_SAFE_ATTR,tt),e.FORBID_CONTENTS&&(He===ze&&(He=S(He)),b(He,e.FORBID_CONTENTS,tt)),Ue&&(he["#text"]=!0),De&&b(he,["html","head","body"]),he.table&&(b(he,["tbody"]),delete Ae.tbody),e.TRUSTED_TYPES_POLICY){if("function"!=typeof e.TRUSTED_TYPES_POLICY.createHTML)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createHTML" hook.');if("function"!=typeof e.TRUSTED_TYPES_POLICY.createScriptURL)throw A('TRUSTED_TYPES_POLICY configuration option must provide a "createScriptURL" hook.');Q=e.TRUSTED_TYPES_POLICY,ee=Q.createHTML("")}else void 0===Q&&(Q=K(G,c)),null!==Q&&"string"==typeof ee&&(ee=Q.createHTML(""));i&&i(e),nt=e}},at=b({},["mi","mo","mn","ms","mtext"]),lt=b({},["foreignobject","desc","title","annotation-xml"]),ct=b({},["title","style","font","a","script"]),st=b({},D);b(st,L),b(st,v);const ut=b({},x);b(ut,k);const mt=function(e){let t=J(e);t&&t.tagName||(t={namespaceURI:Ke,tagName:"template"});const n=p(e.tagName),o=p(t.tagName);return!!$e[e.namespaceURI]&&(e.namespaceURI===qe?t.namespaceURI===Xe?"svg"===n:t.namespaceURI===je?"svg"===n&&("annotation-xml"===o||at[o]):Boolean(st[n]):e.namespaceURI===je?t.namespaceURI===Xe?"math"===n:t.namespaceURI===qe?"math"===n&<[o]:Boolean(ut[n]):e.namespaceURI===Xe?!(t.namespaceURI===qe&&!lt[o])&&(!(t.namespaceURI===je&&!at[o])&&(!ut[n]&&(ct[n]||!st[n]))):!("application/xhtml+xml"!==Je||!$e[e.namespaceURI]))},ft=function(e){f(o.removed,{element:e});try{e.parentNode.removeChild(e)}catch(t){e.remove()}},pt=function(e,t){try{f(o.removed,{attribute:t.getAttributeNode(e),from:t})}catch(e){f(o.removed,{attribute:null,from:t})}if(t.removeAttribute(e),"is"===e&&!Te[e])if(xe||ke)try{ft(t)}catch(e){}else try{t.setAttribute(e,"")}catch(e){}},dt=function(e){let t=null,n=null;if(ve)e=""+e;else{const t=h(e,/^[\r\n\t ]+/);n=t&&t[0]}"application/xhtml+xml"===Je&&Ke===Xe&&(e=''+e+"");const o=Q?Q.createHTML(e):e;if(Ke===Xe)try{t=(new B).parseFromString(o,Je)}catch(e){}if(!t||!t.documentElement){t=te.createDocument(Ke,"template",null);try{t.documentElement.innerHTML=Ve?ee:o}catch(e){}}const i=t.body||t.documentElement;return e&&n&&i.insertBefore(r.createTextNode(n),i.childNodes[0]||null),Ke===Xe?re.call(t,De?"html":"body")[0]:De?t.documentElement:i},ht=function(e){return ne.call(e.ownerDocument||e,e,F.SHOW_ELEMENT|F.SHOW_COMMENT|F.SHOW_TEXT,null)},gt=function(e){return e instanceof z&&("string"!=typeof e.nodeName||"string"!=typeof e.textContent||"function"!=typeof e.removeChild||!(e.attributes instanceof H)||"function"!=typeof e.removeAttribute||"function"!=typeof e.setAttribute||"string"!=typeof e.namespaceURI||"function"!=typeof e.insertBefore||"function"!=typeof e.hasChildNodes)},Tt=function(e){return"function"==typeof N&&e instanceof N},yt=function(e,t,n){ae[e]&&u(ae[e],(e=>{e.call(o,t,n,nt)}))},Et=function(e){let t=null;if(yt("beforeSanitizeElements",e,null),gt(e))return ft(e),!0;const n=tt(e.nodeName);if(yt("uponSanitizeElement",e,{tagName:n,allowedTags:he}),e.hasChildNodes()&&!Tt(e.firstElementChild)&&E(/<[/\w]/g,e.innerHTML)&&E(/<[/\w]/g,e.textContent))return ft(e),!0;if(!he[n]||Ae[n]){if(!Ae[n]&&_t(n)){if(Ee.tagNameCheck instanceof RegExp&&E(Ee.tagNameCheck,n))return!1;if(Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(n))return!1}if(Ue&&!He[n]){const t=J(e)||e.parentNode,n=Z(e)||e.childNodes;if(n&&t){for(let o=n.length-1;o>=0;--o)t.insertBefore(V(n[o],!0),$(e))}}return ft(e),!0}return e instanceof P&&!mt(e)?(ft(e),!0):"noscript"!==n&&"noembed"!==n&&"noframes"!==n||!E(/<\/no(script|embed|frames)/i,e.innerHTML)?(we&&3===e.nodeType&&(t=e.textContent,u([le,ce,se],(e=>{t=g(t,e," ")})),e.textContent!==t&&(f(o.removed,{element:e.cloneNode()}),e.textContent=t)),yt("afterSanitizeElements",e,null),!1):(ft(e),!0)},At=function(e,t,n){if(Oe&&("id"===t||"name"===t)&&(n in r||n in ot))return!1;if(be&&!_e[t]&&E(ue,t));else if(Ne&&E(me,t));else if(!Te[t]||_e[t]){if(!(_t(e)&&(Ee.tagNameCheck instanceof RegExp&&E(Ee.tagNameCheck,e)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(e))&&(Ee.attributeNameCheck instanceof RegExp&&E(Ee.attributeNameCheck,t)||Ee.attributeNameCheck instanceof Function&&Ee.attributeNameCheck(t))||"is"===t&&Ee.allowCustomizedBuiltInElements&&(Ee.tagNameCheck instanceof RegExp&&E(Ee.tagNameCheck,n)||Ee.tagNameCheck instanceof Function&&Ee.tagNameCheck(n))))return!1}else if(Ge[t]);else if(E(de,g(n,pe,"")));else if("src"!==t&&"xlink:href"!==t&&"href"!==t||"script"===e||0!==T(n,"data:")||!Be[e]){if(Se&&!E(fe,g(n,pe,"")));else if(n)return!1}else;return!0},_t=function(e){return e.indexOf("-")>0},Nt=function(e){yt("beforeSanitizeAttributes",e,null);const{attributes:t}=e;if(!t)return;const n={attrName:"",attrValue:"",keepAttr:!0,allowedAttributes:Te};let r=t.length;for(;r--;){const i=t[r],{name:a,namespaceURI:l,value:c}=i,s=tt(a);let f="value"===a?c:y(c);if(n.attrName=s,n.attrValue=f,n.keepAttr=!0,n.forceKeepAttr=void 0,yt("uponSanitizeAttribute",e,n),f=n.attrValue,n.forceKeepAttr)continue;if(pt(a,e),!n.keepAttr)continue;if(!Re&&E(/\/>/i,f)){pt(a,e);continue}we&&u([le,ce,se],(e=>{f=g(f,e," ")}));const p=tt(e.nodeName);if(At(p,s,f)){if(!Ie||"id"!==s&&"name"!==s||(pt(a,e),f=Me+f),Q&&"object"==typeof G&&"function"==typeof G.getAttributeType)if(l);else switch(G.getAttributeType(p,s)){case"TrustedHTML":f=Q.createHTML(f);break;case"TrustedScriptURL":f=Q.createScriptURL(f)}try{l?e.setAttributeNS(l,a,f):e.setAttribute(a,f),m(o.removed)}catch(e){}}}yt("afterSanitizeAttributes",e,null)},bt=function e(t){let n=null;const o=ht(t);for(yt("beforeSanitizeShadowDOM",t,null);n=o.nextNode();)yt("uponSanitizeShadowNode",n,null),Et(n)||(n.content instanceof s&&e(n.content),Nt(n));yt("afterSanitizeShadowDOM",t,null)};return o.sanitize=function(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=null,r=null,i=null,l=null;if(Ve=!e,Ve&&(e="\x3c!--\x3e"),"string"!=typeof e&&!Tt(e)){if("function"!=typeof e.toString)throw A("toString is not a function");if("string"!=typeof(e=e.toString()))throw A("dirty is not a string, aborting")}if(!o.isSupported)return e;if(Le||it(t),o.removed=[],"string"==typeof e&&(Pe=!1),Pe){if(e.nodeName){const t=tt(e.nodeName);if(!he[t]||Ae[t])throw A("root node is forbidden and cannot be sanitized in-place")}}else if(e instanceof N)n=dt("\x3c!----\x3e"),r=n.ownerDocument.importNode(e,!0),1===r.nodeType&&"BODY"===r.nodeName||"HTML"===r.nodeName?n=r:n.appendChild(r);else{if(!xe&&!we&&!De&&-1===e.indexOf("<"))return Q&&Ce?Q.createHTML(e):e;if(n=dt(e),!n)return xe?null:Ce?ee:""}n&&ve&&ft(n.firstChild);const c=ht(Pe?e:n);for(;i=c.nextNode();)Et(i)||(i.content instanceof s&&bt(i.content),Nt(i));if(Pe)return e;if(xe){if(ke)for(l=oe.call(n.ownerDocument);n.firstChild;)l.appendChild(n.firstChild);else l=n;return(Te.shadowroot||Te.shadowrootmode)&&(l=ie.call(a,l,!0)),l}let m=De?n.outerHTML:n.innerHTML;return De&&he["!doctype"]&&n.ownerDocument&&n.ownerDocument.doctype&&n.ownerDocument.doctype.name&&E(j,n.ownerDocument.doctype.name)&&(m="\n"+m),we&&u([le,ce,se],(e=>{m=g(m,e," ")})),Q&&Ce?Q.createHTML(m):m},o.setConfig=function(){let e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};it(e),Le=!0},o.clearConfig=function(){nt=null,Le=!1},o.isValidAttribute=function(e,t,n){nt||it({});const o=tt(e),r=tt(t);return At(o,r,n)},o.addHook=function(e,t){"function"==typeof t&&(ae[e]=ae[e]||[],f(ae[e],t))},o.removeHook=function(e){if(ae[e])return m(ae[e])},o.removeHooks=function(e){ae[e]&&(ae[e]=[])},o.removeAllHooks=function(){ae={}},o}();return V})); +//# sourceMappingURL=purify.min.js.map diff --git a/InfoGenie-frontend/public/toolbox/人生倒计时/index.html b/InfoGenie-frontend/public/toolbox/人生倒计时/index.html new file mode 100644 index 00000000..fb30702f --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/人生倒计时/index.html @@ -0,0 +1,202 @@ + + + + +人生倒计时 + + + + + +
    +
    +

    人生倒计时

    +
    +
    +
    今天 · 剩余小时
    +
    +
    距离今天结束还有
    +
    -- 小时
    +
    +
    +
    +
    +
    +
    本周 · 剩余天数
    +
    +
    (周一为一周起点)
    +
    --
    +
    +
    +
    +
    +
    + +
    +
    本月 · 剩余天数
    +
    +
    当前月份还剩
    +
    --
    +
    +
    +
    +
    +
    + +
    +
    2025 · 剩余天数
    +
    +
    距离今年结束还有
    +
    --
    +
    +
    +
    +
    +
    + +
    +
    重要节日倒计时
    +
    +
    +

    五一劳动节

    +
    --
    +
    +
    +
    +

    国庆节

    +
    --
    +
    +
    +
    +

    圣诞节

    +
    --
    +
    +
    +
    +
    + +
    +
    + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/做决定转盘/index.html b/InfoGenie-frontend/public/toolbox/做决定转盘/index.html new file mode 100644 index 00000000..4ecebdd0 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/做决定转盘/index.html @@ -0,0 +1,262 @@ + + + + + 做决定转盘 + + + +
    +

    做决定转盘

    + +
    +
    +
    + + +
    +
    +
    + + +
    +
    +
    提示:点击“做决定”抽取后,可“保存结果为图片”分享到聊天/相册。
    +
    + + +
    +
    + ✏️ 编辑选项(点我展开/收起) +
    +
    + + +
    +
    + + +
    +
    +
    每行一个选项(会自动同步到转盘)
    +
    +
    +
    +
    + +
    + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/图片圆角处理/index.html b/InfoGenie-frontend/public/toolbox/图片圆角处理/index.html new file mode 100644 index 00000000..77ec0222 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/图片圆角处理/index.html @@ -0,0 +1,380 @@ + + + + + 图片圆角处理 + + + +
    +
    +
    + +

    图片圆角处理(四角独立,最高至圆形)

    +
    +

    上传图片 → 调节四个角的圆角强度(0–100%)→ 预览并下载透明圆角 PNG。已针对手机竖屏优化。

    + + 支持 JPG / PNG / WebP 等常见格式 +
    + +
    +
    + + +
    + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    + + +
    +
    +
    + +
    + +
    + +
    + + +
    + +
    小贴士:将四个角都拉到 100%,在方形图片上会得到完全圆形效果。
    +
    + +
    + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/图片转Base64编码/index.html b/InfoGenie-frontend/public/toolbox/图片转Base64编码/index.html new file mode 100644 index 00000000..03dde361 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/图片转Base64编码/index.html @@ -0,0 +1,327 @@ + + + + + + + 图片转化 base64 编码 + + + + +
    +
    +

    图片转化 base64 编码

    +
    上传或拖拽图片,立即生成 Base64 / Data URL,支持一键复制与清空。已针对手机竖屏优化。
    +
    +
    + +
    +
    点击选择图片或直接拖拽到这里
    +
    支持 PNG / JPG / GIF / WebP / SVG 等常见格式
    +
    + +
    + + +
    + +
    本工具在浏览器本地完成转换,不会上传图片或保存数据。
    + +
    + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/图片黑白处理/index.html b/InfoGenie-frontend/public/toolbox/图片黑白处理/index.html new file mode 100644 index 00000000..2e882d9c --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/图片黑白处理/index.html @@ -0,0 +1,295 @@ + + + + + + + 图片黑白处理 + + + +
    +
    +

    图片黑白处理 · 轻柔绿意版

    +

    上传一张图片,拖动滑块设置黑白程度(0% 原图 → 100% 全黑白),一键下载处理结果。完全本地处理,无需联网。

    +
    +
    +
    + + +
    +
    +
    + +
    100%
    +
    + +
    + + +
    +
    +
    + +
    +
    + +
    ⬆️ 请选择一张图片开始…
    +
    +
    +
    + +
    © 黑白处理在您的设备本地完成 · 支持手机竖屏友好显示
    + +
    + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/在线JavaScript执行/app.js b/InfoGenie-frontend/public/toolbox/在线JavaScript执行/app.js new file mode 100644 index 00000000..ec3544b1 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/在线JavaScript执行/app.js @@ -0,0 +1,136 @@ +(function () { + const $ = (id) => document.getElementById(id); + const codeEl = $("code"); + const runBtn = $("runBtn"); + const copyBtn = $("copyBtn"); + const pasteBtn = $("pasteBtn"); + const clearBtn = $("clearBtn"); + const outputEl = $("output"); + const sandboxEl = $("sandbox"); + + // 以JS方式设置带换行的占位符,避免HTML属性中的 \n 无效 + codeEl.placeholder = "在此编写或粘贴 JavaScript 代码…\n例如:\nconsole.log('Hello, InfoGenie!');"; + + let sandboxReady = false; + + // 沙箱页面(srcdoc)内容:拦截 console、收集错误、支持 async/await + const sandboxHtml = ` + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/在线JavaScript执行/styles.css b/InfoGenie-frontend/public/toolbox/在线JavaScript执行/styles.css new file mode 100644 index 00000000..169bbadf --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/在线JavaScript执行/styles.css @@ -0,0 +1,176 @@ +/* 全局与主题 */ +:root { + --bg-1: #eaf9e8; /* 淡绿色 */ + --bg-2: #f4ffd9; /* 淡黄绿色 */ + --panel: rgba(255, 255, 255, 0.78); + --text: #1d2a1d; + --muted: #486a48; + --accent: #5bb271; + --accent-2: #93d18f; + --border: rgba(93, 160, 93, 0.25); + --code-bg: rgba(255, 255, 255, 0.88); + --error: #b00020; + --warn: #8a6d3b; + --info: #2f6f3a; +} + +/* 隐藏滚动条但保留滚动 */ +html, body { + height: 100%; + overflow: auto; + -ms-overflow-style: none; /* IE 10+ */ + scrollbar-width: none; /* Firefox */ +} +html::-webkit-scrollbar, body::-webkit-scrollbar { width: 0; height: 0; } + +/* 背景与排版 */ +html, body { + margin: 0; + padding: 0; + background: linear-gradient(180deg, var(--bg-1), var(--bg-2)); + color: var(--text); + font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif; +} + +.page { + box-sizing: border-box; + max-width: 760px; + margin: 0 auto; + padding: calc(env(safe-area-inset-top, 12px) + 8px) 14px calc(env(safe-area-inset-bottom, 12px) + 14px); + display: flex; + flex-direction: column; + gap: 16px; +} + +.header { + display: flex; + flex-direction: column; + gap: 6px; +} +.title { + margin: 0; + font-size: 22px; + line-height: 1.2; + letter-spacing: 0.2px; +} +.subtitle { + margin: 0; + font-size: 13px; + color: var(--muted); +} + +.editor-section, .output-section { + background: var(--panel); + border: 1px solid var(--border); + border-radius: 14px; + box-shadow: 0 10px 20px rgba(64, 129, 64, 0.06); + backdrop-filter: saturate(1.2) blur(8px); + padding: 12px; +} + +.label { + display: block; + font-size: 12px; + color: var(--muted); + margin-bottom: 8px; +} + +.editor { + box-sizing: border-box; + width: 100%; + min-height: 36vh; + max-height: 48vh; + resize: vertical; + padding: 10px 12px; + border-radius: 10px; + border: 1px solid var(--border); + outline: none; + background: var(--code-bg); + color: #192519; + font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + font-size: 14px; + line-height: 1.5; + white-space: pre; + overflow: auto; + -ms-overflow-style: none; + scrollbar-width: none; +} +.editor::-webkit-scrollbar { width: 0; height: 0; } + +.toolbar { + display: flex; + gap: 8px; + margin-top: 10px; +} + +.btn { + -webkit-tap-highlight-color: transparent; + appearance: none; + border: 1px solid var(--border); + background: #ffffffd6; + color: #204220; + padding: 10px 14px; + border-radius: 10px; + font-size: 14px; + line-height: 1; + cursor: pointer; +} +.btn:hover { filter: brightness(1.02) saturate(1.02); } +.btn:active { transform: translateY(1px); } +.btn.primary { + background: linear-gradient(180deg, var(--accent-2), var(--accent)); + color: #fff; + border-color: rgba(0,0,0,0.06); +} +.btn.ghost { + background: transparent; +} + +.output-header { + display: flex; + align-items: center; + justify-content: space-between; + margin-bottom: 8px; +} + +.output { + box-sizing: border-box; + width: 100%; + min-height: 28vh; + max-height: 40vh; + padding: 10px 12px; + border-radius: 10px; + border: 1px solid var(--border); + background: var(--code-bg); + color: #192519; + font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace; + font-size: 14px; + line-height: 1.5; + white-space: pre-wrap; + overflow: auto; + -ms-overflow-style: none; + scrollbar-width: none; +} +.output::-webkit-scrollbar { width: 0; height: 0; } + +.sandbox { display: none; width: 0; height: 0; border: 0; } + +/* 控制不同日志级别颜色 */ +.line.log { color: #1f2a1f; } +.line.info { color: var(--info); } +.line.warn { color: var(--warn); } +.line.error { color: var(--error); } +.line.tip { color: #507a58; font-style: italic; } + +/* 竖屏优化 */ +@media (orientation: portrait) { + .page { max-width: 640px; } + .editor { min-height: 40vh; } + .output { min-height: 30vh; } +} + +/* 小屏进一步优化 */ +@media (max-width: 380px) { + .btn { padding: 9px 12px; font-size: 13px; } + .title { font-size: 20px; } +} \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/数字时钟/index.html b/InfoGenie-frontend/public/toolbox/数字时钟/index.html new file mode 100644 index 00000000..b01f3f5b --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/数字时钟/index.html @@ -0,0 +1,92 @@ + + + + + + + + 数字时钟 + + + +
    +
    00:00:00
    +
    + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/白板/index.html b/InfoGenie-frontend/public/toolbox/白板/index.html new file mode 100644 index 00000000..7355da16 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/白板/index.html @@ -0,0 +1,278 @@ + + + + + + 白板 + + + +
    +
    +
    + 颜色 + + 画笔粗细 + + 8px +
    +
    +
    + + +
    + 橡皮粗细 + + 20px +
    +
    + + +
    +
    +
    + +
    +
    + + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/视频播放器/hls.min.js b/InfoGenie-frontend/public/toolbox/视频播放器/hls.min.js new file mode 100644 index 00000000..6b760065 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/视频播放器/hls.min.js @@ -0,0 +1,2 @@ +!function t(e){var r,i;r=this,i=function(){"use strict";function r(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(t);e&&(i=i.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,i)}return r}function i(t){for(var e=1;et.length)&&(e=t.length);for(var r=0,i=new Array(e);r=t.length?{done:!0}:{done:!1,value:t[i++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function v(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var m={exports:{}};!function(t,e){var r,i,n,a,s;r=/^(?=((?:[a-zA-Z0-9+\-.]+:)?))\1(?=((?:\/\/[^\/?#]*)?))\2(?=((?:(?:[^?#\/]*\/)*[^;?#\/]*)?))\3((?:;[^?#]*)?)(\?[^#]*)?(#[^]*)?$/,i=/^(?=([^\/?#]*))\1([^]*)$/,n=/(?:\/|^)\.(?=\/)/g,a=/(?:\/|^)\.\.\/(?!\.\.\/)[^\/]*(?=\/)/g,s={buildAbsoluteURL:function(t,e,r){if(r=r||{},t=t.trim(),!(e=e.trim())){if(!r.alwaysNormalize)return t;var n=s.parseURL(t);if(!n)throw new Error("Error trying to parse base URL.");return n.path=s.normalizePath(n.path),s.buildURLFromParts(n)}var a=s.parseURL(e);if(!a)throw new Error("Error trying to parse relative URL.");if(a.scheme)return r.alwaysNormalize?(a.path=s.normalizePath(a.path),s.buildURLFromParts(a)):e;var o=s.parseURL(t);if(!o)throw new Error("Error trying to parse base URL.");if(!o.netLoc&&o.path&&"/"!==o.path[0]){var l=i.exec(o.path);o.netLoc=l[1],o.path=l[2]}o.netLoc&&!o.path&&(o.path="/");var u={scheme:o.scheme,netLoc:a.netLoc,path:null,params:a.params,query:a.query,fragment:a.fragment};if(!a.netLoc&&(u.netLoc=o.netLoc,"/"!==a.path[0]))if(a.path){var h=o.path,d=h.substring(0,h.lastIndexOf("/")+1)+a.path;u.path=s.normalizePath(d)}else u.path=o.path,a.params||(u.params=o.params,a.query||(u.query=o.query));return null===u.path&&(u.path=r.alwaysNormalize?s.normalizePath(a.path):a.path),s.buildURLFromParts(u)},parseURL:function(t){var e=r.exec(t);return e?{scheme:e[1]||"",netLoc:e[2]||"",path:e[3]||"",params:e[4]||"",query:e[5]||"",fragment:e[6]||""}:null},normalizePath:function(t){for(t=t.split("").reverse().join("").replace(n,"");t.length!==(t=t.replace(a,"")).length;);return t.split("").reverse().join("")},buildURLFromParts:function(t){return t.scheme+t.netLoc+t.path+t.params+t.query+t.fragment}},t.exports=s}(m);var p=m.exports,y=Number.isFinite||function(t){return"number"==typeof t&&isFinite(t)},E=Number.isSafeInteger||function(t){return"number"==typeof t&&Math.abs(t)<=T},T=Number.MAX_SAFE_INTEGER||9007199254740991,S=function(t){return t.MEDIA_ATTACHING="hlsMediaAttaching",t.MEDIA_ATTACHED="hlsMediaAttached",t.MEDIA_DETACHING="hlsMediaDetaching",t.MEDIA_DETACHED="hlsMediaDetached",t.BUFFER_RESET="hlsBufferReset",t.BUFFER_CODECS="hlsBufferCodecs",t.BUFFER_CREATED="hlsBufferCreated",t.BUFFER_APPENDING="hlsBufferAppending",t.BUFFER_APPENDED="hlsBufferAppended",t.BUFFER_EOS="hlsBufferEos",t.BUFFER_FLUSHING="hlsBufferFlushing",t.BUFFER_FLUSHED="hlsBufferFlushed",t.MANIFEST_LOADING="hlsManifestLoading",t.MANIFEST_LOADED="hlsManifestLoaded",t.MANIFEST_PARSED="hlsManifestParsed",t.LEVEL_SWITCHING="hlsLevelSwitching",t.LEVEL_SWITCHED="hlsLevelSwitched",t.LEVEL_LOADING="hlsLevelLoading",t.LEVEL_LOADED="hlsLevelLoaded",t.LEVEL_UPDATED="hlsLevelUpdated",t.LEVEL_PTS_UPDATED="hlsLevelPtsUpdated",t.LEVELS_UPDATED="hlsLevelsUpdated",t.AUDIO_TRACKS_UPDATED="hlsAudioTracksUpdated",t.AUDIO_TRACK_SWITCHING="hlsAudioTrackSwitching",t.AUDIO_TRACK_SWITCHED="hlsAudioTrackSwitched",t.AUDIO_TRACK_LOADING="hlsAudioTrackLoading",t.AUDIO_TRACK_LOADED="hlsAudioTrackLoaded",t.SUBTITLE_TRACKS_UPDATED="hlsSubtitleTracksUpdated",t.SUBTITLE_TRACKS_CLEARED="hlsSubtitleTracksCleared",t.SUBTITLE_TRACK_SWITCH="hlsSubtitleTrackSwitch",t.SUBTITLE_TRACK_LOADING="hlsSubtitleTrackLoading",t.SUBTITLE_TRACK_LOADED="hlsSubtitleTrackLoaded",t.SUBTITLE_FRAG_PROCESSED="hlsSubtitleFragProcessed",t.CUES_PARSED="hlsCuesParsed",t.NON_NATIVE_TEXT_TRACKS_FOUND="hlsNonNativeTextTracksFound",t.INIT_PTS_FOUND="hlsInitPtsFound",t.FRAG_LOADING="hlsFragLoading",t.FRAG_LOAD_EMERGENCY_ABORTED="hlsFragLoadEmergencyAborted",t.FRAG_LOADED="hlsFragLoaded",t.FRAG_DECRYPTED="hlsFragDecrypted",t.FRAG_PARSING_INIT_SEGMENT="hlsFragParsingInitSegment",t.FRAG_PARSING_USERDATA="hlsFragParsingUserdata",t.FRAG_PARSING_METADATA="hlsFragParsingMetadata",t.FRAG_PARSED="hlsFragParsed",t.FRAG_BUFFERED="hlsFragBuffered",t.FRAG_CHANGED="hlsFragChanged",t.FPS_DROP="hlsFpsDrop",t.FPS_DROP_LEVEL_CAPPING="hlsFpsDropLevelCapping",t.MAX_AUTO_LEVEL_UPDATED="hlsMaxAutoLevelUpdated",t.ERROR="hlsError",t.DESTROYING="hlsDestroying",t.KEY_LOADING="hlsKeyLoading",t.KEY_LOADED="hlsKeyLoaded",t.LIVE_BACK_BUFFER_REACHED="hlsLiveBackBufferReached",t.BACK_BUFFER_REACHED="hlsBackBufferReached",t.STEERING_MANIFEST_LOADED="hlsSteeringManifestLoaded",t}({}),L=function(t){return t.NETWORK_ERROR="networkError",t.MEDIA_ERROR="mediaError",t.KEY_SYSTEM_ERROR="keySystemError",t.MUX_ERROR="muxError",t.OTHER_ERROR="otherError",t}({}),A=function(t){return t.KEY_SYSTEM_NO_KEYS="keySystemNoKeys",t.KEY_SYSTEM_NO_ACCESS="keySystemNoAccess",t.KEY_SYSTEM_NO_SESSION="keySystemNoSession",t.KEY_SYSTEM_NO_CONFIGURED_LICENSE="keySystemNoConfiguredLicense",t.KEY_SYSTEM_LICENSE_REQUEST_FAILED="keySystemLicenseRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_REQUEST_FAILED="keySystemServerCertificateRequestFailed",t.KEY_SYSTEM_SERVER_CERTIFICATE_UPDATE_FAILED="keySystemServerCertificateUpdateFailed",t.KEY_SYSTEM_SESSION_UPDATE_FAILED="keySystemSessionUpdateFailed",t.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED="keySystemStatusOutputRestricted",t.KEY_SYSTEM_STATUS_INTERNAL_ERROR="keySystemStatusInternalError",t.MANIFEST_LOAD_ERROR="manifestLoadError",t.MANIFEST_LOAD_TIMEOUT="manifestLoadTimeOut",t.MANIFEST_PARSING_ERROR="manifestParsingError",t.MANIFEST_INCOMPATIBLE_CODECS_ERROR="manifestIncompatibleCodecsError",t.LEVEL_EMPTY_ERROR="levelEmptyError",t.LEVEL_LOAD_ERROR="levelLoadError",t.LEVEL_LOAD_TIMEOUT="levelLoadTimeOut",t.LEVEL_PARSING_ERROR="levelParsingError",t.LEVEL_SWITCH_ERROR="levelSwitchError",t.AUDIO_TRACK_LOAD_ERROR="audioTrackLoadError",t.AUDIO_TRACK_LOAD_TIMEOUT="audioTrackLoadTimeOut",t.SUBTITLE_LOAD_ERROR="subtitleTrackLoadError",t.SUBTITLE_TRACK_LOAD_TIMEOUT="subtitleTrackLoadTimeOut",t.FRAG_LOAD_ERROR="fragLoadError",t.FRAG_LOAD_TIMEOUT="fragLoadTimeOut",t.FRAG_DECRYPT_ERROR="fragDecryptError",t.FRAG_PARSING_ERROR="fragParsingError",t.FRAG_GAP="fragGap",t.REMUX_ALLOC_ERROR="remuxAllocError",t.KEY_LOAD_ERROR="keyLoadError",t.KEY_LOAD_TIMEOUT="keyLoadTimeOut",t.BUFFER_ADD_CODEC_ERROR="bufferAddCodecError",t.BUFFER_INCOMPATIBLE_CODECS_ERROR="bufferIncompatibleCodecsError",t.BUFFER_APPEND_ERROR="bufferAppendError",t.BUFFER_APPENDING_ERROR="bufferAppendingError",t.BUFFER_STALLED_ERROR="bufferStalledError",t.BUFFER_FULL_ERROR="bufferFullError",t.BUFFER_SEEK_OVER_HOLE="bufferSeekOverHole",t.BUFFER_NUDGE_ON_STALL="bufferNudgeOnStall",t.INTERNAL_EXCEPTION="internalException",t.INTERNAL_ABORTED="aborted",t.UNKNOWN="unknown",t}({}),R=function(){},k={trace:R,debug:R,log:R,warn:R,info:R,error:R},b=k;function D(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i"):R}(e)}))}function I(t,e){if("object"==typeof console&&!0===t||"object"==typeof t){D(t,"debug","log","info","warn","error");try{b.log('Debug logs enabled for "'+e+'" in hls.js version 1.5.7')}catch(t){b=k}}else b=k}var w=b,C=/^(\d+)x(\d+)$/,_=/(.+?)=(".*?"|.*?)(?:,|$)/g,x=function(){function t(e){"string"==typeof e&&(e=t.parseAttrList(e)),o(this,e)}var e=t.prototype;return e.decimalInteger=function(t){var e=parseInt(this[t],10);return e>Number.MAX_SAFE_INTEGER?1/0:e},e.hexadecimalInteger=function(t){if(this[t]){var e=(this[t]||"0x").slice(2);e=(1&e.length?"0":"")+e;for(var r=new Uint8Array(e.length/2),i=0;iNumber.MAX_SAFE_INTEGER?1/0:e},e.decimalFloatingPoint=function(t){return parseFloat(this[t])},e.optionalFloat=function(t,e){var r=this[t];return r?parseFloat(r):e},e.enumeratedString=function(t){return this[t]},e.bool=function(t){return"YES"===this[t]},e.decimalResolution=function(t){var e=C.exec(this[t]);if(null!==e)return{width:parseInt(e[1],10),height:parseInt(e[2],10)}},t.parseAttrList=function(t){var e,r={};for(_.lastIndex=0;null!==(e=_.exec(t));){var i=e[2];0===i.indexOf('"')&&i.lastIndexOf('"')===i.length-1&&(i=i.slice(1,-1)),r[e[1].trim()]=i}return r},s(t,[{key:"clientAttrs",get:function(){return Object.keys(this).filter((function(t){return"X-"===t.substring(0,2)}))}}]),t}();function P(t){return"SCTE35-OUT"===t||"SCTE35-IN"===t}var F=function(){function t(t,e){if(this.attr=void 0,this._startDate=void 0,this._endDate=void 0,this._badValueForSameId=void 0,e){var r=e.attr;for(var i in r)if(Object.prototype.hasOwnProperty.call(t,i)&&t[i]!==r[i]){w.warn('DATERANGE tag attribute: "'+i+'" does not match for tags with ID: "'+t.ID+'"'),this._badValueForSameId=i;break}t=o(new x({}),r,t)}if(this.attr=t,this._startDate=new Date(t["START-DATE"]),"END-DATE"in this.attr){var n=new Date(this.attr["END-DATE"]);y(n.getTime())&&(this._endDate=n)}}return s(t,[{key:"id",get:function(){return this.attr.ID}},{key:"class",get:function(){return this.attr.CLASS}},{key:"startDate",get:function(){return this._startDate}},{key:"endDate",get:function(){if(this._endDate)return this._endDate;var t=this.duration;return null!==t?new Date(this._startDate.getTime()+1e3*t):null}},{key:"duration",get:function(){if("DURATION"in this.attr){var t=this.attr.decimalFloatingPoint("DURATION");if(y(t))return t}else if(this._endDate)return(this._endDate.getTime()-this._startDate.getTime())/1e3;return null}},{key:"plannedDuration",get:function(){return"PLANNED-DURATION"in this.attr?this.attr.decimalFloatingPoint("PLANNED-DURATION"):null}},{key:"endOnNext",get:function(){return this.attr.bool("END-ON-NEXT")}},{key:"isValid",get:function(){return!!this.id&&!this._badValueForSameId&&y(this.startDate.getTime())&&(null===this.duration||this.duration>=0)&&(!this.endOnNext||!!this.class)}}]),t}(),M=function(){this.aborted=!1,this.loaded=0,this.retry=0,this.total=0,this.chunkCount=0,this.bwEstimate=0,this.loading={start:0,first:0,end:0},this.parsing={start:0,end:0},this.buffering={start:0,first:0,end:0}},O="audio",N="video",U="audiovideo",B=function(){function t(t){var e;this._byteRange=null,this._url=null,this.baseurl=void 0,this.relurl=void 0,this.elementaryStreams=((e={})[O]=null,e[N]=null,e[U]=null,e),this.baseurl=t}return t.prototype.setByteRange=function(t,e){var r,i=t.split("@",2);r=1===i.length?(null==e?void 0:e.byteRangeEndOffset)||0:parseInt(i[1]),this._byteRange=[r,parseInt(i[0])+r]},s(t,[{key:"byteRange",get:function(){return this._byteRange?this._byteRange:[]}},{key:"byteRangeStartOffset",get:function(){return this.byteRange[0]}},{key:"byteRangeEndOffset",get:function(){return this.byteRange[1]}},{key:"url",get:function(){return!this._url&&this.baseurl&&this.relurl&&(this._url=p.buildAbsoluteURL(this.baseurl,this.relurl,{alwaysNormalize:!0})),this._url||""},set:function(t){this._url=t}}]),t}(),G=function(t){function e(e,r){var i;return(i=t.call(this,r)||this)._decryptdata=null,i.rawProgramDateTime=null,i.programDateTime=null,i.tagList=[],i.duration=0,i.sn=0,i.levelkeys=void 0,i.type=void 0,i.loader=null,i.keyLoader=null,i.level=-1,i.cc=0,i.startPTS=void 0,i.endPTS=void 0,i.startDTS=void 0,i.endDTS=void 0,i.start=0,i.deltaPTS=void 0,i.maxStartPTS=void 0,i.minEndPTS=void 0,i.stats=new M,i.data=void 0,i.bitrateTest=!1,i.title=null,i.initSegment=null,i.endList=void 0,i.gap=void 0,i.urlId=0,i.type=e,i}l(e,t);var r=e.prototype;return r.setKeyFormat=function(t){if(this.levelkeys){var e=this.levelkeys[t];e&&!this._decryptdata&&(this._decryptdata=e.getDecryptData(this.sn))}},r.abortRequests=function(){var t,e;null==(t=this.loader)||t.abort(),null==(e=this.keyLoader)||e.abort()},r.setElementaryStreamInfo=function(t,e,r,i,n,a){void 0===a&&(a=!1);var s=this.elementaryStreams,o=s[t];o?(o.startPTS=Math.min(o.startPTS,e),o.endPTS=Math.max(o.endPTS,r),o.startDTS=Math.min(o.startDTS,i),o.endDTS=Math.max(o.endDTS,n)):s[t]={startPTS:e,endPTS:r,startDTS:i,endDTS:n,partial:a}},r.clearElementaryStreamInfo=function(){var t=this.elementaryStreams;t[O]=null,t[N]=null,t[U]=null},s(e,[{key:"decryptdata",get:function(){if(!this.levelkeys&&!this._decryptdata)return null;if(!this._decryptdata&&this.levelkeys&&!this.levelkeys.NONE){var t=this.levelkeys.identity;if(t)this._decryptdata=t.getDecryptData(this.sn);else{var e=Object.keys(this.levelkeys);if(1===e.length)return this._decryptdata=this.levelkeys[e[0]].getDecryptData(this.sn)}}return this._decryptdata}},{key:"end",get:function(){return this.start+this.duration}},{key:"endProgramDateTime",get:function(){if(null===this.programDateTime)return null;if(!y(this.programDateTime))return null;var t=y(this.duration)?this.duration:0;return this.programDateTime+1e3*t}},{key:"encrypted",get:function(){var t;if(null!=(t=this._decryptdata)&&t.encrypted)return!0;if(this.levelkeys){var e=Object.keys(this.levelkeys),r=e.length;if(r>1||1===r&&this.levelkeys[e[0]].encrypted)return!0}return!1}}]),e}(B),K=function(t){function e(e,r,i,n,a){var s;(s=t.call(this,i)||this).fragOffset=0,s.duration=0,s.gap=!1,s.independent=!1,s.relurl=void 0,s.fragment=void 0,s.index=void 0,s.stats=new M,s.duration=e.decimalFloatingPoint("DURATION"),s.gap=e.bool("GAP"),s.independent=e.bool("INDEPENDENT"),s.relurl=e.enumeratedString("URI"),s.fragment=r,s.index=n;var o=e.enumeratedString("BYTERANGE");return o&&s.setByteRange(o,a),a&&(s.fragOffset=a.fragOffset+a.duration),s}return l(e,t),s(e,[{key:"start",get:function(){return this.fragment.start+this.fragOffset}},{key:"end",get:function(){return this.start+this.duration}},{key:"loaded",get:function(){var t=this.elementaryStreams;return!!(t.audio||t.video||t.audiovideo)}}]),e}(B),H=function(){function t(t){this.PTSKnown=!1,this.alignedSliding=!1,this.averagetargetduration=void 0,this.endCC=0,this.endSN=0,this.fragments=void 0,this.fragmentHint=void 0,this.partList=null,this.dateRanges=void 0,this.live=!0,this.ageHeader=0,this.advancedDateTime=void 0,this.updated=!0,this.advanced=!0,this.availabilityDelay=void 0,this.misses=0,this.startCC=0,this.startSN=0,this.startTimeOffset=null,this.targetduration=0,this.totalduration=0,this.type=null,this.url=void 0,this.m3u8="",this.version=null,this.canBlockReload=!1,this.canSkipUntil=0,this.canSkipDateRanges=!1,this.skippedSegments=0,this.recentlyRemovedDateranges=void 0,this.partHoldBack=0,this.holdBack=0,this.partTarget=0,this.preloadHint=void 0,this.renditionReports=void 0,this.tuneInGoal=0,this.deltaUpdateFailed=void 0,this.driftStartTime=0,this.driftEndTime=0,this.driftStart=0,this.driftEnd=0,this.encryptedFragments=void 0,this.playlistParsingError=null,this.variableList=null,this.hasVariableRefs=!1,this.fragments=[],this.encryptedFragments=[],this.dateRanges={},this.url=t}return t.prototype.reloaded=function(t){if(!t)return this.advanced=!0,void(this.updated=!0);var e=this.lastPartSn-t.lastPartSn,r=this.lastPartIndex-t.lastPartIndex;this.updated=this.endSN!==t.endSN||!!r||!!e||!this.live,this.advanced=this.endSN>t.endSN||e>0||0===e&&r>0,this.updated||this.advanced?this.misses=Math.floor(.6*t.misses):this.misses=t.misses+1,this.availabilityDelay=t.availabilityDelay},s(t,[{key:"hasProgramDateTime",get:function(){return!!this.fragments.length&&y(this.fragments[this.fragments.length-1].programDateTime)}},{key:"levelTargetDuration",get:function(){return this.averagetargetduration||this.targetduration||10}},{key:"drift",get:function(){var t=this.driftEndTime-this.driftStartTime;return t>0?1e3*(this.driftEnd-this.driftStart)/t:1}},{key:"edge",get:function(){return this.partEnd||this.fragmentEnd}},{key:"partEnd",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].end:this.fragmentEnd}},{key:"fragmentEnd",get:function(){var t;return null!=(t=this.fragments)&&t.length?this.fragments[this.fragments.length-1].end:0}},{key:"age",get:function(){return this.advancedDateTime?Math.max(Date.now()-this.advancedDateTime,0)/1e3:0}},{key:"lastPartIndex",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].index:-1}},{key:"lastPartSn",get:function(){var t;return null!=(t=this.partList)&&t.length?this.partList[this.partList.length-1].fragment.sn:this.endSN}}]),t}();function V(t){return Uint8Array.from(atob(t),(function(t){return t.charCodeAt(0)}))}function Y(t){var e,r,i=t.split(":"),n=null;if("data"===i[0]&&2===i.length){var a=i[1].split(";"),s=a[a.length-1].split(",");if(2===s.length){var o="base64"===s[0],l=s[1];o?(a.splice(-1,1),n=V(l)):(e=W(l).subarray(0,16),(r=new Uint8Array(16)).set(e,16-e.length),n=r)}}return n}function W(t){return Uint8Array.from(unescape(encodeURIComponent(t)),(function(t){return t.charCodeAt(0)}))}var j="undefined"!=typeof self?self:void 0,q={CLEARKEY:"org.w3.clearkey",FAIRPLAY:"com.apple.fps",PLAYREADY:"com.microsoft.playready",WIDEVINE:"com.widevine.alpha"},X="org.w3.clearkey",z="com.apple.streamingkeydelivery",Q="com.microsoft.playready",J="urn:uuid:edef8ba9-79d6-4ace-a3c8-27dcd51d21ed";function $(t){switch(t){case z:return q.FAIRPLAY;case Q:return q.PLAYREADY;case J:return q.WIDEVINE;case X:return q.CLEARKEY}}var Z="edef8ba979d64acea3c827dcd51d21ed";function tt(t){switch(t){case q.FAIRPLAY:return z;case q.PLAYREADY:return Q;case q.WIDEVINE:return J;case q.CLEARKEY:return X}}function et(t){var e=t.drmSystems,r=t.widevineLicenseUrl,i=e?[q.FAIRPLAY,q.WIDEVINE,q.PLAYREADY,q.CLEARKEY].filter((function(t){return!!e[t]})):[];return!i[q.WIDEVINE]&&r&&i.push(q.WIDEVINE),i}var rt,it=null!=j&&null!=(rt=j.navigator)&&rt.requestMediaKeySystemAccess?self.navigator.requestMediaKeySystemAccess.bind(self.navigator):null;function nt(t,e,r){return Uint8Array.prototype.slice?t.slice(e,r):new Uint8Array(Array.prototype.slice.call(t,e,r))}var at,st=function(t,e){return e+10<=t.length&&73===t[e]&&68===t[e+1]&&51===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},ot=function(t,e){return e+10<=t.length&&51===t[e]&&68===t[e+1]&&73===t[e+2]&&t[e+3]<255&&t[e+4]<255&&t[e+6]<128&&t[e+7]<128&&t[e+8]<128&&t[e+9]<128},lt=function(t,e){for(var r=e,i=0;st(t,e);)i+=10,i+=ut(t,e+6),ot(t,e+10)&&(i+=10),e+=i;if(i>0)return t.subarray(r,r+i)},ut=function(t,e){var r=0;return r=(127&t[e])<<21,r|=(127&t[e+1])<<14,r|=(127&t[e+2])<<7,r|=127&t[e+3]},ht=function(t,e){return st(t,e)&&ut(t,e+6)+10<=t.length-e},dt=function(t){for(var e=gt(t),r=0;r>4){case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:u+=String.fromCharCode(a);break;case 12:case 13:s=t[h++],u+=String.fromCharCode((31&a)<<6|63&s);break;case 14:s=t[h++],o=t[h++],u+=String.fromCharCode((15&a)<<12|(63&s)<<6|(63&o)<<0)}}return u};function St(){if(!navigator.userAgent.includes("PlayStation 4"))return at||void 0===self.TextDecoder||(at=new self.TextDecoder("utf-8")),at}var Lt=function(t){for(var e="",r=0;r>24,t[e+1]=r>>16&255,t[e+2]=r>>8&255,t[e+3]=255&r}function xt(t,e){var r=[];if(!e.length)return r;for(var i=t.byteLength,n=0;n1?n+a:i;if(bt(t.subarray(n+4,n+8))===e[0])if(1===e.length)r.push(t.subarray(n+8,s));else{var o=xt(t.subarray(n+8,s),e.slice(1));o.length&&Rt.apply(r,o)}n=s}return r}function Pt(t){var e=[],r=t[0],i=8,n=It(t,i);i+=4;var a=0,s=0;0===r?(a=It(t,i),s=It(t,i+4),i+=8):(a=wt(t,i),s=wt(t,i+8),i+=16),i+=2;var o=t.length+s,l=Dt(t,i);i+=2;for(var u=0;u>>31)return w.warn("SIDX has hierarchical references (not supported)"),null;var f=It(t,h);h+=4,e.push({referenceSize:c,subsegmentDuration:f,info:{duration:f/n,start:o,end:o+c-1}}),o+=c,i=h+=4}return{earliestPresentationTime:a,timescale:n,version:r,referencesCount:l,references:e}}function Ft(t){for(var e=[],r=xt(t,["moov","trak"]),n=0;n12){var h=4;if(3!==u[h++])break;h=Ot(u,h),h+=2;var d=u[h++];if(128&d&&(h+=2),64&d&&(h+=u[h++]),4!==u[h++])break;h=Ot(u,h);var c=u[h++];if(64!==c)break;if(n+="."+Nt(c),h+=12,5!==u[h++])break;h=Ot(u,h);var f=u[h++],g=(248&f)>>3;31===g&&(g+=1+((7&f)<<3)+((224&u[h])>>5)),n+="."+g}break;case"hvc1":case"hev1":var v=xt(r,["hvcC"])[0],m=v[1],p=["","A","B","C"][m>>6],y=31&m,E=It(v,2),T=(32&m)>>5?"H":"L",S=v[12],L=v.subarray(6,12);n+="."+p+y,n+="."+E.toString(16).toUpperCase(),n+="."+T+S;for(var A="",R=L.length;R--;){var k=L[R];(k||A)&&(A="."+k.toString(16).toUpperCase()+A)}n+=A;break;case"dvh1":case"dvhe":var b=xt(r,["dvcC"])[0],D=b[2]>>1&127,I=b[2]<<5&32|b[3]>>3&31;n+="."+Ut(D)+"."+Ut(I);break;case"vp09":var w=xt(r,["vpcC"])[0],C=w[4],_=w[5],x=w[6]>>4&15;n+="."+Ut(C)+"."+Ut(_)+"."+Ut(x);break;case"av01":var P=xt(r,["av1C"])[0],F=P[1]>>>5,M=31&P[1],O=P[2]>>>7?"H":"M",N=(64&P[2])>>6,U=(32&P[2])>>5,B=2===F&&N?U?12:10:N?10:8,G=(16&P[2])>>4,K=(8&P[2])>>3,H=(4&P[2])>>2,V=3&P[2];n+="."+F+"."+Ut(M)+O+"."+Ut(B)+"."+G+"."+K+H+V+"."+Ut(1)+"."+Ut(1)+"."+Ut(1)+".0"}return{codec:n,encrypted:a}}function Ot(t,e){for(var r=e+5;128&t[e++]&&e>1&63;return 39===r||40===r}return 6==(31&e)}function Yt(t,e,r,i){var n=Wt(t),a=0;a+=e;for(var s=0,o=0,l=0;a=n.length)break;s+=l=n[a++]}while(255===l);o=0;do{if(a>=n.length)break;o+=l=n[a++]}while(255===l);var u=n.length-a,h=a;if(ou){w.error("Malformed SEI payload. "+o+" is too small, only "+u+" bytes left to parse.");break}if(4===s){if(181===n[h++]){var d=Dt(n,h);if(h+=2,49===d){var c=It(n,h);if(h+=4,1195456820===c){var f=n[h++];if(3===f){var g=n[h++],v=64&g,m=v?2+3*(31&g):0,p=new Uint8Array(m);if(v){p[0]=g;for(var y=1;y16){for(var E=[],T=0;T<16;T++){var S=n[h++].toString(16);E.push(1==S.length?"0"+S:S),3!==T&&5!==T&&7!==T&&9!==T||E.push("-")}for(var L=o-16,A=new Uint8Array(L),R=0;R0?(a=new Uint8Array(4),e.length>0&&new DataView(a.buffer).setUint32(0,e.length,!1)):a=new Uint8Array;var l=new Uint8Array(4);return r&&r.byteLength>0&&new DataView(l.buffer).setUint32(0,r.byteLength,!1),function(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i>24&255,o[1]=a>>16&255,o[2]=a>>8&255,o[3]=255&a,o.set(t,4),s=0,a=8;s>8*(15-r)&255;return e}(e);return new t(this.method,this.uri,"identity",this.keyFormatVersions,r)}var i=Y(this.uri);if(i)switch(this.keyFormat){case J:this.pssh=i,i.length>=22&&(this.keyId=i.subarray(i.length-22,i.length-6));break;case Q:var n=new Uint8Array([154,4,240,121,152,64,66,134,171,146,230,91,224,136,95,149]);this.pssh=jt(n,null,i);var a=new Uint16Array(i.buffer,i.byteOffset,i.byteLength/2),s=String.fromCharCode.apply(null,Array.from(a)),o=s.substring(s.indexOf("<"),s.length),l=(new DOMParser).parseFromString(o,"text/xml").getElementsByTagName("KID")[0];if(l){var u=l.childNodes[0]?l.childNodes[0].nodeValue:l.getAttribute("VALUE");if(u){var h=V(u).subarray(0,16);!function(t){var e=function(t,e,r){var i=t[e];t[e]=t[r],t[r]=i};e(t,0,3),e(t,1,2),e(t,4,5),e(t,6,7)}(h),this.keyId=h}}break;default:var d=i.subarray(0,16);if(16!==d.length){var c=new Uint8Array(16);c.set(d,16-d.length),d=c}this.keyId=d}if(!this.keyId||16!==this.keyId.byteLength){var f=qt[this.uri];if(!f){var g=Object.keys(qt).length%Number.MAX_SAFE_INTEGER;f=new Uint8Array(16),new DataView(f.buffer,12,4).setUint32(0,g),qt[this.uri]=f}this.keyId=f}return this},t}(),zt=/\{\$([a-zA-Z0-9-_]+)\}/g;function Qt(t){return zt.test(t)}function Jt(t,e,r){if(null!==t.variableList||t.hasVariableRefs)for(var i=r.length;i--;){var n=r[i],a=e[n];a&&(e[n]=$t(t,a))}}function $t(t,e){if(null!==t.variableList||t.hasVariableRefs){var r=t.variableList;return e.replace(zt,(function(e){var i=e.substring(2,e.length-1),n=null==r?void 0:r[i];return void 0===n?(t.playlistParsingError||(t.playlistParsingError=new Error('Missing preceding EXT-X-DEFINE tag for Variable Reference: "'+i+'"')),e):n}))}return e}function Zt(t,e,r){var i,n,a=t.variableList;if(a||(t.variableList=a={}),"QUERYPARAM"in e){i=e.QUERYPARAM;try{var s=new self.URL(r).searchParams;if(!s.has(i))throw new Error('"'+i+'" does not match any query parameter in URI: "'+r+'"');n=s.get(i)}catch(e){t.playlistParsingError||(t.playlistParsingError=new Error("EXT-X-DEFINE QUERYPARAM: "+e.message))}}else i=e.NAME,n=e.VALUE;i in a?t.playlistParsingError||(t.playlistParsingError=new Error('EXT-X-DEFINE duplicate Variable Name declarations: "'+i+'"')):a[i]=n||""}function te(t,e,r){var i=e.IMPORT;if(r&&i in r){var n=t.variableList;n||(t.variableList=n={}),n[i]=r[i]}else t.playlistParsingError||(t.playlistParsingError=new Error('EXT-X-DEFINE IMPORT attribute not found in Multivariant Playlist: "'+i+'"'))}function ee(t){if(void 0===t&&(t=!0),"undefined"!=typeof self)return(t||!self.MediaSource)&&self.ManagedMediaSource||self.MediaSource||self.WebKitMediaSource}var re={audio:{a3ds:1,"ac-3":.95,"ac-4":1,alac:.9,alaw:1,dra1:1,"dts+":1,"dts-":1,dtsc:1,dtse:1,dtsh:1,"ec-3":.9,enca:1,fLaC:.9,flac:.9,FLAC:.9,g719:1,g726:1,m4ae:1,mha1:1,mha2:1,mhm1:1,mhm2:1,mlpa:1,mp4a:1,"raw ":1,Opus:1,opus:1,samr:1,sawb:1,sawp:1,sevc:1,sqcp:1,ssmv:1,twos:1,ulaw:1},video:{avc1:1,avc2:1,avc3:1,avc4:1,avcp:1,av01:.8,drac:1,dva1:1,dvav:1,dvh1:.7,dvhe:.7,encv:1,hev1:.75,hvc1:.75,mjp2:1,mp4v:1,mvc1:1,mvc2:1,mvc3:1,mvc4:1,resv:1,rv60:1,s263:1,svc1:1,svc2:1,"vc-1":1,vp08:1,vp09:.9},text:{stpp:1,wvtt:1}};function ie(t,e,r){return void 0===r&&(r=!0),!t.split(",").some((function(t){return!ne(t,e,r)}))}function ne(t,e,r){var i;void 0===r&&(r=!0);var n=ee(r);return null!=(i=null==n?void 0:n.isTypeSupported(ae(t,e)))&&i}function ae(t,e){return e+'/mp4;codecs="'+t+'"'}function se(t){if(t){var e=t.substring(0,4);return re.video[e]}return 2}function oe(t){return t.split(",").reduce((function(t,e){var r=re.video[e];return r?(2*r+t)/(t?3:2):(re.audio[e]+t)/(t?2:1)}),0)}var le={},ue=/flac|opus/i;function he(t,e){return void 0===e&&(e=!0),t.replace(ue,(function(t){return function(t,e){if(void 0===e&&(e=!0),le[t])return le[t];for(var r={flac:["flac","fLaC","FLAC"],opus:["opus","Opus"]}[t],i=0;i0&&a.length0&&X.bool("CAN-SKIP-DATERANGES"),h.partHoldBack=X.optionalFloat("PART-HOLD-BACK",0),h.holdBack=X.optionalFloat("HOLD-BACK",0);break;case"PART-INF":var z=new x(I);h.partTarget=z.decimalFloatingPoint("PART-TARGET");break;case"PART":var Q=h.partList;Q||(Q=h.partList=[]);var J=g>0?Q[Q.length-1]:void 0,$=g++,Z=new x(I);Jt(h,Z,["BYTERANGE","URI"]);var tt=new K(Z,E,e,$,J);Q.push(tt),E.duration+=tt.duration;break;case"PRELOAD-HINT":var et=new x(I);Jt(h,et,["URI"]),h.preloadHint=et;break;case"RENDITION-REPORT":var rt=new x(I);Jt(h,rt,["URI"]),h.renditionReports=h.renditionReports||[],h.renditionReports.push(rt);break;default:w.warn("line parsed but not handled: "+s)}}}p&&!p.relurl?(d.pop(),v-=p.duration,h.partList&&(h.fragmentHint=p)):h.partList&&(Le(E,p),E.cc=m,h.fragmentHint=E,u&&Re(E,u,h));var it=d.length,nt=d[0],at=d[it-1];if((v+=h.skippedSegments*h.targetduration)>0&&it&&at){h.averagetargetduration=v/it;var st=at.sn;h.endSN="initSegment"!==st?st:0,h.live||(at.endList=!0),nt&&(h.startCC=nt.cc)}else h.endSN=0,h.startCC=0;return h.fragmentHint&&(v+=h.fragmentHint.duration),h.totalduration=v,h.endCC=m,T>0&&function(t,e){for(var r=t[e],i=e;i--;){var n=t[i];if(!n)return;n.programDateTime=r.programDateTime-1e3*n.duration,r=n}}(d,T),h},t}();function ye(t,e,r){var i,n,a=new x(t);Jt(r,a,["KEYFORMAT","KEYFORMATVERSIONS","URI","IV","URI"]);var s=null!=(i=a.METHOD)?i:"",o=a.URI,l=a.hexadecimalInteger("IV"),u=a.KEYFORMATVERSIONS,h=null!=(n=a.KEYFORMAT)?n:"identity";o&&a.IV&&!l&&w.error("Invalid IV: "+a.IV);var d=o?pe.resolve(o,e):"",c=(u||"1").split("/").map(Number).filter(Number.isFinite);return new Xt(s,d,h,c,l)}function Ee(t){var e=new x(t).decimalFloatingPoint("TIME-OFFSET");return y(e)?e:null}function Te(t,e){var r=(t||"").split(/[ ,]+/).filter((function(t){return t}));["video","audio","text"].forEach((function(t){var i=r.filter((function(e){return function(t,e){var r=re[e];return!!r&&!!r[t.slice(0,4)]}(e,t)}));i.length&&(e[t+"Codec"]=i.join(","),r=r.filter((function(t){return-1===i.indexOf(t)})))})),e.unknownCodecs=r}function Se(t,e,r){var i=e[r];i&&(t[r]=i)}function Le(t,e){t.rawProgramDateTime?t.programDateTime=Date.parse(t.rawProgramDateTime):null!=e&&e.programDateTime&&(t.programDateTime=e.endProgramDateTime),y(t.programDateTime)||(t.programDateTime=null,t.rawProgramDateTime=null)}function Ae(t,e,r,i){t.relurl=e.URI,e.BYTERANGE&&t.setByteRange(e.BYTERANGE),t.level=r,t.sn="initSegment",i&&(t.levelkeys=i),t.initSegment=null}function Re(t,e,r){t.levelkeys=e;var i=r.encryptedFragments;i.length&&i[i.length-1].levelkeys===e||!Object.keys(e).some((function(t){return e[t].isCommonEncryption}))||i.push(t)}var ke="manifest",be="level",De="audioTrack",Ie="subtitleTrack",we="main",Ce="audio",_e="subtitle";function xe(t){switch(t.type){case De:return Ce;case Ie:return _e;default:return we}}function Pe(t,e){var r=t.url;return void 0!==r&&0!==r.indexOf("data:")||(r=e.url),r}var Fe=function(){function t(t){this.hls=void 0,this.loaders=Object.create(null),this.variableList=null,this.hls=t,this.registerListeners()}var e=t.prototype;return e.startLoad=function(t){},e.stopLoad=function(){this.destroyInternalLoaders()},e.registerListeners=function(){var t=this.hls;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_LOADING,this.onLevelLoading,this),t.on(S.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.on(S.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_LOADING,this.onLevelLoading,this),t.off(S.AUDIO_TRACK_LOADING,this.onAudioTrackLoading,this),t.off(S.SUBTITLE_TRACK_LOADING,this.onSubtitleTrackLoading,this)},e.createInternalLoader=function(t){var e=this.hls.config,r=e.pLoader,i=e.loader,n=new(r||i)(e);return this.loaders[t.type]=n,n},e.getInternalLoader=function(t){return this.loaders[t.type]},e.resetInternalLoader=function(t){this.loaders[t]&&delete this.loaders[t]},e.destroyInternalLoaders=function(){for(var t in this.loaders){var e=this.loaders[t];e&&e.destroy(),this.resetInternalLoader(t)}},e.destroy=function(){this.variableList=null,this.unregisterListeners(),this.destroyInternalLoaders()},e.onManifestLoading=function(t,e){var r=e.url;this.variableList=null,this.load({id:null,level:0,responseType:"text",type:ke,url:r,deliveryDirectives:null})},e.onLevelLoading=function(t,e){var r=e.id,i=e.level,n=e.pathwayId,a=e.url,s=e.deliveryDirectives;this.load({id:r,level:i,pathwayId:n,responseType:"text",type:be,url:a,deliveryDirectives:s})},e.onAudioTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,a=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:De,url:n,deliveryDirectives:a})},e.onSubtitleTrackLoading=function(t,e){var r=e.id,i=e.groupId,n=e.url,a=e.deliveryDirectives;this.load({id:r,groupId:i,level:null,responseType:"text",type:Ie,url:n,deliveryDirectives:a})},e.load=function(t){var e,r,i,n=this,a=this.hls.config,s=this.getInternalLoader(t);if(s){var l=s.context;if(l&&l.url===t.url&&l.level===t.level)return void w.trace("[playlist-loader]: playlist request ongoing");w.log("[playlist-loader]: aborting previous loader for type: "+t.type),s.abort()}if(r=t.type===ke?a.manifestLoadPolicy.default:o({},a.playlistLoadPolicy.default,{timeoutRetry:null,errorRetry:null}),s=this.createInternalLoader(t),y(null==(e=t.deliveryDirectives)?void 0:e.part)&&(t.type===be&&null!==t.level?i=this.hls.levels[t.level].details:t.type===De&&null!==t.id?i=this.hls.audioTracks[t.id].details:t.type===Ie&&null!==t.id&&(i=this.hls.subtitleTracks[t.id].details),i)){var u=i.partTarget,h=i.targetduration;if(u&&h){var d=1e3*Math.max(3*u,.8*h);r=o({},r,{maxTimeToFirstByteMs:Math.min(d,r.maxTimeToFirstByteMs),maxLoadTimeMs:Math.min(d,r.maxTimeToFirstByteMs)})}}var c=r.errorRetry||r.timeoutRetry||{},f={loadPolicy:r,timeout:r.maxLoadTimeMs,maxRetry:c.maxNumRetry||0,retryDelay:c.retryDelayMs||0,maxRetryDelay:c.maxRetryDelayMs||0},g={onSuccess:function(t,e,r,i){var a=n.getInternalLoader(r);n.resetInternalLoader(r.type);var s=t.data;0===s.indexOf("#EXTM3U")?(e.parsing.start=performance.now(),pe.isMediaPlaylist(s)?n.handleTrackOrLevelPlaylist(t,e,r,i||null,a):n.handleMasterPlaylist(t,e,r,i)):n.handleManifestParsingError(t,r,new Error("no EXTM3U delimiter"),i||null,e)},onError:function(t,e,r,i){n.handleNetworkError(e,r,!1,t,i)},onTimeout:function(t,e,r){n.handleNetworkError(e,r,!0,void 0,t)}};s.load(t,f,g)},e.handleMasterPlaylist=function(t,e,r,i){var n=this.hls,a=t.data,s=Pe(t,r),o=pe.parseMasterPlaylist(a,s);if(o.playlistParsingError)this.handleManifestParsingError(t,r,o.playlistParsingError,i,e);else{var l=o.contentSteering,u=o.levels,h=o.sessionData,d=o.sessionKeys,c=o.startTimeOffset,f=o.variableList;this.variableList=f;var g=pe.parseMasterPlaylistMedia(a,s,o),v=g.AUDIO,m=void 0===v?[]:v,p=g.SUBTITLES,y=g["CLOSED-CAPTIONS"];m.length&&(m.some((function(t){return!t.url}))||!u[0].audioCodec||u[0].attrs.AUDIO||(w.log("[playlist-loader]: audio codec signaled in quality level, but no embedded audio track signaled, create one"),m.unshift({type:"main",name:"main",groupId:"main",default:!1,autoselect:!1,forced:!1,id:-1,attrs:new x({}),bitrate:0,url:""}))),n.trigger(S.MANIFEST_LOADED,{levels:u,audioTracks:m,subtitles:p,captions:y,contentSteering:l,url:s,stats:e,networkDetails:i,sessionData:h,sessionKeys:d,startTimeOffset:c,variableList:f})}},e.handleTrackOrLevelPlaylist=function(t,e,r,i,n){var a=this.hls,s=r.id,o=r.level,l=r.type,u=Pe(t,r),h=y(o)?o:y(s)?s:0,d=xe(r),c=pe.parseLevelPlaylist(t.data,u,h,d,0,this.variableList);if(l===ke){var f={attrs:new x({}),bitrate:0,details:c,name:"",url:u};a.trigger(S.MANIFEST_LOADED,{levels:[f],audioTracks:[],url:u,stats:e,networkDetails:i,sessionData:null,sessionKeys:null,contentSteering:null,startTimeOffset:null,variableList:null})}e.parsing.end=performance.now(),r.levelDetails=c,this.handlePlaylistLoaded(c,t,e,r,i,n)},e.handleManifestParsingError=function(t,e,r,i,n){this.hls.trigger(S.ERROR,{type:L.NETWORK_ERROR,details:A.MANIFEST_PARSING_ERROR,fatal:e.type===ke,url:t.url,err:r,error:r,reason:r.message,response:t,context:e,networkDetails:i,stats:n})},e.handleNetworkError=function(t,e,r,n,a){void 0===r&&(r=!1);var s="A network "+(r?"timeout":"error"+(n?" (status "+n.code+")":""))+" occurred while loading "+t.type;t.type===be?s+=": "+t.level+" id: "+t.id:t.type!==De&&t.type!==Ie||(s+=" id: "+t.id+' group-id: "'+t.groupId+'"');var o=new Error(s);w.warn("[playlist-loader]: "+s);var l=A.UNKNOWN,u=!1,h=this.getInternalLoader(t);switch(t.type){case ke:l=r?A.MANIFEST_LOAD_TIMEOUT:A.MANIFEST_LOAD_ERROR,u=!0;break;case be:l=r?A.LEVEL_LOAD_TIMEOUT:A.LEVEL_LOAD_ERROR,u=!1;break;case De:l=r?A.AUDIO_TRACK_LOAD_TIMEOUT:A.AUDIO_TRACK_LOAD_ERROR,u=!1;break;case Ie:l=r?A.SUBTITLE_TRACK_LOAD_TIMEOUT:A.SUBTITLE_LOAD_ERROR,u=!1}h&&this.resetInternalLoader(t.type);var d={type:L.NETWORK_ERROR,details:l,fatal:u,url:t.url,loader:h,context:t,error:o,networkDetails:e,stats:a};if(n){var c=(null==e?void 0:e.url)||t.url;d.response=i({url:c,data:void 0},n)}this.hls.trigger(S.ERROR,d)},e.handlePlaylistLoaded=function(t,e,r,i,n,a){var s=this.hls,o=i.type,l=i.level,u=i.id,h=i.groupId,d=i.deliveryDirectives,c=Pe(e,i),f=xe(i),g="number"==typeof i.level&&f===we?l:void 0;if(t.fragments.length){t.targetduration||(t.playlistParsingError=new Error("Missing Target Duration"));var v=t.playlistParsingError;if(v)s.trigger(S.ERROR,{type:L.NETWORK_ERROR,details:A.LEVEL_PARSING_ERROR,fatal:!1,url:c,error:v,reason:v.message,response:e,context:i,level:g,parent:f,networkDetails:n,stats:r});else switch(t.live&&a&&(a.getCacheAge&&(t.ageHeader=a.getCacheAge()||0),a.getCacheAge&&!isNaN(t.ageHeader)||(t.ageHeader=0)),o){case ke:case be:s.trigger(S.LEVEL_LOADED,{details:t,level:g||0,id:u||0,stats:r,networkDetails:n,deliveryDirectives:d});break;case De:s.trigger(S.AUDIO_TRACK_LOADED,{details:t,id:u||0,groupId:h||"",stats:r,networkDetails:n,deliveryDirectives:d});break;case Ie:s.trigger(S.SUBTITLE_TRACK_LOADED,{details:t,id:u||0,groupId:h||"",stats:r,networkDetails:n,deliveryDirectives:d})}}else{var m=new Error("No Segments found in Playlist");s.trigger(S.ERROR,{type:L.NETWORK_ERROR,details:A.LEVEL_EMPTY_ERROR,fatal:!1,url:c,error:m,reason:m.message,response:e,context:i,level:g,parent:f,networkDetails:n,stats:r})}},t}();function Me(t,e){var r;try{r=new Event("addtrack")}catch(t){(r=document.createEvent("Event")).initEvent("addtrack",!1,!1)}r.track=t,e.dispatchEvent(r)}function Oe(t,e){var r=t.mode;if("disabled"===r&&(t.mode="hidden"),t.cues&&!t.cues.getCueById(e.id))try{if(t.addCue(e),!t.cues.getCueById(e.id))throw new Error("addCue is failed for: "+e)}catch(r){w.debug("[texttrack-utils]: "+r);try{var i=new self.TextTrackCue(e.startTime,e.endTime,e.text);i.id=e.id,t.addCue(i)}catch(t){w.debug("[texttrack-utils]: Legacy TextTrackCue fallback failed: "+t)}}"disabled"===r&&(t.mode=r)}function Ne(t){var e=t.mode;if("disabled"===e&&(t.mode="hidden"),t.cues)for(var r=t.cues.length;r--;)t.removeCue(t.cues[r]);"disabled"===e&&(t.mode=e)}function Ue(t,e,r,i){var n=t.mode;if("disabled"===n&&(t.mode="hidden"),t.cues&&t.cues.length>0)for(var a=function(t,e,r){var i=[],n=function(t,e){if(et[r].endTime)return-1;for(var i=0,n=r;i<=n;){var a=Math.floor((n+i)/2);if(et[a].startTime&&i-1)for(var a=n,s=t.length;a=e&&o.endTime<=r)i.push(o);else if(o.startTime>r)return i}return i}(t.cues,e,r),s=0;sWe&&(d=We),d-h<=0&&(d=h+.25);for(var c=0;ce.startDate&&(!t||e.startDate.05&&this.forwardBufferLength>1){var l=Math.min(2,Math.max(1,a)),u=Math.round(2/(1+Math.exp(-.75*o-this.edgeStalled))*20)/20;t.playbackRate=Math.min(l,Math.max(1,u))}else 1!==t.playbackRate&&0!==t.playbackRate&&(t.playbackRate=1)}}}}},e.estimateLiveEdge=function(){var t=this.levelDetails;return null===t?null:t.edge+t.age},e.computeLatency=function(){var t=this.estimateLiveEdge();return null===t?null:t-this.currentTime},s(t,[{key:"latency",get:function(){return this._latency||0}},{key:"maxLatency",get:function(){var t=this.config,e=this.levelDetails;return void 0!==t.liveMaxLatencyDuration?t.liveMaxLatencyDuration:e?t.liveMaxLatencyDurationCount*e.targetduration:0}},{key:"targetLatency",get:function(){var t=this.levelDetails;if(null===t)return null;var e=t.holdBack,r=t.partHoldBack,i=t.targetduration,n=this.config,a=n.liveSyncDuration,s=n.liveSyncDurationCount,o=n.lowLatencyMode,l=this.hls.userConfig,u=o&&r||e;(l.liveSyncDuration||l.liveSyncDurationCount||0===u)&&(u=void 0!==a?a:s*i);var h=i;return u+Math.min(1*this.stallCount,h)}},{key:"liveSyncPosition",get:function(){var t=this.estimateLiveEdge(),e=this.targetLatency,r=this.levelDetails;if(null===t||null===e||null===r)return null;var i=r.edge,n=t-e-this.edgeStalled,a=i-r.totalduration,s=i-(this.config.lowLatencyMode&&r.partTarget||r.targetduration);return Math.min(Math.max(a,n),s)}},{key:"drift",get:function(){var t=this.levelDetails;return null===t?1:t.drift}},{key:"edgeStalled",get:function(){var t=this.levelDetails;if(null===t)return 0;var e=3*(this.config.lowLatencyMode&&t.partTarget||t.targetduration);return Math.max(t.age-e,0)}},{key:"forwardBufferLength",get:function(){var t=this.media,e=this.levelDetails;if(!t||!e)return 0;var r=t.buffered.length;return(r?t.buffered.end(r-1):e.edge)-this.currentTime}}]),t}(),ze=["NONE","TYPE-0","TYPE-1",null],Qe=["SDR","PQ","HLG"],Je="",$e="YES",Ze="v2",tr=function(){function t(t,e,r){this.msn=void 0,this.part=void 0,this.skip=void 0,this.msn=t,this.part=e,this.skip=r}return t.prototype.addDirectives=function(t){var e=new self.URL(t);return void 0!==this.msn&&e.searchParams.set("_HLS_msn",this.msn.toString()),void 0!==this.part&&e.searchParams.set("_HLS_part",this.part.toString()),this.skip&&e.searchParams.set("_HLS_skip",this.skip),e.href},t}(),er=function(){function t(t){this._attrs=void 0,this.audioCodec=void 0,this.bitrate=void 0,this.codecSet=void 0,this.url=void 0,this.frameRate=void 0,this.height=void 0,this.id=void 0,this.name=void 0,this.videoCodec=void 0,this.width=void 0,this.details=void 0,this.fragmentError=0,this.loadError=0,this.loaded=void 0,this.realBitrate=0,this.supportedPromise=void 0,this.supportedResult=void 0,this._avgBitrate=0,this._audioGroups=void 0,this._subtitleGroups=void 0,this._urlId=0,this.url=[t.url],this._attrs=[t.attrs],this.bitrate=t.bitrate,t.details&&(this.details=t.details),this.id=t.id||0,this.name=t.name,this.width=t.width||0,this.height=t.height||0,this.frameRate=t.attrs.optionalFloat("FRAME-RATE",0),this._avgBitrate=t.attrs.decimalInteger("AVERAGE-BANDWIDTH"),this.audioCodec=t.audioCodec,this.videoCodec=t.videoCodec,this.codecSet=[t.videoCodec,t.audioCodec].filter((function(t){return!!t})).map((function(t){return t.substring(0,4)})).join(","),this.addGroupId("audio",t.attrs.AUDIO),this.addGroupId("text",t.attrs.SUBTITLES)}var e=t.prototype;return e.hasAudioGroup=function(t){return rr(this._audioGroups,t)},e.hasSubtitleGroup=function(t){return rr(this._subtitleGroups,t)},e.addGroupId=function(t,e){if(e)if("audio"===t){var r=this._audioGroups;r||(r=this._audioGroups=[]),-1===r.indexOf(e)&&r.push(e)}else if("text"===t){var i=this._subtitleGroups;i||(i=this._subtitleGroups=[]),-1===i.indexOf(e)&&i.push(e)}},e.addFallback=function(){},s(t,[{key:"maxBitrate",get:function(){return Math.max(this.realBitrate,this.bitrate)}},{key:"averageBitrate",get:function(){return this._avgBitrate||this.realBitrate||this.bitrate}},{key:"attrs",get:function(){return this._attrs[0]}},{key:"codecs",get:function(){return this.attrs.CODECS||""}},{key:"pathwayId",get:function(){return this.attrs["PATHWAY-ID"]||"."}},{key:"videoRange",get:function(){return this.attrs["VIDEO-RANGE"]||"SDR"}},{key:"score",get:function(){return this.attrs.optionalFloat("SCORE",0)}},{key:"uri",get:function(){return this.url[0]||""}},{key:"audioGroups",get:function(){return this._audioGroups}},{key:"subtitleGroups",get:function(){return this._subtitleGroups}},{key:"urlId",get:function(){return 0},set:function(t){}},{key:"audioGroupIds",get:function(){return this.audioGroups?[this.audioGroupId]:void 0}},{key:"textGroupIds",get:function(){return this.subtitleGroups?[this.textGroupId]:void 0}},{key:"audioGroupId",get:function(){var t;return null==(t=this.audioGroups)?void 0:t[0]}},{key:"textGroupId",get:function(){var t;return null==(t=this.subtitleGroups)?void 0:t[0]}}]),t}();function rr(t,e){return!(!e||!t)&&-1!==t.indexOf(e)}function ir(t,e){var r=e.startPTS;if(y(r)){var i,n=0;e.sn>t.sn?(n=r-t.start,i=t):(n=t.start-r,i=e),i.duration!==n&&(i.duration=n)}else e.sn>t.sn?t.cc===e.cc&&t.minEndPTS?e.start=t.start+(t.minEndPTS-t.start):e.start=t.start+t.duration:e.start=Math.max(t.start-e.duration,0)}function nr(t,e,r,i,n,a){i-r<=0&&(w.warn("Fragment should have a positive duration",e),i=r+e.duration,a=n+e.duration);var s=r,o=i,l=e.startPTS,u=e.endPTS;if(y(l)){var h=Math.abs(l-r);y(e.deltaPTS)?e.deltaPTS=Math.max(h,e.deltaPTS):e.deltaPTS=h,s=Math.max(r,l),r=Math.min(r,l),n=Math.min(n,e.startDTS),o=Math.min(i,u),i=Math.max(i,u),a=Math.max(a,e.endDTS)}var d=r-e.start;0!==e.start&&(e.start=r),e.duration=i-e.start,e.startPTS=r,e.maxStartPTS=s,e.startDTS=n,e.endPTS=i,e.minEndPTS=o,e.endDTS=a;var c,f=e.sn;if(!t||ft.endSN)return 0;var g=f-t.startSN,v=t.fragments;for(v[g]=e,c=g;c>0;c--)ir(v[c],v[c-1]);for(c=g;c=0;n--){var a=i[n].initSegment;if(a){r=a;break}}t.fragmentHint&&delete t.fragmentHint.endPTS;var s,l,u,h,d,c=0;if(function(t,e,r){for(var i=e.skippedSegments,n=Math.max(t.startSN,e.startSN)-e.startSN,a=(t.fragmentHint?1:0)+(i?e.endSN:Math.min(t.endSN,e.endSN))-e.startSN,s=e.startSN-t.startSN,o=e.fragmentHint?e.fragments.concat(e.fragmentHint):e.fragments,l=t.fragmentHint?t.fragments.concat(t.fragmentHint):t.fragments,u=n;u<=a;u++){var h=l[s+u],d=o[u];i&&!d&&u=i.length||or(e,i[r].start)}function or(t,e){if(e){for(var r=t.fragments,i=t.skippedSegments;i499)}(n)||!!r);return t.shouldRetry?t.shouldRetry(t,e,r,i,a):a}var mr=function(t,e){for(var r=0,i=t.length-1,n=null,a=null;r<=i;){var s=e(a=t[n=(r+i)/2|0]);if(s>0)r=n+1;else{if(!(s<0))return a;i=n-1}}return null};function pr(t,e,r,i){void 0===r&&(r=0),void 0===i&&(i=0);var n=null;if(t){n=e[t.sn-e[0].sn+1]||null;var a=t.endDTS-r;a>0&&a<15e-7&&(r+=15e-7)}else 0===r&&0===e[0].start&&(n=e[0]);if(n&&(!t||t.level===n.level)&&0===yr(r,i,n))return n;var s=mr(e,yr.bind(null,r,i));return!s||s===t&&n?n:s}function yr(t,e,r){if(void 0===t&&(t=0),void 0===e&&(e=0),r.start<=t&&r.start+r.duration>t)return 0;var i=Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return r.start+r.duration-i<=t?1:r.start-i>t&&r.start?-1:0}function Er(t,e,r){var i=1e3*Math.min(e,r.duration+(r.deltaPTS?r.deltaPTS:0));return(r.endProgramDateTime||0)-i>t}var Tr=0,Sr=2,Lr=3,Ar=5,Rr=0,kr=1,br=2,Dr=function(){function t(t){this.hls=void 0,this.playlistError=0,this.penalizedRenditions={},this.log=void 0,this.warn=void 0,this.error=void 0,this.hls=t,this.log=w.log.bind(w,"[info]:"),this.warn=w.warn.bind(w,"[warning]:"),this.error=w.error.bind(w,"[error]:"),this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(S.ERROR,this.onError,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this)},e.unregisterListeners=function(){var t=this.hls;t&&(t.off(S.ERROR,this.onError,this),t.off(S.ERROR,this.onErrorOut,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this))},e.destroy=function(){this.unregisterListeners(),this.hls=null,this.penalizedRenditions={}},e.startLoad=function(t){},e.stopLoad=function(){this.playlistError=0},e.getVariantLevelIndex=function(t){return(null==t?void 0:t.type)===we?t.level:this.hls.loadLevel},e.onManifestLoading=function(){this.playlistError=0,this.penalizedRenditions={}},e.onLevelUpdated=function(){this.playlistError=0},e.onError=function(t,e){var r,i;if(!e.fatal){var n=this.hls,a=e.context;switch(e.details){case A.FRAG_LOAD_ERROR:case A.FRAG_LOAD_TIMEOUT:case A.KEY_LOAD_ERROR:case A.KEY_LOAD_TIMEOUT:return void(e.errorAction=this.getFragRetryOrSwitchAction(e));case A.FRAG_PARSING_ERROR:if(null!=(r=e.frag)&&r.gap)return void(e.errorAction={action:Tr,flags:Rr});case A.FRAG_GAP:case A.FRAG_DECRYPT_ERROR:return e.errorAction=this.getFragRetryOrSwitchAction(e),void(e.errorAction.action=Sr);case A.LEVEL_EMPTY_ERROR:case A.LEVEL_PARSING_ERROR:var s,o,l=e.parent===we?e.level:n.loadLevel;return void(e.details===A.LEVEL_EMPTY_ERROR&&null!=(s=e.context)&&null!=(o=s.levelDetails)&&o.live?e.errorAction=this.getPlaylistRetryOrSwitchAction(e,l):(e.levelRetry=!1,e.errorAction=this.getLevelSwitchAction(e,l)));case A.LEVEL_LOAD_ERROR:case A.LEVEL_LOAD_TIMEOUT:return void("number"==typeof(null==a?void 0:a.level)&&(e.errorAction=this.getPlaylistRetryOrSwitchAction(e,a.level)));case A.AUDIO_TRACK_LOAD_ERROR:case A.AUDIO_TRACK_LOAD_TIMEOUT:case A.SUBTITLE_LOAD_ERROR:case A.SUBTITLE_TRACK_LOAD_TIMEOUT:if(a){var u=n.levels[n.loadLevel];if(u&&(a.type===De&&u.hasAudioGroup(a.groupId)||a.type===Ie&&u.hasSubtitleGroup(a.groupId)))return e.errorAction=this.getPlaylistRetryOrSwitchAction(e,n.loadLevel),e.errorAction.action=Sr,void(e.errorAction.flags=kr)}return;case A.KEY_SYSTEM_STATUS_OUTPUT_RESTRICTED:var h=n.levels[n.loadLevel],d=null==h?void 0:h.attrs["HDCP-LEVEL"];return void(d?e.errorAction={action:Sr,flags:br,hdcpLevel:d}:this.keySystemError(e));case A.BUFFER_ADD_CODEC_ERROR:case A.REMUX_ALLOC_ERROR:case A.BUFFER_APPEND_ERROR:return void(e.errorAction=this.getLevelSwitchAction(e,null!=(i=e.level)?i:n.loadLevel));case A.INTERNAL_EXCEPTION:case A.BUFFER_APPENDING_ERROR:case A.BUFFER_FULL_ERROR:case A.LEVEL_SWITCH_ERROR:case A.BUFFER_STALLED_ERROR:case A.BUFFER_SEEK_OVER_HOLE:case A.BUFFER_NUDGE_ON_STALL:return void(e.errorAction={action:Tr,flags:Rr})}e.type===L.KEY_SYSTEM_ERROR&&this.keySystemError(e)}},e.keySystemError=function(t){var e=this.getVariantLevelIndex(t.frag);t.levelRetry=!1,t.errorAction=this.getLevelSwitchAction(t,e)},e.getPlaylistRetryOrSwitchAction=function(t,e){var r=cr(this.hls.config.playlistLoadPolicy,t),i=this.playlistError++;if(vr(r,i,dr(t),t.response))return{action:Ar,flags:Rr,retryConfig:r,retryCount:i};var n=this.getLevelSwitchAction(t,e);return r&&(n.retryConfig=r,n.retryCount=i),n},e.getFragRetryOrSwitchAction=function(t){var e=this.hls,r=this.getVariantLevelIndex(t.frag),i=e.levels[r],n=e.config,a=n.fragLoadPolicy,s=n.keyLoadPolicy,o=cr(t.details.startsWith("key")?s:a,t),l=e.levels.reduce((function(t,e){return t+e.fragmentError}),0);if(i&&(t.details!==A.FRAG_GAP&&i.fragmentError++,vr(o,l,dr(t),t.response)))return{action:Ar,flags:Rr,retryConfig:o,retryCount:l};var u=this.getLevelSwitchAction(t,r);return o&&(u.retryConfig=o,u.retryCount=l),u},e.getLevelSwitchAction=function(t,e){var r=this.hls;null==e&&(e=r.loadLevel);var i=this.hls.levels[e];if(i){var n,a,s=t.details;i.loadError++,s===A.BUFFER_APPEND_ERROR&&i.fragmentError++;var o=-1,l=r.levels,u=r.loadLevel,h=r.minAutoLevel,d=r.maxAutoLevel;r.autoLevelEnabled||(r.loadLevel=-1);for(var c,f=null==(n=t.frag)?void 0:n.type,g=(f===Ce&&s===A.FRAG_PARSING_ERROR||"audio"===t.sourceBufferName&&(s===A.BUFFER_ADD_CODEC_ERROR||s===A.BUFFER_APPEND_ERROR))&&l.some((function(t){var e=t.audioCodec;return i.audioCodec!==e})),v="video"===t.sourceBufferName&&(s===A.BUFFER_ADD_CODEC_ERROR||s===A.BUFFER_APPEND_ERROR)&&l.some((function(t){var e=t.codecSet,r=t.audioCodec;return i.codecSet!==e&&i.audioCodec===r})),m=null!=(a=t.context)?a:{},p=m.type,y=m.groupId,E=function(){var e=(T+u)%l.length;if(e!==u&&e>=h&&e<=d&&0===l[e].loadError){var r,n,a=l[e];if(s===A.FRAG_GAP&&t.frag){var c=l[e].details;if(c){var m=pr(t.frag,c.fragments,t.frag.start);if(null!=m&&m.gap)return 0}}else{if(p===De&&a.hasAudioGroup(y)||p===Ie&&a.hasSubtitleGroup(y))return 0;if(f===Ce&&null!=(r=i.audioGroups)&&r.some((function(t){return a.hasAudioGroup(t)}))||f===_e&&null!=(n=i.subtitleGroups)&&n.some((function(t){return a.hasSubtitleGroup(t)}))||g&&i.audioCodec===a.audioCodec||!g&&i.audioCodec!==a.audioCodec||v&&i.codecSet===a.codecSet)return 0}return o=e,1}},T=l.length;T--&&(0===(c=E())||1!==c););if(o>-1&&r.loadLevel!==o)return t.levelRetry=!0,this.playlistError=0,{action:Sr,flags:Rr,nextAutoLevel:o}}return{action:Sr,flags:kr}},e.onErrorOut=function(t,e){var r;switch(null==(r=e.errorAction)?void 0:r.action){case Tr:break;case Sr:this.sendAlternateToPenaltyBox(e),e.errorAction.resolved||e.details===A.FRAG_GAP?/MediaSource readyState: ended/.test(e.error.message)&&(this.warn('MediaSource ended after "'+e.sourceBufferName+'" sourceBuffer append error. Attempting to recover from media error.'),this.hls.recoverMediaError()):e.fatal=!0}e.fatal&&this.hls.stopLoad()},e.sendAlternateToPenaltyBox=function(t){var e=this.hls,r=t.errorAction;if(r){var i=r.flags,n=r.hdcpLevel,a=r.nextAutoLevel;switch(i){case Rr:this.switchLevel(t,a);break;case br:n&&(e.maxHdcpLevel=ze[ze.indexOf(n)-1],r.resolved=!0),this.warn('Restricting playback to HDCP-LEVEL of "'+e.maxHdcpLevel+'" or lower')}r.resolved||this.switchLevel(t,a)}},e.switchLevel=function(t,e){void 0!==e&&t.errorAction&&(this.warn("switching to level "+e+" after "+t.details),this.hls.nextAutoLevel=e,t.errorAction.resolved=!0,this.hls.nextLoadLevel=this.hls.nextAutoLevel)},t}(),Ir=function(){function t(t,e){this.hls=void 0,this.timer=-1,this.requestScheduled=-1,this.canLoad=!1,this.log=void 0,this.warn=void 0,this.log=w.log.bind(w,e+":"),this.warn=w.warn.bind(w,e+":"),this.hls=t}var e=t.prototype;return e.destroy=function(){this.clearTimer(),this.hls=this.log=this.warn=null},e.clearTimer=function(){-1!==this.timer&&(self.clearTimeout(this.timer),this.timer=-1)},e.startLoad=function(){this.canLoad=!0,this.requestScheduled=-1,this.loadPlaylist()},e.stopLoad=function(){this.canLoad=!1,this.clearTimer()},e.switchParams=function(t,e){var r=null==e?void 0:e.renditionReports;if(r){for(var i=-1,n=0;n=0&&h>e.partTarget&&(u+=1)}return new tr(l,u>=0?u:void 0,Je)}}},e.loadPlaylist=function(t){-1===this.requestScheduled&&(this.requestScheduled=self.performance.now())},e.shouldLoadPlaylist=function(t){return this.canLoad&&!!t&&!!t.url&&(!t.details||t.details.live)},e.shouldReloadPlaylist=function(t){return-1===this.timer&&-1===this.requestScheduled&&this.shouldLoadPlaylist(t)},e.playlistLoaded=function(t,e,r){var i=this,n=e.details,a=e.stats,s=self.performance.now(),o=a.loading.first?Math.max(0,s-a.loading.first):0;if(n.advancedDateTime=Date.now()-o,n.live||null!=r&&r.live){if(n.reloaded(r),r&&this.log("live playlist "+t+" "+(n.advanced?"REFRESHED "+n.lastPartSn+"-"+n.lastPartIndex:n.updated?"UPDATED":"MISSED")),r&&n.fragments.length>0&&ar(r,n),!this.canLoad||!n.live)return;var l,u=void 0,h=void 0;if(n.canBlockReload&&n.endSN&&n.advanced){var d=this.hls.config.lowLatencyMode,c=n.lastPartSn,f=n.endSN,g=n.lastPartIndex,v=c===f;-1!==g?(u=v?f+1:c,h=v?d?0:g:g+1):u=f+1;var m=n.age,p=m+n.ageHeader,y=Math.min(p-n.partTarget,1.5*n.targetduration);if(y>0){if(r&&y>r.tuneInGoal)this.warn("CDN Tune-in goal increased from: "+r.tuneInGoal+" to: "+y+" with playlist age: "+n.age),y=0;else{var E=Math.floor(y/n.targetduration);u+=E,void 0!==h&&(h+=Math.round(y%n.targetduration/n.partTarget)),this.log("CDN Tune-in age: "+n.ageHeader+"s last advanced "+m.toFixed(2)+"s goal: "+y+" skip sn "+E+" to part "+h)}n.tuneInGoal=y}if(l=this.getDeliveryDirectives(n,e.deliveryDirectives,u,h),d||!v)return void this.loadPlaylist(l)}else(n.canBlockReload||n.canSkipUntil)&&(l=this.getDeliveryDirectives(n,e.deliveryDirectives,u,h));var T=this.hls.mainForwardBufferInfo,S=T?T.end-T.len:0,L=function(t,e){void 0===e&&(e=1/0);var r=1e3*t.targetduration;if(t.updated){var i=t.fragments;if(i.length&&4*r>e){var n=1e3*i[i.length-1].duration;nthis.requestScheduled+L&&(this.requestScheduled=a.loading.start),void 0!==u&&n.canBlockReload?this.requestScheduled=a.loading.first+L-(1e3*n.partTarget||1e3):-1===this.requestScheduled||this.requestScheduled+L=u.maxNumRetry)return!1;if(i&&null!=(d=t.context)&&d.deliveryDirectives)this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" without delivery-directives'),this.loadPlaylist();else{var c=fr(u,l);this.timer=self.setTimeout((function(){return e.loadPlaylist()}),c),this.warn("Retrying playlist loading "+(l+1)+"/"+u.maxNumRetry+' after "'+r+'" in '+c+"ms")}t.levelRetry=!0,n.resolved=!0}return h},t}(),wr=function(){function t(t,e,r){void 0===e&&(e=0),void 0===r&&(r=0),this.halfLife=void 0,this.alpha_=void 0,this.estimate_=void 0,this.totalWeight_=void 0,this.halfLife=t,this.alpha_=t?Math.exp(Math.log(.5)/t):0,this.estimate_=e,this.totalWeight_=r}var e=t.prototype;return e.sample=function(t,e){var r=Math.pow(this.alpha_,t);this.estimate_=e*(1-r)+r*this.estimate_,this.totalWeight_+=t},e.getTotalWeight=function(){return this.totalWeight_},e.getEstimate=function(){if(this.alpha_){var t=1-Math.pow(this.alpha_,this.totalWeight_);if(t)return this.estimate_/t}return this.estimate_},t}(),Cr=function(){function t(t,e,r,i){void 0===i&&(i=100),this.defaultEstimate_=void 0,this.minWeight_=void 0,this.minDelayMs_=void 0,this.slow_=void 0,this.fast_=void 0,this.defaultTTFB_=void 0,this.ttfb_=void 0,this.defaultEstimate_=r,this.minWeight_=.001,this.minDelayMs_=50,this.slow_=new wr(t),this.fast_=new wr(e),this.defaultTTFB_=i,this.ttfb_=new wr(t)}var e=t.prototype;return e.update=function(t,e){var r=this.slow_,i=this.fast_,n=this.ttfb_;r.halfLife!==t&&(this.slow_=new wr(t,r.getEstimate(),r.getTotalWeight())),i.halfLife!==e&&(this.fast_=new wr(e,i.getEstimate(),i.getTotalWeight())),n.halfLife!==t&&(this.ttfb_=new wr(t,n.getEstimate(),n.getTotalWeight()))},e.sample=function(t,e){var r=(t=Math.max(t,this.minDelayMs_))/1e3,i=8*e/r;this.fast_.sample(r,i),this.slow_.sample(r,i)},e.sampleTTFB=function(t){var e=t/1e3,r=Math.sqrt(2)*Math.exp(-Math.pow(e,2)/2);this.ttfb_.sample(r,Math.max(t,5))},e.canEstimate=function(){return this.fast_.getTotalWeight()>=this.minWeight_},e.getEstimate=function(){return this.canEstimate()?Math.min(this.fast_.getEstimate(),this.slow_.getEstimate()):this.defaultEstimate_},e.getEstimateTTFB=function(){return this.ttfb_.getTotalWeight()>=this.minWeight_?this.ttfb_.getEstimate():this.defaultTTFB_},e.destroy=function(){},t}(),_r={supported:!0,configurations:[],decodingInfoResults:[{supported:!0,powerEfficient:!0,smooth:!0}]},xr={};function Pr(t,e,r){var n=t.videoCodec,a=t.audioCodec;if(!n||!a||!r)return Promise.resolve(_r);var s={width:t.width,height:t.height,bitrate:Math.ceil(Math.max(.9*t.bitrate,t.averageBitrate)),framerate:t.frameRate||30},o=t.videoRange;"SDR"!==o&&(s.transferFunction=o.toLowerCase());var l=n.split(",").map((function(t){return{type:"media-source",video:i(i({},s),{},{contentType:ae(t,"video")})}}));return a&&t.audioGroups&&t.audioGroups.forEach((function(t){var r;t&&(null==(r=e.groups[t])||r.tracks.forEach((function(e){if(e.groupId===t){var r=e.channels||"",i=parseFloat(r);y(i)&&i>2&&l.push.apply(l,a.split(",").map((function(t){return{type:"media-source",audio:{contentType:ae(t,"audio"),channels:""+i}}})))}})))})),Promise.all(l.map((function(t){var e=function(t){var e=t.audio,r=t.video,i=r||e;if(i){var n=i.contentType.split('"')[1];if(r)return"r"+r.height+"x"+r.width+"f"+Math.ceil(r.framerate)+(r.transferFunction||"sd")+"_"+n+"_"+Math.ceil(r.bitrate/1e5);if(e)return"c"+e.channels+(e.spatialRendering?"s":"n")+"_"+n}return""}(t);return xr[e]||(xr[e]=r.decodingInfo(t))}))).then((function(t){return{supported:!t.some((function(t){return!t.supported})),configurations:l,decodingInfoResults:t}})).catch((function(t){return{supported:!1,configurations:l,decodingInfoResults:[],error:t}}))}function Fr(t,e){var r=!1,i=[];return t&&(r="SDR"!==t,i=[t]),e&&(i=e.allowedVideoRanges||Qe.slice(0),i=(r=void 0!==e.preferHDR?e.preferHDR:function(){if("function"==typeof matchMedia){var t=matchMedia("(dynamic-range: high)"),e=matchMedia("bad query");if(t.media!==e.media)return!0===t.matches}return!1}())?i.filter((function(t){return"SDR"!==t})):["SDR"]),{preferHDR:r,allowedVideoRanges:i}}function Mr(t,e){w.log('[abr] start candidates with "'+t+'" ignored because '+e)}function Or(t,e,r){if("attrs"in t){var i=e.indexOf(t);if(-1!==i)return i}for(var n=0;n-1,p=e.getBwEstimate(),E=i.levels,T=E[t.level],L=o.total||Math.max(o.loaded,Math.round(l*T.averageBitrate/8)),A=m?u-v:u;A<1&&m&&(A=Math.min(u,8*o.loaded/p));var R=m?1e3*o.loaded/A:0,k=R?(L-o.loaded)/R:8*L/p+c/1e3;if(!(k<=g)){var b,D=R?8*R:p,I=Number.POSITIVE_INFINITY;for(b=t.level-1;b>h;b--){var C=E[b].maxBitrate;if((I=e.getTimeToLoadFrag(c/1e3,D,l*C,!E[b].details))=k||I>10*l)){i.nextLoadLevel=i.nextAutoLevel=b,m?e.bwEstimator.sample(u-Math.min(c,v),o.loaded):e.bwEstimator.sampleTTFB(u);var _=E[b].maxBitrate;e.getBwEstimate()*e.hls.config.abrBandWidthUpFactor>_&&e.resetEstimator(_),e.clearTimer(),w.warn("[abr] Fragment "+t.sn+(r?" part "+r.index:"")+" of level "+t.level+" is loading too slowly;\n Time to underbuffer: "+g.toFixed(3)+" s\n Estimated load time for current fragment: "+k.toFixed(3)+" s\n Estimated load time for down switch fragment: "+I.toFixed(3)+" s\n TTFB estimate: "+(0|v)+" ms\n Current BW estimate: "+(y(p)?0|p:"Unknown")+" bps\n New BW estimate: "+(0|e.getBwEstimate())+" bps\n Switching to level "+b+" @ "+(0|_)+" bps"),i.trigger(S.FRAG_LOAD_EMERGENCY_ABORTED,{frag:t,part:r,stats:o})}}}}}}},this.hls=t,this.bwEstimator=this.initEstimator(),this.registerListeners()}var e=t.prototype;return e.resetEstimator=function(t){t&&(w.log("setting initial bwe to "+t),this.hls.config.abrEwmaDefaultEstimate=t),this.firstSelection=-1,this.bwEstimator=this.initEstimator()},e.initEstimator=function(){var t=this.hls.config;return new Cr(t.abrEwmaSlowVoD,t.abrEwmaFastVoD,t.abrEwmaDefaultEstimate)},e.registerListeners=function(){var t=this.hls;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.FRAG_LOADING,this.onFragLoading,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(S.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.on(S.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t&&(t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.FRAG_LOADING,this.onFragLoading,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.LEVEL_SWITCHING,this.onLevelSwitching,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(S.MAX_AUTO_LEVEL_UPDATED,this.onMaxAutoLevelUpdated,this),t.off(S.ERROR,this.onError,this))},e.destroy=function(){this.unregisterListeners(),this.clearTimer(),this.hls=this._abandonRulesCheck=null,this.fragCurrent=this.partCurrent=null},e.onManifestLoading=function(t,e){this.lastLoadedFragLevel=-1,this.firstSelection=-1,this.lastLevelLoadSec=0,this.fragCurrent=this.partCurrent=null,this.onLevelsUpdated(),this.clearTimer()},e.onLevelsUpdated=function(){this.lastLoadedFragLevel>-1&&this.fragCurrent&&(this.lastLoadedFragLevel=this.fragCurrent.level),this._nextAutoLevel=-1,this.onMaxAutoLevelUpdated(),this.codecTiers=null,this.audioTracksByGroup=null},e.onMaxAutoLevelUpdated=function(){this.firstSelection=-1,this.nextAutoLevelKey=""},e.onFragLoading=function(t,e){var r,i=e.frag;this.ignoreFragment(i)||(i.bitrateTest||(this.fragCurrent=i,this.partCurrent=null!=(r=e.part)?r:null),this.clearTimer(),this.timer=self.setInterval(this._abandonRulesCheck,100))},e.onLevelSwitching=function(t,e){this.clearTimer()},e.onError=function(t,e){if(!e.fatal)switch(e.details){case A.BUFFER_ADD_CODEC_ERROR:case A.BUFFER_APPEND_ERROR:this.lastLoadedFragLevel=-1,this.firstSelection=-1;break;case A.FRAG_LOAD_TIMEOUT:var r=e.frag,i=this.fragCurrent,n=this.partCurrent;if(r&&i&&r.sn===i.sn&&r.level===i.level){var a=performance.now(),s=n?n.stats:r.stats,o=a-s.loading.start,l=s.loading.first?s.loading.first-s.loading.start:-1;if(s.loaded&&l>-1){var u=this.bwEstimator.getEstimateTTFB();this.bwEstimator.sample(o-Math.min(u,l),s.loaded)}else this.bwEstimator.sampleTTFB(o)}}},e.getTimeToLoadFrag=function(t,e,r,i){return t+r/e+(i?this.lastLevelLoadSec:0)},e.onLevelLoaded=function(t,e){var r=this.hls.config,i=e.stats.loading,n=i.end-i.start;y(n)&&(this.lastLevelLoadSec=n/1e3),e.details.live?this.bwEstimator.update(r.abrEwmaSlowLive,r.abrEwmaFastLive):this.bwEstimator.update(r.abrEwmaSlowVoD,r.abrEwmaFastVoD)},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part,n=i?i.stats:r.stats;if(r.type===we&&this.bwEstimator.sampleTTFB(n.loading.first-n.loading.start),!this.ignoreFragment(r)){if(this.clearTimer(),r.level===this._nextAutoLevel&&(this._nextAutoLevel=-1),this.firstSelection=-1,this.hls.config.abrMaxWithRealBitrate){var a=i?i.duration:r.duration,s=this.hls.levels[r.level],o=(s.loaded?s.loaded.bytes:0)+n.loaded,l=(s.loaded?s.loaded.duration:0)+a;s.loaded={bytes:o,duration:l},s.realBitrate=Math.round(8*o/l)}if(r.bitrateTest){var u={stats:n,frag:r,part:i,id:r.type};this.onFragBuffered(S.FRAG_BUFFERED,u),r.bitrateTest=!1}else this.lastLoadedFragLevel=r.level}},e.onFragBuffered=function(t,e){var r=e.frag,i=e.part,n=null!=i&&i.stats.loaded?i.stats:r.stats;if(!n.aborted&&!this.ignoreFragment(r)){var a=n.parsing.end-n.loading.start-Math.min(n.loading.first-n.loading.start,this.bwEstimator.getEstimateTTFB());this.bwEstimator.sample(a,n.loaded),n.bwEstimate=this.getBwEstimate(),r.bitrateTest?this.bitrateTestDelay=a/1e3:this.bitrateTestDelay=0}},e.ignoreFragment=function(t){return t.type!==we||"initSegment"===t.sn},e.clearTimer=function(){this.timer>-1&&(self.clearInterval(this.timer),this.timer=-1)},e.getAutoLevelKey=function(){return this.getBwEstimate()+"_"+this.getStarvationDelay().toFixed(2)},e.getNextABRAutoLevel=function(){var t=this.fragCurrent,e=this.partCurrent,r=this.hls,i=r.maxAutoLevel,n=r.config,a=r.minAutoLevel,s=e?e.duration:t?t.duration:0,o=this.getBwEstimate(),l=this.getStarvationDelay(),u=n.abrBandWidthFactor,h=n.abrBandWidthUpFactor;if(l){var d=this.findBestLevel(o,a,i,l,0,u,h);if(d>=0)return d}var c=s?Math.min(s,n.maxStarvationDelay):n.maxStarvationDelay;if(!l){var f=this.bitrateTestDelay;f&&(c=(s?Math.min(s,n.maxLoadingDelay):n.maxLoadingDelay)-f,w.info("[abr] bitrate test took "+Math.round(1e3*f)+"ms, set first fragment max fetchDuration to "+Math.round(1e3*c)+" ms"),u=h=1)}var g=this.findBestLevel(o,a,i,l,c,u,h);if(w.info("[abr] "+(l?"rebuffering expected":"buffer is empty")+", optimal quality level "+g),g>-1)return g;var v=r.levels[a],m=r.levels[r.loadLevel];return(null==v?void 0:v.bitrate)<(null==m?void 0:m.bitrate)?a:r.loadLevel},e.getStarvationDelay=function(){var t=this.hls,e=t.media;if(!e)return 1/0;var r=e&&0!==e.playbackRate?Math.abs(e.playbackRate):1,i=t.mainForwardBufferInfo;return(i?i.len:0)/r},e.getBwEstimate=function(){return this.bwEstimator.canEstimate()?this.bwEstimator.getEstimate():this.hls.config.abrEwmaDefaultEstimate},e.findBestLevel=function(t,e,r,i,n,a,s){var o,l=this,u=i+n,h=this.lastLoadedFragLevel,d=-1===h?this.hls.firstLevel:h,c=this.fragCurrent,f=this.partCurrent,g=this.hls,v=g.levels,m=g.allAudioTracks,p=g.loadLevel,E=g.config;if(1===v.length)return 0;var T,S=v[d],L=!(null==S||null==(o=S.details)||!o.live),A=-1===p||-1===h,R="SDR",k=(null==S?void 0:S.frameRate)||0,b=E.audioPreference,D=E.videoPreference,I=this.audioTracksByGroup||(this.audioTracksByGroup=function(t){return t.reduce((function(t,e){var r=t.groups[e.groupId];r||(r=t.groups[e.groupId]={tracks:[],channels:{2:0},hasDefault:!1,hasAutoSelect:!1}),r.tracks.push(e);var i=e.channels||"2";return r.channels[i]=(r.channels[i]||0)+1,r.hasDefault=r.hasDefault||e.default,r.hasAutoSelect=r.hasAutoSelect||e.autoselect,r.hasDefault&&(t.hasDefaultAudio=!0),r.hasAutoSelect&&(t.hasAutoSelectAudio=!0),t}),{hasDefaultAudio:!1,hasAutoSelectAudio:!1,groups:{}})}(m));if(A){if(-1!==this.firstSelection)return this.firstSelection;var C=this.codecTiers||(this.codecTiers=function(t,e,r,i){return t.slice(r,i+1).reduce((function(t,r){if(!r.codecSet)return t;var i=r.audioGroups,n=t[r.codecSet];n||(t[r.codecSet]=n={minBitrate:1/0,minHeight:1/0,minFramerate:1/0,maxScore:0,videoRanges:{SDR:0},channels:{2:0},hasDefaultAudio:!i,fragmentError:0}),n.minBitrate=Math.min(n.minBitrate,r.bitrate);var a=Math.min(r.height,r.width);return n.minHeight=Math.min(n.minHeight,a),n.minFramerate=Math.min(n.minFramerate,r.frameRate),n.maxScore=Math.max(n.maxScore,r.score),n.fragmentError+=r.fragmentError,n.videoRanges[r.videoRange]=(n.videoRanges[r.videoRange]||0)+1,i&&i.forEach((function(t){if(t){var r=e.groups[t];n.hasDefaultAudio=n.hasDefaultAudio||e.hasDefaultAudio?r.hasDefault:r.hasAutoSelect||!e.hasDefaultAudio&&!e.hasAutoSelectAudio,Object.keys(r.channels).forEach((function(t){n.channels[t]=(n.channels[t]||0)+r.channels[t]}))}})),t}),{})}(v,I,e,r)),_=function(t,e,r,i,n){for(var a=Object.keys(t),s=null==i?void 0:i.channels,o=null==i?void 0:i.audioCodec,l=s&&2===parseInt(s),u=!0,h=!1,d=1/0,c=1/0,f=1/0,g=0,v=[],m=Fr(e,n),p=m.preferHDR,E=m.allowedVideoRanges,T=function(){var e=t[a[S]];u=e.channels[2]>0,d=Math.min(d,e.minHeight),c=Math.min(c,e.minFramerate),f=Math.min(f,e.minBitrate);var r=E.filter((function(t){return e.videoRanges[t]>0}));r.length>0&&(h=!0,v=r)},S=a.length;S--;)T();d=y(d)?d:0,c=y(c)?c:0;var L=Math.max(1080,d),A=Math.max(30,c);return f=y(f)?f:r,r=Math.max(f,r),h||(e=void 0,v=[]),{codecSet:a.reduce((function(e,i){var n=t[i];if(i===e)return e;if(n.minBitrate>r)return Mr(i,"min bitrate of "+n.minBitrate+" > current estimate of "+r),e;if(!n.hasDefaultAudio)return Mr(i,"no renditions with default or auto-select sound found"),e;if(o&&i.indexOf(o.substring(0,4))%5!=0)return Mr(i,'audio codec preference "'+o+'" not found'),e;if(s&&!l){if(!n.channels[s])return Mr(i,"no renditions with "+s+" channel sound found (channels options: "+Object.keys(n.channels)+")"),e}else if((!o||l)&&u&&0===n.channels[2])return Mr(i,"no renditions with stereo sound found"),e;return n.minHeight>L?(Mr(i,"min resolution of "+n.minHeight+" > maximum of "+L),e):n.minFramerate>A?(Mr(i,"min framerate of "+n.minFramerate+" > maximum of "+A),e):v.some((function(t){return n.videoRanges[t]>0}))?n.maxScore=oe(e)||n.fragmentError>t[e].fragmentError)?e:(g=n.maxScore,i):(Mr(i,"no variants with VIDEO-RANGE of "+JSON.stringify(v)+" found"),e)}),void 0),videoRanges:v,preferHDR:p,minFramerate:c,minBitrate:f}}(C,R,t,b,D),x=_.codecSet,P=_.videoRanges,F=_.minFramerate,M=_.minBitrate,O=_.preferHDR;T=x,R=O?P[P.length-1]:P[0],k=F,t=Math.max(t,M),w.log("[abr] picked start tier "+JSON.stringify(_))}else T=null==S?void 0:S.codecSet,R=null==S?void 0:S.videoRange;for(var N,U=f?f.duration:c?c.duration:0,B=this.bwEstimator.getEstimateTTFB()/1e3,G=[],K=function(){var e,o=v[H],c=H>d;if(!o)return 0;if(E.useMediaCapabilities&&!o.supportedResult&&!o.supportedPromise){var g=navigator.mediaCapabilities;"function"==typeof(null==g?void 0:g.decodingInfo)&&function(t,e,r,i,n,a){var s=t.audioCodec?t.audioGroups:null,o=null==a?void 0:a.audioCodec,l=null==a?void 0:a.channels,u=l?parseInt(l):o?1/0:2,h=null;if(null!=s&&s.length)try{h=1===s.length&&s[0]?e.groups[s[0]].channels:s.reduce((function(t,r){if(r){var i=e.groups[r];if(!i)throw new Error("Audio track group "+r+" not found");Object.keys(i.channels).forEach((function(e){t[e]=(t[e]||0)+i.channels[e]}))}return t}),{2:0})}catch(t){return!0}return void 0!==t.videoCodec&&(t.width>1920&&t.height>1088||t.height>1920&&t.width>1088||t.frameRate>Math.max(i,30)||"SDR"!==t.videoRange&&t.videoRange!==r||t.bitrate>Math.max(n,8e6))||!!h&&y(u)&&Object.keys(h).some((function(t){return parseInt(t)>u}))}(o,I,R,k,t,b)?(o.supportedPromise=Pr(o,I,g),o.supportedPromise.then((function(t){if(l.hls){o.supportedResult=t;var e=l.hls.levels,r=e.indexOf(o);t.error?w.warn('[abr] MediaCapabilities decodingInfo error: "'+t.error+'" for level '+r+" "+JSON.stringify(t)):t.supported||(w.warn("[abr] Unsupported MediaCapabilities decodingInfo result for level "+r+" "+JSON.stringify(t)),r>-1&&e.length>1&&(w.log("[abr] Removing unsupported level "+r),l.hls.removeLevel(r)))}}))):o.supportedResult=_r}if(T&&o.codecSet!==T||R&&o.videoRange!==R||c&&k>o.frameRate||!c&&k>0&&k=2*U&&0===n?v[H].averageBitrate:v[H].maxBitrate,x=l.getTimeToLoadFrag(B,m,_*C,void 0===D);if(m>=_&&(H===h||0===o.loadError&&0===o.fragmentError)&&(x<=B||!y(x)||L&&!l.bitrateTestDelay||x"+H+" adjustedbw("+Math.round(m)+")-bitrate="+Math.round(m-_)+" ttfb:"+B.toFixed(1)+" avgDuration:"+C.toFixed(1)+" maxFetchDuration:"+u.toFixed(1)+" fetchDuration:"+x.toFixed(1)+" firstSelection:"+A+" codecSet:"+T+" videoRange:"+R+" hls.loadLevel:"+p)),A&&(l.firstSelection=H),{v:H}}},H=r;H>=e;H--)if(0!==(N=K())&&N)return N.v;return-1},s(t,[{key:"firstAutoLevel",get:function(){var t=this.hls,e=t.maxAutoLevel,r=t.minAutoLevel,i=this.getBwEstimate(),n=this.hls.config.maxStarvationDelay,a=this.findBestLevel(i,r,e,0,n,1,1);if(a>-1)return a;var s=this.hls.firstLevel,o=Math.min(Math.max(s,r),e);return w.warn("[abr] Could not find best starting auto level. Defaulting to first in playlist "+s+" clamped to "+o),o}},{key:"forcedAutoLevel",get:function(){return this.nextAutoLevelKey?-1:this._nextAutoLevel}},{key:"nextAutoLevel",get:function(){var t=this.forcedAutoLevel,e=this.bwEstimator.canEstimate(),r=this.lastLoadedFragLevel>-1;if(!(-1===t||e&&r&&this.nextAutoLevelKey!==this.getAutoLevelKey()))return t;var i=e&&r?this.getNextABRAutoLevel():this.firstAutoLevel;if(-1!==t){var n=this.hls.levels;if(n.length>Math.max(t,i)&&n[t].loadError<=n[i].loadError)return t}return this._nextAutoLevel=i,this.nextAutoLevelKey=this.getAutoLevelKey(),i},set:function(t){var e=this.hls,r=e.maxAutoLevel,i=e.minAutoLevel,n=Math.min(Math.max(t,i),r);this._nextAutoLevel!==n&&(this.nextAutoLevelKey="",this._nextAutoLevel=n)}}]),t}(),Kr=function(){function t(){this._boundTick=void 0,this._tickTimer=null,this._tickInterval=null,this._tickCallCount=0,this._boundTick=this.tick.bind(this)}var e=t.prototype;return e.destroy=function(){this.onHandlerDestroying(),this.onHandlerDestroyed()},e.onHandlerDestroying=function(){this.clearNextTick(),this.clearInterval()},e.onHandlerDestroyed=function(){},e.hasInterval=function(){return!!this._tickInterval},e.hasNextTick=function(){return!!this._tickTimer},e.setInterval=function(t){return!this._tickInterval&&(this._tickCallCount=0,this._tickInterval=self.setInterval(this._boundTick,t),!0)},e.clearInterval=function(){return!!this._tickInterval&&(self.clearInterval(this._tickInterval),this._tickInterval=null,!0)},e.clearNextTick=function(){return!!this._tickTimer&&(self.clearTimeout(this._tickTimer),this._tickTimer=null,!0)},e.tick=function(){this._tickCallCount++,1===this._tickCallCount&&(this.doTick(),this._tickCallCount>1&&this.tickImmediate(),this._tickCallCount=0)},e.tickImmediate=function(){this.clearNextTick(),this._tickTimer=self.setTimeout(this._boundTick,0)},e.doTick=function(){},t}(),Hr="NOT_LOADED",Vr="APPENDING",Yr="PARTIAL",Wr="OK",jr=function(){function t(t){this.activePartLists=Object.create(null),this.endListFragments=Object.create(null),this.fragments=Object.create(null),this.timeRanges=Object.create(null),this.bufferPadding=.2,this.hls=void 0,this.hasGaps=!1,this.hls=t,this._registerListeners()}var e=t.prototype;return e._registerListeners=function(){var t=this.hls;t.on(S.BUFFER_APPENDED,this.onBufferAppended,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this)},e._unregisterListeners=function(){var t=this.hls;t.off(S.BUFFER_APPENDED,this.onBufferAppended,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this)},e.destroy=function(){this._unregisterListeners(),this.fragments=this.activePartLists=this.endListFragments=this.timeRanges=null},e.getAppendedFrag=function(t,e){var r=this.activePartLists[e];if(r)for(var i=r.length;i--;){var n=r[i];if(!n)break;var a=n.end;if(n.start<=t&&null!==a&&t<=a)return n}return this.getBufferedFrag(t,e)},e.getBufferedFrag=function(t,e){for(var r=this.fragments,i=Object.keys(r),n=i.length;n--;){var a=r[i[n]];if((null==a?void 0:a.body.type)===e&&a.buffered){var s=a.body;if(s.start<=t&&t<=s.end)return s}}return null},e.detectEvictedFragments=function(t,e,r,i){var n=this;this.timeRanges&&(this.timeRanges[t]=e);var a=(null==i?void 0:i.fragment.sn)||-1;Object.keys(this.fragments).forEach((function(i){var s=n.fragments[i];if(s&&!(a>=s.body.sn))if(s.buffered||s.loaded){var o=s.range[t];o&&o.time.some((function(t){var r=!n.isTimeBuffered(t.startPTS,t.endPTS,e);return r&&n.removeFragment(s.body),r}))}else s.body.type===r&&n.removeFragment(s.body)}))},e.detectPartialFragments=function(t){var e=this,r=this.timeRanges,i=t.frag,n=t.part;if(r&&"initSegment"!==i.sn){var a=Xr(i),s=this.fragments[a];if(!(!s||s.buffered&&i.gap)){var o=!i.relurl;Object.keys(r).forEach((function(t){var a=i.elementaryStreams[t];if(a){var l=r[t],u=o||!0===a.partial;s.range[t]=e.getBufferedTimes(i,n,u,l)}})),s.loaded=null,Object.keys(s.range).length?(s.buffered=!0,(s.body.endList=i.endList||s.body.endList)&&(this.endListFragments[s.body.type]=s),qr(s)||this.removeParts(i.sn-1,i.type)):this.removeFragment(s.body)}}},e.removeParts=function(t,e){var r=this.activePartLists[e];r&&(this.activePartLists[e]=r.filter((function(e){return e.fragment.sn>=t})))},e.fragBuffered=function(t,e){var r=Xr(t),i=this.fragments[r];!i&&e&&(i=this.fragments[r]={body:t,appendedPTS:null,loaded:null,buffered:!1,range:Object.create(null)},t.gap&&(this.hasGaps=!0)),i&&(i.loaded=null,i.buffered=!0)},e.getBufferedTimes=function(t,e,r,i){for(var n={time:[],partial:r},a=t.start,s=t.end,o=t.minEndPTS||s,l=t.maxStartPTS||a,u=0;u=h&&o<=d){n.time.push({startPTS:Math.max(a,i.start(u)),endPTS:Math.min(s,i.end(u))});break}if(ah){var c=Math.max(a,i.start(u)),f=Math.min(s,i.end(u));f>c&&(n.partial=!0,n.time.push({startPTS:c,endPTS:f}))}else if(s<=h)break}return n},e.getPartialFragment=function(t){var e,r,i,n=null,a=0,s=this.bufferPadding,o=this.fragments;return Object.keys(o).forEach((function(l){var u=o[l];u&&qr(u)&&(r=u.body.start-s,i=u.body.end+s,t>=r&&t<=i&&(e=Math.min(t-r,i-t),a<=e&&(n=u.body,a=e)))})),n},e.isEndListAppended=function(t){var e=this.endListFragments[t];return void 0!==e&&(e.buffered||qr(e))},e.getState=function(t){var e=Xr(t),r=this.fragments[e];return r?r.buffered?qr(r)?Yr:Wr:Vr:Hr},e.isTimeBuffered=function(t,e,r){for(var i,n,a=0;a=i&&e<=n)return!0;if(e<=i)return!1}return!1},e.onFragLoaded=function(t,e){var r=e.frag,i=e.part;if("initSegment"!==r.sn&&!r.bitrateTest){var n=i?null:e,a=Xr(r);this.fragments[a]={body:r,appendedPTS:null,loaded:n,buffered:!1,range:Object.create(null)}}},e.onBufferAppended=function(t,e){var r=this,i=e.frag,n=e.part,a=e.timeRanges;if("initSegment"!==i.sn){var s=i.type;if(n){var o=this.activePartLists[s];o||(this.activePartLists[s]=o=[]),o.push(n)}this.timeRanges=a,Object.keys(a).forEach((function(t){var e=a[t];r.detectEvictedFragments(t,e,s,n)}))}},e.onFragBuffered=function(t,e){this.detectPartialFragments(e)},e.hasFragment=function(t){var e=Xr(t);return!!this.fragments[e]},e.hasParts=function(t){var e;return!(null==(e=this.activePartLists[t])||!e.length)},e.removeFragmentsInRange=function(t,e,r,i,n){var a=this;i&&!this.hasGaps||Object.keys(this.fragments).forEach((function(s){var o=a.fragments[s];if(o){var l=o.body;l.type!==r||i&&!l.gap||l.startt&&(o.buffered||n)&&a.removeFragment(l)}}))},e.removeFragment=function(t){var e=Xr(t);t.stats.loaded=0,t.clearElementaryStreamInfo();var r=this.activePartLists[t.type];if(r){var i=t.sn;this.activePartLists[t.type]=r.filter((function(t){return t.fragment.sn!==i}))}delete this.fragments[e],t.endList&&delete this.endListFragments[t.type]},e.removeAllFragments=function(){this.fragments=Object.create(null),this.endListFragments=Object.create(null),this.activePartLists=Object.create(null),this.hasGaps=!1},t}();function qr(t){var e,r,i;return t.buffered&&(t.body.gap||(null==(e=t.range.video)?void 0:e.partial)||(null==(r=t.range.audio)?void 0:r.partial)||(null==(i=t.range.audiovideo)?void 0:i.partial))}function Xr(t){return t.type+"_"+t.level+"_"+t.sn}var zr={length:0,start:function(){return 0},end:function(){return 0}},Qr=function(){function t(){}return t.isBuffered=function(e,r){try{if(e)for(var i=t.getBuffered(e),n=0;n=i.start(n)&&r<=i.end(n))return!0}catch(t){}return!1},t.bufferInfo=function(e,r,i){try{if(e){var n,a=t.getBuffered(e),s=[];for(n=0;ns&&(i[a-1].end=t[n].end):i.push(t[n])}else i.push(t[n])}else i=t;for(var o,l=0,u=e,h=e,d=0;d=c&&er.startCC||t&&t.cc>>8^255&m^99,t[f]=m,e[m]=f;var p=c[f],y=c[p],E=c[y],T=257*c[m]^16843008*m;i[f]=T<<24|T>>>8,n[f]=T<<16|T>>>16,a[f]=T<<8|T>>>24,s[f]=T,T=16843009*E^65537*y^257*p^16843008*f,l[m]=T<<24|T>>>8,u[m]=T<<16|T>>>16,h[m]=T<<8|T>>>24,d[m]=T,f?(f=p^c[c[c[E^p]]],g^=c[c[g]]):f=g=1}},e.expandKey=function(t){for(var e=this.uint8ArrayToUint32Array_(t),r=!0,i=0;is.end){var h=a>u;(a0&&null!=a&&a.key&&a.iv&&"AES-128"===a.method){var s=self.performance.now();return r.decrypter.decrypt(new Uint8Array(n),a.key.buffer,a.iv.buffer).catch((function(e){throw i.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.FRAG_DECRYPT_ERROR,fatal:!1,error:e,reason:e.message,frag:t}),e})).then((function(n){var a=self.performance.now();return i.trigger(S.FRAG_DECRYPTED,{frag:t,payload:n,stats:{tstart:s,tdecrypt:a}}),e.payload=n,r.completeInitSegmentLoad(e)}))}return r.completeInitSegmentLoad(e)})).catch((function(e){r.state!==fi&&r.state!==Li&&(r.warn(e),r.resetFragmentLoading(t))}))},r.completeInitSegmentLoad=function(t){if(!this.levels)throw new Error("init load aborted, missing levels");var e=t.frag.stats;this.state=gi,t.frag.data=new Uint8Array(t.payload),e.parsing.start=e.buffering.start=self.performance.now(),e.parsing.end=e.buffering.end=self.performance.now(),this.tick()},r.fragContextChanged=function(t){var e=this.fragCurrent;return!t||!e||t.sn!==e.sn||t.level!==e.level},r.fragBufferedComplete=function(t,e){var r,i,n,a,s=this.mediaBuffer?this.mediaBuffer:this.media;if(this.log("Buffered "+t.type+" sn: "+t.sn+(e?" part: "+e.index:"")+" of "+(this.playlistType===we?"level":"track")+" "+t.level+" (frag:["+(null!=(r=t.startPTS)?r:NaN).toFixed(3)+"-"+(null!=(i=t.endPTS)?i:NaN).toFixed(3)+"] > buffer:"+(s?ci(Qr.getBuffered(s)):"(detached)")+")"),"initSegment"!==t.sn){var o;if(t.type!==_e){var l=t.elementaryStreams;if(!Object.keys(l).some((function(t){return!!l[t]})))return void(this.state=gi)}var u=null==(o=this.levels)?void 0:o[t.level];null!=u&&u.fragmentError&&(this.log("Resetting level fragment error count of "+u.fragmentError+" on frag buffered"),u.fragmentError=0)}this.state=gi,s&&(!this.loadedmetadata&&t.type==we&&s.buffered.length&&(null==(n=this.fragCurrent)?void 0:n.sn)===(null==(a=this.fragPrevious)?void 0:a.sn)&&(this.loadedmetadata=!0,this.seekToStartPos()),this.tick())},r.seekToStartPos=function(){},r._handleFragmentLoadComplete=function(t){var e=this.transmuxer;if(e){var r=t.frag,i=t.part,n=t.partsLoaded,a=!n||0===n.length||n.some((function(t){return!t})),s=new Jr(r.level,r.sn,r.stats.chunkCount+1,0,i?i.index:-1,!a);e.flush(s)}},r._handleFragmentLoadProgress=function(t){},r._doFragLoad=function(t,e,r,i){var n,a=this;void 0===r&&(r=null);var s=null==e?void 0:e.details;if(!this.levels||!s)throw new Error("frag load aborted, missing level"+(s?"":" detail")+"s");var o=null;if(!t.encrypted||null!=(n=t.decryptdata)&&n.key?!t.encrypted&&s.encryptedFragments.length&&this.keyLoader.loadClear(t,s.encryptedFragments):(this.log("Loading key for "+t.sn+" of ["+s.startSN+"-"+s.endSN+"], "+("[stream-controller]"===this.logPrefix?"level":"track")+" "+t.level),this.state=vi,this.fragCurrent=t,o=this.keyLoader.load(t).then((function(t){if(!a.fragContextChanged(t.frag))return a.hls.trigger(S.KEY_LOADED,t),a.state===vi&&(a.state=gi),t})),this.hls.trigger(S.KEY_LOADING,{frag:t}),null===this.fragCurrent&&(o=Promise.reject(new Error("frag load aborted, context changed in KEY_LOADING")))),r=Math.max(t.start,r||0),this.config.lowLatencyMode&&"initSegment"!==t.sn){var l=s.partList;if(l&&i){r>t.end&&s.fragmentHint&&(t=s.fragmentHint);var u=this.getNextPart(l,t,r);if(u>-1){var h,d=l[u];return this.log("Loading part sn: "+t.sn+" p: "+d.index+" cc: "+t.cc+" of playlist ["+s.startSN+"-"+s.endSN+"] parts [0-"+u+"-"+(l.length-1)+"] "+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),this.nextLoadPosition=d.start+d.duration,this.state=mi,h=o?o.then((function(r){return!r||a.fragContextChanged(r.frag)?null:a.doFragPartsLoad(t,d,e,i)})).catch((function(t){return a.handleFragLoadError(t)})):this.doFragPartsLoad(t,d,e,i).catch((function(t){return a.handleFragLoadError(t)})),this.hls.trigger(S.FRAG_LOADING,{frag:t,part:d,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING parts")):h}if(!t.url||this.loadedEndOfParts(l,r))return Promise.resolve(null)}}this.log("Loading fragment "+t.sn+" cc: "+t.cc+" "+(s?"of ["+s.startSN+"-"+s.endSN+"] ":"")+("[stream-controller]"===this.logPrefix?"level":"track")+": "+t.level+", target: "+parseFloat(r.toFixed(3))),y(t.sn)&&!this.bitrateTest&&(this.nextLoadPosition=t.start+t.duration),this.state=mi;var c,f=this.config.progressive;return c=f&&o?o.then((function(e){return!e||a.fragContextChanged(null==e?void 0:e.frag)?null:a.fragmentLoader.load(t,i)})).catch((function(t){return a.handleFragLoadError(t)})):Promise.all([this.fragmentLoader.load(t,f?i:void 0),o]).then((function(t){var e=t[0];return!f&&e&&i&&i(e),e})).catch((function(t){return a.handleFragLoadError(t)})),this.hls.trigger(S.FRAG_LOADING,{frag:t,targetBufferTime:r}),null===this.fragCurrent?Promise.reject(new Error("frag load aborted, context changed in FRAG_LOADING")):c},r.doFragPartsLoad=function(t,e,r,i){var n=this;return new Promise((function(a,s){var o,l=[],u=null==(o=r.details)?void 0:o.partList;!function e(o){n.fragmentLoader.loadPart(t,o,i).then((function(i){l[o.index]=i;var s=i.part;n.hls.trigger(S.FRAG_LOADED,i);var h=lr(r,t.sn,o.index+1)||ur(u,t.sn,o.index+1);if(!h)return a({frag:t,part:s,partsLoaded:l});e(h)})).catch(s)}(e)}))},r.handleFragLoadError=function(t){if("data"in t){var e=t.data;t.data&&e.details===A.INTERNAL_ABORTED?this.handleFragLoadAborted(e.frag,e.part):this.hls.trigger(S.ERROR,e)}else this.hls.trigger(S.ERROR,{type:L.OTHER_ERROR,details:A.INTERNAL_EXCEPTION,err:t,error:t,fatal:!0});return null},r._handleTransmuxerFlush=function(t){var e=this.getCurrentContext(t);if(e&&this.state===Ei){var r=e.frag,i=e.part,n=e.level,a=self.performance.now();r.stats.parsing.end=a,i&&(i.stats.parsing.end=a),this.updateLevelTiming(r,i,n,t.partial)}else this.fragCurrent||this.state===fi||this.state===Li||(this.state=gi)},r.getCurrentContext=function(t){var e=this.levels,r=this.fragCurrent,i=t.level,n=t.sn,a=t.part;if(null==e||!e[i])return this.warn("Levels object was unset while buffering fragment "+n+" of level "+i+". The current chunk will not be buffered."),null;var s=e[i],o=a>-1?lr(s,n,a):null,l=o?o.fragment:function(t,e,r){if(null==t||!t.details)return null;var i=t.details,n=i.fragments[e-i.startSN];return n||((n=i.fragmentHint)&&n.sn===e?n:ea&&this.flushMainBuffer(s,t.start)}else this.flushMainBuffer(0,t.start)},r.getFwdBufferInfo=function(t,e){var r=this.getLoadPosition();return y(r)?this.getFwdBufferInfoAtPos(t,r,e):null},r.getFwdBufferInfoAtPos=function(t,e,r){var i=this.config.maxBufferHole,n=Qr.bufferInfo(t,e,i);if(0===n.len&&void 0!==n.nextStart){var a=this.fragmentTracker.getBufferedFrag(e,r);if(a&&n.nextStart=r&&(e.maxMaxBufferLength/=2,this.warn("Reduce max buffer length to "+e.maxMaxBufferLength+"s"),!0)},r.getAppendedFrag=function(t,e){var r=this.fragmentTracker.getAppendedFrag(t,we);return r&&"fragment"in r?r.fragment:r},r.getNextFragment=function(t,e){var r=e.fragments,i=r.length;if(!i)return null;var n,a=this.config,s=r[0].start;if(e.live){var o=a.initialLiveManifestSize;if(ie},r.getNextFragmentLoopLoading=function(t,e,r,i,n){var a=t.gap,s=this.getNextFragment(this.nextLoadPosition,e);if(null===s)return s;if(t=s,a&&t&&!t.gap&&r.nextStart){var o=this.getFwdBufferInfoAtPos(this.mediaBuffer?this.mediaBuffer:this.media,r.nextStart,i);if(null!==o&&r.len+o.len>=n)return this.log('buffer full after gaps in "'+i+'" playlist starting at sn: '+t.sn),null}return t},r.mapToInitFragWhenRequired=function(t){return null==t||!t.initSegment||null!=t&&t.initSegment.data||this.bitrateTest?t:t.initSegment},r.getNextPart=function(t,e,r){for(var i=-1,n=!1,a=!0,s=0,o=t.length;s-1&&rr.start&&r.loaded},r.getInitialLiveFragment=function(t,e){var r=this.fragPrevious,i=null;if(r){if(t.hasProgramDateTime&&(this.log("Live playlist, switching playlist, load frag with same PDT: "+r.programDateTime),i=function(t,e,r){if(null===e||!Array.isArray(t)||!t.length||!y(e))return null;if(e<(t[0].programDateTime||0))return null;if(e>=(t[t.length-1].endProgramDateTime||0))return null;r=r||0;for(var i=0;i=t.startSN&&n<=t.endSN){var a=e[n-t.startSN];r.cc===a.cc&&(i=a,this.log("Live playlist, switching playlist, load frag with next SN: "+i.sn))}i||(i=function(t,e){return mr(t,(function(t){return t.cce?-1:0}))}(e,r.cc),i&&this.log("Live playlist, switching playlist, load frag with same CC: "+i.sn))}}else{var s=this.hls.liveSyncPosition;null!==s&&(i=this.getFragmentAtPosition(s,this.bitrateTest?t.fragmentEnd:t.edge,t))}return i},r.getFragmentAtPosition=function(t,e,r){var i,n=this.config,a=this.fragPrevious,s=r.fragments,o=r.endSN,l=r.fragmentHint,u=n.maxFragLookUpTolerance,h=r.partList,d=!!(n.lowLatencyMode&&null!=h&&h.length&&l);if(d&&l&&!this.bitrateTest&&(s=s.concat(l),o=l.sn),i=te-u?0:u):s[s.length-1]){var c=i.sn-r.startSN,f=this.fragmentTracker.getState(i);if((f===Wr||f===Yr&&i.gap)&&(a=i),a&&i.sn===a.sn&&(!d||h[0].fragment.sn>i.sn)&&a&&i.level===a.level){var g=s[c+1];i=i.sn=a-e.maxFragLookUpTolerance&&n<=s;if(null!==i&&r.duration>i&&(n"+t.startSN+" prev-sn: "+(o?o.sn:"na")+" fragments: "+i),l}return n},r.waitForCdnTuneIn=function(t){return t.live&&t.canBlockReload&&t.partTarget&&t.tuneInGoal>Math.max(t.partHoldBack,3*t.partTarget)},r.setStartPosition=function(t,e){var r=this.startPosition;if(r "+(null==(n=this.fragCurrent)?void 0:n.url))}else{var a=e.details===A.FRAG_GAP;a&&this.fragmentTracker.fragBuffered(i,!0);var s=e.errorAction,o=s||{},l=o.action,u=o.retryCount,h=void 0===u?0:u,d=o.retryConfig;if(s&&l===Ar&&d){this.resetStartWhenNotLoaded(this.levelLastLoaded);var c=fr(d,h);this.warn("Fragment "+i.sn+" of "+t+" "+i.level+" errored with "+e.details+", retrying loading "+(h+1)+"/"+d.maxNumRetry+" in "+c+"ms"),s.resolved=!0,this.retryDate=self.performance.now()+c,this.state=pi}else if(d&&s){if(this.resetFragmentErrors(t),!(h.5;i&&this.reduceMaxBufferLength(r.len);var n=!i;return n&&this.warn("Buffer full error while media.currentTime is not buffered, flush "+e+" buffer"),t.frag&&(this.fragmentTracker.removeFragment(t.frag),this.nextLoadPosition=t.frag.start),this.resetLoadingState(),n}return!1},r.resetFragmentErrors=function(t){t===Ce&&(this.fragCurrent=null),this.loadedmetadata||(this.startFragRequested=!1),this.state!==fi&&(this.state=gi)},r.afterBufferFlushed=function(t,e,r){if(t){var i=Qr.getBuffered(t);this.fragmentTracker.detectEvictedFragments(e,i,r),this.state===Si&&this.resetLoadingState()}},r.resetLoadingState=function(){this.log("Reset loading state"),this.fragCurrent=null,this.fragPrevious=null,this.state=gi},r.resetStartWhenNotLoaded=function(t){if(!this.loadedmetadata){this.startFragRequested=!1;var e=t?t.details:null;null!=e&&e.live?(this.startPosition=-1,this.setStartPosition(e,0),this.resetLoadingState()):this.nextLoadPosition=this.startPosition}},r.resetWhenMissingContext=function(t){this.warn("The loading context changed while buffering fragment "+t.sn+" of level "+t.level+". This chunk will not be buffered."),this.removeUnbufferedFrags(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState()},r.removeUnbufferedFrags=function(t){void 0===t&&(t=0),this.fragmentTracker.removeFragmentsInRange(t,1/0,this.playlistType,!1,!0)},r.updateLevelTiming=function(t,e,r,i){var n,a=this,s=r.details;if(s){if(!Object.keys(t.elementaryStreams).reduce((function(e,n){var o=t.elementaryStreams[n];if(o){var l=o.endPTS-o.startPTS;if(l<=0)return a.warn("Could not parse fragment "+t.sn+" "+n+" duration reliably ("+l+")"),e||!1;var u=i?0:nr(s,t,o.startPTS,o.endPTS,o.startDTS,o.endDTS);return a.hls.trigger(S.LEVEL_PTS_UPDATED,{details:s,level:r,drift:u,type:n,frag:t,start:o.startPTS,end:o.endPTS}),!0}return e}),!1)&&null===(null==(n=this.transmuxer)?void 0:n.error)){var o=new Error("Found no media in fragment "+t.sn+" of level "+t.level+" resetting transmuxer to fallback to playlist timing");if(0===r.fragmentError&&(r.fragmentError++,t.gap=!0,this.fragmentTracker.removeFragment(t),this.fragmentTracker.fragBuffered(t,!0)),this.warn(o.message),this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!1,error:o,frag:t,reason:"Found no media in msn "+t.sn+' of level "'+r.url+'"'}),!this.hls)return;this.resetTransmuxer()}this.state=Ti,this.hls.trigger(S.FRAG_PARSED,{frag:t,part:e})}else this.warn("level.details undefined")},r.resetTransmuxer=function(){this.transmuxer&&(this.transmuxer.destroy(),this.transmuxer=null)},r.recoverWorkerError=function(t){"demuxerWorker"===t.event&&(this.fragmentTracker.removeAllFragments(),this.resetTransmuxer(),this.resetStartWhenNotLoaded(this.levelLastLoaded),this.resetLoadingState())},s(e,[{key:"state",get:function(){return this._state},set:function(t){var e=this._state;e!==t&&(this._state=t,this.log(e+"->"+t))}}]),e}(Kr),bi=function(){function t(){this.chunks=[],this.dataLength=0}var e=t.prototype;return e.push=function(t){this.chunks.push(t),this.dataLength+=t.length},e.flush=function(){var t,e=this.chunks,r=this.dataLength;return e.length?(t=1===e.length?e[0]:function(t,e){for(var r=new Uint8Array(e),i=0,n=0;n0&&s.samples.push({pts:this.lastPTS,dts:this.lastPTS,data:i,type:Ge,duration:Number.POSITIVE_INFINITY});n>>5}function Pi(t,e){return e+1=t.length)return!1;var i=xi(t,e);if(i<=r)return!1;var n=e+i;return n===t.length||Pi(t,n)}return!1}function Mi(t,e,r,i,n){if(!t.samplerate){var a=function(t,e,r,i){var n,a,s,o,l=navigator.userAgent.toLowerCase(),u=i,h=[96e3,88200,64e3,48e3,44100,32e3,24e3,22050,16e3,12e3,11025,8e3,7350];n=1+((192&e[r+2])>>>6);var d=(60&e[r+2])>>>2;if(!(d>h.length-1))return s=(1&e[r+2])<<2,s|=(192&e[r+3])>>>6,w.log("manifest codec:"+i+", ADTS type:"+n+", samplingIndex:"+d),/firefox/i.test(l)?d>=6?(n=5,o=new Array(4),a=d-3):(n=2,o=new Array(2),a=d):-1!==l.indexOf("android")?(n=2,o=new Array(2),a=d):(n=5,o=new Array(4),i&&(-1!==i.indexOf("mp4a.40.29")||-1!==i.indexOf("mp4a.40.5"))||!i&&d>=6?a=d-3:((i&&-1!==i.indexOf("mp4a.40.2")&&(d>=6&&1===s||/vivaldi/i.test(l))||!i&&1===s)&&(n=2,o=new Array(2)),a=d)),o[0]=n<<3,o[0]|=(14&d)>>1,o[1]|=(1&d)<<7,o[1]|=s<<3,5===n&&(o[1]|=(14&a)>>1,o[2]=(1&a)<<7,o[2]|=8,o[3]=0),{config:o,samplerate:h[d],channelCount:s,codec:"mp4a.40."+n,manifestCodec:u};var c=new Error("invalid ADTS sampling index:"+d);t.emit(S.ERROR,S.ERROR,{type:L.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!0,error:c,reason:c.message})}(e,r,i,n);if(!a)return;t.config=a.config,t.samplerate=a.samplerate,t.channelCount=a.channelCount,t.codec=a.codec,t.manifestCodec=a.manifestCodec,w.log("parsed codec:"+t.codec+", rate:"+a.samplerate+", channels:"+a.channelCount)}}function Oi(t){return 9216e4/t}function Ni(t,e,r,i,n){var a,s=i+n*Oi(t.samplerate),o=function(t,e){var r=_i(t,e);if(e+r<=t.length){var i=xi(t,e)-r;if(i>0)return{headerLength:r,frameLength:i}}}(e,r);if(o){var l=o.frameLength,u=o.headerLength,h=u+l,d=Math.max(0,r+h-e.length);d?(a=new Uint8Array(h-u)).set(e.subarray(r+u,e.length),0):a=e.subarray(r+u,r+h);var c={unit:a,pts:s};return d||t.samples.push(c),{sample:c,length:h,missing:d}}var f=e.length-r;return(a=new Uint8Array(f)).set(e.subarray(r,e.length),0),{sample:{unit:a,pts:s},length:f,missing:-1}}var Ui=null,Bi=[32,64,96,128,160,192,224,256,288,320,352,384,416,448,32,48,56,64,80,96,112,128,160,192,224,256,320,384,32,40,48,56,64,80,96,112,128,160,192,224,256,320,32,48,56,64,80,96,112,128,144,160,176,192,224,256,8,16,24,32,40,48,56,64,80,96,112,128,144,160],Gi=[44100,48e3,32e3,22050,24e3,16e3,11025,12e3,8e3],Ki=[[0,72,144,12],[0,0,0,0],[0,72,144,12],[0,144,144,12]],Hi=[0,1,1,4];function Vi(t,e,r,i,n){if(!(r+24>e.length)){var a=Yi(e,r);if(a&&r+a.frameLength<=e.length){var s=i+n*(9e4*a.samplesPerFrame/a.sampleRate),o={unit:e.subarray(r,r+a.frameLength),pts:s,dts:s};return t.config=[],t.channelCount=a.channelCount,t.samplerate=a.sampleRate,t.samples.push(o),{sample:o,length:a.frameLength,missing:0}}}}function Yi(t,e){var r=t[e+1]>>3&3,i=t[e+1]>>1&3,n=t[e+2]>>4&15,a=t[e+2]>>2&3;if(1!==r&&0!==n&&15!==n&&3!==a){var s=t[e+2]>>1&1,o=t[e+3]>>6,l=1e3*Bi[14*(3===r?3-i:3===i?3:4)+n-1],u=Gi[3*(3===r?0:2===r?1:2)+a],h=3===o?1:2,d=Ki[r][i],c=Hi[i],f=8*d*c,g=Math.floor(d*l/u+s)*c;if(null===Ui){var v=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);Ui=v?parseInt(v[1]):0}return!!Ui&&Ui<=87&&2===i&&l>=224e3&&0===o&&(t[e+3]=128|t[e+3]),{sampleRate:u,channelCount:h,frameLength:g,samplesPerFrame:f}}}function Wi(t,e){return 255===t[e]&&224==(224&t[e+1])&&0!=(6&t[e+1])}function ji(t,e){return e+18&&109===t[r+4]&&111===t[r+5]&&111===t[r+6]&&102===t[r+7])return!0;r=i>1?r+i:e}return!1}(t)},e.demux=function(t,e){this.timeOffset=e;var r=t,i=this.videoTrack,n=this.txtTrack;if(this.config.progressive){this.remainderData&&(r=Kt(this.remainderData,t));var a=function(t){var e={valid:null,remainder:null},r=xt(t,["moof"]);if(r.length<2)return e.remainder=t,e;var i=r[r.length-1];return e.valid=nt(t,0,i.byteOffset-8),e.remainder=nt(t,i.byteOffset-8),e}(r);this.remainderData=a.remainder,i.samples=a.valid||new Uint8Array}else i.samples=r;var s=this.extractID3Track(i,e);return n.samples=Ht(e,i),{videoTrack:i,audioTrack:this.audioTrack,id3Track:s,textTrack:this.txtTrack}},e.flush=function(){var t=this.timeOffset,e=this.videoTrack,r=this.txtTrack;e.samples=this.remainderData||new Uint8Array,this.remainderData=null;var i=this.extractID3Track(e,this.timeOffset);return r.samples=Ht(t,e),{videoTrack:e,audioTrack:Di(),id3Track:i,textTrack:Di()}},e.extractID3Track=function(t,e){var r=this.id3Track;if(t.samples.length){var i=xt(t.samples,["emsg"]);i&&i.forEach((function(t){var i=function(t){var e=t[0],r="",i="",n=0,a=0,s=0,o=0,l=0,u=0;if(0===e){for(;"\0"!==bt(t.subarray(u,u+1));)r+=bt(t.subarray(u,u+1)),u+=1;for(r+=bt(t.subarray(u,u+1)),u+=1;"\0"!==bt(t.subarray(u,u+1));)i+=bt(t.subarray(u,u+1)),u+=1;i+=bt(t.subarray(u,u+1)),u+=1,n=It(t,12),a=It(t,16),o=It(t,20),l=It(t,24),u=28}else if(1===e){n=It(t,u+=4);var h=It(t,u+=4),d=It(t,u+=4);for(u+=4,s=Math.pow(2,32)*h+d,E(s)||(s=Number.MAX_SAFE_INTEGER,w.warn("Presentation time exceeds safe integer limit and wrapped to max safe integer in parsing emsg box")),o=It(t,u),l=It(t,u+=4),u+=4;"\0"!==bt(t.subarray(u,u+1));)r+=bt(t.subarray(u,u+1)),u+=1;for(r+=bt(t.subarray(u,u+1)),u+=1;"\0"!==bt(t.subarray(u,u+1));)i+=bt(t.subarray(u,u+1)),u+=1;i+=bt(t.subarray(u,u+1)),u+=1}return{schemeIdUri:r,value:i,timeScale:n,presentationTime:s,presentationTimeDelta:a,eventDuration:o,id:l,payload:t.subarray(u,t.byteLength)}}(t);if(zi.test(i.schemeIdUri)){var n=y(i.presentationTime)?i.presentationTime/i.timeScale:e+i.presentationTimeDelta/i.timeScale,a=4294967295===i.eventDuration?Number.POSITIVE_INFINITY:i.eventDuration/i.timeScale;a<=.001&&(a=Number.POSITIVE_INFINITY);var s=i.payload;r.samples.push({data:s,len:s.byteLength,dts:n,pts:n,type:He,duration:a})}}))}return r},e.demuxSampleAes=function(t,e,r){return Promise.reject(new Error("The MP4 demuxer does not support SAMPLE-AES decryption"))},e.destroy=function(){},t}(),Ji=function(t,e){var r=0,i=5;e+=i;for(var n=new Uint32Array(1),a=new Uint32Array(1),s=new Uint8Array(1);i>0;){s[0]=t[e];var o=Math.min(i,8),l=8-o;a[0]=4278190080>>>24+l<>l,r=r?r<e.length)return-1;if(11!==e[r]||119!==e[r+1])return-1;var a=e[r+4]>>6;if(a>=3)return-1;var s=[48e3,44100,32e3][a],o=63&e[r+4],l=2*[64,69,96,64,70,96,80,87,120,80,88,120,96,104,144,96,105,144,112,121,168,112,122,168,128,139,192,128,140,192,160,174,240,160,175,240,192,208,288,192,209,288,224,243,336,224,244,336,256,278,384,256,279,384,320,348,480,320,349,480,384,417,576,384,418,576,448,487,672,448,488,672,512,557,768,512,558,768,640,696,960,640,697,960,768,835,1152,768,836,1152,896,975,1344,896,976,1344,1024,1114,1536,1024,1115,1536,1152,1253,1728,1152,1254,1728,1280,1393,1920,1280,1394,1920][3*o+a];if(r+l>e.length)return-1;var u=e[r+6]>>5,h=0;2===u?h+=2:(1&u&&1!==u&&(h+=2),4&u&&(h+=2));var d=(e[r+6]<<8|e[r+7])>>12-h&1,c=[2,1,2,3,3,4,4,5][u]+d,f=e[r+5]>>3,g=7&e[r+5],v=new Uint8Array([a<<6|f<<1|g>>2,(3&g)<<6|u<<3|d<<2|o>>4,o<<4&224]),m=i+n*(1536/s*9e4),p=e.subarray(r,r+l);return t.config=v,t.channelCount=c,t.samplerate=s,t.samples.push({unit:p,pts:m}),l}var tn=function(){function t(){this.VideoSample=null}var e=t.prototype;return e.createVideoSample=function(t,e,r,i){return{key:t,frame:!1,pts:e,dts:r,units:[],debug:i,length:0}},e.getLastNalUnit=function(t){var e,r,i=this.VideoSample;if(i&&0!==i.units.length||(i=t[t.length-1]),null!=(e=i)&&e.units){var n=i.units;r=n[n.length-1]}return r},e.pushAccessUnit=function(t,e){if(t.units.length&&t.frame){if(void 0===t.pts){var r=e.samples,i=r.length;if(!i)return void e.dropped++;var n=r[i-1];t.pts=n.pts,t.dts=n.dts}e.samples.push(t)}t.debug.length&&w.log(t.pts+"/"+t.dts+":"+t.debug)},t}(),en=function(){function t(t){this.data=void 0,this.bytesAvailable=void 0,this.word=void 0,this.bitsAvailable=void 0,this.data=t,this.bytesAvailable=t.byteLength,this.word=0,this.bitsAvailable=0}var e=t.prototype;return e.loadWord=function(){var t=this.data,e=this.bytesAvailable,r=t.byteLength-e,i=new Uint8Array(4),n=Math.min(4,e);if(0===n)throw new Error("no bytes available");i.set(t.subarray(r,r+n)),this.word=new DataView(i.buffer).getUint32(0),this.bitsAvailable=8*n,this.bytesAvailable-=n},e.skipBits=function(t){var e;t=Math.min(t,8*this.bytesAvailable+this.bitsAvailable),this.bitsAvailable>t?(this.word<<=t,this.bitsAvailable-=t):(t-=this.bitsAvailable,t-=(e=t>>3)<<3,this.bytesAvailable-=e,this.loadWord(),this.word<<=t,this.bitsAvailable-=t)},e.readBits=function(t){var e=Math.min(this.bitsAvailable,t),r=this.word>>>32-e;if(t>32&&w.error("Cannot read more than 32 bits at a time"),this.bitsAvailable-=e,this.bitsAvailable>0)this.word<<=e;else{if(!(this.bytesAvailable>0))throw new Error("no bits available");this.loadWord()}return(e=t-e)>0&&this.bitsAvailable?r<>>t))return this.word<<=t,this.bitsAvailable-=t,t;return this.loadWord(),t+this.skipLZ()},e.skipUEG=function(){this.skipBits(1+this.skipLZ())},e.skipEG=function(){this.skipBits(1+this.skipLZ())},e.readUEG=function(){var t=this.skipLZ();return this.readBits(t+1)-1},e.readEG=function(){var t=this.readUEG();return 1&t?1+t>>>1:-1*(t>>>1)},e.readBoolean=function(){return 1===this.readBits(1)},e.readUByte=function(){return this.readBits(8)},e.readUShort=function(){return this.readBits(16)},e.readUInt=function(){return this.readBits(32)},e.skipScalingList=function(t){for(var e=8,r=8,i=0;i4){var f=new en(c).readSliceType();2!==f&&4!==f&&7!==f&&9!==f||(h=!0)}h&&null!=(d=l)&&d.frame&&!l.key&&(s.pushAccessUnit(l,t),l=s.VideoSample=null),l||(l=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),l.frame=!0,l.key=h;break;case 5:a=!0,null!=(o=l)&&o.frame&&!l.key&&(s.pushAccessUnit(l,t),l=s.VideoSample=null),l||(l=s.VideoSample=s.createVideoSample(!0,r.pts,r.dts,"")),l.key=!0,l.frame=!0;break;case 6:a=!0,Yt(i.data,1,r.pts,e.samples);break;case 7:var g,v;a=!0,u=!0;var m=i.data,p=new en(m).readSPS();if(!t.sps||t.width!==p.width||t.height!==p.height||(null==(g=t.pixelRatio)?void 0:g[0])!==p.pixelRatio[0]||(null==(v=t.pixelRatio)?void 0:v[1])!==p.pixelRatio[1]){t.width=p.width,t.height=p.height,t.pixelRatio=p.pixelRatio,t.sps=[m],t.duration=n;for(var y=m.subarray(1,4),E="avc1.",T=0;T<3;T++){var S=y[T].toString(16);S.length<2&&(S="0"+S),E+=S}t.codec=E}break;case 8:a=!0,t.pps=[i.data];break;case 9:a=!0,t.audFound=!0,l&&s.pushAccessUnit(l,t),l=s.VideoSample=s.createVideoSample(!1,r.pts,r.dts,"");break;case 12:a=!0;break;default:a=!1,l&&(l.debug+="unknown NAL "+i.type+" ")}l&&a&&l.units.push(i)})),i&&l&&(this.pushAccessUnit(l,t),this.VideoSample=null)},r.parseAVCNALu=function(t,e){var r,i,n=e.byteLength,a=t.naluState||0,s=a,o=[],l=0,u=-1,h=0;for(-1===a&&(u=0,h=31&e[0],a=0,l=1);l=0){var d={data:e.subarray(u,i),type:h};o.push(d)}else{var c=this.getLastNalUnit(t.samples);c&&(s&&l<=4-s&&c.state&&(c.data=c.data.subarray(0,c.data.byteLength-s)),i>0&&(c.data=Kt(c.data,e.subarray(0,i)),c.state=0))}l=0&&a>=0){var f={data:e.subarray(u,n),type:h,state:a};o.push(f)}if(0===o.length){var g=this.getLastNalUnit(t.samples);g&&(g.data=Kt(g.data,e))}return t.naluState=a,o},e}(tn),nn=function(){function t(t,e,r){this.keyData=void 0,this.decrypter=void 0,this.keyData=r,this.decrypter=new di(e,{removePKCS7Padding:!1})}var e=t.prototype;return e.decryptBuffer=function(t){return this.decrypter.decrypt(t,this.keyData.key.buffer,this.keyData.iv.buffer)},e.decryptAacSample=function(t,e,r){var i=this,n=t[e].unit;if(!(n.length<=16)){var a=n.subarray(16,n.length-n.length%16),s=a.buffer.slice(a.byteOffset,a.byteOffset+a.length);this.decryptBuffer(s).then((function(a){var s=new Uint8Array(a);n.set(s,16),i.decrypter.isSync()||i.decryptAacSamples(t,e+1,r)}))}},e.decryptAacSamples=function(t,e,r){for(;;e++){if(e>=t.length)return void r();if(!(t[e].unit.length<32||(this.decryptAacSample(t,e,r),this.decrypter.isSync())))return}},e.getAvcEncryptedData=function(t){for(var e=16*Math.floor((t.length-48)/160)+16,r=new Int8Array(e),i=0,n=32;n=t.length)return void i();for(var n=t[e].units;!(r>=n.length);r++){var a=n[r];if(!(a.data.length<=48||1!==a.type&&5!==a.type||(this.decryptAvcSample(t,e,r,i,a),this.decrypter.isSync())))return}}},t}(),an=188,sn=function(){function t(t,e,r){this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.sampleAes=null,this.pmtParsed=!1,this.audioCodec=void 0,this.videoCodec=void 0,this._duration=0,this._pmtId=-1,this._videoTrack=void 0,this._audioTrack=void 0,this._id3Track=void 0,this._txtTrack=void 0,this.aacOverFlow=null,this.remainderData=null,this.videoParser=void 0,this.observer=t,this.config=e,this.typeSupported=r,this.videoParser=new rn}t.probe=function(e){var r=t.syncOffset(e);return r>0&&w.warn("MPEG2-TS detected but first sync word found @ offset "+r),-1!==r},t.syncOffset=function(t){for(var e=t.length,r=Math.min(940,e-an)+1,i=0;i1&&(0===a&&s>2||o+an>r))return a}i++}return-1},t.createTrack=function(t,e){return{container:"video"===t||"audio"===t?"video/mp2t":void 0,type:t,id:kt[t],pid:-1,inputTimeScale:9e4,sequenceNumber:0,samples:[],dropped:0,duration:"audio"===t?e:void 0}};var e=t.prototype;return e.resetInitSegment=function(e,r,i,n){this.pmtParsed=!1,this._pmtId=-1,this._videoTrack=t.createTrack("video"),this._audioTrack=t.createTrack("audio",n),this._id3Track=t.createTrack("id3"),this._txtTrack=t.createTrack("text"),this._audioTrack.segmentCodec="aac",this.aacOverFlow=null,this.remainderData=null,this.audioCodec=r,this.videoCodec=i,this._duration=n},e.resetTimeStamp=function(){},e.resetContiguity=function(){var t=this._audioTrack,e=this._videoTrack,r=this._id3Track;t&&(t.pesData=null),e&&(e.pesData=null),r&&(r.pesData=null),this.aacOverFlow=null,this.remainderData=null},e.demux=function(e,r,i,n){var a;void 0===i&&(i=!1),void 0===n&&(n=!1),i||(this.sampleAes=null);var s=this._videoTrack,o=this._audioTrack,l=this._id3Track,u=this._txtTrack,h=s.pid,d=s.pesData,c=o.pid,f=l.pid,g=o.pesData,v=l.pesData,m=null,p=this.pmtParsed,y=this._pmtId,E=e.length;if(this.remainderData&&(E=(e=Kt(this.remainderData,e)).length,this.remainderData=null),E>4>1){if((I=k+5+e[k+4])===k+an)continue}else I=k+4;switch(D){case h:b&&(d&&(a=dn(d))&&this.videoParser.parseAVCPES(s,u,a,!1,this._duration),d={data:[],size:0}),d&&(d.data.push(e.subarray(I,k+an)),d.size+=k+an-I);break;case c:if(b){if(g&&(a=dn(g)))switch(o.segmentCodec){case"aac":this.parseAACPES(o,a);break;case"mp3":this.parseMPEGPES(o,a);break;case"ac3":this.parseAC3PES(o,a)}g={data:[],size:0}}g&&(g.data.push(e.subarray(I,k+an)),g.size+=k+an-I);break;case f:b&&(v&&(a=dn(v))&&this.parseID3PES(l,a),v={data:[],size:0}),v&&(v.data.push(e.subarray(I,k+an)),v.size+=k+an-I);break;case 0:b&&(I+=e[I]+1),y=this._pmtId=ln(e,I);break;case y:b&&(I+=e[I]+1);var C=un(e,I,this.typeSupported,i);(h=C.videoPid)>0&&(s.pid=h,s.segmentCodec=C.segmentVideoCodec),(c=C.audioPid)>0&&(o.pid=c,o.segmentCodec=C.segmentAudioCodec),(f=C.id3Pid)>0&&(l.pid=f),null===m||p||(w.warn("MPEG-TS PMT found at "+k+" after unknown PID '"+m+"'. Backtracking to sync byte @"+T+" to parse all TS packets."),m=null,k=T-188),p=this.pmtParsed=!0;break;case 17:case 8191:break;default:m=D}}else R++;if(R>0){var _=new Error("Found "+R+" TS packet/s that do not start with 0x47");this.observer.emit(S.ERROR,S.ERROR,{type:L.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!1,error:_,reason:_.message})}s.pesData=d,o.pesData=g,l.pesData=v;var x={audioTrack:o,videoTrack:s,id3Track:l,textTrack:u};return n&&this.extractRemainingSamples(x),x},e.flush=function(){var t,e=this.remainderData;return this.remainderData=null,t=e?this.demux(e,-1,!1,!0):{videoTrack:this._videoTrack,audioTrack:this._audioTrack,id3Track:this._id3Track,textTrack:this._txtTrack},this.extractRemainingSamples(t),this.sampleAes?this.decrypt(t,this.sampleAes):t},e.extractRemainingSamples=function(t){var e,r=t.audioTrack,i=t.videoTrack,n=t.id3Track,a=t.textTrack,s=i.pesData,o=r.pesData,l=n.pesData;if(s&&(e=dn(s))?(this.videoParser.parseAVCPES(i,a,e,!0,this._duration),i.pesData=null):i.pesData=s,o&&(e=dn(o))){switch(r.segmentCodec){case"aac":this.parseAACPES(r,e);break;case"mp3":this.parseMPEGPES(r,e);break;case"ac3":this.parseAC3PES(r,e)}r.pesData=null}else null!=o&&o.size&&w.log("last AAC PES packet truncated,might overlap between fragments"),r.pesData=o;l&&(e=dn(l))?(this.parseID3PES(n,e),n.pesData=null):n.pesData=l},e.demuxSampleAes=function(t,e,r){var i=this.demux(t,r,!0,!this.config.progressive),n=this.sampleAes=new nn(this.observer,this.config,e);return this.decrypt(i,n)},e.decrypt=function(t,e){return new Promise((function(r){var i=t.audioTrack,n=t.videoTrack;i.samples&&"aac"===i.segmentCodec?e.decryptAacSamples(i.samples,0,(function(){n.samples?e.decryptAvcSamples(n.samples,0,0,(function(){r(t)})):r(t)})):n.samples&&e.decryptAvcSamples(n.samples,0,0,(function(){r(t)}))}))},e.destroy=function(){this._duration=0},e.parseAACPES=function(t,e){var r,i,n,a=0,s=this.aacOverFlow,o=e.data;if(s){this.aacOverFlow=null;var l=s.missing,u=s.sample.unit.byteLength;if(-1===l)o=Kt(s.sample.unit,o);else{var h=u-l;s.sample.unit.set(o.subarray(0,l),h),t.samples.push(s.sample),a=s.missing}}for(r=a,i=o.length;r0;)o+=n;else w.warn("[tsdemuxer]: AC3 PES unknown PTS")},e.parseID3PES=function(t,e){if(void 0!==e.pts){var r=o({},e,{type:this._videoTrack?He:Ge,duration:Number.POSITIVE_INFINITY});t.samples.push(r)}else w.warn("[tsdemuxer]: ID3 PES unknown PTS")},t}();function on(t,e){return((31&t[e+1])<<8)+t[e+2]}function ln(t,e){return(31&t[e+10])<<8|t[e+11]}function un(t,e,r,i){var n={audioPid:-1,videoPid:-1,id3Pid:-1,segmentVideoCodec:"avc",segmentAudioCodec:"aac"},a=e+3+((15&t[e+1])<<8|t[e+2])-4;for(e+=12+((15&t[e+10])<<8|t[e+11]);e0)for(var l=e+5,u=o;u>2;){106===t[l]&&(!0!==r.ac3?w.log("AC-3 audio found, not supported in this browser for now"):(n.audioPid=s,n.segmentAudioCodec="ac3"));var h=t[l+1]+2;l+=h,u-=h}break;case 194:case 135:w.warn("Unsupported EC-3 in M2TS found");break;case 36:w.warn("Unsupported HEVC in M2TS found")}e+=o+5}return n}function hn(t){w.log(t+" with AES-128-CBC encryption found in unencrypted stream")}function dn(t){var e,r,i,n,a,s=0,o=t.data;if(!t||0===t.size)return null;for(;o[0].length<19&&o.length>1;)o[0]=Kt(o[0],o[1]),o.splice(1,1);if(1===((e=o[0])[0]<<16)+(e[1]<<8)+e[2]){if((r=(e[4]<<8)+e[5])&&r>t.size-6)return null;var l=e[7];192&l&&(n=536870912*(14&e[9])+4194304*(255&e[10])+16384*(254&e[11])+128*(255&e[12])+(254&e[13])/2,64&l?n-(a=536870912*(14&e[14])+4194304*(255&e[15])+16384*(254&e[16])+128*(255&e[17])+(254&e[18])/2)>54e5&&(w.warn(Math.round((n-a)/9e4)+"s delta between PTS and DTS, align them"),n=a):a=n);var u=(i=e[8])+9;if(t.size<=u)return null;t.size-=u;for(var h=new Uint8Array(t.size),d=0,c=o.length;df){u-=f;continue}e=e.subarray(u),f-=u,u=0}h.set(e,s),s+=f}return r&&(r-=i+3),{data:h,pts:n,dts:a,len:r}}return null}var cn=function(t){function e(){return t.apply(this,arguments)||this}l(e,t);var r=e.prototype;return r.resetInitSegment=function(e,r,i,n){t.prototype.resetInitSegment.call(this,e,r,i,n),this._audioTrack={container:"audio/mpeg",type:"audio",id:2,pid:-1,sequenceNumber:0,segmentCodec:"mp3",samples:[],manifestCodec:r,duration:n,inputTimeScale:9e4,dropped:0}},e.probe=function(t){if(!t)return!1;var e=lt(t,0),r=(null==e?void 0:e.length)||0;if(e&&11===t[r]&&119===t[r+1]&&void 0!==dt(e)&&Ji(t,r)<=16)return!1;for(var i=t.length;r1?r-1:0),n=1;n>24&255,o[1]=e>>16&255,o[2]=e>>8&255,o[3]=255&e,o.set(t,4),a=0,e=8;a>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,85,196,0,0]))},t.mdia=function(e){return t.box(t.types.mdia,t.mdhd(e.timescale,e.duration),t.hdlr(e.type),t.minf(e))},t.mfhd=function(e){return t.box(t.types.mfhd,new Uint8Array([0,0,0,0,e>>24,e>>16&255,e>>8&255,255&e]))},t.minf=function(e){return"audio"===e.type?t.box(t.types.minf,t.box(t.types.smhd,t.SMHD),t.DINF,t.stbl(e)):t.box(t.types.minf,t.box(t.types.vmhd,t.VMHD),t.DINF,t.stbl(e))},t.moof=function(e,r,i){return t.box(t.types.moof,t.mfhd(e),t.traf(i,r))},t.moov=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trak(e[r]);return t.box.apply(null,[t.types.moov,t.mvhd(e[0].timescale,e[0].duration)].concat(i).concat(t.mvex(e)))},t.mvex=function(e){for(var r=e.length,i=[];r--;)i[r]=t.trex(e[r]);return t.box.apply(null,[t.types.mvex].concat(i))},t.mvhd=function(e,r){r*=e;var i=Math.floor(r/(gn+1)),n=Math.floor(r%(gn+1)),a=new Uint8Array([1,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,e>>24&255,e>>16&255,e>>8&255,255&e,i>>24,i>>16&255,i>>8&255,255&i,n>>24,n>>16&255,n>>8&255,255&n,0,1,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255]);return t.box(t.types.mvhd,a)},t.sdtp=function(e){var r,i,n=e.samples||[],a=new Uint8Array(4+n.length);for(r=0;r>>8&255),a.push(255&n),a=a.concat(Array.prototype.slice.call(i));for(r=0;r>>8&255),s.push(255&n),s=s.concat(Array.prototype.slice.call(i));var o=t.box(t.types.avcC,new Uint8Array([1,a[3],a[4],a[5],255,224|e.sps.length].concat(a).concat([e.pps.length]).concat(s))),l=e.width,u=e.height,h=e.pixelRatio[0],d=e.pixelRatio[1];return t.box(t.types.avc1,new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,l>>8&255,255&l,u>>8&255,255&u,0,72,0,0,0,72,0,0,0,0,0,0,0,1,18,100,97,105,108,121,109,111,116,105,111,110,47,104,108,115,46,106,115,0,0,0,0,0,0,0,0,0,0,0,0,0,0,24,17,17]),o,t.box(t.types.btrt,new Uint8Array([0,28,156,128,0,45,198,192,0,45,198,192])),t.box(t.types.pasp,new Uint8Array([h>>24,h>>16&255,h>>8&255,255&h,d>>24,d>>16&255,d>>8&255,255&d])))},t.esds=function(t){var e=t.config.length;return new Uint8Array([0,0,0,0,3,23+e,0,1,0,4,15+e,64,21,0,0,0,0,0,0,0,0,0,0,0,5].concat([e]).concat(t.config).concat([6,1,2]))},t.audioStsd=function(t){var e=t.samplerate;return new Uint8Array([0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,t.channelCount,0,16,0,0,0,0,e>>8&255,255&e,0,0])},t.mp4a=function(e){return t.box(t.types.mp4a,t.audioStsd(e),t.box(t.types.esds,t.esds(e)))},t.mp3=function(e){return t.box(t.types[".mp3"],t.audioStsd(e))},t.ac3=function(e){return t.box(t.types["ac-3"],t.audioStsd(e),t.box(t.types.dac3,e.config))},t.stsd=function(e){return"audio"===e.type?"mp3"===e.segmentCodec&&"mp3"===e.codec?t.box(t.types.stsd,t.STSD,t.mp3(e)):"ac3"===e.segmentCodec?t.box(t.types.stsd,t.STSD,t.ac3(e)):t.box(t.types.stsd,t.STSD,t.mp4a(e)):t.box(t.types.stsd,t.STSD,t.avc1(e))},t.tkhd=function(e){var r=e.id,i=e.duration*e.timescale,n=e.width,a=e.height,s=Math.floor(i/(gn+1)),o=Math.floor(i%(gn+1));return t.box(t.types.tkhd,new Uint8Array([1,0,0,7,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,3,r>>24&255,r>>16&255,r>>8&255,255&r,0,0,0,0,s>>24,s>>16&255,s>>8&255,255&s,o>>24,o>>16&255,o>>8&255,255&o,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,64,0,0,0,n>>8&255,255&n,0,0,a>>8&255,255&a,0,0]))},t.traf=function(e,r){var i=t.sdtp(e),n=e.id,a=Math.floor(r/(gn+1)),s=Math.floor(r%(gn+1));return t.box(t.types.traf,t.box(t.types.tfhd,new Uint8Array([0,0,0,0,n>>24,n>>16&255,n>>8&255,255&n])),t.box(t.types.tfdt,new Uint8Array([1,0,0,0,a>>24,a>>16&255,a>>8&255,255&a,s>>24,s>>16&255,s>>8&255,255&s])),t.trun(e,i.length+16+20+8+16+8+8),i)},t.trak=function(e){return e.duration=e.duration||4294967295,t.box(t.types.trak,t.tkhd(e),t.mdia(e))},t.trex=function(e){var r=e.id;return t.box(t.types.trex,new Uint8Array([0,0,0,0,r>>24,r>>16&255,r>>8&255,255&r,0,0,0,1,0,0,0,0,0,0,0,0,0,1,0,1]))},t.trun=function(e,r){var i,n,a,s,o,l,u=e.samples||[],h=u.length,d=12+16*h,c=new Uint8Array(d);for(r+=8+d,c.set(["video"===e.type?1:0,0,15,1,h>>>24&255,h>>>16&255,h>>>8&255,255&h,r>>>24&255,r>>>16&255,r>>>8&255,255&r],0),i=0;i>>24&255,a>>>16&255,a>>>8&255,255&a,s>>>24&255,s>>>16&255,s>>>8&255,255&s,o.isLeading<<2|o.dependsOn,o.isDependedOn<<6|o.hasRedundancy<<4|o.paddingValue<<1|o.isNonSync,61440&o.degradPrio,15&o.degradPrio,l>>>24&255,l>>>16&255,l>>>8&255,255&l],12+16*i);return t.box(t.types.trun,c)},t.initSegment=function(e){t.types||t.init();var r=t.moov(e);return Kt(t.FTYP,r)},t}();vn.types=void 0,vn.HDLR_TYPES=void 0,vn.STTS=void 0,vn.STSC=void 0,vn.STCO=void 0,vn.STSZ=void 0,vn.VMHD=void 0,vn.SMHD=void 0,vn.STSD=void 0,vn.FTYP=void 0,vn.DINF=void 0;var mn=9e4;function pn(t,e,r,i){void 0===r&&(r=1),void 0===i&&(i=!1);var n=t*e*r;return i?Math.round(n):n}function yn(t,e){return void 0===e&&(e=!1),pn(t,1e3,1/mn,e)}var En=null,Tn=null,Sn=function(){function t(t,e,r,i){if(this.observer=void 0,this.config=void 0,this.typeSupported=void 0,this.ISGenerated=!1,this._initPTS=null,this._initDTS=null,this.nextAvcDts=null,this.nextAudioPts=null,this.videoSampleDuration=null,this.isAudioContiguous=!1,this.isVideoContiguous=!1,this.videoTrackConfig=void 0,this.observer=t,this.config=e,this.typeSupported=r,this.ISGenerated=!1,null===En){var n=(navigator.userAgent||"").match(/Chrome\/(\d+)/i);En=n?parseInt(n[1]):0}if(null===Tn){var a=navigator.userAgent.match(/Safari\/(\d+)/i);Tn=a?parseInt(a[1]):0}}var e=t.prototype;return e.destroy=function(){this.config=this.videoTrackConfig=this._initPTS=this._initDTS=null},e.resetTimeStamp=function(t){w.log("[mp4-remuxer]: initPTS & initDTS reset"),this._initPTS=this._initDTS=t},e.resetNextTimestamp=function(){w.log("[mp4-remuxer]: reset next timestamp"),this.isVideoContiguous=!1,this.isAudioContiguous=!1},e.resetInitSegment=function(){w.log("[mp4-remuxer]: ISGenerated flag reset"),this.ISGenerated=!1,this.videoTrackConfig=void 0},e.getVideoStartPts=function(t){var e=!1,r=t.reduce((function(t,r){var i=r.pts-t;return i<-4294967296?(e=!0,Ln(t,r.pts)):i>0?t:r.pts}),t[0].pts);return e&&w.debug("PTS rollover detected"),r},e.remux=function(t,e,r,i,n,a,s,o){var l,u,h,d,c,f,g=n,v=n,m=t.pid>-1,p=e.pid>-1,y=e.samples.length,E=t.samples.length>0,T=s&&y>0||y>1;if((!m||E)&&(!p||T)||this.ISGenerated||s){if(this.ISGenerated){var S,L,A,R,k=this.videoTrackConfig;!k||e.width===k.width&&e.height===k.height&&(null==(S=e.pixelRatio)?void 0:S[0])===(null==(L=k.pixelRatio)?void 0:L[0])&&(null==(A=e.pixelRatio)?void 0:A[1])===(null==(R=k.pixelRatio)?void 0:R[1])||this.resetInitSegment()}else h=this.generateIS(t,e,n,a);var b,D=this.isVideoContiguous,I=-1;if(T&&(I=function(t){for(var e=0;e0){w.warn("[mp4-remuxer]: Dropped "+I+" out of "+y+" video samples due to a missing keyframe");var C=this.getVideoStartPts(e.samples);e.samples=e.samples.slice(I),e.dropped+=I,b=v+=(e.samples[0].pts-C)/e.inputTimeScale}else-1===I&&(w.warn("[mp4-remuxer]: No keyframe found out of "+y+" video samples"),f=!1);if(this.ISGenerated){if(E&&T){var _=this.getVideoStartPts(e.samples),x=(Ln(t.samples[0].pts,_)-_)/e.inputTimeScale;g+=Math.max(0,x),v+=Math.max(0,-x)}if(E){if(t.samplerate||(w.warn("[mp4-remuxer]: regenerate InitSegment as audio detected"),h=this.generateIS(t,e,n,a)),u=this.remuxAudio(t,g,this.isAudioContiguous,a,p||T||o===Ce?v:void 0),T){var P=u?u.endPTS-u.startPTS:0;e.inputTimeScale||(w.warn("[mp4-remuxer]: regenerate InitSegment as video detected"),h=this.generateIS(t,e,n,a)),l=this.remuxVideo(e,v,D,P)}}else T&&(l=this.remuxVideo(e,v,D,0));l&&(l.firstKeyFrame=I,l.independent=-1!==I,l.firstKeyFramePTS=b)}}return this.ISGenerated&&this._initPTS&&this._initDTS&&(r.samples.length&&(c=An(r,n,this._initPTS,this._initDTS)),i.samples.length&&(d=Rn(i,n,this._initPTS))),{audio:u,video:l,initSegment:h,independent:f,text:d,id3:c}},e.generateIS=function(t,e,r,i){var n,a,s,o=t.samples,l=e.samples,u=this.typeSupported,h={},d=this._initPTS,c=!d||i,f="audio/mp4";if(c&&(n=a=1/0),t.config&&o.length){switch(t.timescale=t.samplerate,t.segmentCodec){case"mp3":u.mpeg?(f="audio/mpeg",t.codec=""):u.mp3&&(t.codec="mp3");break;case"ac3":t.codec="ac-3"}h.audio={id:"audio",container:f,codec:t.codec,initSegment:"mp3"===t.segmentCodec&&u.mpeg?new Uint8Array(0):vn.initSegment([t]),metadata:{channelCount:t.channelCount}},c&&(s=t.inputTimeScale,d&&s===d.timescale?c=!1:n=a=o[0].pts-Math.round(s*r))}if(e.sps&&e.pps&&l.length){if(e.timescale=e.inputTimeScale,h.video={id:"main",container:"video/mp4",codec:e.codec,initSegment:vn.initSegment([e]),metadata:{width:e.width,height:e.height}},c)if(s=e.inputTimeScale,d&&s===d.timescale)c=!1;else{var g=this.getVideoStartPts(l),v=Math.round(s*r);a=Math.min(a,Ln(l[0].dts,g)-v),n=Math.min(n,g-v)}this.videoTrackConfig={width:e.width,height:e.height,pixelRatio:e.pixelRatio}}if(Object.keys(h).length)return this.ISGenerated=!0,c?(this._initPTS={baseTime:n,timescale:s},this._initDTS={baseTime:a,timescale:s}):n=s=void 0,{tracks:h,initPTS:n,timescale:s}},e.remuxVideo=function(t,e,r,i){var n,a,s=t.inputTimeScale,l=t.samples,u=[],h=l.length,d=this._initPTS,c=this.nextAvcDts,f=8,g=this.videoSampleDuration,v=Number.POSITIVE_INFINITY,m=Number.NEGATIVE_INFINITY,p=!1;if(!r||null===c){var y=e*s,E=l[0].pts-Ln(l[0].dts,l[0].pts);En&&null!==c&&Math.abs(y-E-c)<15e3?r=!0:c=y-E}for(var T=d.baseTime*s/d.timescale,R=0;R0?R-1:R].dts&&(p=!0)}p&&l.sort((function(t,e){var r=t.dts-e.dts,i=t.pts-e.pts;return r||i})),n=l[0].dts;var b=(a=l[l.length-1].dts)-n,D=b?Math.round(b/(h-1)):g||t.inputTimeScale/30;if(r){var I=n-c,C=I>D,_=I<-1;if((C||_)&&(C?w.warn("AVC: "+yn(I,!0)+" ms ("+I+"dts) hole between fragments detected at "+e.toFixed(3)):w.warn("AVC: "+yn(-I,!0)+" ms ("+I+"dts) overlapping between fragments detected at "+e.toFixed(3)),!_||c>=l[0].pts||En)){n=c;var x=l[0].pts-I;if(C)l[0].dts=n,l[0].pts=x;else for(var P=0;Px);P++)l[P].dts-=I,l[P].pts-=I;w.log("Video: Initial PTS/DTS adjusted: "+yn(x,!0)+"/"+yn(n,!0)+", delta: "+yn(I,!0)+" ms")}}for(var F=0,M=0,O=n=Math.max(0,n),N=0;N0?$.dts-l[J-1].dts:D;if(st=J>0?$.pts-l[J-1].pts:D,ot.stretchShortVideoTrack&&null!==this.nextAudioPts){var ut=Math.floor(ot.maxBufferHole*s),ht=(i?v+i*s:this.nextAudioPts)-$.pts;ht>ut?((g=ht-lt)<0?g=lt:j=!0,w.log("[mp4-remuxer]: It is approximately "+ht/90+" ms to the next segment; using duration "+g/90+" ms for the last video frame.")):g=lt}else g=lt}var dt=Math.round($.pts-$.dts);q=Math.min(q,g),z=Math.max(z,g),X=Math.min(X,st),Q=Math.max(Q,st),u.push(new bn($.key,g,tt,dt))}if(u.length)if(En){if(En<70){var ct=u[0].flags;ct.dependsOn=2,ct.isNonSync=0}}else if(Tn&&Q-X0&&(i&&Math.abs(p-m)<9e3||Math.abs(Ln(g[0].pts-y,p)-m)<20*u),g.forEach((function(t){t.pts=Ln(t.pts-y,p)})),!r||m<0){if(g=g.filter((function(t){return t.pts>=0})),!g.length)return;m=0===n?0:i&&!f?Math.max(0,p):g[0].pts}if("aac"===t.segmentCodec)for(var E=this.config.maxAudioFramesDrift,T=0,R=m;T=E*u&&I<1e4&&f){var C=Math.round(D/u);(R=b-C*u)<0&&(C--,R+=u),0===T&&(this.nextAudioPts=m=R),w.warn("[mp4-remuxer]: Injecting "+C+" audio frame @ "+(R/a).toFixed(3)+"s due to "+Math.round(1e3*D/a)+" ms gap.");for(var _=0;_0))return;N+=v;try{F=new Uint8Array(N)}catch(t){return void this.observer.emit(S.ERROR,S.ERROR,{type:L.MUX_ERROR,details:A.REMUX_ALLOC_ERROR,fatal:!1,error:t,bytes:N,reason:"fail allocating audio mdat "+N})}d||(new DataView(F.buffer).setUint32(0,N),F.set(vn.types.mdat,4))}F.set(H,v);var Y=H.byteLength;v+=Y,c.push(new bn(!0,l,Y,0)),O=V}var W=c.length;if(W){var j=c[c.length-1];this.nextAudioPts=m=O+s*j.duration;var q=d?new Uint8Array(0):vn.moof(t.sequenceNumber++,M/s,o({},t,{samples:c}));t.samples=[];var X=M/a,z=m/a,Q={data1:q,data2:F,startPTS:X,endPTS:z,startDTS:X,endDTS:z,type:"audio",hasAudio:!0,hasVideo:!1,nb:W};return this.isAudioContiguous=!0,Q}},e.remuxEmptyAudio=function(t,e,r,i){var n=t.inputTimeScale,a=n/(t.samplerate?t.samplerate:n),s=this.nextAudioPts,o=this._initDTS,l=9e4*o.baseTime/o.timescale,u=(null!==s?s:i.startDTS*n)+l,h=i.endDTS*n+l,d=1024*a,c=Math.ceil((h-u)/d),f=fn.getSilentFrame(t.manifestCodec||t.codec,t.channelCount);if(w.warn("[mp4-remuxer]: remux empty Audio"),f){for(var g=[],v=0;v4294967296;)t+=r;return t}function An(t,e,r,i){var n=t.samples.length;if(n){for(var a=t.inputTimeScale,s=0;s0;n||(i=xt(e,["encv"])),i.forEach((function(t){xt(n?t.subarray(28):t.subarray(78),["sinf"]).forEach((function(t){var e=Bt(t);if(e){var i=e.subarray(8,24);i.some((function(t){return 0!==t}))||(w.log("[eme] Patching keyId in 'enc"+(n?"a":"v")+">sinf>>tenc' box: "+Lt(i)+" -> "+Lt(r)),e.set(r,8))}}))}))})),t}(t,i)),this.emitInitSegment=!0},e.generateInitSegment=function(t){var e=this.audioCodec,r=this.videoCodec;if(null==t||!t.byteLength)return this.initTracks=void 0,void(this.initData=void 0);var i=this.initData=Ft(t);i.audio&&(e=In(i.audio,O)),i.video&&(r=In(i.video,N));var n={};i.audio&&i.video?n.audiovideo={container:"video/mp4",codec:e+","+r,initSegment:t,id:"main"}:i.audio?n.audio={container:"audio/mp4",codec:e,initSegment:t,id:"audio"}:i.video?n.video={container:"video/mp4",codec:r,initSegment:t,id:"main"}:w.warn("[passthrough-remuxer.ts]: initSegment does not contain moov or trak boxes."),this.initTracks=n},e.remux=function(t,e,r,i,n,a){var s,o,l=this.initPTS,u=this.lastEndTime,h={audio:void 0,video:void 0,text:i,id3:r,initSegment:void 0};y(u)||(u=this.lastEndTime=n||0);var d=e.samples;if(null==d||!d.length)return h;var c={initPTS:void 0,timescale:1},f=this.initData;if(null!=(s=f)&&s.length||(this.generateInitSegment(d),f=this.initData),null==(o=f)||!o.length)return w.warn("[passthrough-remuxer.ts]: Failed to generate initSegment."),h;this.emitInitSegment&&(c.tracks=this.initTracks,this.emitInitSegment=!1);var g=function(t,e){for(var r=0,i=0,n=0,a=xt(t,["moof","traf"]),s=0;sn}(l,m,n,g)||c.timescale!==l.timescale&&a)&&(c.initPTS=m-n,l&&1===l.timescale&&w.warn("Adjusting initPTS by "+(c.initPTS-l.baseTime)),this.initPTS=l={baseTime:c.initPTS,timescale:1});var p=t?m-l.baseTime/l.timescale:u,E=p+g;!function(t,e,r){xt(e,["moof","traf"]).forEach((function(e){xt(e,["tfhd"]).forEach((function(i){var n=It(i,4),a=t[n];if(a){var s=a.timescale||9e4;xt(e,["tfdt"]).forEach((function(t){var e=t[0],i=r*s;if(i){var n=It(t,4);if(0===e)n-=i,_t(t,4,n=Math.max(n,0));else{n*=Math.pow(2,32),n+=It(t,8),n-=i,n=Math.max(n,0);var a=Math.floor(n/(At+1)),o=Math.floor(n%(At+1));_t(t,4,a),_t(t,8,o)}}}))}}))}))}(f,d,l.baseTime/l.timescale),g>0?this.lastEndTime=E:(w.warn("Duration parsed from mp4 should be greater than zero"),this.resetNextTimestamp());var T=!!f.audio,S=!!f.video,L="";T&&(L+="audio"),S&&(L+="video");var A={data1:d,startPTS:p,startDTS:p,endPTS:E,endDTS:E,type:L,hasAudio:T,hasVideo:S,nb:1,dropped:0};return h.audio="audio"===A.type?A:void 0,h.video="audio"!==A.type?A:void 0,h.initSegment=c,h.id3=An(r,n,l,l),i.samples.length&&(h.text=Rn(i,n,l)),h},t}();function In(t,e){var r=null==t?void 0:t.codec;if(r&&r.length>4)return r;if(e===O){if("ec-3"===r||"ac-3"===r||"alac"===r)return r;if("fLaC"===r||"Opus"===r)return he(r,!1);var i="mp4a.40.5";return w.info('Parsed audio codec "'+r+'" or audio object type not handled. Using "'+i+'"'),i}return w.warn('Unhandled video codec "'+r+'"'),"hvc1"===r||"hev1"===r?"hvc1.1.6.L120.90":"av01"===r?"av01.0.04M.08":"avc1.42e01e"}try{kn=self.performance.now.bind(self.performance)}catch(t){w.debug("Unable to use Performance API on this environment"),kn=null==j?void 0:j.Date.now}var wn=[{demux:Qi,remux:Dn},{demux:sn,remux:Sn},{demux:Xi,remux:Sn},{demux:cn,remux:Sn}];wn.splice(2,0,{demux:$i,remux:Sn});var Cn=function(){function t(t,e,r,i,n){this.async=!1,this.observer=void 0,this.typeSupported=void 0,this.config=void 0,this.vendor=void 0,this.id=void 0,this.demuxer=void 0,this.remuxer=void 0,this.decrypter=void 0,this.probe=void 0,this.decryptionPromise=null,this.transmuxConfig=void 0,this.currentTransmuxState=void 0,this.observer=t,this.typeSupported=e,this.config=r,this.vendor=i,this.id=n}var e=t.prototype;return e.configure=function(t){this.transmuxConfig=t,this.decrypter&&this.decrypter.reset()},e.push=function(t,e,r,i){var n=this,a=r.transmuxing;a.executeStart=kn();var s=new Uint8Array(t),o=this.currentTransmuxState,l=this.transmuxConfig;i&&(this.currentTransmuxState=i);var u=i||o,h=u.contiguous,d=u.discontinuity,c=u.trackSwitch,f=u.accurateTimeOffset,g=u.timeOffset,v=u.initSegmentChange,m=l.audioCodec,p=l.videoCodec,y=l.defaultInitPts,E=l.duration,T=l.initSegmentData,R=function(t,e){var r=null;return t.byteLength>0&&null!=(null==e?void 0:e.key)&&null!==e.iv&&null!=e.method&&(r=e),r}(s,e);if(R&&"AES-128"===R.method){var k=this.getDecrypter();if(!k.isSync())return this.decryptionPromise=k.webCryptoDecrypt(s,R.key.buffer,R.iv.buffer).then((function(t){var e=n.push(t,null,r);return n.decryptionPromise=null,e})),this.decryptionPromise;var b=k.softwareDecrypt(s,R.key.buffer,R.iv.buffer);if(r.part>-1&&(b=k.flush()),!b)return a.executeEnd=kn(),_n(r);s=new Uint8Array(b)}var D=this.needsProbing(d,c);if(D){var I=this.configureTransmuxer(s);if(I)return w.warn("[transmuxer] "+I.message),this.observer.emit(S.ERROR,S.ERROR,{type:L.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,fatal:!1,error:I,reason:I.message}),a.executeEnd=kn(),_n(r)}(d||c||v||D)&&this.resetInitSegment(T,m,p,E,e),(d||v||D)&&this.resetInitialTimestamp(y),h||this.resetContiguity();var C=this.transmux(s,R,g,f,r),_=this.currentTransmuxState;return _.contiguous=!0,_.discontinuity=!1,_.trackSwitch=!1,a.executeEnd=kn(),C},e.flush=function(t){var e=this,r=t.transmuxing;r.executeStart=kn();var i=this.decrypter,n=this.currentTransmuxState,a=this.decryptionPromise;if(a)return a.then((function(){return e.flush(t)}));var s=[],o=n.timeOffset;if(i){var l=i.flush();l&&s.push(this.push(l,null,t))}var u=this.demuxer,h=this.remuxer;if(!u||!h)return r.executeEnd=kn(),[_n(t)];var d=u.flush(o);return xn(d)?d.then((function(r){return e.flushRemux(s,r,t),s})):(this.flushRemux(s,d,t),s)},e.flushRemux=function(t,e,r){var i=e.audioTrack,n=e.videoTrack,a=e.id3Track,s=e.textTrack,o=this.currentTransmuxState,l=o.accurateTimeOffset,u=o.timeOffset;w.log("[transmuxer.ts]: Flushed fragment "+r.sn+(r.part>-1?" p: "+r.part:"")+" of level "+r.level);var h=this.remuxer.remux(i,n,a,s,u,l,!0,this.id);t.push({remuxResult:h,chunkMeta:r}),r.transmuxing.executeEnd=kn()},e.resetInitialTimestamp=function(t){var e=this.demuxer,r=this.remuxer;e&&r&&(e.resetTimeStamp(t),r.resetTimeStamp(t))},e.resetContiguity=function(){var t=this.demuxer,e=this.remuxer;t&&e&&(t.resetContiguity(),e.resetNextTimestamp())},e.resetInitSegment=function(t,e,r,i,n){var a=this.demuxer,s=this.remuxer;a&&s&&(a.resetInitSegment(t,e,r,i),s.resetInitSegment(t,e,r,n))},e.destroy=function(){this.demuxer&&(this.demuxer.destroy(),this.demuxer=void 0),this.remuxer&&(this.remuxer.destroy(),this.remuxer=void 0)},e.transmux=function(t,e,r,i,n){return e&&"SAMPLE-AES"===e.method?this.transmuxSampleAes(t,e,r,i,n):this.transmuxUnencrypted(t,r,i,n)},e.transmuxUnencrypted=function(t,e,r,i){var n=this.demuxer.demux(t,e,!1,!this.config.progressive),a=n.audioTrack,s=n.videoTrack,o=n.id3Track,l=n.textTrack;return{remuxResult:this.remuxer.remux(a,s,o,l,e,r,!1,this.id),chunkMeta:i}},e.transmuxSampleAes=function(t,e,r,i,n){var a=this;return this.demuxer.demuxSampleAes(t,e,r).then((function(t){return{remuxResult:a.remuxer.remux(t.audioTrack,t.videoTrack,t.id3Track,t.textTrack,r,i,!1,a.id),chunkMeta:n}}))},e.configureTransmuxer=function(t){for(var e,r=this.config,i=this.observer,n=this.typeSupported,a=this.vendor,s=0,o=wn.length;s1&&l.id===(null==m?void 0:m.stats.chunkCount),L=!y&&(1===E||0===E&&(1===T||S&&T<=0)),A=self.performance.now();(y||E||0===n.stats.parsing.start)&&(n.stats.parsing.start=A),!a||!T&&L||(a.stats.parsing.start=A);var R=!(m&&(null==(h=n.initSegment)?void 0:h.url)===(null==(d=m.initSegment)?void 0:d.url)),k=new Fn(p,L,o,y,g,R);if(!L||p||R){w.log("[transmuxer-interface, "+n.type+"]: Starting new transmux session for sn: "+l.sn+" p: "+l.part+" level: "+l.level+" id: "+l.id+"\n discontinuity: "+p+"\n trackSwitch: "+y+"\n contiguous: "+L+"\n accurateTimeOffset: "+o+"\n timeOffset: "+g+"\n initSegmentChange: "+R);var b=new Pn(r,i,e,s,u);this.configureTransmuxer(b)}if(this.frag=n,this.part=a,this.workerContext)this.workerContext.worker.postMessage({cmd:"demux",data:t,decryptdata:v,chunkMeta:l,state:k},t instanceof ArrayBuffer?[t]:[]);else if(f){var D=f.push(t,v,l,k);xn(D)?(f.async=!0,D.then((function(t){c.handleTransmuxComplete(t)})).catch((function(t){c.transmuxerError(t,l,"transmuxer-interface push error")}))):(f.async=!1,this.handleTransmuxComplete(D))}},r.flush=function(t){var e=this;t.transmuxing.start=self.performance.now();var r=this.transmuxer;if(this.workerContext)this.workerContext.worker.postMessage({cmd:"flush",chunkMeta:t});else if(r){var i=r.flush(t);xn(i)||r.async?(xn(i)||(i=Promise.resolve(i)),i.then((function(r){e.handleFlushResult(r,t)})).catch((function(r){e.transmuxerError(r,t,"transmuxer-interface flush error")}))):this.handleFlushResult(i,t)}},r.transmuxerError=function(t,e,r){this.hls&&(this.error=t,this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.FRAG_PARSING_ERROR,chunkMeta:e,fatal:!1,error:t,err:t,reason:r}))},r.handleFlushResult=function(t,e){var r=this;t.forEach((function(t){r.handleTransmuxComplete(t)})),this.onFlush(e)},r.onWorkerMessage=function(t){var e=t.data,r=this.hls;switch(e.event){case"init":var i,n=null==(i=this.workerContext)?void 0:i.objectURL;n&&self.URL.revokeObjectURL(n);break;case"transmuxComplete":this.handleTransmuxComplete(e.data);break;case"flush":this.onFlush(e.data);break;case"workerLog":w[e.data.logType]&&w[e.data.logType](e.data.message);break;default:e.data=e.data||{},e.data.frag=this.frag,e.data.id=this.id,r.trigger(e.event,e.data)}},r.configureTransmuxer=function(t){var e=this.transmuxer;this.workerContext?this.workerContext.worker.postMessage({cmd:"configure",config:t}):e&&e.configure(t)},r.handleTransmuxComplete=function(t){t.chunkMeta.transmuxing.end=self.performance.now(),this.onTransmuxComplete(t)},e}();function Kn(t,e){if(t.length!==e.length)return!1;for(var r=0;r0&&-1===t?(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e,this.state=gi):(this.loadedmetadata=!1,this.state=yi),this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()},r.doTick=function(){switch(this.state){case gi:this.doTickIdle();break;case yi:var e,r=this.levels,i=this.trackId,n=null==r||null==(e=r[i])?void 0:e.details;if(n){if(this.waitForCdnTuneIn(n))break;this.state=Ai}break;case pi:var a,s=performance.now(),o=this.retryDate;if(!o||s>=o||null!=(a=this.media)&&a.seeking){var l=this.levels,u=this.trackId;this.log("RetryDate reached, switch back to IDLE state"),this.resetStartWhenNotLoaded((null==l?void 0:l[u])||null),this.state=gi}break;case Ai:var h=this.waitingData;if(h){var d=h.frag,c=h.part,f=h.cache,g=h.complete;if(void 0!==this.initPTS[d.cc]){this.waitingData=null,this.waitingVideoCC=-1,this.state=mi;var v={frag:d,part:c,payload:f.flush(),networkDetails:null};this._handleFragmentLoadProgress(v),g&&t.prototype._handleFragmentLoadComplete.call(this,v)}else if(this.videoTrackCC!==this.waitingVideoCC)this.log("Waiting fragment cc ("+d.cc+") cancelled because video is at cc "+this.videoTrackCC),this.clearWaitingFragment();else{var m=this.getLoadPosition(),p=Qr.bufferInfo(this.mediaBuffer,m,this.config.maxBufferHole);yr(p.end,this.config.maxFragLookUpTolerance,d)<0&&(this.log("Waiting fragment cc ("+d.cc+") @ "+d.start+" cancelled because another fragment at "+p.end+" is needed"),this.clearWaitingFragment())}}else this.state=gi}this.onTickEnd()},r.clearWaitingFragment=function(){var t=this.waitingData;t&&(this.fragmentTracker.removeFragment(t.frag),this.waitingData=null,this.waitingVideoCC=-1,this.state=gi)},r.resetLoadingState=function(){this.clearWaitingFragment(),t.prototype.resetLoadingState.call(this)},r.onTickEnd=function(){var t=this.media;null!=t&&t.readyState&&(this.lastCurrentTime=t.currentTime)},r.doTickIdle=function(){var t=this.hls,e=this.levels,r=this.media,i=this.trackId,n=t.config;if((r||!this.startFragRequested&&n.startFragPrefetch)&&null!=e&&e[i]){var a=e[i],s=a.details;if(!s||s.live&&this.levelLastLoaded!==a||this.waitForCdnTuneIn(s))this.state=yi;else{var o=this.mediaBuffer?this.mediaBuffer:this.media;this.bufferFlushed&&o&&(this.bufferFlushed=!1,this.afterBufferFlushed(o,O,Ce));var l=this.getFwdBufferInfo(o,Ce);if(null!==l){var u=this.bufferedTrack,h=this.switchingTrack;if(!h&&this._streamEnded(l,s))return t.trigger(S.BUFFER_EOS,{type:"audio"}),void(this.state=Si);var d=this.getFwdBufferInfo(this.videoBuffer?this.videoBuffer:this.media,we),c=l.len,f=this.getMaxBufferLength(null==d?void 0:d.len),g=s.fragments,v=g[0].start,m=this.flushing?this.getLoadPosition():l.end;if(h&&r){var p=this.getLoadPosition();u&&!Hn(h.attrs,u.attrs)&&(m=p),s.PTSKnown&&pv||l.nextStart)&&(this.log("Alt audio track ahead of main track, seek to start of alt audio track"),r.currentTime=v+.05)}if(!(c>=f&&!h&&md.end+s.targetduration;if(T||(null==d||!d.len)&&l.len){var L=this.getAppendedFrag(y.start,we);if(null===L)return;if(E||(E=!!L.gap||!!T&&0===d.len),T&&!E||E&&l.nextStart&&l.nextStart-1)n=a[o];else{var l=Or(s,this.tracks);n=this.tracks[l]}}var u=this.findTrackId(n);-1===u&&n&&(u=this.findTrackId(null));var h={audioTracks:a};this.log("Updating audio tracks, "+a.length+" track(s) found in group(s): "+(null==r?void 0:r.join(","))),this.hls.trigger(S.AUDIO_TRACKS_UPDATED,h);var d=this.trackId;if(-1!==u&&-1===d)this.setAudioTrack(u);else if(a.length&&-1===d){var c,f=new Error("No audio track selected for current audio group-ID(s): "+(null==(c=this.groupIds)?void 0:c.join(","))+" track count: "+a.length);this.warn(f.message),this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.AUDIO_TRACK_LOAD_ERROR,fatal:!0,error:f})}}else this.shouldReloadPlaylist(n)&&this.setAudioTrack(this.trackId)}},r.onError=function(t,e){!e.fatal&&e.context&&(e.context.type!==De||e.context.id!==this.trackId||this.groupIds&&-1===this.groupIds.indexOf(e.context.groupId)||(this.requestScheduled=-1,this.checkRetry(e)))},r.setAudioOption=function(t){var e=this.hls;if(e.config.audioPreference=t,t){var r=this.allAudioTracks;if(this.selectDefaultTrack=!1,r.length){var i=this.currentTrack;if(i&&Nr(t,i,Ur))return i;var n=Or(t,this.tracksInGroup,Ur);if(n>-1){var a=this.tracksInGroup[n];return this.setAudioTrack(n),a}if(i){var s=e.loadLevel;-1===s&&(s=e.firstAutoLevel);var o=function(t,e,r,i,n){var a=e[i],s=e.reduce((function(t,e,r){var i=e.uri;return(t[i]||(t[i]=[])).push(r),t}),{})[a.uri];s.length>1&&(i=Math.max.apply(Math,s));var o=a.videoRange,l=a.frameRate,u=a.codecSet.substring(0,4),h=Br(e,i,(function(e){if(e.videoRange!==o||e.frameRate!==l||e.codecSet.substring(0,4)!==u)return!1;var i=e.audioGroups,a=r.filter((function(t){return!i||-1!==i.indexOf(t.groupId)}));return Or(t,a,n)>-1}));return h>-1?h:Br(e,i,(function(e){var i=e.audioGroups,a=r.filter((function(t){return!i||-1!==i.indexOf(t.groupId)}));return Or(t,a,n)>-1}))}(t,e.levels,r,s,Ur);if(-1===o)return null;e.nextLoadLevel=o}if(t.channels||t.audioCodec){var l=Or(t,r);if(l>-1)return r[l]}}}return null},r.setAudioTrack=function(t){var e=this.tracksInGroup;if(t<0||t>=e.length)this.warn("Invalid audio track id: "+t);else{this.clearTimer(),this.selectDefaultTrack=!1;var r=this.currentTrack,n=e[t],a=n.details&&!n.details.live;if(!(t===this.trackId&&n===r&&a||(this.log("Switching to audio-track "+t+' "'+n.name+'" lang:'+n.lang+" group:"+n.groupId+" channels:"+n.channels),this.trackId=t,this.currentTrack=n,this.hls.trigger(S.AUDIO_TRACK_SWITCHING,i({},n)),a))){var s=this.switchParams(n.url,null==r?void 0:r.details);this.loadPlaylist(s)}}},r.findTrackId=function(t){for(var e=this.tracksInGroup,r=0;r=n[o].start&&s<=n[o].end){a=n[o];break}var l=r.start+r.duration;a?a.end=l:(a={start:s,end:l},n.push(a)),this.fragmentTracker.fragBuffered(r),this.fragBufferedComplete(r,null)}}},r.onBufferFlushing=function(t,e){var r=e.startOffset,i=e.endOffset;if(0===r&&i!==Number.POSITIVE_INFINITY){var n=i-1;if(n<=0)return;e.endOffsetSubtitles=Math.max(0,n),this.tracksBuffered.forEach((function(t){for(var e=0;e=n.length||s!==i)&&o){this.log("Subtitle track "+s+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+",duration:"+a.totalduration),this.mediaBuffer=this.mediaBufferTimeRanges;var l=0;if(a.live||null!=(r=o.details)&&r.live){var u=this.mainDetails;if(a.deltaUpdateFailed||!u)return;var h,d=u.fragments[0];o.details?0===(l=this.alignPlaylists(a,o.details,null==(h=this.levelLastLoaded)?void 0:h.details))&&d&&or(a,l=d.start):a.hasProgramDateTime&&u.hasProgramDateTime?(ri(a,u),l=a.fragments[0].start):d&&or(a,l=d.start)}o.details=a,this.levelLastLoaded=o,this.startFragRequested||!this.mainDetails&&a.live||this.setStartPosition(this.mainDetails||a,l),this.tick(),a.live&&!this.fragCurrent&&this.media&&this.state===gi&&(pr(null,a.fragments,this.media.currentTime,0)||(this.warn("Subtitle playlist not aligned with playback"),o.details=void 0))}}else this.warn("Subtitle tracks were reset while loading level "+s)},r._handleFragmentLoadComplete=function(t){var e=this,r=t.frag,i=t.payload,n=r.decryptdata,a=this.hls;if(!this.fragContextChanged(r)&&i&&i.byteLength>0&&null!=n&&n.key&&n.iv&&"AES-128"===n.method){var s=performance.now();this.decrypter.decrypt(new Uint8Array(i),n.key.buffer,n.iv.buffer).catch((function(t){throw a.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.FRAG_DECRYPT_ERROR,fatal:!1,error:t,reason:t.message,frag:r}),t})).then((function(t){var e=performance.now();a.trigger(S.FRAG_DECRYPTED,{frag:r,payload:t,stats:{tstart:s,tdecrypt:e}})})).catch((function(t){e.warn(t.name+": "+t.message),e.state=gi}))}},r.doTick=function(){if(this.media){if(this.state===gi){var t=this.currentTrackId,e=this.levels,r=null==e?void 0:e[t];if(!r||!e.length||!r.details)return;var i=this.config,n=this.getLoadPosition(),a=Qr.bufferedInfo(this.tracksBuffered[this.currentTrackId]||[],n,i.maxBufferHole),s=a.end,o=a.len,l=this.getFwdBufferInfo(this.media,we),u=r.details;if(o>this.getMaxBufferLength(null==l?void 0:l.len)+u.levelTargetDuration)return;var h=u.fragments,d=h.length,c=u.edge,f=null,g=this.fragPrevious;if(sc-v?0:v;!(f=pr(g,h,Math.max(h[0].start,s),m))&&g&&g.start>>=0)>i-1)throw new DOMException("Failed to execute '"+e+"' on 'TimeRanges': The index provided ("+r+") is greater than the maximum bound ("+i+")");return t[r][e]};this.buffered={get length(){return t.length},end:function(r){return e("end",r,t.length)},start:function(r){return e("start",r,t.length)}}},Xn=function(t){function e(e){var r;return(r=t.call(this,e,"[subtitle-track-controller]")||this).media=null,r.tracks=[],r.groupIds=null,r.tracksInGroup=[],r.trackId=-1,r.currentTrack=null,r.selectDefaultTrack=!0,r.queuedDefaultTrack=-1,r.asyncPollTrackChange=function(){return r.pollTrackChange(0)},r.useTextTrackPolling=!1,r.subtitlePollingInterval=-1,r._subtitleDisplay=!0,r.onTextTracksChanged=function(){if(r.useTextTrackPolling||self.clearInterval(r.subtitlePollingInterval),r.media&&r.hls.config.renderTextTracksNatively){for(var t=null,e=Be(r.media.textTracks),i=0;i-1&&(this.subtitleTrack=this.queuedDefaultTrack,this.queuedDefaultTrack=-1),this.useTextTrackPolling=!(this.media.textTracks&&"onchange"in this.media.textTracks),this.useTextTrackPolling?this.pollTrackChange(500):this.media.textTracks.addEventListener("change",this.asyncPollTrackChange))},r.pollTrackChange=function(t){self.clearInterval(this.subtitlePollingInterval),this.subtitlePollingInterval=self.setInterval(this.onTextTracksChanged,t)},r.onMediaDetaching=function(){this.media&&(self.clearInterval(this.subtitlePollingInterval),this.useTextTrackPolling||this.media.textTracks.removeEventListener("change",this.asyncPollTrackChange),this.trackId>-1&&(this.queuedDefaultTrack=this.trackId),Be(this.media.textTracks).forEach((function(t){Ne(t)})),this.subtitleTrack=-1,this.media=null)},r.onManifestLoading=function(){this.tracks=[],this.groupIds=null,this.tracksInGroup=[],this.trackId=-1,this.currentTrack=null,this.selectDefaultTrack=!0},r.onManifestParsed=function(t,e){this.tracks=e.subtitleTracks},r.onSubtitleTrackLoaded=function(t,e){var r=e.id,i=e.groupId,n=e.details,a=this.tracksInGroup[r];if(a&&a.groupId===i){var s=a.details;a.details=e.details,this.log("Subtitle track "+r+' "'+a.name+'" lang:'+a.lang+" group:"+i+" loaded ["+n.startSN+"-"+n.endSN+"]"),r===this.trackId&&this.playlistLoaded(r,e,s)}else this.warn("Subtitle track with id:"+r+" and group:"+i+" not found in active group "+(null==a?void 0:a.groupId))},r.onLevelLoading=function(t,e){this.switchLevel(e.level)},r.onLevelSwitching=function(t,e){this.switchLevel(e.level)},r.switchLevel=function(t){var e=this.hls.levels[t];if(e){var r=e.subtitleGroups||null,i=this.groupIds,n=this.currentTrack;if(!r||(null==i?void 0:i.length)!==(null==r?void 0:r.length)||null!=r&&r.some((function(t){return-1===(null==i?void 0:i.indexOf(t))}))){this.groupIds=r,this.trackId=-1,this.currentTrack=null;var a=this.tracks.filter((function(t){return!r||-1!==r.indexOf(t.groupId)}));if(a.length)this.selectDefaultTrack&&!a.some((function(t){return t.default}))&&(this.selectDefaultTrack=!1),a.forEach((function(t,e){t.id=e}));else if(!n&&!this.tracksInGroup.length)return;this.tracksInGroup=a;var s=this.hls.config.subtitlePreference;if(!n&&s){this.selectDefaultTrack=!1;var o=Or(s,a);if(o>-1)n=a[o];else{var l=Or(s,this.tracks);n=this.tracks[l]}}var u=this.findTrackId(n);-1===u&&n&&(u=this.findTrackId(null));var h={subtitleTracks:a};this.log("Updating subtitle tracks, "+a.length+' track(s) found in "'+(null==r?void 0:r.join(","))+'" group-id'),this.hls.trigger(S.SUBTITLE_TRACKS_UPDATED,h),-1!==u&&-1===this.trackId&&this.setSubtitleTrack(u)}else this.shouldReloadPlaylist(n)&&this.setSubtitleTrack(this.trackId)}},r.findTrackId=function(t){for(var e=this.tracksInGroup,r=this.selectDefaultTrack,i=0;i-1){var n=this.tracksInGroup[i];return this.setSubtitleTrack(i),n}if(r)return null;var a=Or(t,e);if(a>-1)return e[a]}}return null},r.loadPlaylist=function(e){t.prototype.loadPlaylist.call(this);var r=this.currentTrack;if(this.shouldLoadPlaylist(r)&&r){var i=r.id,n=r.groupId,a=r.url;if(e)try{a=e.addDirectives(a)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}this.log("Loading subtitle playlist for id "+i),this.hls.trigger(S.SUBTITLE_TRACK_LOADING,{url:a,id:i,groupId:n,deliveryDirectives:e||null})}},r.toggleTrackModes=function(){var t=this.media;if(t){var e,r=Be(t.textTracks),i=this.currentTrack;if(i&&((e=r.filter((function(t){return Vn(i,t)}))[0])||this.warn('Unable to find subtitle TextTrack with name "'+i.name+'" and language "'+i.lang+'"')),[].slice.call(r).forEach((function(t){"disabled"!==t.mode&&t!==e&&(t.mode="disabled")})),e){var n=this.subtitleDisplay?"showing":"hidden";e.mode!==n&&(e.mode=n)}}},r.setSubtitleTrack=function(t){var e=this.tracksInGroup;if(this.media)if(t<-1||t>=e.length||!y(t))this.warn("Invalid subtitle track id: "+t);else{this.clearTimer(),this.selectDefaultTrack=!1;var r=this.currentTrack,i=e[t]||null;if(this.trackId=t,this.currentTrack=i,this.toggleTrackModes(),i){var n=!!i.details&&!i.details.live;if(t!==this.trackId||i!==r||!n){this.log("Switching to subtitle-track "+t+(i?' "'+i.name+'" lang:'+i.lang+" group:"+i.groupId:""));var a=i.id,s=i.groupId,o=void 0===s?"":s,l=i.name,u=i.type,h=i.url;this.hls.trigger(S.SUBTITLE_TRACK_SWITCH,{id:a,groupId:o,name:l,type:u,url:h});var d=this.switchParams(i.url,null==r?void 0:r.details);this.loadPlaylist(d)}}else this.hls.trigger(S.SUBTITLE_TRACK_SWITCH,{id:t})}else this.queuedDefaultTrack=t},s(e,[{key:"subtitleDisplay",get:function(){return this._subtitleDisplay},set:function(t){this._subtitleDisplay=t,this.trackId>-1&&this.toggleTrackModes()}},{key:"allSubtitleTracks",get:function(){return this.tracks}},{key:"subtitleTracks",get:function(){return this.tracksInGroup}},{key:"subtitleTrack",get:function(){return this.trackId},set:function(t){this.selectDefaultTrack=!1,this.setSubtitleTrack(t)}}]),e}(Ir),zn=function(){function t(t){this.buffers=void 0,this.queues={video:[],audio:[],audiovideo:[]},this.buffers=t}var e=t.prototype;return e.append=function(t,e,r){var i=this.queues[e];i.push(t),1!==i.length||r||this.executeNext(e)},e.insertAbort=function(t,e){this.queues[e].unshift(t),this.executeNext(e)},e.appendBlocker=function(t){var e,r=new Promise((function(t){e=t})),i={execute:e,onStart:function(){},onComplete:function(){},onError:function(){}};return this.append(i,t),r},e.executeNext=function(t){var e=this.queues[t];if(e.length){var r=e[0];try{r.execute()}catch(e){w.warn('[buffer-operation-queue]: Exception executing "'+t+'" SourceBuffer operation: '+e),r.onError(e);var i=this.buffers[t];null!=i&&i.updating||this.shiftAndExecuteNext(t)}}},e.shiftAndExecuteNext=function(t){this.queues[t].shift(),this.executeNext(t)},e.current=function(t){return this.queues[t][0]},t}(),Qn=/(avc[1234]|hvc1|hev1|dvh[1e]|vp09|av01)(?:\.[^.,]+)+/,Jn=function(){function t(t){var e=this;this.details=null,this._objectUrl=null,this.operationQueue=void 0,this.listeners=void 0,this.hls=void 0,this.bufferCodecEventsExpected=0,this._bufferCodecEventsTotal=0,this.media=null,this.mediaSource=null,this.lastMpegAudioChunk=null,this.appendSource=void 0,this.appendErrors={audio:0,video:0,audiovideo:0},this.tracks={},this.pendingTracks={},this.sourceBuffer=void 0,this.log=void 0,this.warn=void 0,this.error=void 0,this._onEndStreaming=function(t){e.hls&&e.hls.pauseBuffering()},this._onStartStreaming=function(t){e.hls&&e.hls.resumeBuffering()},this._onMediaSourceOpen=function(){var t=e.media,r=e.mediaSource;e.log("Media source opened"),t&&(t.removeEventListener("emptied",e._onMediaEmptied),e.updateMediaElementDuration(),e.hls.trigger(S.MEDIA_ATTACHED,{media:t,mediaSource:r})),r&&r.removeEventListener("sourceopen",e._onMediaSourceOpen),e.checkPendingTracks()},this._onMediaSourceClose=function(){e.log("Media source closed")},this._onMediaSourceEnded=function(){e.log("Media source ended")},this._onMediaEmptied=function(){var t=e.mediaSrc,r=e._objectUrl;t!==r&&w.error("Media element src was set while attaching MediaSource ("+r+" > "+t+")")},this.hls=t;var r="[buffer-controller]";this.appendSource=t.config.preferManagedMediaSource&&"undefined"!=typeof self&&self.ManagedMediaSource,this.log=w.log.bind(w,r),this.warn=w.warn.bind(w,r),this.error=w.error.bind(w,r),this._initSourceBuffer(),this.registerListeners()}var e=t.prototype;return e.hasSourceTypes=function(){return this.getSourceBufferTypes().length>0||Object.keys(this.pendingTracks).length>0},e.destroy=function(){this.unregisterListeners(),this.details=null,this.lastMpegAudioChunk=null,this.hls=null},e.registerListeners=function(){var t=this.hls;t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.BUFFER_RESET,this.onBufferReset,this),t.on(S.BUFFER_APPENDING,this.onBufferAppending,this),t.on(S.BUFFER_CODECS,this.onBufferCodecs,this),t.on(S.BUFFER_EOS,this.onBufferEos,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.on(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.on(S.FRAG_PARSED,this.onFragParsed,this),t.on(S.FRAG_CHANGED,this.onFragChanged,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.BUFFER_RESET,this.onBufferReset,this),t.off(S.BUFFER_APPENDING,this.onBufferAppending,this),t.off(S.BUFFER_CODECS,this.onBufferCodecs,this),t.off(S.BUFFER_EOS,this.onBufferEos,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),t.off(S.LEVEL_UPDATED,this.onLevelUpdated,this),t.off(S.FRAG_PARSED,this.onFragParsed,this),t.off(S.FRAG_CHANGED,this.onFragChanged,this)},e._initSourceBuffer=function(){this.sourceBuffer={},this.operationQueue=new zn(this.sourceBuffer),this.listeners={audio:[],video:[],audiovideo:[]},this.appendErrors={audio:0,video:0,audiovideo:0},this.lastMpegAudioChunk=null},e.onManifestLoading=function(){this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=0,this.details=null},e.onManifestParsed=function(t,e){var r=2;(e.audio&&!e.video||!e.altAudio)&&(r=1),this.bufferCodecEventsExpected=this._bufferCodecEventsTotal=r,this.log(this.bufferCodecEventsExpected+" bufferCodec event(s) expected")},e.onMediaAttaching=function(t,e){var r=this.media=e.media,i=ee(this.appendSource);if(r&&i){var n,a=this.mediaSource=new i;this.log("created media source: "+(null==(n=a.constructor)?void 0:n.name)),a.addEventListener("sourceopen",this._onMediaSourceOpen),a.addEventListener("sourceended",this._onMediaSourceEnded),a.addEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(a.addEventListener("startstreaming",this._onStartStreaming),a.addEventListener("endstreaming",this._onEndStreaming));var s=this._objectUrl=self.URL.createObjectURL(a);if(this.appendSource)try{r.removeAttribute("src");var o=self.ManagedMediaSource;r.disableRemotePlayback=r.disableRemotePlayback||o&&a instanceof o,$n(r),function(t,e){var r=self.document.createElement("source");r.type="video/mp4",r.src=e,t.appendChild(r)}(r,s),r.load()}catch(t){r.src=s}else r.src=s;r.addEventListener("emptied",this._onMediaEmptied)}},e.onMediaDetaching=function(){var t=this.media,e=this.mediaSource,r=this._objectUrl;if(e){if(this.log("media source detaching"),"open"===e.readyState)try{e.endOfStream()}catch(t){this.warn("onMediaDetaching: "+t.message+" while calling endOfStream")}this.onBufferReset(),e.removeEventListener("sourceopen",this._onMediaSourceOpen),e.removeEventListener("sourceended",this._onMediaSourceEnded),e.removeEventListener("sourceclose",this._onMediaSourceClose),this.appendSource&&(e.removeEventListener("startstreaming",this._onStartStreaming),e.removeEventListener("endstreaming",this._onEndStreaming)),t&&(t.removeEventListener("emptied",this._onMediaEmptied),r&&self.URL.revokeObjectURL(r),this.mediaSrc===r?(t.removeAttribute("src"),this.appendSource&&$n(t),t.load()):this.warn("media|source.src was changed by a third party - skip cleanup")),this.mediaSource=null,this.media=null,this._objectUrl=null,this.bufferCodecEventsExpected=this._bufferCodecEventsTotal,this.pendingTracks={},this.tracks={}}this.hls.trigger(S.MEDIA_DETACHED,void 0)},e.onBufferReset=function(){var t=this;this.getSourceBufferTypes().forEach((function(e){t.resetBuffer(e)})),this._initSourceBuffer()},e.resetBuffer=function(t){var e=this.sourceBuffer[t];try{var r;e&&(this.removeBufferListeners(t),this.sourceBuffer[t]=void 0,null!=(r=this.mediaSource)&&r.sourceBuffers.length&&this.mediaSource.removeSourceBuffer(e))}catch(e){this.warn("onBufferReset "+t,e)}},e.onBufferCodecs=function(t,e){var r=this,i=this.getSourceBufferTypes().length,n=Object.keys(e);if(n.forEach((function(t){if(i){var n=r.tracks[t];if(n&&"function"==typeof n.buffer.changeType){var a,s=e[t],o=s.id,l=s.codec,u=s.levelCodec,h=s.container,d=s.metadata,c=de(n.codec,n.levelCodec),f=null==c?void 0:c.replace(Qn,"$1"),g=de(l,u),v=null==(a=g)?void 0:a.replace(Qn,"$1");if(g&&f!==v){"audio"===t.slice(0,5)&&(g=he(g,r.appendSource));var m=h+";codecs="+g;r.appendChangeType(t,m),r.log("switching codec "+c+" to "+g),r.tracks[t]={buffer:n.buffer,codec:l,container:h,levelCodec:u,metadata:d,id:o}}}}else r.pendingTracks[t]=e[t]})),!i){var a=Math.max(this.bufferCodecEventsExpected-1,0);this.bufferCodecEventsExpected!==a&&(this.log(a+" bufferCodec event(s) expected "+n.join(",")),this.bufferCodecEventsExpected=a),this.mediaSource&&"open"===this.mediaSource.readyState&&this.checkPendingTracks()}},e.appendChangeType=function(t,e){var r=this,i=this.operationQueue,n={execute:function(){var n=r.sourceBuffer[t];n&&(r.log("changing "+t+" sourceBuffer type to "+e),n.changeType(e)),i.shiftAndExecuteNext(t)},onStart:function(){},onComplete:function(){},onError:function(e){r.warn("Failed to change "+t+" SourceBuffer type",e)}};i.append(n,t,!!this.pendingTracks[t])},e.onBufferAppending=function(t,e){var r=this,i=this.hls,n=this.operationQueue,a=this.tracks,s=e.data,o=e.type,l=e.frag,u=e.part,h=e.chunkMeta,d=h.buffering[o],c=self.performance.now();d.start=c;var f=l.stats.buffering,g=u?u.stats.buffering:null;0===f.start&&(f.start=c),g&&0===g.start&&(g.start=c);var v=a.audio,m=!1;"audio"===o&&"audio/mpeg"===(null==v?void 0:v.container)&&(m=!this.lastMpegAudioChunk||1===h.id||this.lastMpegAudioChunk.sn!==h.sn,this.lastMpegAudioChunk=h);var p=l.start,y={execute:function(){if(d.executeStart=self.performance.now(),m){var t=r.sourceBuffer[o];if(t){var e=p-t.timestampOffset;Math.abs(e)>=.1&&(r.log("Updating audio SourceBuffer timestampOffset to "+p+" (delta: "+e+") sn: "+l.sn+")"),t.timestampOffset=p)}}r.appendExecutor(s,o)},onStart:function(){},onComplete:function(){var t=self.performance.now();d.executeEnd=d.end=t,0===f.first&&(f.first=t),g&&0===g.first&&(g.first=t);var e=r.sourceBuffer,i={};for(var n in e)i[n]=Qr.getBuffered(e[n]);r.appendErrors[o]=0,"audio"===o||"video"===o?r.appendErrors.audiovideo=0:(r.appendErrors.audio=0,r.appendErrors.video=0),r.hls.trigger(S.BUFFER_APPENDED,{type:o,frag:l,part:u,chunkMeta:h,parent:l.type,timeRanges:i})},onError:function(t){var e={type:L.MEDIA_ERROR,parent:l.type,details:A.BUFFER_APPEND_ERROR,sourceBufferName:o,frag:l,part:u,chunkMeta:h,error:t,err:t,fatal:!1};if(t.code===DOMException.QUOTA_EXCEEDED_ERR)e.details=A.BUFFER_FULL_ERROR;else{var n=++r.appendErrors[o];e.details=A.BUFFER_APPEND_ERROR,r.warn("Failed "+n+"/"+i.config.appendErrorMaxRetry+' times to append segment in "'+o+'" sourceBuffer'),n>=i.config.appendErrorMaxRetry&&(e.fatal=!0)}i.trigger(S.ERROR,e)}};n.append(y,o,!!this.pendingTracks[o])},e.onBufferFlushing=function(t,e){var r=this,i=this.operationQueue,n=function(t){return{execute:r.removeExecutor.bind(r,t,e.startOffset,e.endOffset),onStart:function(){},onComplete:function(){r.hls.trigger(S.BUFFER_FLUSHED,{type:t})},onError:function(e){r.warn("Failed to remove from "+t+" SourceBuffer",e)}}};e.type?i.append(n(e.type),e.type):this.getSourceBufferTypes().forEach((function(t){i.append(n(t),t)}))},e.onFragParsed=function(t,e){var r=this,i=e.frag,n=e.part,a=[],s=n?n.elementaryStreams:i.elementaryStreams;s[U]?a.push("audiovideo"):(s[O]&&a.push("audio"),s[N]&&a.push("video")),0===a.length&&this.warn("Fragments must have at least one ElementaryStreamType set. type: "+i.type+" level: "+i.level+" sn: "+i.sn),this.blockBuffers((function(){var t=self.performance.now();i.stats.buffering.end=t,n&&(n.stats.buffering.end=t);var e=n?n.stats:i.stats;r.hls.trigger(S.FRAG_BUFFERED,{frag:i,part:n,stats:e,id:i.type})}),a)},e.onFragChanged=function(t,e){this.trimBuffers()},e.onBufferEos=function(t,e){var r=this;this.getSourceBufferTypes().reduce((function(t,i){var n=r.sourceBuffer[i];return!n||e.type&&e.type!==i||(n.ending=!0,n.ended||(n.ended=!0,r.log(i+" sourceBuffer now EOS"))),t&&!(n&&!n.ended)}),!0)&&(this.log("Queueing mediaSource.endOfStream()"),this.blockBuffers((function(){r.getSourceBufferTypes().forEach((function(t){var e=r.sourceBuffer[t];e&&(e.ending=!1)}));var t=r.mediaSource;t&&"open"===t.readyState?(r.log("Calling mediaSource.endOfStream()"),t.endOfStream()):t&&r.log("Could not call mediaSource.endOfStream(). mediaSource.readyState: "+t.readyState)})))},e.onLevelUpdated=function(t,e){var r=e.details;r.fragments.length&&(this.details=r,this.getSourceBufferTypes().length?this.blockBuffers(this.updateMediaElementDuration.bind(this)):this.updateMediaElementDuration())},e.trimBuffers=function(){var t=this.hls,e=this.details,r=this.media;if(r&&null!==e&&this.getSourceBufferTypes().length){var i=t.config,n=r.currentTime,a=e.levelTargetDuration,s=e.live&&null!==i.liveBackBufferLength?i.liveBackBufferLength:i.backBufferLength;if(y(s)&&s>0){var o=Math.max(s,a),l=Math.floor(n/a)*a-o;this.flushBackBuffer(n,a,l)}if(y(i.frontBufferFlushThreshold)&&i.frontBufferFlushThreshold>0){var u=Math.max(i.maxBufferLength,i.frontBufferFlushThreshold),h=Math.max(u,a),d=Math.floor(n/a)*a+h;this.flushFrontBuffer(n,a,d)}}},e.flushBackBuffer=function(t,e,r){var i=this,n=this.details,a=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(s){var o=a[s];if(o){var l=Qr.getBuffered(o);if(l.length>0&&r>l.start(0)){if(i.hls.trigger(S.BACK_BUFFER_REACHED,{bufferEnd:r}),null!=n&&n.live)i.hls.trigger(S.LIVE_BACK_BUFFER_REACHED,{bufferEnd:r});else if(o.ended&&l.end(l.length-1)-t<2*e)return void i.log("Cannot flush "+s+" back buffer while SourceBuffer is in ended state");i.hls.trigger(S.BUFFER_FLUSHING,{startOffset:0,endOffset:r,type:s})}}}))},e.flushFrontBuffer=function(t,e,r){var i=this,n=this.sourceBuffer;this.getSourceBufferTypes().forEach((function(a){var s=n[a];if(s){var o=Qr.getBuffered(s),l=o.length;if(l<2)return;var u=o.start(l-1),h=o.end(l-1);if(r>u||t>=u&&t<=h)return;if(s.ended&&t-h<2*e)return void i.log("Cannot flush "+a+" front buffer while SourceBuffer is in ended state");i.hls.trigger(S.BUFFER_FLUSHING,{startOffset:u,endOffset:1/0,type:a})}}))},e.updateMediaElementDuration=function(){if(this.details&&this.media&&this.mediaSource&&"open"===this.mediaSource.readyState){var t=this.details,e=this.hls,r=this.media,i=this.mediaSource,n=t.fragments[0].start+t.totalduration,a=r.duration,s=y(i.duration)?i.duration:0;t.live&&e.config.liveDurationInfinity?(i.duration=1/0,this.updateSeekableRange(t)):(n>s&&n>a||!y(a))&&(this.log("Updating Media Source duration to "+n.toFixed(3)),i.duration=n)}},e.updateSeekableRange=function(t){var e=this.mediaSource,r=t.fragments;if(r.length&&t.live&&null!=e&&e.setLiveSeekableRange){var i=Math.max(0,r[0].start),n=Math.max(i,i+t.totalduration);this.log("Media Source duration is set to "+e.duration+". Setting seekable range to "+i+"-"+n+"."),e.setLiveSeekableRange(i,n)}},e.checkPendingTracks=function(){var t=this.bufferCodecEventsExpected,e=this.operationQueue,r=this.pendingTracks,i=Object.keys(r).length;if(i&&(!t||2===i||"audiovideo"in r)){this.createSourceBuffers(r),this.pendingTracks={};var n=this.getSourceBufferTypes();if(n.length)this.hls.trigger(S.BUFFER_CREATED,{tracks:this.tracks}),n.forEach((function(t){e.executeNext(t)}));else{var a=new Error("could not create source buffer for media codec(s)");this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.BUFFER_INCOMPATIBLE_CODECS_ERROR,fatal:!0,error:a,reason:a.message})}}},e.createSourceBuffers=function(t){var e=this,r=this.sourceBuffer,i=this.mediaSource;if(!i)throw Error("createSourceBuffers called when mediaSource was null");var n=function(n){if(!r[n]){var a=t[n];if(!a)throw Error("source buffer exists for track "+n+", however track does not");var s=a.levelCodec||a.codec;s&&"audio"===n.slice(0,5)&&(s=he(s,e.appendSource));var o=a.container+";codecs="+s;e.log("creating sourceBuffer("+o+")");try{var l=r[n]=i.addSourceBuffer(o),u=n;e.addBufferListener(u,"updatestart",e._onSBUpdateStart),e.addBufferListener(u,"updateend",e._onSBUpdateEnd),e.addBufferListener(u,"error",e._onSBUpdateError),e.appendSource&&e.addBufferListener(u,"bufferedchange",(function(t,r){var i=r.removedRanges;null!=i&&i.length&&e.hls.trigger(S.BUFFER_FLUSHED,{type:n})})),e.tracks[n]={buffer:l,codec:s,container:a.container,levelCodec:a.levelCodec,metadata:a.metadata,id:a.id}}catch(t){e.error("error while trying to add sourceBuffer: "+t.message),e.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.BUFFER_ADD_CODEC_ERROR,fatal:!1,error:t,sourceBufferName:n,mimeType:o})}}};for(var a in t)n(a)},e._onSBUpdateStart=function(t){this.operationQueue.current(t).onStart()},e._onSBUpdateEnd=function(t){var e;if("closed"!==(null==(e=this.mediaSource)?void 0:e.readyState)){var r=this.operationQueue;r.current(t).onComplete(),r.shiftAndExecuteNext(t)}else this.resetBuffer(t)},e._onSBUpdateError=function(t,e){var r,i=new Error(t+" SourceBuffer error. MediaSource readyState: "+(null==(r=this.mediaSource)?void 0:r.readyState));this.error(""+i,e),this.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.BUFFER_APPENDING_ERROR,sourceBufferName:t,error:i,fatal:!1});var n=this.operationQueue.current(t);n&&n.onError(i)},e.removeExecutor=function(t,e,r){var i=this.media,n=this.mediaSource,a=this.operationQueue,s=this.sourceBuffer[t];if(!i||!n||!s)return this.warn("Attempting to remove from the "+t+" SourceBuffer, but it does not exist"),void a.shiftAndExecuteNext(t);var o=y(i.duration)?i.duration:1/0,l=y(n.duration)?n.duration:1/0,u=Math.max(0,e),h=Math.min(r,o,l);h>u&&(!s.ending||s.ended)?(s.ended=!1,this.log("Removing ["+u+","+h+"] from the "+t+" SourceBuffer"),s.remove(u,h)):a.shiftAndExecuteNext(t)},e.appendExecutor=function(t,e){var r=this.sourceBuffer[e];if(r)r.ended=!1,r.appendBuffer(t);else if(!this.pendingTracks[e])throw new Error("Attempting to append to the "+e+" SourceBuffer, but it does not exist")},e.blockBuffers=function(t,e){var r=this;if(void 0===e&&(e=this.getSourceBufferTypes()),!e.length)return this.log("Blocking operation requested, but no SourceBuffers exist"),void Promise.resolve().then(t);var i=this.operationQueue,n=e.map((function(t){return i.appendBlocker(t)}));Promise.all(n).then((function(){t(),e.forEach((function(t){var e=r.sourceBuffer[t];null!=e&&e.updating||i.shiftAndExecuteNext(t)}))}))},e.getSourceBufferTypes=function(){return Object.keys(this.sourceBuffer)},e.addBufferListener=function(t,e,r){var i=this.sourceBuffer[t];if(i){var n=r.bind(this,t);this.listeners[t].push({event:e,listener:n}),i.addEventListener(e,n)}},e.removeBufferListeners=function(t){var e=this.sourceBuffer[t];e&&this.listeners[t].forEach((function(t){e.removeEventListener(t.event,t.listener)}))},s(t,[{key:"mediaSrc",get:function(){var t,e=(null==(t=this.media)?void 0:t.firstChild)||this.media;return null==e?void 0:e.src}}]),t}();function $n(t){var e=t.querySelectorAll("source");[].slice.call(e).forEach((function(e){t.removeChild(e)}))}var Zn={42:225,92:233,94:237,95:243,96:250,123:231,124:247,125:209,126:241,127:9608,128:174,129:176,130:189,131:191,132:8482,133:162,134:163,135:9834,136:224,137:32,138:232,139:226,140:234,141:238,142:244,143:251,144:193,145:201,146:211,147:218,148:220,149:252,150:8216,151:161,152:42,153:8217,154:9473,155:169,156:8480,157:8226,158:8220,159:8221,160:192,161:194,162:199,163:200,164:202,165:203,166:235,167:206,168:207,169:239,170:212,171:217,172:249,173:219,174:171,175:187,176:195,177:227,178:205,179:204,180:236,181:210,182:242,183:213,184:245,185:123,186:125,187:92,188:94,189:95,190:124,191:8764,192:196,193:228,194:214,195:246,196:223,197:165,198:164,199:9475,200:197,201:229,202:216,203:248,204:9487,205:9491,206:9495,207:9499},ta=function(t){var e=t;return Zn.hasOwnProperty(t)&&(e=Zn[t]),String.fromCharCode(e)},ea=15,ra=100,ia={17:1,18:3,21:5,22:7,23:9,16:11,19:12,20:14},na={17:2,18:4,21:6,22:8,23:10,19:13,20:15},aa={25:1,26:3,29:5,30:7,31:9,24:11,27:12,28:14},sa={25:2,26:4,29:6,30:8,31:10,27:13,28:15},oa=["white","green","blue","cyan","red","yellow","magenta","black","transparent"],la=function(){function t(){this.time=null,this.verboseLevel=0}return t.prototype.log=function(t,e){if(this.verboseLevel>=t){var r="function"==typeof e?e():e;w.log(this.time+" ["+t+"] "+r)}},t}(),ua=function(t){for(var e=[],r=0;rra&&(this.logger.log(3,"Too large cursor position "+this.pos),this.pos=ra)},e.moveCursor=function(t){var e=this.pos+t;if(t>1)for(var r=this.pos+1;r=144&&this.backSpace();var r=ta(t);this.pos>=ra?this.logger.log(0,(function(){return"Cannot insert "+t.toString(16)+" ("+r+") at position "+e.pos+". Skipping it!"})):(this.chars[this.pos].setChar(r,this.currPenState),this.moveCursor(1))},e.clearFromPos=function(t){var e;for(e=t;e0&&(r=t?"["+e.join(" | ")+"]":e.join("\n")),r},e.getTextAndFormat=function(){return this.rows},t}(),ga=function(){function t(t,e,r){this.chNr=void 0,this.outputFilter=void 0,this.mode=void 0,this.verbose=void 0,this.displayedMemory=void 0,this.nonDisplayedMemory=void 0,this.lastOutputScreen=void 0,this.currRollUpRow=void 0,this.writeScreen=void 0,this.cueStartTime=void 0,this.logger=void 0,this.chNr=t,this.outputFilter=e,this.mode=null,this.verbose=0,this.displayedMemory=new fa(r),this.nonDisplayedMemory=new fa(r),this.lastOutputScreen=new fa(r),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null,this.logger=r}var e=t.prototype;return e.reset=function(){this.mode=null,this.displayedMemory.reset(),this.nonDisplayedMemory.reset(),this.lastOutputScreen.reset(),this.outputFilter.reset(),this.currRollUpRow=this.displayedMemory.rows[14],this.writeScreen=this.displayedMemory,this.mode=null,this.cueStartTime=null},e.getHandler=function(){return this.outputFilter},e.setHandler=function(t){this.outputFilter=t},e.setPAC=function(t){this.writeScreen.setPAC(t)},e.setBkgData=function(t){this.writeScreen.setBkgData(t)},e.setMode=function(t){t!==this.mode&&(this.mode=t,this.logger.log(2,(function(){return"MODE="+t})),"MODE_POP-ON"===this.mode?this.writeScreen=this.nonDisplayedMemory:(this.writeScreen=this.displayedMemory,this.writeScreen.reset()),"MODE_ROLL-UP"!==this.mode&&(this.displayedMemory.nrRollUpRows=null,this.nonDisplayedMemory.nrRollUpRows=null),this.mode=t)},e.insertChars=function(t){for(var e=this,r=0;r=46,e.italics)e.foreground="white";else{var r=Math.floor(t/2)-16;e.foreground=["white","green","blue","cyan","red","yellow","magenta"][r]}this.logger.log(2,"MIDROW: "+JSON.stringify(e)),this.writeScreen.setPen(e)},e.outputDataUpdate=function(t){void 0===t&&(t=!1);var e=this.logger.time;null!==e&&this.outputFilter&&(null!==this.cueStartTime||this.displayedMemory.isEmpty()?this.displayedMemory.equals(this.lastOutputScreen)||(this.outputFilter.newCue(this.cueStartTime,e,this.lastOutputScreen),t&&this.outputFilter.dispatchCue&&this.outputFilter.dispatchCue(),this.cueStartTime=this.displayedMemory.isEmpty()?null:e):this.cueStartTime=e,this.lastOutputScreen.copy(this.displayedMemory))},e.cueSplitAtTime=function(t){this.outputFilter&&(this.displayedMemory.isEmpty()||(this.outputFilter.newCue&&this.outputFilter.newCue(this.cueStartTime,t,this.displayedMemory),this.cueStartTime=t))},t}(),va=function(){function t(t,e,r){this.channels=void 0,this.currentChannel=0,this.cmdHistory={a:null,b:null},this.logger=void 0;var i=this.logger=new la;this.channels=[null,new ga(t,e,i),new ga(t+1,r,i)]}var e=t.prototype;return e.getHandler=function(t){return this.channels[t].getHandler()},e.setHandler=function(t,e){this.channels[t].setHandler(e)},e.addData=function(t,e){var r,i,n,a=!1;this.logger.time=t;for(var s=0;s ("+ua([i,n])+")"),(r=this.parseCmd(i,n))||(r=this.parseMidrow(i,n)),r||(r=this.parsePAC(i,n)),r||(r=this.parseBackgroundAttributes(i,n)),!r&&(a=this.parseChars(i,n))){var o=this.currentChannel;o&&o>0?this.channels[o].insertChars(a):this.logger.log(2,"No channel found yet. TEXT-MODE?")}r||a||this.logger.log(2,"Couldn't parse cleaned data "+ua([i,n])+" orig: "+ua([e[s],e[s+1]]))}},e.parseCmd=function(t,e){var r=this.cmdHistory;if(!((20===t||28===t||21===t||29===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=33&&e<=35))return!1;if(pa(t,e,r))return ma(null,null,r),this.logger.log(3,"Repeated command ("+ua([t,e])+") is dropped"),!0;var i=20===t||21===t||23===t?1:2,n=this.channels[i];return 20===t||21===t||28===t||29===t?32===e?n.ccRCL():33===e?n.ccBS():34===e?n.ccAOF():35===e?n.ccAON():36===e?n.ccDER():37===e?n.ccRU(2):38===e?n.ccRU(3):39===e?n.ccRU(4):40===e?n.ccFON():41===e?n.ccRDC():42===e?n.ccTR():43===e?n.ccRTD():44===e?n.ccEDM():45===e?n.ccCR():46===e?n.ccENM():47===e&&n.ccEOC():n.ccTO(e-32),ma(t,e,r),this.currentChannel=i,!0},e.parseMidrow=function(t,e){var r=0;if((17===t||25===t)&&e>=32&&e<=47){if((r=17===t?1:2)!==this.currentChannel)return this.logger.log(0,"Mismatch channel in midrow parsing"),!1;var i=this.channels[r];return!!i&&(i.ccMIDROW(e),this.logger.log(3,"MIDROW ("+ua([t,e])+")"),!0)}return!1},e.parsePAC=function(t,e){var r,i=this.cmdHistory;if(!((t>=17&&t<=23||t>=25&&t<=31)&&e>=64&&e<=127||(16===t||24===t)&&e>=64&&e<=95))return!1;if(pa(t,e,i))return ma(null,null,i),!0;var n=t<=23?1:2;r=e>=64&&e<=95?1===n?ia[t]:aa[t]:1===n?na[t]:sa[t];var a=this.channels[n];return!!a&&(a.setPAC(this.interpretPAC(r,e)),ma(t,e,i),this.currentChannel=n,!0)},e.interpretPAC=function(t,e){var r,i={color:null,italics:!1,indent:null,underline:!1,row:t};return r=e>95?e-96:e-64,i.underline=1==(1&r),r<=13?i.color=["white","green","blue","cyan","red","yellow","magenta","white"][Math.floor(r/2)]:r<=15?(i.italics=!0,i.color="white"):i.indent=4*Math.floor((r-16)/2),i},e.parseChars=function(t,e){var r,i,n=null,a=null;if(t>=25?(r=2,a=t-8):(r=1,a=t),a>=17&&a<=19?(i=17===a?e+80:18===a?e+112:e+144,this.logger.log(2,"Special char '"+ta(i)+"' in channel "+r),n=[i]):t>=32&&t<=127&&(n=0===e?[t]:[t,e]),n){var s=ua(n);this.logger.log(3,"Char codes = "+s.join(",")),ma(t,e,this.cmdHistory)}return n},e.parseBackgroundAttributes=function(t,e){var r;if(!((16===t||24===t)&&e>=32&&e<=47||(23===t||31===t)&&e>=45&&e<=47))return!1;var i={};16===t||24===t?(r=Math.floor((e-32)/2),i.background=oa[r],e%2==1&&(i.background=i.background+"_semi")):45===e?i.background="transparent":(i.foreground="black",47===e&&(i.underline=!0));var n=t<=23?1:2;return this.channels[n].setBkgData(i),ma(t,e,this.cmdHistory),!0},e.reset=function(){for(var t=0;tt)&&(this.startTime=t),this.endTime=e,this.screen=r,this.timelineController.createCaptionsTrack(this.trackName)},e.reset=function(){this.cueRanges=[],this.startTime=null},t}(),Ea=function(){if(null!=j&&j.VTTCue)return self.VTTCue;var t=["","lr","rl"],e=["start","middle","end","left","right"];function r(t,e){if("string"!=typeof e)return!1;if(!Array.isArray(t))return!1;var r=e.toLowerCase();return!!~t.indexOf(r)&&r}function i(t){return r(e,t)}function n(t){for(var e=arguments.length,r=new Array(e>1?e-1:0),i=1;i100)throw new Error("Position must be between 0 and 100.");E=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"positionAlign",n({},l,{get:function(){return T},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");T=e,this.hasBeenReset=!0}})),Object.defineProperty(o,"size",n({},l,{get:function(){return S},set:function(t){if(t<0||t>100)throw new Error("Size must be between 0 and 100.");S=t,this.hasBeenReset=!0}})),Object.defineProperty(o,"align",n({},l,{get:function(){return L},set:function(t){var e=i(t);if(!e)throw new SyntaxError("An invalid or illegal string was specified.");L=e,this.hasBeenReset=!0}})),o.displayState=void 0}return a.prototype.getCueAsHTML=function(){return self.WebVTT.convertCueToDOMTree(self,this.text)},a}(),Ta=function(){function t(){}return t.prototype.decode=function(t,e){if(!t)return"";if("string"!=typeof t)throw new Error("Error - expected string data.");return decodeURIComponent(encodeURIComponent(t))},t}();function Sa(t){function e(t,e,r,i){return 3600*(0|t)+60*(0|e)+(0|r)+parseFloat(i||0)}var r=t.match(/^(?:(\d+):)?(\d{2}):(\d{2})(\.\d+)?/);return r?parseFloat(r[2])>59?e(r[2],r[3],0,r[4]):e(r[1],r[2],r[3],r[4]):null}var La=function(){function t(){this.values=Object.create(null)}var e=t.prototype;return e.set=function(t,e){this.get(t)||""===e||(this.values[t]=e)},e.get=function(t,e,r){return r?this.has(t)?this.values[t]:e[r]:this.has(t)?this.values[t]:e},e.has=function(t){return t in this.values},e.alt=function(t,e,r){for(var i=0;i=0&&r<=100)return this.set(t,r),!0}return!1},t}();function Aa(t,e,r,i){var n=i?t.split(i):[t];for(var a in n)if("string"==typeof n[a]){var s=n[a].split(r);2===s.length&&e(s[0],s[1])}}var Ra=new Ea(0,0,""),ka="middle"===Ra.align?"middle":"center";function ba(t,e,r){var i=t;function n(){var e=Sa(t);if(null===e)throw new Error("Malformed timestamp: "+i);return t=t.replace(/^[^\sa-zA-Z-]+/,""),e}function a(){t=t.replace(/^\s+/,"")}if(a(),e.startTime=n(),a(),"--\x3e"!==t.slice(0,3))throw new Error("Malformed time stamp (time stamps must be separated by '--\x3e'): "+i);t=t.slice(3),a(),e.endTime=n(),a(),function(t,e){var i=new La;Aa(t,(function(t,e){var n;switch(t){case"region":for(var a=r.length-1;a>=0;a--)if(r[a].id===e){i.set(t,r[a].region);break}break;case"vertical":i.alt(t,e,["rl","lr"]);break;case"line":n=e.split(","),i.integer(t,n[0]),i.percent(t,n[0])&&i.set("snapToLines",!1),i.alt(t,n[0],["auto"]),2===n.length&&i.alt("lineAlign",n[1],["start",ka,"end"]);break;case"position":n=e.split(","),i.percent(t,n[0]),2===n.length&&i.alt("positionAlign",n[1],["start",ka,"end","line-left","line-right","auto"]);break;case"size":i.percent(t,e);break;case"align":i.alt(t,e,["start",ka,"end","left","right"])}}),/:/,/\s/),e.region=i.get("region",null),e.vertical=i.get("vertical","");var n=i.get("line","auto");"auto"===n&&-1===Ra.line&&(n=-1),e.line=n,e.lineAlign=i.get("lineAlign","start"),e.snapToLines=i.get("snapToLines",!0),e.size=i.get("size",100),e.align=i.get("align",ka);var a=i.get("position","auto");"auto"===a&&50===Ra.position&&(a="start"===e.align||"left"===e.align?0:"end"===e.align||"right"===e.align?100:50),e.position=a}(t,e)}function Da(t){return t.replace(//gi,"\n")}var Ia=function(){function t(){this.state="INITIAL",this.buffer="",this.decoder=new Ta,this.regionList=[],this.cue=null,this.oncue=void 0,this.onparsingerror=void 0,this.onflush=void 0}var e=t.prototype;return e.parse=function(t){var e=this;function r(){var t=e.buffer,r=0;for(t=Da(t);r>>0).toString()};function xa(t,e,r){return _a(t.toString())+_a(e.toString())+_a(r)}function Pa(t,e,r,i,n,a,s){var o,l,u,h=new Ia,d=Tt(new Uint8Array(t)).trim().replace(wa,"\n").split("\n"),c=[],f=e?(o=e.baseTime,void 0===(l=e.timescale)&&(l=1),pn(o,mn,1/l)):0,g="00:00.000",v=0,m=0,p=!0;h.oncue=function(t){var a=r[i],s=r.ccOffset,o=(v-f)/9e4;if(null!=a&&a.new&&(void 0!==m?s=r.ccOffset=a.start:function(t,e,r){var i=t[e],n=t[i.prevCC];if(!n||!n.new&&i.new)return t.ccOffset=t.presentationOffset=i.start,void(i.new=!1);for(;null!=(a=n)&&a.new;){var a;t.ccOffset+=i.start-n.start,i.new=!1,n=t[(i=n).prevCC]}t.presentationOffset=r}(r,i,o)),o){if(!e)return void(u=new Error("Missing initPTS for VTT MPEGTS"));s=o-r.presentationOffset}var l=t.endTime-t.startTime,h=Ln(9e4*(t.startTime+s-m),9e4*n)/9e4;t.startTime=Math.max(h,0),t.endTime=Math.max(h+l,0);var d=t.text.trim();t.text=decodeURIComponent(encodeURIComponent(d)),t.id||(t.id=xa(t.startTime,t.endTime,d)),t.endTime>0&&c.push(t)},h.onparsingerror=function(t){u=t},h.onflush=function(){u?s(u):a(c)},d.forEach((function(t){if(p){if(Ca(t,"X-TIMESTAMP-MAP=")){p=!1,t.slice(16).split(",").forEach((function(t){Ca(t,"LOCAL:")?g=t.slice(6):Ca(t,"MPEGTS:")&&(v=parseInt(t.slice(7)))}));try{m=function(t){var e=parseInt(t.slice(-3)),r=parseInt(t.slice(-6,-4)),i=parseInt(t.slice(-9,-7)),n=t.length>9?parseInt(t.substring(0,t.indexOf(":"))):0;if(!(y(e)&&y(r)&&y(i)&&y(n)))throw Error("Malformed X-TIMESTAMP-MAP: Local:"+t);return e+=1e3*r,(e+=6e4*i)+36e5*n}(g)/1e3}catch(t){u=t}return}""===t&&(p=!1)}h.parse(t+"\n")})),h.flush()}var Fa="stpp.ttml.im1t",Ma=/^(\d{2,}):(\d{2}):(\d{2}):(\d{2})\.?(\d+)?$/,Oa=/^(\d*(?:\.\d*)?)(h|m|s|ms|f|t)$/,Na={left:"start",center:"center",right:"end",start:"start",end:"end"};function Ua(t,e,r,i){var n=xt(new Uint8Array(t),["mdat"]);if(0!==n.length){var a,s,l,u,h=n.map((function(t){return Tt(t)})),d=(a=e.baseTime,s=1,void 0===(l=e.timescale)&&(l=1),void 0===u&&(u=!1),pn(a,s,1/l,u));try{h.forEach((function(t){return r(function(t,e){var r=(new DOMParser).parseFromString(t,"text/xml"),i=r.getElementsByTagName("tt")[0];if(!i)throw new Error("Invalid ttml");var n={frameRate:30,subFrameRate:1,frameRateMultiplier:0,tickRate:0},a=Object.keys(n).reduce((function(t,e){return t[e]=i.getAttribute("ttp:"+e)||n[e],t}),{}),s="preserve"!==i.getAttribute("xml:space"),l=Ga(Ba(i,"styling","style")),u=Ga(Ba(i,"layout","region")),h=Ba(i,"body","[begin]");return[].map.call(h,(function(t){var r=Ka(t,s);if(!r||!t.hasAttribute("begin"))return null;var i=Ya(t.getAttribute("begin"),a),n=Ya(t.getAttribute("dur"),a),h=Ya(t.getAttribute("end"),a);if(null===i)throw Va(t);if(null===h){if(null===n)throw Va(t);h=i+n}var d=new Ea(i-e,h-e,r);d.id=xa(d.startTime,d.endTime,d.text);var c=function(t,e,r){var i="http://www.w3.org/ns/ttml#styling",n=null,a=["displayAlign","textAlign","color","backgroundColor","fontSize","fontFamily"],s=null!=t&&t.hasAttribute("style")?t.getAttribute("style"):null;return s&&r.hasOwnProperty(s)&&(n=r[s]),a.reduce((function(r,a){var s=Ha(e,i,a)||Ha(t,i,a)||Ha(n,i,a);return s&&(r[a]=s),r}),{})}(u[t.getAttribute("region")],l[t.getAttribute("style")],l),f=c.textAlign;if(f){var g=Na[f];g&&(d.lineAlign=g),d.align=f}return o(d,c),d})).filter((function(t){return null!==t}))}(t,d))}))}catch(t){i(t)}}else i(new Error("Could not parse IMSC1 mdat"))}function Ba(t,e,r){var i=t.getElementsByTagName(e)[0];return i?[].slice.call(i.querySelectorAll(r)):[]}function Ga(t){return t.reduce((function(t,e){var r=e.getAttribute("xml:id");return r&&(t[r]=e),t}),{})}function Ka(t,e){return[].slice.call(t.childNodes).reduce((function(t,r,i){var n;return"br"===r.nodeName&&i?t+"\n":null!=(n=r.childNodes)&&n.length?Ka(r,e):e?t+r.textContent.trim().replace(/\s+/g," "):t+r.textContent}),"")}function Ha(t,e,r){return t&&t.hasAttributeNS(e,r)?t.getAttributeNS(e,r):null}function Va(t){return new Error("Could not parse ttml timestamp "+t)}function Ya(t,e){if(!t)return null;var r=Sa(t);return null===r&&(Ma.test(t)?r=function(t,e){var r=Ma.exec(t),i=(0|r[4])+(0|r[5])/e.subFrameRate;return 3600*(0|r[1])+60*(0|r[2])+(0|r[3])+i/e.frameRate}(t,e):Oa.test(t)&&(r=function(t,e){var r=Oa.exec(t),i=Number(r[1]);switch(r[2]){case"h":return 3600*i;case"m":return 60*i;case"ms":return 1e3*i;case"f":return i/e.frameRate;case"t":return i/e.tickRate}return i}(t,e))),r}var Wa=function(){function t(t){this.hls=void 0,this.media=null,this.config=void 0,this.enabled=!0,this.Cues=void 0,this.textTracks=[],this.tracks=[],this.initPTS=[],this.unparsedVttFrags=[],this.captionsTracks={},this.nonNativeCaptionsTracks={},this.cea608Parser1=void 0,this.cea608Parser2=void 0,this.lastCc=-1,this.lastSn=-1,this.lastPartIndex=-1,this.prevCC=-1,this.vttCCs={ccOffset:0,presentationOffset:0,0:{start:0,prevCC:-1,new:!0}},this.captionsProperties=void 0,this.hls=t,this.config=t.config,this.Cues=t.config.cueHandler,this.captionsProperties={textTrack1:{label:this.config.captionsTextTrack1Label,languageCode:this.config.captionsTextTrack1LanguageCode},textTrack2:{label:this.config.captionsTextTrack2Label,languageCode:this.config.captionsTextTrack2LanguageCode},textTrack3:{label:this.config.captionsTextTrack3Label,languageCode:this.config.captionsTextTrack3LanguageCode},textTrack4:{label:this.config.captionsTextTrack4Label,languageCode:this.config.captionsTextTrack4LanguageCode}},t.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.on(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.on(S.FRAG_LOADING,this.onFragLoading,this),t.on(S.FRAG_LOADED,this.onFragLoaded,this),t.on(S.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.on(S.FRAG_DECRYPTED,this.onFragDecrypted,this),t.on(S.INIT_PTS_FOUND,this.onInitPtsFound,this),t.on(S.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.on(S.BUFFER_FLUSHING,this.onBufferFlushing,this)}var e=t.prototype;return e.destroy=function(){var t=this.hls;t.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this),t.off(S.MEDIA_DETACHING,this.onMediaDetaching,this),t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.SUBTITLE_TRACKS_UPDATED,this.onSubtitleTracksUpdated,this),t.off(S.FRAG_LOADING,this.onFragLoading,this),t.off(S.FRAG_LOADED,this.onFragLoaded,this),t.off(S.FRAG_PARSING_USERDATA,this.onFragParsingUserdata,this),t.off(S.FRAG_DECRYPTED,this.onFragDecrypted,this),t.off(S.INIT_PTS_FOUND,this.onInitPtsFound,this),t.off(S.SUBTITLE_TRACKS_CLEARED,this.onSubtitleTracksCleared,this),t.off(S.BUFFER_FLUSHING,this.onBufferFlushing,this),this.hls=this.config=null,this.cea608Parser1=this.cea608Parser2=void 0},e.initCea608Parsers=function(){if(this.config.enableCEA708Captions&&(!this.cea608Parser1||!this.cea608Parser2)){var t=new ya(this,"textTrack1"),e=new ya(this,"textTrack2"),r=new ya(this,"textTrack3"),i=new ya(this,"textTrack4");this.cea608Parser1=new va(1,t,e),this.cea608Parser2=new va(3,r,i)}},e.addCues=function(t,e,r,i,n){for(var a,s,o,l,u=!1,h=n.length;h--;){var d=n[h],c=(a=d[0],s=d[1],o=e,l=r,Math.min(s,l)-Math.max(a,o));if(c>=0&&(d[0]=Math.min(d[0],e),d[1]=Math.max(d[1],r),u=!0,c/(r-e)>.5))return}if(u||n.push([e,r]),this.config.renderTextTracksNatively){var f=this.captionsTracks[t];this.Cues.newCue(f,e,r,i)}else{var g=this.Cues.newCue(null,e,r,i);this.hls.trigger(S.CUES_PARSED,{type:"captions",cues:g,track:t})}},e.onInitPtsFound=function(t,e){var r=this,i=e.frag,n=e.id,a=e.initPTS,s=e.timescale,o=this.unparsedVttFrags;"main"===n&&(this.initPTS[i.cc]={baseTime:a,timescale:s}),o.length&&(this.unparsedVttFrags=[],o.forEach((function(t){r.onFragLoaded(S.FRAG_LOADED,t)})))},e.getExistingTrack=function(t,e){var r=this.media;if(r)for(var i=0;ii.cc||l.trigger(S.SUBTITLE_FRAG_PROCESSED,{success:!1,frag:i,error:e})}))}else s.push(t)},e._fallbackToIMSC1=function(t,e){var r=this,i=this.tracks[t.level];i.textCodec||Ua(e,this.initPTS[t.cc],(function(){i.textCodec=Fa,r._parseIMSC1(t,e)}),(function(){i.textCodec="wvtt"}))},e._appendCues=function(t,e){var r=this.hls;if(this.config.renderTextTracksNatively){var i=this.textTracks[e];if(!i||"disabled"===i.mode)return;t.forEach((function(t){return Oe(i,t)}))}else{var n=this.tracks[e];if(!n)return;var a=n.default?"default":"subtitles"+e;r.trigger(S.CUES_PARSED,{type:"subtitles",cues:t,track:a})}},e.onFragDecrypted=function(t,e){e.frag.type===_e&&this.onFragLoaded(S.FRAG_LOADED,e)},e.onSubtitleTracksCleared=function(){this.tracks=[],this.captionsTracks={}},e.onFragParsingUserdata=function(t,e){this.initCea608Parsers();var r=this.cea608Parser1,i=this.cea608Parser2;if(this.enabled&&r&&i){var n=e.frag,a=e.samples;if(n.type!==we||"NONE"!==this.closedCaptionsForLevel(n))for(var s=0;sthis.autoLevelCapping&&this.streamController&&this.streamController.nextLevelSwitch(),this.autoLevelCapping=e.autoLevelCapping}}},e.getMaxLevel=function(e){var r=this,i=this.hls.levels;if(!i.length)return-1;var n=i.filter((function(t,i){return r.isLevelAllowed(t)&&i<=e}));return this.clientRect=null,t.getMaxLevelByMediaSize(n,this.mediaWidth,this.mediaHeight)},e.startCapping=function(){this.timer||(this.autoLevelCapping=Number.POSITIVE_INFINITY,self.clearInterval(this.timer),this.timer=self.setInterval(this.detectPlayerSize.bind(this),1e3),this.detectPlayerSize())},e.stopCapping=function(){this.restrictedLevels=[],this.firstLevel=-1,this.autoLevelCapping=Number.POSITIVE_INFINITY,this.timer&&(self.clearInterval(this.timer),this.timer=void 0)},e.getDimensions=function(){if(this.clientRect)return this.clientRect;var t=this.media,e={width:0,height:0};if(t){var r=t.getBoundingClientRect();e.width=r.width,e.height=r.height,e.width||e.height||(e.width=r.right-r.left||t.width||0,e.height=r.bottom-r.top||t.height||0)}return this.clientRect=e,e},e.isLevelAllowed=function(t){return!this.restrictedLevels.some((function(e){return t.bitrate===e.bitrate&&t.width===e.width&&t.height===e.height}))},t.getMaxLevelByMediaSize=function(t,e,r){if(null==t||!t.length)return-1;for(var i,n,a=t.length-1,s=Math.max(e,r),o=0;o=s||l.height>=s)&&(i=l,!(n=t[o+1])||i.width!==n.width||i.height!==n.height)){a=o;break}}return a},s(t,[{key:"mediaWidth",get:function(){return this.getDimensions().width*this.contentScaleFactor}},{key:"mediaHeight",get:function(){return this.getDimensions().height*this.contentScaleFactor}},{key:"contentScaleFactor",get:function(){var t=1;if(!this.hls.config.ignoreDevicePixelRatio)try{t=self.devicePixelRatio}catch(t){}return t}}]),t}(),za=function(){function t(t){this.hls=void 0,this.isVideoPlaybackQualityAvailable=!1,this.timer=void 0,this.media=null,this.lastTime=void 0,this.lastDroppedFrames=0,this.lastDecodedFrames=0,this.streamController=void 0,this.hls=t,this.registerListeners()}var e=t.prototype;return e.setStreamController=function(t){this.streamController=t},e.registerListeners=function(){this.hls.on(S.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.unregisterListeners=function(){this.hls.off(S.MEDIA_ATTACHING,this.onMediaAttaching,this)},e.destroy=function(){this.timer&&clearInterval(this.timer),this.unregisterListeners(),this.isVideoPlaybackQualityAvailable=!1,this.media=null},e.onMediaAttaching=function(t,e){var r=this.hls.config;if(r.capLevelOnFPSDrop){var i=e.media instanceof self.HTMLVideoElement?e.media:null;this.media=i,i&&"function"==typeof i.getVideoPlaybackQuality&&(this.isVideoPlaybackQualityAvailable=!0),self.clearInterval(this.timer),this.timer=self.setInterval(this.checkFPSInterval.bind(this),r.fpsDroppedMonitoringPeriod)}},e.checkFPS=function(t,e,r){var i=performance.now();if(e){if(this.lastTime){var n=i-this.lastTime,a=r-this.lastDroppedFrames,s=e-this.lastDecodedFrames,o=1e3*a/n,l=this.hls;if(l.trigger(S.FPS_DROP,{currentDropped:a,currentDecoded:s,totalDroppedFrames:r}),o>0&&a>l.config.fpsDroppedMonitoringThreshold*s){var u=l.currentLevel;w.warn("drop FPS ratio greater than max allowed value for currentLevel: "+u),u>0&&(-1===l.autoLevelCapping||l.autoLevelCapping>=u)&&(u-=1,l.trigger(S.FPS_DROP_LEVEL_CAPPING,{level:u,droppedLevel:l.currentLevel}),l.autoLevelCapping=u,this.streamController.nextLevelSwitch())}}this.lastTime=i,this.lastDroppedFrames=r,this.lastDecodedFrames=e}},e.checkFPSInterval=function(){var t=this.media;if(t)if(this.isVideoPlaybackQualityAvailable){var e=t.getVideoPlaybackQuality();this.checkFPS(t,e.totalVideoFrames,e.droppedVideoFrames)}else this.checkFPS(t,t.webkitDecodedFrameCount,t.webkitDroppedFrameCount)},t}(),Qa="[eme]",Ja=function(){function t(e){this.hls=void 0,this.config=void 0,this.media=null,this.keyFormatPromise=null,this.keySystemAccessPromises={},this._requestLicenseFailureCount=0,this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},this.setMediaKeysQueue=t.CDMCleanupPromise?[t.CDMCleanupPromise]:[],this.onMediaEncrypted=this._onMediaEncrypted.bind(this),this.onWaitingForKey=this._onWaitingForKey.bind(this),this.debug=w.debug.bind(w,Qa),this.log=w.log.bind(w,Qa),this.warn=w.warn.bind(w,Qa),this.error=w.error.bind(w,Qa),this.hls=e,this.config=e.config,this.registerListeners()}var e=t.prototype;return e.destroy=function(){this.unregisterListeners(),this.onMediaDetached();var t=this.config;t.requestMediaKeySystemAccessFunc=null,t.licenseXhrSetup=t.licenseResponseCallback=void 0,t.drmSystems=t.drmSystemOptions={},this.hls=this.onMediaEncrypted=this.onWaitingForKey=this.keyIdToKeySessionPromise=null,this.config=null},e.registerListeners=function(){this.hls.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.on(S.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.on(S.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.on(S.MANIFEST_LOADED,this.onManifestLoaded,this)},e.unregisterListeners=function(){this.hls.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),this.hls.off(S.MEDIA_DETACHED,this.onMediaDetached,this),this.hls.off(S.MANIFEST_LOADING,this.onManifestLoading,this),this.hls.off(S.MANIFEST_LOADED,this.onManifestLoaded,this)},e.getLicenseServerUrl=function(t){var e=this.config,r=e.drmSystems,i=e.widevineLicenseUrl,n=r[t];if(n)return n.licenseUrl;if(t===q.WIDEVINE&&i)return i;throw new Error('no license server URL configured for key-system "'+t+'"')},e.getServerCertificateUrl=function(t){var e=this.config.drmSystems[t];if(e)return e.serverCertificateUrl;this.log('No Server Certificate in config.drmSystems["'+t+'"]')},e.attemptKeySystemAccess=function(t){var e=this,r=this.hls.levels,i=function(t,e,r){return!!t&&r.indexOf(t)===e},n=r.map((function(t){return t.audioCodec})).filter(i),a=r.map((function(t){return t.videoCodec})).filter(i);return n.length+a.length===0&&a.push("avc1.42e01e"),new Promise((function(r,i){!function t(s){var o=s.shift();e.getMediaKeysPromise(o,n,a).then((function(t){return r({keySystem:o,mediaKeys:t})})).catch((function(e){s.length?t(s):i(e instanceof rs?e:new rs({type:L.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_ACCESS,error:e,fatal:!0},e.message))}))}(t)}))},e.requestMediaKeySystemAccess=function(t,e){var r=this.config.requestMediaKeySystemAccessFunc;if("function"!=typeof r){var i="Configured requestMediaKeySystemAccess is not a function "+r;return null===it&&"http:"===self.location.protocol&&(i="navigator.requestMediaKeySystemAccess is not available over insecure protocol "+location.protocol),Promise.reject(new Error(i))}return r(t,e)},e.getMediaKeysPromise=function(t,e,r){var i=this,n=function(t,e,r,i){var n;switch(t){case q.FAIRPLAY:n=["cenc","sinf"];break;case q.WIDEVINE:case q.PLAYREADY:n=["cenc"];break;case q.CLEARKEY:n=["cenc","keyids"];break;default:throw new Error("Unknown key-system: "+t)}return function(t,e,r,i){return[{initDataTypes:t,persistentState:i.persistentState||"optional",distinctiveIdentifier:i.distinctiveIdentifier||"optional",sessionTypes:i.sessionTypes||[i.sessionType||"temporary"],audioCapabilities:e.map((function(t){return{contentType:'audio/mp4; codecs="'+t+'"',robustness:i.audioRobustness||"",encryptionScheme:i.audioEncryptionScheme||null}})),videoCapabilities:r.map((function(t){return{contentType:'video/mp4; codecs="'+t+'"',robustness:i.videoRobustness||"",encryptionScheme:i.videoEncryptionScheme||null}}))}]}(n,e,r,i)}(t,e,r,this.config.drmSystemOptions),a=this.keySystemAccessPromises[t],s=null==a?void 0:a.keySystemAccess;if(!s){this.log('Requesting encrypted media "'+t+'" key-system access with config: '+JSON.stringify(n)),s=this.requestMediaKeySystemAccess(t,n);var o=this.keySystemAccessPromises[t]={keySystemAccess:s};return s.catch((function(e){i.log('Failed to obtain access to key-system "'+t+'": '+e)})),s.then((function(e){i.log('Access for key-system "'+e.keySystem+'" obtained');var r=i.fetchServerCertificate(t);return i.log('Create media-keys for "'+t+'"'),o.mediaKeys=e.createMediaKeys().then((function(e){return i.log('Media-keys created for "'+t+'"'),r.then((function(r){return r?i.setMediaKeysServerCertificate(e,t,r):e}))})),o.mediaKeys.catch((function(e){i.error('Failed to create media-keys for "'+t+'"}: '+e)})),o.mediaKeys}))}return s.then((function(){return a.mediaKeys}))},e.createMediaKeySessionContext=function(t){var e=t.decryptdata,r=t.keySystem,i=t.mediaKeys;this.log('Creating key-system session "'+r+'" keyId: '+Lt(e.keyId||[]));var n=i.createSession(),a={decryptdata:e,keySystem:r,mediaKeys:i,mediaKeysSession:n,keyStatus:"status-pending"};return this.mediaKeySessions.push(a),a},e.renewKeySession=function(t){var e=t.decryptdata;if(e.pssh){var r=this.createMediaKeySessionContext(t),i=this.getKeyIdString(e);this.keyIdToKeySessionPromise[i]=this.generateRequestWithPreferredKeySession(r,"cenc",e.pssh,"expired")}else this.warn("Could not renew expired session. Missing pssh initData.");this.removeSession(t)},e.getKeyIdString=function(t){if(!t)throw new Error("Could not read keyId of undefined decryptdata");if(null===t.keyId)throw new Error("keyId is null");return Lt(t.keyId)},e.updateKeySession=function(t,e){var r,i=t.mediaKeysSession;return this.log('Updating key-session "'+i.sessionId+'" for keyID '+Lt((null==(r=t.decryptdata)?void 0:r.keyId)||[])+"\n } (data length: "+(e?e.byteLength:e)+")"),i.update(e)},e.selectKeySystemFormat=function(t){var e=Object.keys(t.levelkeys||{});return this.keyFormatPromise||(this.log("Selecting key-system from fragment (sn: "+t.sn+" "+t.type+": "+t.level+") key formats "+e.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(e)),this.keyFormatPromise},e.getKeyFormatPromise=function(t){var e=this;return new Promise((function(r,i){var n=et(e.config),a=t.map($).filter((function(t){return!!t&&-1!==n.indexOf(t)}));return e.getKeySystemSelectionPromise(a).then((function(t){var e=t.keySystem,n=tt(e);n?r(n):i(new Error('Unable to find format for key-system "'+e+'"'))})).catch(i)}))},e.loadKey=function(t){var e=this,r=t.keyInfo.decryptdata,i=this.getKeyIdString(r),n="(keyId: "+i+' format: "'+r.keyFormat+'" method: '+r.method+" uri: "+r.uri+")";this.log("Starting session for key "+n);var a=this.keyIdToKeySessionPromise[i];return a||(a=this.keyIdToKeySessionPromise[i]=this.getKeySystemForKeyPromise(r).then((function(i){var a=i.keySystem,s=i.mediaKeys;return e.throwIfDestroyed(),e.log("Handle encrypted media sn: "+t.frag.sn+" "+t.frag.type+": "+t.frag.level+" using key "+n),e.attemptSetMediaKeys(a,s).then((function(){e.throwIfDestroyed();var t=e.createMediaKeySessionContext({keySystem:a,mediaKeys:s,decryptdata:r});return e.generateRequestWithPreferredKeySession(t,"cenc",r.pssh,"playlist-key")}))}))).catch((function(t){return e.handleError(t)})),a},e.throwIfDestroyed=function(t){if(!this.hls)throw new Error("invalid state")},e.handleError=function(t){this.hls&&(this.error(t.message),t instanceof rs?this.hls.trigger(S.ERROR,t.data):this.hls.trigger(S.ERROR,{type:L.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_KEYS,error:t,fatal:!0}))},e.getKeySystemForKeyPromise=function(t){var e=this.getKeyIdString(t),r=this.keyIdToKeySessionPromise[e];if(!r){var i=$(t.keyFormat),n=i?[i]:et(this.config);return this.attemptKeySystemAccess(n)}return r},e.getKeySystemSelectionPromise=function(t){if(t.length||(t=et(this.config)),0===t.length)throw new rs({type:L.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_NO_CONFIGURED_LICENSE,fatal:!0},"Missing key-system license configuration options "+JSON.stringify({drmSystems:this.config.drmSystems}));return this.attemptKeySystemAccess(t)},e._onMediaEncrypted=function(t){var e=this,r=t.initDataType,i=t.initData;if(this.debug('"'+t.type+'" event: init data type: "'+r+'"'),null!==i){var n,a;if("sinf"===r&&this.config.drmSystems[q.FAIRPLAY]){var s=bt(new Uint8Array(i));try{var o=V(JSON.parse(s).sinf),l=Bt(new Uint8Array(o));if(!l)return;n=l.subarray(8,24),a=q.FAIRPLAY}catch(t){return void this.warn('Failed to parse sinf "encrypted" event message initData')}}else{var u=function(t){if(!(t instanceof ArrayBuffer)||t.byteLength<32)return null;var e={version:0,systemId:"",kids:null,data:null},r=new DataView(t),i=r.getUint32(0);if(t.byteLength!==i&&i>44)return null;if(1886614376!==r.getUint32(4))return null;if(e.version=r.getUint32(8)>>>24,e.version>1)return null;e.systemId=Lt(new Uint8Array(t,12,16));var n=r.getUint32(28);if(0===e.version){if(i-320)for(var a,s=0,o=n.length;s in key message");return W(atob(f))},e.setupLicenseXHR=function(t,e,r,i){var n=this,a=this.config.licenseXhrSetup;return a?Promise.resolve().then((function(){if(!r.decryptdata)throw new Error("Key removed");return a.call(n.hls,t,e,r,i)})).catch((function(s){if(!r.decryptdata)throw s;return t.open("POST",e,!0),a.call(n.hls,t,e,r,i)})).then((function(r){return t.readyState||t.open("POST",e,!0),{xhr:t,licenseChallenge:r||i}})):(t.open("POST",e,!0),Promise.resolve({xhr:t,licenseChallenge:i}))},e.requestLicense=function(t,e){var r=this,i=this.config.keyLoadPolicy.default;return new Promise((function(n,a){var s=r.getLicenseServerUrl(t.keySystem);r.log("Sending license request to URL: "+s);var o=new XMLHttpRequest;o.responseType="arraybuffer",o.onreadystatechange=function(){if(!r.hls||!t.mediaKeysSession)return a(new Error("invalid state"));if(4===o.readyState)if(200===o.status){r._requestLicenseFailureCount=0;var l=o.response;r.log("License received "+(l instanceof ArrayBuffer?l.byteLength:l));var u=r.config.licenseResponseCallback;if(u)try{l=u.call(r.hls,o,s,t)}catch(t){r.error(t)}n(l)}else{var h=i.errorRetry,d=h?h.maxNumRetry:0;if(r._requestLicenseFailureCount++,r._requestLicenseFailureCount>d||o.status>=400&&o.status<500)a(new rs({type:L.KEY_SYSTEM_ERROR,details:A.KEY_SYSTEM_LICENSE_REQUEST_FAILED,fatal:!0,networkDetails:o,response:{url:s,data:void 0,code:o.status,text:o.statusText}},"License Request XHR failed ("+s+"). Status: "+o.status+" ("+o.statusText+")"));else{var c=d-r._requestLicenseFailureCount+1;r.warn("Retrying license request, "+c+" attempts left"),r.requestLicense(t,e).then(n,a)}}},t.licenseXhr&&t.licenseXhr.readyState!==XMLHttpRequest.DONE&&t.licenseXhr.abort(),t.licenseXhr=o,r.setupLicenseXHR(o,s,t,e).then((function(e){var i=e.xhr,n=e.licenseChallenge;t.keySystem==q.PLAYREADY&&(n=r.unpackPlayReadyKeyMessage(i,n)),i.send(n)}))}))},e.onMediaAttached=function(t,e){if(this.config.emeEnabled){var r=e.media;this.media=r,r.addEventListener("encrypted",this.onMediaEncrypted),r.addEventListener("waitingforkey",this.onWaitingForKey)}},e.onMediaDetached=function(){var e=this,r=this.media,i=this.mediaKeySessions;r&&(r.removeEventListener("encrypted",this.onMediaEncrypted),r.removeEventListener("waitingforkey",this.onWaitingForKey),this.media=null),this._requestLicenseFailureCount=0,this.setMediaKeysQueue=[],this.mediaKeySessions=[],this.keyIdToKeySessionPromise={},Xt.clearKeyUriToKeyIdMap();var n=i.length;t.CDMCleanupPromise=Promise.all(i.map((function(t){return e.removeSession(t)})).concat(null==r?void 0:r.setMediaKeys(null).catch((function(t){e.log("Could not clear media keys: "+t)})))).then((function(){n&&(e.log("finished closing key sessions and clearing media keys"),i.length=0)})).catch((function(t){e.log("Could not close sessions and clear media keys: "+t)}))},e.onManifestLoading=function(){this.keyFormatPromise=null},e.onManifestLoaded=function(t,e){var r=e.sessionKeys;if(r&&this.config.emeEnabled&&!this.keyFormatPromise){var i=r.reduce((function(t,e){return-1===t.indexOf(e.keyFormat)&&t.push(e.keyFormat),t}),[]);this.log("Selecting key-system from session-keys "+i.join(", ")),this.keyFormatPromise=this.getKeyFormatPromise(i)}},e.removeSession=function(t){var e=this,r=t.mediaKeysSession,i=t.licenseXhr;if(r){this.log("Remove licenses and keys and close session "+r.sessionId),t._onmessage&&(r.removeEventListener("message",t._onmessage),t._onmessage=void 0),t._onkeystatuseschange&&(r.removeEventListener("keystatuseschange",t._onkeystatuseschange),t._onkeystatuseschange=void 0),i&&i.readyState!==XMLHttpRequest.DONE&&i.abort(),t.mediaKeysSession=t.decryptdata=t.licenseXhr=void 0;var n=this.mediaKeySessions.indexOf(t);return n>-1&&this.mediaKeySessions.splice(n,1),r.remove().catch((function(t){e.log("Could not remove session: "+t)})).then((function(){return r.close()})).catch((function(t){e.log("Could not close session: "+t)}))}},t}();Ja.CDMCleanupPromise=void 0;var $a,Za,ts,es,rs=function(t){function e(e,r){var i;return(i=t.call(this,r)||this).data=void 0,e.error||(e.error=new Error(r)),i.data=e,e.err=e.error,i}return l(e,t),e}(c(Error));!function(t){t.MANIFEST="m",t.AUDIO="a",t.VIDEO="v",t.MUXED="av",t.INIT="i",t.CAPTION="c",t.TIMED_TEXT="tt",t.KEY="k",t.OTHER="o"}($a||($a={})),function(t){t.DASH="d",t.HLS="h",t.SMOOTH="s",t.OTHER="o"}(Za||(Za={})),function(t){t.OBJECT="CMCD-Object",t.REQUEST="CMCD-Request",t.SESSION="CMCD-Session",t.STATUS="CMCD-Status"}(ts||(ts={}));var is=((es={})[ts.OBJECT]=["br","d","ot","tb"],es[ts.REQUEST]=["bl","dl","mtp","nor","nrr","su"],es[ts.SESSION]=["cid","pr","sf","sid","st","v"],es[ts.STATUS]=["bs","rtp"],es),ns=function t(e,r){this.value=void 0,this.params=void 0,Array.isArray(e)&&(e=e.map((function(e){return e instanceof t?e:new t(e)}))),this.value=e,this.params=r},as=function(t){this.description=void 0,this.description=t},ss="Dict";function os(t,e,r,i){return new Error("failed to "+t+' "'+(n=e,(Array.isArray(n)?JSON.stringify(n):n instanceof Map?"Map{}":n instanceof Set?"Set{}":"object"==typeof n?JSON.stringify(n):String(n))+'" as ')+r,{cause:i});var n}var ls="Bare Item",us="Boolean",hs="Byte Sequence",ds="Decimal",cs="Integer",fs=/[\x00-\x1f\x7f]+/,gs="Token",vs="Key";function ms(t,e,r){return os("serialize",t,e,r)}function ps(t){if(!1===ArrayBuffer.isView(t))throw ms(t,hs);return":"+(e=t,btoa(String.fromCharCode.apply(String,e))+":");var e}function ys(t){if(function(t){return t<-999999999999999||99999999999999912)throw ms(t,ds);var r=e.toString();return r.includes(".")?r:r+".0"}var Ss="String";function Ls(t){var e,r=(e=t).description||e.toString().slice(7,-1);if(!1===/^([a-zA-Z*])([!#$%&'*+\-.^_`|~\w:/]*)$/.test(r))throw ms(r,gs);return r}function As(t){switch(typeof t){case"number":if(!y(t))throw ms(t,ls);return Number.isInteger(t)?ys(t):Ts(t);case"string":return function(t){if(fs.test(t))throw ms(t,Ss);return'"'+t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')+'"'}(t);case"symbol":return Ls(t);case"boolean":return function(t){if("boolean"!=typeof t)throw ms(t,us);return t?"?1":"?0"}(t);case"object":if(t instanceof Date)return function(t){return"@"+ys(t.getTime()/1e3)}(t);if(t instanceof Uint8Array)return ps(t);if(t instanceof as)return Ls(t);default:throw ms(t,ls)}}function Rs(t){if(!1===/^[a-z*][a-z0-9\-_.*]*$/.test(t))throw ms(t,vs);return t}function ks(t){return null==t?"":Object.entries(t).map((function(t){var e=t[0],r=t[1];return!0===r?";"+Rs(e):";"+Rs(e)+"="+As(r)})).join("")}function bs(t){return t instanceof ns?""+As(t.value)+ks(t.params):As(t)}function Ds(t,e){var r;if(void 0===e&&(e={whitespace:!0}),"object"!=typeof t)throw ms(t,ss);var i=t instanceof Map?t.entries():Object.entries(t),n=null!=(r=e)&&r.whitespace?" ":"";return Array.from(i).map((function(t){var e=t[0],r=t[1];r instanceof ns==0&&(r=new ns(r));var i,n=Rs(e);return!0===r.value?n+=ks(r.params):(n+="=",Array.isArray(r.value)?n+="("+(i=r).value.map(bs).join(" ")+")"+ks(i.params):n+=bs(r)),n})).join(","+n)}var Is=function(t){return"ot"===t||"sf"===t||"st"===t},ws=function(t){return"number"==typeof t?y(t):null!=t&&""!==t&&!1!==t},Cs=function(t){return Math.round(t)},_s=function(t){return 100*Cs(t/100)},xs={br:Cs,d:Cs,bl:_s,dl:_s,mtp:_s,nor:function(t,e){return null!=e&&e.baseUrl&&(t=function(t,e){var r=new URL(t),i=new URL(e);if(r.origin!==i.origin)return t;for(var n=r.pathname.split("/").slice(1),a=i.pathname.split("/").slice(1,-1);n[0]===a[0];)n.shift(),a.shift();for(;a.length;)a.shift(),n.unshift("..");return n.join("/")}(t,e.baseUrl)),encodeURIComponent(t)},rtp:_s,tb:Cs};function Ps(t,e){return void 0===e&&(e={}),t?function(t,e){return Ds(t,e)}(function(t,e){var r={};if(null==t||"object"!=typeof t)return r;var i=Object.keys(t).sort(),n=o({},xs,null==e?void 0:e.formatters),a=null==e?void 0:e.filter;return i.forEach((function(i){if(null==a||!a(i)){var s=t[i],o=n[i];o&&(s=o(s,e)),"v"===i&&1===s||"pr"==i&&1===s||ws(s)&&(Is(i)&&"string"==typeof s&&(s=new as(s)),r[i]=s)}})),r}(t,e),o({whitespace:!1},e)):""}function Fs(t,e,r){return o(t,function(t,e){var r;if(void 0===e&&(e={}),!t)return{};var i=Object.entries(t),n=Object.entries(is).concat(Object.entries((null==(r=e)?void 0:r.customHeaderMap)||{})),a=i.reduce((function(t,e){var r,i=e[0],a=e[1],s=(null==(r=n.find((function(t){return t[1].includes(i)})))?void 0:r[0])||ts.REQUEST;return null!=t[s]||(t[s]={}),t[s][i]=a,t}),{});return Object.entries(a).reduce((function(t,r){var i=r[0],n=r[1];return t[i]=Ps(n,e),t}),{})}(e,r))}var Ms="CMCD",Os=/CMCD=[^&#]+/;function Ns(t,e,r){var i=function(t,e){if(void 0===e&&(e={}),!t)return"";var r=Ps(t,e);return Ms+"="+encodeURIComponent(r)}(e,r);if(!i)return t;if(Os.test(t))return t.replace(Os,i);var n=t.includes("?")?"&":"?";return""+t+n+i}var Us=function(){function t(t){var e=this;this.hls=void 0,this.config=void 0,this.media=void 0,this.sid=void 0,this.cid=void 0,this.useHeaders=!1,this.includeKeys=void 0,this.initialized=!1,this.starved=!1,this.buffering=!0,this.audioBuffer=void 0,this.videoBuffer=void 0,this.onWaiting=function(){e.initialized&&(e.starved=!0),e.buffering=!0},this.onPlaying=function(){e.initialized||(e.initialized=!0),e.buffering=!1},this.applyPlaylistData=function(t){try{e.apply(t,{ot:$a.MANIFEST,su:!e.initialized})}catch(t){w.warn("Could not generate manifest CMCD data.",t)}},this.applyFragmentData=function(t){try{var r=t.frag,i=e.hls.levels[r.level],n=e.getObjectType(r),a={d:1e3*r.duration,ot:n};n!==$a.VIDEO&&n!==$a.AUDIO&&n!=$a.MUXED||(a.br=i.bitrate/1e3,a.tb=e.getTopBandwidth(n)/1e3,a.bl=e.getBufferLength(n)),e.apply(t,a)}catch(t){w.warn("Could not generate segment CMCD data.",t)}},this.hls=t;var r=this.config=t.config,i=r.cmcd;null!=i&&(r.pLoader=this.createPlaylistLoader(),r.fLoader=this.createFragmentLoader(),this.sid=i.sessionId||function(){try{return crypto.randomUUID()}catch(i){try{var t=URL.createObjectURL(new Blob),e=t.toString();return URL.revokeObjectURL(t),e.slice(e.lastIndexOf("/")+1)}catch(t){var r=(new Date).getTime();return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=(r+16*Math.random())%16|0;return r=Math.floor(r/16),("x"==t?e:3&e|8).toString(16)}))}}}(),this.cid=i.contentId,this.useHeaders=!0===i.useHeaders,this.includeKeys=i.includeKeys,this.registerListeners())}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.on(S.MEDIA_DETACHED,this.onMediaDetached,this),t.on(S.BUFFER_CREATED,this.onBufferCreated,this)},e.unregisterListeners=function(){var t=this.hls;t.off(S.MEDIA_ATTACHED,this.onMediaAttached,this),t.off(S.MEDIA_DETACHED,this.onMediaDetached,this),t.off(S.BUFFER_CREATED,this.onBufferCreated,this)},e.destroy=function(){this.unregisterListeners(),this.onMediaDetached(),this.hls=this.config=this.audioBuffer=this.videoBuffer=null,this.onWaiting=this.onPlaying=null},e.onMediaAttached=function(t,e){this.media=e.media,this.media.addEventListener("waiting",this.onWaiting),this.media.addEventListener("playing",this.onPlaying)},e.onMediaDetached=function(){this.media&&(this.media.removeEventListener("waiting",this.onWaiting),this.media.removeEventListener("playing",this.onPlaying),this.media=null)},e.onBufferCreated=function(t,e){var r,i;this.audioBuffer=null==(r=e.tracks.audio)?void 0:r.buffer,this.videoBuffer=null==(i=e.tracks.video)?void 0:i.buffer},e.createData=function(){var t;return{v:1,sf:Za.HLS,sid:this.sid,cid:this.cid,pr:null==(t=this.media)?void 0:t.playbackRate,mtp:this.hls.bandwidthEstimate/1e3}},e.apply=function(t,e){void 0===e&&(e={}),o(e,this.createData());var r=e.ot===$a.INIT||e.ot===$a.VIDEO||e.ot===$a.MUXED;this.starved&&r&&(e.bs=!0,e.su=!0,this.starved=!1),null==e.su&&(e.su=this.buffering);var i=this.includeKeys;i&&(e=Object.keys(e).reduce((function(t,r){return i.includes(r)&&(t[r]=e[r]),t}),{})),this.useHeaders?(t.headers||(t.headers={}),Fs(t.headers,e)):t.url=Ns(t.url,e)},e.getObjectType=function(t){var e=t.type;return"subtitle"===e?$a.TIMED_TEXT:"initSegment"===t.sn?$a.INIT:"audio"===e?$a.AUDIO:"main"===e?this.hls.audioTracks.length?$a.VIDEO:$a.MUXED:void 0},e.getTopBandwidth=function(t){var e,r=0,i=this.hls;if(t===$a.AUDIO)e=i.audioTracks;else{var n=i.maxAutoLevel,a=n>-1?n+1:i.levels.length;e=i.levels.slice(0,a)}for(var s,o=g(e);!(s=o()).done;){var l=s.value;l.bitrate>r&&(r=l.bitrate)}return r>0?r:NaN},e.getBufferLength=function(t){var e=this.hls.media,r=t===$a.AUDIO?this.audioBuffer:this.videoBuffer;return r&&e?1e3*Qr.bufferInfo(r,e.currentTime,this.config.maxBufferHole).len:NaN},e.createPlaylistLoader=function(){var t=this.config.pLoader,e=this.applyPlaylistData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i=t.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(t,r,i){e(t),this.loader.load(t,r,i)},s(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},e.createFragmentLoader=function(){var t=this.config.fLoader,e=this.applyFragmentData,r=t||this.config.loader;return function(){function t(t){this.loader=void 0,this.loader=new r(t)}var i=t.prototype;return i.destroy=function(){this.loader.destroy()},i.abort=function(){this.loader.abort()},i.load=function(t,r,i){e(t),this.loader.load(t,r,i)},s(t,[{key:"stats",get:function(){return this.loader.stats}},{key:"context",get:function(){return this.loader.context}}]),t}()},t}(),Bs=function(){function t(t){this.hls=void 0,this.log=void 0,this.loader=null,this.uri=null,this.pathwayId=".",this.pathwayPriority=null,this.timeToLoad=300,this.reloadTimer=-1,this.updated=0,this.started=!1,this.enabled=!0,this.levels=null,this.audioTracks=null,this.subtitleTracks=null,this.penalizedPathways={},this.hls=t,this.log=w.log.bind(w,"[content-steering]:"),this.registerListeners()}var e=t.prototype;return e.registerListeners=function(){var t=this.hls;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.MANIFEST_PARSED,this.onManifestParsed,this),t.on(S.ERROR,this.onError,this)},e.unregisterListeners=function(){var t=this.hls;t&&(t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.MANIFEST_PARSED,this.onManifestParsed,this),t.off(S.ERROR,this.onError,this))},e.startLoad=function(){if(this.started=!0,this.clearTimeout(),this.enabled&&this.uri){if(this.updated){var t=1e3*this.timeToLoad-(performance.now()-this.updated);if(t>0)return void this.scheduleRefresh(this.uri,t)}this.loadSteeringManifest(this.uri)}},e.stopLoad=function(){this.started=!1,this.loader&&(this.loader.destroy(),this.loader=null),this.clearTimeout()},e.clearTimeout=function(){-1!==this.reloadTimer&&(self.clearTimeout(this.reloadTimer),this.reloadTimer=-1)},e.destroy=function(){this.unregisterListeners(),this.stopLoad(),this.hls=null,this.levels=this.audioTracks=this.subtitleTracks=null},e.removeLevel=function(t){var e=this.levels;e&&(this.levels=e.filter((function(e){return e!==t})))},e.onManifestLoading=function(){this.stopLoad(),this.enabled=!0,this.timeToLoad=300,this.updated=0,this.uri=null,this.pathwayId=".",this.levels=this.audioTracks=this.subtitleTracks=null},e.onManifestLoaded=function(t,e){var r=e.contentSteering;null!==r&&(this.pathwayId=r.pathwayId,this.uri=r.uri,this.started&&this.startLoad())},e.onManifestParsed=function(t,e){this.audioTracks=e.audioTracks,this.subtitleTracks=e.subtitleTracks},e.onError=function(t,e){var r=e.errorAction;if((null==r?void 0:r.action)===Sr&&r.flags===kr){var i=this.levels,n=this.pathwayPriority,a=this.pathwayId;if(e.context){var s=e.context,o=s.groupId,l=s.pathwayId,u=s.type;o&&i?a=this.getPathwayForGroupId(o,u,a):l&&(a=l)}a in this.penalizedPathways||(this.penalizedPathways[a]=performance.now()),!n&&i&&(n=i.reduce((function(t,e){return-1===t.indexOf(e.pathwayId)&&t.push(e.pathwayId),t}),[])),n&&n.length>1&&(this.updatePathwayPriority(n),r.resolved=this.pathwayId!==a),r.resolved||w.warn("Could not resolve "+e.details+' ("'+e.error.message+'") with content-steering for Pathway: '+a+" levels: "+(i?i.length:i)+" priorities: "+JSON.stringify(n)+" penalized: "+JSON.stringify(this.penalizedPathways))}},e.filterParsedLevels=function(t){this.levels=t;var e=this.getLevelsForPathway(this.pathwayId);if(0===e.length){var r=t[0].pathwayId;this.log("No levels found in Pathway "+this.pathwayId+'. Setting initial Pathway to "'+r+'"'),e=this.getLevelsForPathway(r),this.pathwayId=r}return e.length!==t.length?(this.log("Found "+e.length+"/"+t.length+' levels in Pathway "'+this.pathwayId+'"'),e):t},e.getLevelsForPathway=function(t){return null===this.levels?[]:this.levels.filter((function(e){return t===e.pathwayId}))},e.updatePathwayPriority=function(t){var e;this.pathwayPriority=t;var r=this.penalizedPathways,i=performance.now();Object.keys(r).forEach((function(t){i-r[t]>3e5&&delete r[t]}));for(var n=0;n0){this.log('Setting Pathway to "'+a+'"'),this.pathwayId=a,hr(e),this.hls.trigger(S.LEVELS_UPDATED,{levels:e});var l=this.hls.levels[s];o&&l&&this.levels&&(l.attrs["STABLE-VARIANT-ID"]!==o.attrs["STABLE-VARIANT-ID"]&&l.bitrate!==o.bitrate&&this.log("Unstable Pathways change from bitrate "+o.bitrate+" to "+l.bitrate),this.hls.nextLoadLevel=s);break}}}},e.getPathwayForGroupId=function(t,e,r){for(var i=this.getLevelsForPathway(r).concat(this.levels||[]),n=0;n=2&&(0===r.loading.first&&(r.loading.first=Math.max(self.performance.now(),r.loading.start),n.timeout!==n.loadPolicy.maxLoadTimeMs&&(self.clearTimeout(this.requestTimeout),n.timeout=n.loadPolicy.maxLoadTimeMs,this.requestTimeout=self.setTimeout(this.loadtimeout.bind(this),n.loadPolicy.maxLoadTimeMs-(r.loading.first-r.loading.start)))),4===i)){self.clearTimeout(this.requestTimeout),e.onreadystatechange=null,e.onprogress=null;var a=e.status,s="text"!==e.responseType;if(a>=200&&a<300&&(s&&e.response||null!==e.responseText)){r.loading.end=Math.max(self.performance.now(),r.loading.first);var o=s?e.response:e.responseText,l="arraybuffer"===e.responseType?o.byteLength:o.length;if(r.loaded=r.total=l,r.bwEstimate=8e3*r.total/(r.loading.end-r.loading.first),!this.callbacks)return;var u=this.callbacks.onProgress;if(u&&u(r,t,o,e),!this.callbacks)return;var h={url:e.responseURL,data:o,code:a};this.callbacks.onSuccess(h,r,t,e)}else{var d=n.loadPolicy.errorRetry;vr(d,r.retry,!1,{url:t.url,data:void 0,code:a})?this.retry(d):(w.error(a+" while loading "+t.url),this.callbacks.onError({code:a,text:e.statusText},t,e,r))}}}},e.loadtimeout=function(){var t,e=null==(t=this.config)?void 0:t.loadPolicy.timeoutRetry;if(vr(e,this.stats.retry,!0))this.retry(e);else{var r;w.warn("timeout while loading "+(null==(r=this.context)?void 0:r.url));var i=this.callbacks;i&&(this.abortInternal(),i.onTimeout(this.stats,this.context,this.loader))}},e.retry=function(t){var e=this.context,r=this.stats;this.retryDelay=fr(t,r.retry),r.retry++,w.warn((status?"HTTP Status "+status:"Timeout")+" while loading "+(null==e?void 0:e.url)+", retrying "+r.retry+"/"+t.maxNumRetry+" in "+this.retryDelay+"ms"),this.abortInternal(),this.loader=null,self.clearTimeout(this.retryTimeout),this.retryTimeout=self.setTimeout(this.loadInternal.bind(this),this.retryDelay)},e.loadprogress=function(t){var e=this.stats;e.loaded=t.loaded,t.lengthComputable&&(e.total=t.total)},e.getCacheAge=function(){var t=null;if(this.loader&&Hs.test(this.loader.getAllResponseHeaders())){var e=this.loader.getResponseHeader("age");t=e?parseFloat(e):null}return t},e.getResponseHeader=function(t){return this.loader&&new RegExp("^"+t+":\\s*[\\d.]+\\s*$","im").test(this.loader.getAllResponseHeaders())?this.loader.getResponseHeader(t):null},t}(),Ys=/(\d+)-(\d+)\/(\d+)/,Ws=function(){function t(t){this.fetchSetup=void 0,this.requestTimeout=void 0,this.request=null,this.response=null,this.controller=void 0,this.context=null,this.config=null,this.callbacks=null,this.stats=void 0,this.loader=null,this.fetchSetup=t.fetchSetup||js,this.controller=new self.AbortController,this.stats=new M}var e=t.prototype;return e.destroy=function(){this.loader=this.callbacks=this.context=this.config=this.request=null,this.abortInternal(),this.response=null,this.fetchSetup=this.controller=this.stats=null},e.abortInternal=function(){this.controller&&!this.stats.loading.end&&(this.stats.aborted=!0,this.controller.abort())},e.abort=function(){var t;this.abortInternal(),null!=(t=this.callbacks)&&t.onAbort&&this.callbacks.onAbort(this.stats,this.context,this.response)},e.load=function(t,e,r){var i=this,n=this.stats;if(n.loading.start)throw new Error("Loader can only be used once.");n.loading.start=self.performance.now();var a=function(t,e){var r={method:"GET",mode:"cors",credentials:"same-origin",signal:e,headers:new self.Headers(o({},t.headers))};return t.rangeEnd&&r.headers.set("Range","bytes="+t.rangeStart+"-"+String(t.rangeEnd-1)),r}(t,this.controller.signal),s=r.onProgress,l="arraybuffer"===t.responseType,u=l?"byteLength":"length",h=e.loadPolicy,d=h.maxTimeToFirstByteMs,c=h.maxLoadTimeMs;this.context=t,this.config=e,this.callbacks=r,this.request=this.fetchSetup(t,a),self.clearTimeout(this.requestTimeout),e.timeout=d&&y(d)?d:c,this.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,t,i.response)}),e.timeout),self.fetch(this.request).then((function(a){i.response=i.loader=a;var o=Math.max(self.performance.now(),n.loading.start);if(self.clearTimeout(i.requestTimeout),e.timeout=c,i.requestTimeout=self.setTimeout((function(){i.abortInternal(),r.onTimeout(n,t,i.response)}),c-(o-n.loading.start)),!a.ok){var u=a.status,h=a.statusText;throw new Xs(h||"fetch, bad network response",u,a)}return n.loading.first=o,n.total=function(t){var e=t.get("Content-Range");if(e){var r=function(t){var e=Ys.exec(t);if(e)return parseInt(e[2])-parseInt(e[1])+1}(e);if(y(r))return r}var i=t.get("Content-Length");if(i)return parseInt(i)}(a.headers)||n.total,s&&y(e.highWaterMark)?i.loadProgressively(a,n,t,e.highWaterMark,s):l?a.arrayBuffer():"json"===t.responseType?a.json():a.text()})).then((function(a){var o=i.response;if(!o)throw new Error("loader destroyed");self.clearTimeout(i.requestTimeout),n.loading.end=Math.max(self.performance.now(),n.loading.first);var l=a[u];l&&(n.loaded=n.total=l);var h={url:o.url,data:a,code:o.status};s&&!y(e.highWaterMark)&&s(n,t,a,o),r.onSuccess(h,n,t,o)})).catch((function(e){if(self.clearTimeout(i.requestTimeout),!n.aborted){var a=e&&e.code||0,s=e?e.message:null;r.onError({code:a,text:s},t,e?e.details:null,n)}}))},e.getCacheAge=function(){var t=null;if(this.response){var e=this.response.headers.get("age");t=e?parseFloat(e):null}return t},e.getResponseHeader=function(t){return this.response?this.response.headers.get(t):null},e.loadProgressively=function(t,e,r,i,n){void 0===i&&(i=0);var a=new bi,s=t.body.getReader();return function o(){return s.read().then((function(s){if(s.done)return a.dataLength&&n(e,r,a.flush(),t),Promise.resolve(new ArrayBuffer(0));var l=s.value,u=l.length;return e.loaded+=u,u=i&&n(e,r,a.flush(),t)):n(e,r,l,t),o()})).catch((function(){return Promise.reject()}))}()},t}();function js(t,e){return new self.Request(t.url,e)}var qs,Xs=function(t){function e(e,r,i){var n;return(n=t.call(this,e)||this).code=void 0,n.details=void 0,n.code=r,n.details=i,n}return l(e,t),e}(c(Error)),zs=/\s/,Qs=i(i({autoStartLoad:!0,startPosition:-1,defaultAudioCodec:void 0,debug:!1,capLevelOnFPSDrop:!1,capLevelToPlayerSize:!1,ignoreDevicePixelRatio:!1,preferManagedMediaSource:!0,initialLiveManifestSize:1,maxBufferLength:30,backBufferLength:1/0,frontBufferFlushThreshold:1/0,maxBufferSize:6e7,maxBufferHole:.1,highBufferWatchdogPeriod:2,nudgeOffset:.1,nudgeMaxRetry:3,maxFragLookUpTolerance:.25,liveSyncDurationCount:3,liveMaxLatencyDurationCount:1/0,liveSyncDuration:void 0,liveMaxLatencyDuration:void 0,maxLiveSyncPlaybackRate:1,liveDurationInfinity:!1,liveBackBufferLength:null,maxMaxBufferLength:600,enableWorker:!0,workerPath:null,enableSoftwareAES:!0,startLevel:void 0,startFragPrefetch:!1,fpsDroppedMonitoringPeriod:5e3,fpsDroppedMonitoringThreshold:.2,appendErrorMaxRetry:3,loader:Vs,fLoader:void 0,pLoader:void 0,xhrSetup:void 0,licenseXhrSetup:void 0,licenseResponseCallback:void 0,abrController:Gr,bufferController:Jn,capLevelController:Xa,errorController:Dr,fpsController:za,stretchShortVideoTrack:!1,maxAudioFramesDrift:1,forceKeyFrameOnDiscontinuity:!0,abrEwmaFastLive:3,abrEwmaSlowLive:9,abrEwmaFastVoD:3,abrEwmaSlowVoD:9,abrEwmaDefaultEstimate:5e5,abrEwmaDefaultEstimateMax:5e6,abrBandWidthFactor:.95,abrBandWidthUpFactor:.7,abrMaxWithRealBitrate:!1,maxStarvationDelay:4,maxLoadingDelay:4,minAutoBitrate:0,emeEnabled:!1,widevineLicenseUrl:void 0,drmSystems:{},drmSystemOptions:{},requestMediaKeySystemAccessFunc:it,testBandwidth:!0,progressive:!1,lowLatencyMode:!0,cmcd:void 0,enableDateRangeMetadataCues:!0,enableEmsgMetadataCues:!0,enableID3MetadataCues:!0,useMediaCapabilities:!0,certLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:null,errorRetry:null}},keyLoadPolicy:{default:{maxTimeToFirstByteMs:8e3,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"},errorRetry:{maxNumRetry:8,retryDelayMs:1e3,maxRetryDelayMs:2e4,backoff:"linear"}}},manifestLoadPolicy:{default:{maxTimeToFirstByteMs:1/0,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},playlistLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:2,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},fragLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:12e4,timeoutRetry:{maxNumRetry:4,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:6,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},steeringManifestLoadPolicy:{default:{maxTimeToFirstByteMs:1e4,maxLoadTimeMs:2e4,timeoutRetry:{maxNumRetry:2,retryDelayMs:0,maxRetryDelayMs:0},errorRetry:{maxNumRetry:1,retryDelayMs:1e3,maxRetryDelayMs:8e3}}},manifestLoadingTimeOut:1e4,manifestLoadingMaxRetry:1,manifestLoadingRetryDelay:1e3,manifestLoadingMaxRetryTimeout:64e3,levelLoadingTimeOut:1e4,levelLoadingMaxRetry:4,levelLoadingRetryDelay:1e3,levelLoadingMaxRetryTimeout:64e3,fragLoadingTimeOut:2e4,fragLoadingMaxRetry:6,fragLoadingRetryDelay:1e3,fragLoadingMaxRetryTimeout:64e3},{cueHandler:{newCue:function(t,e,r,i){for(var n,a,s,o,l,u=[],h=self.VTTCue||self.TextTrackCue,d=0;d=16?o--:o++;var g=Da(l.trim()),v=xa(e,r,g);null!=t&&null!=(c=t.cues)&&c.getCueById(v)||((a=new h(e,r,g)).id=v,a.line=d+1,a.align="left",a.position=10+Math.min(80,10*Math.floor(8*o/32)),u.push(a))}return t&&u.length&&(u.sort((function(t,e){return"auto"===t.line||"auto"===e.line?0:t.line>8&&e.line>8?e.line-t.line:t.line-e.line})),u.forEach((function(e){return Oe(t,e)}))),u}},enableWebVTT:!0,enableIMSC1:!0,enableCEA708Captions:!0,captionsTextTrack1Label:"English",captionsTextTrack1LanguageCode:"en",captionsTextTrack2Label:"Spanish",captionsTextTrack2LanguageCode:"es",captionsTextTrack3Label:"Unknown CC",captionsTextTrack3LanguageCode:"",captionsTextTrack4Label:"Unknown CC",captionsTextTrack4LanguageCode:"",renderTextTracksNatively:!0}),{},{subtitleStreamController:jn,subtitleTrackController:Xn,timelineController:Wa,audioStreamController:Yn,audioTrackController:Wn,emeController:Ja,cmcdController:Us,contentSteeringController:Bs});function Js(t){return t&&"object"==typeof t?Array.isArray(t)?t.map(Js):Object.keys(t).reduce((function(e,r){return e[r]=Js(t[r]),e}),{}):t}function $s(t){var e=t.loader;e!==Ws&&e!==Vs?(w.log("[config]: Custom loader detected, cannot enable progressive streaming"),t.progressive=!1):function(){if(self.fetch&&self.AbortController&&self.ReadableStream&&self.Request)try{return new self.ReadableStream({}),!0}catch(t){}return!1}()&&(t.loader=Ws,t.progressive=!0,t.enableSoftwareAES=!0,w.log("[config]: Progressive streaming enabled, using FetchLoader"))}var Zs=function(t){function e(e,r){var i;return(i=t.call(this,e,"[level-controller]")||this)._levels=[],i._firstLevel=-1,i._maxAutoLevel=-1,i._startLevel=void 0,i.currentLevel=null,i.currentLevelIndex=-1,i.manualLevelIndex=-1,i.steering=void 0,i.onParsedComplete=void 0,i.steering=r,i._registerListeners(),i}l(e,t);var r=e.prototype;return r._registerListeners=function(){var t=this.hls;t.on(S.MANIFEST_LOADING,this.onManifestLoading,this),t.on(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.on(S.LEVEL_LOADED,this.onLevelLoaded,this),t.on(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.on(S.FRAG_BUFFERED,this.onFragBuffered,this),t.on(S.ERROR,this.onError,this)},r._unregisterListeners=function(){var t=this.hls;t.off(S.MANIFEST_LOADING,this.onManifestLoading,this),t.off(S.MANIFEST_LOADED,this.onManifestLoaded,this),t.off(S.LEVEL_LOADED,this.onLevelLoaded,this),t.off(S.LEVELS_UPDATED,this.onLevelsUpdated,this),t.off(S.FRAG_BUFFERED,this.onFragBuffered,this),t.off(S.ERROR,this.onError,this)},r.destroy=function(){this._unregisterListeners(),this.steering=null,this.resetLevels(),t.prototype.destroy.call(this)},r.stopLoad=function(){this._levels.forEach((function(t){t.loadError=0,t.fragmentError=0})),t.prototype.stopLoad.call(this)},r.resetLevels=function(){this._startLevel=void 0,this.manualLevelIndex=-1,this.currentLevelIndex=-1,this.currentLevel=null,this._levels=[],this._maxAutoLevel=-1},r.onManifestLoading=function(t,e){this.resetLevels()},r.onManifestLoaded=function(t,e){var r=this.hls.config.preferManagedMediaSource,i=[],n={},a={},s=!1,o=!1,l=!1;e.levels.forEach((function(t){var e,u,h=t.attrs,d=t.audioCodec,c=t.videoCodec;-1!==(null==(e=d)?void 0:e.indexOf("mp4a.40.34"))&&(qs||(qs=/chrome|firefox/i.test(navigator.userAgent)),qs&&(t.audioCodec=d=void 0)),d&&(t.audioCodec=d=he(d,r)),0===(null==(u=c)?void 0:u.indexOf("avc1"))&&(c=t.videoCodec=function(t){var e=t.split(".");if(e.length>2){var r=e.shift()+".";return(r+=parseInt(e.shift()).toString(16))+("000"+parseInt(e.shift()).toString(16)).slice(-4)}return t}(c));var f=t.width,g=t.height,v=t.unknownCodecs;if(s||(s=!(!f||!g)),o||(o=!!c),l||(l=!!d),!(null!=v&&v.length||d&&!ie(d,"audio",r)||c&&!ie(c,"video",r))){var m=h.CODECS,p=h["FRAME-RATE"],y=h["HDCP-LEVEL"],E=h["PATHWAY-ID"],T=h.RESOLUTION,S=h["VIDEO-RANGE"],L=(E||".")+"-"+t.bitrate+"-"+T+"-"+p+"-"+m+"-"+S+"-"+y;if(n[L])if(n[L].uri===t.url||t.attrs["PATHWAY-ID"])n[L].addGroupId("audio",h.AUDIO),n[L].addGroupId("text",h.SUBTITLES);else{var A=a[L]+=1;t.attrs["PATHWAY-ID"]=new Array(A+1).join(".");var R=new er(t);n[L]=R,i.push(R)}else{var k=new er(t);n[L]=k,a[L]=1,i.push(k)}}})),this.filterAndSortMediaOptions(i,e,s,o,l)},r.filterAndSortMediaOptions=function(t,e,r,i,n){var a=this,s=[],o=[],l=t;if((r||i)&&n&&(l=l.filter((function(t){var e,r=t.videoCodec,i=t.videoRange,n=t.width,a=t.height;return(!!r||!(!n||!a))&&!!(e=i)&&Qe.indexOf(e)>-1}))),0!==l.length){if(e.audioTracks){var u=this.hls.config.preferManagedMediaSource;to(s=e.audioTracks.filter((function(t){return!t.audioCodec||ie(t.audioCodec,"audio",u)})))}e.subtitles&&to(o=e.subtitles);var h=l.slice(0);l.sort((function(t,e){if(t.attrs["HDCP-LEVEL"]!==e.attrs["HDCP-LEVEL"])return(t.attrs["HDCP-LEVEL"]||"")>(e.attrs["HDCP-LEVEL"]||"")?1:-1;if(r&&t.height!==e.height)return t.height-e.height;if(t.frameRate!==e.frameRate)return t.frameRate-e.frameRate;if(t.videoRange!==e.videoRange)return Qe.indexOf(t.videoRange)-Qe.indexOf(e.videoRange);if(t.videoCodec!==e.videoCodec){var i=se(t.videoCodec),n=se(e.videoCodec);if(i!==n)return n-i}if(t.uri===e.uri&&t.codecSet!==e.codecSet){var a=oe(t.codecSet),s=oe(e.codecSet);if(a!==s)return s-a}return t.averageBitrate!==e.averageBitrate?t.averageBitrate-e.averageBitrate:0}));var d=h[0];if(this.steering&&(l=this.steering.filterParsedLevels(l)).length!==h.length)for(var c=0;cm&&m===Qs.abrEwmaDefaultEstimate&&(this.hls.bandwidthEstimate=p)}break}var y=n&&!i,E={levels:l,audioTracks:s,subtitleTracks:o,sessionData:e.sessionData,sessionKeys:e.sessionKeys,firstLevel:this._firstLevel,stats:e.stats,audio:n,video:i,altAudio:!y&&s.some((function(t){return!!t.url}))};this.hls.trigger(S.MANIFEST_PARSED,E),(this.hls.config.autoStartLoad||this.hls.forceStartLoad)&&this.hls.startLoad(this.hls.config.startPosition)}else Promise.resolve().then((function(){if(a.hls){e.levels.length&&a.warn("One or more CODECS in variant not supported: "+JSON.stringify(e.levels[0].attrs));var t=new Error("no level with compatible codecs found in manifest");a.hls.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.MANIFEST_INCOMPATIBLE_CODECS_ERROR,fatal:!0,url:e.url,error:t,reason:t.message})}}))},r.onError=function(t,e){!e.fatal&&e.context&&e.context.type===be&&e.context.level===this.level&&this.checkRetry(e)},r.onFragBuffered=function(t,e){var r=e.frag;if(void 0!==r&&r.type===we){var i=r.elementaryStreams;if(!Object.keys(i).some((function(t){return!!i[t]})))return;var n=this._levels[r.level];null!=n&&n.loadError&&(this.log("Resetting level error count of "+n.loadError+" on frag buffered"),n.loadError=0)}},r.onLevelLoaded=function(t,e){var r,i,n=e.level,a=e.details,s=this._levels[n];if(!s)return this.warn("Invalid level index "+n),void(null!=(i=e.deliveryDirectives)&&i.skip&&(a.deltaUpdateFailed=!0));n===this.currentLevelIndex?(0===s.fragmentError&&(s.loadError=0),this.playlistLoaded(n,e,s.details)):null!=(r=e.deliveryDirectives)&&r.skip&&(a.deltaUpdateFailed=!0)},r.loadPlaylist=function(e){t.prototype.loadPlaylist.call(this);var r=this.currentLevelIndex,i=this.currentLevel;if(i&&this.shouldLoadPlaylist(i)){var n=i.uri;if(e)try{n=e.addDirectives(n)}catch(t){this.warn("Could not construct new URL with HLS Delivery Directives: "+t)}var a=i.attrs["PATHWAY-ID"];this.log("Loading level index "+r+(void 0!==(null==e?void 0:e.msn)?" at sn "+e.msn+" part "+e.part:"")+" with"+(a?" Pathway "+a:"")+" "+n),this.clearTimer(),this.hls.trigger(S.LEVEL_LOADING,{url:n,level:r,pathwayId:i.attrs["PATHWAY-ID"],id:0,deliveryDirectives:e||null})}},r.removeLevel=function(t){var e,r=this,i=this._levels.filter((function(e,i){return i!==t||(r.steering&&r.steering.removeLevel(e),e===r.currentLevel&&(r.currentLevel=null,r.currentLevelIndex=-1,e.details&&e.details.fragments.forEach((function(t){return t.level=-1}))),!1)}));hr(i),this._levels=i,this.currentLevelIndex>-1&&null!=(e=this.currentLevel)&&e.details&&(this.currentLevelIndex=this.currentLevel.details.fragments[0].level),this.hls.trigger(S.LEVELS_UPDATED,{levels:i})},r.onLevelsUpdated=function(t,e){var r=e.levels;this._levels=r},r.checkMaxAutoUpdated=function(){var t=this.hls,e=t.autoLevelCapping,r=t.maxAutoLevel,i=t.maxHdcpLevel;this._maxAutoLevel!==r&&(this._maxAutoLevel=r,this.hls.trigger(S.MAX_AUTO_LEVEL_UPDATED,{autoLevelCapping:e,levels:this.levels,maxAutoLevel:r,minAutoLevel:this.hls.minAutoLevel,maxHdcpLevel:i}))},s(e,[{key:"levels",get:function(){return 0===this._levels.length?null:this._levels}},{key:"level",get:function(){return this.currentLevelIndex},set:function(t){var e=this._levels;if(0!==e.length){if(t<0||t>=e.length){var r=new Error("invalid level idx"),i=t<0;if(this.hls.trigger(S.ERROR,{type:L.OTHER_ERROR,details:A.LEVEL_SWITCH_ERROR,level:t,fatal:i,error:r,reason:r.message}),i)return;t=Math.min(t,e.length-1)}var n=this.currentLevelIndex,a=this.currentLevel,s=a?a.attrs["PATHWAY-ID"]:void 0,o=e[t],l=o.attrs["PATHWAY-ID"];if(this.currentLevelIndex=t,this.currentLevel=o,n!==t||!o.details||!a||s!==l){this.log("Switching to level "+t+" ("+(o.height?o.height+"p ":"")+(o.videoRange?o.videoRange+" ":"")+(o.codecSet?o.codecSet+" ":"")+"@"+o.bitrate+")"+(l?" with Pathway "+l:"")+" from level "+n+(s?" with Pathway "+s:""));var u={level:t,attrs:o.attrs,details:o.details,bitrate:o.bitrate,averageBitrate:o.averageBitrate,maxBitrate:o.maxBitrate,realBitrate:o.realBitrate,width:o.width,height:o.height,codecSet:o.codecSet,audioCodec:o.audioCodec,videoCodec:o.videoCodec,audioGroups:o.audioGroups,subtitleGroups:o.subtitleGroups,loaded:o.loaded,loadError:o.loadError,fragmentError:o.fragmentError,name:o.name,id:o.id,uri:o.uri,url:o.url,urlId:0,audioGroupIds:o.audioGroupIds,textGroupIds:o.textGroupIds};this.hls.trigger(S.LEVEL_SWITCHING,u);var h=o.details;if(!h||h.live){var d=this.switchParams(o.uri,null==a?void 0:a.details);this.loadPlaylist(d)}}}}},{key:"manualLevel",get:function(){return this.manualLevelIndex},set:function(t){this.manualLevelIndex=t,void 0===this._startLevel&&(this._startLevel=t),-1!==t&&(this.level=t)}},{key:"firstLevel",get:function(){return this._firstLevel},set:function(t){this._firstLevel=t}},{key:"startLevel",get:function(){if(void 0===this._startLevel){var t=this.hls.config.startLevel;return void 0!==t?t:this.hls.firstAutoLevel}return this._startLevel},set:function(t){this._startLevel=t}},{key:"nextLoadLevel",get:function(){return-1!==this.manualLevelIndex?this.manualLevelIndex:this.hls.nextAutoLevel},set:function(t){this.level=t,-1===this.manualLevelIndex&&(this.hls.nextAutoLevel=t)}}]),e}(Ir);function to(t){var e={};t.forEach((function(t){var r=t.groupId||"";t.id=e[r]=e[r]||0,e[r]++}))}var eo=function(){function t(t){this.config=void 0,this.keyUriToKeyInfo={},this.emeController=null,this.config=t}var e=t.prototype;return e.abort=function(t){for(var e in this.keyUriToKeyInfo){var r=this.keyUriToKeyInfo[e].loader;if(r){var i;if(t&&t!==(null==(i=r.context)?void 0:i.frag.type))return;r.abort()}}},e.detach=function(){for(var t in this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t];(e.mediaKeySessionContext||e.decryptdata.isCommonEncryption)&&delete this.keyUriToKeyInfo[t]}},e.destroy=function(){for(var t in this.detach(),this.keyUriToKeyInfo){var e=this.keyUriToKeyInfo[t].loader;e&&e.destroy()}this.keyUriToKeyInfo={}},e.createKeyLoadError=function(t,e,r,i,n){return void 0===e&&(e=A.KEY_LOAD_ERROR),new oi({type:L.NETWORK_ERROR,details:e,fatal:!1,frag:t,response:n,error:r,networkDetails:i})},e.loadClear=function(t,e){var r=this;if(this.emeController&&this.config.emeEnabled)for(var i=t.sn,n=t.cc,a=function(){var t=e[s];if(n<=t.cc&&("initSegment"===i||"initSegment"===t.sn||i2,c=!h||e&&e.start<=a||h-a>2&&!this.fragmentTracker.getPartialFragment(a);if(d||c)return;this.moved=!1}if(!this.moved&&null!==this.stalled){var f;if(!(u.len>0||h))return;var g=Math.max(h,u.start||0)-a,v=this.hls.levels?this.hls.levels[this.hls.currentLevel]:null,m=(null==v||null==(f=v.details)?void 0:f.live)?2*v.details.targetduration:2,p=this.fragmentTracker.getPartialFragment(a);if(g>0&&(g<=m||p))return void(i.paused||this._trySkipBufferHole(p))}var y=self.performance.now();if(null!==n){var E=y-n;if(s||!(E>=250)||(this._reportStall(u),this.media)){var T=Qr.bufferInfo(i,a,r.maxBufferHole);this._tryFixBufferStall(T,E)}}else this.stalled=y}else if(this.moved=!0,s||(this.nudgeRetry=0),null!==n){if(this.stallReported){var S=self.performance.now()-n;w.warn("playback not stuck anymore @"+a+", after "+Math.round(S)+"ms"),this.stallReported=!1}this.stalled=null}}},e._tryFixBufferStall=function(t,e){var r=this.config,i=this.fragmentTracker,n=this.media;if(null!==n){var a=n.currentTime,s=i.getPartialFragment(a);if(s&&(this._trySkipBufferHole(s)||!this.media))return;(t.len>r.maxBufferHole||t.nextStart&&t.nextStart-a1e3*r.highBufferWatchdogPeriod&&(w.warn("Trying to nudge playhead over buffer-hole"),this.stalled=null,this._tryNudgeBuffer())}},e._reportStall=function(t){var e=this.hls,r=this.media;if(!this.stallReported&&r){this.stallReported=!0;var i=new Error("Playback stalling at @"+r.currentTime+" due to low buffer ("+JSON.stringify(t)+")");w.warn(i.message),e.trigger(S.ERROR,{type:L.MEDIA_ERROR,details:A.BUFFER_STALLED_ERROR,fatal:!1,error:i,buffer:t.len})}},e._trySkipBufferHole=function(t){var e=this.config,r=this.hls,i=this.media;if(null===i)return 0;var n=i.currentTime,a=Qr.bufferInfo(i,n,0),s=n0&&a.len<1&&i.readyState<3,u=s-n;if(u>0&&(o||l)){if(u>e.maxBufferHole){var h=this.fragmentTracker,d=!1;if(0===n){var c=h.getAppendedFrag(0,we);c&&s1?(i=0,this.bitrateTest=!0):i=r.firstAutoLevel),r.nextLoadLevel=i,this.level=r.loadLevel,this.loadedmetadata=!1}e>0&&-1===t&&(this.log("Override startPosition with lastCurrentTime @"+e.toFixed(3)),t=e),this.state=gi,this.nextLoadPosition=this.startPosition=this.lastCurrentTime=t,this.tick()}else this._forceStartLoad=!0,this.state=fi},r.stopLoad=function(){this._forceStartLoad=!1,t.prototype.stopLoad.call(this)},r.doTick=function(){switch(this.state){case Ri:var t=this.levels,e=this.level,r=null==t?void 0:t[e],i=null==r?void 0:r.details;if(i&&(!i.live||this.levelLastLoaded===r)){if(this.waitForCdnTuneIn(i))break;this.state=gi;break}if(this.hls.nextLoadLevel!==this.level){this.state=gi;break}break;case pi:var n,a=self.performance.now(),s=this.retryDate;if(!s||a>=s||null!=(n=this.media)&&n.seeking){var o=this.levels,l=this.level,u=null==o?void 0:o[l];this.resetStartWhenNotLoaded(u||null),this.state=gi}}this.state===gi&&this.doTickIdle(),this.onTickEnd()},r.onTickEnd=function(){t.prototype.onTickEnd.call(this),this.checkBuffer(),this.checkFragmentChanged()},r.doTickIdle=function(){var t=this.hls,e=this.levelLastLoaded,r=this.levels,i=this.media;if(null!==e&&(i||!this.startFragRequested&&t.config.startFragPrefetch)&&(!this.altAudio||!this.audioOnly)){var n=t.nextLoadLevel;if(null!=r&&r[n]){var a=r[n],s=this.getMainFwdBufferInfo();if(null!==s){var o=this.getLevelDetails();if(o&&this._streamEnded(s,o)){var l={};return this.altAudio&&(l.type="video"),this.hls.trigger(S.BUFFER_EOS,l),void(this.state=Si)}t.loadLevel!==n&&-1===t.manualLevel&&this.log("Adapting to level "+n+" from level "+this.level),this.level=t.nextLoadLevel=n;var u=a.details;if(!u||this.state===Ri||u.live&&this.levelLastLoaded!==a)return this.level=n,void(this.state=Ri);var h=s.len,d=this.getMaxBufferLength(a.maxBitrate);if(!(h>=d)){this.backtrackFragment&&this.backtrackFragment.start>s.end&&(this.backtrackFragment=null);var c=this.backtrackFragment?this.backtrackFragment.start:s.end,f=this.getNextFragment(c,u);if(this.couldBacktrack&&!this.fragPrevious&&f&&"initSegment"!==f.sn&&this.fragmentTracker.getState(f)!==Wr){var g,v=(null!=(g=this.backtrackFragment)?g:f).sn-u.startSN,m=u.fragments[v-1];m&&f.cc===m.cc&&(f=m,this.fragmentTracker.removeFragment(m))}else this.backtrackFragment&&s.len&&(this.backtrackFragment=null);if(f&&this.isLoopLoading(f,c)){if(!f.gap){var p=this.audioOnly&&!this.altAudio?O:N,y=(p===N?this.videoBuffer:this.mediaBuffer)||this.media;y&&this.afterBufferFlushed(y,p,we)}f=this.getNextFragmentLoopLoading(f,u,s,we,d)}f&&(!f.initSegment||f.initSegment.data||this.bitrateTest||(f=f.initSegment),this.loadFragment(f,a,c))}}}}},r.loadFragment=function(e,r,i){var n=this.fragmentTracker.getState(e);this.fragCurrent=e,n===Hr||n===Yr?"initSegment"===e.sn?this._loadInitSegment(e,r):this.bitrateTest?(this.log("Fragment "+e.sn+" of level "+e.level+" is being downloaded to test bitrate and will not be buffered"),this._loadBitrateTestFrag(e,r)):(this.startFragRequested=!0,t.prototype.loadFragment.call(this,e,r,i)):this.clearTrackerIfNeeded(e)},r.getBufferedFrag=function(t){return this.fragmentTracker.getBufferedFrag(t,we)},r.followingBufferedFrag=function(t){return t?this.getBufferedFrag(t.end+.5):null},r.immediateLevelSwitch=function(){this.abortCurrentFrag(),this.flushMainBuffer(0,Number.POSITIVE_INFINITY)},r.nextLevelSwitch=function(){var t=this.levels,e=this.media;if(null!=e&&e.readyState){var r,i=this.getAppendedFrag(e.currentTime);i&&i.start>1&&this.flushMainBuffer(0,i.start-1);var n=this.getLevelDetails();if(null!=n&&n.live){var a=this.getMainFwdBufferInfo();if(!a||a.len<2*n.targetduration)return}if(!e.paused&&t){var s=t[this.hls.nextLoadLevel],o=this.fragLastKbps;r=o&&this.fragCurrent?this.fragCurrent.duration*s.maxBitrate/(1e3*o)+1:0}else r=0;var l=this.getBufferedFrag(e.currentTime+r);if(l){var u=this.followingBufferedFrag(l);if(u){this.abortCurrentFrag();var h=u.maxStartPTS?u.maxStartPTS:u.start,d=u.duration,c=Math.max(l.end,h+Math.min(Math.max(d-this.config.maxFragLookUpTolerance,d*(this.couldBacktrack?.5:.125)),d*(this.couldBacktrack?.75:.25)));this.flushMainBuffer(c,Number.POSITIVE_INFINITY)}}}},r.abortCurrentFrag=function(){var t=this.fragCurrent;switch(this.fragCurrent=null,this.backtrackFragment=null,t&&(t.abortRequests(),this.fragmentTracker.removeFragment(t)),this.state){case vi:case mi:case pi:case Ei:case Ti:this.state=gi}this.nextLoadPosition=this.getLoadPosition()},r.flushMainBuffer=function(e,r){t.prototype.flushMainBuffer.call(this,e,r,this.altAudio?"video":null)},r.onMediaAttached=function(e,r){t.prototype.onMediaAttached.call(this,e,r);var i=r.media;this.onvplaying=this.onMediaPlaying.bind(this),this.onvseeked=this.onMediaSeeked.bind(this),i.addEventListener("playing",this.onvplaying),i.addEventListener("seeked",this.onvseeked),this.gapController=new no(this.config,i,this.fragmentTracker,this.hls)},r.onMediaDetaching=function(){var e=this.media;e&&this.onvplaying&&this.onvseeked&&(e.removeEventListener("playing",this.onvplaying),e.removeEventListener("seeked",this.onvseeked),this.onvplaying=this.onvseeked=null,this.videoBuffer=null),this.fragPlaying=null,this.gapController&&(this.gapController.destroy(),this.gapController=null),t.prototype.onMediaDetaching.call(this)},r.onMediaPlaying=function(){this.tick()},r.onMediaSeeked=function(){var t=this.media,e=t?t.currentTime:null;y(e)&&this.log("Media seeked to "+e.toFixed(3));var r=this.getMainFwdBufferInfo();null!==r&&0!==r.len?this.tick():this.warn('Main forward buffer length on "seeked" event '+(r?r.len:"empty")+")")},r.onManifestLoading=function(){this.log("Trigger BUFFER_RESET"),this.hls.trigger(S.BUFFER_RESET,void 0),this.fragmentTracker.removeAllFragments(),this.couldBacktrack=!1,this.startPosition=this.lastCurrentTime=this.fragLastKbps=0,this.levels=this.fragPlaying=this.backtrackFragment=this.levelLastLoaded=null,this.altAudio=this.audioOnly=this.startFragRequested=!1},r.onManifestParsed=function(t,e){var r,i,n=!1,a=!1;e.levels.forEach((function(t){var e=t.audioCodec;e&&(n=n||-1!==e.indexOf("mp4a.40.2"),a=a||-1!==e.indexOf("mp4a.40.5"))})),this.audioCodecSwitch=n&&a&&!("function"==typeof(null==(i=ro())||null==(r=i.prototype)?void 0:r.changeType)),this.audioCodecSwitch&&this.log("Both AAC/HE-AAC audio found in levels; declaring level codec as HE-AAC"),this.levels=e.levels,this.startFragRequested=!1},r.onLevelLoading=function(t,e){var r=this.levels;if(r&&this.state===gi){var i=r[e.level];(!i.details||i.details.live&&this.levelLastLoaded!==i||this.waitForCdnTuneIn(i.details))&&(this.state=Ri)}},r.onLevelLoaded=function(t,e){var r,i=this.levels,n=e.level,a=e.details,s=a.totalduration;if(i){this.log("Level "+n+" loaded ["+a.startSN+","+a.endSN+"]"+(a.lastPartSn?"[part-"+a.lastPartSn+"-"+a.lastPartIndex+"]":"")+", cc ["+a.startCC+", "+a.endCC+"] duration:"+s);var o=i[n],l=this.fragCurrent;!l||this.state!==mi&&this.state!==pi||l.level!==e.level&&l.loader&&this.abortCurrentFrag();var u=0;if(a.live||null!=(r=o.details)&&r.live){var h;if(this.checkLiveUpdate(a),a.deltaUpdateFailed)return;u=this.alignPlaylists(a,o.details,null==(h=this.levelLastLoaded)?void 0:h.details)}if(o.details=a,this.levelLastLoaded=o,this.hls.trigger(S.LEVEL_UPDATED,{details:a,level:n}),this.state===Ri){if(this.waitForCdnTuneIn(a))return;this.state=gi}this.startFragRequested?a.live&&this.synchronizeToLiveEdge(a):this.setStartPosition(a,u),this.tick()}else this.warn("Levels were reset while loading level "+n)},r._handleFragmentLoadProgress=function(t){var e,r=t.frag,i=t.part,n=t.payload,a=this.levels;if(a){var s=a[r.level],o=s.details;if(!o)return this.warn("Dropping fragment "+r.sn+" of level "+r.level+" after level details were reset"),void this.fragmentTracker.removeFragment(r);var l=s.videoCodec,u=o.PTSKnown||!o.live,h=null==(e=r.initSegment)?void 0:e.data,d=this._getAudioCodec(s),c=this.transmuxer=this.transmuxer||new Gn(this.hls,we,this._handleTransmuxComplete.bind(this),this._handleTransmuxerFlush.bind(this)),f=i?i.index:-1,g=-1!==f,v=new Jr(r.level,r.sn,r.stats.chunkCount,n.byteLength,f,g),m=this.initPTS[r.cc];c.push(n,h,d,l,r,i,o.totalduration,u,v,m)}else this.warn("Levels were reset while fragment load was in progress. Fragment "+r.sn+" of level "+r.level+" will not be buffered")},r.onAudioTrackSwitching=function(t,e){var r=this.altAudio;if(!e.url){if(this.mediaBuffer!==this.media){this.log("Switching on main audio, use media.buffered to schedule main fragment loading"),this.mediaBuffer=this.media;var i=this.fragCurrent;i&&(this.log("Switching to main audio track, cancel main fragment load"),i.abortRequests(),this.fragmentTracker.removeFragment(i)),this.resetTransmuxer(),this.resetLoadingState()}else this.audioOnly&&this.resetTransmuxer();var n=this.hls;r&&(n.trigger(S.BUFFER_FLUSHING,{startOffset:0,endOffset:Number.POSITIVE_INFINITY,type:null}),this.fragmentTracker.removeAllFragments()),n.trigger(S.AUDIO_TRACK_SWITCHED,e)}},r.onAudioTrackSwitched=function(t,e){var r=e.id,i=!!this.hls.audioTracks[r].url;if(i){var n=this.videoBuffer;n&&this.mediaBuffer!==n&&(this.log("Switching on alternate audio, use video.buffered to schedule main fragment loading"),this.mediaBuffer=n)}this.altAudio=i,this.tick()},r.onBufferCreated=function(t,e){var r,i,n=e.tracks,a=!1;for(var s in n){var o=n[s];if("main"===o.id){if(i=s,r=o,"video"===s){var l=n[s];l&&(this.videoBuffer=l.buffer)}}else a=!0}a&&r?(this.log("Alternate track found, use "+i+".buffered to schedule main fragment loading"),this.mediaBuffer=r.buffer):this.mediaBuffer=this.media},r.onFragBuffered=function(t,e){var r=e.frag,i=e.part;if(!r||r.type===we){if(this.fragContextChanged(r))return this.warn("Fragment "+r.sn+(i?" p: "+i.index:"")+" of level "+r.level+" finished buffering, but was aborted. state: "+this.state),void(this.state===Ti&&(this.state=gi));var n=i?i.stats:r.stats;this.fragLastKbps=Math.round(8*n.total/(n.buffering.end-n.loading.first)),"initSegment"!==r.sn&&(this.fragPrevious=r),this.fragBufferedComplete(r,i)}},r.onError=function(t,e){var r;if(e.fatal)this.state=Li;else switch(e.details){case A.FRAG_GAP:case A.FRAG_PARSING_ERROR:case A.FRAG_DECRYPT_ERROR:case A.FRAG_LOAD_ERROR:case A.FRAG_LOAD_TIMEOUT:case A.KEY_LOAD_ERROR:case A.KEY_LOAD_TIMEOUT:this.onFragmentOrKeyLoadError(we,e);break;case A.LEVEL_LOAD_ERROR:case A.LEVEL_LOAD_TIMEOUT:case A.LEVEL_PARSING_ERROR:e.levelRetry||this.state!==Ri||(null==(r=e.context)?void 0:r.type)!==be||(this.state=gi);break;case A.BUFFER_APPEND_ERROR:case A.BUFFER_FULL_ERROR:if(!e.parent||"main"!==e.parent)return;if(e.details===A.BUFFER_APPEND_ERROR)return void this.resetLoadingState();this.reduceLengthAndFlushBuffer(e)&&this.flushMainBuffer(0,Number.POSITIVE_INFINITY);break;case A.INTERNAL_EXCEPTION:this.recoverWorkerError(e)}},r.checkBuffer=function(){var t=this.media,e=this.gapController;if(t&&e&&t.readyState){if(this.loadedmetadata||!Qr.getBuffered(t).length){var r=this.state!==gi?this.fragCurrent:null;e.poll(this.lastCurrentTime,r)}this.lastCurrentTime=t.currentTime}},r.onFragLoadEmergencyAborted=function(){this.state=gi,this.loadedmetadata||(this.startFragRequested=!1,this.nextLoadPosition=this.startPosition),this.tickImmediate()},r.onBufferFlushed=function(t,e){var r=e.type;if(r!==O||this.audioOnly&&!this.altAudio){var i=(r===N?this.videoBuffer:this.mediaBuffer)||this.media;this.afterBufferFlushed(i,r,we),this.tick()}},r.onLevelsUpdated=function(t,e){this.level>-1&&this.fragCurrent&&(this.level=this.fragCurrent.level),this.levels=e.levels},r.swapAudioCodec=function(){this.audioCodecSwap=!this.audioCodecSwap},r.seekToStartPos=function(){var t=this.media;if(t){var e=t.currentTime,r=this.startPosition;if(r>=0&&e0&&(nT.cc;if(!1!==n.independent){var R=h.startPTS,k=h.endPTS,b=h.startDTS,D=h.endDTS;if(l)l.elementaryStreams[h.type]={startPTS:R,endPTS:k,startDTS:b,endDTS:D};else if(h.firstKeyFrame&&h.independent&&1===a.id&&!A&&(this.couldBacktrack=!0),h.dropped&&h.independent){var I=this.getMainFwdBufferInfo(),w=(I?I.end:this.getLoadPosition())+this.config.maxBufferHole,C=h.firstKeyFramePTS?h.firstKeyFramePTS:R;if(!L&&w2&&(o.gap=!0);o.setElementaryStreamInfo(h.type,R,k,b,D),this.backtrackFragment&&(this.backtrackFragment=o),this.bufferFragmentData(h,o,l,a,L||A)}else{if(!L&&!A)return void this.backtrack(o);o.gap=!0}}if(v){var _=v.startPTS,x=v.endPTS,P=v.startDTS,F=v.endDTS;l&&(l.elementaryStreams[O]={startPTS:_,endPTS:x,startDTS:P,endDTS:F}),o.setElementaryStreamInfo(O,_,x,P,F),this.bufferFragmentData(v,o,l,a)}if(g&&null!=c&&null!=(e=c.samples)&&e.length){var M={id:r,frag:o,details:g,samples:c.samples};i.trigger(S.FRAG_PARSING_METADATA,M)}if(g&&d){var N={id:r,frag:o,details:g,samples:d.samples};i.trigger(S.FRAG_PARSING_USERDATA,N)}}}else this.resetWhenMissingContext(a)},r._bufferInitSegment=function(t,e,r,i){var n=this;if(this.state===Ei){this.audioOnly=!!e.audio&&!e.video,this.altAudio&&!this.audioOnly&&delete e.audio;var a=e.audio,s=e.video,o=e.audiovideo;if(a){var l=t.audioCodec,u=navigator.userAgent.toLowerCase();this.audioCodecSwitch&&(l&&(l=-1!==l.indexOf("mp4a.40.5")?"mp4a.40.2":"mp4a.40.5"),1!==a.metadata.channelCount&&-1===u.indexOf("firefox")&&(l="mp4a.40.5")),l&&-1!==l.indexOf("mp4a.40.5")&&-1!==u.indexOf("android")&&"audio/mpeg"!==a.container&&(l="mp4a.40.2",this.log("Android: force audio codec to "+l)),t.audioCodec&&t.audioCodec!==l&&this.log('Swapping manifest audio codec "'+t.audioCodec+'" for "'+l+'"'),a.levelCodec=l,a.id="main",this.log("Init audio buffer, container:"+a.container+", codecs[selected/level/parsed]=["+(l||"")+"/"+(t.audioCodec||"")+"/"+a.codec+"]")}s&&(s.levelCodec=t.videoCodec,s.id="main",this.log("Init video buffer, container:"+s.container+", codecs[level/parsed]=["+(t.videoCodec||"")+"/"+s.codec+"]")),o&&this.log("Init audiovideo buffer, container:"+o.container+", codecs[level/parsed]=["+t.codecs+"/"+o.codec+"]"),this.hls.trigger(S.BUFFER_CODECS,e),Object.keys(e).forEach((function(t){var a=e[t].initSegment;null!=a&&a.byteLength&&n.hls.trigger(S.BUFFER_APPENDING,{type:t,data:a,frag:r,part:null,chunkMeta:i,parent:r.type})})),this.tickImmediate()}},r.getMainFwdBufferInfo=function(){return this.getFwdBufferInfo(this.mediaBuffer?this.mediaBuffer:this.media,we)},r.backtrack=function(t){this.couldBacktrack=!0,this.backtrackFragment=t,this.resetTransmuxer(),this.flushBufferGap(t),this.fragmentTracker.removeFragment(t),this.fragPrevious=null,this.nextLoadPosition=t.start,this.state=gi},r.checkFragmentChanged=function(){var t=this.media,e=null;if(t&&t.readyState>1&&!1===t.seeking){var r=t.currentTime;if(Qr.isBuffered(t,r)?e=this.getAppendedFrag(r):Qr.isBuffered(t,r+.1)&&(e=this.getAppendedFrag(r+.1)),e){this.backtrackFragment=null;var i=this.fragPlaying,n=e.level;i&&e.sn===i.sn&&i.level===n||(this.fragPlaying=e,this.hls.trigger(S.FRAG_CHANGED,{frag:e}),i&&i.level===n||this.hls.trigger(S.LEVEL_SWITCHED,{level:n}))}}},s(e,[{key:"nextLevel",get:function(){var t=this.nextBufferedFrag;return t?t.level:-1}},{key:"currentFrag",get:function(){var t=this.media;return t?this.fragPlaying||this.getAppendedFrag(t.currentTime):null}},{key:"currentProgramDateTime",get:function(){var t=this.media;if(t){var e=t.currentTime,r=this.currentFrag;if(r&&y(e)&&y(r.programDateTime)){var i=r.programDateTime+1e3*(e-r.start);return new Date(i)}}return null}},{key:"currentLevel",get:function(){var t=this.currentFrag;return t?t.level:-1}},{key:"nextBufferedFrag",get:function(){var t=this.currentFrag;return t?this.followingBufferedFrag(t):null}},{key:"forceStartLoad",get:function(){return this._forceStartLoad}}]),e}(ki),so=function(){function t(e){void 0===e&&(e={}),this.config=void 0,this.userConfig=void 0,this.coreComponents=void 0,this.networkControllers=void 0,this.started=!1,this._emitter=new On,this._autoLevelCapping=-1,this._maxHdcpLevel=null,this.abrController=void 0,this.bufferController=void 0,this.capLevelController=void 0,this.latencyController=void 0,this.levelController=void 0,this.streamController=void 0,this.audioTrackController=void 0,this.subtitleTrackController=void 0,this.emeController=void 0,this.cmcdController=void 0,this._media=null,this.url=null,this.triggeringException=void 0,I(e.debug||!1,"Hls instance");var r=this.config=function(t,e){if((e.liveSyncDurationCount||e.liveMaxLatencyDurationCount)&&(e.liveSyncDuration||e.liveMaxLatencyDuration))throw new Error("Illegal hls.js config: don't mix up liveSyncDurationCount/liveMaxLatencyDurationCount and liveSyncDuration/liveMaxLatencyDuration");if(void 0!==e.liveMaxLatencyDurationCount&&(void 0===e.liveSyncDurationCount||e.liveMaxLatencyDurationCount<=e.liveSyncDurationCount))throw new Error('Illegal hls.js config: "liveMaxLatencyDurationCount" must be greater than "liveSyncDurationCount"');if(void 0!==e.liveMaxLatencyDuration&&(void 0===e.liveSyncDuration||e.liveMaxLatencyDuration<=e.liveSyncDuration))throw new Error('Illegal hls.js config: "liveMaxLatencyDuration" must be greater than "liveSyncDuration"');var r=Js(t),n=["TimeOut","MaxRetry","RetryDelay","MaxRetryTimeout"];return["manifest","level","frag"].forEach((function(t){var i=("level"===t?"playlist":t)+"LoadPolicy",a=void 0===e[i],s=[];n.forEach((function(n){var o=t+"Loading"+n,l=e[o];if(void 0!==l&&a){s.push(o);var u=r[i].default;switch(e[i]={default:u},n){case"TimeOut":u.maxLoadTimeMs=l,u.maxTimeToFirstByteMs=l;break;case"MaxRetry":u.errorRetry.maxNumRetry=l,u.timeoutRetry.maxNumRetry=l;break;case"RetryDelay":u.errorRetry.retryDelayMs=l,u.timeoutRetry.retryDelayMs=l;break;case"MaxRetryTimeout":u.errorRetry.maxRetryDelayMs=l,u.timeoutRetry.maxRetryDelayMs=l}}})),s.length&&w.warn('hls.js config: "'+s.join('", "')+'" setting(s) are deprecated, use "'+i+'": '+JSON.stringify(e[i]))})),i(i({},r),e)}(t.DefaultConfig,e);this.userConfig=e,r.progressive&&$s(r);var n=r.abrController,a=r.bufferController,s=r.capLevelController,o=r.errorController,l=r.fpsController,u=new o(this),h=this.abrController=new n(this),d=this.bufferController=new a(this),c=this.capLevelController=new s(this),f=new l(this),g=new Fe(this),v=new qe(this),m=r.contentSteeringController,p=m?new m(this):null,y=this.levelController=new Zs(this,p),E=new jr(this),T=new eo(this.config),L=this.streamController=new ao(this,E,T);c.setStreamController(L),f.setStreamController(L);var A=[g,y,L];p&&A.splice(1,0,p),this.networkControllers=A;var R=[h,d,c,f,v,E];this.audioTrackController=this.createController(r.audioTrackController,A);var k=r.audioStreamController;k&&A.push(new k(this,E,T)),this.subtitleTrackController=this.createController(r.subtitleTrackController,A);var b=r.subtitleStreamController;b&&A.push(new b(this,E,T)),this.createController(r.timelineController,R),T.emeController=this.emeController=this.createController(r.emeController,R),this.cmcdController=this.createController(r.cmcdController,R),this.latencyController=this.createController(Xe,R),this.coreComponents=R,A.push(u);var D=u.onErrorOut;"function"==typeof D&&this.on(S.ERROR,D,u)}t.isMSESupported=function(){return io()},t.isSupported=function(){return function(){if(!io())return!1;var t=ee();return"function"==typeof(null==t?void 0:t.isTypeSupported)&&(["avc1.42E01E,mp4a.40.2","av01.0.01M.08","vp09.00.50.08"].some((function(e){return t.isTypeSupported(ae(e,"video"))}))||["mp4a.40.2","fLaC"].some((function(e){return t.isTypeSupported(ae(e,"audio"))})))}()},t.getMediaSource=function(){return ee()};var e=t.prototype;return e.createController=function(t,e){if(t){var r=new t(this);return e&&e.push(r),r}return null},e.on=function(t,e,r){void 0===r&&(r=this),this._emitter.on(t,e,r)},e.once=function(t,e,r){void 0===r&&(r=this),this._emitter.once(t,e,r)},e.removeAllListeners=function(t){this._emitter.removeAllListeners(t)},e.off=function(t,e,r,i){void 0===r&&(r=this),this._emitter.off(t,e,r,i)},e.listeners=function(t){return this._emitter.listeners(t)},e.emit=function(t,e,r){return this._emitter.emit(t,e,r)},e.trigger=function(t,e){if(this.config.debug)return this.emit(t,t,e);try{return this.emit(t,t,e)}catch(e){if(w.error("An internal error happened while handling event "+t+'. Error message: "'+e.message+'". Here is a stacktrace:',e),!this.triggeringException){this.triggeringException=!0;var r=t===S.ERROR;this.trigger(S.ERROR,{type:L.OTHER_ERROR,details:A.INTERNAL_EXCEPTION,fatal:r,event:t,error:e}),this.triggeringException=!1}}return!1},e.listenerCount=function(t){return this._emitter.listenerCount(t)},e.destroy=function(){w.log("destroy"),this.trigger(S.DESTROYING,void 0),this.detachMedia(),this.removeAllListeners(),this._autoLevelCapping=-1,this.url=null,this.networkControllers.forEach((function(t){return t.destroy()})),this.networkControllers.length=0,this.coreComponents.forEach((function(t){return t.destroy()})),this.coreComponents.length=0;var t=this.config;t.xhrSetup=t.fetchSetup=void 0,this.userConfig=null},e.attachMedia=function(t){w.log("attachMedia"),this._media=t,this.trigger(S.MEDIA_ATTACHING,{media:t})},e.detachMedia=function(){w.log("detachMedia"),this.trigger(S.MEDIA_DETACHING,void 0),this._media=null},e.loadSource=function(t){this.stopLoad();var e=this.media,r=this.url,i=this.url=p.buildAbsoluteURL(self.location.href,t,{alwaysNormalize:!0});this._autoLevelCapping=-1,this._maxHdcpLevel=null,w.log("loadSource:"+i),e&&r&&(r!==i||this.bufferController.hasSourceTypes())&&(this.detachMedia(),this.attachMedia(e)),this.trigger(S.MANIFEST_LOADING,{url:t})},e.startLoad=function(t){void 0===t&&(t=-1),w.log("startLoad("+t+")"),this.started=!0,this.networkControllers.forEach((function(e){e.startLoad(t)}))},e.stopLoad=function(){w.log("stopLoad"),this.started=!1,this.networkControllers.forEach((function(t){t.stopLoad()}))},e.resumeBuffering=function(){this.started&&this.networkControllers.forEach((function(t){"fragmentLoader"in t&&t.startLoad(-1)}))},e.pauseBuffering=function(){this.networkControllers.forEach((function(t){"fragmentLoader"in t&&t.stopLoad()}))},e.swapAudioCodec=function(){w.log("swapAudioCodec"),this.streamController.swapAudioCodec()},e.recoverMediaError=function(){w.log("recoverMediaError");var t=this._media;this.detachMedia(),t&&this.attachMedia(t)},e.removeLevel=function(t){this.levelController.removeLevel(t)},e.setAudioOption=function(t){var e;return null==(e=this.audioTrackController)?void 0:e.setAudioOption(t)},e.setSubtitleOption=function(t){var e;return null==(e=this.subtitleTrackController)||e.setSubtitleOption(t),null},s(t,[{key:"levels",get:function(){var t=this.levelController.levels;return t||[]}},{key:"currentLevel",get:function(){return this.streamController.currentLevel},set:function(t){w.log("set currentLevel:"+t),this.levelController.manualLevel=t,this.streamController.immediateLevelSwitch()}},{key:"nextLevel",get:function(){return this.streamController.nextLevel},set:function(t){w.log("set nextLevel:"+t),this.levelController.manualLevel=t,this.streamController.nextLevelSwitch()}},{key:"loadLevel",get:function(){return this.levelController.level},set:function(t){w.log("set loadLevel:"+t),this.levelController.manualLevel=t}},{key:"nextLoadLevel",get:function(){return this.levelController.nextLoadLevel},set:function(t){this.levelController.nextLoadLevel=t}},{key:"firstLevel",get:function(){return Math.max(this.levelController.firstLevel,this.minAutoLevel)},set:function(t){w.log("set firstLevel:"+t),this.levelController.firstLevel=t}},{key:"startLevel",get:function(){var t=this.levelController.startLevel;return-1===t&&this.abrController.forcedAutoLevel>-1?this.abrController.forcedAutoLevel:t},set:function(t){w.log("set startLevel:"+t),-1!==t&&(t=Math.max(t,this.minAutoLevel)),this.levelController.startLevel=t}},{key:"capLevelToPlayerSize",get:function(){return this.config.capLevelToPlayerSize},set:function(t){var e=!!t;e!==this.config.capLevelToPlayerSize&&(e?this.capLevelController.startCapping():(this.capLevelController.stopCapping(),this.autoLevelCapping=-1,this.streamController.nextLevelSwitch()),this.config.capLevelToPlayerSize=e)}},{key:"autoLevelCapping",get:function(){return this._autoLevelCapping},set:function(t){this._autoLevelCapping!==t&&(w.log("set autoLevelCapping:"+t),this._autoLevelCapping=t,this.levelController.checkMaxAutoUpdated())}},{key:"bandwidthEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimate():NaN},set:function(t){this.abrController.resetEstimator(t)}},{key:"ttfbEstimate",get:function(){var t=this.abrController.bwEstimator;return t?t.getEstimateTTFB():NaN}},{key:"maxHdcpLevel",get:function(){return this._maxHdcpLevel},set:function(t){(function(t){return ze.indexOf(t)>-1})(t)&&this._maxHdcpLevel!==t&&(this._maxHdcpLevel=t,this.levelController.checkMaxAutoUpdated())}},{key:"autoLevelEnabled",get:function(){return-1===this.levelController.manualLevel}},{key:"manualLevel",get:function(){return this.levelController.manualLevel}},{key:"minAutoLevel",get:function(){var t=this.levels,e=this.config.minAutoBitrate;if(!t)return 0;for(var r=t.length,i=0;i=e)return i;return 0}},{key:"maxAutoLevel",get:function(){var t,e=this.levels,r=this.autoLevelCapping,i=this.maxHdcpLevel;if(t=-1===r&&null!=e&&e.length?e.length-1:r,i)for(var n=t;n--;){var a=e[n].attrs["HDCP-LEVEL"];if(a&&a<=i)return n}return t}},{key:"firstAutoLevel",get:function(){return this.abrController.firstAutoLevel}},{key:"nextAutoLevel",get:function(){return this.abrController.nextAutoLevel},set:function(t){this.abrController.nextAutoLevel=t}},{key:"playingDate",get:function(){return this.streamController.currentProgramDateTime}},{key:"mainForwardBufferInfo",get:function(){return this.streamController.getMainFwdBufferInfo()}},{key:"allAudioTracks",get:function(){var t=this.audioTrackController;return t?t.allAudioTracks:[]}},{key:"audioTracks",get:function(){var t=this.audioTrackController;return t?t.audioTracks:[]}},{key:"audioTrack",get:function(){var t=this.audioTrackController;return t?t.audioTrack:-1},set:function(t){var e=this.audioTrackController;e&&(e.audioTrack=t)}},{key:"allSubtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.allSubtitleTracks:[]}},{key:"subtitleTracks",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTracks:[]}},{key:"subtitleTrack",get:function(){var t=this.subtitleTrackController;return t?t.subtitleTrack:-1},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleTrack=t)}},{key:"media",get:function(){return this._media}},{key:"subtitleDisplay",get:function(){var t=this.subtitleTrackController;return!!t&&t.subtitleDisplay},set:function(t){var e=this.subtitleTrackController;e&&(e.subtitleDisplay=t)}},{key:"lowLatencyMode",get:function(){return this.config.lowLatencyMode},set:function(t){this.config.lowLatencyMode=t}},{key:"liveSyncPosition",get:function(){return this.latencyController.liveSyncPosition}},{key:"latency",get:function(){return this.latencyController.latency}},{key:"maxLatency",get:function(){return this.latencyController.maxLatency}},{key:"targetLatency",get:function(){return this.latencyController.targetLatency}},{key:"drift",get:function(){return this.latencyController.drift}},{key:"forceStartLoad",get:function(){return this.streamController.forceStartLoad}}],[{key:"version",get:function(){return"1.5.7"}},{key:"Events",get:function(){return S}},{key:"ErrorTypes",get:function(){return L}},{key:"ErrorDetails",get:function(){return A}},{key:"DefaultConfig",get:function(){return t.defaultConfig?t.defaultConfig:Qs},set:function(e){t.defaultConfig=e}}]),t}();return so.defaultConfig=void 0,so},"object"==typeof exports&&"undefined"!=typeof module?module.exports=i():"function"==typeof define&&define.amd?define(i):(r="undefined"!=typeof globalThis?globalThis:r||self).Hls=i()}(!1); +//# sourceMappingURL=hls.min.js.map diff --git a/InfoGenie-frontend/public/toolbox/视频播放器/index.html b/InfoGenie-frontend/public/toolbox/视频播放器/index.html new file mode 100644 index 00000000..cb51b073 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/视频播放器/index.html @@ -0,0 +1,412 @@ + + + + + ▶️视频播放器 + + + +
    +
    +
    ▶️视频播放器
    + +
    +
    + + +
    +
    + + + 未选择文件 +
    +
    + +
    +
    + +
    + +
    +
    + +
    +
    + 00:00 + + --:-- +
    +
    + + + + + + + + + + +
    未加载视频
    +
    +
    +
    +
    + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/计算器/app.js b/InfoGenie-frontend/public/toolbox/计算器/app.js new file mode 100644 index 00000000..d2ed738a --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/计算器/app.js @@ -0,0 +1,225 @@ +(() => { + const { createApp, ref, computed, watch } = Vue; + + // 检测是否可用 Math.js + const hasMath = typeof math !== 'undefined'; + if (hasMath) { + math.config({ number: 'BigNumber', precision: 64 }); + } + + // 保存原始三角函数以便覆盖时调用 + const originalSin = hasMath ? math.sin : null; + const originalCos = hasMath ? math.cos : null; + const originalTan = hasMath ? math.tan : null; + + // 角度转换因子(deg -> rad) + const RAD_FACTOR = hasMath ? math.divide(math.pi, math.bignumber(180)) : (Math.PI / 180); + + // 动态角度模式变量供三角函数使用 + let angleModeVar = 'deg'; + + function sinWrapper(x) { + try { + if (angleModeVar === 'deg') { + const xr = hasMath ? math.multiply(x, RAD_FACTOR) : (Number(x) * RAD_FACTOR); + return hasMath ? originalSin(xr) : Math.sin(xr); + } + return hasMath ? originalSin(x) : Math.sin(Number(x)); + } catch (e) { throw e; } + } + function cosWrapper(x) { + try { + if (angleModeVar === 'deg') { + const xr = hasMath ? math.multiply(x, RAD_FACTOR) : (Number(x) * RAD_FACTOR); + return hasMath ? originalCos(xr) : Math.cos(xr); + } + return hasMath ? originalCos(x) : Math.cos(Number(x)); + } catch (e) { throw e; } + } + function tanWrapper(x) { + try { + if (angleModeVar === 'deg') { + const xr = hasMath ? math.multiply(x, RAD_FACTOR) : (Number(x) * RAD_FACTOR); + return hasMath ? originalTan(xr) : Math.tan(xr); + } + return hasMath ? originalTan(x) : Math.tan(Number(x)); + } catch (e) { throw e; } + } + + // 覆盖三角函数以支持角度模式(Math.js 可用时) + if (hasMath) { + math.import({ sin: sinWrapper, cos: cosWrapper, tan: tanWrapper }, { override: true }); + } + + function formatBig(value) { + try { + if (value == null) return ''; + if (hasMath) { + return math.format(value, { + notation: 'auto', + precision: 14, + lowerExp: -6, + upperExp: 15, + }); + } else { + const num = typeof value === 'number' ? value : Number(value); + if (!isFinite(num)) return '错误'; + const str = num.toFixed(12); + return str.replace(/\.0+$/, '').replace(/(\.[0-9]*?)0+$/, '$1'); + } + } catch (e) { + return String(value); + } + } + + function normalize(exp) { + // 将显示符号标准化为计算符号,保留原字符不做删除 + return exp + .replace(/×/g, '*') + .replace(/÷/g, '/') + .replace(/√/g, 'sqrt'); + } + + createApp({ + setup() { + const expression = ref(''); + const result = ref(hasMath ? math.bignumber(0) : 0); + const errorMsg = ref(''); + const lastAns = ref(hasMath ? math.bignumber(0) : 0); + const angleMode = ref('deg'); + + watch(angleMode, (val) => { angleModeVar = val; }); + + const formattedExpression = computed(() => expression.value || '0'); + const formattedResult = computed(() => errorMsg.value ? '' : formatBig(result.value)); + + function isParenthesesBalanced(s) { + let count = 0; + for (const ch of s) { + if (ch === '(') count++; + else if (ch === ')') count--; + if (count < 0) return false; + } + return count === 0; + } + + function safeEvaluate(exp) { + errorMsg.value = ''; + try { + const s = normalize(exp); + if (!s) { result.value = hasMath ? math.bignumber(0) : 0; return result.value; } + // 检测非法字符:仅允许数字、运算符、括号、字母(用于函数和ANS),以及空白 + if (/[^0-9\.\+\-\*\/\^\(\)a-zA-Z\s]/.test(s)) { throw new Error('错误'); } + if (!isParenthesesBalanced(s)) throw new Error('错误'); + if (hasMath) { + const scope = { ANS: lastAns.value }; + const res = math.evaluate(s, scope); + // 防止除以零等无效情况 + if (res && res.isFinite && !res.isFinite()) { throw new Error('错误'); } + result.value = res; + return res; + } else { + // 原生回退:将表达式映射到安全本地函数 + let expr = s + .replace(/\^/g, '**') + .replace(/sin\(/g, '__sin(') + .replace(/cos\(/g, '__cos(') + .replace(/tan\(/g, '__tan(') + .replace(/sqrt\(/g, '__sqrt(') + .replace(/\bANS\b/g, String(lastAns.value)); + // 严格校验(只允许安全字符) + if (/[^0-9+\-*/()._^a-zA-Z\s]/.test(expr)) throw new Error('错误'); + // 定义本地安全函数 + const __sqrt = (x) => Math.sqrt(Number(x)); + const __sin = (x) => angleModeVar === 'deg' ? Math.sin(Number(x) * Math.PI / 180) : Math.sin(Number(x)); + const __cos = (x) => angleModeVar === 'deg' ? Math.cos(Number(x) * Math.PI / 180) : Math.cos(Number(x)); + const __tan = (x) => angleModeVar === 'deg' ? Math.tan(Number(x) * Math.PI / 180) : Math.tan(Number(x)); + const res = Function('__sqrt','__sin','__cos','__tan', `"use strict"; return (${expr});`)(__sqrt,__sin,__cos,__tan); + if (!isFinite(res)) throw new Error('错误'); + result.value = res; + return res; + } + } catch (err) { + errorMsg.value = '错误'; + return null; + } + } + + watch(expression, (exp) => { safeEvaluate(exp); }); + + function press(token) { + // 避免连续两个小数点 + if (token === '.' && expression.value.slice(-1) === '.') return; + expression.value += token; + } + + function op(opSymbol) { + const last = expression.value.slice(-1); + if (/[\+\-×÷\*\/\^]/.test(last)) { + expression.value = expression.value.slice(0, -1) + opSymbol; + } else { + expression.value += opSymbol; + } + } + + function func(fn) { + const map = { sqrt: 'sqrt', sin: 'sin', cos: 'cos', tan: 'tan' }; + const f = map[fn] || fn; + expression.value += f + '('; + } + + function square() { + expression.value += '^2'; + } + + function backspace() { + if (!expression.value) return; + expression.value = expression.value.slice(0, -1); + } + + function clear() { + expression.value = ''; + result.value = math.bignumber(0); + errorMsg.value = ''; + } + + function equals() { + const res = safeEvaluate(expression.value); + if (res != null) { + lastAns.value = res; + expression.value = formatBig(res); + result.value = res; + } + } + + function ans() { + expression.value += 'ANS'; + } + + function setAngle(mode) { + angleMode.value = mode; + } + + // 初始计算 + safeEvaluate(expression.value); + + return { + expression, + result, + errorMsg, + formattedExpression, + formattedResult, + angleMode, + setAngle, + press, + op, + func, + clear, + backspace, + equals, + square, + ans, + }; + }, + }).mount('#app'); +})(); \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/计算器/index.html b/InfoGenie-frontend/public/toolbox/计算器/index.html new file mode 100644 index 00000000..47793762 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/计算器/index.html @@ -0,0 +1,63 @@ + + + + + + 🖩网页计算器 + + + +
    +
    +
    🖩网页计算器
    +
    + +
    +
    {{ formattedExpression }}
    +
    {{ errorMsg || formattedResult }}
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + + + + + + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/计算器/styles.css b/InfoGenie-frontend/public/toolbox/计算器/styles.css new file mode 100644 index 00000000..50eb56c1 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/计算器/styles.css @@ -0,0 +1,138 @@ +:root { + --bg-start: #d9f7d9; + --bg-end: #e9fbd7; + --btn-bg-1: #f7fff0; + --btn-bg-2: #efffe6; + --accent-1: #a6e3a1; + --accent-2: #8fd68b; + --text: #173b2b; + --text-soft: #406a53; +} + +html, body { height: 100%; } + +body { + margin: 0; + font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', 'PingFang SC', 'Microsoft YaHei', 'Heiti SC', 'WenQuanYi Micro Hei', sans-serif; + background: linear-gradient(135deg, var(--bg-start), var(--bg-end)); + color: var(--text); + overflow: auto; /* 保留滚动效果 */ + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; +} + +/* 隐藏滚动条 */ +html::-webkit-scrollbar, body::-webkit-scrollbar { display: none; width: 0; height: 0; } +html, body { scrollbar-width: none; } + +.calculator { + max-width: 420px; + margin: 0 auto; + min-height: 100vh; + padding: 12px env(safe-area-inset-right) 24px env(safe-area-inset-left); + display: flex; + flex-direction: column; + gap: 10px; +} + +.topbar { + display: flex; + justify-content: space-between; + align-items: center; +} + +.brand { + font-weight: 600; + letter-spacing: 0.5px; +} + +.angle-toggle { + display: inline-flex; + background: rgba(255,255,255,0.35); + border-radius: 999px; + padding: 3px; +} + +.angle-toggle button { + appearance: none; + border: none; + background: transparent; + padding: 8px 12px; + border-radius: 999px; + color: #24543a; + font-weight: 600; +} + +.angle-toggle button.active { + background: #b8e2b1; + box-shadow: 0 1px 2px rgba(0,0,0,0.08) inset; +} + +.display { + background: rgba(255,255,255,0.6); + border-radius: 14px; + padding: 12px 14px; + box-shadow: 0 4px 12px rgba(0,0,0,0.06); +} + +.expression { + min-height: 28px; + font-size: 18px; + color: var(--text-soft); + word-break: break-all; +} + +.result { + font-size: 32px; + font-weight: 700; + text-align: right; + color: var(--text); + padding-top: 4px; +} + +.result.error { color: #d35454; } + +.keypad { + display: grid; + grid-template-columns: repeat(4, 1fr); + gap: 10px; +} + +.keypad button { + appearance: none; + border: none; + border-radius: 12px; + padding: 14px 0; + min-height: 58px; /* 移动端友好触控 */ + font-size: 18px; + font-weight: 600; + color: var(--text); + background: linear-gradient(180deg, var(--btn-bg-1), var(--btn-bg-2)); + box-shadow: 0 2px 6px rgba(0,0,0,0.08); + -webkit-tap-highlight-color: transparent; +} + +.keypad button:active { + transform: translateY(1px); + box-shadow: 0 1px 4px rgba(0,0,0,0.10); +} + +.keypad .action { + background: linear-gradient(180deg, var(--accent-1), var(--accent-2)); + color: #0f2a1f; +} + +.keypad .span-2 { grid-column: span 2; } + +.tips { + opacity: 0.7; + text-align: center; + font-size: 12px; + margin-top: auto; + padding-bottom: 8px; +} + +@media (max-width: 360px) { + .keypad button { min-height: 52px; font-size: 16px; } + .result { font-size: 28px; } +} \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/记事本/index.html b/InfoGenie-frontend/public/toolbox/记事本/index.html new file mode 100644 index 00000000..2ae7d475 --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/记事本/index.html @@ -0,0 +1,260 @@ + + + + + + + 记事本 + + + +
    +
    +
    📝记事本
    + + + +
    +
    + + +
    +
    + +
    已复制到剪贴板
    + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/随机Emoji表情/index.html b/InfoGenie-frontend/public/toolbox/随机Emoji表情/index.html new file mode 100644 index 00000000..696bfcaf --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/随机Emoji表情/index.html @@ -0,0 +1,177 @@ + + + + + + 随机Emoji表情 + + + + +
    +
    +
    +
    随机 Emoji 表情
    +
    点击任意 Emoji 复制
    +
    +
    +
    +
    +
    +
    已复制!
    + + + + \ No newline at end of file diff --git a/InfoGenie-frontend/public/toolbox/随机数生成器/index.html b/InfoGenie-frontend/public/toolbox/随机数生成器/index.html new file mode 100644 index 00000000..b3cc1edd --- /dev/null +++ b/InfoGenie-frontend/public/toolbox/随机数生成器/index.html @@ -0,0 +1,242 @@ + + + + + 随机数生成器 + + + +
    +
    +
    +

    随机数生成器

    +
    设置范围与数量,一键生成(整数,包含最小值与最大值)。
    +
    +
    +
    +
    + + +
    +
    + + +
    +
    + +
    + +
    + + +
    +
    最多一次生成 100 个。若最小值大于最大值,将自动互换。
    +
    + +
    + + +
    +
    + + +
    +
    + + + +
    + \ No newline at end of file diff --git a/InfoGenie-frontend/src/assets/fonts/MinecraftAE.ttf b/InfoGenie-frontend/src/assets/fonts/MinecraftAE.ttf new file mode 100644 index 00000000..330c0743 Binary files /dev/null and b/InfoGenie-frontend/src/assets/fonts/MinecraftAE.ttf differ diff --git a/InfoGenie-frontend/src/assets/fonts/kaiti1.ttf b/InfoGenie-frontend/src/assets/fonts/kaiti1.ttf new file mode 100644 index 00000000..e3c7007c Binary files /dev/null and b/InfoGenie-frontend/src/assets/fonts/kaiti1.ttf differ diff --git a/InfoGenie-frontend/src/components/Footer.js b/InfoGenie-frontend/src/components/Footer.js index c286a26a..49535011 100755 --- a/InfoGenie-frontend/src/components/Footer.js +++ b/InfoGenie-frontend/src/components/Footer.js @@ -101,7 +101,7 @@ const Footer = () => { - 蜀ICP备2025151694号 | Copyright © 2025-{currentYear} + 蜀ICP备2025151694号 | Copyright © 2025-{currentYear} diff --git a/InfoGenie-frontend/src/components/Header.js b/InfoGenie-frontend/src/components/Header.js index d9b414a1..4bdaddc8 100755 --- a/InfoGenie-frontend/src/components/Header.js +++ b/InfoGenie-frontend/src/components/Header.js @@ -197,7 +197,13 @@ const MobileMenuContent = styled.div.withConfig({ right: 0; width: 280px; height: 100vh; - background: white; + background: linear-gradient(135deg, + rgba(255, 240, 245, 0.95) 0%, /* 淡粉红色 */ + rgba(255, 253, 240, 0.95) 35%, /* 淡黄色 */ + rgba(240, 255, 240, 0.95) 70%, /* 淡绿色 */ + rgba(248, 250, 252, 0.95) 100% /* 接近白色 */ + ); + backdrop-filter: blur(10px); transform: translateX(${props => props.isOpen ? '0' : '100%'}); transition: transform 0.3s ease; padding: 20px; diff --git a/InfoGenie-frontend/src/config/StaticPageConfig.js b/InfoGenie-frontend/src/config/StaticPageConfig.js index 2730467d..1e923713 100755 --- a/InfoGenie-frontend/src/config/StaticPageConfig.js +++ b/InfoGenie-frontend/src/config/StaticPageConfig.js @@ -28,7 +28,7 @@ export const AI_MODEL_APPS = [ IsShow: true }, { - title: 'AI翻译助手', + title: 'AI翻译官', description: '基于AI的翻译工具', link: '/aimodelapp/AI语言翻译助手/index.html', gradient: 'linear-gradient(135deg,rgb(80, 77, 243) 0%,rgb(30, 211, 111) 100%)', @@ -59,13 +59,29 @@ export const AI_MODEL_APPS = [ icon: '🐧', IsShow: true }, + { + title: 'AI文章排版', + description: '将您的文章添加Emoji美化,并排版成markdown格式', + link: '/aimodelapp/AI文章排版/index.html', + gradient: 'linear-gradient(135deg,rgba(238, 252, 113, 1) 0%,rgba(9, 185, 103, 1) 100%)', + icon: '📕', + IsShow: true + }, + { + title: 'AI亲戚称呼计算器', + description: '基于AI的中国亲戚关系查询工具', + link: '/aimodelapp/AI中国亲戚称呼计算器/index.html', + gradient: 'linear-gradient(135deg,rgba(48, 155, 255, 1) 0%,rgba(230, 107, 255, 1) 100%)', + icon: '👨‍👩‍👧', + IsShow: true + }, ]; //休闲游戏 export const SMALL_GAMES = [ { title: '2048', - description: '经典数字合并游戏,挑战你的策略思维', + description: '经典数字合并游戏,挑战你的数学思维', link: '/smallgame/2048/index.html', gradient: 'linear-gradient(135deg, #f093fb 0%, #f5576c 100%)', icon: '🔢', @@ -81,7 +97,7 @@ export const SMALL_GAMES = [ }, { title: '俄罗斯方块', - description: '经典落块消除游戏,永恒的经典之作', + description: '十分解压的方块消除游戏,永恒的经典之作', link: '/smallgame/俄罗斯方块/index.html', gradient: 'linear-gradient(135deg, #4ade80 0%, #22c55e 100%)', icon: '🧩', @@ -89,20 +105,44 @@ export const SMALL_GAMES = [ }, { title: '贪吃蛇', - description: '经典贪吃蛇游戏,考验你的反应速度和手指协调', + description: '有趣的贪吃蛇游戏,考验你的操作速度和策略', link: '/smallgame/贪吃蛇/index.html', gradient: 'linear-gradient(135deg,rgb(37, 132, 240) 0%, #f5576c 100%)', icon: '🐍', IsShow: true }, - { + { title: '扫雷', - description: '经典扫雷游戏,考验你的反应速度和手指协调', + description: '经典扫雷游戏,考验你的思维能力和策略', link: '/smallgame/扫雷/index.html', gradient: 'linear-gradient(135deg,rgb(37, 132, 240) 0%, #f5576c 100%)', icon: '💣', IsShow: true }, + { + title: '躲树叶', + description: '躲避掉落的树叶,加油坚持到最后', + link: '/smallgame/躲树叶/index.html', + gradient: 'linear-gradient(135deg,rgba(26, 231, 70, 1) 0%, #14d9fcff 100%)', + icon: '🌳', + IsShow: true + }, + { + title: '打飞机', + description: '用子弹击落飞来的敌机,坚持到最后', + link: '/smallgame/打飞机/index.html', + gradient: 'linear-gradient(135deg,rgba(240, 96, 204, 1) 0%, #ff405aff 100%)', + icon: '✈️', + IsShow: true + }, + { + title: '跑酷', + description: '躲避障碍物,吃掉更多的金币', + link: '/smallgame/跑酷/index.html', + gradient: 'linear-gradient(135deg,rgba(64, 61, 255, 1) 0%, #28eaf8ff 100%)', + icon: '🏃‍♂️', + IsShow: true + }, ]; //聚合应用 @@ -111,71 +151,95 @@ export const API_60S_CATEGORIES = [ title: '热搜榜单', icon: '🔥', color: '#ff6b6b', + description: '实时追踪各大平台热门话题,掌握最新网络动态和流行趋势', apis: [ - { title: '哔哩哔哩热搜榜', link: '/60sapi/热搜榜单/哔哩哔哩热搜榜/index.html', icon: '📺', IsShow: true }, + { title: '哔哩哔哩热搜', link: '/60sapi/热搜榜单/哔哩哔哩热搜榜/index.html', icon: '📺', IsShow: true }, { title: '抖音热搜榜', link: '/60sapi/热搜榜单/抖音热搜榜/index.html', icon: '🎵', IsShow: true }, - { title: '小红书热搜榜', link: '/60sapi/热搜榜单/小红书热点/index.html', icon: '📖', IsShow: true }, - { title: '猫眼票房排行榜', link: '/60sapi/热搜榜单/猫眼票房排行榜/index.html', icon: '🎬', IsShow: true }, - { title: '猫眼电视收视率排行榜', link: '/60sapi/热搜榜单/猫眼电视收视排行/index.html', icon: '📺', IsShow: true }, - { title: '猫眼电影实时票房', link: '/60sapi/热搜榜单/猫眼电影实时票房/index.html', icon: '🎬', IsShow: true }, - { title: '猫眼网剧实时热搜榜', link: '/60sapi/热搜榜单/猫眼网剧实时热度/index.html', icon: '💻', IsShow: true }, - { title: '今日头条热搜榜', link: '/60sapi/热搜榜单/头条热搜榜/index.html', icon: '📰', IsShow: true }, - { title: '网易云榜单', link: '/60sapi/热搜榜单/网易云榜单/index.html', icon: '🎶', IsShow: true }, + { title: '小红书热搜榜', link: '/60sapi/热搜榜单/小红书热点/index.html', icon: '🍠', IsShow: true }, + { title: '百度热搜榜', link: '/60sapi/热搜榜单/百度实时热搜/index.html', icon: '🔍', IsShow: true }, { title: '微博热搜榜', link: '/60sapi/热搜榜单/微博热搜榜/index.html', icon: '📱', IsShow: true }, - { title: '知乎热门话题', link: '/60sapi/热搜榜单/知乎热门话题/index.html', icon: '💡', IsShow: true }, - { title: 'HackerNews HotRanks', link: '/60sapi/热搜榜单/Hacker News 榜单/index.html', icon: '💻', IsShow: true }, - - { title: '百度实时热搜榜', link: '/60sapi/热搜榜单/百度实时热搜/index.html', icon: '🔍', IsShow: true }, - { title: '百度电视剧热搜榜', link: '/60sapi/热搜榜单/百度电视剧榜/index.html', icon: '📺', IsShow: true }, - { title: '百度贴吧话题榜', link: '/60sapi/热搜榜单/百度贴吧话题榜/index.html', icon: '💬', IsShow: true }, + { title: '今日头条热搜', link: '/60sapi/热搜榜单/头条热搜榜/index.html', icon: '📰', IsShow: true }, { title: '懂车帝热搜榜', link: '/60sapi/热搜榜单/懂车帝热搜/index.html', icon: '🚗', IsShow: true }, + { title: '知乎热门话题', link: '/60sapi/热搜榜单/知乎热门话题/index.html', icon: '💡', IsShow: true }, + { title: '猫眼票房排行', link: '/60sapi/热搜榜单/猫眼票房排行榜/index.html', icon: '🎬', IsShow: true }, + { title: '猫眼电视热搜', link: '/60sapi/热搜榜单/猫眼电视收视排行/index.html', icon: '📺', IsShow: true }, + { title: '猫眼电影票房', link: '/60sapi/热搜榜单/猫眼电影实时票房/index.html', icon: '🎬', IsShow: true }, + { title: '猫眼网剧热搜', link: '/60sapi/热搜榜单/猫眼网剧实时热度/index.html', icon: '💻', IsShow: true }, + { title: '网易云榜单', link: '/60sapi/热搜榜单/网易云榜单/index.html', icon: '🎶', IsShow: true }, + { title: 'HackerNews', link: '/60sapi/热搜榜单/Hacker News 榜单/index.html', icon: '💻', IsShow: true }, + { title: '百度电视剧热搜', link: '/60sapi/热搜榜单/百度电视剧榜/index.html', icon: '📺', IsShow: true }, + { title: '百度贴吧热搜', link: '/60sapi/热搜榜单/百度贴吧话题榜/index.html', icon: '💬', IsShow: true }, + ] }, { title: '日更资讯', icon: '📰', color: '#81c784', + description: '每日精选优质内容,提供最新资讯和实用信息', apis: [ - { title: '必应每日壁纸', link: '/60sapi/日更资讯/必应每日壁纸/index.html', icon: '🖼️', IsShow: true }, + { title: '每日必应壁纸', link: '/60sapi/日更资讯/必应每日壁纸/index.html', icon: '🖼️', IsShow: true }, { title: '历史上的今天', link: '/60sapi/日更资讯/历史上的今天/index.html', icon: '📅', IsShow: true }, { title: '每日国际汇率', link: '/60sapi/日更资讯/每日国际汇率/index.html', icon: '💱', IsShow: true }, - { title: '每天60s读懂世界', link: '/60sapi/日更资讯/每天60s读懂世界/index.html', icon: '🌍', IsShow: true } + { title: '每日60s新闻', link: '/60sapi/日更资讯/每天60s读懂世界/index.html', icon: '🌍', IsShow: true } ] }, { title: '实用功能', icon: '🛠️', color: '#45b7d1', + description: '集成多种便民工具,让生活和工作更加便捷高效', apis: [ { title: '百度百科词条', link: '/60sapi/实用功能/百度百科词条/index.html', icon: '📚', IsShow: true }, - { title: '公网IP地址', link: '/60sapi/实用功能/公网IP地址/index.html', icon: '🌐', IsShow: true }, + { title: '查询公网IP', link: '/60sapi/实用功能/公网IP地址/index.html', icon: '🌐', IsShow: true }, { title: '哈希解压压缩', link: '/60sapi/实用功能/哈希解压压缩/index.html', icon: '🗜️', IsShow: true }, { title: '链接OG信息', link: '/60sapi/实用功能/链接OG信息/index.html', icon: '🔗', IsShow: false }, { title: '密码强度检测', link: '/60sapi/实用功能/密码强度检测/index.html', icon: '🔐', IsShow: true }, { title: '农历信息', link: '/60sapi/实用功能/农历信息/index.html', icon: '📅', IsShow: true }, { title: '配色方案', link: '/60sapi/实用功能/配色方案/index.html', icon: '🎨', IsShow: true }, { title: '身体健康分析', link: '/60sapi/实用功能/身体健康分析/index.html', icon: '🏥', IsShow: true }, - { title: '生成二维码', link: '/60sapi/实用功能/生成二维码/index.html', icon: '📱', IsShow: true }, + { title: '二维码生成', link: '/60sapi/实用功能/生成二维码/index.html', icon: '📱', IsShow: true }, { title: '随机密码生成器', link: '/60sapi/实用功能/随机密码生成器/index.html', icon: '🔒', IsShow: true }, - { title: '随机颜色', link: '/60sapi/实用功能/随机颜色/index.html', icon: '🌈', IsShow: true }, + { title: '随机颜色生成器', link: '/60sapi/实用功能/随机颜色/index.html', icon: '🌈', IsShow: true }, { title: '天气预报', link: '/60sapi/实用功能/天气预报/index.html', icon: '🌤️', IsShow: true }, { title: 'EpicGames免费游戏', link: '/60sapi/实用功能/EpicGames免费游戏/index.html', icon: '🎮', IsShow: true }, { title: '在线机器翻译', link: '/60sapi/实用功能/在线翻译/index.html', icon: '🌍', IsShow: false }, + //新增的 + { title: '在线白板', link: '/toolbox/白板/index.html', icon: '🀆', IsShow: true }, + { title: '记事本', link: '/toolbox/记事本/index.html', icon: '🗒️', IsShow: true }, + { title: '视频播放器', link: '/toolbox/视频播放器/index.html', icon: '▶️', IsShow: true }, + { title: '图片转Base64编码', link: '/toolbox/图片转Base64编码/index.html', icon: '🔀', IsShow: true }, + { title: '在线JavaScript执行', link: '/toolbox/在线JavaScript执行/index.html', icon: '🟩', IsShow: true }, + { title: 'Json编辑器', link: '/toolbox/Json编辑器/index.html', icon: '📑', IsShow: true }, + { title: 'Markdown解析器', link: '/toolbox/Markdown解析器/index.html', icon: '⌨︎', IsShow: true }, + { title: 'AI聊天', link: '/toolbox/AI聊天/index.html', icon: '🤖', IsShow: true }, + { title: '随机数生成器', link: '/toolbox/随机数生成器/index.html', icon: '🎲', IsShow: true }, + { title: '图片黑白处理', link: '/toolbox/图片黑白处理/index.html', icon: '🖻', IsShow: true }, + { title: '图片圆角处理', link: '/toolbox/图片圆角处理/index.html', icon: '🖼', IsShow: true }, + ] }, { title: '娱乐消遣', icon: '🎉', color: '#f7b731', + description: '轻松有趣的娱乐内容,为您的闲暇时光增添乐趣', apis: [ - { title: '随机唱歌音频', link: '/60sapi/娱乐消遣/随机唱歌音频/index.html', icon: '🎤', IsShow: true }, + { title: '哼歌一曲', link: '/60sapi/娱乐消遣/随机唱歌音频/index.html', icon: '🎤', IsShow: true }, { title: '随机发病文学', link: '/60sapi/娱乐消遣/随机发病文学/index.html', icon: '📖', IsShow: false }, - { title: '随机搞笑段子', link: '/60sapi/娱乐消遣/随机搞笑段子/index.html', icon: '😂', IsShow: true }, - { title: '随机冷笑话', link: '/60sapi/娱乐消遣/随机冷笑话/index.html', icon: '😄', IsShow: true }, + { title: '段子游乐场', link: '/60sapi/娱乐消遣/随机搞笑段子/index.html', icon: '😂', IsShow: true }, + { title: '冷笑话大全', link: '/60sapi/娱乐消遣/随机冷笑话/index.html', icon: '😄', IsShow: true }, { title: '随机一言', link: '/60sapi/娱乐消遣/随机一言/index.html', icon: '💭', IsShow: true }, - { title: '随机运势', link: '/60sapi/娱乐消遣/随机运势/index.html', icon: '⭐', IsShow: true }, - { title: '随机JavaScript趣味题', link: '/60sapi/娱乐消遣/随机JavaScript趣味题/index.html', icon: '💻', IsShow: true }, - { title: '随机KFC文案', link: '/60sapi/娱乐消遣/随机KFC文案/index.html', icon: '🍗', IsShow: true } + { title: '水晶球占卜', link: '/60sapi/娱乐消遣/随机运势/index.html', icon: '⭐', IsShow: true }, + { title: 'JavaScript趣味题', link: '/60sapi/娱乐消遣/随机JavaScript趣味题/index.html', icon: '💻', IsShow: true }, + { title: '疯狂星期四', link: '/60sapi/娱乐消遣/随机KFC文案/index.html', icon: '🍗', IsShow: true }, + { title: '真理之道', link: '/60sapi/娱乐消遣/随机答案之书/index.html', icon: '📘', IsShow: true }, + { title: '随机Emoji', link: '/toolbox/随机Emoji表情/index.html', icon: '😊', IsShow: true }, + + { title: '人生倒计时', link: '/toolbox/人生倒计时/index.html', icon: '⏲️', IsShow: true }, + { title: '数字时钟', link: '/toolbox/数字时钟/index.html', icon: '⏲︎', IsShow: true }, + { title: '做决定转盘', link: '/toolbox/做决定转盘/index.html', icon: '🎡', IsShow: true }, + ] } ]; diff --git a/InfoGenie-frontend/src/config/env.js b/InfoGenie-frontend/src/config/env.js index 770cd243..85253079 100644 --- a/InfoGenie-frontend/src/config/env.js +++ b/InfoGenie-frontend/src/config/env.js @@ -1,11 +1,26 @@ // 环境配置文件 // 统一管理所有环境变量配置 +// 获取环境变量中的 API URL,如果为空则使用当前域名 +const getApiUrl = () => { + // 优先使用环境变量 + const envApiUrl = process.env.REACT_APP_API_URL; + + // 如果环境变量存在且不为空,使用环境变量 + if (envApiUrl && envApiUrl.trim() !== '') { + return envApiUrl; + } + + // 否则使用当前域名(Docker 环境) + return window.location.origin; +}; + // 统一环境配置 const config = { - //API_URL: 'https://infogenie.api.shumengya.top', - API_URL: 'http://127.0.0.1:5002', // 确保本地开发环境正常工作 - DEBUG: true, + API_URL: getApiUrl(), // Docker 环境: 使用当前域名,开发环境可通过 .env 配置 + //API_URL: 'http://127.0.0.1:5002', // 本地开发环境(在 .env.development 中配置) + //API_URL: 'https://infogenie.api.shumengya.top', // 原生产环境(在 .env.production 中配置) + DEBUG: process.env.REACT_APP_DEBUG === 'true', LOG_LEVEL: 'debug' }; diff --git a/InfoGenie-frontend/src/pages/AboutPage.js b/InfoGenie-frontend/src/pages/AboutPage.js index 20cab754..fb4ff570 100644 --- a/InfoGenie-frontend/src/pages/AboutPage.js +++ b/InfoGenie-frontend/src/pages/AboutPage.js @@ -34,7 +34,7 @@ const PageHeader = styled.div` const PageTitle = styled.h1` color: white; - font-size: 44.8px; + font-size: 40px; font-weight: 700; margin-bottom: 10px; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); @@ -224,7 +224,7 @@ const AboutPage = () => { 关于我们 - 了解万象口袋的更多信息和功能特色(,,・ω・,,) + 了解万象口袋的更多信息和功能特色(,,・ω・,,) @@ -251,7 +251,6 @@ const AboutPage = () => { Web端在线体验 - https://infogenie.shumengya.top @@ -261,7 +260,6 @@ const AboutPage = () => { 最新版下载地址 - https://work.shumengya.top/#/work/InfoGenie diff --git a/InfoGenie-frontend/src/pages/AiModelPage.js b/InfoGenie-frontend/src/pages/AiModelPage.js index 548128aa..47128a6b 100755 --- a/InfoGenie-frontend/src/pages/AiModelPage.js +++ b/InfoGenie-frontend/src/pages/AiModelPage.js @@ -1,5 +1,6 @@ import React, { useState, useEffect } from 'react'; import { useNavigate } from 'react-router-dom'; +import { createPortal } from 'react-dom'; import styled from 'styled-components'; import { FiCpu, FiUser, FiExternalLink, FiArrowLeft } from 'react-icons/fi'; import { useUser } from '../contexts/UserContext'; @@ -13,6 +14,7 @@ const AiContainer = styled.div` opacity: 0; transform: translateY(20px); animation: pageEnter 0.8s ease-out forwards; + position: relative; @keyframes pageEnter { 0% { @@ -39,7 +41,7 @@ const PageHeader = styled.div` const PageTitle = styled.h1` color: white; - font-size: 44.8px; + font-size: 40px; font-weight: 700; margin-bottom: 10px; text-shadow: 0 2px 10px rgba(0, 0, 0, 0.3); @@ -62,11 +64,20 @@ const PageDescription = styled.p` const LoginPrompt = styled.div` background: white; - border-radius: 16px; + border-radius: 0; padding: 60px 40px; text-align: center; - box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1); - margin-bottom: 40px; + box-shadow: none; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + min-height: 100vh; + display: flex; + flex-direction: column; + justify-content: center; + align-items: center; `; const AppGrid = styled.div` @@ -74,6 +85,18 @@ const AppGrid = styled.div` grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px; margin-bottom: 40px; + + @media (max-width: 768px) { + grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); + gap: 16px; + margin-bottom: 32px; + } + + @media (max-width: 480px) { + grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); + gap: 12px; + margin-bottom: 24px; + } `; const AppCard = styled.div` @@ -91,6 +114,16 @@ const AppCard = styled.div` box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15); border-color: #4ade80; } + + @media (max-width: 768px) { + padding: 18px; + border-radius: 12px; + } + + @media (max-width: 480px) { + padding: 16px; + border-radius: 10px; + } `; const AppHeader = styled.div` @@ -105,11 +138,27 @@ const AppTitle = styled.h3` font-weight: bold; color: #1f2937; margin: 0; + + @media (max-width: 768px) { + font-size: 18px; + } + + @media (max-width: 480px) { + font-size: 16px; + } `; const AppIcon = styled.div` font-size: 24px; color: #4ade80; + + @media (max-width: 768px) { + font-size: 22px; + } + + @media (max-width: 480px) { + font-size: 20px; + } `; const AppDescription = styled.p` @@ -117,6 +166,18 @@ const AppDescription = styled.p` font-size: 14px; line-height: 1.5; margin-bottom: 16px; + + @media (max-width: 768px) { + font-size: 13px; + margin-bottom: 14px; + line-height: 1.4; + } + + @media (max-width: 480px) { + font-size: 12px; + margin-bottom: 12px; + line-height: 1.3; + } `; const AppFooter = styled.div` @@ -135,6 +196,20 @@ const AppTheme = styled.div` font-size: 24px; background: rgba(74, 222, 128, 0.1); border: 1px solid rgba(74, 222, 128, 0.3); + + @media (max-width: 768px) { + width: 36px; + height: 36px; + font-size: 20px; + border-radius: 6px; + } + + @media (max-width: 480px) { + width: 32px; + height: 32px; + font-size: 18px; + border-radius: 5px; + } `; const LaunchButton = styled.button` @@ -155,6 +230,20 @@ const LaunchButton = styled.button` transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74, 222, 128, 0.3); } + + @media (max-width: 768px) { + padding: 7px 14px; + font-size: 13px; + border-radius: 6px; + gap: 5px; + } + + @media (max-width: 480px) { + padding: 6px 12px; + font-size: 12px; + border-radius: 5px; + gap: 4px; + } `; const LoginIcon = styled.div` @@ -196,68 +285,237 @@ const LoginButton = styled.button` } `; -const EmbeddedContainer = styled.div` - position: fixed; - top: 0; - left: 0; - width: 100%; - height: 100%; - background: #000; - z-index: 1000; - display: flex; - align-items: center; - justify-content: center; - padding: 0; -`; +// 独立全屏嵌套网页组件 +const FullscreenEmbeddedPage = ({ app, onClose }) => { + useEffect(() => { + // 禁用页面滚动 + document.body.style.overflow = 'hidden'; + + // 键盘事件监听 + const handleKeyDown = (e) => { + if (e.key === 'Escape') { + onClose(); + } + }; + + document.addEventListener('keydown', handleKeyDown); + + return () => { + // 恢复页面滚动 + document.body.style.overflow = 'auto'; + document.removeEventListener('keydown', handleKeyDown); + }; + }, [onClose]); -const EmbeddedContent = styled.div` - background: white; - border-radius: 0; - width: 100%; - height: 100%; - position: relative; - overflow: hidden; - box-shadow: none; -`; + const fullscreenStyles = { + position: 'fixed', + top: 0, + left: 0, + width: '100vw', + height: '100vh', + backgroundColor: '#ffffff', + zIndex: 999999, + display: 'flex', + flexDirection: 'column', + fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif', + margin: 0, + padding: 0, + boxSizing: 'border-box', + // 重置所有可能的继承样式 + fontSize: '16px', + lineHeight: '1.5', + color: '#333', + textAlign: 'left', + textDecoration: 'none', + textTransform: 'none', + letterSpacing: 'normal', + wordSpacing: 'normal', + textShadow: 'none', + boxShadow: 'none', + border: 'none', + borderRadius: 0, + outline: 'none', + transform: 'none', + transition: 'none', + animation: 'none', + filter: 'none', + backdropFilter: 'none', + opacity: 1, + visibility: 'visible', + overflow: 'hidden' + }; -const EmbeddedHeader = styled.div` - background: linear-gradient(135deg, #4ade80, #22c55e); - color: white; - padding: 15px 20px; - padding-top: max(15px, env(safe-area-inset-top)); - display: flex; - align-items: center; - justify-content: space-between; - position: relative; - z-index: 1001; -`; + const headerStyles = { + backgroundColor: '#4ade80', + color: '#ffffff', + padding: '12px 20px', + display: 'flex', + alignItems: 'center', + justifyContent: 'space-between', + boxShadow: '0 2px 8px rgba(0,0,0,0.1)', + flexShrink: 0, + minHeight: '56px', + boxSizing: 'border-box', + margin: 0, + border: 'none', + borderRadius: 0, + fontSize: '16px', + fontWeight: 'normal', + textAlign: 'left', + textDecoration: 'none', + textTransform: 'none', + letterSpacing: 'normal', + wordSpacing: 'normal', + textShadow: 'none', + transform: 'none', + transition: 'none', + animation: 'none', + filter: 'none', + backdropFilter: 'none', + opacity: 1, + visibility: 'visible', + overflow: 'visible' + }; -const BackButton = styled.button` - background: rgba(255, 255, 255, 0.2); - border: none; - color: white; - padding: 8px 16px; - border-radius: 20px; - cursor: pointer; - display: flex; - align-items: center; - gap: 8px; - font-size: 14px; - transition: all 0.3s ease; - - &:hover { - background: rgba(255, 255, 255, 0.3); - } -`; + const titleStyles = { + fontSize: '18px', + fontWeight: '500', + margin: 0, + padding: 0, + color: '#ffffff', + textAlign: 'left', + textDecoration: 'none', + textTransform: 'none', + letterSpacing: 'normal', + wordSpacing: 'normal', + textShadow: 'none', + boxShadow: 'none', + border: 'none', + borderRadius: 0, + outline: 'none', + transform: 'none', + transition: 'none', + animation: 'none', + filter: 'none', + backdropFilter: 'none', + opacity: 1, + visibility: 'visible', + overflow: 'visible', + boxSizing: 'border-box' + }; -const EmbeddedFrame = styled.iframe` - width: 100%; - height: calc(100% - 60px); - border: none; - background: white; - position: relative; - z-index: 1000; -`; + const backButtonStyles = { + backgroundColor: 'rgba(255, 255, 255, 0.15)', + color: '#ffffff', + border: 'none', + padding: '8px 16px', + borderRadius: '6px', + cursor: 'pointer', + display: 'flex', + alignItems: 'center', + gap: '6px', + fontSize: '14px', + fontWeight: '500', + transition: 'background-color 0.2s ease', + margin: 0, + textAlign: 'center', + textDecoration: 'none', + textTransform: 'none', + letterSpacing: 'normal', + wordSpacing: 'normal', + textShadow: 'none', + boxShadow: 'none', + outline: 'none', + transform: 'none', + animation: 'none', + filter: 'none', + backdropFilter: 'none', + opacity: 1, + visibility: 'visible', + overflow: 'visible', + boxSizing: 'border-box' + }; + + const iframeStyles = { + width: '100%', + height: 'calc(100vh - 56px)', + border: 'none', + backgroundColor: '#ffffff', + flexGrow: 1, + margin: 0, + padding: 0, + boxSizing: 'border-box', + fontSize: '16px', + lineHeight: '1.5', + color: '#333', + textAlign: 'left', + textDecoration: 'none', + textTransform: 'none', + letterSpacing: 'normal', + wordSpacing: 'normal', + textShadow: 'none', + boxShadow: 'none', + borderRadius: 0, + outline: 'none', + transform: 'none', + transition: 'none', + animation: 'none', + filter: 'none', + backdropFilter: 'none', + opacity: 1, + visibility: 'visible', + overflow: 'hidden' + }; + + const handleBackButtonHover = (e) => { + e.target.style.backgroundColor = 'rgba(255, 255, 255, 0.25)'; + }; + + const handleBackButtonLeave = (e) => { + e.target.style.backgroundColor = 'rgba(255, 255, 255, 0.15)'; + }; + + // 在iframe加载时注入token + const handleIframeLoad = (e) => { + try { + const iframe = e.target; + const token = localStorage.getItem('token'); + + if (iframe && iframe.contentWindow && token) { + // 将token传递给iframe + iframe.contentWindow.localStorage.setItem('token', token); + } + } catch (error) { + console.error('iframe通信错误:', error); + } + }; + + return ( +
    +
    +

    {app.title}

    + +
    +