"""board-coach.html — 去掉进度条，改为文字展示业绩小时数+下一档还需小时数"""
import re

from _env_paths import ensure_repo_root
ensure_repo_root()

filepath = "docs/h5_ui/pages/board-coach.html"
with open(filepath, "r", encoding="utf-8") as f:
    c = f.read()

# 定义每个助教的进度条区域和替换内容
replacements = [
    # 小燕: 86.2h, 下一档100h, 还差13.8h
    (
        '''                    <!-- 定档业绩：到下一档进度（本月时展示） -->
                    <div class="mt-1.5">
                        <div class="flex items-center justify-between text-xs text-gray-7 mb-1">
                            <span>星级 → 王牌</span>
                            <span class="text-primary font-medium">86.2h / 100h</span>
                        </div>
                        <div class="w-full bg-gray-2 rounded-full h-1.5">
                            <div class="bg-gradient-to-r from-primary to-blue-400 h-1.5 rounded-full" style="width:86%"></div>
                        </div>
                    </div>''',
        '''                    <div class="mt-1 flex items-center gap-2 text-xs">
                        <span class="font-bold text-primary text-sm">86.2h</span>
                        <span class="text-gray-7">下一档还需 <span class="text-warning font-medium">13.8h</span></span>
                    </div>'''
    ),
    # 泡芙: 72.5h, 下一档80h, 还差7.5h
    (
        '''                    <div class="mt-1.5">
                        <div class="flex items-center justify-between text-xs text-gray-7 mb-1">
                            <span>高级 → 星级</span>
                            <span class="text-primary font-medium">72.5h / 80h</span>
                        </div>
                        <div class="w-full bg-gray-2 rounded-full h-1.5">
                            <div class="bg-gradient-to-r from-primary to-blue-400 h-1.5 rounded-full" style="width:90%"></div>
                        </div>
                    </div>''',
        '''                    <div class="mt-1 flex items-center gap-2 text-xs">
                        <span class="font-bold text-primary text-sm">72.5h</span>
                        <span class="text-gray-7">下一档还需 <span class="text-warning font-medium">7.5h</span></span>
                    </div>'''
    ),
    # Amy: 68.0h, 下一档100h, 还差32h
    (
        '''                    <div class="mt-1.5">
                        <div class="flex items-center justify-between text-xs text-gray-7 mb-1">
                            <span>星级 → 王牌</span>
                            <span class="text-primary font-medium">68.0h / 100h</span>
                        </div>
                        <div class="w-full bg-gray-2 rounded-full h-1.5">
                            <div class="bg-gradient-to-r from-primary to-blue-400 h-1.5 rounded-full" style="width:68%"></div>
                        </div>
                    </div>''',
        '''                    <div class="mt-1 flex items-center gap-2 text-xs">
                        <span class="font-bold text-primary text-sm">68.0h</span>
                        <span class="text-gray-7">下一档还需 <span class="text-warning font-medium">32.0h</span></span>
                    </div>'''
    ),
    # Mia: 55.0h, 下一档60h, 还差5h
    (
        '''                    <div class="mt-1.5">
                        <div class="flex items-center justify-between text-xs text-gray-7 mb-1">
                            <span>中级 → 高级</span>
                            <span class="text-primary font-medium">55.0h / 60h</span>
                        </div>
                        <div class="w-full bg-gray-2 rounded-full h-1.5">
                            <div class="bg-gradient-to-r from-primary to-blue-400 h-1.5 rounded-full" style="width:92%"></div>
                        </div>
                    </div>''',
        '''                    <div class="mt-1 flex items-center gap-2 text-xs">
                        <span class="font-bold text-primary text-sm">55.0h</span>
                        <span class="text-gray-7">下一档还需 <span class="text-warning font-medium">5.0h</span></span>
                    </div>'''
    ),
    # 糖糖: 42.0h, 已达标
    (
        '''                    <div class="mt-1.5">
                        <div class="flex items-center justify-between text-xs text-gray-7 mb-1">
                            <span>初级 → 中级</span>
                            <span class="text-primary font-medium">42.0h / 40h ✅</span>
                        </div>
                        <div class="w-full bg-gray-2 rounded-full h-1.5">
                            <div class="bg-gradient-to-r from-success to-emerald-400 h-1.5 rounded-full" style="width:100%"></div>
                        </div>
                    </div>''',
        '''                    <div class="mt-1 flex items-center gap-2 text-xs">
                        <span class="font-bold text-success text-sm">42.0h</span>
                        <span class="text-success font-medium">✅ 已达标</span>
                    </div>'''
    ),
    # 露露: 38.0h, 下一档60h, 还差22h
    (
        '''                    <div class="mt-1.5">
                        <div class="flex items-center justify-between text-xs text-gray-7 mb-1">
                            <span>中级 → 高级</span>
                            <span class="text-primary font-medium">38.0h / 60h</span>
                        </div>
                        <div class="w-full bg-gray-2 rounded-full h-1.5">
                            <div class="bg-gradient-to-r from-primary to-blue-400 h-1.5 rounded-full" style="width:63%"></div>
                        </div>
                    </div>''',
        '''                    <div class="mt-1 flex items-center gap-2 text-xs">
                        <span class="font-bold text-primary text-sm">38.0h</span>
                        <span class="text-gray-7">下一档还需 <span class="text-warning font-medium">22.0h</span></span>
                    </div>'''
    ),
]

for old, new in replacements:
    if old in c:
        c = c.replace(old, new)
        print(f"  ✅ 替换成功")
    else:
        print(f"  ❌ 未找到匹配")

with open(filepath, "w", encoding="utf-8") as f:
    f.write(c)

print("board-coach.html 进度条已替换为文字")
