
    %h                       S SK Jr  S SKrS SKrS SKJr  S SKJr  S SK	J
r
  S SK	Jr  S SK	Jr  SS	KJr  SS
KJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJr  SSKJ r   SSKJ!r!  SSKJ"r"  SSKJ#r#  SSK$J%r%  SSK&J'r'  SSK&J(r(  \RR                  (       a  S SK*J+r+  S SK*J,r,  SS K-J.r.  SS!KJ/r/  SS"K&J0r0   " S# S$5      r1 " S% S&5      r2g)'    )annotationsN)pformat)Lock)quote)urljoin)
urlunsplit   )_get_environ)_wsgi_decoding_dance)ImmutableDict)	MultiDict)BadHost)HTTPException)MethodNotAllowed)NotFound)
_urlencode)get_host   )DEFAULT_CONVERTERS)
BuildError)NoMatch)RequestAliasRedirect)RequestPath)RequestRedirect)WebsocketMismatch)StateMachineMatcher)_simple_rule_re)Rule)WSGIApplication)WSGIEnvironment)Request)BaseConverter)RuleFactoryc                  P   \ rS rSrSr\" \5      r\r	         S                   SS jjr
\SS j5       r\R                  SS j5       rSS jr\SS j5       rSSS	 jjrSS
 jr      S               SS jjr  S       SS jjrSS jrSS jrSrg)Map)   a   The map class stores all the URL rules and some configuration
parameters.  Some of the configuration values are only stored on the
`Map` instance since those affect all rules, others are just defaults
and can be overridden for each rule.  Note that you have to specify all
arguments besides the `rules` as keyword arguments!

:param rules: sequence of url rules for this map.
:param default_subdomain: The default subdomain for rules without a
                          subdomain defined.
:param strict_slashes: If a rule ends with a slash but the matched
    URL does not, redirect to the URL with a trailing slash.
:param merge_slashes: Merge consecutive slashes when matching or
    building URLs. Matches will redirect to the normalized URL.
    Slashes in variable parts are not merged.
:param redirect_defaults: This will redirect to the default rule if it
                          wasn't visited that way. This helps creating
                          unique URLs.
:param converters: A dict of converters that adds additional converters
                   to the list of converters. If you redefine one
                   converter this will override the original one.
:param sort_parameters: If set to `True` the url parameters are sorted.
                        See `url_encode` for more details.
:param sort_key: The sort key function for `url_encode`.
:param host_matching: if set to `True` it enables the host matching
                      feature and disables the subdomain one.  If
                      enabled the `host` parameter to rules is used
                      instead of the `subdomain` one.

.. versionchanged:: 3.0
    The ``charset`` and ``encoding_errors`` parameters were removed.

.. versionchanged:: 1.0
    If ``url_scheme`` is ``ws`` or ``wss``, only WebSocket rules will match.

.. versionchanged:: 1.0
    The ``merge_slashes`` parameter was added.

.. versionchanged:: 0.7
    The ``encoding_errors`` and ``host_matching`` parameters were added.

.. versionchanged:: 0.5
    The ``sort_parameters`` and ``sort_key``  paramters were added.
Nc
                z   [        U5      U l        0 U l        SU l        U R	                  5       U l        X l        X0l        XPl        Xl	        U R                  R                  5       U l        U(       a  U R                  R                  U5        Xpl        Xl        U=(       d    S H  n
U R!                  U
5        M     g )NT )r   _matcher_rules_by_endpoint_remap
lock_class_remap_lockdefault_subdomainstrict_slashesredirect_defaultshost_matchingdefault_converterscopy
convertersupdatesort_parameterssort_keyadd)selfrulesr.   r/   merge_slashesr0   r4   r6   r7   r1   rulefactorys              L/var/www/auris/envauris/lib/python3.13/site-packages/werkzeug/routing/map.py__init__Map.__init__^   s     ,M:;=??,!2,!2*11668OO"":..  ;B;KHH[! '    c                .    U R                   R                  $ Nr)   r;   )r9   s    r=   r;   Map.merge_slashes~   s    }}***r@   c                $    XR                   l        g rB   rC   )r9   values     r=   r;   rD      s    &+#r@   c                    U R                  5         [        U5      nU R                  U    H%  nUR                  UR                  5      (       d  M%    g   g)a  Iterate over all rules and check if the endpoint expects
the arguments provided.  This is for example useful if you have
some URLs that expect a language code and others that do not and
you want to wrap the builder a bit so that the current language
code is automatically added if not provided but endpoints expect
it.

:param endpoint: the endpoint to check.
:param arguments: this function accepts one or more arguments
                  as positional arguments.  Each one of them is
                  checked.
TF)r5   setr*   issubset	arguments)r9   endpointrJ   arguments_setrules        r=   is_endpoint_expectingMap.is_endpoint_expecting   sH     	I++H5D%%dnn55 6 r@   c                x    U R                   R                  5        VVs/ s H  o  H  o"PM     M     snn$ s  snnf rB   )r*   values)r9   r:   rM   s      r=   _rules
Map._rules   s3    "&"9"9"@"@"BU"Butu"BUUUs   6c                    U R                  5         Ub  [        U R                  U   5      $ [        U R                  5      $ )zIterate over all rules or the rules of an endpoint.

:param endpoint: if provided only the rules for that endpoint
                 are returned.
:return: an iterator
)r5   iterr*   rR   )r9   rK   s     r=   
iter_rulesMap.iter_rules   s8     	//9::DKK  r@   c                &   UR                  U 5       Hu  nUR                  U 5        UR                  (       d  U R                  R	                  U5        U R
                  R                  UR                  / 5      R                  U5        Mw     SU l	        g)zAdd a new rule or factory to the map and bind it.  Requires that the
rule is not bound to another map.

:param rulefactory: a :class:`Rule` or :class:`RuleFactory`
TN)
	get_rulesbind
build_onlyr)   r8   r*   
setdefaultrK   appendr+   )r9   r<   rM   s      r=   r8   Map.add   sk      ))$/DIIdO??!!$'##..t}}bAHHN	 0
 r@   c           
     h   UR                  5       nU R                  (       a  Ub  [        S5      eOUc  U R                  nUc  SnUc  SnUR	                  S5      u  pn	 UR                  S5      R                  S5      n[        U U U U	 3UUUUUU5      $ ! [         a  n
[        5       U
eSn
A
ff = f)a  Return a new :class:`MapAdapter` with the details specified to the
call.  Note that `script_name` will default to ``'/'`` if not further
specified or `None`.  The `server_name` at least is a requirement
because the HTTP RFC requires absolute URLs for redirects and so all
redirect exceptions raised by Werkzeug will contain the full canonical
URL.

If no path_info is passed to :meth:`match` it will use the default path
info passed to bind.  While this doesn't really make sense for
manual bind calls, it's useful if you bind a map to a WSGI
environment which already contains the path info.

`subdomain` will default to the `default_subdomain` for this map if
no defined. If there is no `default_subdomain` you cannot use the
subdomain feature.

.. versionchanged:: 1.0
    If ``url_scheme`` is ``ws`` or ``wss``, only WebSocket rules
    will match.

.. versionchanged:: 0.15
    ``path_info`` defaults to ``'/'`` if ``None``.

.. versionchanged:: 0.8
    ``query_args`` can be a string.

.. versionchanged:: 0.7
    Added ``query_args``.
Nz2host matching enabled and a subdomain was provided/:idnaascii)
lowerr1   RuntimeErrorr.   	partitionencodedecodeUnicodeErrorr   
MapAdapter)r9   server_namescript_name	subdomain
url_schemedefault_method	path_info
query_argsport_sepportes              r=   rZ   Map.bind   s    N "'')$"#WXX %..IKI '2&;&;C&@#t	#%,,V4;;GDK mH:dV,	
 		
  	#)"	#s    B 
B1!B,,B1c                z  ^ [        U5      m[        T5      R                  5       nTS   n[        S TR	                  SS5      R                  5       R                  S5       5       5      nU(       a.  TR	                  SS5      R                  5       S:X  a
  US:X  a  S	OS
nUc  UnOSUR                  5       nUS;   a  UR                  S5      (       a  USS nO!US;   a  UR                  S5      (       a  USS nUc  U R                  (       dt  UR                  S5      nUR                  S5      n[        U5      * n	XyS U:w  a   [        R                  " SU< SU< 3SS9  SnOSR                  [        SUSU	 5      5      nSU4S jjn
U
" S5      nU
" S5      nU
" S5      n[        R                  U UUUUTS   UUS9$ )a  Like :meth:`bind` but you can pass it an WSGI environment and it
will fetch the information from that dictionary.  Note that because of
limitations in the protocol there is no way to get the current
subdomain and real `server_name` from the environment.  If you don't
provide it, Werkzeug will use `SERVER_NAME` and `SERVER_PORT` (or
`HTTP_HOST` if provided) as used `server_name` with disabled subdomain
feature.

If `subdomain` is `None` but an environment and a server name is
provided it will calculate the current subdomain automatically.
Example: `server_name` is ``'example.com'`` and the `SERVER_NAME`
in the wsgi `environ` is ``'staging.dev.example.com'`` the calculated
subdomain will be ``'staging.dev'``.

If the object passed as environ has an environ attribute, the value of
this attribute is used instead.  This allows you to pass request
objects.  Additionally `PATH_INFO` added as a default of the
:class:`MapAdapter` so that you don't have to pass the path info to
the match method.

.. versionchanged:: 1.0.0
    If the passed server name specifies port 443, it will match
    if the incoming scheme is ``https`` without a port.

.. versionchanged:: 1.0.0
    A warning is shown when the passed server name does not
    match the incoming WSGI server name.

.. versionchanged:: 0.8
   This will no longer raise a ValueError when an unexpected server
   name was passed.

.. versionchanged:: 0.5
    previously this method accepted a bogus `calculate_subdomain`
    parameter that did not have any effect.  It was removed because
    of that.

:param environ: a WSGI environment.
:param server_name: an optional server name hint (see above).
:param subdomain: optionally the current subdomain (see above).
zwsgi.url_schemec              3  H   #    U  H  nUR                  5       S :H  v   M     g7f)upgradeN)strip).0vs     r=   	<genexpr>&Map.bind_to_environ.<locals>.<genexpr>.  s"      
F GGI"Fs    "HTTP_CONNECTION ,HTTP_UPGRADE	websockethttpswsswsN>   r   httpz:80>   r   r   z:443.zCurrent server name z& doesn't match configured server name r	   )
stacklevelz	<invalid>c                D   > TR                  U 5      nUb  [        U5      $ g rB   )getr   )namevalenvs     r=   _get_wsgi_string-Map.bind_to_environ.<locals>._get_wsgi_stringU  s#    ''$-C+C00r@   SCRIPT_NAME	PATH_INFOQUERY_STRINGREQUEST_METHOD)rq   )r   strreturn
str | None)r
   r   rd   anyr   splitendswithr1   lenwarningswarnjoinfilterr%   rZ   )r9   environrk   rm   wsgi_server_nameschemerx   cur_server_namereal_server_nameoffsetr   rl   rp   rq   r   s                 @r=   bind_to_environMap.bind_to_environ   s   ^ 7##C=..0&' 
WW.399;AA#F
 

 sww~r288:kI$/UTF*K%++-K 'K,@,@,G,G)#2.++0D0DV0L0L)#2.T%7%7.44S9O*005*++Fw'+;; *+;*> ?$$/?4 
 (	HHVD/'62J%KL		 '}5$[1	%n5
xx !!  	
 		
r@   c                N   U R                   (       d  gU R                     U R                   (       d
   SSS5        gU R                  R                  5         U R                  R                  5        H  nUR                  S S9  M     SU l         SSS5        g! , (       d  f       g= f)zjCalled before matching and building to keep the compiled rules
in the correct order after things changed.
Nc                "    U R                  5       $ rB   )build_compare_key)xs    r=   <lambda>Map.update.<locals>.<lambda>v  s    )<)<)>r@   )keyF)r+   r-   r)   r5   r*   rQ   sortr9   r:   s     r=   r5   
Map.updatei  sv     {{;;  MM  "00779

>
? :DK s   BAB
B$c                |    U R                  5       n[        U 5      R                   S[        [	        U5      5       S3$ )N())rV   type__name__r   listr   s     r=   __repr__Map.__repr__y  s6    !t*%%&aU(<'=Q??r@   )r)   r+   r-   r*   r4   r.   r1   r0   r7   r6   r/   )	Nr   TTTNFNF)r:   zt.Iterable[RuleFactory] | Noner.   r   r/   boolr;   r   r0   r   r4   z*t.Mapping[str, type[BaseConverter]] | Noner6   r   r7   z!t.Callable[[t.Any], t.Any] | Noner1   r   r   None)r   r   )rF   r   r   r   )rK   t.AnyrJ   r   r   r   )r   z
list[Rule]rB   )rK   zt.Any | Noner   zt.Iterator[Rule])r<   r#   r   r   )NNr   GETNN)rk   r   rl   r   rm   r   rn   r   ro   r   rp   r   rq   "t.Mapping[str, t.Any] | str | Noner   rj   NN)r   zWSGIEnvironment | Requestrk   r   rm   r   r   rj   )r   r   )r   r   )r   
__module____qualname____firstlineno____doc__r   r   r2   r   r,   r>   propertyr;   setterrN   rR   rV   r8   rZ   r   r5   r   __static_attributes__r(   r@   r=   r%   r%   )   s   *Z ''9:
 J 15!##""&AE %6:#"-" " 	"
 "  " ?" " 4" " 
"@ + + , ,( V V
!  #' $ # $9=C
C
  C
 	C

 C
 C
 C
 7C
 
C
P #' $	k
*k
  k
 	k

 
k
Z  @r@   r%   c                     \ rS rSrSr S               SS jjr   S         SS jjr\R                       S           SS jj5       r	\R                       S           SS jj5       r	     S           SS jjr	SSS	 jjr
SSS
 jjrSS jr          S S jrS!S jr  S       S"S jjr            S#S jr          S$S jr     S%             S&S jjrSrg)'rj   i~  zReturned by :meth:`Map.bind` or :meth:`Map.bind_to_environ` and does
the URL matching and building based on runtime information.
Nc	                    Xl         X l        UR                  S5      (       d  US-  nX0l        X@l        XPl        X`l        Xpl        Xl        U R
                  S;   U l	        g )Nr`   >   r   r   )
maprk   r   rl   rm   rn   rp   ro   rq   r   )	r9   r   rk   rl   rm   rn   rp   ro   rq   s	            r=   r>   MapAdapter.__init__  sZ     &##C((3K&"$",$M9r@   c                      U R                  X#5      u  pVU" XV5      $ ! [         a  nUs SnA$ SnAff = f! [         a  nU(       a  Us SnA$ e SnAff = f)a#  Does the complete dispatching process.  `view_func` is called with
the endpoint and a dict with the values for the view.  It should
look up the view function, call it, and return a response object
or WSGI application.  http exceptions are not caught by default
so that applications can display nicer error messages by just
catching them by hand.  If you want to stick with the default
error messages you can pass it ``catch_http_exceptions=True`` and
it will catch the http exceptions.

Here a small example for the dispatch usage::

    from werkzeug.wrappers import Request, Response
    from werkzeug.wsgi import responder
    from werkzeug.routing import Map, Rule

    def on_index(request):
        return Response('Hello from the index')

    url_map = Map([Rule('/', endpoint='index')])
    views = {'index': on_index}

    @responder
    def application(environ, start_response):
        request = Request(environ)
        urls = url_map.bind_to_environ(environ)
        return urls.dispatch(lambda e, v: views[e](request, **v),
                             catch_http_exceptions=True)

Keep in mind that this method might return exception objects, too, so
use :class:`Response.force_type` to get a response object.

:param view_func: a function that is called with the endpoint as
                  first argument and the value dict as second.  Has
                  to dispatch to the actual view function with this
                  information.  (see above)
:param path_info: the path info to use for matching.  Overrides the
                  path info specified on binding.
:param method: the HTTP method used for matching.  Overrides the
               method specified on binding.
:param catch_http_exceptions: set to `True` to catch any of the
                              werkzeug :class:`HTTPException`\s.
Nmatchr   r   )r9   	view_funcrp   methodcatch_http_exceptionsrK   argsrt   s           r=   dispatchMapAdapter.dispatch  s]    b		!%I!> X,, #   	$	s=    7 
4/47 47 
AA	AAAc                    g rB   r(   r9   rp   r   return_rulerq   r   s         r=   r   MapAdapter.match  s     /2r@   c                    g rB   r(   r   s         r=   r   r     s     .1r@   c           
     2  ^^ U R                   R                  5         Uc  U R                  nUc  U R                  =(       d    0 nU=(       d    U R                  R                  5       nUc  U R                  nU R                  nU R                   R                  (       d  U R                  b  U R                  nU(       a  SUR                  S5       3OSn U R                   R                  R                  XgX%5      nUu  mmU R                   R                  (       a"  U R                  TUTU5      n	U	b  [        U	5      eTR                   b  [#        TR                   [$        5      (       a+  SUU4S jjn
[&        R(                  " U
TR                   5      n	OTR                   " U 40 TD6n	U R                  (       a  U R                   SU R                   3nOU R                  n[        [+        U R,                  =(       d    S SU U R.                   3U	5      5      eU(       a  TT4$ TR0                  T4$ ! [2         a4  n[5        UR                  SS	9n[        U R7                  X5      5      SeSnAf[8         a=  n[        U R;                  U S
U 3UR0                  UR<                  UU5      5      SeSnAf[>         aZ  nUR@                  (       a  [C        [E        UR@                  5      S9SeURF                  (       a  [I        5       Se[K        5       SeSnAff = f)a  The usage is simple: you just pass the match method the current
path info as well as the method (which defaults to `GET`).  The
following things can then happen:

- you receive a `NotFound` exception that indicates that no URL is
  matching.  A `NotFound` exception is also a WSGI application you
  can call to get a default page not found page (happens to be the
  same object as `werkzeug.exceptions.NotFound`)

- you receive a `MethodNotAllowed` exception that indicates that there
  is a match for this URL but not for the current request method.
  This is useful for RESTful applications.

- you receive a `RequestRedirect` exception with a `new_url`
  attribute.  This exception is used to notify you about a request
  Werkzeug requests from your WSGI application.  This is for example the
  case if you request ``/foo`` although the correct URL is ``/foo/``
  You can use the `RequestRedirect` instance as response-like object
  similar to all other subclasses of `HTTPException`.

- you receive a ``WebsocketMismatch`` exception if the only
  match is a WebSocket rule but the bind is an HTTP request, or
  if the match is an HTTP rule but the bind is a WebSocket
  request.

- you get a tuple in the form ``(endpoint, arguments)`` if there is
  a match (unless `return_rule` is True, in which case you get a tuple
  in the form ``(rule, arguments)``)

If the path info is not passed to the match method the default path
info of the map is used (defaults to the root URL if not defined
explicitly).

All of the exceptions raised are subclasses of `HTTPException` so they
can be used as WSGI responses. They will all render generic error or
redirect pages.

Here is a small example for matching:

>>> m = Map([
...     Rule('/', endpoint='index'),
...     Rule('/downloads/', endpoint='downloads/index'),
...     Rule('/downloads/<int:id>', endpoint='downloads/show')
... ])
>>> urls = m.bind("example.com", "/")
>>> urls.match("/", "GET")
('index', {})
>>> urls.match("/downloads/42")
('downloads/show', {'id': 42})

And here is what happens on redirect and missing URLs:

>>> urls.match("/downloads")
Traceback (most recent call last):
  ...
RequestRedirect: http://example.com/downloads/
>>> urls.match("/missing")
Traceback (most recent call last):
  ...
NotFound: 404 Not Found

:param path_info: the path info to use for matching.  Overrides the
                  path info specified on binding.
:param method: the HTTP method used for matching.  Overrides the
               method specified on binding.
:param return_rule: return the rule that matched instead of just the
                    endpoint (defaults to `False`).
:param query_args: optional query arguments that are used for
                   automatic redirects as string or dictionary.  It's
                   currently not possible to use the query arguments
                   for URL matching.
:param websocket: Match WebSocket instead of HTTP requests. A
    websocket request has a ``ws`` or ``wss``
    :attr:`url_scheme`. This overrides that detection.

.. versionadded:: 1.0
    Added ``websocket``.

.. versionchanged:: 0.8
    ``query_args`` can be a string.

.. versionadded:: 0.7
    Added ``query_args``.

.. versionadded:: 0.6
    Added ``return_rule``.
Nr`   r   c                   > TU R                  S5         nTR                  U R                  S5         R                  U5      $ )Nr   )group_convertersto_url)r   rF   rM   rvs     r=   _handle_match'MapAdapter.match.<locals>._handle_match  s9     "5;;q> 2#//A?FFuMMr@   r   r   z://z!$&'()*+,/:;=@)safe|)valid_methods)r   zt.Match[str]r   r   )&r   r5   rp   rq   ro   upperr   rk   r1   rm   lstripr)   r   r0   get_default_redirectr   redirect_to
isinstancer   r   subr   rn   rl   rK   r   r   make_redirect_urlr   make_alias_redirect_urlmatched_valuesr   have_match_forr   r   websocket_mismatchr   r   )r9   rp   r   r   rq   r   domain_part	path_partresultredirect_urlr   netlocrt   new_pathrM   r   s                 @@r=   r   r     s   ~ 	I.BJ/D//668I&&xx%%$..*D..K3<a	((-./"	<	)XX&&,,[VWF4 HD"xx))#88vr:V+),77+d..44N N $3#6#6}dFVFV#WL#'#3#3D#?B#?L>> $/q1A1A0BCF!--F%??4f5SAQAQ@RS$  Rx}}b((u  	Q[[/?@H!&&x< $ 		!,,"m1YK0JJ$$   	'&T!:J:J5KLRVV##')t3*$&	's1   &H1 1
L;/I**L78J//L<ALLc                ^     U R                  X5        g! [         a     g[         a     gf = f)a\  Test if a rule would match.  Works like `match` but returns `True`
if the URL matches, or `False` if it does not exist.

:param path_info: the path info to use for matching.  Overrides the
                  path info specified on binding.
:param method: the HTTP method used for matching.  Overrides the
               method specified on binding.
FTr   )r9   rp   r   s      r=   testMapAdapter.test  s>    	JJy)
 	  	   		s    
,	,,c                     U R                  USS9  / $ ! [         a  nUR                  s SnA$ SnAf[         a     / $ f = f)zNReturns the valid methods that match for a given path.

.. versionadded:: 0.7
z--)r   N)r   r   r   r   )r9   rp   rt   s      r=   allowed_methodsMapAdapter.allowed_methods  sJ    
	JJyJ.
 		   	#??" 			s    
A /A A A c                    U R                   R                  (       a  Uc  U R                  $ U$ Uc  U R                  nOUnU(       a  U SU R                   3$ U R                  $ )zFigures out the full host name for the given domain part.  The
domain part is a subdomain in case host matching is disabled or
a full host name.
r   )r   r1   rk   rm   )r9   r   rm   s      r=   r   MapAdapter.get_host  sd    
 88!!"'''I#I[$"2"2!344###r@   c                z   U R                   R                  (       d   eU R                   R                  UR                      Hw  nXQL a    gUR	                  U5      (       d  M!  UR                  X25      (       d  M9  UR                  UR                  5        UR                  U5      u  pgU R                  XtUS9s  $    g)zuA helper that returns the URL to redirect to if it finds one.
This is used for default redirecting only.

:internal:
)r   N)
r   r0   r*   rK   provides_defaults_forsuitable_forr5   defaultsbuildr   )r9   rM   r   rQ   rq   rr   paths           r=   r   MapAdapter.get_default_redirect  s     xx)))),,T]];A y
 	 &&t,,1O1Oajj)$%GGFO!--dK-XX < r@   c                F    [        U[        5      (       d  [        U5      $ U$ rB   )r   r   r   )r9   rq   s     r=   encode_query_argsMapAdapter.encode_query_args  s     *c**j))r@   c                4   Uc  U R                   nU(       a  U R                  U5      nOSnU R                  =(       d    SnU R                  U5      nSR	                  U R
                  R                  S5      UR                  S5      45      n[        XVXtS45      $ )z$Creates a redirect URL.

:internal:
Nr   r`   )	rq   r  rn   r   r   rl   ry   r   r   )r9   rp   rq   r   	query_strr   hostr  s           r=   r   MapAdapter.make_redirect_url  s     J..z:II*F}}[)xx))//4i6F6Fs6KLM6$?@@r@   c                ~    U R                  X#USSS9nU(       a  USU R                  U5       3-  nXa:w  d   S5       eU$ )z0Internally called to make an alias redirect URL.FT)append_unknownforce_external?z6detected invalid alias setting. No canonical URL found)r  r  )r9   r  rK   rQ   r   rq   urls          r=   r   "MapAdapter.make_alias_redirect_url  sW     jjfU4  
 Qt--j9:;;C{TTT{
r@   c                   Uc"  U R                  XU R                  U5      nUb  U$ SnU R                  R                  R	                  US5       H  nUR                  X#5      (       d  M  UR                  X$5      nUc  M1  US   US   UR                  4nU R                  R                  (       a   US   U R                  :X  a  Us  $ Uc  UnM  M  Us  $    U$ )z~Helper for :meth:`build`.  Returns subdomain and path for the
rule that accepts this endpoint, values and method.

:internal:
Nr(   r   r   )
_partial_buildro   r   r*   r   r   r  r   r1   rk   )	r9   rK   rQ   r   r  r   first_matchrM   build_rvs	            r=   r  MapAdapter._partial_build  s     >$$$"5"5~B ~	
 HH//33HbAD  00::f='"1+x{DNNCBxx--a5D$4$44#%I(0*,K 1  "	 B r@   c                   U R                   R                  5         U(       a  [        U[        5      (       aP  [        R                  U5       VVs0 s H-  u  px[        U5      S:w  d  M  U[        U5      S:X  a  US   OU_M/     nnnO,UR                  5        VVs0 s H  u  pxUc  M
  Xx_M     nnnO0 nU R                  XX55      n	U	c  [        XX05      eU	u  pnU R                  U
5      nUc  U R                  nUS;   nU(       a  SnU(       a  SOSnOU(       a  U(       a  SOS	nU(       d  U R                   R                  (       a  XR                  :X  d*  U R                   R                  (       d>  XR                  :X  a/  U R                  R                  S
5       S
UR!                  S
5       3$ U(       a  U S3OSnU SU U R                  SS  S
UR!                  S
5       3$ s  snnf s  snnf )a{
  Building URLs works pretty much the other way round.  Instead of
`match` you call `build` and pass it the endpoint and a dict of
arguments for the placeholders.

The `build` function also accepts an argument called `force_external`
which, if you set it to `True` will force external URLs. Per default
external URLs (include the server name) will only be used if the
target URL is on a different subdomain.

>>> m = Map([
...     Rule('/', endpoint='index'),
...     Rule('/downloads/', endpoint='downloads/index'),
...     Rule('/downloads/<int:id>', endpoint='downloads/show')
... ])
>>> urls = m.bind("example.com", "/")
>>> urls.build("index", {})
'/'
>>> urls.build("downloads/show", {'id': 42})
'/downloads/42'
>>> urls.build("downloads/show", {'id': 42}, force_external=True)
'http://example.com/downloads/42'

Because URLs cannot contain non ASCII data you will always get
bytes back.  Non ASCII characters are urlencoded with the
charset defined on the map instance.

Additional values are converted to strings and appended to the URL as
URL querystring parameters:

>>> urls.build("index", {'q': 'My Searchstring'})
'/?q=My+Searchstring'

When processing those additional values, lists are furthermore
interpreted as multiple values (as per
:py:class:`werkzeug.datastructures.MultiDict`):

>>> urls.build("index", {'q': ['a', 'b', 'c']})
'/?q=a&q=b&q=c'

Passing a ``MultiDict`` will also add multiple values:

>>> urls.build("index", MultiDict((('p', 'z'), ('q', 'a'), ('q', 'b'))))
'/?p=z&q=a&q=b'

If a rule does not exist when building a `BuildError` exception is
raised.

The build method accepts an argument called `method` which allows you
to specify the method you want to have an URL built for if you have
different methods for the same endpoint specified.

:param endpoint: the endpoint of the URL to build.
:param values: the values for the URL to build.  Unhandled values are
               appended to the URL as query parameters.
:param method: the HTTP method for the rule if there are different
               URLs for different methods on the same endpoint.
:param force_external: enforce full canonical external URLs. If the URL
                       scheme is not provided, this will generate
                       a protocol-relative URL.
:param append_unknown: unknown parameters are appended to the generated
                       URL as query string argument.  Disable this
                       if you want the builder to ignore those.
:param url_scheme: Scheme to use in place of the bound
    :attr:`url_scheme`.

.. versionchanged:: 2.0
    Added the ``url_scheme`` parameter.

.. versionadded:: 0.6
   Added the ``append_unknown`` parameter.
r   r   N>   r   r   Tr   r   r   r   r`   ra   r   z//)r   r5   r   r   dictitemsr   r  r   r   rn   r1   rk   rm   rl   rstripr   )r9   rK   rQ   r   r  r  rn   kr{   r   r   r  r   r  securer   s                   r=   r  MapAdapter.build<  s   ` 	&),, !%

6 2 21v{ 3AA!!2 2   ,2<<>K>41Q$!$>KF  6J:Xv<<')$9}}[)J
 //!N"(dJ$*J XX##0@0@(@HH**{nn/L&&--c231T[[5E4FGG%/J<q!RD6$"2"23B"7!8$++c:J9KLLO Ls   G%(G%	G+'G+)	ro   r   rp   rq   rl   rk   rm   rn   r   rB   )r   r%   rk   r   rl   r   rm   r   rn   r   rp   r   ro   r   rq   r   )NNF)
r   z9t.Callable[[str, t.Mapping[str, t.Any]], WSGIApplication]rp   r   r   r   r   r   r   r   )NNFNN)rp   r   r   r   r   zt.Literal[False]rq   r   r   bool | Noner   z#tuple[t.Any, t.Mapping[str, t.Any]])NNTNN)rp   r   r   r   r   zt.Literal[True]rq   r   r   r   r   z"tuple[Rule, t.Mapping[str, t.Any]])rp   r   r   r   r   r   rq   r   r   r   r   z*tuple[t.Any | Rule, t.Mapping[str, t.Any]]r   )rp   r   r   r   r   r   )rp   r   r   zt.Iterable[str])r   r   r   r   )
rM   r   r   r   rQ   zt.MutableMapping[str, t.Any]rq   t.Mapping[str, t.Any] | strr   r   )rq   r!  r   r   )rp   r   rq   r   r   r   r   r   )r  r   rK   r   rQ   t.Mapping[str, t.Any]r   r   rq   r!  r   r   )
rK   r   rQ   r"  r   r   r  r   r   ztuple[str, str, bool] | None)NNFTN)rK   r   rQ   zt.Mapping[str, t.Any] | Noner   r   r  r   r  r   rn   r   r   r   )r   r   r   r   r   r>   r   toverloadr   r   r   r   r   r  r   r   r  r  r   r(   r@   r=   rj   rj   ~  s%    :>:: : 	:
 : : : : 7:8 !%!&+:L: : 	:
  $: 
:x ZZ !%!(-9=!%22 2 &	2
 72 2 
-2 2 ZZ !%!'+9=!%11 1 %	1
 71 1 
,1 1 !%!!9=!%l)l) l) 	l)
 7l) l) 
4l)\"$*  -	
 0 
2 :>"&	AA 7A  	A
 
A.  &	
  0 
"'' &' 	'
 ' 
&'X 04!$#!%{M{M -{M 	{M
 {M {M {M 
{M {Mr@   rj   )3
__future__r   typingr#  r   pprintr   	threadingr   urllib.parser   r   r   	_internalr
   r   datastructuresr   r   
exceptionsr   r   r   r   urlsr   wsgir   r4   r   r   r   r   r   r   r   matcherr   r:   r   r   TYPE_CHECKING_typeshed.wsgir   r    wrappers.requestr!   r"   r#   r%   rj   r(   r@   r=   <module>r3     s    "        # $ , * &   & ) !   * "  , # ' ) ( " ??..*)"R@ R@j
yM yMr@   