§
    º³Ùg›;  ã            
       ó”  — d Z ddlZddlmZmZmZmZmZ ddlm	Z	m
Z
 ddlmZ ddlmZmZ dej        deeef         d	eeej        ej        f                  fd
„Z	 ddej        deeef         dee
         d	eej                 fd„Zde_        dej        deeef         d	eej                 fd„Zdej        deeef         d	eej                 fd„Z	 ddej        deeef         dee
         d	eej                 fd„Zde_        dej        deeef         d	eej                 fd„Zdej        deeef         d	eej                 fd„Z dS )aó  
A collection of functions that generate drawings from formatted input data.
See :py:mod:`~qiskit.visualization.timeline.types` for more info on the required data.

An end-user can write arbitrary functions that generate custom drawings.
Generators in this module are called with the `formatter` kwarg. This data provides
the stylesheet configuration.


There are 4 types of generators in this module.

1. generator.gates

In this stylesheet entry the input data is `types.ScheduledGate` and generates gate objects
such as time buckets and gate name annotations.

The function signature of the generator is restricted to:

    ```python

    def my_object_generator(
            gate: types.ScheduledGate,
            formatter: Dict[str, Any]) -> List[ElementaryData]:

        # your code here: create and return drawings related to the gate object.
    ```

If a generator object has the attribute ``accepts_program`` set to ``True``, then the generator will
be called with an additional keyword argument ``program: QuantumCircuit``.

2. generator.bits

In this stylesheet entry the input data is `types.Bits` and generates timeline objects
such as zero line and name of bit associated with the timeline.

The function signature of the generator is restricted to:

    ```python

    def my_object_generator(
            bit: types.Bits,
            formatter: Dict[str, Any]) -> List[ElementaryData]:

        # your code here: create and return drawings related to the bit object.
    ```

If a generator object has the attribute ``accepts_program`` set to ``True``, then the generator will
be called with an additional keyword argument ``program: QuantumCircuit``.

3. generator.barriers

In this stylesheet entry the input data is `types.Barrier` and generates barrier objects
such as barrier lines.

The function signature of the generator is restricted to:

    ```python

    def my_object_generator(
            barrier: types.Barrier,
            formatter: Dict[str, Any]) -> List[ElementaryData]:

        # your code here: create and return drawings related to the barrier object.
    ```

If a generator object has the attribute ``accepts_program`` set to ``True``, then the generator will
be called with an additional keyword argument ``program: QuantumCircuit``.

4. generator.gate_links

In this stylesheet entry the input data is `types.GateLink` and generates barrier objects
such as barrier lines.

The function signature of the generator is restricted to:

    ```python

    def my_object_generator(
            link: types.GateLink,
            formatter: Dict[str, Any]) -> List[ElementaryData]:

        # your code here: create and return drawings related to the link object.
    ```

If a generator object has the attribute ``accepts_program`` set to ``True``, then the generator will
be called with an additional keyword argument ``program: QuantumCircuit``.

Arbitrary generator function satisfying the above format can be accepted.
Returned `ElementaryData` can be arbitrary subclasses that are implemented in
the plotter API.
é    N)ÚListÚUnionÚDictÚAnyÚOptional)ÚQubitÚQuantumCircuit)ÚCircuitError)ÚtypesÚdrawingsÚgateÚ	formatterÚreturnc                 óæ  — 	 t          | j                             ¦   «         ¦  «        }n# t          t          f$ r d}Y nw xY w	 | j        j        pd}n# t          $ r d}Y nw xY w| j        j        || j        | j        | j	        |d 
                    t          t           | j        j        ¦  «        ¦  «        dœ}|d                              | j        j        |d         ¦  «        }| j	        dk    rŸ|d         ||d         |d	         d
œ}| j        j        dk    rt          j        j        }nt          j        j        }t%          j        || j        | j        | j	        z   gd|d         z  d|d         z  g| j        | j                 ||¬¦  «        }nc|d         ||d         dddœ}|d         }	|d         }
t%          j        t          j        j        | j        | j                 | j        d|	|
|¬¦  «        }|gS )aH  Generate time bucket or symbol of scheduled gate.

    If gate duration is zero or frame change a symbol is generated instead of time box.
    The face color of gates depends on the operand type.

    Stylesheet:
        - The `gate` style is applied for finite duration gate.
        - The `frame_change` style is applied for zero duration gate.
        - The `gate_face_color` style is applied for face color.

    Args:
        gate: Gate information source.
        formatter: Dictionary of stylesheet settings.

    Returns:
        List of `TextData` or `BoxData` drawings.
    zn/aú, )ÚnameÚlabelÚbitsÚt0ÚdurationÚunitaryÚ
parametersúcolor.gatesúcolor.default_gater   z
layer.gatez
alpha.gatezline_width.gate)ÚzorderÚ	facecolorÚalphaÚ	linewidthÚdelayç      à¿zbox_height.gateç      à?)Ú	data_typeÚxvalsÚyvalsÚbitÚmetaÚstyleszlayer.frame_changeztext_size.frame_changeÚcenter©r   ÚcolorÚsizeÚvaÚhazunicode_symbol.frame_changezlatex_symbol.frame_change)r"   r%   ÚxvalÚyvalÚtextÚlatexr'   )ÚstrÚoperandÚ	to_matrixÚAttributeErrorr
   r   r   r   r   r   ÚjoinÚmapÚparamsÚgetr   ÚBoxTypeÚDELAYÚ
SCHED_GATEr   ÚBoxDataÚbit_positionÚTextDataÚ
SymbolTypeÚFRAME)r   r   r   r   r&   r*   r'   r"   ÚdrawingÚunicode_symbolÚlatex_symbols              ú^/granary/edev/quantum/lib/python3.11/site-packages/qiskit/visualization/timeline/generators.pyÚgen_sched_gaterF   q   s?  € ð*Ý�d”l×,Ò,Ñ.Ô.Ñ/Ô/ˆˆøÝ�LÐ)ð ð ð ØˆˆˆðøøøðØ”Ô"Ð+ eˆˆøÝð ð ð Øˆˆˆðøøøð ”Ô!ØØ”	ØŒgØ”MØØ—i’i¥¥C¨¬Ô)<Ñ =Ô =Ñ>Ô>ðð €Dð �mÔ$×(Ò(¨¬Ô):¸IÐFZÔ<[Ñ\Ô\€Eà„}�qÒÐð   Ô-ØØ˜|Ô,Ø"Ð#4Ô5ð	
ð 
ˆð Œ<Ô Ò'Ð'ÝœÔ+ˆIˆIåœÔ0ˆIåÔ"ØØ”7˜DœG d¤mÑ3Ð4Ø˜)Ð$5Ô6Ñ6¸¸iÐHYÔ>ZÑ8ZÐ[Ø”	˜$Ô+Ô,ØØð
ñ 
ô 
ˆˆð  Ð 4Ô5ØØÐ6Ô7ØØð
ð 
ˆð #Ð#@ÔAˆØ Ð!<Ô=ˆåÔ#ÝÔ&Ô,Ø”	˜$Ô+Ô,Ø”ØØØØð
ñ 
ô 
ˆð ˆ9Ðs   ‚&) ©?¾?ÁA ÁA!Á A!Úprogramc           	      ó@  ‡— | j         dk    rd}d}n
d}|d         }|d         |d         |d         |ddœ}d	| j        j        › d
�}|d                              | j        j        |¦  «        }| j        j        › }|› }	t	          | j        ¦  «        dk    r_‰€%d                     d„ | j        D ¦   «         ¦  «        }
n&d                     ˆfd„| j        D ¦   «         ¦  «        }
|d|
› d�z  }|	d|
› d�z  }	g }| j        j        D ]M}	 |                     t          |¦  «        d›¦  «         Œ(# t          $ r |                     |› ¦  «         Y ŒJw xY wd                     |¦  «        }|r"| j        j        dk    r|d|› d�z  }|	d|› d�z  }	| j         dk    r|d| j         › d�z  }|	d| j         › d�z  }	| j        j        dk    rt          j        j        }nt          j        j        }t          j        || j        d| j         z  z   || j        | j                 ||	|¬¦  «        }|gS )aº  Generate gate name.

    Parameters and associated bits are also shown.

    Stylesheet:
        - `gate_name` style is applied.
        - `gate_latex_repr` key is used to find the latex representation of the gate name.

    Args:
        gate: Gate information source.
        formatter: Dictionary of stylesheet settings.
        program: Optional program that the bits are a part of.

    Returns:
        List of `TextData` drawings.
    r   r(   Úbottomúlabel_offset.frame_changeúlayer.gate_nameúcolor.gate_nameútext_size.gate_namer)   ú{\rm Ú}úlatex_symbol.gatesé   Nr   c              3   ó^   K  — | ](}t          t          |¦  «        ¦  «        d d…         V — Œ)dS )éýÿÿÿN)r2   Úid)Ú.0r%   s     rE   ú	<genexpr>z%gen_full_gate_name.<locals>.<genexpr>ü   s7   è è € Ð HÐ H°s¥¥R¨¡W¤W¡¤¨b¨c¨cÔ!2Ð HÐ HÐ HÐ HÐ HÐ Hó    c              3   óN   •K  — | ]}‰                      |¦  «        j        › V — Œ d S ©N)Úfind_bitÚindex)rU   r%   rG   s     €rE   rV   z%gen_full_gate_name.<locals>.<genexpr>þ   s7   øè è € Ð WÐ WÀc G×$4Ò$4°SÑ$9Ô$9Ô$?Ð!AÐ WÐ WÐ WÐ WÐ WÐ WrW   ú[ú]z.2fr   ú(ú)r!   ©r"   r.   r/   r%   r0   r1   r'   )r   r3   r   r9   Úlenr   r6   r8   ÚappendÚfloatÚ
ValueErrorr   Ú	LabelTyper;   Ú	GATE_NAMEr   r?   r   r>   )r   r   rG   Úv_alignÚv_posr'   Údefault_nameÚ
latex_nameÚlabel_plainÚlabel_latexÚbits_strr8   ÚvalÚ
params_strr"   rB   s     `             rE   Úgen_full_gate_namerp   Í   s¶  ø€ ð& „}�qÒÐàˆØˆˆð ˆØÐ5Ô6ˆð Ð-Ô.ØÐ,Ô-ØÐ/Ô0ØØðð €Fð 3˜Tœ\Ô.Ð2Ð2Ð2€LØÐ/Ô0×4Ò4°T´\Ô5FÈÑUÔU€Jà”\Ô&Ð(€KØ Ð"€Kõ ˆ4Œ9�~„~˜ÒÐØˆ?ð —y’yÐ HÐ H¸d¼iÐ HÑ HÔ HÑHÔHˆHˆHà—y’yÐ WÐ WÐ WÐ WÈTÌYÐ WÑ WÔ WÑWÔWˆHØ�˜8���Ñ&ˆØ�˜8���Ñ&ˆð €FØŒ|Ô"ð $ð $ˆð	$Ø�MŠM�U 3™ZœZÐ-Ð-Ñ.Ô.Ð.Ð.øÝð 	$ð 	$ð 	$Ø�MŠM˜S˜(Ñ#Ô#Ð#Ð#Ð#ð	$øøøà—’˜6Ñ"Ô"€Jàð )�d”lÔ'¨7Ò2Ð2ØÐ(˜:Ð(Ð(Ð(Ñ(ˆØÐ(˜:Ð(Ð(Ð(Ñ(ˆð „}�qÒÐØÐ+˜4œ=Ð+Ð+Ð+Ñ+ˆØÐ+˜4œ=Ð+Ð+Ð+Ñ+ˆð „|Ô˜GÒ#Ð#Ý”OÔ)ˆ	ˆ	å”OÔ-ˆ	åÔØØŒW�s˜Tœ]Ñ*Ñ*ØØŒI�dÔ'Ô(ØØØðñ ô €Gð ˆ9Ðs   Ä$D)Ä) EÅETc           	      óØ  — | j         dk    rd}d}n
d}|d         }|d         |d         |d         |ddœ}d	| j        j        › d
�}|d                              | j        j        |¦  «        }| j        j        › }|› }| j        j        dk    rt          j        j        }	nt          j        j        }	t          j	        |	| j
        d| j         z  z   || j        | j                 |||¬¦  «        }
|
gS )ah  Generate gate name.

    Only operand name is shown.

    Stylesheet:
        - `gate_name` style is applied.
        - `gate_latex_repr` key is used to find the latex representation of the gate name.

    Args:
        gate: Gate information source.
        formatter: Dictionary of stylesheet settings.

    Returns:
        List of `TextData` drawings.
    r   r(   rI   rJ   rK   rL   rM   r)   rN   rO   rP   r   r!   r`   )r   r3   r   r9   r   re   r;   rf   r   r?   r   r   r>   )r   r   rg   rh   r'   ri   rj   rk   rl   r"   rB   s              rE   Úgen_short_gate_namerr   *  s  € ð$ „}�qÒÐàˆØˆˆð ˆØÐ5Ô6ˆð Ð-Ô.ØÐ,Ô-ØÐ/Ô0ØØðð €Fð 3˜Tœ\Ô.Ð2Ð2Ð2€LØÐ/Ô0×4Ò4°T´\Ô5FÈÑUÔU€Jà”\Ô&Ð(€KØ�/€Kð „|Ô˜GÒ#Ð#Ý”OÔ)ˆ	ˆ	å”OÔ-ˆ	åÔØØŒW�s˜Tœ]Ñ*Ñ*ØØŒI�dÔ'Ô(ØØØðñ ô €Gð ˆ9ÐrW   r%   c                 óþ   — |d         |d         |d         |d         dœ}t          j        t          j        j        t          j        j        t          j        j        gd|d         z  d|d         z  g| |¬	¦  «        }|gS )
a	  Generate time slot of associated bit.

    Stylesheet:
        - `timeslot` style is applied.

    Args:
        bit: Bit object associated to this drawing.
        formatter: Dictionary of stylesheet settings.

    Returns:
        List of `BoxData` drawings.
    zlayer.timeslotzalpha.timeslotzline_width.timeslotzcolor.timeslot)r   r   r   r   r    zbox_height.timeslotr!   ©r"   r#   r$   r%   r'   )r   r=   r   r:   ÚTIMELINEÚAbstractCoordinateÚLEFTÚRIGHT)r%   r   r'   rB   s       rE   Úgen_timeslotry   f  s—   € ð Ð,Ô-ØÐ+Ô,ØÐ4Ô5ØÐ/Ô0ð	ð €Fõ ÔÝ”-Ô(ÝÔ'Ô,­eÔ.FÔ.LÐMØ�iÐ 5Ô6Ñ6¸¸iÐH]Ô>^Ñ8^Ð_ØØðñ ô €Gð ˆ9ÐrW   c           	      ó6  — |d         |d         |d         dddœ}|€6t          j        dd	¬
¦  «         t          | t          ¦  «        rdnd}d|› d�}nŒ|                     | ¦  «        }|j        rI|j        d         d         j        }d|j        d         d         j        › d|j        d         d         › d�}n't          | t          ¦  «        rdnd}d|› d|j        › d�}t          j
        t          j        j        t          j        j        d| |||¬¦  «        }|gS )a7  Generate bit label.

    Stylesheet:
        - `bit_name` style is applied.

    Args:
        bit: Bit object associated to this drawing.
        formatter: Dictionary of stylesheet settings.
        program: Optional program that the bits are a part of.

    Returns:
        List of `TextData` drawings.
    zlayer.bit_namezcolor.bit_nameztext_size.bit_namer(   Úrightr)   Nz;bits cannot be accurately named without passing a 'program'é   )Ú
stacklevelÚqÚcrN   rO   éÿÿÿÿr   z}_{rQ   r`   )ÚwarningsÚwarnÚ
isinstancer   rZ   Ú	registersr   Úprefixr[   r   r?   r   re   ÚBIT_NAMErv   rw   )r%   r   rG   r'   rk   rl   ÚlocrB   s           rE   Úgen_bit_namerˆ   …  sU  € ð& Ð,Ô-ØÐ+Ô,ØÐ.Ô/ØØðð €Fð €ÝŒÐSÐ`aÐbÑbÔbÐbÝ'¨­UÑ3Ô3Ð<�c�c¸ˆØ/ Ð/Ð/Ð/ˆˆà×Ò˜sÑ#Ô#ˆØŒ=ð 	DØœ-¨Ô+¨AÔ.Ô3ˆKØ^ C¤M°"Ô$5°aÔ$8Ô$?Ð^Ð^ÀcÄmÐTVÔFWÐXYÔFZÐ^Ð^Ð^ˆKˆKå!+¨CµÑ!7Ô!7Ð@˜#˜#¸SˆKØC KÐCÐC°c´iÐCÐCÐCˆKåÔÝ”/Ô*ÝÔ%Ô*ØØØØØðñ ô €Gð ˆ9ÐrW   Úbarrierc                 óà   — |d         |d         |d         |d         |d         dœ}t          j        t          j        j        | j        | j        gddg| j        | j                 |¬	¦  «        }|gS )
zìGenerate barrier line.

    Stylesheet:
        - `barrier` style is applied.

    Args:
        barrier: Barrier instruction.
        formatter: Dictionary of stylesheet settings.

    Returns:
        List of `LineData` drawings.
    zalpha.barrierzlayer.barrierzline_width.barrierzline_style.barrierzcolor.barrier©r   r   r   Ú	linestyler*   r    r!   rt   )r   ÚLineDatar   ÚLineTypeÚBARRIERr   r   r>   )r‰   r   r'   rB   s       rE   Úgen_barrierr�   ¼  sˆ   € ð ˜?Ô+Ø˜OÔ,ØÐ3Ô4ØÐ3Ô4Ø˜?Ô+ðð €Fõ ÔÝ”.Ô(ØŒz˜7œ:Ð&Ø�SˆkØŒL˜Ô-Ô.Øðñ ô €Gð ˆ9ÐrW   Úlinkc                 óØ   — |d                               | j        |d         ¦  «        }|d         |d         |d         |d         |dœ}t          j        | j        | j        |¬¦  «        }|gS )	a\  Generate gate link line.

    Line color depends on the operand type.

    Stylesheet:
        - `gate_link` style is applied.
        - The `gate_face_color` style is applied for line color.

    Args:
        link: Gate link object.
        formatter: Dictionary of stylesheet settings.

    Returns:
        List of `GateLinkData` drawings.
    r   r   zalpha.gate_linkzlayer.gate_linkzline_width.gate_linkzline_style.gate_linkr‹   )r   r.   r'   )r9   Úopnamer   ÚGateLinkDatar   r   )r‘   r   r*   r'   rB   s        rE   Úgen_gate_linkr•   Ü  s€   € ð$ �mÔ$×(Ò(¨¬°iÐ@TÔ6UÑVÔV€Eð Ð,Ô-ØÐ-Ô.ØÐ5Ô6ØÐ5Ô6Øðð €Fõ Ô#¨¬¸¼ÈÐPÑPÔP€Gàˆ9ÐrW   rY   )!Ú__doc__r�   Útypingr   r   r   r   r   Úqiskit.circuitr   r	   Úqiskit.circuit.exceptionsr
   Úqiskit.visualization.timeliner   r   ÚScheduledGater2   r?   r=   rF   rp   Úaccepts_programrr   ÚBitsry   rˆ   ÚBarrierr�   r�   ÚGateLinkr”   r•   © rW   rE   ú<module>r¡      s­  ððZð Zðx €€€Ø 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3Ð 3à 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ð 0Ø 2Ð 2Ð 2Ð 2Ð 2Ð 2Ø 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9Ð 9ðYØ
Ô
ðYà�C˜�HŒ~ðYð 
ˆ%�Ô! 8Ô#3Ð3Ô
4Ô5ðYð Yð Yð Yðz _cðWð WØ
Ô
ðWØ*.¨s°C¨x¬.ðWØCKÈNÔC[ðWà	ˆ(Ô
ÔðWð Wð Wð Wðt &*Ð Ô "ð9Ø
Ô
ð9Ø*.¨s°C¨x¬.ð9à	ˆ(Ô
Ôð9ð 9ð 9ð 9ðx�e”jð ¨T°#°s°(¬^ð ÀÀXÔEUÔ@Vð ð ð ð ðD )-ð1ð 1Ø	Œð1à�C˜�HŒ~ð1ð �nÔ%ð1ð 
ˆ(Ô
Ôð	1ð 1ð 1ð 1ðh  $€Ô ð˜œð °4¸¸S¸´>ð ÀdÈ8ÔK\ÔF]ð ð ð ð ð@˜œð °4¸¸S¸´>ð ÀdÈ8ÔK`ÔFað ð ð ð ð ð rW   