
    _j!
                        S SK Jr  S SKJrJrJrJrJr  S SKJ	r	   S SK
Jr  SS jrSrSrS	rS
rSr\S   rSS jrSS jrSS jrSS jrSS jrg! \ a    SS jr N;f = f)    )annotations)LiteralUnionget_argsOptionalAny)Headers)get_current_appc                     g N r       H/home/rurouni/.local/lib/python3.13/site-packages/fal_client/_headers.pyr
   r
      s    r   c                 P    [        5       =n b  U R                  b  U R                  $ g)z7Get the current request if we are running in a fal app.N)r
   current_request)apps    r   _current_fal_app_requestr      s*      -#2E2E2Q"""r      zX-Fal-Request-TimeoutzX-Fal-Request-Timeout-TypezX-Fal-Runner-HintzX-Fal-Queue-Priority)normallowc                     [        U 5      n U [        ::  a  [        S[         S35      e[        U 5      U[        '   g! [         a    [        SU  35      ef = f)zN
Validates the timeout and adds the timeout header to the headers dictionary.
zTimeout must be a number, got zTimeout must be greater than z secondsN)float
ValueErrorMIN_REQUEST_TIMEOUT_SECONDSstrREQUEST_TIMEOUT_HEADER)timeoutheaderss     r   add_timeout_headerr   "   sn    E.
 --+,G+HQ
 	
 '*'lG"#  E9'CDDEs	   = Ac                    X[         '   g r   )RUNNER_HINT_HEADER)hintr   s     r   add_hint_headerr#   3   s    "&r   c                `    [        [        5      nX;  a  [        SU SU  S35      eX[        '   g)a
  
Validates the priority and adds the priority header to the headers dictionary.

Args:
    priority: Queue priority, must be "normal" or "low".
    headers: Headers dictionary to add the priority header to.

Raises:
    ValueError: If priority is not a valid value.
zPriority must be one of z, got ''N)r   Priorityr   QUEUE_PRIORITY_HEADER)priorityr   valid_prioritiess      r   add_priority_headerr*   7   sA      )'&'7&8zK
 	
 &.!"r   c                v    [        5       =n(       a(  UR                  R                  S5      =n(       a  X S'   g g g Nzx-fal-cdn-token)r   r   get)r   request	cdn_tokens      r   add_fal_app_context_headersr0   J   s>    *,,w,++,=>>9>)2%& ? -r   c                v    [        5       =n(       a(  U R                  S5      =n(       a  X!R                  S'   g g g r,   )r   r-   r   )response_headersr.   r/   s      r   handle_response_headersr3   P   s?    *,,w,(,,->??9?1:OO-. @ -r   N)returnzOptional[Any])r   zUnion[int, float]r   dict[str, str]r4   None)r"   r   r   r5   r4   r6   )r(   r&   r   r5   r4   r6   )r   r5   r4   r6   )r2   r	   r4   r6   )
__future__r   typingr   r   r   r   r   httpxr	   fal.refr
   ImportErrorr   r   r   REQUEST_TIMEOUT_TYPE_HEADERr!   r'   r&   r   r#   r*   r0   r3   r   r   r   <module>r=      s|    " : : '    1 : ( .  ?#3"'.&3;O  s   A AA