# Pack grande Mirko (45 imgs, 9/stage x 5). Generación por stages validados.
# stages: sugerente (beach) / spicy1 (billiard) / spicy2 (bed) / explicit1 (pole, half naked) / explicit2 (final nude, sin bunny)
# Uso: python Engine/_mirko_pack.py

import json
import pathlib
import sys

sys.path.insert(0, "Engine")
from api_client import ForgeClient

BASE = pathlib.Path(r"C:\Users\Usuario\Downloads\SD")
OUT = BASE / "Output" / "packs" / "mirko_bunny"
OUT.mkdir(parents=True, exist_ok=True)

MASTER = """masterpiece, best quality, highly detailed, sharp focus, very aesthetic, very awa,
detailed background, score_9, score_8_up, <lora:IFL_v1.0_IL:0.7> <lora:add-detail-xl:0.5>
<lora:blackwhiplash(bwl)-guy90-Illust-Lorav3:0.6> blaash, <lora:scara2b_ill_v1.00:0.7> scara2b-style,
<lora:Add_color_ILXLv1:3>, 1girl, solo"""

NEG = ("lowres, bad anatomy, bad hands, extra fingers, missing fingers, extra limbs, missing limbs, "
       "fused fingers, poorly drawn face, poorly drawn hands, censored, mosaic censoring, bar censor, "
       "mirror, reflection, extra person, 2girls, 2boys, duplicate, cloned face, gun, pistol")

MIRKO = "<lora:Mirko:0.8>, mirko, rabbit_ears, red_eyes, white_hair, very_long_hair, large_breasts, dark_skin, dark-skinned_female, mature_female, muscular_female, rabbit_tail"
BUNNY = "playboy_bunny, white_leotard, strapless_leotard, white_shirt, fishnet_pantyhose, rabbit_tail"

STAGES = {
 "sugerente": [
   "standing, hands on hips, muscular, beach, ocean, sunny day, looking_at_viewer, from front",
   "sitting on edge, legs crossed, leaning forward, beach, ocean, sunny day, smiling, from front",
   "sitting on sand, hands on thighs, beach, sea, day, looking_at_viewer, from front",
   "standing, hand running through hair, parted lips, beach, ocean, sunny day, from side",
   "kneeling, sitting on heels, hands on thighs, beach, sunny day, looking up, from front",
   "lying on side, propped on elbow, one leg bent, sultry gaze, beach, sand, day, from side",
   "leaning against wooden post, one leg up, arms above head, teasing smile, beach, pier, day, from front",
   "stretching arms up, arched back, confident expression, beach, sunny day, from front",
   "standing, looking over shoulder, back arch, slight smile, beach, ocean, day, from side",
 ],
 "spicy1": [
   "leaning over pool table, holding billiard cue, aiming, from side, casino, neon lights, pool table, night",
   "standing, holding cue, smiling, casino, neon lights, night, pool table, from front",
   "leaning against bar, one arm on bar, smiling, indoors, club, neon lights, night, from side",
   "sitting on bar stool, legs crossed, leaning forward, smiling, indoors, club, night, from front",
   "standing, hand on hip, weight on one leg, smiling, indoors, casino, night, from front",
   "sitting on chair, legs over armrest, lazy confident pose, indoors, lounge, night, from side",
   "bending forward slightly, hands on knees, eye contact, indoors, club, night, from front",
   "kneeling, holding tray, serving pose, indoors, club, night, from front",
   "standing, hand on hip, weight on one leg, smiling, indoors, nightclub, night, from front",
 ],
 "spicy2": [
   "lying, on_back, legs_up, knees to chest, stretching, indoors, bed, night, from front",
   "sitting on bed edge, legs crossed, leaning forward, smiling, indoors, bedroom, night, from front",
   "lying on side, propped on elbow, one leg bent, sultry gaze, indoors, bedroom, night, from side",
   "sitting on chair, legs over armrest, lazy confident pose, indoors, bedroom, night, from side",
   "stretching arms up, arched back, confident expression, indoors, bedroom, night, from front",
   "leaning against headboard, arms above head, teasing smile, indoors, bedroom, night, from front",
   "sitting on bed, hands on thighs, looking_at_viewer, indoors, bedroom, night, from front",
   "kneeling, sitting on heels, hands on thighs, looking up, indoors, bedroom, night, from front",
   "sitting with legs spread, hands between thighs, biting lip, indoors, bedroom, night, from front",
 ],
 "explicit1": [
   "pole_dancing, pole, spinning, sitting on pole, legs wrapped around pole, indoors, club, stage, night, from front",
   "pole_dancing, pole, one leg hooked around pole, arched back, arms up, indoors, club, stage, night, from front",
   "leaning over pool table, holding billiard cue, aiming, from side, casino, neon lights, pool table, night",
   "lying, on_back, legs_up, knees to chest, stretching, indoors, bed, night, from front",
   "sitting on bed edge, legs crossed, leaning forward, smiling, indoors, bedroom, night, from front",
   "standing, hands on hips, muscular, beach, ocean, sunny day, looking_at_viewer, from front",
   "bending forward slightly, hands on knees, eye contact, indoors, club, night, from front",
   "kneeling, holding tray, serving pose, indoors, club, night, from front",
   "sitting on bar stool, legs crossed, leaning forward, smiling, indoors, club, night, from front",
 ],
 "explicit2": [
   "cowgirl_position, straddling, riding, sex, vaginal, indoors, bed, night, from front",
   "on_back, spreading_legs, sex, vaginal, indoors, bed, night, from front",
   "sex_from_behind, doggystyle, bent_over, sex, deep_penetration, outdoors, forest, from behind",
   "missionary, on_back, spreading_legs, sex, indoors, bed, night, from front",
   "cowgirl_position, straddling, hands on chest, bouncing, sex, vaginal, indoors, bed, night, from front",
   "on_stomach, prone_bone, sex, vaginal, indoors, bed, night, from behind",
   "on_side, spooning, sex, indoors, bed, night, from side",
   "sitting on face, facesitting, hetero, indoors, bed, night, from front",
   "standing, sex, vaginal, indoors, bedroom, night, from front",
 ],
}

def chica(stage):
    if stage == "explicit2":
        return f"1girl, {MIRKO}"
    return f"1girl, {MIRKO}, {BUNNY}, half naked" + (", solo" if stage in ("sugerente", "spicy1", "spicy2") else "")

def couple(stage, pose):
    if stage in ("sugerente", "spicy1", "spicy2"):
        return False
    return ("hetero" in pose or "sex" in pose)

client = ForgeClient("http://127.0.0.1:7860")
assert client.check_status(), "Forge no responde"

manifest = []
for stage, poses in STAGES.items():
    for i, pose in enumerate(poses, 1):
        prompt = f"{MASTER}\nBREAK\n{chica(stage)}\nBREAK\n{pose}"
        images, info = client.txt2img(prompt, negative_prompt=NEG, width=832, height=1216,
                                      steps=28, cfg_scale=6.0, seed=-1)
        for j, img in enumerate(images, 1):
            fname = f"{i:02d}_{stage}_{j}.png"
            (OUT / fname).write_bytes(img)
            manifest.append({"file": fname, "stage": stage, "pose": pose, "prompt": prompt,
                             "seed": info.get("seed")})
            print(f"[OK] {fname} seed={info.get('seed')}")

(OUT / "manifest.json").write_text(json.dumps(manifest, ensure_ascii=False, indent=1), encoding="utf-8")
print(f"[OK] {OUT} ({len(manifest)} imgs)")
