// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t,n){var r=Scanner.fromMessage(e);r.setLocale(t);var a,i,o,c,s,u,l,m,p,T,g,d,h,C;if(!n.emailTitelConfirmation.test(e.subject)&&!n.emailTitelCancelConfirmation.test(e.subject))return CONTINUE;s=r.getSpan().innerCapture(n.reservationId,1);var S=r.getSpan().nextText(n.price).nextAnyTag("td").innerCapture(/($<price>[\d,.]+)\s+($<currency>[A-Z]{3})/);o=S?S.$price:null,c=S?S.$currency:null,a=r.getSpan().innerCapture(n.guestName,1),l=r.getSpan().nextText(n.checkInDate).nextDate(),m=r.getSpan().nextText(n.checkOutDate).nextDate();var f=r.getSpan().nextText("BEST WESTERN").parentAnyTag("td").tagContents().innerCapture(/($<name>BEST WESTERN .+)\n($<address>[^]+)\nPhone: ($<phone>.*)/);if(f&&(T=f.$name,d=f.$address,g=f.$phone),n.emailTitelConfirmation.test(e.subject)){if(!ASSERT(a,s,l,m,d))return CONTINUE;u="Confirmed"}if(n.emailTitelCancelConfirmation.test(e.subject)){if(!ASSERT(a,s,l,m,d))return CONTINUE;u="Cancelled"}return[{"@context":"http://schema.org","@type":"http://schema.org/LodgingReservation",underName:{"@type":"http://schema.org/Person",name:a,email:i},totalPrice:o,priceCurrency:c,checkinTime:l,checkoutTime:m,modifyReservationUrl:h,cancelReservationUrl:C,reservationStatus:"http://schema.org/Reservation"+(u||"Confirmed"),reservationId:s,reservationFor:{"@type":"http://schema.org/LodgingBusiness",name:T,url:p,telephone:g,address:d}}]}}).call();