
    e!hM                       U 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lmZ ddlmZ ddlmZ ddlmZ dd	lmZ dd
lmZ ddlmZ ddlmZ 	 	 	 	 	 	 	 	 	 	 	 	 d)dZ G d d      ZdZdZdZ G d d      Z G d de      Z G d de      Z G d de      Z ej<                  dd      ZeeedZ de!d <   	 d*	 	 	 	 	 d+d!Z"d,d"Z#d-d#Z$d.d$Z%d/d%Z&d0d&Z'	 	 	 	 	 	 	 	 	 	 d1d'Z(	 	 	 	 	 	 	 	 d2d(Z)y)3    )annotationsN)gettext   )Argument)Command)Context)Group)Option)	Parameter)ParameterSource)echoc                    |j                  d      \  }}}t        |      }|y || |||      }|dk(  rt        |j                                y|dk(  rt        |j	                                yy)a   Perform shell completion for the given CLI program.

    :param cli: Command being called.
    :param ctx_args: Extra arguments to pass to
        ``cli.make_context``.
    :param prog_name: Name of the executable in the shell.
    :param complete_var: Name of the environment variable that holds
        the completion instruction.
    :param instruction: Value of ``complete_var`` with the completion
        instruction and shell, in the form ``instruction_shell``.
    :return: Status code to exit with.
    _r   sourcer   complete)	partitionget_completion_classr   r   r   )	clictx_args	prog_namecomplete_varinstructionshellr   comp_clscomps	            ^/var/www/html/diagnosisapp-backend/venv/lib/python3.12/site-packages/click/shell_completion.pyshell_completer      ss    & (11#6E1k#E*HC9l;DhT[[]j T]]_    c                  <    e Zd ZdZdZ	 	 d	 	 	 	 	 	 	 	 	 ddZddZy)	CompletionItema)  Represents a completion value and metadata about the value. The
    default metadata is ``type`` to indicate special shell handling,
    and ``help`` if a shell supports showing a help string next to the
    value.

    Arbitrary parameters can be passed when creating the object, and
    accessed using ``item.attr``. If an attribute wasn't passed,
    accessing it returns ``None``.

    :param value: The completion suggestion.
    :param type: Tells the shell script to provide special completion
        support for the type. Click uses ``"dir"`` and ``"file"``.
    :param help: String shown next to the value if supported.
    :param kwargs: Arbitrary metadata. The built-in implementations
        don't use this, but custom type completions paired with custom
        shell support could use it.
    valuetypehelp_infoNc                <    || _         || _        || _        || _        y Nr!   )selfr"   r#   r$   kwargss        r   __init__zCompletionItem.__init__N   s      "
	 $	
r   c                8    | j                   j                  |      S r'   )r%   get)r(   names     r   __getattr__zCompletionItem.__getattr__Z   s    zz~~d##r   )plainN)
r"   t.Anyr#   strr$   
str | Noner)   r0   returnNone)r-   r1   r3   r0   )__name__
__module____qualname____doc__	__slots__r*   r.    r   r   r    r    9   sP    $ 3I
 	

 
 	

 
 

$r   r    a  %(complete_func)s() {
    local IFS=$'\n'
    local response

    response=$(env COMP_WORDS="${COMP_WORDS[*]}" COMP_CWORD=$COMP_CWORD %(complete_var)s=bash_complete $1)

    for completion in $response; do
        IFS=',' read type value <<< "$completion"

        if [[ $type == 'dir' ]]; then
            COMPREPLY=()
            compopt -o dirnames
        elif [[ $type == 'file' ]]; then
            COMPREPLY=()
            compopt -o default
        elif [[ $type == 'plain' ]]; then
            COMPREPLY+=($value)
        fi
    done

    return 0
}

%(complete_func)s_setup() {
    complete -o nosort -F %(complete_func)s %(prog_name)s
}

%(complete_func)s_setup;
a  #compdef %(prog_name)s

%(complete_func)s() {
    local -a completions
    local -a completions_with_descriptions
    local -a response
    (( ! $+commands[%(prog_name)s] )) && return 1

    response=("${(@f)$(env COMP_WORDS="${words[*]}" COMP_CWORD=$((CURRENT-1)) %(complete_var)s=zsh_complete %(prog_name)s)}")

    for type key descr in ${response}; do
        if [[ "$type" == "plain" ]]; then
            if [[ "$descr" == "_" ]]; then
                completions+=("$key")
            else
                completions_with_descriptions+=("$key":"$descr")
            fi
        elif [[ "$type" == "dir" ]]; then
            _path_files -/
        elif [[ "$type" == "file" ]]; then
            _path_files -f
        fi
    done

    if [ -n "$completions_with_descriptions" ]; then
        _describe -V unsorted completions_with_descriptions -U
    fi

    if [ -n "$completions" ]; then
        compadd -U -V unsorted -a completions
    fi
}

if [[ $zsh_eval_context[-1] == loadautofunc ]]; then
    # autoload from fpath, call function directly
    %(complete_func)s "$@"
else
    # eval/source/. command, register function for later
    compdef %(complete_func)s %(prog_name)s
fi
af  function %(complete_func)s;
    set -l response (env %(complete_var)s=fish_complete COMP_WORDS=(commandline -cp) COMP_CWORD=(commandline -t) %(prog_name)s);

    for completion in $response;
        set -l metadata (string split "," $completion);

        if test $metadata[1] = "dir";
            __fish_complete_directories $metadata[2];
        else if test $metadata[1] = "file";
            __fish_complete_path $metadata[2];
        else if test $metadata[1] = "plain";
            echo $metadata[2];
        end;
    end;
end;

complete --no-files --command %(prog_name)s --arguments "(%(complete_func)s)";
c                      e Zd ZU dZded<   	 ded<   	 	 	 	 	 	 	 	 	 	 	 ddZedd       ZddZddZ	dd	Z
dd
ZddZddZy)ShellCompletea  Base class for providing shell completion support. A subclass for
    a given shell will override attributes and methods to implement the
    completion instructions (``source`` and ``complete``).

    :param cli: Command being called.
    :param prog_name: Name of the executable in the shell.
    :param complete_var: Name of the environment variable that holds
        the completion instruction.

    .. versionadded:: 8.0
    zt.ClassVar[str]r-   source_templatec                <    || _         || _        || _        || _        y r'   )r   r   r   r   )r(   r   r   r   r   s        r   r*   zShellComplete.__init__   s!      "(r   c                    t        j                  dd| j                  j                  dd      t         j                        }d| dS )zQThe name of the shell function defined by the completion
        script.
        z\W* -r   )flags_completion)resubr   replaceASCII)r(   	safe_names     r   	func_namezShellComplete.func_name   s<    
 FF62t~~'='=c3'GrxxX	9+[))r   c                J    | j                   | j                  | j                  dS )zVars for formatting :attr:`source_template`.

        By default this provides ``complete_func``, ``complete_var``,
        and ``prog_name``.
        )complete_funcr   r   )rI   r   r   r(   s    r   source_varszShellComplete.source_vars   s%     "^^ --
 	
r   c                <    | j                   | j                         z  S )zProduce the shell script that defines the completion
        function. By default this ``%``-style formats
        :attr:`source_template` with the dict returned by
        :meth:`source_vars`.
        )r=   rM   rL   s    r   r   zShellComplete.source   s     ##d&6&6&888r   c                    t         )zUse the env vars defined by the shell script to return a
        tuple of ``args, incomplete``. This must be implemented by
        subclasses.
        NotImplementedErrorrL   s    r   get_completion_argsz!ShellComplete.get_completion_args  s
    
 "!r   c                    t        | j                  | j                  | j                  |      }t	        |||      \  }}|j                  ||      S )aT  Determine the context and last complete command or parameter
        from the complete args. Call that object's ``shell_complete``
        method to get the completions for the incomplete value.

        :param args: List of complete args before the incomplete value.
        :param incomplete: Value being completed. May be empty.
        )_resolve_contextr   r   r   _resolve_incompleter   )r(   args
incompletectxobjs        r   get_completionszShellComplete.get_completions	  sE     txxM-c4DZ!!#z22r   c                    t         )zFormat a completion item into the form recognized by the
        shell script. This must be implemented by subclasses.

        :param item: Completion item to format.
        rP   r(   items     r   format_completionzShellComplete.format_completion  s
     "!r   c                    | j                         \  }}| j                  ||      }|D cg c]  }| j                  |       }}dj                  |      S c c}w )zProduce the completion data to send back to the shell.

        By default this calls :meth:`get_completion_args`, gets the
        completions, then calls :meth:`format_completion` for each
        completion.
        
)rR   rZ   r^   join)r(   rV   rW   completionsr]   outs         r   r   zShellComplete.complete  s[      335j**4<8CDt%%d+DDyy~ Es   AN)
r   r   r   cabc.MutableMapping[str, t.Any]r   r1   r   r1   r3   r4   r3   r1   )r3   zdict[str, t.Any]r3   ztuple[list[str], str])rV   	list[str]rW   r1   r3   zlist[CompletionItem]r]   r    r3   r1   )r5   r6   r7   r8   __annotations__r*   propertyrI   rM   r   rR   rZ   r^   r   r:   r   r   r<   r<      s    
 
 %$
)
) 2
) 	
)
 
) 

) * *

9"
3"
r   r<   c                  N     e Zd ZdZdZeZedd       Zd fdZ	d	dZ
d
dZ xZS )BashCompletezShell completion for Bash.bashc                    dd l } dd l}| j                  d      }|d }nO|j                  |dddg|j                        }t        j                  d|j                  j                               }|;|j                         \  }}|dk  s
|dk(  r|dk  rt        t        d	      d
       y y y t        t        d      d
       y )Nr   rm   z--norcz-czecho "${BASH_VERSION}")stdoutz^(\d+)\.(\d+)\.\d+4zCShell completion is not supported for Bash versions older than 4.4.T)errz@Couldn't detect Bash version, shell completion is not supported.)shutil
subprocesswhichrunPIPErD   searchro   decodegroupsr   r   )rr   rs   bash_exematchoutputmajorminors          r   _check_versionzBashComplete._check_version0  s    <<'E^^8T+CD! $ F II3V]]5I5I5KLE <<>LE5s{eslus{4  0;l TUr   c                @    | j                          t        | 	         S r'   )r   superr   )r(   	__class__s    r   r   zBashComplete.sourceQ  s    w~r   c                    t        t        j                  d         }t        t        j                  d         }|d| }	 ||   }||fS # t        $ r d}Y ||fS w xY wN
COMP_WORDS
COMP_CWORDr   r@   split_arg_stringosenvironint
IndexErrorr(   cwordscwordrV   rW   s        r   rR   z BashComplete.get_completion_argsU  o    !"**\":;BJJ|,-a	J Z  	JZ	   A AAc                8    |j                    d|j                   S )N,)r#   r"   r\   s     r   r^   zBashComplete.format_completiona  s    ))Adjj\**r   )r3   r4   re   rf   rh   )r5   r6   r7   r8   r-   _SOURCE_BASHr=   staticmethodr   r   rR   r^   __classcell__)r   s   @r   rl   rl   *  s2    $D"O @ 
 +r   rl   c                  (    e Zd ZdZdZeZddZddZy)ZshCompletezShell completion for Zsh.zshc                    t        t        j                  d         }t        t        j                  d         }|d| }	 ||   }||fS # t        $ r d}Y ||fS w xY wr   r   r   s        r   rR   zZshComplete.get_completion_argsk  r   r   c                r    |j                    d|j                   d|j                  r|j                   S d S )Nr`   r   )r#   r"   r$   r\   s     r   r^   zZshComplete.format_completionw  s7    ))Btzzl"$))TYY,MNN,MNNr   Nrf   rh   )	r5   r6   r7   r8   r-   _SOURCE_ZSHr=   rR   r^   r:   r   r   r   r   e  s    #D!O
 Or   r   c                  (    e Zd ZdZdZeZddZddZy)FishCompletezShell completion for Fish.fishc                    t        t        j                  d         }t        j                  d   }|dd  }|r|r|d   |k(  r|j                          ||fS )Nr   r   r   )r   r   r   pop)r(   r   rW   rV   s       r   rR   z FishComplete.get_completion_args  sT    !"**\":;ZZ-
abz $48z#9HHJZr   c                    |j                   r(|j                   d|j                   d|j                    S |j                   d|j                   S )Nr   	)r$   r#   r"   r\   s     r   r^   zFishComplete.format_completion  sE    99ii[$**R		{;;))Adjj\**r   Nrf   rh   )	r5   r6   r7   r8   r-   _SOURCE_FISHr=   rR   r^   r:   r   r   r   r   {  s    $D"O
 +r   r   ShellCompleteTypeztype[ShellComplete])bound)rm   r   r   zdict[str, type[ShellComplete]]_available_shellsc                4    || j                   }| t        |<   | S )am  Register a :class:`ShellComplete` subclass under the given name.
    The name will be provided by the completion instruction environment
    variable during completion.

    :param cls: The completion class that will handle completion for the
        shell.
    :param name: Name to register the class under. Defaults to the
        class's ``name`` attribute.
    )r-   r   )clsr-   s     r   add_completion_classr     s"     |xx!dJr   c                ,    t         j                  |       S )zLook up a registered :class:`ShellComplete` subclass by the name
    provided by the completion instruction environment variable. If the
    name isn't registered, returns ``None``.

    :param shell: Name the class is registered under.
    )r   r,   )r   s    r   r   r     s       ''r   c                    ddl }|j                  | d      }d|_        d|_        g }	 |D ]  }|j                  |        	 |S # t        $ r |j                  |j
                         Y |S w xY w)a  Split an argument string as with :func:`shlex.split`, but don't
    fail if the string is incomplete. Ignores a missing closing quote or
    incomplete escape sequence and uses the partial token as-is.

    .. code-block:: python

        split_arg_string("example 'my file")
        ["example", "my file"]

        split_arg_string("example my\")
        ["example", "my"]

    :param string: String to split.

    .. versionchanged:: 8.2
        Moved to ``shell_completion`` from ``parser``.
    r   NT)posixr@   )shlexwhitespace_split
commentersappend
ValueErrortoken)stringr   lexrc   r   s        r   r   r     s|    $ 
++fD+
)CCCN
C 	EJJu	 J   	

399Js   A $A,+A,c                   t        |t              sy|j                  J | j                  j	                  |j                        }|j
                  dk(  xsn | j                  |j                        t        j                  uxsA |j
                  dkD  xr0 t        |t        t        f      xr t        |      |j
                  k  S )zDetermine if the given parameter is an argument that can still
    accept values.

    :param ctx: Invocation context for the command represented by the
        parsed complete args.
    :param param: Argument object being checked.
    Fr   r   )
isinstancer   r-   paramsr,   nargsget_parameter_sourcer   COMMANDLINEtuplelistlen)rX   paramr"   s      r   _is_incomplete_argumentr     s     eX&::!!!JJNN5::&Er 	
##EJJ/7R7RR	
 KK!O )55$-0)E
U[[(r   c                .    |sy|d   }|| j                   v S )z5Check if the value looks like the start of an option.Fr   )_opt_prefixes)rX   r"   cs      r   _start_of_optionr     s"    aA!!!!r   c                    t        |t              sy|j                  s|j                  ryd}t	        t        |            D ](  \  }}|dz   |j                  kD  r nt        | |      s'|}* |duxr ||j                  v S )zDetermine if the given parameter is an option that needs a value.

    :param args: List of complete args before the incomplete value.
    :param param: Option object being checked.
    FNr   )	r   r
   is_flagcount	enumeratereversedr   r   opts)rX   rV   r   last_optionindexargs         r   _is_incomplete_optionr     s     eV$}}K/ 
s19u{{"C%K d"@{ejj'@@r   c           	        d|d<    | j                   ||j                         fi |5 }|j                  |j                  z   }|r|j                  }t        |t              r|j                  s]|j                  ||      \  }}}||cddd       S |j                  |||d      5 }|j                  |j                  z   }|}ddd       nv|}|rT|j                  ||      \  }}}||cddd       S |j                  |||ddd      5 }	|j                  }|	}ddd       |rT|}g |j                  |j                  }nn|rddd       |S # 1 sw Y   xY w# 1 sw Y   CxY w# 1 sw Y   S xY w)a`  Produce the context hierarchy starting with the command and
    traversing the complete arguments. This only follows the commands,
    it doesn't trigger input prompts or callbacks.

    :param cli: Command being called.
    :param prog_name: Name of the executable in the shell.
    :param args: List of complete args before the incomplete value.
    Tresilient_parsingN)parentr   F)r   allow_extra_argsallow_interspersed_argsr   )	make_contextcopy_protected_argsrV   commandr   r	   chainresolve_command)
r   r   r   rV   rX   r   r-   cmdsub_ctxsub_sub_ctxs
             r   rT   rT     s    %)H !			)TYY[	=H	= )""SXX-kkG'5)}}&-&=&=c4&HOD#t{") ) ))d3$ *  & "22SXX=%	& & "G*1*A*A#t*Lc4;#&3) )6 !--  #&-149.2 .  	2 )#*<<D&1G	2 " "CDW44Dw||DDM )V J=& &	2 	27)V JsN   AE$E$$E &E$0E$E
E$! E$E	E$E!	E$$E.c                r   |dk(  rd}n6d|v r2t        | |      r&|j                  d      \  }}}|j                  |       d|vrt        | |      r| j                  |fS | j                  j	                  |       }|D ]  }t        | ||      s||fc S  |D ]  }t        | |      s||fc S  | j                  |fS )ah  Find the Click object that will handle the completion of the
    incomplete value. Return the object and the incomplete value.

    :param ctx: Invocation context for the command represented by
        the parsed complete args.
    :param args: List of complete args before the incomplete value.
    :param incomplete: Value being completed. May be empty.
    =r@   z--)r   r   r   r   
get_paramsr   r   )rX   rV   rW   r-   r   r   r   s          r   rU   rU   X  s     S
	
	/Z@(2237aD 4,S*={{J&&[[##C(F  % dE2*$$%  %"3.*$$% ;;
""r   )r   r   r   rd   r   r1   r   r1   r   r1   r3   r   r'   )r   r   r-   r2   r3   r   )r   r1   r3   ztype[ShellComplete] | None)r   r1   r3   rg   )rX   r   r   r   r3   bool)rX   r   r"   r1   r3   r   )rX   r   rV   rg   r   r   r3   r   )
r   r   r   rd   r   r1   rV   rg   r3   r   )rX   r   rV   rg   rW   r1   r3   ztuple[Command | Parameter, str])*
__future__r   collections.abcabccabcr   rD   typingtr   r   corer   r   r   r	   r
   r   r   utilsr   r   r    r   r   r   r<   rl   r   r   TypeVarr   r   ri   r   r   r   r   r   r   rT   rU   r:   r   r   <module>r      s   "  	 	          ! #	#-# # 	#
 # 	#L"$ "$L@*X.e eP8+= 8+vO- O,+= +2 AII19NO  5 1  04	",(("J2"A0:	:-: : 	:
 :z,#	,#!,#/2,#$,#r   