
    +hv                         d dl Z d dlZd dlmZ d dlmZ  ej                  dej                        Z ej                  d      Z	d Z
d Zd Zdd	Zd
 Zedd       Zedd       Zy)    N)deque)contextmanageraZ  
(
 (?:                     # Start of non-capturing group
  (?:\r\n|\r|\n)      |  # Match any single newline, or
  [^\r\n'"]+          |  # Match any character series without quotes or
                         # newlines, or
  "(?:[^"\\]|\\.)*"   |  # Match double-quoted strings, or
  '(?:[^'\\]|\\.)*'      # Match single quoted strings
 )
)
z(\r\n|\r|\n)c                     t        |       }t        j                  |      }dg}|D ]9  }|st        j	                  |      r|j                  d       -|dxx   |z  cc<   ; |S )zSplit a string on all unquoted newlines.

    Unlike str.splitlines(), this will ignore CR/LF/CR+LF if the requisite
    character is inside of a string. )strSPLIT_REGEXsplit
LINE_MATCHmatchappend)stmttextlinesoutputlineslines        A/var/www/html/venv/lib/python3.12/site-packages/sqlparse/utils.pysplit_unquoted_newlinesr   $   sk    
 t9Dd#E$K $d#r"Ot#O$     c                 :    | y| d   dv r| d   | d   k(  r| dd } | S )z4Helper that removes surrounding quotes from strings.Nr   )"'`r       )vals    r   remove_quotesr   6   s5    
{
1v SVs2w%6!BiJr   c                        fd}|S )zqFunction decorator to help with recursion

    :param cls: Classes to not recurse over
    :return: function
    c                       fdS )Nc                 j    | j                         D ]  }t        |      r |         |        y N)get_sublists
isinstance)tlistsgroupclsf	wrapped_fs     r   r(   z(recurse.<locals>.wrap.<locals>.wrapped_fF   s6    ,,. &!&#.f%& eHr   r   )r'   r(   r&   s   `@r   wrapzrecurse.<locals>.wrapE   s    	 r   r   )r&   r)   s   ` r   recurser*   ?   s     Kr   c                      |}|rt        |t              s|gn|}|rt        |t              s|gn|} y|rt         |      ry|rt         fd|D              ry|rt         fd|D              ryy)a  Helper function to simplify comparisons Instance, Match and TokenType
    :param token:
    :param i: Class or Tuple/List of Classes
    :param m: Tuple of TokenType & Value. Can be list of Tuple for multiple
    :param t: TokenType or Tuple/List of TokenTypes
    :return:  bool
    FTc              3   <   K   | ]  } j                   |   y wr!   )r   ).0patterntokens     r   	<genexpr>zimt.<locals>.<genexpr>a   s     JW;5;;0Js   c              3   :   K   | ]  }j                   |v   y wr!   )ttype)r-   r2   r/   s     r   r0   zimt.<locals>.<genexpr>c   s     ?u{{e+?s   )r#   listany)r/   imtclsstypes	mpatternss   `      r   imtr;   Q   sr     Dz!T2QEE:a#6AI}	*UD)	sJ	JJ	3???r   c                 F    t        t        j                  | |      d       y)zCAdvance the iterator n-steps ahead. If n is none, consume entirely.r   )maxlenN)r   	itertoolsislice)iteratorns     r   consumerB   i   s    	)

8Q
'2r   c              #   h   K   | xj                   |z  c_         d  | xj                   |z  c_         y wr!   )offsetfilter_rA   s     r   rD   rD   n   %     NNaN	NNaN   02c              #   h   K   | xj                   |z  c_         d  | xj                   |z  c_         y wr!   )indentrE   s     r   rJ   rJ   u   rG   rH   )NNN)r   )r   )r>   recollectionsr   
contextlibr   compileVERBOSEr	   r   r   r   r*   r;   rB   rD   rJ   r   r   r   <module>rP      s     	  % bjj 
 ZZ
 RZZ(
$$03
    r   