{{- /*
    Unified Piece Entry Component
    Displays piece entries with category-specific descriptions across all views

    Usage: {{ template "_unified_piece_entry" (dict
        "Piece" $piece
        "CurrentActorID" $currentActorID
        "DisplayMode" "issue|akteure|place|search"
        "ShowPlaceTags" true|false
        "UseColonFormat" true|false
        "ShowContinuation" true|false
        "LongForm" true|false
    ) }}

    Parameters:
    - Piece: The piece object to display
    - CurrentActorID: ID of current actor (for akteure view context)
    - DisplayMode: Context for formatting ("issue", "akteure", "place", "search")
    - ShowPlaceTags: Whether to show place tags (default: true)
    - UseColonFormat: Use colon format instead of "mit" for place view (default: false)
    - ShowContinuation: Show continuation prefixes (default: true for issue mode)
    - LongForm: Whether to show annotations in a new line after the piece (default: false)
*/ -}}

{{- $pieceInput := .Piece -}}
{{- $currentActorID := .CurrentActorID -}}
{{- $displayMode := .DisplayMode -}}
{{- if not $displayMode -}}{{ $displayMode = "issue" }}{{- end -}}
{{- $showPlaceTags := .ShowPlaceTags -}}
{{- if eq $showPlaceTags nil -}}{{ $showPlaceTags = true }}{{- end -}}
{{- $useColonFormat := .UseColonFormat -}}
{{- if eq $useColonFormat nil -}}{{ $useColonFormat = false }}{{- end -}}
{{- $showContinuation := .ShowContinuation -}}
{{- if eq $showContinuation nil -}}{{ $showContinuation = (eq $displayMode "issue") }}{{- end -}}
{{- $longForm := .LongForm -}}
{{- if eq $longForm nil -}}{{ $longForm = false }}{{- end -}}

{{- /* Handle different piece types: viewmodels.PieceByIssue vs xmlmodels.Piece */ -}}
{{- $piece := $pieceInput -}}
{{- $isContinuation := false -}}
{{- if eq $displayMode "issue" -}}
	{{- /* Issue view uses viewmodels.PieceByIssue with .Piece field */ -}}
	{{- $piece = $pieceInput.Piece -}}
	{{- $isContinuation = $pieceInput.IsContinuation -}}
{{- end -}}

{{- $fortsPrefix := "" -}}
{{- if and $showContinuation $isContinuation -}}
	{{- $fortsPrefix = "<span class=\"italic text-gray-600\">(Forts.) </span>" -}}
{{- end -}}

<div class="entry-description leading-snug mb-1">
	{{- $categoryFlags := GetCategoryFlags $piece -}}

	{{- $place := "" -}}
	{{- $placeID := "" -}}
	{{- if $piece.PlaceRefs -}}
		{{- $placeObj := GetPlace (index $piece.PlaceRefs 0).Ref -}}
		{{- if gt (len $placeObj.Names) 0 -}}
			{{- $place = index $placeObj.Names 0 -}}
			{{- $placeID = $placeObj.ID -}}
		{{- end -}}
	{{- end -}}

	{{- $title := "" -}}
	{{- if $piece.Title -}}
		{{- $title = index $piece.Title 0 -}}
	{{- else if $piece.Incipit -}}
		{{- $title = index $piece.Incipit 0 -}}
	{{- end -}}

	{{- $workTitle := "" -}}
	{{- $workTitleFull := "" -}}
	{{- $workAuthorName := "" -}}
	{{- $workAuthorID := "" -}}
	{{- /* Initialize work contributor collections */ -}}
	{{- $workAuthors := slice -}}
	{{- $workTranslators := slice -}}
	{{- $workEditors := slice -}}
	{{- if $piece.WorkRefs -}}
		{{- $work := GetWork (index $piece.WorkRefs 0).Ref -}}
		{{- /* Determine short title (PreferredTitle) and full title (Citation.Title) */ -}}
		{{- if $work.PreferredTitle -}}
			{{- $workTitle = $work.PreferredTitle -}}
		{{- else if $work.Citation.Title -}}
			{{- $workTitle = $work.Citation.Title -}}
		{{- else if $work.Citation.Chardata -}}
			{{- $workTitle = $work.Citation.Chardata -}}
		{{- end -}}
		{{- /* Always get full title for highlighted state */ -}}
		{{- if $work.Citation.Title -}}
			{{- $workTitleFull = $work.Citation.Title -}}
		{{- else if $work.Citation.Chardata -}}
			{{- $workTitleFull = $work.Citation.Chardata -}}
		{{- else if $work.PreferredTitle -}}
			{{- $workTitleFull = $work.PreferredTitle -}}
		{{- end -}}
		{{- /* Get work contributors: authors, translators, editors */ -}}
		{{- if $work.AgentRefs -}}
			{{- range $workAgentRef := $work.AgentRefs -}}
				{{- if (or (eq $workAgentRef.Category "") (eq $workAgentRef.Category "autor")) -}}
					{{- $workAgent := GetAgent $workAgentRef.Ref -}}
					{{- if and $workAgent (gt (len $workAgent.Names) 0) -}}
						{{- $workAuthors = append $workAuthors (dict "ID" $workAgentRef.Ref "Name" (index $workAgent.Names 0)) -}}
					{{- end -}}
				{{- else if eq $workAgentRef.Category "übersetzer" -}}
					{{- $workAgent := GetAgent $workAgentRef.Ref -}}
					{{- if and $workAgent (gt (len $workAgent.Names) 0) -}}
						{{- $workTranslators = append $workTranslators (dict "ID" $workAgentRef.Ref "Name" (index $workAgent.Names 0)) -}}
					{{- end -}}
				{{- else if eq $workAgentRef.Category "herausgeber" -}}
					{{- $workAgent := GetAgent $workAgentRef.Ref -}}
					{{- if and $workAgent (gt (len $workAgent.Names) 0) -}}
						{{- $workEditors = append $workEditors (dict "ID" $workAgentRef.Ref "Name" (index $workAgent.Names 0)) -}}
					{{- end -}}
				{{- end -}}
			{{- end -}}
		{{- end -}}
		{{- /* Legacy single author variables for compatibility */ -}}
		{{- if gt (len $workAuthors) 0 -}}
			{{- $workAuthorName = (index $workAuthors 0).Name -}}
			{{- $workAuthorID = (index $workAuthors 0).ID -}}
		{{- end -}}
	{{- end -}}

	{{- /* Place tags helper - handle multiple places */ -}}
	{{- $placeTag := "" -}}
	{{- if and $showPlaceTags $piece.PlaceRefs -}}
		{{- range $placeRef := $piece.PlaceRefs -}}
			{{- $placeObj := GetPlace $placeRef.Ref -}}
			{{- if gt (len $placeObj.Names) 0 -}}
				{{- $placeName := index $placeObj.Names 0 -}}
				{{- $placeTag = printf "%s <a href=\"/ort/%s\" class=\"ml-0\"><span class=\"place-tag inline-block bg-slate-200 text-slate-700 text-xs px-2 py-0.5 rounded-md whitespace-nowrap hover:bg-slate-300 hover:text-slate-800 transition-colors duration-150 !indent-0\">%s</span></a>" $placeTag $placeObj.ID $placeName -}}
			{{- end -}}
		{{- end -}}
	{{- end -}}

	{{- /* Author prefix for colon format (place view) */ -}}
	{{- $colonPrefix := "" -}}
	{{- if $useColonFormat -}}
		{{- $colonPrefix = ", " -}}
	{{- else -}}
		{{- $colonPrefix = " mit " -}}
	{{- end -}}

	{{- /* Collect authors, translators, and editors */ -}}
	{{- $authors := slice -}}
	{{- $translators := slice -}}
	{{- $editors := slice -}}
	{{- range $agentref := $piece.AgentRefs -}}
		{{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}}
			{{- $agent := GetAgent $agentref.Ref -}}
			{{- if and $agent (gt (len $agent.Names) 0) -}}
				{{- $authors = append $authors (dict "ID" $agentref.Ref "Name" (index $agent.Names 0)) -}}
			{{- end -}}
		{{- else if eq $agentref.Category "übersetzer" -}}
			{{- $agent := GetAgent $agentref.Ref -}}
			{{- if and $agent (gt (len $agent.Names) 0) -}}
				{{- $translators = append $translators (dict "ID" $agentref.Ref "Name" (index $agent.Names 0)) -}}
			{{- end -}}
		{{- else if eq $agentref.Category "herausgeber" -}}
			{{- $agent := GetAgent $agentref.Ref -}}
			{{- if and $agent (gt (len $agent.Names) 0) -}}
				{{- $editors = append $editors (dict "ID" $agentref.Ref "Name" (index $agent.Names 0)) -}}
			{{- end -}}
		{{- end -}}
	{{- end -}}


	{{- /* Generate category-specific descriptions */ -}}

	{{- if $categoryFlags.Rezension -}}
		{{- /* Always show: Author(s), Rezension von: Work */ -}}
		{{- Safe $fortsPrefix -}}
		{{- $authorElements := slice -}}
		{{- range $author := $authors -}}
			{{- if or (not $currentActorID) (ne $author.ID $currentActorID) -}}
				{{- $authorElements = append $authorElements (printf "<a href=\"/akteure/%s\" class=\"author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600\">%s</a>" $author.ID $author.Name) -}}
			{{- end -}}
		{{- end -}}
		{{- range $translator := $translators -}}
			{{- if or (not $currentActorID) (ne $translator.ID $currentActorID) -}}
				{{- $authorElements = append $authorElements (printf "<a href=\"/akteure/%s\" class=\"author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600\">%s</a> (Übers.)" $translator.ID $translator.Name) -}}
			{{- end -}}
		{{- end -}}
		{{- range $editor := $editors -}}
			{{- if or (not $currentActorID) (ne $editor.ID $currentActorID) -}}
				{{- $authorElements = append $authorElements (printf "<a href=\"/akteure/%s\" class=\"author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600\">%s</a> (Hrsg.)" $editor.ID $editor.Name) -}}
			{{- end -}}
		{{- end -}}
		{{- range $index, $element := $authorElements -}}
			{{- if gt $index 0 }}, {{ end }}{{ Safe $element }}
		{{- end -}}
		{{- if gt (len $authorElements) 0 -}}, {{- end }} Rezension von: <span class="review-format">{{- /* inline with space after colon */ -}}
			{{ if or (gt (len $workAuthors) 0) (gt (len $workTranslators) 0) (gt (len $workEditors) 0) }}
				{{- /* Display work authors */ -}}
				{{- range $index, $author := $workAuthors -}}
					{{- if gt $index 0 }}, {{ end }}
					<a href="/akteure/{{ $author.ID }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ $author.Name }}</a>
				{{- end -}}
				{{- /* Display work translators */ -}}
				{{- if gt (len $workTranslators) 0 -}}
					{{- if gt (len $workAuthors) 0 }}, {{ end }}
					{{- range $index, $translator := $workTranslators -}}
						{{- if gt $index 0 }}, {{ end }}
						<a href="/akteure/{{ $translator.ID }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ $translator.Name }}</a> (Übers.)
					{{- end -}}
				{{- end -}}
				{{- /* Display work editors */ -}}
				{{- if gt (len $workEditors) 0 -}}
					{{- if or (gt (len $workAuthors) 0) (gt (len $workTranslators) 0) }}, {{ end }}
					{{- range $index, $editor := $workEditors -}}
						{{- if gt $index 0 }}, {{ end }}
						<a href="/akteure/{{ $editor.ID }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ $editor.Name }}</a> (Hrsg.)
					{{- end -}}
				{{- end -}},
			{{ end }}
			{{ if $workTitle }}
				<em
					class="work-title"
					data-short-title="{{ $workTitle }}"
					{{ if $workTitleFull }}data-full-title="{{ $workTitleFull }}"{{ end }}
					>{{ $workTitle }}</em
				>
			{{ else if $title }}
				<em>{{ $title }}</em>
			{{ else }}
				[Werk unbekannt]
			{{ end }}</span
		>{{ Safe $placeTag }}

	{{- else if $categoryFlags.Weltnachrichten -}}
		{{- Safe $fortsPrefix -}}Politische Nachrichten aus aller Welt{{ Safe $placeTag }}

	{{- else if $categoryFlags.EinkommendeFremde -}}
		{{- if $categoryFlags.Lokalnachrichten -}}
			{{- Safe $fortsPrefix -}}Lokale Meldungen über einreisende Fremde
		{{- else if $categoryFlags.Nachruf -}}
			{{- Safe $fortsPrefix -}}Nachruf und Einreiseliste
		{{- else -}}
			{{- Safe $fortsPrefix -}}Einreiseliste
		{{- end -}}{{ Safe $placeTag }}

	{{- else if $categoryFlags.Wechselkurse -}}
		{{- Safe $fortsPrefix -}}Wechselkurse{{ Safe $placeTag }}

	{{- else if $categoryFlags.Buecher -}}
		{{- Safe $fortsPrefix -}}Bücheranzeigen{{ if $title }}: <em>{{ $title }}</em>{{ end }}{{ Safe $placeTag }}

	{{- else if $categoryFlags.Lokalanzeigen -}}
		{{- Safe $fortsPrefix -}}{{- if $categoryFlags.Nachruf -}}Todesanzeige{{- else -}}Lokalanzeige{{- end -}}{{ if $title }}: <em>{{ $title }}</em>{{ end }}{{ Safe $placeTag }}

	{{- else if $categoryFlags.Lokalnachrichten -}}
		{{- Safe $fortsPrefix -}}{{- if $categoryFlags.Lotterie -}}Lotterienachrichten{{- else if $categoryFlags.Nachruf -}}Nachrufe{{- else if $categoryFlags.Theaterkritik -}}Theaternachrichten{{- else if $categoryFlags.Panegyrik -}}Festlichkeiten{{- else -}}Lokalnachrichten{{- end -}}{{ Safe $placeTag }}

	{{- else if $categoryFlags.Gedicht -}}
		{{- $authorFound := false -}}
		{{- range $agentref := $piece.AgentRefs -}}
			{{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}}
				{{- $agent := GetAgent $agentref.Ref -}}
				{{- if and $agent (gt (len $agent.Names) 0) -}}
					{{- if and $useColonFormat (ne $agentref.Ref $currentActorID) -}}
						{{- Safe $fortsPrefix -}}<a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>{{ $colonPrefix }}
					{{- else if not $useColonFormat -}}
						{{- Safe $fortsPrefix -}}<a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>,
					{{- else -}}
						{{- Safe $fortsPrefix -}}
					{{- end -}}
					{{ if $categoryFlags.Kommentar }}
						Gedicht mit Kommentar
					{{ else if $categoryFlags.Uebersetzung }}
						Gedichtübersetzung
					{{ else if $categoryFlags.GelehrteNachrichten }}
						Gedicht zu gelehrten Angelegenheiten
					{{ else }}
						Gedicht
					{{ end }}{{ if $title }}: <em>„{{ $title }}"</em>{{ end }}{{ Safe $placeTag }}
					{{- $authorFound = true -}}
					{{- break -}}
				{{- end -}}
			{{- end -}}
		{{- end -}}
		{{- if not $authorFound -}}
			{{- Safe $fortsPrefix -}}{{ if $categoryFlags.Kommentar }}
				Gedicht mit Kommentar
			{{ else if $categoryFlags.Uebersetzung }}
				Gedichtübersetzung
			{{ else if $categoryFlags.GelehrteNachrichten }}
				Gedicht zu gelehrten Angelegenheiten
			{{ else }}
				Gedicht
			{{ end }}{{ if $title }}: <em>„{{ $title }}"</em>{{ end }}{{ Safe $placeTag }}
		{{- end -}}

	{{- else if $categoryFlags.Vorladung -}}
		{{- Safe $fortsPrefix -}}Gerichtliche Vorladung{{ if $title }}: <em>{{ $title }}</em>{{ end }}{{ Safe $placeTag }}

	{{- else if $categoryFlags.Aufsatz -}}
		{{- $authorFound := false -}}
		{{- range $agentref := $piece.AgentRefs -}}
			{{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}}
				{{- $agent := GetAgent $agentref.Ref -}}
				{{- if and $agent (gt (len $agent.Names) 0) -}}
					{{- if and $useColonFormat (ne $agentref.Ref $currentActorID) -}}
						{{- Safe $fortsPrefix -}}<a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>{{ $colonPrefix }}
					{{- else if not $useColonFormat -}}
						{{- Safe $fortsPrefix -}}<a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>,
					{{- else -}}
						{{- Safe $fortsPrefix -}}
					{{- end -}}
					{{ if $categoryFlags.Replik }}
						Erwiderung
					{{ else if $categoryFlags.Uebersetzung }}
						Übersetzung
					{{ else if $categoryFlags.Nachruf }}
						Nachruf
					{{ else if $categoryFlags.Kommentar }}
						Kommentar
					{{ else if $categoryFlags.Rezepte }}
						Rezepte und Anleitungen
					{{ else }}
						Aufsatz
					{{ end }}{{ if $title }}: <em>„{{ $title }}"</em>{{ end }}{{ Safe $placeTag }}
					{{- $authorFound = true -}}
					{{- break -}}
				{{- end -}}
			{{- end -}}
		{{- end -}}
		{{- if not $authorFound -}}
			{{- Safe $fortsPrefix -}}{{ if $categoryFlags.Replik }}
				Erwiderung
			{{ else if $categoryFlags.Uebersetzung }}
				Übersetzung
			{{ else if $categoryFlags.Nachruf }}
				Nachruf
			{{ else if $categoryFlags.Kommentar }}
				Kommentar
			{{ else if $categoryFlags.Rezepte }}
				Rezepte und Anleitungen
			{{ else }}
				Aufsatz
			{{ end }}{{ if $title }}: <em>„{{ $title }}"</em>{{ end }}{{ Safe $placeTag }}
		{{- end -}}

	{{- else if $categoryFlags.GelehrteNachrichten -}}
		{{- Safe $fortsPrefix -}}{{- if $categoryFlags.Theaterkritik -}}Theaterkritik{{- else if $categoryFlags.Kommentar -}}Gelehrter Kommentar{{- else -}}Gelehrte Nachrichten{{- end -}}{{ Safe $placeTag }}

	{{- else if $categoryFlags.Theaterkritik -}}
		{{- $authorFound := false -}}
		{{- range $agentref := $piece.AgentRefs -}}
			{{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}}
				{{- $agent := GetAgent $agentref.Ref -}}
				{{- if and $agent (gt (len $agent.Names) 0) -}}
					{{- if and $useColonFormat (ne $agentref.Ref $currentActorID) -}}
						{{- Safe $fortsPrefix -}}<a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>{{ $colonPrefix }}
					{{- else if not $useColonFormat -}}
						{{- Safe $fortsPrefix -}}<a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>,
					{{- else -}}
						{{- Safe $fortsPrefix -}}
					{{- end -}}
					Theaterkritik{{ if $workTitle }}
						zu <em>{{ $workTitle }}</em>{{ if $workAuthorName }}
							von
							<a href="/akteure/{{ $workAuthorID }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ $workAuthorName }}</a>
						{{ end }}
					{{ else if $title }}
						zu <em>{{ $title }}</em>
					{{ end }}{{ Safe $placeTag }}
					{{- $authorFound = true -}}
					{{- break -}}
				{{- end -}}
			{{- end -}}
		{{- end -}}
		{{- if not $authorFound -}}
			{{- Safe $fortsPrefix -}}Theaterkritik{{ if $workTitle }}
				zu <em>{{ $workTitle }}</em>{{ if $workAuthorName }}
					von <a href="/akteure/{{ $workAuthorID }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ $workAuthorName }}</a>
				{{ end }}
			{{ else if $title }}
				zu <em>{{ $title }}</em>
			{{ end }}{{ Safe $placeTag }}
		{{- end -}}

	{{- else if $categoryFlags.Proklamation -}}
		{{- Safe $fortsPrefix -}}Amtliche Proklamation{{ if $title }}: <em>{{ $title }}</em>{{ end }}{{ Safe $placeTag }}

	{{- else if $categoryFlags.Ineigenersache -}}
		{{- Safe $fortsPrefix -}}{{- if $categoryFlags.Kommentar -}}{{- if $categoryFlags.Nachtrag -}}Ergänzender Kommentar{{- else -}}Redaktioneller Kommentar{{- end -}}{{- else if $categoryFlags.Replik -}}Redaktionelle Stellungnahme{{- else -}}Anmerkung der Redaktion{{- end -}}{{ if $title }}: <em>{{ $title }}</em>{{ end }}{{ Safe $placeTag }}

	{{- else if $categoryFlags.Brief -}}
		{{- Safe $fortsPrefix -}}{{- if $categoryFlags.Nachruf -}}Kondolenzbrief{{- else -}}Leserbrief{{- end -}}
		{{- $authorFound := false -}}{{- range $agentref := $piece.AgentRefs -}}
			{{- if (or (eq $agentref.Category "") (eq $agentref.Category "autor")) -}}
				{{- $agent := GetAgent $agentref.Ref -}}{{- if and $agent (gt (len $agent.Names) 0) -}}
					von
					<a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a
					>{{- $authorFound = true -}}{{- break -}}
				{{- end -}}
			{{- end -}}
		{{- end -}}{{ Safe $placeTag }}

	{{- else -}}
		{{- /* Check for Nachruf category in AgentRefs first */ -}}
		{{- $obituaryPersonFound := false -}}
		{{- range $agentref := $piece.AgentRefs -}}
			{{- if eq $agentref.Category "nachruf" -}}
				{{- $agent := GetAgent $agentref.Ref -}}
				{{- if and $agent (gt (len $agent.Names) 0) -}}
					{{- if not $obituaryPersonFound -}}
						{{- Safe $fortsPrefix -}}Nachruf auf <a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>
					{{- else -}}
						, <a href="/akteure/{{ $agentref.Ref }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ index $agent.Names 0 }}</a>
					{{- end -}}
					{{- $obituaryPersonFound = true -}}
				{{- end -}}
			{{- end -}}
		{{- end -}}
		{{- if $obituaryPersonFound -}}
			{{ Safe $placeTag }}
		{{- else -}}
			{{- /* Default handling for pieces without special categories */ -}}
			{{- if or (gt (len $authors) 0) (gt (len $translators) 0) (gt (len $editors) 0) -}}
				{{- $hasCurrentActorAuthor := false -}}
				{{- range $author := $authors -}}
					{{- if eq $author.ID $currentActorID -}}
						{{- $hasCurrentActorAuthor = true -}}
					{{- end -}}
				{{- end -}}
				{{- $hasCurrentActorTranslator := false -}}
				{{- range $translator := $translators -}}
					{{- if eq $translator.ID $currentActorID -}}
						{{- $hasCurrentActorTranslator = true -}}
					{{- end -}}
				{{- end -}}
				{{- $hasCurrentActorEditor := false -}}
				{{- range $editor := $editors -}}
					{{- if eq $editor.ID $currentActorID -}}
						{{- $hasCurrentActorEditor = true -}}
					{{- end -}}
				{{- end -}}
				{{- /* Show other authors/translators/editors in prefix */ -}}
				{{- if and $useColonFormat (or (not $hasCurrentActorAuthor) (not $hasCurrentActorTranslator) (not $hasCurrentActorEditor)) -}}
					{{- Safe $fortsPrefix -}}
					{{- $authorElements := slice -}}
					{{- range $author := $authors -}}
						{{- if ne $author.ID $currentActorID -}}
							{{- $authorElements = append $authorElements (printf "<a href=\"/akteure/%s\" class=\"author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600\">%s</a>" $author.ID $author.Name) -}}
						{{- end -}}
					{{- end -}}
					{{- range $translator := $translators -}}
						{{- if ne $translator.ID $currentActorID -}}
							{{- $authorElements = append $authorElements (printf "<a href=\"/akteure/%s\" class=\"author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600\">%s</a> (Übers.)" $translator.ID $translator.Name) -}}
						{{- end -}}
					{{- end -}}
					{{- range $editor := $editors -}}
						{{- if ne $editor.ID $currentActorID -}}
							{{- $authorElements = append $authorElements (printf "<a href=\"/akteure/%s\" class=\"author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600\">%s</a> (Hrsg.)" $editor.ID $editor.Name) -}}
						{{- end -}}
					{{- end -}}
					{{- range $index, $element := $authorElements -}}
						{{- if gt $index 0 }}, {{ end }}{{ Safe $element }}
					{{- end -}}
					{{- if gt (len $authorElements) 0 -}}{{ $colonPrefix }}{{- end -}}
				{{- else if not $useColonFormat -}}
					{{- Safe $fortsPrefix -}}
					{{- $authorElements := slice -}}
					{{- range $author := $authors -}}
						{{- if ne $author.ID $currentActorID -}}
							{{- $authorElements = append $authorElements (printf "<a href=\"/akteure/%s\" class=\"author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600\">%s</a>" $author.ID $author.Name) -}}
						{{- end -}}
					{{- end -}}
					{{- range $translator := $translators -}}
						{{- if ne $translator.ID $currentActorID -}}
							{{- $authorElements = append $authorElements (printf "<a href=\"/akteure/%s\" class=\"author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600\">%s</a> (Übers.)" $translator.ID $translator.Name) -}}
						{{- end -}}
					{{- end -}}
					{{- range $editor := $editors -}}
						{{- if ne $editor.ID $currentActorID -}}
							{{- $authorElements = append $authorElements (printf "<a href=\"/akteure/%s\" class=\"author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600\">%s</a> (Hrsg.)" $editor.ID $editor.Name) -}}
						{{- end -}}
					{{- end -}}
					{{- range $index, $element := $authorElements -}}
						{{- if gt $index 0 }}, {{ end }}{{ Safe $element }}
					{{- end -}}
					{{- if gt (len $authorElements) 0 -}}
						{{- if $title }}: <em>{{ $title }}</em>{{ end }}{{ if $workTitle }}
						{{- if or (gt (len $authorElements) 0) (and $title (not $categoryFlags.Uebersetzung)) }}, {{ end }}{{ if $categoryFlags.Uebersetzung }}Übersetzung aus:{{ else }}Auszug aus:{{ end }} {{ if $workAuthorName }}
							<a href="/akteure/{{ $workAuthorID }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ $workAuthorName }}</a>, {{ end }}<em
							class="work-title"
							data-short-title="{{ $workTitle }}"
							{{ if $workTitleFull }}data-full-title="{{ $workTitleFull }}"{{ end }}
							>{{ $workTitle }}</em>
						{{ end }}
					{{- else -}}
						{{- if $title }}<em>{{ $title }}</em>{{ end }}{{ if $workTitle }}
						{{- if and $title (not $categoryFlags.Uebersetzung) }}, {{ end }}{{ if $categoryFlags.Uebersetzung }}Übersetzung aus:{{ else }}Auszug aus:{{ end }} {{ if $workAuthorName }}
							<a href="/akteure/{{ $workAuthorID }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ $workAuthorName }}</a>, {{ end }}<em
							class="work-title"
							data-short-title="{{ $workTitle }}"
							{{ if $workTitleFull }}data-full-title="{{ $workTitleFull }}"{{ end }}
							>{{ $workTitle }}</em>
						{{ end }}
					{{- end -}}{{ Safe $placeTag }}
				{{- else -}}
					{{- Safe $fortsPrefix -}}{{ if $title }}<em>{{ $title }}</em>{{ end }}{{ if $workTitle }}
					{{ if and $title (not $categoryFlags.Uebersetzung) }}, {{ end }}{{ if $categoryFlags.Uebersetzung }}Übersetzung aus:{{ else }}Auszug aus:{{ end }} {{ if $workAuthorName }}
						<a href="/akteure/{{ $workAuthorID }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ $workAuthorName }}</a>, {{ end }}<em
						class="work-title"
						data-short-title="{{ $workTitle }}"
						{{ if $workTitleFull }}data-full-title="{{ $workTitleFull }}"{{ end }}
						>{{ $workTitle }}</em>
					{{ end }}{{ Safe $placeTag }}
				{{- end -}}
			{{- else -}}
				{{- Safe $fortsPrefix -}}{{ if $title }}<em>{{ $title }}</em>{{ end }}{{ if $workTitle }}
					{{ if and $title (not $categoryFlags.Uebersetzung) }}, {{ end }}{{ if $categoryFlags.Uebersetzung }}Übersetzung aus:{{ else }}Auszug aus:{{ end }} {{ if $workAuthorName }}
						<a href="/akteure/{{ $workAuthorID }}" class="author-link text-slate-700 hover:text-slate-900 underline decoration-slate-400 hover:decoration-slate-600">{{ $workAuthorName }}</a>, {{ end }}<em
						class="work-title"
						data-short-title="{{ $workTitle }}"
						{{ if $workTitleFull }}data-full-title="{{ $workTitleFull }}"{{ end }}
						>{{ $workTitle }}</em>
				{{ else if not $title }}
					Beitrag ohne Titel
				{{ end }}{{ Safe $placeTag }}
			{{- end -}}
		{{- end -}}

	{{- end -}}
</div>

{{- if or (eq $displayMode "issue") $longForm -}}
	{{- /* Show annotations for issue view (non-continuation pieces) or long form mode */ -}}
	{{- if or (and (eq $displayMode "issue") (not $isContinuation)) $longForm -}}
		{{- range $annotation := $piece.AnnotationNote.Annotations -}}
			<div class="italic text-sm mt-0.5 text-slate-600 indent-0">
				{{ Safe $annotation.HTML }}
			</div>
		{{- end -}}
	{{- end -}}
{{- end -}}
