Ë
    ñÏjò  ã                  ó‚   — U d Z ddlmZ ddlZddlZddlmZ ddlZddlm	Z
 dZded<   dd	„Zddd
„Z	dd„Zdadd„Zdd„Zy)z"UUID helpers backed by uuid-utils.é    )ÚannotationsN)ÚFinal)Úuuid7i Êš;r   Ú_NANOS_PER_SECONDc                ó0   — t        | t        «      \  }}||fS )zDSplit a nanosecond timestamp into seconds and remaining nanoseconds.)Údivmodr   ©ÚnanosecondsÚsecondsÚnanoss      úV/var/www/html/gaurav-v2/venv/lib/python3.12/site-packages/langsmith/_internal/_uuid.pyÚ_to_timestamp_and_nanosr      s   € ä˜KÔ):Ó;�N€GˆUØ�Eˆ>Ðó    c                óP   — | €
t        «       S t        | «      \  }}t        ||¬«      S )zäGenerate a UUID from a Unix timestamp in nanoseconds and random bits.

    UUIDv7 objects feature monotonicity within a millisecond.

    Args:
        nanoseconds: Optional ns timestamp. If not provided, uses current time.
    )Ú	timestampr   )Ú_uuid_utils_uuid7r   r	   s      r   r   r      s.   € ð, ÐÜ Ó"Ð"Ü,¨[Ó9�N€GˆUÜ w°eÔ<Ð<r   c                ó    — | j                   dk(  S )z˜Check if a UUID is version 7.

    Args:
        uuid_obj: The UUID to check.

    Returns:
        True if the UUID is version 7, False otherwise.
    é   )Úversion)Úuuid_objs    r   Ú
is_uuid_v7r   1   s   € ð ×Ñ˜qÑ Ð r   Fc                óf   — t        | «      s&t        sdat        j                  dt        d¬«       yyy)z«Warn if a UUID is not version 7.

    Args:
        uuid_obj: The UUID to check.
        id_type: The type of ID (e.g., "run_id", "trace_id") for the warning message.
    TzÎLangSmith now uses UUID v7 for run and trace identifiers. This warning appears when passing custom IDs. Please use: from langsmith import uuid7
            id = uuid7()
Future versions will require UUID v7.é   )Ú
stacklevelN)r   Ú_UUID_V7_WARNING_EMITTEDÚwarningsÚwarnÚUserWarning)r   Úid_types     r   Úwarn_if_not_uuid_v7r    @   s7   € ô �hÔÕ(@Ø#'Ð Ü�‰ð8ô Øö
	
ð )AÐr   c                ój  — | › d|› �j                  «       }t        j                  |«      j                  «       }t	        d«      }t        | «      r| j                  dd |dd n|dd |dd d|d   dz  z  |d<   |d   |d	<   d
|d   dz  z  |d<   |dd |dd t        j                  t        |«      ¬«      S )a3  Generate a deterministic UUID7 derived from an original UUID and a key.

    A pure function of ``original_id`` and ``key``: it reads no ambient state, so
    the same pair always yields the same UUID, in any process, at any time. This
    is used for creating replica ids that are reproducible across distributed
    systems.

    A UUID v7 original keeps its timestamp, so derived ids stay ordered by run
    start time. Any other original has none to keep, and the field is
    hash-derived: stable, but not chronological.

    Args:
        original_id: The source UUID (ideally UUID v7 to preserve timestamp).
        key: A string key used for deterministic derivation (e.g., project name).

    Returns:
        A new UUID v7 with preserved timestamp (if original is v7) and
        deterministic random bits.

    Example:
        >>> original = uuid7()
        >>> replica_id = uuid7_deterministic(original, "replica-project")
        >>> # Same inputs always produce same output
        >>> assert uuid7_deterministic(original, "replica-project") == replica_id
    Ú:é   r   é   é
   ép   é   é   r   é€   é   é?   é   r   é	   )Úbytes)	ÚencodeÚxxhashÚxxh3_128ÚdigestÚ	bytearrayr   r.   ÚuuidÚUUID)Úoriginal_idÚkeyÚ
hash_inputÚhÚbs        r   Úuuid7_deterministicr;   W   s×   € ð6  �=  # Ð'×.Ñ.Ó0€JÜ�‰˜
Ó#×*Ñ*Ó,€Aô 	�"‹€Aä�+Ôà×"Ñ" 1 QÐ'ˆˆ!ˆA‰ð
 �2�b�ˆˆ!ˆAˆð �1�Q‘4˜$‘;Ñ€A€a�Dð ˆQ‰4€A€a�Dð �1�Q‘4˜$‘;Ñ€A€a�Dð ��"ˆg€A€aˆ€Gä�9‰9œ5 ›8Ô$Ð$r   )r
   ÚintÚreturnztuple[int, int])N)r
   z
int | Noner=   ú	uuid.UUID)r   r>   r=   Úbool)r   r>   r   Ústrr=   ÚNone)r6   r>   r7   r@   r=   r>   )Ú__doc__Ú
__future__r   r4   r   Útypingr   r0   Úuuid_utils.compatr   r   r   Ú__annotations__r   r   r   r    r;   © r   r   Ú<module>rH      sF   ðÚ (å "ã Û Ý ã Ý 8à(Ð �5Ó (óô=ó8	!ð !Ð ó
ô.=%r   