+
     i!  c                  s    ^ RI Ht ^ RIt^ RIHt ^ RIHtHtHtH	t	H
t
Ht ^ RIHt ^ RIHtHtHt ^ RIHtHt ^ RIHt ]'       d   ^ R	IHt ^ R
IHt ^ RIHt ^ RIHt  ! R R4      tR# )i    )annotationsN)chain)ListDictTYPE_CHECKINGOptionalTupleUnion)
MacroError)ArgumentArgumentConfigArgumentFlags)MacroInjectEventCallback)logger)EventListener)RawValue)Context)Mappingc                  s   ] tR t^+t$ RtR]R&   R]R&   R]R&   R]R	&   R
]R&   R R ltR R ltR R ltR R lt	]
R 4       t]
R R l4       tR R ltR R ltR R ltR R ltR,R  R! lltR" R# ltR$ R% ltR& R' ltR( R) ltR* tR+tR# )-TaskzwBase Class for functions like `if_eq` or `key`

A macro like `key(a).key(b)` will contain two instances of this class.
zList[ArgumentConfig]argument_configszDict[str, Argument]	argumentsr   mappingOptional[Context]contextzList[Macro]child_macrosc          
     s,    V ^8  d   QhRRRRRRRRR	R
/# )   positional_argsList[RawValue]keyword_argsDict[str, RawValue]r   r   r   r   returnNone Zformat   "H/usr/lib/python3.14/site-packages/inputremapper/injection/macros/task.py__annotate__Task.__annotate__:   s<     : :': *: #	:
 : 
:    c                	s8   W0n         W@n        . V n        V P                  4        V P                   Uu/ uF  pVP
                  \        WT4      bK  	  upV n        V P                  4        V P                  P                  4        F  pV P                  WbV4       K  	  V P                  V4       \        VP                  4       V4       FJ  p\        VP                  \        4      '       g   K%  V P                  P!                  VP                  4       KL  	  R # u upi N)r   r   r   _validate_argument_configsr   namer	   r   _setup_asyncio_eventsvalues_initialize_argument_initialize_spread_argr   Z
isinstancevaluer   Zappend)selfr   r   r   r   argument_configargumentZ	raw_values   &&&&&   r$   __init__ZTask.__init__:   s     '') $(#8#8
#8   (?"DD#8

 	""$--/H%%hoN 0 	##O4|224oFI)//511!!((9 G
s   Dc                    V ^8  d   QhRRRR/# )r   callbackr   r   r    r!   r"   r#   r$   r%   r&   W   s     $ $"5 $$ $r'   c                s   "   \        4       h5i)zaMacro logic goes here.

Call the callback with the type, code and value that should be injected.
)ZNotImplementedError)r0   r5      &&r$   runZTask.runW   s     
 "##s   c               r4   r   listenerr   r   r    r!   r"   r#   r$   r%   r&   ^   s     	- 	-= 	-T 	-r'   c                sp    V P                   f   Q hV P                   P                  P                  V4       R# )zListeners get each event from the source device.

After all listeners are done, the event will go into the mapping handlers.

Make sure to remove your event_listener once you are done.
N)r   	listenersaddr0   r9   r6   r$   add_event_listenerZTask.add_event_listener^   s,     ||'''""8,r'   c               r4   r8   r!   r"   r#   r$   r%   r&   i   s     0 0m 0 0r'   c                	sp    V P                   f   Q hV P                   P                  P                  V4       R # r(   )r   r:   Zremover<   r6   r$   remove_event_listenerZTask.remove_event_listeneri   s*    ||'''%%h/r'   c                	sV    V P                    Uu. uF  qP                  NK  	  up# u upi r(   )r   r*   )clsr1      & r$   get_macro_argument_namesZTask.get_macro_argument_namesm   s&    <?<P<PQ<P$$<PQQQs   &c                   V ^8  d   QhRR/# )r   r   zTuple[int, Union[int, float]]r!   r"   r#   r$   r%   r&   r   s     * *#@ *r'   c                s    ^ pV P                   p\        V4      pV FP  pVP                  \        P                  8X  d   \        R4      pK/  VP                  4       '       g   KG  V^,          pKR  	  W3# )zKGet the number of required parameters and the maximum number of parameters.Zinf)r   lenpositionr   spreadZfloatis_required)r?   Zmin_num_argsr   Zmax_num_argsr1   s   &    r$   get_num_parametersZTask.get_num_parametersq   sn     //*-.>*?/O''=+?+??$U|**,,!  0 ))r'   c               rB   )r   r   r	   r!   r"   r#   r$   r%   r&      s     - -X -r'   c                	s(    V P                   V,          # r(   )r   )r0   Zargument_namer6   r$   get_argumentZTask.get_argument   s    ~~m,,r'   c               rB   r   r   r    r!   r"   r#   r$   r%   r&      s     
( 
(t 
(r'   c                s   V P                    F  pVP                  4        K  	  V P                  4       '       d   \        P                  ! R4       R# V P
                  P                  4        V P                  P                  4        R# )z&The user pressed the trigger key down.zAlready holdingN)	r   press_trigger
is_holdingr   Zerror_trigger_release_eventclear_trigger_press_eventsetr0   Zmacror@   r$   rJ   ZTask.press_trigger   sa    &&E! ' ??LL*+##))+!!%%'r'   c               rB   rI   r!   r"   r#   r$   r%   r&      s     	$ 	$ 	$r'   c                s    V P                  4       '       g   R# V P                  P                  4        V P                  P	                  4        V P
                   F  pVP                  4        K  	  R# )z"The user released the trigger key.N)rK   rL   rO   rN   rM   r   release_triggerrP   r@   r$   rQ   ZTask.release_trigger   sR      ##'')!!'')&&E!!# 'r'   c               rB   )r   r   Zboolr!   r"   r#   r$   r%   r&      s     8 8D 8r'   c                s@    V P                   P                  4       '       * # )z7Check if the macro is waiting for a key to be released.)rL   Zis_setr0      &r$   rK   ZTask.is_holding   s    ..55777r'   Nc               rB   rI   r!   r"   r#   r$   r%   r&      s     D DT Dr'   c                s   "   \         P                  ! V P                  P                  R,          4      G Rj  xL
  R#  L5i)zTo add a pause between keystrokes.

This was needed at some point because it appeared that injecting keys too
fast will prevent them from working. It probably depends on the environment.
i  N)asyncioZsleepr   Zmacro_key_sleep_ms)r0   Z_r6   r$   keycode_pauseZTask.keycode_pause   s(      mmDLL;;dBCCCs   5A >A c               r4   )r   r   r   r   r    r!   r"   r#   r$   r%   r&      s"     H H'H 
Hr'   c                s   RpV P                   P                  4        F&  pVP                  \        P                  8X  g   K$  Tp M	  Vf   R# . VOpV P                   P                  4        FL  pVP                  \        P                  8w  g   K$  VP                  \        V4      8  g   K@  WCP                   KN  	  VP                  V4       R# )zGPut all positional arguments that aren't used into the spread argument.N)r   r,   rD   r   rE   rC   Zinitialize_variables)r0   r   Zspread_argumentr2   Zremaining_positional_argss   &&   r$   r.   ZTask._initialize_spread_arg   s    
 /3--/H  M$8$88"* 0
 "$6o$6!--/H  M$8$88X=N=NQT)R > ..?.?@	 0 	,,-FGr'   c               r4   )r   rD   Zintr   zOptional[Argument]r!   r"   r#   r$   r%   r&      s      3 ;M r'   c                	sr    V P                   P                  4        F  pVP                  V8X  g   K  Vu # 	  R # r(   )r   r,   rD   )r0   rD   r2   s   && r$   _find_argument_by_positionZTask._find_argument_by_position   s1    --/H  H, 0 r'   c               rB   rI   r!   r"   r#   r$   r%   r&      s     * *t *r'   c                	s    \         P                  ! 4       V n        \         P                  ! 4       V n        V P                  P	                  4        V P                  P                  4        R # r(   )rT   ZEventrL   rN   rO   rM   rR   rS   r$   r+   ZTask._setup_asyncio_events   sD     '.mmo#$+MMO!##'')!!'')r'   c               s(    V ^8  d   QhRRRRRRRR/# )	r   r2   r	   r   r   r   r   r   r    r!   r"   r#   r$   r%   r&      s8     K KK *K (	K
 
Kr'   c                	s   VP                   \        P                  8X  d   R # VP                  4        F*  w  rEVP                  V8X  g   K  VP                  V4        R # 	  VP                   \        V4      8  d$   VP                  W1P                   ,          4       R # VP                  4       '       g   VP                  4        R # \        RVP                   24      h)NzCould not initialize argument )
rD   r   rE   Zitemsr*   Zinitialize_variablerC   rF   Zinitialize_defaultr   )r0   r2   r   r   r*   r/   s   &&&&  r$   r-   ZTask._initialize_argument   s      4 44'--/KD}}$,,U3 0
 s?33((9J9J)KL##%%'') 9(--IJJr'   c                	s   \        4       p\        4       pV P                   Fg  pVP                  pWA9   d   \        R V R24      hVP	                  V4       VP
                  pWR9   d   \        RV R24      hVP	                  V4       Ki  	  R# )zDuplicate position z in ArgumentConfigzDuplicate name N)rO   r   rD   r   r;   r*   )r0   Z	positionsZnamesr1   rD   r*   s   &     r$   r)   ZTask._validate_argument_configs   s    E	#44O&//H$ #6ykAS!TUUMM(#"''D} ?4&8J!KLLIIdO  5r'   )rN   rL   r   r   r   r   r(   )Z__name__Z
__module__Z__qualname__Z__firstlineno__Z__doc__Z__annotations__r3   r7   r=   r>   ZclassmethodrA   rG   rH   rJ   rQ   rK   rU   r.   rV   r+   r-   r)   Z__static_attributes__r!   r'   r$   r   r   +   s    
 +*"" ::$	-0 R R * * -
(	$8DH0*K6r'   r   ) Z
__future__r    rT   Z	itertoolsr   Ztypingr   r   r   r   r   r   Z'inputremapper.configs.validation_errorsr   Z'inputremapper.injection.macros.argumentr	   r
   r   Z$inputremapper.injection.macros.macror   r   Zinputremapper.logging.loggerr   Z8inputremapper.injection.mapping_handlers.mapping_handlerr   Z(inputremapper.injection.macros.raw_valuer   Zinputremapper.injection.contextr   Zinputremapper.configs.mappingr   r   r!   r'   r$   <module>rW      sG   * #   D D > 
 L /VA75M Mr'   