#!/bin/bash
# NEONCYBER - Marathon (Bungie) Inspired
# Far-future geometric minimalism, alien architecture, retro-future aesthetic
# Usage: ./generate-marathon.sh

set -e

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

echo "🔺 NEONCYBER - Marathon Inspired"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo "Bungie Marathon aesthetic - far-future alien geometry"
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
echo ""

PROMPTS=(
    # 1: Ancient alien terminal room
    "Ancient alien terminal room in Marathon style, far-future minimalist aesthetic. Geometric brutalist architecture with vertical green phosphor text terminals embedded in walls. Cyan circuit patterns on dark metallic surfaces. Empty corridor with harsh angular shadows. Green and cyan low-fi computer interface glow. Retro-future 90s sci-fi aesthetic. Clean geometric composition, no organic elements. 1920x1080 widescreen, Marathon terminal quality."

    # 2: Pfhor architecture corridor
    "Alien Pfhor architecture corridor in Marathon aesthetic, far-future geometric style. Purple and red angular brutalist design. Alien glyphs and symbols on metallic panels. Harsh lighting creating dramatic geometric shadows. Empty lonely space station corridor. Clean minimal alien architecture. Low polygon retro-future aesthetic. Glitch artifacts on alien text. 1920x1080 widescreen, Pfhor design masterpiece."

    # 3: Cyborg maintenance bay
    "Cyborg maintenance bay in Marathon style, minimalist far-future industrial. Green status monitors and cyan diagnostic screens. Geometric charging stations with angular design. Dark gray metallic surfaces with circuit board patterns. Empty automated medical bay. Retro computer terminal aesthetic. Clean brutalist geometry. Digital scan line artifacts. 1920x1080 widescreen, cyborg bay quality."

    # 4: Ancient Jjaro artifact chamber
    "Ancient Jjaro civilization artifact chamber in Marathon aesthetic. Impossibly geometric alien architecture - perfect angular forms. Cyan and purple energy glows from alien technology. Massive geometric pillars and platforms. Empty archaeological discovery atmosphere. Far-future meets ancient alien. Clean minimal composition. Mathematical precision in architecture. 1920x1080 widescreen, Jjaro mystery masterpiece."

    # 5: S'pht compiler terminal
    "S'pht compiler terminal room in Marathon style, alien geometric minimalism. Green phosphor text displays showing alien code. Purple circuit patterns creating geometric lattice. Angular brutalist alien computer architecture. Empty data processing chamber. Retro terminal aesthetic meets far-future AI. Clean geometric shadows. Digital corruption artifacts. 1920x1080 widescreen, S'pht compiler quality."

    # 6: Deep space colony hub
    "Deep space colony central hub in Marathon aesthetic, far-future brutalist design. Dark metallic corridors with green emergency lighting. Cyan navigation symbols and directional arrows. Geometric angular architecture creating dramatic perspectives. Empty desolate space station. Retro-future minimalism. Harsh shadows, clean geometry. Pixel sorting glitch on signage. 1920x1080 widescreen, Marathon colony masterpiece."
)

DESCRIPTIONS=(
    "Ancient Terminal Room"
    "Pfhor Architecture"
    "Cyborg Maintenance Bay"
    "Jjaro Artifact Chamber"
    "S'pht Compiler Terminal"
    "Deep Space Colony Hub"
)

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

    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
    echo "[$NUM/6] $DESC"
    echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"

    WORKFLOW=$(cat <<EOF
{
  "prompt": {
    "1": {"inputs": {"unet_name": "z_image_turbo_bf16.safetensors", "weight_dtype": "default"}, "class_type": "UNETLoader"},
    "2": {"inputs": {"clip_name": "qwen_3_4b.safetensors", "type": "qwen_image"}, "class_type": "CLIPLoader"},
    "3": {"inputs": {"vae_name": "ae.safetensors"}, "class_type": "VAELoader"},
    "4": {"inputs": {"text": "$PROMPT", "clip": ["2", 0]}, "class_type": "CLIPTextEncode"},
    "5": {"inputs": {"text": "low quality, blurry, people, organic, rounded, soft curves, bright daylight", "clip": ["2", 0]}, "class_type": "CLIPTextEncode"},
    "6": {"inputs": {"width": 1920, "height": 1080, "batch_size": 1}, "class_type": "EmptyLatentImage"},
    "7": {"inputs": {"seed": $(python3 -c "import random; print(random.randint(1, 2**32-1))"), "steps": 8, "cfg": 1.0, "sampler_name": "euler", "scheduler": "sgm_uniform", "denoise": 1, "model": ["1", 0], "positive": ["4", 0], "negative": ["5", 0], "latent_image": ["6", 0]}, "class_type": "KSampler"},
    "8": {"inputs": {"samples": ["7", 0], "vae": ["3", 0]}, "class_type": "VAEDecode"},
    "9": {"inputs": {"filename_prefix": "wp/wp_marathon_${TIMESTAMP}_v${NUM}", "images": ["8", 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 6 Marathon variations queued!"
echo ""
echo "📁 Files: ComfyUI/output/wp/"
echo "  wp_marathon_${TIMESTAMP}_v1_*.png - Ancient Terminal Room"
echo "  wp_marathon_${TIMESTAMP}_v2_*.png - Pfhor Architecture"
echo "  wp_marathon_${TIMESTAMP}_v3_*.png - Cyborg Maintenance Bay"
echo "  wp_marathon_${TIMESTAMP}_v4_*.png - Jjaro Artifact Chamber"
echo "  wp_marathon_${TIMESTAMP}_v5_*.png - S'pht Compiler Terminal"
echo "  wp_marathon_${TIMESTAMP}_v6_*.png - Deep Space Colony Hub"
echo ""
echo "🔺 Far-future alien geometry incoming!"
