// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e);a.setLocale(t);var n,i,g,o,p,m,l,d,s,u,h,T,c,C,x,N,v,f,A=[],y=[],S=[];n=a.getSpan().next(r.reservationId).parentAnyTag("td").tagContents().innerCapture(regExpFormatted(/\1\s*(.*)/,r.reservationId),1),s=a.getSpan().next(r.pricePrefix).nextAnyTag("td").tagContents(),u=s.innerCapture(/([\d,.]+)/,1),h=s.innerCapture(/([^\d,.]+)/,1).trim();var b=a.getSpan().next(r.manageBooking).next(r.yourItinerary);for(T=b.withEnd(b.next(r.itineraryEnd).getStart()).allInnerTagsFiltered("td4"),c=0;c<T.length;c++)x=T[c],x.innerDate().exists()&&(C={},i=x.innerCapture(/^($<airlineCode>\D+)($<flightNumber>\d+)/),C.airlineCode=i.$airlineCode,C.flightNumber=i.$flightNumber,N=x.nextAnyTag("td").tagContents().innerCapture(/^($<airlineName>.*)\|.*\|($<status>.*)$/),C.airlineName=N.$airlineName.trim(),C.airlineStatus=N.$status,g=C.airlineName.nextTag("td7").tagContents(),m=g.nextTag("td7").nextTag("td7").tagContents(),"ja_JP"===t&&(g=(""+g).replace(/ /g,"-")),C.departureTime=combineDateAndTime(g,m),p=m.nextTag("td7").nextTag("td7").tagContents(),C.departureAirport=(""+p+" "+p.nextAnyTag("td").tagContents()).trim(),o=p.nextTag("table7").nextTag("td7").tagContents(),l=o.nextTag("td7").nextTag("td7").tagContents(),"ja_JP"===t&&(o=(""+o).replace(/ /g,"-")),C.arrivalTime=combineDateAndTime(o,l),d=l.nextTag("td7").nextTag("td7").tagContents(),C.arrivalAirport=(""+d+" "+d.nextAnyTag("td").tagContents()).trim(),ASSERT(C.airlineName,C.airlineCode,C.flightNumber,C.departureTime,C.departureAirport,C.arrivalTime,C.arrivalAirport)&&A.push(C));for(v=a.getSpan().next(r.ticketNumberPrefix).collapseToEnd().withEnd(a.getSpan().next(r.passengerPostFix).getStart()).allInnerTagsFiltered("td5"),c=0;c<v.length;c++)f=v[c].tagContents().innerCapture(/($<ticketNumber>.*)\s+\(($<name>.*)\)/),S.push({name:f.$name,ticketNumber:f.$ticketNumber});for(0===S.length&&S.push({name:a.getSpan().innerCapture(r.nameCapture,1)}),c=0;c<A.length;c++){C=A[c];for(var $=0;$<S.length;$++){ASSERT(C.airlineName||C.airlineCode,C.flightNumber,C.departureAirport,C.departureTime),f=S[$];var k={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:C.airlineName,airlineCode:C.airlineCode,flightNumber:C.flightNumber,departureAirportFuzzy:C.departureAirport,departureTime:C.departureTime,arrivalAirportFuzzy:C.arrivalAirport,arrivalTime:C.arrivalTime},underName:{"@type":"http://schema.org/Person",name:f.name},reservationId:n,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:u,priceCurrency:h,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:f.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat"}}};y.push(k)}}if(y.length)return y}}).call();