§
    ¨Mºf]  ã                   óî   — d Z ddlmZmZ  G d„ d¦  «        Z G d„ d¦  «        Z G d„ d¦  «        Zg Z	 d	d
lm	Z
 ee
z  Zd	dlmZ ed„ eD ¦   «         z  Zn# e$ r
ZY dZ[ndZ[ww xY w G d„ d¦  «        ZdS )aÎ  
Django-plotly-dash middleware

This middleware enables the collection of items from templates for inclusion in the header and footer

Copyright (c) 2018 Gibbs Consulting and others - see CONTRIBUTIONS.md

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

é   )Úserve_locallyÚstatic_pathc                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )ÚEmbeddedHolderz7Hold details of embedded content from processing a viewc                 ó0   — d| _         d| _        d| _        d S ©NÚ )ÚcssÚconfigÚscripts©Úselfs    ú\/var/www/surfInsights/venv3-11/lib/python3.11/site-packages/django_plotly_dash/middleware.pyÚ__init__zEmbeddedHolder.__init__"   s   € ØˆŒØˆŒØˆŒˆˆó    c                 ó   — |r	|| _         dS dS )zAdd css contentN)r
   )r   r
   s     r   Úadd_csszEmbeddedHolder.add_css&   s   € àð 	ØˆDŒHˆHˆHð	ð 	r   c                 ó   — |r	|| _         dS dS )zAdd config contentN)r   )r   r   s     r   Ú
add_configzEmbeddedHolder.add_config*   s   € àð 	!Ø ˆDŒKˆKˆKð	!ð 	!r   c                 ó.   — |r| xj         |z  c_         dS dS )zAdd js contentN)r   )r   r   s     r   Úadd_scriptszEmbeddedHolder.add_scripts.   s(   € àð 	$ØˆLŒL˜GÑ#ˆLŒLˆLˆLð	$ð 	$r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r   © r   r   r   r       sV   € € € € € Ø=Ð=ðð ð ðð ð ð!ð !ð !ð$ð $ð $ð $ð $r   r   c                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )ÚContentCollectorzõ
    Collect content during view processing, and substitute in response by finding magic strings.

    This enables view functionality, such as template tags, to introduce content such as css and js
    inclusion into the header and footer.
    c                 óV   — d| _         d| _        t          ¦   «         | _        d| _        d S )NÚ%DJANGO_PLOTLY_DASH_HEADER_PLACEHOLDERÚ%DJANGO_PLOTLY_DASH_FOOTER_PLACEHOLDERúutf-8)Úheader_placeholderÚfooter_placeholderr   Úembedded_holderÚ	_encodingr   s    r   r   zContentCollector.__init__:   s+   € Ø"IˆÔØ"IˆÔå-Ñ/Ô/ˆÔØ ˆŒˆˆr   c                 ó  — 	 |                       |j        | j        | j        j        ¦  «        }|                       || j        d                     | j        j        | j        j        g¦  «        ¦  «        |_        n# t          $ r Y nw xY w|S )z9Locate placeholder magic strings and replace with contentú
)
Ú_replaceÚcontentr#   r%   r
   r$   Újoinr   r   ÚAttributeError)r   ÚresponseÚc1s      r   Úadjust_responsez ContentCollector.adjust_responseA   s¦   € ð	Ø—’˜xÔ/Ø#Ô6Ø#Ô3Ô7ñ9ô 9ˆBð  $Ÿ}š}¨RØ-1Ô-DØ-1¯YªY¸Ô8LÔ8SØ8<Ô8LÔ8Tð8Vñ .Wô .Wñ Xô  XˆHÔÐøõ ð 	ð 	ð 	àˆDð	øøøð ˆs   ‚A5A8 Á8
BÂBc                 ó‚   — |                      |                      |¦  «        |                      |r|nd¦  «        ¦  «        S r   )ÚreplaceÚ_encode)r   r*   ÚplaceholderÚsubstitutions       r   r)   zContentCollector._replaceS   sA   € Ø�Š˜tŸ|š|¨KÑ8Ô8Ø#Ÿ|š|¸LÐ,P¨L¨LÈbÑQÔQñSô Sð 	Sr   c                 ó6   — |                      | j        ¦  «        S ©N©Úencoder&   ©r   Ústrings     r   r2   zContentCollector._encodeW   ó   € Ø�}Š}˜Tœ^Ñ,Ô,Ð,r   N)r   r   r   r   r   r/   r)   r2   r   r   r   r   r   3   s]   € € € € € ðð ð!ð !ð !ðð ð ð$Sð Sð Sð-ð -ð -ð -ð -r   r   c                   ó   — e Zd ZdZd„ Zd„ ZdS )ÚBaseMiddlewarezDjango-plotly-dash middlewarec                 ó   — || _         d S r6   )Úget_response)r   r?   s     r   r   zBaseMiddleware.__init__]   s   € Ø(ˆÔÐÐr   c                 óŠ   — t          ¦   «         |_        |                      |¦  «        }|j                             |¦  «        }|S r6   )r   Údpd_content_handlerr?   r/   )r   Úrequestr-   s      r   Ú__call__zBaseMiddleware.__call__`   s>   € å&6Ñ&8Ô&8ˆÔ#Ø×$Ò$ WÑ-Ô-ˆØÔ.×>Ò>¸xÑHÔHˆàˆr   N)r   r   r   r   r   rC   r   r   r   r=   r=   Z   s8   € € € € € Ø#Ð#ð)ð )ð )ðð ð ð ð r   r=   é    )Úsubstitutions)Ústatic_substitutionsc                 ó6   — g | ]\  }}|t          |¦  «        f‘ŒS r   )r   )Ú.0ÚxÚys      r   ú
<listcomp>rK   o   s'   € ÐOÐOÐO±$°!°Q˜1�k¨!™nœnÐ-ÐOÐOÐOr   Nc                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚExternalRedirectionMiddlewarezHMiddleware to force redirection in third-party content through rewritingc                 ó~   ‡ — |‰ _         g }t          ¦   «         r
|t          z  }d‰ _        ˆ fd„|D ¦   «         ‰ _        d S )Nr"   c                 ój   •— g | ]/\  }}‰                      |¦  «        ‰                      |¦  «        f‘Œ0S r   )r2   )rH   ÚsourceÚtargetr   s      €r   rK   z:ExternalRedirectionMiddleware.__init__.<locals>.<listcomp>�   sS   ø€ ð Zð Zð ZÙ9G¸Àð  $Ÿ|š|¨FÑ3Ô3Ø#Ÿ|š|¨FÑ3Ô3ð5ð Zð Zð Zr   )r?   r   Údpd_substitutionsr&   rE   )r   r?   rE   s   `  r   r   z&ExternalRedirectionMiddleware.__init__w   sf   ø€ Ø(ˆÔàˆå‰?Œ?ð 	/ØÕ.Ñ.ˆMà ˆŒðZð Zð Zð ZØKXðZñ Zô ZˆÔÐÐr   c                 ó¶   — |                       |¦  «        }	 |j        }| j        D ]\  }}|                     ||¦  «        }Œ||_        n# t          $ r Y nw xY w|S r6   )r?   r*   rE   r1   r,   )r   rB   r-   r*   rP   rQ   s         r   rC   z&ExternalRedirectionMiddleware.__call__„   s   € à×$Ò$ WÑ-Ô-ˆð
	ØÔ&ˆGà"&Ô"4ð :ð :‘�˜Ø!Ÿ/š/¨&°&Ñ9Ô9��à&ˆHÔÐøåð 	ð 	ð 	àˆDð	øøøð ˆs   —1A	 Á	
AÁAc                 ó6   — |                      | j        ¦  «        S r6   r7   r9   s     r   r2   z%ExternalRedirectionMiddleware._encode–   r;   r   N)r   r   r   r   r   rC   r2   r   r   r   rM   rM   t   sJ   € € € € € ØNÐNðZð Zð Zðð ð ð$-ð -ð -ð -ð -r   rM   )r   Úutilr   r   r   r   r=   rR   Údpd_static_support.mappingsrE   Údpd_direct_substitutionsrF   Údpd_ss_substitutionsÚ	ExceptionÚerM   r   r   r   ú<module>r[      sY  ððð ð6 -Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,Ð ,ð$ð $ð $ð $ð $ñ $ô $ð $ð&%-ð %-ð %-ð %-ð %-ñ %-ô %-ð %-ðNð ð ð ð ñ ô ð ð  Ð ð	ØUÐUÐUÐUÐUÐUØÐ1Ñ1ÐØXÐXÐXÐXÐXÐXØÐOÐOÐ:NÐOÑOÔOÑOÐÐøØð 	ð 	ð 	Ø€D€D€D€Døøøøð	øøøð#-ð #-ð #-ð #-ð #-ñ #-ô #-ð #-ð #-ð #-s   µ A ÁA%Á A%