o
    Rhg                     @   sl  d Z ddlmZ ddlmZ ddlmZmZ ddlm	Z	 ddl
mZ ddlmZ G d	d
 d
eZG dd deeeZG dd deZG dd deeeZG dd deeeZG dd deZG dd deeeZG dd deZG dd deZG dd deZG dd deZG dd  d eZG d!d" d"eZG d#d$ d$eZG d%d& d&eZG d'd( d(eZd)S )*z#linebot.models.flex_message module.    )ABCMeta)with_metaclass   )
BackgroundLinearGradientBackground)
get_action)Base)SendMessagec                       "   e Zd ZdZd fdd	Z  ZS )FlexSendMessagezFlexSendMessage.

    https://developers.line.biz/en/reference/messaging-api/#flex-message

    Flex Messages are messages with a customizable layout.
    You can customize the layout freely by combining multiple elements.
    Nc                    s:   t t| jdi | d| _|| _| |ttd| _dS )z__init__ method.

        :param str alt_text: Alternative text
        :param contents: Flex Message container object
        :type contents: :py:class:`linebot.models.flex_message.FlexContainer`
        :param kwargs:
        flex)bubblecarouselN )	superr   __init__typealt_text$get_or_new_from_json_dict_with_typesBubbleContainerCarouselContainercontents)selfr   r   kwargs	__class__r   ]/home/air/sanwanet/backup_V2/venv/lib/python3.10/site-packages/linebot/models/flex_message.pyr   %   s   
zFlexSendMessage.__init__NN__name__
__module____qualname____doc__r   __classcell__r   r   r   r   r          r   c                           e Zd ZdZ fddZ  ZS )FlexContainerzFlexContainer.

    https://developers.line.biz/en/reference/messaging-api/#container

    A container is the top-level structure of a Flex Message.
    c                        t t| jdi | d| _dS 1__init__ method.

        :param kwargs:
        Nr   )r   r&   r   r   r   r   r   r   r   r   A      
zFlexContainer.__init__r   r   r   r   r   r&   9       r&   c                       s&   e Zd ZdZ		d fdd	Z  ZS )r   zBubbleContainer.

    https://developers.line.biz/en/reference/messaging-api/#bubble

    This is a container that contains one message bubble.
    It can contain four blocks: header, hero, body, and footer.
    Nc	           
         s   t t| jdi |	 d| _|| _|| _| |t| _| 	|t
ttd| _| |t| _| |t| _| |t| _t|| _dS )aJ  __init__ method.

        :param str size: The size of the bubble. `nano`, `micro`, `kilo`, `mega`, or `giga`.
        :param str direction: Text directionality and the order of components
            in horizontal boxes in the container
        :param header: Header block
        :type header: :py:class:`linebot.models.flex_message.BoxComponent`
        :param hero: Hero block
        :type hero: :py:class:`linebot.models.flex_message.ImageComponent`
            | :py:class:`linebot.models.flex_message.BoxComponent`
            | :py:class:`linebot.models.flex_message.VideoComponent`
        :param body: Body block
        :type body: :py:class:`linebot.models.flex_message.BoxComponent`
        :param footer: Footer block
        :type footer: :py:class:`linebot.models.flex_message.BoxComponent`
        :param styles: Style of each block
        :type styles: :py:class:`linebot.models.flex_message.BubbleStyle`
        :param action: Action performed when this button is tapped
        :type action: list[T <= :py:class:`linebot.models.actions.Action`]
        :param kwargs:
        r   )imageboxvideoNr   )r   r   r   r   size	directionget_or_new_from_json_dictBoxComponentheaderr   ImageComponentVideoComponentherobodyfooterBubbleStylestylesr   action)
r   r0   r1   r4   r7   r8   r9   r;   r<   r   r   r   r   r   T   s    zBubbleContainer.__init__)NNNNNNNNr   r   r   r   r   r   K   s
    r   c                       r
   )r:   z[BubbleStyle.

    https://developers.line.biz/en/reference/messaging-api/#bubble-style
    Nc                    sR   t t| jdi | | |t| _| |t| _| |t| _| |t| _dS )a  __init__ method.

        :param header: Style of the header block
        :type header: :py:class:`linebot.models.flex_message.BlockStyle`
        :param hero: Style of the hero block
        :type hero: :py:class:`linebot.models.flex_message.BlockStyle`
        :param body: Style of the body block
        :type body: :py:class:`linebot.models.flex_message.BlockStyle`
        :param footer: Style of the footer block
        :type footer: :py:class:`linebot.models.flex_message.BlockStyle`
        :param kwargs:
        Nr   )	r   r:   r   r2   
BlockStyler4   r7   r8   r9   )r   r4   r7   r8   r9   r   r   r   r   r      s
   zBubbleStyle.__init__)NNNNr   r   r   r   r   r:   ~       r:   c                       r
   )r=   zYBlockStyle.

    https://developers.line.biz/en/reference/messaging-api/#block-style
    Nc                    s,   t t| jdi | || _|| _|| _dS )a  __init__ method.

        :param str background_color: Background color of the block. Use a hexadecimal color code
        :param bool separator: True to place a separator above the block
            True will be ignored for the first block in a container
            because you cannot place a separator above the first block.
            The default value is False
        :param str separator_color: Color of the separator. Use a hexadecimal color code
        :param kwargs:
        Nr   )r   r=   r   background_color	separatorseparator_color)r   r?   r@   rA   r   r   r   r   r      s   
zBlockStyle.__init__)NNNr   r   r   r   r   r=      r>   r=   c                       r
   )r   zCarouselContainer.

    https://developers.line.biz/en/reference/messaging-api/#f-carousel

    This is a container that contains multiple bubble containers, or message bubbles.
    The bubbles will be shown in order by scrolling horizontally.
    Nc                    sJ   t t| jdi | d| _g }|r |D ]}|| |t q|| _dS )z__init__ method.

        :param contents: Array of bubble containers
        :type contents: list[T <= :py:class:`linebot.models.flex_message.BubbleContainer`]
        :param kwargs:
        r   Nr   )r   r   r   r   appendr2   r   r   )r   r   r   new_contentsitr   r   r   r      s   
zCarouselContainer.__init__Nr   r   r   r   r   r      r$   r   c                       r%   )FlexComponentzFlexComponent.

    https://developers.line.biz/en/reference/messaging-api/#component

    Components are objects that compose a Flex Message container.
    c                    r'   r(   )r   rF   r   r   r*   r   r   r   r      r+   zFlexComponent.__init__r   r   r   r   r   rF      r,   rF   c                       sX   e Zd ZdZ																											d fdd	Z  ZS )r3   zBoxComponent.

    https://developers.line.biz/en/reference/messaging-api/#box

    This is a component that defines the layout of child components.
    You can also include a box in a box.
    Nc                    s
  t t| jdi | d| _|| _|| _|| _|| _|| _|| _	|| _
|
| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _|| _t|| _t|	dt i| _!g }|r|D ]}|"| |tt#t$t%t&t't(t)t*d	 qj|| _+dS )a	  __init__ method.

        :param str layout: The placement style of components in this box
        :param contents: Components in this box
        :type contents: list[T <= :py:class:`linebot.models.flex_message.FlexComponent`]
        :param str background_color: Background color of the block
        :param str border_color: Color of box border
        :param str border_width: Width of box border
        :param str corner_radius: Radius at the time of rounding the corners of the border
        :param str justify_content: How child elements are aligned along the main axis of
            the parent element
        :param str align_items: How child elements are aligned along the cross axis of
            the parent element
        :param background: Background object
        :type background: T <= :py:class:`linebot.models.background.Background`
        :param str width: Width of the box
        :param str max_width: Maximum width of the box
        :param str height: Height of the box
        :param str max_height: Maximum height of the box
        :param float flex: The ratio of the width or height of this box within the parent box
            and the previous component in the parent box
        :param str spacing: Minimum space between components in this box
        :param str margin: Minimum space between this box
        :param str padding_all: Free space between the borders of this box and the child element
        :param str padding_top: Free space between the border at the upper end of this box
            and the upper end of the child element
        :param str padding_bottom: Free space between the border at the lower end of this box
            and the lower end of the child element
        :param str padding_start: Free space between the border at the left end of this box
            and the left end of the child element
        :param str padding_end: Free space between the border at the right end of this box
            and the right end of the child element
        :param str position: Reference position for placing this box
        :param str offset_top: The top offset
        :param str offset_bottom: The bottom offset
        :param str offset_start: The left offset
        :param str offset_end: The right offset
        :param action: Action performed when this button is tapped
        :type action: list[T <= :py:class:`linebot.models.actions.Action`]
        :param kwargs:
        r.   linearGradient)	r.   buttonfillericonr-   spanr@   textr/   Nr   ),r   r3   r   r   layoutr?   border_colorborder_widthcorner_radiusjustify_contentalign_itemswidth	max_widthheight
max_heightr   spacingmarginpadding_allpadding_toppadding_bottompadding_startpadding_endposition
offset_topoffset_bottomoffset_start
offset_endr   r<   r   r   r   
backgroundrB   ButtonComponentFillerComponentIconComponentr5   SpanComponentSeparatorComponentTextComponentr6   r   )r   rM   r   r?   rN   rO   rP   rQ   rR   rc   rS   rT   rU   rV   r   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   r<   r   rC   rD   r   r   r   r      s^   F

zBoxComponent.__init__)NNNNNNNNNNNNNNNNNNNNNNNNNNNr   r   r   r   r   r3      s<    	r3   c                       s<   e Zd ZdZ													d fdd	Z  ZS )rd   zButtonComponent.

    https://developers.line.biz/en/reference/messaging-api/#button

    This component draws a button.
    When the user taps a button, a specified action is performed.
    Nc                    sr   t t| jdi | d| _t|| _|| _|| _|| _|| _	|| _
|| _|| _|	| _|
| _|| _|| _|| _dS )aJ  __init__ method.

        :param action: Action performed when this button is tapped
        :type action: list[T <= :py:class:`linebot.models.actions.Action`]
        :param float flex: The ratio of the width or height of this component within the parent box
        :param str margin: Minimum space between this component
            and the previous component in the parent box
        :param str position: Reference position for placing this box
        :param str offset_top: The top offset
        :param str offset_bottom: The bottom offset
        :param str offset_start: The left offset
        :param str offset_end: The right offset
        :param str height: Height of the button
        :param str style: Style of the button
        :param str color: Character color when the style property is link.
            Background color when the style property is primary or secondary.
            Use a hexadecimal color code
        :param str gravity: Vertical alignment style
        :param str adjust_mode: The method by which to adjust the text font size
        :param kwargs:
        rH   Nr   )r   rd   r   r   r   r<   r   rX   r^   r_   r`   ra   rb   rU   stylecolorgravityadjust_mode)r   r<   r   rX   r^   r_   r`   ra   rb   rU   rj   rk   rl   rm   r   r   r   r   r   i  s   $

zButtonComponent.__init__)NNNNNNNNNNNNNr   r   r   r   r   rd   `  s     	rd   c                       r
   )re   zFillerComponent.

    https://developers.line.biz/en/reference/messaging-api/#filler

    This is an invisible component to fill extra space between components.
    Nc                    s&   t t| jdi | d| _|| _dS )r)   rI   Nr   )r   re   r   r   r   )r   r   r   r   r   r   r     s   
zFillerComponent.__init__rE   r   r   r   r   r   re         re   c                       s4   e Zd ZdZ									d fdd	Z  ZS )rf   zxIconComponent.

    https://developers.line.biz/en/reference/messaging-api/#icon

    This component draws an icon.
    Nc
                    sV   t t| jdi |
 d| _|| _|| _|| _|| _|| _|| _	|| _
|| _|	| _dS )a  __init__ method.

        :param str url: Image URL
            Protocol: HTTPS
            Image format: JPEG or PNG
        :param str margin: Minimum space between this component
            and the previous component in the parent box
        :param str position: Reference position for placing this box
        :param str offset_top: The top offset
        :param str offset_bottom: The bottom offset
        :param str offset_start: The left offset
        :param str offset_end: The right offset
        :param str size: Maximum size of the icon width
        :param str aspect_ratio: Aspect ratio of the icon
        :param kwargs:
        rJ   Nr   )r   rf   r   r   urlrX   r^   r_   r`   ra   rb   r0   aspect_ratio)r   ro   rX   r^   r_   r`   ra   rb   r0   rp   r   r   r   r   r     s   
zIconComponent.__init__)	NNNNNNNNNr   r   r   r   r   rf     s    rf   c                       sB   e Zd ZdZ																d fdd	Z  ZS )r5   z}ImageComponent.

    https://developers.line.biz/en/reference/messaging-api/#f-image

    This component draws an image.
    NFc                    s   t t| jdi | d| _|| _|| _|| _|| _|| _|| _	|| _
|| _|	| _|
| _|| _|| _|| _|| _t|| _|| _dS )a  __init__ method.

        :param str url: Image URL
            Protocol: HTTPS
            Image format: JPEG or PNG
        :param float flex: The ratio of the width or height of this component within the parent box
        :param str margin: Minimum space between this component
            and the previous component in the parent box
        :param str position: Reference position for placing this box
        :param str offset_top: The top offset
        :param str offset_bottom: The bottom offset
        :param str offset_start: The left offset
        :param str offset_end: The right offset
        :param str align: Horizontal alignment style
        :param str gravity: Vertical alignment style
        :param str size: Maximum size of the image width
        :param str aspect_ratio: Aspect ratio of the image
        :param str aspect_mode: Style of the image
        :param str background_color: Background color of the image. Use a hexadecimal color code.
        :param action: Action performed when this image is tapped
        :type action: list[T <= :py:class:`linebot.models.actions.Action`]
        :param bool animated: True to play an animated image. Default is False.
        :param kwargs:
        r-   Nr   )r   r5   r   r   ro   r   rX   r^   r_   r`   ra   rb   alignrl   r0   rp   aspect_moder?   r   r<   animated)r   ro   r   rX   r^   r_   r`   ra   rb   rq   rl   r0   rp   rr   r?   r<   rs   r   r   r   r   r     s$   *

zImageComponent.__init__)NNNNNNNNNNNNNNNFr   r   r   r   r   r5     s&    r5   c                       r
   )rh   zSeparatorComponent.

    https://developers.line.biz/en/reference/messaging-api/#separator

    This component draws a separator between components in the parent box.
    Nc                    s,   t t| jdi | d| _|| _|| _dS )z__init__ method.

        :param str margin: Minimum space between this component
            and the previous component in the parent box
        :param str color: Color of the separator. Use a hexadecimal color code
        :param kwargs:
        r@   Nr   )r   rh   r   r   rX   rk   )r   rX   rk   r   r   r   r   r   .  s   
zSeparatorComponent.__init__r   r   r   r   r   r   rh   &  rn   rh   c                       s.   e Zd ZdZ						d fdd	Z  ZS )rg   zSpanComponent.

    https://developers.line.biz/en/reference/messaging-api/#span

    This component renders multiple text strings with different designs in one row.
    Nc                    sD   t t| jdi | d| _|| _|| _|| _|| _|| _|| _	dS )a   __init__ method.

        :param str text: Text
        :param str color: Font color
        :param str size: Font size
        :param str weight: Font weight
        :param str style: Style of the text
        :param str decoration: Decoration of the text
        :param kwargs:
        rK   Nr   )
r   rg   r   r   rL   r0   weightrk   rj   
decoration)r   rL   rk   r0   rt   rj   ru   r   r   r   r   r   D  s   
zSpanComponent.__init__)NNNNNNr   r   r   r   r   rg   <  s    rg   c                       sJ   e Zd ZdZ																				d fdd	Z  ZS )ri   zTextComponent.

    https://developers.line.biz/en/reference/messaging-api/#f-text

    This component draws text. You can format the text.
    Nc                    s   t t jdi | d _| _| _| _| _| _| _	| _
|	 _|
 _| _| _| _| _| _| _| _t| _| _| _|rW fdd|D  _dS d _dS )a  __init__ method.

        :param str text: Text
        :param contents: Array of spans
        :type contents: list[T <= :py:class:`linebot.models.flex_message.SpanComponent`]
        :param float flex: The ratio of the width or height of this component within the parent box
        :param str margin: Minimum space between this component
            and the previous component in the parent box
        :param str position: Reference position for placing this box
        :param str offset_top: The top offset
        :param str offset_bottom: The bottom offset
        :param str offset_start: The left offset
        :param str offset_end: The right offset
        :param str size: Font size
        :param str align: Horizontal alignment style
        :param str gravity: Vertical alignment style
        :param bool wrap: rue to wrap text. The default value is False.
            If set to True, you can use a new line character (\n) to begin on a new line.
        :param str line_spacing: Line spacing in a wrapping text
        :param int max_lines: Max number of lines
        :param str weight: Font weight
        :param str color: Font color
        :param action: Action performed when this image is tapped
        :type action: list[T <= :py:class:`linebot.models.actions.Action`]
        :param str style: Style of the text
        :param str decoration: Decoration of the text
        :param kwargs:
        rL   c                    s   g | ]}  |tqS r   )r2   rg   ).0rD   r   r   r   
<listcomp>  s    z*TextComponent.__init__.<locals>.<listcomp>Nr   )r   ri   r   r   rL   r   rX   r^   r_   r`   ra   rb   r0   rq   rl   wrapline_spacing	max_linesrt   rk   r   r<   rj   ru   r   )r   rL   r   r   rX   r^   r_   r`   ra   rb   r0   rq   rl   ry   rz   r{   rt   rk   r<   rj   ru   r   r   rw   r   r   h  s0   2

zTextComponent.__init__)NNNNNNNNNNNNNNNNNNNNr   r   r   r   r   ri   `  s.    ri   c                       s,   e Zd ZdZ					d fdd	Z  ZS )r6   z~VideoComponent.

    https://developers.line.biz/en/reference/messaging-api/#f-video

    This component renders a video.
    Nc                    sP   t t| jdi | d| _|| _|| _| |ttd| _	|| _
t|| _dS )a  __init__ method.

        :param str url: URL of video file
        :param str preview_url: URL of preview image
        :param alt_content: Alternative content
        :type alt_content: :py:class:`linebot.models.flex_message.ImageComponent`
            | :py:class:`linebot.models.flex_message.BoxComponent`
        :param float aspect_ratio: Aspect ratio of the video
        :param action: Action performed when this video is tapped
        :type action: list[T <= :py:class:`linebot.models.actions.Action`]
        :param kwargs:
        r/   )r-   r.   Nr   )r   r6   r   r   ro   preview_urlr   r5   r3   alt_contentrp   r   r<   )r   ro   r|   r}   rp   r<   r   r   r   r   r     s   zVideoComponent.__init__)NNNNNr   r   r   r   r   r6     s    r6   N)r"   abcr   future.utilsr   rc   r   r   actionsr   baser   send_messagesr	   r   r&   r   r:   r=   r   rF   r3   rd   re   rf   r5   rh   rg   ri   r6   r   r   r   r   <module>   s0   3 >0F$V