
    h              
       d   d Z ddlZddlZdZdZ ej                  j                  j                  e Z	 ej                  j                  j                  eD  cg c]  } d| z   	 c}  Z
ej                  j                  j                  dddd	d
      Z e ed      D cg c]  } ee	      |    ed|z         f c}      Z e ed      D cg c]  } ee
      |    ed|z         f c}      Zej$                  dej&                  dej(                  diZdZedz  Zd Zd Zyc c} w c c}w c c}w )a  
Utilities for working with the terminal.

**Module Overview:**

::

  encoding - provides the ANSI escape sequence for a terminal attribute
  format - wrap text with ANSI for the given colors or attributes

.. data:: Color (enum)
.. data:: BgColor (enum)

  Foreground or background terminal colors.

  =========== ===========
  Color       Description
  =========== ===========
  **BLACK**   black color
  **BLUE**    blue color
  **CYAN**    cyan color
  **GREEN**   green color
  **MAGENTA** magenta color
  **RED**     red color
  **WHITE**   white color
  **YELLOW**  yellow color
  =========== ===========

.. data:: Attr (enum)

  Terminal text attributes.

  .. versionchanged:: 1.5.0
     Added the LINES attribute.

  =================== ===========
  Attr                Description
  =================== ===========
  **BOLD**            heavy typeface
  **HIGHLIGHT**       inverted foreground and background
  **UNDERLINE**       underlined text
  **READLINE_ESCAPE** wrap encodings in `RL_PROMPT_START_IGNORE and RL_PROMPT_END_IGNORE sequences <https://stackoverflow.com/questions/9468435/look-how-to-fix-column-calculation-in-python-readline-if-use-color-prompt>`_
  **LINES**           formats lines individually
  =================== ===========
    N)BLACKREDGREENYELLOWBLUEMAGENTACYANWHITEFBG_BOLD	UNDERLINE	HIGHLIGHTREADLINE_ESCAPELINES      (   147z[%sm0c                  V   g }| D ]  }|dk(  rd}t         j                  j                  j                  |      }t        j                  |d      }t        j                  ||      }t        j                  ||      }|sx|j                  |        |rt        dj                  |      z  S y)ai  
  Provides the ANSI escape sequence for these terminal color or attributes.

  .. versionadded:: 1.5.0

  :param list attr: :data:`~stem.util.terminal.Color`,
    :data:`~stem.util.terminal.BgColor`, or :data:`~stem.util.terminal.Attr` to
    provide an ecoding for

  :returns: **str** of the ANSI escape sequence, **None** no attributes are
    recognized
  HILIGHTr   N;)stemutil	str_tools_to_camel_caseFG_ENCODINGgetBG_ENCODINGATTR_ENCODINGappendCSIjoin)attrsterm_encodingsattrterm_encodings       X/var/www/betterdocs.net/sherlock_api/venv/lib/python3.12/site-packages/stem/util/term.pyencodingr+   I   s     . +d yd99--d3DOOD$/MOOD-8M!%%dM:MM*+ .)))     c           	      V   t         j                  j                  j                  |       } t        r| S t
        j                  |v rct        |      }|j                  t
        j                         | j                  d      D cg c]  }t        |g|  }}dj                  |      S t        | v r<dj                  | j                  t              D cg c]  }t        |g|  c}      S t        | t        }}|r$t
        j                  |v r
d|z  }d|z  }|| z   |z   S | S c c}w c c}w )a  
  Simple terminal text formatting using `ANSI escape sequences
  <https://en.wikipedia.org/wiki/ANSI_escape_code#CSI_codes>`_.
  The following are some toolkits providing similar capabilities:

  * `django.utils.termcolors <https://github.com/django/django/blob/master/django/utils/termcolors.py>`_
  * `termcolor <https://pypi.org/project/termcolor/>`_
  * `colorama <https://pypi.org/project/colorama/>`_

  .. versionchanged:: 1.6.0
     Normalized return value to be unicode to better support python 2/3
     compatibility.

  :param str msg: string to be formatted
  :param str attr: text attributes, this can be :data:`~stem.util.term.Color`,
    :data:`~stem.util.term.BgColor`, or :data:`~stem.util.term.Attr` enums
    and are case insensitive (so strings like 'red' are fine)

  :returns: **unicode** wrapped with ANSI escape encodings, starting with the given
    attributes and ending with a reset
  
 z%s)r   r   r   _to_unicodeDISABLE_COLOR_SUPPORTAttrr   listremovesplitformatr%   RESETr+   r   )msgr(   linelinescompprefixsuffixs          r*   r6   r6   l   s   . 			'',#J	ZZ4:DKK

-0YYt_=TVD 4 =E=99U
 c\77CIIe4DEDF4'$'EFFT?E&&t#f$ff$fC<&  J% > Fs   D!D&)__doc__stem.util.enumr   stem.util.str_toolsTERM_COLORSr1   r   enumEnumColorBgColorr2   dictranger3   strr   r!   r   r   r   r"   r$   r7   r+   r6   )coloris   00r*   <module>rK      s+  ,\  U
  		[)
$))..

;G%G
Hyy~~6;=NPWX 58DaT%[^Sa[1DEU1XFT']1%s26{3FGCdnncJc	 *F1_  H EFs   D#D(D-