{{ define "user/fragments/vouchButton" }}
{{ $isVouched := false }}
{{ $isDenounced := false }}
{{ if .VouchRelationship }}
  {{ if .VouchRelationship.IsDirectVouch }}
    {{ $isVouched = true }}
  {{ else if .VouchRelationship.IsDirectDenounce }}
    {{ $isDenounced = true }}
  {{ end }}
{{ end }}

{{ $userDid := "" }}
{{ with .VouchRelationship }}
  {{ $userDid = .SubjectDid.String }}
{{ end }}
{{ $popoverId := index . "PopoverId" }}
{{ if not $popoverId }}{{ $popoverId = printf "vouch-modal-%s" (normalizeForHtmlId $userDid) }}{{ end }}
<button
  id="vouch-btn-{{ normalizeForHtmlId $userDid }}"
  type="button"
  popovertarget="{{ $popoverId }}"
  popovertargetaction="toggle"
  class="{{ if $isVouched }}btn-create{{else if $isDenounced}}btn-cancel{{else}}btn{{end}} w-full flex gap-2 items-center justify-center">
  {{ if $isVouched }}
    {{ i "shield-check" "size-4" }} Vouched
  {{ else if $isDenounced }}
    {{ i "shield-off" "size-4" }} Denounced
  {{ else }}
    {{ i "shield-question-mark" "size-4" }} Vouch
  {{ end }}
</button>
{{ end }}
