// 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,g,d,s,l,u,m,C,h,y,T,c,v,A,f,x,$=[],b=[];for(n=a.getSpan().next(t.reservationId).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1\s+(.*)/,t.reservationId),1),m=a.getSpan().next(t.checkInUrl).nextLink(),i=a.getSpan().next(t.itinerary).parentTag("table4").allInnerCapture(regExpFormatted(/(\1)/,t.flight),1),y=a.getSpan().next(t.passengerInfo).parentAnyTag("table").allInnerTags("tr6"),o=0;o<y.length-1;o++){for(h={},h.name=y[o].nextTag("td7").tagContents(),h.seat={},h.seatingType={},f=y[o].allInnerCapture(/(\D{2,3}-\D{2,3})/,1),T=0;T<f.length;T++)c=f[T].previousAnyTag("td").tagContents().innerCapture(/(\d+)/,1),h.seat[c]=f[T].nextAnyTag("td").tagContents(),h.seatingType[c]=h.seat[c].nextAnyTag("td").tagContents();b.push(h)}for(s=a.getSpan().next(t.price).nextAnyTag("td").tagContents().innerCapture(/($<currency>[^\d,.]+)($<price>[\d,.]+)/),l=s.$price,u=s.$currency,o=0;o<i.length;o++)p={},g=i[o].previousAnyTag("td").tagContents().innerCapture(regExpFormatted(/($<departureAirport>.*)\(($<departureCode>.*)\)\s\1\s+($<arrivalAirport>.*)\(($<arrivalCode>.*)\)/,t.to)),p.departureAirportFuzzy=g.$departureAirport.trim(),p.departureAirportCode=g.$departureCode,p.arrivalAirportFuzzy=g.$arrivalAirport.trim(),p.arrivalAirportCode=g.$arrivalCode,v=i[o].previousAnyTag("td").firstDate(),A=a.getDateDD(i[o].previousAnyTag("td").lastInnerDate()),p.departureTime=combineDateAndTime(v,A.iso8601),p.arrivalTime=combineDateAndTime(v,A.endIso8601),i[o].previousAnyTag("td").inner(regExpFormatted(/(\1)/,t.plusDay),1).exists()&&(p.arrivalTime=modifyDate(p.arrivalTime,1,0,0,0)),p.seatingType=i[o].nextAnyTag("td").tagContents().innerCapture(/\n(.*)/,1),d=i[o].parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1\s($<airlineCode>\D+)($<flightNumber>\d+)/,t.flight)),p.airlineCode=d.$airlineCode.trim(),p.flightNumber=d.$flightNumber,ASSERT(p.departureAirportCode,p.arrivalAirportCode,p.departureTime,p.arrivalTime,p.airlineCode,p.flightNumber)&&$.push(p);C=a.getSpan().next(t.ticketNumber).nextAnyTag("td").tagContents();var F=[];for(x="Confirmed",a.getSpan().next(t.pending).exists()&&(x="Pending"),o=0;o<$.length;o++)for(p=$[o],T=0;T<b.length;T++){h=b[T];var z={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:p.airlineName,airlineCode:p.airlineCode,flightNumber:p.flightNumber,departureAirportFuzzy:p.departureAirportFuzzy,departureAirportCode:p.departureAirportCode,departureTime:p.departureTime,arrivalAirportFuzzy:p.arrivalAirportFuzzy,arrivalAirportCode:p.arrivalAirportCode,arrivalTime:p.arrivalTime},underName:{"@type":"http://schema.org/Person",name:h.name},checkinUrl:m,reservationId:n,reservationStatus:"http://schema.org/Reservation"+x,totalPrice:l,priceCurrency:u,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:C,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:h.seat[""+p.flightNumber],seatingType:h.seatingType[""+p.flightNumber]}}};F.push(z)}if(F.length)return F}}).call();