#!/bin/bash
# NEONCYBER - SDXL High Quality Upgrade
# Regenerate favorite prompts with SDXL for top-notch wallpaper quality
# Usage: ./generate-sdxl.sh

set -e

COMFYUI="http://192.168.1.57:8188"
TIMESTAMP=$(date +%H%M%S)

echo "🎨 NEONCYBER - SDXL High Quality"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Professional wallpaper quality - 30-40 steps"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

# Add your favorite prompts here after reviewing the showcase
# Example format:
PROMPTS=(
    # Copy your winning prompts from the showcase here
    "Cyberpunk alley with vertical pixel sorting glitch, minimal anime aesthetic. Neon signs streak downward through corrupted data. Magenta and cyan buildings sorted into digital columns. Wet pavement reflects glitched reality. Empty atmospheric mood with bokeh lights. Digital corruption as artistic medium. 1920x1080 widescreen, pixel sort masterpiece."

    # Add more prompts as needed...
)

DESCRIPTIONS=(
    "Vertical Pixel Sort"
    # Add corresponding descriptions...
)

for i in "${!PROMPTS[@]}"; do
    NUM=$((i + 1))
    PROMPT="${PROMPTS[$i]}"
    DESC="${DESCRIPTIONS[$i]}"

    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo "[$NUM/${#PROMPTS[@]}] $DESC"
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

    WORKFLOW=$(cat <<EOF
{
  "prompt": {
    "1": {"inputs": {"ckpt_name": "sd_xl_base_1.0.safetensors"}, "class_type": "CheckpointLoaderSimple"},
    "2": {"inputs": {"text": "$PROMPT", "clip": ["1", 1]}, "class_type": "CLIPTextEncode"},
    "3": {"inputs": {"text": "low quality, blurry, people, watermark, text, signature, normal photo, realistic", "clip": ["1", 1]}, "class_type": "CLIPTextEncode"},
    "4": {"inputs": {"width": 1920, "height": 1080, "batch_size": 1}, "class_type": "EmptyLatentImage"},
    "5": {"inputs": {"seed": $(python3 -c "import random; print(random.randint(1, 2**32-1))"), "steps": 35, "cfg": 7.0, "sampler_name": "euler_ancestral", "scheduler": "normal", "denoise": 1, "model": ["1", 0], "positive": ["2", 0], "negative": ["3", 0], "latent_image": ["4", 0]}, "class_type": "KSampler"},
    "6": {"inputs": {"samples": ["5", 0], "vae": ["1", 2]}, "class_type": "VAEDecode"},
    "7": {"inputs": {"filename_prefix": "wp/wp_sdxl_${TIMESTAMP}_v${NUM}", "images": ["6", 0]}, "class_type": "SaveImage"}
  }
}
EOF
)

    RESPONSE=$(curl -s -X POST "$COMFYUI/prompt" -H "Content-Type: application/json" -d "$WORKFLOW")
    PROMPT_ID=$(echo "$RESPONSE" | python3 -c "import sys, json; print(json.load(sys.stdin).get('prompt_id', ''))" 2>/dev/null || echo "")

    if [ -n "$PROMPT_ID" ]; then
        echo "✅ Queued: $PROMPT_ID"
    else
        echo "❌ Failed to queue"
    fi
    echo ""
done

echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "✨ All SDXL variants queued!"
echo ""
echo "📁 Files: ComfyUI/output/wp/"
echo "  wp_sdxl_${TIMESTAMP}_v*_*.png"
echo ""
echo "🎨 Professional quality wallpapers incoming!"
