{{ $featureName := .Get "feature_name" }}
{{ $feature := index site.Data.summary $featureName }}
{{ if not $feature }}
  {{ errorf "[summary-bar] invalid feature: %s %v" $featureName .Position }}
{{ end }}
{{ if $feature }}
  {{ $subscriptionIcons := dict
    "Business" "domain"
    "Team" "groups"
    "Pro" "person_add"
    "Personal" "person"
    "Available to all" "public"
    "Docker Hardened Images Enterprise" "/icons/dhi.svg"
  }}
  {{ $availabilityIcons := dict
    "Experimental" "science"
    "Beta" "bolt"
    "Early Access" "rocket_launch"
    "GA" "check_circle"
    "Retired" "package_2"
  }}
  {{ $requiresIcon := "browser_updated" }}
  {{ $forIcon := "admin_panel_settings" }}


  <div
    class="not-prose summary-bar"
  >
    {{ with $feature.subscription }}
      <div class="flex flex-wrap gap-1">
        <span class="font-bold">Subscription:</span>
        {{ range . }}
          <span>{{ . }}</span>
          <span class="icon-svg">
            {{ $icon := index $subscriptionIcons . }}
            {{ if $icon }}
              {{ partial "icon" $icon }}
            {{ else }}
              {{ partial "icon" "default_icon" }}
            {{ end }}
          </span>
        {{ end }}
      </div>
    {{ end }}

    {{ with $feature.availability }}
      {{ $availabilityText := . }}
      <div class="flex flex-wrap gap-1">
        <span class="font-bold">Availability:</span>
        <span>
          {{ $availabilityText }}
          {{ range $key, $icon := $availabilityIcons }}
            {{ if in $availabilityText $key }}
              <span class="icon-svg">{{ partial "icon" $icon }}</span>
            {{ end }}
          {{ end }}
        </span>
      </div>
    {{ end }}

    {{ with $feature.requires }}
      <div class="flex flex-wrap gap-1">
        <span class="font-bold">Requires:</span>
        <span>{{ . | markdownify }}</span>
        <span class="icon-svg">
          {{ partial "icon" $requiresIcon }}
        </span>
      </div>
    {{ end }}

    {{ with $feature.for }}
      <div class="flex flex-wrap gap-1">
        <span class="font-bold">For:</span>
        <span>{{ . }}</span>
        {{ if eq . "Administrators" }}
          <span class="icon-svg">
            {{ partial "icon" $forIcon }}
          </span>
        {{ end }}
      </div>
    {{ end }}
  </div>
{{ end }}
