#compdef -value- -array-value- -value-,-default-,-default-

# You can customize completion for different parameters by writing
# functions with the tag-line `#compdef -T value <name>'.
# The function searches for the strings `<param-name>:<param-type>'
# and `<param-name>'. If the line contains a command (as in `make foo=<TAB>')
# the string `<command>:<param-name>:<param-type>' is also searched for.

if [[ "$service" != -value-,* ]]; then
  local strs ctx=

  strs=( -default- )

  if [[ "$compstate[context]" != *value && -n "$_comp_command1" ]]; then
    ctx="${_comp_command}"
    strs=( "${_comp_command1}" "$strs[@]" )
    [[ -n "$_comp_command2" ]] &&
        strs=( "${_comp_command2}" "$strs[@]" )
  fi

  _dispatch -value-,${compstate[parameter]},$ctx \
            -value-,{${compstate[parameter]},-default-},${^strs}
else
  if [[ "$compstate[parameter]" != *-* &&
        "$compstate[context]" = *value &&
        "${(Pt)${compstate[parameter]}}" = assoc* ]]; then
    if (( CURRENT & 1 )); then
      _wanted association-keys expl 'association key' \
          compadd -k "$compstate[parameter]"
    else
      compstate[parameter]="${compstate[parameter]}-${words[CURRENT-1]}"

      _dispatch -value-,${compstate[parameter]}, \
                -value-,{${compstate[parameter]},-default-},-default-
    fi
  else
    local pats

    if { zstyle -a ":completion:${curcontext}:" assign-list pats &&
         [[ "$compstate[parameter]" = (${(j:|:)~pats}) ]] } ||
       [[ "$PREFIX$SUFFIX" = *:* ]]; then
      compset -P '*:'
      compset -S ':*'
      _default -r '\-\n\t /:' "$@"
    else
      _default "$@"
    fi
  fi
fi
