// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,n){var a=Scanner.fromMessage(e);a.setLocale(t);var r,i,p,g,s,o,c,l,x,d,u,C,m,h,S,T,f,y,v,D,R,b,E;if(n.confirm.test(e.subject)||n.street.test(e.plain)){p=a.getSpan().innerCapture(n.reservationId,1),r=(""+a.getSpan().innerCapture(n.guestName,1)).trim();var A=a.getSpan().nextRegExp(n.bookingDetails).next(n.pickupDetails).parentAnyTag("table").tagContents();R=A.innerDate(),D=A.innerPhoneNumber(),n.street.test(e.html)&&(b=a.getSpan().nextRegExp(n.pickupDetails).nextRegExp(n.street).nextAnyTag("td").tagContents().trim(),b=b.split(/\//).join(" "),E=a.getSpan().nextRegExp(n.pickupDetails).nextRegExp(n.city).nextAnyTag("td").tagContents().trim(),v=a.getDetachedSpan(b+" "+E).innerAddress(),v.exists()||(v=b+" "+E)),v&&0!==(""+v).length||(v=A.innerAddress()),v&&0!==(""+v).length||(A=""+A,A=A.substr(0,A.indexOf(""+D)),A=A.split("\n"),A=""+A.slice(2).join("\n"),v=A);var k=a.getSpan().nextRegExp(n.bookingDetails).next(n.dropoffDetails).parentAnyTag("table").tagContents();f=k.innerDate(),T=k.innerPhoneNumber(),n.street.test(e.html)&&(b=a.getSpan().nextRegExp(n.dropoffDetails).nextRegExp(n.street).nextAnyTag("td").tagContents().trim(),b=b.split(/\//).join(" "),E=a.getSpan().nextRegExp(n.dropoffDetails).nextRegExp(n.city).nextAnyTag("td").tagContents().trim(),S=a.getDetachedSpan(b+" "+E).innerAddress(),S.exists()||(S=b+" "+E)),S&&0!==(""+S).length||(S=k.innerAddress()),S&&0!==(""+S).length||(k=""+k,k=k.substr(0,k.indexOf(""+T)),k=k.split("\n"),k=""+k.slice(2).join("\n"),S=k),d=a.getSpan().nextText(n.car).nextTag("table4").nextTag("td4").nextTag("td4").nextTag("td4").nextTag("td4").tagContents(),0===(""+d).length&&(d=a.getSpan().nextText(n.car).nextTag("table5").nextTag("td5").tagContents().trim()),0===(""+d).length&&(d=a.getSpan().next(n.carLabel).parentAnyTag("td").tagContents().trim()),l=a.getSpan().nextText(n.totalPrice).nextTag("td5").tagContents().innerCapture(/([\d,.]+)/,1),x=a.getSpan().nextText(n.totalPrice).nextTag("td5").tagContents().innerCapture(/([^\d,.]+)/,1),l.exists()||(l=a.getSpan().nextText(n.totalPrice).nextTag("td4").tagContents().innerCapture(/([\d,.]+)/,1),x=a.getSpan().nextText(n.totalPrice).nextTag("td4").tagContents().innerCapture(/([^\d,.]+)/,1)),c=o=a.getSpan().nextText(n.modifyUrl).parentTag("td3").innerLink(),g=a.getSpan().next(n.cancelled).exists()?"Cancelled":"Confirmed"}else{if(!n.cancel.test(e.subject))return CONTINUE;p=a.getSpan().innerCapture(n.cancellationId,1),r=a.getSpan().innerCapture(n.guestNameCancel,1),i=a.getSpan().innerCapture(n.guestEmailCancel,1);var A=""+a.getSpan().innerCapture(n.pickUp,1);A=A.split("\n"),R=""+A[0],v=A[1]+"\n"+A[2],D=""+A[3];var m=""+a.getSpan().innerCapture(n.pickUp,1);m=m.split("\n"),R=getFuzzyDate(a.getDetachedSpan(""+m[0])),v=m[1]+"\n"+m[2],D=""+m[3];var m=""+a.getSpan().innerCapture(n.dropOff,1);m=m.split("\n"),f=getFuzzyDate(a.getDetachedSpan(""+m[0])),S=m[1]+"\n"+m[2],T=""+m[3],d=a.getSpan().innerCapture(n.carCancel,1);var P=a.getSpan().innerCapture(n.priceCancel,1);l=P.innerCapture(/([\d,.]+)/,1),x=P.innerCapture(/([^\d,.]+)/,1),g="Cancelled"}if(ASSERT(p,r,v,R))return[{"@context":"http://schema.org","@type":"http://schema.org/RentalCarReservation",totalPrice:l,priceCurrency:x,reservationId:p,reservationStatus:"http://schema.org/Reservation"+(g||"Confirmed"),checkinUrl:s,modifyReservationUrl:o,cancelReservationUrl:c,underName:{"@type":"http://schema.org/Person",name:r,email:i},provider:{"@type":"http://schema.org/Organization",name:"Budget"},reservationFor:{"@type":"http://schema.org/Car",brand:{"@type":"http://schema.org/Organization",name:d},license:u,color:C},pickupTime:R,pickupLocation:{"@type":"http://schema.org/Place",name:y,telephone:D,address:v},dropoffTime:f,dropoffLocation:{"@type":"http://schema.org/Place",name:h,telephone:T,address:S}}]}}).call();