#!/usr/bin/env python3
"""
Update product pages to render tips dynamically from translations.
"""

import re

files = ['formula.html', 'bottles.html', 'wipes.html', 'breast-pumps.html']

for filename in files:
    filepath = f'/root/clawd/stroller-app/{filename}'
    
    with open(filepath, 'r') as f:
        html = f.read()
    
    # Find the tips-grid div and replace its content with a comment
    # Pattern: <div class="tips-grid"> ... </div> (may have nested divs)
    
    # Look for tips section and clear hardcoded tips
    pattern = r'(<div class="tips-grid">)(.*?)(</div>\s*</section>)'
    
    replacement = r'\1\n        <!-- Tips rendered dynamically by ProductI18n based on market -->\n      \3'
    
    html = re.sub(pattern, replacement, html, flags=re.DOTALL)
    
    with open(filepath, 'w') as f:
        f.write(html)
    
    print(f'✓ Updated {filename}')

print('\n✅ All product pages updated to render tips dynamically!')
