
    Vpf              	         d Z ddlmZ ddlmZmZ ddlmZ ddlZddl	m
Z
 e
ee         eeeeef         eeeeeef         f         Zeee                  Z ed           G d	 d
                      ZdZdZdZdZ e e ed           ed          dz                        e e ed           ed          dz                       z    e e ed           ed          dz                       z    ed           ed          gz   Zd Z e            Zd,dZd-dZd.d!Zd/d#Zd0d'Zd1d)Z G d* d+          Z dS )2zQ
An implementation of sourcemaps following `TC39 <https://tc39.es/source-map>`_.
    )annotations)IterableSequence)	dataclassN)UnionT)frozenc                  b    e Zd ZU ded<   ded<   ded<   ded<   ded<   edd            ZddZdS )	SourceMapintversionzSequence[str]sourcessources_contentnamesMappingsmappings	json_datastrreturnc           
         t          j        |          } | |d         |d         |d         |d         t          |d                             S )z#Deserialize a source map from JSON.r   r   sourcesContentr   r   )r   r   r   r   r   )jsonloadsdeserialize_mappings)clsr   datas      R/var/www/html/nettyfy-visnx/env/lib/python3.11/site-packages/jax/_src/sourcemap.py	from_jsonzSourceMap.from_json/   sZ     :i  D3YY-.7m%d:&677       c                    | j         | j        | j        | j        t	          | j                  d}t          j        |          S )zSerialize a source map to JSON.)r   r   r   r   r   )r   r   r   r   serialize_mappingsr   r   dumps)selfr   s     r   to_jsonzSourceMap.to_json;   sD     <<.&t}55 D :dr   N)r   r   r   r
   )r   r   )__name__
__module____qualname____annotations__classmethodr   r#    r   r   r
   r
   %   s         ,,,     	 	 	 ;		 	 	 	 	 	r   r
                AZaz09+/c                 v     d t          t                    D               fdt          d          D             S )Nc                    i | ]\  }}||	S r)   r)   ).0dcs      r   
<dictcomp>z)make_vlq_decode_table.<locals>.<dictcomp>T   s    555TQAq555r   c                <    g | ]}                     |d           S N)get)r8   ilookups     r   
<listcomp>z)make_vlq_decode_table.<locals>.<listcomp>U   s'    	2	2	2!&**Q

	2	2	2r      )	enumerateVLQ_ALPHABETrange)r@   s   @r   make_vlq_decode_tablerF   S   s>    55Y|44555&	2	2	2	2uSzz	2	2	22r   encIterable[int]r   r   c                >   t          |           }t          t          |                   }t          |t          z            }|t
          z  dz	  }d}|t          z  r>|t          z  }t          t          |                   }||t
          z  |z  z  }|t          z  >|r| n|S )z%Decode a Base-64-VLQ into an integer.r*   )iterVLQ_DECODE_TABLEnextboolVLQ_SIGN_MASKVLQ_VALUE_MASKVLQ_MORE_MASKVLQ_VALUE_BITWIDTH)rG   enc_iterr9   signvalueshifts         r   
decode_vlqrW   [   s    #YY(tH~~&!	a-	 	 $~!
#%
%	M +	Eh(A	a. U**E 	
M +
 	"%U"r   rU   bytesc                    | dk     r	|  dz  dz  n| dz  } g }	 | t           z  }| t          z  } | dk    }|r
|t          z  }|                    t          |                    |snJt          |          S )z%Encode an integer into a Base-64-VLQ.r   r*   )rP   rR   rQ   appendrD   rX   )rU   bufr9   mores       r   
encode_vlqr]   l   s     "'UFq=1
%
#A	  E19D =aJJ|A  
sr   Segmentc                   t          |           }t          |          }	 t          |          }n# t          $ r |fcY S w xY wt          |          }t          |          }	 t          |          }n# t          $ r	 ||||fcY S w xY w|||||fS )z)Decode a sequence of VLQs into a segment.)rK   rW   StopIteration)rG   rS   colsourcesource_line
source_colnames          r   decode_segmentrf   ~   s    #YY(8#!!FF	   6MMM 8$$+(##*0hDD	 0 0 0Z////0 
fk:t	33s    0 A A "A2 2BBsegc                @    d                     d | D                       S )z)Encode a segment into a sequence of VLQs.r   c              3  4   K   | ]}t          |          V  d S r=   )r]   )r8   rU   s     r   	<genexpr>z!encode_segment.<locals>.<genexpr>   s*      55*U##555555r   join)rg   s    r   encode_segmentrm      s#    	55555	5	55r   mappings_strr   r   c                b    t          | d          }d |                    d          D             S )z%Decode a string of TC39 mapping data.ascii)encodingc           
         g | ];}|r5t          t          t          |                    d                               ng <S )   ,)listmaprf   split)r8   mappings     r   rA   z(deserialize_mappings.<locals>.<listcomp>   sQ     
 
 

 9@Gd3~w}}T2233444R
 
 
r      ;)rX   rv   )rn   mappings_bytess     r   r   r      sC    888.
 
#))$//
 
 
 r   r   c                j    d                     d | D                       }|                    d          S )z3Encode mappings into a string of TC39 mapping data.rx   c              3  T   K   | ]#}d                      d |D                       V  $dS )rs   c              3  4   K   | ]}t          |          V  d S r=   )rm   )r8   rg   s     r   rj   z/serialize_mappings.<locals>.<genexpr>.<genexpr>   s*      44s##444444r   Nrk   )r8   segss     r   rj   z%serialize_mappings.<locals>.<genexpr>   sN        9=dii44t44444     r   rp   )rl   decode)r   rG   s     r   r    r       sE    		  AI   	 	# 
G		r   c                  ,    e Zd ZdZd Zd Zd Zd	dZdS )
MappingsGeneratora"  MappingsGenerator is a builder API for mappings.

  TC39 mapping data is inconvenient to emit directly: in an effort to compress
  data
  it encodes most indices using values _relative_ to the previous element.
  MappingsGenerator simplifies things by taking absolute indices everywhere.
  c                h    d | _         d| _        d| _        d| _        d| _        g | _        d | _        d S )Nr   )	_last_col_last_source_last_source_line_last_source_col
_last_name	_mappings
_cur_groupr"   s    r   __init__zMappingsGenerator.__init__   s:    DNDDDDODNDOOOr   c                `    d| _         g | _        | j                            | j                   dS )zStart a new group (line).r   N)r   r   r   rZ   r   s    r   	new_groupzMappingsGenerator.new_group   s.    DNDON$/*****r   c                   t          |          dk    sJ | j        }|t          d          |d         | j        z
  }|d         | _        t          |          dk    r|                    |f           dS |d         | j        z
  }|d         | _        |d         | j        z
  }|d         | _        |d         | j        z
  }|d         | _        t          |          dk    r|                    ||||f           dS |d         | j        z
  }|d         | _        t          |          dk    r|                    |||||f           dS J d
            )a  Start a new source mapping segment in the current group.

    Args:
      *seg: A segment as in TC39, but all indices are absolute. See
        https://tc39.es/source-map/#mappings-structure for details.

    Raises:
      RuntimeError: If no current group exists.
    r*   Nz-No current group. Forgot to call new_group()?r            r-   Fzinvalid segment)	lenr   RuntimeErrorr   rZ   r   r   r   r   )r"   rg   groupra   rb   rc   rd   re   s           r   new_segmentzMappingsGenerator.new_segment   sV    s88q====OE}HIII
a&4>
!CVDN
3xx1}}llC6fVd''FADa&411K VDQ$//JFD
3xx1}}llCj9:::fq6DO#D!fDO
3xx1}}llCj$?@@@f#####r   r   r   c                    | j         S )z2Return the mapping as a list of segments per line.)r   r   s    r   r   zMappingsGenerator.mappings   s
    >r   N)r   r   )r$   r%   r&   __doc__r   r   r   r   r)   r   r   r   r      s`           + + +($ ($ ($T     r   r   )rG   rH   r   r   )rU   r   r   rX   )rG   rH   r   r^   )rg   r^   r   rX   )rn   r   r   r   )r   r   r   r   )!r   
__future__r   collections.abcr   r   dataclassesr   r   typingr   tupler   r^   r   r
   rO   rQ   rP   rR   rt   rE   ordrD   rF   rL   rW   r]   rf   rm   r   r    r   r)   r   r   <module>r      s    # " " " " " . . . . . . . . ! ! ! ! ! !       
 	#Jc3S()5c3S1H+II
 HW%& $       B  Dss3xxSA	&	&''
d55S33s88a<(())*
d55S33s88a<(())* s3xxS 3 3 3
 )(** # # # #"   $4 4 4 4(6 6 6 6
      D D D D D D D D D Dr   