% 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 {
  <div class="container">
    <div style="text-align: center;">
      Gleis <%= $wr->platform %><br/>
    </div>
  </div>
  <div class="container">
    <div class="wagonorder exit-<%= stash('exit_dir') // 'unknown'%>">
%     for my $sector ($wr->sectors) {
        <div class="section" style="
        top: <%= $sector->start_percent %>%; bottom: <%= 100 - $sector->end_percent %>%;">
%=        $sector->name
        </div>
%     }
%     for my $group ($wr->groups) {
%       my $first = 1;
%       for my $wagon ($group->carriages) {
%=        include '_wagon', wr => $wr, group => $group, wagon => $wagon, first => $first, multi => (scalar $wr->destinations) - 1 + (scalar $wr->train_numbers) - 1, wref => $wref, exit_dir => stash('exit_dir'), train_no => param('number');
%         $first = 0;
%       }
%     }
      </div>
    % for my $group ($wr->groups) {
      % if ($group->description) {
        <div style="text-align: center;">
          %= $group->description
          % if ($group->designation) {
            „<%= $group->designation %>“
          % }
          % if (scalar $wr->groups > 1 and $group->has_sectors) {
            in Abschnitt <%= join(q{}, sort $group->sectors) %>
          % }
        </div>
      % }
    % }
      <div style="text-align: center;">
        nach
%=      join( ' / ', map { $_->{name} } $wr->destinations )
      </div>
<!--  <div>
      Legende: ♿ Behindertengerechte Ausstattung / 🍴 Bistro/Restaurant / 🚪 Abteile vorhanden
    </div>
-->
    <p class="copyright">
      Quelle: DB Wagenreihungs-API (<%= stash('ts') // q{} %>). Angaben ohne Gewähr.
    </p>

  </div>
% }