Ë
    Fü´jPý  ã                  ó¬  — d Z ddlmZ ddlmZmZ ddlmZmZ ddl	m
Z
 ddlmZmZ ddlmZ ddlmZ er
dd	lZdd
lmZ  G d„ dee«      Z G d„ dee«      Z G d„ dee«      Z G d„ dee«      Z G d„ dee«      Z G d„ dee«      Z G d„ dee«      Z G d„ dee«      Z G d„ de«      Z G d„ d«      Z G d„ d ee«      Z G d!„ d"ee«      Z G d#„ d$e«      Z  G d%„ d&ee«      Z! G d'„ d(e«      Z" G d)„ d*e«      Z# G d+„ d,ee«      Z$ G d-„ d.ee«      Z% G d/„ d0ee«      Z& G d1„ d2ee«      Z' G d3„ d4ee«      Z( G d5„ d6e«      Z) G d7„ d8e«      Z* G d9„ d:«      Z+y	);z#Provide classes related to widgets.é    )Úannotations)ÚJSONEncoderÚdumps)ÚTYPE_CHECKINGÚAny)ÚAPI_PATH)ÚDynamicAttributesÚPRAWBase)ÚBaseList)ÚcachedpropertyN)Úmodelsc                  ó   — e Zd ZdZy)ÚButtona  Class to represent a single button inside a :class:`.ButtonWidget`.

    .. include:: ../../typical_attributes.rst

    ============== =====================================================================
    Attribute      Description
    ============== =====================================================================
    ``color``      The hex color used to outline the button.
    ``fillColor``  The hex color for the background of the button.
    ``height``     Image height. Only present on image buttons.
    ``hoverState`` A ``dict`` describing the state of the button when hovered over.
                   Optional.
    ``kind``       Either ``"text"`` or ``"image"``.
    ``linkUrl``    A link that can be visited by clicking the button. Only present on
                   image buttons.
    ``text``       The text displayed on the button.
    ``textColor``  The hex color for the text of the button.
    ``url``        - If the button is a text button, a link that can be visited by
                     clicking the button.
                   - If the button is an image button, the URL of a Reddit-hosted image.
    ``width``      Image width. Only present on image buttons.
    ============== =====================================================================

    N©Ú__name__Ú
__module__Ú__qualname__Ú__doc__© ó    úX/root/workspace/ytshorts/venv/lib/python3.12/site-packages/praw/models/reddit/widgets.pyr   r      s   „ òr   r   c                  ó   — e Zd ZdZy)ÚCalendarConfigurationaø  Class to represent the configuration of a :class:`.Calendar`.

    .. include:: ../../typical_attributes.rst

    =================== ================================================
    Attribute           Description
    =================== ================================================
    ``numEvents``       The number of events to display on the calendar.
    ``showDate``        Whether to show the dates of events.
    ``showDescription`` Whether to show the descriptions of events.
    ``showLocation``    Whether to show the locations of events.
    ``showTime``        Whether to show the times of events.
    ``showTitle``       Whether to show the titles of events.
    =================== ================================================

    Nr   r   r   r   r   r   -   s   „ òr   r   c                  ó   — e Zd ZdZy)ÚHoveraŒ  Class to represent the hover data for a :class:`.ButtonWidget`.

    These values will take effect when the button is hovered over (the user moves their
    cursor so it's on top of the button).

    .. include:: ../../typical_attributes.rst

    ============= =====================================================================
    Attribute     Description
    ============= =====================================================================
    ``color``     The hex color used to outline the button.
    ``fillColor`` The hex color for the background of the button.
    ``textColor`` The hex color for the text of the button.
    ``height``    Image height. Only present on image buttons.
    ``kind``      Either ``text`` or ``image``.
    ``text``      The text displayed on the button.
    ``url``       - If the button is a text button, a link that can be visited by
                    clicking the button.
                  - If the button is an image button, the URL of a Reddit-hosted image.
    ``width``     Image width. Only present on image buttons.
    ============= =====================================================================

    Nr   r   r   r   r   r   @   s   „ òr   r   c                  ó   — e Zd ZdZy)ÚImagea  Class to represent an image that's part of a :class:`.ImageWidget`.

    .. include:: ../../typical_attributes.rst

    =========== =================================================
    Attribute   Description
    =========== =================================================
    ``height``  Image height.
    ``linkUrl`` A link that can be visited by clicking the image.
    ``url``     The URL of the (Reddit-hosted) image.
    ``width``   Image width.
    =========== =================================================

    Nr   r   r   r   r   r   Z   ó   „ òr   r   c                  ó   — e Zd ZdZy)Ú	ImageDataaÒ  Class for image data that's part of a :class:`.CustomWidget`.

    .. include:: ../../typical_attributes.rst

    ========== =========================================
    Attribute  Description
    ========== =========================================
    ``height`` The image height.
    ``name``   The image name.
    ``url``    The URL of the image on Reddit's servers.
    ``width``  The image width.
    ========== =========================================

    Nr   r   r   r   r    r    k   r   r   r    c                  ó   — e Zd ZdZy)ÚMenuLinka“  Class to represent a single link inside a :class:`.Menu` or :class:`.Submenu`.

    .. include:: ../../typical_attributes.rst

    ========= ====================================
    Attribute Description
    ========= ====================================
    ``text``  The text of the menu link.
    ``url``   The URL that the menu item links to.
    ========= ====================================

    Nr   r   r   r   r"   r"   |   s   „ òr   r"   c                  ó   — e Zd ZdZy)ÚStylesap  Class to represent the style information of a widget.

    .. include:: ../../typical_attributes.rst

    =================== ========================================================
    Attribute           Description
    =================== ========================================================
    ``backgroundColor`` The background color of a widget, given as a hexadecimal
                        (``0x######``).
    ``headerColor``     The header color of a widget, given as a hexadecimal
                        (``0x######``).
    =================== ========================================================

    Nr   r   r   r   r$   r$   ‹   r   r   r$   c                  ó   — e Zd ZdZdZy)ÚSubmenuaŽ  Class to represent a submenu of links inside a :class:`.Menu`.

    .. include:: ../../typical_attributes.rst

    ============ ======================================================================
    Attribute    Description
    ============ ======================================================================
    ``children`` A list of the :class:`.MenuLink`\ s in this submenu. Can be iterated
                 over by iterating over the :class:`.Submenu` (e.g., ``for menu_link in
                 submenu``).
    ``text``     The name of the submenu.
    ============ ======================================================================

    ÚchildrenN©r   r   r   r   ÚCHILD_ATTRIBUTEr   r   r   r&   r&   œ   s   „ ñð !�Or   r&   c                  ó´   ‡ — e Zd ZdZedd„«       Zedd„«       Zedd„«       Zedd„«       Zedd„«       Z	edd„«       Z
dd„Zdˆ fd	„Zdd
„Zdˆ fd„Zdd„Zˆ xZS )ÚSubredditWidgetsaœ	  Class to represent a :class:`.Subreddit`'s widgets.

    Create an instance like so:

    .. code-block:: python

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

    Data will be lazy-loaded. By default, PRAW will not request progressively loading
    images from Reddit. To enable this, instantiate a :class:`.SubredditWidgets` object
    via :meth:`~.Subreddit.widgets`, then set the attribute ``progressive_images`` to
    ``True`` before performing any action that would result in a network request.

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        widgets.progressive_images = True
        for widget in widgets.sidebar:
            # do something
            ...

    Access a :class:`.Subreddit`'s widgets with the following attributes:

    .. code-block:: python

        print(widgets.id_card)
        print(widgets.moderators_widget)
        print(widgets.sidebar)
        print(widgets.topbar)

    The attribute :attr:`.id_card` contains the :class:`.Subreddit`'s ID card, which
    displays information like the number of subscribers.

    The attribute :attr:`.moderators_widget` contains the :class:`.Subreddit`'s
    moderators widget, which lists the moderators of the subreddit.

    The attribute :attr:`.sidebar` contains a list of widgets which make up the sidebar
    of the subreddit.

    The attribute :attr:`.topbar` contains a list of widgets which make up the top bar
    of the subreddit.

    To edit a :class:`.Subreddit`'s widgets, use :attr:`~.SubredditWidgets.mod`. For
    example:

    .. code-block:: python

        widgets.mod.add_text_area(
            short_name="My title",
            text="**bold text**",
            styles={"backgroundColor": "#FFFF66", "headerColor": "#3333EE"},
        )

    For more information, see :class:`.SubredditWidgetsModeration`.

    To edit a particular widget, use ``.mod`` on the widget. For example:

    .. code-block:: python

        for widget in widgets.sidebar:
            widget.mod.update(shortName="Exciting new name")

    For more information, see :class:`.WidgetModeration`.

    **Currently available widgets**:

    - :class:`.ButtonWidget`
    - :class:`.Calendar`
    - :class:`.CommunityList`
    - :class:`.CustomWidget`
    - :class:`.IDCard`
    - :class:`.ImageWidget`
    - :class:`.Menu`
    - :class:`.ModeratorsWidget`
    - :class:`.PostFlairWidget`
    - :class:`.RulesWidget`
    - :class:`.TextArea`

    c                ó:   — | j                   | j                  d      S )z7Get this :class:`.Subreddit`'s :class:`.IDCard` widget.ÚidCardWidget©ÚitemsÚlayout©Úselfs    r   Úid_cardzSubredditWidgets.id_card   s   € ð �z‰z˜$Ÿ+™+ nÑ5Ñ6Ð6r   c                ó¾   — i }| j                   j                  «       D ]=  \  }}| j                  |d<   | j                  j                  j                  |¬«      ||<   Œ? |S )zCGet this :class:`.Subreddit`'s widgets as a dict from ID to widget.Ú	subreddit©Údata)Ú
_raw_itemsr/   r5   Ú_redditÚ	_objectorÚ	objectify)r2   r/   Ú	item_namer7   s       r   r/   zSubredditWidgets.items  si   € ð ˆð �_‰_×"Ñ"Ó$ò	Kñ 
ØØà $§¡ˆD�ÑØ#Ÿ|™|×5Ñ5×?Ñ?ÀTÐ?ÓJˆE�)Òð	Kð ˆr   c                óB   — t        | j                  | j                  «      S )a0  Get an instance of :class:`.SubredditWidgetsModeration`.

        .. note::

            Using any of the methods of :class:`.SubredditWidgetsModeration` will likely
            result in the data of this :class:`.SubredditWidgets` being outdated. To
            re-sync, call :meth:`.refresh`.

        )ÚSubredditWidgetsModerationr5   r9   r1   s    r   ÚmodzSubredditWidgets.mod  s   € ô *¨$¯.©.¸$¿,¹,ÓGÐGr   c                ó:   — | j                   | j                  d      S )z:Get this :class:`.Subreddit`'s :class:`.ModeratorsWidget`.ÚmoderatorWidgetr.   r1   s    r   Úmoderators_widgetz"SubredditWidgets.moderators_widget   s   € ð �z‰z˜$Ÿ+™+Ð&7Ñ8Ñ9Ð9r   c                óf   — | j                   d   d   D �cg c]  }| j                  |   ‘Œ c}S c c}w )z;Get a list of :class:`.Widget`\ s that make up the sidebar.ÚsidebarÚorder©r0   r/   ©r2   Úwidget_names     r   rD   zSubredditWidgets.sidebar%  s1   € ð <@¿;¹;ÀyÑ;QÐRYÑ;ZÖ[¨K�—
‘
˜;Ó'Ò[Ð[ùÒ[ó   •.c                óf   — | j                   d   d   D �cg c]  }| j                  |   ‘Œ c}S c c}w )z;Get a list of :class:`.Widget`\ s that make up the top bar.ÚtopbarrE   rF   rG   s     r   rK   zSubredditWidgets.topbar*  s1   € ð <@¿;¹;ÀxÑ;PÐQXÑ;YÖZ¨K�—
‘
˜;Ó'ÒZÐZùÒZrI   c                óÀ   — |j                  d«      s(| j                  s| j                  «        t        | |«      S | j                  j
                  ›d|›�}t        |«      ‚)zReturn the value of ``attr``.Ú_z object has no attribute )Ú
startswithÚ_fetchedÚ_fetchÚgetattrÚ	__class__r   ÚAttributeError)r2   ÚattrÚmsgs      r   Ú__getattr__zSubredditWidgets.__getattr__/  sQ   € à�‰˜sÔ#¨D¯MªMØ�K‰KŒMÜ˜4 Ó&Ð&Ø—‘×(Ñ(Ð+Ð+DÀTÀHÐMˆÜ˜SÓ!Ð!r   c                ór   •— d| _         d| _        || _        d| _        t        ‰| �  |j                  i «       y)z…Initialize a :class:`.SubredditWidgets` instance.

        :param subreddit: The :class:`.Subreddit` the widgets belong to.

        NF)r8   rO   r5   Úprogressive_imagesÚsuperÚ__init__r9   )r2   r5   rR   s     €r   rZ   zSubredditWidgets.__init__7  s7   ø€ ð 26ˆŒØˆŒØ"ˆŒØ"'ˆÔä‰Ñ˜×*Ñ*¨BÕ/r   c                ó"   — d| j                   ›d�S )z?Return an object initialization representation of the instance.zSubredditWidgets(subreddit=ú)©r5   r1   s    r   Ú__repr__zSubredditWidgets.__repr__D  s   € à,¨T¯^©^Ð,>¸aÐ@Ð@r   c                óp  •— | j                   j                  t        d   j                  | j                  ¬«      d| j
                  i¬«      }|j                  d«      | _        t        ‰| �%  | j                  j                   |«       g d¢}| j                  j                  }|D ]  } ||d «       Œ d| _        y )NÚwidgetsr]   rX   )Úparamsr/   )r3   rB   rD   rK   r/   T)r9   Úgetr   Úformatr5   rX   Úpopr8   rY   rZ   Ú__dict__rO   )r2   r7   Úcached_property_namesÚinst_dict_popÚnamerR   s        €r   rP   zSubredditWidgets._fetchH  sª   ø€ Ø�|‰|×ÑÜ�YÑ×&Ñ&°·±Ð&Ó@Ø(¨$×*AÑ*AÐBð  ó 
ˆð
 Ÿ(™( 7Ó+ˆŒÜ‰Ñ˜Ÿ™×/Ñ/°Ô6ò!
Ðð Ÿ™×)Ñ)ˆØ)ò 	&ˆDÙ˜$ Õ%ð	&ð ˆ�r   c                ó$   — | j                  «        y)a¢  Refresh the :class:`.Subreddit`'s widgets.

        By default, PRAW will not request progressively loading images from Reddit. To
        enable this, set the attribute ``progressive_images`` to ``True`` prior to
        calling ``refresh()``.

        .. code-block:: python

            widgets = reddit.subreddit("test").widgets
            widgets.progressive_images = True
            widgets.refresh()

        N)rP   r1   s    r   ÚrefreshzSubredditWidgets.refresh^  s   € ð 	�‰�r   )Úreturnzmodels.IDCard)rk   zdict[str, models.Widget])rk   z!models.SubredditWidgetsModeration)rk   zmodels.ModeratorsWidget)rk   zlist[models.Widget])rk   zlist[models.Menu])rT   Ústrrk   r   )r5   úmodels.Subredditrk   ÚNone)rk   rl   ©rk   rn   )r   r   r   r   r   r3   r/   r?   rB   rD   rK   rV   rZ   r^   rP   rj   Ú__classcell__©rR   s   @r   r+   r+   ¯   s¢   ø„ ñNð` ò7ó ð7ð òó ðð ò
Hó ð
Hð ò:ó ð:ð ò\ó ð\ð ò[ó ð[ó"õ0óAõ÷,r   r+   c                  ó2  — e Zd Z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„Z	 	 	 	 	 	 	 	 	 	 	 	 dd„Z	 	 	 	 	 	 	 	 	 	 dd„Zddœdd„Zdd„Zy)r>   a  Class for moderating a :class:`.Subreddit`'s widgets.

    Get an instance of this class from :attr:`.SubredditWidgets.mod`.

    Example usage:

    .. code-block:: python

        styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
        reddit.subreddit("test").widgets.mod.add_text_area(
            short_name="My title", text="**bold text**", styles=styles
        )

    .. note::

        To use this class's methods, the authenticated user must be a moderator with
        appropriate permissions.

    c                ó    — || _         || _        y)z;Initialize a :class:`.SubredditWidgetsModeration` instance.N)Ú
_subredditr9   )r2   r5   Úreddits      r   rZ   z#SubredditWidgetsModeration.__init__„  s   € à#ˆŒØˆ�r   c                óÊ   — t         d   j                  | j                  ¬«      }| j                  j	                  |dt        |t        ¬«      i¬«      }| j                  |_        |S )NÚwidget_creater]   Újson©Úclsr6   )r   rc   rt   r9   Úpostr   ÚWidgetEncoderr5   )r2   ÚpayloadÚpathÚwidgets       r   Ú_create_widgetz)SubredditWidgetsModeration._create_widget‹  sT   € Ü˜Ñ(×/Ñ/¸$¿/¹/Ð/ÓJˆØ—‘×"Ñ" 4¨v´u¸WÌ-Ô7XÐ.YÐ"ÓZˆØŸ?™?ˆÔØˆr   c               óV   — ||d||dœ}|j                  |«       | j                  |«      S )aø  Add and return a :class:`.ButtonWidget`.

        :param buttons: A list of dictionaries describing buttons, as specified in
            `Reddit docs`_. As of this writing, the format is:

            Each button is either a text button or an image button. A text button looks
            like this:

            .. code-block:: text

                {
                    "kind": "text",
                    "text": a string no longer than 30 characters,
                    "url": a valid URL,
                    "color": a 6-digit rgb hex color, e.g., `#AABBCC`,
                    "textColor": a 6-digit rgb hex color, e.g., `#AABBCC`,
                    "fillColor": a 6-digit rgb hex color, e.g., `#AABBCC`,
                    "hoverState": {...}
                }

            An image button looks like this:

            .. code-block:: text

                {
                    "kind": "image",
                    "text": a string no longer than 30 characters,
                    "linkUrl": a valid URL,
                    "url": a valid URL of a Reddit-hosted image,
                    "height": an integer,
                    "width": an integer,
                    "hoverState": {...}
                }

            Both types of buttons have the field ``hoverState``. The field does not have
            to be included (it is optional). If it is included, it can be one of two
            types: ``"text"`` or ``"image"``. A text ``hoverState`` looks like this:

            .. code-block:: text

                {
                    "kind": "text",
                    "text": a string no longer than 30 characters,
                    "color": a 6-digit rgb hex color, e.g., `#AABBCC`,
                    "textColor": a 6-digit rgb hex color, e.g., `#AABBCC`,
                    "fillColor": a 6-digit rgb hex color, e.g., `#AABBCC`
                }

            An image ``hoverState`` looks like this:

            .. code-block:: text

                {
                    "kind": "image",
                    "url": a valid URL of a Reddit-hosted image,
                    "height": an integer,
                    "width": an integer
                }

            .. note::

                The method :meth:`.upload_image` can be used to upload images to Reddit
                for a ``url`` field that holds a Reddit-hosted image.

            .. note::

                An image ``hoverState`` may be paired with a text widget, and a text
                ``hoverState`` may be paired with an image widget.

        :param description: Markdown text to describe the widget.
        :param short_name: A name for the widget, no longer than 30 characters.
        :param styles: A dictionary with keys ``"backgroundColor"`` and
            ``"headerColor"``, and values of hex colors. For example,
            ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

        :returns: The created :class:`.ButtonWidget`.

        .. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

        Example usage:

        .. code-block:: python

            widget_moderation = reddit.subreddit("test").widgets.mod
            my_image = widget_moderation.upload_image("/path/to/pic.jpg")
            buttons = [
                {
                    "kind": "text",
                    "text": "View source",
                    "url": "https://github.com/praw-dev/praw",
                    "color": "#FF0000",
                    "textColor": "#00FF00",
                    "fillColor": "#0000FF",
                    "hoverState": {
                        "kind": "text",
                        "text": "ecruos weiV",
                        "color": "#FFFFFF",
                        "textColor": "#000000",
                        "fillColor": "#0000FF",
                    },
                },
                {
                    "kind": "image",
                    "text": "View documentation",
                    "linkUrl": "https://praw.readthedocs.io",
                    "url": my_image,
                    "height": 200,
                    "width": 200,
                    "hoverState": {"kind": "image", "url": my_image, "height": 200, "width": 200},
                },
            ]
            styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
            new_widget = widget_moderation.add_button_widget(
                short_name="Things to click",
                description="Click some of these *cool* links!",
                buttons=buttons,
                styles=styles,
            )

        Úbutton)ÚbuttonsÚdescriptionÚkindÚ	shortNameÚstyles©Úupdater€   )r2   rƒ   r„   Ú
short_namer‡   Úother_settingsÚbutton_widgets          r   Úadd_button_widgetz,SubredditWidgetsModeration.add_button_widget‘  s<   € ðD Ø&ØØ#Øñ
ˆð 	×Ñ˜^Ô,Ø×"Ñ" =Ó1Ð1r   c               óX   — ||d|||dœ}|j                  |«       | j                  |«      S )at  Add and return a :class:`.Calendar` widget.

        :param configuration: A dictionary as specified in `Reddit docs`_. For example:

            .. code-block:: python

                {
                    "numEvents": 10,
                    "showDate": True,
                    "showDescription": False,
                    "showLocation": False,
                    "showTime": True,
                    "showTitle": True,
                }

        :param google_calendar_id: An email-style calendar ID. To share a Google
            Calendar, make it public, then find the "Calendar ID".
        :param requires_sync: Whether the calendar needs synchronization.
        :param short_name: A name for the widget, no longer than 30 characters.
        :param styles: A dictionary with keys ``"backgroundColor"`` and
            ``"headerColor"``, and values of hex colors. For example,
            ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

        :returns: The created :class:`.Calendar`.

        .. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

        Example usage:

        .. code-block:: python

            widget_moderation = reddit.subreddit("test").widgets.mod
            styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
            config = {
                "numEvents": 10,
                "showDate": True,
                "showDescription": False,
                "showLocation": False,
                "showTime": True,
                "showTitle": True,
            }
            calendar_id = "y6nm89jy427drk8l71w75w9wjn@group.calendar.google.com"
            new_widget = widget_moderation.add_calendar(
                short_name="Upcoming Events",
                google_calendar_id=calendar_id,
                requires_sync=True,
                configuration=config,
                styles=styles,
            )

        Úcalendar)ÚconfigurationÚgoogleCalendarIdr…   ÚrequiresSyncr†   r‡   rˆ   )r2   r�   Úgoogle_calendar_idÚrequires_syncrŠ   r‡   r‹   r�   s           r   Úadd_calendarz'SubredditWidgetsModeration.add_calendar  s=   € ð| +Ø 2ØØ)Ø#Øñ
ˆð 	�‰˜Ô'Ø×"Ñ" 8Ó,Ð,r   Ú )r„   c               óV   — ||d||dœ}|j                  |«       | j                  |«      S )aQ  Add and return a :class:`.CommunityList` widget.

        :param data: A list of subreddits. Subreddits can be represented as ``str`` or
            as :class:`.Subreddit`. These types may be mixed within the list.
        :param description: A string containing Markdown (default: ``""``).
        :param short_name: A name for the widget, no longer than 30 characters.
        :param styles: A dictionary with keys ``"backgroundColor"`` and
            ``"headerColor"``, and values of hex colors. For example,
            ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

        :returns: The created :class:`.CommunityList`.

        Example usage:

        .. code-block:: python

            widget_moderation = reddit.subreddit("test").widgets.mod
            styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
            subreddits = ["learnpython", reddit.subreddit("redditdev")]
            new_widget = widget_moderation.add_community_list(
                short_name="My fav subs", data=subreddits, styles=styles, description="description"
            )

        zcommunity-list)r7   r„   r…   r†   r‡   rˆ   )r2   r7   r„   rŠ   r‡   r‹   Úcommunity_lists          r   Úadd_community_listz-SubredditWidgetsModeration.add_community_listd  s<   € ðD Ø&Ø$Ø#Øñ
ˆð 	×Ñ˜nÔ-Ø×"Ñ" >Ó2Ð2r   c               óZ   — |||d|||dœ}|j                  |«       | j                  |«      S )ai
  Add and return a :class:`.CustomWidget`.

        :param css: The CSS for the widget, no longer than 100000 characters.

            .. note::

                As of this writing, Reddit will not accept empty CSS. If you wish to
                create a custom widget without CSS, consider using ``"/**/"`` (an empty
                comment) as your CSS.

        :param height: The height of the widget, between 50 and 500.
        :param image_data: A list of dictionaries as specified in `Reddit docs`_. Each
            dictionary represents an image and has the key ``"url"`` which maps to the
            URL of an image hosted on Reddit's servers. Images should be uploaded using
            :meth:`.upload_image`.

            For example:

            .. code-block:: python

                [
                    {
                        "url": "https://some.link",  # from upload_image()
                        "width": 600,
                        "height": 450,
                        "name": "logo",
                    },
                    {
                        "url": "https://other.link",  # from upload_image()
                        "width": 450,
                        "height": 600,
                        "name": "icon",
                    },
                ]

        :param short_name: A name for the widget, no longer than 30 characters.
        :param styles: A dictionary with keys ``"backgroundColor"`` and
            ``"headerColor"``, and values of hex colors. For example,
            ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.
        :param text: The Markdown text displayed in the widget.

        :returns: The created :class:`.CustomWidget`.

        .. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

        Example usage:

        .. code-block:: python

            widget_moderation = reddit.subreddit("test").widgets.mod
            image_paths = ["/path/to/image1.jpg", "/path/to/image2.png"]
            image_urls = [widget_moderation.upload_image(img_path) for img_path in image_paths]
            image_data = [
                {"width": 600, "height": 450, "name": "logo", "url": image_urls[0]},
                {"width": 450, "height": 600, "name": "icon", "url": image_urls[1]},
            ]
            styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
            new_widget = widget_moderation.add_custom_widget(
                image_short_name="My widget",
                text="# Hello world!",
                css="/**/",
                height=200,
                image_data=image_data,
                styles=styles,
            )

        Úcustom)ÚcssÚheightÚ	imageDatar…   r†   r‡   Útextrˆ   )	r2   rœ   r�   Ú
image_datarŠ   r‡   rŸ   r‹   Úcustom_widgets	            r   Úadd_custom_widgetz,SubredditWidgetsModeration.add_custom_widget�  sB   € ð^ ØØ#ØØ#ØØñ
ˆð 	×Ñ˜^Ô,Ø×"Ñ" =Ó1Ð1r   c               óT   — |d||dœ}|j                  |«       | j                  |«      S )a%  Add and return an :class:`.ImageWidget`.

        :param data: A list of dictionaries as specified in `Reddit docs`_. Each
            dictionary has the key ``"url"`` which maps to the URL of an image hosted on
            Reddit's servers. Images should be uploaded using :meth:`.upload_image`.

            For example:

            .. code-block:: python

                [
                    {
                        "url": "https://some.link",  # from upload_image()
                        "width": 600,
                        "height": 450,
                        "linkUrl": "https://github.com/praw-dev/praw",
                    },
                    {
                        "url": "https://other.link",  # from upload_image()
                        "width": 450,
                        "height": 600,
                        "linkUrl": "https://praw.readthedocs.io",
                    },
                ]

        :param short_name: A name for the widget, no longer than 30 characters.
        :param styles: A dictionary with keys ``"backgroundColor"`` and
            ``"headerColor"``, and values of hex colors. For example,
            ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

        :returns: The created :class:`.ImageWidget`.

        .. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

        Example usage:

        .. code-block:: python

            widget_moderation = reddit.subreddit("test").widgets.mod
            image_paths = ["/path/to/image1.jpg", "/path/to/image2.png"]
            image_data = [
                {
                    "width": 600,
                    "height": 450,
                    "linkUrl": "",
                    "url": widget_moderation.upload_image(img_path),
                }
                for img_path in image_paths
            ]
            styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
            new_widget = widget_moderation.add_image_widget(
                short_name="My cool pictures", data=image_data, styles=styles
            )

        Úimage)r7   r…   r†   r‡   rˆ   )r2   r7   rŠ   r‡   r‹   Úimage_widgets         r   Úadd_image_widgetz+SubredditWidgetsModeration.add_image_widgeté  s9   € ð@ ØØ#Øñ	
ˆð 	×Ñ˜NÔ+Ø×"Ñ" <Ó0Ð0r   c               óP   — |ddœ}|j                  |«       | j                  |«      S )a§  Add and return a :class:`.Menu` widget.

        :param data: A list of dictionaries describing menu contents, as specified in
            `Reddit docs`_. As of this writing, the format is:

            .. code-block:: text

                [
                    {
                        "text": a string no longer than 20 characters,
                        "url": a valid URL
                    },

                    OR

                    {
                        "children": [
                            {
                                "text": a string no longer than 20 characters,
                                "url": a valid URL,
                            },
                            ...
                        ],
                        "text": a string no longer than 20 characters,
                    },
                    ...
                ]


        :returns: The created :class:`.Menu`.

        .. _reddit docs: https://www.reddit.com/dev/api#POST_api_widget

        Example usage:

        .. code-block:: python

            widget_moderation = reddit.subreddit("test").widgets.mod
            menu_contents = [
                {"text": "My homepage", "url": "https://example.com"},
                {
                    "text": "Python packages",
                    "children": [
                        {"text": "PRAW", "url": "https://praw.readthedocs.io/"},
                        {"text": "requests", "url": "https://docs.python-requests.org/"},
                    ],
                },
                {"text": "Reddit homepage", "url": "https://reddit.com"},
            ]
            new_widget = widget_moderation.add_menu(data=menu_contents)

        Úmenu)r7   r…   rˆ   )r2   r7   r‹   r¨   s       r   Úadd_menuz#SubredditWidgetsModeration.add_menu1  s,   € ðt  fÑ-ˆØ�‰�NÔ#Ø×"Ñ" 4Ó(Ð(r   c               óV   — |d|||dœ}|j                  |«       | j                  |«      S )a¥  Add and return a :class:`.PostFlairWidget`.

        :param display: Display style. Either ``"cloud"`` or ``"list"``.
        :param order: A list of flair template IDs. You can get all flair template IDs
            in a subreddit with:

            .. code-block:: python

                flairs = [f["id"] for f in subreddit.flair.link_templates]

        :param short_name: A name for the widget, no longer than 30 characters.
        :param styles: A dictionary with keys ``"backgroundColor"`` and
            ``"headerColor"``, and values of hex colors. For example,
            ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.

        :returns: The created :class:`.PostFlairWidget`.

        Example usage:

        .. code-block:: python

            subreddit = reddit.subreddit("test")
            widget_moderation = subreddit.widgets.mod
            flairs = [f["id"] for f in subreddit.flair.link_templates]
            styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
            new_widget = widget_moderation.add_post_flair_widget(
                short_name="Some flairs", display="list", order=flairs, styles=styles
            )

        z
post-flair)Údisplayr…   rE   r†   r‡   rˆ   )r2   r«   rE   rŠ   r‡   r‹   Ú
post_flairs          r   Úadd_post_flair_widgetz0SubredditWidgetsModeration.add_post_flair_widgeto  s<   € ðP Ø ØØ#Øñ
ˆ
ð 	×Ñ˜.Ô)Ø×"Ñ" :Ó.Ð.r   c               óT   — d|||dœ}|j                  |«       | j                  |«      S )a:  Add and return a :class:`.TextArea` widget.

        :param short_name: A name for the widget, no longer than 30 characters.
        :param styles: A dictionary with keys ``"backgroundColor"`` and
            ``"headerColor"``, and values of hex colors. For example,
            ``{"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}``.
        :param text: The Markdown text displayed in the widget.

        :returns: The created :class:`.TextArea`.

        Example usage:

        .. code-block:: python

            widget_moderation = reddit.subreddit("test").widgets.mod
            styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
            new_widget = widget_moderation.add_text_area(
                short_name="My cool title", text="*Hello* **world**!", styles=styles
            )

        Útextarea)r…   r†   r‡   rŸ   rˆ   )r2   rŠ   r‡   rŸ   r‹   Ú	text_areas         r   Úadd_text_areaz(SubredditWidgetsModeration.add_text_area   s8   € ð< Ø#ØØñ	
ˆ	ð 	×Ñ˜Ô(Ø×"Ñ" 9Ó-Ð-r   rD   )Úsectionc               ó  — |D �cg c])  }t        |t        «      r|j                  n
t        |«      ‘Œ+ }}t        d   j                  || j                  ¬«      }| j                  j                  |t        |«      |dœ¬«       yc c}w )aü  Reorder the widgets.

        :param new_order: A list of widgets. Represented as a list that contains
            :class:`.Widget` objects, or widget IDs as strings. These types may be
            mixed.
        :param section: The section to reorder (default: ``"sidebar"``).

        Example usage:

        .. code-block:: python

            widgets = reddit.subreddit("test").widgets
            order = list(widgets.sidebar)
            order.reverse()
            widgets.mod.reorder(order)

        Úwidget_order)r²   r5   )rx   r²   r6   N)
Ú
isinstanceÚWidgetÚidrl   r   rc   rt   r9   Úpatchr   )r2   Ú	new_orderr²   ÚthingrE   r~   s         r   Úreorderz"SubredditWidgetsModeration.reorderÆ  ss   € ð$ U^Ö^È5œZ¨¬vÔ6�—’¼CÀ»JÑFÐ^ˆÐ^Ü˜Ñ'×.Ñ.°wÈ$Ï/É/Ð.ÓZˆØ�‰×Ñ˜4¬u°U«|ÈÑ&PÐÕQùò _s   ….Bc               ó8   — |j                  | j                  «      S )a©  Upload an image to Reddit and get the URL.

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

        :returns: The URL of the uploaded image as a ``str``.

        This method is used to upload images for widgets. For example, it can be used in
        conjunction with :meth:`.add_image_widget`, :meth:`.add_custom_widget`, and
        :meth:`.add_button_widget`.

        Example usage:

        .. code-block:: python

            from praw.models import WidgetMedia

            my_sub = reddit.subreddit("test")
            image_url = my_sub.widgets.mod.upload_image(WidgetMedia("/path/to/image.jpg"))
            image_data = [{"width": 300, "height": 300, "url": image_url, "linkUrl": ""}]
            styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
            my_sub.widgets.mod.add_image_widget(
                short_name="My cool pictures", data=image_data, styles=styles
            )

        )Ú_uploadrt   )r2   Úmedias     r   Úupload_imagez'SubredditWidgetsModeration.upload_imageÜ  s   € ð4 �}‰}˜TŸ_™_Ó-Ð-r   N)r5   rm   ru   úpraw.Redditrk   rn   )r}   údict[str, Any]rk   r   )rƒ   z1list[dict[str, dict[str, str | int] | str | int]]r„   rl   rŠ   rl   r‡   údict[str, str]r‹   r   rk   zmodels.ButtonWidget)r�   zdict[str, bool | int]r“   rl   r”   ÚboolrŠ   rl   r‡   rÂ   r‹   r   rk   zmodels.Calendar)r7   zlist[str | models.Subreddit]r„   rl   rŠ   rl   r‡   rÂ   r‹   r   rk   zmodels.CommunityList)rœ   rl   r�   Úintr    úlist[dict[str, str | int]]rŠ   rl   r‡   rÂ   rŸ   rl   r‹   r   rk   zmodels.CustomWidget)
r7   rÅ   rŠ   rl   r‡   rÂ   r‹   r   rk   zmodels.ImageWidget)r7   z+list[dict[str, list[dict[str, str]] | str]]r‹   r   rk   zmodels.Menu | Widget)r«   rl   rE   z	list[str]rŠ   rl   r‡   rÂ   r‹   r   rk   zmodels.PostFlairWidget | Widget)
rŠ   rl   r‡   rÂ   rŸ   rl   r‹   r   rk   zmodels.TextArea)r¹   zlist[Widget | str]r²   rl   rk   rn   )r¾   zmodels.WidgetMediark   rl   )r   r   r   r   rZ   r€   r�   r•   r™   r¢   r¦   r©   r­   r±   r»   r¿   r   r   r   r>   r>   o  sC  „ ñó(óðI2ð CðI2ð ð	I2ð
 ðI2ð ðI2ð ðI2ð 
óI2ðVF-ð -ðF-ð  ð	F-ð
 ðF-ð ðF-ð ðF-ð ðF-ð 
óF-ðX ñ	)3ð +ð)3ð ð	)3ð
 ð)3ð ð)3ð ð)3ð 
ó)3ðVX2ð ðX2ð ð	X2ð
 /ðX2ð ðX2ð ðX2ð ðX2ð ðX2ð 
óX2ðtF1ð )ðF1ð ð	F1ð
 ðF1ð ðF1ð 
óF1ðP<)ð :ð<)ð ð	<)ð
 
ó<)ð|//ð ð//ð ð	//ð
 ð//ð ð//ð ð//ð 
)ó//ðb$.ð ð$.ð ð	$.ð
 ð$.ð ð$.ð 
ó$.ðL HQõ Rô,.r   r>   c                  óF   ‡ — e Zd ZdZedd„«       Zdd„Zdd„Zd	ˆ fd„Zˆ xZ	S )
r¶   z+Base class to represent a :class:`.Widget`.c                óD   — t        | | j                  | j                  «      S )aR  Get an instance of :class:`.WidgetModeration` for this widget.

        .. note::

            Using any of the methods of :class:`.WidgetModeration` will likely make the
            data in the :class:`.SubredditWidgets` that this widget belongs to outdated.
            To remedy this, call :meth:`~.SubredditWidgets.refresh`.

        )ÚWidgetModerationr5   r9   r1   s    r   r?   z
Widget.modü  s   € ô    d§n¡n°d·l±lÓCÐCr   c                óô   — t        |t        «      r5| j                  j                  «       |j                  j                  «       k(  S t	        |«      j                  «       | j                  j                  «       k(  S )z&Check equality against another object.)rµ   r¶   r·   Úlowerrl   )r2   Úothers     r   Ú__eq__zWidget.__eq__	  sN   € ä�eœVÔ$Ø—7‘7—=‘=“? e§h¡h§n¡nÓ&6Ñ6Ð6Ü�5‹z×ÑÓ! T§W¡W§]¡]£_Ñ4Ð4r   c                óˆ   — t        | j                  j                  «      t        | j                  j	                  «       «      z  S )z(Return the hash of the current instance.)ÚhashrR   r   r·   rÊ   r1   s    r   Ú__hash__zWidget.__hash__  s+   € ä�D—N‘N×+Ñ+Ó,¬t°D·G±G·M±M³OÓ/DÑDÐDr   c                óR   •— d| _         d| _        t        ‰| �  ||¬«       d| _        y)z'Initialize a :class:`.Widget` instance.r–   ©Ú_dataN)r5   r·   rY   rZ   Ú_mod)r2   ru   rÒ   rR   s      €r   rZ   zWidget.__init__  s*   ø€ àˆŒØˆŒÜ‰Ñ˜ uÐÔ-Øˆ�	r   )rk   zmodels.WidgetModeration)rË   Úobjectrk   rÃ   )rk   rÄ   ©ru   rÀ   rÒ   rÁ   rk   rn   )
r   r   r   r   r   r?   rÌ   rÏ   rZ   rp   rq   s   @r   r¶   r¶   ù  s/   ø„ Ù5àò
Dó ð
Dó5óE÷ñ r   r¶   c                  ó   — e Zd ZdZdZy)ÚButtonWidgetaÄ  Class to represent a widget containing one or more buttons.

    Find an existing one:

    .. code-block:: python

        button_widget = None
        widgets = reddit.subreddit("test").widgets
        for widget in widgets.sidebar:
            if isinstance(widget, praw.models.ButtonWidget):
                button_widget = widget
                break

        for button in button_widget:
            print(button.text, button.url)

    Create one:

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        buttons = [
            {
                "kind": "text",
                "text": "View source",
                "url": "https://github.com/praw-dev/praw",
                "color": "#FF0000",
                "textColor": "#00FF00",
                "fillColor": "#0000FF",
                "hoverState": {
                    "kind": "text",
                    "text": "ecruos weiV",
                    "color": "#000000",
                    "textColor": "#FFFFFF",
                    "fillColor": "#0000FF",
                },
            },
            {
                "kind": "text",
                "text": "View documentation",
                "url": "https://praw.readthedocs.io",
                "color": "#FFFFFF",
                "textColor": "#FFFF00",
                "fillColor": "#0000FF",
            },
        ]
        styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
        button_widget = widgets.mod.add_button_widget(
            "Things to click", "Click some of these *cool* links!", buttons, styles
        )

    For more information on creation, see :meth:`.add_button_widget`.

    Update one:

    .. code-block:: python

        new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
        button_widget = button_widget.mod.update(shortName="My fav buttons", styles=new_styles)

    Delete one:

    .. code-block:: python

        button_widget.mod.delete()

    .. include:: ../../typical_attributes.rst

    ==================== ==============================================================
    Attribute            Description
    ==================== ==============================================================
    ``buttons``          A list of :class:`.Button`\ s. These can also be accessed just
                         by iterating over the :class:`.ButtonWidget` (e.g., ``for
                         button in button_widget``).
    ``description``      The description, in Markdown.
    ``description_html`` The description, in HTML.
    ``id``               The widget ID.
    ``kind``             The widget kind (always ``"button"``).
    ``shortName``        The short name of the widget.
    ``styles``           A ``dict`` with the keys ``"backgroundColor"`` and
                         ``"headerColor"``.
    ``subreddit``        The :class:`.Subreddit` the button widget belongs to.
    ==================== ==============================================================

    rƒ   Nr(   r   r   r   r×   r×     s   „ ñTðl  �Or   r×   c                  ó   — e Zd ZdZy)ÚCalendara	  Class to represent a calendar widget.

    Find an existing one:

    .. code-block:: python

        calendar = None
        widgets = reddit.subreddit("test").widgets
        for widget in widgets.sidebar:
            if isinstance(widget, praw.models.Calendar):
                calendar = widget
                break

        print(calendar.googleCalendarId)

    Create one:

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
        config = {
            "numEvents": 10,
            "showDate": True,
            "showDescription": False,
            "showLocation": False,
            "showTime": True,
            "showTitle": True,
        }
        cal_id = "y6nm89jy427drk8l71w75w9wjn@group.calendar.google.com"
        calendar = widgets.mod.add_calendar(
            short_name="Upcoming Events",
            google_calendar_id=cal_id,
            requires_sync=True,
            configuration=config,
            styles=styles,
        )

    For more information on creation, see :meth:`.add_calendar`.

    Update one:

    .. code-block:: python

        new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
        calendar = calendar.mod.update(shortName="My fav events", styles=new_styles)

    Delete one:

    .. code-block:: python

        calendar.mod.delete()

    .. include:: ../../typical_attributes.rst

    ================= =====================================================
    Attribute         Description
    ================= =====================================================
    ``configuration`` A ``dict`` describing the calendar configuration.
    ``data``          A list of dictionaries that represent events.
    ``id``            The widget ID.
    ``kind``          The widget kind (always ``"calendar"``).
    ``requiresSync``  A ``bool`` representing whether the calendar requires
                      synchronization.
    ``shortName``     The short name of the widget.
    ``styles``        A ``dict`` with the keys ``"backgroundColor"`` and
                      ``"headerColor"``.
    ``subreddit``     The :class:`.Subreddit` the button widget belongs to.
    ================= =====================================================

    Nr   r   r   r   rÙ   rÙ   u  s   „ òFr   rÙ   c                  ó   — e Zd ZdZdZy)ÚCommunityLista  Class to represent a Related Communities widget.

    Find an existing one:

    .. code-block:: python

        community_list = None
        widgets = reddit.subreddit("test").widgets
        for widget in widgets.sidebar:
            if isinstance(widget, praw.models.CommunityList):
                community_list = widget
                break

        print(community_list)

    Create one:

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
        subreddits = ["learnpython", reddit.subreddit("test")]
        community_list = widgets.mod.add_community_list(
            short_name="Related subreddits",
            data=subreddits,
            styles=styles,
            description="description",
        )

    For more information on creation, see :meth:`.add_community_list`.

    Update one:

    .. code-block:: python

        new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
        community_list = community_list.mod.update(shortName="My fav subs", styles=new_styles)

    Delete one:

    .. code-block:: python

        community_list.mod.delete()

    .. include:: ../../typical_attributes.rst

    ============= =====================================================================
    Attribute     Description
    ============= =====================================================================
    ``data``      A list of :class:`.Subreddit`\ s. These can also be iterated over by
                  iterating over the :class:`.CommunityList` (e.g., ``for sub in
                  community_list``).
    ``id``        The widget ID.
    ``kind``      The widget kind (always ``"community-list"``).
    ``shortName`` The short name of the widget.
    ``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
    ``subreddit`` The :class:`.Subreddit` the button widget belongs to.
    ============= =====================================================================

    r7   Nr(   r   r   r   rÛ   rÛ   ¿  s   „ ñ;ðz �Or   rÛ   c                  ó$   ‡ — e Zd ZdZdˆ fd„Zˆ xZS )ÚCustomWidgeta…  Class to represent a custom widget.

    Find an existing one:

    .. code-block:: python

        custom = None
        widgets = reddit.subreddit("test").widgets
        for widget in widgets.sidebar:
            if isinstance(widget, praw.models.CustomWidget):
                custom = widget
                break

        print(custom.text)
        print(custom.css)

    Create one:

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
        custom = widgets.mod.add_custom_widget(
            short_name="My custom widget",
            text="# Hello world!",
            css="/**/",
            height=200,
            image_data=[],
            styles=styles,
        )

    For more information on creation, see :meth:`.add_custom_widget`.

    Update one:

    .. code-block:: python

        new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
        custom = custom.mod.update(shortName="My fav customization", styles=new_styles)

    Delete one:

    .. code-block:: python

        custom.mod.delete()

    .. include:: ../../typical_attributes.rst

    ================= ============================================================
    Attribute         Description
    ================= ============================================================
    ``css``           The CSS of the widget, as a ``str``.
    ``height``        The height of the widget, as an ``int``.
    ``id``            The widget ID.
    ``imageData``     A ``list`` of :class:`.ImageData` that belong to the widget.
    ``kind``          The widget kind (always ``"custom"``).
    ``shortName``     The short name of the widget.
    ``styles``        A ``dict`` with the keys ``"backgroundColor"`` and
                      ``"headerColor"``.
    ``stylesheetUrl`` A link to the widget's stylesheet.
    ``subreddit``     The :class:`.Subreddit` the button widget belongs to.
    ``text``          The text contents, as Markdown.
    ``textHtml``      The text contents, as HTML.
    ================= ============================================================

    c                óŠ   •— |j                  d«      D �cg c]  }t        ||«      ‘Œ c}|d<   t        ‰| �  ||¬«       yc c}w )z-Initialize a :class:`.CustomWidget` instance.rž   rÑ   N)rd   r    rY   rZ   )r2   ru   rÒ   r7   rR   s       €r   rZ   zCustomWidget.__init__D  s@   ø€ àBGÇ)Á)ÈKÓBXÖY¸$œi¨°Õ5ÒYˆˆkÑÜ‰Ñ˜ uÐÕ-ùò Zs   •A rÕ   )r   r   r   r   rZ   rp   rq   s   @r   rÝ   rÝ      s   ø„ ñA÷F.ñ .r   rÝ   c                  ó   — e Zd ZdZy)ÚIDCardaù  Class to represent an ID card widget.

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        id_card = widgets.id_card
        print(id_card.subscribersText)

    Update one:

    .. code-block:: python

        widgets.id_card.mod.update(currentlyViewingText="Bots")

    .. include:: ../../typical_attributes.rst

    ========================= =======================================================
    Attribute                 Description
    ========================= =======================================================
    ``currentlyViewingCount`` The number of redditors viewing the subreddit.
    ``currentlyViewingText``  The text displayed next to the view count. For example,
                              ``"users online"``.
    ``description``           The subreddit description.
    ``id``                    The widget ID.
    ``kind``                  The widget kind (always ``"id-card"``).
    ``shortName``             The short name of the widget.
    ``styles``                A ``dict`` with the keys ``"backgroundColor"`` and
                              ``"headerColor"``.
    ``subreddit``             The :class:`.Subreddit` the button widget belongs to.
    ``subscribersCount``      The number of subscribers to the subreddit.
    ``subscribersText``       The text displayed next to the subscriber count. For
                              example, "users subscribed".
    ========================= =======================================================

    Nr   r   r   r   rà   rà   J  s   „ ò"r   rà   c                  ó   — e Zd ZdZdZy)ÚImageWidgetaÀ  Class to represent an image widget.

    Find an existing one:

    .. code-block:: python

        image_widget = None
        widgets = reddit.subreddit("test").widgets
        for widget in widgets.sidebar:
            if isinstance(widget, praw.models.ImageWidget):
                image_widget = widget
                break

        for image in image_widget:
            print(image.url)

    Create one:

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        image_paths = ["/path/to/image1.jpg", "/path/to/image2.png"]
        image_data = [
            {
                "width": 600,
                "height": 450,
                "linkUrl": "",
                "url": widgets.mod.upload_image(img_path),
            }
            for img_path in image_paths
        ]
        styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
        image_widget = widgets.mod.add_image_widget(
            short_name="My cool pictures", data=image_data, styles=styles
        )

    For more information on creation, see :meth:`.add_image_widget`.

    Update one:

    .. code-block:: python

        new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
        image_widget = image_widget.mod.update(shortName="My fav images", styles=new_styles)

    Delete one:

    .. code-block:: python

        image_widget.mod.delete()

    .. include:: ../../typical_attributes.rst

    ============= =====================================================================
    Attribute     Description
    ============= =====================================================================
    ``data``      A list of the :class:`.Image`\ s in this widget. Can be iterated over
                  by iterating over the :class:`.ImageWidget` (e.g., ``for img in
                  image_widget``).
    ``id``        The widget ID.
    ``kind``      The widget kind (always ``"image"``).
    ``shortName`` The short name of the widget.
    ``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
    ``subreddit`` The :class:`.Subreddit` the button widget belongs to.
    ============= =====================================================================

    r7   Nr(   r   r   r   râ   râ   p  s   „ ñBðH �Or   râ   c                  ó   — e Zd ZdZdZy)ÚMenuaø  Class to represent the top menu widget of a :class:`.Subreddit`.

    Menus can generally be found as the first item in a :class:`.Subreddit`'s top bar.

    .. code-block:: python

        topbar = reddit.subreddit("test").widgets.topbar
        if len(topbar) > 0:
            probably_menu = topbar[0]
            assert isinstance(probably_menu, praw.models.Menu)
            for item in probably_menu:
                if isinstance(item, praw.models.Submenu):
                    print(item.text)
                    for child in item:
                        print("\t", child.text, child.url)
                else:  # MenuLink
                    print(item.text, item.url)

    Create one:

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        menu_contents = [
            {"text": "My homepage", "url": "https://example.com"},
            {
                "text": "Python packages",
                "children": [
                    {"text": "PRAW", "url": "https://praw.readthedocs.io/"},
                    {"text": "requests", "url": "http://python-requests.org"},
                ],
            },
            {"text": "Reddit homepage", "url": "https://reddit.com"},
        ]
        menu = widgets.mod.add_menu(data=menu_contents)

    For more information on creation, see :meth:`.add_menu`.

    Update one:

    .. code-block:: python

        menu_items = list(menu)
        menu_items.reverse()
        menu = menu.mod.update(data=menu_items)

    Delete one:

    .. code-block:: python

        menu.mod.delete()

    .. include:: ../../typical_attributes.rst

    ============= ====================================================================
    Attribute     Description
    ============= ====================================================================
    ``data``      A list of the :class:`.MenuLink`\ s and :class:`.Submenu`\ s in this
                  widget. Can be iterated over by iterating over the :class:`.Menu`
                  (e.g., ``for item in menu``).
    ``id``        The widget ID.
    ``kind``      The widget kind (always ``"menu"``).
    ``subreddit`` The :class:`.Subreddit` the button widget belongs to.
    ============= ====================================================================

    r7   Nr(   r   r   r   rä   rä   ¸  s   „ ñAðF �Or   rä   c                  ó(   ‡ — e Zd ZdZdZdˆ fd„Zˆ xZS )ÚModeratorsWidgetaè  Class to represent a moderators widget.

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        print(widgets.moderators_widget)

    Update one:

    .. code-block:: python

        new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
        widgets.moderators_widget.mod.update(styles=new_styles)

    .. include:: ../../typical_attributes.rst

    ============= =====================================================================
    Attribute     Description
    ============= =====================================================================
    ``id``        The widget ID.
    ``kind``      The widget kind (always ``"moderators"``).
    ``mods``      A list of the :class:`.Redditor`\ s that moderate the subreddit. Can
                  be iterated over by iterating over the :class:`.ModeratorsWidget`
                  (e.g., ``for mod in widgets.moderators_widget``).
    ``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
    ``subreddit`` The :class:`.Subreddit` the button widget belongs to.
    ``totalMods`` The total number of moderators in the subreddit.
    ============= =====================================================================

    Úmodsc                óZ   •— | j                   }|€J ‚||vrg ||<   t        ‰| �	  ||¬«       y)z1Initialize a :class:`.ModeratorsWidget` instance.NrÑ   ©r)   rY   rZ   ©r2   ru   rÒ   Úchild_attributerR   s       €r   rZ   zModeratorsWidget.__init__!  ó>   ø€ à×.Ñ.ˆØÐ*Ð*Ð*Ø %Ñ'à%'ˆE�/Ñ"Ü‰Ñ˜ uÐÕ-r   rÕ   ©r   r   r   r   r)   rZ   rp   rq   s   @r   ræ   ræ   ÿ  s   ø„ ñð> €O÷.ñ .r   ræ   c                  ó   — e Zd ZdZdZy)ÚPostFlairWidgetaâ  Class to represent a post flair widget.

    Find an existing one:

    .. code-block:: python

        post_flair_widget = None
        widgets = reddit.subreddit("test").widgets
        for widget in widgets.sidebar:
            if isinstance(widget, praw.models.PostFlairWidget):
                post_flair_widget = widget
                break

        for flair in post_flair_widget:
            print(flair)
            print(post_flair_widget.templates[flair])

    Create one:

    .. code-block:: python

        subreddit = reddit.subreddit("test")
        widgets = subreddit.widgets
        flairs = [f["id"] for f in subreddit.flair.link_templates]
        styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
        post_flair = widgets.mod.add_post_flair_widget(
            short_name="Some flairs", display="list", order=flairs, styles=styles
        )

    For more information on creation, see :meth:`.add_post_flair_widget`.

    Update one:

    .. code-block:: python

        new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
        post_flair = post_flair.mod.update(shortName="My fav flairs", styles=new_styles)

    Delete one:

    .. code-block:: python

        post_flair.mod.delete()

    .. include:: ../../typical_attributes.rst

    ============= =====================================================================
    Attribute     Description
    ============= =====================================================================
    ``display``   The display style of the widget, either ``"cloud"`` or ``"list"``.
    ``id``        The widget ID.
    ``kind``      The widget kind (always ``"post-flair"``).
    ``order``     A list of the flair IDs in this widget. Can be iterated over by
                  iterating over the :class:`.PostFlairWidget` (e.g., ``for flair_id in
                  post_flair``).
    ``shortName`` The short name of the widget.
    ``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
    ``subreddit`` The :class:`.Subreddit` the button widget belongs to.
    ``templates`` A ``dict`` that maps flair IDs to dictionaries that describe flairs.
    ============= =====================================================================

    rE   Nr(   r   r   r   rï   rï   +  s   „ ñ=ð~ �Or   rï   c                  ó(   ‡ — e Zd ZdZdZdˆ fd„Zˆ xZS )ÚRulesWidgetaÚ  Class to represent a rules widget.

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        rules_widget = None
        for widget in widgets.sidebar:
            if isinstance(widget, praw.models.RulesWidget):
                rules_widget = widget
                break
        from pprint import pprint

        pprint(rules_widget.data)

    Update one:

    .. code-block:: python

        new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
        rules_widget.mod.update(display="compact", shortName="The LAWS", styles=new_styles)

    .. include:: ../../typical_attributes.rst

    ============= =====================================================================
    Attribute     Description
    ============= =====================================================================
    ``data``      A list of the subreddit rules. Can be iterated over by iterating over
                  the :class:`.RulesWidget` (e.g., ``for rule in rules_widget``).
    ``display``   The display style of the widget, either ``"full"`` or ``"compact"``.
    ``id``        The widget ID.
    ``kind``      The widget kind (always ``"subreddit-rules"``).
    ``shortName`` The short name of the widget.
    ``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
    ``subreddit`` The :class:`.Subreddit` the button widget belongs to.
    ============= =====================================================================

    r7   c                óZ   •— | j                   }|€J ‚||vrg ||<   t        ‰| �	  ||¬«       y)z,Initialize a :class:`.RulesWidget` instance.NrÑ   ré   rê   s       €r   rZ   zRulesWidget.__init__—  rì   r   rÕ   rí   rq   s   @r   rñ   rñ   n  s   ø„ ñ$ðL €O÷.ñ .r   rñ   c                  ó   — e Zd ZdZy)ÚTextAreaaê  Class to represent a text area widget.

    Find a text area in a subreddit:

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        text_area = None
        for widget in widgets.sidebar:
            if isinstance(widget, praw.models.TextArea):
                text_area = widget
                break
        print(text_area.text)

    Create one:

    .. code-block:: python

        widgets = reddit.subreddit("test").widgets
        styles = {"backgroundColor": "#FFFF66", "headerColor": "#3333EE"}
        text_area = widgets.mod.add_text_area(
            short_name="My cool title", text="*Hello* **world**!", styles=styles
        )

    For more information on creation, see :meth:`.add_text_area`.

    Update one:

    .. code-block:: python

        new_styles = {"backgroundColor": "#FFFFFF", "headerColor": "#FF9900"}
        text_area = text_area.mod.update(shortName="My fav text", styles=new_styles)

    Delete one:

    .. code-block:: python

        text_area.mod.delete()

    .. include:: ../../typical_attributes.rst

    ============= =====================================================================
    Attribute     Description
    ============= =====================================================================
    ``id``        The widget ID.
    ``kind``      The widget kind (always ``"textarea"``).
    ``shortName`` The short name of the widget.
    ``styles``    A ``dict`` with the keys ``"backgroundColor"`` and ``"headerColor"``.
    ``subreddit`` The :class:`.Subreddit` the button widget belongs to.
    ``text``      The widget's text, as Markdown.
    ``textHtml``  The widget's text, as HTML.
    ============= =====================================================================

    Nr   r   r   r   rô   rô   ¡  s   „ ò5r   rô   c                  ó$   — e Zd ZU dZded<   dd„Zy)r|   z'Class to encode widget-related objects.ztype[models.Subreddit]Ú_subreddit_classc                ó  — t        || j                  «      rt        |«      S t        |t        «      r?t	        |«      j                  «       D ��ci c]  \  }}|j                  d«      rŒ||“Œ c}}S t        j                  | |«      S c c}}w )zSerialize ``PRAWBase`` objects.rM   )	rµ   rö   rl   r
   Úvarsr/   rN   r   Údefault)r2   ÚoÚkeyÚvals       r   rù   zWidgetEncoder.defaultß  sm   € ä�a˜×.Ñ.Ô/Ü�q“6ˆMÜ�aœÔ"Ü-1°!«W¯]©]«_×X¡  cÀCÇNÁNÐSVÕDW�C˜‘HÓXÐXÜ×"Ñ" 4¨Ó+Ð+ùó Ys   ÁBÁ(BN)rú   r   rk   r   )r   r   r   r   Ú__annotations__rù   r   r   r   r|   r|   Ú  s   … Ù1à,Ó,ô,r   r|   c                  ó8   — e Zd ZdZ	 	 	 	 	 	 	 	 dd„Zdd„Zdd„Zy)	rÈ   zíClass for moderating a particular widget.

    Example usage:

    .. code-block:: python

        widget = reddit.subreddit("test").widgets.sidebar[0]
        widget.mod.update(shortName="My new title")
        widget.mod.delete()

    c                ó.   — || _         || _        || _        y)z1Initialize a :class:`.WidgetModeration` instance.N)r   r9   rt   )r2   r   r5   ru   s       r   rZ   zWidgetModeration.__init__õ  s   € ð ˆŒØˆŒØ#ˆ�r   c                óª   — t         d   j                  | j                  | j                  j                  ¬«      }| j
                  j                  |«       y)zuDelete the widget.

        Example usage:

        .. code-block:: python

            widget.mod.delete()

        Úwidget_modify©r5   Ú	widget_idN)r   rc   rt   r   r·   r9   Údelete)r2   r~   s     r   r  zWidgetModeration.delete   sA   € ô ˜Ñ(×/Ñ/¸$¿/¹/ÐUY×U`ÑU`×UcÑUcÐ/ÓdˆØ�‰×Ñ˜DÕ!r   c                óÜ  — t         d   j                  | j                  | j                  j                  ¬«      }t        | j                  «      j                  «       D ��ci c]  \  }}|j                  d«      rŒ||“Œ }}}|d= |j                  dd«       |j                  |«       | j                  j                  |dt        |t        ¬«      i¬	«      }| j                  |_        |S c c}}w )
a  Update the widget. Returns the updated widget.

        Parameters differ based on the type of widget. See `Reddit documentation
        <https://www.reddit.com/dev/api#PUT_api_widget_{widget_id}>`_ or the document of
        the particular type of widget.

        :returns: The updated :class:`.Widget`.

        For example, update a text widget like so:

        .. code-block:: python

            text_widget.mod.update(shortName="New text area", text="Hello!")

        .. note::

            Most parameters follow the ``lowerCamelCase`` convention. When in doubt,
            check the Reddit documentation linked above.

        r  r  rM   r5   r?   Nrx   ry   r6   )r   rc   rt   r   r·   rø   r/   rN   rd   r‰   r9   Úputr   r|   r5   )r2   Úkwargsr~   rû   Úvaluer}   r   s          r   r‰   zWidgetModeration.update  sÉ   € ô* ˜Ñ(×/Ñ/¸$¿/¹/ÐUY×U`ÑU`×UcÑUcÐ/ÓdˆÜ04°T·[±[Ó0A×0GÑ0GÓ0I×e¡* # uÐQT×Q_ÑQ_Ð`cÕQd�3˜‘:ÐeˆÑeØ�KÐ Ø�‰�E˜4Ô Ø�‰�vÔØ—‘×!Ñ! $¨f´e¸GÌÔ6WÐ-XÐ!ÓYˆØŸ?™?ˆÔØˆùó fs   ÁC(Á9C(N)r   r¶   r5   zmodels.Subreddit | strru   rÀ   rk   rn   ro   )r  r   rk   r¶   )r   r   r   r   rZ   r  r‰   r   r   r   rÈ   rÈ   è  s<   „ ñ
ð	$àð	$ð *ð	$ð ð		$ð
 
ó	$ó"ôr   rÈ   ),r   Ú
__future__r   rx   r   r   Útypingr   r   Ú
praw.constr   Úpraw.models.baser	   r
   Úpraw.models.list.baser   Úpraw.util.cacher   Úprawr   r   r   r   r   r    r"   r$   r&   r+   r>   r¶   r×   rÙ   rÛ   rÝ   rà   râ   rä   ræ   rï   rñ   rô   r|   rÈ   r   r   r   ú<module>r     s‹  ðÙ )å "ç #ß %å ß 8Ý *Ý *áÛÝôÐ ô ô6Ð-¨xô ô&Ð˜xô ô4Ð˜xô ô"Ð! 8ô ô"Ð  (ô ôÐ ô ô"!Ð ô !ô&}�xô }÷@G
.ñ G
.ôTÐ ô ôDW �6˜8ô W ôtGˆvô GôT>�F˜Hô >ôBG.�6ô G.ôT#ˆVô #ôLE�&˜(ô EôPDˆ6�8ô DôN).�v˜xô ).ôX@�f˜hô @ôF0.�&˜(ô 0.ôf6ˆvô 6ôr,�Kô ,÷Aò Ar   