a
    Cg                     @   sf   d dl mZmZ d dl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 G dd dZd	S )
    )ListSequence)Command)INLINE_STYLES)DOM)Options
OptionsMap)BlockElementc                   @   sZ   e Zd ZdZdZeddddZedddd	Ze	d
ddZ
eeee edddZdS )
StyleStatez
    Handles the creation of inline styles on elements.
    Receives inline_style commands, and generates the element's `style`
    attribute from those.
    stylesstyle_optionsN)r   returnc                 C   s   g | _ || _d S Nr   )selfr    r   [/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/draftjs_exporter/style_state.py__init__   s    zStyleState.__init__)commandr   c                 C   s6   |j dkr| j|j n|j dkr2| j|j d S )NZstart_inline_styleZstop_inline_style)namer   appenddataremove)r   r   r   r   r   apply   s    

zStyleState.apply)r   c                 C   s   | j  S r   )r   )r   r   r   r   is_empty   s    zStyleState.is_empty)decorated_nodeblockblocksr   c                 C   sr   |}|   sn| jjdd | jD ]L}t| j|tj}t|j	}||d< ||d< d|i|d< t
|j||}q |S )NT)reverser   r   styleZinline_style_range)r   r   sortr   getr   r   ZFALLBACKdictpropsr   Zcreate_elementelement)r   r   r   r   noder    optionsr$   r   r   r   render_styles    s    

zStyleState.render_styles)__name__
__module____qualname____doc__	__slots__r   r   r   r   boolr   r
   r	   r   r(   r   r   r   r   r   
   s   
r   N)typingr   r   Zdraftjs_exporter.commandr   Zdraftjs_exporter.constantsr   Zdraftjs_exporter.domr   Zdraftjs_exporter.optionsr   r   Zdraftjs_exporter.typesr	   r
   r   r   r   r   r   <module>   s   