+
    Q(i]                     2   R t ^ RIt^ RIt^ RIt^ RIHt ^ RIHt ^ RIH	t	H
t
HtHt ^ RIHtHtHt ^ RIHt ^ RIHt ^ RIHtHt ^ R	IHtHt ]	'       d   ^ R
IHt  ! R R]4      t] ! R R4      4       tR R ltR R lt R R lt!RR R llt"RR R llt#R# )zqShared shell completion infrastructure.

Provides data extraction, type analysis, and text processing utilities.
N)Enum)Path)TYPE_CHECKINGAnyget_args
get_origin)ITERABLE_TYPESis_annotatedis_union)ArgumentCollection)CycloptsError)RegisteredCommandgroups_from_app)frozenis_class_and_subclass)Appc                   &    ] tR t^tRtRtRtRtRtR# )CompletionActionz'Shell-agnostic completion action types.nonefilesdirectories N)	__name__
__module____qualname____firstlineno____doc__NONEFILESDIRECTORIES__static_attributes__r       _/Users/agent/.openclaw/workspace/venv/lib/python3.14/site-packages/cyclopts/completion/_base.pyr   r      s    1DEKr!   r   c                   0   a  ] tR t^t o RtV 3R ltRtV tR# )CompletionDataz#Completion data for a command path.c                L   < V ^8  d   Qh/ R;R&   S[ S[,          ;R&   S[;R&   # )   r   	argumentscommandshelp_format)listr   str)format__classdict__s   "r"   __annotate__CompletionData.__annotate__   s2      $#	 
 $%%   r!   r   N)r   r   r   r   r   __annotate_func__r    __classdictcell__)r-   s   @r"   r$   r$      s     -  r!   r$   c                d    V ^8  d   QhRRR\         \        \        R3,          \        3,          /# )r&   appr   return.)dicttupler+   r$   )r,   s   "r"   r.   r.   (   s,     7 7 74c3h0O+P 7r!   c                8   a aa / oRR VV V3R llloS! 4        S# )a  Recursively extract completion data for app and all subcommands.

Parameters
----------
app : App
    The Cyclopts application to extract completion data from.

Returns
-------
dict[tuple[str, ...], CompletionData]
    Mapping from command path tuples to their completion data.
c                >    V ^8  d   QhR\         \        R3,          /# )r&   command_path.)r6   r+   )r,   s   "r"   r.   -extract_completion_data.<locals>.__annotate__7   s     %9 %9uS#X %9r!   c                p  <  SP                  \        V 4      4      w  rpVR,          p\        4       pSP                  T4      pSP                  T4      ;_uu_ 4        T F:  pTP                  '       g   K  TP!                  R
R7      p	TP#                  T	4       K<  	  R	R	R	4       . p
\%        TR
R7       FY  w  rTP&                  '       g   K  T F:  pTP(                  P&                  '       g   K!  Y9  g   K)  T
P+                  T4       K<  	  K[  	  TP                  P                  RRR7      p\        YjTR7      ST &   T
 F>  pTP,                   F+  pTP/                  R4      '       d   K  S! Y3,           4       K-  	  K@  	  R	#   \        \        \        3 d   p\
        P                  P                  R4      '       d   h \        P                  ! RT : RT 2^R7       SP                  P                  RRR7      p\        \        4       . TR7      ST &    R	p?R	# R	p?ii ; i  + '       g   i     EL; i)z@Recursively extract completion data for command and subcommands.CYCLOPTS_COMPLETION_DEBUGz3Failed to extract completion data for command path z: )
stacklevelr)   markdown)fallback)r'   r(   r)   NT)parse_docstring)resolve_lazy-)parse_commandsr*   r   
ValueError	TypeErrorosenvirongetwarningswarn	app_stackresolver$   r   _get_resolution_contextdefault_commandassemble_argument_collectionextendr   showr3   appendnames
startswith)r9   _execution_pathcommand_apper)   r'   apps_for_paramssubappapp_argumentsr(   groupregistered_commandsregistered_commandcmd_name_extractr3   completion_datas   &              r"   ra   )extract_completion_data.<locals>._extract7   s   	#&#5#5d<6H#I Aq(,K '(	55nE]]>**))))$*$G$GX\$G$]M$$]3 * + *9+TX*Y&Ezzz*=&)--2227I7Y (:; +> +Z "++33MJ3W(6kv(w%"*.44**3//\K78 5 #+; z95 	zz~~9::MMOP\O__abcaderst--//
/SK,:,.-OL) 	 +**s*   &F H$7'H$H!A;HH!$H5	)r   r   )r3   ra   rb   s   f@@r"   extract_completion_datard   (   s#     >@O%9 %9N Jr!   c                0    V ^8  d   QhR\         R\        /# )r&   	type_hintr4   )r   r   )r,   s   "r"   r.   r.   b   s     &! &!S &!-= &!r!   c                   \        V 4      '       d   \        \        V 4      ^ ,          4      # \        V 4      '       dX   \        V 4       F8  pV\	        R4      Jg   K  \        V4      pV\
        P                  8w  g   K6  Vu # 	  \
        P                  # \        V 4      p\        V\        \        4      4      '       d6   \        V 4      pV'       d#   \        V4      ^8  d   \        V^ ,          4      # T;'       g    T pV\        J g   \        V\        4      '       d   \
        P                  # \
        P                  # )zGet completion action from type hint.

Parameters
----------
type_hint : Any
    Type annotation.

Returns
-------
CompletionAction
    Completion action for type.
N)r	   get_completion_actionr   r
   typer   r   r   r   r6   r   lenr   r   )rf   argactionoriginargstarget_types   &     r"   rh   rh   b   s     I$Xi%8%;<<	I&C$t*$.s3-222!M	 '
  $$$	"F VU>%:;;	"CIN(a11%%IKd3KFF%%%   r!   c                0    V ^8  d   QhR\         R\         /# )r&   textr4   r+   )r,   s   "r"   r.   r.      s      C C r!   c                    \         P                  ! RRV 4      p \         P                  ! RRV 4      P                  4       p V # )zClean choice text without shell-specific escaping.

Parameters
----------
text : str
    Raw choice text.

Returns
-------
str
    Cleaned text (not shell-escaped).
[\x00-\x1f\x7f] \s+ )resubstrip)rq   s   &r"   clean_choice_textr{      s7     66$b$/D66&#t$**,DKr!   c                <    V ^8  d   QhR\         R\         R\         /# )r&   namecharsr4   rr   )r,   s   "r"   r.   r.      s!      3 s  r!   c                f    V P                  RR4      pV F  pVP                  VRV 24      pK  	  V# )a  Escape glob/pattern characters for shell case patterns.

Both bash and zsh case patterns treat glob characters as special even inside
quotes. This function escapes them with backslashes for literal matching.

Parameters
----------
name : str
    String to escape.
chars : str
    Characters to escape. Default covers basic glob chars.
    For zsh, also pass "()|" for extended patterns.

Returns
-------
str
    Escaped string safe for shell case patterns.
\z\\)replace)r}   r~   resultchars   &&  r"   escape_for_shell_patternr      s9    ( \\$'F4&k2 Mr!   c                H    V ^8  d   QhR\         R\         R\        R\         /# )r&   rq   r,   
max_lengthr4   )r+   int)r,   s   "r"   r.   r.      s(     ! !s !C !# !s !r!   c                   ^ RI Hp ^ RIHp VP	                  WR7      pV! V4      p \
        P                  ! RRV 4      p \
        P                  ! RRV 4      P                  4       p \        V 4      V8  d   V RV^,
           R	,           p V # )
a  Strip markup and render to plain text for shell completions.

Converts formatted text (markdown/RST/rich) to plain text suitable for
shell completion descriptions. Removes control characters, normalizes
whitespace, and truncates if needed.

Parameters
----------
text : str
    Text with markup.
format : str
    Markup format: "markdown", "rst", "rich", or "plaintext".
max_length : int
    Maximum length before truncation.

Returns
-------
str
    Plain text (not shell-escaped).
)extract_text)
InlineText)r,   rt   ru   rv   rw   Nu   …)	cyclopts._markupr   cyclopts.help.inline_textr   from_formatrx   ry   rz   rj   )rq   r,   r   r   r   inlines   &&&   r"   strip_markupr      s|    * .4##D#8FD66$b$/D66&#t$**,D
4y:$j1n%-Kr!   )z*?[])r>   P   )$r   rG   rx   rJ   enumr   pathlibr   typingr   r   r   r   cyclopts.annotationsr   r	   r
   cyclopts.argumentr   cyclopts.exceptionsr   cyclopts.group_extractorsr   r   cyclopts.utilsr   r   cycloptsr   r   r$   rd   rh   r{   r   r   r   r!   r"   <module>r      s~   
 
 	    ; ; G G 0 - H 8 t     7t&!R$4! !r!   