
    D6i}                     D    d dl Z d dlmZ d dlmZmZ d Z G d de      Zy)    N)url_for)current_apprequestc                 R   t         j                  d   rt        | fi |S fd} ||       r3	 |j                  d      }j                  }t
        j                  jt
        j                  j                  v rNj                  t
        j                     j                  r'j                  t
        j                     j                  }j                  j                  j                  d   |	      }j                  d
   rNt        j                  j                  ||d         }t!        t        j                  j#                  |            |d<   |j%                  | |d      S t        | fi |S # t        $ r- d}j                  d   }|du s|t
        j                  rd}Y bw xY w)a  
    Generates a URL to the given endpoint.

    If the endpoint is for a static resource then a URL to the CDN is
    generated, otherwise the call is passed on to `flask.url_for`.

    Because this function is set as a jinja environment variable when
    `CDN.init_app` is invoked, this function replaces `flask.url_for` in
    templates automatically. It is unlikely that this function will need to be
    directly called from within your application code, unless you need to refer
    to static assets outside of your templates.
    	CDN_DEBUGc                 ~    | j                   d   v ryj                   d   D ]  }| j                  d|z        s y y)NCDN_ENDPOINTSTz.%sF)configendswith)endpointxapps     L/home/azureuser/techstart-app/venv/lib/python3.12/site-packages/flask_cdn.pyendpoint_matchzurl_for.<locals>.endpoint_match   sI    szz/22O, 	A  +	     _schemehttp	CDN_HTTPSThttps
CDN_DOMAIN)
url_schemeCDN_TIMESTAMPfilenamet)valuesforce_external)r   r
   flask_url_forpopKeyErrorr   	is_securestatic_folder	blueprint
blueprintshas_static_folderurl_mapbindospathjoinintgetmtimebuild)	r   r   r   scheme	cdn_httpsr!   urlsr(   r   s	           @r   r   r      sm    C
zz+X000 h	!ZZ	*F )))!!S^^3w001CCNN7+<+<=KKM{{

< 8VL::o&77<<vj/ABDbgg..t45F3Kzz(6$zGG,V,,)  	!F

;/ID Y%67;L;L 		!s   E0 02F&%F&c                       e Zd ZdZddZd Zy)CDNa~  
    The CDN object allows your application to use Flask-CDN.

    When initialising a CDN object you may optionally provide your
    :class:`flask.Flask` application object if it is ready. Otherwise,
    you may provide it later by using the :meth:`init_app` method.

    :param app: optional :class:`flask.Flask` application object
    :type app: :class:`flask.Flask` or None
    Nc                 :    || _         || j                  |       yy)z
        An alternative way to pass your :class:`flask.Flask` application
        object to Flask-CDN. :meth:`init_app` also takes care of some
        default `settings`_.

        :param app: the :class:`flask.Flask` application object.
        N)r   init_app)selfr   s     r   __init__zCDN.__init__H   s!     ?MM# r   c                     d|j                   fdddddgfg}|D ]!  \  }}|j                  j                  ||       # |j                  d   rt        |j                  j
                  d<   y y )	Nr   )r   N)r   N)r   Tr	   staticr   r   )debugr
   
setdefaultr   	jinja_envglobals)r4   r   defaultskvs        r   r3   zCDN.init_appT   sx     #)),('+$xj1	3  	(DAqJJ!!!Q'	( ::l#/6CMM!!), $r   )N)__name__
__module____qualname____doc__r5   r3    r   r   r1   r1   =   s    	
7r   r1   )r'   flaskr   r   r   r   objectr1   rC   r   r   <module>rF      s     	 * &3-l"7& "7r   