// Copyright 2014 Apple Inc.  All Rights Reserved.
new ReverseTemplateList([new ReverseTemplate("tickets.com-en",function(e){return/^Thank You for your order\./.test(e.subject)},function(e){if(!/^Thank You for your order\./.test(e.subject))return CONTINUE;var t=Scanner.fromMessage(e);t.setLocale("en_US");var a,n,r,s,o,i,c,l,u=[];a=t.getSpan().innerCapture(/\bDeliver To:\s+(.*)\s/,1),n=t.getSpan().innerCapture(/\bYour confirmation number is: (.*)\s/,1),details=t.getSpan().nextText("The tickets you have purchased").nextAnyTag("table"),c=getFuzzyDate(details),i=details.firstDate().parentAnyTag("td").tagContents().innerCapture(/^(.*)\s/,1),l=i.nextTag("td1").tagContents();var p=t.getSpan().innerCapture(/\bTotal: [\D]*([\d,.]+)\s/,1),g={};if(t.getSpan().nextText("Section").nextText("Row").nextText("Seat").exists()){details=t.getSpan().nextText("Section").nextText("Row").nextText("Seat").parentAnyTag("table"),o=details.getTagNumber(),details=details.allInnerTags("tr"+o).map(function(e){return e.allInnerTags("td"+o).map(function(e){return""+e.tagContents()})}).filter(function(e){return e.length>=3});for(var m=1;m<details.length;m++)s=details[m][0],r=details[m][1],seat=details[m][2],g[s]||(g[s]={}),g[s][r]||(g[s][r]=[]),g[s][r].push(seat)}s=Object.keys(g);for(var m=0;m<s.length;m++){r=Object.keys(g[s[m]]);for(var h=0;h<r.length;h++)ASSERT(a,p,n,i,l,c)&&u.push({name:a,totalPrice:p,ticketNumber:n,seatSection:s[m],seatRow:r[h],seatNumber:g[s[m]][r[h]].join(", "),eventName:i,place:l,startDate:c})}if(u.length){for(var d,T=[],m=0;m<u.length;m++)d=u[m],T.push({"@context":"http://schema.org","@type":"http://schema.org/EventReservation",name:d.name,totalPrice:d.totalPrice,priceCurrency:d.priceCurrency,reservedTicket:{"@type":"http://schema.org/Ticket",ticketNumber:d.ticketNumber,ticketToken:d.ticketDownloadUrl,ticketedSeat:{"@type":"http://schema.org/Seat",seatNumber:d.seatNumber,seatRow:d.seatRow,seatSection:d.seatSection}},reservationFor:{"@type":"http://schema.org/Event",eventStatus:"http://schema.org/EventConfirmed",name:d.eventName,url:d.eventUrl,startDate:d.startDate,endDate:d.endDate,location:{"@type":"http://schema.org/Place",name:d.place,telephone:d.phoneNumber,address:d.address}}});return T}},"0/1/2/3/4/5/1248/1248/1338","SG91ee99e2")]);