// Copyright 2014 Apple Inc.  All Rights Reserved.
new ReverseTemplateList([new ReverseTemplate("alaskaair.com-cancellation-en",function(e){return/^Canceled Reservation: Your .*? Trip/.test(e.subject)},function(e){if(int(e.epoch)<1356998400)return CONTINUE;var r=Scanner.fromMessage(e);r.setLocale("en_US");var t,a,i,n,o,p,s,m,u,l,d,c,g,h,v=[],C={};if(/^Canceled Reservation:/.test(e.subject)){var N=/\s($<name>.*)\s+-\s+($<ticketNumber>\d+)/;for(u=r.getSpan().nextText("TRAVELERS - TICKET NUMBERS").withEnd(r.getSpan().nextText("Confirmation Code").getStart());u.innerCapture(N);){n=u.innerCapture(N),o=n.$name;var b=n.$ticketNumber;valid(o,b)&&(C[""+o]={name:o,ticketNumber:b,seats:{},seatingType:{}}),u=u.withStart(n[0].getEnd())}t=r.getSpan().innerCapture(/Confirmation Code: (\w+)/,1);var S=concatRegExp(/($<currentDate>.*)\s+/,/($<airlineName>.*) #($<flightNumber>\d+)\s+/,/Depart: .* \(($<departureCode>[A-Z]{3})\) ($<departureTime>at .*)\s+/,/Arrive: .* \(($<arrivalCode>[A-Z]{3})\)/);u=r.getSpan().nextText("ITINERARY").withEnd(r.getSpan().nextText("FARE SUMMARY").getStart());var T=r.getSpan().innerCapture(/\bFARE SUMMARY \((\w+)\)\s+/,1);for(m=r.getSpan().innerCapture(/\bTotal: .*([\d,.]+)/,1);u.innerCapture(S);)n=u.innerCapture(S),p=n.$currentDate,l=n.$airlineName,s=n.$flightNumber,c=n.$departureCode,d=getFuzzyDate(n[0]),h=n.$arrivalCode,g=n.$currentDate,ASSERT(l,s,c,d,h,g)&&v.push({airlineName:l,flightNumber:s,totalPrice:m,priceCurrency:T,reservationId:t,reservationStatus:"Cancelled",departureCode:c,departureTime:d,arrivalCode:h,arrivalTime:g,passengers:C}),u=u.withStart(n[0].getEnd())}for(var f=[],y=0;y<v.length;y++)for(var A=v[y],R=Object.keys(A.passengers),$=0;$<R.length;$++){var E=A.passengers[R[$]];/alaska/i.test(A.airlineName)&&(A.airlineCode="AS"),i={"@context":"http://schema.org","@type":"http://schema.org/FlightReservation",reservationFor:{"@type":"http://apple.com/FuzzyFlight",airlineName:A.airlineName,airlineCode:A.airlineCode,flightNumber:A.flightNumber,departureAirportFuzzy:A.departureAirport,departureAirportCode:A.departureCode,departureTime:A.departureTime,arrivalAirportFuzzy:A.arrivalAirport,arrivalAirportCode:A.arrivalCode,arrivalTime:A.arrivalTime},underName:{"@type":"http://schema.org/Person",name:E.name},checkinUrl:a,reservationStatus:"http://schema.org/Reservation"+(A.reservationStatus||"Confirmed"),reservationId:valid(A.reservationId)?A.reservationId:t,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:E.ticketNumber,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:E.seats[A.flightNumber],seatingType:E.seatingType[A.flightNumber]}},totalPrice:E.totalPrice,priceCurrency:E.priceCurrency},not(E.membershipNumber)||(i.programMembershipUsed={"@type":"http://schema.org/ProgramMembership",membershipNumber:E.membershipNumber,programName:E.programName}),f.push(i)}return f.length?f:void 0},"0/1/2/3/4/5/240/333/334","SGf0a3316e")]);