// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e);a.setLocale(t);var n,i,o,l,p,s,g,m,u,d,c,h,T,v,x,C,b,f,N=[],A=[],k=[];n=a.getSpan().innerCapture(regExpFormatted(/\1(\w+)/,r.reservationId),1),s=a.getSpan().next(r.checkIn).nextLink();var y=a.getSpan().nextText("Your ticket(s) is/are:").parentTag("td2").tagContents().split("http");for(y.pop(),x=0;x<y.length;x++)[,b,g]=y[x].innerCapture(/\s(.+): (\d+)/),N[""+b]={name:b,ticketNumber:g,seats:{}};var S=a.getSpan().nextText("Your Booking Reference is").nextTag("table3").allInnerTagsFiltered("table4");for(x=0;x<S.length;x++){var F=S[x].innerCapture(/($<airlineName>.+) Flight Number ($<airlineCode>[A-Z0-9]{2}) ($<flightNumber>\d+)/);d=S[x].innerDate(),m=F.$airlineName,u=F.$airlineCode,T=F.$flightNumber;var D=S[x].allInnerTags("table5");[,i]=D[0].nextText("Departure:").nextTag("td5").tagContents().innerCapture(/(.+)\n/),o=D[0].nextText("Departure:").nextTag("td5").innerDate(),""+D[0].nextText("Arrival:").nextTag("td5").tagContents(),[,p]=D[0].nextText("Arrival:").nextTag("td5").tagContents().innerCapture(/(.+)\n/),l=D[0].nextText("Arrival:").nextTag("td5").innerDate(),o=combineDateAndTime(d,o),l=combineDateAndTime(d,l);var z=D[2].allInnerTags("table6"),I="";for(v=Object.keys(N),C=0;C<z.length;C++){var $=z[C].nextText("Seat(s):").previousTag("td6").tagContents();I=(""+z[C].nextText("Seat(s):").nextTag("td6").tagContents()).match(/(.+)\//)[1].trim();for(var R=0;R<y.length;R++)if(0===(""+v[R]).localeCompare(""+$)){N[v[R]].seats[""+T]=I;break}}ASSERT(T,o,l)&&A.push({airlineName:m,airlineCode:u,flightNumber:T,departureTime:o,departureCode:c,departureAirport:i.trim(),arrivalTime:l,arrivalCode:h,arrivalAirport:p.trim(),passengers:N})}for(x=0;x<A.length;x++){var f=A[x],P=Object.keys(f.passengers);for(C=0;C<P.length;C++){v=f.passengers[P[C]];var j={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:f.airlineName,airlineCode:f.airlineCode,flightNumber:f.flightNumber,departureAirportFuzzy:f.departureAirport,departureAirportCode:f.departureCode,departureTime:f.departureTime,arrivalAirportFuzzy:f.arrivalAirport,arrivalAirportCode:f.arrivalCode,arrivalTime:f.arrivalTime},underName:{"@type":"http://schema.org/Person",name:v.name},checkinUrl:s,reservationId:n,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:v.totalPrice,priceCurrency:v.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:v.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:v.seats[""+f.flightNumber],seatingType:""}}};k.push(j)}}if(k.length)return k}}).call();