§
    #xÅj‰  ã                   ó”   — d dl Z d dlmZmZ d dlmZmZmZ dZ e j	        d¦  «        Z
ddœdee         dee         d	ee         fd
„ZdS )é    N)ÚOptionalÚcast)ÚKNOWN_AGENTSÚ	AgentNameÚDetectionResultzAI-Agentz^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$)Úexpected_productÚ
user_agentr   Úreturnc                óæ  — |�|st          d¦  «        ‚| sdS |                      ¦   «         }t          |¦  «        dk    rdS |\  }}|                     d¦  «        \  }}}t                               |¦  «        rt                               |¦  «        sdS |�||k    rdS |                     d¦  «        \  }}}	|t          k    s	|	t          vrdS t          t          t          |	¦  «        ddd¦  «        S )a?  Parse an explicit coding-agent identity from a User-Agent value.

    The value must be exactly two whitespace-separated products::

        <product>/<version> AI-Agent/<agent>

    ``product`` and ``version`` must be non-empty RFC 9110 tokens, the marker
    must be exactly ``AI-Agent``, and ``agent`` must be one of
    ``KNOWN_AGENTS``. Matching is case-sensitive. Leading and trailing
    whitespace is ignored; comments and additional products are rejected.

    Pass ``expected_product`` to ignore identities that were not sent by a
    specific client. This only filters out unrelated User-Agent values; it does
    not authenticate the caller, who can send any header they like.

    Returns a ``DetectionResult`` with ``confidence="high"`` and
    ``source="user-agent"``, or ``None`` when the value does not match.
    Nz3expected_product must be a non-empty string or Noneé   ú/Úhighz
user-agentz
User-Agent)Ú
ValueErrorÚsplitÚlenÚ	partitionÚ_TOKENÚmatchÚAGENT_MARKERr   r   r   r   )
r	   r   ÚpartsÚclient_productÚagent_productÚproductÚ_ÚversionÚmarkerÚagents
             úKC:\Projects\Historical\venv\Lib\site-packages\agent_detector/_user_agent.pyÚparse_invoking_agentr      s	  € ð0 Ð#Ð,<Ð#ÝÐNÑOÔOÐOàð Øˆtà×ÒÑÔ€EÝ
ˆ5�z„z�Q‚€Øˆtà$)Ñ!€N�Mà(×2Ò2°3Ñ7Ô7Ñ€GˆQ�Ý�<Š<˜Ñ Ô ð ­¯ª°WÑ(=Ô(=ð ØˆtàÐ#¨Ð3CÒ(CÐ(CØˆtà$×.Ò.¨sÑ3Ô3Ñ€FˆAˆuØ•ÒÐ ­lÐ!:Ð!:Øˆtå�4¥	¨5Ñ1Ô1°6¸<ÈÑVÔVÐVó    )ÚreÚtypingr   r   Úagent_detector._detectorr   r   r   r   Úcompiler   Ústrr   © r    r   ú<module>r'      sÀ   ðØ 	€	€	€	Ø !Ð !Ð !Ð !Ð !Ð !Ð !Ð !à MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ MÐ Mð €ð 
ˆŒÐ5Ñ	6Ô	6€ð '+ð/Wð /Wð /WØ˜”ð/Wð ˜s”mð/Wð ˆoÔð	/Wð /Wð /Wð /Wð /Wð /Wr    