+
    ‚°ñj»"  ã                  ó0  € R t ^ RIHt ^ RIt^ RIt^ RIHt ^ RIHtHt ^ RI	H
t
Ht  ! R R]4      tRtR	t^€t]! R
R7       ! R R4      4       tRtRR R lltRR R lltR R R lltR R ltR R lt]! R^^]P0                  R7      tR R ltR R ltR# )!u¥  Opaque keyset-pagination cursor for /api/assets.

Payload JSON uses short keys to keep the encoded length small:

    {"s": <sort_field>, "v": <value>, "id": <id>, "o": <order>}

The `o` key binds the cursor to the sort direction it was minted under,
so replaying a `desc` cursor against an `asc` request fails with
``INVALID_CURSOR`` rather than silently walking the wrong direction.
`o` is mandatory on every payload â€” a cursor without it is rejected as
malformed.

Encoding is base64url with no padding. Cursors are opaque tokens: the
payload format is internal to this server, and clients must treat a
cursor as a black box handed back via `next_cursor`. No byte-level
compatibility with any other implementation is required.

Time values are serialized as Unix microseconds (UTC) â€” microsecond
precision is sufficient to round-trip the timestamps stored by the
database without rounding rows in the same millisecond bucket.
)ÚannotationsN)Ú	dataclass)ÚdatetimeÚtimezone)ÚIterableÚOptionalc                  ó   € ] tR t^tRtRtR# )ÚInvalidCursorErrorzˆRaised on a malformed, oversized, or unsupported-sort-field cursor.

Map to a 400 response with code ``INVALID_CURSOR`` at the handler.
© N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__Ú__static_attributes__r
   ó    Ú>C:\Ai_Coding\apps\studio\ComfyUI\app\assets\services\cursor.pyr	   r	      s   † õr   r	   i    i   T)Úfrozenc                  ó@   € ] tR t^:t$ R]R&   R]R&   R]R&   R]R&   RtR# )ÚCursorPayloadÚstrÚ
sort_fieldÚvalueÚidÚorderr
   N)r   r   r   r   Ú__annotations__r   r
   r   r   r   r   :   s   ‡ àƒOØƒJØƒGØ‡Jr   r   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )é   r   r   r   r   r   Úreturnr
   )Úformats   "r   Ú__annotate__r    E   s7   € ÷ Vñ V˜cð V¨#ð V°3ð V¸sð VÐPSñ Vr   c                ó²  € V\         9  d   \        R\          RV: 24      hV'       g   \        R4      h\        V4      \        8”  d   \        R4      h\        V4      \        8”  d   \        R4      hRV RVRVR	V/p\
        P                  ! VRR
R7      p\        P                  ! VP                  R4      4      P                  R4      P                  R4      # )a  Encode a cursor payload as a base64url (no-padding) string.

`order` binds the cursor to the sort direction it was minted under so a
later request with a flipped `order` query parameter is rejected with
``INVALID_CURSOR`` rather than silently walking the wrong direction.
zorder must be one of z, got zid must be non-emptyúid exceeds maximum lengthúvalue exceeds maximum lengthÚsÚvr   ÚoF)Ú
separatorsÚensure_asciizutf-8ó   =Úascii)Ú,Ú:)Ú_VALID_ORDERSr	   ÚlenÚMAX_CURSOR_ID_LENGTHÚMAX_CURSOR_VALUE_LENGTHÚjsonÚdumpsÚbase64Úurlsafe_b64encodeÚencodeÚrstripÚdecode)r   r   r   r   ÚpayloadÚraws   &&&&  r   Úencode_cursorr:   E   sÂ   € ð ”MÔ!Ü Ð#8¼¸ÀvÈeÉYÐ!WÓXÐX÷ Ü Ð!7Ó8Ð8Ü
ˆ2ƒwÔ%Ô%Ü Ð!<Ó=Ð=Ü
ˆ5ƒzÔ+Ô+Ü Ð!?Ó@Ð@Ø�J  U¨D°"°c¸5ÐA€GÜ
�*Š*�W¨À%Ô
H€Cô ×#Ò# C§J¡J¨wÓ$7Ó8×?Ñ?ÀÓE×LÑLÈWÓUÐUr   c          
     ó,   € V ^8„  d   QhRRRRRRRRRR/# )r   r   r   Útr   r   r   r   r
   )r   s   "r   r    r    _   s7   € ÷ 
Cñ 
C¨ð 
C°ð 
C¸cð 
CÈ#ð 
CÐ[^ñ 
Cr   c                ó²   € VP                   f   \        R4      h\        VP                  \        P
                  4      4      p\        V \        V4      W#R7      # )zóEncode a time-typed cursor at Unix microsecond precision.

Accepts an aware datetime (any timezone) and normalizes to UTC. Naive
datetimes are rejected so callers can't accidentally encode the local
wall-clock value of a UTC-stored timestamp.
z2encode_cursor_from_time requires an aware datetime)r   )ÚtzinfoÚ
ValueErrorÚ_datetime_to_unix_microsÚ
astimezoner   Úutcr:   r   )r   r<   r   r   Úmicross   &&&& r   Úencode_cursor_from_timerD   _   sD   € ð 	‡x�xÒÜÐMÓNÐNÜ% a§l¡l´8·<±<Ó&@ÓA€FÜ˜¤S¨£[°"ÔBÐBr   c               ó(   € V ^8„  d   QhRRRRRRRR/# )	r   Úcursorr   Úallowed_sort_fieldszIterable[str]Úexpected_orderz
str | Noner   r   r
   )r   s   "r   r    r    l   s<   € ÷ @Qñ @QØð@Qà&ð@Qð ð@Qð ñ	@Qr   c                ó°  € \        V 4      \        8”  d   \        R4      h R\        V 4      ) ^,          ,          p\        P                  ! W,           4      p \        P                  ! T4      p\        T\        4      '       g   \        R4      hTP                  R4      pTP                  R4      pTP                  R	4      p	TP                  R
4      p
\        T\        4      '       d-   \        T\        4      '       d   \        T	\        4      '       g   \        R4      hT	R8X  d   \        R4      h\        T	4      \         8”  d   \        R4      h\        T4      \"        8”  d   \        R4      hYq9  d   \        RT: 24      h\        T
\        4      '       g   \        R4      hT
\$        9  d   \        RT
: 24      hTe   Y¢8w  d   \        RT
: RT: 24      h\'        YxYšR7      #   \
        \        P                  P                  3 d   p\        RT 24      ThRp?ii ; i  \        P                  \        3 d   p\        RT 24      ThRp?ii ; i)u  Parse an opaque cursor.

``allowed_sort_fields`` is the endpoint's accepted sort-field list â€” a
cursor carrying a field outside this set is rejected so a cursor minted
for one column can't be replayed against another (e.g. a ``created_at``
timestamp string compared against a ``name`` column).

``expected_order`` (``"asc"``/``"desc"``), when supplied, must match the
payload's ``o`` field. ``o`` is required on every payload; a cursor
missing it is rejected as malformed.

Passing no allowed fields rejects every cursor.
zcursor exceeds maximum lengthÚ=z
encoding: Nz	payload: zpayload: expected objectr$   r%   r   r&   z%payload: missing or non-string s/v/idÚ z
missing idr"   r#   zunsupported sort field zmissing or non-string ozunsupported order zcursor order z does not match request order )r   r   r   r   )r.   ÚMAX_ENCODED_CURSOR_LENGTHr	   r3   Úurlsafe_b64decoder?   ÚbinasciiÚErrorr1   ÚloadsÚJSONDecodeErrorÚUnicodeDecodeErrorÚ
isinstanceÚdictÚgetr   r/   r0   r-   r   )rF   rG   rH   Úpaddingr9   ÚeÚdecodedr   r   r   r   s   &&&        r   Údecode_cursorrY   l   s  € ô$ ˆ6ƒ{Ô.Ô.Ü Ð!@ÓAÐAð:ð œ#˜f›+˜¨Õ)Õ*ˆÜ×&Ò& vÕ'7Ó8ˆð9Ü—*’*˜S“/ˆô �gœt×$Ò$Ü Ð!;Ó<Ð<à—‘˜SÓ!€JØ�K‰K˜Ó€EØ	�‰�TÓ	€BØ�K‰K˜Ó€Eä�j¤#×&Ò&¬j¸Ä×.DÒ.DÌJÐWYÔ[^×L_ÒL_Ü Ð!HÓIÐIà	ˆR„xÜ  Ó.Ð.Ü
ˆ2ƒwÔ%Ô%Ü Ð!<Ó=Ð=Ü
ˆ5ƒzÔ+Ô+Ü Ð!?Ó@Ð@àÔ,Ü Ð#:¸:¹.Ð!IÓJÐJä�eœS×!Ò!Ü Ð!:Ó;Ð;Ø”MÔ!Ü Ð#5°e±YÐ!?Ó@Ð@ØÒ! eÔ&=Ü Ø˜E™9Ð$BÀ>ÑBTÐUó
ð 	
ô  JÀÔPÐPøôM œŸ™×-Ñ-Ð.ô :Ü  :¨a¨SÐ!1Ó2¸Ð9ûð:ûô
 × Ñ Ô"4Ð5ô 9Ü  9¨Q¨C Ó1°qÐ8ûð9ús/   ¡6G* ÁH& Ç*%H#ÈHÈH#È&IÉIÉIc               ó    € V ^8„  d   QhRRRR/# )r   r8   úOptional[CursorPayload]r   r   r
   )r   s   "r   r    r    ¯   s   € ÷ Uñ UÐ 7ð U¸Hñ Ur   c                ó  € V f   \        R4      h \        V P                  4      p \	        T4      #   \         d   p\        RT 24      ThRp?ii ; i  \
        \        \        3 d   p\        RT 24      ThRp?ii ; i)zDParse a time-typed cursor value as Unix microseconds, returning UTC.Núnil cursor payloadz value is not a valid timestamp: z%value is out of representable range: )r	   Úintr   r?   Ú_unix_micros_to_datetimeÚOverflowErrorÚOSError)r8   rC   rW   s   &  r   Údecode_cursor_timerb   ¯   s“   € à‚Ü Ð!5Ó6Ð6ðPÜ�W—]‘]Ó#ˆðUÜ'¨Ó/Ð/øô ô PÜ Ð#CÀAÀ3Ð!GÓHÈaÐOûðPûô œ7¤JÐ/ô Uô !Ð#HÈÈÐ!LÓMÐSTÐTûðUús+   ‘2 §
A ²A½AÁAÁA>Á*A9Á9A>c               ó    € V ^8„  d   QhRRRR/# )r   r8   r[   r   r^   r
   )r   s   "r   r    r    ¿   s   € ÷ Nñ NÐ6ð N¸3ñ Nr   c                ó�   € V f   \        R4      h \        V P                  4      #   \         d   p\        RT 24      ThRp?ii ; i)z*Parse a cursor value as a base-10 integer.Nr]   zvalue is not a valid integer: )r	   r^   r   r?   )r8   rW   s   & r   Údecode_cursor_intre   ¿   sO   € à‚Ü Ð!5Ó6Ð6ðNÜ�7—=‘=Ó!Ð!øÜô NÜ Ð#AÀ!ÀÐ!EÓFÈAÐMûðNús   ‘& ¦A±A Á Ai²  )r>   c               ó    € V ^8„  d   QhRRRR/# )r   r<   r   r   r^   r
   )r   s   "r   r    r    Ì   s   € ÷ Rñ R ð R¨Sñ Rr   c                ó”   € V \         ,
          pVP                  R,          VP                  ,           R,          VP                  ,           # )zBConvert an aware UTC datetime to Unix microseconds (integer math).i€Q é@B )Ú_EPOCHÚdaysÚsecondsÚmicroseconds)r<   Údeltas   & r   r@   r@   Ì   s3   € à”�J€EØ�J‰J˜Õ %§-¡-Õ/°9Õ<¸u×?QÑ?QÕQÐQr   c               ó    € V ^8„  d   QhRRRR/# )r   rC   r^   r   r   r
   )r   s   "r   r    r    Ò   s   € ÷ añ a Sð a¨Xñ ar   c                óŠ   € \        V R4      w  r\        P                  ! V\        P                  R7      P                  VR7      # )zBConvert Unix microseconds to a UTC datetime, preserving precision.rh   )Útz)Úmicrosecond)Údivmodr   Úfromtimestampr   rB   Úreplace)rC   rk   Úmicro_remainders   &  r   r_   r_   Ò   s7   € ä% f¨iÓ8Ñ€GÜ×!Ò! '¬h¯l©lÔ;×CÑCÐP_ÐCÓ`Ð`r   )ÚascÚdesc)rw   )N)r   Ú
__future__r   r3   r1   Údataclassesr   r   r   Útypingr   r   r?   r	   rL   r0   r/   r   r-   r:   rD   rY   rb   re   rB   ri   r@   r_   r
   r   r   Ú<module>r{      s¥   ðñõ* #ã Û Ý !ß 'ß %ô˜ô ð, !Ð ØÐ ØÐ ñ �$Ô÷ð ó ðð  €÷V÷4
C÷@QõFUõ Nñ 
�$˜˜1 X§\¡\Ô	2€õR÷ar   