// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){var a=Scanner.fromMessage(e);a.setLocale(r);var n,i,o,p,l,m,s,d,g,u,c,h,b,f,v,T,C,N=[],x={},$=loadHelper("united.com-common.js"),y=t.scheduleChangeNotification&&a.getSpan().innerRegExp(regExpFormatted(/\b\1/,t.scheduleChangeNotification)).exists();p=a.getSpan().nextText(t.travelerInformation).parentTag("table4").allInnerTags("table5");for(var S,F=0;S=p[F++];)d=S.allInnerTagsFiltered("td5"),3===d.length&&(o=""+d[0],x[o]={name:o,seatMap:$.getSeatMap(d[2]),seats:{},seatingType:{}});i=a.getSpan().nextText(t.flightCheckInReminder).nextLink(),n=a.getSpan().nextText(t.confirmationNumber).parentTag("td4").innerCapture(regExpFormatted(/\1\s+(\w+)/,t.confirmationNumber),1),not(n)&&y&&(n=a.getSpan().innerCapture(regExpFormatted(/\1\s+(\w+)/,t.scheduleChangeNotification),1));var A=y?t.scheduleChange:t.confirmationNumber;if(m=a.getSpan().nextText(A).nextTag("table4").withEnd(a.getSpan().nextText(t.travelerInformation).parentTag("table4").getStart()).allInnerTagsFiltered("td4"),C=/^($<code>[A-Z]+)($<flightNumber>\d+)$/,m.length)for(var F=0,k=m.length;F<k;F++)if(m[F].innerCapture(C)&&F+3<k){if(g=m[F].innerCapture(C),u=g?g.$code:null,s=g?g.$flightNumber:null,c=m[F+1].innerCapture(/^($<time>\d{1,2}:\d{2} [a.pm]+)\s+($<date>.*)\s+.*\(($<code>[A-Z]{3}).*\)$/),b=c?c.$code:null,h=c?combineDateAndTime(c.$date,c.$time):null,f=m[F+2].innerCapture(/^($<time>\d{1,2}:\d{2} [a.pm]+)\s+($<date>.*)\s+.*\(($<code>[A-Z]{3}).*\)$/),T=f?f.$code:null,v=f?combineDateAndTime(f.$date,f.$time):null,l=m[F+3].innerCapture(regExpFormatted(/\b\1\s+(.*)\s/,t.fareClass),1),p=Object.keys(x),valid(s))for(var E,I=0;I<p.length;I++)valid(l)&&(x[p[I]].seatingType[s]=l),valid(T,b)&&(E=""+b+" - "+T,x[p[I]].seats[s]=x[p[I]].seatMap[E]);ASSERT(u,s,b,h,T,v)&&N.push({airlineCode:u,flightNumber:s,departureCode:b,departureTime:h,arrivalCode:T,arrivalTime:v,passengers:x})}for(var z,M=[],F=0;F<N.length;F++)for(var R=N[F],j=Object.keys(R.passengers),I=0;I<j.length;I++){var w=R.passengers[j[I]];z={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineCode:R.airlineCode,flightNumber:R.flightNumber,departureAirportFuzzy:R.departureAirport,departureAirportCode:R.departureCode,departureTime:R.departureTime,arrivalAirportFuzzy:R.arrivalAirport,arrivalAirportCode:R.arrivalCode,arrivalTime:R.arrivalTime},underName:{"@type":"http://schema.org/Person",name:w.name},checkinUrl:i,reservationId:n,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:w.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:w.seats[R.flightNumber],seatingType:w.seatingType[R.flightNumber]}},totalPrice:w.price,priceCurrency:w.currency,reservationStatus:"http://schema.org/ReservationConfirmed"},valid(w.membershipNumber)&&(z.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:w.membershipNumber,programName:"Frequent Flyer"}),M.push(z)}if(M.length)return M}}).call();