§
    ®eîix>  ã                   ó¢   — d Z ddlmZ ddlmZ ddlmZ ddlZddlZddlZddlm	Z	 dd„Z
dd	„Zdd
„Zdd„Zdd„Zd„ Zdd„Zd„ Zdd„Zd„ Zd„ ZdS )z?Provides tab completion functionality for CLIs built with Fire.é    )Úabsolute_import)Údivision)Úprint_functionN)ÚinspectutilsÚbashc                 ó†   — |dk    rt          | t          |¦  «        |¦  «        S t          | t          |¦  «        |¦  «        S )NÚfish)Ú_FishScriptÚ	_CommandsÚ_BashScript)ÚnameÚ	componentÚdefault_optionsÚshells       úS/home/div/.hermes/hermes-agent/venv/lib/python3.11/site-packages/fire/completion.pyÚScriptr      s?   € Ø
ˆf‚_€_Ý�t�Y yÑ1Ô1°?ÑCÔCÐCÝ	�T�9 YÑ/Ô/°Ñ	AÔ	AÐAó    c                 óø  ‡ ‡‡— |pt          ¦   «         }t          ‰ ||¦  «        \  }}}d}d}d}dŠdŠˆ ˆˆfd„}	g }
t          ¦   «         }|                     ‰ ¦  «         |                     t          |                     ¦   «         ¦  «        ¦  «        }|                     t          |                     ¦   «         ¦  «        ¦  «        }|D ]Š} |	|¦  «                             d                     t          ||                              ||         ¦  «        ¦  «        ¦  «        ¬¦  «        }|
                     |                     ||¬	¦  «        ¦  «         Œ‹d
                     |
¦  «        }|                     |¬¦  «        }|                     ‰ ‰ |d                     |¦  «        ‰  	                    dd¦  «         	                    dd¦  «         	                    dd¦  «        d                     |¦  «        ¬¦  «        S )aX  Returns a Bash script registering a completion function for the commands.

  Args:
    name: The first token in the commands, also the name of the command.
    commands: A list of all possible commands that tab completion can complete
        to. Each command is a list or tuple of the string tokens that make up
        that command.
    default_options: A dict of options that can be used with any command. Use
        this if there are flags that can always be appended to a command.
  Returns:
    A string which is the Bash script. Source the bash script to enable tab
    completion in Bash.
  aâ  # bash completion support for {name}
# DO NOT EDIT.
# This script is autogenerated by fire/completion.py.

_complete-{identifier}()
{{
  local cur prev opts lastcommand
  COMPREPLY=()
  prev="${{COMP_WORDS[COMP_CWORD-1]}}"
  cur="${{COMP_WORDS[COMP_CWORD]}}"
  lastcommand=$(get_lastcommand)

  opts="{default_options}"
  GLOBAL_OPTIONS="{global_options}"

{checks}

  COMPREPLY=( $(compgen -W "${{opts}}" -- ${{cur}}) )
  return 0
}}

get_lastcommand()
{{
  local lastcommand i

  lastcommand=
  for ((i=0; i < ${{#COMP_WORDS[@]}}; ++i)); do
    if [[ ${{COMP_WORDS[i]}} != -* ]] && [[ -n ${{COMP_WORDS[i]}} ]] && [[
      ${{COMP_WORDS[i]}} != $cur ]]; then
      lastcommand=${{COMP_WORDS[i]}}
    fi
  done

  echo $lastcommand
}}

filter_options()
{{
  local opts
  opts=""
  for opt in "$@"
  do
    if ! option_already_entered $opt; then
      opts="$opts $opt"
    fi
  done

  echo $opts
}}

option_already_entered()
{{
  local opt
  for opt in ${{COMP_WORDS[@]:0:$COMP_CWORD}}
  do
    if [ $1 == $opt ]; then
      return 0
    fi
  done
  return 1
}}

is_prev_global()
{{
  local opt
  for opt in $GLOBAL_OPTIONS
  do
    if [ $opt == $prev ]; then
      return 0
    fi
  done
  return 1
}}

complete -F _complete-{identifier} {command}
z;
  case "${{lastcommand}}" in
  {lastcommand_checks}
  esaczQ
    {command})
      {opts_assignment}
      opts=$(filter_options $opts)
    ;;z‚
      if is_prev_global; then
        opts="${{GLOBAL_OPTIONS}}"
      else
        opts="{options} ${{GLOBAL_OPTIONS}}"
      fiz,
      opts="{options} ${{GLOBAL_OPTIONS}}" c                 ó   •— | ‰k    r‰S ‰S ©N© )Úcommandr   Ú%opts_assignment_main_command_templateÚ#opts_assignment_subcommand_templates    €€€r   Ú_GetOptsAssignmentTemplatez/_BashScript.<locals>._GetOptsAssignmentTemplate—   s   ø€ Ø�$‚€Ø2Ð2à0Ð0r   Ú )Úoptions)r   Úopts_assignmentÚ
)Úlastcommand_checksú/Ú ú.Ú,)r   r   Úchecksr   Ú
identifierÚglobal_options)
ÚsetÚ_GetMapsÚaddÚunionÚkeysÚformatÚjoinÚsortedÚappendÚreplace)r   Úcommandsr   r'   Úoptions_mapÚsubcommands_mapÚbash_completion_templateÚcheck_wrapperÚlastcommand_check_templater   ÚlinesÚcommands_setr   r   r    r%   r   r   s   `               @@r   r   r   "   s<  øøø€ ð $Ð,¥s¡u¤u€/Ý19Ø
ˆH�oñ2ô 2Ñ.€.�+˜ðKÐðZ
€-ð
 
Ðð)Ð%ð+/Ð'ð1ð 1ð 1ð 1ð 1ð 1ð 1ð €%Ý‘”€,Ø×Ò�4ÑÔÐØ×#Ò#¥C¨×(<Ò(<Ñ(>Ô(>Ñ$?Ô$?Ñ@Ô@€,Ø×#Ò#¥C¨×(8Ò(8Ñ(:Ô(:Ñ$;Ô$;Ñ<Ô<€,Øð 
ð 
€gØ0Ð0°Ñ9Ô9×@Ò@Ø—’Ý�;˜wÔ'×-Ò-¨o¸gÔ.FÑGÔGÑHÔHñ
ô 
ð Añ ô €Oð
 
‡L‚LØ"×)Ò)ØØ+ð 	*ñ 	-ô 	-ñô ð ð ð
 —y’y Ñ'Ô'Ðà×ÒØ+ð  ñ ô €&ð
 ×%Ò%ØØØØŸ(š( ?Ñ3Ô3Ø—\’\ # rÑ*Ô*×2Ò2°3¸Ñ;Ô;×CÒCÀCÈÑLÔLØŸš .Ñ1Ô1ð &ñ ô ð	r   c                 óh  — |pt          ¦   «         }t          | ||¦  «        \  }}}d}d}d}d}	t          |                     ¦   «         ¦  «                             t          |                     ¦   «         ¦  «        ¦  «        D ]}
||
         D ]}||                     | |
|¬¦  «        z  }Œ||
                              |¦  «        D ];}|
| k    }||                     | |
|r|	nd|                     d¦  «        ¬¦  «        z  }Œ<Œ€|                     d	                     d
„ |D ¦   «         ¦  «        ¬¦  «        S )aX  Returns a Fish script registering a completion function for the commands.

  Args:
    name: The first token in the commands, also the name of the command.
    commands: A list of all possible commands that tab completion can complete
        to. Each command is a list or tuple of the string tokens that make up
        that command.
    default_options: A dict of options that can be used with any command. Use
        this if there are flags that can always be appended to a command.
  Returns:
    A string which is the Fish script. Source the fish script to enable tab
    completion in Fish.
  aL  function __fish_using_command
    set cmd (commandline -opc)
    for i in (seq (count $cmd) 1)
        switch $cmd[$i]
        case "-*"
        case "*"
            if [ $cmd[$i] = $argv[1] ]
                return 0
            else
                return 1
            end
        end
    end
    return 1
end

function __option_entered_check
    set cmd (commandline -opc)
    for i in (seq (count $cmd))
        switch $cmd[$i]
        case "-*"
            if [ $cmd[$i] = $argv[1] ]
                return 1
            end
        end
    end
    return 0
end

function __is_prev_global
    set cmd (commandline -opc)
    set global_options {global_options}
    set prev (count $cmd)

    for opt in $global_options
        if [ "--$opt" = $cmd[$prev] ]
            echo $prev
            return 0
        end
    end
    return 1
end

zJcomplete -c {name} -n '__fish_using_command {command}' -f -a {subcommand}
z}complete -c {name} -n '__fish_using_command {command};{prev_global_check} and __option_entered_check --{option}' -l {option}
z and __is_prev_global;)r   r   Ú
subcommandr"   ú--)r   r   Úprev_global_checkÚoptionr   c              3   ó"   K  — | ]
}d |› d �V — ŒdS )ú"Nr   )Ú.0r>   s     r   ú	<genexpr>z_FishScript.<locals>.<genexpr>  s*   è è € ÐIÐI°˜m &˜m˜m˜mÐIÐIÐIÐIÐIÐIr   )r'   )r(   r)   r,   r+   r-   Úlstripr.   )r   r2   r   r'   r3   r4   Úfish_sourceÚsubcommand_templateÚflag_templater=   r   r;   r>   Úcheck_neededs                 r   r
   r
   ¿   sŠ  € ð $Ð,¥s¡u¤u€/Ý19Ø
ˆH�oñ2ô 2Ñ.€.�+˜ð+€+ðZ;ÐðF€-ð /ÐÝ�_×)Ò)Ñ+Ô+Ñ,Ô,×2Ò2µ3°{×7GÒ7GÑ7IÔ7IÑ3JÔ3JÑKÔKð ð €gØ% gÔ.ð ð ˆ
ØÐ(×/Ò/ØØØð 0ñ ô ñ €k€kð ˜gÔ&×,Ò,¨^Ñ<Ô<ð ð ˆØ ’_€lØ�]×)Ò)ØØØ1=ÐEÐ-Ð-À2Ø—’˜tÑ$Ô$ð	 *ñ ô ñ €k€kðð 
×	Ò	Ø—X’XÐIÐI¸.ÐIÑIÔIÑIÔIð 
ñ 
ô 
ð r   Fc                 ó†  — t          |t          ¦  «        r|                     d¦  «        rdS |rdS |t          u s|t          u s	|t
          u rdS t          |t          t          ¦  «        ¦  «        rdS g }t          j        |¦  «        r||v rdS t          j	        | ¦  «        rt|€t          j        | ¦  «        pi }|                     |¦  «        }|rE|j        dv rdS t          t          dt          d¦  «        ¦  «        }t          |j        |¦  «        rdS t          |t          ¦  «        r|                     d¦  «         S dS )a¶  Returns whether a member should be included in auto-completion or help.

  Determines whether a member of an object with the specified name should be
  included in auto-completion or help text(both usage and detailed help).

  If the member name starts with '__', it will always be excluded. If it
  starts with only one '_', it will be included for all non-string types. If
  verbose is True, the members, including the private members, are included.

  When not in verbose mode, some modules and functions are excluded as well.

  Args:
    component: The component containing the member.
    name: The name of the member.
    member: The member itself.
    class_attrs: (optional) If component is a class, provide this as:
      inspectutils.GetClassAttrsDict(component). If not provided, it will be
      computed.
    verbose: Whether to include private members.
  Returns
    A boolean value indicating whether the member should be included.
  Ú__FTN)ÚmethodÚpropertyÚ_tuplegetterÚ_)Ú
isinstanceÚstrÚ
startswithr   r   r   ÚtypeÚinspectÚismoduleÚisclassr   ÚGetClassAttrsDictÚgetÚkindÚgetattrÚcollectionsÚobject)r   r   ÚmemberÚclass_attrsÚverboseÚmodules_to_hideÚ
class_attrÚtuplegetters           r   ÚMemberVisiblera     sa  € õ. �•cÑÔð ˜tŸš¨tÑ4Ô4ð Øˆ5Øð Øˆ4Ø•ÐÐØ	•8Ð	Ð	Ø	•>Ð	!Ð	!Øˆ5Ý���_Ñ-Ô-Ñ.Ô.ð Øˆ5à€/ÝÔ�fÑÔð  &¨OÐ";Ð";Øˆ5Ý„_�YÑÔð àÐÝ Ô2°9Ñ=Ô=ÐCÀ€kØ—’ Ñ&Ô&€JØð 	ð 
ŒÐ2Ð	2Ð	2Øˆuõ �K¨½¸d¹¼ÑDÔD€kÝ	�JÔ% {Ñ	3Ô	3ð ØˆuÝ�•cÑÔð $Ø�Š˜sÑ#Ô#Ð#Ð#Ø	ˆr   c                 óÐ   ‡ ‡‡— t          ‰ t          ¦  «        r‰                      ¦   «         }nt          j        ‰ ¦  «        }‰€t          j        ‰ ¦  «        Šˆˆ ˆfd„|D ¦   «         S )a  Returns a list of the members of the given component.

  If verbose is True, then members starting with _ (normally ignored) are
  included.

  Args:
    component: The component whose members to list.
    class_attrs: (optional) If component is a class, you may provide this as:
      inspectutils.GetClassAttrsDict(component). If not provided, it will be
      computed. If provided, this determines how class members will be treated
      for visibility. In particular, methods are generally hidden for
      non-instantiated classes, but if you wish them to be shown (e.g. for
      completion scripts) then pass in a different class_attr for them.
    verbose: Whether to include private members.
  Returns:
    A list of tuples (member_name, member) of all members of the component.
  Nc           	      óF   •— g | ]\  }}t          ‰||‰‰¬ ¦  «        ¯||f‘ŒS )©r\   r]   )ra   )rA   Úmember_namer[   r\   r   r]   s      €€€r   ú
<listcomp>z"VisibleMembers.<locals>.<listcomp>o  sR   ø€ ð 
ð 
ð 
Ù 3 ¨VÝ	�y +¨vÀ;Ø&ð
(ñ 
(ô 
(ð
Ø�FÐð
ð 
ð 
r   )rN   ÚdictÚitemsrR   Ú
getmembersr   rU   )r   r\   r]   Úmemberss   ``` r   ÚVisibleMembersrk   U  s‡   øøø€ õ$ �	�4Ñ Ô ð ,Ø�oŠoÑÔ€G€GåÔ  Ñ+Ô+€Gð ÐÝÔ0°Ñ;Ô;€Kð
ð 
ð 
ð 
ð 
ð 
Ø7>ð
ñ 
ô 
ð r   c                 óp   — g }| D ]0}|                      dd¦  «        }|                     d|› �¦  «         Œ1|S )zÖTakes a list of fn args and returns a list of the fn's completion strings.

  Args:
    fn_args: A list of the args accepted by a function.
  Returns:
    A list of possible completion strings for that function.
  rM   Ú-r<   )r1   r0   )Úfn_argsÚcompletionsÚargs      r   Ú_CompletionsFromArgsrq   v  sN   € ð €+Øð #ð #€cØ
�+Š+�c˜3Ñ
Ô
€CØ×Ò�z˜C�z�zÑ"Ô"Ð"Ð"Ø	Ðr   c                 ó˜  — t          j        | ¦  «        st          j        | ¦  «        r0t          j        | ¦  «        }t          |j        |j        z   ¦  «        S t          | t          t          f¦  «        r&d„ t          t          | ¦  «        ¦  «        D ¦   «         S t          j        | ¦  «        rg S d„ t          | |¬¦  «        D ¦   «         S )a´  Gives possible Fire command completions for the component.

  A completion is a string that can be appended to a command to continue that
  command. These are used for TAB-completions in Bash for Fire CLIs.

  Args:
    component: The component whose completions to list.
    verbose: Whether to include all completions, even private members.
  Returns:
    A list of completions for a command that would so far return the component.
  c                 ó,   — g | ]}t          |¦  «        ‘ŒS r   )rO   )rA   Úindexs     r   rf   zCompletions.<locals>.<listcomp>–  s   € Ð:Ð:Ð:˜5�C�‰JŒJÐ:Ð:Ð:r   c                 ó2   — g | ]\  }}t          |¦  «        ‘ŒS r   )Ú_FormatForCommand)rA   re   rM   s      r   rf   zCompletions.<locals>.<listcomp>œ  s4   € ð 
ð 
ð 
á
ˆ+�qõ ˜Ñ$Ô$ð
ð 
ð 
r   ©r]   )rR   Ú	isroutinerT   r   ÚGetFullArgSpecrq   ÚargsÚ
kwonlyargsrN   ÚtupleÚlistÚrangeÚlenÚisgeneratorrk   )r   r]   Úspecs      r   ÚCompletionsr‚   …  sÍ   € õ Ô�yÑ!Ô!ð =¥W¤_°YÑ%?Ô%?ð =ÝÔ& yÑ1Ô1€DÝ ¤	¨D¬OÑ ;Ñ<Ô<Ð<å�	�E¥4˜=Ñ)Ô)ð ;Ø:Ð:¥E­#¨i©.¬.Ñ$9Ô$9Ð:Ñ:Ô:Ð:åÔ˜Ñ#Ô#ð à€Ið
ð 
å*¨9¸gÐFÑFÔFð
ñ 
ô 
ð r   c                 ó¤   — t          | t          ¦  «        st          | ¦  «        } |                      d¦  «        r| S |                      dd¦  «        S )aÈ  Replaces underscores with hyphens, unless the token starts with a token.

  This is because we typically prefer hyphens to underscores at the command
  line, but we reserve hyphens at the start of a token for flags. This becomes
  relevant when --verbose is activated, so that things like __str__ don't get
  transformed into --str--, which would get confused for a flag.

  Args:
    token: The token to transform.
  Returns:
    The transformed token.
  rM   rm   )rN   rO   rP   r1   )Útokens    r   rv   rv   ¢  sP   € õ 
�E�3Ñ	Ô	ð Ý�‰JŒJ€Eà
×Ò�cÑÔð Ø€Là	�Š�s˜CÑ	 Ô	 Ð r   é   c              #   ó\  K  — t          j        | ¦  «        st          j        | ¦  «        rt          | d¬¦  «        D ]}|fV — Œt          j        | ¦  «        rdS |dk     rdS t	          | i d¬¦  «        D ]7\  }}t          |¦  «        }|fV — t          ||dz
  ¦  «        D ]
}|f|z   V — ŒŒ8dS )a	  Yields tuples representing commands.

  To use the command from Python, insert '.' between each element of the tuple.
  To use the command from the command line, insert ' ' between each element of
  the tuple.

  Args:
    component: The component considered to be the root of the yielded commands.
    depth: The maximum depth with which to traverse the member DAG for commands.
  Yields:
    Tuples, each tuple representing one possible command for this CLI.
    Only traverses the member DAG up to a depth of depth.
  Frw   Né   rd   )rR   rx   rT   r‚   rk   rv   r   )r   ÚdepthÚ
completionre   r[   r   s         r   r   r   ¸  s
  è è € õ Ô�yÑ!Ô!ð ¥W¤_°YÑ%?Ô%?ð Ý! )°UÐ;Ñ;Ô;ð ð ˆ
ØˆMÐÐÐÐÝÔ�yÑ!Ô!ð Ø
€Fà
ˆQ‚Y€YØ
€Fõ ,¨IÀ2Ø49ð;ñ ;ô ;ð %ð %Ñ€k�6õ $ KÑ0Ô0€Kàˆ.ÐÐÐå˜V U¨Q¡YÑ/Ô/ð %ð %ˆØˆN˜WÑ$Ð$Ð$Ð$Ð$ð%ð%ð %r   c                 ó,   — |                       d¦  «        S )Nrm   )rP   )rp   s    r   Ú	_IsOptionr‹   Û  s   € Ø	�Š˜Ñ	Ô	Ðr   c                 óf  ‡— t          j         ‰¦  «        }t          j        ˆfd„¦  «        }t          j        t          ¦  «        }|D ]å}t	          |¦  «        dk    rSt          |d         ¦  «        r|                     |d         ¦  «         ŒF||                               |d         ¦  «         Œh|r{|d         }t          |d         ¦  «        }t          |¦  «        r|}	n|}	|	|                              |¦  «         |	|                     dd¦  «                                      |¦  «         Œæ|||fS )aÐ  Returns sets of subcommands and options for each command.

  Args:
    name: The first token in the commands, also the name of the command.
    commands: A list of all possible commands that tab completion can complete
        to. Each command is a list or tuple of the string tokens that make up
        that command.
    default_options: A dict of options that can be used with any command. Use
        this if there are flags that can always be appended to a command.
  Returns:
    global_options: A set of all options of the first token of the command.
    subcommands_map: A dict storing set of subcommands for each
        command/subcommand.
    options_map: A dict storing set of options for each subcommand.
  c                  ó,   •— t          j         ‰ ¦  «        S r   )Úcopy)r   s   €r   ú<lambda>z_GetMaps.<locals>.<lambda>ð  s   ø€ µ´	¸/Ñ0JÔ0J€ r   r‡   r   éþÿÿÿéÿÿÿÿrM   rm   )	rŽ   rY   Údefaultdictr(   r   r‹   r*   rv   r1   )
r   r2   r   r'   r3   r4   r   r;   rp   Úargs_maps
     `       r   r)   r)   ß  s9  ø€ õ  ”9˜_Ñ-Ô-€.ÝÔ'Ð(JÐ(JÐ(JÐ(JÑKÔK€+ÝÔ+­CÑ0Ô0€/àð 6ð 6€gÝ
ˆ7�|„|�qÒÐÝ	�7˜1”:Ñ	Ô	ð .Ø×Ò˜7 1œ:Ñ&Ô&Ð&Ð&à˜Ô×!Ò! '¨!¤*Ñ-Ô-Ð-Ð-à	ð 
6Ø˜2”;€jÝ˜g bœkÑ*Ô*€cå	�3‰Œð #Øˆˆà"ˆàˆzÔ×Ò˜sÑ#Ô#Ð#Øˆz×!Ò! # sÑ+Ô+Ô,×0Ò0°Ñ5Ô5Ð5øà	˜ oÐ	5Ð5r   )Nr   r   )NF)F)r…   )Ú__doc__Ú
__future__r   r   r   rY   rŽ   rR   Úfirer   r   r   r
   ra   rk   rq   r‚   rv   r   r‹   r)   r   r   r   ú<module>r—      sW  ðð FÐ Eà &Ð &Ð &Ð &Ð &Ð &Ø Ð Ð Ð Ð Ð Ø %Ð %Ð %Ð %Ð %Ð %à Ð Ð Ð Ø €€€Ø €€€à Ð Ð Ð Ð Ð ðBð Bð Bð BðZð Zð Zð ZðzZð Zð Zð Zðz6ð 6ð 6ð 6ðrð ð ð ðBð ð ðð ð ð ð:!ð !ð !ð, %ð  %ð  %ð  %ðFð ð ð'6ð '6ð '6ð '6ð '6r   