
    Hoh7                     0   U d dl Z d dlZd dlmZmZ  e j
                         dk(  Zeed<   dee	   de
dee	   fdZd	e	dee	   dee	   fd
Z ej                  d      Z ej                  dej                        Zdej                  e	   de	fdZde	de	fdZy)    N)MatchOptionalGraalVMIS_GRAALmidxreturnc                 \    d|cxk  r| j                   j                  k  rn n	| |   xs d S d S )Nr   )regroups)r   r   s     k/var/www/html/wine-match-dev/backend/winematch-backend/venv/lib/python3.12/site-packages/ua_parser/utils.pygetr      s)     35!$$++5AcFNd?4?    replc                 b    | syt        j                  dfd|       j                         xs dS )a  The replacement rules are frustratingly subtle and innimical to
    standard python fallback semantics:

    - if there is a non-null replacement pattern, then it must be used with
      match groups as template parameters (at indices 1+)
      - the result is stripped
      - if it is an empty string, then it's replaced by a null
    - otherwise fallback to a (possibly optional) match group
    - or null (device brand has no fallback)

    Replacement rules only apply to OS and Device matchers, the UA
    matcher has bespoke replacement semantics for the family (just
    $1), and no replacement for the other fields, either there is a
    static replacement or it falls back to the corresponding
    (optional) match group.

    Nz\$(\d)c                 <    t        t        | d               xs dS )N    )r   int)nr   s    r   <lambda>zreplacer.<locals>.<lambda>!   s    s1c!A$i'8'>B r   )r   substrip)r   r   s    `r   replacerr      s.    $ 66)>EKKMUQUUr   z\{(0|1)\s*,\s*\d{3,}\}z!
\[[^]]*\\(d|w)[^]]*\]
|
\\(d|w)
c                 d    | d   rdnd\  }}| d   j                  d|      j                  d|      S )Nr   )z0-9z
A-Za-z0-9_)z[0-9]z[A-Za-z0-9_]r   z\dz\w)replace)r   dws      r   class_replacerr   /   s7    $%aD .GDAqQ4<<q!))%33r   patternc                 d    t         j                  d |       } t        j                  t        |       S )a  uap-core makes significant use of large bounded repetitions, to
    mitigate catastrophic backtracking.

    However this explodes the number of states (and thus graph size)
    for finite automaton engines, which significantly increases their
    memory use, and for those which use JITs it can exceed the JIT
    threshold and force fallback to a slower engine (seems to be the
    case for graal's TRegex).
    c                     | d   dk(  rdS dS )Nr   0*+ )r   s    r   r   zfa_simplifier.<locals>.<lambda>>   s    adcks s r   )REPETITION_PATTERNr   CLASS_PATTERNr   )r    s    r   fa_simplifierr)   4   s*     !$$%JGTG^W55r   )platformr   typingr   r   python_implementationr   bool__annotations__strr   r   r   compiler'   VERBOSEr(   r   r)   r&   r   r   <module>r2      s     	 "///1Y>$ >@5: @C @HSM @V3 V5: V(3- V0  RZZ 9: 


 JJ4bhhsm 4 4
63 63 6r   