Ë
    Fü´j]  ã                  ó¸   — d dl mZ d dlZd dlmZmZmZ d dlmZ  ej                  d«      Z
 ej                  d«      Zdd„Zdd„Zdd	„Z	 	 	 	 	 	 	 	 dd
„Zdd„Zy)é    )ÚannotationsN)ÚAnyÚMappingÚCallable©Úquotez^(?:\.|%2[eE]){1,2}$z	\{(\w+)\}c                ó   — t        | d¬«      S )uÇ   Percent-encode `value` for use in a URI path segment.

    Considers characters not in `pchar` set from RFC 3986 Â§3.3 to be unsafe.
    https://datatracker.ietf.org/doc/html/rfc3986#section-3.3
    z!$&'()*+,;=:@©Úsafer   ©Úvalues    úQ/root/workspace/ytshorts/venv/lib/python3.12/site-packages/openai/_utils/_path.pyÚ_quote_path_segment_partr      s   € ô �˜_Ô-Ð-ó    c                ó   — t        | d¬«      S )uÐ   Percent-encode `value` for use in a URI query string.

    Considers &, = and characters not in `query` set from RFC 3986 Â§3.4 to be unsafe.
    https://datatracker.ietf.org/doc/html/rfc3986#section-3.4
    z!$'()*+,;:@/?r
   r   r   s    r   Ú_quote_query_partr      s   € ô �˜_Ô-Ð-r   c                ó   — t        | d¬«      S )uÆ   Percent-encode `value` for use in a URI fragment.

    Considers characters not in `fragment` set from RFC 3986 Â§3.5 to be unsafe.
    https://datatracker.ietf.org/doc/html/rfc3986#section-3.5
    z!$&'()*+,;=:@/?r
   r   r   s    r   Ú_quote_fragment_partr   &   s   € ô �Ð.Ô/Ð/r   c                ó0  — t         j                  | «      }t        dt        |«      d«      D ]X  }||   }||vrt	        d|› d�«      ‚||   }|€d||<   Œ(t        |t        «      r
|rdnd||<   ŒB |t        ||   «      «      ||<   ŒZ dj                  |«      S )	zÍReplace {name} placeholders in `template`, quoting each value with `quoter`.

    Placeholder names are looked up in `values`.

    Raises:
        KeyError: If a placeholder is not found in `values`.
    é   é   za value for placeholder {z} was not providedÚnullÚtrueÚfalseÚ )	Ú_PLACEHOLDER_REÚsplitÚrangeÚlenÚKeyErrorÚ
isinstanceÚboolÚstrÚjoin)ÚtemplateÚvaluesÚquoterÚpartsÚiÚnameÚvals          r   Ú_interpolater,   /   s¬   € ô ×!Ñ! (Ó+€Eä�1”c˜%“j !Ó$ò 
1ˆØ�Q‰xˆØ�vÑÜÐ7¸°vÐ=PÐQÓRÐRØ�T‰lˆØˆ;ØˆE�!ŠHÜ˜œTÔ"Ù!$‘v¨'ˆE�!ŠHáœc &¨¡,Ó/Ó0ˆE�!ŠHð
1ð �7‰7�5‹>Ðr   c               ó~  — d}d}| }d|v r|j                  dd«      \  }}d|v r|j                  dd«      \  }}|}t        ||t        «      }|j                  d«      D ])  }t        j	                  |«      sŒt        d|›d|›d�«      ‚ |}|�|dt        ||t        «      z   z  }|�|dt        ||t        «      z   z  }|S )	u‹  Interpolate {name} placeholders in `template` from keyword arguments.

    Args:
        template: The template string containing {name} placeholders.
        **kwargs: Keyword arguments to interpolate into the template.

    Returns:
        The template with placeholders interpolated and percent-encoded.

        Safe characters for percent-encoding are dependent on the URI component.
        Placeholders in path and fragment portions are percent-encoded where the `segment`
        and `fragment` sets from RFC 3986 respectively are considered safe.
        Placeholders in the query portion are percent-encoded where the `query` set from
        RFC 3986 Â§3.4 is considered safe except for = and & characters.

    Raises:
        KeyError: If a placeholder is not found in `kwargs`.
        ValueError: If resulting path contains /./ or /../ segments (including percent-encoded dot-segments).
    Nú#r   ú?ú/zConstructed path z contains dot-segment z which is not allowed)r   r,   r   Ú_DOT_SEGMENT_REÚmatchÚ
ValueErrorr   r   )	r%   ÚkwargsÚfragment_templateÚquery_templateÚrestÚpath_templateÚpath_resultÚsegmentÚresults	            r   r8   r8   N   sù   € ð* %)ÐØ!%€Nà€DØ
ˆd�{Ø"&§*¡*¨S°!Ó"4ÑˆÐØ
ˆd�{Ø#Ÿz™z¨#¨qÓ1ÑˆˆnØ€Mô ˜}¨fÔ6NÓO€Kð ×$Ñ$ SÓ)ò xˆÜ× Ñ  Õ)ÜÐ0°°Ð?UÐV]ÐU`Ð`uÐvÓwÐwðxð €FØÐ!Ø�#œ ^°VÔ=NÓOÑOÑOˆØÐ$Ø�#œÐ%6¸Ô@TÓUÑUÑUˆà€Mr   )r   r#   Úreturnr#   )r%   r#   r&   zMapping[str, Any]r'   zCallable[[str], str]r<   r#   )r%   r#   r4   r   r<   r#   )Ú
__future__r   ÚreÚtypingr   r   r   Úurllib.parser   Úcompiler1   r   r   r   r   r,   r8   © r   r   ú<module>rC      sz   ðÝ "ã 	÷ñ õ
 ð �"—*‘*Ð4Ó5€à�"—*‘*˜\Ó*€ó	.ó.ó0ðØðàðð !ðð 	ó	ô>1r   