// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,r){var a=Scanner.fromMessage(e);a.setLocale(t);var n,i,l,o,p,g,s,m,u,h,d,c,T,C,v,f=[],b=[],y=[];for(n=a.getSpan().innerCapture(regExpFormatted(/\1\s+(\w+)/,r.reservationId),1),g=a.getSpan().next(r.checkIn).nextLink(),m=a.getSpan().next(r.passengerDetails).parentAnyTag("table").allInnerTags("tr2"),s=1;s<m.length;s++)h={},u=m[s].allInnerTags("td2"),u.length>2&&(h.name=u[0].tagContents(),h.ticketNumber=u[1].tagContents().innerCapture(/(\d+)/,1),h.seats=u[2].tagContents().split(","),ASSERT(h.name)&&f.push(h));for(c=a.getSpan().next(r.flightDetails).nextTag("table3").allInnerTags("tr3"),s=0;s<c.length;s++)d={},u=c[s].allInnerTags("td3"),u.length>2&&(T=u[0].allInnerDates(),T.length>1?(i=T[0],l=T[1]):i=l=T[0],d.departureTime=combineDateAndTime(i,u[1].innerDate()),d.departureAirport=u[1].tagContents().innerCapture(/(.*)\n/,1),d.arrivalTime=combineDateAndTime(l,u[2].innerDate()),d.arrivalAirport=u[2].tagContents().innerCapture(/(.*)\n/,1),C=u[3].innerCapture(/($<airlineCode>\w+)\s($<flightNumber>\d+)/),d.airlineCode=C.$airlineCode,d.flightNumber=C.$flightNumber,d.seatingType=u[4].tagContents().innerCapture(/\n(.*)/,1),ASSERT(d.departureAirport,d.arrivalAirport,d.departureTime,d.arrivalTime,d.airlineCode,d.flightNumber)&&b.push(d));for(v=r.bookingPending?"Pending":"Confirmed",s=0;s<b.length;s++){d=b[s];for(var A=0;A<f.length;A++){h=f[A];var N={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:"Etihad",airlineCode:d.airlineCode,flightNumber:d.flightNumber,departureAirportFuzzy:d.departureAirport,departureTime:d.departureTime,arrivalAirportFuzzy:d.arrivalAirport,arrivalTime:d.arrivalTime},underName:{"@type":"http://schema.org/Person",name:h.name},checkinUrl:g,reservationId:n,reservationStatus:"http://schema.org/Reservation"+v,totalPrice:o,priceCurrency:p,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:h.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:h.seats[s].trim(),seatingType:d.seatingType}}};y.push(N)}}if(y.length)return y}}).call();