// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){var a=Scanner.fromMessage(e);a.setLocale(r);var i,n,p,o,s,l,m,g,d,u,h,c,T,v,b,N,C=[],y={};i=a.getSpan().nextText(t.reference).nextAnyTag("td").tagContents(),m=a.getSpan().nextText(t.passenger).withEnd(a.getSpan().nextText(t.payment).getStart()).allInnerTagsFiltered("td3");for(var f=0;f<m.length;f+=2)m[f]&&m[f+1]&&(y[""+m[f]]={name:m[f],seats:{},seatingType:{},ticketNumber:m[f+1].innerCapture(/(\d+)/,1)});s=a.getSpan().allInnerTags("table3");for(var f=0;f<s.length;f++)if(s[f].innerTag("td3").innerText(t.flightNumber).exists()){var A=s[f].collapseToStart().withStart(s[f].previousTag("table3").getEnd());if(m=A.innerCapture(/($<departureTime>\d{2}:\d{2})\s+($<departureAirport>.*)\s+\(.*\s+\(($<departureCode>[A-Z]{3})\)\)\s+-\s+($<arrivalTime>\d{2}:\d{2})($<arrivalAirport>.*?)\s+\(.*\s+\(($<arrivalCode>[A-Z]{3})\)\)/),m&&(h=a.getDetachedSpan(""+A.innerDate()+" "+m.$departureTime).innerDate(),c=m.$departureAirport,T=m.$departureCode,v=a.getDetachedSpan(""+A.innerDate()+" "+m.$arrivalTime).innerDate(),b=m.$arrivalAirport,N=m.$arrivalCode),g=s[f].innerText(t.flightNumber).nextAnyTag("td").tagContents().innerCapture(/($<code>\D+)($<flightNumber>\d+)/),u=g?g.$code:null,l=g?g.$flightNumber:null,d=s[f].innerText(t.operated).nextAnyTag("td").tagContents(),o=s[f].innerText(t.class).nextAnyTag("td").tagContents(),valid(l,o))for(var p=Object.keys(y),x=0;x<p.length;x++)y[p[x]].seatingType[""+l]=o;ASSERT(u,l,T,h,N,v)&&C.push({airlineName:d,airlineCode:u,flightNumber:l,departureCode:T,departureAirport:c,departureTime:h,arrivalCode:N,arrivalAirport:b,arrivalTime:v,passengers:y}),d=u=l=T=c=h=N=b=v=null}for(var $=[],f=0;f<C.length;f++)for(var S=C[f],k=Object.keys(S.passengers),D=0;D<k.length;D++){var F=S.passengers[k[D]],z={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:S.airlineName,airlineCode:S.airlineCode,flightNumber:S.flightNumber,departureAirportFuzzy:S.departureAirport,departureAirportCode:S.departureCode,departureTime:S.departureTime,arrivalAirportFuzzy:S.arrivalAirport,arrivalAirportCode:S.arrivalCode,arrivalTime:S.arrivalTime},underName:{"@type":"http://schema.org/Person",name:F.name,email:F.email},checkinUrl:n,reservationId:i,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:F.totalPrice,priceCurrency:F.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:F.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:F.seats[S.flightNumber],seatingType:F.seatingType[S.flightNumber]}}};valid(F.membershipNumber,F.programName)&&(z.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:F.membershipNumber,programName:F.programName}),$.push(z)}return $.length?$:CONTINUE}}).call();