
    C6iH                       U d 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
mZmZmZmZ ddlmZ ddlmZmZmZmZ ddlmZm
ZmZ eeef   Zeez  Zee   Z ee   Z! e       Z"d	e#d
<   e G d de$             Z%d>dZ&d>dZ'd?dZ(	 	 	 	 	 	 d@dZ)	 	 	 	 	 	 dAdZ*	 	 	 	 	 	 dAdZ+	 	 	 	 	 	 dBdZ, e-        e-        e-       f	 	 	 	 	 dCdZ. e-        e-        e-       f	 	 	 	 	 dCdZ/ e-        e-        e-       f	 	 	 	 	 dCdZ0 e-        e-        e-       f	 	 	 	 	 dCdZ1 e-        e-        e-       f	 	 	 	 	 dCdZ2 e-        e-        e-       f	 	 	 	 	 dCdZ3 e-        e-        e-       f	 	 	 	 	 dCdZ4 ede& e.h dh dh d      e) e2h dh dh d             Z5 ed!e& e/h d"h d#h d      e* e3h d"h d#h d             Z6 ed$e' e0h d%h d#h d&      e+ e4h d%h d#h d&             Z7 ed'e' e0h d(h d#h d&      e+ e4h d(h d#h d&             Z8 ed)e( e1d*hh d#h d&      e, e4h d+h d#h d&             Z9 ed,e( e1d-hh d&.      e, e4d/d0hd-hh d&             Z: ed1e5fd2e6fd3e7fd4e8fd5e9fd6e:ffD  ci c]  \  } }|  ejv                  |       c}}       Z<d7e#d8<   ef	 	 	 	 	 dDd9Z=e G d: d;             Z>dEd<Z?y=c c}} w )FzI
Referencing implementations for JSON Schema specs (historic & current).
    )annotations)IterableSequenceSet)Any)AnchorRegistryResourceSpecification
exceptions)frozen)_UNSETResolvedResolver_Unset)URIr   MappingSchemaRegistryEMPTY_REGISTRYc                      e Zd ZU dZded<   y)UnknownDialectz
    A dialect identifier was found for a dialect unknown by this library.

    If it's a custom ("unofficial") dialect, be sure you've registered it.
    r   uriN)__name__
__module____qualname____doc____annotations__     Y/home/azureuser/techstart-app/venv/lib/python3.12/site-packages/referencing/jsonschema.pyr   r   $   s     
Hr   r   c                F    t        | t              ry | j                  d      S )N$id)
isinstanceboolget)contentss    r    
_dollar_idr'   /   s    (D!<<r   c                |    t        | t              sd| v ry | j                  d      }||j                  d      s|S y y )N$refr"   #)r#   r$   r%   
startswithr&   ids     r    _legacy_dollar_idr.   5   s@    (D!Vx%7	e	B	~bmmC0	 1~r   c                \    d| v ry | j                  d      }||j                  d      s|S y y )Nr)   r-   r*   )r%   r+   r,   s     r    
_legacy_idr0   =   s7    	d	B	~bmmC0	 1~r   c              #     K   t        |t              ry |j                  d      }|t        || j	                  |             |j                  d      }|t        || j	                  |             y y w)N$anchornameresourcez$dynamicAnchor)r#   r$   r%   r   create_resourceDynamicAnchor)specificationr&   anchordynamic_anchors       r    _anchorr;   E   s      (D!\\)$F"228<
 	

 \\"23N!"228<
 	
 "s   A6A8c                    t        |t              rg S |j                  d      }|g S t        || j	                  |            gS )Nr2   r3   )r#   r$   r%   r   r6   )r8   r&   r9   s      r    _anchor_2019r=   Z   sN     (D!	\\)$F~	"228<	
 r   c                    t        |t              rg S |j                  dd      }|j                  d      sg S t	        |dd  | j                  |            gS )Nr"    r*      r3   )r#   r$   r%   r+   r   r6   r8   r&   r-   s      r    _legacy_anchor_in_dollar_idrB   k   s]     (D!		eR	 B==	AB"228<	
 r   c                    |j                  dd      }|j                  d      sg S t        |dd  | j                  |            gS )Nr-   r?   r*   r@   r3   )r%   r+   r   r6   rA   s      r    _legacy_anchor_in_idrD   |   sN     
dB	B==	AB"228<	
 r   c                     d fd}|S )z
    Create a callable returning JSON Schema specification-style subschemas.

    Relies on specifying the set of keywords containing subschemas in their
    values, in a subobject's values, or in a subarray.
    c              3     K   t        | t              ry D ]  }|| v s| |     D ]  }|| v s| |   E d {     D ]"  }|| v s| |   j                         E d {    $ y 7 .7 	wN)r#   r$   values)r&   eachin_subarrayin_subvaluesin_values     r    subresources_ofz)_subresources_of.<locals>.subresources_of   s     h% 	%Dxtn$	%   	*Dx#D>))	* ! 	3Dx#D>00222	3 * 3s1   A-A-A-A)A-A-!A+"A-+A-r&   SchemareturnIterable[ObjectSchema]r   rL   rK   rJ   rM   s   ``` r    _subresources_ofrS      s    3 r   c                     d fd}|S )O
    Specifically handle older drafts where there are some funky keywords.
    c              3  H  K   t        | t              ry D ]  }|| v s| |     D ]  }|| v s| |   E d {     D ]"  }|| v s| |   j                         E d {    $ | j                  d      }| t        |t              r|E d {    y | y y 7 a7 <7 wNitems)r#   r$   rH   r%   r   )r&   rI   rX   rJ   rK   rL   s      r    rM   z:_subresources_of_with_crazy_items.<locals>.subresources_of   s     h% 	%Dxtn$	%   	*Dx#D>))	* ! 	3Dx#D>00222	3 W%%*   	  * 3
 !sC   B"B"B"BB"B"!B".B"B B"B" B"rN   r   rR   s   ``` r    !_subresources_of_with_crazy_itemsrY      s    ( r   c                     d fd}|S )rU   c              3    K   t        | t              ry D ]  }|| v s| |     D ]  }|| v s| |   E d {     D ]"  }|| v s| |   j                         E d {    $ | j                  d      }|t        |t              r|E d {    n| | j                  d      }|Et        |j                               }t        |d       }t        |t              r| |E d {    y y y 7 7 7 f7 w)NrX   dependencies)r#   r$   rH   r%   r   iternextr   	r&   rI   rX   r\   rH   valuerJ   rK   rL   s	         r    rM   zG_subresources_of_with_crazy_items_dependencies.<locals>.subresources_of   s$    h% 	%Dxtn$	%   	*Dx#D>))	* ! 	3Dx#D>00222	3 W%%*   ||N3#,--/0F&E%)!!! * $ * 3
 ! "sV   C;C;C;C3C;C;!C5".C;C7AC;+C9,C;5C;7C;9C;rN   r   rR   s   ``` r    ._subresources_of_with_crazy_items_dependenciesra      s    "6 r   c                     d fd}|S )zT
    Specifically handle even older drafts where there are some funky keywords.
    c              3  .  K   D ]  }|| v s| |     D ]  }|| v s| |   E d {     D ]"  }|| v s| |   j                         E d {    $ | j                  d      }|t        |t              r|E d {    n| | j                  d      }|Ct	        |j                               }t        |d       }t        |t              r| |E d {    dD ](  }| j                  |      }t        |t              s%| * y 7 7 7 7 8w)NrX   r\   )additionalItemsadditionalProperties)rH   r%   r#   r   r]   r^   r   r_   s	         r    rM   zJ_subresources_of_with_crazy_aP_items_dependencies.<locals>.subresources_of   s9     	%Dxtn$	%   	*Dx#D>))	* ! 	3Dx#D>00222	3 W%%*   ||N3#,--/0F&E%)!!!= 	DLL&E%)	' * 3
 ! "s[   
DDDDDDD.D?D ADD*DDDDD)r&   ObjectSchemarP   rQ   r   rR   s   ``` r    1_subresources_of_with_crazy_aP_items_dependenciesrg      s    < r   c                2     ||z  	 	 	 	 	 	 	 	 d fd}|S )Nc                |    t        |       }|D ]  }|vs|vst        |d       |c S  |j                  |      S rG   )r]   r^   in_subresourcesegmentsresolversubresource	_segmentssegmentin_childrL   s        r    maybe_in_subresourcez3_maybe_in_subresource.<locals>.maybe_in_subresource  sQ    
 N	  	 Gh&x'4	4+@+H		 
 &&{33r   rl   zSequence[int | str]rm   _Resolver[Any]rn   zResource[Any]rP   rt   r   rL   rK   rJ   rr   rq   s   `   @r    _maybe_in_subresourcerv     s@    
 k)H4%4 4 #4 
	4  r   c                2     ||z  	 	 	 	 	 	 	 	 d fd}|S )Nc                    t        |       }|D ]M  }|dk(  r-t        |j                  t              r|j	                  |      c S |vs:|vst        |d       K|c S  |j	                  |      S rW   r]   r#   r&   r   rj   r^   rk   s        r    rr   z?_maybe_in_subresource_crazy_items.<locals>.maybe_in_subresource6  s    
 N	  		 G'!j$$'  ..{;;h&x'4	4+@+H		  &&{33r   rs   r   ru   s   `   @r    !_maybe_in_subresource_crazy_itemsrz   /  @    
 k)H4%4 4 #4 
	4$  r   c                2     ||z  	 	 	 	 	 	 	 	 d fd}|S )Nc                    t        |       }|D ]L  }|dv r-t        |j                  t              r|j	                  |      c S |vs9|vst        |d       J|c S  |j	                  |      S )N>   rX   r\   ry   rk   s        r    rr   zL_maybe_in_subresource_crazy_items_dependencies.<locals>.maybe_in_subresourceR  s    
 N	  		 G33
$$9  ..{;;h&x'4	4+@+H		  &&{33r   rs   r   ru   s   `   @r    ._maybe_in_subresource_crazy_items_dependenciesr~   K  r{   r   zdraft2020-12>   ifnotelsethenrX   containscontentSchemapropertyNamesunevaluatedItemsre   unevaluatedProperties>   allOfanyOfoneOfprefixItems>   $defs
propertiesdefinitionsdependentSchemaspatternProperties)rL   rJ   rK   )r4   id_ofrM   
anchors_inrr   zdraft2019-09>   r   r   r   r   r   r   r   rd   r   re   r   >   r   r   r   zdraft-07>   r   r   r   r   r   r   rd   re   >   r   r   r   zdraft-06>   r   r   r   rd   re   zdraft-04r   >   r   rd   re   zdraft-03extends)rJ   rK   rd   re   z,https://json-schema.org/draft/2020-12/schemaz,https://json-schema.org/draft/2019-09/schemaz&http://json-schema.org/draft-07/schemaz&http://json-schema.org/draft-06/schemaz&http://json-schema.org/draft-04/schemaz&http://json-schema.org/draft-03/schemazRegistry[Specification[Schema]]_SPECIFICATIONSc                    t         j                  | j                  d            }||j                  S |t        u rt        |       |S )z
    Retrieve the `Specification` with the given dialect identifier.

    Raises:

        `UnknownDialect`

            if the given ``dialect_id`` isn't known

    r*   )r   r%   rstripr&   r   r   )
dialect_iddefaultr5   s      r    specification_withr   =  sI     "":#4#4S#9:H   &Z((Nr   c                  .    e Zd ZU dZded<   ded<   ddZy)	r7   z4
    Dynamic anchors, introduced in draft 2020.
    strr4   SchemaResourcer5   c                P   | j                   }|j                         D ]I  \  }}	 |j                  || j                        j                  }t        |t              s>|j                   }K t        |j                  |j                  |            S # t
        j                  $ r Y w xY w)z2
        Resolve this anchor dynamically.
        )r&   rm   )r5   dynamic_scoper9   r4   r`   r   NoSuchAnchorr#   r7   	_Resolvedr&   rj   )selfrm   lastr   registryr9   s         r    resolvezDynamicAnchor.resolve\  s     }}%335 	'MC!dii8>> &-0	' ]],,T2
 	
	 ** s   &BB%$B%Nrm   z_Resolver[Schema]rP   z_Resolved[Schema])r   r   r   r   r   r   r   r   r    r7   r7   S  s     I
r   r7   c                X   | j                  d      }t        |j                  t              r~|j                  j	                  d      rc| j                         D ]P  \  }}| j                  |      }t        |j                  t              r|j                  j	                  d      s |S |}R |S )u   
    Recursive references (via recursive anchors), present only in draft 2019.

    As per the 2019 specification (§ 8.2.4.2.1), only the ``#`` recursive
    reference is supported (and is therefore assumed to be the relevant
    reference).
    r*   z$recursiveAnchor)lookupr#   r&   r   r%   r   )rm   resolvedr   _next_resolveds        r    lookup_recursive_refr   n  s     s#H(##W-(2C2C2G2G3 ,,. 	%FC$OOC0M&& #++//0BCO %H	% Or   N)r&   rO   rP   
URI | None)r&   rf   rP   r   )r8   Specification[Schema]r&   rO   rP   zIterable[AnchorType[Schema]])r8   r   r&   rO   rP   zIterable[Anchor[Schema]])r8   zSpecification[ObjectSchema]r&   rf   rP   zIterable[Anchor[ObjectSchema]])rL   Set[str]rK   r   rJ   r   )r   r   r   zSpecification[Any] | _UnsetrP   zSpecification[Any]r   )@r   
__future__r   collections.abcr   r   r   typingr   referencingr   r	   r
   r   r   referencing._attrsr   referencing._corer   r   r   r   	_Resolverr   referencing.typingr   
AnchorTyper   r   rf   r$   rO   r   r   r   r   	Exceptionr   r'   r.   r0   r;   r=   rB   rD   	frozensetrS   rY   ra   rg   rv   rz   r~   DRAFT202012DRAFT201909DRAFT7DRAFT6DRAFT4DRAFT3opaquer   r   r7   r   )r   r8   s   00r    <module>r      s   # 3 3  M M %  B A sCx  
	 &! &! "* + Y  
(

 "
*( "( ". $  #&[%K : #&[%K B #&[%K$$$ $P #&[%K''' 'V #&[%K     0 #&[%K     : #&[%K     : 	
$
 ?
. .
 ?
72h 	
5
 0
. :
 0
72h 
	
B	
 0G +G	
 0G% 
D 
	
B
 0G
 +G
 0G

8 
	
E/G
 $GC/G
  
	
EKG $G#%;<KG
  4< <[I;[I5v>5v>5v>5v>*

%J 	OHOOM22
40 " ,2( , 
 
 
4
s   K
