
    Ehn<                     H   S SK r S SKrS SKrS SKrS SKrS SKrS SKJr  S SKJrJ	r	  S SK
Jr  S SKJ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  \" 5       r\ R4                  " 5       rS rS rS rS rS r S r!S r"S r#S r$S r%          SS jr&S r'S r(S r)g)    N)fnmatch)isfilejoin)Path)parse_qs   )	_validate)context_value)get_app)get_relative_path)AttributeDictc           	         [         R                  n/ SQnU R                  S5      S   n/ n[        R                  R                  U5      (       aA  [        R                  " U5       Vs/ s H   n[        [        X5      5      (       d  M  UPM"     nnSnSnU H]  nUR                  S5      u  pnUR                  5       U;   d  M-  X:X  d  XR                  SS5      :X  a  Us  $ U	S:X  a  UnU	S:X  d  M[  UnM_     U(       a  U$ U$ s  snf )	z
Return:
- A page specific image: `assets/<module>.<extension>` is used, e.g. `assets/weekly_analytics.png`
- A generic app image at `assets/app.<extension>`
- A logo at `assets/logo.<extension>`
)apngavifgifjpegjpgpngsvgwebp.N_-applogo)CONFIGassets_foldersplitospathexistslistdirr   r   	partitionlowerreplace)moduler   valid_extensionspage_idfiles_in_assetsfapp_file	logo_filefnfn_without_extensionr   	extensions               ^C:\Users\julio\OneDrive\Documentos\Trabajo\Ideas Frescas\venv\Lib\site-packages\dash/_pages.py_infer_imager2      s     ((MSll3#GO	ww~~m$$zz-0
0!F4;Q4RA0 	 
 HI-/\\#->*?? 00$/'??3+DD	#u,#v-	  /
s   'DDc                 f    U R                  S5      S   R                  SS5      R                  5       $ )Nr   r   r    )r   r&   
capitalize)module_names    r1   _module_name_to_page_namer7   ?   s.    S!"%--c37BBDD    c                    Uc  [         R                  (       ao  [        [        [         R                  5      R                  5      nU R                  U5      S   R                  SS5      R                  SS5      R                  5       nOIU R                  SS5      R                  SS5      R                  5       nO[        R                  " SSU5      nUR                  S5      (       d  SU-   nU$ UnU$ )Nr   r   r   r   /<.*?>none)r   pages_folderstrr   namer   r&   r%   resub
startswith)r6   templatepages_moduler!   s       r1   _infer_pathrE   C   s    tF$7$78==>L!!,/3c"c"	  &&sC088cBHHJD vvgvx0!__S113:DK 8<DKr8   c                     U [         R                  ;  a  g[         R                  U    R                  nU=(       a    UR                  S5      $ )NFz__init__.py)sysmodules__file__endswith)r6   files     r1   _module_name_is_packagerL   W   s9    #++%;;{#,,D0DMM-00r8   c                     [        U 5      R                  SS5      R                  [        R                  5      R                  [        R                  S5      $ )N.py r   )r>   r&   stripr    sep)r!   s    r1   _path_to_module_namerR   ^   s9    t9UB'--bff5==bffcJJr8   c                    U R                  [        R                  5      S   n[        U5      n[        R
                  R                  [        R                  5      n[        R                  R                  U5      (       a  [        R                  [        U5      S  nO[        R                  n[        U5      nU SU 3n[        [        R                  5      (       a  [        R                   SU 3nU$ )Nr   r   )r   r   r=   rR   flaskhelpersget_root_pathr?   rB   lenrL   )	page_pathrelative_pathr'   	proj_rootparent_pathparent_moduler6   s          r1   _infer_module_namer]   b   s    OOF$7$78<M!-0F++FKK8I%%i00))#i.*:;))(5M"O1VH-Kv{{++Q{m4r8   c                     U (       a  U R                  S5      (       d  0 $ U SS  n[        USS9nUR                  5        VVs0 s H  u  p4U[        U5      S:X  a  US   OU_M     snn$ s  snnf )N?r   T)keep_blank_valuesr   )rB   r   itemsrW   )searchquery_string	parsed_qskvs        r1   _parse_query_stringrg   s   si    **3//	!":L>I6?oo6GH6GdaAs1v{qt)6GHHHs   #A)c                 D   [         R                  " SSU5      n[         R                  " SSU5      n[        X5      (       d  g[         R                  " SU5      n[         R                  " X05      n[	        US   [
        5      (       a  US   OUn[        [        XE5      5      $ )z
creates the dict of path variables passed to the layout
e.g. path_template= "/asset/<asset_id>"
     if pathname provided by the browser is "/assets/a100"
     returns **{"asset_id": "a100"}
r;   *z(.*)Nz<(.*?)>r   )r@   rA   r   findall
isinstancetupledictzip)pathnamepath_templatewildcard_patternvar_pattern	var_names	variabless         r1   _parse_path_variablesru   ~   s     vvgsM:&&&-8K 8.. 

9m4I 

;1I *9Q< ? ?	!YII)**r8   c                    ^  U 4S jnU$ )Nc                  .   > [         R                  " T SS9$ )Ni-  )code)rT   redirect)redirect_tos   r1   ry   +_create_redirect_function.<locals>.redirect   s    ~~k44r8    )rz   ry   s   ` r1   _create_redirect_functionr}      s    5 Or8   c           
          [        5       nU (       aa  [        U 5      (       aP  U  HI  nUR                  U5      nUR                  R	                  UU[        UR                  U5      5      5        MK     g g g )N)r   rW   r   serveradd_url_ruler}   )redirect_fromr!   r   ry   fullnames        r1   _set_redirectr      sb    
)C]++%H,,X6HJJ##)#*?*?*EF & ,}r8   c           
      @   [         R                  " 5       R                  S5      (       a  g[        R                  " [        5        [        [        R                  " U 5      UUUb  UO
[        X5      UUb  UO
[        U 5      S9nUR                  UUb  UO([        R                  S:w  a  [        R                  OUS   S9  UR                  " SU(       a  UO&[        R                  (       a  [        R                  OSUUU
S.UD6  UR                  UUb  UO
[        U 5      US	9  UR                  [        XS
   5      S9  U[        U '   US   (       a  [        R                  " US   5        U
b  U
[        U    S'   [!        S [        R#                  5        5       5      n[        R#                  5        H.  nUS
   S:X  a	  U(       d  SOUS   US'   [%        US
   5      US'   M0     ['        [        R#                  5       S S9 H  n[        R)                  US   5        M     g)a  
Assigns the variables to `dash.page_registry` as an `OrderedDict`
(ordered by `order`).

`dash.page_registry` is used by `pages_plugin` to set up the layouts as
a multi-page Dash app. This includes the URL routing callbacks
(using `dcc.Location`) and the HTML templates to include title,
meta description, and the meta description image.

`dash.page_registry` can also be used by Dash developers to create the
page navigation links or by template authors.

- `module`:
   The module path where this page's `layout` is defined. Often `__name__`.

- `path`:
   URL Path, e.g. `/` or `/home-page`.
   If not supplied, will be inferred from the `path_template` or `module`,
   e.g. based on path_template: `/asset/<asset_id` to `/asset/none`
   e.g. based on module: `pages.weekly_analytics` to `/weekly-analytics`

- `relative_path`:
    The path with `requests_pathname_prefix` prefixed before it.
    Use this path when specifying local URL paths that will work
    in environments regardless of what `requests_pathname_prefix` is.
    In some deployment environments, like Dash Enterprise,
    `requests_pathname_prefix` is set to the application name,
    e.g. `my-dash-app`.
    When working locally, `requests_pathname_prefix` might be unset and
    so a relative URL like `/page-2` can just be `/page-2`.
    However, when the app is deployed to a URL like `/my-dash-app`, then
    `relative_path` will be `/my-dash-app/page-2`.

- `path_template`:
   Add variables to a URL by marking sections with <variable_name>. The layout function
   then receives the <variable_name> as a keyword argument.
   e.g. path_template= "/asset/<asset_id>"
        then if pathname in browser is "/assets/a100" then layout will receive **{"asset_id":"a100"}

- `name`:
   The name of the link.
   If not supplied, will be inferred from `module`,
   e.g. `pages.weekly_analytics` to `Weekly analytics`

- `order`:
   The order of the pages in `page_registry`.
   If not supplied, then the filename is used and the page with path `/` has
   order `0`

- `title`:
   (string or function) Specifies the page title displayed in the browser tab.
    If not supplied, the app's title is used if different from the default "Dash".
    Otherwise, the title is the given `name` or inferred from the module name.
    For example, `pages.weekly_analytics` is inferred as "Weekly Analytics".

- `description`:
   (string or function) The <meta type="description"></meta>.
   If not defined, the application description will be used if available.

- `image`:
   The meta description image used by social media platforms.
   If not supplied, then it looks for the following images in `assets/`:
    - A page specific image: `assets/<module>.<extension>` is used, e.g. `assets/weekly_analytics.png`
    - A generic app image at `assets/app.<extension>`
    - A logo at `assets/logo.<extension>`
    When inferring the image file, it will look for the following extensions:
    APNG, AVIF, GIF, JPEG, JPG, PNG, SVG, WebP.

-  `image_url`:
   Overrides the image property and sets the `<image>` meta tag to the provided image URL.

- `redirect_from`:
   A list of paths that should redirect to this page.
   For example: `redirect_from=['/v2', '/v3']`

- `layout`:
   The layout function or component for this page.
   If not supplied, then looks for `layout` from within the supplied `module`.

- `**kwargs`:
   Arbitrary keyword arguments that can be stored

***

`page_registry` stores the original property that was passed in under
`supplied_<property>` and the coerced property under `<property>`.
For example, if this was called:
```
register_page(
    'pages.historical_outlook',
    name='Our historical view',
    custom_key='custom value'
)
```
Then this will appear in `page_registry`:
```
OrderedDict([
    (
        'pages.historical_outlook',
        dict(
            module='pages.historical_outlook',

            supplied_path=None,
            path='/historical-outlook',

            supplied_name='Our historical view',
            name='Our historical view',

            supplied_title=None,
            title='Our historical view'

            supplied_layout=None,
            layout=<function pages.historical_outlook.layout>,

            custom_key='custom value'
        )
    ),
])
```
ignore_register_pageN)r'   supplied_pathrp   r!   supplied_namer?   Dashr?   )supplied_titletitlerO   )descriptionordersupplied_ordersupplied_layout)supplied_imageimage	image_urlr!   )r   rp   layoutc              3   .   #    U  H  oS    SLv   M     g7f)r   Nr|   ).0ps     r1   	<genexpr> register_page.<locals>.<genexpr>c  s      1GA
4'1Gs   r:   r   r   r   rY   c                     U S   S L [        U S   [        [        45      (       a  U S   O
[        S5      [        U S   5      U S   4$ )Nr   infr'   )rk   intfloatr>   )is    r1   <lambda>register_page.<locals>.<lambda>q  sF    gJ$$QwZ#u>>AgJE%L'
OhK	
r8   )keyr'   r|   )r
   getr	   validate_use_pagesr   rm   validate_module_namerE   r7   updater   r   r2   r   PAGE_REGISTRYvalidate_templateanyvaluesr   sortedmove_to_end)r'   r!   rp   r?   r   r   r   r   r   r   r   kwargspageorder_suppliedr   s                  r1   register_pager      s   L 566  (--f5#%T;v+M%T+DV+LD 	KK  <<6! \\&\   	KK 
    
 
 	KK)u|F/C  
 	KKmM<HKI M&O##D$9:*0fh'  1>1E1E1G N !!#6c!.Aa@P>Q 	
'
 /qy9/	 $ 
 	!!$x.1r8   c                     S n[         R                  5        HT  nUS   (       a+  US   R                  S5      n[        X5      nU(       a  X!4s  $ XS   R                  S5      :X  d  MQ  X!4s  $    0 S 4$ )Nrp   r:   r!   )r   r   rP   ru   )path_idpath_variablesr   template_ids       r1   _path_to_pager   {  sv    N$$& /55c:K27HN++6l((--'' ' t8Or8   c                    [        [        R                  R                  R	                  S5      5      u  pUR                  SS5      nU(       a  U R                  U5      nU(       a:  SR                  [        R                  R                  UR                  S5      /5      OS nUR                  S5      nU(       a  UOUnUR                  SU R                  5      n[        U5      (       a  U(       a  U" S0 UD6OU" 5       nUR                  SS5      n[        U5      (       a  U(       a  U" S0 UD6OU" 5       nSUS.SS	S
.S[        R                  R                  S
.SUS
.SUS
.SU=(       d    SS
.SUS
.SSS
.SUS
.SU=(       d    SS
./
$ )Nr:   r   rO   r   r   r   )r?   contentztwitter:cardsummary_large_image)propertyr   ztwitter:urlztwitter:titleztwitter:descriptionztwitter:imagezog:titlezog:typewebsitezog:descriptionzog:imager|   )r   rT   requestr!   rP   r   get_asset_urlr   url_rootlstripr   callableurl)	r   
start_pager   r   assets_image_urlsupplied_image_urlr   r   r   s	            r1   _page_meta_tagsr     s_   !.u}}/A/A/G/G/L!MJ NN7B'E!!%(@E''c):;<4  $4&8">NINN7CII.E+9''uw..3K7Ek3N3;= ;7#0EF"u}}/@/@A$7*{C$bAE295%+>IO< r8   c                    [         R                  " U 5       GH  u  pnU Vs/ s H4  oDR                  S5      (       a  M  UR                  S5      (       a  M2  UPM6     snUS S & U GH`  nUR                  S5      (       d,  UR                  S5      (       d  UR                  S5      (       d  MH  [         R                  R                  X5      n[        USS9 nUR                  5       nSU;  a   S S S 5        M   S S S 5        [        U5      n	[        R                  R                  X5      n
[        R                  R                  U
5      nU
R                  R                  U5        U[        R                   U	'   U	["        ;   d  GM   ["        U	   S   (       a  GM4  [$        R&                  " X5        [)        US5      ["        U	   S'   GMc     GM     g s  snf ! , (       d  f       N= f)	Nr   r   rN   zutf-8)encodingr   r   r   )r    walkrB   rJ   r!   r   openreadr]   	importlibutilspec_from_file_locationmodule_from_specloaderexec_modulerG   rH   r   r	   validate_pages_layoutgetattr)r=   rootdirsfilesdrK   rX   r+   r   r6   specpage_modules               r1   _import_layouts_from_pagesr     se   WW\2E"Vd,,s*;1ALLQTDU1dVQDs##ts';';4==QVCWCWT0Ii'2a&&("'1 321 3
 -Y7K>>99+QD#..99$?KKK##K0'2CKK$ },%k23DEE//I7>{H7Uk*84)  3V
 32s   GGGG
G#)
NNNNNNNNNN)*collectionsr   importlib.utilr    r@   rG   r   os.pathr   r   pathlibr   urllib.parser   rT   rO   r	   _callback_contextr
   _get_appr   
_get_pathsr   _utilsr   r   OrderedDictr   r2   r7   rE   rL   rR   r]   rg   ru   r}   r   r   r   r   r   r|   r8   r1   <module>r      s       	 	 
     !   ,  ) !	'')$NE(1K"I+6	 
	


L2^
 FVr8   