
    F2j:                     x    d Z ddlmZmZ ddlmZ ddlmZ ddlm	Z	m
Z
 ddlmZmZmZ  G d de          ZdgZd	S )
zTEXT values from :rfc:`5545`.    )AnyClassVar)Self)JCalParsingError)
Parameters_escape_char)DEFAULT_ENCODING	ICAL_TYPE
to_unicodec            	       b    e Zd ZU dZdZee         ed<   eed<   dZ	e
dfdeeef         dz  deded	ef fd
Zd	efdZd	efdZeded	efd            Zed	efd            ZddlmZmZmZmZmZ ded	efdZed	ee         fd            Zeded	efd            Z eded	efd            Z! xZ"S )vTexta  vText is a data type that contains human-readable text values.

    The vText property uses the :rfc:`5545#section-3.3.11` TEXT value type
    in various icalendar properties to show free-form text that others can read.
    This class can be created from Python strings, and can be used to add text
    descriptions to calendar events.

    To create a TEXT object, pass in the string you want when creating the
    object.

    To add a line break, use ``\n`` or ``\N``.

    Use the LANGUAGE property parameter to set the language of the text.

    When the TEXT object is serialized to an icalendar stream, certain
    characters are escaped or changed.
    These characters include the COMMA, SEMICOLON, BACKSLASH, and line breaks.

    Examples:

        vText property as a TEXT value type.

        .. code-block:: text

            Project XYZ Final Review\nConference Room - 3B\nCome Prepared.

        Create a vText property, and display it in a readable format.

        .. code-block:: pycon

            >>> from icalendar.prop import vText
            >>> desc = 'Project XYZ Final Review\nConference Room - 3B\nCome Prepared.'
            >>> text = vText(desc)
            >>> text
            vText(b'Project XYZ Final Review\\nConference Room - 3B\\nCome Prepared.')
            >>> print(text.ical_value)
            Project XYZ Final Review
            Conference Room - 3B
            Come Prepared.

        Add a SUMMARY to an event, then display its value as a vText property then in a readable format:

        .. code-block:: pycon

            >>> from icalendar import Event
            >>> event = Event()
            >>> event.add('SUMMARY', desc)
            >>> event['SUMMARY']
            vText(b'Project XYZ Final Review\\nConference Room - 3B\\nCome Prepared.')
            >>> print(event.to_ical().decode())
            BEGIN:VEVENT
            SUMMARY:Project XYZ Final Review\nConference Room - 3B\nCome Prepared.
            END:VEVENT

    TEXTdefault_valueparams)encodingr   Nvaluer   returnc                    t          ||          }t                                          | |          }||_        t	          |          |_        |S )N)r   )r   super__new__r   r   r   )clsr   r   r   self	__class__s        [/home/thesage/.hermes/hermes-agent/venv/lib/python3.11/site-packages/icalendar/prop/text.pyr   zvText.__new__H   sI     58444wwsE**  ((    c                 2    d|                                  dS )NzvText())to_icalr   s    r   __repr__zvText.__repr__U   s    +++++r   c                 P    t          |                               | j                  S N)r   encoder   r   s    r   r   zvText.to_icalX   s     D!!((777r   icalc                      | |          S r"    )r   r$   s     r   	from_icalzvText.from_ical[   s    s4yyr   c                      t          |           S )zThe string value of the text.)strr   s    r   
ical_valuezvText.ical_value_   s     4yyr   r   )ALTREPGAPLANGUAGERELTYPEVALUEnamec                     |dk    r|i d|                      dd          gS || j                                        | j                                        t          |           gS )zBThe jCal representation of this property according to :rfc:`7265`.request-statustext;   )splitr   to_jcalr/   lowerr)   )r   r0   s     r   r7   zvText.to_jcalf   s\    ###"fdjja&8&899dk))++TZ-=-=-?-?TKKr   c                      | d          gS )zExamples of vText.zHello World!r&   )r   s    r   exampleszvText.examplesl   s     N##$$r   jcal_propertyc                    t          j        ||            |d         }|dk    rddlm} |                    |          S |d         }|dk    r=t          j        |d         t          | d           d                    |d                   }t          j        |t          | d            | |t          j
        |                    S )zParse jCal from :rfc:`7265`.

        Parameters:
            jcal_property: The jCal property to parse.

        Raises:
            ~error.JCalParsingError: If the provided jCal is invalid.
        r   
categories)	vCategory   r2   r4   )r   )r   validate_propertyicalendar.propr>   	from_jcalvalidate_list_typer)   joinvalidate_value_typer   from_jcal_property)r   r;   r0   r>   strings        r   rB   zvText.from_jcalq   s     	*=#>>>Q<000000&&}555q!###/a0@#sANNNXXmA.//F,VS#qAAAs0??
 
 
 	
r   
jcal_valuec                     t          j        |t          t          t          f|             | t          |                    S )z Parse a jCal value into a vText.)r   rE   r)   intfloat)r   rH   s     r   parse_jcal_valuezvText.parse_jcal_value   s6     	,Z#sE9JCPPPs3z??###r   )#__name__
__module____qualname____doc__r   r   r)   __annotations__r   	__slots__r	   dictr   r
   r   r   r    bytesr   classmethodr'   propertyr*   icalendar.paramr+   r,   r-   r.   r/   listr7   r:   rB   rL   __classcell__)r   s   @r   r   r      s        6 6p $*M8C=)))&I
 )(, 
 S#X%  
     ,# , , , ,8 8 8 8 8 Y 4    [ C    X FEEEEEEEEEEEEELC LD L L L L %d % % % [% 
d 
t 
 
 
 [
2 $# $$ $ $ $ [$ $ $ $ $r   r   N)rP   typingr   r   icalendar.compatibilityr   icalendar.errorr   icalendar.parserr   r   icalendar.parser_toolsr	   r
   r   r)   r   __all__r&   r   r   <module>r`      s    # #                 ( ( ( ( ( ( , , , , , , 5 5 5 5 5 5 5 5 J J J J J J J J J JD$ D$ D$ D$ D$C D$ D$ D$N )r   