// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){var a=Scanner.fromMessage(e);a.setLocale(r);var i,n=a.getSpan(),o=t.isCancellation?"Cancelled":"Confirmed",p=[],l=[],s=[],u=n.next("Passengers").parentTag("table6").allInnerTags("table8");u.shift().allInnerTags("td8")[1].tagContents().split(/\n/).slice(2).filter(function(e){return!t.ticketNumberRegExp.test(e)}).forEach(function(e){p.push({name:e.trim()})});var m,d;return u.forEach(function(e){var r=e.allInnerTags("td8")[0].tagContents();if(t.dateFormatRegExp.test(""+r))m=d=r.innerDate();else{var i,n,o,p,l,u,c,h,g,f,v;[,l,g]=e.innerCapture(/([A-Z]{3})\s+([A-Z]{3})/),[,u,f]=e.innerCapture(t.timeFormatRegExp),[,i,o]=e.innerCapture(t.airlineAndFlightNumberRegExp),t.isOverNightRegExp.test(""+e)&&(d=modifyDate(d,1)),c=a.getDetachedSpan(m+" "+u).innerDate(),v=a.getDetachedSpan(d+" "+f).innerDate(),s.push({airlineName:i,airlineCode:n,flightNumber:o,departureAirport:p,departureAirportCode:l,departureDateTime:c,arrivalAirport:h,arrivalAirportCode:g,arrivalDateTime:v}),int(modifyDate(d,0).split("-")[2])-int(modifyDate(m,0).split("-")[2])>0&&(m=d)}}),0===p.length&&p.push({}),s.forEach(function(e){p.forEach(function(r){ASSERT(e.airlineName||e.airlineCode,e.flightNumber,e.departureAirport||e.departureAirportCode,e.departureDateTime),l.push({"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineCode:e.airlineCode,airlineName:e.airlineName,flightNumber:e.flightNumber,departureAirportFuzzy:e.departureAirport,departureAirportCode:e.departureAirportCode,departureTime:e.departureDateTime,arrivalAirportFuzzy:e.arrivalAirport,arrivalAirportCode:e.arrivalAirportCode,arrivalTime:e.arrivalDateTime},underName:{"@type":"http://schema.org/Person",name:r.name},reservationId:i,reservationStatus:"http://schema.org/Reservation"+o,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:r.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:r.seat,seatingType:null}}})})}),l}}).call();