
    -ea                       U d Z ddlmZ ddlZ ej        e          ZddlZddlm	Z	 ddl
mZmZmZmZmZmZmZmZmZmZ ddlmZmZmZ ddlmZmZ dd	lmZmZmZm Z m!Z!m"Z"m#Z#m$Z$m%Z%m&Z&m'Z'm(Z(m)Z)m*Z*m+Z+m,Z, dd
l-m.Z. ddl/m0Z0 erddl1m2Z2 dZ3ered         Z4eddded            Z5edddfd            Z5dddgdZ5edddhd            Z6edddid            Z6dddjd Z6ddd!dkd$Z7dd%ddddd&d'dld4Z8ed5ddmd8            Z9ed5ddnd:            Z9ed5ddod>            Z9ed5ddpd?            Z9ed5ddqd@            Z9ed5ddrdB            Z9g dddfdsdCZ9 edDe)E          Z:ee;e:         e<e:         gee)e+df         f         Z=dFe>dG<   dddHdtdOZ?dudRZ@ edSe$E          ZAddTdvdXZBdwd[ZCdxdyd_ZD ed`          ZEdzddZFdS ){z0 Functions for arranging bokeh layout objects.

    )annotationsN)defaultdict)
TYPE_CHECKINGAnyCallableIterableIteratorLiteralSequenceTypeVarUnionoverload   )LocationLocationTypeSizingModeType)	UndefinedUndefinedType)ColumnCopyToolExamineToolFlexBoxFullscreenToolGridBoxGridPlot	LayoutDOMPlotRowSaveToolSpacerToolToolbar	ToolProxy	UIElement)	dataclass)warn)	TypeAlias)columngridgridplotlayoutrowr    )logoautohideactive_dragactive_inspectactive_scroll
active_tapactive_multi)sizing_modechildrenlist[UIElement]r4   SizingModeType | Nonekwargsr   returnr   c                   d S N r5   r4   r8   s      -lib/python3.11/site-packages/bokeh/layouts.pyr,   r,   V   s    hkhk    r$   c                    d S r;   r<   r4   r5   r8   s      r>   r,   r,   X   s    `c`cr?   UIElement | list[UIElement]c                    t          |d|                    dd          i}t          || d           t          d|| d|S )a)   Create a row of Bokeh Layout objects. Forces all objects to
    have the same sizing_mode, which is required for complex layouts to work.

    Args:
        children (list of :class:`~bokeh.models.LayoutDOM` ): A list of instances for
            the row. Can be any of the following - |Plot|,
            :class:`~bokeh.models.Widget`,
            :class:`~bokeh.models.Row`,
            :class:`~bokeh.models.Column`,
            :class:`~bokeh.models.Spacer`.

        sizing_mode (``"fixed"``, ``"stretch_both"``, ``"scale_width"``, ``"scale_height"``, ``"scale_both"`` ): How
            will the items in the layout resize to fill the available space.
            Default is ``"fixed"``. For more information on the different
            modes see :attr:`~bokeh.models.LayoutDOM.sizing_mode`
            description on :class:`~bokeh.models.LayoutDOM`.

    Returns:
        Row: A row of LayoutDOM objects all with the same sizing_mode.

    Examples:

        >>> row(plot1, plot2)
        >>> row(children=[widgets, plot], sizing_mode='stretch_both')
    r5   Nr,   widgetr5   r4   r<   )_parse_children_argpop_handle_child_sizingr   r4   r5   r8   	_childrens       r>   r,   r,   [   sT    4 $XU

:t8T8TUUIK>>>>E	{EEfEEEr?   r   c                   d S r;   r<   r=   s      r>   r(   r(   y   s    nqnqr?   c                    d S r;   r<   rA   s      r>   r(   r(   {   s    fifir?   c                    t          |d|                    dd          i}t          || d           t          d|| d|S )a;   Create a column of Bokeh Layout objects. Forces all objects to
    have the same sizing_mode, which is required for complex layouts to work.

    Args:
        children (list of :class:`~bokeh.models.LayoutDOM` ): A list of instances for
            the column. Can be any of the following - |Plot|,
            :class:`~bokeh.models.Widget`,
            :class:`~bokeh.models.Row`,
            :class:`~bokeh.models.Column`,
            :class:`~bokeh.models.Spacer`.

        sizing_mode (``"fixed"``, ``"stretch_both"``, ``"scale_width"``, ``"scale_height"``, ``"scale_both"`` ): How
            will the items in the layout resize to fill the available space.
            Default is ``"fixed"``. For more information on the different
            modes see :attr:`~bokeh.models.LayoutDOM.sizing_mode`
            description on :class:`~bokeh.models.LayoutDOM`.

    Returns:
        Column: A column of LayoutDOM objects all with the same sizing_mode.

    Examples:

        >>> column(plot1, plot2)
        >>> column(children=[widgets, plot], sizing_mode='stretch_both')
    r5   Nr(   rD   rF   r<   )rG   rH   rI   r   rJ   s       r>   r(   r(   ~   sT    4 $XU

:t8T8TUUIKAAAAH9+HHHHHr?   rF   argslist[UIElement] | Nonec                6    t          |d| i}t          ||fi |S )a   Create a grid-based arrangement of Bokeh Layout objects.

    Args:
        children (list of lists of :class:`~bokeh.models.LayoutDOM` ): A list of lists of instances
            for a grid layout. Can be any of the following - |Plot|,
            :class:`~bokeh.models.Widget`,
            :class:`~bokeh.models.Row`,
            :class:`~bokeh.models.Column`,
            :class:`~bokeh.models.Spacer`.

        sizing_mode (``"fixed"``, ``"stretch_both"``, ``"scale_width"``, ``"scale_height"``, ``"scale_both"`` ): How
            will the items in the layout resize to fill the available space.
            Default is ``"fixed"``. For more information on the different
            modes see :attr:`~bokeh.models.LayoutDOM.sizing_mode`
            description on :class:`~bokeh.models.LayoutDOM`.

    Returns:
        Column: A column of ``Row`` layouts of the children, all with the same sizing_mode.

    Examples:

        >>> layout([[plot_1, plot_2], [plot_3, plot_4]])
        >>> layout(
                children=[
                    [widget_1, plot_1],
                    [slider],
                    [widget_2, plot_2, plot_3]
                ],
                sizing_mode='fixed',
            )

    r5   )rG   _create_grid)r5   r4   rO   r8   rK   s        r>   r+   r+      s/    B $T=H==I	;99&999r?   aboveT)r4   toolbar_locationncolswidthheighttoolbar_optionsmerge_toolslist[list[UIElement | None]]rT   LocationType | NonerU   
int | NonerV   rW   rX    dict[ToolbarOptions, Any] | NonerY   boolr   c          
     L   i |r't          t          |          st          d|           t          |           } |rEt	          d | D                       rt          d          t          t          | |                    } | sg } g }g }	t          |           D ]\  }
}t          |          D ]\  }}|t          |t                    r|rL|
                    t          t                              D ]#}|                    |j                   d|_        $|||_        |||_        |t%          |          r||_        |	                    ||
|f           t          |t(                    rt          d          d'd}g }|D ]}|                    |j                   |rt/          ||          }d |D             }d |D             }d |D             }d |D             }d |D             }d |D             }d |D             }t1          d          }d(fd} ||d          } ||d          } ||d           } ||d!          } ||d"          } ||d#          }  ||d$          }!t3          ||||||| |!%          }t5          |	|||&          }"|"S ))aM	   Create a grid of plots rendered on separate canvases.

    The ``gridplot`` function builds a single toolbar for all the plots in the
    grid. ``gridplot`` is designed to layout a set of plots. For general
    grid layout, use the :func:`~bokeh.layouts.layout` function.

    Args:
        children (list of lists of |Plot|): An array of plots to display in a
            grid, given as a list of lists of Plot objects. To leave a position
            in the grid empty, pass None for that position in the children list.
            OR list of |Plot| if called with ncols.

        sizing_mode (``"fixed"``, ``"stretch_both"``, ``"scale_width"``, ``"scale_height"``, ``"scale_both"`` ): How
            will the items in the layout resize to fill the available space.
            Default is ``"fixed"``. For more information on the different
            modes see :attr:`~bokeh.models.LayoutDOM.sizing_mode`
            description on :class:`~bokeh.models.LayoutDOM`.

        toolbar_location (``above``, ``below``, ``left``, ``right`` ): Where the
            toolbar will be located, with respect to the grid. Default is
            ``above``. If set to None, no toolbar will be attached to the grid.

        ncols (int, optional): Specify the number of columns you would like in your grid.
            You must only pass an un-nested list of plots (as opposed to a list of lists of plots)
            when using ncols.

        width (int, optional): The width you would like all your plots to be

        height (int, optional): The height you would like all your plots to be.

        toolbar_options (dict, optional) : A dictionary of options that will be
            used to construct the grid's toolbar (an instance of
            :class:`~bokeh.models.Toolbar`). If none is supplied,
            Toolbar's defaults will be used.

        merge_tools (``True``, ``False``): Combine tools from all child plots into
            a single toolbar.

    Returns:
        GridPlot:

    Examples:

        >>> gridplot([[plot_1, plot_2], [plot_3, plot_4]])
        >>> gridplot([plot_1, plot_2, plot_3, plot_4], ncols=2, width=200, height=100)
        >>> gridplot(
                children=[[plot_1, plot_2], [None, plot_3]],
                toolbar_location='right'
                sizing_mode='fixed',
                toolbar_options=dict(logo='gray')
            )

    Nz#Invalid value of toolbar_location: r5   c              3  @   K   | ]}t          |t                    V  d S r;   
isinstancelist.0childs     r>   	<genexpr>zgridplot.<locals>.<genexpr>  s,      ==5z%&&======r?   z-Cannot provide a nested list when using ncols)typez>Only UIElement and LayoutDOM items can be inserted into a gridcls
type[Tool]group
list[Tool]r9   Tool | ToolProxy | Nonec                j    t          | t          t          t          t          f          r
 |             S d S r;   )
issubclassr   r   r   r   )rj   rl   s     r>   mergezgridplot.<locals>.merge,  s-    cHh^LMM 	355L4r?   )rq   c                    g | ]	}|j         
S r<   )r-   rf   toolbars     r>   
<listcomp>zgridplot.<locals>.<listcomp>:  s    444wgl444r?   c                    g | ]	}|j         
S r<   )r.   rs   s     r>   ru   zgridplot.<locals>.<listcomp>;  s    <<<w'"<<<r?   c                    g | ]	}|j         
S r<   )r/   rs   s     r>   ru   zgridplot.<locals>.<listcomp><  s    BBBWW(BBBr?   c                    g | ]	}|j         
S r<   )r0   rs   s     r>   ru   zgridplot.<locals>.<listcomp>=  s    HHH7.HHHr?   c                    g | ]	}|j         
S r<   )r1   rs   s     r>   ru   zgridplot.<locals>.<listcomp>>  s    FFFw,FFFr?   c                    g | ]	}|j         
S r<   )r2   rs   s     r>   ru   zgridplot.<locals>.<listcomp>?  s    @@@7G&@@@r?   c                    g | ]	}|j         
S r<   )r3   rs   s     r>   ru   zgridplot.<locals>.<listcomp>@  s    DDDwg*DDDr?   Vvalueslist[V]nameToolbarOptionsV | UndefinedTypec                    |v r|         S t          t          |                     }|dk    rt          S |dk    rt          d| d           | d         S )Nr   r   z-found multiple competing values for 'toolbar.z"' property; using the latest value)lensetr   r&   )r}   r   nrX   s      r>   assert_uniquezgridplot.<locals>.assert_uniqueC  sh    ?"""4((F66UUiiiijjjbzr?   r-   r.   r/   r0   r1   r2   r3   )toolsr-   r.   r/   r0   r1   r2   r3   )r5   rt   rT   r4   )rj   rk   rl   rm   r9   rn   )r}   r~   r   r   r9   r   )hasattrr   
ValueErrorrG   anyrd   _chunks	enumeraterc   r   selectdictr   appendrt   rT   rV   rW   _has_auto_sizingr4   r$   extendr   group_toolsr   r"   r   )#r5   r4   rT   rU   rV   rW   rX   rY   toolbarsitemsyr,   xitemplotrq   r   rt   logos	autohidesactive_dragsactive_inspectsactive_scrollsactive_tapsactive_multisr|   r   r-   r.   r/   r0   r1   r2   r3   gps#         `                            r>   r*   r*      s   |  Wx!122 	WUCSUUVVV"H555H 2==H===== 	NLMMM%0011   !H.0EH%% c c3 ~~ 	c 	cGAt|D),, c 5 $DdOOO < < 5 5 55504--$!&DJ%"(DK*/?/E/E*'2D$dAq\****D),, c !abbb+	c.    %'E $ $W]#### 0E///44(444E<<(<<<IBBBBBLHHhHHHOFFHFFFN@@h@@@KDD(DDDMA      =''D}Y
33H-m<<K"]?4DEEN!M./BBM{L99J =??L%#!	 	 	G 
)	
 
 
B Ir?   .-list[UIElement | list[UIElement | list[Any]]]r   c                   d S r;   r<   rF   s     r>   r)   r)   j  s    {~{~r?   Row | Columnc                   d S r;   r<   rF   s     r>   r)   r)   l  s    Z]Z]r?   list[UIElement | None]nrowsintc                   d S r;   r<   )r5   r4   r   s      r>   r)   r)   n      pspsr?   c                   d S r;   r<   )r5   r4   rU   s      r>   r)   r)   p  r   r?   c                   d S r;   r<   )r5   r4   r   rU   s       r>   r)   r)   r  s    ||r?   strc                   d S r;   r<   rF   s     r>   r)   r)   t  s    QTQTr?   c                &   	
 t            G d d                      t            G d d                      t            G d d                      
t            G d d                      	d	
fd}t           t                    rj|Qt                     }t	          j        ||z              fdt          d|          D                       }nqd d!fd            }n\t           t                    rd"dd#d$fd  d          }n+t           t                    rt          t          d           ||          }|/||_        |j        D ] }|d         }t          |          r||_        !|S )%a  
    Conveniently create a grid of layoutable objects.

    Grids are created by using ``GridBox`` model. This gives the most control over
    the layout of a grid, but is also tedious and may result in unreadable code in
    practical applications. ``grid()`` function remedies this by reducing the level
    of control, but in turn providing a more convenient API.

    Supported patterns:

    1. Nested lists of layoutable objects. Assumes the top-level list represents
       a column and alternates between rows and columns in subsequent nesting
       levels. One can use ``None`` for padding purpose.

       >>> grid([p1, [[p2, p3], p4]])
       GridBox(children=[
           (p1, 0, 0, 1, 2),
           (p2, 1, 0, 1, 1),
           (p3, 2, 0, 1, 1),
           (p4, 1, 1, 2, 1),
       ])

    2. Nested ``Row`` and ``Column`` instances. Similar to the first pattern, just
       instead of using nested lists, it uses nested ``Row`` and ``Column`` models.
       This can be much more readable that the former. Note, however, that only
       models that don't have ``sizing_mode`` set are used.

       >>> grid(column(p1, row(column(p2, p3), p4)))
       GridBox(children=[
           (p1, 0, 0, 1, 2),
           (p2, 1, 0, 1, 1),
           (p3, 2, 0, 1, 1),
           (p4, 1, 1, 2, 1),
       ])

    3. Flat list of layoutable objects. This requires ``nrows`` and/or ``ncols`` to
       be set. The input list will be rearranged into a 2D array accordingly. One
       can use ``None`` for padding purpose.

       >>> grid([p1, p2, p3, p4], ncols=2)
       GridBox(children=[
           (p1, 0, 0, 1, 1),
           (p2, 0, 1, 1, 1),
           (p3, 1, 0, 1, 1),
           (p4, 1, 1, 1, 1),
       ])

    c                      e Zd ZU ded<   dS )grid.<locals>.rowlist[row | col]r5   N__name__
__module____qualname____annotations__r<   r?   r>   r,   r              !!!!!!r?   r,   c                      e Zd ZU ded<   dS )grid.<locals>.colr   r5   Nr   r<   r?   r>   colr     r   r?   r   c                  B    e Zd ZU ded<   ded<   ded<   ded<   ded<   dS )	grid.<locals>.Itemr   r+   r   r0c0r1c1Nr   r<   r?   r>   Itemr     s@         r?   r   c                  .    e Zd ZU ded<   ded<   ded<   dS )grid.<locals>.Gridr   r   rU   z
list[Item]r   Nr   r<   r?   r>   Gridr     s0         





r?   r   r9   r   c           	     "   dddfdddd	
fd |           }g }|j         D ]L}|j        C|                    |j        |j        |j        |j        |j        z
  |j        |j        z
  f           Mt          |          S )Nar   br9   c                h    t          |           t          |          }} |dk    r|| |z  }} |dk    | S Nr   )abs)r   r   s     r>   gcdz"grid.<locals>.flatten.<locals>.gcd  s=    q663q66qAq&&!a%1 q&&Hr?   restc                6    |D ]}| |z   | |          z  } | S r;   r<   )r   r   r   r   s      r>   lcmz"grid.<locals>.flatten.<locals>.lcm  s1     ' 'qSSSAYY&Hr?   rg   r   r^   c                .    | j         dk    o
| j        dk    S r   )r   rU   rg   s    r>   nonemptyz'grid.<locals>.flatten.<locals>.nonempty  s    ;!#8q(88r?   r+   row | col | LayoutDOMc                   t          |           rt          t          t          | j                                      }|s 	ddg           S  d |D              }t          d |D                       }g }d}|D ]g}||j        z  }|j        D ]I}|                     
|j	        ||j
        z  |j        |z   ||j        z  |j        |z                        J||j        z  }h 	|||          S t          |           rt          t          t          | j                                      }|s 	ddg           S t          d |D                       } d |D              }g }d}|D ]g}||j        z  }|j        D ]I}|                     
|j	        |j
        |z   ||j        z  |j        |z   ||j        z                       J||j        z  }h 	|||          S  	dd 
| dddd          g          S )Nr   c                    g | ]	}|j         
S r<   r   re   s     r>   ru   z;grid.<locals>.flatten.<locals>._flatten.<locals>.<listcomp>      BBBuu{BBBr?   c              3  $   K   | ]}|j         V  d S r;   rU   re   s     r>   rh   z:grid.<locals>.flatten.<locals>._flatten.<locals>.<genexpr>  $      >>EEK>>>>>>r?   c              3  $   K   | ]}|j         V  d S r;   r   re   s     r>   rh   z:grid.<locals>.flatten.<locals>._flatten.<locals>.<genexpr>  r   r?   c                    g | ]	}|j         
S r<   r   re   s     r>   ru   z;grid.<locals>.flatten.<locals>._flatten.<locals>.<listcomp>  r   r?   r   )rc   rd   filtermapr5   sumr   r   r   r+   r   r   r   r   rU   )r+   r5   r   rU   r   offsetrg   factorir   r   _flattenr   r   r   r,   s            r>   r   z'grid.<locals>.flatten.<locals>._flatten  s~   &#&& '>xXv1O1O P PQQ *41b>>)BBBBBC>>X>>>>>$&% * *E"EK/F"[ m mTT!(F14KPVWXW[P[]^]adj]j%k%kllllek)FFtE5%000FC(( >xXv1O1O P PQQ *41b>>)>>X>>>>>BBBBBC% * *E"EK/F"[ m mTT!(AD6M6!$;PQPTW]P]_efgfj_j%k%kllllek)FFtE5%000tAq441a#;#;"<===r?   r`   )r   r   r   r   r9   r   )r   r   r   r   r9   r   )rg   r   r9   r^   )r+   r   r9   r   )r   r+   r   r   r   r   r   r   )r+   r)   r5   r   r   r   r   r   r   r   r   r,   s       @@@@r>   flattenzgrid.<locals>.flatten  s    	 	 	 		 	 	 	 	 	
	9 	9 	9 	9(	> (	> (	> (	> (	> (	> (	> (	> (	> (	> (	> (	>T x 	R 	RAx#14qtad{AD14K PQQQ))))r?   Nc                <    g | ]} ||z                      S r<   r<   )rf   r   r5   rU   r,   s     r>   ru   zgrid.<locals>.<listcomp>  s0    QQQ33x!E'	233QQQr?   r   r5   list[LayoutDOM]levelr   c                ~    t          | t                    r%dz  dk    rn} |fd| D                       S | S )N   r   c                .    g | ]} |d z             S )r   r<   )rf   rg   r   traverses     r>   ru   z*grid.<locals>.traverse.<locals>.<listcomp>
  s)    %W%W%WExxuQw'?'?%W%W%Wr?   rb   )r5   r   	containerr   r,   r   s    ` r>   r   zgrid.<locals>.traverse  sX    h-- $',qyA~~3I$9%W%W%W%W%WX%W%W%WXXX#Or?   rg   r   r^   c                6    t          |           o
| j        dk    S r   )r   spacingr   s    r>   	is_usablezgrid.<locals>.is_usable  s    #E**Au}/AAr?   Fr   	top_levelc                    t          | t                    rQ|s |           rDt          | t                    rn} |t          t	          | j                                      S | S r;   )rc   r   r   rd   r   r5   )r   r   r   r   r   r,   r   s      r>   r   zgrid.<locals>.traverse  sl    $(( i 99T?? #-dF#;#;DCC	 yc(DM&B&B!C!CDDDr?   T)r   z expected a list, string or model)r9   r   r   )r5   r   r   r   )rg   r   r9   r^   )F)r   r   r   r^   )r%   rc   rd   r   mathceilranger   r   NotImplementedErrorr   r4   r5   r   )r5   r4   r   rU   r   Nr+   r)   rg   r   r   r   r   r,   r   s   `  `     @@@@@@r>   r)   r)   w  s   b " " " " " " " Y"" " " " " " " Y"        Y        Y
@* @* @* @* @* @* @* @* @*F (D!! = 1HA}	!E'**SQQQQQQU1a=O=OQQQRRFF$ $ $ $ $ $ $ $ $ Xh''FF	Hi	(	( =	B 	B 	B 	B	 	 	 	 	 	 	 	 	 	 (d333	Hc	"	" =!!;<<<76??D&] 	1 	1E1XF'' 1%0"Kr?   T)boundr'   MergeFn)rq   ignorer   list[Tool | ToolProxy]rq   MergeFn[Tool] | Noner   set[str] | Nonec                  t            G d d                      }t          t                    }g }|ddh}| D ]w}t          |t                    r|                    |           -|                                }|D ]	}||v r||= 
||j                                      |||                     x|                                D ]$\  }	}
|. ||	d |
D                       }||                    |           6|
r|
^}}|j	        g}t          |          D ]A}|j
        |j
        k    r/|                    |j	                   |
                    |           B|
                    |           t          |          dk    r|                    |d                    nI|$ ||	|          x}|                    |           n#|                    t	          |	                     |
&|S )
z' Group common tools into tool proxies. c                  $    e Zd ZU ded<   ded<   dS )group_tools.<locals>.ToolEntryr!   toolr   propsNr   r<   r?   r>   	ToolEntryr  6  s"         







r?   r  Noverlay	renderersc                    g | ]	}|j         
S r<   )r  )rf   entrys     r>   ru   zgroup_tools.<locals>.<listcomp>M  s     A A A A A Ar?   r   r   )r   )r%   r   rd   rc   r#   r   properties_with_values	__class__r   r  r  remover   )r   rq   r   r  by_typecomputedr  r  attrrj   entriesmergedheadtailrl   r   s                   r>   r   r   3  sI           Y 9DD8I8IG')H~[) C CdI&& 	COOD!!!!//11E $ $5==dDN#**99T5+A+ABBBB 8 8WU3 A A A A ABBF!''' 	8!KD4!%ET

 ) ):++LL+++NN4(((NN4   5zzQa))))"c50A0A(A'N%%%%	 6 6 6777  	8  Or?   r   r   c                @    | j         d u o| j        dk    o
| j        dk    S )Nauto)r4   width_policyheight_policy)r   s    r>   r   r   h  s+    t#d(9V(CdHZ^dHddr?   Lr`   L | list[L]list[L] | Nonelist[L]c                    t          |          dk    r| t          d          | s=t          |          dk    r|\  }t          |t                    r|S t          |          S | S )Nr   z;'children' keyword cannot be used with positional argumentsr   )r   r   rc   rd   )r5   rO   args      r>   rG   rG   l  sk    
4yy1}}-VWWW t99>>ES#t$$ 
DzzOr?   rE   Nonec                   | D ]j}t          |t                    rt          |t                    s%t          d| d| dt	          |                     |t          |          r||_        kd S )Nz,Only LayoutDOM items can be inserted into a z. Tried to insert: 	 of type )rc   r$   r   r   ri   r   r4   )r5   r4   rE   r   s       r>   rI   rI   {  s     + +dI&& 	$	** 	D  CF  C  Cgk  C  Cvz{  wA  wA  C  C  D  D  D"'7'='="*D+ +r?   iterable%Iterable[UIElement | list[UIElement]]layerc           	        g }| D ]}t          |t                    r(|                    t          |||dz                        ?t          |t                    r.|t          |          r||_        |                    |           t          |t                    r|                    |           t          d| dt          |                     |dz  dk    rt          d||d|S t          d||d|S )	z)Recursively create grid from input lists.r   NzUOnly LayoutDOM items can be inserted into a layout.
                Tried to insert: r  r   r   rF   r<   )rc   rd   r   rR   r   r   r4   r$   r   ri   r(   r,   )r   r4   r"  r8   return_listr   s         r>   rR   rR     s>   #%K  dD!! 	|D+uqyIIJJJJi(( 
	&+;D+A+A&#. t$$$$i(( 	t$$$$@"&@ @15d@ @   qyA~~N{NNvNNNKK[KKFKKKr?   IlSequence[I]Iterator[Sequence[I]]c              #     K   t          |t                    s
J d            t          dt          |           |          D ]}| |||z            V  dS )z-Yield successive n-sized chunks from list, l.zncols must be an integerr   N)rc   r   r   r   )r&  rU   r   s      r>   r   r     sk      eS!!==#====1c!ffe$$  1u9o r?   )r5   r6   r4   r7   r8   r   r9   r   )r5   r$   r4   r7   r8   r   r9   r   )r5   rB   r4   r7   r8   r   r9   r   )r5   r6   r4   r7   r8   r   r9   r   )r5   r$   r4   r7   r8   r   r9   r   )r5   rB   r4   r7   r8   r   r9   r   )
rO   r$   r5   rP   r4   r7   r8   r   r9   r   )r5   rZ   r4   r7   rT   r[   rU   r\   rV   r\   rW   r\   rX   r]   rY   r^   r9   r   )r5   r   r4   r7   r9   r   )r5   r   r4   r7   r9   r   )r5   r   r4   r7   r   r   r9   r   )r5   r   r4   r7   rU   r   r9   r   )
r5   r   r4   r7   r   r   rU   r   r9   r   )r5   r   r4   r7   r9   r   )
r5   r   r4   r7   r   r\   rU   r\   r9   r   )r   r   rq   r   r   r   r9   r   )r   r   r9   r^   )rO   r  r5   r  r9   r  )r5   r6   r4   r7   rE   r   r9   r  r   )r   r!  r4   r7   r"  r   r9   r   )r&  r'  rU   r   r9   r(  )G__doc__
__future__r   logging	getLoggerr   logr   collectionsr   typingr   r   r   r   r	   r
   r   r   r   r   
core.enumsr   r   r   core.property.singletonsr   r   modelsr   r   r   r   r   r   r   r   r   r   r   r    r!   r"   r#   r$   util.dataclassesr%   util.warningsr&   typing_extensionsr'   __all__r   r,   r(   r+   r*   r)   r   ri   rd   r   r   r   r   r  rG   rI   rR   r%  r   r<   r?   r>   <module>r8     sZ     # " " " " " g!!  # # # # # #                        ? > > > > > > > > > > > > > > > > >                                   $ ( ' ' ' ' '       ,++++++  A  AN 
KO k k k k k 
 k	CG c c c c c 
 cUY F F F F F F< 
NR q q q q q 
 q	FJ i i i i i 
 iX\ I I I I I I> AEko ": ": ": ": ": ":L .207  !<@ f f f f f fR 
jm ~ ~ ~ ~ ~ 
 ~	IL ] ] ] ] ] 
 ]	SV s s s s s 
 s	SV s s s s s 
 s	SV      
 	@C T T T T T 
 T$\`vz s s s s sr GCttAwQ0%i8M2NNO O O O OPT"&/ / / / / /je e e e GCy!!!GK      + + + +L L L L L, GCLL     r?   