// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,n,t){function r(e){return e=e.replace(/[^\d\sa-zA-z:]+/g," ").replace(/\s+/g," ").replace(/^(\d+)\s(\d+)\s/,"$1/$2/"),e=getFuzzyDate(a.getDetachedSpan(e))}var a=Scanner.fromMessage(e);a.setLocale(n);var i,c,p,o,u,s,l,C,m,g,d,S,h,f;if(!t.emailTitelConfirmation.test(e.subject)&&!t.emailTitelCancelConfirmation.test(e.subject))return CONTINUE;u=a.getSpan().innerCapture(t.reservationId,1),i=a.getSpan().innerCapture(t.guestName,1),c=a.getSpan().innerCapture(t.guestEmail,1),l=""+a.getSpan().innerCapture(t.checkinDate,1),C=""+a.getSpan().innerCapture(t.checkoutDate,1),l=r(l),C=r(C),m=f=h=a.getSpan().innerCapture(t.modifyUrl,1).innerLink();var v=a.getSpan().innerCapture(t.price,1);if(p=v.innerCapture(/([\d,.]+)/,1),o=v.innerCapture(/([^\d,.]+)/,1).trim(),g=a.getSpan().innerCapture(t.hotelName,1),d=a.getSpan().innerCapture(t.hotelPhone,1),S=""+a.getSpan().innerCapture(t.hotelAddress,1),t.emailTitelConfirmation.test(e.subject)){if(!ASSERT(i,u,l,C,S))return CONTINUE;s="Confirmed"}if(t.emailTitelCancelConfirmation.test(e.subject)){i=a.getSpan().innerCapture(t.cancelGuestName,1),u=a.getSpan().innerCapture(t.cancelGuestName,2),g=a.getSpan().innerCapture(t.cancelHotelName,1);var v=a.getSpan().innerCapture(t.cancelPrice,1);if(p=v.innerCapture(/([\d,.]+)/,1),o=v.innerCapture(/([^\d,.]+)/,1).trim(),l=a.getSpan().innerCapture(t.cancelCheckinDate,1).innerDate(),!ASSERT(i,u,l,g))return CONTINUE;s="Cancelled"}return[{"@context":"http://schema.org","@type":"http://schema.org/LodgingReservation",underName:{"@type":"http://schema.org/Person",name:i,email:c},totalPrice:p,priceCurrency:o,checkinTime:l,checkoutTime:C,modifyReservationUrl:h,cancelReservationUrl:f,reservationStatus:"http://schema.org/Reservation"+(s||"Confirmed"),reservationId:u,reservationFor:{"@type":"http://schema.org/LodgingBusiness",name:g,url:m,telephone:d,address:S}}]}}).call();