// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){function e(e,r){for(var t=0;t<e.length;)r.test(e[t])?e.splice(t,1):t++;return e}return function(r,t,a){var n=Scanner.fromMessage(r);n.setLocale(a);var i,p,l,o,m,g,s,d,u,h,b,T,v,C,c,N,x,A,f,l,o,y=[],F={},$=n.getSpan().next(t.total);(""+$).length>0&&(b=$.nextTag("table5").nextTag("table5").nextTag("table5").nextTag("table5").nextTag("table5").nextTag("table5").nextTag("td5").tagContents(),l=b.innerCapture(/([\d,.]+)/,1),o=b.innerCapture(/([^\d,.]+)/,1)),i=""+n.getSpan().innerCapture(t.reservationId,1),N=n.getSpan().nextRegExp(/Ticket number\(s\)/).nextTag("table3").nextTag("table3").allInnerTagsFiltered("td3");for(var k=0;k<N.length;k++)N[k].innerCapture(/($<name>.*) <.*?>/)&&(c=N[k].innerCapture(/($<name>.*) <.*?>/,1),x=N[k+1]&&N[k+1].innerCapture(/^(\d+)$/,1)),valid(c)&&(F[""+c]={name:c,ticketNumber:x,seats:{},seatingType:{},frequentFlier:""}),c=null;for(A=n.getSpan().next(t.terminal).nextTag("table4").nextTag("table4").allInnerTags("table5"),m=0;m<A.length;m+=5){T={},u=A[m].innerDate(),v=A[m+1].allInnerDates(),T.departureTime=combineDateAndTime(u,v[0]),T.arrivalTime=combineDateAndTime(u,v[1]),C=A[m+2].nextAnyTag("td").tagContents().innerCapture(regExpFormatted(/($<departureAirport>.*)\s+\(($<departureCode>.*)\)\s+\1\s+($<arrivalAirport>.*)\s+\(($<arrivalCode>.*)\)/,t.to)),T.departureAirport=C.$departureAirport,T.departureCode=C.$departureCode,T.arrivalAirport=C.$arrivalAirport,T.arrivalCode=C.$arrivalCode,T.flightNumber=A[m+3].nextAnyTag("td").tagContents();var h=A[m+4].nextTag("table6"),S=h.nextTag("table6"),z=S.nextTag("table6");f=Object.keys(F);var I=(""+h.nextAnyTag("td").tagContents()).split(/\s\n\n/),D=e((""+S.nextAnyTag("td").tagContents()).split(/\n\n/),/\[/),R=e((""+z.nextAnyTag("td").tagContents()).split(/\n\n/),/\[/);for(s=0;s<f.length;s++)F[I[s]].seats[""+T.flightNumber]=/select seat/i.test(R[s])?"":R[s],d=D[s],F[I[s]].membershipNumber="N/A"===d?"":d,valid(d)&&(F[I[s]].programName="Frequent Flyer");ASSERT(T.flightNumber,T.departureTime,T.arrivalTime,T.departureCode,T.arrivalCode)&&y.push({airlineName:"JetBlue",airlineCode:"B6",flightNumber:T.flightNumber,departureTime:T.departureTime,departureCode:T.departureCode,departureAirport:T.departureAirport,arrivalTime:T.arrivalTime,arrivalCode:T.arrivalCode,arrivalAirport:T.arrivalAirport,passengers:F})}var E=[];for(m=0;m<y.length;m++){var T=y[m];for(f=Object.keys(T.passengers),g=0;g<f.length;g++){var M=T.passengers[f[g]],P={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:T.airlineName,airlineCode:T.airlineCode,flightNumber:T.flightNumber,departureAirportFuzzy:T.departureAirport,departureAirportCode:T.departureCode,departureTime:T.departureTime,arrivalAirportFuzzy:T.arrivalAirport,arrivalAirportCode:T.arrivalCode,arrivalTime:T.arrivalTime},underName:{"@type":"http://schema.org/Person",name:M.name},checkinUrl:p,reservationId:i,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:l,priceCurrency:o,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:M.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:M.seats[T.flightNumber],seatingType:M.seatingType[T.flightNumber]}}};valid(M.membershipNumber,M.programName)&&(P.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:M.membershipNumber,programName:M.programName}),E.push(P)}}if(E.length)return E}}).call();