#!/usr/bin/env python3
"""Blur client names - v4 targeting exact text positions."""

from PIL import Image, ImageFilter
import os

input_path = "/Users/assafdagan/.clawdbot/media/inbound/f01c84e1-5f12-4bcf-bfb8-257edba844eb.jpg"
output_path = "/Users/assafdagan/clawd/output/blurred-status-v4.jpg"

img = Image.open(input_path)
w, h = img.size
print(f"Image size: {w}x{h}")

# Based on what's visible in the image, targeting specific text regions
blur_regions = [
    # "Phat Foods:" first bullet (leave some of Week 1 visible)
    (30, 118, 240, 175),
    
    # "Spoken:" and "Dovi remarks" on second bullet
    (30, 185, 600, 235),
    
    # "SparkBeyond, White Space, Finally Foods" on General line
    (170, 232, 710, 285),
    
    # "1. Phat Foods Deadline Approaching" header
    (15, 395, 600, 450),
    
    # "2. Spoken Project (Dovi Remarks)" header  
    (15, 570, 630, 628),
    
    # "Phat Foods check-in" in Tomorrow's Priorities section
    (35, 1060, 390, 1118),
    
    # "Complete Dovi review" 
    (35, 1120, 410, 1180),
]

result = img.copy()

for i, (x1, y1, x2, y2) in enumerate(blur_regions):
    x1 = max(0, x1)
    y1 = max(0, y1) 
    x2 = min(w, x2)
    y2 = min(h, y2)
    
    cropped = img.crop((x1, y1, x2, y2))
    blurred = cropped.filter(ImageFilter.GaussianBlur(radius=25))
    result.paste(blurred, (x1, y1))
    print(f"Region {i+1}: y={y1}-{y2}")

os.makedirs(os.path.dirname(output_path), exist_ok=True)
result.save(output_path, quality=95)
print(f"\nSaved: {output_path}")
