+
    Q(i,                        R t ^ RIHt ^ RIt^ RIt^ RIt^ RIHt ^ RIH	t	 ^ RI
Ht ]! R4      t]	 ! R R4      4       tR	 R
 ltR# )z-Pagination utilities for MCP list operations.)annotationsN)Sequence)	dataclass)TypeVarTc                  H    ] tR t^t$ RtR]R&   R R lt]R R l4       tRt	R	# )
CursorStatezInternal representation of pagination cursor state.

The cursor encodes the offset into the result set. This is opaque to clients
per the MCP spec - they should not parse or modify cursors.
intoffsetc                   V ^8  d   QhRR/# )   returnstr )formats   "b/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/fastmcp/utilities/pagination.py__annotate__CursorState.__annotate__   s     @ @ @    c                    \         P                  ! RV P                  /4      p\        P                  ! VP                  4       4      P                  4       # )z(Encode cursor state to an opaque string.o)jsondumpsr
   base64urlsafe_b64encodeencodedecode)selfdatas   & r   r   CursorState.encode   s9    zz3,-''6==??r   c                    V ^8  d   QhRRRR/# )r   cursorr   r   r   r   )r   s   "r   r   r      s     A AC AK Ar   c                F    \         P                  ! \        P                  ! VP	                  4       4      P                  4       4      pV ! VR,          R7      #   \         P                  \        \        \        \        P                  3 d   p\        RT 24      ThRp?ii ; i)zeDecode cursor from an opaque string.

Raises:
    ValueError: If the cursor is invalid or malformed.
r   r
   zInvalid cursor: N)r   loadsr   urlsafe_b64decoder   r   JSONDecodeErrorKeyError
ValueError	TypeErrorbinasciiError)clsr!   r   es   &&  r   r   CursorState.decode   s    
	A::f66v}}GNNPQDd3i((  NN
 	A /x89q@	As   AA 4B BB r   N)
__name__
__module____qualname____firstlineno____doc____annotations__r   classmethodr   __static_attributes__r   r   r   r   r      s*     K@
 A Ar   r   c               (    V ^8  d   QhRRRRRRRR/# )	r   itemszSequence[T]r!   z
str | None	page_sizer	   r   ztuple[list[T], str | None]r   )r   s   "r   r   r   2   s0         	r   c                    ^ pV'       d"   \         P                  V4      pVP                  pW2,           p\        WV 4      pRpV\	        V 4      8  d   \        VR7      P                  4       pWg3# )aU  Paginate a sequence of items.

Args:
    items: The full sequence to paginate.
    cursor: Optional cursor from a previous request. None for first page.
    page_size: Maximum number of items per page.

Returns:
    Tuple of (page_items, next_cursor). next_cursor is None if no more pages.

Raises:
    ValueError: If the cursor is invalid.
Nr#   )r   r   r
   listlenr   )r8   r!   r9   r
   stateendpagenext_cursors   &&&     r   paginate_sequencerA   2   si    $ F""6*

CS!"DK
SZ!-446r   )r3   
__future__r   r   r*   r   collections.abcr   dataclassesr   typingr   r   r   rA   r   r   r   <module>rF      sH    3 "    $ ! CL A A ADr   