
    $gZ1                     "   d Z ddlmZ ddlmZ ddlmZ ddlmc m	Z ddl
Z
ddlZddlmZ dZdZd	Zd
ZdZdZdZdZdZdZdZdZeeefZdZdefZdZdZd ZeZd Z d Z!d Z"d Z#d Z$d Z%d Z&d Z' G d  d!e          Z( G d" d#e          Z)d$ Z*dS )%a  
Emoji.

pymdownx.emoji
Emoji extension for EmojiOne's, GitHub's, or Twemoji's gemoji.

MIT license.

Copyright (c) 2016 - 2017 Isaac Muse <isaacmuse@gmail.com>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software,
and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions
of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
    )	Extension)InlineProcessor)utilN   z(:[+\-\w]+:))emojionegemojitwemojife0fzAhttps://cdnjs.cloudflare.com/ajax/libs/emojione/2.2.7/assets/svg/zAhttps://cdnjs.cloudflare.com/ajax/libs/emojione/2.2.7/assets/png/z>https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.0.3/assets/svg/z@https://cdn.jsdelivr.net/gh/jdecked/twemoji@15.0.3/assets/72x72/z;https://github.githubassets.com/images/icons/emoji/unicode/z3https://github.githubassets.com/images/icons/emoji/nonelongshorthtml_entityunicode   zUsing emoji indexes with no arguments is now deprecated.
Emoji indexes now take 2 arguments: 'options' and 'md'.
Please update your custom index accordingly.
c                 x    |                      di           }|r|                                D ]\  }}|||<   dS dS )z'Add additional attributes from options.
attributesN)getitems)optionsr   attrkvs        N/var/www/html/netbox-4.1.3/venv/lib/python3.11/site-packages/pymdownx/emoji.pyadd_attributesr   8   sY     ;;|R((D JJLL 	 	DAqJqMM 	 	    c                     ddl m} |j        t          j        |j                  t          j        |j                  dS )zThe EmojiOne index.r   )	emoji1_dbnameemojialiases) r   r   copydeepcopyr    r!   r   md	emoji_maps      r   r   r   F   I     )(((((y//=!233  r   c                     ddl m} |j        t          j        |j                  t          j        |j                  dS )zThe Gemoji index.r   )	gemoji_dbr   )r"   r*   r   r#   r$   r    r!   r%   s      r   r   r   Q   r(   r   c                     ddl m} |j        t          j        |j                  t          j        |j                  dS )zThe Twemoji index.r   )
twemoji_dbr   )r"   r,   r   r#   r$   r    r!   r%   s      r   r	   r	   \   sI     *)))))y//=!233  r   c	                    | dk    rt           }	t          }
n#| dk    rt          }	t          }
nt          }	t          }
|du}|                    d|           }|r|                    d|	          }n|                    d|
          }d                    ||r|n	|dd	                   }|||d
}|r||d<   t          ||           t          j        d|          S )zReturn PNG element.r   r	   Nclasses
image_pathnon_standard_image_pathz{}{}.pngr   classaltsrctitleimg)	GITHUB_UNICODE_CDN
GITHUB_CDNTWEMOJI_PNG_CDNEMOJIONE_PNG_CDNr   formatr   etreeElement)index	shortnamealiasucr4   r6   categoryr   r&   def_image_pathdef_non_std_image_path
is_unicoder.   r/   r5   r   s                   r   to_pngrG   j   s    +!+	)		(!0)!14Jkk)U++G  T[[~>>

[[!:<RSS



-i"o C  J  $#
77J'''=
+++r   c	                    | dk    rt           }	nt          }	|                    d|           |d                    |                    d|	          |          d}
|r||
d<   t	          ||
           t          j        d|
          S )zReturn SVG element.r	   r.   z{}{}.svgr/   r2   r6   r7   )TWEMOJI_SVG_CDNEMOJIONE_SVG_CDNr   r<   r   r=   r>   )r?   r@   rA   rB   r4   r6   rC   r   r&   svg_pathr   s              r   to_svgrL      s     	"# Y..  KKh//
 
 J  $#
77J'''=
+++r   c	                     dd|                     d|           |                     dd          |r|nd|dz  i}	|r||	d<   t          ||	           t          j        d	|	          }
t	          j        |          |
_        |
S )
zReturn PNG sprite element.r3   z,%(class)s-%(size)s-%(category)s _%(unicode)sr.   size64r"   )r3   rN   rC   r   r6   span)r   r   r=   r>   md_utilAtomicStringtext)r?   r@   rA   rB   r4   r6   rC   r   r&   r   els              r   to_png_spriterU      s     	?[[E22KK--%-52	C
 C
 
J  $#
77J'''	vz	*	*B"3''BGIr   c	                 <   d                     |                    dd          |          }	t          j        dd|                    d|           i          }
t          j        |
d          }t          j        |          |_        t          j        |
dd	|	i           |
S )
z
    Return SVG sprite element.

    ```
    <svg class="%(classes)s"><description>%(alt)s</description>
    <use xlink:href="%(sprite)s#emoji-%(unicode)s"></use></svg>
    ```
    z{}#emoji-{}r/   z(./../assets/sprites/emojione.sprites.svgsvgr3   r.   descriptionusez
xlink:href)r<   r   r=   r>   
SubElementrQ   rR   rS   )r?   r@   rA   rB   r4   r6   rC   r   r&   
xlink_hrefrW   descs               r   to_svg_spriter]      s     %%L"LMMr J -Y)F)FG
H
HCC//D$S))DI	S%,
!;<<<Jr   c	                 6    |j                             |          S )zReturn html entities.)	htmlStashstore)	r?   r@   rA   rB   r4   r6   rC   r   r&   s	            r   to_altra      s     <c"""r   c                   H    e Zd ZdZd Zd Zd Zd Zd Zd Z	d Z
d	 Zd
 ZdS )EmojiPatternzWReturn element of type `tag` with a text attribute of group(2) of an `InlineProcessor`.c                 @   t          j        | ||           |d         }|d         }|d         | _        |                     |d                    |t          v | _        |t          k    | _        |d         | _        |t          v r|nt          | _        |d         | _        dS )Initialize.r6   r4   r   emoji_indexremove_variation_selectoremoji_generatorN)r   __init__r   
_set_indexUNICODE_ALTunicode_altUNICODE_ENTITYencoded_altremove_var_selVALID_TITLENO_TITLEr6   	generator)selfpatternconfigr&   r6   r4   s         r   ri   zEmojiPattern.__init__   s     	 w333wUmi(}-...+-.0$%@A#{22UU
 12r   c                     t          t          j        |          j                  r || j        | j                  | _        dS t          j        t                      |            | _        dS )zSet the index.N)
leninspectgetfullargspecargsr   r&   rf   r   warn_deprecatedMSG_INDEX_WARN)rs   r?   s     r   rj   zEmojiPattern._set_index   se     w%e,,122 	'$uT\47;;D 000$uwwDr   c                 >    |                     dt          z   d          S )zRemove variation selectors.-r"   )replaceUNICODE_VARIATION_SELECTOR_16rs   values     r   _remove_variation_selectorz'EmojiPattern._remove_variation_selector   s     }}S#@@"EEEr   c                 f    d                     d |                    d          D                       S )zGet the Unicode char.r"   c                 R    g | ]$}t          j        t          |d                     %S )   )r   get_charint).0cs     r   
<listcomp>z2EmojiPattern._get_unicode_char.<locals>.<listcomp>  s*    LLLac!Rjj11LLLr   r~   )joinsplitr   s     r   _get_unicode_charzEmojiPattern._get_unicode_char  s1     wwLL5;;s;K;KLLLMMMr   c                     |                     d          }|                     d|          }|r| j        r|                     |          }||fS )ac  
        Get Unicode and Unicode alt.

        Unicode: This is the stripped down form of the Unicode, no joining chars and no variation chars.
            Unicode code points are not always valid.  If this is present and there is no 'unicode_alt',
            Unicode code points can be counted on as valid.  For the most part, the returned `uc` should
            be used to reference image files, or create classes, but for inserting actual Unicode, 'uc_alt'
            should be used.

        Unicode Alt: When present, this will always be valid Unicode points.  This contains not just the
            needed characters to identify the Unicode emoji, but the formatting as well. Joining characters
            and variation characters will be present. If you don't want variation chars, enable the global
            'remove_variation_selector' option.
        r   rl   )r   ro   r   )rs   r    rB   uc_alts       r   _get_unicodezEmojiPattern._get_unicode  sW      YYy!!="-- 	=d) 	=44V<<F6zr   c                 b    | j         t          k    r	|d         }n| j         t          k    r|}nd}|S )zGet the title.r   N)r6   
LONG_TITLESHORT_TITLE)rs   r@   r    r6   s       r   
_get_titlezEmojiPattern._get_title  s:     :##&MEEZ;&&EEEr   c                     || j         s|}nM|                     |          }| j        r1d                    d t	          j        |          D                       }|S )zGet alt form.Nr"   c                 V    g | ]&}t           j        d t          j        |          z  z   'S )z#x%04x;)rQ   AMP_SUBSTITUTEr   get_ord)r   points     r   r   z)EmojiPattern._get_alt.<locals>.<listcomp>2  s0    wwwTYW+y4<;N;N/NOwwwr   )rl   r   rn   r   r   get_code_points)rs   r@   r   r4   s       r   _get_altzEmojiPattern._get_alt)  sm     >!1>CC((00C ggww]a]qru]v]vwww  
r   c                 ,    |                     d          S )zGet the category.rC   )r   )rs   r    s     r   _get_categoryzEmojiPattern._get_category6  s     yy$$$r   c                 4   |                     d          }| j        d                             ||          }||k    rdn|}| j        d                             |d          }|r|                     |          \  }}|                     ||          }	|                     ||          }
|                     |          }|                     | j        d         ||||
|	|| j        | j	        	  	        }||
                    d          |                    d          fS )zHandle emoji pattern matches.r   r!   Nr    r   r   )grouprf   r   r   r   r   r   rr   r   r&   startend)rs   mdatarT   r@   rA   r    rB   r   r6   r4   rC   s               r   handleMatchzEmojiPattern.handleMatch;  s    WWQZZ$Y/33B;;	!RR )--i>> 	**511JBOOB..E--F++C))%00H (
 
B 1771::quuQxx''r   N)__name__
__module____qualname____doc__ri   rj   r   r   r   r   r   r   r    r   r   rc   rc      s        aa3 3 3' ' 'F F F
N N N
  .	 	 	  % % %
( ( ( ( (r   rc   c                   (     e Zd ZdZ fdZd Z xZS )EmojiExtensionz&Add emoji extension to Markdown class.c                     t           dgt          dgddgddgddgi d	gd
| _         t                      j        |i | dS )re   zSFunction that returns the desired emoji index. - Default: 'pymdownx.emoji.emojione'z8Emoji generator method. - Default: pymdownx.emoji.to_pngr   zWhat title to use on images. You can use 'long' which shows the long name, 'short' which shows the shortname (:short:), or 'none' which shows no title. - Default: 'short'r   zControl alt form. 'short' sets alt to the shortname (:short:), 'uniocde' sets alt to the raw Unicode value, and 'html_entity' sets alt to the HTML entity. - Default: 'unicode'Fz;Remove variation selector 16 from unicode. - Default: FalsezDEmoji options see documentation for options for github and emojione.)rf   rh   r6   r4   rg   r   N)r   rG   ru   superri   )rs   rz   kwargs	__class__s      r   ri   zEmojiExtension.__init__Z  s    
 e
 J 
 % ' M*
 V3
 
< 	$)&)))))r   c                     |                                  }t          j        |dg           |j                            t          t          ||          dd           dS )zAdd support for emoji.:r    K   N)
getConfigsr   escape_charsinlinePatternsregisterrc   RE_EMOJI)rs   r&   ru   s      r   extendMarkdownzEmojiExtension.extendMarkdown}  sV     """se$$$
""<&"#E#EwPRSSSSSr   )r   r   r   r   ri   r   __classcell__)r   s   @r   r   r   W  sU        00!* !* !* !* !*FT T T T T T Tr   r   c                      t          | i |S )zReturn extension.)r   )rz   r   s     r   makeExtensionr     s     4*6***r   )+r   markdownr   markdown.inlinepatternsr   r   rQ   xml.etree.ElementTreer=   ElementTreerx   r#   r"   r   SUPPORTED_INDEXESr   rJ   r;   rI   r:   r8   r9   rq   r   r   rp   rm   rk   LEGACY_ARG_COUNTr|   r   add_attriubtesr   r   r	   rG   rL   rU   r]   ra   rc   r   r   r   r   r   <module>r      s   0       3 3 3 3 3 3 $ $ $ $ $ $ % % % % % % % % %        5  & V V RTR B

;1.)           ', ', ',T, , ,2  .  *# # #r( r( r( r( r(? r( r( r(j-T -T -T -T -TY -T -T -Tf+ + + + +r   