// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){if(!e||!r||!t)return CONTINUE;var a=Scanner.fromMessage(e);a.setLocale(r);var i,n,l,o,p,s,c,d,u,g,h,m,v,T,C,x,f,y,A,F,b=a.getSpan(),I=[],N={};n=b.withInterval(b.nextText(t.reservationId).getEnd(),b.nextText(t.reservationIdPostFix).getStart()).trim();var S=b.nextText(t.passengerDetails).nextTag("table3").allInnerTagsFiltered("td3"),P=[];for(A=0;A<S.length;A++)/\u2022/.test(""+S[A])||P.push(S[A]);for(c=b.nextText(t.totalPrice).nextTag("td3").tagContents().innerCapture(/($<priceCurrency>[\w]+)\s($<totalPrice>[\d,.]+)/),d=c?c.$totalPrice:null,u=c?c.$priceCurrency:null,A=0;A<P.length;A++)o=""+P[A],N[""+o]={name:o,totalPrice:d,priceCurrency:u};for(p=b.withInterval(b.nextText(t.flightDetails).getEnd(),b.nextText(t.endOfFlightDetails).getStart()).allInnerTagsFiltered("table3"),A=0;A<p.length;A++){var k=p[A].allInnerTagsFiltered("td3");h=p[A].innerDate(),[,g,s]=k[5].innerCapture(/([A-Z0-9]+)\s(\d+)/),[,m,v]=k[6].innerCapture(/(.+)\n(.+)/),[,C,x]=k[7].innerCapture(/(.+)\n(.+)/),m=combineDateAndTime(h,m),C=combineDateAndTime(h,C),ASSERT(s,m,C)&&I.push({airlineCode:g,flightNumber:s,departureTime:m,departureCode:T,departureAirport:v.trim(),arrivalTime:C,arrivalCode:f,arrivalAirport:x.trim(),passengers:N})}var z=[];for(A=0;A<I.length;A++){var D=I[A],E=Object.keys(D.passengers);for(F=0;F<E.length;F++){y=D.passengers[E[F]];var $={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:"Copa Airlines",airlineCode:"CM",flightNumber:D.flightNumber,departureAirportFuzzy:D.departureAirport,departureAirportCode:D.departureCode,departureTime:D.departureTime,arrivalAirportFuzzy:D.arrivalAirport,arrivalAirportCode:D.arrivalCode,arrivalTime:D.arrivalTime},underName:{"@type":"http://schema.org/Person",name:y.name},checkinUrl:l,reservationId:n,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:y.totalPrice,priceCurrency:y.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:i,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:"",seatingType:""}}};z.push($)}}return z.length?z:void 0}}).call();