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