
    io                        % S r SSKrSSKJrJr  SSKJr  SSKJ	r	  SSK
Jr  SSKJrJrJrJrJrJrJrJrJrJrJrJrJrJr  SSKJr  SS	KJrJr  SS
K J!r!J"r"J#r#J$r$  SSK%J&r&J'r'J(r(  SSK)J*r*J+r+  \(       a  SSK,J-r-  O\.r- " S S\-5      r/ " S S\-5      r0\\/\04   r1\\2/\24   r3\\/\4   r4\\5   r6\\\5      r7\\6\74   r8\\5/\84   r9\\S4   r:\\:S4   r;\\:\;4   r<\<r=\\/\=4   r>\\2\5\?\@4   rA\\\2   /\\A   4   rB\<rC\\\   \2/\C4   rD\\2\4   rE\\2/\\   4   rF\\2/\\2   4   rG\\E/\C4   rH\\E/\\CS4   4   rI\\1   rJ\\1S4   rK\\/\J4   rL\\L   rM " S S5      rNS\&S\\2   4S jrOS\S\4S jrPS\&S\34S jrQS\&S\34S jrR\S\JSSS\\H\I4   S\9S \>S\K4S! j5       rS\S\S\LS\\H\I4   S\9S \>S\K4S" j5       rSS\\J\4   S\MS\\H\I4   S\9S \>S\K4S# jrSS\&S\94S$ jrTS\&S%\!S&\2S\>4S' jrUS\&S%\!S(\GS)\3S*\BS+\DS\H4S, jrVS-\HS\I4S. jrWS/\\   S%\!S\\   4S0 jrXS\&S\34S1 jrYS\&S\B4S2 jrZS\&S%\!S&\2S\D4S3 jr[\" \3\	" S45      5      r\\3\]S5'   \\4S\2S6\3S\24S7 jjr^S8\\4   S\44S9 jr_\S:\5S;\2S\24S< j5       r`\S:\S;\2S\4S= j5       r`S:\S;\2S\4S> jr`S?\R                  " S@5      R                  4S:\ESA\cSB\FS\\2   4SC jjrdg)Da  
Utilities and definitions for natsort, mostly all used to define
the natsort_key function.

SOME CONVENTIONS USED IN THIS FILE.

1 - Factory Functions

Most of the logic of natsort revolves around factory functions
that create branchless transformation functions. For example, rather
than making a string transformation function that has an if
statement to determine whether or not to perform .lowercase() at
runtime for each element to transform, there is a string transformation
factory function that will return a function that either calls
.lowercase() or does nothing. In this way, all the branches and
decisions are taken care of once, up front. In addition to a slight
speed improvement, this provides a more extensible infrastructure.

Each of these factory functions will end with the suffix "_factory"
to indicate that they themselves return a function.

2 - Keyword Parameters For Local Scope

Many of the closures that are created by the factory functions
have signatures similar to the following

    >>> def factory(parameter):
    ...     val = 'yes' if parameter else 'no'
    ...     def closure(x, _val=val):
    ...          return '{} {}'.format(_val, x)
    ...     return closure
    ...

The variable value is passed as the default to a keyword argument.
This is a micro-optimization
that ensures "val" is a local variable instead of global variable
and thus has a slightly improved performance at runtime.

    N)partialreduce)chain)methodcaller)PurePath)AnyCallableDictIterableIteratorListMatchOptionalPatternTYPE_CHECKINGTupleUnioncastoverload)	normalize)	try_floattry_int)
StrOrBytesget_decimal_pointget_strxfrmget_thousands_sep)NSTypeNS_DUMBns)digits_no_decimalsnumeric_no_decimals)Protocolc                   &    \ rS rSrS\S\4S jrSrg)SupportsDunderLTT   _SupportsDunderLT__otherreturnc                     g N )selfr&   s     :/app/mltbenv/lib/python3.13/site-packages/natsort/utils.py__lt__SupportsDunderLT.__lt__U           r*   N)__name__
__module____qualname____firstlineno__r   boolr-   __static_attributes__r*   r0   r,   r$   r$   T       c d r0   r$   c                   &    \ rS rSrS\S\4S jrSrg)SupportsDunderGTY   _SupportsDunderGT__otherr'   c                     g r)   r*   )r+   r;   s     r,   __gt__SupportsDunderGT.__gt__Z   r/   r0   r*   N)r1   r2   r3   r4   r   r5   r=   r6   r*   r0   r,   r9   r9   Y   r7   r0   r9   .c                   (   \ rS rSr% Sr\r\\S'   \	r
\\S'   Sr\\S'   Sr\\S'   \S	\S
\\   4S j5       r\S
\\   4S j5       r\S
\\   4S j5       r\S
\\   4S j5       r\S
\\   4S j5       r\S
\\   4S j5       r\S
\\   4S j5       rSrg)NumericalRegularExpressions   z
Container of regular expressions that match numbers.

The numbers also account for unicode non-decimal characters.

Not intended to be made an instance - use class methods only.
numericdigitsz(?:[eE][-+]?\d+)?expz(?:\d+\.?\d*|\.\d+)	float_numfmtr'   c           	      z    [         R                  " UR                  " S0 [        U 5      D6[         R                  S9$ )zAGiven a format string, construct the regex with class attributes.flagsr*   )recompileformatvarsU)clsrF   s     r,   _construct_regex,NumericalRegularExpressions._construct_regex   s)     zz#**1tCy1>>r0   c                 $    U R                  S5      $ )z)Regular expression to match a signed int.z([-+]?\d+|[{digits}])rP   rO   s    r,   int_sign$NumericalRegularExpressions.int_sign   s     ##$<==r0   c                 $    U R                  S5      $ )z,Regular expression to match an unsigned int.z(\d+|[{digits}])rS   rT   s    r,   
int_nosign&NumericalRegularExpressions.int_nosign   s     ##$788r0   c                 $    U R                  S5      $ )z9Regular expression to match a signed float with exponent.z#([-+]?{float_num}{exp}|[{numeric}])rS   rT   s    r,   float_sign_exp*NumericalRegularExpressions.float_sign_exp   s     ##$JKKr0   c                 $    U R                  S5      $ )z<Regular expression to match an unsigned float with exponent.z({float_num}{exp}|[{numeric}])rS   rT   s    r,   float_nosign_exp,NumericalRegularExpressions.float_nosign_exp        ##$EFFr0   c                 $    U R                  S5      $ )z<Regular expression to match a signed float without exponent.z([-+]?{float_num}|[{numeric}])rS   rT   s    r,   float_sign_noexp,NumericalRegularExpressions.float_sign_noexp   r`   r0   c                 $    U R                  S5      $ )z?Regular expression to match an unsigned float without exponent.z({float_num}|[{numeric}])rS   rT   s    r,   float_nosign_noexp.NumericalRegularExpressions.float_nosign_noexp   s     ##$@AAr0   r*   N)r1   r2   r3   r4   __doc__r!   rB   str__annotations__r    rC   rD   rE   classmethodr   rP   rU   rX   r[   r^   rb   re   r6   r*   r0   r,   r@   r@      s    'GS&$FC$#C#+Is+?3 ?73< ? ? > > > 973< 9 9 Lws| L L G G G G G G B73< B Br0   r@   algr'   c                 2   U [         R                  -  (       a6  U [         R                  [         R                  -  [         R                  -  -  n O$U [         R                  [         R                  -  -  n [         R                  [
        R                  5       [         R                  [
        R                  5       [         R                  [         R                  -  [
        R                  5       [         R                  [         R                  -  [
        R                  5       [         R                  [         R                  -  [
        R                  5       [         R                  [         R                  -  [         R                  -  [
        R                  5       0U    $ )a  
Select an appropriate regex for the type of number of interest.

Parameters
----------
alg : ns enum
    Used to indicate the regular expression to select.

Returns
-------
regex : compiled regex object
    Regular expression object that matches the desired number type.

)r   FLOATSIGNEDNOEXPINTr@   rX   r^   rU   r[   re   rb   rk   s    r,   regex_chooserrr      s     RXX~rxx"))#bhh..rvv		!! 	+668
->>@
7@@B
2999HHJ
2888KKM
299rxx')D)U)U)W 
 r0   xc                     U $ )z9A function that does nothing and returns the input as-is.r*   rs   s    r,   _no_oprv      s    Hr0   c                 Z    U [         R                  -  (       a  SOSn[        [        U5      $ )a4  
Create a function that will normalize unicode input data.

Parameters
----------
alg : ns enum
    Used to indicate how to normalize unicode.

Returns
-------
func : callable
    A function that accepts string (unicode) input and returns the
    the input normalized with the desired normalization scheme.

NFKDNFDr   COMPATIBILITYNORMALIZEr   r   rk   normalization_forms     r,   _normalize_input_factoryr~      s'      $')B)B#B9011r0   c                 Z    U [         R                  -  (       a  SOSn[        [        U5      $ )a-  
Create a function that will compose unicode input data.

Parameters
----------
alg : ns enum
    Used to indicate how to compose unicode.

Returns
-------
func : callable
    A function that accepts string (unicode) input and returns the
    the input normalized with the desired composition scheme.
NFKCNFCrz   r|   s     r,   _compose_input_factoryr      s'     $')B)B#B9011r0   valkeystring_func
bytes_funcnum_funcc                     g r)   r*   r   r   r   r   r   s        r,   natsort_keyr   	       r0   c                     g r)   r*   r   s        r,   r   r     r   r0   c                   ^^^ Ub  U" U 5      n [        U [        [        45      (       a  T" U 5      $ [        U [        5      (       a  T" U 5      $ [        U [        5      (       a  [        UUU4S jU  5       5      $ T" U 5      $ )a  
Key to sort strings and numbers naturally.

It works by splitting the string into components of strings and numbers,
and then converting the numbers into actual ints or floats.

Parameters
----------
val : str | bytes | int | float | iterable
key : callable | None
    A key to apply to the *val* before any other operations are performed.
string_func : callable
    If *val* (or the output of *key* if given) is of type *str*, this
    function will be applied to it. The function must return
    a tuple.
bytes_func : callable
    If *val* (or the output of *key* if given) is of type *bytes*, this
    function will be applied to it. The function must return
    a tuple.
num_func : callable
    If *val* (or the output of *key* if given) is not of type *bytes*,
    *str*, nor is iterable, this function will be applied to it.
    The function must return a tuple.

Returns
-------
out : tuple
    The string split into its string and numeric components.
    It *always* starts with a string, and then alternates
    between numbers and strings (unless it was applied
    recursively, in which case it will return tuples of tuples,
    but the lowest-level tuples will then *always* start with
    a string etc.).

See Also
--------
parse_string_factory
parse_bytes_factory
parse_number_or_none_factory

c              3   B   >#    U  H  n[        US TTT5      v   M     g 7fr)   )r   ).0rs   r   r   r   s     r,   	<genexpr>natsort_key.<locals>.<genexpr>Z  s$      
MPK4j(CCSs   )
isinstancerh   r   bytesr   tupler   s     ```r,   r   r     sz    d #h#X''3	C		#	C	"	" 
MP
 
 	
 }r0   c                     U [         R                  -  (       a  U [         R                  -  (       a  S $ U [         R                  -  (       a  S $ U [         R                  -  (       a  S $ S $ )av  
Create a function that will format a *bytes* object into a tuple.

Parameters
----------
alg : ns enum
    Indicate how to format the *bytes*.

Returns
-------
func : callable
    A function that accepts *bytes* input and returns a tuple
    with the formatted *bytes*. Intended to be used as the
    *bytes_func* argument to *natsort_key*.

See Also
--------
natsort_key

c                 &    U R                  5       44$ r)   lowerru   s    r,   <lambda>%parse_bytes_factory.<locals>.<lambda>y  s    1779,r0   c                 
    U 44$ r)   r*   ru   s    r,   r   r   {  s    1$r0   c                 $    U R                  5       4$ r)   r   ru   s    r,   r   r   }  s    !'')r0   c                     U 4$ r)   r*   ru   s    r,   r   r     s    !r0   )r   PATH
IGNORECASErq   s    r,   parse_bytes_factoryr   a  sI    . RWW}r}},((	rww  	r}}	%%r0   seppre_sepc                   ^^ U [         R                  -  (       a  [        S5      O
[        S5      nUUU[        S5      :H  4S[        S[        S[        S[
        S[        4
S jjmU [         R                  -  (       a7  U [         R                  -  (       a  U [         R                  -  (       a  UU4S	 j$ U [         R                  -  (       a  U [         R                  -  (       a  UU4S
 j$ U [         R                  -  (       a  U4S j$ T$ )a  
Create a function that will format a number (or None) into a tuple.

Parameters
----------
alg : ns enum
    Indicate how to format the *bytes*.
sep : str
    The string character to be inserted before the number
    in the returned tuple.
pre_sep : str
    In the event that *alg* contains ``UNGROUPLETTERS``, this
    string will be placed in a single-element tuple at the front
    of the returned nested tuple.

Returns
-------
func : callable
    A function that accepts numeric input (e.g. *int* or *float*)
    and returns a tuple containing the number with the leading string
    *sep*. Intended to be used as the *num_func* argument to
    *natsort_key*.

See Also
--------
natsort_key

+inf-infr   _nan_replace_sepreverser'   c                 b    X :w  a  X!U(       a  S4$ S4$ U c  X!S4$ X:X  a  X!U(       a  S4$ S4$ X 4$ )z?Given a number, place it in a tuple with a leading null string.312r*   )r   r   r   r   s       r,   func*parse_number_or_none_factory.<locals>.func  sQ     :gs>>3>>[s** gs>>3>>9r0   c                    > T4T" U 5      44$ r)   r*   rs   r   r   s    r,   r   .parse_number_or_none_factory.<locals>.<lambda>  s    G:tAw/1r0   c                    > T4T" U 5      4$ r)   r*   r   s    r,   r   r     s    7*d1g.r0   c                    > T" U 5      4$ r)   r*   )rs   r   s    r,   r   r     s    $q'r0   )
r   NANLASTfloatr   r   r5   
BasicTupler   UNGROUPLETTERSLOCALEALPHA)rk   r   r   nan_replacer   s     ` @r,   parse_number_or_none_factoryr     s    > $'#3%-vK *#uV}4	  	
 
( RWW}r000S2>>5I11	r  	 S2>>%9..	rww##r0   splitterinput_transformcomponent_transformfinal_transformc           	      "  ^^^^^^^	^
 U [         -  =(       a    U [        R                  -  (       + nU(       a  TO[        m
[	        U 5      m	U [        R                  -  (       a  [        U 5      O[        mS[        S[        4UUUUU	U
UU4S jjnU$ )a  
Create a function that will split and format a *str* into a tuple.

Parameters
----------
alg : ns enum
    Indicate how to format and split the *str*.
sep : str
    The string character to be inserted between adjacent numeric
    objects in the returned tuple.
splitter : callable
    A function the will accept a string and returns an iterable
    of strings where the numbers are separated from the non-numbers.
input_transform : callable
    A function to apply to the string input *before* applying
    the *splitter* function. Must return a string.
component_transform : callable
    A function that is operated elementwise on the output of
    *splitter*. It must accept a single string and return either
    a string or a number.
final_transform : callable
    A function to operate on the return value as a whole. It
    must accept a tuple and a string argument - the tuple
    should be the result of applying the above functions, and the
    string is the original input value. It must return a tuple.

Returns
-------
func : callable
    A function that accepts string input and returns a tuple
    containing the string split into numeric and non-numeric
    components, where the numeric components are converted into
    numeric objects. The first element is *always* a string,
    and then alternates number then string. Intended to be
    used as the *string_func* argument to *natsort_key*.

See Also
--------
natsort_key
input_string_transform_factory
string_component_transform_factory
final_data_transform_factory

rs   r'   c                    > [        U [        5      (       a  [        U 5      n T" U 5      nT" U5      T" U5      p2T
" U5      nT" U5      n[        S U5      nT	" U5      n[	        UT5      nT" X5      $ r)   )r   r   rh   filtersep_inserter)rs   aboriginalcdefgr   compose_inputr   r   normalize_inputoriginal_funcr   r   s            r,   r   "parse_string_factory.<locals>.func  sw    a"" AA A%a(-*:8!QK4O"C q++r0   )r   r   r   rv   r~   r   PathArgFinalTransform)rk   r   r   r   r   r   orig_after_xfrmr   r   r   r   s    `````  @@@r,   parse_string_factoryr     sj    l =AS2>>-ABO'6OFM.s3O363G*3/VM, ,N , ," Kr0   	str_splitc                    ^  U 4S j$ )a  
Create a function that will properly split and format a path.

Parameters
----------
str_split : callable
    The output of the *parse_string_factory* function.

Returns
-------
func : callable
    A function that accepts a string or path-like object
    and splits it into its path components, then passes
    each component to *str_split* and returns the result
    as a nested tuple. Can be used as the *string_func*
    argument to *natsort_key*.

See Also
--------
natsort_key
parse_string_factory

c                 @   > [        [        T[        U 5      5      5      $ r)   )r   mappath_splitter)rs   r   s    r,   r   $parse_path_factory.<locals>.<lambda>(  s    U3y-*:;<r0   r*   )r   s   `r,   parse_path_factoryr     s    0 =<r0   iteratorc              #   N  #     [         [        4n[        U 5      n[        U5      U;   a  Uv   Uv   [        U 5      n[        U5      U;   a  [        U5      U;   a  Uv   Uv   U  H+  nXEpC[        U5      U;   a  [        U5      U;   a  Uv   Uv   M-     g! [         a     gf = f7f)ad  
Insert '' between numbers in an iterator.

Parameters
----------
iterator
sep : str
    The string character to be inserted between adjacent numeric objects.

Yields
------
The values of *iterator* in order, with *sep* inserted where adjacent
elements are numeric. If the first element in the input is numeric
then *sep* will be the first value yielded.

N)intr   nexttypeStopIteration)r   r   typesfirstsecondrs   s         r,   r   r   +  s     " eX;%I h;%DLE$9I A"6E{e#V(=	L	 
   	s)   B%BB B%
B"B%!B""B%c                    U [         R                  -  nU [        -  n/ nU(       a  U(       a  U(       a!  U(       d  UR                  [	        S5      5        U [         R
                  -  (       a  UR                  [	        S5      5        U [         R                  -  (       GaW  SnSnU [         R                  -  (       a?  [        R                  " [        5       5      nUSU-   S-   -  nUSU-   S-   -  nUSU-   S-   -  nUR                  [        R                  " [        5       5      US	9n[        R                  " U[        R                  S
9nUR                  [        UR                   S5      5        [        5       nU [         R                  -  (       af  US:w  a`  Sn	U	R                  [        R                  " U5      S9n	[        R                  " U	5      n
UR                  [        U
R                   S5      5        [#        U5      $ )a  
Create a function to transform a string.

Parameters
----------
alg : ns enum
    Indicate how to format the *str*.

Returns
-------
func : callable
    A function to be used as the *input_transform* argument to
    *parse_string_factory*.

See Also
--------
parse_string_factory

swapcasecasefolda^  
            (?<=[0-9]{{1}})  # At least 1 number
            (?<![0-9]{{4}})  # No more than 3 numbers
            {nodecimal}      # Cannot follow decimal
            {thou}           # The thousands separator
            (?=[0-9]{{3}}    # Three numbers must follow
             ([^0-9]|$)      # But a non-number after that
            )
         z(?<!z[0-9])z	[0-9]{2})z	[0-9]{3}))thou	nodecimalrH   .z&(?<=[0-9]){decimal}|{decimal}(?=[0-9]))decimal)r   LOWERCASEFIRSTr   appendr   r   	LOCALENUMrm   rJ   escaper   rL   r   rK   VERBOSEr   subchain_functions)rk   lowfirstdumbfunction_chainstrip_thousandsr   r   strip_thousands_rer   switch_decimalswitch_decimal_res              r,   input_string_transform_factoryr   X  s   * R&&&H=D &(NX8Dl:67
R]]l:67
R\\ 	> 		+-.A1y00I1|33I1|33I)00,./9 1 
  ZZrzzJg&8&<&<bAB $%>gnFN+22299W;M2NN "

> :!!'*;*?*?"EF >**r0   c                 B   U [         R                  -  nU [        -  nU [         R                  -  =(       d    U=(       a    UnU [         R                  -  (       a  [        S5      O
[        S5      n/ nU(       a  UR                  [        5        U(       a  UR                  [        5       5        U(       a  S[        U5      0O0 nSUS'   U [         R                  -  (       a"  XFS'   [        [        [        [        40 UD65      $ [        [        [        [        40 UD65      $ )a<  
Create a function to either transform a string or convert to a number.

Parameters
----------
alg : ns enum
    Indicate how to format the *str*.

Returns
-------
func : callable
    A function to be used as the *component_transform* argument to
    *parse_string_factory*.

See Also
--------
parse_string_factory

r   r   on_failTr   nan)r   r   r   GROUPLETTERSr   r   r   grouplettersr   r   rm   r   StrTransformerr   r   r   )rk   
use_localer   group_lettersnan_val
func_chainkwargss          r,   "string_component_transform_factoryr    s    * r~~%J=D2??*D
0CtM"RZZ/eFmU6]G 57J,'+-( :Di45FF5M
RXX~uNGI$@$@AANGG$>v$>??r0   c                    U [         R                  -  (       a  U [         R                  -  (       a  U [        -  =(       a    U [         R                  -  n[        [        U(       a  [        S5      O[        5      nUUU4S[        [           S[        S[        S[        S[        S[        4S jjnU$ [        UU4S[        [           S[        S[        S[        S[        S[        4S	 jjnU$ )
a  
Create a function to transform a tuple.

Parameters
----------
alg : ns enum
    Indicate how to format the *str*.
sep : str
    Separator that was passed to *parse_string_factory*.
pre_sep : str
    String separator to insert at the at the front
    of the return tuple in the case that the first element
    is *sep*.

Returns
-------
func : callable
    A function to be used as the *final_transform* argument to
    *parse_string_factory*.

See Also
--------
parse_string_factory

r   	split_valr   
_transformr   _pre_sepr'   c                 `    [        U 5      n U (       d  gU S   U:X  a  U4U 4$ U" US   5      4U 4$ )z
Return a tuple with the first character of the first element
of the return value as the first element, and the return value
as the second element. This will be used to perform gross sorting
by the first letter.
)r*   r*   r   r   r  r   r  r   r	  s        r,   r   *final_data_transform_factory.<locals>.func  sD     i(I1% {I--"3q6*,i77r0   c                     [        U 5      $ r)   r  r  s        r,   r   r    s     ##r0   )r   r   r   r   r   r   StrToStrr   rv   r   NatsortInTyperh   r   r   )rk   r   r   swap	transformr   s         r,   final_data_transform_factoryr    s    8 R3#7W}8r'8'8!8t<
#;P	
 $-"#	8.	8	8 !	8 		8
 	8 	8@ K $*"#	$.	$	$ !	$ 		$
 	$ 	$ Kr0   r   lower_function_lowc                 b   ^ SR                  [        R                  " U4S jU  5       5      5      $ )z
Double all characters, making doubled letters lowercase.

Parameters
----------
x : str

Returns
-------
str

Examples
--------

    >>> groupletters("Apple")
    'aAppppllee'

r   c              3   8   >#    U  H  nT" U5      U4v   M     g 7fr)   r*   )r   yr  s     r,   r   groupletters.<locals>.<genexpr>$  s     '@aa!as   )joinichainfrom_iterable)rs   r  s    `r,   r   r     s%    & 776'''@a'@@AAr0   	functionsc                 ~    [        U 5      n U (       d  [        $ [        U 5      S:X  a  U S   $ [        [        S U 5      $ )a  
Chain a list of single-argument functions together and return.

The functions are applied in list order, and the output of the
previous functions is passed to the next function.

Parameters
----------
functions : list
    A list of single-argument functions to chain together.

Returns
-------
func : callable
    A single argument function.

Examples
--------
Chain several functions together!

    >>> funcs = [lambda x: x * 4, len, lambda x: x + 5]
    >>> func = chain_functions(funcs)
    >>> func('hey')
    17

   r   c                     U" U 5      $ r)   r*   )resr   s     r,   r   !chain_functions.<locals>.<lambda>I  s    afr0   )listrv   lenr   r   )r  s    r,   r   r   '  s=    6 YI	Y1	| v4i@@r0   sencodingc                     g r)   r*   r%  r&  s     r,   do_decodingr)  L      r0   c                     g r)   r*   r(  s     r,   r)  r)  Q  r*  r0   c                 R    [        U [        5      (       a  U R                  U5      $ U $ )a  
Helper to decode a *bytes* object, or return the object as-is.

Parameters
----------
s : bytes | object
encoding : str
    The encoding to use to decode *s*.

Returns
-------
decoded
    *str* if *s* was *bytes* and the decoding was successful.
    *s* if *s* was not *bytes*.

)r   r   decoder(  s     r,   r)  r)  V  s%    " !Uxx!!r0   Tz\.\d
treat_base_d_matchc                    [        U [        5      (       d  [        U 5      n  U R                  Gt p4/ nU(       au  [        [        [        U5      R                  5      5       H:  u  pgU" U5      (       d  US:  d  [        U5      S:  a    OUR                  U5        M<     UR                  5         UR                  SR                  U5      S5      nU(       a  U/O/ n[        S[        X8U5      5      $ ! [         a    / n[	        U 5      n Nf = f)a  
Split a string into its path components.

Assumes a string is a path or is path-like.

Parameters
----------
s : str | pathlib.Path
treat_base: bool, optional
    If True, treat the base of component of the file path as
    special and split off extensions. If False, do not do this.
    The default is True.

Returns
-------
split : tuple
    The path split by directory components and extensions.

Examples
--------

    >>> tuple(path_splitter("this/thing.ext"))
    ('this', 'thing', '.ext')

r     r   N)r   r   parts
ValueErrorrh   	enumeratereversedsuffixesr$  r   r   replacer  r   r  )	r%  r.  r/  
path_partsbaser6  isuffixbase_components	            r,   r   r   n  s    8 a""QKGG
 H #8HTN,C,C#DEIA1q5CK!OOOF# F 	 <<)2.D#dVN $z8DEE-  
1vs   C1 1D
D)erg   rJ   	functoolsr   r   	itertoolsr   r  operatorr   pathlibr   typingr   r	   r
   r   r   r   r   r   r   r   r   r   r   r   unicodedatar   natsort.compat.fastnumbersr   r   natsort.compat.localer   r   r   r   natsort.ns_enumr   r   r   natsort.unicode_numbersr    r!   typing_extensionsr"   objectr$   r9   Sortablerh   r  AnyCallr   
BytesTupleNestedBytesTupleBytesTransformBytesTransformerr   NestedAnyTupleAnyTupleNumTransformNumTransformerr   r   StrBytesNumr   r   FinalTransformerr   MatchFnStrSplitter	StrParserPathSplitterr  NatsortOutTypeKeyTypeMaybeKeyTyper@   rr   rv   r~   r   r   r   r   r   r   r   r   r  r  r  ri   r   r   r)  rK   matchr5   r   r*   r0   r,   <module>r]     s  &N 
 % % !      " 9  0 / K*Hx 
x 
 !#334SE3J
C5#:
 5\
u& z#334UG^34  38_
z3'^+,3%-. Cs*+8C=/8K+@@A Xc]C0.@A 
X

C5(5/)
* uhsm+,gY./	 	5)<#==> "x}%
C5-'
( 3B 3Blv '#, <c c 
2& 2X 2(2 28 2& 
		 y,./ !	
   
 
		 y,./ !	
   
?	}c!	"?	? y,./? !	?
 ? ?DV (8 B<	< <+.<<~L	L	L L 	L
 (L &L L^=) = =6*8C= *z *hsm *ZC+ C+8 C+L)@F )@~ )@X@	@ @+.@@F  ,z*BC C +9 BC Bx BS B,"Ax0 "AW "AJ 
5 C C  
 
3 # #  
3 # # 2 $(RZZ=P=V=V8F8F 8F3:8Fc]8Fr0   