// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e);a.setLocale(t);var n,i,s,m,p,g,o,l,d,u,h,c,x,T,C,y,b,f,v,N,A,S,$,D,F,P,E=[],R={};n=a.getSpan().next(r.reservationId).parentAnyTag("td").tagContents().innerCapture(/(\w+)\s*$/,1),m=a.getSpan().nextText(r.passenger).nextTag("table2").allInnerTags("tr2").map(function(e){return e.allInnerTagsFiltered("td2")}).filter(function(e){if(!r.namesRegexExcludePassengerText.test(e)&&!r.namesRegexExcludeContactText.test(e)&&!r.namesRegexExcludeEmailText.test(e)&&!r.namesRegexExcludeMembershipText.test(e)&&e.length>0)return e}),l=a.getSpan().next(r.totalPrice).nextTag("td3").tagContents(),g=l.innerCapture(/([\d,.\s]+)/,1).trim(),o=l.innerCapture(/([^\d,.\s]+)/,1).trim(),a.getSpan().next(r.membership).exists()&&(y=a.getSpan().nextText(r.membership).nextTag("td3").tagContents(),""!==y&&(f=y.innerCapture(/(\w+)\s\d+/,1),b=y.innerCapture(/\w+\s(\d+)/,1)));for(var k=0,z=m.length;k<z;k++)d=m[k],s=""+d[0],R[s]={name:s,programName:f,membershipNumber:b,ticketNumber:d[2],seats:{},seatingType:{},totalPrice:g,priceCurrency:o};for(F=a.getSpan().allInnerCapture(regExpFormatted(/(\1\s*\d+)/,r.flight),1),$=0;$<F.length;$++)D=F[$],v=D.nextAnyTag("td").tagContents().innerCapture(r.date),S="ja_JP"===t?""+v.$date+"-"+v.$month+"-"+v.$year:""+v.$date+" "+v.$month+" "+v.$year,v=N=a.getDetachedSpan(S).innerDate(),c=D.next(r.departure).nextAnyTag("td").tagContents(),x=c.nextAnyTag("td").tagContents(),T=x.next(r.arrival).nextAnyTag("td").tagContents(),C=T.nextAnyTag("td").tagContents(),P=C.next(r.flightInfo).nextAnyTag("td").tagContents().innerCapture(/($<airlineName>\w.*)\s+($<airlineCode>\D+)($<flightNumber>\d+)/),h=P.$airlineCode,p=P.$flightNumber,u=P.$airlineName,A=C.next(r.seatingType).nextAnyTag("td").tagContents(),c=combineDateAndTime(v,c),T.inner(r.overnight).exists()?(T=combineDateAndTime(N,T.innerDate()),T=modifyDate(T,1,0,0,0)):T=combineDateAndTime(N,T),ASSERT(p,c,x,T,C)&&(0===u.length&&(u="US Airways"),E.push({airlineName:u,airlineCode:h,flightNumber:p,departureAirport:x,departureTime:c,arrivalAirport:C,arrivalTime:T,passengers:R}));for(var I=[],$=0;$<E.length;$++)for(var D=E[$],w=Object.keys(D.passengers),M=0;M<w.length;M++){var U=D.passengers[w[M]],j={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:D.airlineName,airlineCode:D.airlineCode,flightNumber:D.flightNumber,departureAirportFuzzy:D.departureAirport,departureAirportCode:D.departureCode,departureTime:D.departureTime,arrivalAirportFuzzy:D.arrivalAirport,arrivalAirportCode:D.arrivalCode,arrivalTime:D.arrivalTime},underName:{"@type":"http://schema.org/Person",name:U.name,email:U.email},checkinUrl:i,reservationId:n,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:U.totalPrice,priceCurrency:U.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:U.seats[D.flightNumber],seatingType:U.seatingType[D.flightNumber]}}};U.membershipNumber&&U.programName&&(j.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:U.membershipNumber,programName:U.programName}),I.push(j)}if(I.length)return I}}).call();