// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){var a=Scanner.fromMessage(e);a.setLocale(r);var n,i,p,o,x,d,g=[],m=1,u=[],l=[];for(n=a.getSpan().innerCapture(regExpFormatted(/\1(.*)/,t.refernce),1).trim(),i=a.getSpan().nextText(t.price).nextRegExp(regExpFormatted(/[A-Z]{3}\d+/)),p=i.innerCapture(regExpFormatted(/(\d+)/),1),o=i.innerCapture(regExpFormatted(/([A-Z]{3})/),1),x=a.getSpan().nextText(t.passenger+" "+m);x.exists();){var v={},s=x.nextText(t.name);v.name=a.getSpan().withInterval(s.getEnd(),s.nextText("\n").getStart()).trim(),v.ticketNumber=x.nextText(t.ticket).nextRegExp(regExpFormatted(/\d+/)),ASSERT(v.name)&&u.push(v),x=x.nextText(t.passenger+" "+m),m++}for(d=a.getSpan().nextText(t.itinerary).nextText("\n").nextText(t.flight);d.nextText(t.information).exists();){var h,c={},A=d.nextRegExp(regExpFormatted(/[A-Z]{2,3}\d+/));c.airlineCode=A.innerCapture(regExpFormatted(/([A-Z]{2,3})/),1),c.flightNumber=A.innerCapture(regExpFormatted(/(\d+)/),1),h=a.getSpan().withInterval(d.nextText("\n").getEnd(),d.nextText("\n").nextText("\n").getStart()),h=h.innerCapture(regExpFormatted(/\1 ($<dep>.*) \2 ($<arrival>.*)/,t.from,t.to)),h&&(c.departureAirport=h.$dep.innerCapture(regExpFormatted(/(.*)\(.*\)/),1),c.departureAirportCode=h.$dep.innerCapture(regExpFormatted(/([A-Z]{3})/),1),c.arrivalAirportCode=h.$arrival.innerCapture(regExpFormatted(/([A-Z]{3})/),1),c.arrivalAirport=h.$arrival.innerCapture(regExpFormatted(/(.*)\(.*\)/),1)),c.departureDate=d.nextText(t.departing).nextDate(),c.arrivalDate=d.nextText(t.arriving).nextDate(),ASSERT(c.departureAirport,c.arrivalAirport,c.departureDate,c.arrivalDate,c.flightNumber)&&l.push(c),d=d.nextText(t.flight)}for(var C=0;C<l.length;C++)for(var T=l[C],E=0;E<u.length;E++){var F=u[E],f={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:"Air Canada",airlineCode:T.airlineCode,flightNumber:T.flightNumber,departureAirportFuzzy:T.departureAirport,departureAirportCode:T.departureAirportCode,departureTime:T.departureDate,arrivalAirportFuzzy:T.arrivalAirport,arrivalAirportCode:T.arrivalAirportCode,arrivalTime:T.arrivalDate},underName:{"@type":"http://schema.org/Person",name:F.name},reservationId:n,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:p,priceCurrency:o,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:F.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:""}}};g.push(f)}return g}}).call();