// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){if(int(e.epoch)<1356998400)return STOP;var a=Scanner.fromMessage(e);a.setLocale(r);var n,i,l,p,o,m,s,u,g,c,h,d,v,f,b,C,T,y,N,x,A,F,S,k=[],$={};i=a.getSpan().innerCapture(regExpFormatted(/\1\s+(.*?)\s/,t.bookingReference),1),t.checkinUrl&&(l=a.getSpan().nextText(t.checkinUrl).nextLink()),d=a.getSpan().innerCapture(regExpFormatted(/\1 ($<priceCurrency>[A-Z]{3}) ($<totalPrice>[\d,. ]+)/,t.totalFare)),d?(F=d?d.$totalPrice.trim():null,S=d?d.$priceCurrency:null):(d=a.getSpan().next(t.totalFare).nextAnyTag("td").tagContents(),F=d.innerCapture(/([\d,.]+)/,1),S=d.innerCapture(/([^\d,.]+)/,1).trim()),o=a.getSpan().nextText(t.passengers).nextTag("table4").allInnerTags("tr4").map(function(e){return e.allInnerTagsFiltered("td4")}).filter(function(e){return e.length>=3});for(var D=0;D<o.length;D++){f=o[D],p=f[0],$[""+p]={name:p,seats:{},seatingType:{},programName:"Frequent Flyer",membershipNumber:""+f[1]!=t.NA&&f[1]||null,totalPrice:F,priceCurrency:S},A=f.length>3?3:2,s=f[A].split("\n");for(var P,z=0;z<s.length;z++)P=s[z].split("/ "),m=P[1]&&P[1].innerCapture(/(\d+[A-Z])/,1),valid(m)&&($[""+p].seats[""+P[0]]=m)}c=a.getSpan().nextText(t.itineraryDetails).nextTag("table4").allInnerTags("tr4").map(function(e){return e.allInnerTagsFiltered("td4")}).filter(function(e){return e.length>=8});for(var I=0;I<c.length;I++){g=c[I],u=g[0].innerDate(),b=g[1].innerCapture(/($<code>\D+)($<flightNumber>\d+)/),C=b?b.$code:null,h=b?b.$flightNumber:null,y=g[3].innerCapture(/([A-Z]{3}) </,1),T=combineDateAndTime(u,g[3].innerDate()),x=g[4].innerCapture(/([A-Z]{3}) </,1),v=g[4].innerCapture(/(\+1)$/,1).exists(),v&&(u=modifyDate(u,1)),N=combineDateAndTime(u,g[4].innerDate());var R=g[g.length-1];if(valid(h,R)){o=Object.keys($);for(var D=0;D<o.length;D++)$[""+o[D]].seatingType[""+h]=R}ASSERT(C,h,T,y,N,x)&&k.push({airlineCode:C,flightNumber:h,departureTime:T,departureCode:y,arrivalTime:N,arrivalCode:x,passengers:$})}for(var U=[],I=0;I<k.length;I++)for(var Z=k[I],E=Object.keys(Z.passengers),M=0;M<E.length;M++){var O=Z.passengers[E[M]],j={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:Z.airlineName,airlineCode:Z.airlineCode,flightNumber:Z.flightNumber,departureAirportFuzzy:Z.departureAirport,departureAirportCode:Z.departureCode,departureTime:Z.departureTime,arrivalAirportFuzzy:Z.arrivalAirport,arrivalAirportCode:Z.arrivalCode,arrivalTime:Z.arrivalTime},underName:{"@type":"http://schema.org/Person",name:O.name},checkinUrl:l,reservationId:i,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:O.totalPrice,priceCurrency:O.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:n,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:O.seats[""+Z.airlineCode+(""+Z.flightNumber)],seatingType:O.seatingType[Z.flightNumber]}}};valid(O.membershipNumber,O.programName)&&(j.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:O.membershipNumber,programName:O.programName}),U.push(j)}return U.length?U:void 0}}).call();