% if (not $wr or $wr->errstr) {
  <div class="container">
    <div class="error">
      <strong>Fehler bei der Abfrage der Wagenreihung:</strong>
      <%= $wr ? $wr->errstr : $wr_error %>
    </div>
  </div>
% }
% else {
  % my $has_multi_dest = 0;
  % my $has_multi_desc = 0;
  % if (scalar $wr->destinations > 1) {
    % $has_multi_dest = 1;
  % }
  % if (scalar $wr->train_descriptions > 1) {
    % $has_multi_desc = 1;
  % }
  <div class="container">
    <div style="text-align: center;">
%=    join( ' / ', $wr->origins )
      →
%=    join( ' / ', map { $_->{name} } $wr->destinations )
    </div>
    % if ($has_multi_dest) {
      <div style="text-align: center;">
        % for my $destination ($wr->destinations) {
          Nach <%= $destination->{name} %> in Abschnitt <%= join(q{}, sort @{$destination->{sections} // []}) %><br/>
       % }
      </div>
    % }
    <%= $wr->station_name %> Gleis <%= $wr->platform %><br/>
    % for my $desc ($wr->train_descriptions) {
      % if ($desc->{text}) {
        %= $desc->{text}
        % if ($has_multi_desc and length(join(q{}, sort @{$desc->{sections}}))) {
          in Abschnitt <%= join(q{}, sort @{$desc->{sections}}) %>
        % }
        <br/>
      % }
    % }
  </div>
  <div class="container">
    <div class="wagonorder exit-<%= stash('exit_dir') // 'unknown'%>">
%     if (not $wr->has_bad_wagons) {
%       for my $section ($wr->sections) {
          <div class="section" style="
          top: <%= $section->{start_percent} %>%; bottom: <%= 100 - $section->{end_percent} %>%;">
%=          $section->{name}
          </div>
%       }
%     }
%     for my $wagon ($wr->wagons) {
%=      include '_wagon', direction => $wr->direction, wagon => $wagon, type => $wr->train_type, wref => $wref, exit_dir => stash('exit_dir');
%     }
      </div>
<!--  <div>
      Legende: ♿ Behindertengerechte Ausstattung / 🍴 Bistro/Restaurant / 🚪 Abteile vorhanden
    </div>
-->
    <p class="copyright">
      Quelle: DB Wagenreihungs-API. Angaben ohne Gewähr.
    </p>

  </div>
% }