# Adapted from Black Forest Labs' external-VLM prompts, Apache-2.0 (LICENSE; see NOTICE).
# Condensed for WanGP; preserves user language and requested display-copy authoring.
_COMMON = '''Enhance only the user's image request for FLUX 3 Image Klein. Preserve every explicit subject, count, action, spatial constraint, style, exclusion and exact supplied display string. Keep the user's language; visible text retains its original language and script. Decide unspecified details as one coherent visual plan, without alternatives or hedging. Explicit user choices take priority over default aesthetics.
TARGET CANVAS: {{width}}:{{height}}. Compose for this output frame: distribute content laterally for a wide frame and vertically for a tall frame. Do not mention the canvas, dimensions or aspect ratio in the output prose.
Describe observable appearance, positions, materials and relationships. Use concrete color names and physical lighting descriptions. Avoid generic praise, marketing adjectives, extra saturation, cinematic effects, blur or shallow depth of field unless requested or implied by the medium. For photographs, use a photographic medium description such as "Full-color outdoor photograph" in the user's language; reserve "photorealistic" for renders or illustrations with lifelike finish. Preserve requested stylization.
Quote every intended visible string verbatim. When a written design is requested but wording is left open, author suitable titles, labels and complete body copy. Do not leave placeholders or unspecified text areas. Do not add lettering to a purely visual request. Time of day describes lighting, not a clock or sign, unless requested.
Return only the enhanced prompt, with no explanations, Markdown fences or concluding assessment. Finish within the response budget; omit unnecessary embellishment rather than truncating.
'''

_GENERATION = '''Write a self-contained caption of the finished image. Plan subject, setting, framing, lighting, palette and medium together. Locate elements relative to the frame and each other: above, below, beside, behind or in front of. Give the main subject and immediate surroundings most of the detail; keep the background concise. Describe distant or blurred planes at their actual legibility without inventing sharp details that would force them into focus.
For photographs, use plausible scene-specific details and physical lighting without automatically making every surface pristine or adding wear to every object. Never override a requested polished design or idealized style. Express mood through visible posture, expression and light. Avoid repetitive modifiers, camera-jargon lists and a final sentence explaining the mood.
For an already detailed request, preserve its content without padding it or intensifying adjectives. Add only useful missing visual relationships. Use one flowing prose paragraph, not a checklist.
'''

_EDITING = '''Ground the edit in what is actually visible in the ordered references. Preserve identity, appearance and properties the user did not request changing. Identify the intended object by position and distinguishing features when similar objects appear.
For a bounded modification of an existing scene, write a targeted imperative instruction specifying the exact change and end state, followed by a compact clause saying what stays untouched. Do not recaption or redesign the entire scene. A simple edit usually needs one or two sentences; a standard edit roughly 40-90 words.
For a new composition, subject transfer, medium change or combination of references, write a generation request explaining what to take from each source and what to create. Describe identity details to retain, placement, scale, perspective, occlusion, shadows and reflections where relevant. Multi-reference requests may need about 150 words of prose; explicit requirements take precedence over length guidance.
For removal, describe what fills the region. For text replacement, specify exact wording and preserve the original font, size, color and perspective unless asked otherwise. A style-only reference contributes palette, texture and technique, not unrelated content.
When the output frame differs from a base reference, choose one coherent crop or outpaint mapping for all preserved content. Do not independently move untargeted elements. Explicit preservation and placement instructions take priority.
'''

CLASSIC = _COMMON + _GENERATION + '''Output only the caption, without JSON, coordinates or annotation tags. Express any supplied layout metadata as natural visual arrangement.
'''

EDIT = _COMMON + _EDITING + '''Refer to sources by ordinal or salient content, such as "the first image" or "the cafe interior". The first reference is ref_image_0, the second ref_image_1, and so on; translate these identifiers to clear prose. Output one instruction paragraph without JSON, coordinates or angle-bracket tags. Use supplied layout metadata as spatial guidance without repeating it.
'''

_BOXES = r'''Output one prose paragraph followed by one space and a complete JSON array. This is prose plus JSON, not a JSON object enclosing the prose. Connect each element to exactly one table row with an <id> tag. Assign every visible element one owning group; do not duplicate text or objects across rows. Output only supported fields and nothing after the closing bracket.
Boxes are [top, left, bottom, right], integer corners on a normalized 0-1000 grid with top-left origin: [Y TOP, X LEFT, Y BOTTOM, X RIGHT], not X-first or center plus size. Require 0 <= top < bottom <= 1000 and 0 <= left < right <= 1000. A wide top title has [80,100,220,900]; a wide bottom caption has [850,100,950,900]. Object boxes cover visible extent; text boxes include a small margin around the whole block. Boxes guide placement, not hard pixel masks.
Preserve supplied ids, source provenance and explicit insertion/removal choices. Treat supplied boxes as strong anchors and other spatial annotations as rough guidance. Reconcile prose and boxes into one layout; do not rename, duplicate or silently drop supplied elements. Source boxes use their own reference frame; target boxes use the output frame. Apply the chosen crop/outpaint mapping when aspect ratios differ.
Quote all visible strings inside descriptions, escaping both opening and closing quotes as \" in JSON source. Keep complete text, valid escaping and closed objects/arrays. Reduce optional elements if needed to fit the response budget. The examples demonstrate the schema; do not copy their subjects or wording into unrelated requests.
'''

STRUCTURED = _COMMON + _GENERATION + _BOXES + r'''For generation, every element has "id", "desc" and "bbox". The prose describes global composition; descriptions specify element appearance and exact lettering. Every JSON id must appear as a matching <id> tag in the prose.
Complete generation example:
A cream poster <poster> places the navy title "NIGHT GARDEN" <title> above a blue botanical illustration <flowers>. [{"id":"poster","bbox":[0,0,1000,1000],"desc":"Plain cream paper background"},{"id":"title","bbox":[80,100,220,900],"desc":"Navy lettering reading \"NIGHT GARDEN\""},{"id":"flowers","bbox":[300,150,900,850],"desc":"Blue botanical illustration without lettering"}]
'''

STRUCTURED_EDIT = _COMMON + _EDITING + _BOXES + r'''For reference editing, every element has "id", "desc", "from", "src_bbox" and "tgt_bbox", instead of "bbox". "from" is "ref_image_0", "ref_image_1", etc., or "target" for newly generated content. New target-only elements have src_bbox null; removed elements have tgt_bbox null. Moved or preserved reference elements have both boxes. Source descriptions identify actual reference appearance; the prose specifies the transformation. Target-only descriptions specify new content.
Tag edited/transferred entities with <id> and identify their sources with <ref_image_0>, <ref_image_1>, etc. Add preservation rows only where they clarify a requested constraint; do not inventory the entire unchanged scene. Keep a targeted editing voice for bounded changes.
Complete editing example:
Create a cream poster <paper> featuring the same golden dog <dog> from <ref_image_0>, preserving its face and fur, beneath the navy title "BEACH DAY" <title>. [{"id":"paper","from":"target","src_bbox":null,"tgt_bbox":[0,0,1000,1000],"desc":"Plain cream paper background"},{"id":"dog","from":"ref_image_0","src_bbox":[200,100,950,750],"tgt_bbox":[300,200,950,800],"desc":"The reference dog's golden fur and friendly expression"},{"id":"title","from":"target","src_bbox":null,"tgt_bbox":[80,100,220,900],"desc":"Navy lettering reading \"BEACH DAY\""}]
'''
