§
    éŽ’j®  ã                   ó6  — d Z ddlZddlZddlmZmZmZ ddlmZ	 e	j
        j        e	j
        j        e	j
        j        dœZdedee	j        ged         f         de	j        fd	„Zd
eej        z  dee	j        ee	j                 ged         f         de	j        fd„ZdS )z’Helper factories for common trigger patterns.

These are thin wrappers that return Trigger callables with correct
cancellation handling built in.
é    N)Ú	AwaitableÚCallableÚSequence)Útriggers)é   é   é   Úinterval_secondsÚcallbackÚreturnc                 ó�   ‡ ‡— ‰ dk    rt          d‰ › �¦  «        ‚dt          j        ddfˆˆ fd„}d‰ › d�|_        d	‰ › d
�|_        |S )u5  Creates a trigger that runs callback on a fixed interval.

  The callback is invoked repeatedly with `interval_seconds` between
  each invocation. The first invocation happens after the first interval
  elapses (not immediately).

  Args:
    interval_seconds: Seconds between invocations. Must be positive.
    callback: Async function called each interval. Receives the TriggerContext â€”
      use ctx.send() inside the callback to push messages to the agent.

  Returns:
    A Trigger function.

  Raises:
    ValueError: If interval_seconds is not positive.
  r   z'interval_seconds must be positive, got Úctxr   Nc              “   ób   •K  — 	 t          j        ‰¦  «        ƒ d {V —†  ‰| ¦  «        ƒ d {V —† Œ,)N)ÚasyncioÚsleep)r   r   r
   s    €€úQC:\Projects\DSCons\.venv\Lib\site-packages\google\antigravity\triggers\helpers.pyÚ_triggerzevery.<locals>._triggerA   sT   øè è € ðÝŒMÐ*Ñ+Ô+Ð+Ð+Ð+Ð+Ð+Ð+Ð+ØˆH�S‰MŒMÐÐÐÐÐÐÐðó    Úevery_ÚszInterval trigger: runs every zs.)Ú
ValueErrorÚtriggers_moduleÚTriggerContextÚ__name__Ú__doc__)r
   r   r   s   `` r   Úeveryr   '   s’   øø€ ð* ˜ÒÐÝ
ØDÐ2BÐDÐDñô ð ð�/Ô8ð ¸Tð ð ð ð ð ð ð ð
 3Ð/Ð2Ð2Ð2€(ÔØIÐ5EÐIÐIÐI€(ÔØ	€/r   Úpathc                 óª   ‡‡— t          | ¦  «        Šdt          j        ddfˆˆfd„}dt          j        ‰¦  «        j        › �|_        d‰› d�|_        |S )a/  Creates a trigger that calls callback when files at path change.

  Uses watchfiles for efficient OS-level file watching. The watchfiles
  dependency is imported lazily so it's only required when this helper
  is actually used.

  Raw watchfiles events are converted to ``FileChange`` objects before
  being passed to the callback.

  Args:
    path: File or directory path to watch.
    callback: Async function called with (ctx, changes) on each change event.
      ``changes`` is a sequence of ``FileChange`` objects.

  Returns:
    A Trigger function.
  r   r   Nc              “   óÔ   •K  — 	 dd l }n"# t          $ r}t          d¦  «        |‚d }~ww xY w|                     ‰¦  «        2 3 d {V —†}d„ |D ¦   «         } ‰| |¦  «        ƒ d {V —† Œ&6 d S )Nr   zPwatchfiles is required for on_file_change triggers. Add it to your dependencies.c           	      óª   — g | ]P\  }}t          j        t                               t	          |¦  «        t           j        j        ¦  «        |¬ ¦  «        ‘ŒQS ))Úkindr   )r   Ú
FileChangeÚ_WATCHFILES_CHANGE_MAPÚgetÚintÚFileChangeKindÚMODIFIED)Ú.0Úchange_typeÚchanged_paths      r   ú
<listcomp>z4on_file_change.<locals>._trigger.<locals>.<listcomp>n   sk   € ð ð ð ñ (ˆk˜<õ Ô
$Ý)×-Ò-Ý�kÑ"Ô"¥OÔ$BÔ$Kñô ð  ð	ñ ô ðð ð r   )Ú
watchfilesÚImportErrorÚawatch)r   r,   ÚeÚraw_changesÚchangesr   Ú
watch_paths        €€r   r   z on_file_change.<locals>._triggere   sâ   øè è € ðØÐÐÐÐøÝð ð ð Ýð)ñô ð ðøøøøðøøøð
 (×.Ò.¨zÑ:Ô:ð 
#ð 
#ð 
#ð 
#ð 
#ð 
#ð 
#ˆkðð ð ,7ðñ ô €gð ˆH�S˜'Ñ"Ô"Ð"Ð"Ð"Ð"Ð"Ð"Ð"Ð"ð ;Ð:Ð:s   …
 Š
)”$¤)ÁA'Úon_file_change_zFile watcher trigger for ú.)Ústrr   r   ÚpathlibÚPathÚnamer   r   )r   r   r   r2   s    ` @r   Úon_file_changer9   K   s}   øø€ õ0 �4‰yŒy€*ð#�/Ô8ð #¸Tð #ð #ð #ð #ð #ð #ð #ð( H­¬°ZÑ(@Ô(@Ô(EÐGÐG€(ÔØ>°Ð>Ð>Ð>€(ÔØ	€/r   )r   r   r6   Útypingr   r   r   Úgoogle.antigravity.triggersr   r   r&   ÚADDEDr'   ÚDELETEDr#   Úfloatr   ÚTriggerr   r5   r7   r"   r9   © r   r   ú<module>rA      s)  ððð ð €€€Ø €€€Ø 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0à CÐ CÐ CÐ CÐ CÐ Cð Ô%Ô+ØÔ%Ô.ØÔ%Ô-ðð Ð ð!Øð!à˜Ô6Ð7¸À4¼ÐHÔIð!ð Ôð!ð !ð !ð !ðH0Ø
�”Ñ
ð0àØ	Ô	'¨°/Ô2LÔ)MÐNØ�$Œð	ôð0ð Ôð0ð 0ð 0ð 0ð 0ð 0r   