
    A'h
                         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
mZ d dlmZ d dlmZ deeeee   f      dee   fd	Z G d
 dee   e
ee   eeee   f   ee   f         Zy)    )IteratorSequence)AnyGenericUnion)Self)BaseChannelValue)MISSING)EmptyChannelErrorvaluesreturnc              #   \   K   | D ]!  }t        |t              r|E d {    | # y 7 wN)
isinstancelist)r   values     _/home/kushmeetdev/Regenta/Chatbot/venv/lib/python3.12/site-packages/langgraph/channels/topic.pyflattenr      s0      eT"K	s   ,*,c                        e Zd ZdZdZddee   deddf fdZde	defd	Z
edefd
       Zedefd       ZdefdZdee   fdZdee   defdZdeeeee   f      defdZdee   fdZdefdZ xZS )TopiczA configurable PubSub Topic.

    Args:
        typ: The type of the value stored in the channel.
        accumulate: Whether to accumulate values across steps. If False, the channel will be emptied after each step.
    )r   
accumulatetypr   r   Nc                 ^    t         |   |       || _        t        t                  | _        y r   )super__init__r   r   r
   r   )selfr   r   	__class__s      r   r   zTopic.__init__    s$    $5km    r   c                 X    t        |t              xr |j                  | j                  k(  S r   )r   r   r   )r   r   s     r   __eq__zTopic.__eq__'   s#    %'OE,<,<,OOr   c                 (    t         | j                     S )z,The type of the value stored in the channel.)r   r   r   s    r   	ValueTypezTopic.ValueType*   s     !!r   c                 N    t         | j                  t        | j                     f   S )z/The type of the update received by the channel.)r   r   r   r#   s    r   
UpdateTypezTopic.UpdateType/   s      TXXtDHH~-..r   c                     | j                  | j                  | j                        }| j                  |_        | j                  j                         |_        |S )zReturn a copy of the channel.)r   r   r   keyr   copy)r   emptys     r   r)   z
Topic.copy4   s>    txx9HH	{{'')r   c                     | j                   S r   )r   r#   s    r   
checkpointzTopic.checkpoint;   s    {{r   r,   c                     | j                  | j                  | j                        }| j                  |_        |t        ur#t        |t              r|d   |_        |S ||_        |S )N   )r   r   r   r(   r   r   tupler   )r   r,   r*   s      r   from_checkpointzTopic.from_checkpoint>   sW    txx9HH	W$*e,)!}   *r   r   c                     t        | j                        }| j                  st        t                  | _        t	        |      x}r| j                  j                  |       | j                  |k7  S r   )r   r   r   r
   r   extend)r   r   currentflat_valuess       r   updatezTopic.updateI   sT    t{{#u+-DK!&/);)KK{+{{g%%r   c                 P    | j                   rt        | j                         S t        r   )r   r   r   r#   s    r   getz	Topic.getQ   s    ;;$$##r   c                 ,    t        | j                        S r   )boolr   r#   s    r   is_availablezTopic.is_availableW   s    DKK  r   )F)__name__
__module____qualname____doc__	__slots__typer
   r9   r   objectr!   propertyr   r$   r&   r   r)   r   r,   r0   r   r   r5   r7   r:   __classcell__)r   s   @r   r   r      s     )I$DK $T $d $PF Pt P "3 " " /C / /d DK 	$u+ 	$ 	&XeE4;,>&?@ &T &$Xe_ $!d !r   r   N)collections.abcr   r   typingr   r   r   typing_extensionsr   langgraph.channels.baser	   r
   langgraph.constantsr   langgraph.errorsr   r   r   r    r   r   <module>rK      s|    . & & " 6 ' .HU5$u+#567 HUO E!ENud5k'9!:DKGHE!r   