#!/bin/bash
# Retry failed images sequentially with delay to avoid rate limits
cd /home/z/my-project/public/images

STYLE="luxury product photography, matte black background with subtle gold bokeh, elegant dark studio scene, cinematic rim lighting, soft cyan and violet neon glow accents, ultra premium feel, high quality, detailed, centered composition, no text"

gen() {
  local file="$1"; local prompt="$2"; local size="$3"
  if [ -f "$file" ] && [ $(stat -c%s "$file") -gt 30000 ]; then echo "SKIP $file"; return; fi
  for i in 1 2 3 4; do
    if z-ai image -p "$prompt, $STYLE" -o "./$file" -s "$size"; then echo "OK $file"; return; fi
    echo "retry $i for $file, sleeping 20s..."; sleep 20
  done
  echo "FAIL $file"
}

gen hero.png "wide cinematic interior of an ultra luxury modern smart home living room at night, floor to ceiling windows, warm golden ambient lighting mixed with cyan neon LED strips, elegant dark marble and black walnut, motorized curtains glowing softly, smart wall touch panel glowing, moody atmospheric, architectural photography, high quality, detailed" 1440x720
sleep 8
gen touch-switch.png "elegant smart glass touch light switch panel on dark wall, glowing amber backlight and gold trim, minimalist luxury" 1024x1024
sleep 8
gen smart-curtain.png "luxury motorized electric curtains with sheer fabric in elegant dark penthouse, golden dusk light, automated curtain rail glowing subtly" 1024x1024
sleep 8
gen audio-system.png "premium ceiling speaker and wall audio panel with golden accents, dark luxury interior, subtle cyan sound wave glow" 1024x1024

echo "--- RESULTS ---"
for f in *.png; do echo "$f : $(stat -c%s "$f") bytes"; done
