
    [i-                       d dl mZ d dlZd dlZd dlZd dlZd dlmZ d dl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 	 	 	 	 	 	 dd
ZddZddZ G d dej4                        Z G d dej4                        ZddZy)    )annotationsN)Callable)Any)RunnableRunnableLambdaRunnableSequence)ChannelVersions)override)RunnableCallableRunnableSeq)PregelProtocolc           	         | rmt        t        t        |j                               d            } |       }|j	                         D ci c]  \  }}|| j                  ||      kD  r|| }}}|S |}|S c c}}w )zEGet subset of current_versions that are newer than previous_versions.N)typenextitervaluesitemsget)previous_versionscurrent_versionsversion_typenull_versionkvnew_versionss          h/var/www/html/userprofiledev.eatanceapp.com/venv/lib/python3.12/site-packages/langgraph/pregel/_utils.pyget_new_channel_versionsr      s     D&6&=&=&?!@$GH#~ )..0
01$((L99 qD0 	 
  (
s   	"A4c                V   ddl m} | g}|D ]  }t        |t              rt        ||      r|j                  dur|c S t        |t
              st        |t              r|j                  |j                         nt        |t              r|j                  |j                         t        |t              s|j                  ,|j                  d t        |j                        D               |j                  |j                  d t        |j                        D                y )Nr   )PregelFc              3  P   K   | ]  }t        |d       r|j                  n|   yw__self__Nhasattrr"   .0nls     r   	<genexpr>z'find_subgraph_pregel.<locals>.<genexpr>6   s*      "< $+2z#:BKKB<   $&c              3  P   K   | ]  }t        |d       r|j                  n|   ywr!   r#   r%   s     r   r(   z'find_subgraph_pregel.<locals>.<genexpr>;   s*      "= $+2z#:BKKB=r)   )langgraph.pregelr   
isinstancer   checkpointerr   r   extendstepsr   depsr   funcget_function_nonlocalsafunc)	candidater   
candidatescs       r   find_subgraph_pregelr7   $   s    '"+Jq.)6*annE.IH+,
1k0Jagg&>*aff%+,vv!!! "4QVV<"  $!! "4QWW=" % .     c                6   	 t        j                  |       }t        j                  t	        j
                  |            }t               }|j                  |       g }t        | d      r4t        | j                        rt        j                  | j                        nt        j                  |       }i |j                  |j                  }|j                         D ]  \  }}||j                  v r|j                  |       |j                  D ]V  }	d|	v s|	j!                  |      s|}
|	j#                  d      dd D ]  }|
 7	 t%        |
|      }
 |j                  |
       X  	 |S # t&        $ r Y  jw xY w# t(        t*        t,        t.        f$ r g cY S w xY w)zGet the nonlocal variables accessed by a function.

    Args:
        func: The function to check.

    Returns:
        List[Any]: The nonlocal variables accessed by the function.
    __wrapped__.   N)inspect	getsourceastparsetextwrapdedentFunctionNonLocalsvisitr$   callabler:   getclosurevarsglobals	nonlocalsr   append
startswithsplitgetattrAttributeErrorSyntaxError	TypeErrorOSErrorSystemError)r1   codetreevisitorr   closurer5   r   r   kkvvparts               r   r2   r2   C   su     &yy./#%d t]+9I9I0J ""4#3#34''- 	
 >=7+<+<=
$$&DAqG%%%a ''"9q!1B "ab 1:!&%,R%6 !2 b) ( '& M $2 & %& G[9 	sB   DE: E: &E: E*E: *	E7	3E: 6E7	7E: :FFc                  N    e Zd ZdZddZedd       Zed	d       Zed
d       Zy)rC   z2Get the nonlocal variables accessed of a function.c                "    t               | _        y N)setrH   selfs    r   __init__zFunctionNonLocals.__init__q   s    #&5r8   c                    t               }|j                  |       | j                  j                  |j                  |j
                  z
         y)zVisit a function definition.

        Args:
            node: The node to visit.

        Returns:
            Any: The result of the visit.
        N	NonLocalsrD   rH   updateloadsstoresr^   noderT   s      r   visit_FunctionDefz#FunctionNonLocals.visit_FunctionDeft   6     +dgmmgnn<=r8   c                    t               }|j                  |       | j                  j                  |j                  |j
                  z
         y)zVisit an async function definition.

        Args:
            node: The node to visit.

        Returns:
            Any: The result of the visit.
        Nra   rf   s      r   visit_AsyncFunctionDefz(FunctionNonLocals.visit_AsyncFunctionDef   ri   r8   c                    t               }|j                  |       | j                  j                  |j                  |j
                  z
         y)zVisit a lambda function.

        Args:
            node: The node to visit.

        Returns:
            Any: The result of the visit.
        Nra   rf   s      r   visit_LambdazFunctionNonLocals.visit_Lambda   ri   r8   NreturnNone)rg   zast.FunctionDefro   r   )rg   zast.AsyncFunctionDefro   r   )rg   z
ast.Lambdaro   r   )	__name__
__module____qualname____doc__r_   r
   rh   rk   rm    r8   r   rC   rC   n   sF    <) > > > > > >r8   rC   c                  <    e Zd ZdZddZedd       Zedd       Zy)	rb   z Get nonlocal variables accessed.c                @    t               | _        t               | _        y r[   )r\   rd   re   r]   s    r   r_   zNonLocals.__init__   s    "u
 #r8   c                ,   t        |j                  t        j                        r&| j                  j                  |j                         yt        |j                  t        j                        r&| j                  j                  |j                         yy)zVisit a name node.

        Args:
            node: The node to visit.

        Returns:
            Any: The result of the visit.
        N)	r,   ctxr?   Loadrd   addidStorere   )r^   rg   s     r   
visit_NamezNonLocals.visit_Name   sU     dhh)JJNN477##)),KKOODGG$ -r8   c                H   t        |j                  t        j                        r|j                  }|j
                  }t        |t        j                        r9|j
                  dz   |z   }|j                  }t        |t        j                        r9t        |t        j                        rQ| j                  j                  |j                  dz   |z          | j                  j                  |j                         yt        |t        j                        rt        |j                  t        j                        r0| j                  j                  |j                  j                         y|j                  }d}t        |t        j                        rH|r|j
                  dz   |z   }n|j
                  }|j                  }t        |t        j                        rHt        |t        j                        r,| j                  j                  |j                  dz   |z          yyyy)zVisit an attribute node.

        Args:
            node: The node to visit.

        Returns:
            Any: The result of the visit.
        r;    N)r,   ry   r?   rz   valueattr	AttributeNamerd   r{   r|   discardCallr1   )r^   rg   parent	attr_exprs       r   visit_AttributezNonLocals.visit_Attribute   sm    dhh)ZZF		IVS]]3"KK#-	9	 VS]]3 &#((+

vyy3:;

""699-FCHH-fkk3884JJNN6;;>>2#[[F "I$VS]];$(.c(9I(EI(.I!' %VS]]; "&#((3

vyy3'BC 4 . *r8   Nrn   )rg   zast.Namero   r   )rg   zast.Attributero   r   )rq   rr   rs   rt   r_   r
   r~   r   ru   r8   r   rb   rb      s4    *& % % D Dr8   rb   c                @    t        t        j                  d|             S )zCCheck if the given string matches the format of xxh3_128_hexdigest.z[0-9a-f]{32})boolre	fullmatch)r   s    r   is_xxh3_128_hexdigestr      s    _e455r8   )r   r	   r   r	   ro   r	   )r4   r   ro   zPregelProtocol | None)r1   r   ro   z	list[Any])r   strro   r   )
__future__r   r?   r=   r   rA   collections.abcr   typingr   langchain_core.runnablesr   r   r   langgraph.checkpoint.baser	   typing_extensionsr
   langgraph._internal._runnabler   r   langgraph.pregel.protocolr   r   r7   r2   NodeVisitorrC   rb   r   ru   r8   r   <module>r      s}    " 
  	  $  O O 5 & G 4&:I$>(V.> .>b6D 6Dr6r8   