
    wBf                        d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 	 ddl
m
Z
  e	d	d
d      d        Z G d de      Zedd fdZ e	dd	      d dd fd       Zedd fdZ e	dd	      d        Zy# e$ r	 ddlm
Z
 Y ^w xY w)zCommon collection classes.    )reduce)MappingSet   )
isiterable   )
deprecated)
frozendictz24.9z25.3z$Use `frozendict.deepfreeze` instead.)addendumc                 P   t        | t              r2t        | t              r| S t        d | j                         D              S t        | t              r$t        | t
              r| S t        d | D              S t        |       r$t        | t              r| S t        d | D              S | S )Nc              3   <   K   | ]  \  }}|t        |      f  y wNmake_immutable).0kvs      7lib/python3.12/site-packages/conda/auxlib/collection.py	<genexpr>z!make_immutable.<locals>.<genexpr>   s     KTQ1nQ/0Ks   c              3   2   K   | ]  }t        |        y wr   r   r   r   s     r   r   z!make_immutable.<locals>.<genexpr>   s     :q*:   c              3   2   K   | ]  }t        |        y wr   r   r   s     r   r   z!make_immutable.<locals>.<genexpr>   s     61^A&6r   )
isinstancer   r
   itemsr   	frozensetr   tuple)values    r   r   r      s     %!eZ(LKU[[]KKK	E3	eY'L:E:::	E	eU#L6666    c                   "     e Zd ZdZ fdZ xZS )AttrDictzSub-classes dict, and further allows attribute-like access to dictionary items.

    Examples:
        >>> d = AttrDict({'a': 1})
        >>> d.a, d['a'], d.get('a')
        (1, 1, 1)
        >>> d.b = 2
        >>> d.b, d['b']
        (2, 2)
    c                 2    t        |   |i | | | _        y r   )super__init____dict__)selfargskwargs	__class__s      r   r$   zAttrDict.__init__.   s    $)&)r   )__name__
__module____qualname____doc__r$   __classcell__)r)   s   @r   r!   r!   #   s    	 r   r!   Nc                     | S r    xs    r   <lambda>r3   3   s    q r   c                 ^    t        fd| D        t        |      r |             S |      S )a  Give the first value that satisfies the key test.

    Args:
        seq (iterable):
        key (callable): test for each element of iterable
        default: returned when all elements fail test
        apply (callable): applied to element before return, but not to default value

    Returns: first element in seq that passes key, mutated with optional apply

    Examples:
        >>> first([0, False, None, [], (), 42])
        42
        >>> first([0, False, None, [], ()]) is None
        True
        >>> first([0, False, None, [], ()], default='ohai')
        'ohai'
        >>> import re
        >>> m = first(re.match(regex, 'abc') for regex in ['b.*', 'a(.*)'])
        >>> m.group(1)
        'bc'

        The optional `key` argument specifies a one-argument predicate function
        like that used for `filter()`.  The `key` argument, if supplied, must be
        in keyword form.  For example:
        >>> first([1, 1, 3, 4, 5], key=lambda x: x % 2 == 0)
        4

    c              3   @   K   | ]  } |      s |        y wr   r0   r   r2   applykeys     r   r   zfirst.<locals>.<genexpr>Q   s     1a#a&q1   )nextcallableseqr8   defaultr7   s    ` `r   firstr?   3   s*    < 131@Q79__W^__r   z24.3c                     t        |       S r   )boolr   r   s     r   r3   r3   U   s
    DG r   c                 
    | |fS r   r0   rB   s     r   r3   r3   U   s    qRSf r   c                 2    t        fd| D        |      S )Nc              3   J   K   | ]  \  }} ||      s ||        y wr   r0   )r   r   r   r7   r8   s      r   r   zfirstitem.<locals>.<genexpr>V   s#     :AAq	q!:s   ##)r:   )mapr8   r>   r7   s    ` `r   	firstitemrG   T   s    ::GDDr   c                     | S r   r0   r1   s    r   r3   r3   Y   s    a r   c                 D    t        fdt        |       D        |      S )Nc              3   @   K   | ]  } |      s |        y wr   r0   r6   s     r   r   zlast.<locals>.<genexpr>Z   s     ;aCFq;r9   )r:   reversedr<   s    ` `r   lastrL   Y   s    ;8C=;WEEr   c                 j    	 t        d |        y# t        $ r}t        |      dk7  r Y d}~yd}~ww xY w)zjCalls each element of sequence to invoke the side effect.

    Args:
        seq:

    Returns: None

    c                      |       S r   r0   )_ys     r   r3   zcall_each.<locals>.<lambda>h   s    AC r   z0reduce() of empty sequence with no initial valueN)r   	TypeErrorstr)r=   es     r   	call_eachrT   ]   s8    % q6GG Hs    	2-2)r-   	functoolsr   collections.abcr   r   compatr   deprecationsr	   r
   ImportError_vendor.frozendictr   dictr!   rA   r?   rG   rL   rT   r0   r   r   <module>r\      s       (  %0%
 FF%KL M(t   [ `B FF+TAT E E K F FF i  0/0s   A5 5BB