// Copyright 2014 Apple Inc.  All Rights Reserved.
(function(){return function(e,t){var n=Scanner.fromMessage(e);n.setLocale("en_US");for(var r=n.getSpan(),a=[],o=[],c=[],i=e.plain.split(/Check In/i).length-1,s=(e.plain.slice(),0);s<i;s++)r=r.next(/(^Hotel[\s\S]*?)(?:^Flight [A-Z]|^Hotel$|^Car Rental$|^Plan)/gm),c.push(""+r);return c.forEach(function(e){var r,a,c,i,s,h,l,m,u,d,p,g,v,f,k,D,T=n.getDetachedSpan(e),I=e.slice(),e=e.split("\n");i=/Confirmation #.*\n.*\n(.*)\n/.exec(I),i&&2===i.length&&(i=i[1]),m=T.nextDate(),p=T.nextDate().nextDate(),v=e[4],k=T.nextAddress(),""+k==""&&(k=e[6].split("<")[0]),f=e[8],r=/Rate.*\n.*\n([\d,.]+)\s*([A-Z]{2,3})/.exec(I),r&&3===r.length&&(a=r[1],c=r[2]),o.push({totalPrice:a,priceCurrency:c,reservationId:i,reservationStatus:s,checkInTime:h,checkInDate:l,checkInDateTime:m,checkOutTime:u,checkOutDate:d,checkOutDateTime:p,hotelUrl:g,hotelName:v,hotelPhone:f,hotelAddress:k,modifyReservationUrl:D,underPersonName:t.underName})}),o.forEach(function(e){ASSERT(e.checkInDateTime,e.checkOutDateTime,e.hotelName,e.hotelAddress),a.push({"@context":"http://schema.org","@type":"http://schema.org/LodgingReservation",underName:{"@type":"http://schema.org/Person",name:e.underPersonName},totalPrice:e.totalPrice,priceCurrency:e.priceCurrency,checkinTime:e.checkInDateTime,checkoutTime:e.checkOutDateTime,modifyReservationUrl:e.modifyReservationUrl,reservationStatus:"http://schema.org/Reservation"+(e.reservationStatus||"Confirmed"),reservationId:e.reservationId,reservationFor:{"@type":"http://schema.org/LodgingBusiness",name:e.hotelName,url:e.hotelUrl,telephone:e.hotelPhone,address:e.hotelAddress}})}),a.length>=1?a:CONTINUE}}).call();