Ë
    :vžj“<  ã                   óJ  — d 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
 ddlm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iZ ee«       G d„ de«      «       Z ee«       G d„ dee«      «       Z ee«       G d„ dee«      «       Z ee«       G d„ dee«      «       Zy)z7Implement common widgets layouts as reusable componentsé    N)Údefaultdict)ÚInstanceÚBoolÚUnicodeÚCUnicodeÚCaselessStrEnumÚTuple)ÚInteger)Ú	HasTraitsÚ
TraitError)ÚobserveÚvalidateé   )ÚWidget)ÚGridBox)Ú	doc_substÚstyle_paramsaÍ  

    grid_gap : str
        CSS attribute used to set the gap between the grid cells

    justify_content : str, in ['flex-start', 'flex-end', 'center', 'space-between', 'space-around']
        CSS attribute used to align widgets vertically

    align_items : str, in ['top', 'bottom', 'center', 'flex-start', 'flex-end', 'baseline', 'stretch']
        CSS attribute used to align widgets horizontally

    width : str
    height : str
        width and heightc                   óª   ‡ — e Zd ZdZ eddd¬«      Z eg d¢dd¬«      Z eg d¢dd	¬«      Z eddd
¬«      Z	 eddd
¬«      Z
ˆ fd„Zd„ Zd„ Zd„ Zˆ xZS )ÚLayoutPropertiesaK  Mixin class for layout templates

    This class handles mainly style attributes (height, grid_gap etc.)

    Parameters
    ----------

    {style_params}


    Note
    ----

    This class is only meant to be used in inheritance as mixin with other
    classes. It will not work, unless `self.layout` attribute is defined.

    NTzThe grid-gap CSS attribute.)Ú
allow_noneÚhelp)ú
flex-startúflex-endÚcenterzspace-betweenzspace-aroundz"The justify-content CSS attribute.)ÚtopÚbottomr   r   r   ÚbaselineÚstretchzThe align-items CSS attribute.zThe width CSS attribute.c                 ó°   •— t        ‰| �  di |¤Ž t        t        «      | _        dddœ| j                  d<   | j                  «        | j                  «        y )Nr   r   )r   r   Úalign_items© )ÚsuperÚ__init__r   ÚdictÚ_property_rewriteÚ_copy_layout_propsÚ_set_observers©ÚselfÚkwargsÚ	__class__s     €út/workspace/moltex-experiments/.pixi/envs/default/lib/python3.12/site-packages/ipywidgets/widgets/widget_templates.pyr#   zLayoutProperties.__init__O   sQ   ø€ Ü‰ÑÑ"˜6Ò"Ü!,¬TÓ!2ˆÔØ8DØ;Eñ1Gˆ×Ñ˜}Ñ-à×ÑÔ!Ø×ÑÕó    c                 ó„   — |d   |d   }}| j                   |   j                  ||«      }t        | j                  ||«       y)z=delegate the trait types to their counterparts in self.layoutÚnewÚnameN)r%   ÚgetÚsetattrÚlayout)r)   ÚchangeÚvaluer0   s       r,   Ú_delegate_to_layoutz$LayoutProperties._delegate_to_layoutW   s@   € à˜U‘m V¨F¡^ˆtˆØ×&Ñ& tÑ,×0Ñ0°¸Ó>ˆÜ�—‘˜T 5Õ)r-   c                 ód   — t         j                  «       }| j                  | j                  |«       y)z<set observers on all layout properties defined in this classN)r   Úclass_trait_namesr   r6   )r)   Ú_propss     r,   r'   zLayoutProperties._set_observers]   s$   € ä!×3Ñ3Ó5ˆØ�‰�T×-Ñ-¨vÕ6r-   c                 óÄ   — t         j                  «       }|D ]G  }t        | |«      }|sŒ| j                  |   j	                  ||«      }t        | j                  ||«       ŒI y ©N)r   r8   Úgetattrr%   r1   r2   r3   )r)   r9   Úpropr5   s       r,   r&   z#LayoutProperties._copy_layout_propsb   sV   € ä!×3Ñ3Ó5ˆãˆDÜ˜D $Ó'ˆEÚØ×.Ñ.¨tÑ4×8Ñ8¸ÀÓF�Ü˜Ÿ™ T¨5Õ1ñ	 r-   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úgrid_gapr   Újustify_contentr    ÚwidthÚheightr#   r6   r'   r&   Ú__classcell__©r+   s   @r,   r   r   "   sŒ   ø„ ññ& ØØØ*ô,€Hñ &ò	*àØ1ô	3€Oñ
 "ò	 ð Ð>ô	@€Kñ
 ØØØ'ô)€Eñ ØØØ'ô)€Fôò*ò7ö
2r-   r   c            
       óR  ‡ — e Zd ZdZ eed¬«      Z eed¬«      Z eed¬«      Z eed¬«      Z	 eed¬«      Z
 e e«        e«        e«       g d¢¬«      Z e e«        e«        e«       g d¢¬«      Z ed¬«      Zˆ fd„Zed„ «       Zd	„ Zd
„ Z edddddddd«      d„ «       Zˆ xZS )Ú	AppLayouta"   Define an application like layout of widgets.

    Parameters
    ----------

    header: instance of Widget
    left_sidebar: instance of Widget
    center: instance of Widget
    right_sidebar: instance of Widget
    footer: instance of Widget
        widgets to fill the positions in the layout

    merge: bool
        flag to say whether the empty positions should be automatically merged

    pane_widths: list of numbers/strings
        the fraction of the total layout width each of the central panes should occupy
        (left_sidebar,
        center, right_sidebar)

    pane_heights: list of numbers/strings
        the fraction of the width the vertical space that the panes should occupy
         (left_sidebar, center, right_sidebar)

    {style_params}

    Examples
    --------

    T©r   )Ú1frÚ2frrK   ©Údefault_value)rK   Ú3frrK   c                 óD   •— t        ‰| �  di |¤Ž | j                  «        y ©Nr!   ©r"   r#   Ú_update_layoutr(   s     €r,   r#   zAppLayout.__init__œ   ó   ø€ Ü‰ÑÑ"˜6Ò"Ø×ÑÕr-   c                 óœ   — t        j                  d| «      r| S t        j                  d| «      r| dz   S t        dj                  | «      «      ‚)Nz\d+\.?\d*(px|fr|%)$z
\d+\.?\d*$Úfrzqthe pane sizes must be in one of the following formats: '10px', '10fr', 10 (will be converted to '10fr').Got '{}')ÚreÚmatchÚ	TypeErrorÚformat)Úsizes    r,   Ú_size_to_csszAppLayout._size_to_css    sI   € ä�8‰8Ð*¨DÔ1ØˆKÜ�8‰8�M 4Ô(Ø˜$‘;Ðäð #ç#)¡6¨$£<ó1ð 	1r-   c                 ó@   — t        t        | j                  |«      «      S r;   )ÚlistÚmapr\   )r)   Ú	size_lists     r,   Ú_convert_sizeszAppLayout._convert_sizes«   s   € Ü”C˜×)Ñ)¨9Ó5Ó6Ð6r-   c                 ó„  — g d¢g d¢g d¢g}| j                  | j                  «      }| j                  | j                  «      }| j                  | j                  | j
                  | j                  | j                  dœ}|j                  «       D ��ci c]
  \  }}|�||“Œ }}}|sy |j                  «       D ]  \  }}||j                  _
        Œ | j                  rÛt        |«      dk(  r+t        |j                  «       «      d   }|||g|||g|||gg}n¢| j                  €|D ]  }|d= Œ |d= | j
                  €|d   d   |d   d<   | j                  €|d   d   |d   d<   | j
                  €%| j                  €| j                  €d	gd
gg}dg}ddg}| j                  €|d= |d= | j                  €|d= |d= dj                  d„ |D «       «      }	dj                  |«      | j                  _        dj                  |«      | j                  _        |	| j                  _        t'        |j)                  «       «      | _        y c c}}w )N)Úheaderrc   rc   )úleft-sidebarr   úright-sidebar)Úfooterrf   rf   )rc   rf   rd   re   r   r   r   éþÿÿÿéÿÿÿÿrc   rf   rK   Ú
c              3   ó\   K  — | ]$  }d j                  dj                  |«      «      –— Œ& y­w©z"{}"Ú N©rZ   Újoin©Ú.0Úlines     r,   Ú	<genexpr>z+AppLayout._update_layout.<locals>.<genexpr>ë   ó*   è ø€ ð ,MÙ8K°ð -3¯M©M¸#¿(¹(À4».×,IÙ8Kùó   ‚*,rl   )ra   Úpane_widthsÚpane_heightsrc   rf   Úleft_sidebarÚright_sidebarr   Úitemsr3   Ú	grid_areaÚmergeÚlenr^   Úkeysrn   Úgrid_template_columnsÚgrid_template_rowsÚgrid_template_areasÚtupleÚvaluesÚchildren)
r)   r€   r~   r   Úall_childrenÚpositionÚchildrƒ   ÚrowÚgrid_template_areas_csss
             r,   rS   zAppLayout._update_layout®   s�  € â=ÚJÚ=ð?Ðð !%× 3Ñ 3°D×4DÑ4DÓ EÐØ!×0Ñ0°×1BÑ1BÓCÐà"&§+¡+Ø"&§+¡+Ø(,×(9Ñ(9Ø)-×);Ñ);Ø"&§+¡+ñ	/ˆð ,8×+=Ñ+=Ô+?ô*Ù+?™˜ %ØÐ(ð ˜uÑ$Ø+?ð 	ñ *ñ Øà'Ÿ~™~Ö/‰OˆH�eØ%-ˆE�L‰LÕ"ð  0ð �:Š:ä�8‹} Ò!Ü §¡£Ó0°Ñ3�Ø(0°(¸HÐ'EØ(0°(¸HÐ'EØ(0°(¸HÐ'Eð'GÑ#ð
 —;‘;Ð&Û2˜Ø ™Fð  3à-¨aÐ0à×$Ñ$Ð,Ø0CÀAÑ0FÀqÑ0IÐ'¨Ñ*¨1Ñ-à×%Ñ%Ð-Ø1DÀQÑ1GÈÑ1KÐ'¨Ñ*¨2Ñ.à×%Ñ%Ð-Ø×*Ñ*Ð2ØŸ™Ð+Ø,4¨:¸°zÐ*BÐ'Ø-2¨GÐ)Ø*/°¨Ð&à—;‘;Ð&Ø+¨AÐ.Ø*¨1Ð-à—;‘;Ð&Ø+¨BÐ/Ø*¨2Ð.ð #'§)¡)ñ ,MÙ8Kó,Mó #MÐð -0¯H©HÐ5JÓ,Kˆ�‰Ô)Ø),¯©Ð2DÓ)Eˆ�‰Ô&Ø*Aˆ�‰Ô'ä˜hŸo™oÓ/Ó0ˆ�ùók*s   ÂH<rf   rc   r   rw   rx   r{   ru   rv   c                 ó$   — | j                  «        y r;   ©rS   ©r)   r4   s     r,   Ú_child_changedzAppLayout._child_changedô   s   € ð 	×ÑÕr-   )r>   r?   r@   rA   r   r   rc   rf   rw   rx   r   r	   r   ru   rv   r   r{   r#   Ústaticmethodr\   ra   rS   r   rŒ   rF   rG   s   @r,   rI   rI   l   sÖ   ø„ ññ@ �f¨Ô.€FÙ�f¨Ô.€FÙ˜F¨tÔ4€LÙ˜V°Ô5€MÙ�f¨Ô.€Fñ ™›
¡H£J±³
Ú&;ô=€Ká™›¡X£Z±³Ú'<ô>€Lñ ˜tÔ$€Eôð ñ1ó ð1ò7òD1ñL ˆX�x ¨>¸?ÈGØ˜Nó,ñó,ôr-   rI   c                   óv   ‡ — e Zd ZdZ e«       Z e«       Zd
ˆ fd„	Z edd«      d„ «       Z	d„ Z
d„ Zd„ Zd	„ Zˆ xZS )ÚGridspecLayoutaŸ   Define a N by M grid layout

    Parameters
    ----------

    n_rows : int
        number of rows in the grid

    n_columns : int
        number of columns in the grid

    {style_params}

    Examples
    --------

    >>> from ipywidgets import GridspecLayout, Button, Layout
    >>> layout = GridspecLayout(n_rows=4, n_columns=2, height='200px')
    >>> layout[:3, 0] = Button(layout=Layout(height='auto', width='auto'))
    >>> layout[1:, 1] = Button(layout=Layout(height='auto', width='auto'))
    >>> layout[-1, 0] = Button(layout=Layout(height='auto', width='auto'))
    >>> layout[0, 1] = Button(layout=Layout(height='auto', width='auto'))
    >>> layout
    c                 ó&  •— t        ‰| �  di |¤Ž || _        || _        t	        | j                  «      D �cg c]  }dg| j                  z  ‘Œ c}| _        d| j                  fz  | _        d| j                  fz  | _        i | _        d| _	        y c c}w )NÚ.zrepeat(%d, 1fr)r   r!   )
r"   r#   Ún_rowsÚ	n_columnsÚrangeÚ_grid_template_areasÚ_grid_template_rowsÚ_grid_template_columnsÚ	_childrenÚ	_id_count)r)   r’   r“   r*   Úir+   s        €r,   r#   zGridspecLayout.__init__  s‰   ø€ Ü‰ÑÑ"˜6Ò"ØˆŒØ"ˆŒÜEJÈ4Ï;É;ÔEWÓ$XÑEWÀ c U¨T¯^©^Ó%;ÐEWÑ$XˆÔ!à#4¸¿¹°~Ñ#EˆÔ Ø&7¸4¿>¹>Ð:KÑ&KˆÔ#ØˆŒØˆ�ùò %Ys   ¶Br’   r“   c                 ó2   — |d   dkD  r|d   S t        d«      ‚)Nr5   r   z-n_rows and n_columns must be positive integer)r   )r)   Úproposals     r,   Ú_validate_integerz GridspecLayout._validate_integer#  s&   € à�GÑ˜qÒ Ø˜GÑ$Ð$ÜÐHÓIÐIr-   c                 ó  — t        |t        «      r-|j                  | j                  «      \  }}}t	        |||«      }n|g}t        |t        «      r0|j                  | j
                  «      \  }}}t	        |||«      }||fS |g}||fS )zDconvert a two-dimensional slice to a list of rows and column indices)Ú
isinstanceÚsliceÚindicesr’   r”   r“   )r)   r‡   ÚcolumnÚstartÚstopÚstrideÚrowsÚcolumnss           r,   Ú_get_indices_from_slicez&GridspecLayout._get_indices_from_slice)  sŒ   € ô �cœ5Ô!Ø"%§+¡+¨d¯k©kÓ":ÑˆE�4˜Ü˜  fÓ-‰Dà�5ˆDä�fœeÔ$Ø"(§.¡.°·±Ó"@ÑˆE�4˜Ü˜E 4¨Ó0ˆGð �Wˆ}Ðð �hˆGà�Wˆ}Ðr-   c                 ó„  — |\  }}| xj                   dz  c_         d| j                   z  }||j                  _        | j                  ||«      \  }}|D ]M  }|D ]F  }| j                  |   |   }|dk7  r|| j
                  v r| j
                  |= || j                  |   |<   ŒH ŒO || j
                  |<   | j                  «        y )Nr   z
widget%03dr‘   )r™   r3   rz   r¨   r•   r˜   rS   )	r)   Úkeyr5   r‡   r¢   Úobj_idr¦   r§   Úcurrent_values	            r,   Ú__setitem__zGridspecLayout.__setitem__:  sÂ   € Ø‰ˆˆVØ�Š˜!Ñ�Ø §¡Ñ.ˆØ!'ˆ�‰Ôà×4Ñ4°S¸&ÓA‰ˆˆgãˆCÛ!�Ø $× 9Ñ 9¸#Ñ >¸vÑ F�Ø  CÒ'¨M¸T¿^¹^Ñ,KØŸ™ }Ð5Ø9?�×)Ñ)¨#Ñ.¨vÒ6ñ	 "ð ð "'ˆ�‰�vÑØ×ÑÕr-   c                 ó´   —  | j                   |Ž \  }}d }|D ]1  }|D ]*  }| j                  |   |   }|xs |}||k7  sŒ!t        d«      ‚ Œ3 | j                  |   S )NzTThe slice spans several widgets, but only a single widget can be retrieved at a time)r¨   r•   rY   r˜   )r)   rª   r¦   r§   r«   r‡   r¢   Ú
new_obj_ids           r,   Ú__getitem__zGridspecLayout.__getitem__L  s{   € Ø4˜×4Ñ4°cÐ:‰ˆˆgàˆÛˆCÛ!�Ø!×6Ñ6°sÑ;¸FÑC�
ØÒ- :�Ø˜ZÓ'Ü#ð %0ó 1ð 1ñ	 "ð ð �~‰~˜fÑ%Ð%r-   c                 ó&  — dj                  d„ | j                  D «       «      }| j                  | j                  _        | j
                  | j                  _        || j                  _        t        | j                  j                  «       «      | _        y )Nri   c              3   ó\   K  — | ]$  }d j                  dj                  |«      «      –— Œ& y­wrk   rm   ro   s     r,   rr   z0GridspecLayout._update_layout.<locals>.<genexpr>]  s*   è ø€ ð ,SÙ8Q°ð -3¯M©M¸#¿(¹(À4».×,IÙ8Qùrt   )rn   r•   r—   r3   r~   r–   r   r€   r�   r˜   r‚   rƒ   )r)   rˆ   s     r,   rS   zGridspecLayout._update_layout[  sr   € à"&§)¡)ñ ,SØ8<×8QÒ8Qó,Só #SÐð -1×,GÑ,Gˆ�‰Ô)Ø)-×)AÑ)Aˆ�‰Ô&Ø*Aˆ�‰Ô'Ü˜dŸn™n×3Ñ3Ó5Ó6ˆ�r-   )NN)r>   r?   r@   rA   r
   r’   r“   r#   r   r�   r¨   r­   r°   rS   rF   rG   s   @r,   r�   r�   ú   sN   ø„ ññ2 ‹Y€FÙ“	€Iõ	ñ ˆh˜Ó$ñJó %ðJò
ò"ò$&ö7r-   r�   c                   ó®   ‡ — e Zd ZdZ eed¬«      Z eed¬«      Z eed¬«      Z eed¬«      Z	 e
d¬«      Zˆ fd„Zd„ Z eddd	d
d«      d„ «       Zˆ xZS )ÚTwoByTwoLayoutaã   Define a layout with 2x2 regular grid.

    Parameters
    ----------

    top_left: instance of Widget
    top_right: instance of Widget
    bottom_left: instance of Widget
    bottom_right: instance of Widget
        widgets to fill the positions in the layout

    merge: bool
        flag to say whether the empty positions should be automatically merged

    {style_params}

    Examples
    --------

    >>> from ipywidgets import TwoByTwoLayout, Button
    >>> TwoByTwoLayout(top_left=Button(description="Top left"),
    ...                top_right=Button(description="Top right"),
    ...                bottom_left=Button(description="Bottom left"),
    ...                bottom_right=Button(description="Bottom right"))

    TrJ   rM   c                 óD   •— t        ‰| �  di |¤Ž | j                  «        y rQ   rR   r(   s     €r,   r#   zTwoByTwoLayout.__init__Œ  rT   r-   c                 ó„  — ddgddgg}| j                   | j                  | j                  | j                  dœ}|j	                  «       D ��ci c]
  \  }}|�||“Œ }}}|sy |j	                  «       D ]  \  }}||j
                  _        Œ | j                  r½t        |«      dk(  r%t        |j                  «       «      d   }||g||gg}nŠdd	g}t        |«      D ]x  \  }}|j                  d
|z   «      |j                  d|z   «      }
}	|dz   dz  }|	€|
€|d   |   |d   |<   |d   |   |d   |<   ŒW|	€|d   |   |d   |<   Œh|
�Œk|d   |   |d   |<   Œz dj                  d„ |D «       «      }d| j
                  _        d| j
                  _        || j
                  _        t#        |j%                  «       «      | _        y c c}}w )Nútop-leftú	top-rightúbottom-leftúbottom-right)r·   r¸   r¹   rº   r   r   ÚleftÚrightztop-zbottom-é   ri   c              3   ó\   K  — | ]$  }d j                  dj                  |«      «      –— Œ& y­wrk   rm   ro   s     r,   rr   z0TwoByTwoLayout._update_layout.<locals>.<genexpr>»  rs   rt   z1fr 1fr)Útop_leftÚ	top_rightÚbottom_leftÚbottom_rightry   r3   rz   r{   r|   r^   r}   Ú	enumerater1   rn   r~   r   r€   r�   r‚   rƒ   )r)   r€   r„   r…   r†   rƒ   r§   rš   r¢   r   r   Úi_neighbourrˆ   s                r,   rS   zTwoByTwoLayout._update_layout�  s  € ð !+¨KÐ8Ø -¨~Ð>ð@Ðð &*§]¡]Ø&*§n¡nØ(,×(8Ñ(8Ø)-×):Ñ):ñ<ˆð ,8×+=Ñ+=Ô+?ô*Ù+?™˜ %ØÐ(ð ˜uÑ$Ø+?ð 	ñ *ñ Øà'Ÿ~™~Ö/‰OˆH�eØ%-ˆE�L‰LÕ"ð  0ð �:Š:ä�8‹} Ò!Ü §¡£Ó0°Ñ3�Ø(0°(Ð';Ø(0°(Ð';ð'=Ñ#ð " 7Ð+�Ü!*¨7Ö!3‘I�A�vØ"*§,¡,¨v¸©Ó"?ÀÇÁÈiÐZ`ÑN`ÓAa˜�CØ#$ q¡5¨A¡+�KØ�{ v ~à4GÈÑ4JÈ;Ñ4WÐ+¨AÑ.¨qÑ1Ø4GÈÑ4JÈ;Ñ4WÐ+¨AÑ.¨qÒ1Ø˜à4GÈÑ4JÈ1Ñ4MÐ+¨AÑ.¨qÒ1Ø™à4GÈÑ4JÈ1Ñ4MÐ+¨AÑ.¨qÒ1ð "4ð #'§)¡)ñ ,MÙ8Kó,Mó #MÐð -6ˆ�‰Ô)Ø)2ˆ�‰Ô&Ø*Aˆ�‰Ô'ä˜hŸo™oÓ/Ó0ˆ�ùóO*s   ÁF<r¿   rÁ   rÀ   rÂ   r{   c                 ó$   — | j                  «        y r;   rŠ   r‹   s     r,   rŒ   zTwoByTwoLayout._child_changedÄ  s   € à×ÑÕr-   )r>   r?   r@   rA   r   r   r¿   rÀ   rÁ   rÂ   r   r{   r#   rS   r   rŒ   rF   rG   s   @r,   r´   r´   f  ss   ø„ ññ8 ˜¨4Ô0€HÙ˜¨DÔ1€IÙ˜6¨dÔ3€KÙ˜F¨tÔ4€Lñ ˜tÔ$€Eôò21ñh ˆZ˜¨°^ÀWÓMñó Nôr-   r´   )rA   rW   Úcollectionsr   Ú	traitletsr   r   r   r   r   r	   r
   r   r   r   r   Úwidgetr   Ú
widget_boxr   Údocutilsr   Ú_doc_snippetsr   rI   r�   r´   r!   r-   r,   Ú<module>rÌ      sÏ   ðÙ =ã 	Ý #ç O× OÝ ß +ß 'å Ý å ð ð ð€ñ" ˆ=ÓôG2�yó G2ó ðG2ñR ˆ=ÓôJ�Ð)ó Jó ðJñZ ˆ=Óôh7�WÐ.ó h7ó ðh7ñV ˆ=Óô_�WÐ.ó _ó ñ_r-   