
    -Ph'                     x   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mZmZ  e	e          Zd	ed
dfdZ G d de          Z G d de          Z G d de          Z G d dej        ej                  Z G d dej        ej                  Zd Zd Zd Zd Z G d de          Z dS )    )nodes)
directives)Sphinx)SphinxPostTransform)	getLogger   )findall)WARNING_TYPESdDirectivecreate_componentis_componentappreturnNc                 |   |                      dt                     |                      dt                     |                      dt                     |                     t
                     |                     t          t          t          f           |                     t          t          t          f           d S )Ntab-settab-itemztab-set-codehtml)add_directiveTabSetDirectiveTabItemDirectiveTabSetCodeDirectiveadd_post_transformTabSetHtmlTransformadd_nodesd_tab_inputvisit_tab_inputdepart_tab_inputsd_tab_labelvisit_tab_labeldepart_tab_label)r   s    R/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/sphinx_design/tabs.py
setup_tabsr#      s    i111j"2333n&9:::.///LL_6F$GLHHHLL_6F$GLHHHHH    c                   V    e Zd ZdZdZej        ej        dZde	e
j                 fdZdS )r   z#A container for a set of tab items.T)
sync-groupclassr   c                     |                                   t          ddg| j                            dg                     }|                     |           | j                            | j        | j        |           |j	        D ]x}t          |d          s.t                              dt           d|t          d	            n9d
|j	        d         v r)| j                            dd          |j	        d         d<   y|gS )Nr   
sd-tab-setr'   classesr   z2All children of a 'tab-set' should be 'tab-item' [.tab]tablocationtypesubtypesync_idr   r&   
sync_group)assert_has_contentr   optionsgetset_source_infostatenested_parsecontentcontent_offsetchildrenr   LOGGERwarningr
   )selftab_setitems      r"   run_with_defaultsz!TabSetDirective.run_with_defaults   s'   !!!"Mt|/?/?/L/LM
 
 
 	W%%%
d.A7KKK$ 	W 	WDj11 A-9A A A!%!     DM!,,,151A1A,PU1V1Va .yr$   N)__name__
__module____qualname____doc__has_contentr   unchanged_requiredclass_optionoption_speclistr   NoderB    r$   r"   r   r      sY        --K 3( K
4
#3      r$   r   c                       e Zd ZdZdZdZdZej        ej	        ej
        ej        ej        ej        dZdeej                 fdZdS )r   a  A single tab item in a tab set.

    Note: This directive generates a single container,
    for the label and content::

        <container design_component="tab-item" has_title=True>
            <rubric>
                ...title nodes
            <container design_component="tab-content">
                ...content nodes

    This allows for a default rendering in non-HTML outputs.

    The ``TabHtmlTransform`` then transforms this container
    into the HTML specific structure.
    r   T)selectedsyncnameclass-containerclass-labelclass-contentr   c           	      4   |                                   t          | j        j        d          s=t                              dt           d| j        j        | j	        ft          d           t          ddg| j                            dg           d	| j        v 
          }| j                            | j        d         | j	                  \  }}t!          j        | j        d         dg|R ddg| j                            dg           i}d| j        v r| j        d         |d<   |                     |           ||z  }t          ddg| j                            dg                     }| j                            | j        | j        |           ||z  }|gS )Nr   z2The parent of a 'tab-item' should be a 'tab-set' [r,   r-   r.   r   sd-tab-itemrR   rO   )r+   rO   r    r+   sd-tab-labelrS   rP   r2   tab-contentsd-tab-contentrT   r*   )r4   r   state_machinenoder=   r>   r
   envdocnamelinenor   r5   r6   r8   inline_text	argumentsr   rubricadd_namer9   r:   r;   )r?   tab_item	textnodes_	tab_labeltab_contents         r"   rB   z"TabItemDirective.run_with_defaultsS   s   !!!D.3Y?? 	NNX\XXX(*DK8!	     $"MT\%5%56G%L%LM DL0
 
 
 z--dnQ.?MM	1LN1
 
 
 
 $Jdl&6&6}b&I&IJ	
 
	 T\!!#'<#7Ii i   I '%N(8(8"(M(MN
 
 
 	
d.A;OOOKzr$   N)rC   rD   rE   rF   required_argumentsfinal_argument_whitespacerG   r   flagrH   	unchangedrI   rJ   rK   r   rL   rB   rM   r$   r"   r   r   5   s         "  $KO-$%2!.#0 K$4
#3 $ $ $ $ $ $r$   r   c                   n    e Zd ZdZdZej        ej        ej        ej        dZ	de
ej                 fdZdS )r   z?A container for a set of tab items, generated from code blocks.T)no-syncr&   	class-set
class-itemr   c           
         |                                   t          ddg| j                            dg                     }|                     |           | j                            | j        | j        |           g }|j	        D ]i}t          |t          j                  s-t                              dt           d|t          d           J|                    d	d
          }t          j        |                                t          j        |                                          dg| j                            dg                     }d| j        vr#| j                            dd          |d<   ||d<   t          d|gdg| j                            dg                     }t          d||gdg| j                            dg                     }|                    |           k||_	        |gS )Nr   r)   ro   r*   z>All children of a 'tab-code-set' should be a 'literal_block' [z
.tab_code]tab_coder.   languageunknownrX   rS   rn   r&   coder3   r2   rY   rZ   rT   )r<   r+   r   rV   rp   )r4   r   r5   r6   r7   r8   r9   r:   r;   r<   
isinstancer   literal_blockr=   r>   r
   rb   upperTextappend)r?   r@   new_childrenrA   rs   rg   rh   rd   s           r"   rB   z%TabSetCodeDirective.run_with_defaults   s+   !!!"Qt|/?/?R/P/PQ
 
 
 	W%%%
d.A7KKK$ 	* 	*DdE$788 M4@M M M$%&     xx
I66H  
8>>++,,'N$,*:*:="*M*MN  I
 ,,*.,*:*:<*P*P	,''/	)$*)RDL,<,<_b,Q,QR  K
 (#[1&L)9)9,)K)KL  H
 ))))'yr$   N)rC   rD   rE   rF   rG   r   rk   rH   rI   rJ   rK   r   rL   rB   rM   r$   r"   r   r   z   sd        IIK? 3, -	 K'4
#3 ' ' ' ' ' 'r$   r   c                       e Zd ZdS )r   NrC   rD   rE   rM   r$   r"   r   r              Dr$   r   c                       e Zd ZdS )r   Nr}   rM   r$   r"   r   r      r~   r$   r   c                     |d         g|d         |d         d}|d         rd|d<   | j                              | j        |dfi |           d S )Nidr0   set_id)idsr0   rQ   checkedinputbodyrz   starttagr?   r\   
attributess      r"   r   r      sg    t*tF|T(^TTJI * )
9I]T]4??J??@@@@@r$   c                     d S )NrM   r?   r\   s     r"   r   r      s	     	Dr$   c                     d|d         i}d|v rd|v r|d         |d<   |d         |d<   | j                              | j        |dfi |           d S )Nforinput_idr2   r3   zdata-sync-idzdata-sync-grouplabelr   r   s      r"   r    r       sv    j)*JD\T11%))_
>"(,\(:
$%I]T]4??J??@@@@@r$   c                 :    | j                             d           d S )Nz</label>)r   rz   r   s     r"   r!   r!      s    IZ     r$   c                   "    e Zd ZdZdZdZddZdS )r   z1Transform tab-set to HTML specific AST structure.   r   r   Nc           
         d}d}d}t           t          | j                  d                     D ]\  }}|t          |          z   }g }d}t          |j                  D ]L\  }	}
|
                    dd          r1||	} t                              dt           d	|
t          d
           M|dn|}t          |j                  D ]'\  }	}
	 |
j        \  }}n# t          $ r  w xY w|t          |          z   }|dz  }t          d||d|	|k              }|
j        |
j        c|_        |_        |                    |           t          ddg|j        R ||d         d}|                    d          r|dxx         |d         z  cc<   d|v rd|v r|d         |d<   |d         |d<   |
j        |
j        c|_        |_        |                    |           |                    |           )||_        dS )zRun the transform.zsd-tab-set-zsd-tab-item-r   c                 "    t          | d          S )Nr   )r   )r\   s    r"   <lambda>z)TabSetHtmlTransform.run.<locals>.<lambda>   s    T90M0M r$   NrO   Fz)Multiple selected 'tab-item' directives [r,   r-   r.   r   rW   radio)r   r   r0   r   r+   )r   r+   r   r3   r2   )	enumerater	   documentstrr<   r6   r=   r>   r
   
ValueErrorr   sourcelinerz   r   )r?   tab_set_id_basetab_item_id_basetab_item_id_numtab_set_id_numr@   tab_set_identityr<   selected_idxidxrd   rg   rh   tab_item_identity
input_node
label_nodes                   r"   runzTabSetHtmlTransform.run   s    ()'0"GDM""#M#MNN(
 (
 :	( :	(#NG  /^1D1DDHL!*7+;!<!< 
 
X<<
E22 	#+'*[[[[%-!-$)	 '    !- 411,L!*7+;!<!< $- $-X-5->*I{{!   $4s?7K7K$K!1$ *(+  L0  
 6>_hm2
!:?
+++ * '  /%i0  
 =='' :u%%%5)99%%%9,,i1G1G/8/FJ|,,5i,@Jy)5=_hm2
!:?
+++ ,,,,'Gu:	( :	(s   
CC')r   N)rC   rD   rE   rF   default_priorityformatsr   rM   r$   r"   r   r      s?        ;;GB( B( B( B( B( B(r$   r   )!docutilsr   docutils.parsers.rstr   sphinx.applicationr   !sphinx.transforms.post_transformsr   sphinx.util.loggingr   _compatr	   sharedr
   r   r   r   rC   r=   r#   r   r   r   ElementGeneralr   TextElementr   r   r   r    r!   r   rM   r$   r"   <module>r      s6         + + + + + + % % % % % % A A A A A A ) ) ) ) ) )       M M M M M M M M M M M M	8		IF It I I I I    k   >B B B B B{ B B BJ2 2 2 2 2+ 2 2 2j	 	 	 	 	5=%- 	 	 		 	 	 	 	5$em 	 	 	A A A	 	 	A A A! ! !H( H( H( H( H(- H( H( H( H( H(r$   