Ë
    Fü´jN9  ã                  óT   — d Z ddlmZ ddlmZmZ ddlmZ erddlm	Z	  G d„ d«      Z
y)	z&Provide the SubredditStylesheet class.é    )Úannotations)ÚTYPE_CHECKINGÚAny)ÚAPI_PATH)Úmodelsc                  óÆ   — e Zd ZdZdd„Zdd„Zdd„Zdd„Zdd„Zdd„Z	dd„Z
dd	„Zdd
„Zdd„Zdd„Zddœdd„Zdd„Zd d„Zddœ	 	 	 	 	 d!d„Zd d„Zd"d„Zd d„Zd"d„Zd"d„Zy)#ÚSubredditStylesheeta„  Provides a set of stylesheet functions to a :class:`.Subreddit`.

    For example, to add the css data ``.test{color:blue}`` to the existing stylesheet:

    .. code-block:: python

        subreddit = reddit.subreddit("test")
        stylesheet = subreddit.stylesheet()
        stylesheet.stylesheet += ".test{color:blue}"
        subreddit.stylesheet.update(stylesheet.stylesheet)

    c                ó’   — t         d   j                  | j                  ¬«      }| j                  j                  j	                  |«      S )z®Return the :class:`.Subreddit`'s stylesheet.

        To be used as:

        .. code-block:: python

            stylesheet = reddit.subreddit("test").stylesheet()

        Úabout_stylesheet©Ú	subreddit)r   Úformatr   Ú_redditÚget©ÚselfÚurls     úe/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/reddit/subreddit/stylesheet.pyÚ__call__zSubredditStylesheet.__call__   s<   € ô Ð)Ñ*×1Ñ1¸D¿N¹NÐ1ÓKˆØ�~‰~×%Ñ%×)Ñ)¨#Ó.Ð.ó    c                ó   — || _         y)a  Initialize a :class:`.SubredditStylesheet` instance.

        :param subreddit: The :class:`.Subreddit` associated with the stylesheet.

        An instance of this class is provided as:

        .. code-block:: python

            reddit.subreddit("test").stylesheet

        Nr   )r   r   s     r   Ú__init__zSubredditStylesheet.__init__(   s   € ð #ˆ�r   c                ó˜   — t         d   j                  | j                  ¬«      }| j                  j                  j	                  ||¬«       y )NÚstructured_stylesr   ©Údata)r   r   r   r   Úpatch)r   Ú
style_datar   s      r   Ú_update_structured_stylesz-SubredditStylesheet._update_structured_styles6   s<   € ÜÐ*Ñ+×2Ñ2¸T¿^¹^Ð2ÓLˆØ�‰×Ñ×$Ñ$ S¨zÐ$Õ:r   c                ó.   — ddi}| j                  |«       y)zôRemove the current :class:`.Subreddit` (redesign) banner image.

        Succeeds even if there is no banner image.

        For example:

        .. code-block:: python

            reddit.subreddit("test").stylesheet.delete_banner()

        ÚbannerBackgroundImageÚ N©r   ©r   r   s     r   Údelete_bannerz!SubredditStylesheet.delete_banner:   s   € ð (¨Ð,ˆØ×&Ñ& tÕ,r   c                ó0   — dddœ}| j                  |«       y)aI  Remove the current :class:`.Subreddit` (redesign) banner additional image.

        Succeeds even if there is no additional image. Will also delete any configured
        hover image.

        For example:

        .. code-block:: python

            reddit.subreddit("test").stylesheet.delete_banner_additional_image()

        r"   )ÚbannerPositionedImageÚsecondaryBannerPositionedImageNr#   r$   s     r   Údelete_banner_additional_imagez2SubredditStylesheet.delete_banner_additional_imageI   s   € ð *,ÈrÑRˆØ×&Ñ& tÕ,r   c                ó.   — ddi}| j                  |«       y)a  Remove the current :class:`.Subreddit` (redesign) banner hover image.

        Succeeds even if there is no hover image.

        For example:

        .. code-block:: python

            reddit.subreddit("test").stylesheet.delete_banner_hover_image()

        r(   r"   Nr#   r$   s     r   Údelete_banner_hover_imagez-SubredditStylesheet.delete_banner_hover_imageY   s   € ð 1°"Ð5ˆØ×&Ñ& tÕ,r   c                ó”   — t         d   j                  | j                  ¬«      }| j                  j                  j	                  |«       y)zéRemove the current :class:`.Subreddit` header image.

        Succeeds even if there is no header image.

        For example:

        .. code-block:: python

            reddit.subreddit("test").stylesheet.delete_header()

        Údelete_sr_headerr   N©r   r   r   r   Úpostr   s     r   Údelete_headerz!SubredditStylesheet.delete_headerh   ó9   € ô Ð)Ñ*×1Ñ1¸D¿N¹NÐ1ÓKˆØ�‰×Ñ×#Ñ# CÕ(r   c                óœ   — t         d   j                  | j                  ¬«      }| j                  j                  j	                  |d|i¬«       y)zõRemove the named image from the :class:`.Subreddit`.

        Succeeds even if the named image does not exist.

        For example:

        .. code-block:: python

            reddit.subreddit("test").stylesheet.delete_image("smile")

        Údelete_sr_imager   Úimg_namer   Nr.   )r   Únamer   s      r   Údelete_imagez SubredditStylesheet.delete_imagew   sC   € ô Ð(Ñ)×0Ñ0¸4¿>¹>Ð0ÓJˆØ�‰×Ñ×#Ñ# C¨z¸4Ð.@Ð#ÕAr   c                ó.   — ddi}| j                  |«       y)a$  Remove the current :class:`.Subreddit` (redesign) mobile banner.

        Succeeds even if there is no mobile banner.

        For example:

        .. code-block:: python

            subreddit = reddit.subreddit("test")
            subreddit.stylesheet.delete_banner_hover_image()

        ÚmobileBannerImager"   Nr#   r$   s     r   Údelete_mobile_bannerz(SubredditStylesheet.delete_mobile_banner†   s   € ð $ RÐ(ˆØ×&Ñ& tÕ,r   c                ó”   — t         d   j                  | j                  ¬«      }| j                  j                  j	                  |«       y)zòRemove the current :class:`.Subreddit` mobile header.

        Succeeds even if there is no mobile header.

        For example:

        .. code-block:: python

            reddit.subreddit("test").stylesheet.delete_mobile_header()

        r-   r   Nr.   r   s     r   Údelete_mobile_headerz(SubredditStylesheet.delete_mobile_header–   r1   r   c                ó”   — t         d   j                  | j                  ¬«      }| j                  j                  j	                  |«       y)zìRemove the current :class:`.Subreddit` mobile icon.

        Succeeds even if there is no mobile icon.

        For example:

        .. code-block:: python

            reddit.subreddit("test").stylesheet.delete_mobile_icon()

        Údelete_sr_iconr   Nr.   r   s     r   Údelete_mobile_iconz&SubredditStylesheet.delete_mobile_icon¥   s9   € ô Ð'Ñ(×/Ñ/¸$¿.¹.Ð/ÓIˆØ�‰×Ñ×#Ñ# CÕ(r   N)Úreasonc               ó¤   — d||dœ}t         d   j                  | j                  ¬«      }| j                  j                  j	                  ||¬«       y)ao  Update the :class:`.Subreddit`'s stylesheet.

        :param stylesheet: The CSS for the new stylesheet.
        :param reason: The reason for updating the stylesheet.

        For example:

        .. code-block:: python

            reddit.subreddit("test").stylesheet.update(
                "p { color: green; }", reason="color text green"
            )

        Úsave)Úopr?   Ústylesheet_contentsÚsubreddit_stylesheetr   r   Nr.   )r   Ú
stylesheetr?   r   r   s        r   ÚupdatezSubredditStylesheet.update´   sJ   € ð ¨ÀzÑRˆÜÐ-Ñ.×5Ñ5ÀÇÁÐ5ÓOˆØ�‰×Ñ×#Ñ# C¨dÐ#Õ3r   c              ó>   — |j                  | j                  |d¬«      S )a£  Upload an image to the :class:`.Subreddit`.

        :param media: The :class:`.StylesheetImage` to upload.
        :param name: The name to use for the image. If an image already exists with the
            same name, it will be replaced.

        :returns: A dictionary containing a link to the uploaded image under the key
            ``img_src``.

        :raises: ``prawcore.TooLarge`` if the overall request body is too large.
        :raises: :class:`.RedditAPIException` if there are other issues with the
            uploaded image. Unfortunately the exception info might not be very specific,
            so try through the website with the same image to see what the problem
            actually might be.

        For example:

        .. code-block:: python

            from praw.models import StylesheetImage

            reddit.subreddit("test").stylesheet.upload(StylesheetImage("img.png"), name="smile")

        Úimg)r5   Úupload_type©Ú_uploadr   )r   Úmediar5   s      r   ÚuploadzSubredditStylesheet.uploadÇ   s   € ð2 �}‰}˜TŸ^™^°$ÀEˆ}ÓJÐJr   c               óh   — d}|j                  | j                  |¬«      }| j                  ||i«       y)aÇ  Upload an image for the :class:`.Subreddit`'s (redesign) banner image.

        :param media: The :class:`.StylesheetAsset` to upload.

        :raises: ``prawcore.TooLarge`` if the overall request body is too large.
        :raises: :class:`.RedditAPIException` if there are other issues with the
            uploaded image. Unfortunately the exception info might not be very specific,
            so try through the website with the same image to see what the problem
            actually might be.

        For example:

        .. code-block:: python

            from praw.models import StylesheetAsset

            reddit.subreddit("test").stylesheet.upload_banner(StylesheetAsset("banner.png"))

        r!   ©Ú
image_typeN©rK   r   r   ©r   rL   rP   Ú	image_urls       r   Úupload_bannerz!SubredditStylesheet.upload_bannerâ   s2   € ð( -ˆ
Ø—M‘M $§.¡.¸Z�MÓHˆ	Ø×&Ñ&¨
°IÐ'>Õ?r   )Úalignc              óÆ   — i }|�|dvrd}t        |«      ‚||d<   d}|j                  | j                  |¬«      }||i}|r|j                  |«       | j	                  |«       y)aj  Upload an image for the :class:`.Subreddit`'s (redesign) additional image.

        :param media: The :class:`.StylesheetAsset` to upload.
        :param align: Either ``"left"``, ``"centered"``, or ``"right"``. (default:
            ``"left"``).

        :raises: ``prawcore.TooLarge`` if the overall request body is too large.
        :raises: :class:`.RedditAPIException` if there are other issues with the
            uploaded image. Unfortunately the exception info might not be very specific,
            so try through the website with the same image to see what the problem
            actually might be.

        For example:

        .. code-block:: python

            from praw.models import StylesheetAsset

            subreddit = reddit.subreddit("test")
            subreddit.stylesheet.upload_banner_additional_image(StylesheetAsset("banner.png"))

        N>   ÚleftÚrightÚcenteredz>'align' argument must be either 'left', 'centered', or 'right'ÚbannerPositionedImagePositionr'   rO   )Ú
ValueErrorrK   r   rF   r   )r   rL   rU   Ú	alignmentÚmsgrP   rS   r   s           r   Úupload_banner_additional_imagez2SubredditStylesheet.upload_banner_additional_imageú   sv   € ð: ˆ	ØÐØÐ9Ñ9ØV�Ü  “oÐ%Ø9>ˆIÐ5Ñ6à,ˆ
Ø—M‘M $§.¡.¸Z�MÓHˆ	Ø  )Ð,ˆ
ÙØ×Ñ˜iÔ(Ø×&Ñ& zÕ2r   c               óh   — d}|j                  | j                  |¬«      }| j                  ||i«       y)aN  Upload an image for the :class:`.Subreddit`'s (redesign) additional image.

        :param media: The :class:`.StylesheetAsset` to upload.

        Fails if the :class:`.Subreddit` does not have an additional image defined.

        :raises: ``prawcore.TooLarge`` if the overall request body is too large.
        :raises: :class:`.RedditAPIException` if there are other issues with the
            uploaded image. Unfortunately the exception info might not be very specific,
            so try through the website with the same image to see what the problem
            actually might be.

        For example:

        .. code-block:: python

            from praw.models import StylesheetAsset

            subreddit = reddit.subreddit("test")
            subreddit.stylesheet.upload_banner_hover_image(StylesheetAsset("banner.png"))

        r(   rO   NrQ   rR   s       r   Úupload_banner_hover_imagez-SubredditStylesheet.upload_banner_hover_image%  s2   € ð. 6ˆ
Ø—M‘M $§.¡.¸Z�MÓHˆ	Ø×&Ñ&¨
°IÐ'>Õ?r   c               ó<   — |j                  | j                  d¬«      S )a5  Upload an image to be used as the :class:`.Subreddit`'s header image.

        :param media: The :class:`.StylesheetImage` to upload.

        :returns: A dictionary containing a link to the uploaded image under the key
            ``img_src``.

        :raises: ``prawcore.TooLarge`` if the overall request body is too large.
        :raises: :class:`.RedditAPIException` if there are other issues with the
            uploaded image. Unfortunately the exception info might not be very specific,
            so try through the website with the same image to see what the problem
            actually might be.

        For example:

        .. code-block:: python

            from praw.models import StylesheetImage

            reddit.subreddit("test").stylesheet.upload_header(StylesheetImage("header.png"))

        Úheader©rI   rJ   ©r   rL   s     r   Úupload_headerz!SubredditStylesheet.upload_header@  ó   € ð. �}‰}˜TŸ^™^¸ˆ}ÓBÐBr   c               óh   — d}|j                  | j                  |¬«      }| j                  ||i«       y)aF  Upload an image for the :class:`.Subreddit`'s (redesign) mobile banner.

        :param media: The :class:`.StylesheetAsset` to upload.

        For example:

        .. code-block:: python

            from praw.models import StylesheetAsset

            subreddit = reddit.subreddit("test")
            subreddit.stylesheet.upload_mobile_banner(StylesheetAsset("banner.png"))

        Fails if the :class:`.Subreddit` does not have an additional image defined.

        :raises: ``prawcore.TooLarge`` if the overall request body is too large.
        :raises: :class:`.RedditAPIException` if there are other issues with the
            uploaded image. Unfortunately the exception info might not be very specific,
            so try through the website with the same image to see what the problem
            actually might be.

        r8   rO   NrQ   rR   s       r   Úupload_mobile_bannerz(SubredditStylesheet.upload_mobile_bannerY  s2   € ð. )ˆ
Ø—M‘M $§.¡.¸Z�MÓHˆ	Ø×&Ñ&¨
°IÐ'>Õ?r   c               ó<   — |j                  | j                  d¬«      S )a=  Upload an image to be used as the :class:`.Subreddit`'s mobile header.

        :param media: The :class:`.StylesheetImage` to upload.

        :returns: A dictionary containing a link to the uploaded image under the key
            ``img_src``.

        :raises: ``prawcore.TooLarge`` if the overall request body is too large.
        :raises: :class:`.RedditAPIException` if there are other issues with the
            uploaded image. Unfortunately the exception info might not be very specific,
            so try through the website with the same image to see what the problem
            actually might be.

        For example:

        .. code-block:: python

            from praw.models import StylesheetImage

            reddit.subreddit("test").stylesheet.upload_mobile_header(StylesheetImage("header.png"))

        Úbannerrc   rJ   rd   s     r   Úupload_mobile_headerz(SubredditStylesheet.upload_mobile_headert  rf   r   c               ó<   — |j                  | j                  d¬«      S )a7  Upload an image to be used as the :class:`.Subreddit`'s mobile icon.

        :param media: The :class:`.StylesheetImage` to upload.

        :returns: A dictionary containing a link to the uploaded image under the key
            ``img_src``.

        :raises: ``prawcore.TooLarge`` if the overall request body is too large.
        :raises: :class:`.RedditAPIException` if there are other issues with the
            uploaded image. Unfortunately the exception info might not be very specific,
            so try through the website with the same image to see what the problem
            actually might be.

        For example:

        .. code-block:: python

            from praw.models import StylesheetImage

            reddit.subreddit("test").stylesheet.upload_mobile_icon(StylesheetImage("icon.png"))

        Úiconrc   rJ   rd   s     r   Úupload_mobile_iconz&SubredditStylesheet.upload_mobile_icon�  s   € ð. �}‰}˜TŸ^™^¸ˆ}Ó@Ð@r   )Úreturnzmodels.Stylesheet)r   zmodels.Subredditro   ÚNone)r   zdict[str, str | Any]ro   rp   )ro   rp   )r5   Ústrro   rp   )rE   rq   r?   ú
str | Nonero   rp   )rL   úmodels.StylesheetImager5   rq   ro   údict[str, str])rL   úmodels.StylesheetAssetro   rp   )rL   ru   rU   rr   ro   rp   )rL   rs   ro   rt   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   r   r%   r)   r+   r0   r6   r9   r;   r>   rF   rM   rT   r^   r`   re   rh   rk   rn   © r   r   r	   r	      s›   „ ñó/ó#ó;ó-ó-ó -ó)óBó-ó )ó)ð ?Cõ 4ó&Kó6@ð: !ñ)3à%ð)3ð
 ð)3ð 
ó)3óV@ó6Có2@ó6Cô2Ar   r	   N)ry   Ú
__future__r   Útypingr   r   Ú
praw.constr   Úprawr   r	   rz   r   r   ú<module>r      s%   ðÙ ,å "ç %å áÝ÷WAò WAr   