8fиrUddlZddlmZmZddlmZddlmZddlm Z m Z m Z m Z m Z mZmZmZmZmZddlmZddlmZdd lmZdd lmZdd lmZmZdd lmZdd l m!Z!ddl"m#Z#ddl$m%Z%ddl&m'Z'ddl(m)Z)ddl*m+Z+m,Z,e r ddl-m.Z.m/Z/m0Z0m1Z1dZ2de3d<dZ4de3d<ej5dZ6ee7dfZ8 e e7gee,fZ9GddeZ:Gdde%Z;ee>?d"gd#e>?d$gd%e.Z-e-@d&e-Ae>d'(e-Ae-@d)e-Ae>d*d+,e-Ae-@d-e-Ae>d.d/,e-Ae-@d0e-Ae>d1d2,e-AdSdS)3N)partialreduce)gcd) itemgetter) TYPE_CHECKINGAnyCallableDictIterableList NamedTupleOptionalTupleUnion) loop_last) pick_bool) divide_line) AlignMethod)cell_len set_cell_size)Lines)strip_control_codes) EmojiVariant) JupyterMixin) Measurement)Segment)Style StyleType)ConsoleConsoleOptions JustifyMethodOverflowMethoddefaultr"DEFAULT_JUSTIFYfoldr#DEFAULT_OVERFLOWz\s+$TextceZdZUdZeed< eed< eeefed< defdZ de fdZ dede de dffd Zdeddfd Zdeddfd Zd eddfd ZdS)Spanz A marked up region in some text.startendstylereturnc8d|jd|jd|jdS)NzSpan(z, ))r+r,r-selfs u/builddir/build/BUILD/imunify360-venv-2.3.5/opt/imunify360/venv/lib/python3.11/site-packages/pip/_vendor/rich/text.py__repr__z Span.__repr__8s)@tz@@TX@@@@@@c"|j|jkSN)r,r+r1s r3__bool__z Span.__bool__;sx$*$$r5offsetc||jkr|dfS||jkr|dfS|\}}}t|t|||}t|j||}||fS)z)Split a span in to 2 from a given offset.N)r+r,r*min)r2r9r+r,r-span1span2s r3splitz Span.split>sv DJ  :  TX  :  sEUCV,,e44UYU++e|r5c<|\}}}t||z||z|S)zMove start and end by a given offset. Args: offset (int): Number of characters to add to start and end. Returns: TextSpan: A new TextSpan with adjusted position. r*r2r9r+r,r-s r3movez Span.moveKs*!sEEFNC&L%888r5c\|\}}}||kr|St|t|||S)zCrop the span at the given offset. Args: offset (int): A value between start and end. Returns: Span: A new (possibly smaller) span. )r*r;rAs r3 right_cropzSpan.right_cropWs:!sE S==KE3vs++U333r5cellsc>|r|\}}}t|||z|S|S)zExtend the span by the given number of cells. Args: cells (int): Additional space to add to end of span. Returns: Span: A span. r@)r2rEr+r,r-s r3extendz Span.extendes3   $ E3sU{E22 2Kr5N)__name__ __module__ __qualname____doc__int__annotations__rstrrr4boolr8rrr>rBrDrGr5r3r*r*.s** JJJ HHH e )A#AAAA%$%%%% C E&(62B*B$C     93 96 9 9 9 9 4 4 4 4 4 4 C F      r5r*ceZdZdZgdZ dddddddddedeeefd ed d ed d ee dedee dee e ddfdZ de fdZde fdZdefdZdefdZdeddfdZdede fdZdede fdZdee efddfdZede fdZedefdZeddddddd dedeeefd!e d"eed ed d ed deddfd#Zedddddd$d%dedeeefd ed d ed d ee dedee ddfd&Ze dddd'dede d ed d ed ddf d(Z!edddddd$dd)d*eede"ee ffdeeefd ed d ed d ee dede d+ee#eefddfd,Z$edefd-Z%e%j&d.eddfd/Z%ede e fd0Z'e'j&de e ddfd1Z'dd2eddfd3Z(dd4Z) ddeeefd6e dee ddfd7Z* ddeeefd6e dee ddfd8Z+ dd+e#eefd6e dee ddfd9Z,dd+ee#eefd:eddfd;Z-dd?d@e defdAZ/dBe ddfdCZ0 dddDdEedeee1e fdFede fdGZ2ddHdIe3edeeefdJe de fdKZ4ddLZ5dMe ddfdNZ6dOe ddfdPZ7d>d?dQdRde3e8fdSZ9d>d?dQdRde:fdTZ;dd>d?dede3dUfdVZddZd[d\e d ed d]e ddfd^Z?dd_Z@ddae dbeddfdcZAddae dbeddfddZBddae dbeddfdeZCddfeDdge dbeddfdhZE ddedefdeeedifddfdjZFddkZGdle3e"eee fddfdmZHddnZI ddZdZdodpedqe dre deJfdsZKdte3e deJfduZLddwe ddfdxZMddd$ddyd>d?dge d ed d ed de d ee deJfdzZNdge deJfd{ZOde fd|ZP dd}d~ddee dbede ddfdZQdS)r(aText with color / style. Args: text (str, optional): Default unstyled text. Defaults to "". style (Union[str, Style], optional): Base style for text. Defaults to "". justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None. end (str, optional): Character to end text with. Defaults to "\\n". tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None. spans (List[Span], optional). A list of predefined style spans. Defaults to None. ) _textr-justifyoverflowno_wrapr,tab_size_spans_lengthN )rSrTrUr,rVspanstextr-rSr"rTr#rUr,rVr[r.ct|} | g|_||_||_||_||_||_||_|pg|_t| |_ dSr7) rrRr-rSrTrUr,rVrWlenrX) r2r\r-rSrTrUr,rVr[sanitized_texts r3__init__z Text.__init__sc-T22$%  29 4<    "'+2 // r5c|jSr7)rXr1s r3__len__z Text.__len__s |r5c*t|jSr7)rOrXr1s r3r8z Text.__bool__sDL!!!r5c|jSr7plainr1s r3__str__z Text.__str__s zr5c(d|jd|jdS)Nz)rfrWr1s r3r4z Text.__repr__s7 77t{7777r5otherct|ttfr+|}|||St Sr7) isinstancerNr(copyappendNotImplemented)r2rkresults r3__add__z Text.__add__sB ec4[ ) ) YY[[F MM% Mr5czt|tstS|j|jko|j|jkSr7)rmr(rprfrWr2rks r3__eq__z Text.__eq__s7%&& "! !zU[(HT[EL-HHr5ct|tr ||jvSt|tr|j|jvSdS)NF)rmrNrfr(rts r3 __contains__zText.__contains__sG eS ! ! -DJ& & t $ $ -;$*, ,ur5slicec dtddffd }t|tr ||S|tj\}}}|dkr||g}|dSt d)Nr9r.r(cxttjfdjDd}|S)NcRg|]#\}}}|cxkr|knn dd|$S)rrrP.0r+r,r-_Spanr9s r3 z9Text.__getitem__..get_text_at..sY)sEV,,,,u,,,,,E!Q&&,,,r5rY)r[r,)r*r(rfrW)r9r\r~r2s` @r3 get_text_atz%Text.__getitem__..get_text_atsaE 6"-1[ DKr5rz%slices with step!=1 are not supported)rLrmindicesr^rfdivide TypeError)r2rxrr+stopstepliness` r3 __getitem__zText.__getitem__s         eS ! ! I;u%% % % c$*oo > > E4qyy UDM22Qx GHHHr5c*t|jS)z5Get the number of cells required to render this text.)rrfr1s r3rz Text.cell_lens ###r5cddlm}g}|j}dd|jfgd|jDd|jDt |d|jf}|tddd}|j}|D]C\}}} ||kr||||||}| r||rd | d nd | d Dd |} | S) z~Get console markup to render this Text. Returns: str: A string potentially creating markup tags. r)escaperFc34K|]}|jd|jfVdSFN)r+r-r}spans r3 zText.markup..s- F F$tz5$*- F F F F F Fr5c34K|]}|jd|jfVdSTN)r,r-rs r3rzText.markup..s- C Cttxtz* C C C C C Cr5Tkeyz[/][rY) markuprrfr-rWr^sortrrojoin) r2routputrf markup_spanspositionror9closingr-rs r3rz Text.markupsB #"""""  tz " F F$+ F F F D Ct{ C C C ZZtz *  jA..///&2 C C "FGU  vveHVO455666! CA}E}}}}\\\\BBB r5T)r-emoji emoji_variantrSrTr,rrcZddlm}|||||} || _|| _|| _| S)aCreate Text instance from markup. Args: text (str): A string containing console markup. style (Union[str, Style], optional): Base style for text. Defaults to "". emoji (bool, optional): Also render emoji code. Defaults to True. emoji_variant (str, optional): Optional emoji variant, either "text" or "emoji". Defaults to None. justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. end (str, optional): Character to end text with. Defaults to "\\n". Returns: Text: A Text instance with markup rendered. r)render)rr)rrrSrTr,) clsr\r-rrrSrTr,r rendered_texts r3 from_markupzText.from_markupsL4 #"""""tU%}UUU ' !)  r5r-rSrTrUr,rVc ddlm}td||||||} |} | d| |D} | S)aCreate a Text object from a string containing ANSI escape codes. Args: text (str): A string containing escape codes. style (Union[str, Style], optional): Base style for text. Defaults to "". justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None. end (str, optional): Character to end text with. Defaults to "\\n". tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None. r) AnsiDecoderrZ)rSrTrUr,rVr-c3K|]}|VdSr7rPr}lines r3rz!Text.from_ansi..Gs"CCdTCCCCCCr5)ansirr(rdecode) rr\r-rSrTrUr,rVrjoinerdecoderrqs r3 from_ansizText.from_ansi$s}. &%%%%%    +--CCgnnT.B.BCCCCC r5rSrTcL||||}|||S)aaConstruct a Text instance with a pre-applied styled. A style applied in this way won't be used to pad the text when it is justified. Args: text (str): A string containing console markup. style (Union[str, Style]): Style to apply to the text. Defaults to "". justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. Returns: Text: A text instance with a style applied to the entire string. r)stylize)rr\r-rSrT styled_texts r3styledz Text.styledJs4*c$(CCC E"""r5)r-rSrTrUr,rVmetapartsrc|||||||} | j} t} |D]*} t| | tfr | | %| | +|r| || S)aConstruct a text instance by combining a sequence of strings with optional styles. The positional arguments should be either strings, or a tuple of string + style. Args: style (Union[str, Style], optional): Base style for text. Defaults to "". justify (str, optional): Justify method: "left", "center", "full", "right". Defaults to None. overflow (str, optional): Overflow method: "crop", "fold", "ellipsis". Defaults to None. no_wrap (bool, optional): Disable text wrapping, or None for default. Defaults to None. end (str, optional): Character to end text with. Defaults to "\\n". tab_size (int): Number of spaces per tab, or ``None`` to use ``console.tab_size``. Defaults to None. meta (Dict[str, Any], optional). Meta data to apply to text, or None for no meta data. Default to None Returns: Text: A new text instance. r)ror(rmrN apply_meta) rr-rSrTrUr,rVrrr\ro_Textparts r3assemblez Text.assemblecs6s      D$ -- t   " OOD ! ! ! r5ct|jdkr%d|jg|jdd<|jdS)z Get the text as a single string.rrYNr)r^rRrr1s r3rfz Text.plainsC tz??a  WWTZ001DJqqqMz!}r5new_textc||jkrXt|}|g|jdd<|j}t ||_||jkr|dSdSdS)zSet the text to a new value.N)rfrrRrXr^ _trim_spans)r2rr_ old_lengths r3rfz Text.plains{ tz ! !0::N+,DJqqqMJ~..DLDL((  """"" " ! )(r5c|jS)z.Get a reference to the internal list of spans.rWr1s r3r[z Text.spanss {r5c$|dd|_dS)z Set spans.Nr)r2r[s r3r[z Text.spanssAAAh r5rfc nt||j|j|j|j|j|j}|S)zNReturn a new Text instance with copied metadata (but not the string or spans).r)r(r-rSrTrUr,rV)r2rf copy_selfs r3 blank_copyzText.blank_copys? *L]L]   r5c t|j|j|j|j|j|j|j}|j|jdd<|S)zReturn a copy of this instance.rN) r(rfr-rSrTrUr,rVrW)r2rs r3rnz Text.copysT J*L]L]   #k r5rr+c |rpt|}|dkr||z}||}|dkr||z}||ks||krdS|jt|t |||dSdS)azApply a style to the text, or a portion of the text. Args: style (Union[str, Style]): Style instance or style definition to apply. start (int): Start offset (negative indexing is supported). Defaults to 0. end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None. rN)r^rWror*r;r2r-r+r,lengths r3rz Text.stylizes  EYYFqyy{Qwwsl#,, K  tE3vs+;+;UCC D D D D D E Er5c |rqt|}|dkr||z}||}|dkr||z}||ks||krdS|jdt|t |||dSdS)aApply a style to the text, or a portion of the text. Styles will be applied before other styles already present. Args: style (Union[str, Style]): Style instance or style definition to apply. start (int): Start offset (negative indexing is supported). Defaults to 0. end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None. rN)r^rWinsertr*r;rs r3stylize_beforezText.stylize_befores  HYYFqyy{Qwwsl#,, K  q$uc&#.>.>"F"F G G G G G H Hr5c^tj|}||||dS)agApply metadata to the text, or a portion of the text. Args: meta (Dict[str, Any]): A dict of meta information. start (int): Start offset (negative indexing is supported). Defaults to 0. end (Optional[int], optional): End offset (negative indexing is supported), or None for end of text. Defaults to None. )r+r,N)r from_metar)r2rr+r,r-s r3rzText.apply_metas1%% U%S 11111r5handlersc |in|}|d|D|tj||S)aApply event handlers (used by Textual project). Example: >>> from rich.text import Text >>> text = Text("hello world") >>> text.on(click="view.toggle('world')") Args: meta (Dict[str, Any]): Mapping of meta information. **handlers: Keyword args are prefixed with "@" to defined handlers. Returns: Text: Self is returned to method may be chained. Nc i|] \}}d|| S)@rP)r}rvalues r3 zText.on..s$III*#uYYYIIIr5)updateitemsrrr)r2rrs r3onzText.on s]\rrt II8H8HIIIJJJ U_T**+++ r5suffixc|j|r$|t|dSdS)zaRemove a suffix if it exists. Args: suffix (str): Suffix to remove. N)rfendswithrDr^)r2rs r3 remove_suffixzText.remove_suffixsD :  v & & ) OOCKK ( ( ( ( ( ) )r5consoler r9c|dkrt||z}|j}||j}|jD]&\}}}||cxkr|krn|||dz }'|S)a Get the style of a character at give offset. Args: console (~Console): Console where text will be rendered. offset (int): Offset in to text (negative indexing supported) Returns: Style: A Style instance. rrYr$)r^ get_styler-rnrW)r2rr9rr-r+r, span_styles r3get_style_at_offsetzText.get_style_at_offset's A::YY'F%  $*%%**,,&*k ; ; "E3 V$$$$u$$$$$:r:::: r5spacescdkrdS|j}dz}|rTt|fd|D|jdd<|j||xjz c_dS|xj|z c_dS)zExtend the Text given number of spaces where the spaces have the same style as the last character. Args: spaces (int): Number of spaces to add to the Text. rNricTg|]$}|jkr|n|%SrP)r,rG)r}r end_offsetrs r3rz%Text.extend_style..GsF(,x:'='= F###4r5)r[r^rWrRrorXrf)r2rr[ new_spacesrs ` @r3 extend_stylezText.extend_style;s Q;; F 6\  %TJ!DKN J  j ) ) ) LLF "LLLL JJ* $JJJJr5) style_prefix re_highlightrc d}|jj}t}|j}t j||D]}|j} |rO| \} } t|r||| | n|} | | | kr||| | | |dz }| D]6} | | \} } | dkr | | kr||| | || 7|S)aHighlight text with a regular expression, where group names are translated to styles. Args: re_highlight (str): A regular expression. style (Union[GetStyleCallable, StyleType]): Optional style to apply to whole match, or a callable which accepts the matched text and returns a style. Defaults to None. style_prefix (str, optional): Optional prefix to add to style group names. Returns: int: Number of regex matches rNr) rWror*rfrefinditerrcallable groupdictkeys)r2rr-rcount append_spanr~rfmatchget_spanr+r, match_stylenames r3highlight_regexzText.highlight_regexPs8&k(  [u55 L LEzH @%XZZ s9A%SeeE%)$4555e *sU{{KeS+ > >??? QJE))..00 L L%Xd^^ sB;;3;;KeS\2I42I2I J JKKK L r5)case_sensitivewordsrc.dd|D}|jj}d}t}t j||j|rdn tjD]5}|d\} } ||| | ||dz }6|S)aBHighlight words with a style. Args: words (Iterable[str]): Words to highlight. style (Union[str, Style]): Style to apply. case_sensitive (bool, optional): Enable case sensitive matching. Defaults to True. Returns: int: Number of words highlighted. |c3>K|]}tj|VdSr7)rrr}words r3rz'Text.highlight_words..s*>>BIdOO>>>>>>r5rflagsr) rrWror*rrrf IGNORECASEr) r2rr-rre_wordsadd_spanrr~rr+r,s r3highlight_wordszText.highlight_wordsvs"88>>>>>>>;%[ dj^(N     EAJE3 HUU5#u-- . . . QJEE r5cB|j|_dS)z"Strip whitespace from end of text.N)rfrstripr1s r3rz Text.rstripsZ&&(( r5sizect|}||krm||z }t|j}|It|d}|t ||dSdSdS)zRemove whitespace beyond a certain width at the end of the text. Args: size (int): The desired size of the text. Nr)r^_re_whitespacesearchrfgrouprDr;)r2r text_lengthexcesswhitespace_matchwhitespace_counts r3 rstrip_endzText.rstrip_ends $ii    4'F-44TZ@@ +#&'7'='=a'@'@#A#A $4f = =>>>>>  ,+r5 new_lengthct|}||kr:||kr|||z dS|||z dSdS)z.s(>>Xd^^>>>>>>r5rc34K|]}t|VdSr7r rs r3rz(Text.__rich_measure__..s(114111111r5)rf splitlinesmaxr>r)r2rrr\rmax_text_widthrmin_text_widths r3__rich_measure__zText.__rich_measure__sz!!BGN>>>>>>>>Q 5: NC115111 1 1 1 >>:::r5rc#NKt}|j}|js"t|V|r ||VdSt|jt jtt|jd}fd|D|j d<dgd|Dd|Dt|d df}| tdd gj }j}ijt jd t ffd } t#||ddD]J\\} } } \} }}| r || n || | | kr||| | | VK|r||VdSdS) aRender the text as Segments. Args: console (Console): Console instance. end (Optional[str], optional): Optional end character. Returns: Iterable[Segment]: Result of render that may be written to the console. Nrrc8i|]\}}||jSrPr-)r}indexrrs r3rzText.render..s+VVVkeTUIIdj11VVVr5r)rFrc30K|]\}}|jd|fVdSr)r+r}r*rs r3rzText.render..s/ M M[UDtz5%( M M M M M Mr5c30K|]\}}|jd|fVdSrrr,s r3rzText.render..s/ J J+%txu% J J J J J Jr5Trr.ctfdtD}|}||S|}||<|S)z#Construct current style from stack.c3(K|] }|V dSr7rP)r} _style_id style_maps r3rz9Text.render..get_current_style..s(OOI9Y/OOOOOOr5)tuplesorted)styles cached_style current_stylecombinestack style_cachestyle_cache_getr1s r3get_current_stylez&Text.render..get_current_stylescOOOOOOOOOF*?622L'###GFOOM"/K  r5)rrfrWrrrnulllist enumerater-r^rrroremovegetr7zip)r2rr,_Segmentr\enumerated_spansr[ stack_append stack_popr;r9leavingstyle_id next_offset_r7rr8r9r:r1s @@@@@@r3rz Text.rendersZz{ $--    $hsmm### FG-uz||DDD  $+q 9 9::VVVVEUVVV  y,, !   M M.iter_textsqz !"+E"2"2##JD$JJJ#" ## !         r5rc3FK|]\}}}|z|z|VdSr7rPr|s r3rzText.join..'sS%E3funfslE::r5) rr rRrGrWror*r-r^rX) r2rrrM extend_textr extend_spansr\r~r9s `` @@r3rz Text.joins/??$$ !8F+ ! ! ! ! ! ! !n+ o, - IKK  D K # # #z K EE&&3t99*rrRrrr(rr^rXrW) r2rVrror cell_positionrr tab_remainderrrqs r3 expand_tabszText.expand_tabs/s tz ! ! F  }H  H!JJttJ<< ! !D4:%%t !  44 @@! ! !Dz**400 7)-B).xf   zJ&& 8j((U4:s:tx'@'@$*MM'&&r5Nr^rfr*rW)r2r~ras @@r3rzText._trim_spanstsU__           AAAr5rir characterct|dks Jdr>|z}||j||_tfd|jD|jdd<dSdS)zPad left and right with a given number of characters. Args: count (int): Width of padding. character (str): The character to pad with. Must be a string of length 1. r&Character must be a string of length 1c>g|]\}}}|z|z|SrPrPr}r+r,r-r~rs r3rzText.pad..E%E3eemS5[%88r5Nrc)r2rrdpad_charactersr~s ` @r3rWzText.pads9~~"""$L"""  &.N*HDJHHHDJE)-DKNNN   r5ct|dks Jdr:|z|j|_tfd|jD|jdd<dSdS)zPad the left with a given character. Args: count (int): Number of characters to pad. character (str, optional): Character to pad with. Defaults to " ". rrfc>g|]\}}}|z|z|SrPrPrhs r3rz!Text.pad_left..rir5Nrc)r2rrdr~s ` @r3pad_leftz Text.pad_lefts9~~"""$L"""  %-;tz;;DJE)-DKNNN  r5cnt|dks Jd|r|j||z|_dSdS)zPad the right with a given character. Args: count (int): Number of characters to pad. character (str, optional): Character to pad with. Defaults to " ". rrfN)r^rf)r2rrds r3rzText.pad_rightsS9~~"""$L"""  < J; E(9;;DJJJ < >>>> lI66666 7 7r5rc pt|ttfstdt |rxt|trt |}|j|t |}t ||r,|jt||z||xj z c_ nt|trt|td|j |j r:|jt |z|j |j|j |jfd|jD|xj t |z c_ |S)zAdd text with an optional style. Args: text (Union[Text, str]): A str or Text to append. style (str, optional): A style name. Defaults to None. Returns: Text: Returns self for chaining. z(Only str or Text can be appended to TextNz2style must not be set when appending Text instancec3FK|]\}}}|z|z|VdSr7rPr}r+r,r-r~r s r3rzText.append..sU##)sEE%+-s[/@%HH######r5)rmrNr(rr^rrRrorWr*rX ValueErrorr-rfrG)r2r\r-r_r9r~r s @@r3roz Text.appends$d ,, HFGG G t99 *$$$ *!4T!:!: !!.111T!.11 RK&&tFF[4H%'P'PQQQ + D$'' *$$L#l :K&&k;T+BDJOO !!$*--- ""#####-1[### D )  r5c xt|j|jr:|jt |z|j|j|j|jfd|jD|xjt |z c_|S)a Append another Text instance. This method is more performant that Text.append, but only works for Text. Args: text (Text): The Text instance to append to this instance. Returns: Text: Returns self for chaining. c3FK|]\}}}|z|z|VdSr7rPrxs r3rz#Text.append_text..sU  !sE E%+%s['8% @ @      r5) r*rXr-rWror^rRrfrG)r2r\r~r s @@r3 append_textzText.append_textsl : X K  uu[+D 2I4:VV W W W $*%%%      %)[       D !  r5tokensc  |jj}|jj}t}t |}|D]J\}}|||r&||||t |z||t |z }K||_|S)a)Append iterable of str and style. Style may be a Style instance or a str style definition. Args: tokens (Iterable[Tuple[str, Optional[StyleType]]]): An iterable of tuples containing str content and style. Returns: Text: Returns self for chaining. )rRrorWr*r^rX)r2r}r|rr~r9contentr-s r3 append_tokenszText.append_tokenssj' k( T$ # #NGU K  I EE&&3w<<*?GGHHH c'll "FF  r5cD|j|jdS)zCopy styles from another Text instance. Args: text (Text): A Text instance to copy styles from, must be the same length. N)rWrG)r2r\s r3 copy_styleszText.copy_styless" 4;'''''r5)rS allow_blank separatorrSrcs Jd|jvr"t|gS|rE|dt jt jD}nOdttffd }tfd||D}|s) r| |S)aSplit rich text in to lines, preserving styles. Args: separator (str, optional): String to split on. Defaults to "\\n". include_separator (bool, optional): Include the separator in the lines. Defaults to False. allow_blank (bool, optional): Return a blank line if the text ends with a separator. Defaults to False. Returns: List[RichText]: A list of rich text, one per line of the original. zseparator must not be emptyc3>K|]}|VdSr7rr}rs r3rzText.split..;s;   %       r5r.c3KtjtjD]!}|\}}|V|V"dSr7)rrrr)rr+r,rr\s r3 flatten_spansz!Text.split..flatten_spans@s[[9)=)=tDDE!&JE3KKKIIIIr5c32K|]}|jk |VdSr7re)r}rrs r3rzText.split..Fs8yAXAXAXAXAXAXr5) rfrrnrrrrr rLrpop)r2rrSrrrr\s ` @r3r>z Text.split#s9"77777yz D $))++'' '  KK  )+RYy5I5I4)P)P   EE  8C=        !%]]__!=!=E t}}Y77  IIKKK r5offsetsc t|}|s"t|gS|jt }dg||}tt ||dd}|j|j|jttfd|D}|j s|Sd|j D}t |}t} |j D]\} } d} |} | | zdz} ||\}}| |kr|dz } n | |kr|dz} nn | | zdz}-| |kr|}n4|x}} |} ||\}}| |kr|dz } n | |kr|dz} nn | | zdz}-t||dzD]X}||\}}td| |z }t| |z ||z }||kr||| ||Y|S)zDivide text in to a number of lines at given offsets. Args: offsets (Iterable[int]): Offsets used to divide text. Returns: Lines: New RichText instances between offsets. rrNc3LK|]\}}||VdS))r-rSrTNrP)r}r+r,rrSrTr-r\s r3rzText.divide..fsb  s EU3Y!          r5c&g|]}|jjSrP)rWrors r3rzText.divide..rsIII+IIIr5rt)r=rrnrfr^rAr-rSrTr(rW_linesr*ranger#r;)r2r_offsetsr divide_offsets line_ranges new_lines _line_appends line_countr~ span_startspan_end lower_bound upper_bound start_line_no line_startline_end end_line_noline_no new_startnew_endrrSrTr-r\s @@@@@r3rz Text.divideOs== ($))++'' 'z$ii 4h4 43~~abb/ABBCC  ,=        *     {  II 8HIII %% +/;$ M$ M 'J%K$K(;61.rbr5N)r^rfr*rWrRrX)r2rr~ras @@r3rDzText.right_crops__v-           AAAj6'*+   r5rc`|p |jpt}|p |jpt}t ||jdp|dk}t } |dD]} d| vr| ||rt | g} n8tt| ||dk} | | } | D]} | ||r| ||||| D]} | || | | | S) aCWord wrap the text. Args: console (Console): Console instance. width (int): Number of cells available per line. justify (str, optional): Justify method: "default", "left", "center", "full", "right". Defaults to "default". overflow (str, optional): Overflow method: "crop", "fold", or "ellipsis". Defaults to None. tab_size (int, optional): Default tab size. Defaults to 8. no_wrap (bool, optional): Disable wrapping, Defaults to False. Returns: Lines: Number of lines. FrYTrrRr&)r&r)rT)rSr%rTr'rrUrr>rVrrNrrr\rG) r2rrprSrTrVrU wrap_justify wrap_overflowrrrrs r3rz Text.wrapsd.A$,A/  EDME5E GT\599QX=QJJ4J00 $ $Dt||  *** 1!4&MM %c$ii]f=TUUU KK00 ! ' '&&&& !!UL="" = = em <<<< LL # # # # r5ct}|j}|D]"}||||#|S)zFit the text in to given width by chopping in to lines. Args: width (int): Maximum characters in a line. Returns: Lines: Lines container. )rror>r)r2rprrors r3fitzText.fitsQwwJJLL  D OOE " " " F4LLLL r5cdtjd|jtjD} t t d|Dpd}n#t $rd}YnwxYw|S)zrAuto-detect indentation of code. Returns: int: Number of spaces used to indent code. cRh|]$}t|d%Sr)r^r rs r3 z*Text.detect_indentation..s:     A     r5 ^( *)(.*)$rcg|] }|dz| S)rtrP)r}indents r3rz+Text.detect_indentation..s"RRRvPQzRVRRRr5r)rrrf MULTILINErrr)r2 _indentations indentations r3detect_indentationzText.detect_indentations  ]DJblSSS    sRR-RRRSSXWX K   KKK s!A A#"A#u│z dim green)rdr- indent_sizec||n|}|}||d|dz z}tjd}g}|j} d} |dD]} || j} | r| ds| dz } 9| d} tt| |\}}||zd|z}|| jt|dz| _| |dt|| r*| t|| g| zd} | | | r(| td | g| z|d |}|S) uAdds indent guide lines to text. Args: indent_size (Optional[int]): Size of indentation, or None to auto detect. Defaults to None. character (str, optional): Character to use for indentation. Defaults to "│". style (Union[Style, str], optional): Style of indent guides. Returns: Text: New text with indentation guides. NrirrrTrrtr)rYrZ)rrnrVrcompileror>rrfr divmodr^rrGr(rr)r2rrdr- _indent_sizer\ indent_line re_indentradd_line blank_linesrrr full_indentsremaining_space new_indentrs r3with_indent_guideszText.with_indent_guidess$5@4Gt..000[ yy{{ ">C> J}-- " # JJ4J00  DOODJ//E  A q [[^^F,23v;; ,M,M )L/',6Oo8MOOJ#djZ1B1B&CCDJ LL3z?? 3 3 3   $z"?"?"?!@;!NOOO HTNNNN  D   d2U3334{B C C C??4((--i88r5)rYrY)rY)r.r()rNr7)r.N)ri)r\r(r.r()r\r(r.N)rZr)RrHrIrJrK __slots__rNrrrrOrLr r*r`rbr8rgr4rrrobjectrurwrxrpropertyrr classmethodrrrrrrr rrfsetterr[rrnrrrrrrrGetStyleCallablerr rrrrrrrr&rrrVr\rrWrmrrroror|rrrr>rrDrrrrrPr5r3r(r(us      I#%0 .2/3"&"&&*0000S%Z 0 /* 0 +, 0$003-0T #0 0000."$""""8#8888SVIFItIIII &TIsEz!2IvIIII4$#$$$X$X: $&04-1/3S%Z     - /*+, [B $&-1/3"&"#####S%Z # /* # +, #$##3-# ###[#J .2/3  /*  +,  [0$&-1/3"&)-+++c65i#889+S%Z +/* + +, + $ +++tCH~&+ +++[+ZsX  \#c#d###\#tDzX \4:$\   V        "! EES%Z EEc] E  EEEE:! HHS%Z HHc] H  HHHH6JN 2 2cN 2+. 29A# 2  2 2 2 2xS#X/CF()C)D))))9ce(%3%4%%%%0?C$  $$$$. 9:;$  $ $$$$V $ }S%Z    :)))) ?s ?t ? ? ? ?5S5T5555; ;+;; ' ;;;;& ;  ;+; ;  ; ; ; ;9 9 i9 c9 8I;N9 9 9 9 v%(6*%v%%%%N('('HSM('T('('('('\04 ////+, /  /  ////6     t"ccD < ? .((((*#(! **** *  *  ****XMhsmMMMMM^T*.2/3"&..... /* . +, ..$. ....` C.&*.& ...c]. .  .  ......r5__main__)r a Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. Loremboldipsumitaliczjustify='left'redr)zjustify='center'greenrs)r-rSzjustify='right'bluerightzjustify='full'magentafull)Br functoolsrrmathroperatorrtypingrrr r r r r rrr_loopr_pickr_wraprrorrErr containersrcontrolrrrjupyterrmeasurersegmentrr-rrrr r!r"r#r%rMr'rr rNTextTyperr*r(rHpip._vendor.rich.consoler\rruleprintrPr5r3rs %%%%%%%%                        ********((((((!!!!!! ########POOOOOOOOOOOO#,,,,%+"+++G$$ f 1SE8I#667DDDDD:DDDN|||||<|||~% z000000 4 P  D 'F+++'H---giiG LL!""" MM$eM$$$ MMOOO LL#$$$ MM$gxM888 MMOOO LL"### MM$fgM666 MMOOO LL!""" MM$iM888 MMOOOOO3r5