+
    j(                     b    R t ^ RIt^RIHt ^ t^t^t^t^t^t	^ t
^!tRtRtRtRt ! R R4      tR# )a  
TLV (Type-Length-Value) Binary Encoder/Decoder

Provides efficient binary serialization for dirty worker protocol messages.
Inspired by OpenBSD msgctl/msgsnd message format.

Type Codes:
    0x00: None (no value bytes)
    0x01: bool (1 byte: 0x00 or 0x01)
    0x05: int64 (8 bytes big-endian signed)
    0x06: float64 (8 bytes IEEE 754)
    0x10: bytes (4-byte length + raw bytes)
    0x11: string (4-byte length + UTF-8 encoded)
    0x20: list (4-byte count + encoded elements)
    0x21: dict (4-byte count + encoded key-value pairs)
N)DirtyProtocolErrorc                   |   a  ] tR t^,t o Rt]V 3R lR l4       t]R
V 3R lR ll4       t]V 3R lR l4       tRt	V t
R	# )
TLVEncoderz
TLV binary encoder/decoder.

Encodes Python values to binary TLV format and decodes back.
Supports: None, bool, int, float, bytes, str, list, dict.
c                    < V ^8  d   QhRS[ /# )   returnbytes)format__classdict__s   "G/var/www/idalgo/venv/lib/python3.14/site-packages/gunicorn/dirty/tlv.py__annotate__TLVEncoder.__annotate__5   s     H
 H
 H
    c                   V f   \        \        .4      # \        V \        4      '       d!   \        \        V '       d   ^.4      # ^ .4      # \        V \
        4      '       d-   \        \        .4      \        P                  ! RV 4      ,           # \        V \        4      '       d-   \        \        .4      \        P                  ! RV 4      ,           # \        V \         4      '       dp   \        V 4      \        8  d    \        R\        V 4       R\         R24      h\        \        .4      \        P                  ! R\        V 4      4      ,           V ,           # \        V \        4      '       d   V P!                  R4      p\        V4      \"        8  d    \        R\        V4       R\"         R24      h\        \$        .4      \        P                  ! R\        V4      4      ,           V,           # \        V \&        \(        34      '       d   \        V 4      \*        8  d    \        R	\        V 4       R
\*         R24      h\        \,        .4      \        P                  ! R\        V 4      4      .pV  F'  pVP/                  \0        P!                  V4      4       K)  	  RP3                  V4      # \        V \4        4      '       d   \        V 4      \6        8  d    \        R\        V 4       R
\6         R24      h\        \8        .4      \        P                  ! R\        V 4      4      .pV P;                  4        Fn  w  rE\        V\        4      '       g   \        V4      pVP/                  \0        P!                  V4      4       VP/                  \0        P!                  V4      4       Kp  	  RP3                  V4      # \        R\=        V 4      P>                   24      h)a  
Encode a Python value to TLV binary format.

Args:
    value: Python value to encode (None, bool, int, float,
           bytes, str, list, or dict)

Returns:
    bytes: TLV-encoded binary data

Raises:
    DirtyProtocolError: If value type is not supported
>q>dBytes too large:  bytes (max: )>Iutf-8String too large: List too large:  items (max: r   Dict too large: z#Unsupported type for TLV encoding: ) r	   	TYPE_NONE
isinstancebool	TYPE_BOOLint
TYPE_INT64structpackfloatTYPE_FLOAT64lenMAX_BYTES_SIZEr   
TYPE_BYTESstrencodeMAX_STRING_SIZETYPE_STRINGlisttupleMAX_LIST_SIZE	TYPE_LISTappendr   joindictMAX_DICT_SIZE	TYPE_DICTitemstype__name__)valueencodedpartsitemkvs   &     r   r*   TLVEncoder.encode4   s    =)%%eT"")UT=>>=>>eS!!*&T5)AAAeU##,(6;;tU+CCCeU##5zN*('E
| 4+,A/  *&T3u:)FFNNeS!!ll7+G7|o-((W 7,-Q0  +'&++dCL*IIGSSedE]++5zM)(&s5zl 3*O1.  I;'T3u:)FGEZ..t45 88E?"eT""5zM)(&s5zl 3*O1.  I;'T3u:)FGE!!S))AAZ..q12Z..q12 & 88E?" 1$u+2F2F1GH
 	
r   c                ,   < V ^8  d   QhRS[ RS[RS[/# )r   dataoffsetr   )r	   r    r.   )r
   r   s   "r   r   r      s'     Y
 Y
U Y
C Y
 Y
r   c                *   V\        V 4      8  d   \        RWV^,            R7      hW,          pV^,          pV\        8X  d   RV3# V\        8X  dC   V\        V 4      8  d   \        RW^,
          V^,            R7      hW,          ^ 8g  pW1^,           3# V\        8X  df   V^,           \        V 4      8  d   \        RW^,
          V^,            R7      h\
        P                  ! RWV^,            4      ^ ,          pW1^,           3# V\        8X  df   V^,           \        V 4      8  d   \        RW^,
          V^,            R7      h\
        P                  ! RWV^,            4      ^ ,          pW1^,           3# V\        8X  d   V^,           \        V 4      8  d   \        R	W^,
          V^,            R7      h\
        P                  ! R
WV^,            4      ^ ,          pV^,          pV\        8  d   \        RV R\         R24      hW,           \        V 4      8  d4   \        RV R\        V 4      V,
           2W^,
          V^,            R7      hWW,            pW1V,           3# V\        8X  d   V^,           \        V 4      8  d   \        RW^,
          V^,            R7      h\
        P                  ! R
WV^,            4      ^ ,          pV^,          pV\        8  d   \        RV R\         R24      hW,           \        V 4      8  d4   \        RV R\        V 4      V,
           2W^,
          V^,            R7      h WW,            P                  R4      pY1T,           3# V\        8X  d   V^,           \        V 4      8  d   \        RW^,
          V^,            R7      h\
        P                  ! R
WV^,            4      ^ ,          pV^,          pV\         8  d   \        RV R\          R24      h. p\#        V4       F+  p\$        P                  W4      w  rVP'                  V	4       K-  	  Wq3# V\(        8X  Ed   V^,           \        V 4      8  d   \        RW^,
          V^,            R7      h\
        P                  ! R
WV^,            4      ^ ,          pV^,          pV\*        8  d   \        RV R\*         R24      h/ p
\#        V4       Fl  p\$        P                  W4      w  r\-        V\.        4      '       g"   \        R\1        V4      P2                   24      h\$        P                  W4      w  r1W:V&   Kn  	  W3# \        RVR 2W^,
          V^,            R7      h  \         d)   p\        RT 2YT\        T^4      ,            R7      hRp?ii ; i)z
Decode a TLV-encoded value from binary data.

Args:
    data: Binary data to decode
    offset: Starting offset in the data

Returns:
    tuple: (decoded_value, new_offset)

Raises:
    DirtyProtocolError: If data is malformed or truncated
z Truncated TLV data: no type byteraw_dataNz&Truncated TLV data: missing bool valuez$Truncated TLV data: incomplete int64r   z&Truncated TLV data: incomplete float64r   z+Truncated TLV data: incomplete bytes lengthr   r   r   r   zTruncated TLV data: expected z bytes, got z,Truncated TLV data: incomplete string lengthr   z bytes for string, got r   zInvalid UTF-8 in string: z)Truncated TLV data: incomplete list countr   r   z)Truncated TLV data: incomplete dict countr   zDict key must be string, got zUnknown TLV type code: 0x02x)r&   r   r   r   r!   r"   unpackr%   r(   r'   r,   r+   decodeUnicodeDecodeErrorminr0   r/   ranger   r1   r5   r4   r   r)   r7   r8   )rA   rB   	type_coder9   lengthecountr6   _r<   resultkeys   &&          r   rH   TLVEncoder.decode   s    SY$2Vb[1 
 L	!	!<	!T"(<!1*Vb[9  LD(E1*$$
"zCI%(:!1*Vb[9  MM$FQJ(?@CE1*$$$zCI%(<!1*Vb[9  MM$FQJ(?@CE1*$$
"zCI%(A!1*Vb[9  ]]4VaZ)@A!DFaKF&('x}^<LAN  T*(3F8 <t9v-.0!1*Vb[9 
 0E6/))#zCI%(B!1*Vb[9  ]]4VaZ)@A!DFaKF'((o=NaP  T*(3F8 <t9v-.0!1*Vb[9 
FO4;;GD 6/))	!zCI%(?!1*Vb[9  MM$FQJ(?@CEaKF}$(&ug]=/K  E5\)00>T" " = 	!zCI%(?!1*Vb[9  MM$FQJ(?@CEaKF}$(&ug]=/K  F5\(//=!#s++,7S	8J8J7KL  !+ 1 1$ ?#s " >! '	#71*Vb[1
 	
i & (/s3!#fb/)AB s   ;U V*#VVc                    < V ^8  d   QhRS[ /# )r   rA   r   )r
   r   s   "r   r   r     s      % r   c                    \         P                  V ^ 4      w  rV\        V 4      8w  d+   \        R\        V 4      V,
           R2WV^,            R7      hV# )z
Decode a complete TLV-encoded value, ensuring all data is consumed.

Args:
    data: Binary data to decode

Returns:
    Decoded Python value

Raises:
    DirtyProtocolError: If data is malformed or has trailing bytes
zTrailing data after TLV: z bytesrD   )r   rH   r&   r   )rA   r9   rB   s   &  r   decode_fullTLVEncoder.decode_full  sZ     #))$2SY$+CI,>+?vFVb[1  r    N)    )r8   
__module____qualname____firstlineno____doc__staticmethodr*   rH   rV   __static_attributes____classdictcell__)r   s   @r   r   r   ,   sR      H
 H
T Y
 Y
 Y
v  r   r   i   i   )r]   r"   errorsr   r   r   r!   r%   r(   r,   r0   r5   r+   r'   r/   r4   r   rX   r   r   <module>rb      s^   
"  & 		

		 #!C Cr   