Ë
    ±bjä  ã            	       óf   — d Z ddlmZ  G d„ de«      Zdededz  fd„Zdd	d
œdededz  deddfd„Zy)zEDetect Hudl permission / 403 Forbidden pages and raise a clear error.é    )ÚPagec                   óf   ‡ — e Zd ZdZ	 ddddddœdededz  dedz  dedz  d	ef
ˆ fd
„Zdefd„Zˆ xZS )ÚHudlForbiddenErrorz9Raised when Hudl returns the classic 403 permission page.NÚexchange©ÚdetailÚurlÚteam_idÚareaÚmessager   r	   r
   r   c                ó€   •— t         ‰| �  |«       d| _        |xs d| _        d| _        || _        || _        || _        y )Nú(You need permission to access this page.zÄEither you're not logged in or your current email isn't linked to this team. Try logging in or contact your coach to double-check permissions. If you continue to have trouble, hit up Hudl Support.zError 403 - Forbidden)ÚsuperÚ__init__Útitler   Úcoder	   r
   r   )Úselfr   r   r	   r
   r   Ú	__class__s         €úG/var/www/html/sergio/sergio-backend/app/automation/tasks/permissions.pyr   zHudlForbiddenError.__init__   sL   ø€ ô 	‰Ñ˜Ô!Ø?ˆŒ
Øò 
ðDð 	Œð
 ,ˆŒ	ØˆŒØˆŒØˆ�	ó    Úreturnc                 ó¨   — ddd| j                   | j                   | j                  | j                  | j                  | j                  | j
                  dœ
S )NÚ	forbiddeni“  )
ÚstatusÚerrorr   r   r   r   Ú
error_coder	   r
   r   )r   r   r   r	   r
   r   )r   s    r   Úas_dictzHudlForbiddenError.as_dict   sF   € à!Ø ØØ—Z‘ZØ—z‘zØ—k‘kØŸ)™)Ø—8‘8Ø—|‘|Ø—I‘Iñ
ð 	
r   )r   )	Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ústrr   Údictr   Ú__classcell__)r   s   @r   r   r      sl   ø„ ÙCð Bðð "ØØ"Øòàðð �d‘
ð	ð
 �4‰Zðð �t‘ðð õð*
˜÷ 
r   r   Úpager   Nc              ƒ   ód   K  — 	 | j                  d«      ƒ d{  –—† }|S 7 Œ# t        $ r Y yw xY w­w)z}
    Return forbidden payload if the current page is Hudl's 403 screen
    ("You need permission to access this page.").
    a.  () => {
              const title = (document.title || '').toLowerCase();
              const body = (document.body?.innerText || '');
              const h1 = (document.querySelector('h1')?.innerText || '').trim();
              const isForbidden =
                title.includes('forbidden') ||
                /you need permission to access this page/i.test(body) ||
                /error\s*403/i.test(body) ||
                /you need permission to access this page/i.test(h1);

              if (!isForbidden) return null;

              return {
                title: h1 || 'You need permission to access this page.',
                detail: body.includes("not logged in")
                  ? "Either you're not logged in or your current email isn't linked to this team. Try logging in or contact your coach to double-check permissions. If you continue to have trouble, hit up Hudl Support."
                  : (body.slice(0, 400) || null),
                error_code: 'Error 403 - Forbidden',
                url: location.href,
              };
            }N)ÚevaluateÚ	Exception)r%   Úinfos     r   Údetect_hudl_forbiddenr*   ,   sB   è ø€ ð
Ø—]‘]ðó
÷ 
ˆð. ˆð/
ùô0 ò Ùðüs(   ‚0„! ˜™! ž0Ÿ! ¡	-ª0¬-­0r   )r
   r   r
   r   c             ƒ   óØ   K  — t        | «      ƒ d{  –—† }|syt        |j                  d«      xs d|j                  d«      |j                  d«      xs | j                  ||¬«      ‚7 ŒV­w)zGRaise HudlForbiddenError when the headed browser is on Hudl's 403 page.Nr   r   r   r	   r   )r*   r   Úgetr	   )r%   r
   r   r)   s       r   Úraise_if_hudl_forbiddenr-   N   se   è ø€ ô ' tÓ,×,€DÙØÜ
Ø�‰�ÓÒGÐGØ�x‰x˜Ó!Ø�H‰H�U‹OÒ'˜tŸx™xØØôð ð -ús   ‚A*‘A(’AA*)	r!   Úplaywright.async_apir   ÚPermissionErrorr   r#   r*   r"   r-   © r   r   Ú<module>r1      sg   ðÙ KÝ %ô$
˜ô $
ðN dð ¨t°d©{ó ðJ Øò	Ø
ðð �4‰Zðð ð	ð
 
ôr   