// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,r,t){function a(e){var t;if("ja_JP"===r){if(t=e.tagContents().innerCapture(/($<day>\d{1,2}) ($<month>\d{1,2}) ($<year>\d{2})/),valid(t))return n.getDetachedSpan(""+t.$month+"/"+t.$day+"/20"+t.$year).innerDate()}else{if("zh_Hans_CN"!==r)return e.tagContents().innerDate();if(t=e.tagContents().innerCapture(/($<day>\d{1,2}) ($<month>.{2,3}) ($<year>\d{2})/),valid(t))return n.getDetachedSpan(t.$year+"\u5e74"+t.$month+(""+t.$day)+"\u65e5").innerDate()}}var n=Scanner.fromMessage(e);n.setLocale(r);var i,p,o,l,m,g,s,d,u,h,T,c,v,f,b,x,N,y,C,S,A,$,P,D,k,z,F,R,U,I,M,E,L,j=[],O=[],_={};i=n.getSpan().next(t.confirmationCode).parentTag("table4").nextTag("table5").tagContents(),l=n.getSpan().nextText(t.passenger).parentTag("table4").nextTag("table5").nextTag("table5").allInnerTags("td5"),u=n.getSpan().nextText(t.totalPrice).nextTag("td5").nextTag("td5").tagContents().innerCapture(/($<currency>\w+)\s($<totalPrice>.+)/),s=u?u.$totalPrice:null,d=u?u.$currency:null;for(var K=0;K<l.length;K+=3)o=l[K+1].tagContents().innerCapture(/(.+)\(/,1).trim(),y=""+l[K+2].nextText(t.ticketNumber).nextTag("td7").tagContents(),_[o]={name:o,programName:S,membershipNumber:C,ticketNumber:y,seats:{},seatingType:{},totalPrice:s,priceCurrency:d};m=i.nextRegExp(t.flightSummary).nextTag("table4").allInnerTags("table6").filter(function(e){return!t.totalTravelTime.test(e)});for(var w=n.getSpan().nextRegExp(t.flightSummary).nextTag("table4").allInnerTags("td5").map(function(e){return e.allInnerTagsFiltered("td5")}).filter(function(e){return t.flightNumber.test(e)||t.train.test(e)}),B=[],H=0;H<m.length;H++)B.push([m[H],w[H]]);for(var H=0;H<B.length;H++)c=B[H][0].nextTag("td6").tagContents().innerDate(),c=a(B[H][0].nextTag("td6")),v=B[H][0].nextTag("td6").nextTag("td6").tagContents().innerDate(),v=combineDateAndTime(c,v),f=B[H][0].nextTag("td6").nextTag("td6").tagContents().innerCapture(/\d\d:\d\d\s(.+)/,1),b=a(B[H][0].nextTag("tr6").nextTag("tr6").nextTag("td6")),x=B[H][0].nextTag("tr6").nextTag("tr6").nextTag("td6").nextTag("td6").tagContents().innerDate(),x=combineDateAndTime(b,x),N=B[H][0].nextTag("tr6").nextTag("tr6").nextTag("td6").nextTag("td6").tagContents().innerCapture(/\d\d:\d\d\s(.+)/,1),null!==B[H][1]&&(t.train.test(B[H][1])?(T=g=h="",M="KLM",$=f,F=N,ASSERT(v,$,x,F,M)&&O.push({departurePlatform:A,departureName:$,departureTelephone:P,departureUrl:D,departureAddress:k,departureTime:v,arrivalPlatform:z,arrivalName:F,arrivalTelephone:R,arrivalUrl:U,arrivalAddress:I,arrivalTime:x,provider:M,trainName:E,trainNumber:L,passengers:_})):(T=n.getDetachedSpan(""+B[H][1]).innerCapture(t.flightNumber,1),g=n.getDetachedSpan(""+B[H][1]).innerCapture(t.flightNumber,2),h=n.getDetachedSpan(""+B[H][1]).innerCapture(t.operatedBy,1),ASSERT(T,g,v,f,x,N)&&(h.getLength()||(h="KLM"),j.push({airlineCode:T,airlineName:h,flightNumber:g,departureAirport:f,departureTime:v,arrivalAirport:N,arrivalTime:x,passengers:_}))));for(var J=[],H=0;H<j.length;H++)for(var q=j[H],G=Object.keys(q.passengers),Q=0;Q<G.length;Q++){var V=q.passengers[G[Q]],W={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:q.airlineName,airlineCode:q.airlineCode,flightNumber:q.flightNumber,departureAirportFuzzy:q.departureAirport,departureAirportCode:q.departureCode,departureTime:q.departureTime,arrivalAirportFuzzy:q.arrivalAirport,arrivalAirportCode:q.arrivalCode,arrivalTime:q.arrivalTime},underName:{"@type":"http://schema.org/Person",name:V.name,email:V.email},checkinUrl:p,reservationId:i,reservationStatus:"http://schema.org/ReservationConfirmed",totalPrice:V.totalPrice,priceCurrency:V.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:V.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:V.seats[q.flightNumber],seatingType:V.seatingType[q.flightNumber]}}};valid(V.membershipNumber,V.programName)&&(W.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:V.membershipNumber,programName:V.programName}),J.push(W)}for(var H=0;H<O.length;H++)for(var q=O[H],G=Object.keys(q.passengers),Q=0;Q<G.length;Q++){var V=q.passengers[G[Q]];J.push({"@context":"http://schema.org","@type":"http://schema.org/TrainReservation",reservationFor:{"@type":"http://schema.org/TrainTrip",departurePlatform:q.departurePlatform,departureStation:{"@type":"http://schema.org/TrainStation",name:q.departureName,telephone:q.departureTelephone,url:q.departureUrl,address:q.departureAddress},departureTime:q.departureTime,arrivalPlatform:q.arrivalPlatform,arrivalStation:{"@type":"http://schema.org/TrainStation",name:q.arrivalName,telephone:q.arrivalTelephone,url:q.arrivalUrl,address:q.arrivalAddress},arrivalTime:q.arrivalTime,provider:{"@type":"http://schema.org/Organization",name:q.provider},trainName:q.trainName,trainNumber:q.trainNumber}})}if(J.length)return J}}).call();