a
    Dg^                     @   s@  d dl Z d dlZd dl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 d dlmZ d dlmZ d dlmZ d d	l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!m"Z"m#Z#m$Z$m%Z% g dZ&G dd deZ'G dd de Z(G dd de(e"dZ)G dd deZ*G dd deZ+ee+ e) dS )    N)OrderedDictdefaultdict)MappingMutableSequence)PickleError)forms)ValidationError)_load_field)	ErrorList)cached_propertyformat_html_join)gettext)versioned_static)Adapterregister   )Block
BoundBlockDeclarativeSubBlocksMetaclassget_error_json_dataget_error_list_json_dataget_help_icon)BaseStreamBlockStreamBlockStreamValueStreamBlockValidationErrorc                       s&   e Zd Zd fdd	Zdd Z  ZS )r   Nc                    s~   t || _i | _|d u rnT| D ]J\}}t|t rH| d | j|< q"t|trb|d | j|< q"|| j|< q"t d d S )Nr   zValidation error in StreamBlock)	r
   non_block_errorsblock_errorsitems
isinstanceZas_datalistsuper__init__)selfr   r   indexval	__class__ Z/var/www/lab.imftr.de/x/nb_venv/lib/python3.9/site-packages/wagtail/blocks/stream_block.pyr#   %   s    



z#StreamBlockValidationError.__init__c                 C   s:   i }| j rt| j |d< | jr6dd | j D |d< |S )Nmessagesc                 S   s   i | ]\}}|t |qS r)   )r   ).0r%   errorr)   r)   r*   
<dictcomp>G   s   z;StreamBlockValidationError.as_json_data.<locals>.<dictcomp>ZblockErrors)r   r   r   r   )r$   resultr)   r)   r*   as_json_dataB   s    
z'StreamBlockValidationError.as_json_data)NN)__name__
__module____qualname__r#   r0   __classcell__r)   r)   r'   r*   r   $   s   r   c                       s   e Zd Zd4 fdd	Zedd Zd5ddZd	d
 Zdd Zdd Z	dd Z
edd Zdd Zdd Zdd Zdd Zdd Zdd Zd6dd Zd7d!d"Zd#d$ Zd%d& Zd'd( Zd)d* Zd+d, Z fd-d.Zed/d0 ZG d1d2 d2Zg d3Z  ZS )8r   NTc                    sT   || _ || _t jf i | | j | _|rP|D ]\}}|| || j|< q2d S N)_constructor_kwargssearch_indexr"   r#   Zbase_blockscopychild_blocksset_name)r$   Zlocal_blocksr7   kwargsnameblockr'   r)   r*   r#   O   s    
zBaseStreamBlock.__init__c                    s&   |r fdd|D }| |fi |S )Nc                    s   g | ]\}}|  |fqS r)   )Z	get_block)r,   r<   r%   lookupr)   r*   
<listcomp>_   s   z9BaseStreamBlock.construct_from_lookup.<locals>.<listcomp>r)   )clsr?   r9   r;   r)   r>   r*   construct_from_lookup\   s
    
z%BaseStreamBlock.construct_from_lookupc                 C   s   t | g |dS )Nraw_textr   )r$   rD   r)   r)   r*   empty_valued   s    zBaseStreamBlock.empty_valuec                 C   s   t | j dd dS )z(Child blocks, sorted in to their groups.c                 S   s   | j jS r5   metagroupchild_blockr)   r)   r*   <lambda>j       z5BaseStreamBlock.sorted_child_blocks.<locals>.<lambda>key)sortedr9   valuesr$   r)   r)   r*   sorted_child_blocksg   s    z#BaseStreamBlock.sorted_child_blocksc                 C   s   t j|  dd dS )z
        The available child block types of this stream block, organised into groups according to
        their meta.group attribute.
        Returned as an iterable of (group_name, list_of_blocks) tuples
        c                 S   s   | j jS r5   rG   rJ   r)   r)   r*   rL   t   rM   z6BaseStreamBlock.grouped_child_blocks.<locals>.<lambda>rN   )	itertoolsgroupbyrS   rR   r)   r)   r*   grouped_child_blocksm   s    z$BaseStreamBlock.grouped_child_blocksc           	      C   s   t |d|  }g }td|D ]}|d||f  r4q|d||f  }z| j| }W n tyh   Y qY n0 |t |d||f  ||||d||f |d||f f q|  t| dd	 |D S )
N%s-countr   z%s-%d-deletedz
%s-%d-typez%s-%d-orderz%s-%d-valuez%s-%d-idc                 S   s   g | ]\}}}}|||fqS r)   r)   )r,   r%   Zchild_block_type_namevalueblock_idr)   r)   r*   r@      s   z7BaseStreamBlock.value_from_datadict.<locals>.<listcomp>)	intranger9   KeyErrorappendvalue_from_datadictgetsortr   )	r$   datafilesprefixcountZvalues_with_indexesiZblock_type_namerK   r)   r)   r*   r^   w   s4    
z#BaseStreamBlock.value_from_datadictc                 C   s   d| |vS )NrW   r)   )r$   ra   rb   rc   r)   r)   r*   value_omitted_from_data   s    z'BaseStreamBlock.value_omitted_from_datac                 C   s   | j jS r5   )rH   requiredrR   r)   r)   r*   rg      s    zBaseStreamBlock.requiredc                 C   s  g }i }t  }t|D ]Z\}}z$||jj|j|j|jf W q tyn } z|||< W Y d }~qd }~0 0 q| j	j
d ur| j	j
t|kr|ttdd| j	j
i  n$| jrt|dkr|ttd | j	jd ur| j	jt|k r|ttdd| j	ji  | j	jrtt}|D ]}	||	j  d7  < q&| j	j D ]\}
}| j|
 }|dd }|dd }||
 }|d ur||kr|td|jtdd|i  |d urL||k rL|td|jtdd|i  qL|s|r
t||d	t| |S )
Nz*The minimum number of items is %(min_num)dmin_numr   zThis field is required.z*The maximum number of items is %(max_num)dmax_numr   z{}: {})r   r   )r
   	enumerater]   r=   r<   cleanrX   idr   rH   rh   len_rg   ri   block_countsr   rZ   
block_typer   r9   r_   formatlabelr   r   )r$   rX   Zcleaned_dataerrorsr   re   childero   item
block_nameZmin_maxr=   ri   rh   Zblock_countr)   r)   r*   rk      s     
 


	
zBaseStreamBlock.cleanc              
      s   t |tr|S t |trJ|rJzt|}W n tyH    j|d Y S 0 |sV  S t|}t |d trt  fdd|D ddS zdd |D  W nD t	tfy } z(t	d|d	t
|d
|W Y d }~n
d }~0 0 t  fdd|D S d S )NrC   r   c                    s   g | ]}|d   j v r|qS )type)r9   )r,   Z
child_datarR   r)   r*   r@     s   z-BaseStreamBlock.to_python.<locals>.<listcomp>Tis_lazyc                 S   s   g | ]\}}d qS r5   r)   )r,   xyr)   r)   r*   r@     rM   zCannot handle z (type z) as a value of a StreamBlockc                    s.   g | ]&\}}| j v r| j | |fqS r)   )r9   	normalize)r,   kvrR   r)   r*   r@     s   
)r    r   strjsonloads
ValueErrorrF   r!   dict	TypeErrorrx   )r$   rX   excr)   rR   r*   	to_python   s@    


zBaseStreamBlock.to_pythonc           
         s   t t}g }|D ]d}g }|D ]L}|d }|jvr4q|| }t|}	||d  |||d|	f q|| qfdd| D   fdd|D S )Nrx   rX   rl   c                    s"   i | ]\}}| j | |qS r)   )r9   bulk_to_python)r,   rp   child_input_listrR   r)   r*   r.   =  s   z2BaseStreamBlock.bulk_to_python.<locals>.<dictcomp>c                    s(   g | ] }t  fd d|D ddqS )c                    s$   g | ]\}}}| | | |fqS r)   r)   )r,   rp   rl   child_index)child_outputsr)   r*   r@   G  s   z=BaseStreamBlock.bulk_to_python.<locals>.<listcomp>.<listcomp>Fry   rE   )r,   	block_mapr   r$   r)   r*   r@   D  s   	
z2BaseStreamBlock.bulk_to_python.<locals>.<listcomp>)r   r!   r9   rm   r]   r_   r   )
r$   rQ   Zchild_inputsZ
block_mapsstreamr   Z
block_dictrp   r   r   r)   r   r*   r     s&    	

	zBaseStreamBlock.bulk_to_pythonc                 C   s   |sg S |  S d S r5   )get_prep_valuer$   rX   r)   r)   r*   r   P  s    zBaseStreamBlock.get_prep_valuec                 C   s
   |  |S r5   )r   r   r)   r)   r*   r}   [  s    zBaseStreamBlock.normalizec                 C   s   |sg S dd |D S d S )Nc                 S   s(   g | ] }|j j|j |j|jd qS )rx   rX   rl   )r=   r<   get_form_staterX   rl   r,   rt   r)   r)   r*   r@   b  s
   z2BaseStreamBlock.get_form_state.<locals>.<listcomp>r)   r   r)   r)   r*   r   ^  s
    zBaseStreamBlock.get_form_statec                    s   |d u rg S  fdd|D S )Nc                    s,   g | ]$}|j j|j j|j d |jdqS )contextr   )r=   r<   get_api_representationrX   rl   r   r   r)   r*   r@   p  s   z:BaseStreamBlock.get_api_representation.<locals>.<listcomp>r)   r$   rX   r   r)   r   r*   r   k  s
    
z&BaseStreamBlock.get_api_representationc                    s   t dd fdd|D S )N
z <div class="block-{1}">{0}</div>c                    s   g | ]}|j  d |jfqS )r   )renderrp   r   r   r)   r*   r@     rM   z0BaseStreamBlock.render_basic.<locals>.<listcomp>r   r   r)   r   r*   render_basic{  s
    zBaseStreamBlock.render_basicc                 C   s0   | j s
g S g }|D ]}||j|j q|S r5   )r7   extendr=   get_searchable_contentrX   )r$   rX   contentrt   r)   r)   r*   r     s    z&BaseStreamBlock.get_searchable_contentc                 c   sl   |D ]b}|j |jD ]N\}}}}|r6|j d| n|j}|rP|j d| n|j}||||fV  qqd S )N.)r=   extract_referencesrX   rp   rl   )r$   rX   rt   modelZ	object_idZ
model_pathZcontent_pathr)   r)   r*   r     s    z"BaseStreamBlock.extract_referencesc                 C   sD   |r6|^}}|D ]"}|j |kr|j|j|  S qn
| |S dS )z
        Given a list of elements from a content path, retrieve the block at that path
        as a BoundBlock object, or None if the path does not correspond to a valid block.
        N)rl   r=   get_block_by_content_pathrX   bind)r$   rX   Zpath_elementsrl   Zremaining_elementsrt   r)   r)   r*   r     s    
z)BaseStreamBlock.get_block_by_content_pathc                 C   s$   d}t | j g}| j}|||fS )a  
        Always deconstruct StreamBlock instances as if they were plain StreamBlocks with all of the
        field definitions passed to the constructor - even if in reality this is a subclass of StreamBlock
        with the fields defined declaratively, or some combination of the two.

        This ensures that the field definitions get frozen into migrations, rather than leaving a reference
        to a custom subclass in the user's models.py that may or may not stick around.
        wagtail.blocks.StreamBlock)r!   r9   r   r6   )r$   pathargsr;   r)   r)   r*   deconstruct  s    	zBaseStreamBlock.deconstructc                    s.   d} fdd| j  D g}| j}|||fS )Nr   c                    s   g | ]\}}|  |fqS r)   )Z	add_block)r,   r<   r=   r>   r)   r*   r@     s   z;BaseStreamBlock.deconstruct_with_lookup.<locals>.<listcomp>)r9   r   r6   )r$   r?   r   r   r;   r)   r>   r*   deconstruct_with_lookup  s    
z'BaseStreamBlock.deconstruct_with_lookupc                    sV   t  jf i |}| j D ]4\}}||jf i | ||jf i | q|S r5   )r"   checkr9   r   r   _check_name)r$   r;   rs   r<   rK   r'   r)   r*   r     s
    zBaseStreamBlock.checkc                 C   s   | j jtjjuS r5   )rH   defaultr   Z_meta_classrR   r)   r)   r*   _has_default  s    zBaseStreamBlock._has_defaultc                   @   s,   e Zd ZdZg ZdZdZdZdZi Z	dZ
dS )zBaseStreamBlock.MetaplaceholderTNF)r1   r2   r3   iconr   rg   form_classnamerh   ri   ro   	collapsedr)   r)   r)   r*   Meta  s   r   )rg   rh   ri   ro   r   )NT)N)N)N) r1   r2   r3   r#   classmethodrB   rF   rS   rV   r^   rf   propertyrg   rk   r   r   r   r}   r   r   r   r   r   r   r   r   r   r   r   r   ZMUTABLE_META_ATTRIBUTESr4   r)   r)   r'   r*   r   N   s8   


%
F61



r   c                   @   s   e Zd ZdS )r   N)r1   r2   r3   r)   r)   r)   r*   r     s   r   )	metaclassc                   @   s   e Zd ZdZG dd deZG dd deZG dd deZ	d0d
dZ
dd Zdd Zdd Zdd Zdd Zedd Zdd Zdd Zd1ddZd2ddZd d! Zd"d# Zd$d% Zd3d&d'Zd(d) Zd*d+ Zed,d- Zd.d/ Zd	S )4r   z
    Custom type used to represent the value of a StreamBlock; behaves as a sequence of BoundBlocks
    (which keep track of block types in a way that the values alone wouldn't).
    c                       s<   e Zd ZdZ fddZedd Zdd Zdd	 Z  Z	S )
zStreamValue.StreamChilda  
        Iterating over (or indexing into) a StreamValue returns instances of StreamChild.
        These are wrappers for the individual data items in the stream, extending BoundBlock
        (which keeps track of the data item's corresponding Block definition object, and provides
        the `render` method to render itself with a template) with an `id` property (a UUID
        assigned to the item - this is managed by the enclosing StreamBlock and is not a property
        of blocks in general) and a `block_type` property.
        c                    s"   | d| _t j|i | d S Nrl   )poprl   r"   r#   )r$   r   r;   r'   r)   r*   r#     s    z StreamValue.StreamChild.__init__c                 C   s   | j jS )a  
            Syntactic sugar so that we can say child.block_type instead of child.block.name.
            (This doesn't belong on BoundBlock itself because the idea of block.name denoting
            the child's "type" ('heading', 'paragraph' etc) is unique to StreamBlock, and in the
            wider context people are liable to confuse it with the block class (CharBlock etc).
            )r=   r<   rR   r)   r)   r*   rp     s    z"StreamValue.StreamChild.block_typec                 C   s   | j | j| j| jdS )Nr   )rp   r=   r   rX   rl   rR   r)   r)   r*   r     s    z&StreamValue.StreamChild.get_prep_valuec                 C   s*   | j r| jj| j| j fS | jj| jfS d S r5   )rl   r=   r<   rX   rR   r)   r)   r*   	_as_tuple  s    z!StreamValue.StreamChild._as_tuple)
r1   r2   r3   __doc__r#   r   rp   r   r   r4   r)   r)   r'   r*   StreamChild  s   	
	r   c                   @   sH   e Zd ZdZdd Zdd Zdd Zdd	 Zd
d Zdd Z	dd Z
dS )zStreamValue.RawDataViewa  
        Internal helper class to present the stream data in raw JSONish format. For backwards
        compatibility with old code that manipulated StreamValue.stream_data, this is considered
        mutable to some extent, with the proviso that once the BoundBlock representation has been
        accessed, any changes to fields within raw data will not propagate back to the BoundBlock
        and will not be saved back when calling get_prep_value.
        c                 C   s
   || _ d S r5   stream_value)r$   r   r)   r)   r*   r#   !  s    z StreamValue.RawDataView.__init__c                 C   s4   | j j| }|d u r0| j j|  }|| j j|< |S r5   )r   	_raw_data_bound_blocksr   r$   re   rv   r)   r)   r*   __getitem__$  s
    z#StreamValue.RawDataView.__getitem__c                 C   s   t | jjS r5   )rm   r   r   rR   r)   r)   r*   __len__-  s    zStreamValue.RawDataView.__len__c                 C   s   || j j|< d | j j|< d S r5   )r   r   r   r   r)   r)   r*   __setitem__0  s    z#StreamValue.RawDataView.__setitem__c                 C   s   | j |= d S r5   r   r$   re   r)   r)   r*   __delitem__5  s    z#StreamValue.RawDataView.__delitem__c                 C   s$   | j j|| | j j|d  d S r5   )r   r   insertr   r   r)   r)   r*   r   9  s    zStreamValue.RawDataView.insertc                 C   s   t t| S r5   )reprr!   rR   r)   r)   r*   __repr__=  s    z StreamValue.RawDataView.__repr__N)r1   r2   r3   r   r#   r   r   r   r   r   r   r)   r)   r)   r*   RawDataView  s   	r   c                   @   s2   e Zd ZdZdddZdd Zdd Zd	d
 ZdS )zStreamValue.BlockNameLookupz
        Dict-like object returned from `blocks_by_name`, for looking up a stream's blocks by name.
        Uses lazy evaluation on access, so that we're not redundantly constructing StreamChild
        instances for blocks of different names.
        Tc                 C   s   || _ |jj | _|| _d S r5   )r   stream_blockr9   keysblock_namesfind_all)r$   r   r   r)   r)   r*   r#   G  s    z$StreamValue.BlockNameLookup.__init__c                 C   s   | j r
g nd }|| jvr|S tt| jD ]X}| jj| d u rT| jj| d |krTq*| j| }|j|kr*| j rz|| q*|  S q*|S )Nrx   )	r   r   r[   rm   r   r   r   rp   r]   )r$   rw   r/   re   r=   r)   r)   r*   r   N  s    



z'StreamValue.BlockNameLookup.__getitem__c                 c   s   | j E d H  d S r5   )r   rR   r)   r)   r*   __iter__g  s    z$StreamValue.BlockNameLookup.__iter__c                 C   s
   t | jS r5   )rm   r   rR   r)   r)   r*   r   j  s    z#StreamValue.BlockNameLookup.__len__N)T)r1   r2   r3   r   r#   r   r   r   r)   r)   r)   r*   BlockNameLookup@  s
   
r   FNc                    sV   | _ | _| _|r.| _dgt|  _n$dgt|  _ fdd|D  _dS )a  
        Construct a StreamValue linked to the given StreamBlock,
        with child values given in stream_data.

        Passing is_lazy=True means that stream_data is raw JSONish data as stored
        in the database, and needs to be converted to native values
        (using block.to_python()) when accessed. In this mode, stream_data is a
        list of dicts, each containing 'type' and 'value' keys.

        Passing is_lazy=False means that stream_data consists of immediately usable
        native values. In this mode, stream_data is a list of (type_name, value)
        or (type_name, value, id) tuples.

        raw_text exists solely as a way of representing StreamField content that is
        not valid JSON; this may legitimately occur if an existing text field is
        migrated to a StreamField. In this situation we return a blank StreamValue
        with the raw text accessible under the `raw_text` attribute, so that migration
        code can be rewritten to convert it as desired.
        Nc                    s   g | ]}  |qS r)   )_construct_stream_child)r,   rv   rR   r)   r*   r@     s   z(StreamValue.__init__.<locals>.<listcomp>)r   rz   rD   r   rm   r   )r$   r   Zstream_datarz   rD   r)   rR   r*   r#   m  s    
zStreamValue.__init__c                 C   sZ   t |tjr|S z|\}}}W n ty<   |\}}d}Y n0 | jj| }tj|||dS )z
        Create a StreamChild instance from a (type, value, id) or (type, value) tuple,
        or return item if it's already a StreamChild
        Nrl   )r    r   r   r   r   r9   )r$   rv   	type_namerX   rY   Z	block_defr)   r)   r*   r     s    
z#StreamValue._construct_stream_childc                    sj   t |tr:|t j\}}} fddt|||D S  j| d u r` j| } |d   j| S )Nc                    s   g | ]} | qS r)   r)   )r,   jrR   r)   r*   r@     rM   z+StreamValue.__getitem__.<locals>.<listcomp>rx   )r    sliceindicesrm   r   r[   r   _prefetch_blocks)r$   re   startstopstep	raw_valuer)   rR   r*   r     s    

zStreamValue.__getitem__c                 C   s   |  || j|< d S r5   )r   r   r   r)   r)   r*   r     s    zStreamValue.__setitem__c                 C   s   | j |= | j|= d S r5   )r   r   r   r)   r)   r*   r     s    zStreamValue.__delitem__c                 C   s&   | j || | | j|d  d S r5   )r   r   r   r   r   r)   r)   r*   r     s    zStreamValue.insertc                 C   s
   t | S r5   )r   r   rR   r)   r)   r*   raw_data  s    zStreamValue.raw_datac                    sv    j j }t fddt jD }|| }t| |D ]*\}}t	j
|| j| dd j|< qFdS )a7  
        Populate _bound_blocks with all items in this stream of type `type_name` that exist in
        _raw_data but do not already exist in _bound_blocks.

        Fetching is done via the block's bulk_to_python method, so that database lookups are
        batched into a single query where possible.
        c                 3   s8   | ]0\}} j | d u r|d kr||d fV  qd S )Nrx   rX   )r   )r,   re   raw_itemr$   r   r)   r*   	<genexpr>  s   z/StreamValue._prefetch_blocks.<locals>.<genexpr>rl   r   N)r   r9   r   rj   r   r   rQ   zipr   r   r   r_   r   )r$   r   rK   Z
raw_valuesZconverted_valuesre   rX   r)   r   r*   r     s    zStreamValue._prefetch_blocksc                 C   sr   g }t | jD ]^\}}|r>|js.tt |_||  q| j| }|	dsbtt |d< || q|S r   )
rj   r   rl   r   uuiduuid4r]   r   r   r_   )r$   Z
prep_valuere   rv   r   r)   r)   r*   r     s    

zStreamValue.get_prep_valuec                 C   s"   t j| dd}|r|| S |S d S )NTr   r   r   r$   rw   r?   r)   r)   r*   blocks_by_name  s    zStreamValue.blocks_by_namec                 C   s"   t j| dd}|r|| S |S d S )NFr   r   r   r)   r)   r*   first_block_by_name  s    zStreamValue.first_block_by_namec                 C   s   t |trt|t| krdS tdt| D ]v}| j| d u rh|j| d u rh| j| |j| kr dS q,| | }|| }|j|jks|j|jks|j|jkr, dS q,dS )NFr   T)	r    r   rm   r[   r   r   rp   rl   rX   )r$   otherre   Z	this_itemZ
other_itemr)   r)   r*   __eq__  s     


zStreamValue.__eq__c                 C   s
   t | jS r5   )rm   r   rR   r)   r)   r*   r     s    zStreamValue.__len__c                 C   s   dt | j dt| dS )N< >)rx   r1   r!   rR   r)   r)   r*   r     s    zStreamValue.__repr__c                 C   s   | j j| |dS )Nr   r   r   )r$   r   r)   r)   r*   render_as_block  s    zStreamValue.render_as_blockc                 C   s   | j | S r5   r   rR   r)   r)   r*   __html__  s    zStreamValue.__html__c                 C   s   |   S r5   )r   rR   r)   r)   r*   __str__  s    zStreamValue.__str__c                 C   s   t | ||}||S )z%Returns StreamValue from pickled data)r	   r   )	app_labelZ
model_name
field_nameZfield_valuefieldr)   r)   r*   _deserialize_pickle_value"  s    z%StreamValue._deserialize_pickle_valuec                 C   sJ   z
| j }W n ty$   tdY n0 | j|jjj|jjj|j| 	 ffS )NzFStreamValue can only be pickled if it is associated with a StreamField)
Z_stream_fieldAttributeErrorr   r   r   Z_metar   Zobject_namer<   r   )r$   Zstream_fieldr)   r)   r*   
__reduce__(  s    

zStreamValue.__reduce__)FN)N)N)N)r1   r2   r3   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   staticmethodr   r   r)   r)   r)   r*   r     s2   %(-
'




r   c                   @   s$   e Zd ZdZdd Zedd ZdS )StreamBlockAdapterr   c                 C   s   |j | |j|jj|j|j|jj|jj|jj	|jj
|jjtdtdtdtdtdtddd}t|jd	d }|r||d
< t |d< |j| dd |j D |gS )NzMove upz	Move downZDragZ	DuplicateDeleteAdd)ZMOVE_UPZ	MOVE_DOWNZDRAGZ	DUPLICATEDELETEZADD)rr   descriptionrg   r   Z
blockDefIdZisPreviewable	classnameZmaxNumZminNumZblockCountsr   strings	help_textZhelpTextZhelpIconc                 S   s    i | ]\}}|| | qS r)   )r   get_default)r,   r<   rK   r)   r)   r*   r.   \  s   z.StreamBlockAdapter.js_args.<locals>.<dictcomp>)rr   get_descriptionrg   rH   r   Zdefinition_prefixZis_previewabler   ri   rh   ro   r   rn   getattrr   r<   rV   r9   r   )r$   r=   rH   r   r)   r)   r*   js_args>  s<    
zStreamBlockAdapter.js_argsc                 C   s   t jtdgdS )Nz"wagtailadmin/js/telepath/blocks.js)Zjs)r   ZMediar   rR   r)   r)   r*   mediac  s    zStreamBlockAdapter.mediaN)r1   r2   r3   Zjs_constructorr   r   r   r)   r)   r)   r*   r   ;  s   %r   ),rT   r   r   collectionsr   r   collections.abcr   r   pickler   Zdjangor   Zdjango.core.exceptionsr   Zdjango.db.models.fieldsr	   Zdjango.forms.utilsr
   Zdjango.utils.functionalr   Zdjango.utils.htmlr   Zdjango.utils.translationr   rn   Zwagtail.admin.staticfilesr   Zwagtail.telepathr   r   baser   r   r   r   r   r   __all__r   r   r   r   r   r)   r)   r)   r*   <module>   s6    	*     P1