
    k7i                     B   % S SK rS SKrS SKrS SKrS SKrS SKrS SKrS SK JrJ	r	J
r
  S SKJrJrJr  S SKJrJr  S SKJrJr  S SKJrJrJrJrJrJrJr  \R6                  S:  a  S SKJr  OSrS S	KJrJrJ r J!r!J"r"  S S
K#J$r$J%r%  S SK&J'r'J(r(  S SK)J*r*J+r+J,r,J-r-J.r.  \R6                  S:  a  S SKJr  OSr\(       a  S SK/J0r0  \" S5      r1\" S\S9r2\" S\S9r3\4\4\5   \6\6\5   \7\7\5   \8\8\5S4   \9\9\5\54   0r:\9\;\;4   \<S'   \	\6\R                  \6\
\6\Rz                  R|                  \7\Rz                  R~                  \7\Rz                  R                  \6\Rz                  R                  \9\Rz                  R                  \90rC\9\;\;4   \<S'   \	\R                  \
\4\6\7\81rD\9\5\\
\5   S4   4   rES\5S\F4S jrGS\5S\H4S jrIS\5S\J4S jrKS\5S\L4S jrMS\5S\4S jrNS\5S\4S jrOS\5S\4S jrPS\;\2   S \S!\54   S"\\5/\54   S\24S# jrQS$\;\3   S%\	\5   \	S!   -  S"\\5/\54   S\34S& jrR\F\G\H\I\J\K\L\M\\N\\O\\P0rS\9\\4   \<S''   S\;\   S%S!S(\\;\5/\4   S-  S"\\5/\54   S\84
S) jrTS\S*\9S+\9S(\S-  S"\\5/\54   4
S, jrUS S!S\S-\R                  S\54S. jrWS\;\1   S*\9\5\4   S\14S/ jrXS\;\1   S \
S!   S+\9\5S04   S1\S\14
S2 jrYS \S!\
S!   4   S(\\\5/\4   S-  S"\\5/\54   4S3 jrZ  S7S\S%\
\5   \
S!   -  \E-  S(\\;\5/\4   S-  S"\\5/\54   S-  4S4 jjr[S8S\S5\FS\8\H\F4   4S6 jjr\g)9    N)CallableIterableSequence)datedatetime	timedelta)EnumFlag)partialreduce)TYPE_CHECKINGAnyLiteralTypeVarUnionget_args
get_origin)      )TypeAliasType)is_annotatedis_enum_flagis_nonetypeis_unionresolve)CoercionErrorValidationError)	FieldInfoget_field_infos)UNSETdefault_name_transformgrouper
is_builtinis_class_and_subclassTokenTE)boundF._implicit_iterable_type_mapping"_abstract_to_concrete_type_mappingNestedCliArgssreturnc                 X    U R                  5       n U S;   a  gU S;   a  g[        [        S9e)N>   0fnnofalseF>   1tyyestrueT)target_type)lowerr   boolr.   s    K/home/james-whalen/.local/lib/python3.13/site-packages/cyclopts/_convert.py_boolr@   Q   s2    		A**	
,	, --    c                 J   U R                  5       n U R                  S5      (       a  [        U S5      $ U R                  S5      (       a  [        U S5      $ U R                  S5      (       a  [        U S5      $ SU ;   a  [        [        [	        U 5      5      5      $ [        U 5      $ )N0x   0o   0b   .)r<   
startswithintroundfloatr>   s    r?   _intrN   \   s    		A||D1bz	
d		1ay	
d		1ay	 5q?##1vrA   c                     [        U SS9$ )Nutf8)encoding)bytesr>   s    r?   _bytesrS   m   s    V$$rA   c                 *    [        [        U 5      5      $ N)	bytearrayrS   r>   s    r?   
_bytearrayrW   q   s    VAYrA   c                 .    [         R                  " U 5      $ )z4Parse a date string.

Returns
-------
datetime.date
)r   fromisoformatr>   s    r?   _daterZ   u   s     a  rA   c                      [         R                  " U 5      $ ! [         a8    [         R                  " U R                  5       R	                  SSS5      5      s $ f = f)z<Parse a datetime string.

Returns
-------
datetime.datetime
 r'      )r   rY   
ValueErrorstripreplacer>   s    r?   	_datetimera      sR    F%%a(( F %%aggi&7&7S!&DEE	Fs    ?AAc                    SnU R                  S5      (       a  SnU SS n [        R                  " SU 5      nU(       d  [        SU  35      eSnU Hw  u  pEn[	        U5      nUS	:X  a  X5-  nM  US
:X  a	  X5S-  -  nM,  US:X  a	  X5S-  -  nM;  US:X  a	  X5S-  -  nMJ  US:X  a	  X5S-  -  nMY  US:X  a	  X5S-  -  nMh  US:X  d  Mp  X5S-  -  nMy     U(       a  U* n[        US9$ )zParse a timedelta string.F-Tr]   Nz((\d+\.\d+|\d+)([smhdwMy]))z!Could not parse duration string: r   r.   m<   hi  diQ wi:	 Mi ' r8   i3)seconds)rJ   refindallr^   rM   r   )r.   negativematchesrj   _valueunits          r?   
_timedeltarr      s   H||CabEjj7;G<QC@AAG!$e3;GS[rz!GS[t|#GS[u}$GS[v~%GS[w&GS[x''G# "& (W%%rA   type_tokenr&   name_transformc                     SSK Jn  [        X5      nU(       a  UR                  OUnU" U5      nU R                  R                  5        H  u  pxU" U5      U:X  d  M  Us  $    [        U(       a  UU S9eSU S9e)ziMatch a token's value to an enum's member.

Applies ``name_transform`` to both the value and the member.
r   r%   Nrt   r;   )cyclopts.argumentr&   
isinstancerp   __members__itemsr   )	rs   rt   ru   r&   is_tokenrp   value_transformednamemembers	            r?   get_enum_memberr      s~     (%'H#EKKE&u-))//1$#44M 2 e %) rA   	enum_typetokensc                 ^   ^ ^ [        [        R                  U U4S jU 5       T " S5      5      $ )a  Convert tokens to a Flag enum value.

Parameters
----------
enum_type : type[F]
    The Flag enum type to convert to.
tokens : Iterable[str] | Iterable[Token]
    The tokens to convert. Can be member names or :class:`Token` objects.
name_transform : Callable[[str], str] | None
    Function to transform names for comparison.

Returns
-------
F
    The combined flag value.

Raises
------
CoercionError
    If a token is not a valid flag member.
c              3   >   >#    U  H  n[        TUT5      v   M     g 7frU   )r   ).0rt   r   ru   s     r?   	<genexpr>$convert_enum_flag.<locals>.<genexpr>   s     OuE>	:	:s   r   )r   operatoror_)r   r   ru   s   ` `r?   convert_enum_flagr      s(    4 OO! rA   _converters	converterc          
      j  ^^^ [        [        XS9m[        S [        U 5       5       5      n[	        U 5      u  mn[        TS5      mU(       a  [        U5      T-  nU(       a  [        ST S[        U5       S3S9e[        U5      S:X  a  US   mO![        U5      S:X  a  [        mO[        S	5      e[        UUU4S
 j[        UT5       5       5      $ T[        U5      :w  a  [        ST S[        U5       S3S9eU Vs/ s H  n[	        U5      S   PM     nn[        U5      n	U V
Vs/ s H(  n
[        U
5       Vs/ s H  n[        U	5      PM     snPM*     nn
nU Vs/ s H  n[        U5      S:X  a  US   OUPM     nn[        U4S j[        XLSS9 5       5      nU$ s  snf s  snf s  snn
f s  snf )Nr   ru   c              3   2   #    U  H  oS Ld  M	  Uv   M     g7f).N r   xs     r?   r   !_convert_tuple.<locals>.<genexpr>   s     C?asl?s   	r]   z4Incorrect number of arguments: expected multiple of z	 but got rI   )msgr   z%A tuple must have 0 or 1 inner-types.c              3   L   >#    U  H  nT" TTS :X  a  US   OU5      v   M     g7f)r]   r   Nr   )r   chunkconvertinner_token_count
inner_types     r?   r   r     s0      
; J,=,BaNN;s   !$z(Incorrect number of arguments: expected c              3   8   >#    U  H  u  pT" X5      v   M     g 7frU   r   )r   r   argr   s      r?   r   r     s     lDkGJ,,Dks   F)strict)r   _converttupler   token_countmaxlenr   strr^   r"   iterrangenextzip)rs   r   ru   r   inner_typesconsume_all	remainderr   args_per_convertitsizero   batchedelemoutr   r   r   s                  @@@r?   _convert_tupler      s    h)SGC8E?CCK%0%7"{-q1K"33	JK\J]]fgjkqgrfsstu  {q $QJ"JDEE 
 ):;
 
 	
 F+>?P>QQZ[^_e[fZgghi  8CC{!KN1-{C&\?OP?OteDk2kDHk2?OPCJK74c$i1n47$67KlCejDkllJ D2PKs$   ?F )F*<F%F* F0%F*datafield_infosc                 n   SSK Jn  0 nUR                  5        H  u  pxXq;   d  M  X   n	U	by  [        UR                  [
        5      (       dZ  U" [        U	[        [        -  5      (       a  [        R                  " U	5      O
[        U	5      S9n
[        UR                  U
/X45      nOU	nXU'   M     U " S0 UD6$ )a  Convert JSON dict to dataclass with proper type conversion for fields.

Parameters
----------
type_ : Type
    The dataclass type to create.
data : dict
    The JSON dictionary containing field values.
field_infos : dict
    Field information from the dataclass.
converter : Callable | None
    Optional converter function.
name_transform : Callable[[str], str]
    Function to transform field names.

Returns
-------
Instance of type_ with properly converted field values.
r   r%   rp   r   )cyclopts.tokenr&   r{   r$   hintr   ry   dictlistjsondumpsr   )rs   r   r   r   ru   r&   converted_data
field_name
field_inforp   rt   converted_values               r?   _convert_jsonr   #  s    4 %N"-"3"3"5
$E )>zPS)T)TE4RV;9W9WDJJu$5]`af]gh")*//E7I"^"')8:& #6 ">""rA   errorc           	         U R                   R                  5       n[        US5      (       a  UR                  O![        US5      (       a  UR                  S-
  OSn[        SUS-
  5      n[        [        U5      US-   5      nX5U nUS:  a  SU-   nU[        U5      :  a  US-   nXE-
  nUS:  a  US-  nSn	[        R                  " S	U5      (       a  S
n	OF[        R                  " SU5      (       a  Sn	O'[        R                  " SU5      (       a  Sn	OSU;   a  Sn	SUR                   SU SSU-   SUR                   U	 3	$ )aW  Create a helpful error message for JSON decode errors.

Parameters
----------
token : Token
    The token containing the invalid JSON.
type_ : Type
    The target type we were trying to convert to.
error : json.JSONDecodeError
    The JSON decode error that occurred.

Returns
-------
str
    A formatted error message with context and hints.
poscolnor]   r      z...r    z\bTrue\bz8
    Hint: Use lowercase 'true' instead of Python's Truez	\bFalse\bz:
    Hint: Use lowercase 'false' instead of Python's Falsez\bNone\bz.
    Hint: Use 'null' instead of Python's None'z9
    Hint: JSON requires double quotes, not single quoteszInvalid JSON for z:
    z
    r\   z^ )rp   r_   hasattrr   r   r   minr   rk   search__name__r   )
rt   rs   r   	value_str	error_possnippet_startsnippet_endsnippet
marker_posr   s
             r?   !_create_json_decode_error_messager   Q  sJ   * !!#I %UE22		7SXZaKbKbahiI 9r>*Mc)ni"n5Kk2G q'/S^#E/ *Jqa
 D	yyi((J	<	+	+L	;		*	*@			Ku~~.ggYfS:EUDVVXY^YbYbXcdhcijjrA   c                   ^ [        U 5      nU(       d  U " S0 UD6$ / n0 nUR                  5        HS  u  pVUR                  U5      nU(       a2  UR                  [        R
                  :X  a  UR                  XV45        MO  XdU'   MU     [        UR                  5       5      mUR                  U4S jS9  U " S U 5       0 UD6$ )a  Instantiate a type with proper handling of parameter kinds.

Respects POSITIONAL_ONLY, KEYWORD_ONLY, and POSITIONAL_OR_KEYWORD parameter kinds
when constructing the object.

This function is necessary because `inspect.signature().bind(**data)` has the same
limitation we're solving: it cannot accept positional-only parameters as keyword
arguments. For example, `def __init__(self, a, /, b)` requires `a` to be passed
positionally, but when we have a dict `{"a": 1, "b": 2}`, we need to transform
this into the call `type_(1, b=2)`.

Parameters
----------
type_ : type[T]
    The type to instantiate.
data : dict[str, Any]
    Dictionary mapping field names to values.

Returns
-------
T
    Instance of type_ constructed from data.
c                 ,   > TR                  U S   5      $ )Nr   )index)r   field_names_orders    r?   <lambda>'instantiate_from_dict.<locals>.<lambda>  s     1 7 7! =rA   )keyc              3   *   #    U  H	  u  pUv   M     g 7frU   r   )r   ro   vs      r?   r   (instantiate_from_dict.<locals>.<genexpr>  s     *1s   r   )
r   r{   getkindr   POSITIONAL_ONLYappendr   keyssort)	rs   r   r   pos_argskwargsr   rp   r   r   s	           @r?   instantiate_from_dictr     s    0 "%(K}t}HF!ZZ\
 __Z0
*//Y-F-FFOOZ/0!&: * [--/0MM=M>**5f55rA   r   r   c                    Sn0 nU nUR                  5        H  u  pxUR                  n[        U[        5      (       a  X   R                  n	US-  nSn
O7[        U5      u  pUS:X  a  U" XaU   5      n	US-  nOU" XaXDU-    5      n	XK-  nUn
XU'   U
(       a    OU[        U5      :X  d  M    O   U[        U5      :X  d   e[        X5      $ )a  Convert tokens to a structured type with proper positional/keyword argument handling.

Respects the parameter kind of each field:
- POSITIONAL_ONLY: passed as positional argument
- KEYWORD_ONLY or POSITIONAL_OR_KEYWORD: passed as keyword argument

This correctly handles types with keyword-only fields (e.g., dataclasses with kw_only=True).

Parameters
----------
type_ : type[T]
    The target structured type to instantiate.
token : Sequence[Token]
    The tokens to convert.
field_infos : dict[str, FieldInfo]
    Field information for the structured type.
convert : Callable
    Conversion function for nested types.

Returns
-------
T
    Instance of type_ constructed from the tokens.
r   r]   F)r{   r   r$   r   rp   r   r   r   )rs   rt   r   r   ir   r   r   r   rp   should_breaktokens_per_elementr   s                r?   _convert_structured_typer     s    < 	
ADD"-"3"3"5
 !s++HNNEFA L.9$.?+!Q&Ah/QA4F0F&GH'&L Z E
?1 #64 E
?? --rA   c                d  ^^^^ SSK Jm  SSKJn  Sn[	        U 5      (       aS  SSKJn  UR                  U 5      u  n mTR                  (       a
  SnU4S jnUnTR                  (       a  TR                  nOSm[        [        X#S9m[        [        X#S9n[        U 5      nU[        ;   a	  [        U   n[        U 5      mU [        L a  T" [        [        [        4   U5      n	GOU [         ;   a  T" [         U    U5      n	GOU [        ;   a(  [        U    n
[         R#                  X5      nT" X5      n	GO[$        b*  ['        U [$        5      (       a  T" U R(                  U5      n	GO[+        U5      (       aI  T H  n[-        U5      (       a  M   T" X5      n	  GOP   ['        U[0        5      (       a  [2        e[5        XS	9eU[6        L ag  Sn[        U 5       H   n T" [9        U5      U5      nX:X  d  M  Un	  GO   U(       a  Xl        Ue[5        ['        U[0        5      (       a  US   U S	9eUU S	9eU[<        L a(  ['        UT5      (       a	  U" XUS
9n	GOU" U /UQ7SU06n	GOU[>        ;   a  [A        TS   5      u  nn['        U[0        5      (       d  [2        eTS   nUS:  a&  [C        U4S jU 5       5      (       a  U[        La  UnO!US:  a  [E        [G        U5      /U-  SS06nOUnU" UU4S jU 5       5      n	GO[I        U [J        5      (       a'  [M        U ['        U[0        5      (       a  UOU/U5      n	GO[I        U [N        5      (       a@  ['        U[0        5      (       a  [2        eUc  [Q        XU5      n	GOoU" XRR                  5      n	GO[[U        U 5      n[W        U 5      (       d  U(       d  ['        UT5      (       d   e URX                  [Z        La  URX                  n	GOUc&  [\        R#                  X 5      " URR                  5      n	OU(       a	  U" X5      n	OU" XRR                  5      n	O['        UT5      (       a  URR                  Ra                  5       Rc                  S5      (       aT  U [        LaK   [d        Rf                  " URR                  5      n['        U[        5      (       d  [h        e[k        U UUX#5      n	O%['        U[0        5      (       d  U/n[q        XUT5      n	T(       a   TRr                   H  nU" X	5        M     U	$ U	$ ! [.         a     GM  f = f! [4         a  nUn SnAGM`  SnAff = f! [4         a.  nUR:                  c  U Ul        UR^                  c  UUl/        e SnAf[2         a    [5        XS	9Sef = f! [d        Rl                   a  n[o        XU5      n[5        UXS9UeSnAf[h         a)    ['        U[0        5      (       d  U/n[q        XUT5      n	 GNf = f! [t        [2        [h        4 a0  n[w        URx                  (       a  URx                  S   OSU	S9UeSnAff = f)zInner recursive conversion function for public ``convert``.

Parameters
----------
converter: Callable
name_transform: Callable
r   r%   )	ParameterFTc                    > TR                   (       d   eTR                   n[        U[        5      (       a  [        X5      n[        R
                  " U5      (       a	  U" U45      $ U" X45      $ rU   )r   ry   r   getattrinspectismethod)t_rp   resolved_convertercparams      r?   converter_with_token&_convert.<locals>.converter_with_token  si    '''' &,%5%5"0#66)0)H& ##$677-uh77 .b(;;rA   Nr   rw   )r   r   r]   c              3      >#    U  HA  n[        UT5      =(       a)    UR                  R                  5       R                  S 5      v   MC     g7f){N)ry   rp   r_   rJ   )r   r7   r&   s     r?   r   _convert.<locals>.<genexpr>n  s8     \V[QRJq%(LQWW]]_-G-G-LLV[s   A	Ar   c              3   <   >#    U  H  nT" TS    U5      v   M     g7f)r   Nr   )r   er   r   s     r?   r   r   w  s     Bc'+a.!44cs   r   )r   rt   r;   r   )exception_messagerp   )=rx   r&   cyclopts.parameterr   r   from_annotationr   ru   r   r   r   r   r,   r   r   r   r+   r   r   ry   	__value__r   r   	Exceptionr   r^   r   r   typer;   r   ITERABLE_TYPESr   anyr   r   r$   r
   r   r	   r   rp   r   r#   implicit_valuer    r   rt   r_   rJ   r   loads	TypeErrorr   JSONDecodeErrorr   r   	validatorAssertionErrorr   args)rs   rt   r   ru   r   converter_needs_tokenr   convert_tupleorigin_typer   concrete_typedefault_paramr7   last_coercion_errorchoiceresr   countro   r   genr   r   r   r  r&   r   r   r   s                            @@@@r?   r   r     s    (,!E0!11%8v$(!<" -I  #22Nh)SGNi_MU#K 888E5/K}d38ne,	1	15e<eD	4	4 ;5A7;;MYm+		"z%'G'Geoou-	+		A1~~a'  %**  e??		"uoFd6lE2 } & #27/))#j6Q6Q%(joppW\jopp		eU##	BCCCCC		& {1~.q%** !^
AI\V[\\\#% CQYU}u,;U;CCBcBB	ud	+	+
5(0K0KuRWQXZhi	ud	+	+eX&&!%?CE;;/C%e, eKeU++++N''u4..C&%//%7DC*#E1C#E;;7C %''EKK,=,=,?,J,J3,O,OTYadTdW::ekk2D%dD11''t[)\C "%22"GE.u['R
	c#--	%% .
 J3Jw   ! &'#D ! ==($)AM77?#AG N#%CMN ++ X;E!LC'CuPVWW  W%eX66!&25gVC	W& 
I6 	c!AFF1IRWZ[abb	cs   	TT?T8  (T8 	T8 T8 5A	V ,W* 
TT
T5'T00T58
V)U++VW'V112W'&W'*X/?+X**X/c                   ^ SSK Jm  U(       d  [        e[        U[        5      (       d-  [        US   [
        5      (       a  [        U4S jU 5       5      nUc  [        n[        [        X#S9n[        [        X#S9n[        U 5      n U [        L a  [
        n [        R                  X 5      n U [        ;   a  [        U    n[        R                  Xf5      n [!        U 5      nU[        ;   a	  [        U   nU=(       d    U nU[        L a	  U" U /UQ76 $ U["        ;   a  U" X5      $ U[        L ar  [        U[        5      (       d  [        e [%        U 5      S   n	UR)                  5        V
Vs0 s H  u  pU
[+        XX#S9_M     nn
n[,        R                  X5      " S	0 UD6$ [        U[        5      (       a  [        SU < S35      e[/        U5      (       a  [1        XU5      $ [3        U5      S:X  a  U" XS   5      $ [5        U 5      u  pUS:X  a  U Vs/ s H
  o" X5      PM     sn$ [3        U5      U:X  a  U" X5      $ [7        S5      e! [&         a
    [
        n	 GNf = fs  snn
f s  snf )
aT  Coerce variables into a specified type.

Internally used to coercing string CLI tokens into python builtin types.
Externally, may be useful in a custom converter.
See Cyclopt's automatic coercion rules :doc:`/rules`.

If ``type_`` **is not** iterable, then each element of ``tokens`` will be converted independently.
If there is more than one element, then the return type will be a ``Tuple[type_, ...]``.
If there is a single element, then the return type will be ``type_``.

If ``type_`` **is** iterable, then all elements of ``tokens`` will be collated.

Parameters
----------
type_: Type
    A type hint/annotation to coerce ``*args`` into.
tokens: Union[Sequence[str], NestedCliArgs]
    String tokens to coerce.
    Generally, either a list of strings, or a dictionary of list of strings (recursive).
    Each leaf in the dictionary tree should be a list of strings.
converter: Optional[Callable[[Type, str], Any]]
    An optional function to convert tokens to the inner-most types.
    The converter should have signature:

    .. code-block:: python

        def converter(type_: type, value: str) -> Any:
            "Perform conversion of string token."

    This allows to use the :func:`convert` function to handle the the difficult task
    of traversing lists/tuples/unions/etc, while leaving the final conversion logic to
    the caller.
name_transform: Optional[Callable[[str], str]]
    Currently only used for ``Enum`` type hints.
    A function that transforms enum names and CLI values into a normalized format.

    The function should have signature:

    .. code-block:: python

        def name_transform(s: str) -> str:
            "Perform name transform."

    where the returned value is the name to be used on the CLI.

    If ``None``, defaults to ``cyclopts.default_name_transform``.

Returns
-------
Any
    Coerced version of input ``*args``.
r   r%   c              3   B   >#    U  H  nT" [        U5      S 9v   M     g7f)r   N)r   )r   r   r&   s     r?   r   convert.<locals>.<genexpr>  s     ;Fqu3q6*Fs   r   r]   z*Dictionary of tokens provided for unknown rI   zUnreachable?r   )rx   r&   r^   ry   r   r   r   r!   r   r   r   r   r   r+   r   r,   r   r   r   
IndexErrorr{   r   r   r   r   r   r   NotImplementedError)rs   r   r   ru   convert_privr
  r  r  maybe_origin_type
value_typekr   dict_convertedr   ro   itemr&   s                   @r?   r   r     sM   t (fd##
6!9c(B(B;F;;/8yXLNi_MENE|+//=E 22:5A/33MQU#K888E#,ueU,V,,	n	,E**	d	"&$''	!%+J gmfrfrft
ft^b^_Awz	YYft 	 
 0DV~VV	FD	!	!EeYaPQQ	'	(	( !!2NKKv;!ay11 +E 2":@A&$L-&AA[....%n55+  	J	
 Bs   I &II IIskip_converter_paramsc                 4   SSK Jn  U" XS9u  p4U HE  nUR                  c  M  UR                  S:X  a    gX0La  [        USS9u  pgOSnUR                  U4s  $    Un [	        U 5      nU[
        ;   a	  [
        U   nU [
        ;   a)  [
        U    n	[        R                  X5      n [	        U 5      nU=(       d    U [        L a*  [        U 5      n
U
(       a  [        S	 U
 5       5      S
U
;   4$ gU=(       d    U [        L a  gU [        ;   d"  U[        ;   a  [        [        U 5      5      S:X  a  g[        U 5      (       a  gU[        ;   a5  [        [        U 5      5      (       a  [        [        U 5      S   5      S   S4$ [        b*  [!        U [        5      (       a  [        U R"                  5      $ [%        U 5      (       aK  [        U 5      n[        US   5      nUSS  H'  n[        U5      nX:w  d  M  ['        SUS    SU 35      e   U$ [)        U 5      (       a  g[+        U 5      nSu  nnUR-                  5        HT  nUR.                  UR0                  L a  SnOUR2                  (       d  M2  [        UR4                  5      u  nnUU-  nUU-  nMV     U(       d  gUU4$ )aC  The number of tokens after a keyword the parameter should consume.

Parameters
----------
type_: Type
    A type hint/annotation to infer token_count from if not explicitly specified.
skip_converter_params: bool
    If True, don't extract converter parameters from __cyclopts__.
    Used to prevent infinite recursion when determining consume_all behavior.

Returns
-------
int
    Number of tokens to consume.
bool
    If this is ``True`` and positional, consume all remaining tokens.
    The returned number of tokens constitutes a single element of the iterable-to-be-parsed.
r   )get_parameters)r  N)r]   TTFc              3   J   #    U  H  oS Ld  M	  [        U5      S   v   M     g7f).r   N)r   r   s     r?   r   token_count.<locals>.<genexpr>w  s      G$Q3,({1~a($s   ##.)r   Fr]   z=Cannot Union types that consume different numbers of tokens: r\   )r]   F)r   r   n_tokensr   r   r,   r+   r   r   r   sumr=   r   r   r   r   ry   r   r   r^   r#   r   valuesr   VAR_POSITIONALrequiredr   )rs   r  r   resolved_type
parametersparamro   consume_all_from_typer  r  r  sub_argstoken_count_target	sub_type_thisr   r  r   rp   
elem_countelem_consume_alls                        r?   r   r   >  s   * 2 .u bM>>%~~#
 !- 0;=`d/e,A, -2)~~'<<<! $ EU#K888E 22:5A/33MQ 'u&G$GGPTTT

4	'	.	 [N%Bs8TY?G[_`G`	e				&3x+?+?8E?1-.q1477		"z%'G'G5??++	%E?(!5!!"Iy)D) ST\]^T_S``abkalm  & "!	E		 &e,%{ '')EzzU111"^^+6uzz+B(J(ZE++K * k!!rA   )NN)F)]collections.abccollectionsr   r   r   rk   systypingr   r   r   r   r   r   enumr	   r
   	functoolsr   r   r   r   r   r   r   r   r   version_infor   cyclopts.annotationsr   r   r   r   r   cyclopts.exceptionsr   r   cyclopts.field_infor   r   cyclopts.utilsr    r!   r"   r#   r$   rx   r&   r'   r(   r*   	frozensetr   r   setr   r   r+   r   __annotations__abcSet
MutableSetMutableSequenceMappingMutableMappingr,   r   r-   r=   r@   rK   rN   rR   rS   rV   rW   rZ   ra   rr   r   r   r   r   r   r  r   r   r   r   r   r   r   rA   r?   <module>rG     s       	 
  8 8 . .  %   w$M [ [ > : d dw$M' CLCtCt
 y~$s)S	5c?$sCx.5 dDj!1  d
OOTdOOOOOO##TOOTOO""D	8 "Dt$4 	 
OO	 S% >??@.S .T .C C "%c %e % #  )  !S !T !F F F "&# "&) "&J7# cUCZ( 	.AwSMHW-- cUCZ( 	F 	%	6z%iz$T#x-  (9(( sS()D0( cUCZ(	(
 (V+#+#
+# +# $	+#
 cUCZ(+#\5k5k5k 5k 		5kp*6a *6S#X *61 *6Z=.7=.G=. c;&'=. 	=.
 =.@J(7++,J c
C(4/	J
 cUCZ(J` 4826	x6x6SMHW--=x6 sS()D0x6 cUCZ(4/	x6vd"s d"4 d"E#t)DT d"rA   