<template>
  <span class="flex items-center gap-2 text-xs">
    <span class="flex items-center gap-1 font-mono text-fg-muted">
      <GitBranch :size="13" />{{ branch ?? t('worktrees.detached') }}
    </span>
    <span v-if="git.ahead" class="text-accent" :title="t('git.ahead')">↑{{ git.ahead }}</span>
    <span v-if="git.behind" class="text-warn" :title="t('git.behind')">↓{{ git.behind }}</span>
    <span v-if="git.stagedCount" class="text-accent" :title="t('git.staged')">●{{ git.stagedCount }}</span>
    <span v-if="git.unstagedCount" class="text-warn" :title="t('git.unstaged')">○{{ git.unstagedCount }}</span>
    <span v-if="git.conflictCount" class="text-danger" :title="t('git.conflicts')">⚠{{ git.conflictCount }}</span>
    <span v-if="isClean" class="text-fg-subtle">{{ t('worktrees.clean') }}</span>
  </span>
</template>

<script setup lang="ts">
import { computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { GitBranch } from '@lucide/vue';
import type { WorktreeGitStatus } from '@arboretum/shared';

const props = defineProps<{ git: WorktreeGitStatus; branch: string | null }>();
const { t } = useI18n();

const isClean = computed(
  () => !props.git.dirtyCount && !props.git.ahead && !props.git.behind && !props.git.stagedCount && !props.git.unstagedCount,
);
</script>
