% if (@{$departures}) {

% if (not param('ajax')) {
<div class="app" data-station="<%= $station %>">
<div class="moreinfo collapsed-moreinfo">
	<div class="mheader">
		<div>
			<span class="train-line"></span>
			<span class="train-no"></span>
		</div>
		<div>
			<span class="train-origin"></span>
			→
			<span class="train-dest"></span>
		</div>
	</div>
	<div class="mfooter"></div>
</div>
<ul>
% } # not param('ajax')
% my $i = 0;
% my $dt_now = DateTime->now;
% for my $departure (@{$departures}) {
%   $i++;
%   my $route_str = q{};
%   my $via_max = @{$departure->{via} // []};
%   my $via_cur = 0;
%   for my $stop (@{$departure->{via} // []}) {
%     $via_cur++;
%     $route_str .= $stop . ($via_cur < $via_max ? ' - ' : q{});
%   }
    <li
% if (param('hafas')) {
      data-jid="<%= $departure->{journey_id} =~ s{#}{%23}gr %>"
% }
      data-train="<%= ($departure->{train_type} // q{}) %> <%= ($departure->{train_no} // $departure->{train} // q{}) %>"
      data-line="<%= $departure->{train_type} %> <%= $departure->{train_line} // $departure->{train_no} %>"
      data-no="<%= $departure->{train_line} ? $departure->{train_no} : q{} %>"
      data-linetype="<%= $departure->{linetype} %>"
      data-from="<%= $departure->{origin} // q{???} %>"
      data-to="<%= $departure->{destination} // q{???} %>"
      data-station="<%= $departure->{station} // $station %>"
      data-platform="<%= $departure->{scheduled_platform} // $departure->{platform} // '' %>"
      data-arrival="<%= $departure->{sched_arrival} // '' %>"
      data-departure="<%= $departure->{sched_departure} // '' %>"
      data-moreinfo="<%= join(q{|}, map { ($_->[0]->isa('DateTime') ? $_->[0]->strftime('%H:%M') . ' ' . $_->[1] : $_->[0] . ' ' . $_->[1]{text}) } @{ $departure->{moreinfo} // [] } ) %>"
      data-routeprev="<%= join(q{|}, @{ $departure->{route_pre} // [] } ) %>"
      data-routenext="<%= join(q{|}, @{ $departure->{route_post} // [] } ) %>"
%   if ($departure->{is_cancelled} or $departure->{departure_is_cancelled}) {
      class="cancelled">
%   }
%   else {
      >
%   }
%   if (param('hafas')) {
      <a href="/z/<%= Mojo::Util::url_escape($departure->{journey_id}) . '?hafas=1&highlight=' .  Mojo::Util::url_escape($departure->{station} // $station) %>">
%   }
%   else {
      <a href="/z/<%= Mojo::Util::url_escape(($departure->{train_type} // q{}) . ' ' . ($departure->{train_no} // $departure->{train} // q{})) . '/' .  Mojo::Util::url_escape($departure->{station} // $station) %>">
%   }
    <div class="anchor" id="<%= ($departure->{train_type} // q{x}) . ($departure->{train_no} // q{x}) %>"></div>
    <div class="line <%= $departure->{linetype} %>">
    % if ($departure->{train_type} and $departure->{train_no}) {
%=    $departure->{train_type}
%   }
%   if ($departure->{train_line} ) {
%=    $departure->{train_line}
%   }
%   elsif ($departure->{train_no}) {
      <span class="trainno"><%= $departure->{train_no} %></span>
%   }
%   else {
%=    $departure->{train}
%   }
%   if ($departure->{train_line} and $departure->{train_no}
%       and $departure->{train_line} ne $departure->{train_no}
%       and param('detailed')) {
      <div class="trainno_sub"><%= $departure->{train_no} %></div>
%   }
    </div>
%   if (@{$departure->{replaced_by}} or @{$departure->{replacement_for}}) {
      <div class="lineinfo">
%     if (@{$departure->{replaced_by}}) {
        %#<span class="replaced">→ Ersatzzug</span>
%     }
%     if (@{$departure->{replacement_for}}) {
        <span class="replacement">Ersatzzug</span>
%     }
      </div>
%   }
%   if ($departure->{sched_departure}) {
      <span class="dest">
        <span class="visually-hidden">nach</span>
%=      $departure->{destination}
      </span>
%   }
%   else {
      <span class="origin">
        <span class="visually-hidden">von</span>
%=      $departure->{origin}
      </span>
%   }
    <span class="time <%= ($show_realtime and $departure->{delay} and not
      $departure->{is_cancelled}) ? 'delayed' : q{} %>">
%     if ($departure->{delay} and not $departure->{is_cancelled}) {
%       if ($show_realtime) {
%         if ($departure->{delay} > ($hide_low_delay ? 4 : 0)) {
            <span class="delaynorm" aria-hidden="true">+<%= $departure->{delay} %> ⇒</span>
%         }
%         elsif ($departure->{delay} < 0) {
            <span class="undelaynorm" aria-hidden="true"><%= $departure->{delay} %> ⇒</span>
%         }
%       }
%       else {
%         if ($departure->{delay} > ($hide_low_delay ? 4 : 0)) {
            <span class="delay" aria-hidden="true">+<%= $departure->{delay} %></span>
%         }
%         elsif ($departure->{delay} < 0) {
            <span class="undelay" aria-hidden="true"><%= $departure->{delay} %></span>
%         }
%       }
%     }
%     elsif ($departure->{missing_realtime}) {
        <span class="visually-hidden">Echtzeitdaten fehlen</span>
        <span class="no-realtime" aria-hidden="true"><i class="material-icons">gps_off</i></span>
%     }
%     if (param('detailed')) {
%       my $arrow = '→';
%       if (not $departure->{sched_arrival}) {
%         $arrow = '↦';
%       }
%       elsif (not $departure->{sched_departure}) {
%         $arrow = '⇥';
%       }
%       if ($show_realtime) {
%=        ($departure->{arrival} // q{}) . $arrow . ($departure->{departure} // q{})
%       }
%       else {
%=        ($departure->{sched_arrival} // q{}) . $arrow . ($departure->{sched_departure} // q{})
%       }
%     }
%     else {
%=      $departure->{time}
%     }
    </span>
%   if (($departure->{scheduled_platform} and $departure->{platform} and
%       $departure->{scheduled_platform} ne $departure->{platform})
%       or $departure->{changed_platform}) {
      <span class="platform changed-platform">
%   }
%   else {
      <span class="platform">
%   }
%   if ($departure->{load}{FIRST} or $departure->{load}{SECOND}) {
%     my ($text, $icon1, $icon2) = utilization_icon([$departure->{load}{FIRST}, $departure->{load}{SECOND}]);
      <span class="load">
        <i class="material-icons" style="vertical-align: bottom;" aria-hidden="true"><%= $icon2 %></i>
      </span>
%   }
%   elsif (my $o = $departure->{occupancy}) {
      <span class="load">
%       my ($text, $icon) = occupancy_icon($o);
        <i class="material-icons" style="vertical-align: bottom;" aria-hidden="true"><%= $icon %></i>
      </span>
%   }
    <span class="visually-hidden">Gleis</span>
%=  $departure->{platform}
    </span>
%   if ($departure->{info} and length $departure->{info}) {
      <span class="info">
%=    $departure->{info}
      </span>
%   }
%   else {
      <span class="route">
      <span class="visually-hidden">über</span>
%=    $route_str
      </span>
%   }
    </a>
    </li>

% }
% if (not param('ajax')) {

  </ul>
  </div> <!-- app -->
% }

% }
% elsif (not param('ajax')) {

<div class="container">
<div class="error"><strong>Keine Abfahrten gefunden.</strong>
Möglicherweise ist der Filter zu restriktiv, oder an dieser Station fahren
momentan keine Züge.</div>
</div> <!-- container -->

% }