#!/usr/bin/env python3
"""Writes Z-Image Turbo job files (Shuttrr, sarthakstudio) for the cast sheets, location plates and photo props."""
import json, pathlib
OUT = pathlib.Path(__file__).parent / "prompts" / "zimage"; OUT.mkdir(parents=True, exist_ok=True)
R = "/Users/sarthakrawool/omni-test/rb"
STYLE = ("3D animated feature film character design, stylised cartoon grown-up on realistic adult body proportions, about seven heads tall, long adult legs, clearly an adult and never a child, "
         "big round wide-open eyes with lots of white, soft thin eyebrows, an adult face shape with defined cheekbones and jaw, slightly long nose with a rounded tip, small mouth, "
         "clean smooth render, minimal texture on clothes and hair, soft studio lighting")
SHEET = ("Character turnaround reference sheet on a plain light grey background: the same character shown three times side by side at the same size, "
         "full body standing, front view on the left, side profile view in the middle facing right, back view on the right showing the back of the head and the hair, "
         "neutral relaxed pose, arms at the sides, even spacing, nothing else in the image. ")
FACE = ("Tight close-up headshot of a grown adult: the face fills most of the frame, cropped just below the chin and shoulders, facing the camera straight on, eyes looking at the camera, calm friendly expression, "
        "plain light grey background, nothing else in the image. ")
CAST = {
 "nina": "a mature adult woman in her mid forties with an adult woman's face: a longer oval face, defined cheekbones, faint crow's feet and smile lines, a mother of teenagers, tall adult figure, warm light-brown skin, shoulder-length curly dark-brown hair with a few grey strands, reading glasses pushed up on top of her head, "
         "kind tired eyes, a mustard-yellow knit cardigan over a plain white T-shirt, a small forest-green rabbit-head pin on the cardigan's left chest, dark jeans, white sneakers",
 "greg": "a middle-aged 48-year-old adult man, tall and stocky with a slight belly, warm light-brown skin, balding on top with short grey-brown sides, light stubble, a smug grin, "
         "a plain navy quarter-zip pullover, khaki trousers, brown loafers, a black smartwatch",
 "dad":  "an elderly 75-year-old grandfather, tall and thin, wrinkled face, slightly stooped, warm light-brown skin, neat combed white hair, bushy white eyebrows, big ears, gentle eyes, "
         "a red-and-brown plaid flannel shirt with brown suspenders, grey trousers, brown slippers",
 "mom":  "an elderly 71-year-old grandmother, short and plump, wrinkled face, warm light-brown skin, white-blonde curly perm, round glasses on a beaded chain, rosy cheeks, cheeky smile, "
         "a coral blouse, small pearl earrings, grey slacks",
}
SET = ("3D animated feature film background environment, empty of people, clean smooth stylised render, natural moderately rich colour, "
       "strong contrast with soft deep shadows, vertical composition, ")
PLATES = {
 "kitchen_day": "a cosy family kitchen in a Midwestern house in the morning: cream cabinets, a wooden kitchen table, a blue recycling bin by the counter, "
                "a coffee maker, a doorway to the hallway on the right, warm daylight from a window over the sink, a few Christmas cards on the fridge",
 "kitchen_night": "the same cosy family kitchen at night: cream cabinets, a wooden kitchen table with an open silver laptop on it, a warm pendant lamp over the table, "
                  "dark blue window, the rest of the room in soft shadow, a few Christmas cards on the fridge",
 "living_xmas": "a warm family living room on Christmas morning: a decorated Christmas tree with warm fairy lights, wrapped presents under the tree, "
                "a beige sofa, a knitted blanket, soft golden morning light from a window, a mug on the side table",
}
PROPS = {
 "faded": "An old photograph print seen straight on, filling the whole image edge to edge: the image is almost completely faded to a flat pale grey, "
          "with only a ghostly hint of a young woman's outline holding a small bundle, water stains, cracked corners, a crease across it. "
          "Stylised 3D animated feature film prop, no writing anywhere.",
 "restored": "A restored black-and-white photograph print from the 1940s seen straight on, filling the whole image edge to edge: a young woman in a 1940s dress with "
             "wavy dark hair smiles softly and holds a baby boy wrapped in a white blanket in her arms, in front of a small wooden house porch, sharp and clean. "
             "Stylised 3D animated feature film look: big round eyes, soft rounded faces, small mouths. No writing anywhere.",
}
jobs = []
SHEET4 = ("A four-panel character model sheet in one single image, plain light grey background, four tall panels side by side separated by thin white lines. "
          "Left panel: a tight close-up portrait of the character's face and hair, filling the panel. "
          "Second panel: front view of the outfit from the shoulders down to the shoes, the top edge of the panel cuts through the neck so no face is in this panel. "
          "Third panel: back view, the character stands facing away from the viewer, showing the back of the hair, the back of the head and the back of the clothes, no face visible. "
          "Fourth panel: side view of the outfit from the shoulders down to the shoes, the top edge of the panel cuts through the neck so no face is in this panel. "
          "The character: ")
for k, d in CAST.items():
    jobs.append((f"sheet4_{k}", SHEET4 + d + ". " + STYLE, 2048, 1024))
for k, d in PLATES.items():
    jobs.append((f"plate_{k}", SET + d, 720, 1280))
for k, d in PROPS.items():
    jobs.append((f"prop_{k}", d, 896, 1152))
for name, prompt, w, h in jobs:
    for seed in ((7, 21) if not name.startswith("sheet4") else (7, 21, 33)):
        req = {"model": "z-image-turbo-8bit", "prompt": prompt, "width": w, "height": h, "seed": seed,
               "params": {"steps": 9}, "output": f"{R}/zimage/{name}_s{seed}.png"}
        (OUT / f"{name}_s{seed}.json").write_text(json.dumps(req, indent=1))
print(len(jobs) * 2, "jobs ->", OUT)
