
    jKjX                     l    d Z ddlmZ ddlmZ ddlmZ ddlmZ ddlm	Z	  G d d      Z
 G d	 d
      Zy)ue  JSONSchema path caches module.

Both caches store ``Resolved`` values keyed on hashable schema paths.
Staleness across ``referencing.Registry`` growth is *not* handled by
invalidation here; the callers rebind cached ``Resolved`` values to the
current registry on read (see
``jsonschema_path._referencing_compat.rebind_registry``). This relies on
the assumption that registries grow monotonically — resources are added,
never replaced. Handlers that return drifting content for the same URI
violate that assumption; users who need to defend against that should
disable caching with ``resolved_cache_maxsize=0``.
    )OrderedDict)Sequence)	LookupKey)
LookupNode)Resolvedc                       e Zd ZdefdZdee   deedf   dz  fdZdee   de	e
   dz  fdZdee   d	e	e
   ddfd
Zy)FullPathResolvedCachemaxsizec                 0    || _         t               | _        y N)_maxsizer   _cache)selfr
   s     g/Users/ahmed/devFolder/Ultron/claude-voice/.venv/lib/python3.12/site-packages/jsonschema_path/caches.py__init__zFullPathResolvedCache.__init__   s     M 	    partsreturn.Nc                 r    | j                   dk  ry t        |      }	 t        |       |S # t        $ r Y y w xY w)Nr   )r   tuplehash	TypeError)r   r   parts_tuples      r   	_make_keyzFullPathResolvedCache._make_key   sE     ==AEl	   		s   * 	66c                     | j                  |      }|y | j                  j                  |      }|y | j                  j                  |       |S r   )r   r   getmove_to_end)r   r   keycacheds       r   r   zFullPathResolvedCache.get-   sK     nnU#;%>$r   resolvedc                     | j                  |      }|y || j                  |<   | j                  j                  |       t        | j                        | j                  kD  r| j                  j                  d       y y )NF)last)r   r   r   lenr   popitem)r   r   r    r   s       r   setzFullPathResolvedCache.set<   si    
 nnU#;#C$t{{dmm+KKU+ ,r   )__name__
__module____qualname__intr   r   r   r   r   r   r   r   r%    r   r   r	   r	      s     	" 
y#~		%	" 
*		$,	", :&, 
	,r   r	   c                       e Zd ZddZdee   ddfdZdeedf   dee	ee   f   dz  fdZ
deedf   d	e	dee   ddfd
Zdeedf   d	e	dee   ddfdZy)PrefixResolvedCacher   Nc                     i | _         y r   r   )r   s    r   r   zPrefixResolvedCache.__init__L   s	    IKr   r    c                 "    || j                   d<   y )Nr*   r.   )r   r    s     r   	seed_rootzPrefixResolvedCache.seed_rootO   s    "Br   r   .c                     t        t        |      dz
  dd      D ]+  }|d | }	 | j                  j                  |      }|'||fc S  y # t        $ r Y :w xY w)N   )ranger#   r   r   r   )r   r   idxprefixr   s        r   longest_prefix_hitz&PrefixResolvedCache.longest_prefix_hitR   sl     UaR0C4C[F0 !F{" 1   s   A			AAindexc                 L    |d| }	 || j                   |<   y# t        $ r Y yw xY w)z9Overwrite an existing prefix entry (used after a rebind).N)r   r   r   r   r8   r    r6   s        r   replacezPrefixResolvedCache.replaceb   s4     v	"*DKK 		s    	##c                 v    |t        |      dz
  k\  ry |d |dz    }	 || j                  |<   y # t        $ r Y y w xY w)Nr2   )r#   r   r   r:   s        r   store_intermediatez&PrefixResolvedCache.store_intermediateo   sL     CJN"{#	"*DKK 		s   , 	88)r   N)r&   r'   r(   r   r   r   r0   r   r   r)   r7   r;   r=   r*   r   r   r,   r,   K   s    L#(:"6 #4 #Y^$ 
sHZ((	)D	0 Y^$  :&	
 
Y^$  :&	
 
r   r,   N)__doc__collectionsr   collections.abcr   pathable.typesr   r   referencing._corer   r	   r,   r*   r   r   <module>rC      s0    $ $ $ % &2, 2,j1 1r   