// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e),i=a.getSpan();a.setLocale(t);var n,p,s,o=i.nextText(r.reservationIdPrefix).parentTag("td4").tagContents().innerCapture(regExpFormatted(/\1(.+)\n/,r.reservationIdPrefix),1).trim(),m=i.nextText(r.itineraryPrefix).nextTag("table5").allInnerTags("tr5");m.pop(),m.pop();for(var d,u,g=[],l=[],T=[],c=0,h={},v=0;v<m.length;v++)m[v]=m[v].allInnerTagsFiltered("td5"),d=/Flight\s[0-9]\,/,d.test(m[v])===!0&&(h.departureDate=(""+m[v]).split(",")[1]+(""+m[v]).split(",")[2],h.departureDate=getFuzzyDate(a.getDetachedSpan(""+h.departureDate)),s=h.departureDate),d=/Depart\,/,d.test(m[v])===!0&&(u=(""+m[v]).match(/(.+),(.+)\s([0-9]+)\n?/),h.airlineName=u[2],h.flightNumber=u[3]),d=/(AM,)|(PM,)/,d.test(m[v])===!0&&(u=u=(""+m[v]).match(/^(.+?),(.+)\((.+)\)/),0===c?(h.departureTime=u[1],h.departureAirport=u[2],h.departureAirportCode=u[3],h.departureTime=getFuzzyDate(a.getDetachedSpan(""+h.departureTime)),h.departureTime=combineDateAndTime(s,h.departureTime),c=1):(h.arrivalTime=u[1],h.arravalAirport=u[2],h.arrivalAirportCode=u[3],h.arrivalTime=getFuzzyDate(a.getDetachedSpan(""+h.arrivalTime)),h.arrivalTime=combineDateAndTime(s,h.arrivalTime),c=0)),d=/Seats:/,d.test(m[v])===!0?(h.seats=(""+m[v]).match(/Seats:\s(.+)\|\sSeats/)[1],g.push(h),h={}):(d=/Meal:/,d.test(m[v])===!0&&g.push(h));for(var x=1,C=a.getSpan().nextText(r.passenger+" "+x);C.exists();){var f={};f.name=C.nextTag("td4").tagContents(),f.ticketNumber=(""+C.nextText(r.ticket).nextTag("td4").tagContents()).match(/^([0-9]+)\s/)[1],f.seatingType=C.nextText(r.Seatpreference).nextTag("td4").tagContents().trim(),ASSERT(f.name)&&l.push(f),x++,C=a.getSpan().nextText(r.passenger+" "+x)}n=i.nextText(r.pricePrefix).nextTag("td4").tagContents();var A=n;for(n=A.innerCapture(/([\d,.-]+)/,1),p=A.innerCapture(/([^\d,.-]+)/,1).trim(),v=0;v<g.length;v++){var S=g[v],y=[];d=/,/,d.test(S.seats)===!0&&(y=S.seats.split(","));for(var D=0;D<l.length;D++){var z=l[D],F=y[D],N={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:S.airlineName,airlineCode:S.airlineCode,flightNumber:S.flightNumber,departureAirportFuzzy:S.departureAirport,departureAirportCode:S.departureAirportCode,departureTime:S.departureTime,arrivalAirportFuzzy:S.arrivalAirport,arrivalAirportCode:S.arrivalAirportCode,arrivalTime:S.arrivalTime},underName:{"@type":"http://schema.org/Person",name:z.name},reservationId:o,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:n,priceCurrency:p,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:z.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:F}}};T.push(N)}}return T}}).call();