
    xjC                        d Z ddlmZ ddlmZ ddlmZ ddlmZ ddl	m
Z
mZ  ed           G d	 d
                      ZddZddZddZddZdS )z>Side-effect-free HTML preview generation for render manifests.    )annotations)	dataclass)escape)ValidationResult)RenderManifestvalidate_render_manifestT)frozenc                  T    e Zd ZU ded<   ded<   ded<   ded<   dZded<   dZded	<   d
S )RenderPreviewstr	script_idtitlepreview_typehtml ztuple[str, ...]side_effectsexternal_callsN)__name__
__module____qualname____annotations__r   r   r       V/home/agent/jarvis_runtime/autoshortsbot/AutoShortsBot/autoshorts/rendering/preview.pyr   r      s[         NNNJJJIII$&L&&&&&(N((((((r   r   valuer   returnboolc                0    | pd                                  S )N )strip)r   s    r   	_is_blankr       s    ""$$$$r   indexintc                   |j          d|j         d}d                    dd| ddt          |j                   dd	t          |           d
dt          |j                   d
dt          |j                   d
dt          |j        j                   d
dt          |j	        j                   d
dt          |j
                   d
df	          S )Nu   –sr   z<section class="scene">z<h2>02dz. z</h2>z<p><strong>Time:</strong> z</p>z <p><strong>Asset mode:</strong> z<p><strong>Motion:</strong> z<p><strong>Caption:</strong> z<p><strong>Label:</strong> z!<p><strong>Placeholder:</strong> z
</section>)start_secondsend_secondsjoinr   scene_purpose
asset_modemotion_instructioncaption_layertextlabel_layerplaceholder_asset_path)r!   item
time_ranges      r   _timeline_rowr2      s    &>>4+;>>>J77%A5AAAt'9 : :AAAA
););AAALvdo/F/FLLLP6$2I+J+JPPPQF43E3J,K,KQQQM&1A1F*G*GMMMYt7R0S0SYYY
	
  r   manifestr   c                   t          |           }|j        s't          d                    |j                            | j        }d                    d t          | j        d          D                       }dt          | j	                   dt          | j	                   dt          | j
                   d	|j         d
|j         d|j         d| d}t          | j
        | j	        d|dd          S )zCBuild an inspectable HTML timeline preview without rendering media.z; 
c              3  <   K   | ]\  }}t          ||          V  d S )N)r2   ).0r!   r0   s      r   	<genexpr>z%build_html_preview.<locals>.<genexpr>3   s0      iiKE4]5$//iiiiiir      )startzJ<!doctype html>
<html lang="en">
<head>
  <meta charset="utf-8">
  <title>u]   — render preview</title>
  <style>
    body { font-family: system-ui, sans-serif; background: #111827; color: #f9fafb; margin: 2rem; }
    .meta, .scene { border: 1px solid #374151; border-radius: 12px; padding: 1rem; margin: 1rem 0; }
    .scene { background: #1f2937; }
    strong { color: #93c5fd; }
  </style>
</head>
<body>
  <main>
    <h1>zC</h1>
    <section class="meta">
      <p><strong>Script:</strong> z'</p>
      <p><strong>Format:</strong> xz, zfps</p>
      <p><strong>Text policy:</strong> captions and labels are renderer-owned; no generated text inside assets.</p>
    </section>
    z
  </main>
</body>
</html>html_timeliner   )r   r   r   r   r   r   )r   is_valid
ValueErrorr(   errorssettings	enumeratetimeliner   r   r   widthheightfpsr   )r3   
validationr@   rowsr   s        r   build_html_previewrH   +   s>    *(33J 7:#455666 H99ii9XM^fgChChChiiiiiD 
 
 	  
		   $*(*<#=#=! " $,># " 5=O# " HP|# ( 
)  D0 $n$   r   previewr   c                J   g }t          | j                  r|                    d           t          | j                  r|                    d           | j        dk    r|                    d           t          | j                  r|                    d           d| j                                        vr|                    d           | j        r|                    d           | j        r|                    d	           t          | t          |          
          S )Nzscript_id is requiredztitle is requiredr<   z"preview_type must be html_timelinezhtml is requiredz<htmlz*html preview must contain an html documentz"preview must not have side effectsz(preview must not call external renderers)r=   r?   )r    r   appendr   r   r   casefoldr   r   r   tuple)rI   r?   s     r   validate_render_previewrN   V   s   F"## /-... +)***..:;;; *()))gl++----BCCC <:;;; B@AAAZfFFFFr   N)r   r   r   r   )r!   r"   r   r   )r3   r   r   r   )rI   r   r   r   )__doc__
__future__r   dataclassesr   r   r   autoshorts.ideas.candidater   autoshorts.rendering.manifestr   r   r   r    r2   rH   rN   r   r   r   <module>rT      s   D D " " " " " " ! ! ! ! ! !       7 7 7 7 7 7 R R R R R R R R $) ) ) ) ) ) ) )% % % %   "( ( ( (VG G G G G Gr   