{{ define "repo/pulls/fragments/pullHeader" }}
<section id="pull-{{ .Pull.PullId }}">
    <header class="pb-2">
        <h1 class="text-2xl dark:text-white">
            {{ .Pull.Title | description }}
            <span class="text-gray-500 dark:text-gray-400">#{{ .Pull.PullId }}</span>
        </h1>
    </header>

    <div class="flex items-center gap-2">
        {{ template "repo/pulls/fragments/pullState" .Pull.State }}
        <span class="text-gray-500 dark:text-gray-400 text-sm flex flex-wrap items-center gap-1">
            opened by
            {{ template "user/fragments/picLink" (list .Pull.OwnerDid "size-6" (index .VouchRelationships (did .Pull.OwnerDid))) }}
            <a href="/{{ resolve .Pull.OwnerDid }}">{{ resolve .Pull.OwnerDid }}</a>
            <span class="select-none before:content-['\00B7']"></span>
            {{ template "repo/fragments/time" .Pull.Created }}

            <span class="select-none before:content-['\00B7']"></span>
            <span>
              targeting
              <span class="text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center">
                <a href="/{{ .RepoInfo.FullName }}/tree/{{ .Pull.TargetBranch }}" class="no-underline hover:underline">{{ .Pull.TargetBranch }}</a>
              </span>
            </span>
            {{ if not .Pull.IsPatchBased }}
              from
              <span class="text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 mx-1/2 inline-flex items-center">
                {{ if not .Pull.IsForkBased }}
                {{ $repoPath := .RepoInfo.FullName }}
                  <a href="/{{ $repoPath }}/tree/{{ pathEscape .Pull.PullSource.Branch }}" class="no-underline hover:underline">{{ .Pull.PullSource.Branch }}</a>
                {{ else if .Pull.PullSource.Repo }}
                {{ $repoPath := print (resolve .Pull.PullSource.Repo.Did) "/" .Pull.PullSource.Repo.Slug }}
                  <a href="/{{ $repoPath }}" class="no-underline hover:underline">{{ $repoPath }}</a>:
                  <a href="/{{ $repoPath }}/tree/{{ pathEscape .Pull.PullSource.Branch }}" class="no-underline hover:underline">{{ .Pull.PullSource.Branch }}</a>
                {{ else }}
                  <span class="italic">[deleted fork]</span>:
                  {{ .Pull.PullSource.Branch }}
                {{ end }}
              </span>
            {{ end }}

            {{ if and .LoggedInUser (eq .LoggedInUser.Did .Pull.OwnerDid) }}
              <a
                class="text-gray-500 dark:text-gray-400 flex gap-1 items-center group cursor-pointer"
                hx-get="/{{ .RepoInfo.FullName }}/pulls/{{ .Pull.PullId }}/edit"
                hx-swap="innerHTML"
                hx-target="#pull-{{.Pull.PullId}}">
                {{ i "pencil" "size-3" }}
              </a>
            {{ end }}
        </span>
    </div>

    {{ if .Pull.Body }}
        <article id="body" class="mt-8 prose dark:prose-invert">
            {{ .Pull.Body | markdown }}
        </article>
    {{ end }}

    <div class="mt-2">
      {{ $aturi := .Pull.AtUri }}
      {{ template "repo/fragments/reactions"
        (dict "Reactions"   (index .Reactions $aturi)
              "UserReacted" (index .UserReacted $aturi)
              "ThreadAt"    $aturi) }}
    </div>
</section>


{{ end }}
