
    }
i              	           d dl Zd dl mZmZ d dlmZmZ d dlmZm	Z	m
Z
 d dlmZ d dlmZ d dlmZmZ d dlmZmZmZmZ d d	lmZ d
Zd Zdedeeef         fdZ G d dee         eeeef                   ZdS )    N)CallableSequence)AnyGeneric)NotRequiredRequiredSelf)	OVERWRITE)MISSING)BaseChannelValue)EmptyChannelError	ErrorCodeInvalidUpdateErrorcreate_error_message)	Overwrite)BinaryOperatorAggregatec                     t          | d          rt          | j                  S t          | d          r/| 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    C:\Users\Dell Inspiron 16\Desktop\tws\AgrotaPowerBi\back-agrota-powerbi\mcp-client-agrota\venv\Lib\site-packages\langgraph/channels/binop.pyr   r      s`    q, +Q\***q, ,ALX{4K$K$KQZ]+++H    valuereturnc                     t          | t                    r	d| j        fS t          | t                    r:t	          |                                           t          hk    rd| t                   fS dS )zEInspects the given value and returns (is_overwrite, overwrite_value).T)FN)
isinstancer   r   dictsetkeysr
   r   s    r   _get_overwriter$       sd    %## !U[  % &3uzz||#4#4#C#CU9%%%;r   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 )r   zStores the result of applying a binary operator to the current value and each new value.

    ```python
    import operator

    total = Channels.BinaryOperatorAggregate(int, operator.add)
    ```
    )r   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          }	  |            | _        d S # t           $ r t"          | _        Y d S w xY wN)super__init__r&   r   collectionsabcr   MutableSequencelistSet
MutableSetr!   MappingMutableMappingr    r   	Exceptionr   )selfr'   r&   	__class__s      r   r+   z BinaryOperatorAggregate.__init__5   s      C  ;?+[_-LMMMC;?&(BCCCC;?*KO,JKKKC	!DJJJ 	! 	! 	! DJJJJ	!s   ;C C&%C&r   r   c                     t          |t                    o/|j        j        dk    r| j        j        dk    r|j        | j        u ndS )Nz<lambda>T)r   r   r&   __name__)r5   r   s     r   __eq__zBinaryOperatorAggregate.__eq__F   sP    %!899 
~&*44&*44 Ndm++ 		
r   c                     | j         S )z,The type of the value stored in the channel.r'   r5   s    r   	ValueTypez!BinaryOperatorAggregate.ValueTypeN        xr   c                     | j         S )z/The type of the update received by the channel.r;   r<   s    r   
UpdateTypez"BinaryOperatorAggregate.UpdateTypeS   r>   r   c                 v    |                      | j        | j                  }| j        |_        | j        |_        |S )zReturn a copy of the channel.)r6   r'   r&   keyr   )r5   emptys     r   copyzBinaryOperatorAggregate.copyX   s0    tx77H	jr   
checkpointc                 ~    |                      | j        | j                  }| j        |_        |t          ur||_        |S r)   )r6   r'   r&   rB   r   r   )r5   rE   rC   s      r   from_checkpointz'BinaryOperatorAggregate.from_checkpoint_   s9    tx77H	W$$$EKr   valuesc                 >   |sdS | j         t          u r|d         | _         |dd          }d}|D ]n}t          |          \  }}|r6|r*t          dt          j                  }t          |          || _         d}L|s |                     | j         |          | _         odS )NFr      z4Can receive only one Overwrite value per super-step.)message
error_codeT)r   r   r$   r   r   INVALID_CONCURRENT_GRAPH_UPDATEr   r&   )r5   rH   seen_overwriter   is_overwriteoverwrite_valuemsgs          r   updatezBinaryOperatorAggregate.updatef   s     	5:  DJABBZF$ 	> 	>E,:5,A,A)L/ 	! 2. V#,#L  C -S111,
!%! >!]]4:u==
tr   c                 H    | j         t          u rt                      | j         S r)   )r   r   r   r<   s    r   getzBinaryOperatorAggregate.get}   s#    :  #%%%zr   c                     | j         t          uS r)   )r   r   r<   s    r   is_availablez$BinaryOperatorAggregate.is_available   s    z((r   c                     | j         S r)   r#   r<   s    r   rE   z"BinaryOperatorAggregate.checkpoint   s
    zr   )r8   
__module____qualname____doc__	__slots__typer   r   r+   objectboolr9   propertyr=   r@   r	   rD   rG   r   rR   rT   rV   rE   __classcell__)r6   s   @r   r   r   )   s         &I!DK !8UENE<Q3R ! ! ! ! ! !"
F 
t 
 
 
 
 4;    X DK    Xd    % D    Xe_     .U    
)d ) ) ) )E        r   r   )collections.abcr,   r   r   typingr   r   typing_extensionsr   r   r	   langgraph._internal._constantsr
   langgraph._internal._typingr   langgraph.channels.baser   r   langgraph.errorsr   r   r   r   langgraph.typesr   __all__r   tupler^   r$   r    r   r   <module>rl      sz       . . . . . . . .         9 9 9 9 9 9 9 9 9 9 4 4 4 4 4 4 / / / / / / 6 6 6 6 6 6 6 6            & % % % % %
&  # %c	"2    ] ] ] ] ]genk%:M.N ] ] ] ] ]r   