// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){var a=Scanner.fromMessage(e);a.setLocale(r);var i,p,n,o,m,s,u,l,h,g,d,c,v,C,N,b,f,y=[],T=[];if(i=a.getSpan().innerCapture(t.name,1).trim(),N=a.getSpan().innerCapture(regExpFormatted(/\1\s+(.*)/,t.reservationId),1),not(i))return CONTINUE;T[""+i]={name:i,seats:{},seatingType:{},ticketNumber:d,totalPrice:c,priceCurrency:v},b=a.getSpan().allInnerCapture(t.flightInfo);for(var S=0;S<b.length;S++)f=b[S],1===b.length&&(matches=/(\w{3})\s(\w{3})$/.exec(e.subject),u=matches[1],g=matches[2]),m=a.getDetachedSpan(""+f.$departureDate+" "+f.$departureHour+":"+f.$departureMinute).innerDate(),l=a.getDetachedSpan(""+f.$arrivalDate+" "+f.$arrivalHour+":"+f.$arrivalMinute).innerDate(),o=f.$airlineCode,p=f.$flightNumber,s=f.$departureAirport,h=f.$arrivalAirport,n=a.getSpan().innerCapture(regExpFormatted(/\1\s+(.*)/,t.price),1),c=n.innerCapture(/([\d,.]+)/,1),v=n.innerCapture(/([^\d,.]+)/,1).trim(),ASSERT(o,p,s,m,h,l)&&y.push({reservationId:N,airlineCode:o,flightNumber:p,departureAirport:s,departureCode:u,arrivalCode:g,departureTime:m,arrivalAirport:h,arrivalTime:l,passengers:T});var A=[];for(S=0;S<y.length;S++)for(var $=y[S],F=Object.keys($.passengers),k=0;k<F.length;k++){var I=$.passengers[F[k]],z={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:$.airlineName,airlineCode:$.airlineCode,flightNumber:$.flightNumber,departureAirportFuzzy:$.departureAirport,departureAirportCode:$.departureCode,departureTime:$.departureTime,arrivalAirportFuzzy:$.arrivalAirport,arrivalAirportCode:$.arrivalCode,arrivalTime:$.arrivalTime},underName:{"@type":"http://schema.org/Person",name:I.name},checkinUrl:C,reservationId:$.reservationId,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:c,priceCurrency:v,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:d,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:I.seats[$.flightNumber],seatingType:I.seatingType[$.flightNumber]}}};valid(I.membershipNumber,I.programName)&&(z.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:I.membershipNumber,programName:I.programName}),A.push(z)}return A.length?A:void 0}}).call();