
    g)                         d dl mZmZmZ d dlmZ d dlZd dlZ G d de      Z G d d      Z	d Z
d	 Zd
 Zd Zd Zd Zd Z e        e       fdZd Zd Zd Zy)    )MappingMutableMappingSequence)urlsplitNc                   @    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zy
)URIDictz8
    Dictionary which uses normalized URIs as keys.
    c                 4    t        |      j                         S N)r   geturlselfuris     F/var/www/openai/venv/lib/python3.12/site-packages/jsonschema/_utils.py	normalizezURIDict.normalize   s    }##%%    c                 Z    t               | _         | j                  j                  |i | y r
   )dictstoreupdate)r   argskwargss      r   __init__zURIDict.__init__   s$    V


4*6*r   c                 >    | j                   | j                  |         S r
   r   r   r   s     r   __getitem__zURIDict.__getitem__   s    zz$..-..r   c                 @    || j                   | j                  |      <   y r
   r   )r   r   values      r   __setitem__zURIDict.__setitem__   s    */

4>>#&'r   c                 <    | j                   | j                  |      = y r
   r   r   s     r   __delitem__zURIDict.__delitem__   s    JJt~~c*+r   c                 ,    t        | j                        S r
   )iterr   r   s    r   __iter__zURIDict.__iter__       DJJr   c                 ,    t        | j                        S r
   )lenr   r#   s    r   __len__zURIDict.__len__   s    4::r   c                 ,    t        | j                        S r
   )reprr   r#   s    r   __repr__zURIDict.__repr__"   r%   r   N)__name__
__module____qualname____doc__r   r   r   r   r    r$   r(   r+    r   r   r   r      s/    &+/0,  r   r   c                       e Zd ZdZd Zy)UnsetzG
    An as-of-yet unset attribute or unprovided default parameter.
    c                      y)Nz<unset>r0   r#   s    r   r+   zUnset.__repr__+   s    r   N)r,   r-   r.   r/   r+   r0   r   r   r2   r2   &   s    r   r2   c                 F    |s| S |  ddj                  d |D               dS )aB  
    Construct a single string containing indexing operations for the indices.

    For example for a container ``bar``, [1, 2, "foo"] -> bar[1][2]["foo"]

    Arguments:

        container (str):

            A word to use for the thing being indexed

        indices (sequence):

            The indices to format.

    [z][c              3   2   K   | ]  }t        |        y wr
   r*   ).0indexs     r   	<genexpr>z"format_as_index.<locals>.<genexpr>B   s     #EWEDKW   ])join)	containerindicess     r   format_as_indexr@   /   s0    " [$))#EW#EEFaHHr   c              #      K   |j                  di       }dj                  |j                  di             }| D ]$  }||vs|rt        j                  ||      r!| & yw)z
    Return the set of additional properties for the given ``instance``.

    Weeds out properties that should have been validated by ``properties`` and
    / or ``patternProperties``.

    Assumes ``instance`` is dict-like already.
    
properties|patternPropertiesN)getr=   research)instanceschemarB   patternspropertys        r   find_additional_propertiesrL   E   s\      L"-Jxx

#6;<H:%BIIh9N	 s   =A   A c                 Z    t        |       dk(  rdnd}dj                  d | D              |fS )z@
    Create an error message for extra items or properties.
       waswerez, c              3   2   K   | ]  }t        |        y wr
   r7   )r8   extras     r   r:   zextras_msg.<locals>.<genexpr>\   s     5fUT%[fr;   )r'   r=   )extrasverbs     r   
extras_msgrU   W   s0     K1$5&D995f55t;;r   c                 ,    t        | t              r| gS | S )z]
    Wrap ``thing`` in a list if it's a single str.

    Otherwise, return it unchanged.
    )
isinstancestr)things    r   ensure_listrZ   _   s     %wLr   c                 x    t        |       t              k7  ryt        fd| j                         D              S )zI
    Check if two mappings are equal using the semantics of `equal`.
    Fc              3   N   K   | ]  \  }}|v xr t        ||           y wr
   equal)r8   keyr   twos      r   r:   z!_mapping_equal.<locals>.<genexpr>p   s4      %JC 	s
-uUCH--%s   "%)r'   allitemsoner`   s    `r   _mapping_equalre   j   s8     3x3s8 ))+  r   c                 j    t        |       t        |      k7  ryt        d t        | |      D              S )zJ
    Check if two sequences are equal using the semantics of `equal`.
    Fc              3   :   K   | ]  \  }}t        ||        y wr
   r]   )r8   ijs      r   r:   z"_sequence_equal.<locals>.<genexpr>|   s     5}tq!uQ{}s   )r'   ra   ziprc   s     r   _sequence_equalrk   v   s.     3x3s85s3}555r   c                 4   | |u ryt        | t              st        |t              r| |k(  S t        | t              rt        |t              rt        | |      S t        | t              rt        |t              rt        | |      S t        |       t        |      k(  S )z
    Check if two things are equal evading some Python type hierarchy semantics.

    Specifically in JSON Schema, evade `bool` inheriting from `int`,
    recursing into sequences to do the same.
    T)rW   rX   r   rk   r   re   unboolrc   s     r   r^   r^      s~     cz#sz#s3cz#x ZX%>sC((#wJsG$<c3''#;&+%%r   c                     | du r|S | du r|S | S )zH
    A hack to make True and 1 and False and 0 unique for ``uniq``.
    TFr0   )elementtruefalses      r   rm   rm      s"     $	E	Nr   c                 @   	 t        d | D              }t        j                  |dd      }t        ||      D ]  \  }}t	        ||      s y 	 y# t
        t        f$ r? g }| D ]5  }t        |      }|D ]  }t	        ||      s  Y y |j                  |       7 Y yw xY w)z
    Check if all of a container's elements are unique.

    Tries to rely on the container being recursively sortable, or otherwise
    falls back on (slow) brute force.
    c              3   2   K   | ]  }t        |        y wr
   )rm   )r8   rh   s     r   r:   zuniq.<locals>.<genexpr>   s     3AfQir;   rN   NFT)	sorted	itertoolsislicerj   r^   NotImplementedError	TypeErrorrm   append)r>   sortslicedrh   ri   seenes          r   uniqr~      s    333!!$40f%DAqQ{ &   + 	Aq	AA;   KKN  	s*   AA 
A A 2BBBBc           	         | j                  |d      rg S g }d|v rt        t        t        |                  S |j	                  d      }|f| j
                  j                  |      }|j                  t        | j                  |j                  |j                        ||j                               |j	                  d      }|f| j
                  j                  |      }|j                  t        | j                  |j                  |j                        ||j                               d|v r#|t        t        t        |d                     z  }d|v rf| j                  |d   	      j                  |      r+|t        | ||d         z  }d
|v r+|t        | ||d
         z  }nd|v r|t        | ||d         z  }dD ]P  }||v st        |      D ];  \  }}	| j                  ||   	      j                  |	      s+|j                  |       = R dD ]@  }||v s||   D ]1  }
t        | j!                  ||
      d      }|"|t        | ||
      z  }3 B |S )z
    Get all indexes of items that get evaluated under the current schema.

    Covers all keywords related to unevaluatedItems: items, prefixItems, if,
    then, else, contains, unevaluatedItems, allOf, oneOf, anyOf
    booleanrb   $refNrI   	_resolver$dynamicRefprefixItemsifrI   thenelse)containsunevaluatedItemsallOfoneOfanyOf)is_typelistranger'   rE   r   lookupextend%find_evaluated_item_indexes_by_schemaevolvecontentsresolveris_valid	enumeratery   nextdescend)	validatorrH   rI   evaluated_indexesrefresolved
dynamicRefkeywordkv	subschemaerrss               r   r   r      s    +	&E#h-())
**V
C
&&--c2  1  #,,&// !  !!		
 M*J&&--j9  1  #,,&// !  !!		
 T%F=,A(B"CDDv~6$<099(C!F8VD\"  !%Jx& ! v!F8VF^"  4f!(+1##6'?#;DDQG%,,Q/ , 4 /f#G_	I--h	BDI<%)N!8Y* % - / r   c                 *   | j                  |d      rg S g }|j                  d      }|f| j                  j                  |      }|j	                  t        | j                  |j                  |j                        ||j                               |j                  d      }|f| j                  j                  |      }|j	                  t        | j                  |j                  |j                        ||j                               dD ]d  }||v s||   }| j                  |d      r|r||j                         z  }5| j                  |d      sH|D ]  }	|	|v s|j                  |	        f d|v r9|D ]4  }	|d   D ]*  }
t        j                  |
|	      s|j                  |	       , 6 d	|v r0|d	   j                         D ]  \  }	}|	|vr|t        | ||      z  } d
D ]@  }||v s||   D ]1  }t        | j                  ||      d      }|"|t        | ||      z  }3 B d|v rg| j                  |d         j!                  |      r,|t        | ||d         z  }d|v r|t        | ||d         z  }|S d|v r|t        | ||d         z  }|S )a  
    Get all keys of items that get evaluated under the current schema.

    Covers all keywords related to unevaluatedProperties: properties,
    additionalProperties, unevaluatedProperties, patternProperties,
    dependentSchemas, allOf, oneOf, anyOf, if, then, else
    r   r   Nr   r   )rB   additionalPropertiesunevaluatedPropertiesobjectrD   dependentSchemasr   r   r   r   r   )r   rE   r   r   r   &find_evaluated_property_keys_by_schemar   r   r   keysry   rF   rG   rb   r   r   r   )r   rH   rI   evaluated_keysr   r   r   r   schema_valuerK   patternr   r   s                r   r   r     s     +	N
**V
C
&&--c22  #,,&// !  !!		
 M*J&&--j92  #,,&// !  !!		
 f!'?L  y9l(--/1""<: ,H8+&--h7 !- f$ H!"5699Wh/"))(3 7 !
 V##)*<#=#C#C#EHix'D8Y N $F /f#G_	I--h	BDI<"&L!8Y' N - / v~6$<099(CD8VD\ N "Hx#   vD8VF^ N r   )collections.abcr   r   r   urllib.parser   ru   rF   r   r2   r@   rL   rU   rZ   re   rk   r^   r   rm   r~   r   r   r0   r   r   <module>r      sp    = = !  	 n  > I,$<	6&$   8JZZr   