
    (Gg              	           d dl Zd dlmZmZmZmZ d dlmZm	Z	m
Z
 d dlmZmZ d dlmZ d dlmZ d Z G d d	ee   eeeef         Zy)
    N)CallableGenericSequenceType)NotRequiredRequiredSelf)BaseChannelValue)MISSING)EmptyChannelErrorc                     t        | d      rt        | j                        S t        | d      r0| j                  t        t        fv rt        | j
                  d         S | S )z=Strips Annotated, Required and NotRequired from a given type.
__origin__r   )hasattr_strip_extrasr   r   r   __args__)ts    u/home/kushmeetdev/apache_webroot/langgraph_flaskproject/venv/lib/python3.12/site-packages/langgraph/channels/binop.pyr   r      sM    q,Q\\**q,ALLX{4K$KQZZ]++H    c                        e Zd ZdZdZdee   deeegef   f fdZde	de
fdZedee   fd	       Zedee   fd
       ZdefdZdedefdZdee   de
fdZdefdZde
fdZdefdZ xZS )BinaryOperatorAggregatezStores the result of applying a binary operator to the current value and each new value.

    ```python
    import operator

    total = Channels.BinaryOperatorAggregate(int, operator.add)
    ```
    )valueoperatortypr   c                    t         |   |       || _        t        |      }|t        j
                  j                  t        j
                  j                  fv rt        }|t        j
                  j                  t        j
                  j                  fv rt        }|t        j
                  j                  t        j
                  j                  fv rt        }	  |       | _        y # t         $ r t"        | _        Y y w xY wN)super__init__r   r   collectionsabcr   MutableSequencelistSet
MutableSetsetMappingMutableMappingdictr   	Exceptionr   )selfr   r   	__class__s      r   r   z BinaryOperatorAggregate.__init__"   s      C ;??++[__-L-LMMC;??&&(B(BCCC;??**KOO,J,JKKC	!DJ 	! DJ	!s   C% %C<;C<r   returnc                     t        |t              xrL |j                  j                  dk7  r1| j                  j                  dk7  r|j                  | j                  u S dS )Nz<lambda>T)
isinstancer   r   __name__)r*   r   s     r   __eq__zBinaryOperatorAggregate.__eq__3   sW    %!89 
~~&&*4&&*4 NNdmm+	
 		
r   c                     | j                   S )z,The type of the value stored in the channel.r   r*   s    r   	ValueTypez!BinaryOperatorAggregate.ValueType;        xxr   c                     | j                   S )z/The type of the update received by the channel.r2   r3   s    r   
UpdateTypez"BinaryOperatorAggregate.UpdateType@   r5   r   c                     | j                  | j                  | j                        }| j                  |_        | j                  |_        |S )zReturn a copy of the channel.)r+   r   r   keyr   )r*   emptys     r   copyzBinaryOperatorAggregate.copyE   s5    txx7HH	jjr   
checkpointc                     | j                  | j                  | j                        }| j                  |_        |t        ur||_        |S r   )r+   r   r   r9   r   r   )r*   r<   r:   s      r   from_checkpointz'BinaryOperatorAggregate.from_checkpointL   s9    txx7HH	W$$EKr   valuesc                     |sy| j                   t        u r|d   | _         |dd  }|D ]#  }| j                  | j                   |      | _         % y)NFr      T)r   r   r   )r*   r?   r   s      r   updatezBinaryOperatorAggregate.updateS   sR    :: DJABZF 	:Etzz59DJ	:r   c                 R    | j                   t        u r
t               | j                   S r   )r   r   r   r3   s    r   getzBinaryOperatorAggregate.get]   s!    :: #%%zzr   c                 &    | j                   t        uS r   )r   r   r3   s    r   is_availablez$BinaryOperatorAggregate.is_availableb   s    zz((r   c                     | j                   S r   )r   r3   s    r   r<   z"BinaryOperatorAggregate.checkpointe   s    zzr   )r/   
__module____qualname____doc__	__slots__r   r   r   r   objectboolr0   propertyr4   r7   r	   r;   r>   r   rB   rD   rF   r<   __classcell__)r+   s   @r   r   r      s     &I!DK !8UENE<Q3R !"
F 
t 
 4;   DK  d % D Xe_  U 
)d )E r   r   )collections.abcr   typingr   r   r   r   typing_extensionsr   r   r	   langgraph.channels.baser
   r   langgraph.constantsr   langgraph.errorsr   r   r    r   r   <module>rW      sB     4 4 9 9 6 ' .Pgenk%:M.N Pr   