
    6j                         d Z ddlmZ ddlZddlmZ ddlmZ ddlm	Z	 dZ
dZd	Zed
z   Zd"dZd#dZd#dZd#dZd#dZd#dZd$dZd%dZd&dZd'dZd(d!ZdS ))a  Wan2.2 Image-to-Video prompt planning for mechanism-led shorts.

This module converts motion-led shot plans into concrete keyframe and I2V
prompt specs. It deliberately keeps generated text, numbers, labels, and UI
out of AI-video clips; those belong to the deterministic renderer.
    )annotationsN)Path)Any_slug"photorealistic_macro_investigationwan22_i2v_quality_416x736a2  cartoon, animation, deformed subject, duplicated subject, disappearing subject, melting body, distorted geometry, blurry, low detail, flickering colors, abstract, static image, camera shake, overexposed, underexposed, dark frame, text, subtitles, captions, watermark, logo, unreadable letters, fake UI textz, unreadable license plate, fake license plate text, brand logos, distorted wheels, melted car body, broken windshield geometry, fake numbers, fake labelsscenedict[str, Any]returnboolc                4    |                      d          dk    S )N
asset_typecinematic_ai_videogetr
   s    T/home/agent/jarvis_runtime/autoshortsbot/AutoShortsBot/autoshorts/keyframe_prompt.py_is_wan_candidater   !   s    99\""&:::    strc                    	 dS )Na  Photorealistic vertical image of a red used compact car in a bright European vehicle inspection garage, full front three-quarter view, clean empty license plate area, visible wheels and body panels, soft overhead lights, realistic reflections, shallow depth of field, balanced exposure, high quality inspection-bay photography. Leave clean negative space for captions in the upper third and lower third. No text, no logos, no watermark. r   s    r   _car_keyframe_promptr   %   s    	+ r   c                l    t          |           }d}|                     d          dk    rd}d| d| dS )N purposeproblemzl A subtle surface layer starts to peel away visually, hinting that the visible price is not the full system.zePhotorealistic vertical video of the same red used compact car in a bright inspection garage. Camera .z Subtle light sweep over the hood and windshield, realistic reflections, stable composition, balanced exposure, high quality automotive inspection footage. Preserve the same car and garage. No text, no logo, no watermark.)_motion_directiver   )r
   motionmechanism_clauses      r   _car_motion_promptr#   0   sd    u%%Fyyy(( J	U 	U 	U#3	U 	U 	Ur   c                    |                      dd          }|dk    rdS |dk    rdS |                      dd          }|r|S dS )	Nr   r   pattern_interruptz^slowly pushes in from a front three-quarter angle, then lands on a subtle freeze-like emphasisr   zFslowly pushes in from a front three-quarter angle with gentle parallaxvisual_motionz%slowly pushes in with subtle parallaxr   )r
   r   r&   s      r   r    r    =   s_    ii	2&&G%%%oo)WWIIor22M 22r   c                    d| d          dS )NznPhotorealistic vertical macro-investigation image, one clear subject in a realistic environment. Visual task: visual_directionz. Bright balanced exposure, clean composition, high contrast, enough negative space for renderer captions, no readable text, no logos, no watermark.r   r   s    r   _fallback_keyframe_promptr)   I   s$    	"%*+=%>	" 	" 	"r   c                >    t          |           }d| d| d          dS )NzgPhotorealistic vertical video preserving the same subject and environment from the start image. Camera z'. Motion supports this retention goal: retention_goalz[. Balanced exposure, stable composition, realistic texture. No text, no logo, no watermark.)r    )r
   r!   s     r   _fallback_motion_promptr,   R   sD    u%%F	d	d 	dHMN^H_	d 	d 	dr   	shot_planc                   d                     |                    dd          |                    dd          |                     dd          |                     dd          g                                          }d|v pd|v pd	|v pd
|v }|rt          |           nt	          |           }|rt          |           nt          |           }|rt          nt          }d| d         d| d         | d         | d         t          t          |||t          |           | d         | d         dddt          dt          t          | d                   t          | d                   z
  d                    ddddddddddd d!d"d#	d$S )%N titler   pillarr(   	voiceoverautocaroccasiongaragescene_r
   02dr   r   r+   Tzupper third and lower third   endstart   )&subject_identifiable_first_half_secondno_baked_textcaption_safe_spacepreferred_duration_secondsreview_requirednative_wan22_ti2v_i2vzwan2.2_ti2v_5B_fp16.safetensorsz&umt5_xxl_fp8_e4m3fn_scaled.safetensorszwan2.2_vae.safetensorsi  i  )widthheight=         g      @)	workflow_familymodeltext_encodervae
resolutionframesfpsstepscfg)scene_idsource_scener   r   style_profile
wan_presetkeyframe_prompti2v_motion_promptnegative_promptmotion_directivesource_visual_directionr+   clip_requirementscomfyui)joinr   lowerr   r)   r#   r,   CAR_NEGATIVE_PROMPTBASE_NEGATIVE_PROMPTSTYLE_PROFILEWAN22_QUALITY_PRESETr    maxroundfloat)r
   r-   visualis_car_scenerU   motion_promptrW   s          r   _scene_prompt_specrh   [   s   XXMM'2&&MM(B''II("--IIk2&&		
  egg  V#dud*:NdRZ^dRdL5Ag*5111G`afGgGgO1=a&u---CZ[`CaCaM-9S))?SO1U7^111g#L)&****-e44#();#< 016:!"?*-auU5\7J7JUSXY`SaMbMb7bde1f1f*g*g#
 
  76D+$'377

 

)  r   c           	         d| d         d| d         | d         | d         | d         |                      dd          d	d
S )Nr7   r
   r8   r   r   r(   r&   r   zYRenderer-generated motion layer; keep labels, arrows, numbers and captions deterministic.)rQ   rR   r   r   r(   r&   noter   r   s    r   _renderer_noterk      sW    1U7^111g#L)!"45?B77k  r   c           
     (    d  d         D             }d  d         D             }dt            d          d          d          d         d	d
dd                     di                               dd          d fd|D             d |D             dS )z9Build Wan2.2 I2V prompt specs from a mechanism shot plan.c                0    g | ]}t          |          |S r   r   .0r
   s     r   
<listcomp>z)build_i2v_prompt_plan.<locals>.<listcomp>   s&    TTT5;LU;S;STTTTr   scenesc                0    g | ]}t          |          |S r   rn   ro   s     r   rq   z)build_i2v_prompt_plan.<locals>.<listcomp>   s'    ^^^EVW\E]E]^u^^^r   zi2v_prompt_plan.v1idr0   seriesr1   )rt   r0   ru   r1   /keyframe_to_wan22_i2v_to_deterministic_rendererz&photorealistic texture and motion onlyzHcaptions, labels, numbers, arrows, mechanism layers and audit-safe truthfinal_render_intentstatic_card_limitr   )production_modeai_video_rolerenderer_rolerx   c                0    g | ]}t          |          S r   )rh   )rp   r
   r-   s     r   rq   z)build_i2v_prompt_plan.<locals>.<listcomp>   s$    OOOE%eY77OOOr   c                ,    g | ]}t          |          S r   )rk   ro   s     r   rq   z)build_i2v_prompt_plan.<locals>.<listcomp>   s      T T T5!6!6 T T Tr   )schema_versionrS   videostrategyrr   renderer_only_scenes)r`   r   )r-   	ai_scenesrenderer_sceness   `  r   build_i2v_prompt_planr      s    TTIh$7TTTI^^)H*=^^^O.&D/w'))	
 
  QEg!*/Db!I!I!M!MNacd!e!e	
 
 POOOYOOO T TO T T T!  r   planc                >    t          | d         d                    dS )Nr   rt   z.jsonr   )r   s    r   _prompt_plan_filenamer      s"    DM$'((////r   
shot_planslist[dict[str, Any]]
output_dirr   
list[Path]c                   |                     dd           g }| D ]g}t          |          }|t          |          z  }|                    t	          j        |dd          dz   d           |                    |           h|S )	z,Write Wan2.2 I2V prompt plans as JSON files.T)parentsexist_okr9   F)indentensure_ascii
zutf-8)encoding)mkdirr   r   
write_textjsondumpsappend)r   r   pathsr-   prompt_planpaths         r   write_i2v_prompt_plansr      s    TD111E  	+I661+>>>
;quMMMPTT_fgggTLr   )r
   r   r   r   )r
   r   r   r   )r
   r   r-   r   r   r   )r
   r   r   r   )r-   r   r   r   )r   r   r   r   )r   r   r   r   r   r   )__doc__
__future__r   r   pathlibr   typingr   autoshorts.script_draftsr   r`   ra   r_   r^   r   r   r#   r    r)   r,   rh   rk   r   r   r   r   r   r   <module>r      su    # " " " " "              * * * * * *42 B  MM ; ; ; ;   
 
 
 
	3 	3 	3 	3      , , , ,^	 	 	 	   00 0 0 0	 	 	 	 	 	r   