import re
from pathlib import Path

file_path = Path("app/modules/core/presentation/health_static.py")
content = file_path.read_text(encoding="utf-8")

def duplicate_route(match):
    full_route = match.group(0)
    # Extract the route path without /v1/erp
    original_path = match.group(1)
    
    # We only want to duplicate if it has /v1/erp
    if original_path.startswith("/v1/erp/"):
        stripped = original_path.replace("/v1/erp", "")
        # Return both the v1/erp route and the stripped route
        # Wait, if we just do:
        return f'@router.get("{stripped}", response_class=HTMLResponse)\n@router.get("{original_path}", response_class=HTMLResponse)'
    
    return full_route

# Match all @router.get lines that have response_class=HTMLResponse
new_content = re.sub(r'@router\.get\("([^"]+)", response_class=HTMLResponse\)', duplicate_route, content)

# Also handle get_lmstudio_models
new_content = new_content.replace('@router.get("/v1/erp/settings/lmstudio-models")', '@router.get("/settings/lmstudio-models")\n@router.get("/v1/erp/settings/lmstudio-models")')

file_path.write_text(new_content, encoding="utf-8")
print("Done")
