import os
import re

def update_credentials(filepath):
    with open(filepath, 'r') as f:
        content = f.read()

    # Define replacements
    email = "ilyass@anthonyemanuel.com"
    domain = "anthonyemanuel.com"
    
    # We must handle both the raw string {{EMAIL}} and the JSX version {"{{EMAIL}}"}
    content = content.replace('{"{{EMAIL}}"}', email)
    content = content.replace('{{EMAIL}}', email)
    
    content = content.replace('{"{{DOMAIN}}"}', domain)
    content = content.replace('{{DOMAIN}}', domain)

    with open(filepath, 'w') as f:
        f.write(content)

# We update everywhere
for root, dirs, files in os.walk('.'):
    if 'node_modules' in root or '.git' in root or '.next' in root or 'out' in root:
        continue
    for file in files:
        if file.endswith('.tsx') or file.endswith('.ts') or file.endswith('.php') or file.endswith('.xml') or file.endswith('.md'):
            update_credentials(os.path.join(root, file))

print("Credentials updated")
