Plugin Directory

Changeset 2230414


Ignore:
Timestamp:
01/20/2020 03:19:37 PM (6 years ago)
Author:
bookwize
Message:

ibe scripts update

Location:
bookwize-integrated-cinnamon
Files:
189 added
5 edited

Legend:

Unmodified
Added
Removed
  • bookwize-integrated-cinnamon/trunk/README.txt

    r2229183 r2230414  
    120120= 2.1.17 =
    121121bug fix
     122
     123= 2.1.18 =
     124booking engine scripts version update
  • bookwize-integrated-cinnamon/trunk/bookwize-integrated-cinnamon.php

    r2229183 r2230414  
    1717 * Plugin URI:        https://www.bookwize.com/
    1818 * Description:       Integarted Bookwize Plugin (Cinnamon)
    19  * Version:           2.1.17
     19 * Version:           2.1.18
    2020 * Author:            Bookwize
    2121 * Author URI:        https://www.bookwize.com/
  • bookwize-integrated-cinnamon/trunk/includes/class-bookwize-integrated-cinnamon.php

    r2229183 r2230414  
    6767
    6868        $this->bookwize = 'bookwize-integrated';
    69         $this->version  = '2.1.17';
     69        $this->version  = '2.1.18';
    7070
    7171        $this->load_dependencies();
  • bookwize-integrated-cinnamon/trunk/public/class-bookwize-public.php

    r2229183 r2230414  
    8787        }
    8888        add_action('bookwize_enqueue_scripts_and_styles',[$this, 'enqueue_scripts_and_styles']);
     89        add_action('wp_head', [$this, 'bw_preload_scripts']);
    8990    }
    9091
     
    173174        $this->config();
    174175
    175 
    176         wp_register_script($this->bookwize . '-vendors', plugin_dir_url(__FILE__) . 'js/vendors-v3.min.js', [], "1.4", true);       
     176        //wp_register_script($this->bookwize . '-vendors', 'https://bookwizecdn.azureedge.net/vendors/vendors-v3-1.4.min.js', [], false, true);
     177        wp_register_script($this->bookwize . '-vendors', plugin_dir_url(__FILE__) . 'js/vendors-v3.min.js', [], "1.4", false);               
    177178        wp_add_inline_script($this->bookwize . '-vendors', 'var IBEConfig =' . json_encode($this->settings) );
    178179
    179         wp_register_script($this->bookwize . '-app', plugin_dir_url(__FILE__) . 'js/ibe.min.js', [$this->bookwize . '-vendors'], "5.3.13", true);     
    180    
     180        //wp_register_script($this->bookwize . '-app', 'https://bookwizecdn.azureedge.net/app/ibe-5.3.15.min.js', [$this->bookwize . '-vendors'], false, true);
     181        wp_register_script($this->bookwize . '-app', plugin_dir_url(__FILE__) . 'js/ibe.min.js', [$this->bookwize . '-vendors'], "5.3.15", false);                 
    181182       
    182183        wp_register_script($this->bookwize . '-site', plugin_dir_url(__FILE__) . 'js/bookwize-public.min.js', [
     
    205206        $this->enqueue_registered_styles();
    206207        $this->enqueue_registered_scripts();
     208    }
     209
     210    public function bw_preload_scripts(){
     211        if (bw_is_booking_page()) {
     212            echo '<link rel="preload" href="'.plugin_dir_url(__FILE__) . 'js/vendors-v3.min.js" as="script" />';
     213            echo '<link rel="preload" href="'.plugin_dir_url(__FILE__) . 'js/ibe.min.js" as="script" />';
     214        }
    207215    }
    208216
  • bookwize-integrated-cinnamon/trunk/public/js/ibe.min.js

    r2227785 r2230414  
    1 function minProp(n,t){var i=n.map(function(n){return ko.unwrap(n[t])});return Math.min.apply(Math,i)}function isDateActive(n,t){var i=IBE.Utils.dateIsoFormat(t),r=ko.utils.unwrapObservable(n.hotel);if(!r.availability.hasOwnProperty(i))return!1;switch(r.availability[i]){case-1:return!1;case 0:return IBE.Config.displayResults[displayNotAvailable]!==0;default:return!0}}function getLanguage(n){var t=navigator.language||navigator.userLanguage;return lang=$.datepick.regionalOptions.hasOwnProperty(t)?t:$.datepick.regionalOptions.hasOwnProperty(n)?n:IBE.Config.lang}function localizeDatepicker(n,t,i){t.length>2&&t!=="en-US"&&(t=t.substr(0,2));n.datepick("option").lang!==t&&$.datepick.regionalOptions.hasOwnProperty(t)&&(i=="cinamon"?($.datepick.regionalOptions[t].prevText='<i class="material-icons">&#xE314;<\/i>',$.datepick.regionalOptions[t].nextText='<i class="material-icons">&#xE315;<\/i>'):($.datepick.regionalOptions[t].prevText='<i class="fa fa-chevron-left" />',$.datepick.regionalOptions[t].nextText='<i class="fa fa-chevron-right" />'),n.datepick("option",$.datepick.regionalOptions[t]),n.datepick("option",{lang:t}))}function sameRule(n){for(var i,r=[],u={},t=0,f=n.length;t<f;t++)(i=JSON.stringify(n[t].ruleType),u[i])||(r.push(n[t]),u[i]=!0);return r}var IBE={Models:{},ViewModels:{},Data:{HotelInfo:[],RoomInfo:null,RatePlanInfo:[],ExchangeRates:null,Countries:null,HotelRates:{},RoomAvailability:{}},Translations:{},Utils:{},Config:{},Templates:{}},Cache,MD5,selectedDatepicker,displayNotAvailable,pauseOnSelectEvent,pauseMultiple;IBE.Config={useCache:!0,defaultCache:"sessionStorage",cacheLevel:1,maxStay:90,minStay:1,lang:"en-US",languages:[],localizationUrl:"https://app.bookwize.com/api/v1.3/system/resources/?apikey=",currency:"EUR",googleAnalyticsId:null,googleAnalyticsEnabled:!0,insightParticipantId:"",rsId:0,roomBackgroundImage:"",ibeShowCVC:!0,ibeShowNotes:!0,ibeEnforceMLOS:!1,ibeFlightInfo:!1,ibeArrivalTime:!1,ibeTimePolicy:!1,groupText:"",closeDatesClickable:!0,boardType:{Unknown:0,RoomRate:1,BedAndBreakfast:2,HalfBoard:4,FullBoard:8,AllInclusive:16},guestType:{Adult:"Adult",Children:"Children",Infant:"Infant"},userCookieAcceptance:!1,imageTypes:{offers:{imageTypeKey:"SpecialOffer",imageTransformationKey:"big"},rooms:{imageTypeKey:"Rooms_PopUp",imageTransformationKey:"bigger"},hotel:{imageTypeKey:"MainPhoto",imageTransformationKey:"original"}},supplementPricingType:{PerReservation:0,PerRoom:1,PerGuest:2},supplementTimePricingUnit:{Daily:0,Hourly:1,OneOff:2},supplementTimePricingType:{Stay:0,CheckIn:1,CheckOut:2},roomAvailability:{Available:1,NoAvailability:0,AllotmentOrDatesMissing:-1,HotelIsClosed:-2,AvailabilityRestriction:-3,CannotHost:-4,NoPrices:-5,UponRequest:-6},hotelAvailability:{AvailableOnline:1,AvailableOnRequest:2,HotelIsClosed:3,CannotHost:4,Unknown:0},idDocumentType:{Unknown:0,IdentityCard:1,Passport:2,DrivingLicense:3},gender:{Unknown:0,Male:1,Female:2},titles:{Unknown:0,Mr:1,Mrs:2,Miss:3,Ms:4,Dr:5},sortRoomsBy:["availability.desc","price.asc"],displayResults:{Hide:0,Show:1,OnRequest:2,Online:3},reservationStatus:{UnsavedReservation:0,NewReservationPaymentPending:2,CancelledReservationPaymentExpired:9,ConfirmedReservation:1,NewRequest:3,AcceptedRequest:4,DeclinedRequest:5,CancelledReservation:6,CancelledRequest:7,AlternativeProposed:8,HoldRooms:10,AcceptedRequestForced:11},paymentGatewayType:{None:0,JccRedirect:1,Braintree:2,AlphaBankRedirect:3,PayPal:4,Omise:5,AuthorizeNet:6,Stripe:13},ajaxConfig:{async:!0,cache:!0,dataType:"json",contentType:"application/json",beforeSend:function(n){n.setRequestHeader("Accept-Language","en-US");n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())}},sojernConversionId:"",sojernProductId:"",sojernSearchId:"",sojernCartId:"",tripteaseHotelId:"",tripteaseClientKey:"",tripteaseWidgetClosed:"",ibeShowBoard:!0};IBE.Config.defaultLang=IBE.Config.lang;IBE.Config.defaultLocalizationUrl=IBE.Config.localizationUrl;IBE.Config=$.extend(IBE.Config,IBEConfig);IBE.Config.defaultLocalizationUrl=IBE.Config.baseUrl+IBE.Config.defaultLocalizationUrl;IBE.Config.localizationUrl.substring(0,4)!=="http"&&(IBE.Config.localizationUrl=IBE.Config.baseUrl+IBE.Config.localizationUrl);IBE.Config.ajaxConfig=$.extend(IBE.Config.ajaxConfig,{crossDomain:!0,cache:IBE.Config.useCache,beforeSend:function(n){n.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")}});$.support.cors=!0;$.ajaxSetup(IBE.Config.ajaxConfig),function(n){n.whenAll=function(t){if(t&&t.length){var i=n.Deferred(),e=t.length,r=!1,u,f;return f=function(){--e||i[r?"reject":"resolve"]()},u=function(){r=!0},t.forEach(function(n){n.fail(u).always(f)}),i}return n.Deferred().resolve()}}(jQuery);String.prototype.format||(String.prototype.format=function(){var n=arguments,t=function(t,i){return i in n?n[i]:t};return this.replace(/\{(\d+)\}/g,t)});Cache={prefix:"IBE_",memory:[],supportLocalStorage:function(){if(!IBE.Config.useCache)return!1;try{return typeof Storage!="undefined"?!0:!1}catch(n){return!1}},write:function(n,t,i,r){n=Cache.prefix+n;typeof i=="undefined"&&(i=60);var f=i*6e4,u={value:JSON.stringify(t),timestamp:(new Date).getTime()+f};if(!Cache.supportLocalStorage())return Cache.memory[n]=JSON.stringify(u),t;typeof r=="undefined"&&(r=IBE.Config.defaultCache);try{r.toLowerCase()==="localstorage"?localStorage.setItem(n,JSON.stringify(u)):sessionStorage.setItem(n,JSON.stringify(u))}catch(e){}return t},read:function(n,t){n=Cache.prefix+n;var i;typeof t=="undefined"&&(t=Cache.supportLocalStorage()?IBE.Config.defaultCache||"sessionStorage":"memory");switch(t.toLowerCase()){case"localstorage":i=JSON.parse(localStorage.getItem(n));break;case"sessionstorage":i=JSON.parse(sessionStorage.getItem(n));break;default:Cache.memory[n]!==undefined&&(i=JSON.parse(Cache.memory[n]))}return typeof i=="undefined"||i==null||!i.value?!1:(new Date).getTime()<i.timestamp&&JSON.parse(i.value)},clear:function(n){if(typeof n!="undefined"){n=Cache.prefix+n;var t=Cache.memory.indexOf(n);t>=0&&Cache.memory.splice(t,1);localStorage.removeItem(n);sessionStorage.removeItem(n)}else localStorage.clear(),sessionStorage.clear(),Cache.memory.length=0}};MD5=function(n){function a(n,t){return n<<t|n>>>32-t}function o(n,t){var f,e,r,u,i;return(r=n&2147483648,u=t&2147483648,f=n&1073741824,e=t&1073741824,i=(n&1073741823)+(t&1073741823),f&e)?i^2147483648^r^u:f|e?i&1073741824?i^3221225472^r^u:i^1073741824^r^u:i^r^u}function yt(n,t,i){return n&t|~n&i}function pt(n,t,i){return n&i|t&~i}function wt(n,t,i){return n^t^i}function bt(n,t,i){return t^(n|~i)}function s(n,t,i,r,u,f,e){return n=o(n,o(o(yt(t,i,r),u),e)),o(a(n,f),t)}function h(n,t,i,r,u,f,e){return n=o(n,o(o(pt(t,i,r),u),e)),o(a(n,f),t)}function c(n,t,i,r,u,f,e){return n=o(n,o(o(wt(t,i,r),u),e)),o(a(n,f),t)}function l(n,t,i,r,u,f,e){return n=o(n,o(o(bt(t,i,r),u),e)),o(a(n,f),t)}function kt(n){for(var r,u=n.length,o=u+8,s=(o-o%64)/64,e=(s+1)*16,i=Array(e-1),f=0,t=0;t<u;)r=(t-t%4)/4,f=t%4*8,i[r]=i[r]|n.charCodeAt(t)<<f,t++;return r=(t-t%4)/4,f=t%4*8,i[r]=i[r]|128<<f,i[e-2]=u<<3,i[e-1]=u>>>29,i}function v(n){for(var i="",r="",u,t=0;t<=3;t++)u=n>>>t*8&255,r="0"+u.toString(16),i=i+r.substr(r.length-2,2);return i}function dt(n){var i,r,t;for(n=n.replace(/\r\n/g,"\n"),i="",r=0;r<n.length;r++)t=n.charCodeAt(r),t<128?i+=String.fromCharCode(t):t>127&&t<2048?(i+=String.fromCharCode(t>>6|192),i+=String.fromCharCode(t&63|128)):(i+=String.fromCharCode(t>>12|224),i+=String.fromCharCode(t>>6&63|128),i+=String.fromCharCode(t&63|128));return i}var e=Array(),f,ht,ct,lt,at,t,i,r,u,y=7,p=12,w=17,b=22,k=5,d=9,g=14,nt=20,tt=4,it=11,rt=16,ut=23,ft=6,et=10,ot=15,st=21,vt;for(n=dt(n),e=kt(n),t=1732584193,i=4023233417,r=2562383102,u=271733878,f=0;f<e.length;f+=16)ht=t,ct=i,lt=r,at=u,t=s(t,i,r,u,e[f+0],y,3614090360),u=s(u,t,i,r,e[f+1],p,3905402710),r=s(r,u,t,i,e[f+2],w,606105819),i=s(i,r,u,t,e[f+3],b,3250441966),t=s(t,i,r,u,e[f+4],y,4118548399),u=s(u,t,i,r,e[f+5],p,1200080426),r=s(r,u,t,i,e[f+6],w,2821735955),i=s(i,r,u,t,e[f+7],b,4249261313),t=s(t,i,r,u,e[f+8],y,1770035416),u=s(u,t,i,r,e[f+9],p,2336552879),r=s(r,u,t,i,e[f+10],w,4294925233),i=s(i,r,u,t,e[f+11],b,2304563134),t=s(t,i,r,u,e[f+12],y,1804603682),u=s(u,t,i,r,e[f+13],p,4254626195),r=s(r,u,t,i,e[f+14],w,2792965006),i=s(i,r,u,t,e[f+15],b,1236535329),t=h(t,i,r,u,e[f+1],k,4129170786),u=h(u,t,i,r,e[f+6],d,3225465664),r=h(r,u,t,i,e[f+11],g,643717713),i=h(i,r,u,t,e[f+0],nt,3921069994),t=h(t,i,r,u,e[f+5],k,3593408605),u=h(u,t,i,r,e[f+10],d,38016083),r=h(r,u,t,i,e[f+15],g,3634488961),i=h(i,r,u,t,e[f+4],nt,3889429448),t=h(t,i,r,u,e[f+9],k,568446438),u=h(u,t,i,r,e[f+14],d,3275163606),r=h(r,u,t,i,e[f+3],g,4107603335),i=h(i,r,u,t,e[f+8],nt,1163531501),t=h(t,i,r,u,e[f+13],k,2850285829),u=h(u,t,i,r,e[f+2],d,4243563512),r=h(r,u,t,i,e[f+7],g,1735328473),i=h(i,r,u,t,e[f+12],nt,2368359562),t=c(t,i,r,u,e[f+5],tt,4294588738),u=c(u,t,i,r,e[f+8],it,2272392833),r=c(r,u,t,i,e[f+11],rt,1839030562),i=c(i,r,u,t,e[f+14],ut,4259657740),t=c(t,i,r,u,e[f+1],tt,2763975236),u=c(u,t,i,r,e[f+4],it,1272893353),r=c(r,u,t,i,e[f+7],rt,4139469664),i=c(i,r,u,t,e[f+10],ut,3200236656),t=c(t,i,r,u,e[f+13],tt,681279174),u=c(u,t,i,r,e[f+0],it,3936430074),r=c(r,u,t,i,e[f+3],rt,3572445317),i=c(i,r,u,t,e[f+6],ut,76029189),t=c(t,i,r,u,e[f+9],tt,3654602809),u=c(u,t,i,r,e[f+12],it,3873151461),r=c(r,u,t,i,e[f+15],rt,530742520),i=c(i,r,u,t,e[f+2],ut,3299628645),t=l(t,i,r,u,e[f+0],ft,4096336452),u=l(u,t,i,r,e[f+7],et,1126891415),r=l(r,u,t,i,e[f+14],ot,2878612391),i=l(i,r,u,t,e[f+5],st,4237533241),t=l(t,i,r,u,e[f+12],ft,1700485571),u=l(u,t,i,r,e[f+3],et,2399980690),r=l(r,u,t,i,e[f+10],ot,4293915773),i=l(i,r,u,t,e[f+1],st,2240044497),t=l(t,i,r,u,e[f+8],ft,1873313359),u=l(u,t,i,r,e[f+15],et,4264355552),r=l(r,u,t,i,e[f+6],ot,2734768916),i=l(i,r,u,t,e[f+13],st,1309151649),t=l(t,i,r,u,e[f+4],ft,4149444226),u=l(u,t,i,r,e[f+11],et,3174756917),r=l(r,u,t,i,e[f+2],ot,718787259),i=l(i,r,u,t,e[f+9],st,3951481745),t=o(t,ht),i=o(i,ct),r=o(r,lt),u=o(u,at);return vt=v(t)+v(i)+v(r)+v(u),vt.toLowerCase()};jQuery.base64=function(){function t(t,i){var r=n.indexOf(t.charAt(i));if(r===-1)throw"Cannot decode base64";return r}function u(n){var o=0,i,u,f=n.length,e=[];if(n=String(n),f===0)return n;if(f%4!=0)throw"Cannot decode base64";for(n.charAt(f-1)===r&&(o=1,n.charAt(f-2)===r&&(o=2),f-=4),i=0;i<f;i+=4)u=t(n,i)<<18|t(n,i+1)<<12|t(n,i+2)<<6|t(n,i+3),e.push(String.fromCharCode(u>>16,u>>8&255,u&255));switch(o){case 1:u=t(n,i)<<18|t(n,i+1)<<12|t(n,i+2)<<6;e.push(String.fromCharCode(u>>16,u>>8&255));break;case 2:u=t(n,i)<<18|t(n,i+1)<<12;e.push(String.fromCharCode(u>>16))}return e.join("")}function i(n,t){var i=n.charCodeAt(t);if(i>255)throw"INVALID_CHARACTER_ERR: DOM Exception 5";return i}function f(t){if(arguments.length!==1)throw"SyntaxError: exactly one argument required";t=String(t);var f,u,e=[],o=t.length-t.length%3;if(t.length===0)return t;for(f=0;f<o;f+=3)u=i(t,f)<<16|i(t,f+1)<<8|i(t,f+2),e.push(n.charAt(u>>18)),e.push(n.charAt(u>>12&63)),e.push(n.charAt(u>>6&63)),e.push(n.charAt(u&63));switch(t.length-o){case 1:u=i(t,f)<<16;e.push(n.charAt(u>>18)+n.charAt(u>>12&63)+r+r);break;case 2:u=i(t,f)<<16|i(t,f+1)<<8;e.push(n.charAt(u>>18)+n.charAt(u>>12&63)+n.charAt(u>>6&63)+r)}return e.join("")}var r="=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";return{decode:u,encode:f,VERSION:"1.0"}}(jQuery);window.onerror=function(n,t,i){if(!(n.indexOf("Script error.")>-1)){var u=t+" (line: "+i+")\n"+n,r={};return r.message=u,r.hotelId=IBE.Config.hotelId,r.severity="",n.indexOf("Unable to process binding")>0&&(r.severity="critical",typeof loader!="undefined"&&(loader.title("Failed to initialize booking engine :("),loader.message(r),loader.visible(!0))),IBE.Utils.logEvent(r),!0}};IBE.Utils.request=function(n){var u,t,i,r;if(n.url)return(n.url.indexOf(".html")!==-1?n.beforeSend=function(n){n.setRequestHeader("Content-Type","text/html")}:IBE.Utils.haveAuthenticationCookie()&&(n.beforeSend=function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())}),u={dataType:"json",type:"GET",crossDomain:!0,headers:{}},n=$.extend(!0,u,n),n.headers=n.headers||{},n.headers.hasOwnProperty("Accept-Language")||(n.headers["Accept-Language"]=IBE.Config.lang||"en-US"),IBE.Config.insightParticipantId==""&&(IBE.Config.insightParticipantId=IBE.Utils.generateGuid()),n.headers.hasOwnProperty("Insights-ParticipantId")||IBE.Config.insightParticipantId==""||(n.headers["Insights-ParticipantId"]=IBE.Config.insightParticipantId),t=$.Deferred(),IBE.Config.cacheLevel===2&&n.type.toLowerCase()!=="post"&&(i="ibe_"+MD5(ko.toJSON(n)),r=Cache.read(i),r!==!1))?(t.resolve(r),t.promise()):($.ajax(n).done(function(n){IBE.Config.cacheLevel===2&&Cache.write(i,n);t.resolve(n)}).fail(function(n){t.reject(n)}),t.promise())};IBE.Utils.bindTemplate=function(n,t,i,r){function u(){IBE.Utils.consoleLog("<ibe/template> Binding Template "+i+" for "+typeof t+" in "+n);var u=document.getElementById(n),e=ko.contextFor(u);e&&ko.cleanNode(u);try{typeof r!="undefined"&&typeof r.beforeRender=="function"&&r.beforeRender();ko.applyBindings(t,u);typeof r!="undefined"&&typeof r.afterRender=="function"&&r.afterRender()}catch(o){IBE.Utils.logEvent(o)}f.resolve(i)}typeof i=="undefined"&&(i=$("#"+n).data("template"));i.indexOf("http")<0&&(i=IBE.Config.baseUrl+i);var f=$.Deferred();return IBE.Utils.request({url:i,cache:IBE.Config.useCache,dataType:"html",async:!1}).always(function(t){var i,r;if($("#"+n).html(t),i=$("#"+n).find('script[type="text/html"]'),i.length===0){u();return}r=[];i.each(function(n,t){var u=$(t),i=u.attr("src");typeof i!="undefined"&&(i.indexOf("http")<0&&(i=IBE.Config.baseUrl+i),$(u.data("target")).html()==""&&r.push(IBE.Utils.request({url:i,cache:IBE.Config.useCache,dataType:"html",async:!1,headers:{"Accept-Language":lang}}).always(function(n){$(u.data("target")).html(n)})))});$.when(r).then(function(){u()})}),f.promise()};IBE.Utils.processingRequests={};IBE.Utils.addProcessingRequest=function(n,t,i){t=t||function(){};typeof IBE.Utils.processingRequests[n].callbacks=="undefined"&&(IBE.Utils.processingRequests[n].callbacks=[]);typeof i!="undefined"&&IBE.Utils.processingRequests[n].callbacks.unshift(t);IBE.Utils.processingRequests[n].callbacks.push(t)};IBE.Utils.processingRequestsCallbacks=function(n,t){if(typeof IBE.Utils.processingRequests[n]!="undefined"){if(typeof IBE.Utils.processingRequests[n].callbacks!="undefined")while(IBE.Utils.processingRequests[n].callbacks.length>0){var i=IBE.Utils.processingRequests[n].callbacks.pop();typeof i=="function"&&i(t)}delete IBE.Utils.processingRequests[n]}};IBE.Utils.loadCountries=function(){var n=$.Deferred(),t="Countries";return(IBE.Data.Countries==null&&Cache.read(t)!==!1&&(IBE.Data.Countries=Cache.read(t)),IBE.Data.Countries)?(n.resolve(IBE.Data.Countries),n.promise()):(IBE.Utils.request({dataType:"json",url:IBE.Config.apiBaseUrl+"/countries/?apikey="+IBE.Config.apiKey}).done(function(i){IBE.Data.Countries=i;Cache.write(t,IBE.Data.Countries);n.resolve(i)}),n.promise())};IBE.Utils.loadHotelInfo=function(n,t){IBE.Data.HotelInfo||(IBE.Data.HotelInfo=[]);var i=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},t),r=$.Deferred(),f,e=IBE.Utils.queryString(ko.utils.extend({apikey:i.apiKey,lang:i.lang})),o=IBE.Config.apiBaseUrl+"/hotels/info/"+i.hotelId+"/?"+e,u="HotelInfo_"+i.hotelId+"_"+i.lang;if(IBE.Data.Lang!==IBE.Config.lang&&(IBE.Data.HotelInfo[i.hotelId]=null),IBE.Data.HotelInfo[i.hotelId])return r.resolve(IBE.Data.HotelInfo[i.hotelId]),r.promise();if((f=Cache.read(u))!==!1)return IBE.Data.HotelInfo[i.hotelId]=f,IBE.Data.Lang=IBE.Config.lang,IBE.Utils.LoadAdditionalSettings(i),IBE.Utils.consoleLog("<ibe/cache> HotelInfo loaded from "+IBE.Config.defaultCache),r.resolve(IBE.Data.HotelInfo[i.hotelId]),r.promise();if(typeof IBE.Utils.processingRequests[u]=="undefined")return IBE.Utils.processingRequests[u]={processing:!0},IBE.Utils.request({url:o}).done(function(n){IBE.Data.HotelInfo[i.hotelId]=n;IBE.Data.Lang=IBE.Config.lang;IBE.Utils.LoadAdditionalSettings(i);Cache.write(u,IBE.Data.HotelInfo[i.hotelId]);r.resolve(IBE.Data.HotelInfo[i.hotelId]);IBE.Utils.processingRequestsCallbacks(u,IBE.Data.HotelInfo[i.hotelId])}).fail(function(n){r.reject(n)}),r.promise();IBE.Utils.addProcessingRequest(u,n)};IBE.Utils.LoadAdditionalSettings=function(n){if(IBE.Data.HotelInfo[n.hotelId].settings.ibeFlightInfo&&(IBE.Config.ibeFlightInfo=IBE.Data.HotelInfo[n.hotelId].settings.ibeFlightInfo,IBE.Config.ibeFlightInfo=IBE.Config.ibeFlightInfo==="False"?!1:!0),IBE.Data.HotelInfo[n.hotelId].settings.ibeShowBoard&&(IBE.Config.ibeShowBoard=IBE.Data.HotelInfo[n.hotelId].settings.ibeShowBoard,IBE.Config.ibeShowBoard=IBE.Config.ibeShowBoard==="False"?!1:!0),IBE.Data.HotelInfo[n.hotelId].settings.ibeArrivalTime&&(IBE.Config.ibeArrivalTime=IBE.Data.HotelInfo[n.hotelId].settings.ibeArrivalTime,IBE.Config.ibeArrivalTime=IBE.Config.ibeArrivalTime==="False"?!1:!0),IBE.Data.HotelInfo[n.hotelId].settings.ibeTimePolicy&&(IBE.Config.ibeTimePolicy=IBE.Data.HotelInfo[n.hotelId].settings.ibeTimePolicy,IBE.Config.ibeTimePolicy=IBE.Config.ibeTimePolicy==="False"?!1:!0),IBE.Data.HotelInfo[n.hotelId].settings.closeDatesNotClickable){var t=IBE.Data.HotelInfo[n.hotelId].settings.closeDatesNotClickable;IBE.Config.closeDatesClickable=t==="False"?!0:!1}IBE.Data.HotelInfo[n.hotelId].settings.ibeShowCVC&&(IBE.Config.ibeShowCVC=IBE.Data.HotelInfo[n.hotelId].settings.ibeShowCVC,IBE.Config.ibeShowCVC=IBE.Config.ibeShowCVC==="False"?!1:!0);IBE.Data.HotelInfo[n.hotelId].settings.ibeEnforceMLOS&&(IBE.Config.ibeEnforceMLOS=IBE.Data.HotelInfo[n.hotelId].settings.ibeEnforceMLOS,IBE.Config.ibeEnforceMLOS=IBE.Config.ibeEnforceMLOS==="False"?!1:!0);IBE.Data.HotelInfo[n.hotelId].settings.ibeShowNotes&&(IBE.Config.ibeShowNotes=IBE.Data.HotelInfo[n.hotelId].settings.ibeShowNotes,IBE.Config.ibeShowNotes=IBE.Config.ibeShowNotes==="False"?!1:!0);IBE.Config.externalPaymentGateway=IBE.Data.HotelInfo[n.hotelId].settings.externalPaymentGateway?IBE.Data.HotelInfo[n.hotelId].settings.externalPaymentGateway:"0";IBE.Data.HotelInfo[n.hotelId].settings.webCheckIn&&(IBE.Config.webCheckIn=IBE.Data.HotelInfo[n.hotelId].settings.webCheckIn,IBE.Config.webCheckIn=IBE.Config.webCheckIn==="False"?!1:!0);IBE.Config.memberships=[];IBE.Data.HotelInfo[n.hotelId].memberships&&(IBE.Config.memberships=IBE.Data.HotelInfo[n.hotelId].memberships);IBE.Config.trivagoId=[];IBE.Data.HotelInfo[n.hotelId].settings.trivagoId&&(IBE.Config.trivagoId=IBE.Data.HotelInfo[n.hotelId].settings.trivagoId);IBE.Data.HotelInfo[n.hotelId].settings.moneyFormat&&(IBE.Config.moneyFormat=IBE.Data.HotelInfo[n.hotelId].settings.moneyFormat);IBE.Data.HotelInfo[n.hotelId].settings.group&&(IBE.Config.groupText=IBE.Data.HotelInfo[n.hotelId].settings.group);IBE.Data.HotelInfo[n.hotelId].settings.showCurrencyCode&&(IBE.Config.showCurrencyCode=IBE.Data.HotelInfo[n.hotelId].settings.showCurrencyCode,IBE.Config.showCurrencyCode=IBE.Config.showCurrencyCode==="False"?!1:!0)};IBE.Utils.loadExchangeRates=function(n,t){var u=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},t),r=$.Deferred(),i="ExchangeRates";if(IBE.Data.ExchangeRates==null&&Cache.read(i)!==!1&&(IBE.Data.ExchangeRates=Cache.read(i)),IBE.Data.ExchangeRates)return IBE.Utils.consoleLog("<ibe/cache> ExchangeRates loaded from "+IBE.Config.defaultCache),r.resolve(IBE.Data.ExchangeRates),r.promise();if(typeof IBE.Utils.processingRequests[i]=="undefined")return IBE.Utils.processingRequests[i]={processing:!0},IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/exchangeRates/?apikey="+u.apiKey}).done(function(n){IBE.Data.ExchangeRates=n;Cache.write(i,IBE.Data.ExchangeRates,60);r.resolve(IBE.Data.ExchangeRates);IBE.Utils.processingRequestsCallbacks(i,IBE.Data.ExchangeRates)}).fail(function(n){var t={};t.Message=ko.toJSON(n);t.hotelId=parseInt(IBE.Config.hotelId);t.Severity="critical";IBE.Utils.logEvent(t)}),r.promise();IBE.Utils.addProcessingRequest(i,n)};IBE.Utils.translate=function(n){try{if(IBE.Translations.hasOwnProperty(n))return IBE.Translations[n]}catch(t){IBE.Utils.logEvent({Message:"IBE.Translation failed for key: "+n+". Exception: "+t.toJSON(),HotelId:parseInt(IBE.Config.hotelId),Severity:"warn"})}return n};IBE.Utils.translationsLoaded={};IBE.Utils.loadTranslations=function(n,t){var u;if(typeof n!="undefined"){var f=n.substring(0,2),r=$.Deferred(),i="resources_"+IBE.Config.rsId+"_"+f;if(Cache.read(i)!==!1)return IBE.Config.lang=n,IBE.Translations=Cache.read(i),IBE.Utils.translationsLoaded[n]=!0,IBE.Utils.consoleLog("<ibe/cache> Changed language to "+n+" and fetched resources from "+IBE.Config.defaultCache),typeof t=="function"&&t(n),r.resolve(IBE.Config.lang),r.promise();if(u=IBE.Config.localizationUrl,u+=u.indexOf("?")==-1?"?lang="+f:"&lang="+f,typeof IBE.Utils.processingRequests[i]=="undefined")return IBE.Utils.processingRequests[i]={processing:!0},IBE.Utils.request({url:u,dataType:"text",async:!1,headers:{"Accept-Language":n}}).done(function(u){IBE.Config.lang=n;IBE.Translations=$.parseJSON(u);IBE.Utils.translationsLoaded[n]=!0;IBE.Utils.consoleLog("Changed language to "+n+" and fetched resources from "+IBE.Config.localizationUrl.format(n)+"&lang="+n.substring(0,2));Cache.write(i,IBE.Translations,3600);console.log(new Date+"Processing lang callbacks");IBE.Utils.processingRequestsCallbacks(i,IBE.Config.lang);r.resolve(IBE.Config.lang);typeof t=="function"&&t(n)}).fail(function(){IBE.Utils.consoleLog("Language "+n+" not found. Trying for default language");IBE.Utils.request({url:IBE.Config.localizationUrl.format(IBE.Config.lang),dataType:"text",async:!1}).done(function(u){IBE.Translations=$.parseJSON(u);IBE.Utils.translationsLoaded[n]=!0;IBE.Utils.consoleLog("Changed language to "+IBE.Config.lang+" and fetched resources from "+IBE.Config.localizationUrl.format(IBE.Config.lang));Cache.write(i,IBE.Translations,3600);IBE.Utils.processingRequestsCallbacks(i,IBE.Config.lang);r.resolve(IBE.Config.lang);typeof t=="function"&&t(IBE.Config.lang)})}),r.promise();console.log(new Date+"Add new lang callback "+i);IBE.Utils.addProcessingRequest(i)}};IBE.Utils.findTranslation=function(n){return IBE.Translations.hasOwnProperty(n)?IBE.Translations[n]:n};IBE.Utils.consoleLog=function(n){if(IBE.Config.debug)try{if(typeof n=="object"){console.log(n);return}var t="";n.indexOf("cache")>-1&&(t="color: #db7c07;");n.indexOf("template")>-1&&(t="color: #364280;");n.indexOf("Google")>-1&&(t="color: #25ab26 ;");n.indexOf("error")>-1&&(t="background: #b81414; color: #fff");n="%c"+n;console.log(n,t)}catch(i){}};IBE.Utils.lookupCountry=function(){var n=$.Deferred();return IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/system/countrylookup/?apikey="+IBE.Config.apiKey,dataType:"json",contentType:"application/json"}).done(function(t){n.resolve(t)}).fail(function(n){IBE.Utils.consoleLog("Country Lookup failed");var t={};t.Message=n.toJSON();t.hotelId=parseInt(IBE.Config.hotelId);t.Severity="Warning";IBE.Utils.logEvent(t)}),n.promise()};IBE.Utils.populatePhotos=function(n){var t=[];return typeof n=="undefined"?t:(ko.utils.arrayMap(n,function(n){var i=new IBE.Models.Photo(n);i.url()!=""&&t.push(i)}),t)};IBE.Utils.populateGuestTypes=function(n){if(typeof n=="undefined")return[];var t=[];return $.each(n,function(n,i){var r=new IBE.Models.GuestType(i);t.push(r)}),t};IBE.Utils.populateSettings=function(n){var t,e,o,u,i,s,f,r,h;if(typeof n=="undefined")return[];for(t in n)if(n.hasOwnProperty(t))switch(t){case"maxAdults":case"maxChildren":case"maxRooms":n[t]=parseInt(n[t]);break;case"ibeRoomSorting":e=n[t];o=e.replace("availability.","availabilitySorting.");n[t]=o;break;case"sojern":u=JSON.parse(n[t]);for(i in u)u.hasOwnProperty(i)&&(s=i.toString().charAt(0).toLowerCase()+i.toString().slice(1),IBE.Config[s]=u[i]);break;case"triptease":f=JSON.parse(n[t]);for(r in f)f.hasOwnProperty(r)&&(h=r.toString().charAt(0).toLowerCase()+r.toString().slice(1),IBE.Config[h]=f[r])}return n};IBE.Utils.populateBoardTypes=function(n){if(typeof n=="undefined")return[];var t=[];return $.each(n,function(n,i){var r=new IBE.Models.BoardType(i);t.push(r)}),t};IBE.Utils.weekdayRates=function(n){for(var t,u,e=[],i=[],f=moment(n[0].date()),o=moment(n[n.length-1].date()),s=moment(f).isoWeekday(1),h=moment(o).isoWeekday(7),c=h.diff(s,"days"),l=f.diff(s,"days"),r=0;r<=c;r++)t=new IBE.Models.Daily({}),t.status="stay",t.price=0,t.priceWithoutDiscount=0,u=r-l,u>=0&&u<n.length&&(t.price=n[u].price(),t.priceWithoutDiscount=n[u].priceWithoutDiscount()),t.date=s.clone().add(r,"d"),t.date==f&&(t.status="checkIn"),t.date==o&&(t.status="checkOut"),t.date<f&&(t.status="inactive"),t.date>o&&(t.status="inactive"),i.push(t),(r+1)%7==0&&(e.push(i),i=[]);return i.length>0&&e.push(i),e};IBE.Utils.calculateRoomBoard=function(n){var t=n.preferredBoard();ko.utils.arrayForEach(n.hotelResults(),function(i){ko.utils.arrayForEach(i.requestedRooms(),function(i){ko.utils.arrayForEach(i.roomResults(),function(i){for(var r,o=IBE.Config.boardType[t],f=0,e=i.supportedBoards.replace(/,/g,"").split(" "),s=e.length,u=0;u<s;u++)f+=IBE.Config.boardType[e[u]];r="";r=f&o?n.preferredBoard():IBE.Config.defaultBoardType;ko.utils.arrayForEach(i.rateplans(),function(n){ko.utils.arrayForEach(n.roomBoards(),function(n){n.isSelected(n.boardType()==r);r==t?n.insteadOfBoard(n.boardType()):n.insteadOfBoard(t)})})})})})};IBE.Utils.claculateRateplanId=function(n,t){ko.utils.arrayForEach(n.hotelResults(),function(n){ko.utils.arrayForEach(n.requestedRooms(),function(n){ko.utils.arrayForEach(n.roomResults(),function(n){var i=[],u,r;ko.utils.arrayForEach(n.rateplans(),function(n){var r=ko.utils.arrayFirst(n.roomBoards(),function(n){return n.boardType()===t&&n.averageDailyRate()>0});r!=null&&i.push(r)});u=minProp(i,"price");r=ko.utils.arrayFilter(i,function(n){return n.price()===u});r.length>0&&n.ratePlanId(r[0].ratePlanId)})})})};IBE.Utils.parseDeepLinking=function(n,t){function u(){var u,n,f,e,r,o;if(i.rooms.length>0){for(t.requestedRooms.removeAll(),u=[],n=0;n<i.rooms.length;n++){for(f=new IBE.Models.RequestedRoom(n+1),e=[],r=0;r<i.rooms[n].length;r++)o=new IBE.Models.RequestedRoomGuestType(i.rooms[n][r]),e.push(o);f.guests=e;u.push(f)}t.requestedRooms(u)}}if(typeof n=="undefined"||n.length===0||typeof t=="undefined")return!1;var i={checkIn:"",checkOut:"",rooms:[],couponCode:"",board:t.hotel().info.defaultBoardType(),rateplan:0,lang:IBE.Config.defaultLang,currency:IBE.Config.currency,roomId:0,ref:new IBE.Models.Referrer},r=n.replace("?","").split("&");return r.length<1?!1:(ko.utils.arrayForEach(r,function(n){var u=n.split("="),a=moment(),e,f=new IBE.Models.Referrer,o=null,c,l,s,h,v;(u[0]==="ref"&&typeof u[1]!="undefined"&&u[1].toLowerCase()=="googlehotelads"&&(f.name="GoogleHotelAds",o=r.find(function(n){var t=n.split("=");return t[0].toLowerCase()==="campaignid"&&typeof t[1]!="undefined"}),o&&(f.campaign=o.split("=")[1]),Cache.write("ref",f,43200,"localstorage"),i.ref=f,t.referrer(f)),u[0]==="ref"&&typeof u[1]!="undefined"&&(i.ref===""||typeof i=="object"&&i.ref.name=="")&&(f.name=u[1],Cache.write("ref",f,43200,"localstorage"),i.ref=f,t.referrer(f)),(u[0]==="sig"||u[0]==="cig")&&typeof u[1]!="undefined"&&(f=new IBE.Models.Referrer,f.name="AdWords",o=r.find(function(n){var t=n.split("=");return t[0]==="_campaign"&&typeof t[1]!="undefined"}),o&&(f.campaign=o.split("=")[1]),Cache.write("ref",f,43200,"localstorage"),i.ref=f,t.referrer(f)),u[0]==="trv_reference"&&typeof u[1]!="undefined"&&(f=new IBE.Models.Referrer,f.name="Trivago",f.params={trv_reference:u[1]},Cache.write("ref",f,43200,"localstorage"),i.ref=f,t.referrer(f)),(u[0]==="ci"||u[0]==="checkIn")&&typeof u[1]!="undefined"&&(e=moment(u[1]),e.isValid()?(i.checkIn=moment(u[1]).format("YYYY-MM-DD"),e.diff(a,"days")<0?i.checkIn=moment(t.minCheckInDate()).format("YYYY-MM-DD"):t.checkIn(new Date(i.checkIn))):i=!1),(u[0]==="co"||u[0]==="checkOut")&&typeof u[1]!="undefined"&&(e=moment(u[1]),e.isValid()?(i.checkOut=moment(u[1]).format("YYYY-MM-DD"),e.diff(a,"days")<0&&(i.checkOut=moment(t.minCheckOutDate()).format("YYYY-MM-DD"))):i=!1),i!==!1)&&(u[0]==="couponCode"&&u[1]!=="couponCode"&&(i.couponCode=u[1],t.couponCode(i.couponCode)),u[0]==="board"&&u[1]!=="board"&&u[1]!=="undefined"&&(c=ko.utils.arrayFirst(t.boardTypes(),function(n){return n.boardType===u[1]||n.boardType.toLowerCase()===u[1]}),c!=null&&(i.board=u[1],t.boardType(c.boardType))),u[0]==="lang"&&typeof u[1]!="lang"&&u[1]!=""&&(l=u[1].toLowerCase().replace("_","-"),s=ko.utils.arrayFirst(t.languages(),function(n){return n.locale===l||n.culture.toLowerCase()===l}),s!=null&&(i.lang=s.culture,t.lang(s.culture))),u[0]==="cur"&&typeof u[1]!="cur"&&u[1]!=="undefined"&&(t.currencies().length>0?(h=ko.utils.arrayFirst(t.currencies().rates,function(n){return n.code==u[1]||n.code.toLowerCase()==u[1]}),h!=null&&(i.currency=h.code,t.currency(h.code))):(i.currency=u[1].toUpperCase(),t.currency(u[1].toUpperCase()))),u[0]==="rp"&&typeof u[1]!="undefined"&&(i.rateplan=u[1],t.rateplan=i.rateplan),u[0]==="roomId"&&typeof u[1]!="undefined"&&(i.roomId=parseInt(u[1])),u[0]==="r"&&typeof u[1]!="undefined"&&(u[1]=decodeURIComponent(u[1]),v=u[1].split("^"),ko.utils.arrayForEach(v,function(n){var e,r,f,o,u;if(n!=""){e=n.split("/");r=[];try{ko.utils.arrayForEach(t.hotel().info.guestTypes,function(n){r.push({ageCategory:n.ageCategory,fromAge:n.fromAge,toAge:n.toAge,pax:0})});r=t.hotel().info.guestTypes}catch(s){r=[{ageCategory:"Adult",fromAge:13,toAge:99,pax:0},{ageCategory:"Children",fromAge:3,toAge:12,pax:0},{ageCategory:"Infant",fromAge:0,toAge:2,pax:0}]}for(f=0;f<e.length;f++)if(f==0)r[0].pax(parseInt(e[f]));else for(o=parseInt(e[f]),u=0;u<r.length;u++)if(r[u].fromAge<=o&&r[u].toAge>=o){r[u].pax(r[u].pax()+1);break}i.rooms.push(ko.toJS(r))}})))}),i.checkIn==""||i.checkOut=="")?!1:(t.checkOut(moment(i.checkOut)),t.checkIn(moment(i.checkIn)),i!=!1&&(moment(i.checkIn).diff(moment(t.hotel().conditions.minCheckInDate),"days")<0&&(t.checkIn(t.hotel().conditions.minCheckInDate),i=!1),moment(i.checkOut).diff(i.checkIn,"days")>t.hotel().conditions.maxStay&&(i=!1)),typeof i.rooms!="undefined"&&i.rooms.length==0&&(i=!1),i!==!1&&u(),i)};IBE.Utils.parseOfferRules=function(n,t){var r,i;if(typeof n=="undefined"||typeof n.rules=="undefined"||n.rules.length=="undefined")return!1;r=moment();t.checkIn(r);i=n.rules.minStay;moment(t.checkIn()).diff(moment(n.rules.checkInMin),"days")<0&&t.checkIn(n.rules.checkInMin);moment(t.checkIn()).diff(moment(t.hotel().conditions.minCheckInDate),"days")<0&&t.checkIn(t.hotel().conditions.minCheckInDate);i==="undefined"&&t.checkOut(moment(t.checkIn).add(i,"days"))};IBE.Utils.destroyView=function(){var i;try{for(i=0;i<arguments.length;i++)typeof eval(arguments[i].toLowerCase())!="undefined"&&(ko.cleanNode($("#"+arguments[i])[0]),eval(arguments[i].toLowerCase()).clearMessage())}catch(e){}for(i=0;i<arguments.length;i++)$("#"+arguments[i]).html(""),$("#"+arguments[i]+" *").unbind()};IBE.Utils.prepareView=function(route){var i;try{for(i in routes)i!=route&&typeof routes[i]!="undefined"&&typeof eval(routes[i].toLowerCase())!="undefined"&&(ko.cleanNode($("#"+arguments[i])[0]),eval(routes[i].toLowerCase()).clearMessage())}catch(e){}for(i in routes)i!=route&&($("#"+routes[i]).html(""),$("#"+routes[i]+" *").unbind())};IBE.Utils.prepareMobileView=function(route){var i;try{for(i in routes)i!=route&&typeof routes[i]!="undefined"&&(ko.cleanNode($("#"+routes[i].id)[0]),eval(routes[i].id.toLowerCase()).clearMessage())}catch(e){}for(i in routes)i!=route&&($("#"+routes[i].id).html(""),$("#"+routes[i].id+" *").unbind())};IBE.Utils.logEvent=function(n){if(n.hotelId=n.hotelId||0,IBE.Config.debug===!0){IBE.Utils.consoleLog(n);return}typeof gtag=="function"&&gtag("send","exception",{exDescription:n.message,exFatal:!0,appName:"IBE [hotel: "+n.hotelId+"]",appVersion:"5.0.5"});var t=JSON.stringify(n);IBE.Utils.consoleLog(n);IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/errors/logevent/?apikey="+IBE.Config.apiKey,data:t,contentType:"application/json",dataType:"json"}).done(function(n){IBE.Utils.consoleLog("error logged: "+n)}).fail(function(n,t){IBE.Utils.consoleLog(t)})};IBE.Utils.dateIsoFormat=function(n){return moment.isMoment(n)?n.format("YYYY-MM-DD"):n.getFullYear()+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+("0"+n.getDate()).slice(-2)};IBE.Utils.queryString=function(n){var t="";for(var i in n)t+=i+"="+n[i]+"&";return t.substring(0,t.length-1)};IBE.Utils.dateDiff=function(n,t){return Math.floor((n.getTime()-t.getTime())/864e5)};IBE.Utils.getReservationSetting=function(n,t){return typeof n=="undefined"?"":typeof t=="undefined"||typeof n.reservationSettings=="undefined"?!1:n.reservationSettings.items.hasOwnProperty(t)?n.reservationSettings.items[t]:""};IBE.Utils.money=function(n,t){var u=ko.unwrap(t.currency()||"EUR"),f=t.calculateRate(t.currency(),n),r=ko.utils.arrayFirst(t.currencies().rates,function(n){return n.code==u}),i={precision:2,symbol:u,format:"%v %s"};if(typeof r!="undefined"&&f>0){i.symbol=r.symbol||r.code;switch(r.positivePattern){case"SymbolAlignLeft":i.pattern="%s%v";break;case"SymbolAlignRight":i.pattern="%v%s";break;case"SymbolAlignLeftWithSpace":i.pattern="%s %v";break;case"SymbolAlignRightWithSpace":i.pattern="%v %s";break;default:i.pattern="%s%v"}}return accounting.formatMoney(f,i)};IBE.Utils.getParam=function(n,t){typeof t=="undefined"&&(t=n,n=window.location.search);t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+t+"=([^&#]*)"),i=r.exec(n);return i==null?"":decodeURIComponent(i[1].replace(/\+/g," "))};IBE.Utils.stripTags=function(n){return n.replace(/<\/?[^>]+(>|$)/g,"")};IBE.Utils.gaTrack=function(n){IBE.Config.googleAnalyticsEnabled!==!1&&IBE.Config.googleAnalyticsId!==null&&(IBE.Utils.consoleLog("Google Analytics: "+ko.toJSON(n)),typeof gtag=="function"&&gtag("config",IBE.Config.googleAnalyticsId,{page_title:n.title,page_path:n.path}))};IBE.Utils.gaRemarketingTrack=function(n){if(IBE.Config.debug&&console.log("IBE: In debug mode remarketing tracking is disabled"),google_conversion_id=n||0,google_custom_params=window.google_tag_params,google_remarketing_only=!0,google_conversion_id==0){console.log("IBE: google_conversion_id is not valid");return}var t=document.write;document.write=function(n){$("body").append(n)};$.getScript("//www.googleadservices.com/pagead/conversion.js",function(){setTimeout(function(){document.write=t},100)})};IBE.Utils.authenticationHeader=function(n,t){if(n!==""&&t!==""&&typeof n!="undefined"&&typeof t!="undefined"){var i="Basic "+$.base64.encode(n+":"+t);return document.cookie="Authorization= "+i+";path=/",i}};IBE.Utils.authenticationCredentialsFromCookie=function(){var r=document.cookie.indexOf("Authorization="),n,t,i;return r!==-1&&(n=document.cookie.indexOf(";",r+1),n===-1&&(n=document.cookie.length),t=$.base64.decode(document.cookie.substring(0,n)),i=t.indexOf(":"),i>0)?{username:t.substring(0,i),password:t.substring(i+1)}:null};IBE.Utils.passwordStrength=function(n){var i=0,r,t,u,f,e;if(!n)return i;for(r={},t=0;t<n.length;t++)r[n[t]]=(r[n[t]]||0)+1,i+=5/r[n[t]];u={digits:/\d/.test(n),lower:/[a-z]/.test(n),upper:/[A-Z]/.test(n),nonWords:/\W/.test(n)};f=0;for(e in u)f+=u[e]===!0?1:0;return i+=(f-1)*10,parseInt(i)};IBE.Utils.haveAuthenticationCookie=function(){var n=document.cookie.indexOf("Authorization=");return n!==-1?!0:!1};IBE.Utils.authenticationCookie=function(n,t){var u="Authorization=",r=document.cookie.indexOf(u),i;return r!==-1?(i=document.cookie.indexOf(";",r+1),i===-1&&(i=document.cookie.length),unescape(document.cookie.substring(r+u.length,i))):IBE.Utils.authenticationHeader(n,t)};IBE.Utils.deleteAuthenticationCookie=function(){var n=document.cookie.indexOf("Authorization=");return n!==-1?(document.cookie="Authorization=; expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/",!0):!1};IBE.Utils.convertCountries=function(n){var i=Cache.read("Countries"),t;if(i!==!1&&(t=ko.utils.arrayFirst(i,function(t){return t.code===n}),t!=null))return t.name};IBE.Utils.getEnumerationKey=function(n,t,i){for(var r in n)if(n.hasOwnProperty(r)&&n[r]===t)return i?r.charAt(0).toLowerCase()+r.slice(1):r;return""};IBE.Utils.createFormAlphaBankRedirect=function(n,t){var o=n.redirectPaymentGatewayData,i=JSON.parse(o),u=i.PaymentRedirectUrl,s=(Math.round(n.advancePayment*100)/100).toFixed(2),f='<form id="shopform1" method="POST" action="'+i.PaymentUrl+'" accept-charset="UTF-8" ><input type="hidden" name = "mid" value = "'+i.MerchantId+'" /><input type="hidden" name="lang" value="'+t.lang().substr(0,2)+'" /><input type="hidden" name="deviceCategory" value="0"/><input type="hidden" name="orderid" value="'+n.id+'" /><input type="hidden" name="orderDesc" value="'+n.hotelName+'" /><input type="hidden" name="orderAmount" value="'+s+'" /><input type="hidden" name="currency" value="'+n.currencyCode+'" /><input type="hidden" name="payerEmail" value="'+n.customer.email+'" /><input type="hidden" name="payMethod" value="'+n.externalPaymentGatewayData+'"/><input type="hidden" name="confirmUrl" value="'+u+'" /><input type="hidden" name="cancelUrl" value="'+u+'" /><input type="hidden" name="digest" value="'+i.Digest+'" /><\/form >',e=$(f),r;$("body").append(e);r={message:n,severity:"info",hotelId:0};IBE.Utils.logEvent(r);r={message:f,severity:"info",hotelId:0};IBE.Utils.logEvent(r);$(e).submit()};IBE.Utils.generateGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var t=Math.random()*16|0,i=n=="x"?t:t&3|8;return i.toString(16)})};ko.validation.configure({registerExtenders:!0,messagesOnModified:!0,insertMessages:!0,parseInputAttributes:!0,messageTemplate:null});ko.validation.rules.creditCard={getValue:function(n){return typeof n=="function"?n():n},validator:function(n){var t=new RegExp("^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11})$");return t.test(n)},message:IBE.Utils.translate("validation.creditCard")};ko.validation.rules.checkbox={validator:function(n){return n},message:IBE.Utils.translate("validation.acceptTerms")};ko.validation.rules.phone={validator:function(n){if(typeof n!="undefined"){var t=n.match(/\d+/g);return t!==null&&t[0].length>0}},message:IBE.Utils.translate("validation.required")};ko.validation.registerExtenders();ko.utils.clone=function(n){return ko.mapping.fromJS(ko.toJS(n))};ko.utils.isBound=function(n){return!!ko.dataFor(document.getElementById(n))};ko.numericObservable=function(n){var t=ko.observable(n);return ko.dependentObservable({read:function(){return t()},write:function(n){var i=parseInt(n);t(isNaN(i)?n:i)}})};ko.assignObservable=function(n,t){return ko.isObservable(n)?n:ko.observable(n||t)};ko.assignObservableArray=function(n){return ko.isObservable(n)?n:ko.observableArray(n)};ko.observableArray.fn.filterByProperty=function(n,t){return ko.computed(function(){for(var r,u=this(),f=[],i=0;i<u.length;i++)r=u[i],ko.unwrap(r[n])===ko.unwrap(t)&&f.push(r);return f},this)};ko.extenders.format=function(n,t){return n.format=ko.computed(function(){return n()?moment(n()).format(t):""}),n};ko.observableArray.fn.sortByProperty=function(n){this.sort(function(t,i){var r=[],u;for(r[0]=0,r[1]=0,u=0;u<n.length;u++){var f=Math.pow(10,n.length-u),s=n[u][0],h=n[u][1],e=ko.unwrap(t[s]),o=ko.unwrap(i[s]);e===o?(r[0]+=f,r[1]+=f):h.toLowerCase()==="asc"?(r[0]+=e>o?0:f,r[1]+=e>o?f:0):(r[1]+=e<o?f:0,r[0]+=e<o?0:f)}return r[0]===r[1]?0:r[0]>r[1]?-1:r[0]<r[1]?1:void 0})};ko.dependentObservable.fn.trackReevaluations=function(){return this.reevaluationCount=ko.observable(0),this.subscribe(function(){this.reevaluationCount(this.reevaluationCount()+1)},this),this};ko.bindingHandlers.stopBindings={init:function(){return{controlsDescendantBindings:!0}}};ko.bindingHandlers.gaqPush={init:function(n,t){var i=t(),r=typeof i=="object"&&!(i instanceof Array),u=r?i.track:i,f=r?i.eventName:"click",e=function(){var n={};return n[f]=function(){IBE.Utils.consoleLog("GoogleAnalytics: "+u);gtag(u)},n}}};ko.bindingHandlers.gaTrack={init:function(n,t){if(IBE.Config.googleAnalyticsEnabled!==!1&&IBE.Config.googleAnalyticsId!==null){var i=t(),r=typeof i=="object"&&!(i instanceof Array);IBE.Utils.consoleLog("Google Analytics: "+ko.toJSON(i));typeof gtag=="function"&&gtag("config",IBE.Config.googleAnalyticsId,{page_title:i.title,page_path:i.path})}}};ko.bindingHandlers.backgroundImage={update:function(n,t,i){var u=i().backgroundImageOptions||{},f=ko.utils.unwrapObservable(t()),r="",e;f!==""&&(typeof u.width!="undefined"&&(r+="width="+ko.utils.unwrapObservable(u.width)),typeof u.height!="undefined"&&(r!==""&&(r+="&"),r+="height="+ko.utils.unwrapObservable(u.height)),typeof u.mode!="undefined"&&(r!==""&&(r+="&"),r+="mode="+ko.utils.unwrapObservable(u.mode)),e=f,r!==""&&(e=f+"?"+r),$(n).css({backgroundImage:"url("+e+")"}))}};ko.bindingHandlers.href={update:function(n,t){ko.bindingHandlers.attr.update(n,function(){return{href:t()}})}};ko.bindingHandlers.src={update:function(n,t){ko.bindingHandlers.attr.update(n,function(){return{src:t()}})}};pauseOnSelectEvent=!1;pauseMultiple=!1;ko.bindingHandlers.multiDatepicker={init:function(n,t,i,r){var f,u;n=$(n);f=i().datepickerOptions||{};displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");n.datepick({rangeSelect:!0,monthsToShow:[1,2],firstDay:1,changeMonth:!1,maxDate:"+1y",dateFormat:"dd/mm/yyyy",defaultDate:r.minCheckInDate(),todayText:"",onSelect:function(n){if(n.length!==0&&!pauseMultiple){var t=n[0],i=n[1];if(t-r.checkIn()!=0||i-r.checkOut()!=0){if(selectedDatepicker==="MultiCalendar"){if(t-i==0){selectedDatepicker="";return}pauseOnSelectEvent=!0;r.checkIn(moment(t).startOf("day"));r.checkOut(moment(i).startOf("day"));pauseOnSelectEvent=!1}ko.bindingHandlers.multiDatepicker.styleSelectedDates()}}},onChangeMonthYear:function(){ko.bindingHandlers.multiDatepicker.styleSelectedDates()},onDate:function(n){return isDateActive(r,new Date(n))?{}:{dateClass:"not-available",selectable:!1}}});u=ko.unwrap(i().lang);$.datepick.regionalOptions.hasOwnProperty(u)&&($.datepick.regionalOptions[u].prevText='<i class="fa fa-chevron-left" />',$.datepick.regionalOptions[u].nextText='<i class="fa fa-chevron-right" />',n.datepick("option",$.datepick.regionalOptions[u]),n.datepick("option",{lang:u}));ko.utils.registerEventHandler(n,"click",function(t){t.cancelBubble=!0;t.stopImmediatePropagation();selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")})},update:function(n,t,i){var r;n=$(n);var u=ko.utils.unwrapObservable(t()),f=u[0](),e=u[1]();pauseOnSelectEvent||n.datepick("setDate",f,e);r=ko.unwrap(i().lang);r&&localizeDatepicker(n,r)},styleSelectedDates:function(){window.setTimeout(function(){var n=$("#MultiCalendar .datepick"),t;n.find(".datepick-selected").eq(0).parent().addClass("first-selected");t=n.find(".datepick-selected").length;t>1&&n.find(".datepick-selected").eq(t-1).parent().addClass("last-selected")},20)}};ko.bindingHandlers.datepicker={init:function(n,t,i,r){var o,u,f,e;n=$(n);o=i().datepickerOptions||{};displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");u=ko.utils.unwrapObservable(r.hotel);f=IBE.Config.closeDatesClickable;n.datepick({firstDay:1,changeMonth:!1,yearRange:"c-0:c+2",monthsToShow:1,showTrigger:"#CalendarTrigger",todayText:"",clearText:"",closeText:"",defaultDate:r.minCheckInDate(),onSelect:function(n){if(typeof n!="undefined"){var i=t();i(moment(n[0]))}},onDate:function(n){var t,i={};try{t=n.getFullYear()+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+("0"+n.getDate()).slice(-2)}catch(r){return!0}if(!u.availability.hasOwnProperty(t))return!1;switch(u.availability[t]){case-1:i={dateClass:"not-available",selectable:f};break;case 0:return IBE.Config.displayResults[displayNotAvailable]!=0;default:return!0}return i}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")});e=ko.unwrap(i().lang)||IBE.Config.lang;ko.bindingHandlers.datepicker.changeLanguage(n,e,ko.unwrap(i().theme),ko.unwrap(i().theme))},update:function(n,t,i){n=$(n);ko.bindingHandlers.datepicker.changeLanguage(n,ko.unwrap(i().lang),ko.unwrap(i().theme));var r=ko.utils.unwrapObservable(t());if(typeof r=="undefined"){IBE.Utils.consoleLog("date undefined");return}String(r).indexOf("/Date(")===0&&(r=new Date(parseInt(r.replace(/\/Date\((.*?)\)\//gi,"$1"))));n.datepick("setDate",new Date(r))},changeLanguage:function(n,t,i){t&&localizeDatepicker(n,t,i)},displayNotAvailable:""};ko.bindingHandlers.multiPropertyDatepicker={init:function(n,t,i,r){var f,u;n=$(n);f=i().datepickerOptions||{};displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");n.datepick({firstDay:1,changeMonth:!1,yearRange:"c-0:c+2",monthsToShow:1,showTrigger:"#CalendarTrigger",todayText:"",clearText:"",closeText:"",defaultDate:r.minCheckInDate(),onSelect:function(n){if(typeof n!="undefined"){var i=t();i(moment(n[0]))}}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")});u=ko.unwrap(i().lang)||IBE.Config.lang;ko.bindingHandlers.multiPropertyDatepicker.changeLanguage(n,u,ko.unwrap(i().theme))},update:function(n,t,i){var u,r;if(n=$(n),u=ko.unwrap(i().lang)||IBE.Config.lang,ko.bindingHandlers.multiPropertyDatepicker.changeLanguage(n,u,ko.unwrap(i().theme)),r=ko.utils.unwrapObservable(t()),typeof r=="undefined"){IBE.Utils.consoleLog("date undefined");return}String(r).indexOf("/Date(")==0&&(r=new Date(parseInt(r.replace(/\/Date\((.*?)\)\//gi,"$1"))));n.datepick("setDate",new Date(r))},changeLanguage:function(n,t,i){t&&localizeDatepicker(n,t,i)},displayNotAvailable:""};ko.bindingHandlers.availabilityCalendar={update:function(n,t,i){function f(){n.find("tr td a, tr td span").off("click")}function f(){n.find("tr td a, tr td span").off("click")}var s,u;n=$(n);var c=i().datepickerOptions||{},r=i().availability,e=ko.unwrap(t())[0],o=ko.unwrap(t())[1],h=IBE.Config.closeDatesClickable;displayNotAvailable=i().displayNotAvailable;n.datepick({rangeSelect:!0,firstDay:1,changeMonth:!1,monthsToShow:2,maxDate:"+2y",todayClass:"",dateFormat:"YYYY-MM-DD",prevText:'<i class="fa fa-chevron-left" />',nextText:'<i class="fa fa-chevron-right" />',todayText:"",onDate:function(n){var t={},i=IBE.Utils.dateIsoFormat(n);if(r.hasOwnProperty(i))switch(r[i]){case 0:t=IBE.Config.displayResults[displayNotAvailable]===0?{dateClass:"not-available",selectable:!1}:{dateClass:"not-available",selectable:!0};break;case 1:t={dateClass:"last-room",selectable:!1,title:"Last Room",content:'<span class="last-room-content">'+moment(n).format("D")+"<\/span>"};break;case-1:t={dateClass:"not-available",selectable:h};break;case-100:t={dateClass:"not-available",selectable:!1};break;default:r[i]<0?t.dateClass="not-available":moment(i).isBetween(e.format("YYYY-MM-DD"),o.format("YYYY-MM-DD"))===!1&&(t.dateClass="available",t.title=r[i]+" rooms")}else t={dateClass:"not-available",selectable:!1};return t},onChangeMonthYear:function(){window.setTimeout(function(){f()},20)}});n.datepick("setDate",new Date(e.format("YYYY-MM-DD")),new Date(o.format("YYYY-MM-DD")));f();s=ko.unwrap(i().theme);u=ko.unwrap(i().lang);u&&localizeDatepicker(n,u,s);ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")})}};ko.bindingHandlers.datepickerWithRange={init:function(n,t,i,r){var u,f,e;n=$(n);u=i().datepickerOptions||{};f=IBE.Config.closeDatesClickable;displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");n.datepick({firstDay:1,changeMonth:!1,yearRange:"c-0:c+2",monthsToShow:u.monthsToShow||1,showTrigger:'<i class="material-icons icon-date">&#xE616;<\/i>',dateFormat:"yyyy-mm-dd",pickerClass:u.pickerClass||"",rangeSelect:!1,todayText:"",clearText:"",closeText:"",defaultDate:r.minCheckInDate(),onSelect:function(n){if(typeof n!="undefined"){var i=$("#CheckIn").datepick("getDate"),r=$("#CheckOut").datepick("getDate"),u=t();u(moment(n[0]));$("#datepickerOpened").datepick("setDate",i,r)}},onDate:function(n){var r,t={},u,e;try{r=n.getFullYear()+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+("0"+n.getDate()).slice(-2)}catch(o){return!0}if(!i().availability.hasOwnProperty(r))return!1;u=new Date($("#CheckIn").datepick("getDate"));e=new Date($("#CheckOut").datepick("getDate"));switch(i().availability[r]){case 0:t=IBE.Config.displayResults[displayNotAvailable]===0?{dateClass:"not-available",selectable:!0}:{dateClass:"not-available",selectable:!0};break;case-100:t={dateClass:"not-available",selectable:!0};break;case-1:t={dateClass:"not-available",selectable:f};break;default:return n>=u&&n<=e?n.toString()==u.toString()?{content:n.getUTCDate(),dateClass:"dateRangeFirst"}:n.toString()==e.toString()?{content:n.getUTCDate(),dateClass:"dateRangeLast"}:{content:n.getUTCDate(),dateClass:"dateRange"}:!0}return t}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")});e=ko.unwrap(i().lang)||IBE.Config.lang;ko.bindingHandlers.datepicker.changeLanguage(n,e,ko.unwrap(i().theme),ko.unwrap(i().theme))},update:function(n,t,i){n=$(n);ko.bindingHandlers.datepicker.changeLanguage(n,ko.unwrap(i().lang),ko.unwrap(i().theme));var r=ko.utils.unwrapObservable(t());if(typeof r=="undefined"){IBE.Utils.consoleLog("date undefined");return}String(r).indexOf("/Date(")===0&&(r=new Date(parseInt(r.replace(/\/Date\((.*?)\)\//gi,"$1"))));n.datepick("setDate",new Date(r))},changeLanguage:function(n,t,i){t&&localizeDatepicker(n,t,i)},displayNotAvailable:""};ko.bindingHandlers.datepickerWithRangeOpend={init:function(n,t,i,r){n=$(n);var u=i().datepickerOptions||{},f=IBE.Config.closeDatesClickable;displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");n.datepick({firstDay:1,startDate:"0d",minDate:new Date(i().minDate),changeMonth:!1,yearRange:"c-0:c+2",monthsToShow:u.monthsToShow||1,showTrigger:".icon-date",dateFormat:"yyyy-mm-dd",pickerClass:u.pickerClass||"",rangeSelect:u.rangeSelect||!1,defaultDate:new Date(2017,4,25),todayText:"",clearText:"",closeText:"",onSelect:function(n){if(typeof n!="undefined"&&moment(n[0]).diff(moment(n[1]),"days")!==0){var t=r.checkIn,i=r.checkOut;t(n[0]);i(n[1])}},onDate:function(n){var t={},u=IBE.Utils.dateIsoFormat(n);try{u=n.getFullYear()+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+("0"+n.getDate()).slice(-2)}catch(c){return!0}if(!i().availability.hasOwnProperty(u))return!1;var s=r.checkIn,h=r.checkOut,e=moment(s()).startOf("day"),o=moment(h()).startOf("day");n=moment(n).startOf("day");switch(i().availability[u]){case 0:t=IBE.Config.displayResults[displayNotAvailable]===0?{dateClass:"not-available",selectable:!0}:{dateClass:"not-available",selectable:!0};break;case-100:t={dateClass:"not-available",selectable:!0};break;case-1:t={dateClass:"not-available",selectable:f};break;default:return n>=e&&n<=o?n.diff(e,"days")===0?{content:n.format("D"),dateClass:"dateRangeFirst"}:n.diff(o.utc(),"days")===0?{content:n.format("D"),dateClass:"dateRangeLast"}:{content:n.format("D"),dateClass:"dateRange"}:!0}return t}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")})},update:function(n,t,i){n=$(n);ko.bindingHandlers.datepicker.changeLanguage(n,ko.unwrap(i().lang),ko.unwrap(i().theme));var r=ko.utils.unwrapObservable(t());if(typeof r=="undefined"){IBE.Utils.consoleLog("date undefined");return}String(r).indexOf("/Date(")===0&&(r=new Date(parseInt(r.replace(/\/Date\((.*?)\)\//gi,"$1"))));n.datepick("setDate",new Date(r))},changeLanguage:function(n,t,i){t&&localizeDatepicker(n,t,i)}};ko.bindingHandlers.bindMinDate={update:function(n,t){n=$(n);var i=ko.utils.unwrapObservable(t());n.datepick("option","minDate",new Date(i))}};ko.bindingHandlers.roomSelectionTabs={total:0,getDisabled:function(n){for(var i=[],t=n+1;t<=ko.bindingHandlers.roomSelectionTabs.total-1;t++)i.push(t);return i},init:function(n,t,i){var u=$(n),r=i().tabOptions||{},f=r.active;ko.bindingHandlers.roomSelectionTabs.total=u.find(t()+" li").length;r.disabled=ko.bindingHandlers.roomSelectionTabs.getDisabled(f);u.tabs(r)},update:function(n,t,i,r){var u=$(n),e=ko.utils.unwrapObservable(i().tabOptions),f=r.activeTabIndex(),o=u.tabs("option","active");u.tabs({disabled:ko.bindingHandlers.roomSelectionTabs.getDisabled(f)});u.tabs("enable",f);u.tabs("option","active",f);r.activeRoomIndex(f+1)}};ko.bindingHandlers.stopBinding={init:function(){return{controlsDescendantBindings:!0}}};ko.bindingHandlers.translate={update:function(n,t,i,r,u){var f,o,e,s,h;try{if(f=ko.utils.unwrapObservable(t()),o=ko.unwrap(u.$root.lang())||"",typeof f=="object")for(attr in f)n.setAttribute(attr,IBE.Utils.findTranslation(f[attr]));else e=IBE.Utils.findTranslation(f),i().hasOwnProperty("formatData")&&(e=e.format(ko.unwrap(i().formatData[0]))),n.innerHTML=e;n.setAttribute("lang",o.substring(0,2));s=n.style.display;n.style.display="none";h=n.offsetHeight;n.style.display=s}catch(c){}}};ko.bindingHandlers.stripTags={update:function(n,t,i,r,u){var f=u.$root.lang();return ko.bindingHandlers.text.update(n,function(){return IBE.Utils.stripTags(ko.utils.unwrapObservable(t()))})}};ko.bindingHandlers.date={update:function(n,t,i){var u=i.get("dateFormat")||"YYYY-MM-DD",f=moment(ko.unwrap(t())),r;f.isValid()?n.innerHTML=moment(ko.unwrap(t())).format(u):(r=i().emptyDate,n.innerHTML=r?r:moment().format(u))}};ko.bindingHandlers.money={update:function(n,t,i,r,u){var e=r,c=!1,o,l,a,p,s;if(e.hasOwnProperty("currency")?c=!0:ko.utils.arrayForEach(u.$parents,function(n){c||n.hasOwnProperty("currency")&&n.hasOwnProperty("currencies")&&(c=!0,e=n)}),o=i.get("format")||IBE.Config.moneyFormat||"",l=!1,o!==""?l=!0:o="%v %s",!c||typeof ko.unwrap(e.currencies).rates=="undefined"){a=ko.unwrap(r.currency)||"";n.innerHTML=accounting.formatMoney(ko.unwrap(t()),{precision:2,symbol:a,format:o});return}var v=ko.unwrap(i.get("currency")||e.currency()||"EUR"),y=e.calculateRate(e.currency(),ko.unwrap(t())),h=ko.utils.arrayFirst(e.currencies().rates,function(n){return n.code==v}),f={precision:2,symbol:v,thousand:",",decimal:".",format:o};if(typeof h!="undefined"&&y>0)if(IBE.Config.showCurrencyCode)if(l)f.format=o;else switch(h.positivePattern){case"SymbolAlignLeft":case"SymbolAlignLeftWithSpace":f.format="%s %v";break;case"SymbolAlignRight":case"SymbolAlignRightWithSpace":f.format="%v %s";break;default:f.format="%s %v"}else if(f.symbol=h.symbol||h.code,l)f.format=o;else switch(h.positivePattern){case"SymbolAlignLeft":f.format="%s%v";break;case"SymbolAlignRight":f.format="%v%s";break;case"SymbolAlignLeftWithSpace":f.format="%s %v";break;case"SymbolAlignRightWithSpace":f.format="%v %s";break;default:f.format="%s%v"}if(typeof e.lang!="undefined"){p=1.1;f.decimal=Globalize.format(p,"n2",e.lang()).substring(1,2);switch(f.decimal){case".":f.thousand=",";break;case",":f.thousand=".";break;default:f.thousand=","}}if(s=accounting.formatMoney(y,f),s.toString().length>14){n.innerHTML="<span class='smaller'>"+s+"<\/span>";return}if(s.toString().length>10){n.innerHTML="<span class='small'>"+s+"<\/span>";return}n.innerHTML=s}};ko.bindingHandlers.numeric={init:function(n,t){$(n).numeric({negative:!1});ko.utils.registerEventHandler(n,"change",function(){var i=t();i(parseInt($(n).val()))})},update:function(n,t){ko.bindingHandlers.value.update(n,t)}};ko.bindingHandlers.dailyRateBreakDown={init:function(n,t,i,r){if(r.rateBreakDown()){var o=ko.unwrap(t()),e=o.weeks(),f="",u="";u+='<tr><th class="week"><\/th>';ko.utils.arrayForEach(e[0],function(n){u+="<th>"+n.date.format("ddd")+"<\/th>"});u+="<\/tr>";f+="<thead>"+u+"<\/thead>";u="";ko.utils.arrayForEach(e,function(n){u+="<tr>";ko.utils.arrayForEach(n,function(n){u+="<td>"+n.date.format("DD")+"<\/td>"});u+="<\/tr>"});f+="<tbody>"+u+"<\/tbody>";$(n).append(f)}}};ko.bindingHandlers.preventBubble={init:function(n,t){var i=ko.utils.unwrapObservable(t());ko.utils.registerEventHandler(n,i,function(n){n.cancelBubble=!0;n.stopPropagation&&n.stopPropagation()})}};ko.bindingHandlers.map={init:function(n,t){var i=ko.utils.unwrapObservable(t()),u=new google.maps.LatLng(ko.utils.unwrapObservable(i.latitude),ko.utils.unwrapObservable(i.longitude)),r,f;i.map=new google.maps.Map(n,{center:u,zoom:i.zoom,scrollwheel:!1,mapTypeId:google.maps.MapTypeId.ROADMAP});r=new google.maps.Marker({map:i.map,position:u,title:i.marker().title});f=new google.maps.InfoWindow({content:"<p>"+i.marker().title+"<br /><small>"+i.marker().street+"<\/small><\/p>"});google.maps.event.addListener(r,"click",function(){f.open(i.map,r)})}};ko.bindingHandlers.directionsMap={init:function(n,t){function e(n){var t={origin:n.coords?new google.maps.LatLng(n.lat,n.lng):n.address,destination:u,travelMode:google.maps.DirectionsTravelMode.DRIVING},e={center:u,zoom:i.zoom,mapTypeId:google.maps.MapTypeId.ROADMAP},o=new google.maps.Map(document.getElementById("map"),e);r.setMap(o);r.setPanel(document.getElementById("map-directions"));f.route(t,function(n,t){t===google.maps.DirectionsStatus.OK&&r.setDirections(n)})}var i=ko.utils.unwrapObservable(t()),u=new google.maps.LatLng(ko.utils.unwrapObservable(i.latitude),ko.utils.unwrapObservable(i.longitude)),f=new google.maps.DirectionsService,r=new google.maps.DirectionsRenderer;navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(n){e({coords:!0,lat:n.coords.latitude,lng:n.coords.longitude})})}};ko.bindingHandlers.reservationStatus={update:function(n,t){var i=ko.utils.unwrapObservable(t()),r="";switch(IBE.Config.reservationStatus[i]){case 1:r+=" success "+i.toLowerCase();break;case 2:case 6:r+=" error "+i.toLowerCase();break;case 4:r+=" notice "+i.toLowerCase()}$(n).addClass(r)}};ko.bindingHandlers.popover={update:function(n,t){var i=ko.utils.unwrapObservable(t());i=$.extend(!0,{},{placement:"bottom",toggle:"popover",trigger:"focus",html:!0,exclusive:!1},i);i.title=function(){return t().title};i.content=function(){return t().content};$(n).popover(i)}};ko.bindingHandlers.toJSON={update:function(n,t){return ko.bindingHandlers.text.update(n,function(){return ko.toJSON(t(),null,2)})}};ko.bindingHandlers.logger={update:function(n,t,i){var r=ko.utils.domData.get(n,"_ko_logger")||0,u=ko.toJS(t()||i());ko.utils.domData.set(n,"_ko_logger",++r);window.console&&console.log&&console.log(r,n,u)}};ko.bindingHandlers.cycle={update:function(n,t){var i=$(n),f=ko.unwrap(t()),r={},u=i.data();for(key in u)key.indexOf("cycle")!=-1&&(r[key]=u[key]);i.cycle(r);ko.bindingHandlers.cycle.hover(n);ko.utils.domNodeDisposal.addDisposeCallback(n,function(){i.cycle("destroy")})},hover:function(n){$(n).hover(function(){var n=$(this);$(document).keydown(function(t){if(t.keyCode==37){n.cycle("prev");return}if(t.keyCode==39){n.cycle("next");return}})},function(){$(document).unbind("keydown")})}};ko.bindingHandlers.modal={init:function(n,t){var r=$(n),u=ko.utils.extend({},ko.unwrap(t())),i=$(u.target);i.on("show.bs.modal",function(){$("html").addClass("modal-open");$(".modal-backdrop").height($(document).height())});i.on("shown.bs.modal",function(){$("html").addClass("modal-open");$(".modal-backdrop").height($(document).height())});i.on("hidden.bs.modal",function(){i.data("modal",null)});r.on("click",function(){i.modal({show:!0})});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){i.data("modal",null)})},update:function(){}};ko.bindingHandlers.readMore={init:function(n,t,i){var r=i().readmoreOptions;$(n).html(t());window.setTimeout(function(){$(n).readmore({speed:75,moreLink:'<div class="readmore-js-toggle">'+IBE.Utils.translate("readMore")+"<\/div>",lessLink:'<div class="readmore-js-toggle">'+IBE.Utils.translate("close")+"<\/div>"})},50);ko.utils.domNodeDisposal.addDisposeCallback(n,function(){$(n).readmore("destroy")})}};ko.bindingHandlers.slick={init:function(n){var t=$(n);window.setTimeout(function(){t.slick({infinite:!1,dots:!1,arrows:!0,speed:277,swipe:!0,slidesToShow:1,draggable:!0,fade:!0,cssEase:"linear",accessibility:!0})},50)}};ko.bindingHandlers.select2={init:function(n,t,i){var r={},f=i.get("data"),u;typeof f!="undefined"&&(r.data=f);r.minimumInputLength=i.get("minimumInputLength")||0;var h=i.get("showSearch")?1:-1,e=i.get("width"),o=i.get("selectTemplate"),s=i.get("optionTemplateFunction"),c=$(n).siblings("#option").html();if(r.minimumResultsForSearch=h,s&&(r.formatResult=function(n){return s.call(n,c)}),o&&(r.formatSelection=o),e&&(r.width=e),u=$(n),u.select2(r),i.get("textNval")===!0)u.on("change",function(n){var i=t();i(n.added)});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){$(n).select2("destroy")})},update:function(n,t,i){var r=i.get("data");typeof r!="undefined"&&$(n).select2({data:r})}};ko.bindingHandlers.hidden=function(){function n(n,t){var i=ko.unwrap(t());$(n).css("visibility",i?"hidden":"visible")}return{init:n,update:n}};ko.components.register("passwordstrength-widget",{viewModel:function(n){this.password=ko.observable(n&&n.value||"");self.validatePasswordStrength=ko.computed(function(){return IBE.Utils.passwordStrength(n.value)})},template:'<div class="password-strength" data-bind="visible: password"><span data-bind="value:validatePasswordStrength()"><\/span>            <div class="background" data-bind="css: { success: validatePasswordStrength() > 60, error : validatePasswordStrength() <= 60}, style: { width: validatePasswordStrength()+ \'%\'}">            <\/div>        <\/div>'});ko.bindingHandlers.singleDatepicker={init:function(n,t,i){var r,u;n=$(n);r=i().datepickerOptions||{};n.datepick({firstDay:1,changeMonth:!0,yearRange:"-100:+0",defaultDate:null,monthsToShow:r.monthsToShow||1,showTrigger:'<i class="material-icons icon-date">&#xE616;<\/i>',dateFormat:"yyyy-mm-dd",pickerClass:r.pickerClass||"",rangeSelect:!1,todayText:"",clearText:"",closeText:"",onSelect:function(n){if(typeof n!="undefined"){var i=t();i(moment(n[0]))}}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")});u=ko.unwrap(i().lang)||IBE.Config.lang;ko.bindingHandlers.datepicker.changeLanguage(n,u)},changeLanguage:function(n,t){t&&(t.length>2&&t!=="en-US"&&(t=t.substring(0,2)),n.datepick("option").lang!==t&&$.datepick.regionalOptions.hasOwnProperty(t)&&($.datepick.regionalOptions[t].prevText='<i class="material-icons">&#xE314;<\/i>',$.datepick.regionalOptions[t].nextText='<i class="material-icons">&#xE315;<\/i>',n.datepick("option",$.datepick.regionalOptions[t]),n.datepick("option",{lang:t})))},displayNotAvailable:""};ko.bindingHandlers.timePicker={init:function(n,t,i){var r=i().timepickerOptions||{};$(n).timepicker(r);ko.utils.registerEventHandler(n,"change",function(){var i=t();i($(n).timepicker("getTime"))})},update:function(n,t){var i=ko.utils.unwrapObservable(t()),r=$(n).timepicker("getTime");i-r!=0&&$(n).timepicker("setTime",i)}};ko.bindingHandlers.modifyRoomSelectionTabs={total:0,getDisabled:function(n){for(var i=[],t=n+1;t<=ko.bindingHandlers.roomSelectionTabs.total-1;t++)i.push(t);return i},init:function(n,t,i){var u=$(n),r=i().tabOptions||{},f=r.active;ko.bindingHandlers.roomSelectionTabs.total=u.find(t()+" li").length;r.disabled=ko.bindingHandlers.roomSelectionTabs.getDisabled(f);u.tabs(r)},update:function(n,t,i){var r=$(n),e=ko.utils.unwrapObservable(i().tabOptions),f=e.viewmodel,u=f.activeTabIndex(),o=r.tabs("option","active");r.tabs({disabled:ko.bindingHandlers.roomSelectionTabs.getDisabled(u)});r.tabs("enable",u);r.tabs("option","active",u);f.activeRoomIndex(u+1)}};ko.bindingHandlers.addFiledsAuthorizeNet=function(){$("#CustomerCardHolder").after('<input type="hidden" name="dataValue" id="dataValue" />');$("#CustomerCardHolder").after('<input type="hidden" name="dataDescriptor" id="dataDescriptor" />')};ko.bindingHandlers.mountStripe={init:function(n,t){typeof t().externalPaymentGateway()!="undefined"&&t().externalPaymentGateway().initStripe()}};IBE.Models.Language=function(n){var t=this;n=n||{};t.country=n.country;t.culture=n.culture||"";t.description=n.description;t.locale=n.locale};IBE.Models.Hotel=function(n){var t=this;t.info=n.info||{};t.availability=n.availability||{};t.settings=n.settings||{};t.offers=n.offers||[];t.conditions=n.conditions||{};t.defaults=n.defaults||{};t.memberships=[];typeof n.memberships!="undefined"&&n.memberships!=null&&ko.utils.arrayForEach(n.memberships,function(n){t.memberships.push(new IBE.Models.Membership(n))});t.hasMembership=t.memberships.length>0;t.visibleOffers=ko.computed(function(){return ko.utils.arrayFilter(t.offers,function(n){return n.showOffer})});IBE.Data.Settings=IBE.Utils.populateSettings(t.settings);t.customerRegistrationMode=parseInt(t.settings.customerRegistrationMode)};IBE.Models.RequestedRoom=function(n){var t=this;t.guests=ko.observableArray([]);t.roomResults=ko.observableArray([]);t.roomIndex=ko.observable(n||1);t.rank=0;t.isBestValue=ko.computed({read:function(){var n={},i=[],r=1e15;return ko.utils.arrayForEach(t.roomResults(),function(n){n.minPrice()>0&&i.push({id:n.roomId(),minPrice:n.minPrice()})}),ko.utils.arrayForEach(i,function(t){t.minPrice<=r&&(n=t,r=t.minPrice)}),n},deferEvaluation:!0});t.preferredBoard=ko.observable("");t.orderedRoomsPrices=function(){var n=[];return ko.utils.arrayForEach(t.roomResults(),function(t){t.minPrice()>0&&n.push({availability:t.availability,roomId:t.roomId(),price:t.minPrice(),averageDailyRate:t.averageDailyRate(),name:t.info().name})}),n.sort(function(n,t){return n.price-t.price}),n};t.isVisible=ko.computed({read:function(){var n=!1;return ko.utils.arrayForEach(t.roomResults(),function(t){if(t.isVisible()){n=!0;return}}),n},deferEvaluation:!0});t.sortRoomResults=function(n){for(var r=[],i=0;i<n.length;i++)r.push(n[i].split("."));t.roomResults.sortByProperty(r)};t.canAddGuest=function(n){var i=0;return ko.utils.arrayForEach(t.guests,function(n){if(n.ageCategory()!==IBE.Config.guestType.Infant){var t=ko.utils.unwrapObservable(n.pax);isNaN(parseInt(t))||(i+=parseInt(t))}}),i<n}};IBE.Models.GuestType=function(n){var t=this;n=n||{};t.ageCategory=n.ageCategory||"";t.fromAge=n.fromAge||"";t.toAge=n.toAge||"";t.max=n.max||"";t.min=n.min||"";t.pax=ko.observable(n.pax||0)};IBE.Models.Photo=function(n){var t=this;t.id=n.id;t.type=n.imageType;t.description=n.description;t.title=n.title;t.rank=n.rank;t.url=ko.computed({read:function(){var t=ko.utils.arrayFilter(n.transformations,function(n){return n.key.toLocaleLowerCase().indexOf("original")>-1});return t.length===1?t[0].url:""},deferEvaluation:!0});t.valid=ko.computed({read:function(){var t=ko.utils.arrayFilter(n.transformations,function(n){return n.key.toLocaleLowerCase().indexOf("original")>0});return t.length===1},deferEvaluation:!0})};IBE.Models.Offer=function(n,t){var i=this,r;i.id=n.id;i.hotelId=n.hotelId;i.name=n.name;i.abstract=n.abstract;i.description=n.description;i.rules=n.rules;i.photos=IBE.Utils.populatePhotos(n.photos);i.showOffer=n.showOffer||!1;i.minStay=1;i.cancellationPolicy=n.cancellationRules;i.paymentRules=n.paymentRules;i.havePhoto=ko.computed(function(){return i.photos.length>0});i.info=ko.computed({read:function(){var n=[],r;if(typeof t=="undefined"||typeof t.offers=="undefined")if(IBE.Data.HotelInfo[i.hotelId])n=IBE.Data.HotelInfo[i.hotelId].offers;else return{};else n=t.offers();return r=ko.utils.arrayFirst(n,function(n){return i.offerId===n.id}),r||{}},deferEvaluation:!0});r=[];n.membershipLevels&&n.membershipLevels.length>0&&(r=n.membershipLevels);i.membershipLevels=ko.observableArray(r)};IBE.Models.ReservationSettings=function(n){var t=this;t.items=n||{}};IBE.Models.RequestedRoomGuestType=function(n){var t=this;n=n||{};t.ages=ko.observableArray(n.ages);t.ageCategory=ko.observable(n.ageCategory);n.fromAge===""&&(n.fromAge=0);n.min===""&&(n.min=0);t.fromAge=ko.observable(n.fromAge);t.toAge=ko.observable(n.toAge);t.pax=ko.observable(ko.unwrap(n.pax));t.minValue=ko.observable(n.min);t.maxValue=ko.observable(n.max);t.label=ko.computed(function(){return t.ageCategory()===IBE.Config.guestType.Adult?"":t.fromAge()+"-"+t.toAge()});t.options=ko.computed(function(){for(var i=[],n=t.minValue();n<=t.maxValue();n++)i.push(n);return i});t.increase=function(){t.pax()!=t.maxValue()&&t.pax(t.pax()+1)};t.decrease=function(){t.pax()!=t.minValue()&&t.pax(t.pax()-1)}};IBE.Models.HotelInfo=function(n){var t=this;n=n||{};t.hotelId=n.id||n.hotelId||0;t.name=n.name;t.hotelType=n.hotelType;t.email=n.email;n.website&&n.website.indexOf("http")===-1&&(n.website="http://"+n.website);t.website=n.website;t.abstract=n.abstract;t.cancellationPolicy=n.cancellationPolicy;t.paymentPolicy=n.paymentPolicy;t.stars=n.stars;t.address=new IBE.Models.HotelAddress(n.address);t.logo=n.logo;t.termsConditions=n.termsConditions;typeof n.acceptedCards!="undefined"&&(t.acceptedCards=n.acceptedCards==="All"&&IBEConfig.allCreditCards?IBEConfig.allCreditCards.split(","):n.acceptedCards.split(", "));t.photos=IBE.Utils.populatePhotos(n.photos);t.guestTypes=IBE.Utils.populateGuestTypes(n.guestTypes);t.boardTypes=IBE.Utils.populateBoardTypes(n.boardTypes);t.defaultBoardType=ko.computed({read:function(){return ko.utils.arrayFirst(t.boardTypes,function(n){return n.isDefault}).boardType},deferEvaluation:!0});t.closedDates=[];typeof n.closedDates!="undefined"&&ko.utils.arrayForEach(n.closedDates,function(n){t.closedDates.push({from:new Date(n.closedFrom),to:new Date(n.closedTo)})})};IBE.Models.Terms=function(n){var t=this;t.id=n.id||-1;t.terms=n.terms||"";t.privacy=n.privacyPolicy||"";t.value=ko.observable(!1).extend({checkbox:{message:IBE.Utils.translate("acceptTerms")}})};IBE.Models.Consents=function(n){var t=this;t.id=n.id||-1;t.title=n.title||"";t.value=ko.observable(!1)};IBE.Models.Membership=function(n){var t=this;t.name=n.name||"";t.id=n.id||0};IBE.Models.HotelAddress=function(n){var t=this;t.latitude=n.latitude;t.longitude=n.longitude;t.street=n.street;t.region=n.region;t.city=n.city;t.country=n.country;t.countryCode="";t.phone=n.phone;t.timezone=n.timezone;t.email=n.email};IBE.Models.BoardType=function(n){var t=this;t.name=n.name===""?IBE.Utils.translate(n.boardType):n.name;t.boardType=n.boardType;t.description=n.description;t.isDefault=n.isDefault};IBE.Models.OfferInfo=function(n){var t=this;t.id=n.id;t.name=n.name;t.hotelId=n.hotelId;t.abstract=n.abstract;t.description=n.description;t.showOffer=n.showOffer;t.paymentRules=n.paymentRules||{};t.photos=n.photos||[]};IBE.Models.RatePlanInfo=function(n,t){var i=this,r;if(i.id=n.id,i.defaultName=n.name,i.description=n.description,i.paymentPocily=n.paymentPolicy,i.hideStandardRate=n.hideStandardRate,i.paymentRules=n.paymentRules||{},i.cancellationRules=ko.utils.arrayMap(n.cancellationRules,function(n){return new IBE.Models.CancellationRule(n)}),r=-1,i.paymentRules=ko.utils.arrayMap(n.paymentRules,function(n){return r+=1,n.Index=r,new IBE.Models.PaymentRule(n,t)}),i.paymentRules.length===0){if(!IBE.Data.HotelInfo[n.hotelId])return;i.paymentRules.push({text:IBE.Data.HotelInfo[n.hotelId].info.paymentPolicy})}i.isFreeCancellation=ko.computed({read:function(){var n=!0;return ko.utils.arrayForEach(i.cancellationRules,function(t){(t.penalty>0||t.minimumPenalty>0)&&(t.daysBeforeCheckIn>=0||t.daysBeforeCheckIn===-1)&&(n=!1)}),n},deferEvaluation:!0});i.name=ko.computed({write:function(n){i.defaultName(n)},read:function(){return i.id===0?IBE.Utils.translate("standardRate"):i.defaultName},deferEvaluation:!0});i.photos=n.photos};IBE.Models.RoomInfo=function(n){var t=this;t.id=n.id;t.name=n.name;t.description=n.description;t.alwaysOnRequest=n.alwaysOnRequest;t.availability=n.availability;t.minGuests=n.minGuests;t.maxGuests=n.maxGuests;t.bedrooms=n.bedrooms;t.photos=IBE.Utils.populatePhotos(n.photos);t.facilities=ko.utils.arrayMap(n.facilities,function(n){return new IBE.Models.Facility(n)});t.attributes=ko.utils.arrayMap(n.attributes,function(n){return new IBE.Models.Attribute(n)})};IBE.Models.Request=function(){var n=this;n.hotelResults=ko.observableArray([]);n.checkIn=ko.observable();n.checkOut=ko.observable();n.couponCode=ko.observable("");n.preferredBoard=ko.observable();n.ratePlanId=ko.observable(0);n.nights=ko.pureComputed({read:function(){return moment(n.checkOut()).diff(moment(n.checkIn()),"days")},deferEvaluation:!0});n.preferredBoard.subscribe(function(t){IBE.Utils.calculateRoomBoard(n);IBE.Utils.claculateRateplanId(n,t)},n)};IBE.Models.AvailabilityRestriction=function(n){var t=this;t.id=n.id;t.rules=[];t.text=[];n.rules=sameRule(n.rules);ko.utils.arrayForEach(n.rules,function(n){switch(n.ruleType){case"ReservationDaysMoreThanX":t.text.push(IBE.Utils.translate("restriction.ReservationDaysMoreThanX").format(n.value));reservationDaysMoreThanX="The maximum stay is {0} nights.";break;case"DayMinStayThrough":t.text.push(IBE.Utils.translate("restriction.RoomNightsLessThanX").format(n.value));roomNightsLessThanX="A minimum stay of {0} nights is required.";break;case"ReservationDaysLessThanX":t.text.push(IBE.Utils.translate("restriction.ReservationDaysLessThanX").format(n.value+1));reservationDaysLessThanX="A minimum stay of {0} nights is required.";break;case"RoomNightsMoreThanX":t.text.push(IBE.Utils.translate("restriction.RoomNightsMoreThanX").format(n.value));roomNightsMoreThanX="The maximum stay is {0} nights.";break;case"RoomNightsLessThanX":t.text.push(IBE.Utils.translate("restriction.RoomNightsLessThanX").format(n.value+1));roomNightsLessThanX="A minimum stay of {0} nights is required.";break;case"RoomsMoreThanX":t.text.push(IBE.Utils.translate("restriction.RoomsMoreThanX").format(n.value));roomsMoreThanX="The maximum number of rooms allowed is {0} .";break;case"RoomsLessThanX":t.text.push(IBE.Utils.translate("restriction.RoomsLessThanX").format(n.value+1));roomsLessThanX="The minimum number of rooms is {0} .";break;case"RequestedLessThanXDaysBeforeCheckIn":t.text.push(IBE.Utils.translate("restriction.RequestedLessThanX").format(n.value+1));requestedLessThanX="You can only make a reservation at least {0} days prior check-in date.";break;case"DayClosedDeparture":t.text.push(IBE.Utils.translate("restriction.DayClosedDeparture"));break;case"DayClosedArrival":t.text.push(IBE.Utils.translate("restriction.DayClosedArrival"));break;case"DayClosed":t.text.push(IBE.Utils.translate("restriction.DayClosed"))}})};IBE.Models.RoomResult=function(n){var t=this,r=[];t.rateplans=ko.computed({write:function(n){r(n)},read:function(){return r.sort(function(n,t){return n.price()>t.price()})},deferEvaluation:!0});t.roomId=ko.observable(0);t.hotelId=ko.observable(0);t.roomIndex=ko.observable(1);t.availability=0;t.availabilityStatus="";t.availabilityRestrictions=[];t.viewAvailability=ko.observable(!1);t.isFiltered=ko.observable(!1);t.availableRooms=0;t.supportedBoards=0;t.alternativeBoard=ko.computed({read:function(){return t.boardType()===""?!1:t.boardType()!==n.request().preferredBoard()},deferEvaluation:!0});t.availabilitySorting=ko.computed({read:function(){switch(t.availability){case-3:return.3;default:return t.availability}},deferEvaluation:!0});t.minPrice=ko.computed({read:function(){var n=1e13;return(ko.utils.arrayForEach(t.rateplans(),function(t){t.price()<=n&&(n=t.price())}),n===1e13)?null:n},deferEvaluation:!0});t.info=ko.computed({read:function(){var i=ko.utils.arrayFilter(n.rooms(),function(n){return t.roomId()===n.id});if(i.length===1)return i[0]},deferEvaluation:!0});t.defaultPriceAction=IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayWithoutPrices")];t.isVisible=ko.computed({read:function(){var i=!0,r=0,u=0;if(t.rateplans().length===0&&IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayWithoutPrices")]!==0)return!0;if(ko.utils.arrayForEach(t.rateplans(),function(t){ko.utils.arrayForEach(t.roomBoards(),function(t){u+=t.bookingAction();t.insteadOfBoard()===n.request().preferredBoard()&&t.price()>0&&(r+=t.price())})}),u===0)return!1;if(r<=0)switch(t.defaultPriceAction){case 0:i=!1;break;case 1:i=!0}return i},deferEvaluation:!0},this);t.ratePlanId=ko.observable(0);t.setRatePlanId=function(n){t.ratePlanId(n.ratePlanId())};t.averageDailyRate=ko.computed({read:function(){var n=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()===n.ratePlanId()});return n.length===1?n[0].averageDailyRate():0},deferEvaluation:!0},this);t.showPrices=ko.computed({read:function(){return!(t.availabilityStatus.toLowerCase()==="noprices")},deferEvaluation:!0});t.price=ko.computed({read:function(){var n=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()===n.ratePlanId()});return n.length===1?n[0].price():0},deferEvaluation:!0},this);t.bookingAction=ko.computed({read:function(){var n=0;return $.each(t.rateplans(),function(t,i){if(i.bookingAction()!==0){n=i.bookingAction();return}}),n},deferEvaluation:!0},this);t.hidePrices=ko.computed({read:function(){return IBE.Utils.getReservationSetting(n,"displayNotAvailable")==="HideRoomRates"&&t.bookingAction()!==3},deferEvaluation:!0});t.boardType=ko.computed({read:function(){var n=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()===n.ratePlanId()});return n.length===1?n[0].boardType():""},deferEvaluation:!0},this);t.boardName=ko.computed({read:function(){var i=ko.utils.arrayFirst(n.hotelInfo().boardTypes,function(n){return t.boardType()===n.boardType});return i!=null?i.name:t.boardType()},deferEvaluation:!0});t.bestRatePlanId=ko.computed({read:function(){function u(n,t){var i=n.map(function(n){return ko.unwrap(n[t])});return Math.min.apply(Math,i)}var f=t.rateplans(),n=[],r,i;return(ko.utils.arrayForEach(f,function(i){var r=ko.utils.arrayFirst(i.roomBoards(),function(n){return n.boardType()===t.boardType()&&n.averageDailyRate()>0});r!=null&&n.push(r)}),r=u(n,"price"),i=ko.utils.arrayFilter(n,function(n){return n.price()===r}),i.length>0)?i[0].ratePlanId:0},deferEvaluation:!0},this);t.upsales=ko.computed({read:function(){var r=!1;return ko.utils.arrayForEach(n.roomsPrices(),function(u,f){var e,o,s;if(u.roomId===t.roomId()){if(f===n.roomsPrices().length-1)return;if(e=n.roomsPrices()[f].averageDailyRate-t.averageDailyRate(),r=n.roomsPrices()[f],r.diffAmount=n.roomsPrices()[f].averageDailyRate-t.averageDailyRate(),e<=0)for(o=f+1,s=n.roomsPrices().length,i=o;i<s;i++)if(n.roomsPrices()[i].averageDailyRate-t.averageDailyRate()>0){r=n.roomsPrices()[i];r.diffAmount=n.roomsPrices()[i].averageDailyRate-t.averageDailyRate();return}}}),r},deferEvaluation:!0});t.downsale=ko.computed({read:function(){var r=!1,u=!1,i=[];return ko.utils.arrayForEach(n.request().hotelResults()[0].requestedRooms()[0].roomResults(),function(n){u||(n.roomId()!==t.roomId()&&n.minPrice()<t.minPrice()&&n.availability==IBE.Config.roomAvailability.Available?i.push(n):u=!0)}),i.length>0&&(r=i[i.length-1]),r},deferEvaluation:!0});t.discountPercent=ko.computed({read:function(){var n=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()===n.ratePlanId()});return n.length===1?n[0].discountPercent():0},deferEvaluation:!0},this)};IBE.Models.RatePlan=function(n){var t=this;t.roomBoards=ko.observableArray([]);t.ratePlanId=ko.observable(0);t.info=ko.computed({read:function(){var i=ko.utils.arrayFilter(n.rateplans(),function(n){return t.ratePlanId()===n.id});return i.length===1?i[0]:{}},deferEvaluation:!0});t.defaultPriceAction=IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayWithoutPrices")];t.isVisible=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(n){return n.price()>0}),r,u;if(i==null)switch(t.defaultPriceAction){case 0:return!1;case 1:return!0}return i.ratePlanId==0&&(r=ko.utils.arrayFirst(n.request().hotelResults()[0].requestedRooms()[0].roomResults(),function(n){return n.roomId()==i.roomId}),u=!1,r!=null&&ko.utils.arrayForEach(r.rateplans(),function(n){if(n.info().hideStandardRate){u=!0;return}}),u)?!1:!0},deferEvaluation:!0});t.showPrices=ko.computed({read:function(){var t=IBE.Utils.getReservationSetting(n,"hideRatePlanPrice");return t=t==="True"?!0:!1,!t}});t.averageDailyRate=ko.computed({read:function(){var i=0;return ko.utils.arrayForEach(t.roomBoards(),function(t){if(t.insteadOfBoard()===n.request().preferredBoard()){i=t.price()/n.request().nights();return}}),i},deferEvaluation:!0},this);t.price=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(t){return t.insteadOfBoard()===n.request().preferredBoard()&&t.price()>0});return i!=null?i.price():0},deferEvaluation:!0},this);t.priceWithoutDiscount=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(t){return t.insteadOfBoard()===n.request().preferredBoard()&&t.priceWithoutDiscount()>0});return i!=null?i.priceWithoutDiscount():0},deferEvaluation:!0},this);t.bookingAction=ko.computed({read:function(){var i=0;return $.each(t.roomBoards(),function(t,r){if(r.insteadOfBoard()===n.request().preferredBoard()){i=r.bookingAction();return}}),i},deferEvaluation:!0},this);t.boardType=ko.computed({read:function(){var i="";return $.each(t.roomBoards(),function(t,r){if(r.insteadOfBoard()===n.request().preferredBoard()&&r.price()>0){i=r.boardType();return}}),i},deferEvaluation:!0},this);t.rateBreakDown=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(t){return t.insteadOfBoard()===n.request().preferredBoard()},this);return i?i.rateBreakDown():{}},deferEvaluation:!0});t.advancePayment=ko.computed({read:function(){var r=ko.utils.arrayFirst(n.rateplans(),function(n){return t.ratePlanId()===n.id});if(!r)return!0;var f=moment(),e=moment(n.bookingProcess().checkIn()),u=f.diff(e,"days",!0),i=0;return(ko.utils.arrayForEach(ko.utils.unwrapObservable(r.paymentRules),function(n){n.daysUntilCheckInMax>=u&&n.daysUntilCheckInMin<u&&(i=n.charge,n.minimumCharge>i&&(i=n.minimumCharge))}),i===0)?!1:!0},deferEvaluation:!0});t.discountPercent=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(t){return t.insteadOfBoard()===n.request().preferredBoard()&&t.discountPercent()>0});return i!=null?i.discountPercent():0},deferEvaluation:!0},this)};IBE.Models.RoomBoard=function(n){var t=this;t.rateBreakDown=ko.observable(new IBE.Models.RateBreakDown);t.roomIndex=n.activeRoomIndex();t.roomId=0;t.ratePlanId=ko.observable(0);t.boardType=ko.observable("");t.insteadOfBoard=ko.observable("");t.price=ko.observable(0);t.priceWithoutDiscount=ko.observable(0);t.isSelected=ko.observable(!1);t.discountPercent=ko.computed({read:function(){return 100*(t.priceWithoutDiscount()-t.price())/t.priceWithoutDiscount()},deferEvaluation:!0});t.discount=ko.computed({read:function(){return t.priceWithoutDiscount()-t.price()},deferEvaluation:!0});t.showPrices=ko.computed({write:function(n){t.priceWithoutDiscount(n)},read:function(){return t.price()<0?!1:!0},deferEvaluation:!0});t.notAvailableAction=ko.observable(IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayNotAvailable")]);t.bookingAction=ko.computed({read:function(){var i=this,r,u;return i.roomIndex!==n.activeRoomIndex()?IBE.Config.displayResults.Hide:i.price()<=0?IBE.Utils.getReservationSetting(n,"displayWithoutPrices")=="Show"?t.notAvailableAction():IBE.Config.displayResults.Hide:(r=[],ko.utils.arrayForEach(n.request().hotelResults(),function(n){r=n.alternatives;return}),u=!1,ko.utils.arrayForEach(r,function(r){var e=0,f;if(n.selectedRooms().length>0)for(f=0;f<t.roomIndex-1;f++)typeof n.selectedRooms()[f]!="undefined"&&r[f]===ko.utils.unwrapObservable(n.selectedRooms()[f].roomId)&&e++;if(r[t.roomIndex-1]===i.roomId&&e++,e===t.roomIndex){u=!0;return}}),u?IBE.Config.displayResults.Online:t.notAvailableAction())},deferEvaluation:!0},this);t.info=ko.computed({read:function(){return ko.utils.arrayFirst(n.boards(),function(n){return t.boardType()===n.boardType})},deferEvaluation:!0});t._offerIds=[];t.offers=ko.computed({read:function(){return t.ratePlanId===0?ko.utils.arrayFilter(n.offers(),function(n){return t._offerIds.indexOf(n.id)!==-1}):[]},write:function(n){t.ratePlanId===0&&(t._offerIds=ko.unwrap(n))},deferEvaluation:!0});t.averageDailyRate=ko.computed({read:function(){return t.price()/n.request().nights()},deferEvaluation:!0},this)};IBE.Models.Daily=function(n){var t=this;t.date=ko.observable(n.date);t.status=ko.observable(n.status||"");t.price=ko.observable(n.price);t.priceWithoutDiscount=ko.observable(n.priceWithoutDiscount)};IBE.Models.RateBreakDown=function(n){var t=this;t.daily=ko.observableArray([]);n&&t.daily(ko.utils.arrayMap(n,function(n){return new IBE.Models.Daily(n)}));t.weeks=ko.computed({read:function(){return IBE.Utils.weekdayRates(t.daily())},deferEvaluation:!0})};IBE.Models.SelectedRoom=function(){var n=this;n.roomIndex=ko.observable(1);n.roomId=ko.observable(0);n.ratePlanId=ko.observable(0);n.boardType=ko.observable("");n.board=ko.observable();n.availability=ko.observable("");n.guestTypes=ko.observableArray([]);n.roomInfo=ko.observable();n.cost=ko.observable();n.costWithoutDiscount=ko.observable();n.ratePlan=ko.computed({read:function(){return ko.utils.arrayFirst(IBE.Data.RatePlanInfo,function(t){return t.id===n.ratePlanId()})},deferEvaluation:!0});n.discountPercent=ko.computed({read:function(){return 100*(n.costWithoutDiscount()-n.cost())/n.costWithoutDiscount()},deferEvaluation:!0});n.discount=ko.computed({read:function(){return n.costWithoutDiscount()-n.cost()},deferEvaluation:!0})};IBE.Models.BookingRoom=function(){var n=this;n.roomIndex=1;n.roomId=1;n.ratePlanId=0;n.boardType="";n.guestTypes=ko.observableArray([])};IBE.Models.Transformation=function(n){var t=this;t.width=n.width;t.height=n.height;t.url=n.url;t.key=n.key};IBE.Models.Facility=function(n){var t=this;t.id=n.id;t.name=n.name;t.url=n.url};IBE.Models.Attribute=function(n){var t=this;t.code=n.code;t.value=n.value};IBE.Models.Supplement=function(n){var t=this;n=n||{};t.supplementId=ko.observable(n.id||0);t.category=n.category||"";t.name=n.name||"";t.description=n.description||"";t.units=ko.observable(0);t.isUnique=ko.observable(n.isUnique||0);t.isMandatory=n.isMandatory;t.isVisible=n.isVisible;t.ratePlanId=ko.observable(0);t.setRatePlanId=function(n){t.ratePlanId(n)};t.rateplans=ko.observableArray(ko.utils.arrayMap(n.ratePlans,function(n){return new IBE.Models.SupplementRatePlan(n,t.isMandatory)}));t.prices=ko.computed({read:function(){var i=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()==n.ratePlanId}),n;return i.length==1?i[0].prices():(n=ko.utils.arrayFilter(t.rateplans(),function(n){return n.ratePlanId==0}),n.length==1?n[0].prices():[])},deferEvaluation:!0},this);t.isFree=ko.computed({read:function(){var n=0,i=0;return ko.utils.arrayForEach(t.prices(),function(t){n+=t.price;i+=t.quantity()}),n===0&&i>0},deferEvaluation:!0}).extend({notify:"always"});t.photos=ko.utils.arrayMap(n.photos,function(n){return new IBE.Models.Photo(n)});t.visible=ko.computed({read:function(){return t.prices().length>0&&t.isVisible},deferEvaluation:!0});t.pricingType=ko.observable(n.pricingType);t.timePricingType=ko.observable(n.timePricingType);t.timePricingUnit=ko.observable(n.timePricingUnit);t.roomIndex=ko.computed({read:function(){return IBE.Config.supplementPricingType[t.pricingType()]==IBE.Config.supplementPricingType.PerReservation?0:1},deferEvaluation:!0}).extend({notify:"always"});t.totalPrice=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.prices(),function(t){n+=t.price*t.quantity()}),n},deferEvaluation:!0}).extend({notify:"always"});t.totalPriceWithoutDiscount=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.prices(),function(t){n+=t.priceWithoutDiscount*t.quantity()}),n},deferEvaluation:!0}).extend({notify:"always"});t.quantity=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.prices(),function(t){n+=t.quantity()}),n},deferEvaluation:!0});t.discountAppliedRooms=ko.utils.arrayMap(n.discountAppliedRooms,function(n){return new IBE.Models.SupplementDiscountAppliedRooms(n)})};IBE.Models.SupplementRatePlan=function(n,t){var i=this;n=n||{};i.ratePlanId=n.ratePlanId||0;i.prices=ko.observableArray(ko.utils.arrayMap(n.prices,function(n){return new IBE.Models.SupplementPrice(n,t)}))};IBE.Models.SupplementPrice=function(n,t){var i=this;n=n||{};i.isMandatory=t;i.isVisible=n.isVisible||!0;i.quantity=ko.observable(n.quantity||0);i.price=n.price||0;i.priceWithoutDiscount=n.priceWithoutDiscount||0;i.guestType=n.guestType!=null?new IBE.Models.GuestType(n.guestType):{};i.minQuantity=ko.observable(0);(ko.unwrap(i.isMandatory)||i.price==0)&&(i.minQuantity(n.quantity||1),i.quantity(i.minQuantity()));i.maxQuantity=10;i.isSelected=ko.computed({read:function(){return i.quantity()>0},write:function(n){n||i.isMandatory?i.quantity(1):i.quantity(0)}}).extend({notify:"always"});i.addSupplement=function(){i.quantity()>=i.maxQuantity||i.quantity(parseInt(i.quantity())+1)};i.removeSupplement=function(){i.quantity()>i.minQuantity()&&i.quantity(parseInt(i.quantity())-1)}};IBE.Models.SupplementDiscountAppliedRooms=function(n){var t=this;n=n||{};t.ratePlanId=n.rateplanId||0;t.roomIds=n.roomIds};IBE.Models.BookingSupplement=function(){var n=this;n.supplementId=0;n.guestType={};n.quantity=0;n.roomIndex=0;n.categoryName="";n.ratePlanId=0;n.info={}};IBE.Models.Currencies=function(){var n=this;n.base="";n.rates=[]};IBE.Models.CurrencyRate=function(n){var t=this;t.code=n.code;t.rate=n.rate;t.name=n.name;t.positivePattern=n.positivePattern;t.symbol=n.symbol||n.code};IBE.Models.HotelResult=function(){var n=this;n.requestedRooms=ko.observableArray([]);n.hotelId=ko.observable(parseInt(IBE.Config.hotelId));n.availability=ko.observable();n.selectedSupplements=ko.observableArray([]);n.supplements={}};IBE.Models.Country=function(n){var t=this;t.code=ko.observable(n.code);t.name=ko.observable(n.name)};IBE.Models.CreditCard=function(){function i(n){var t={visa:/^4/,mastercard:/^5[1-5][0-9]/,amex:/^3[47][0-9]/,diners:/^3(?:0[0-5]|[68][0-9])[0-9]/,discover:/^6(?:011|5[0-9]{2})[0-9]/,jcb:/^(?:2131|1800|35\d{3})\d/};return t.visa.test(n)?"visa":t.mastercard.test(n)?"mastercard":t.amex.test(n)?"amex":t.diners.test(n)?"dinersclub":t.discover.test(n)?"discover":t.jcb.test(n)?"jcb":void 0}var n=this,t;n.acceptedCards=ko.observableArray();t=function(){$.when(IBE.Utils.loadHotelInfo()).then(function(t){t.info.acceptedCards==="All"?n.acceptedCards(IBEConfig.allCreditCards.split(",")):n.acceptedCards(t.info.acceptedCards.replace(/,/g,"").split(" "))})};t();n.id=ko.observable(0);n.cardHolder=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredCardHolder")}});n.cardNumber=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredCardNumber")},creditCard:{message:IBE.Utils.translate("validation.invalidCreditCard")}});n.cardExpirationYear=ko.observable("");n.cardExpirationMonth=ko.observable("");n.monthOptions=ko.computed(function(){for(var t=[],n=1;n<=12;n++)t.push(("0"+n).slice(-2));return t});n.yearOptions=ko.computed(function(){for(var r=new Date,t=r.getFullYear(),i=[],n=t;n<=t+15;n++)i.push(n);return i});n.cardVerification=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredCardVerification")},number:!0});n.cardType=ko.observable("");n.getCardType=ko.computed({write:function(){n.cardType(i(n.cardNumber()))},read:function(){return n.cardType(i(n.cardNumber())),n.cardType()},deferEvaluation:!0})};IBE.Models.Company=function(){var n=this;n.name=ko.observable("");n.vatNumber=ko.observable("");n.industry=ko.observable("");n.address=ko.observable("");n.zipCode=ko.observable("");n.phone=ko.observable("")};IBE.Models.Customer=function(n){var t=this,i,r,u;if(n=n||{},t.customerMandatoryFields=ko.observable(),t.customerMandatoryFields.subscribe(function(n){jQuery.isEmptyObject(n)||(n=JSON.parse(n),t.mandatoryAddress(n.MandatoryAddress),t.mandatoryZip(n.MandatoryZip),t.mandatoryPhone(n.MandatoryPhone),t.mandatoryTitle(n.MandatoryTitle),t.mandatoryPhone(n.MandatoryTelephone),t.mandatoryCity(n.MandatoryCity))}),t.mandatoryAddress=ko.observable(),t.mandatoryZip=ko.observable(),t.mandatoryPhone=ko.observable(),t.mandatoryTitle=ko.observable(),t.mandatoryCity=ko.observable(),t.consents=ko.observableArray([]),t.titleOptions=[{key:"Mr",text:IBE.Utils.translate("title-mr")},{key:"Mrs",text:IBE.Utils.translate("title-mrs")},{key:"Miss",text:IBE.Utils.translate("title-miss")},{key:"Ms",text:IBE.Utils.translate("title-ms")},{key:"Dr",text:IBE.Utils.translate("title-dr")}],t.title=ko.observable(n.title),t.firstName=ko.observable(n.firstName).extend({required:{message:IBE.Utils.translate("requiredFirstName")}}),t.lastName=ko.observable(n.lastName).extend({required:{message:IBE.Utils.translate("requiredLastName")}}),t.fullName=ko.computed(function(){return t.firstName()+" "+t.lastName()}),t.email=ko.observable(n.email).extend({required:{message:IBE.Utils.translate("requiredEmail")},email:!0}),t.country=ko.observable(n.country).extend({required:{message:IBE.Utils.translate("requiredCountry")}}),t.region=ko.observable(n.region),t.city=ko.observable(n.city).extend({required:{message:IBE.Utils.translate("requiredCity"),onlyIf:function(){return t.mandatoryCity()===!0}}}),t.address=ko.observable(n.address).extend({required:{message:IBE.Utils.translate("requiredAddress"),onlyIf:function(){return t.mandatoryAddress()===!0}}}),t.zip=ko.observable(n.zip).extend({required:{message:IBE.Utils.translate("requiredZip"),onlyIf:function(){return t.mandatoryZip()===!0}}}),t.fax=ko.observable(n.fax),t.mobile=ko.observable(n.mobilePhone),t.birthdate=ko.observable(n.birthdate),t.phone=ko.observable(n.telephones).extend({required:{message:IBE.Utils.translate("requiredTelephone"),onlyIf:function(){return t.mandatoryPhone()===!0}}}),t.acceptNewsletter=ko.observable(n.acceptNewsletter||!1),t.id=ko.observable(n.customerId||0),t.resetHash=n.resetHash||"",t.reservations=ko.observableArray([]),n.reservations){for(r=[],i=0;i<n.reservations.length;i++)r.push(new IBE.Models.Reservation(n.reservations[i]));t.reservations(r)}if(t.offers=ko.observableArray([]),n.offers){for(u=[],i=0;i<n.offers.length;i++)u.push(new IBE.Models.Offer(n.offers[i]));t.offers(u)}t._data=n;t.toJSON=function(){var n={};return n.customerId=t.id(),n.firstName=t.firstName(),n.lastName=t.lastName(),n.title=t.title(),n.email=t.email(),n.country=t.country(),n.region=t.region(),n.city=t.city(),n.address=t.address(),n.zip=t.zip(),n.fax=t.fax(),n.mobilePhone=t.mobile(),n.telephones=t.phone(),n.birthdate=t.birthdate(),n.acceptNewsletter=t.acceptNewsletter(),n.consents=t.consents(),ko.toJSON(n)}};IBE.Models.Reservation=function(n){var t=this,i,r,u;ko.utils.extend(t,new IBE.ViewModels.Taxes(t));typeof n=="undefined"&&(n={});t.id=n.id||0;t.code=n.code||"";t.orderId=n.orderId||"";t.currencyCode=n.currencyCode||"";t.status=ko.observable(n.status||"");t.hotelId=n.hotelId||0;t.hotelName=n.hotelName||"";t.checkIn=n.checkIn||"";t.checkOut=n.checkOut||"";t.couponCode=n.couponCode||"";t.created=n.created||"";t.cancelled=n.cancellationDate||"";t.lastModified=n.modified||"";t.notes=ko.observable(n.notes||"");t.arrivalNotes=ko.observable(n.arrivalNotes||"");t.totalCost=ko.observable(n.totalCost||"");t.totalCostWithoutDiscount=ko.observable(n.totalCostWithoutDiscount||"");t.advancePayment=ko.observable(n.advancePayment||"");t.reservationTerms=n.reservationTerms||"";t.reservationType=n.reservationType||"";t.sourceName=n.sourceName||"";t.sourceType=n.sourceType||"";t.webCheckIn=ko.observable(n.webCheckIn||!1);t.webCheckInDate=ko.observable(moment(n.webCheckInDate)||null);t.webCheckInActive=ko.observable(n.webCheckInActive||!1);t.payments=ko.observable(n.payments||[]);t.cancellationNotes=ko.observable("");t.pmsOwner=n.pmsOnwer||!1;t.pmsCode=n.pmsCode||"";t.headerText=ko.computed({read:function(){switch(t.status()){case"ConfirmedReservation":return IBE.Utils.translate("reservationSuccessful");case"NewRequest":return IBE.Utils.translate("requestSuccessful");default:return""}},deferEvaluation:!0});t.availableActions=ko.observableArray([]);typeof n.availableActions!="undefined"&&ko.utils.arrayForEach(n.availableActions,function(n){switch(n){case"ConfirmedReservation":case"CancelledReservation":case"CancelledRequest":t.availableActions().push(n)}});t.rooms=ko.utils.arrayMap(n.rooms,function(n){return new IBE.Models.ReservationRoom(n)})||[];t.supplements=ko.utils.arrayMap(n.supplements,function(n){return new IBE.Models.ReservationSupplement(n)})||[];t.cancellationRules=ko.utils.arrayMap(n.cancellationRules,function(n){return new IBE.Models.CancellationRule(n)})||[];t.customer=new IBE.Models.Customer(n.customer);t.cancellationCost=ko.computed(function(){var i=moment(),n=ko.utils.arrayFirst(t.cancellationRules,function(n){var t=i.diff(n.cancelBefore,"days",!0);return t>0});return n!=null?n.cancelAmount:0});t.guests=ko.observableArray([]);n.guests=n.guests||[];ko.utils.arrayForEach(n.guests,function(n){t.guests.push(new IBE.Models.ReservationGuest(n))});r=0;n.guests.length===0&&(u=t.rooms.sort(function(n,t){return n.roomIndex>t.roomIndex?1:-1}),ko.utils.arrayForEach(u,function(u,f){var e=0;for(f!==0||n.webCheckIn||(n.customer.index=r++,n.customer.roomIndex=u.roomIndex,t.guests.push(new IBE.Models.ReservationGuest(n.customer)),e=1),i=e;i<u.adults;i++)u.index=r++,t.guests.push(new IBE.Models.ReservationGuest(u));for(i=0;i<u.children;i++)u.index=r++,t.guests.push(new IBE.Models.ReservationGuest(u));for(i=0;i<u.infants;i++)u.index=r++,t.guests.push(new IBE.Models.ReservationGuest(u))}));t.canUpdateReservation=function(){return t.status()!=="ConfirmedReservation"?!1:t.sourceName!=="Direct"?!1:moment(t.checkIn).endOf("day").diff(moment().endOf("day"),"days")<=0?!1:!0};t.canModifyReservation=function(){return t.status()!=="ConfirmedReservation"?!1:t.sourceName!=="Direct"?!1:moment(t.checkIn).endOf("day").diff(moment().endOf("day"),"days")<=0?!1:t.availableActions().length?!0:!1};t.refresh=function(n){t.id=n.id||0;t.code=n.code||"";t.orderId=n.orderId||"";t.currencyCode=n.currencyCode||"";t.status(n.status);t.hotelId=n.hotelId||0;t.hotelName=n.hotelName||"";t.checkIn=n.checkIn||"";t.checkOut=n.checkOut||"";t.couponCode=n.couponCode||"";t.created=n.created||"";t.cancelled=n.cancellationDate||"";t.lastModified=n.modified||"";t.notes(n.notes);t.arrivalNotes(n.arrivalNotes);t.totalCost(n.totalCost);t.totalCostWithoutDiscount(n.totalCostWithoutDiscount);t.advancePayment(n.advancePayment);t.sourceName=n.sourceName||"";t.sourceType=n.sourceType||"";t.availableActions(n.availableActions)}};IBE.Models.ReservationGuest=function(n){var t=this;n=n||{};t.index=ko.observable(n.index);t.customerId=n.customerId||null;t.providerId=n.providerId||null;t.roomIndex=ko.observable(n.roomIndex);t.guestType=n.guestType;t.firstName=ko.observable(n.firstName);t.lastName=ko.observable(n.lastName);t.birthday=ko.observable(n.birthday);t.telephone=ko.observable(n.telephone).extend({required:{message:IBE.Utils.translate("requiredTelephone")}});t.address=ko.observable(n.address);t.citizenshipCountry=ko.observable(n.citizenshipCountry);t.email=ko.observable(n.email);t.idNumber=ko.observable(n.idNumber);t.documentNumber=ko.observable(n.documentNumber);t.documentType=ko.observable(n.documentType);t.title=ko.observable(n.title);t.gender=ko.observable(n.gender);t.occupation=ko.observable(n.occupation)};IBE.Models.ReservationRoom=function(n){var t=this;t.id=n.id||n.roomId||0;t.roomIndex=n.roomIndex;t.adults=n.adults;t.children=n.children;t.infants=n.infants;t.childrenAges=[];n.roomGuests&&ko.utils.arrayForEach(n.roomGuests,function(n){if(n.ageCategory===IBE.Config.guestType.Children)for(var i=0;i<n.ages.length;i++)t.childrenAges.push(n.ages[i])});t.name=n.name;t.board={name:n.boardName,type:n.boardType,price:n.boardCost,priceBeforeDiscount:n.boardCostBeforeDiscount};t.ratePlanId=n.ratePlanId;t.ratePlanName=n.ratePlanName;t.totalCost=n.totalCost;t.totalCostBeforeDiscount=n.totalCostBeforeDiscount;t.roomCost=n.roomCost;t.roomCostBeforeDiscount=n.roomCostBeforeDiscount;t.payments=ko.utils.arrayMap(n.payments,function(n){return new IBE.Models.Payment(n)});t.roomPhoto=n.roomPhoto||"https://app.bookwize.com/admin/PHOTOS/no-image-466-275.png"};IBE.Models.Payment=function(n){var t=this;t.amount=n.amount;t.datePaid=n.datePaid;t.dateToPay=n.dateToPay;t.id=n.id;t.paymentType=n.paymentType;t.status=n.status;t.transactionId=n.transactionId};IBE.Models.CancellationRule=function(n){var t=this;n=n||{};t.daysBeforeCheckIn=n.daysBeforeCheckIn||0;t.minimumPenalty=n.minimumPenalty||0;t.minimumPenaltyType=n.minimumPenaltyType||"";t.penalty=n.penalty||0;t.penaltyType=n.penaltyType||"";t.text=n.text};IBE.Models.PaymentRule=function(n,t){var i=this;n=n||{};i.index=n.index||0;i.charge=n.charge||0;i.chargeType=n.chargeType||"";i.daysUntilCheckInMax=n.daysUntilCheckInMax||0;i.daysUntilCheckInMin=n.daysUntilCheckInMin||0;i.minimumCharge=n.minimumCharge||0;i.minimumChargeType=n.minimumChargeType||"";i.ruleType=n.ruleType||"";i.text=ko.computed(function(){var n="",f="",r="",u;switch(i.chargeType){case"Percentage":n="%";break;case"FixedPrice":n="";break;case"RoomNight":i.charge>t&&(i.charge=t);n=i.charge>1?IBE.Utils.translate("roomNights"):IBE.Utils.translate("roomNight")}switch(i.minimumChargeType){case"Percentage":f="%";break;case"FixedPrice":f="";break;case"RoomNight":i.minimumCharge>t&&(i.minimumCharge=t);f=i.minimumCharge>1?IBE.Utils.translate("roomNights"):IBE.Utils.translate("roomNight")}if(u="",(i.minimumChargeType!=i.chargeType||i.minimumCharge>i.charge)&&i.minimumCharge>0&&(u="("+i.minimumCharge+" "+f+" "+IBE.Utils.translate("minimum")+") "),i.charge==0)r=IBE.Utils.translate("noAdvancePayment");else if(i.charge==100&&i.chargeType==0)r=IBE.Utils.translate("fullPrepaymentRequired");else switch(i.ruleType){case"OnRequest":r=IBE.Utils.translate("advancePaymentRequiredReservationPlacement").format(i.charge,n,u);break;case"PriorToArrival":r=i.index===0?IBE.Utils.translate("advancePaymentRequiredDaysBeforeArrivalSingle").format(i.charge,n,u,i.daysUntilCheckInMin):IBE.Utils.translate("advancePaymentRequiredDaysBeforeArrival").format(i.charge,n,u,i.daysUntilCheckInMin);break;case"FromRequestUntilCheckIn":r=IBE.Utils.translate("advancePaymentRequiredDaysAfterRequest").format(i.charge,n,u,i.daysUntilCheckInMin);break;case"OnCheckOut":r=IBE.Utils.translate("advancePaymentRequiredDaysAfterRequest").format(i.charge,n,u,i.daysUntilCheckInMin)}return r})};IBE.Models.ReservationSupplement=function(n){var t=this;n=n||{};t.supplementId=ko.observable(n.id||0);t.category=n.category||"";t.name=n.name||"";t.description=n.description||"";t.quantity=ko.observable(n.quantity||0);t.isUnique=ko.observable(n.isUnique||!1);t.pricingType=ko.observable(n.pricingType||"");t.timePricingType=ko.observable(n.timePricingType||"");t.timePricingUnit=ko.observable(n.timePricingUnit||"");t.roomIndex=ko.observable(n.roomIndex||0);t.unitCost=ko.observable(n.unitCost||0);t.unitCostBeforeDiscount=ko.observable(n.unitCostBeforeDiscount||0);t.totalPrice=ko.computed(function(){return t.quantity()*t.unitCost()});t.totalPriceBeforeDiscount=ko.computed(function(){return t.quantity()&t.unitCostBeforeDiscount()});t.photos=IBE.Utils.populatePhotos(n.photos)};IBE.Models.RoomGuest=function(){var n=this;ko.utils.extend(n,IBE.Models.RequestedRoomGuestType);n.ages=ko.observableArray([])};IBE.Models.GoogleMap=function(n){var t=this;t.zoom=n.address.zoom||10;t.latitude=ko.observable(n.address.latitude);t.longitude=ko.observable(n.address.longitude);t.marker=ko.observable({title:n.name,street:n.address.street})};IBE.Models.Message=function(n){var t=this;n=n||{};t.id=ko.observable(n.id||0);t.severity=ko.observable(n.severity||"");t.text=ko.observable(n.text||"")};IBE.Models.Contact=function(){var n=this;n.firstName=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.lastName=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.email=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.subject=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.text=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}})};IBE.ViewModels.Message=function(){var n=this;n._msg=ko.observable(new IBE.Models.Message);n.message=ko.computed({write:function(t){n._msg(new IBE.Models.Message(t))},read:function(){return n._msg()},deferEvaluation:!0});n.clearMessage=function(){n.message({id:0,severity:"",text:""})};n.hasMessage=function(){return n.message().text()!==""}};IBE.Models.Hop=function(n){var t=this;n=n||{};t.checkIn=ko.observable(n.checkIn||"");t.checkOut=ko.observable(n.checkOut||"");t.couponCode=ko.observable(n.couponCode||"");t.minCheckInDate=ko.observable(n.minCheckInDate||"");t.guests=n.guests||[];t.destination=n.destination||null;t.current=ko.observable(n.current||!1)};IBE.Models.Referrer=function(n){var t=this;n=n||{};t.name=n.name||"";t.campaign=n.campaign;t.params=n.params||{}},function(n){n.datepick.regionalOptions.da={monthNames:["Januar","Februar","Marts","April","Maj","Juni","Juli","August","September","Oktober","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec"],dayNames:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"],dayNamesShort:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],dayNamesMin:["Sø","Ma","Ti","On","To","Fr","Lø"],dateFormat:"dd-mm-yyyy",firstDay:0,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Forrige",prevStatus:"Vis forrige måned",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Næste&#x3e;",nextStatus:"Vis næste måned",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Idag",currentStatus:"Vis aktuel måned",todayText:"Idag",todayStatus:"Vis aktuel måned",clearText:"Nulstil",clearStatus:"Nulstil den aktuelle dato",closeText:"Luk",closeStatus:"Luk uden ændringer",yearStatus:"Vis et andet år",monthStatus:"Vis en anden måned",weekText:"Uge",weekStatus:"Årets uge",dayStatus:"Vælg D, M d",defaultStatus:"Vælg en dato",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.da)}(jQuery),function(n){n.datepick.regionalOptions.cs={monthNames:["leden","únor","březen","duben","květen","červen","červenec","srpen","září","říjen","listopad","prosinec"],monthNamesShort:["led","úno","bře","dub","kvě","čer","čvc","srp","zář","říj","lis","pro"],dayNames:["neděle","pondělí","úterý","středa","čtvrtek","pátek","sobota"],dayNamesShort:["ne","po","út","st","čt","pá","so"],dayNamesMin:["ne","po","út","st","čt","pá","so"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Dříve",prevStatus:"Přejít na předchozí měsí",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Později&#x3e;",nextStatus:"Přejít na další měsíc",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Nyní",currentStatus:"Přejde na aktuální měsíc",todayText:"Nyní",todayStatus:"Přejde na aktuální měsíc",clearText:"Vymazat",clearStatus:"Vymaže zadané datum",closeText:"Zavřít",closeStatus:"Zavře kalendář beze změny",yearStatus:"Přejít na jiný rok",monthStatus:"Přejít na jiný měsíc",weekText:"Týd",weekStatus:"Týden v roce",dayStatus:"'Vyber' DD, M d",defaultStatus:"Vyberte datum",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.cs)}(jQuery),function(n){n.datepick.regionalOptions.de={monthNames:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],monthNamesShort:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],dayNames:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],dayNamesShort:["So","Mo","Di","Mi","Do","Fr","Sa"],dayNamesMin:["So","Mo","Di","Mi","Do","Fr","Sa"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;zurück",prevStatus:"letzten Monat zeigen",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Vor&#x3e;",nextStatus:"nächsten Monat zeigen",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"heute",currentStatus:"",todayText:"heute",todayStatus:"",clearText:"löschen",clearStatus:"aktuelles Datum löschen",closeText:"schließen",closeStatus:"ohne Änderungen schließen",yearStatus:"anderes Jahr anzeigen",monthStatus:"anderen Monat anzeigen",weekText:"Wo",weekStatus:"Woche des Monats",dayStatus:"Wähle D, M d",defaultStatus:"Wähle ein Datum",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.de)}(jQuery),function(n){n.datepick.regionalOptions["el-GR"]={monthNames:["Ιανουαριος","Φεβρουαριος","Μαρτιος","Απριλιος","Μαιος","Ιουνιος","Ιουλιος","Αυγουστος","Σεπτεμβριος","Οκτωβριος","Νοεμβριος","Δεκεμβριος"],monthNamesShort:["Ιαν","Φεβ","Μαρ","Απρ","Μαι","Ιουν","Ιουλ","Αυγ","Σεπ","Οκτ","Νοε","Δεκ"],dayNames:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"],dayNamesShort:["Κυρ","Δευ","Τρι","Τετ","Πεμ","Παρ","Σαβ"],dayNamesMin:["Κυ","Δε","Τρ","Τε","Πε","Πα","Σα"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"Προηγούμενος",prevStatus:"Επισκόπηση προηγούμενου μήνα",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Επόμενος",nextStatus:"Επισκόπηση επόμενου μήνα",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Τρέχων Μήνας",currentStatus:"Επισκόπηση τρέχοντος μήνα",todayText:"Τρέχων Μήνας",todayStatus:"Επισκόπηση τρέχοντος μήνα",clearText:"Σβήσιμο",clearStatus:"Σβήσιμο της επιλεγμένης ημερομηνίας",closeText:"Κλείσιμο",closeStatus:"Κλείσιμο χωρίς αλλαγή",yearStatus:"Επισκόπηση άλλου έτους",monthStatus:"Επισκόπηση άλλου μήνα",weekText:"Εβδ",weekStatus:"",dayStatus:"Επιλογή DD d MM",defaultStatus:"Επιλέξτε μια ημερομηνία",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions["el-GR"])}(jQuery),function(n){n.datepick.regionalOptions.el={monthNames:["Ιανουαριος","Φεβρουαριος","Μαρτιος","Απριλιος","Μαιος","Ιουνιος","Ιουλιος","Αυγουστος","Σεπτεμβριος","Οκτωβριος","Νοεμβριος","Δεκεμβριος"],monthNamesShort:["Ιαν","Φεβ","Μαρ","Απρ","Μαι","Ιουν","Ιουλ","Αυγ","Σεπ","Οκτ","Νοε","Δεκ"],dayNames:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"],dayNamesShort:["Κυρ","Δευ","Τρι","Τετ","Πεμ","Παρ","Σαβ"],dayNamesMin:["Κυ","Δε","Τρ","Τε","Πε","Πα","Σα"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"Προηγούμενος",prevStatus:"Επισκόπηση προηγούμενου μήνα",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Επόμενος",nextStatus:"Επισκόπηση επόμενου μήνα",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Τρέχων Μήνας",currentStatus:"Επισκόπηση τρέχοντος μήνα",todayText:"Τρέχων Μήνας",todayStatus:"Επισκόπηση τρέχοντος μήνα",clearText:"Σβήσιμο",clearStatus:"Σβήσιμο της επιλεγμένης ημερομηνίας",closeText:"Κλείσιμο",closeStatus:"Κλείσιμο χωρίς αλλαγή",yearStatus:"Επισκόπηση άλλου έτους",monthStatus:"Επισκόπηση άλλου μήνα",weekText:"Εβδ",weekStatus:"",dayStatus:"Επιλογή DD d MM",defaultStatus:"Επιλέξτε μια ημερομηνία",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.el)}(jQuery),function(n){n.datepick.regionalOptions.es={monthNames:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],monthNamesShort:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],dayNames:["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"],dayNamesShort:["Dom","Lun","Mar","Mié","Juv","Vie","Sáb"],dayNamesMin:["Do","Lu","Ma","Mi","Ju","Vi","Sá"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Ant",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Sig&#x3e;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Hoy",currentStatus:"",todayText:"Hoy",todayStatus:"",clearText:"Limpiar",clearStatus:"",closeText:"Cerrar",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Sm",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.es)}(jQuery),function(n){n.datepick.regionalOptions.fi={monthNames:["Tammikuu","Helmikuu","Maaliskuu","Huhtikuu","Toukokuu","Kes&auml;kuu","Hein&auml;kuu","Elokuu","Syyskuu","Lokakuu","Marraskuu","Joulukuu"],monthNamesShort:["Tammi","Helmi","Maalis","Huhti","Touko","Kes&auml;","Hein&auml;","Elo","Syys","Loka","Marras","Joulu"],dayNamesShort:["Su","Ma","Ti","Ke","To","Pe","Su"],dayNames:["Sunnuntai","Maanantai","Tiistai","Keskiviikko","Torstai","Perjantai","Lauantai"],dayNamesMin:["Su","Ma","Ti","Ke","To","Pe","La"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&laquo;Edellinen",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Seuraava&raquo;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"T&auml;n&auml;&auml;n",currentStatus:"",todayText:"T&auml;n&auml;&auml;n",todayStatus:"",clearText:"Tyhjenn&auml;",clearStatus:"",closeText:"Sulje",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Vk",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.fi)}(jQuery),function(n){n.datepick.regionalOptions.fr={monthNames:["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"],monthNamesShort:["Jan","Fév","Mar","Avr","Mai","Jun","Jul","Aoû","Sep","Oct","Nov","Déc"],dayNames:["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"],dayNamesShort:["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"],dayNamesMin:["Di","Lu","Ma","Me","Je","Ve","Sa"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Préc",prevStatus:"Voir le mois précédent",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"Voir l'année précédent",nextText:"Suiv&#x3e;",nextStatus:"Voir le mois suivant",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"Voir l'année suivant",currentText:"Courant",currentStatus:"Voir le mois courant",todayText:"Aujourd'hui",todayStatus:"Voir aujourd'hui",clearText:"Effacer",clearStatus:"Effacer la date sélectionnée",closeText:"Fermer",closeStatus:"Fermer sans modifier",yearStatus:"Voir une autre année",monthStatus:"Voir un autre mois",weekText:"Sm",weekStatus:"Semaine de l'année",dayStatus:"'Choisir' le DD d MM",defaultStatus:"Choisir la date",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.fr)}(jQuery),function(n){n.datepick.regionalOptions.it={monthNames:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"],monthNamesShort:["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"],dayNames:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"],dayNamesShort:["Dom","Lun","Mar","Mer","Gio","Ven","Sab"],dayNamesMin:["Do","Lu","Ma","Me","Gi","Ve","Sa"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Prec",prevStatus:"Mese precedente",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"Mostra l'anno precedente",nextText:"Succ&#x3e;",nextStatus:"Mese successivo",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"Mostra l'anno successivo",currentText:"Oggi",currentStatus:"Mese corrente",todayText:"Oggi",todayStatus:"Mese corrente",clearText:"Svuota",clearStatus:"Annulla",closeText:"Chiudi",closeStatus:"Chiudere senza modificare",yearStatus:"Seleziona un altro anno",monthStatus:"Seleziona un altro mese",weekText:"Sm",weekStatus:"Settimana dell'anno",dayStatus:"'Seleziona' D, M d",defaultStatus:"Scegliere una data",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.it)}(jQuery),function(n){n.datepick.regionalOptions.pl={monthNames:["Styczeń","Luty","Marzec","Kwiecień","Maj","Czerwiec","Lipiec","Sierpień","Wrzesień","Październik","Listopad","Grudzień"],monthNamesShort:["Sty","Lu","Mar","Kw","Maj","Cze","Lip","Sie","Wrz","Pa","Lis","Gru"],dayNames:["Niedziela","Poniedzialek","Wtorek","Środa","Czwartek","Piątek","Sobota"],dayNamesShort:["Nie","Pn","Wt","Śr","Czw","Pt","So"],dayNamesMin:["N","Pn","Wt","Śr","Cz","Pt","So"],dateFormat:"yyyy-mm-dd",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Poprzedni",prevStatus:"Pokaż poprzedni miesiąc",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Następny&#x3e;",nextStatus:"Pokaż następny miesiąc",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Dziś",currentStatus:"Pokaż aktualny miesiąc",todayText:"Dziś",todayStatus:"Pokaż aktualny miesiąc",clearText:"Wyczyść",clearStatus:"Wyczyść obecną datę",closeText:"Zamknij",closeStatus:"Zamknij bez zapisywania",yearStatus:"Pokaż inny rok",monthStatus:"Pokaż inny miesiąc",weekText:"Tydz",weekStatus:"Tydzień roku",dayStatus:"'Wybierz' D, M d",defaultStatus:"Wybierz datę",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.pl)}(jQuery),function(n){n.datepick.regionalOptions.pt={monthNames:["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],monthNamesShort:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],dayNames:["Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado"],dayNamesShort:["Dom","Seg","Ter","Qua","Qui","Sex","Sáb"],dayNamesMin:["D","S","T","Q","Q","S","S"],dateFormat:"dd/mm/yyyy",firstDay:0,renderer:n.datepick.defaultRenderer,prevText:"&lt;Anterior",prevStatus:"Mês anterior",prevJumpText:"&lt;&lt;",prevJumpStatus:"Ano anterior",nextText:"Próximo&gt;",nextStatus:"Próximo mês",nextJumpText:"&gt;&gt;",nextJumpStatus:"Próximo ano",currentText:"Atual",currentStatus:"Mês atual",todayText:"Hoje",todayStatus:"Hoje",clearText:"Limpar",clearStatus:"Limpar data",closeText:"Fechar",closeStatus:"Fechar o calendário",yearStatus:"Selecionar ano",monthStatus:"Selecionar mês",weekText:"s",weekStatus:"Semana do ano",dayStatus:"DD, d 'de' M 'de' yyyy",defaultStatus:"Selecione um dia",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.pt)}(jQuery),function(n){n.datepick.regionalOptions.ru={monthNames:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],monthNamesShort:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],dayNames:["воскресенье","понедельник","вторник","среда","четверг","пятница","суббота"],dayNamesShort:["вск","пнд","втр","срд","чтв","птн","сбт"],dayNamesMin:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Пред",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"След&#x3e;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Сегодня",currentStatus:"",todayText:"Сегодня",todayStatus:"",clearText:"Очистить",clearStatus:"",closeText:"Закрыть",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Не",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.ru)}(jQuery),function(n){n.datepick.regionalOptions.sk={monthNames:["Január","Február","Marec","Apríl","Máj","Jún","Júl","August","September","Október","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","Máj","Jún","Júl","Aug","Sep","Okt","Nov","Dec"],dayNames:["Nedel'a","Pondelok","Utorok","Streda","Štvrtok","Piatok","Sobota"],dayNamesShort:["Ned","Pon","Uto","Str","Štv","Pia","Sob"],dayNamesMin:["Ne","Po","Ut","St","Št","Pia","So"],dateFormat:"dd.mm.yyyy",firstDay:0,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Predchádzajúci",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Nasledujúci&#x3e;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Dnes",currentStatus:"",todayText:"Dnes",todayStatus:"",clearText:"Zmazať",clearStatus:"",closeText:"Zavrieť",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Ty",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.sk)}(jQuery),function(n){n.datepick.regionalOptions.sq={monthNames:["Janar","Shkurt","Mars","Prill","Maj","Qershor","Korrik","Gusht","Shtator","Tetor","Nëntor","Dhjetor"],monthNamesShort:["Jan","Shk","Mar","Pri","Maj","Qer","Kor","Gus","Sht","Tet","Nën","Dhj"],dayNames:["E Diel","E Hënë","E Martë","E Mërkurë","E Enjte","E Premte","E Shtune"],dayNamesShort:["Di","Hë","Ma","Më","En","Pr","Sh"],dayNamesMin:["Di","Hë","Ma","Më","En","Pr","Sh"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;mbrapa",prevStatus:"trego muajin e fundit",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Përpara&#x3e;",nextStatus:"trego muajin tjetër",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"sot",currentStatus:"",todayText:"sot",todayStatus:"",clearText:"fshije",clearStatus:"fshije datën aktuale",closeText:"mbylle",closeStatus:"mbylle pa ndryshime",yearStatus:"trego tjetër vit",monthStatus:"trego muajin tjetër",weekText:"Ja",weekStatus:"Java e muajit",dayStatus:"'Zgjedh' D, M d",defaultStatus:"Zgjedhe një datë",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.sq)}(jQuery),function(n){n.datepick.regionalOptions.nl={monthNames:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],monthNamesShort:["jan","feb","maa","apr","mei","jun","jul","aug","sep","okt","nov","dec"],dayNames:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"],dayNamesShort:["zon","maa","din","woe","don","vri","zat"],dayNamesMin:["zo","ma","di","wo","do","vr","za"],dateFormat:"dd-mm-yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"←",prevStatus:"Bekijk de vorige maand",prevJumpText:"«",prevJumpStatus:"Bekijk het vorige jaar",nextText:"→",nextStatus:"Bekijk de volgende maand",nextJumpText:"»",nextJumpStatus:"Bekijk het volgende jaar",currentText:"Vandaag",currentStatus:"Bekijk de huidige maand",todayText:"Vandaag",todayStatus:"Bekijk de huidige maand",clearText:"Wissen",clearStatus:"Wis de huidige datum",closeText:"Sluiten",closeStatus:"Sluit zonder verandering",yearStatus:"Bekijk een ander jaar",monthStatus:"Bekijk een andere maand",weekText:"Wk",weekStatus:"Week van het jaar",dayStatus:"dd-mm-yyyy",defaultStatus:"Kies een datum",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.nl)}(jQuery),function(n){n.datepick.regionalOptions.no={monthNames:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],monthNamesShort:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],dayNamesShort:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],dayNames:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"],dayNamesMin:["Sø","Ma","Ti","On","To","Fr","Lø"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&laquo;Forrige",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Neste&raquo;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"I dag",currentStatus:"",todayText:"I dag",todayStatus:"",clearText:"Tøm",clearStatus:"",closeText:"Lukk",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Uke",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.no)}(jQuery),function(n){n.datepick.regionalOptions.sv={monthNames:["Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec"],dayNames:["Söndag","Måndag","Tisdag","Onsdag","Torsdag","Fredag","Lördag"],dayNamesShort:["Sön","Mån","Tis","Ons","Tor","Fre","Lör"],dayNamesMin:["Sö","Må","Ti","On","To","Fr","Lö"],dateFormat:"yyyy-mm-dd",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&laquo;Förra",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Nästa&raquo;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Idag",currentStatus:"",todayText:"Idag",todayStatus:"",clearText:"Rensa",clearStatus:"",closeText:"Stäng",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Ve",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.sv)}(jQuery),function(n){n.datepick.regionalOptions.en={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"Prev",prevStatus:"Show the previous month",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"Show the previous year",nextText:"Next",nextStatus:"Show the next month",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"Show the next year",currentText:"Current",currentStatus:"Show the current month",todayText:"Today",todayStatus:"Show today's month",clearText:"Clear",clearStatus:"Erase the current date",closeText:"Done",closeStatus:"Close without change",yearStatus:"Show a different year",monthStatus:"Show a different month",weekText:"Wk",weekStatus:"Week of the year",dayStatus:"Select DD, M d",defaultStatus:"Select a date",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions["en-GB"])}(jQuery),function(n){n.datepick.regionalOptions["en-US"]={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],dateFormat:"dd MM yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"Prev",prevStatus:"Show the previous month",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"Show the previous year",nextText:"Next",nextStatus:"Show the next month",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"Show the next year",currentText:"Current",currentStatus:"Show the current month",todayText:"Today",todayStatus:"Show today's month",clearText:"Clear",clearStatus:"Erase the current date",closeText:"Done",closeStatus:"Close without change",yearStatus:"Show a different year",monthStatus:"Show a different month",weekText:"Wk",weekStatus:"Week of the year",dayStatus:"Select DD, M d",defaultStatus:"Select a date",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions["en-US"])}(jQuery);IBE.Models.BookingProcess=function(n){var t=this;ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Taxes(t));(typeof n=="undefined"||n==null)&&(n={});t.checkIn=ko.assignObservable(n.checkIn);t.checkOut=ko.assignObservable(n.checkOut);t.couponCode=ko.assignObservable(n.couponCode,"");t.rooms=ko.assignObservableArray(n.rooms);t.supplements=ko.observableArray([]);n.supplements&&ko.utils.arrayPushAll(t.supplements,n.supplements);t.cost=ko.assignObservable(n.cost,0);t.costWithoutDiscount=ko.assignObservable(n.costWithoutDiscount,0);t.advancePayment=ko.assignObservable(n.advancePayment,0);t.tax=ko.assignObservable(n.tax);t.reservationStatus=ko.assignObservable(n.reservationStatus);t.currency=ko.assignObservable(n.currency);t.id=ko.assignObservable(n.Id,"");t.isOnline=ko.assignObservable(n.isOnline,!1);t.cancellationPolicy=ko.assignObservable(n.cancellationPolicy,"");t.paymentPolicy=ko.assignObservable(n.paymentPolicy,"");t.paymentPolicyHotelTextOption=ko.assignObservable(n.paymentPolicyHotelTextOption,"Unknown");t.payments=ko.observableArray();t.timePolicy=ko.assignObservableArray(n.timePolicy,"");t.customer=ko.assignObservable(n.customer);t.nights=ko.computed({read:function(){return t.checkOut().diff(t.checkIn(),"days")},deferEvaluation:!0});t.totalGuests=ko.observable(n.totalGuests||0);t.lang=ko.assignObservable(n.lang);t.roomsCost=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.rooms(),function(t){n+=t.cost()}),n},deferEvaluation:!0});t.supplementsCost=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.supplements(),function(t){n+=t.totalPrice()}),n},deferEvaluation:!0});t.totalCost=ko.computed({read:function(){var n=0;return n+=t.roomsCost(),n+t.supplementsCost()},deferEvaluation:!0});t.roomsCostWithoutDiscount=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.rooms(),function(t){n+=t.costWithoutDiscount()}),n},deferEvaluation:!0});t.supplementsCostWithoutDiscount=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.supplements(),function(t){n+=t.totalPriceWithoutDiscount()}),n},deferEvaluation:!0});t.paymentMethodType=ko.observable(n.paymentMethod);t.totalCostWithoutDiscount=ko.computed({read:function(){var n=0;return n+=t.roomsCostWithoutDiscount(),n+t.supplementsCostWithoutDiscount()},deferEvaluation:!0});t.paymentRules=ko.computed({read:function(){var n=[],e,o;if(t.payments().length===0)return n;var i=0,u=t.checkIn(),s=t.checkOut(),f=moment().startOf("day"),r=t.totalCost();if(ko.utils.arrayForEach(t.payments(),function(i){var u=ko.toJS(i);u.amountCurrency=t.getRateText(u.amount,t.currency());n.push(u);r-=i.amount}),r>0){for(i=n.length-1,n[i].paymentDate===u.format("YYYY-MM-DD")||n[i].paymentDate===s.format("YYYY-MM-DD")?(n[i].amount+=r,n[i].amountCurrency=t.getRateText(n[i].amount,t.currency())):n.push({amount:r,paymentDate:u.format("YYYY-MM-DD"),amountCurrency:t.getRateText(r,t.currency())}),e=!1,i=0;i<n.length;i++)if(f.diff(n[i].paymentDate,"days")===0){e=!0;break}e||n.unshift({paymentDate:f.format("YYYY-MM-DD"),amount:0,amountCurrency:t.getRateText(0,t.currency()),text:IBE.Utils.translate("noAdvancePayment")})}return o=0,ko.utils.arrayForEach(n,function(n){var r=moment(n.paymentDate),i=IBE.Utils.dateIsoFormat(r),t=n.amount;if(IBE.Utils.dateIsoFormat(f)===i&&o===0){t>0?(n.text=IBE.Utils.translate("paymentRuleAdvancePayment").format(n.amountCurrency),o=t):n.text=IBE.Utils.translate("noAdvancePayment");return}if(IBE.Utils.dateIsoFormat(u)===i&&t>0){n.text=IBE.Utils.translate("paymentRulePayUponCheckIn").format(n.amountCurrency);return}if(IBE.Utils.dateIsoFormat(s)===i&&t>0){n.text=IBE.Utils.translate("paymentRulePayUponCheckOut").format(n.amountCurrency);return}if(t>0){n.text=IBE.Utils.translate("paymentRulePayOnDate").format(n.amountCurrency,moment(r).format("DD/MM/YYYY"));return}}),n},deferEvaluation:!0});t.paymentText=ko.computed({read:function(){var n="";ko.utils.arrayForEach(t.paymentRules(),function(t){t.text&&t.text!==""&&(n+="<li>"+t.text+"<\/li>")});switch(t.paymentPolicyHotelTextOption()){case"Append":return n+"<p>"+t.paymentPolicy()+"<\/p>";case"Replace":return t.paymentPolicy();default:return n}},deferEvaluation:!0});t.timePolicyText=ko.computed({read:function(){var n="";return IBE.Config.ibeTimePolicy?(ko.utils.arrayForEach(t.timePolicy(),function(t){t&&t!==""&&(n+="<li>"+t+"<\/li>")}),n=n.replace("Check-In",IBE.Utils.translate("checkIn")),n=n.replace("Check-Out",IBE.Utils.translate("checkOut")),n=n.replace("From",IBE.Utils.translate("from")),n=n.replace("From",IBE.Utils.translate("from")),n=n.replace("to",IBE.Utils.translate("to")),n=n.replace("to",IBE.Utils.translate("to"))):n},deferEvaluation:!0});t.isValidStay=ko.pureComputed({read:function(){return isNaN(t.nights())||t.nights()<=0?!1:!0}});t.bookingProcessPostData=function(){var n={checkIn:t.checkIn().format("YYYY-MM-DD"),checkOut:t.checkOut().format("YYYY-MM-DD"),couponCode:t.couponCode(),ipAddress:null,notes:"",customer:t.customer(),rooms:[],supplements:[],referrer:new IBE.Models.Referrer};return Cache.read("ref","localstorage")&&(n.referrer=Cache.read("ref","localstorage")),typeof t.customer()!="undefined"&&(n.notes=t.customer().notes()),ko.utils.arrayForEach(t.rooms(),function(t){var i={availability:ko.unwrap(t.availability),boardType:ko.unwrap(t.boardType),ratePlanId:ko.unwrap(t.ratePlanId),roomId:ko.unwrap(t.roomId),roomIndex:ko.unwrap(t.roomIndex),guestTypes:[]};ko.utils.arrayForEach(ko.unwrap(t.guestTypes),function(n){i.guestTypes.push({ageCategory:ko.unwrap(n.ageCategory),fromAge:ko.unwrap(n.fromAge),pax:ko.unwrap(n.pax)})});n.rooms.push(i)}),ko.utils.arrayForEach(t.supplements(),function(t){ko.utils.arrayForEach(t.prices(),function(i){if(i.quantity()>0){IBE.Config.supplementPricingType[t.pricingType()]!==IBE.Config.supplementPricingType.PerGuest&&(i.guestType=0);var r={roomIndex:t.roomIndex(),supplementId:t.supplementId(),quantity:i.quantity(),isMandatory:t.isMandatory,pricingType:t.supplementPricingType,guestType:i.guestType};n.supplements.push(r)}})}),n};$.when(t.currenciesPartialInit()).then(function(){})};IBE.ViewModels.Contact=function(){var n=this;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.Models.Contact);n.errors=ko.validation.group(n);n.submit=function(){if(n.clearMessage(),n.errors().length>0)return n.errors.showAllMessages(),!1;n.ready(!1);n.events.notifySubscribers(!1,"ready");var t={message:"Sender: "+n.firstName()+" "+n.lastName()+", <em>"+n.email()+"<\/em><br /><p>"+n.text()+"<\/p>",subject:n.subject()};$.ajax({type:"POST",data:t,url:IBE.Config.apiBaseUrl+"/system/sendmail/?apikey="+IBE.Config.apiKey,success:function(){n.clearMessage();var t={id:200,severity:"success",text:IBE.Utils.translate("contactSendSuccess")};n.message(t);ko.utils.extend(n,new IBE.Models.Contact);n.ready(!0);n.events.notifySubscribers(!0,"ready")},error:function(t){n.clearMessage();var i={id:t.status,severity:"error",text:IBE.Utils.translate("contactSendFailed")};n.message(i);n.ready(!0);n.events.notifySubscribers(!0,"ready")}})};n.init=function(){n.clearMessage();n.ready(!0);n.events.notifySubscribers(!0,"ready")}};IBE.ViewModels.CurrenciesPartialViewModel=function(n){function t(t){if(t.length===0)return!1;var i=new IBE.Models.Currencies;return i.base=t[0].base,ko.utils.arrayForEach(t,function(n){n.Name!=="ERR"&&i.rates.push(new IBE.Models.CurrencyRate(n))}),n.currencies(i),typeof n.currency()=="undefined"&&n.currency(n.baseCurrency),!0}n.baseCurrency=IBE.Config.currency;n.currency=ko.observable();n.currencies=ko.observableArray([]);n.isDifferentCurrency=ko.computed({read:function(){return!(n.currency()===n.baseCurrency)},deferEvaluation:!0}).extend({notify:"always"});n.calculateRate=function(t,i){var r,u;if(n.currencies().length===0)return!1;r=1;try{n.currencies().base!==n.baseCurrency&&(r=ko.utils.arrayFirst(n.currencies().rates,function(t){return t.code==n.baseCurrency}).rate)}catch(f){r=1}u=1;try{u=ko.utils.arrayFirst(n.currencies().rates,function(n){return n.code==t}).rate}catch(f){u=1}return r==1&&u==1?(n.currency(n.baseCurrency),i):u/r*i};n.getRateText=function(t,i,r){var u=i,f;return n.currencies().rates.forEach(function(n){if(n.code==i){u=n.symbol;return}}),f=r||{precision:2,symbol:u,format:"%v %s"},accounting.formatMoney(n.calculateRate(i,t),f)};n.currenciesPartialInit=function(){return $.when(IBE.Utils.loadExchangeRates()).then(function(n){n&&t(n)}),$.when(IBE.Utils.loadExchangeRates())};var i=function(n){n&&t(n)};$.when(IBE.Utils.loadExchangeRates()).then(i)};IBE.ViewModels.CustomerPartialViewModel=function(n){var t=this;ko.utils.extend(t,new IBE.Models.Customer(n));t.paymentReceipt=ko.observable("");t.paymentReceiptOptions=ko.observableArray([{name:"personalInvoice",text:IBE.Utils.translate("personalInvoice")},{name:"companyInvoice",text:IBE.Utils.translate("companyInvoice")}]);t.notes=ko.observable("");t.flightNumber=ko.observable("");t.arrivalTime=ko.observable("");t.arrivalTimeOptions=ko.computed(function(){for(var i,t,r,u=[{name:"",value:""}],n=0;n<24;n++)for(i=n,n<10&&(i="0"+n),t=0;t<2;t++)r=t===0?"0"+t:"30",u.push({name:i+":"+r,value:i+":"+r});return u});t.creditCard=ko.observable(new IBE.Models.CreditCard);t.company=ko.observable(new IBE.Models.Company);t.errors=ko.observable({customer:ko.validation.group(t),creditCard:ko.validation.group(t.creditCard)})};IBE.ViewModels.ExternalPaymentGateway=function(n,t,i){var r=this,e,u,f,o;r.events=new ko.subscribable;ko.utils.extend(r,new IBE.ViewModels.Message);r.ready=ko.observable(!1);r.gateway=ko.observable("");r.paymentToken=ko.observable("");r.externalPaymentGatewayData=ko.observable("");r.redirectPaymentGatewayData=ko.observableArray([]);r.externalPaymentGatewayMessage=ko.observable("");r.externalPaymentGatewayErrors=ko.observable(!1);r.notStoreCreditCard=ko.observable(!1);r.paymentMethod=ko.observable("");r.paymentMethod.subscribe(function(n){r.externalPaymentGatewayData(n)});r.init=function(){r.gateway(t);switch(t){case"Braintree":if(i===""||typeof i=="undefined")return;r.paymentToken(i);break;case"AlphaBankRedirect":break;case"Omise":if(typeof Omise=="undefined")return;Omise.setPublicKey(i);break;case"AuthorizeNet":if(i===""||typeof i=="undefined")return;r.paymentToken(i);break;case"Stripe":if(i===""||typeof i=="undefined")return;r.paymentToken(i);break;case"Payout":if(i===""||typeof i=="undefined")return;r.externalPaymentGatewayData(i);break;default:return}};r.paymentToken.subscribe(function(n){n&&r.paymentToken&&r.initBraintree()});r.initBraintree=function(){var n=r.paymentToken();typeof braintree!="undefined"&&braintree.client.create({authorization:n,threeDSecure:!0},function(n,t){n||(braintree.hostedFields.create({client:t,styles:{"input.invalid":{color:"red"},"input.valid":{color:"green"}},fields:{number:{selector:"#card-number",placeholder:"4111 1111 1111 1111"},cvv:{selector:"#cvv",placeholder:"123"},expirationDate:{selector:"#expiration-date",placeholder:moment(new Date).format("MM/YY")}}},function(n,t){if(e=t,n){r.externalPaymentGatewayErrors(!0);r.events.notifySubscribers(IBE.Utils.translate("correctCreditCard"),"externalPaymentValidation");return}t.on("validityChange",function(){r.externalPaymentGatewayErrors(!1)});r.ready(!0)}),braintree.threeDSecure.create({version:2,client:t},function(n,t){n||(threeDSecure=t)}))})};r.initStripe=function(){var n,t,i;(data=JSON.parse(r.paymentToken()),n=data.publicKey,o=data.clientSecret,typeof Stripe!="undefined")&&(u=Stripe(n,{locale:IBE.Config.lang.split("-",1)[0]}),t=u.elements(),i={base:{color:"#333333",fontFamily:'"ProximaNova-Regular", Helvetica, sans-serif',fontSmoothing:"antialiased",fontSize:"16px","::placeholder":{color:"#999999"}},invalid:{color:"#cd4c2b",iconColor:"#fa755a"}},f=t.create("card",{style:i}),f.mount("#stripe-card"),f.addEventListener("change",function(n){var t=document.getElementById("card-errors");t.textContent=n.error?n.error.message:""}))};r.externalPaymentGatewayErrors.subscribe(function(n){n&&r.externalPaymentGatewayMessage("")});r.beforeSubmit=function(){var c,s,t,i,h;if(typeof braintree!="undefined"&&typeof e!="undefined"&&e.tokenize({cardholderName:$("#cardholder-name").val()},function(t,i){if(t){r.externalPaymentGatewayErrors(!0);r.externalPaymentGatewayMessage(IBE.Utils.translate("correctCreditCard"));return}threeDSecureParameters=r.create3DSobject(i);threeDSecure.verifyCard(threeDSecureParameters,function(t,i){if(t){r.externalPaymentGatewayErrors(!0);return}r.externalPaymentGatewayErrors(!1);r.externalPaymentGatewayData(i.nonce);r.notStoreCreditCard(!0);n.makeReservation()})}),typeof Omise!="undefined"&&(c={name:$("#CustomerCardHolder").val(),number:$("#CustomerNumber").val(),expiration_month:$("#CardExpirationMonth").val(),expiration_year:$("#CardExpirationYear").val(),security_code:$("#CardVerification").val()},Omise.createToken("card",c,function(t,i){t==200?(r.externalPaymentGatewayErrors(!1),r.externalPaymentGatewayData(i.id),r.notStoreCreditCard(!0),n.makeReservation()):(r.externalPaymentGatewayErrors(!0),r.externalPaymentGatewayMessage(i.message))})),typeof Accept!="undefined"){if(s={},t=r.paymentToken().split("-"),t[0]==="undefined"||t[1]==="undefined"||t[0]===""||t[1]===""){n.makeReservation();return}ko.bindingHandlers.addFiledsAuthorizeNet();s.clientKey=t[1];s.apiLoginID=t[0];i={};i.cardNumber=n.customer().creditCard().cardNumber();i.month=n.customer().creditCard().cardExpirationMonth();i.year=n.customer().creditCard().cardExpirationYear();i.cardCode=n.customer().creditCard().cardVerification();h={};h.authData=s;h.cardData=i;Accept.dispatchData(h,l);function l(n){var i=[],t;if(n.messages.resultCode==="Error"){for(t=0;t<n.messages.message.length;)i.push(n.messages.message[t].text),t=t+1;r.externalPaymentGatewayErrors(!0);r.externalPaymentGatewayMessage(i)}else a(n.opaqueData)}function a(t){document.getElementById("dataDescriptor").value=t.dataDescriptor;document.getElementById("dataValue").value=t.dataValue;r.externalPaymentGatewayErrors(!1);r.externalPaymentGatewayData(t.dataDescriptor+","+t.dataValue);r.notStoreCreditCard(!0);n.makeReservation()}}r.gateway()==="AlphaBankRedirect"&&(n.bookingProcess().advancePayment()>0&&r.notStoreCreditCard(!0),n.makeReservation());typeof Stripe!="undefined"&&typeof u!="undefined"&&(r.externalPaymentGatewayData()==""?u.confirmCardSetup(o,{payment_method:{card:f}}).then(function(t){if(t.error){r.externalPaymentGatewayErrors(!0);switch(t.error.code){case"card_declined":r.externalPaymentGatewayMessage(IBE.Utils.translate("cc_"+t.error.code+"_"+t.error.decline_code));break;case"expired_card":case"incorrect_cvc":case"processing_error":case"incorrect_number":case"incorrect_zip":case"invalid_card_type":case"invalid_cvc":case"invalid_expiry_month":case"invalid_expiry_year":case"invalid_number":case"setup_intent_authentication_failure":r.externalPaymentGatewayMessage(IBE.Utils.translate("cc_"+t.error.code));break;default:r.externalPaymentGatewayMessage(IBE.Utils.translate(IBE.Utils.translate("correctCreditCard")))}return}r.externalPaymentGatewayErrors(!1);r.externalPaymentGatewayData(t.setupIntent.payment_method);r.notStoreCreditCard(!0);n.makeReservation()}):n.makeReservation());r.gateway()==="Payout"&&(n.bookingProcess().advancePayment()>0&&r.notStoreCreditCard(!0),n.makeReservation());typeof r.gateway()!="undefined"&&r.gateway()!=="0"&&r.gateway()!=="Braintree"&&r.gateway()!=="AlphaBankRedirect"&&r.gateway()!=="Omise"&&r.gateway()!=="AuthorizeNet"&&r.gateway()!=="Stripe"&&r.gateway()!=="Payout"&&n.makeReservation()};r.create3DSobject=function(t){return{amount:n.bookingProcess().totalCost(),nonce:t.nonce,bin:t.bin,email:n.customer().email(),billingAddress:{givenName:n.customer().firstName(),surname:n.customer().lastName(),phoneNumber:n.customer().phone(),streetAddress:n.customer().address(),locality:n.customer().country().name(),region:n.customer().city(),postalCode:n.customer().zip(),countryCodeAlpha2:n.customer().country().code()},additionalInformation:{workPhoneNumber:n.customer().phone(),shippingGivenName:n.customer().firstName(),shippingSurname:n.customer().lastName(),shippingPhone:n.customer().phone(),shippingAddress:{streetAddress:n.customer().address(),locality:n.customer().country().name(),region:n.customer().city(),postalCode:n.customer().zip(),countryCodeAlpha2:n.customer().country().code()}},onLookupComplete:function(n,t){t()}}};r.init()};IBE.ViewModels.FooterViewModel=function(){function i(t){n.name(t.info.name);n.logo(t.info.logo);n.address(new IBE.Models.HotelAddress(t.info.address));var i=new IBE.Models.Terms(t.info.termsAndPrivacy);n.privacy(i.privacy||"");t.settings.adwordsConversionId&&n.cookieUsed.push('<a href="https://policies.google.com/technologies/cookies" target="_blank"> Adwords <\/span>');t.settings.facebook_TrackId&&n.cookieUsed.push('<a href="https://www.facebook.com/policies/cookies/" target="_blank"> Facebook <\/span>');t.settings.bingCode&&n.cookieUsed.push('<a href="https://www.bink.com/terms/" target="_blank"> Bing <\/span>');t.settings.triptease&&n.cookieUsed.push('<a href="https://www.triptease.com/en/cookie-policy/" target="_blank"> Triptease <\/span>');t.settings.sojern&&n.cookieUsed.push('<a href="https://www.sojern.com/privacy/product-privacy-policy/" target="_blank"> Sojern <\/span>');t.settings.trivagoId&&n.cookieUsed.push('<a href="https://www.trivago.com/privacy-policy" target="_blank"> Trivago <\/span>');n.ready(!0);n.events.notifySubscribers(!0,"ready")}var n=this,t;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));n.name=ko.observable("");n.logo=ko.observable("");n.address=ko.observable();n.privacy=ko.observable();n.cookieUsed=ko.observableArray([]);n.showLogo=ko.computed(function(){return n.logo().length!==0});n.acceptTracking=ko.observable(!1);n.acceptTrackingCookies=ko.observable(!IBE.Config.showCookieAcceptance);n.allowAllCookies=function(){n.acceptTrackingCookies(!0)};n.saveSetting=function(){};t=[];t.push(n.lang.subscribe(function(){n.init()},n));n.dispose=function(){for(var n in t)t[n].dispose()};n.init=function(){$.when(n.languagePartialInit(),n.currenciesPartialInit()).then(function(){var t=function(t){if(t){if(i(t),IBE.Config.paymentGatewayType[t.settings.externalPaymentGateway]===3){var u=document.getElementById("Cookie"),r=document.createElement("IMG");r.setAttribute("src","https://bookwizecdn.azureedge.net/images/Horizontal_Banner_White_trans.png");r.setAttribute("class","bookwize-alphabank-image");u.after(r)}n.acceptTrackingCookies.valueHasMutated()}};$.when(IBE.Utils.loadHotelInfo(t)).then(t)})}};IBE.ViewModels.HeaderViewModel=function(){function i(t){n.name(t.info.name);n.logo(t.info.logo);n.hotel(new IBE.Models.HotelInfo(t.info));n.website(n.hotel().website);typeof t.settings.ibeBackgroundImage!="undefined"&&n.backgroundImage(t.settings.ibeBackgroundImage);n.ready(!0);n.events.notifySubscribers(!0,"ready")}var n=this,t;n.view=ko.observable();n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));n.name=ko.observable("");n.logo=ko.observable("");n.website=ko.observable("");n.backgroundImage=ko.observable("");n.hotel=ko.observable();n.showLogo=ko.computed(function(){return n.logo().length!==0});t=[];t.push(n.lang.subscribe(function(){n.init()},n));n.dispose=function(){for(var n in t)t[n].dispose()};n.init=function(){$.when(n.languagePartialInit(),n.currenciesPartialInit()).then(function(){var n=function(n){n&&typeof n!="undefined"&&i(n)};$.when(IBE.Utils.loadHotelInfo(n)).then(n)})};n.openInNewTab=function(){window.open(n.hotel().website,"_blank")}};IBE.ViewModels.LanguagePartialViewModel=function(n){function t(t){var i,r;t.languages&&(n.languages().length>0||(i=[],typeof IBE.Config.languages=="undefined"&&(IBE.Config.languages=[]),r=[],typeof IBE.Data.HotelInfo[t.id]!="undefined"&&IBE.Data.HotelInfo[t.id]!=null&&typeof IBE.Data.HotelInfo[t.id].settings.languages!="undefined"&&(r=IBE.Data.HotelInfo[t.id].settings.languages.split(",")),ko.utils.arrayForEach(t.languages,function(n){(IBE.Config.languages.length===0||IBE.Config.languages.indexOf(n.culture)!==-1)&&(r.length>0?r.indexOf(n.locale)>=0&&i.push(new IBE.Models.Language(n)):i.push(new IBE.Models.Language(n)))}),i.length===0&&i.push(new IBE.Models.Language({locale:IBE.Config.lang})),i.sort(function(n,t){return n.description==t.description?0:n.description<t.description?-1:1}),n.languages(i)))}n.languages=ko.observableArray([]);n._lang=ko.observable();n.lang=ko.computed({read:function(){return n._lang()},write:function(t){if(typeof t!="undefined"){var i=function(i){typeof i!="undefined"&&(IBE.Config.ajaxConfig=$.extend(IBE.Config.ajaxConfig,{beforeSend:function(n){n.setRequestHeader("Accept-Language",i)}}),$.ajaxSetup(IBE.Config.ajaxConfig),moment.locale(t),n._lang(i),n.events.notifySubscribers(t,"loadTranslations"))};$.when(IBE.Utils.loadTranslations(t,i)).then(i)}},deferEvaluation:!0});n.lang(IBE.Config.lang);n.languagePartialInit=function(n){var i=$.Deferred(),r=function(n){n&&typeof n!="undefined"&&(t(n),i.resolve(n))};return $.when(IBE.Utils.loadHotelInfo(r,n)).then(r),i.promise()}};IBE.ViewModels.Map=function(){function t(t){n.googleMap(new IBE.Models.GoogleMap(t.info));n.clearMessage();n.ready(!0);n.events.notifySubscribers(!0,"ready")}var n=this;n.events=new ko.subscribable;n.ready=ko.observable(!1);n.googleMap=ko.observable();ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);n.init=function(){var n=function(n){n&&t(n)};$.when(IBE.Utils.loadHotelInfo()).then(n)}};IBE.ViewModels.PartialMemberViewModel=function(n,t){typeof n.events=="undefined"&&(n.events=new ko.subscribable);typeof n.message=="undefined"&&ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.PartialAuthenticateMembership(n));t&&n.customer(new IBE.Models.Customer(t));n.logout=function(){n.username("");n.password("");n.customer(null);IBE.Utils.deleteAuthenticationCookie();n.clearMessage();n.events.notifySubscribers({success:!0},"logout")};n.login=function(){var t=$.Deferred();return n.username()===""||n.password()===""?t.resolve():$.ajax({type:"GET",url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()));t.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")},success:function(i){n.customer(new IBE.Models.Customer(i));t.resolve(i);n.events.notifySubscribers({success:!0},"login")},error:function(i){var r={id:i.status,severity:"error",text:i.responseText};i.status===401?(r.text="Wrong email or password.",IBE.Utils.deleteAuthenticationCookie(),n.customer(null)):r.text="An error occurred.";n.message(r);t.resolve(i)}}),t.promise()};n.isAuthenticated=ko.computed(function(){return n.customer()!=null}).extend({notify:"always"});n.customerAuthenticate=function(){var t=$.Deferred();return IBE.Utils.haveAuthenticationCookie()?$.ajax({type:"GET",url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie());n.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")},success:function(i){n.customer(new IBE.ViewModels.CustomerPartialViewModel(i));t.resolve(i)},error:function(i){IBE.Utils.deleteAuthenticationCookie();n.customer(null);t.resolve(i)}}):t.resolve(),t.promise()}};IBE.ViewModels.PartialAuthenticateMembership=function(n,t){n.customer=ko.observable(null);n.username=ko.observable("");n.password=ko.observable("");typeof t!="undefined"&&t!=null&&t.email!==""&&t.code!==""&&(n.username(t.email),n.password(t.code));n.consents=ko.observableArray([]);n.customerConsents=ko.observableArray([]);n.isAuthenticated=ko.computed(function(){return n.customer()!=null});n.customerConsents=ko.computed({read:function(){return n.customer()==null?[]:(ko.utils.arrayForEach(n.consents(),function(t){var i=ko.utils.arrayFirst(n.customer().consents(),function(n){return t.id===n.id});i&&t.value(!0)}),n.consents())},deferEvaluation:!0});n.createRecoveryLink=function(){if(n.clearMessage(),n.username()===""){var t={id:501,severity:"error",text:IBE.Utils.translate("customerUsernameIsEmpty")};return n.message(t),!1}return $.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/createRecoveryLink/?apikey="+IBE.Config.apiKey,data:ko.toJSON({username:n.username()}),beforeSend:function(){n.ready(!1)},success:function(){var t={id:200,severity:"success",text:IBE.Utils.translate("recoveryLinkSuccessfullySent")};n.message(t);n.events.notifySubscribers(t,"hash-sent")},error:function(t){n.events.notifySubscribers(!0,"ready");var i={id:t.status,severity:"error",text:t.responseText};i.text=t.status===404?"Wrong email.":"An error occurred.";n.message(i);n.events.notifySubscribers(i,"error")},complete:function(){n.ready(!0)}}),!0}};IBE.ViewModels.Membership=function(){function i(t){var i=$.Deferred();return t||i.resolve(0),$.ajax({type:"GET",url:"{0}/members/exist?apikey={1}&email={2}".format(IBE.Config.apiBaseUrl,IBE.Config.apiKey,t),beforeSend:function(){n.ready(!1)},success:function(n){i.resolve(n)},error:function(){i.resolve(!1)},complete:function(){n.events.notifySubscribers(!0,"ready");n.ready(!0)}}),i.promise()}var n=this,t;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.PartialAuthenticateMembership(n));n.countries=ko.observableArray([]);n.claimMembership=new IBE.ViewModels.ClaimMembership;n.termsVisible=ko.observable(!0);n.acceptTerms=ko.observable(!1).extend({checkbox:{message:IBE.Utils.translate("acceptTerms")}});n.memberBenefits=ko.computed(function(){if(n.customer()==null)return[];var t=ko.utils.arrayFilter(n.customer().offers(),function(n){return n.membershipLevels().length>0});return t||[]});t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.edit=ko.observable(!1);n._customerData=null;n.startEdit=function(){n._customerData=ko.toJS(n.customer());n.edit(!0)};n.cancelEdit=function(){n.customer(new IBE.Models.Customer(n._customerData));n._customerData=null;n.edit(!1)};n.save=function(){var i=ko.utils.arrayFilter(n.customerConsents(),function(n){return n.value()}),t;n.customer().consents(i);t=n.customer().toJSON();n.ready(!1);$.ajax({type:"POST",data:t,url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey+"&hotelId="+IBE.Config.hotelId,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()));t.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")},success:function(){n.edit(!1);n.clearMessage();var t={id:200,severity:"success",text:IBE.Utils.translate("customerEditSuccess")};n.message(t);n.ready(!0);n.events.notifySubscribers(!0,"ready")},error:function(t){n.clearMessage();var i={id:t.status,severity:"error",text:IBE.Utils.translate("customerEditFailed")};n.message(i);n.events.notifySubscribers(i,"error");n.ready(!0);n.events.notifySubscribers(!0,"ready")}})};n.oldPassword=ko.observable(null).extend({required:{message:IBE.Utils.translate("validation.required")}});n.newPassword=ko.observable(null).extend({required:{message:IBE.Utils.translate("validation.required")}});n.retypePassword=ko.observable(null).extend({required:{message:IBE.Utils.translate("validation.required")}});n.validatePasswordStrength=ko.computed(function(){return IBE.Utils.passwordStrength(n.newPassword())});n.isPasswordValid=ko.computed(function(){return IBE.Utils.passwordStrength(n.newPassword())>=60&&n.newPassword()==n.retypePassword()});n.passwordMessage=ko.computed(function(){var t=[];return IBE.Utils.passwordStrength(n.newPassword())<60&&t.push("weakPassword"),n.newPassword()!=n.retypePassword()&&t.push("customerPasswordMismatch"),t});n.changePassword=function(){var t,i;if(n.newPassword()!==n.retypePassword()||n.newPassword()==="")return n.clearMessage(),t={id:501,severity:"error",text:IBE.Utils.translate("customerPasswordMismatch")},n.message(t),!1;if(IBE.Utils.passwordStrength(n.newPassword()<60))return n.clearMessage(),t={id:502,severity:"error",text:IBE.Utils.translate("weakPassword")},n.message(t),!1;i={oldPassword:n.oldPassword(),newPassword:n.newPassword()};n.ready(!1);$.ajax({type:"POST",data:ko.toJSON(i),url:IBE.Config.apiBaseUrl+"/members/changepassword?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()))},success:function(){n.clearMessage();var t={id:200,severity:"success",text:IBE.Utils.translate("customerPasswordChangeSuccess")};n.message(t);n.ready(!0);n.events.notifySubscribers(!0,"ready");n.events.notifySubscribers(t,"password-change-success")},error:function(t){n.clearMessage();var i={id:t.status,severity:"error",text:IBE.Utils.translate("customerPasswordChangeFailure")};n.message(i);n.events.notifySubscribers(i,"error");n.ready(!0);n.events.notifySubscribers(!0,"ready")}})};n.show=ko.observable(!1);n.toggleChangePassword=ko.observable();n.toggleChangePassword=function(){n.show(!n.show())};n.resetpasswordShow=ko.observable(!1);n.resetPasswordDisplay=function(){n.resetpasswordShow(!0)};n.creditCard=ko.observable(null);n.errors=ko.observable({customer:ko.validation.group(n.customer),password:ko.validation.group(n),creditCard:ko.validation.group(n.creditCard)});n.login=function(){if(n.ready(!1),n.clearMessage(),n.errors().length>0&&IBE.Utils.haveAuthenticationCookie()===!1)return n.errors.showAllMessages(),n.events.notifySubscribers({id:401,severity:"error",text:"Wrong email or password."},"error"),n.ready(!0),!1;$.ajax({type:"GET",url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()));t.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US");n.ready(!1)},success:function(t){n.customer(new IBE.Models.Customer(t));n.initCustomerData();t.consents&&ko.utils.arrayForEach(t.consents,function(t){n.customer().consents.push(new IBE.Models.Consents(t))});n.ready(!0);IBE.Utils.authenticationHeader(n.username(),n.password());n.events.notifySubscribers({success:!0,email:n.username(),code:n.password()},"login");n.events.notifySubscribers(!0,"ready");n.ready(!0)},error:function(t){n.ready(!1);n.events.notifySubscribers(!0,"ready");var i={id:t.status,severity:"error",text:t.responseText};i.text=t.status===401?"Wrong email or password.":"An error occurred.";IBE.Utils.deleteAuthenticationCookie();n.customer(null);n.message(i);n.events.notifySubscribers(i,"error");n.ready(!0)}})};n.logout=function(){n.ready(!1);n.username("");n.password("");n.customer(null);IBE.Utils.deleteAuthenticationCookie();n.clearMessage();n.events.notifySubscribers({success:!0},"logout");n.ready(!0)};n.confirmAction=function(t,i){var e={id:n.currentReservation().reservation().id,newStatus:t,creditCard:{},cancellationNotes:n.currentReservation().reservation().cancellationNotes(),notes:n.currentReservation().reservation().notes()},r=!1,f,u;switch(t){case"CancelledReservation":case"CancelledRequest":n.cancelCode()!=n.currentReservation().reservation().code&&(f={id:5001,severity:"error",text:IBE.Utils.translate("wrongReservationCode")},n.message(f),n.events.notifySubscribers(f,"error"),r=!0);break;case"ConfirmedReservation":n.errors().creditCard().length>0&&(r=!0,n.events.notifySubscribers("","error"),n.errors().creditCard().length==1&&n.errors().creditCard()[0]==null?r=!1:n.errors().creditCard.showAllMessages());u=n.creditCard().cardExpirationYear()+"";u=u.substring(2);e.creditCard={holder:n.creditCard().cardHolder(),expireYear:u,expireMonth:n.creditCard().cardExpirationMonth(),number:n.creditCard().cardNumber(),verification:n.creditCard().cardVerification()}}if(r)return!1;n.clearMessage();IBE.Utils.request({type:"POST",data:ko.toJSON(e),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()))}}).done(function(r){if(n.cancelCode(""),n.currentReservation().reservation(new IBE.Models.Reservation(r)),n.customer(new IBE.ViewModels.CustomerPartialViewModel),n.events.notifySubscribers(!0,t),n.events.notifySubscribers(!0,t),i==="UpdateCreditCard"){var u={id:200,severity:"success",text:IBE.Utils.translate("creditCardUpdated")};n.message(u)}}).fail(function(){var t={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};n.message(t);n.events.notifySubscribers(t,"error")})};n.resetPassword=function(){var i,t,r;return(n.clearMessage(),i=IBE.Utils.getParam("hash"),!i)?(t={id:501,severity:"error",text:IBE.Utils.translate("invalidHash")},n.message(t),!1):n.newPassword()!==n.retypePassword()||n.newPassword()===""?(t={id:501,severity:"error",text:IBE.Utils.translate("customerPasswordMismatch")},n.message(t),!1):(r={password:n.newPassword(),passwordConfirm:n.retypePassword(),hash:i},$.ajax({type:"POST",data:ko.toJSON(r),url:IBE.Config.apiBaseUrl+"/members/resetpassword?apikey="+IBE.Config.apiKey,beforeSend:function(){n.ready(!1)},success:function(){var t={id:200,severity:"success",text:IBE.Utils.translate("customerResetPasswordSuccess")};n.message(t);n.events.notifySubscribers(t,"password-changed")},error:function(t){var i={id:t.status,severity:"error",text:IBE.Utils.translate("customerResetPasswordFailure")};n.message(i);n.events.notifySubscribers(i,"password-error")},complete:function(){n.events.notifySubscribers(!0,"ready");n.ready(!0)}}),!0)};n.createPassword=function(){var t,i,r;return(n.clearMessage(),n.ready(!1),i=n.customer().resetHash,!i)?(t={id:501,severity:"error",text:IBE.Utils.translate("invalidHash")},n.message(t),!1):n.newPassword()!==n.retypePassword()||n.newPassword()===""?(t={id:501,severity:"error",text:IBE.Utils.translate("customerPasswordMismatch")},n.message(t),!1):(r={password:n.newPassword(),passwordConfirm:n.retypePassword(),hash:i},$.ajax({type:"POST",data:ko.toJSON(r),url:IBE.Config.apiBaseUrl+"/members/resetpassword?apikey="+IBE.Config.apiKey,beforeSend:function(){n.ready(!1)},success:function(){t={id:200,severity:"success",text:IBE.Utils.translate("customerCreatePasswordSuccess")};n.message(t);n.events.notifySubscribers(t,"password-created")},error:function(i){t={id:i.status,severity:"error",text:IBE.Utils.translate("customerCreatePasswordFailure")};n.message(t);n.events.notifySubscribers(t,"password-error")},complete:function(){n.events.notifySubscribers(!0,"ready");n.ready(!0)}}),!0)};n.init=function(){n.ready(!1);$.when(n.languagePartialInit(),n.currenciesPartialInit(),IBE.Utils.loadCountries()).then(function(i,r,u){var f,e,o;(n._populateCountries(u),n.dispose(),t.push(n.lang.subscribe(function(){n.init()})),f=i.info.id,f)&&(n.consents([]),IBE.Data.HotelInfo[f].info.consents&&(e=IBE.Data.HotelInfo[f].info.consents,ko.utils.arrayForEach(e,function(t){n.consents.push(new IBE.Models.Consents(t))})),IBE.Data.HotelInfo[f].info.termsAndPrivacy&&(o=IBE.Data.HotelInfo[f].info.termsAndPrivacy,n.terms=new IBE.Models.Terms(o)),n.clearMessage(),IBE.Utils.haveAuthenticationCookie()?n.login():n.username()===""||n.password()===""?(n.customer(null),n.ready(!0),n.events.notifySubscribers(!0,"ready")):n.login())})};n.customerDataRequest=function(t){var i={hotelId:IBE.Config.hotelId,requestType:t};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/personalDataRequest/?apikey="+IBE.Config.apiKey,data:ko.toJSON(i),beforeSend:function(n){IBE.Utils.haveAuthenticationCookie()&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())},success:function(){var t={id:200,severity:"success",text:IBE.Utils.translate("customerDataRequestSuccess")};n.message(t);n.customerEdit(!1);n.ready(!0)},error:function(t){n.events.notifySubscribers(!0,"ready");var i={id:t.status,severity:"error",text:t.responseText};i.text=t.text;n.message(i);n.events.notifySubscribers(i,"error");n.ready(!0)},complete:function(){n.ready(!0)}})};n.customerDataRequest=function(t){var i={hotelId:IBE.Config.hotelId,requestType:t};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/personalDataRequest/?apikey="+IBE.Config.apiKey,data:ko.toJSON(i),beforeSend:function(t){IBE.Utils.haveAuthenticationCookie()&&t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie());n.ready(!1)},success:function(){var t={id:200,severity:"success",text:IBE.Utils.translate("customerDataRequestSuccess")};n.message(t)},error:function(t){n.events.notifySubscribers(!0,"ready");var i={id:t.status,severity:"error",text:t.responseText};i.text=t.text;n.message(i);n.events.notifySubscribers(i,"error")},complete:function(){n.ready(!0)}})};n.isMember=ko.observable(0);n.memberEmailExists=function(){n.username()!==""&&i(n.username()).then(function(t){n.isMember(t);t<0&&n.events.notifySubscribers(!0,"memberNotExist")})};n._populateCountries=function(t){n.countries.removeAll();t.sort(function(n,t){return n.name>t.name?1:-1});ko.utils.arrayPushAll(n.countries,ko.utils.arrayMap(t,function(n){return new IBE.Models.Country(n)}))};n._populateAcceptedCreditCards=function(){};n.getCustomerCountry=function(){if(!n.countries().length)return"";var t=ko.utils.arrayFirst(n.countries(),function(t){if(n.customer())return t.code()===n.customer().country()});return t===null?"":t.name()};n.showUpdateMessage=ko.observable(!1);n.currentReservation=ko.observable(null);n.currentReservation.subscribe(function(t){t!=null&&(n.clearMessage(),t.events.subscribe(function(t){n.message(t);n.events.notifySubscribers(t,"webcheckinSave")},this,"webcheckinSave"),t.events.subscribe(function(t){n.message(t);n.events.notifySubscribers(t,"reservationstatus");n.showUpdateMessage(!0)},this,"reservationstatus"),t.events.subscribe(function(t){n.message(t);n.events.notifySubscribers(t,"error")},this,"error"))});n.cancelCode=ko.observable("");n.cancelCodeIsValid=ko.computed(function(){return n.currentReservation()==null?!1:n.cancelCode()===n.currentReservation().reservation().code});n.showCheckin=function(t){n.currentReservation(new IBE.ViewModels.Reservation(t));n.events.notifySubscribers(!0,"showCheckin")};n.showReservation=function(t){n.currentReservation(new IBE.ViewModels.Reservation(t));n.events.notifySubscribers(!0,"showReservation")};n.initCustomerData=function(){n.customer().reservations().sort(function(n,t){return n.webCheckInActive()===t.webCheckInActive()?0:n.webCheckInActive()?-1:1});n.creditCard=ko.observable(new IBE.Models.CreditCard)};n.webCheckInIsActive=function(){var t=ko.utils.arrayFirst(n.customer().reservations(),function(n){return n.webCheckInActive()});return t!==null};n.genders=[{name:"",value:IBE.Config.gender.Unknown},{name:"male",value:IBE.Config.gender.Male},{name:"female",value:IBE.Config.gender.Female},];n.idDocumentTypes=[{name:"",value:IBE.Config.idDocumentType.Unknown},{name:"identityCard",value:IBE.Config.idDocumentType.IdentityCard},{name:"passport",value:IBE.Config.idDocumentType.Passport},{name:"drivingLicense",value:IBE.Config.idDocumentType.DrivingLicense}];n.titles=[{name:"",value:IBE.Config.titles.Unknown},{name:"mr",value:IBE.Config.titles.Mr},{name:"mrs",value:IBE.Config.titles.Mrs},{name:"miss",value:IBE.Config.titles.Miss},{name:"ms",value:IBE.Config.titles.Ms},{name:"dr",value:IBE.Config.titles.Dr},]};IBE.ViewModels.ClaimMembership=function(){var n=this;n.events=new ko.subscribable;n.ready=ko.observable(!0);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);n.useNotesValidation=ko.observable(!1);n.firstName=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.lastName=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.email=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.telephone=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.notes=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required"),onlyIf:function(){return n.useNotesValidation()}}});n.dateOfArrival=ko.observable(moment());n.reservationCode=ko.observable("");n.apiResponse=ko.observable(null);n.submit=function(){var t,i;if(n.apiResponse(null),t=ko.validation.group(n,{deep:!0}),t().length){t.showAllMessages(!0);return}i={firstName:n.firstName(),lastName:n.lastName(),email:n.email(),telephone:n.telephone(),dateOfArrival:n.dateOfArrival()===""?null:IBE.Utils.dateIsoFormat(n.dateOfArrival()),reservationCode:n.reservationCode(),notes:n.notes()};$.ajax({type:"POST",data:ko.toJSON(i),url:"{0}/members/claim?apikey={1}&hotelId={2}".format(IBE.Config.apiBaseUrl,IBE.Config.apiKey,IBE.Config.hotelId),beforeSend:function(){n.ready(!1)},success:function(t){n.apiResponse(t);n.clearModel()},error:function(n){IBE.Utils.consoleLog(n.responseJSON.message)},complete:function(){n.ready(!0)}})};n.clearModel=function(){n.firstName("");n.lastName("");n.email("");n.telephone("");n.dateOfArrival("");n.reservationCode("");n.firstName.clearError();n.lastName.clearError();n.email.clearError();n.telephone.clearError();n.dateOfArrival.clearError();n.reservationCode.clearError()}};IBE.ViewModels.ModifyReservation=function(n){function f(n){n&&(t.ready(!1),n.reservationId=t.reservation().id,allowForward=!0,t.currentStep()==="Step1-Rooms"?t.setStep("Step2-Rooms",n):t.setStep("Step2-Dates",n))}function r(n){n&&(n.reservationId=t.reservation().id,allowForward=!0,t.ready(!1),t.setStep("Step3",n))}function u(n){n&&(n.reservationId=t.reservation().id,allowForward=!0,t.ready(!1),t.setStep("Step4",n))}var t=this,i;t.events=new ko.subscribable;t.ready=ko.observable(!1);t.ready.subscribe(function(n){loader.visible(!n)});t.tabsCount=1;t.activeTabIndex=ko.observable(0);t.activeRoomIndex=ko.observable(1);t.activeRooms=ko.observableArray([]);t.modifiedRoomsNotAvailable=ko.observable(!1);t.reservation=ko.observable(n);t.reservation().customer=new IBE.ViewModels.CustomerPartialViewModel;ko.utils.extend(t,new IBE.ViewModels.LanguagePartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Message);ko.utils.extend(t,new IBE.ViewModels.PartialAuthenticateMembership(t));t.countries=ko.observableArray([]);i=[];t.dispose=function(){for(var n in i)i[n].dispose()};t.init=function(){t.ready(!1);$.when(t.languagePartialInit(),t.currenciesPartialInit(),IBE.Utils.loadCountries()).then(function(n,r,u){t.countries.removeAll();ko.utils.arrayPushAll(t.countries,ko.utils.arrayMap(u,function(n){return new IBE.Models.Country(n)}));t.dispose();i.push(t.lang.subscribe(function(){t.init()}));t.clearMessage();IBE.Utils.haveAuthenticationCookie()?(t.ready(!0),t.setStep("Wizard"),t.events.notifySubscribers(!0,"ready")):t.ready(!1)})};t.step1=new IBE.ViewModels.Step1ViewModel;t.currentStep=ko.observable("");t.setStep=function(n,i){switch(n){case"Wizard":IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Cancel");IBE.Utils.destroyView("Payment");t.currentStep("Wizard");IBE.Utils.bindTemplate("Wizard",t);break;case"Step1-Dates":t.ready(!1);IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step1-Dates");t.initStep1();break;case"Step1-Rooms":t.ready(!1);IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step1-Rooms");t.initStep1();break;case"Step2-Rooms":t.ready(!1);IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step2-Rooms");t.initStep2(i);break;case"Step2-Dates":t.ready(!1);IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");IBE.Utils.destroyView("Step4-Modify");t.currentStep("Step2-Dates");t.initStep2(i);break;case"Step3":IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step3");t.initStep3(i);break;case"Step4":IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step4");t.initStep4(i);break;case"cancelReservation":IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");t.currentStep("Cancel");t.initCancel(i);break;case"modifyPaymentMethod":IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Cancel");t.currentStep("Payment");t.initModifyPayment(i)}};t.initStep1=function(){t.step1.init()};t.initStep2=function(n){if(typeof t.step2=="undefined"&&(t.step2=new IBE.ViewModels.Step2ViewModel,t.step2.events.subscribe(function(n){r(n)},this,"call"),t.step2.events.subscribe(function(n){r(n)},this,"submit"),t.step2.events.subscribe(function(){t.currentStep()==="Step2-Rooms"?$.when(IBE.Utils.bindTemplate("Step2-Rooms",t)).then(function(){t.ready(!0)}):$.when(IBE.Utils.bindTemplate("Step2-Dates",t)).then(function(){t.ready(!0)})},this,"ready"),t.step2.events.subscribe(function(n){n.severity==="Forbidden"&&t.ready(!1);loader.title("Failed to initialize booking engine :(");loader.message(n);IBE.Utils.logEvent(n)},this,"error")),t.step2.lang=t.lang,t.step2.currency=t.currency,typeof n!="undefined")try{t.step2.init(n);t.activeTabIndex(0);t.activeRoomIndex(1);t.activeRooms([]);t.step2.selectedRooms([]);t.modifiedRoomsNotAvailable(!1)}catch(i){return t.step1.message(i.message),IBE.Utils.logEvent(i),t.ready(!0),!1}return!0};t.initStep3=function(n){return typeof step3=="undefined"&&(t.step3=new IBE.ViewModels.modifyStep3ViewModel,t.step3.events.subscribe(function(n){u(n)},this,"submit"),t.step3.events.subscribe(function(){IBE.Utils.bindTemplate("Step3-Modify",t);t.step3.paymentPolicyRules(t.getPaymentRulesText(n.bookingInfo.payments,n.bookingInfo.cost,n.bookingInfo.checkIn,n.bookingInfo.checkOut));t.ready(!0)},this,"ready"),t.step3.events.subscribe(function(n){loader.title("Failed to initialize booking engine :(");loader.message(n);loader.visible(!0);IBE.Utils.logEvent(n)},this,"error")),t.step3.lang=t.lang,t.step3.paymentPolicyRules=ko.observableArray([]),t.step3.init(n),t.step3.currency=t.currency,!0};t.initStep4=function(n){t.currentStep=4;typeof t.step4=="undefined"&&(t.step4=new IBE.ViewModels.ModifyStep4ViewModel,t.step4.events.subscribe(function(n){u(n)},this,"call"),t.step4.events.subscribe(function(n){u(n)},this,"submit"),t.step4.events.subscribe(function(){t.reservation(t.step4.reservation());IBE.Utils.destroyView("Step3-Modify");t.ready(!0);IBE.Utils.bindTemplate("Step4-Modify",t)},this,"ready"),t.step4.events.subscribe(function(n){t.ready(!0);t.step3.clearMessage();t.step3.message(n);n.severity=="critical"&&(loader.title("Failed to submit booking :("),loader.message(n),loader.visible(!0));IBE.Utils.logEvent(n)},this,"error"));t.step4.lang=t.lang;t.step4.currency=t.currency;try{t.step4.init(n)}catch(i){t.step3.clearMessage();var r={id:"4001",severity:i.severity,text:i.text||i.message};return t.step3.message(r),IBE.Utils.logEvent(r),t.ready(!0),!1}return!0};t.initCancel=function(){IBE.Utils.bindTemplate("Cancel",t)};t.initModifyPayment=function(){IBE.Utils.bindTemplate("Payment",t);t.events.subscribe(function(n){console.log(n)},this,"reservationstatus")};t.step1.ready.subscribe(function(n){if(n){t.ready(!1);t.step1.checkIn(moment(t.reservation().checkIn));t.step1.checkOut(moment(t.reservation().checkOut));t.step1.couponCode(t.reservation().couponCode);t.step1.boardType(t.reservation().rooms[0].board.type);t.reservation().rooms=t.reservation().rooms.sort(function(n,t){return n>t?1:0});var i=[],r=1;ko.utils.arrayForEach(t.reservation().rooms,function(n){var u=new IBE.Models.RequestedRoom(r++);u.guests=t.createGuestTypes(n);i.push(u)});t.step1.requestedRooms(i);ko.utils.arrayForEach(t.step1.requestedRooms(),function(n,i){n.preferredBoard(t.reservation().rooms[i].board.type)});t.currentStep()==="Step1-Rooms"?$.when(IBE.Utils.bindTemplate("Step1-Rooms",t)).then(function(){t.ready(!0)}):$.when(IBE.Utils.bindTemplate("Step1-Dates",t)).then(function(){t.ready(!0)})}});t.step1.events.subscribe(function(n){n.success&&f(n.success);n.failure&&(IBE.Utils.consoleLog("Failed to submit step 1"),IBE.Utils.consoleLog(n.failure))},this,"submit");t.boardChanged=function(n,i){var r=t.step2.selectedRooms()[i-1]};t.checkRoomAvailability=function(n,i){var r={roomExist:!1,rooms:[],selectedRoom:ko.observable(null),selectedRoomResult:ko.observable(null),selectedRateplan:ko.observable(null),selectedBoard:ko.observable(null),selectedRoomRateplans:ko.observableArray([])},f,u;return(r.selectedRoom.subscribe(function(i){if(i){var u=t.constructSelectedRoom(i);r.selectedRoomRateplans(i.rateplans);r.selectedRoomResult(i);u.rateplans=i.rateplans;t.activeRooms()[n-1]?t.activeRooms.replace(t.activeRooms()[n-1],u):t.activeRooms.push(u)}}),r.selectedRateplan.subscribe(function(i){var u=JSON.parse(JSON.stringify(ko.toJS(r.selectedRoom()))),f;u.ratePlanId=i;r.selectedBoard()!==null&&(u.boardType=r.selectedBoard().boardType);f=t.constructSelectedRoom(u);f.rateplans=r.selectedRoomRateplans();t.activeRooms.replace(t.activeRooms()[n-1],f)}),r.selectedBoard.subscribe(function(i){var u=JSON.parse(JSON.stringify(ko.toJS(r.selectedRoom()))),f;u.boardType=i.boardType;u.ratePlanId=r.selectedRateplan();f=t.constructSelectedRoom(u);f.rateplans=r.selectedRoomRateplans();t.activeRooms.replace(t.activeRooms()[n-1],f)}),f=ko.utils.arrayFirst(t.reservation().rooms,function(t){return t.roomIndex===n}),u=ko.utils.arrayFilter(i,function(n){return t.reservationRoomIsAvailable(n)}),!u.length)?r:(r.rooms=u,r)};t.hasAvailabilty=function(n){var i=[],r;return ko.utils.arrayForEach(n,function(n){var r=!1;ko.utils.arrayForEach(n.roomResults(),function(n){t.reservationRoomIsAvailable(n)&&(r=!0)});i.push(r)}),r=ko.utils.arrayFirst(i,function(n){return!n}),r==null};t.selectRoom=function(){t.modifiedRoomsNotAvailable(!1);t.pushToSelectedRooms(t.activeRooms()[t.activeRoomIndex()-1]);var n=t.activeTabIndex()+1,r=n+1,i=!1;if(ko.utils.arrayForEach(t.step2.request().hotelResults(),function(n){var t=ko.utils.arrayFilter(n.requestedRooms(),function(n){return r==n.roomIndex()});t.length>0&&(i=!0)}),i)return t.activeTabIndex(n),t.activeRoomIndex(t.activeRoomIndex()+1),!0;t.modifiedRoomsAreAvailable()&&t.step2Submit();t.modifiedRoomsNotAvailable(!0)};t.pushToSelectedRooms=function(n){var i=t.constructSelectedRoom(n);t.step2.selectedRooms.push(i)};t.constructSelectedRoom=function(n){var i=new IBE.Models.SelectedRoom,f,e,r,u;return i.roomIndex(ko.unwrap(n.roomIndex)),i.roomId(ko.unwrap(n.roomId)),i.ratePlanId(ko.unwrap(n.ratePlanId)),i.boardType(ko.unwrap(n.boardType)),f=ko.utils.arrayFirst(t.step2.boards(),function(n){return n.boardType===i.boardType()}),i.board(f),i.availability(ko.unwrap(n.availability)),i.guestTypes=ko.observableArray([]),ko.utils.arrayForEach(t.step2.request().hotelResults(),function(t){ko.utils.arrayForEach(t.requestedRooms(),function(t){if(ko.unwrap(n.roomIndex)===ko.unwrap(t.roomIndex)){i.guestTypes(t.guests());return}})}),e=ko.utils.arrayFirst(ko.unwrap(n.rateplans),function(n){return ko.unwrap(n.ratePlanId)===i.ratePlanId()}),r=ko.utils.arrayFirst(ko.unwrap(e.roomBoards),function(n){return ko.unwrap(n.boardType)===i.boardType()}),typeof r!="undefined"&&r!=null&&(i.cost(ko.unwrap(r.price)),i.costWithoutDiscount(ko.unwrap(r.priceWithoutDiscount))),i.roomInfo=ko.observable(),u=t.step2.rooms.filterByProperty("id",ko.unwrap(n.roomId)),u().length>0&&i.roomInfo(u()[0]),i};t.reservationRoomIsAvailable=function(n){return n.availability>0&&n.availableRooms>0};t.step2Submit=function(){t.step2.selectedRooms().length<t.step1.requestedRooms().length&&ko.utils.arrayForEach(t.reservation().rooms,function(n){ko.utils.arrayForEach(t.step2.selectedRooms(),function(i){var r,f,u;n.roomIndex!==i.roomIndex()&&(r=new IBE.Models.SelectedRoom,r.roomIndex(n.roomIndex),r.roomId(n.id),r.ratePlanId(n.ratePlanId),r.boardType(n.board.type),f=ko.utils.arrayFirst(t.step2.boards(),function(n){return n.boardType===r.boardType()}),r.board(f),r.guestTypes=t.createGuestTypes(n),r.cost(n.totalCost),r.costWithoutDiscount(n.roomCostBeforeDiscount),r.roomInfo=ko.observable(),u=t.step2.rooms.filterByProperty("id",ko.unwrap(n.id)),u().length>0&&r.roomInfo(u()[0]),t.step2.selectedRooms.push(r))})});var n={};n.bookingInfo={checkIn:moment(t.step2.request().checkIn()).format("YYYY-MM-DD"),checkOut:moment(t.step2.request().checkOut()).format("YYYY-MM-DD"),rooms:t.step2.selectedRooms(),reservationId:t.reservation().id};r(n)};t.createGuestTypes=function(n){var t;if(!n)return[];var f=IBE.Data.HotelInfo[IBEConfig.hotelId].info.guestTypes,u=[],r=ko.utils.arrayFirst(f,function(n){return n.ageCategory===IBE.Config.guestType.Adult}),e=ko.utils.arrayFilter(f,function(n){return n.ageCategory===IBE.Config.guestType.Children}),i=ko.utils.arrayFirst(f,function(n){return n.ageCategory===IBE.Config.guestType.Infant});return IBE.Config.guestType.Adult&&(t=new IBE.Models.RequestedRoomGuestType,t.pax(n.adults||0),t.ageCategory(r.ageCategory),t.fromAge(r.fromAge),t.toAge(r.toAge),t.minValue(r.min),t.maxValue(r.max),u.push(t)),IBE.Config.guestType.Children&&e&&ko.utils.arrayForEach(e,function(t){var i=new IBE.Models.RequestedRoomGuestType;i.ageCategory(IBE.Config.guestType.Children);i.fromAge(t.fromAge);i.toAge(t.toAge);i.minValue(t.min);i.maxValue(t.max);i.pax(0);n.childrenAges&&t.fromAge<=n.childrenAges[0]&&t.toAge>=n.childrenAges[0]&&i.pax(n.children);u.push(i)}),IBE.Config.guestType.Infant&&i&&(t=new IBE.Models.RequestedRoomGuestType,t.pax(n.infants||0),t.ageCategory(i.ageCategory),t.fromAge(i.fromAge),t.toAge(i.toAge),t.minValue(i.min),t.maxValue(i.max),u.push(t)),u};t.getPaymentRulesText=function(n,i,r,u){var f=[],h;if(n.length===0)return f;var e=0,s=moment().startOf("day"),o=ko.unwrap(i);if(ko.utils.arrayForEach(n,function(n){var i=ko.toJS(n);i.amountCurrency=t.getRateText(i.amount,t.currency());f.push(i);o-=n.amount}),o>0){for(e=f.length-1,f[e].paymentDate===r.format("YYYY-MM-DD")||f[e].paymentDate===u.format("YYYY-MM-DD")?(f[e].amount+=o,f[e].amountCurrency=t.getRateText(f[e].amount,t.currency())):f.push({text:"",amount:o,paymentDate:r.format("YYYY-MM-DD"),amountCurrency:t.getRateText(o,t.currency())}),h=!1,e=0;e<f.length-1;e++)if(s.diff(f[e].paymentDate,"days")===0){h=!0;break}h||f.unshift({paymentDate:s.format("YYYY-MM-DD"),amount:0,amountCurrency:t.getRateText(0,t.currency()),text:IBE.Utils.translate("noAdvancePayment")})}return ko.utils.arrayForEach(f,function(n){var t=moment(n.paymentDate),i=n.amount;if(s.diff(t,"days")===0){n.text=i>0?IBE.Utils.translate("paymentRuleAdvancePayment").format(n.amountCurrency):IBE.Utils.translate("noAdvancePayment");return}if(r.diff(t,"days")===0&&n.amount>0){n.text=IBE.Utils.translate("paymentRulePayUponCheckIn").format(n.amountCurrency);return}if(u.diff(t,"days")===0&&n.amount>0){n.text=IBE.Utils.translate("paymentRulePayUponCheckOut").format(n.amountCurrency);return}if(i>0){n.text=IBE.Utils.translate("paymentRulePayOnDate").format(n.amountCurrency,moment(t).format("DD/MM/YYYY"));return}}),f};t.getRoomsForChangeDates=function(n,i){var r=ko.utils.arrayFirst(n,function(n){return n.roomId()===i.id});return r!=null&&ko.utils.arrayForEach(r.rateplans(),function(n){n.ratePlanId()===i.ratePlanId&&r.ratePlanId(i.ratePlanId)}),r==null,r&&!t.activeRooms()[i.roomIndex-1]&&t.activeRooms.push(r),r};t.modifiedRoomsAreAvailable=function(){var i=!0,n={};return t.activeRooms().map(function(n){return n.roomId()}).forEach(function(t){n[t]=(n[t]||0)+1}),t.step2.request().hotelResults()[0].requestedRooms()[0].roomResults().map(function(n){return{roomId:n.roomId(),availableRooms:n.availableRooms}}).forEach(function(t){n[t.roomId]&&(i&=n[t.roomId]<=t.availableRooms)}),i}};IBE.ViewModels.modifyStep3ViewModel=function(n){function r(n){t.modifyProcess.id=n.id;t.modifyProcess.baseCurrency=n.currency;t.modifyProcess.checkIn=moment.utc(n.checkIn);t.modifyProcess.checkOut=moment.utc(n.checkOut);t.modifyProcess.advancePayment=n.advancePayment;t.modifyProcess.cancellationPolicy=n.cancellationPolicy;t.modifyProcess.paymentPolicy=n.paymentPolicy;t.modifyProcess.paymentPolicyHotelTextOption=n.paymentPolicyHotelTextOption;t.modifyProcess.payments=n.payments;t.modifyProcess.cost=ko.observable(n.totalAmount);t.modifyProcess.costWithoutDiscount=ko.observable(n.totalAmountBeforeDiscount);t.modifyProcess.lang=t.lang;IBE.Data.modifyProcess=t.modifyProcess}var t=this,i;t.events=new ko.subscribable;t.ready=ko.observable(!1);ko.utils.extend(t,new IBE.ViewModels.LanguagePartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Message);ko.utils.extend(t,new IBE.ViewModels.PartialMemberViewModel(t));t.modifyProcess=ko.observable();t.hotelInfo=ko.observable();t.allowSubmit=ko.observable(!0);t.termsVisible=ko.observable(!0);i=[];t.dispose=function(){for(var n in i)i[n].dispose()};t.countries=ko.observableArray([]);t.makeReservation=function(){var n;return n={},n.checkIn=t.modifyProcess.checkIn,n.checkOut=t.modifyProcess.checkOut,n.customer=[],n.rooms=ko.utils.arrayMap(t.modifyProcess.rooms,function(n){return{boardType:n.boardType,ratePlanId:n.ratePlanId,roomIndex:n.roomIndex,roomId:n.roomId,guestTypes:n.guestTypes}}),n.cost=t.modifyProcess.cost(),n.advancePayment=t.modifyProcess.advancePayment,t.events.notifySubscribers(n,"submit"),!1};t.init=function(u,f){var e=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},f);$.when(t.languagePartialInit(e),t.currenciesPartialInit(e),t.customerAuthenticate()).then(function(){IBE.Data.Step3InitData=u;i.push(t.lang.subscribe(function(){t.init(IBE.Data.Step3InitData)}));var f=function(n){n&&t.hotelInfo(new IBE.Models.HotelInfo(n.info))};$.when(IBE.Utils.loadHotelInfo(f,e)).then(f);t.customer(new IBE.ViewModels.CustomerPartialViewModel(n));$.when(IBE.Utils.lookupCountry()).then(function(n){var i=ko.utils.arrayFirst(t.countries(),function(t){return t.code()===n});i!=null&&t.customer().country(i)});t.modifyProcess=u.bookingInfo;IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/BookingProcess/"+e.hotelId+"?apikey="+e.apiKey,data:ko.toJSON(t.modifyProcess),headers:{"Content-Type":"application/json"}}).done(function(n){if(t.clearMessage(),n===!1){t.ready(!0);t.events.notifySubscribers(!0,"ready");t.message({id:4001,severity:"error",text:"An error occured. Please try again"});t.events.notifySubscribers(t.message(),"error");return}r(n);t.ready(!0);t.events.notifySubscribers(!0,"ready")}).fail(function(n){t.ready(!0);t.clearMessage();var i={id:n.status,severity:"critical",text:n.statusText+": "+n.responseText};t.message(i);t.events.notifySubscribers(i,"error")})})}};IBE.ViewModels.ModifyStep4ViewModel=function(){function i(t){n.reservation(new IBE.Models.Reservation(t));n.membership.customer(n.reservation().customer);n.bookingProcess=IBE.Data.modifyProcess;n.ready(!0);n.events.notifySubscribers(!0,"ready")}function r(t){n.hotel(new IBE.Models.HotelInfo(t.info));n.reservationSettings=new IBE.Models.ReservationSettings(t.settings);n.googleMap(new IBE.Models.GoogleMap(t.info))}function u(t){function u(n){var t="Basic "+$.base64.encode(n.username+":"+n.password);return document.cookie="Authorization: "+t,t}function f(n){var r="Authorization=",i=document.cookie.indexOf(r),t;return i!==-1?(t=document.cookie.indexOf(";",i+1),t===-1&&(t=document.cookie.length),unescape(document.cookie.substring(i+r.length,t))):u(n)}var r=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n.options);IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/reservation/?apikey="+r.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",f(t));n.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")}}).done(function(t){n.clearMessage();i(t)}).fail(function(t){var i,r;n.ready(!0);n.clearMessage();i="critical";(t.status===400||t.status===500)&&(i="error");r={id:t.status,severity:i,text:t.responseJSON.Message};n.events.notifySubscribers(r,"error")})}function f(t){var r=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n.options);t.checkIn=moment(t.checkIn).format("YYYY-MM-DD");t.checkOut=moment(t.checkOut).format("YYYY-MM-DD");IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/amendreservation/"+r.hotelId+"?apikey="+r.apiKey,data:ko.toJSON(t),headers:{"Content-Type":"application/json"}}).done(function(t){if(n.clearMessage(),t.error){var r={id:t.statusCode(),severity:"error",text:t.responseJSON.message};n.message(r);n.events.notifySubscribers(r,"error");throw r;}i(t)}).fail(function(t){var i,r;n.ready(!0);n.clearMessage();i="critical";(t.status==400||t.status==500)&&(i="error");r={id:t.status,severity:i,text:t.responseJSON.message};n.events.notifySubscribers(r,"error")})}var n=this,t;n.options={};n.events=new ko.subscribable;n.reservation=ko.observable();n.modifyProcess=ko.observable();n.hotel=ko.observable();n.googleMap=ko.observable();n.ready=ko.observable(!1);n.customer=ko.observable();n.membership=new IBE.ViewModels.Membership;ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.ecommerce=ko.observable(!1);n.adWordsSent=ko.observable(!1);n.trackAdWords=function(){var i,t;if(!n.adWordsSent()){if(google_conversion_id=IBE.Utils.getReservationSetting(n,"adwordsConversionId"),IBE.Config.reservationStatus[n.reservation().status()]===3?(i=IBE.Utils.getReservationSetting(n,"adwordsRequestLabel"),i!==""&&(google_conversion_label=i)):google_conversion_label=IBE.Utils.getReservationSetting(n,"adwordsConversionLabel"),google_conversion_value=ko.unwrap(n.reservation().totalCost),google_remarketing_only=!1,google_conversion_id===0||google_conversion_id===""){console.log("IBE: google_conversion_id is not valid");return}n.options.appendAdwordsImage&&(t=document.createElement("img"),t.height=1,t.width=1,t.border=0,t.src="//www.googleadservices.com/pagead/conversion/"+google_conversion_id+"/?value="+ko.unwrap(n.reservation().totalCost)+"&amp;currency_code="+n.currency()+"&amp;label="+google_conversion_label+"&amp;guid=ON&amp;script=0",$("body").append(t));n.options.trackAdwordsAsync&&typeof google_trackConversion!="undefined"&&window.google_trackConversion({google_conversion_id:google_conversion_id,google_conversion_language:"en",google_conversion_format:"3",google_conversion_color:"ffffff",google_conversion_label:google_conversion_label,google_conversion_value:google_conversion_value,google_conversion_currency:n.currency(),google_remarketing_only:!1});n.adWordsSent(!0)}};n.trackTrivagoConversion=function(){var t=Cache.read("ref","localstorage"),u,i,r,f,e;if((t==="Trivago"||t==="trivago"||t&&t.name&&(t.name==="Trivago"||t.name==="trivago"))&&IBE.Config.userCookieAcceptance===!0){if(u=IBE.Utils.getReservationSetting(n,"trivagoTrackingId"),typeof u=="undefined")return;i=IBE.Utils.getReservationSetting(n,"trivagoConversionKey");r=IBE.Utils.getReservationSetting(n,"trivagoSupplierId");t&&t.params&&t.params.trv_reference&&r&&i&&(f=t.params.trv_reference,e={trv_reference:f,advertiser_id:r,hotel:n.reservation().hotelId,arrival:n.reservation().checkIn.format("YYYY-MM-DD"),departure:n.reservation().checkOut.format("YYYY-MM-DD"),volume:n.reservation().totalCost(),booking_id:n.reservation().id,currency:n.reservation().currencyCode,date_format:"Y-m-d",booking_date:moment(n.reservation().created).format("YYYYMMDD-HHmmss"),booking_date_format:"Ymd-His"},IBE.Utils.request({type:"POST",url:"https://secde.trivago.com/tracking/booking",data:JSON.stringify(e),dataType:"json",headers:{"Content-Type":"application/json","X-Trv-Ana-Key":i}}).done(function(){}).fail(function(){}))}};n.trackEcommerce=function(){var i,r,t;if(!n.ecommerce()&&typeof ga!="undefined"){ga("ecommerce:addTransaction",{id:""+n.reservation().id,affiliation:n.reservation().hotelName,revenue:""+ko.unwrap(n.reservation().totalCost),shipping:"0",tax:"0"});i=1;ko.utils.arrayForEach(n.reservation().rooms,function(t){var r=ko.unwrap(t);ga("ecommerce:addItem",{id:""+n.reservation().id,name:r.name+" "+r.board.name,sku:"#"+i+"-"+r.id+" -- "+n.reservation().status(),category:"Rooms",price:r.totalCost,quantity:"1",currency:n.currency()});i+=1});ko.utils.arrayForEach(n.reservation().supplements,function(t){var i=ko.unwrap(t);ga("ecommerce:addItem",{id:""+n.reservation().id,name:i.name,sku:i.supplementId()+" -- "+n.reservation().status(),category:"Supplements",price:i.unitCost(),quantity:i.quantity(),currency:n.currency()})});ga("ecommerce:send");r=[];ko.utils.arrayForEach(n.reservation().rooms,function(t){var u=ko.unwrap(t);r.push({id:""+n.reservation().id,name:u.name+" "+u.board.name,category:"Rooms",quantity:"1",price:u.totalCost});i+=1});ko.utils.arrayForEach(n.reservation().supplements,function(t){var i=ko.unwrap(t);r.push({id:""+n.reservation().id,name:i.name,category:"Supplements",quantity:i.quantity(),price:i.unitCost()})});var u=IBE.Utils.getReservationSetting(n,"adwordsConversionId"),f="",e=IBE.Utils.getReservationSetting(n,"globalAdwordsConversionId"),o=IBE.Utils.getReservationSetting(n,"globalAdwordsConversionLabel"),s=IBE.Utils.getReservationSetting(n,"googleConversionTrackingPartnerId");u&&typeof gtag!="undefined"&&IBE.Config.userCookieAcceptance===!0||(u="");IBE.Config.reservationStatus[n.reservation().status()]===3?f=IBE.Utils.getReservationSetting(n,"adwordsRequestLabel"):IBE.Config.reservationStatus[n.reservation().status()]===1&&(f=IBE.Utils.getReservationSetting(n,"adwordsConversionLabel"));t=[];u&&f&&t.push("AW-"+u+"/"+f);e&&o&&t.push("AW-"+e+"/"+o);s&&t.push("HA-"+s);gtag("event","purchase",{send_to:t.length>0?t:undefined,transaction_id:n.reservation().id,affiliation:n.reservation().hotelName,value:ko.unwrap(n.reservation().totalCost),currency:n.currency(),items:r,checkout_step:4,id:n.reservation().hotelId,start_date:n.reservation().checkIn.format("YYYY-MM-DD"),end_date:n.reservation().checkOut.format("YYYY-MM-DD")});n.ecommerce(!0)}};n.trackBingCode=function(){if(IBE.Config.debug){console.log("IBE: In debug mode bing is disabled");return}window.uetq&&window.uetq.push({ec:"Booking",ea:ko.unwrap(n.reservation().status),el:"",ev:""+ko.unwrap(n.reservation().totalCost)})};n.updateReservation=function(){var t={id:n.reservation().id,newStatus:n.reservation().status(),supplements:_bookingSupplements(),creditCard:{},cancellationNotes:n.reservation().cancellationNotes()};n.clearMessage();IBE.Utils.request({type:"POST",data:ko.toJSON(t),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.reservation().customer.email(),n.reservation().code))}}).done(function(){}).fail(function(t){var i={id:t.status,severity:"critical",text:t.statusText+": "+t.responseText};n.message(i)})};n.init=function(t,i){n.options=ko.utils.extend({trackAdwords:!0,trackAdwordsAsync:!0,appendAdwordsImage:!0,reservationSubmitted:!1,apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},i);$.when(n.languagePartialInit(n.options),n.currenciesPartialInit()).then(function(){n.options.reservationSubmitted=!1;var i=function(n){n&&(r(n),typeof t.username!="undefined"&&typeof t.password!="undefined"?u(t):f(t))};$.when(IBE.Utils.loadHotelInfo(i,n.options)).then(i)})}};IBE.ViewModels.MyReservation=function(n){function r(n){t.hotel(new IBE.Models.HotelInfo(n.info));t.reservationSettings=new IBE.Models.ReservationSettings(n.settings);t.googleMap(new IBE.Models.GoogleMap(n.info))}function u(n){t.countries.removeAll();ko.utils.arrayPushAll(t.countries,ko.utils.arrayMap(n,function(n){return new IBE.Models.Country(n)}))}function f(n){typeof n.info.acceptedCards!="undefined"&&t.acceptedCards(n.info.acceptedCards.split(", "))}var t=this,i;t.events=new ko.subscribable;t.ready=ko.observable(!1);ko.utils.extend(t,new IBE.ViewModels.LanguagePartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Message);t.genders=[{name:"",value:IBE.Config.gender.Unknown},{name:"male",value:IBE.Config.gender.Male},{name:"female",value:IBE.Config.gender.Female},];t.idDocumentTypes=[{name:"",value:IBE.Config.idDocumentType.Unknown},{name:"identityCard",value:IBE.Config.idDocumentType.IidentityCard},{name:"passport",value:IBE.Config.idDocumentType.Passport},{name:"drivingLicense",value:IBE.Config.idDocumentType.DrivingLicense}];t.titles=[{name:"",value:IBE.Config.titles.Unknown},{name:"mr",value:IBE.Config.titles.Mr},{name:"mrs",value:IBE.Config.titles.Mrs},{name:"miss",value:IBE.Config.titles.Miss},{name:"ms",value:IBE.Config.titles.Ms},{name:"dr",value:IBE.Config.titles.Dr},];t.username=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredUsername")}});t.password=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredPassword")}});t.cancelCode=ko.observable("");t.reservation=ko.observable();t.customer=ko.observable();t.acceptedCards=ko.observableArray([]);t.hotel=ko.observable();t.googleMap=ko.observable();t.countries=ko.observableArray([]);t.terms=ko.observable();t.consents=ko.observableArray([]);t.customerConsents=ko.observableArray([]);t.guests=ko.observableArray([]);t.isWebCheckedIn=ko.observable(!1);t.errors=ko.validation.group(t);i=[];t.dispose=function(){for(var n=0;n<i.length;n++)i[n].dispose()};t.customerConsents=ko.computed({read:function(){return ko.utils.arrayForEach(t.consents(),function(n){var i=ko.utils.arrayFirst(t.reservation().customer.consents(),function(t){return n.id===t.id});i&&n.value(!0)}),t.consents()},write:function(){return t.consents([])},deferEvaluation:!0});typeof n!="undefined"&&n.email!==""&&n.code!==""&&(t.username(n.email),t.password(n.code));t.isAuthenticated=ko.observable(!1);t.options={};t.reservationAction=ko.observable("view");t.login=function(n){if(t.options=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n),t.ready(!1),t.clearMessage(),t.errors().length>0&&IBE.Utils.haveAuthenticationCookie()===!1)return t.errors.showAllMessages(),t.events.notifySubscribers({id:401,severity:"error",text:"Wrong email or reservation code."},"error"),t.ready(!0),!1;IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/reservation/?apikey="+IBE.Config.apiKey,beforeSend:function(n){t.username()!==""&&t.password()!==""&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(t.username(),t.password()))}}).done(function(n){var i,r;(t.reservation(new IBE.Models.Reservation(n)),t.reservation().taxes(n.taxes||[]),t.customer(new IBE.ViewModels.CustomerPartialViewModel),t.isWebCheckedIn(t.reservation().webCheckIn()),ko.utils.arrayForEach(t.reservation().rooms,function(n){for(var i=0;i<n.adults;i++)n.guestType=IBE.Config.guestType.Adult,t.guests.push(new IBE.Models.ReservationGuest(n));for(i=0;i<n.children;i++)n.guestType=IBE.Config.guestType.Children,t.guests.push(new IBE.Models.ReservationGuest(n));for(i=0;i<n.infants;i++)n.guestType=IBE.Config.guestType.Infant,t.guests.push(new IBE.Models.ReservationGuest(n))}),t.hotel().hotelId)&&(IBE.Data.HotelInfo[t.hotel().hotelId].info.consents&&(i=IBE.Data.HotelInfo[t.hotel().hotelId].info.consents,ko.utils.arrayForEach(i,function(n){t.consents.push(new IBE.Models.Consents(n))})),n.customer.consents&&ko.utils.arrayForEach(n.customer.consents,function(n){t.reservation().customer.consents.push(new IBE.Models.Consents(n))}),IBE.Data.HotelInfo[t.hotel().hotelId].info.termsAndPrivacy&&(r=IBE.Data.HotelInfo[t.hotel().hotelId].info.termsAndPrivacy,t.terms=new IBE.Models.Terms(r)),$.when(IBE.Utils.loadCountries()).then(function(n){u(n);var i=ko.utils.arrayFilter(t.countries(),function(n){return t.reservation().customer.country()==n.code()})[0];i.name&&(t.reservation().customer.countryName=i.name());t.clearMessage();t.events.notifySubscribers({email:t.username(),code:t.password()},"login");t.events.notifySubscribers(!0,"ready");t.ready(!0);t.isAuthenticated(!0);window.location.href.indexOf("#reservation")>-1&&$("#IBE-MyReservation-ViewReservation").length!=0?t.setView("reservation"):$("#IBE-MyReservation-Welcome").length!=0&&t.setView("welcome")}))}).fail(function(n){if(t.events.notifySubscribers(!0,"ready"),IBE.Utils.haveAuthenticationCookie()&&t.username()===""){t.isAuthenticated(!1);IBE.Utils.deleteAuthenticationCookie();return}var i={id:n.status,severity:"error",text:n.responseText};i.text=n.status===401?"Wrong email or reservation code.":"An error occurred.";t.isAuthenticated(!1);IBE.Utils.deleteAuthenticationCookie();t.events.notifySubscribers(i,"error")})};t.logout=function(){t.username("");t.password("");IBE.Utils.deleteAuthenticationCookie();t.clearMessage();t.isAuthenticated(!1);t.customerConsents([]);t.errors.showAllMessages(!1);t.ready(!0);t.events.notifySubscribers(!0,"logout")};t.displayExternalPayment=ko.observable(!1);t.init=function(){$.when(t.languagePartialInit(),t.currenciesPartialInit()).then(function(n){t.dispose();i.push(t.lang.subscribe(function(){t.init()}));t.ready(!1);t.clearMessage();r(n);f(n);IBE.Utils.haveAuthenticationCookie()?t.login():t.username()===""||t.password()===""?(t.isAuthenticated(!1),t.ready(!0),t.events.notifySubscribers(!0,"ready")):t.login()})};t.setReservationAction=function(n){t.reservationAction(n)};t.customerEdit=ko.observable(!1);t.startEdit=function(){t.customerEdit(!0)};t.cancelEdit=function(){t.customerEdit(!1)};t.setView=function(n){switch(n){case"welcome":IBE.Utils.destroyView("IBE-MyReservation-Account");IBE.Utils.destroyView("IBE-MyReservation-ViewReservation");IBE.Utils.bindTemplate("IBE-MyReservation-Welcome",t);$(".bookwize-nav").removeClass("active");$(".nav-"+n).addClass("active");break;case"account":IBE.Utils.destroyView("IBE-MyReservation-Welcome");IBE.Utils.destroyView("IBE-MyReservation-ViewReservation");IBE.Utils.bindTemplate("IBE-MyReservation-Account",t);$(".bookwize-nav").removeClass("active");$(".nav-"+n).addClass("active");$("#request-personal-data").click(function(){t.customerDataRequest("Export")});$("#delete-personal-data").click(function(){t.customerDataRequest("Delete")});break;case"reservation":IBE.Utils.destroyView("IBE-MyReservation-Account");IBE.Utils.destroyView("IBE-MyReservation-Welcome");IBE.Utils.bindTemplate("IBE-MyReservation-ViewReservation",t);$(".bookwize-nav").removeClass("active");$(".nav-"+n).addClass("active");break;default:t.ready(!0)}};t.customerDataRequest=function(n){var i={hotelId:IBE.Config.hotelId,requestType:n};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/personalDataRequest/?apikey="+IBE.Config.apiKey,data:ko.toJSON(i),beforeSend:function(n){IBE.Utils.haveAuthenticationCookie()&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())},success:function(){var n={id:200,severity:"success",text:IBE.Utils.translate("customerDataRequestSuccess")};t.message(n);t.customerEdit(!1);t.ready(!0)},error:function(n){t.events.notifySubscribers(!0,"ready");var i={id:n.status,severity:"error",text:n.responseText};i.text=n.text;t.message(i);t.events.notifySubscribers(i,"error");t.ready(!0)},complete:function(){t.ready(!0)}})};t.showUpdateCreditCard=function(n){var i,r,u;return!n&&typeof n!="undefined"?!1:(i=moment(),r=moment(t.reservation().checkOut),i.diff(r,"days")>=0)?!1:(u=ko.utils.arrayFirst(t.reservation().availableActions(),function(n){return n==="ConfirmedReservation"}),u)?!1:t.reservation().status()==="NewRequest"||t.reservation().status()==="CancelledReservation"||t.reservation().status()==="CancelledReservationPaymentExpired"?!1:!0};t.confirmAction=function(n,i){var f={id:t.reservation().id,newStatus:n,creditCard:{},cancellationNotes:t.reservation().cancellationNotes(),notes:t.reservation().notes()},r=!1,e,u;switch(n){case"CancelledReservation":case"CancelledRequest":t.cancelCode()!=t.reservation().code&&(e={id:5001,severity:"error",text:IBE.Utils.translate("wrongReservationCode")},t.message(e),t.events.notifySubscribers(e,"error"),r=!0);break;case"ConfirmedReservation":if(t.displayExternalPayment()){f.creditCard=null;break}t.customer().errors().creditCard().length>0&&(r=!0,t.events.notifySubscribers("","error"),t.customer().errors().creditCard().length==1&&t.customer().errors().creditCard()[0]==null?r=!1:t.customer().errors().creditCard.showAllMessages());u=t.customer().creditCard().cardExpirationYear()+"";u=u.substring(2);f.creditCard={holder:t.customer().creditCard().cardHolder(),expireYear:u,expireMonth:t.customer().creditCard().cardExpirationMonth(),number:t.customer().creditCard().cardNumber(),verification:t.customer().creditCard().cardVerification()}}if(r)return!1;t.clearMessage();IBE.Utils.request({type:"POST",data:ko.toJSON(f),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(t.username(),t.password()))}}).done(function(r){if(t.cancelCode(""),t.reservation(new IBE.Models.Reservation(r)),t.customer(new IBE.ViewModels.CustomerPartialViewModel),t.events.notifySubscribers(!0,n),(n=="CancelledReservation"||n=="CancelledRequest")&&t.trackTrivagoConversion(),t.events.notifySubscribers(!0,n),i==="UpdateCreditCard"){var u={id:200,severity:"success",text:IBE.Utils.translate("creditCardUpdated")};t.message(u)}}).fail(function(){var n={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};t.message(n);t.events.notifySubscribers(n,"error")})};t.webCheckIn=function(){var n={code:t.reservation().code,guests:t.guests()};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/reservation/checkin/?apikey="+IBE.Config.apiKey,data:ko.toJSON(n),beforeSend:function(n){t.username()!==""&&t.password()!==""&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(t.username(),t.password()));t.ready(!1)},success:function(n){var i={id:200,severity:"success",text:IBE.Utils.translate("webCheckInSave")};t.isWebCheckedIn(n.webCheckIn);t.message(i)},error:function(n){t.events.notifySubscribers(!0,"ready");var i={id:n.status,severity:"error",text:n.responseText};i.text=n.text;t.message(i);t.events.notifySubscribers(i,"error")},complete:function(){t.ready(!0)}})};t.updateCustomer=function(){var i=ko.utils.arrayFilter(t.customerConsents(),function(n){return n.value()}),n;t.reservation().customer.consents(i);n=t.reservation().customer.toJSON();$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey+"&hotelId="+IBE.Config.hotelId,data:n,beforeSend:function(n){IBE.Utils.haveAuthenticationCookie()&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie());t.ready(!1)},success:function(){var n={id:200,severity:"success",text:IBE.Utils.translate("customerEditSuccess")};t.message(n);t.ready(!0);t.setView("account");t.customerEdit(!1)},error:function(n){t.events.notifySubscribers(!0,"ready");var i={id:n.status,severity:"error",text:n.responseText};t.ready(!0);i.text=n.text;t.message(i);t.events.notifySubscribers(i,"error")},complete:function(){t.ready(!0)}})};t.trackTrivagoConversion=function(){var n=Cache.read("ref","localstorage"),u,i,r,f,e;if((n==="Trivago"||n==="trivago"||n&&n.name&&(n.name==="Trivago"||n.name==="trivago"))&&IBE.Config.userCookieAcceptance===!0){if(u=IBE.Utils.getReservationSetting(t,"trivagoTrackingId"),typeof u=="undefined")return;i=IBE.Utils.getReservationSetting(t,"trivagoConversionKey");r=IBE.Utils.getReservationSetting(t,"trivagoSupplierId");n&&n.params&&n.params.trv_reference&&r&&i&&(f=n.params.trv_reference,e={trv_reference:f,advertiser_id:r,hotel:t.reservation().hotelId,arrival:t.reservation().checkIn.format("YYYY-MM-DD"),departure:t.reservation().checkOut.format("YYYY-MM-DD"),volume:t.reservation().totalCost(),booking_id:t.reservation().id,currency:t.reservation().currencyCode,date_format:"Y-m-d",booking_date:moment(t.reservation().created).format("YYYYMMDD-HHmmss"),booking_date_format:"Ymd-His"},IBE.Utils.request({type:"DELETE",url:"https://secde.trivago.com/tracking/booking",data:JSON.stringify(e),dataType:"json",headers:{"Content-Type":"application/json","X-Trv-Ana-Key":i}}).done(function(){}).fail(function(){}))}}};IBE.ViewModels.PopUpPartialViewModel=function(n){function i(){var n=t.roomId(),f=ko.utils.arrayFilter(t.request().hotelResults(),function(n){return n.hotelId()===t.hotelId()})[0],e=ko.utils.arrayFilter(f.requestedRooms(),function(n){return n.roomIndex()===t.roomIndex()})[0],i=ko.utils.arrayFilter(e.roomResults(),function(n){return n.roomIndex()===t.roomIndex()&&n.roomId()===t.roomId()})[0],u,r;n!==0&&(u=[IBE.Config.apiBaseUrl,"/hotels/availability/",IBE.Config.hotelId,"/",n,"/?apikey=",IBE.Config.apiKey].join(""),r=["RoomAvailability_",t.hotelId(),"_",n,"_",MD5([t.bookingProcess().checkIn(),"_",t.bookingProcess().checkOut()].join(""))].join(""),IBE.Data.RoomAvailability[n]?(i.availability=IBE.Data.RoomAvailability[n],t.data(i)):Cache.read(r)!==!1?(IBE.Data.RoomAvailability[n]=Cache.read(r),i.availability=IBE.Data.RoomAvailability[n],t.data(i)):IBE.Utils.request({url:u}).done(function(u){IBE.Data.RoomAvailability[n]=u;Cache.write(r,IBE.Data.RoomAvailability[n]);i.availability=IBE.Data.RoomAvailability[n];t.data(i)}))}var t=this;ko.utils.extend(t,n);t.roomIndex=ko.observable(1);t.roomId=ko.observable(0);t.ratePlanId=ko.observable(0);t.toggle=function(n,r){t.roomIndex(ko.unwrap(n.roomIndex));t.roomId(n.roomId());t.ratePlanId(n.ratePlanId());i();switch(r){case"availability":case"rateplan":t.activeMenu(r);break;default:t.activeMenu("info")}};t.activeMenu=ko.observable("info");t.selectMenu=ko.computed({write:function(n){t.activeMenu(n)},read:function(){return t.activeMenu()},deferEvaluation:!0});t.data=ko.observable(!1);t.hasFloorplan=ko.computed({read:function(){var i="floorplan",n;return t.data()===!1?!1:t.data().info().photos.length===0||typeof t.data().info().photos=="undefined"?!1:(n=ko.utils.arrayFilter(t.data().info().photos,function(n){return n.type.toLowerCase().indexOf(i)!==-1}),n.length>0?!0:!1)},deferEvaluation:!0})};IBE.ViewModels.Reservation=function(n){var t=this;ko.utils.extend(t,new IBE.ViewModels.Message);ko.utils.extend(t,new IBE.ViewModels.Taxes(t));t.events=new ko.subscribable;t.reservation=ko.observable(n);t.reservationAction=ko.observable("");t.ready=ko.observable(!1);t.creditCard=ko.observable();t.errors=ko.observable({creditCard:ko.validation.group(t.creditCard)});t.setReservationAction=function(n){t.reservationAction(n)};t.save=function(){var n={id:t.reservation().id,code:t.reservation().code,newStatus:t.reservation().status,notes:t.reservation().notes(),cancellactionNotes:t.reservation().cancellactionNotes()};IBE.Utils.request({type:"POST",data:ko.toJSON(n),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())}}).done(function(n){var i=t.reservation().id,r={id:1e3,severity:"info",reservationId:i};t.reservation().refresh(n);t.events.notifySubscribers(r,"reservationinfo")}).fail(function(){var n={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};t.events.notifySubscribers(n,"error");t.message(n)})};t.webCheckIn=function(){var n={code:t.reservation().code,guests:t.reservation().guests()};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/reservation/checkin/?apikey="+IBE.Config.apiKey,data:ko.toJSON(n),beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie());t.ready(!1)},success:function(n){t.clearMessage();var i={id:200,severity:"success",text:IBE.Utils.translate("webCheckInSave")};t.reservation().webCheckIn(n.webCheckIn);t.reservation().webCheckInActive(n.webCheckInActive);t.message(i);t.events.notifySubscribers(i,"webcheckinSave")},error:function(n){t.clearMessage();t.events.notifySubscribers(!0,"ready");var i={id:n.status,severity:"error",text:JSON.parse(n.responseText)};t.message(i);t.events.notifySubscribers(i,"error")},complete:function(){t.ready(!0)}})};t.confirmReservationAction=function(n,i,r){var o={id:t.reservation().id,newStatus:n,creditCard:{},code:t.reservation().code,cancellationNotes:t.reservation().cancellationNotes()},u=!1,e,f;switch(n){case"CancelledReservation":case"CancelledRequest":i.code!=t.reservation().code&&(e={id:5001,severity:"error",text:IBE.Utils.translate("wrongReservationCode")},t.message(e),t.events.notifySubscribers(e,"error"),u=!0);break;case"ConfirmedReservation":t.errors().creditCard().length>0&&(u=!0,t.errors().creditCard().length===1&&t.errors().creditCard()[0]==null?u=!1:t.errors().creditCard.showAllMessages());f=r.cardExpirationYear()+"";f=f.substring(2);o.creditCard={holder:r.cardHolder(),expireYear:f,expireMonth:r.cardExpirationMonth(),number:r.cardNumber(),verification:r.cardVerification()}}if(u)return!1;IBE.Utils.request({type:"POST",data:ko.toJSON(o),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())}}).done(function(i){var r=t.reservation().id,u={id:1e3,severity:"info",text:n,reservationId:r};t.reservation().refresh(i);t.events.notifySubscribers(u,"reservationstatus")}).fail(function(){var n={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};t.events.notifySubscribers(n,"error");t.message(n)})}};IBE.ViewModels.ResponseViewModel=function(){var n=this;n.successTransaction=ko.observable(!1);n.reservationId=ko.observable("");n.authorizationNumber=ko.observable("");n.status=ko.observable("");n.myReservation=ko.observable(null);n.ready=ko.observable(!1);n.statusUpdated=!1;n.events=new ko.subscribable;n.mid=ko.observable("");n.paymentTotal=ko.observable("");n.message=ko.observable("");n.payMethod=ko.observable("");n.paymentRef=ko.observable("");n.orderAmount=ko.observable("");n.txId=ko.observable("");ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));n.status.subscribe(function(t){n.fetchReservation(t)});n.init=function(){$.when(n.languagePartialInit()).then(function(){n.status()===""?n.events.notifySubscribers(!0,"error"):n.events.notifySubscribers(!0,"ready")})};n.events.subscribe(function(){IBEStepsMain.setStep(1)},this,"error");n.events.subscribe(function(){n.ready(!0)},this,"ready");n.fetchReservation=function(){var t=Cache.read("authenticationKey"),r,i;if(t)t=atob(t);else{IBEStepsMain.setStep(1);$("#Header").show();return}r={email:t,code:n.reservationId()};i=new IBE.ViewModels.MyReservation(r);i.reservation.subscribe(function(){n.myReservation(i);n.setConfirmed()});i.init();Cache.clear()};n.setConfirmed=function(){n.statusUpdated||(n.status()==="CAPTURED"?n.confirmAction("ConfirmedReservation"):n.confirmAction("CancelledReservationPaymentExpired"),n.statusUpdated=!0)};n.beforeConfirmAction=function(t,i,r){typeof r=="undefined"&&(r=i);hp.disable($(r.currentTarget));n.confirmAction(t,r)};n.cancelCode=ko.observable("");n.confirmAction=function(t){var i=ko.utils.arrayFirst(n.myReservation().reservation().payments(),function(n){return moment().diff(n.dateToPay,"days")==0&&n.paymentType==="ExternalGateway"}),r="",f;i&&(r=i.id);var i={reservationId:n.myReservation().reservation().id,amount:n.paymentTotal(),transactionId:n.txId(),merchantId:n.mid(),notes:n.message(),transactionLog:" paymentTotal:"+n.paymentTotal()+" payMethod:"+n.payMethod()+" paymentRef:"+n.paymentRef()+" orderAmount:"+n.orderAmount()+" tcID:"+n.txId(),id:r},e={id:n.myReservation().reservation().id,newStatus:t,creditCard:[],cancellationNotes:n.myReservation().reservation().cancellationNotes(),notes:n.myReservation().reservation().notes(),payment:i},u=!1;switch(t){case"CancelledReservation":case"CancelledRequest":n.cancelCode()!=n.myReservation().reservation().code&&(f={id:5001,severity:"error",text:IBE.Utils.translate("wrongReservationCode")},n.events.notifySubscribers(f,"error"),u=!0)}if(u)return!1;IBE.Utils.request({type:"POST",data:ko.toJSON(e),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey}).done(function(i){n.cancelCode("");n.myReservation().reservation(new IBE.Models.Reservation(i));n.events.notifySubscribers(!0,t)}).fail(function(){var t={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};n.message(t);n.events.notifySubscribers(t,"error")})}};IBE.ViewModels.Step1ViewModel=function(){function r(t){var i=new IBE.Models.Hotel({info:new IBE.Models.HotelInfo(t.info),availability:t.availability,settings:t.settings,conditions:t.conditions,defaults:t.defaults,memberships:t.memberships,offers:ko.utils.arrayMap(t.offers,function(t){return new IBE.Models.Offer(t,n)})}),u=moment(),r;i.conditions.firstAvailableDate&&IBE.Utils.getReservationSetting(n,"displayNotAvailable")==0&&(u=moment(i.conditions.firstAvailableDate));i.conditions.minCheckInDate&&(r=moment(i.conditions.minCheckInDate),n.minCheckInDate(r),n.checkIn().diff(r,"days")<=0?n.checkIn(r):n.checkIn().diff(u,"days")<=0&&n.checkIn(u));i.conditions.maxStay>0?n.maxStay(i.conditions.maxStay):n.maxStay(IBE.Config.maxStay);IBE.Config.ibeEnforceMLOS&&n.minStay(parseInt(IBE.Config.minStay));n.maxStay(i.conditions.maxStay);i.settings.maxStay=n.maxStay();n.reservationSettings=new IBE.Models.ReservationSettings(t.settings);n.groupText=IBE.Config.groupText;n.couponExists(t.info.couponExists);n.maxRequestedRooms(i.conditions.maxRequestedRooms);n.boardTypes.removeAll();IBE.Config.ibeShowBoard||n.showBoard(!1);n.boardTypes(i.info.boardTypes);n.boardType(i.info.defaultBoardType());n.rooms=ko.observableArray(ko.utils.arrayMap(t.info.rooms,function(n){return new IBE.Models.RoomInfo(n)}));n.hotel(i);n.requestedRooms().length===0&&n.addRequestedRoom();Cache.read("ref","localstorage")&&n.referrer(new IBE.Models.Referrer(Cache.read("ref","localstorage")));n.ready(!0);n.events.notifySubscribers(!0,"ready")}function i(){var t=[];return ko.utils.arrayForEach(n.requestedRooms(),function(n){var i=[];ko.utils.arrayForEach(n.guests,function(n){i.push({ageCategory:n.ageCategory(),fromAge:n.fromAge(),pax:n.pax(),ages:n.ages()})});t.push(i)}),{checkIn:IBE.Utils.dateIsoFormat(n.checkIn()),checkOut:IBE.Utils.dateIsoFormat(n.checkOut()),rooms:t,couponCode:n.couponCode(),rateplan:n.rateplan,board:n.boardType(),referrer:n.referrer()}}var n=this,t;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.PartialMemberViewModel(n));t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.referrer=ko.observable(new IBE.Models.Referrer);n.allowSubmit=ko.observable(!0);n.rateplan=ko.observable(new IBE.Models.Offer({},n));n.hotel=ko.observable();n.boardTypes=ko.observableArray([]);n.boardType=ko.observable("");n.showBoard=ko.observable(!0);n.board=ko.computed({read:function(){if(!n.hotel())return{};var t=ko.utils.arrayFirst(n.hotel().info.boardTypes,function(t){return t.boardType===n.boardType()});return t==null&&(t=n.hotel().info.boardTypes[0]),t},deferEvaluation:!0});n.rooms=ko.observableArray([]);n.activeRoom=ko.observable(1);n.addGuest=function(t,i){if(t.pax()>t.options().length-1)return!1;if(n.hotel()){if(t.ageCategory()!==IBE.Config.guestType.Infant&&!i.canAddGuest(n.hotel().conditions.maxGuests))return!1;t.pax(t.pax()+1)}};n.addVisible=function(t){return n.hotel()?t.canAddGuest(n.hotel().conditions.maxGuests):{}};n.removeGuest=function(n){if(n.pax()===1&&n.ageCategory()===IBE.Config.guestType.Adult)return!1;n.pax()<=0||n.pax(n.pax()-1)};n.requestedRooms=ko.observableArray([]);n.maxRequestedRooms=ko.observable(1);n.totalGuests=ko.computed({read:function(){var t=0;return ko.utils.arrayForEach(n.requestedRooms(),function(n){ko.utils.arrayForEach(n.guests,function(n){var i=ko.utils.unwrapObservable(n.pax);isNaN(parseInt(i))||(t+=parseInt(i))})}),t},deferEvaluation:!0});n.totalGuestsNoInfants=ko.computed({read:function(){var t=0;return ko.utils.arrayForEach(n.requestedRooms(),function(n){ko.utils.arrayForEach(n.guests,function(n){if(n.ageCategory()!==IBE.Config.guestType.Infant){var i=ko.utils.unwrapObservable(n.pax);isNaN(parseInt(i))||(t+=parseInt(i))}})}),t},deferEvaluation:!0});n.minStay=ko.observable(1);n.maxStay=ko.observable(IBE.Config.maxStay);n.nightOptions=ko.computed({read:function(){for(var i=[],t=1;t<n.maxStay();t++)i.push(t);return i},deferEvaluation:!0});n.nights=ko.computed({write:function(t){var i=moment(n.checkIn());i.add(t,"days");n.checkOut(i)},read:function(){try{return n.checkOut().startOf("day").diff(n.checkIn().startOf("day"),"days")}catch(t){return IBE.Utils.logEvent({message:t.message,hotelId:0,severity:"error"}),1}},deferEvaluation:!0});n._checkIn=ko.observable(moment());n.checkIn=ko.pureComputed({write:function(t){n._checkIn().startOf("day").diff(moment(t).startOf("day"),"days")!==0&&n._checkIn(moment(t))},read:function(){return n._checkIn()}});n.checkIn.subscribe(function(t){var i=moment(t).add(1,"days");n.checkOut()-i<=0&&n.checkOut(i)});n.minCheckInDate=ko.observable(moment());n.maxCheckInDate=moment().add(2,"years");n.minCheckOutDate=ko.computed(function(){var t=moment(n.checkIn());return t.add(n.minStay(),"days"),t});n._checkOut=ko.observable(n.minCheckOutDate());n.checkOut=ko.computed({write:function(t){var i=n.minCheckOutDate(),r;typeof t=="undefined"?i=n.minCheckOutDate():(r=moment(t),r>n.minCheckOutDate()?(i=r,n._checkOut(r)):(i=n.minCheckOutDate(),n._checkOut(n.minCheckOutDate())));n._checkOut().diff(i,"days")!==0&&n._checkOut(i)},read:function(){return n._checkOut()},deferEvaluation:!0});n.dateRange=ko.observable([moment().subtract(1,"days"),moment(),"day"]);n.couponCode=ko.observable("");n.couponValid=ko.observable(!0);n.couponExists=ko.observable(!1);n.bookingProcess=ko.observable(new IBE.Models.BookingProcess({checkIn:n.checkIn,checkOut:n.checkOut,couponCode:n.couponCode,reservationStatus:"Unknown",lang:n.lang,currency:n.currency()}));n.setBoardType=function(t){n.boardType(t.boardType)};n.setRateplan=function(t){IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/offer/"+IBE.Config.hotelId+"/"+t+"?apikey="+IBE.Config.apiKey}).done(function(t){t!==!1&&(n.rateplan(new IBE.Models.Offer(t,n)),n.events.notifySubscribers(!0,"ready"))}).fail(function(){throw{id:"1001",severity:"error",text:"An error occurred"};})};n.canAddRequestedRoom=function(){if(n.hotel())return n.requestedRooms().length<=n.hotel().conditions.maxRequestedRooms-1};n.addRequestedRoom=function(){if(!n.canAddRequestedRoom())return!1;var i=n.requestedRooms().length+1,t=new IBE.Models.RequestedRoom(i);return t.guests=ko.utils.arrayMap(n.hotel().info.guestTypes,function(t){var i=new IBE.Models.RequestedRoomGuestType(t);return t.ageCategory===IBE.Config.guestType.Adult&&i.pax(n.hotel().conditions.defaultAdults),i}),n.requestedRooms.push(t),!0};n.removeRequestedRoom=function(t,i){if(n.requestedRooms().length>1)n.requestedRooms.remove(t);else return!1;if(typeof i!="undefined")try{i.cancelBubble=!0;i.stopImmediatePropagation()}catch(i){}for(var r=0;r<n.requestedRooms().length;r++)n.requestedRooms()[r].roomIndex(r+1);return!0};n.getHotelSettings=function(t){var i="";return $.each(n.hotel().settings,function(n,r){r.Key===t&&(i=r.Value)}),i};n.isDateActive=function(t){var i=IBE.Utils.dateIsoFormat(t);return n.hotel().availability.hasOwnProperty(i)?n.hotel().availability[i]>0:!1};n.isValidCoupon=function(){var t=$.Deferred();return(n.couponCode(n.couponCode().trim()),n.couponCode().length===0)?(n.couponValid(!0),t.resolve(!0),t.promise()):(IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/validateCoupon/"+IBE.Config.hotelId+"/"+encodeURI(n.couponCode())+"?apikey="+IBE.Config.apiKey}).done(function(i){var r=!1;i===!1?(n.message({id:3001,severity:"warning",text:"Coupon is not valid"}),n.couponCode(""),r=!1):r=!0;n.couponValid(r);t.resolve(r)}).fail(function(){n.message({id:"1001",severity:"error",text:"Failed to validate the coupon"});n.couponValid(!1);t.resolve(!1)}),t.promise())};n.validate=function(){if(!n.isValidStay())return n.message({id:3002,severity:"error",text:"invalidDateRange"}),n.events.notifySubscribers({failure:n.message()},"submit"),!1;if(n.couponExists())n.allowSubmit(!1),$.when(n.isValidCoupon()).then(function(t){t?n.events.notifySubscribers({success:i()},"submit"):(n.message({id:3001,severity:"error",text:"invalidPromoCode"}),n.events.notifySubscribers({failure:n.message()},"submit"));n.allowSubmit(!0)});else return n.allowSubmit(!1),n.events.notifySubscribers({success:i()},"submit"),n.allowSubmit(!0),!0;return!0};n.isValidStay=ko.computed({read:function(){return n.nights()>0&&n.nights()<=n.maxStay()},deferEvaluation:!0});n.initTriptease=function(){var n=IBE.Config.tripteaseHotelId,t=IBE.Config.tripteaseClientKey;n&&t&&IBE.Config.userCookieAcceptance===!0&&$("body").append('<script src="https://static.triptease.io/paperboy/'+t+".js?hotelKey="+n+'" defer><\/script>')};n.init=function(i){var u=$.Deferred(),f=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},i);return n.ready(!1),n.dispose(),t.push(n.lang.subscribe(function(){n.init()})),$.when(n.languagePartialInit(f),n.currenciesPartialInit(),n.customerAuthenticate()).then(function(){var t=function(t){t&&typeof t!="undefined"&&(r(t),n.initTriptease(),u.resolve(!0))};$.when(IBE.Utils.loadHotelInfo(t,f)).then(t)}),u.promise()}};IBE.ViewModels.Step2ViewModel=function(){function u(t){var i=!1,r=ko.utils.arrayFirst(n.request().hotelResults(),function(t){return t.hotelId()===n.hotelId()},n),u=ko.utils.unwrapObservable(t);return(ko.utils.arrayForEach(r.requestedRooms(),function(n){i=ko.utils.arrayFirst(n.roomResults(),function(n){return u===n.roomId()})}),i!==!1)?i.availability:!1}function r(r,u){var o=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},u),e,c,f,s,l,h;n.clearMessage();n.baseCurrency=r.currency;n.reservationSettings=new IBE.Models.ReservationSettings(r.settings);IBE.Data.HotelInfo[o.hotelId]&&(IBE.Data.HotelInfo[o.hotelId].info.paymentPolicy=r.hotelInfo[0].paymentPolicy);e=ko.utils.arrayFilter(r.hotelInfo,function(n){return n.hotelId===o.hotelId})[0];n.boards(ko.utils.arrayMap(e.boardTypes,function(n){return new IBE.Models.BoardType(n)}));n.offers(ko.utils.arrayMap(e.offerInfo,function(n){return new IBE.Models.OfferInfo(n)}));c=moment(r.request.checkOut).diff(moment(r.request.checkIn),"days");n.rateplans(ko.utils.arrayMap(e.ratePlanInfo,function(n){return new IBE.Models.RatePlanInfo(n,c)}));n.rooms(ko.utils.arrayMap(e.roomInfo,function(n){return new IBE.Models.RoomInfo(n)}));n.hotelInfo(new IBE.Models.HotelInfo(e));n.hotelInfo().minCheckInDate=new Date(n.reservationSettings.items.MinCheckInDate);f=new IBE.Models.Request;f.checkIn(moment(r.request.checkIn));f.checkOut(moment(r.request.checkOut));f.couponCode(r.request.couponCode);f.preferredBoard(r.request.preferredBoard);f.ratePlanId(r.request.rateplanId);s=[];ko.utils.arrayForEach(r.request.hotelResults,function(t){var i=new IBE.Models.HotelResult,u;i.hotelId(t.hotelId);i.alternatives=t.alternatives;i.availability(IBE.Config.hotelAvailability[t.availability]);n.hotelId(t.hotelId);n.apiKey(o.apiKey);n.tabsCount=t.requestedRooms.length;u=[];ko.utils.arrayForEach(t.requestedRooms,function(t){var i=new IBE.Models.RequestedRoom(n),r,f;i.roomIndex(t.roomIndex);r=[];f=[];ko.utils.arrayForEach(t.guestTypes,function(n){var t=new IBE.Models.RequestedRoomGuestType;t.ageCategory(n.ageCategory);t.fromAge(n.fromAge);t.toAge(n.toAge);t.pax(n.pax);t.minValue(n.min);t.maxValue(n.max);f.push(t)});i.guests=ko.observableArray(f);f=[];ko.utils.arrayForEach(t.roomResults,function(i){var u=new IBE.Models.RoomResult(n),f;u.roomId(i.roomId);u.hotelId(n.hotelId());u.roomIndex(t.roomIndex);u.rank=i.rank;u.availability=IBE.Config.roomAvailability[i.availability];u.availabilityStatus=i.availability;u.availableRooms=i.availableRooms;u.availabilityRestrictions=ko.utils.arrayMap(i.availabilityRestrictions,function(n){return new IBE.Models.AvailabilityRestriction(n)});u.supportedBoards=i.supportedBoards;f=[];ko.utils.arrayForEach(i.ratePlans,function(i){var r=new IBE.Models.RatePlan(n),e;r.ratePlanId(i.ratePlanId);r.offers=ko.observableArray([]);e=[];ko.utils.arrayForEach(i.roomBoards,function(i){var f=new IBE.Models.RoomBoard(n);f.roomIndex=t.roomIndex;f.roomId=u.roomId();f.ratePlanId=r.ratePlanId();f.boardType(i.boardType);f.offers(i.specialOfferList);f.price(i.price);f.priceWithoutDiscount(i.priceWithoutDiscount);f.rateBreakDown=ko.observable(new IBE.Models.RateBreakDown(i.daily));e.push(f)});e.sort(function(n,t){return n.price()>t.price()?1:-1});r.roomBoards=ko.observableArray(e);e=[];f.push(r)});u.rateplans=ko.observableArray(f);f=[];r.push(u)});i.roomResults=ko.observableArray(r);r=[];u.push(i)});i.requestedRooms=ko.observableArray(u);u=[];ko.utils.extend(i,new IBE.ViewModels.SupplementPartialViewModel(t.supplements,r.request.rateplanId));s.push(i)});f.hotelResults=ko.observableArray(s);s=[];n.request(f);IBE.Utils.calculateRoomBoard(n.request());l=new IBE.Models.BookingProcess({checkIn:n.request().checkIn,checkOut:n.request().checkOut,rooms:n.selectedRooms,couponCode:n.request().couponCode(),reservationStatus:"Unknown",lang:n.lang,currency:n.currency,totalGuests:n.request().totalGuests,supplements:ko.observableArray([])});n.bookingProcess(l);h=ko.utils.arrayFilter(n.request().hotelResults(),function(n){return n.hotelId()===o.hotelId})[0];t.push(h.selectedSupplements.subscribe(function(){n.bookingProcess().supplements(ko.unwrap(h.selectedSupplements))}));IBE.Data.RatePlanInfo=IBE.Data.RatePlanInfo.concat(ko.toJS(n.rateplans()));ko.utils.arrayForEach(n.request().hotelResults(),function(t){ko.utils.arrayForEach(t.requestedRooms(),function(t){var r,u,f;ko.utils.arrayForEach(t.roomResults(),function(n){n.rateplans.sort(function(n,t){return n.price()>t.price()?1:-1});n.ratePlanId(n.bestRatePlanId())});r=[];IBE.Config.sortRoomsBy&&IBE.Config.sortRoomsBy.length>0&&(r=IBE.Config.sortRoomsBy);typeof IBE.Data.Settings.ibeRoomSorting!="undefined"&&(r=IBE.Data.Settings.ibeRoomSorting.split(","));r.length>0&&t.sortRoomResults(r);i.hasOwnProperty("roomId")&&(u=[],f=t.roomResults(),ko.utils.arrayFirst(f,function(n,t){if(n.roomId()===i.roomId)return u.push(n),f.splice(t,1),!0}),u.length>0&&(u[0].isFiltered(!0),f.unshift(u[0])));n.roomsPrices(t.orderedRoomsPrices())})});n.popup(new IBE.ViewModels.PopUpPartialViewModel(n));n.ready(!0);n.trackSojernSearch();n.trackSojernProduct();n.showTriptease();n.events.notifySubscribers(!0,"ready")}var n=this,i,t;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.PartialMemberViewModel(n));n.referrer=new IBE.Models.Referrer;n.preferencesChanged=ko.observable(!1);n.hotelId=ko.observable(parseInt(IBE.Config.hotelId));n.apiKey=ko.observable(parseInt(IBE.Config.apiKey));n.bookingProcess=ko.observable();n.rooms=ko.observableArray([]);n.selectedRooms=ko.observableArray([]);n.tabsCount=1;n.activeTabIndex=ko.observable(0);n.activeRoomIndex=ko.observable(1);n.showTabs=ko.computed({read:function(){switch(n.hotel().availability()){case IBE.Config.hotelAvailability.AvailableOnline:return!0;case IBE.Config.hotelAvailability.AvailableOnRequest:return IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayNotAvailable")]==0?!1:!0;default:return!1}},deferEvaluation:!0});n.groupText=IBE.Config.groupText;n.hotel=ko.computed({read:function(){return ko.utils.arrayFirst(n.request().hotelResults(),function(t){return t.hotelId()===n.hotelId()},n)},deferEvaluation:!0});i={};n.rateplans=ko.observableArray([]);n.offers=ko.observableArray([]);n.boards=ko.observableArray([]);n.boardTypeInfo=ko.computed({read:function(){var t=n.request().preferredBoard();return ko.utils.arrayFirst(n.boards(),function(n){return n.boardType===t},n)},deferEvaluation:!0});n.hotelInfo=ko.observable();n.request=ko.observable();n.roomsPrices=ko.observableArray();n.popup=ko.observable(new IBE.ViewModels.PopUpPartialViewModel(n));n.roomImageWidth=ko.observable(390);n.roomImageHeight=ko.observable(310);n.selectRoom=function(t){var h,r,f,e,c;if(n.selectedRooms().length>=n.tabsCount)return!0;if(ko.unwrap(t.bookingAction)===IBE.Config.displayResults.Show)return n.events.notifySubscribers(ko.unwrap(t),"call"),!0;var i=new IBE.Models.SelectedRoom,o=n.activeTabIndex()+1,l=o+1,s=!1;return(ko.utils.arrayForEach(n.request().hotelResults(),function(n){var t=ko.utils.arrayFilter(n.requestedRooms(),function(n){return l==n.roomIndex()});t.length>0&&(s=!0)}),i.roomIndex(ko.unwrap(t.roomIndex)),i.roomId(ko.unwrap(t.roomId)),i.ratePlanId(ko.unwrap(t.ratePlanId)),i.boardType(ko.unwrap(t.boardType)),i.availability(ko.unwrap(u(t.roomId))),h=ko.utils.arrayFirst(n.boards(),function(n){return n.boardType===i.boardType()}),i.board(ko.unwrap(h)),i.guestTypes=ko.observableArray([]),ko.utils.arrayForEach(n.request().hotelResults(),function(n){ko.utils.arrayForEach(n.requestedRooms(),function(n){if(ko.unwrap(t.roomIndex)===ko.unwrap(n.roomIndex())){i.guestTypes(n.guests());return}})}),t instanceof IBE.Models.RoomResult?(r=ko.utils.arrayFirst(t.rateplans(),function(n){return n.ratePlanId()===i.ratePlanId()}),typeof r!="undefined"&&r!=null&&(i.cost(r.price()),i.costWithoutDiscount(r.priceWithoutDiscount()))):t instanceof IBE.Models.RoomBoard&&(i.cost(t.price()),i.costWithoutDiscount(t.priceWithoutDiscount())),i.roomInfo=ko.observable(),f=n.rooms.filterByProperty("id",ko.unwrap(t.roomId)),f().length>0&&i.roomInfo(f()[0]),e=ko.utils.arrayFirst(n.selectedRooms(),function(n){return i.roomIndex===n.roomIndex}),e!==null&&ko.utils.arrayRemoveItem(n.selectedRooms(),e),typeof gtag!="undefined"&&gtag("event","select_room",{event_category:"Step2 Select Room",content_type:"room",items:[{id:i.roomId(),name:i.roomInfo().name,list_name:"Search Results",brand:n.hotelInfo().name,quantity:1,price:i.cost()}]}),n.selectedRooms().push(i),n.bookingProcess.valueHasMutated(),n.bookingProcess().rooms.valueHasMutated(),s)?(n.activeTabIndex(o),!0):n.selectedRooms().length>0?(c=n.prepareData(),n.events.notifySubscribers(c,"submit"),!0):void 0};n.viewAvailability=ko.observable(!1);n.availabilityCalender=function(t,i){var r=t,e=i,s=ko.utils.arrayFilter(n.request().hotelResults(),function(t){return t.hotelId()===n.hotelId()})[0],h=ko.utils.arrayFilter(s.requestedRooms(),function(n){return n.roomIndex()===e})[0],u=ko.utils.arrayFilter(h.roomResults(),function(n){return n.roomIndex()===e&&n.roomId()===r})[0],o,f;r!==0&&(o=[IBE.Config.apiBaseUrl,"/hotels/availability/",IBE.Config.hotelId,"/",r,"/?apikey=",IBE.Config.apiKey].join(""),f=["RoomAvailability_",n.hotelId(),"_",r,"_",MD5([n.bookingProcess().checkIn(),"_",n.bookingProcess().checkOut()].join(""))].join(""),IBE.Data.RoomAvailability[r]?(u.availability=IBE.Data.RoomAvailability[r],u.viewAvailability(!0)):Cache.read(f)!==!1?(IBE.Data.RoomAvailability[r]=Cache.read(f),u.availability=IBE.Data.RoomAvailability[r],u.viewAvailability(!0)):IBE.Utils.request({url:o}).done(function(n){IBE.Data.RoomAvailability[r]=n[0].availability;Cache.write(f,IBE.Data.RoomAvailability[r]);u.availability=IBE.Data.RoomAvailability[r];u.viewAvailability(!0)}))};n.trackSojernSearch=function(){var u=IBE.Config.sojernSearchId,i;if(u&&IBE.Config.userCookieAcceptance===!0){i=0;ko.utils.arrayForEach(n.request().hotelResults()[0].requestedRooms(),function(n){ko.utils.arrayForEach(n.guests(),function(n){n.pax()>0&&(i=i+n.pax())})});var t={hd1:n.bookingProcess().checkIn().format("YYYY-MM-DD"),hd2:n.bookingProcess().checkOut().format("YYYY-MM-DD"),hc1:"",hs1:"",hpr:n.hotelId(),hr:n.request().hotelResults()[0].requestedRooms().length,hpid:n.hotelId(),t:i},f=[],e=[],o=[],r=document.createElement("script"),s={vid:"hot",et:"hs"};for(key in s)t[key]=s[key];for(key in o)f.push(t[o[key]]);t.cid=f.join("|");for(key in t)e.push(key+"="+encodeURIComponent(t[key]));r.type="text/javascript";r.async=!0;r.src="https://beacon.sojern.com/pixel/p/"+u+"?f_v=v6_js&p_v=1&"+e.join("&");(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(r)}};n.trackSojernProduct=function(){var u=IBE.Config.sojernProductId,i;if(u&&IBE.Config.userCookieAcceptance===!0){i=0;ko.utils.arrayForEach(n.request().hotelResults()[0].requestedRooms(),function(n){ko.utils.arrayForEach(n.guests(),function(n){n.pax()>0&&(i=i+n.pax())})});var t={hd1:n.bookingProcess().checkIn().format("YYYY-MM-DD"),hd2:n.bookingProcess().checkOut().format("YYYY-MM-DD"),hc1:"",hs1:"",hpr:n.hotelId(),hr:n.request().hotelResults()[0].requestedRooms().length,hpid:n.hotelId(),t:i},f=[],e=[],o=[],r=document.createElement("script"),s={vid:"hot",et:"hpr"};for(key in s)t[key]=s[key];for(key in o)f.push(t[o[key]]);t.cid=f.join("|");for(key in t)e.push(key+"="+encodeURIComponent(t[key]));r.type="text/javascript";r.async=!0;r.src="https://beacon.sojern.com/pixel/p/"+u+"?f_v=v6_js&p_v=1&"+e.join("&");(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(r)}};n.showTriptease=function(){var t=IBE.Config.tripteaseHotelId,i=IBE.Config.tripteaseClientKey,r=IBE.Config.tripteaseWidgetClosed,u=ko.utils.arrayFirst(n.request().hotelResults(),function(t){return t.hotelId()===n.hotelId()},n);t&&i&&IBE.Config.userCookieAcceptance===!0&&typeof Paperboy!="undefined"&&Paperboy.ready(function(){setTimeout(function(){$(".bookwize-sidebar")&&$(".bookwize-sidebar-vertical").append($(".price-fighter-widget"));var i=0,r=[];ko.utils.arrayForEach(u.requestedRooms(),function(u,f){var e=u.guests()[0].pax();ko.utils.arrayForEach(u.guests(),function(n){n.ageCategory()!=="Adult"&&(i=i+n.pax(),r.push(n.fromAge()))});$(".price-fighter-widget#atr"+(f+1)).attr({"data-pf-hotelkey":t,"data-pf-checkin":moment(ko.unwrap(n.bookingProcess().checkIn())).format("YYYY-MM-DD"),"data-pf-checkout":moment(ko.unwrap(n.bookingProcess().checkOut())).format("YYYY-MM-DD"),"data-pf-direct-price":u.roomResults()[0].price(),"data-pf-room-rate":u.roomResults()[0].rateplans()[0].info().defaultName,"data-pf-currency":n.currency(),"data-pf-layout":"skeleton-1","data-pf-language":n.lang().substr(0,2),"data-pf-adults":e,"data-pf-children":i,"data-pf-children-ages":r})});Paperboy.PriceCheck.activate()},500);r==="True"&&setTimeout(function(){Paperboy.PriceCheck.close()},3e3)})};n.updateTriptease=function(n,t){var i=IBE.Config.tripteaseHotelId,r=IBE.Config.tripteaseClientKey;i&&r&&typeof Paperboy!="undefined"&&Paperboy.ready(function(){$(".price-fighter-widget").attr(n,t);setTimeout(function(){Paperboy.PriceCheck.reset()},500)})};n.removeLastRoom=function(){n.selectedRooms().pop();typeof n.bookingProcess()!="undefined"&&(n.bookingProcess.valueHasMutated(),n.bookingProcess().rooms.valueHasMutated())};n.closedDates=function(n,t){var i=ko.utils.arrayFirst(IBE.Data.HotelInfo[t].info.closedDates,function(t){return moment(t.closedTo).diff(n,"day")>=0});if(i)return IBE.Utils.translate("hotelIsClosedFromTo").format(moment(i.closedFrom).format("LL"),moment(i.closedTo).format("LL"))};n.setRoomIndex=function(t){var f=n.activeTabIndex()+1,i=t.roomIndex()-1,r=!1,u=!1;u=ko.utils.arrayFilter(n.selectedRooms(),function(n){return t.roomIndex()===n.roomIndex()});u.length>0&&(r=!0,n.selectedRooms().splice(i,n.selectedRooms().length));r&&n.activeTabIndex(i);n.bookingProcess.valueHasMutated();n.bookingProcess().rooms.valueHasMutated()};t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.init=function(u,f){n.ready(!1);var e=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang,referrer:new IBE.Models.Referrer},f);i=u;n.referrer=u.ref||u.referrer||u.referer||new IBE.Models.Referrer;n.dispose();t.push(n.lang.subscribe(function(t){n.init(i);n.updateTriptease("data-pf-language",t)}));t.push(n.currency.subscribe(function(t){n.updateTriptease("data-pf-currency",t)}));$.when(n.languagePartialInit(),n.currenciesPartialInit(),n.customerAuthenticate()).then(function(){var f={checkIn:u.checkIn,checkOut:u.checkOut,rooms:u.rooms,ratePlan:u.ratePlan,couponCode:u.couponCode,board:u.board,ipAddress:null,lang:n.lang()||IBE.Config.lang||IBE.Config.defaultLang,hotelId:parseInt(IBE.Config.hotelId),reservationId:u.reservationId||0,referrer:n.referrer||new IBE.Models.Referrer},i=ko.toJSON(f),t="HotelRates_"+e.hotelId+"_"+MD5(i);if(typeof IBE.Data.HotelRates[e.hotelId]=="undefined"&&(IBE.Data.HotelRates[e.hotelId]={}),IBE.Data.HotelRates[e.hotelId].hasOwnProperty(t))return r(IBE.Data.HotelRates[e.hotelId][t]);if(Cache.read(t)!==!1)return r(Cache.read(t),e);IBE.Utils.request({type:"POST",contentType:"application/json",url:IBE.Config.apiBaseUrl+"/hotels/rates/"+e.hotelId+"/?apikey="+e.apiKey,data:i}).done(function(n){IBE.Data.HotelRates[e.hotelId][t]=n;Cache.write(t,IBE.Data.HotelRates[e.hotelId][t]);r(IBE.Data.HotelRates[e.hotelId][t],e);typeof gtag!="undefined"&&gtag("event","send",{event_category:"step1",event_label:"submit"})}).fail(function(t){n.ready(!0);var i={id:t.status,severity:"critical",text:t.statusText+": "+t.responseText};return n.events.notifySubscribers(!1,"ready"),n.events.notifySubscribers(i,"error"),n.message(i),i})}).fail(function(t){console.error(t);var i={id:t.status,severity:"critical",text:t.statusText+": "+t.responseText};return n.events.notifySubscribers(!1,"ready"),n.events.notifySubscribers(i,"error"),n.message(i),i})};n.prepareData=function(){var t={};return t.bookingInfo={checkIn:moment(n.request().checkIn()).format("YYYY-MM-DD"),checkOut:moment(n.request().checkOut()).format("YYYY-MM-DD"),rooms:n.selectedRooms(),couponCode:n.request().couponCode(),supplements:n.request().hotelResults()[0].supplements,notes:"",totalGuests:n.totalGuests,referrer:n.referrer},t.bookingProcess=n.bookingProcess,t}};IBE.ViewModels.Step3ViewModel=function(n){function u(n){t.bookingProcess().id(n.id);t.bookingProcess().baseCurrency=n.currency;t.bookingProcess().isOnline(n.isOnline);t.bookingProcess().checkIn(moment.utc(n.checkIn));t.bookingProcess().checkOut(moment.utc(n.checkOut));t.bookingProcess().couponCode(n.couponCode);t.bookingProcess().paymentMethodType(n.paymentMethod);t.externalPaymentGatewayData(n.externalPaymentGatewayData);t.typePaymentGateway(n.typePaymentGateway);t.bookingProcess().advancePayment(n.advancePayment);t.bookingProcess().cancellationPolicy(n.cancellationPolicy);t.bookingProcess().paymentPolicy(n.paymentPolicy);t.bookingProcess().paymentPolicyHotelTextOption(n.paymentPolicyHotelTextOption);t.bookingProcess().timePolicy(n.timePolicy);t.bookingProcess().payments(n.payments);n.supplements.length>0&&ko.utils.arrayForEach(t.supplements(),function(t){ko.utils.arrayForEach(t.supplementResults(),function(t){var i=ko.utils.arrayFilter(n.supplements,function(n){return n.id===t.supplementId()&&n.roomIndex===t.roomIndex()});ko.utils.arrayForEach(i,function(n){if(n!=null)switch(IBE.Config.supplementPricingType[t.pricingType()]){case IBE.Config.supplementPricingType.PerGuest:ko.utils.arrayForEach(t.prices(),function(i){i.guestType.ageCategory()===n.ageCategory&&(i.quantity(n.quantity),t.isMandatory&&i.minQuantity(n.quantity))});break;default:t.prices()[0].quantity(n.quantity);t.isMandatory&&t.prices()[0].minQuantity(n.quantity)}})})});t.groupText=IBE.Config.groupText;t.bookingProcess().supplements(t.selectedSupplements());i.push(t.selectedSupplements.subscribe(function(){t.bookingProcess().supplements(ko.unwrap(t.selectedSupplements))}));t.bookingProcess().cost=ko.observable(n.totalAmount);t.bookingProcess().costWithoutDiscount=ko.observable(n.totalAmountBeforeDiscount);t.bookingProcess().reservationStatus("Unknown");t.bookingProcess().lang=t.lang;t.bookingProcess().taxes(n.reservationTaxes||[]);IBE.Data.bookingProcess=t.bookingProcess}function f(n){n.sort(function(n,t){return n.name>t.name?1:-1});t.countries.removeAll();ko.utils.arrayPushAll(t.countries,ko.utils.arrayMap(n,function(n){return new IBE.Models.Country(n)}))}function e(n){t.reservationSettings=new IBE.Models.ReservationSettings(n.settings);typeof n.info.acceptedCards!="undefined"&&n.info.acceptedCards!=="All"&&t.acceptedCards(n.info.acceptedCards.split(", "))}var t=this,r,i;t.events=new ko.subscribable;t.ready=ko.observable(!1);ko.utils.extend(t,new IBE.ViewModels.LanguagePartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Message);ko.utils.extend(t,new IBE.ViewModels.PartialMemberViewModel(t));t.referrer=new IBE.Models.Referrer;t.hotelInfo=ko.observable();t.bookingProcess=ko.observable();t.allowSubmit=ko.observable(!0);t.acceptedCards=ko.observableArray([]);t.externalPaymentGateway=ko.observable();t.typePaymentGateway=ko.observable();t.externalPaymentGatewayMessage=ko.observable("");t.externalPaymentGatewayData=ko.observable("");t.redirectPaymentGatewayData=ko.observable("");t.consents=ko.observableArray([]);t.terms=ko.observable();i=[];t.dispose=function(){for(var n in i)i[n].dispose()};t.countries=ko.observableArray([]);t.creditCardChargeText=ko.computed({read:function(){return typeof t.bookingProcess()=="undefined"?"":t.bookingProcess().advancePayment()===0?IBE.Utils.translate("creditCardChargeNoteNoCharge"):IBE.Utils.translate("creditCardChargeNoteAmount").format(t.getRateText(t.bookingProcess().advancePayment(),t.currency()))},deferEvaluation:!0});t.disableButton=ko.observable(!1);t.displayExternalPayment=ko.computed(function(){switch(t.typePaymentGateway()){case"Braintree":return!0;default:return!1}});t.requiredCreditCard=function(){return t.bookingProcess().isOnline()?typeof t.externalPaymentGateway()!="undefined"&&t.typePaymentGateway()==="Braintree"?!1:typeof t.externalPaymentGateway()!="undefined"&&t.typePaymentGateway()==="Stripe"?!1:typeof t.externalPaymentGateway()!="undefined"&&t.typePaymentGateway()==="Payout"&&t.bookingProcess().advancePayment()>0?!1:typeof t.externalPaymentGateway()!="undefined"&&t.typePaymentGateway()==="AlphaBankRedirect"&&t.bookingProcess().advancePayment()>0?!1:typeof t.externalPaymentGateway()!="undefined"&&t.externalPaymentGateway().notStoreCreditCard()?!1:t.displayExternalPayment()?!1:t.bookingProcess().paymentMethodType()==="NoPaymentInfo"?!1:!0:!1};t.disableButton=ko.observable(!1);t.makeReservation=function(){var i,n,f,u;return(t.ready(!1),i=!1,t.disableButton(!0),t.customer().errors().customer().length>0&&t.customer().errors().customer()[0]!==null&&(t.customer().errors().customer.showAllMessages(),i=!0),t.requiredCreditCard()&&t.customer().errors().creditCard().length>0&&(t.customer().errors().creditCard()[0]!==null||!t.customer().creditCard().cardNumber.isValid())&&(t.customer().errors().creditCard.showAllMessages(),i=!0),t.terms.value()||t.terms.id===-1||(t.customer().errors().customer.showAllMessages(),t.terms.value.notifySubscribers(),i=!0),i)?(t.disableButton(!1),typeof t.externalPaymentGateway()!="undefined"&&t.externalPaymentGateway().notStoreCreditCard(!1),t.ready(!0),!1):(r&&r.dispose(),n={},f=[],ko.utils.arrayForEach(t.consents(),function(n){n.value()&&f.push(n.id)}),n.referrer=t.referrer||new IBE.Models.Referrer,n.checkIn=t.bookingProcess().checkIn(),n.checkOut=t.bookingProcess().checkOut(),n.consents=f,n.termsAndPrivacyAcceptedVersion=t.terms.id,n.customer={firstName:t.customer().firstName(),lastName:t.customer().lastName(),email:t.customer().email(),address:t.customer().address(),city:t.customer().city(),zip:t.customer().zip(),telephones:t.customer().phone(),mobile:t.customer().mobile(),fax:t.customer().fax(),birthdate:t.customer().birthdate()&&t.customer().birthdate()!==""?moment(t.customer().birthdate()).format("YYYY-MM-DD"):null},typeof t.externalPaymentGateway()!="undefined"&&(n.externalPaymentGatewayData=t.externalPaymentGateway().externalPaymentGatewayData()),typeof t.customer().title()!="undefined"&&(n.customer.title=t.customer().title().key),typeof t.customer().country()!="undefined"&&(n.customer.country=t.customer().country().code()),t.requiredCreditCard()?(IBE.Config.ibeShowCVC||t.customer().creditCard().cardVerification("000"),u=t.customer().creditCard().cardExpirationYear()+"",u=u.substring(2),n.creditCard={holder:t.customer().creditCard().cardHolder(),expireYear:u,expireMonth:t.customer().creditCard().cardExpirationMonth(),number:t.customer().creditCard().cardNumber(),verification:t.customer().creditCard().cardVerification()}):n.creditCard=null,t.customer().paymentReceipt().name==="companyInvoice"&&(n.company={name:t.customer().company().name(),vatNumber:t.customer().company().vatNumber(),industry:t.customer().company().industry(),address:t.customer().company().address(),zipCode:t.customer().company().zipCode(),phone:t.customer().company().phone()}),n.supplements=[],ko.utils.arrayForEach(t.selectedSupplements(),function(t){ko.utils.arrayForEach(t.prices(),function(i){if(i.quantity()>0){var r=new IBE.Models.BookingSupplement,f=ko.utils.unwrapObservable(t.roomIndex),u=i.guestType;switch(IBE.Config.supplementPricingType[t.pricingType()]){case IBE.Config.supplementPricingType.PerReservation:u=0;f=0;break;case IBE.Config.supplementPricingType.PerRoom:u=0}r.roomIndex=f;r.supplementId=ko.utils.unwrapObservable(t.supplementId);r.quantity=ko.utils.unwrapObservable(i.quantity);r.guestType=u;r.categoryName=t.category();r.ratePlanId=ko.utils.unwrapObservable(t.ratePlanId);n.supplements.push(r)}})}),n.rooms=ko.utils.arrayMap(t.bookingProcess().rooms(),function(n){return{boardType:n.boardType,ratePlanId:n.ratePlanId,roomIndex:n.roomIndex,roomId:n.roomId,guestTypes:n.guestTypes}}),n.couponCode=t.bookingProcess().couponCode(),n.notes=t.customer().notes(),n.cost=t.bookingProcess().cost(),n.advancePayment=t.bookingProcess().advancePayment(),t.events.notifySubscribers(n,"submit"),!1)};t.init=function(r,o){var s=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},o);t.referrer=r.bookingInfo.referrer||new IBE.Models.Referrer;t.customer(new IBE.ViewModels.CustomerPartialViewModel(n));$.when(t.languagePartialInit(s),t.currenciesPartialInit(s),t.customerAuthenticate()).then(function(){IBE.Data.Step3InitData=r;i.push(t.lang.subscribe(function(){t.init(IBE.Data.Step3InitData)}));$.when(IBE.Utils.loadCountries()).then(function(n){f(n)});var n=function(n){n&&(t.hotelInfo(new IBE.Models.HotelInfo(n.info)),t.customer().customerMandatoryFields(n.settings.customerMandatoryFields||{}),e(n),t.consents([]),ko.utils.arrayForEach(n.info.consents,function(n){t.consents.push(new IBE.Models.Consents(n))}),t.terms=new IBE.Models.Terms(n.info.termsAndPrivacy))};$.when(IBE.Utils.loadHotelInfo(n,s)).then(n);t.paymentOptionsRadio=ko.observable(!0);t.paymentOptionsRadio.ForEditing=ko.computed({read:function(){return t.customer().paymentReceipt(t.paymentOptionsRadio()),t.paymentOptionsRadio().toString()},write:function(n){t.paymentOptionsRadio(n==="true")},owner:t});$.when(IBE.Utils.lookupCountry()).then(function(n){var i=ko.utils.arrayFirst(t.countries(),function(t){return t.code()===n});i!=null&&t.customer().country(i)});ko.utils.extend(t,new IBE.ViewModels.SupplementPartialViewModel(r.bookingInfo.supplements(),r.bookingInfo.rooms[0].ratePlanId()));t.bookingProcess=r.bookingProcess;t.currency=t.bookingProcess().currency;t.lang=t.bookingProcess().lang;IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/BookingProcess/"+s.hotelId+"?apikey="+s.apiKey,data:ko.toJSON(t.bookingProcess().bookingProcessPostData()),headers:{"Content-Type":"application/json"}}).done(function(n){if(t.clearMessage(),n===!1){t.ready(!0);t.events.notifySubscribers(!0,"ready");t.message({id:4001,severity:"error",text:"An error occured. Please try again"});t.events.notifySubscribers(t.message(),"error");return}u(n);t.trackSojernCart();t.ready(!0);typeof gtag!="undefined"&&gtag("event","send",{event_category:"step2",event_label:"submit"});t.events.notifySubscribers(!0,"ready")}).fail(function(n){t.ready(!0);t.clearMessage();var i={id:n.status,severity:"critical",text:n.statusText+": "+n.responseText};t.message(i);t.events.notifySubscribers(!1,"ready");t.events.notifySubscribers(i,"error")})})};t.typePaymentGateway.subscribe(function(n){t.bookingProcess().paymentMethodType()==="ExternalPaymentGateway"&&t.externalPaymentGateway(new IBE.ViewModels.ExternalPaymentGateway(t,n,t.externalPaymentGatewayData()))});t.flightInformation=ko.observable(!1);t.showFlightInformationDetails=ko.computed({read:function(){return ko.utils.arrayFirst(t.bookingSupplements(),function(n){return n.categoryName==="transfers"}).length},deferEvaluation:!0});t.flightInformationDetails={flightNumber:ko.observable(""),airportOfArrival:ko.observable(""),estimatedTime:ko.observable("")};t.trackSojernCart=function(){var u=IBE.Config.sojernCartId,i;if(u&&IBE.Config.userCookieAcceptance===!0){if(i=0,typeof t.bookingProcess()=="undefined")return;ko.utils.arrayForEach(t.bookingProcess().rooms(),function(n){ko.utils.arrayForEach(n.guestTypes(),function(n){n.pax()>0&&(i=i+n.pax())})});var n={hd1:t.bookingProcess().checkIn().format("YYYY-MM-DD"),hd2:t.bookingProcess().checkOut().format("YYYY-MM-DD"),hc1:"",hs1:"",hpr:t.hotelInfo().hotelId,hr:t.bookingProcess().rooms().length,hpid:t.hotelInfo().hotelId,t:i,hp:t.bookingProcess().totalCost(),hcu:t.bookingProcess().currency(),hconfno:""},f=[],e=[],o=[],r=document.createElement("script"),s={vid:"hot",et:"hpr"};for(key in s)n[key]=s[key];for(key in o)f.push(n[o[key]]);n.cid=f.join("|");for(key in n)e.push(key+"="+encodeURIComponent(n[key]));r.type="text/javascript";r.async=!0;r.src="https://beacon.sojern.com/pixel/p/"+u+"?f_v=v6_js&p_v=1&"+e.join("&");(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(r)}};t.events.subscribe(function(n){t.externalPaymentGatewayMessage(n)},this,"externalPaymentValidation");t.events.subscribe(function(){t.makeReservation()},this,"makeReservation")};IBE.ViewModels.Step4ViewModel=function(){function i(t){n.reservation(new IBE.Models.Reservation(t));n.membership.customer(n.reservation().customer);typeof IBE.Data.Step3InitData!="undefined"&&ko.utils.extend(n,new IBE.ViewModels.SupplementPartialViewModel(IBE.Data.Step3InitData.bookingInfo.supplements()));n.bookingProcess=IBE.Data.bookingProcess;n.reservation().taxes(t.taxes||[]);n.options.reservationSubmitted||(n.ecommerce(!0),n.trackEcommerce(),n.trackNewAdwords(),n.trackBingCode(),n.trackTrivagoConversion(),n.trackSojernConversion(),n.trackFacebookConversion(),n.initTriptease(),n.googleAds(),n.events.notifySubscribers(t,"track-conversion"));n.ready(!0);n.events.notifySubscribers(!0,"ready")}function r(t){n.hotel(new IBE.Models.HotelInfo(t.info));n.reservationSettings=new IBE.Models.ReservationSettings(t.settings);n.googleMap(new IBE.Models.GoogleMap(t.info))}function u(){var t=[];return ko.utils.arrayForEach(n.selectedSupplements(),function(n){ko.utils.arrayForEach(n.prices(),function(i){if(i.quantity()>0){var r=new IBE.Models.BookingSupplement,f=ko.utils.unwrapObservable(n.roomIndex),u=i.guestType;switch(IBE.Config.supplementPricingType[n.pricingType()]){case IBE.Config.supplementPricingType.PerReservation:u=0;f=0;break;case IBE.Config.supplementPricingType.PerRoom:u=0}r.roomIndex=f;r.supplementId=ko.utils.unwrapObservable(n.supplementId);r.quantity=ko.utils.unwrapObservable(i.quantity);r.guestType=u;t.push(r)}})}),ko.toJS(t)}function f(t){function u(n){var t="Basic "+$.base64.encode(n.username+":"+n.password);return document.cookie="Authorization: "+t,t}function f(n){var r="Authorization=",i=document.cookie.indexOf(r),t;return i!==-1?(t=document.cookie.indexOf(";",i+1),t===-1&&(t=document.cookie.length),unescape(document.cookie.substring(i+r.length,t))):u(n)}var r=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n.options);IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/reservation/?apikey="+r.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",f(t));n.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")}}).done(function(t){n.clearMessage();i(t)}).fail(function(t){var i,r;n.ready(!0);n.clearMessage();i="critical";(t.status===400||t.status===500)&&(i="error");r={id:t.status,severity:i,text:t.responseJSON.Message};n.events.notifySubscribers(r,"error")})}function e(t){var r=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n.options);t.checkIn=moment(t.checkIn).format("YYYY-MM-DD");t.checkOut=moment(t.checkOut).format("YYYY-MM-DD");IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/makereservation/"+r.hotelId+"?apikey="+r.apiKey,data:ko.toJSON(t),headers:{"Content-Type":"application/json"}}).done(function(t){if(n.clearMessage(),t.error){var r={id:t.statusCode(),severity:"error",text:t.responseJSON.message};n.message(r);n.events.notifySubscribers(r,"error");throw r;}if(IBE.Config.externalPaymentGateway==="AlphaBankRedirect"&&IBE.Config.reservationStatus[t.status]===2&&t.redirectPaymentGatewayData!=="undefined"){IBE.Utils.authenticationHeader(t.customer.email,t.code);IBE.Utils.createFormAlphaBankRedirect(t,n);n.ready(!1);return}if(IBE.Config.externalPaymentGateway==="Payout"&&IBE.Config.reservationStatus[t.status]===2&&t.redirectPaymentGatewayData!=="undefined"&&t.redirectPaymentGatewayData!==null){IBE.Utils.authenticationHeader(t.customer.email,t.code);window.location.href=t.redirectPaymentGatewayData;n.ready(!1);return}i(t);IBE.Config.insightParticipantId=""}).fail(function(t){var i,r;n.ready(!0);n.clearMessage();i="critical";(t.status==400||t.status==500)&&(i="error");r={id:t.status,severity:i,text:t.responseJSON.message};n.events.notifySubscribers(r,"error")})}var n=this,t;n.options={};n.events=new ko.subscribable;n.reservation=ko.observable();n.bookingProcess=ko.observable();n.hotel=ko.observable();n.googleMap=ko.observable();n.ready=ko.observable(!1);n.customer=ko.observable();n.ecommerce=ko.observable(!1);n.membership=new IBE.ViewModels.Membership;ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.Taxes(n));t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.adWordsSent=ko.observable(!1);n.trackAdWords=function(){var i,t;if(!n.adWordsSent()){if(google_conversion_id=IBE.Utils.getReservationSetting(n,"adwordsConversionId"),IBE.Config.reservationStatus[n.reservation().status()]===3?(i=IBE.Utils.getReservationSetting(n,"adwordsRequestLabel"),i!==""&&(google_conversion_label=i)):google_conversion_label=IBE.Utils.getReservationSetting(n,"adwordsConversionLabel"),google_conversion_value=ko.unwrap(n.reservation().totalCost),google_remarketing_only=!1,google_conversion_id===0||google_conversion_id===""){console.log("IBE: google_conversion_id is not valid");return}n.options.appendAdwordsImage&&(t=document.createElement("img"),t.height=1,t.width=1,t.border=0,t.src="//www.googleadservices.com/pagead/conversion/"+google_conversion_id+"/?value="+ko.unwrap(n.reservation().totalCost)+"&amp;currency_code="+n.reservation().currencyCode+"&amp;label="+google_conversion_label+"&amp;guid=ON&amp;script=0",$("body").append(t));n.options.trackAdwordsAsync&&typeof google_trackConversion!="undefined"&&window.google_trackConversion({google_conversion_id:google_conversion_id,google_conversion_language:"en",google_conversion_format:"3",google_conversion_color:"ffffff",google_conversion_label:google_conversion_label,google_conversion_value:google_conversion_value,google_conversion_currency:n.reservation().currencyCode,google_remarketing_only:!1});n.adWordsSent(!0)}};n.trackNewAdwords=function(){var t=IBE.Utils.getReservationSetting(n,"adwordsConversionId"),i,r;if(t&&typeof gtag!="undefined"&&IBE.Config.userCookieAcceptance===!0)if(IBE.Config.reservationStatus[n.reservation().status()]===3)i=IBE.Utils.getReservationSetting(n,"adwordsRequestLabel"),i!==""&&(google_conversion_label=i,gtag("event","conversion",{send_to:"AW-"+t+"/"+google_conversion_label,value:n.reservation().totalCost(),currency:n.currency(),transaction_id:n.reservation().id}));else if(IBE.Config.reservationStatus[n.reservation().status()]===1){if(r=IBE.Utils.getReservationSetting(n,"adwordsConversionLabel"),!r)return;gtag("event","conversion",{send_to:"AW-"+t+"/"+r,value:n.reservation().totalCost(),currency:n.currency(),transaction_id:n.reservation().id})}};n.initTriptease=function(){var t=IBE.Config.tripteaseHotelId,i=IBE.Config.tripteaseClientKey;t&&i&&IBE.Config.userCookieAcceptance===!0&&setTimeout(function(){$("body").append('<script defer src="https://static.triptease.io/paperboy/confirm?hotelkey='+t+"&bookingValue="+n.reservation().totalCost()+"&bookingCurrency="+n.reservation().currency()+"&bookingReference="+n.reservation().id+'"><\/script>')},500)};n.trackSojernConversion=function(){if(sojernConversionId=IBE.Config.sojernConversionId,sojernConversionId&&IBE.Config.userCookieAcceptance===!0){var t={hd1:n.reservation().checkIn.format("YYYY-MM-DD"),hd2:n.reservation().checkOut.format("YYYY-MM-DD"),hc1:"",hs1:"",hpr:n.reservation().hotelName,hr:n.reservation().rooms.length,hpid:n.reservation().hotelId,t:n.reservation().guests().length,hp:n.reservation().totalCost(),hcu:n.reservation().currencyCode,hconfno:n.reservation().id},r=[],u=[],f=[],i=document.createElement("script"),e={vid:"hot",et:"hc"};for(key in e)t[key]=e[key];for(key in f)r.push(t[f[key]]);t.cid=r.join("|");for(key in t)u.push(key+"="+encodeURIComponent(t[key]));i.type="text/javascript";i.async=!0;i.src="https://beacon.sojern.com/pixel/p/"+sojernConversionId+"?f_v=v6_js&p_v=1&"+u.join("&");(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(i)}};n.googleAds=function(){var t=document.createElement("img");t.height=1;t.width=1;t.border=0;t.className="google-ads-image";t.src="https://www.googletraveladservices.com/travel/clk/pagead/conversion/2097807373/?label=HPA&guid=ON&script=0&ord="+n.reservation().id+"&data=hct_partner_hotel_id%3D"+n.hotel().hotelId+"%3Bhct_base_price%3D"+ko.unwrap(n.reservation().totalCost)+"%3Bhct_total_price%3D"+ko.unwrap(n.reservation().totalCost)+"%3Bhct_currency_code%3D"+n.currency()+"%3Bhct_checkin_date%3D"+n.reservation().checkIn.format("YYYY-MM-DD")+"%3Bhct_checkout_date%3D"+n.reservation().checkOut.format("YYYY-MM-DD")+"%3Bhct_length_of_stay%3D"+moment(n.reservation().checkOut.format("YYYY-MM-DD")).diff(moment(n.reservation().checkIn.format("YYYY-MM-DD")),"days")+"%3Bhct_date_format%3D%Y-%m-%d%3Bhct_booking_xref%3D"+n.reservation().code+"%3Bhct_ver%3D1.0.i";$("body").append(t)};n.trackFacebookConversion=function(){var t=IBE.Utils.getReservationSetting(n,"facebook_TrackId");t&&typeof fbq!="undefined"&&IBE.Config.userCookieAcceptance===!0&&fbq("track","Purchase",{value:n.reservation().totalCost(),currency:n.currency()})};n.trackTrivagoConversion=function(){var t=Cache.read("ref","localstorage"),u,i,r,f,e;if((t==="Trivago"||t==="trivago"||t&&t.name&&(t.name==="Trivago"||t.name==="trivago"))&&IBE.Config.userCookieAcceptance===!0){if(u=IBE.Utils.getReservationSetting(n,"trivagoTrackingId"),typeof u=="undefined")return;i=IBE.Utils.getReservationSetting(n,"trivagoConversionKey");r=IBE.Utils.getReservationSetting(n,"trivagoSupplierId");t&&t.params&&t.params.trv_reference&&r&&i&&(f=t.params.trv_reference,e={trv_reference:f,advertiser_id:r,hotel:n.reservation().hotelId,arrival:n.reservation().checkIn.format("YYYY-MM-DD"),departure:n.reservation().checkOut.format("YYYY-MM-DD"),volume:n.reservation().totalCost(),booking_id:n.reservation().id,currency:n.reservation().currencyCode,date_format:"Y-m-d",booking_date:moment(n.reservation().created).format("YYYYMMDD-HHmmss"),booking_date_format:"Ymd-His"},IBE.Utils.request({type:"POST",url:"https://secde.trivago.com/tracking/booking",data:JSON.stringify(e),dataType:"json",headers:{"Content-Type":"application/json","X-Trv-Ana-Key":i}}).done(function(){}).fail(function(){}))}};n.trackEcommerce=function(){var f,i,t;if(n.ecommerce()&&typeof gtag!="undefined"&&IBE.Config.reservationStatus[n.reservation().status()]===1){f=1;i=[];ko.utils.arrayForEach(n.reservation().rooms,function(t){var r=ko.unwrap(t);i.push({id:""+n.reservation().id,name:r.name+" "+r.board.name,category:"Rooms",quantity:"1",price:r.totalCost});f+=1});ko.utils.arrayForEach(n.reservation().supplements,function(t){var r=ko.unwrap(t);i.push({id:""+n.reservation().id,name:r.name,category:"Supplements",quantity:r.quantity(),price:r.unitCost()})});var r=IBE.Utils.getReservationSetting(n,"adwordsConversionId"),u="",e=IBE.Utils.getReservationSetting(n,"globalAdwordsConversionId"),o=IBE.Utils.getReservationSetting(n,"globalAdwordsConversionLabel"),s=IBE.Utils.getReservationSetting(n,"googleConversionTrackingPartnerId");r&&typeof gtag!="undefined"&&IBE.Config.userCookieAcceptance===!0||(r="");IBE.Config.reservationStatus[n.reservation().status()]===3?u=IBE.Utils.getReservationSetting(n,"adwordsRequestLabel"):IBE.Config.reservationStatus[n.reservation().status()]===1&&(u=IBE.Utils.getReservationSetting(n,"adwordsConversionLabel"));t=[];r&&u&&t.push("AW-"+r+"/"+u);e&&o&&t.push("AW-"+e+"/"+o);s&&t.push("HA-"+s);gtag("event","purchase",{send_to:t.length>0?t:undefined,transaction_id:n.reservation().id,affiliation:n.reservation().hotelName,value:ko.unwrap(n.reservation().totalCost),currency:n.currency(),items:i,checkout_step:4,id:n.reservation().hotelId,start_date:n.reservation().checkIn.format("YYYY-MM-DD"),end_date:n.reservation().checkOut.format("YYYY-MM-DD")})}};n.trackBingCode=function(){if(IBE.Config.debug){console.log("IBE: In debug mode bing is disabled");return}window.uetq&&IBE.Config.userCookieAcceptance===!0&&window.uetq.push({ec:"Booking",ea:ko.unwrap(n.reservation().status),el:"",ev:""+ko.unwrap(n.reservation().totalCost)})};n.updateReservation=function(){var t={id:n.reservation().id,newStatus:n.reservation().status(),supplements:u(),creditCard:{}};n.clearMessage();IBE.Utils.request({type:"POST",data:ko.toJSON(t),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.reservation().customer.email(),n.reservation().code))}}).done(function(){}).fail(function(t){var i={id:t.status,severity:"critical",text:t.statusText+": "+t.responseText};n.message(i)})};n.init=function(t,i){n.options=ko.utils.extend({trackAdwords:!0,trackAdwordsAsync:!0,appendAdwordsImage:!0,reservationSubmitted:!1,apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},i);$.when(n.languagePartialInit(n.options),n.currenciesPartialInit()).then(function(){n.options.reservationSubmitted=!1;var i=function(n){n&&(r(n),typeof t.username!="undefined"&&typeof t.password!="undefined"?f(t):e(t))};$.when(IBE.Utils.loadHotelInfo(i,n.options)).then(i)})}};IBE.ViewModels.SupplementPartialViewModel=function(n,t){var i=this;i.supplements=ko.observableArray([]);i.selectedSupplements=ko.computed({read:function(){var n=[];return ko.utils.arrayForEach(i.supplements(),function(t){ko.utils.arrayForEach(t.supplementResults(),function(t){var i=!1;ko.utils.arrayForEach(t.prices(),function(n){if(n.quantity()>0){i=!0;return}});i&&n.push(t)})}),n},deferEvaluation:!0});i.bookingSupplements=ko.computed({read:function(){var n=[];return ko.utils.arrayForEach(i.supplements(),function(t){ko.utils.arrayForEach(t.supplementResults(),function(t){ko.utils.arrayForEach(t.prices(),function(i){if(i.quantity()>0){var r=new IBE.Models.BookingSupplement;r.roomIndex=ko.utils.unwrapObservable(t.roomIndex);r.supplementId=ko.utils.unwrapObservable(t.supplementId);r.quantity=ko.utils.unwrapObservable(i.quantity);r.guestType=i.guestType;r.categoryName=t.category();n.push(r)}})})}),n},deferEvaluation:!0});i.showSupplements=ko.computed({read:function(){var n=!1;return ko.utils.arrayForEach(i.supplements(),function(t){ko.utils.arrayForEach(t.supplementResults(),function(t){if(t.isVisible()){var i=0;if(ko.utils.arrayForEach(t.prices(),function(n){i+=n.price()}),i>=0){n=!0;return}}})}),n},deferEvaluation:!0});typeof n!="undefined"&&n!==null&&(t==undefined&&(t=0),n.length>0?(ko.utils.arrayForEach(n,function(n){ko.utils.arrayForEach(n.supplementResults(),function(n){n.setRatePlanId(t)})}),i.supplements=ko.mapping.fromJS(n),i.supplements.valueHasMutated()):$.each(n,function(n,r){var u={categoryName:r.category,supplementResults:ko.observable([])};ko.utils.arrayForEach(r.supplementResults,function(n){var i=new IBE.Models.Supplement(n);i.setRatePlanId(t);u.supplementResults().push(i)});i.supplements.push(u)}))};IBE.ViewModels.Taxes=function(n){n.taxes=ko.observableArray([]);ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));n.excludedTaxes=ko.computed({read:function(){return n.taxes().filter(function(n){return n.payable==="CheckIn"||n.payable==="CheckOut"})},deferEvaluation:!0});n.excludedTaxesCheckIn=ko.computed({read:function(){return n.excludedTaxes().filter(function(n){return n.payable==="CheckIn"}).map(function(n){return n.category=n.category.charAt(0).toLowerCase()+n.category.slice(1),n})},deferEvaluation:!0});n.excludedTaxesCheckOut=ko.computed({read:function(){return n.excludedTaxes().filter(function(n){return n.payable==="CheckOut"}).map(function(n){return n.category=n.category.charAt(0).toLowerCase()+n.category.slice(1),n})},deferEvaluation:!0});n.totalExcludedTaxes=ko.computed({read:function(){return n.excludedTaxes().map(function(n){return n.amount}).reduce(function(n,t){return n+t},0)},deferEvaluation:!0});n.excludedTaxesText=ko.computed({read:function(){var t,i,r,u;return n.excludedTaxes().length?(t=[],i=[],n.excludedTaxes().forEach(function(r){var u=r.category.charAt(0).toLowerCase()+r.category.slice(1);r.payable==="CheckIn"?t.push("{0} {1}".format(n.getRateText(r.amount,n.currency()),IBE.Utils.translate(u))):i.push("{0} {1}".format(n.getRateText(r.amount,n.currency()),IBE.Utils.translate(u)))}),r=[],u=" {0} ".format(IBE.Utils.translate("and")),t.length&&r.push("<li>{0}<\/li>".format(IBE.Utils.translate("excludedTaxText").format(t.join(u),IBE.Utils.translate("checkIn")))),i.length&&r.push("<li>{0}<\/li>".format(IBE.Utils.translate("excludedTaxText").format(i.join(u),IBE.Utils.translate("checkOut")))),r.join("")):""},deferEvaluation:!0})}
     1function minProp(n,t){var i=n.map(function(n){return ko.unwrap(n[t])});return Math.min.apply(Math,i)}function isDateActive(n,t){var i=IBE.Utils.dateIsoFormat(t),r=ko.utils.unwrapObservable(n.hotel);if(!r.availability.hasOwnProperty(i))return!1;switch(r.availability[i]){case-1:return!1;case 0:return IBE.Config.displayResults[displayNotAvailable]!==0;default:return!0}}function getLanguage(n){var t=navigator.language||navigator.userLanguage;return lang=$.datepick.regionalOptions.hasOwnProperty(t)?t:$.datepick.regionalOptions.hasOwnProperty(n)?n:IBE.Config.lang}function localizeDatepicker(n,t,i){t.length>2&&t!=="en-US"&&(t=t.substr(0,2));n.datepick("option").lang!==t&&$.datepick.regionalOptions.hasOwnProperty(t)&&(i=="cinamon"?($.datepick.regionalOptions[t].prevText='<i class="material-icons">&#xE314;<\/i>',$.datepick.regionalOptions[t].nextText='<i class="material-icons">&#xE315;<\/i>'):($.datepick.regionalOptions[t].prevText='<i class="fa fa-chevron-left" />',$.datepick.regionalOptions[t].nextText='<i class="fa fa-chevron-right" />'),n.datepick("option",$.datepick.regionalOptions[t]),n.datepick("option",{lang:t}))}function sameRule(n){for(var i,r=[],u={},t=0,f=n.length;t<f;t++)(i=JSON.stringify(n[t].ruleType),u[i])||(r.push(n[t]),u[i]=!0);return r}var IBE={Models:{},ViewModels:{},Data:{HotelInfo:[],RoomInfo:null,RatePlanInfo:[],ExchangeRates:null,Countries:null,HotelRates:{},RoomAvailability:{}},Translations:{},Utils:{},Config:{},Templates:{}},Cache,MD5,selectedDatepicker,displayNotAvailable,pauseOnSelectEvent,pauseMultiple;IBE.Config={useCache:!0,defaultCache:"sessionStorage",cacheLevel:1,maxStay:90,minStay:1,lang:"en-US",languages:[],localizationUrl:"https://app.bookwize.com/api/v1.3/system/resources/?apikey=",currency:"EUR",googleAnalyticsId:null,googleAnalyticsEnabled:!0,insightParticipantId:"",rsId:0,roomBackgroundImage:"",ibeShowCVC:!0,ibeShowNotes:!0,ibeEnforceMLOS:!1,ibeFlightInfo:!1,ibeArrivalTime:!1,ibeTimePolicy:!1,groupText:"",closeDatesClickable:!0,boardType:{Unknown:0,RoomRate:1,BedAndBreakfast:2,HalfBoard:4,FullBoard:8,AllInclusive:16},guestType:{Adult:"Adult",Children:"Children",Infant:"Infant"},userCookieAcceptance:!1,imageTypes:{offers:{imageTypeKey:"SpecialOffer",imageTransformationKey:"big"},rooms:{imageTypeKey:"Rooms_PopUp",imageTransformationKey:"bigger"},hotel:{imageTypeKey:"MainPhoto",imageTransformationKey:"original"}},supplementPricingType:{PerReservation:0,PerRoom:1,PerGuest:2},supplementTimePricingUnit:{Daily:0,Hourly:1,OneOff:2},supplementTimePricingType:{Stay:0,CheckIn:1,CheckOut:2},roomAvailability:{Available:1,NoAvailability:0,AllotmentOrDatesMissing:-1,HotelIsClosed:-2,AvailabilityRestriction:-3,CannotHost:-4,NoPrices:-5,UponRequest:-6},hotelAvailability:{AvailableOnline:1,AvailableOnRequest:2,HotelIsClosed:3,CannotHost:4,Unknown:0},idDocumentType:{Unknown:0,IdentityCard:1,Passport:2,DrivingLicense:3},gender:{Unknown:0,Male:1,Female:2},titles:{Unknown:0,Mr:1,Mrs:2,Miss:3,Ms:4,Dr:5},sortRoomsBy:["availability.desc","price.asc"],displayResults:{Hide:0,Show:1,OnRequest:2,Online:3},reservationStatus:{UnsavedReservation:0,NewReservationPaymentPending:2,CancelledReservationPaymentExpired:9,ConfirmedReservation:1,NewRequest:3,AcceptedRequest:4,DeclinedRequest:5,CancelledReservation:6,CancelledRequest:7,AlternativeProposed:8,HoldRooms:10,AcceptedRequestForced:11},paymentGatewayType:{None:0,JccRedirect:1,Braintree:2,AlphaBankRedirect:3,PayPal:4,Omise:5,AuthorizeNet:6,Stripe:13},ajaxConfig:{async:!0,cache:!0,dataType:"json",contentType:"application/json",beforeSend:function(n){n.setRequestHeader("Accept-Language","en-US");n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())}},sojernConversionId:"",sojernProductId:"",sojernSearchId:"",sojernCartId:"",tripteaseHotelId:"",tripteaseClientKey:"",tripteaseWidgetClosed:"",ibeShowBoard:!0};IBE.Config.defaultLang=IBE.Config.lang;IBE.Config.defaultLocalizationUrl=IBE.Config.localizationUrl;IBE.Config=$.extend(IBE.Config,IBEConfig);IBE.Config.defaultLocalizationUrl=IBE.Config.baseUrl+IBE.Config.defaultLocalizationUrl;IBE.Config.localizationUrl.substring(0,4)!=="http"&&(IBE.Config.localizationUrl=IBE.Config.baseUrl+IBE.Config.localizationUrl);IBE.Config.ajaxConfig=$.extend(IBE.Config.ajaxConfig,{crossDomain:!0,cache:IBE.Config.useCache,beforeSend:function(n){n.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")}});$.support.cors=!0;$.ajaxSetup(IBE.Config.ajaxConfig),function(n){n.whenAll=function(t){if(t&&t.length){var i=n.Deferred(),e=t.length,r=!1,u,f;return f=function(){--e||i[r?"reject":"resolve"]()},u=function(){r=!0},t.forEach(function(n){n.fail(u).always(f)}),i}return n.Deferred().resolve()}}(jQuery);String.prototype.format||(String.prototype.format=function(){var n=arguments,t=function(t,i){return i in n?n[i]:t};return this.replace(/\{(\d+)\}/g,t)});Cache={prefix:"IBE_",memory:[],supportLocalStorage:function(){if(!IBE.Config.useCache)return!1;try{return typeof Storage!="undefined"?!0:!1}catch(n){return!1}},write:function(n,t,i,r){n=Cache.prefix+n;typeof i=="undefined"&&(i=60);var f=i*6e4,u={value:JSON.stringify(t),timestamp:(new Date).getTime()+f};if(!Cache.supportLocalStorage())return Cache.memory[n]=JSON.stringify(u),t;typeof r=="undefined"&&(r=IBE.Config.defaultCache);try{r.toLowerCase()==="localstorage"?localStorage.setItem(n,JSON.stringify(u)):sessionStorage.setItem(n,JSON.stringify(u))}catch(e){}return t},read:function(n,t){n=Cache.prefix+n;var i;typeof t=="undefined"&&(t=Cache.supportLocalStorage()?IBE.Config.defaultCache||"sessionStorage":"memory");switch(t.toLowerCase()){case"localstorage":i=JSON.parse(localStorage.getItem(n));break;case"sessionstorage":i=JSON.parse(sessionStorage.getItem(n));break;default:Cache.memory[n]!==undefined&&(i=JSON.parse(Cache.memory[n]))}return typeof i=="undefined"||i==null||!i.value?!1:(new Date).getTime()<i.timestamp&&JSON.parse(i.value)},clear:function(n){if(typeof n!="undefined"){n=Cache.prefix+n;var t=Cache.memory.indexOf(n);t>=0&&Cache.memory.splice(t,1);localStorage.removeItem(n);sessionStorage.removeItem(n)}else localStorage.clear(),sessionStorage.clear(),Cache.memory.length=0}};MD5=function(n){function a(n,t){return n<<t|n>>>32-t}function o(n,t){var f,e,r,u,i;return(r=n&2147483648,u=t&2147483648,f=n&1073741824,e=t&1073741824,i=(n&1073741823)+(t&1073741823),f&e)?i^2147483648^r^u:f|e?i&1073741824?i^3221225472^r^u:i^1073741824^r^u:i^r^u}function yt(n,t,i){return n&t|~n&i}function pt(n,t,i){return n&i|t&~i}function wt(n,t,i){return n^t^i}function bt(n,t,i){return t^(n|~i)}function s(n,t,i,r,u,f,e){return n=o(n,o(o(yt(t,i,r),u),e)),o(a(n,f),t)}function h(n,t,i,r,u,f,e){return n=o(n,o(o(pt(t,i,r),u),e)),o(a(n,f),t)}function c(n,t,i,r,u,f,e){return n=o(n,o(o(wt(t,i,r),u),e)),o(a(n,f),t)}function l(n,t,i,r,u,f,e){return n=o(n,o(o(bt(t,i,r),u),e)),o(a(n,f),t)}function kt(n){for(var r,u=n.length,o=u+8,s=(o-o%64)/64,e=(s+1)*16,i=Array(e-1),f=0,t=0;t<u;)r=(t-t%4)/4,f=t%4*8,i[r]=i[r]|n.charCodeAt(t)<<f,t++;return r=(t-t%4)/4,f=t%4*8,i[r]=i[r]|128<<f,i[e-2]=u<<3,i[e-1]=u>>>29,i}function v(n){for(var i="",r="",u,t=0;t<=3;t++)u=n>>>t*8&255,r="0"+u.toString(16),i=i+r.substr(r.length-2,2);return i}function dt(n){var i,r,t;for(n=n.replace(/\r\n/g,"\n"),i="",r=0;r<n.length;r++)t=n.charCodeAt(r),t<128?i+=String.fromCharCode(t):t>127&&t<2048?(i+=String.fromCharCode(t>>6|192),i+=String.fromCharCode(t&63|128)):(i+=String.fromCharCode(t>>12|224),i+=String.fromCharCode(t>>6&63|128),i+=String.fromCharCode(t&63|128));return i}var e=Array(),f,ht,ct,lt,at,t,i,r,u,y=7,p=12,w=17,b=22,k=5,d=9,g=14,nt=20,tt=4,it=11,rt=16,ut=23,ft=6,et=10,ot=15,st=21,vt;for(n=dt(n),e=kt(n),t=1732584193,i=4023233417,r=2562383102,u=271733878,f=0;f<e.length;f+=16)ht=t,ct=i,lt=r,at=u,t=s(t,i,r,u,e[f+0],y,3614090360),u=s(u,t,i,r,e[f+1],p,3905402710),r=s(r,u,t,i,e[f+2],w,606105819),i=s(i,r,u,t,e[f+3],b,3250441966),t=s(t,i,r,u,e[f+4],y,4118548399),u=s(u,t,i,r,e[f+5],p,1200080426),r=s(r,u,t,i,e[f+6],w,2821735955),i=s(i,r,u,t,e[f+7],b,4249261313),t=s(t,i,r,u,e[f+8],y,1770035416),u=s(u,t,i,r,e[f+9],p,2336552879),r=s(r,u,t,i,e[f+10],w,4294925233),i=s(i,r,u,t,e[f+11],b,2304563134),t=s(t,i,r,u,e[f+12],y,1804603682),u=s(u,t,i,r,e[f+13],p,4254626195),r=s(r,u,t,i,e[f+14],w,2792965006),i=s(i,r,u,t,e[f+15],b,1236535329),t=h(t,i,r,u,e[f+1],k,4129170786),u=h(u,t,i,r,e[f+6],d,3225465664),r=h(r,u,t,i,e[f+11],g,643717713),i=h(i,r,u,t,e[f+0],nt,3921069994),t=h(t,i,r,u,e[f+5],k,3593408605),u=h(u,t,i,r,e[f+10],d,38016083),r=h(r,u,t,i,e[f+15],g,3634488961),i=h(i,r,u,t,e[f+4],nt,3889429448),t=h(t,i,r,u,e[f+9],k,568446438),u=h(u,t,i,r,e[f+14],d,3275163606),r=h(r,u,t,i,e[f+3],g,4107603335),i=h(i,r,u,t,e[f+8],nt,1163531501),t=h(t,i,r,u,e[f+13],k,2850285829),u=h(u,t,i,r,e[f+2],d,4243563512),r=h(r,u,t,i,e[f+7],g,1735328473),i=h(i,r,u,t,e[f+12],nt,2368359562),t=c(t,i,r,u,e[f+5],tt,4294588738),u=c(u,t,i,r,e[f+8],it,2272392833),r=c(r,u,t,i,e[f+11],rt,1839030562),i=c(i,r,u,t,e[f+14],ut,4259657740),t=c(t,i,r,u,e[f+1],tt,2763975236),u=c(u,t,i,r,e[f+4],it,1272893353),r=c(r,u,t,i,e[f+7],rt,4139469664),i=c(i,r,u,t,e[f+10],ut,3200236656),t=c(t,i,r,u,e[f+13],tt,681279174),u=c(u,t,i,r,e[f+0],it,3936430074),r=c(r,u,t,i,e[f+3],rt,3572445317),i=c(i,r,u,t,e[f+6],ut,76029189),t=c(t,i,r,u,e[f+9],tt,3654602809),u=c(u,t,i,r,e[f+12],it,3873151461),r=c(r,u,t,i,e[f+15],rt,530742520),i=c(i,r,u,t,e[f+2],ut,3299628645),t=l(t,i,r,u,e[f+0],ft,4096336452),u=l(u,t,i,r,e[f+7],et,1126891415),r=l(r,u,t,i,e[f+14],ot,2878612391),i=l(i,r,u,t,e[f+5],st,4237533241),t=l(t,i,r,u,e[f+12],ft,1700485571),u=l(u,t,i,r,e[f+3],et,2399980690),r=l(r,u,t,i,e[f+10],ot,4293915773),i=l(i,r,u,t,e[f+1],st,2240044497),t=l(t,i,r,u,e[f+8],ft,1873313359),u=l(u,t,i,r,e[f+15],et,4264355552),r=l(r,u,t,i,e[f+6],ot,2734768916),i=l(i,r,u,t,e[f+13],st,1309151649),t=l(t,i,r,u,e[f+4],ft,4149444226),u=l(u,t,i,r,e[f+11],et,3174756917),r=l(r,u,t,i,e[f+2],ot,718787259),i=l(i,r,u,t,e[f+9],st,3951481745),t=o(t,ht),i=o(i,ct),r=o(r,lt),u=o(u,at);return vt=v(t)+v(i)+v(r)+v(u),vt.toLowerCase()};jQuery.base64=function(){function t(t,i){var r=n.indexOf(t.charAt(i));if(r===-1)throw"Cannot decode base64";return r}function u(n){var o=0,i,u,f=n.length,e=[];if(n=String(n),f===0)return n;if(f%4!=0)throw"Cannot decode base64";for(n.charAt(f-1)===r&&(o=1,n.charAt(f-2)===r&&(o=2),f-=4),i=0;i<f;i+=4)u=t(n,i)<<18|t(n,i+1)<<12|t(n,i+2)<<6|t(n,i+3),e.push(String.fromCharCode(u>>16,u>>8&255,u&255));switch(o){case 1:u=t(n,i)<<18|t(n,i+1)<<12|t(n,i+2)<<6;e.push(String.fromCharCode(u>>16,u>>8&255));break;case 2:u=t(n,i)<<18|t(n,i+1)<<12;e.push(String.fromCharCode(u>>16))}return e.join("")}function i(n,t){var i=n.charCodeAt(t);if(i>255)throw"INVALID_CHARACTER_ERR: DOM Exception 5";return i}function f(t){if(arguments.length!==1)throw"SyntaxError: exactly one argument required";t=String(t);var f,u,e=[],o=t.length-t.length%3;if(t.length===0)return t;for(f=0;f<o;f+=3)u=i(t,f)<<16|i(t,f+1)<<8|i(t,f+2),e.push(n.charAt(u>>18)),e.push(n.charAt(u>>12&63)),e.push(n.charAt(u>>6&63)),e.push(n.charAt(u&63));switch(t.length-o){case 1:u=i(t,f)<<16;e.push(n.charAt(u>>18)+n.charAt(u>>12&63)+r+r);break;case 2:u=i(t,f)<<16|i(t,f+1)<<8;e.push(n.charAt(u>>18)+n.charAt(u>>12&63)+n.charAt(u>>6&63)+r)}return e.join("")}var r="=",n="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";return{decode:u,encode:f,VERSION:"1.0"}}(jQuery);window.onerror=function(n,t,i){if(!(n.indexOf("Script error.")>-1)){var u=t+" (line: "+i+")\n"+n,r={};return r.message=u,r.hotelId=IBE.Config.hotelId,r.severity="",n.indexOf("Unable to process binding")>0&&(r.severity="critical",typeof loader!="undefined"&&(loader.title("Failed to initialize booking engine :("),loader.message(r),loader.visible(!0))),IBE.Utils.logEvent(r),!0}};IBE.Utils.request=function(n){var u,t,i,r;if(n.url)return(n.url.indexOf(".html")!==-1?n.beforeSend=function(n){n.setRequestHeader("Content-Type","text/html")}:IBE.Utils.haveAuthenticationCookie()&&(n.beforeSend=function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())}),u={dataType:"json",type:"GET",crossDomain:!0,headers:{}},n=$.extend(!0,u,n),n.headers=n.headers||{},n.headers.hasOwnProperty("Accept-Language")||(n.headers["Accept-Language"]=IBE.Config.lang||"en-US"),IBE.Config.insightParticipantId==""&&(IBE.Config.insightParticipantId=IBE.Utils.generateGuid()),n.headers.hasOwnProperty("Insights-ParticipantId")||IBE.Config.insightParticipantId==""||(n.headers["Insights-ParticipantId"]=IBE.Config.insightParticipantId),t=$.Deferred(),IBE.Config.cacheLevel===2&&n.type.toLowerCase()!=="post"&&(i="ibe_"+MD5(ko.toJSON(n)),r=Cache.read(i),r!==!1))?(t.resolve(r),t.promise()):($.ajax(n).done(function(n){IBE.Config.cacheLevel===2&&Cache.write(i,n);t.resolve(n)}).fail(function(n){t.reject(n)}),t.promise())};IBE.Utils.bindTemplate=function(n,t,i,r){function u(){IBE.Utils.consoleLog("<ibe/template> Binding Template "+i+" for "+typeof t+" in "+n);var u=document.getElementById(n),e=ko.contextFor(u);e&&ko.cleanNode(u);try{typeof r!="undefined"&&typeof r.beforeRender=="function"&&r.beforeRender();ko.applyBindings(t,u);typeof r!="undefined"&&typeof r.afterRender=="function"&&r.afterRender()}catch(o){IBE.Utils.logEvent(o)}f.resolve(i)}typeof i=="undefined"&&(i=$("#"+n).data("template"));i.indexOf("http")<0&&(i=IBE.Config.baseUrl+i);var f=$.Deferred();return IBE.Utils.request({url:i,cache:IBE.Config.useCache,dataType:"html",async:!1}).always(function(t){var i,r;if($("#"+n).html(t),i=$("#"+n).find('script[type="text/html"]'),i.length===0){u();return}r=[];i.each(function(n,t){var u=$(t),i=u.attr("src");typeof i!="undefined"&&(i.indexOf("http")<0&&(i=IBE.Config.baseUrl+i),$(u.data("target")).html()==""&&r.push(IBE.Utils.request({url:i,cache:IBE.Config.useCache,dataType:"html",async:!1,headers:{"Accept-Language":lang}}).always(function(n){$(u.data("target")).html(n)})))});$.when(r).then(function(){u()})}),f.promise()};IBE.Utils.processingRequests={};IBE.Utils.addProcessingRequest=function(n,t,i){t=t||function(){};typeof IBE.Utils.processingRequests[n].callbacks=="undefined"&&(IBE.Utils.processingRequests[n].callbacks=[]);typeof i!="undefined"&&IBE.Utils.processingRequests[n].callbacks.unshift(t);IBE.Utils.processingRequests[n].callbacks.push(t)};IBE.Utils.processingRequestsCallbacks=function(n,t){if(typeof IBE.Utils.processingRequests[n]!="undefined"){if(typeof IBE.Utils.processingRequests[n].callbacks!="undefined")while(IBE.Utils.processingRequests[n].callbacks.length>0){var i=IBE.Utils.processingRequests[n].callbacks.pop();typeof i=="function"&&i(t)}delete IBE.Utils.processingRequests[n]}};IBE.Utils.loadCountries=function(){var n=$.Deferred(),t="Countries";return(IBE.Data.Countries==null&&Cache.read(t)!==!1&&(IBE.Data.Countries=Cache.read(t)),IBE.Data.Countries)?(n.resolve(IBE.Data.Countries),n.promise()):(IBE.Utils.request({dataType:"json",url:IBE.Config.apiBaseUrl+"/countries/?apikey="+IBE.Config.apiKey}).done(function(i){IBE.Data.Countries=i;Cache.write(t,IBE.Data.Countries);n.resolve(i)}),n.promise())};IBE.Utils.loadHotelInfo=function(n,t){IBE.Data.HotelInfo||(IBE.Data.HotelInfo=[]);var i=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},t),r=$.Deferred(),f,e=IBE.Utils.queryString(ko.utils.extend({apikey:i.apiKey,lang:i.lang})),o=IBE.Config.apiBaseUrl+"/hotels/info/"+i.hotelId+"/?"+e,u="HotelInfo_"+i.hotelId+"_"+i.lang;if(IBE.Data.Lang!==IBE.Config.lang&&(IBE.Data.HotelInfo[i.hotelId]=null),IBE.Data.HotelInfo[i.hotelId])return r.resolve(IBE.Data.HotelInfo[i.hotelId]),r.promise();if((f=Cache.read(u))!==!1)return IBE.Data.HotelInfo[i.hotelId]=f,IBE.Data.Lang=IBE.Config.lang,IBE.Utils.LoadAdditionalSettings(i),IBE.Utils.consoleLog("<ibe/cache> HotelInfo loaded from "+IBE.Config.defaultCache),r.resolve(IBE.Data.HotelInfo[i.hotelId]),r.promise();if(typeof IBE.Utils.processingRequests[u]=="undefined")return IBE.Utils.processingRequests[u]={processing:!0},IBE.Utils.request({url:o}).done(function(n){IBE.Data.HotelInfo[i.hotelId]=n;IBE.Data.Lang=IBE.Config.lang;IBE.Utils.LoadAdditionalSettings(i);Cache.write(u,IBE.Data.HotelInfo[i.hotelId]);r.resolve(IBE.Data.HotelInfo[i.hotelId]);IBE.Utils.processingRequestsCallbacks(u,IBE.Data.HotelInfo[i.hotelId])}).fail(function(n){r.reject(n)}),r.promise();IBE.Utils.addProcessingRequest(u,n)};IBE.Utils.LoadAdditionalSettings=function(n){if(IBE.Data.HotelInfo[n.hotelId].settings.ibeFlightInfo&&(IBE.Config.ibeFlightInfo=IBE.Data.HotelInfo[n.hotelId].settings.ibeFlightInfo,IBE.Config.ibeFlightInfo=IBE.Config.ibeFlightInfo==="False"?!1:!0),IBE.Data.HotelInfo[n.hotelId].settings.ibeShowBoard&&(IBE.Config.ibeShowBoard=IBE.Data.HotelInfo[n.hotelId].settings.ibeShowBoard,IBE.Config.ibeShowBoard=IBE.Config.ibeShowBoard==="False"?!1:!0),IBE.Data.HotelInfo[n.hotelId].settings.ibeArrivalTime&&(IBE.Config.ibeArrivalTime=IBE.Data.HotelInfo[n.hotelId].settings.ibeArrivalTime,IBE.Config.ibeArrivalTime=IBE.Config.ibeArrivalTime==="False"?!1:!0),IBE.Data.HotelInfo[n.hotelId].settings.ibeTimePolicy&&(IBE.Config.ibeTimePolicy=IBE.Data.HotelInfo[n.hotelId].settings.ibeTimePolicy,IBE.Config.ibeTimePolicy=IBE.Config.ibeTimePolicy==="False"?!1:!0),IBE.Data.HotelInfo[n.hotelId].settings.closeDatesNotClickable){var t=IBE.Data.HotelInfo[n.hotelId].settings.closeDatesNotClickable;IBE.Config.closeDatesClickable=t==="False"?!0:!1}IBE.Data.HotelInfo[n.hotelId].settings.ibeShowCVC&&(IBE.Config.ibeShowCVC=IBE.Data.HotelInfo[n.hotelId].settings.ibeShowCVC,IBE.Config.ibeShowCVC=IBE.Config.ibeShowCVC==="False"?!1:!0);IBE.Data.HotelInfo[n.hotelId].settings.ibeEnforceMLOS&&(IBE.Config.ibeEnforceMLOS=IBE.Data.HotelInfo[n.hotelId].settings.ibeEnforceMLOS,IBE.Config.ibeEnforceMLOS=IBE.Config.ibeEnforceMLOS==="False"?!1:!0);IBE.Data.HotelInfo[n.hotelId].settings.ibeShowNotes&&(IBE.Config.ibeShowNotes=IBE.Data.HotelInfo[n.hotelId].settings.ibeShowNotes,IBE.Config.ibeShowNotes=IBE.Config.ibeShowNotes==="False"?!1:!0);IBE.Config.externalPaymentGateway=IBE.Data.HotelInfo[n.hotelId].settings.externalPaymentGateway?IBE.Data.HotelInfo[n.hotelId].settings.externalPaymentGateway:"0";IBE.Data.HotelInfo[n.hotelId].settings.webCheckIn&&(IBE.Config.webCheckIn=IBE.Data.HotelInfo[n.hotelId].settings.webCheckIn,IBE.Config.webCheckIn=IBE.Config.webCheckIn==="False"?!1:!0);IBE.Config.memberships=[];IBE.Data.HotelInfo[n.hotelId].memberships&&(IBE.Config.memberships=IBE.Data.HotelInfo[n.hotelId].memberships);IBE.Config.trivagoId=[];IBE.Data.HotelInfo[n.hotelId].settings.trivagoId&&(IBE.Config.trivagoId=IBE.Data.HotelInfo[n.hotelId].settings.trivagoId);IBE.Data.HotelInfo[n.hotelId].settings.moneyFormat&&(IBE.Config.moneyFormat=IBE.Data.HotelInfo[n.hotelId].settings.moneyFormat);IBE.Data.HotelInfo[n.hotelId].settings.group&&(IBE.Config.groupText=IBE.Data.HotelInfo[n.hotelId].settings.group);IBE.Data.HotelInfo[n.hotelId].settings.showCurrencyCode&&(IBE.Config.showCurrencyCode=IBE.Data.HotelInfo[n.hotelId].settings.showCurrencyCode,IBE.Config.showCurrencyCode=IBE.Config.showCurrencyCode==="False"?!1:!0)};IBE.Utils.loadExchangeRates=function(n,t){var u=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},t),r=$.Deferred(),i="ExchangeRates";if(IBE.Data.ExchangeRates==null&&Cache.read(i)!==!1&&(IBE.Data.ExchangeRates=Cache.read(i)),IBE.Data.ExchangeRates)return IBE.Utils.consoleLog("<ibe/cache> ExchangeRates loaded from "+IBE.Config.defaultCache),r.resolve(IBE.Data.ExchangeRates),r.promise();if(typeof IBE.Utils.processingRequests[i]=="undefined")return IBE.Utils.processingRequests[i]={processing:!0},IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/exchangeRates/?apikey="+u.apiKey}).done(function(n){IBE.Data.ExchangeRates=n;Cache.write(i,IBE.Data.ExchangeRates,60);r.resolve(IBE.Data.ExchangeRates);IBE.Utils.processingRequestsCallbacks(i,IBE.Data.ExchangeRates)}).fail(function(n){var t={};t.Message=ko.toJSON(n);t.hotelId=parseInt(IBE.Config.hotelId);t.Severity="critical";IBE.Utils.logEvent(t)}),r.promise();IBE.Utils.addProcessingRequest(i,n)};IBE.Utils.translate=function(n){try{if(IBE.Translations.hasOwnProperty(n))return IBE.Translations[n]}catch(t){IBE.Utils.logEvent({Message:"IBE.Translation failed for key: "+n+". Exception: "+t.toJSON(),HotelId:parseInt(IBE.Config.hotelId),Severity:"warn"})}return n};IBE.Utils.translationsLoaded={};IBE.Utils.loadTranslations=function(n,t){var u;if(typeof n!="undefined"){var f=n.substring(0,2),r=$.Deferred(),i="resources_"+IBE.Config.rsId+"_"+f;if(Cache.read(i)!==!1)return IBE.Config.lang=n,IBE.Translations=Cache.read(i),IBE.Utils.translationsLoaded[n]=!0,IBE.Utils.consoleLog("<ibe/cache> Changed language to "+n+" and fetched resources from "+IBE.Config.defaultCache),typeof t=="function"&&t(n),r.resolve(IBE.Config.lang),r.promise();if(u=IBE.Config.localizationUrl,u+=u.indexOf("?")==-1?"?lang="+f:"&lang="+f,typeof IBE.Utils.processingRequests[i]=="undefined")return IBE.Utils.processingRequests[i]={processing:!0},IBE.Utils.request({url:u,dataType:"text",async:!1,headers:{"Accept-Language":n}}).done(function(u){IBE.Config.lang=n;IBE.Translations=$.parseJSON(u);IBE.Utils.translationsLoaded[n]=!0;IBE.Utils.consoleLog("Changed language to "+n+" and fetched resources from "+IBE.Config.localizationUrl.format(n)+"&lang="+n.substring(0,2));Cache.write(i,IBE.Translations,3600);console.log(new Date+"Processing lang callbacks");IBE.Utils.processingRequestsCallbacks(i,IBE.Config.lang);r.resolve(IBE.Config.lang);typeof t=="function"&&t(n)}).fail(function(){IBE.Utils.consoleLog("Language "+n+" not found. Trying for default language");IBE.Utils.request({url:IBE.Config.localizationUrl.format(IBE.Config.lang),dataType:"text",async:!1}).done(function(u){IBE.Translations=$.parseJSON(u);IBE.Utils.translationsLoaded[n]=!0;IBE.Utils.consoleLog("Changed language to "+IBE.Config.lang+" and fetched resources from "+IBE.Config.localizationUrl.format(IBE.Config.lang));Cache.write(i,IBE.Translations,3600);IBE.Utils.processingRequestsCallbacks(i,IBE.Config.lang);r.resolve(IBE.Config.lang);typeof t=="function"&&t(IBE.Config.lang)})}),r.promise();console.log(new Date+"Add new lang callback "+i);IBE.Utils.addProcessingRequest(i)}};IBE.Utils.findTranslation=function(n){return IBE.Translations.hasOwnProperty(n)?IBE.Translations[n]:n};IBE.Utils.consoleLog=function(n){if(IBE.Config.debug)try{if(typeof n=="object"){console.log(n);return}var t="";n.indexOf("cache")>-1&&(t="color: #db7c07;");n.indexOf("template")>-1&&(t="color: #364280;");n.indexOf("Google")>-1&&(t="color: #25ab26 ;");n.indexOf("error")>-1&&(t="background: #b81414; color: #fff");n="%c"+n;console.log(n,t)}catch(i){}};IBE.Utils.lookupCountry=function(){var n=$.Deferred();return IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/system/countrylookup/?apikey="+IBE.Config.apiKey,dataType:"json",contentType:"application/json"}).done(function(t){n.resolve(t)}).fail(function(n){IBE.Utils.consoleLog("Country Lookup failed");var t={};t.Message=n.toJSON();t.hotelId=parseInt(IBE.Config.hotelId);t.Severity="Warning";IBE.Utils.logEvent(t)}),n.promise()};IBE.Utils.populatePhotos=function(n){var t=[];return typeof n=="undefined"?t:(ko.utils.arrayMap(n,function(n){var i=new IBE.Models.Photo(n);i.url()!=""&&t.push(i)}),t)};IBE.Utils.populateGuestTypes=function(n){if(typeof n=="undefined")return[];var t=[];return $.each(n,function(n,i){var r=new IBE.Models.GuestType(i);t.push(r)}),t};IBE.Utils.populateSettings=function(n){var t,e,o,u,i,s,f,r,h;if(typeof n=="undefined")return[];for(t in n)if(n.hasOwnProperty(t))switch(t){case"maxAdults":case"maxChildren":case"maxRooms":n[t]=parseInt(n[t]);break;case"ibeRoomSorting":e=n[t];o=e.replace("availability.","availabilitySorting.");n[t]=o;break;case"sojern":u=JSON.parse(n[t]);for(i in u)u.hasOwnProperty(i)&&(s=i.toString().charAt(0).toLowerCase()+i.toString().slice(1),IBE.Config[s]=u[i]);break;case"triptease":f=JSON.parse(n[t]);for(r in f)f.hasOwnProperty(r)&&(h=r.toString().charAt(0).toLowerCase()+r.toString().slice(1),IBE.Config[h]=f[r])}return n};IBE.Utils.populateBoardTypes=function(n){if(typeof n=="undefined")return[];var t=[];return $.each(n,function(n,i){var r=new IBE.Models.BoardType(i);t.push(r)}),t};IBE.Utils.weekdayRates=function(n){for(var t,u,e=[],i=[],f=moment(n[0].date()),o=moment(n[n.length-1].date()),s=moment(f).isoWeekday(1),h=moment(o).isoWeekday(7),c=h.diff(s,"days"),l=f.diff(s,"days"),r=0;r<=c;r++)t=new IBE.Models.Daily({}),t.status="stay",t.price=0,t.priceWithoutDiscount=0,u=r-l,u>=0&&u<n.length&&(t.price=n[u].price(),t.priceWithoutDiscount=n[u].priceWithoutDiscount()),t.date=s.clone().add(r,"d"),t.date==f&&(t.status="checkIn"),t.date==o&&(t.status="checkOut"),t.date<f&&(t.status="inactive"),t.date>o&&(t.status="inactive"),i.push(t),(r+1)%7==0&&(e.push(i),i=[]);return i.length>0&&e.push(i),e};IBE.Utils.calculateRoomBoard=function(n){var t=n.preferredBoard();ko.utils.arrayForEach(n.hotelResults(),function(i){ko.utils.arrayForEach(i.requestedRooms(),function(i){ko.utils.arrayForEach(i.roomResults(),function(i){for(var r,o=IBE.Config.boardType[t],f=0,e=i.supportedBoards.replace(/,/g,"").split(" "),s=e.length,u=0;u<s;u++)f+=IBE.Config.boardType[e[u]];r="";r=f&o?n.preferredBoard():IBE.Config.defaultBoardType;ko.utils.arrayForEach(i.rateplans(),function(n){ko.utils.arrayForEach(n.roomBoards(),function(n){n.isSelected(n.boardType()==r);r==t?n.insteadOfBoard(n.boardType()):n.insteadOfBoard(t)})})})})})};IBE.Utils.claculateRateplanId=function(n,t){ko.utils.arrayForEach(n.hotelResults(),function(n){ko.utils.arrayForEach(n.requestedRooms(),function(n){ko.utils.arrayForEach(n.roomResults(),function(n){var i=[],u,r;ko.utils.arrayForEach(n.rateplans(),function(n){var r=ko.utils.arrayFirst(n.roomBoards(),function(n){return n.boardType()===t&&n.averageDailyRate()>0});r!=null&&i.push(r)});u=minProp(i,"price");r=ko.utils.arrayFilter(i,function(n){return n.price()===u});r.length>0&&n.ratePlanId(r[0].ratePlanId)})})})};IBE.Utils.parseDeepLinking=function(n,t){function u(){var u,n,f,e,r,o;if(i.rooms.length>0){for(t.requestedRooms.removeAll(),u=[],n=0;n<i.rooms.length;n++){for(f=new IBE.Models.RequestedRoom(n+1),e=[],r=0;r<i.rooms[n].length;r++)o=new IBE.Models.RequestedRoomGuestType(i.rooms[n][r]),e.push(o);f.guests=e;u.push(f)}t.requestedRooms(u)}}if(typeof n=="undefined"||n.length===0||typeof t=="undefined")return!1;var i={checkIn:"",checkOut:"",rooms:[],couponCode:"",board:t.hotel().info.defaultBoardType(),rateplan:0,lang:IBE.Config.defaultLang,currency:IBE.Config.currency,roomId:0,ref:new IBE.Models.Referrer},r=n.replace("?","").split("&");return r.length<1?!1:(ko.utils.arrayForEach(r,function(n){var u=n.split("="),a=moment(),e,f=new IBE.Models.Referrer,o=null,c,l,s,h,v;(u[0]==="ref"&&typeof u[1]!="undefined"&&u[1].toLowerCase()=="googlehotelads"&&(f.name="GoogleHotelAds",o=r.find(function(n){var t=n.split("=");return t[0].toLowerCase()==="campaignid"&&typeof t[1]!="undefined"}),o&&(f.campaign=o.split("=")[1]),Cache.write("ref",f,43200,"localstorage"),i.ref=f,t.referrer(f)),u[0]==="ref"&&typeof u[1]!="undefined"&&(i.ref===""||typeof i=="object"&&i.ref.name=="")&&(f.name=u[1],Cache.write("ref",f,43200,"localstorage"),i.ref=f,t.referrer(f)),(u[0]==="sig"||u[0]==="cig")&&typeof u[1]!="undefined"&&(f=new IBE.Models.Referrer,f.name="AdWords",o=r.find(function(n){var t=n.split("=");return t[0]==="_campaign"&&typeof t[1]!="undefined"}),o&&(f.campaign=o.split("=")[1]),Cache.write("ref",f,43200,"localstorage"),i.ref=f,t.referrer(f)),u[0]==="trv_reference"&&typeof u[1]!="undefined"&&(f=new IBE.Models.Referrer,f.name="Trivago",f.params={trv_reference:u[1]},Cache.write("ref",f,43200,"localstorage"),i.ref=f,t.referrer(f)),(u[0]==="ci"||u[0]==="checkIn")&&typeof u[1]!="undefined"&&(e=moment(u[1]),e.isValid()?(i.checkIn=moment(u[1]).format("YYYY-MM-DD"),e.diff(a,"days")<0?i.checkIn=moment(t.minCheckInDate()).format("YYYY-MM-DD"):t.checkIn(new Date(i.checkIn))):i=!1),(u[0]==="co"||u[0]==="checkOut")&&typeof u[1]!="undefined"&&(e=moment(u[1]),e.isValid()?(i.checkOut=moment(u[1]).format("YYYY-MM-DD"),e.diff(a,"days")<0&&(i.checkOut=moment(t.minCheckOutDate()).format("YYYY-MM-DD"))):i=!1),i!==!1)&&(u[0]==="couponCode"&&u[1]!=="couponCode"&&(i.couponCode=u[1],t.couponCode(i.couponCode)),u[0]==="board"&&u[1]!=="board"&&u[1]!=="undefined"&&(c=ko.utils.arrayFirst(t.boardTypes(),function(n){return n.boardType===u[1]||n.boardType.toLowerCase()===u[1]}),c!=null&&(i.board=u[1],t.boardType(c.boardType))),u[0]==="lang"&&typeof u[1]!="lang"&&u[1]!=""&&(l=u[1].toLowerCase().replace("_","-"),s=ko.utils.arrayFirst(t.languages(),function(n){return n.locale===l||n.culture.toLowerCase()===l}),s!=null&&(i.lang=s.culture,t.lang(s.culture))),u[0]==="cur"&&typeof u[1]!="cur"&&u[1]!=="undefined"&&(t.currencies().length>0?(h=ko.utils.arrayFirst(t.currencies().rates,function(n){return n.code==u[1]||n.code.toLowerCase()==u[1]}),h!=null&&(i.currency=h.code,t.currency(h.code))):(i.currency=u[1].toUpperCase(),t.currency(u[1].toUpperCase()))),u[0]==="rp"&&typeof u[1]!="undefined"&&(i.rateplan=u[1],t.rateplan=i.rateplan),u[0]==="roomId"&&typeof u[1]!="undefined"&&(i.roomId=parseInt(u[1])),u[0]==="r"&&typeof u[1]!="undefined"&&(u[1]=decodeURIComponent(u[1]),v=u[1].split("^"),ko.utils.arrayForEach(v,function(n){var e,r,f,o,u;if(n!=""){e=n.split("/");r=[];try{ko.utils.arrayForEach(t.hotel().info.guestTypes,function(n){r.push({ageCategory:n.ageCategory,fromAge:n.fromAge,toAge:n.toAge,pax:0})});r=t.hotel().info.guestTypes}catch(s){r=[{ageCategory:"Adult",fromAge:13,toAge:99,pax:0},{ageCategory:"Children",fromAge:3,toAge:12,pax:0},{ageCategory:"Infant",fromAge:0,toAge:2,pax:0}]}for(f=0;f<e.length;f++)if(f==0)r[0].pax(parseInt(e[f]));else for(o=parseInt(e[f]),u=0;u<r.length;u++)if(r[u].fromAge<=o&&r[u].toAge>=o){r[u].pax(r[u].pax()+1);break}i.rooms.push(ko.toJS(r))}})))}),i.checkIn==""||i.checkOut=="")?!1:(t.checkOut(moment(i.checkOut)),t.checkIn(moment(i.checkIn)),i!=!1&&(moment(i.checkIn).diff(moment(t.hotel().conditions.minCheckInDate),"days")<0&&(t.checkIn(t.hotel().conditions.minCheckInDate),i=!1),moment(i.checkOut).diff(i.checkIn,"days")>t.hotel().conditions.maxStay&&(i=!1)),typeof i.rooms!="undefined"&&i.rooms.length==0&&(i=!1),i!==!1&&u(),i)};IBE.Utils.parseOfferRules=function(n,t){var r,i;if(typeof n=="undefined"||typeof n.rules=="undefined"||n.rules.length=="undefined")return!1;r=moment();t.checkIn(r);i=n.rules.minStay;moment(t.checkIn()).diff(moment(n.rules.checkInMin),"days")<0&&t.checkIn(n.rules.checkInMin);moment(t.checkIn()).diff(moment(t.hotel().conditions.minCheckInDate),"days")<0&&t.checkIn(t.hotel().conditions.minCheckInDate);i==="undefined"&&t.checkOut(moment(t.checkIn).add(i,"days"))};IBE.Utils.destroyView=function(){var i;try{for(i=0;i<arguments.length;i++)typeof eval(arguments[i].toLowerCase())!="undefined"&&(ko.cleanNode($("#"+arguments[i])[0]),eval(arguments[i].toLowerCase()).clearMessage())}catch(e){}for(i=0;i<arguments.length;i++)$("#"+arguments[i]).html(""),$("#"+arguments[i]+" *").unbind()};IBE.Utils.prepareView=function(route){var i;try{for(i in routes)i!=route&&typeof routes[i]!="undefined"&&typeof eval(routes[i].toLowerCase())!="undefined"&&(ko.cleanNode($("#"+arguments[i])[0]),eval(routes[i].toLowerCase()).clearMessage())}catch(e){}for(i in routes)i!=route&&($("#"+routes[i]).html(""),$("#"+routes[i]+" *").unbind())};IBE.Utils.prepareMobileView=function(route){var i;try{for(i in routes)i!=route&&typeof routes[i]!="undefined"&&(ko.cleanNode($("#"+routes[i].id)[0]),eval(routes[i].id.toLowerCase()).clearMessage())}catch(e){}for(i in routes)i!=route&&($("#"+routes[i].id).html(""),$("#"+routes[i].id+" *").unbind())};IBE.Utils.logEvent=function(n){if(n.hotelId=n.hotelId||0,IBE.Config.debug===!0){IBE.Utils.consoleLog(n);return}typeof gtag=="function"&&gtag("send","exception",{exDescription:n.message,exFatal:!0,appName:"IBE [hotel: "+n.hotelId+"]",appVersion:"5.0.5"});var t=JSON.stringify(n);IBE.Utils.consoleLog(n);IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/errors/logevent/?apikey="+IBE.Config.apiKey,data:t,contentType:"application/json",dataType:"json"}).done(function(n){IBE.Utils.consoleLog("error logged: "+n)}).fail(function(n,t){IBE.Utils.consoleLog(t)})};IBE.Utils.dateIsoFormat=function(n){return moment.isMoment(n)?n.format("YYYY-MM-DD"):n.getFullYear()+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+("0"+n.getDate()).slice(-2)};IBE.Utils.queryString=function(n){var t="";for(var i in n)t+=i+"="+n[i]+"&";return t.substring(0,t.length-1)};IBE.Utils.dateDiff=function(n,t){return Math.floor((n.getTime()-t.getTime())/864e5)};IBE.Utils.getReservationSetting=function(n,t){return typeof n=="undefined"?"":typeof t=="undefined"||typeof n.reservationSettings=="undefined"?!1:n.reservationSettings.items.hasOwnProperty(t)?n.reservationSettings.items[t]:""};IBE.Utils.money=function(n,t){var u=ko.unwrap(t.currency()||"EUR"),f=t.calculateRate(t.currency(),n),r=ko.utils.arrayFirst(t.currencies().rates,function(n){return n.code==u}),i={precision:2,symbol:u,format:"%v %s"};if(typeof r!="undefined"&&f>0){i.symbol=r.symbol||r.code;switch(r.positivePattern){case"SymbolAlignLeft":i.pattern="%s%v";break;case"SymbolAlignRight":i.pattern="%v%s";break;case"SymbolAlignLeftWithSpace":i.pattern="%s %v";break;case"SymbolAlignRightWithSpace":i.pattern="%v %s";break;default:i.pattern="%s%v"}}return accounting.formatMoney(f,i)};IBE.Utils.getParam=function(n,t){typeof t=="undefined"&&(t=n,n=window.location.search);t=t.replace(/[\[]/,"\\[").replace(/[\]]/,"\\]");var r=new RegExp("[\\?&]"+t+"=([^&#]*)"),i=r.exec(n);return i==null?"":decodeURIComponent(i[1].replace(/\+/g," "))};IBE.Utils.stripTags=function(n){return n.replace(/<\/?[^>]+(>|$)/g,"")};IBE.Utils.gaTrack=function(n){IBE.Config.googleAnalyticsEnabled!==!1&&IBE.Config.googleAnalyticsId!==null&&(IBE.Utils.consoleLog("Google Analytics: "+ko.toJSON(n)),typeof gtag=="function"&&gtag("config",IBE.Config.googleAnalyticsId,{page_title:n.title,page_path:n.path}))};IBE.Utils.gaRemarketingTrack=function(n){if(IBE.Config.debug&&console.log("IBE: In debug mode remarketing tracking is disabled"),google_conversion_id=n||0,google_custom_params=window.google_tag_params,google_remarketing_only=!0,google_conversion_id==0){console.log("IBE: google_conversion_id is not valid");return}var t=document.write;document.write=function(n){$("body").append(n)};$.getScript("//www.googleadservices.com/pagead/conversion.js",function(){setTimeout(function(){document.write=t},100)})};IBE.Utils.authenticationHeader=function(n,t){if(n!==""&&t!==""&&typeof n!="undefined"&&typeof t!="undefined"){var i="Basic "+$.base64.encode(n+":"+t);return document.cookie="Authorization= "+i+";path=/",i}};IBE.Utils.authenticationCredentialsFromCookie=function(){var r=document.cookie.indexOf("Authorization="),n,t,i;return r!==-1&&(n=document.cookie.indexOf(";",r+1),n===-1&&(n=document.cookie.length),t=$.base64.decode(document.cookie.substring(0,n)),i=t.indexOf(":"),i>0)?{username:t.substring(0,i),password:t.substring(i+1)}:null};IBE.Utils.passwordStrength=function(n){var i=0,r,t,u,f,e;if(!n)return i;for(r={},t=0;t<n.length;t++)r[n[t]]=(r[n[t]]||0)+1,i+=5/r[n[t]];u={digits:/\d/.test(n),lower:/[a-z]/.test(n),upper:/[A-Z]/.test(n),nonWords:/\W/.test(n)};f=0;for(e in u)f+=u[e]===!0?1:0;return i+=(f-1)*10,parseInt(i)};IBE.Utils.haveAuthenticationCookie=function(){var n=document.cookie.indexOf("Authorization=");return n!==-1?!0:!1};IBE.Utils.authenticationCookie=function(n,t){var u="Authorization=",r=document.cookie.indexOf(u),i;return r!==-1?(i=document.cookie.indexOf(";",r+1),i===-1&&(i=document.cookie.length),unescape(document.cookie.substring(r+u.length,i))):IBE.Utils.authenticationHeader(n,t)};IBE.Utils.deleteAuthenticationCookie=function(){var n=document.cookie.indexOf("Authorization=");return n!==-1?(document.cookie="Authorization=; expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/",!0):!1};IBE.Utils.convertCountries=function(n){var i=Cache.read("Countries"),t;if(i!==!1&&(t=ko.utils.arrayFirst(i,function(t){return t.code===n}),t!=null))return t.name};IBE.Utils.getEnumerationKey=function(n,t,i){for(var r in n)if(n.hasOwnProperty(r)&&n[r]===t)return i?r.charAt(0).toLowerCase()+r.slice(1):r;return""};IBE.Utils.createFormAlphaBankRedirect=function(n,t){var o=n.redirectPaymentGatewayData,i=JSON.parse(o),u=i.PaymentRedirectUrl,s=(Math.round(n.advancePayment*100)/100).toFixed(2),f='<form id="shopform1" method="POST" action="'+i.PaymentUrl+'" accept-charset="UTF-8" ><input type="hidden" name = "mid" value = "'+i.MerchantId+'" /><input type="hidden" name="lang" value="'+t.lang().substr(0,2)+'" /><input type="hidden" name="deviceCategory" value="0"/><input type="hidden" name="orderid" value="'+n.id+'" /><input type="hidden" name="orderDesc" value="'+n.hotelName+'" /><input type="hidden" name="orderAmount" value="'+s+'" /><input type="hidden" name="currency" value="'+n.currencyCode+'" /><input type="hidden" name="payerEmail" value="'+n.customer.email+'" /><input type="hidden" name="payMethod" value="'+n.externalPaymentGatewayData+'"/><input type="hidden" name="confirmUrl" value="'+u+'" /><input type="hidden" name="cancelUrl" value="'+u+'" /><input type="hidden" name="digest" value="'+i.Digest+'" /><\/form >',e=$(f),r;$("body").append(e);r={message:n,severity:"info",hotelId:0};IBE.Utils.logEvent(r);r={message:f,severity:"info",hotelId:0};IBE.Utils.logEvent(r);$(e).submit()};IBE.Utils.generateGuid=function(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,function(n){var t=Math.random()*16|0,i=n=="x"?t:t&3|8;return i.toString(16)})};ko.validation.configure({registerExtenders:!0,messagesOnModified:!0,insertMessages:!0,parseInputAttributes:!0,messageTemplate:null});ko.validation.rules.creditCard={getValue:function(n){return typeof n=="function"?n():n},validator:function(n){var t=new RegExp("^(?:4[0-9]{12}(?:[0-9]{3})?|5[1-5][0-9]{14}|6(?:011|5[0-9][0-9])[0-9]{12}|3[47][0-9]{13}|3(?:0[0-5]|[68][0-9])[0-9]{11}|(?:2131|1800|35\\d{3})\\d{11})$");return t.test(n)},message:IBE.Utils.translate("validation.creditCard")};ko.validation.rules.checkbox={validator:function(n){return n},message:IBE.Utils.translate("validation.acceptTerms")};ko.validation.rules.phone={validator:function(n){if(typeof n!="undefined"){var t=n.match(/\d+/g);return t!==null&&t[0].length>0}},message:IBE.Utils.translate("validation.required")};ko.validation.registerExtenders();ko.utils.clone=function(n){return ko.mapping.fromJS(ko.toJS(n))};ko.utils.isBound=function(n){return!!ko.dataFor(document.getElementById(n))};ko.numericObservable=function(n){var t=ko.observable(n);return ko.dependentObservable({read:function(){return t()},write:function(n){var i=parseInt(n);t(isNaN(i)?n:i)}})};ko.assignObservable=function(n,t){return ko.isObservable(n)?n:ko.observable(n||t)};ko.assignObservableArray=function(n){return ko.isObservable(n)?n:ko.observableArray(n)};ko.observableArray.fn.filterByProperty=function(n,t){return ko.computed(function(){for(var r,u=this(),f=[],i=0;i<u.length;i++)r=u[i],ko.unwrap(r[n])===ko.unwrap(t)&&f.push(r);return f},this)};ko.extenders.format=function(n,t){return n.format=ko.computed(function(){return n()?moment(n()).format(t):""}),n};ko.observableArray.fn.sortByProperty=function(n){this.sort(function(t,i){var r=[],u;for(r[0]=0,r[1]=0,u=0;u<n.length;u++){var f=Math.pow(10,n.length-u),s=n[u][0],h=n[u][1],e=ko.unwrap(t[s]),o=ko.unwrap(i[s]);e===o?(r[0]+=f,r[1]+=f):h.toLowerCase()==="asc"?(r[0]+=e>o?0:f,r[1]+=e>o?f:0):(r[1]+=e<o?f:0,r[0]+=e<o?0:f)}return r[0]===r[1]?0:r[0]>r[1]?-1:r[0]<r[1]?1:void 0})};ko.dependentObservable.fn.trackReevaluations=function(){return this.reevaluationCount=ko.observable(0),this.subscribe(function(){this.reevaluationCount(this.reevaluationCount()+1)},this),this};ko.bindingHandlers.stopBindings={init:function(){return{controlsDescendantBindings:!0}}};ko.bindingHandlers.gaqPush={init:function(n,t){var i=t(),r=typeof i=="object"&&!(i instanceof Array),u=r?i.track:i,f=r?i.eventName:"click",e=function(){var n={};return n[f]=function(){IBE.Utils.consoleLog("GoogleAnalytics: "+u);gtag(u)},n}}};ko.bindingHandlers.gaTrack={init:function(n,t){if(IBE.Config.googleAnalyticsEnabled!==!1&&IBE.Config.googleAnalyticsId!==null){var i=t(),r=typeof i=="object"&&!(i instanceof Array);IBE.Utils.consoleLog("Google Analytics: "+ko.toJSON(i));typeof gtag=="function"&&gtag("config",IBE.Config.googleAnalyticsId,{page_title:i.title,page_path:i.path})}}};ko.bindingHandlers.backgroundImage={update:function(n,t,i){var u=i().backgroundImageOptions||{},f=ko.utils.unwrapObservable(t()),r="",e;f!==""&&(typeof u.width!="undefined"&&(r+="width="+ko.utils.unwrapObservable(u.width)),typeof u.height!="undefined"&&(r!==""&&(r+="&"),r+="height="+ko.utils.unwrapObservable(u.height)),typeof u.mode!="undefined"&&(r!==""&&(r+="&"),r+="mode="+ko.utils.unwrapObservable(u.mode)),e=f,r!==""&&(e=f+"?"+r),$(n).css({backgroundImage:"url("+e+")"}))}};ko.bindingHandlers.href={update:function(n,t){ko.bindingHandlers.attr.update(n,function(){return{href:t()}})}};ko.bindingHandlers.src={update:function(n,t){ko.bindingHandlers.attr.update(n,function(){return{src:t()}})}};pauseOnSelectEvent=!1;pauseMultiple=!1;ko.bindingHandlers.multiDatepicker={init:function(n,t,i,r){var f,u;n=$(n);f=i().datepickerOptions||{};displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");n.datepick({rangeSelect:!0,monthsToShow:[1,2],firstDay:1,changeMonth:!1,maxDate:"+1y",dateFormat:"dd/mm/yyyy",defaultDate:r.minCheckInDate(),todayText:"",onSelect:function(n){if(n.length!==0&&!pauseMultiple){var t=n[0],i=n[1];if(t-r.checkIn()!=0||i-r.checkOut()!=0){if(selectedDatepicker==="MultiCalendar"){if(t-i==0){selectedDatepicker="";return}pauseOnSelectEvent=!0;r.checkIn(moment(t).startOf("day"));r.checkOut(moment(i).startOf("day"));pauseOnSelectEvent=!1}ko.bindingHandlers.multiDatepicker.styleSelectedDates()}}},onChangeMonthYear:function(){ko.bindingHandlers.multiDatepicker.styleSelectedDates()},onDate:function(n){return isDateActive(r,new Date(n))?{}:{dateClass:"not-available",selectable:!1}}});u=ko.unwrap(i().lang);$.datepick.regionalOptions.hasOwnProperty(u)&&($.datepick.regionalOptions[u].prevText='<i class="fa fa-chevron-left" />',$.datepick.regionalOptions[u].nextText='<i class="fa fa-chevron-right" />',n.datepick("option",$.datepick.regionalOptions[u]),n.datepick("option",{lang:u}));ko.utils.registerEventHandler(n,"click",function(t){t.cancelBubble=!0;t.stopImmediatePropagation();selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")})},update:function(n,t,i){var r;n=$(n);var u=ko.utils.unwrapObservable(t()),f=u[0](),e=u[1]();pauseOnSelectEvent||n.datepick("setDate",f,e);r=ko.unwrap(i().lang);r&&localizeDatepicker(n,r)},styleSelectedDates:function(){window.setTimeout(function(){var n=$("#MultiCalendar .datepick"),t;n.find(".datepick-selected").eq(0).parent().addClass("first-selected");t=n.find(".datepick-selected").length;t>1&&n.find(".datepick-selected").eq(t-1).parent().addClass("last-selected")},20)}};ko.bindingHandlers.datepicker={init:function(n,t,i,r){var o,u,f,e;n=$(n);o=i().datepickerOptions||{};displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");u=ko.utils.unwrapObservable(r.hotel);f=IBE.Config.closeDatesClickable;n.datepick({firstDay:1,changeMonth:!1,yearRange:"c-0:c+2",monthsToShow:1,showTrigger:"#CalendarTrigger",todayText:"",clearText:"",closeText:"",defaultDate:r.minCheckInDate(),onSelect:function(n){if(typeof n!="undefined"){var i=t();i(moment(n[0]))}},onDate:function(n){var t,i={};try{t=n.getFullYear()+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+("0"+n.getDate()).slice(-2)}catch(r){return!0}if(!u.availability.hasOwnProperty(t))return!1;switch(u.availability[t]){case-1:i={dateClass:"not-available",selectable:f};break;case 0:return IBE.Config.displayResults[displayNotAvailable]!=0;default:return!0}return i}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")});e=ko.unwrap(i().lang)||IBE.Config.lang;ko.bindingHandlers.datepicker.changeLanguage(n,e,ko.unwrap(i().theme),ko.unwrap(i().theme))},update:function(n,t,i){n=$(n);ko.bindingHandlers.datepicker.changeLanguage(n,ko.unwrap(i().lang),ko.unwrap(i().theme));var r=ko.utils.unwrapObservable(t());if(typeof r=="undefined"){IBE.Utils.consoleLog("date undefined");return}String(r).indexOf("/Date(")===0&&(r=new Date(parseInt(r.replace(/\/Date\((.*?)\)\//gi,"$1"))));n.datepick("setDate",new Date(r))},changeLanguage:function(n,t,i){t&&localizeDatepicker(n,t,i)},displayNotAvailable:""};ko.bindingHandlers.multiPropertyDatepicker={init:function(n,t,i,r){var f,u;n=$(n);f=i().datepickerOptions||{};displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");n.datepick({firstDay:1,changeMonth:!1,yearRange:"c-0:c+2",monthsToShow:1,showTrigger:"#CalendarTrigger",todayText:"",clearText:"",closeText:"",defaultDate:r.minCheckInDate(),onSelect:function(n){if(typeof n!="undefined"){var i=t();i(moment(n[0]))}}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")});u=ko.unwrap(i().lang)||IBE.Config.lang;ko.bindingHandlers.multiPropertyDatepicker.changeLanguage(n,u,ko.unwrap(i().theme))},update:function(n,t,i){var u,r;if(n=$(n),u=ko.unwrap(i().lang)||IBE.Config.lang,ko.bindingHandlers.multiPropertyDatepicker.changeLanguage(n,u,ko.unwrap(i().theme)),r=ko.utils.unwrapObservable(t()),typeof r=="undefined"){IBE.Utils.consoleLog("date undefined");return}String(r).indexOf("/Date(")==0&&(r=new Date(parseInt(r.replace(/\/Date\((.*?)\)\//gi,"$1"))));n.datepick("setDate",new Date(r))},changeLanguage:function(n,t,i){t&&localizeDatepicker(n,t,i)},displayNotAvailable:""};ko.bindingHandlers.availabilityCalendar={update:function(n,t,i){function f(){n.find("tr td a, tr td span").off("click")}function f(){n.find("tr td a, tr td span").off("click")}var s,u;n=$(n);var c=i().datepickerOptions||{},r=i().availability,e=ko.unwrap(t())[0],o=ko.unwrap(t())[1],h=IBE.Config.closeDatesClickable;displayNotAvailable=i().displayNotAvailable;n.datepick({rangeSelect:!0,firstDay:1,changeMonth:!1,monthsToShow:2,maxDate:"+2y",todayClass:"",dateFormat:"YYYY-MM-DD",prevText:'<i class="fa fa-chevron-left" />',nextText:'<i class="fa fa-chevron-right" />',todayText:"",onDate:function(n){var t={},i=IBE.Utils.dateIsoFormat(n);if(r.hasOwnProperty(i))switch(r[i]){case 0:t=IBE.Config.displayResults[displayNotAvailable]===0?{dateClass:"not-available",selectable:!1}:{dateClass:"not-available",selectable:!0};break;case 1:t={dateClass:"last-room",selectable:!1,title:"Last Room",content:'<span class="last-room-content">'+moment(n).format("D")+"<\/span>"};break;case-1:t={dateClass:"not-available",selectable:h};break;case-100:t={dateClass:"not-available",selectable:!1};break;default:r[i]<0?t.dateClass="not-available":moment(i).isBetween(e.format("YYYY-MM-DD"),o.format("YYYY-MM-DD"))===!1&&(t.dateClass="available",t.title=r[i]+" rooms")}else t={dateClass:"not-available",selectable:!1};return t},onChangeMonthYear:function(){window.setTimeout(function(){f()},20)}});n.datepick("setDate",new Date(e.format("YYYY-MM-DD")),new Date(o.format("YYYY-MM-DD")));f();s=ko.unwrap(i().theme);u=ko.unwrap(i().lang);u&&localizeDatepicker(n,u,s);ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")})}};ko.bindingHandlers.datepickerWithRange={init:function(n,t,i,r){var u,f,e;n=$(n);u=i().datepickerOptions||{};f=IBE.Config.closeDatesClickable;displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");n.datepick({firstDay:1,changeMonth:!1,yearRange:"c-0:c+2",monthsToShow:u.monthsToShow||1,showTrigger:'<i class="material-icons icon-date">&#xE616;<\/i>',dateFormat:"yyyy-mm-dd",pickerClass:u.pickerClass||"",rangeSelect:!1,todayText:"",clearText:"",closeText:"",defaultDate:r.minCheckInDate(),onSelect:function(n){if(typeof n!="undefined"){var i=$("#CheckIn").datepick("getDate"),r=$("#CheckOut").datepick("getDate"),u=t();u(moment(n[0]));$("#datepickerOpened").datepick("setDate",i,r)}},onDate:function(n){var r,t={},u,e;try{r=n.getFullYear()+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+("0"+n.getDate()).slice(-2)}catch(o){return!0}if(!i().availability.hasOwnProperty(r))return!1;u=new Date($("#CheckIn").datepick("getDate"));e=new Date($("#CheckOut").datepick("getDate"));switch(i().availability[r]){case 0:t=IBE.Config.displayResults[displayNotAvailable]===0?{dateClass:"not-available",selectable:!0}:{dateClass:"not-available",selectable:!0};break;case-100:t={dateClass:"not-available",selectable:!0};break;case-1:t={dateClass:"not-available",selectable:f};break;default:return n>=u&&n<=e?n.toString()==u.toString()?{content:n.getUTCDate(),dateClass:"dateRangeFirst"}:n.toString()==e.toString()?{content:n.getUTCDate(),dateClass:"dateRangeLast"}:{content:n.getUTCDate(),dateClass:"dateRange"}:!0}return t}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")});e=ko.unwrap(i().lang)||IBE.Config.lang;ko.bindingHandlers.datepicker.changeLanguage(n,e,ko.unwrap(i().theme),ko.unwrap(i().theme))},update:function(n,t,i){n=$(n);ko.bindingHandlers.datepicker.changeLanguage(n,ko.unwrap(i().lang),ko.unwrap(i().theme));var r=ko.utils.unwrapObservable(t());if(typeof r=="undefined"){IBE.Utils.consoleLog("date undefined");return}String(r).indexOf("/Date(")===0&&(r=new Date(parseInt(r.replace(/\/Date\((.*?)\)\//gi,"$1"))));n.datepick("setDate",new Date(r))},changeLanguage:function(n,t,i){t&&localizeDatepicker(n,t,i)},displayNotAvailable:""};ko.bindingHandlers.datepickerWithRangeOpend={init:function(n,t,i,r){n=$(n);var u=i().datepickerOptions||{},f=IBE.Config.closeDatesClickable;displayNotAvailable=IBE.Utils.getReservationSetting(r,"displayNotAvailable");n.datepick({firstDay:1,startDate:"0d",minDate:new Date(i().minDate),changeMonth:!1,yearRange:"c-0:c+2",monthsToShow:u.monthsToShow||1,showTrigger:".icon-date",dateFormat:"yyyy-mm-dd",pickerClass:u.pickerClass||"",rangeSelect:u.rangeSelect||!1,defaultDate:new Date(2017,4,25),todayText:"",clearText:"",closeText:"",onSelect:function(n){if(typeof n!="undefined"&&moment(n[0]).diff(moment(n[1]),"days")!==0){var t=r.checkIn,i=r.checkOut;t(n[0]);i(n[1])}},onDate:function(n){var t={},u=IBE.Utils.dateIsoFormat(n);try{u=n.getFullYear()+"-"+("0"+(n.getMonth()+1)).slice(-2)+"-"+("0"+n.getDate()).slice(-2)}catch(c){return!0}if(!i().availability.hasOwnProperty(u))return!1;var s=r.checkIn,h=r.checkOut,e=moment(s()).startOf("day"),o=moment(h()).startOf("day");n=moment(n).startOf("day");switch(i().availability[u]){case 0:t=IBE.Config.displayResults[displayNotAvailable]===0?{dateClass:"not-available",selectable:!0}:{dateClass:"not-available",selectable:!0};break;case-100:t={dateClass:"not-available",selectable:!0};break;case-1:t={dateClass:"not-available",selectable:f};break;default:return n>=e&&n<=o?n.diff(e,"days")===0?{content:n.format("D"),dateClass:"dateRangeFirst"}:n.diff(o.utc(),"days")===0?{content:n.format("D"),dateClass:"dateRangeLast"}:{content:n.format("D"),dateClass:"dateRange"}:!0}return t}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")})},update:function(n,t,i){n=$(n);ko.bindingHandlers.datepicker.changeLanguage(n,ko.unwrap(i().lang),ko.unwrap(i().theme));var r=ko.utils.unwrapObservable(t());if(typeof r=="undefined"){IBE.Utils.consoleLog("date undefined");return}String(r).indexOf("/Date(")===0&&(r=new Date(parseInt(r.replace(/\/Date\((.*?)\)\//gi,"$1"))));n.datepick("setDate",new Date(r))},changeLanguage:function(n,t,i){t&&localizeDatepicker(n,t,i)}};ko.bindingHandlers.bindMinDate={update:function(n,t){n=$(n);var i=ko.utils.unwrapObservable(t());n.datepick("option","minDate",new Date(i))}};ko.bindingHandlers.roomSelectionTabs={total:0,getDisabled:function(n){for(var i=[],t=n+1;t<=ko.bindingHandlers.roomSelectionTabs.total-1;t++)i.push(t);return i},init:function(n,t,i){var u=$(n),r=i().tabOptions||{},f=r.active;ko.bindingHandlers.roomSelectionTabs.total=u.find(t()+" li").length;r.disabled=ko.bindingHandlers.roomSelectionTabs.getDisabled(f);u.tabs(r)},update:function(n,t,i,r){var u=$(n),e=ko.utils.unwrapObservable(i().tabOptions),f=r.activeTabIndex(),o=u.tabs("option","active");u.tabs({disabled:ko.bindingHandlers.roomSelectionTabs.getDisabled(f)});u.tabs("enable",f);u.tabs("option","active",f);r.activeRoomIndex(f+1)}};ko.bindingHandlers.stopBinding={init:function(){return{controlsDescendantBindings:!0}}};ko.bindingHandlers.translate={update:function(n,t,i,r,u){var f,o,e,s,h;try{if(f=ko.utils.unwrapObservable(t()),o=ko.unwrap(u.$root.lang())||"",typeof f=="object")for(attr in f)n.setAttribute(attr,IBE.Utils.findTranslation(f[attr]));else e=IBE.Utils.findTranslation(f),i().hasOwnProperty("formatData")&&(e=e.format(ko.unwrap(i().formatData[0]))),n.innerHTML=e;n.setAttribute("lang",o.substring(0,2));s=n.style.display;n.style.display="none";h=n.offsetHeight;n.style.display=s}catch(c){}}};ko.bindingHandlers.stripTags={update:function(n,t,i,r,u){var f=u.$root.lang();return ko.bindingHandlers.text.update(n,function(){return IBE.Utils.stripTags(ko.utils.unwrapObservable(t()))})}};ko.bindingHandlers.date={update:function(n,t,i){var u=i.get("dateFormat")||"YYYY-MM-DD",f=moment(ko.unwrap(t())),r;f.isValid()?n.innerHTML=moment(ko.unwrap(t())).format(u):(r=i().emptyDate,n.innerHTML=r?r:moment().format(u))}};ko.bindingHandlers.money={update:function(n,t,i,r,u){var e=r,c=!1,o,l,a,p,s;if(e.hasOwnProperty("currency")?c=!0:ko.utils.arrayForEach(u.$parents,function(n){c||n.hasOwnProperty("currency")&&n.hasOwnProperty("currencies")&&(c=!0,e=n)}),o=i.get("format")||IBE.Config.moneyFormat||"",l=!1,o!==""?l=!0:o="%v %s",!c||typeof ko.unwrap(e.currencies).rates=="undefined"){a=ko.unwrap(r.currency)||"";n.innerHTML=accounting.formatMoney(ko.unwrap(t()),{precision:2,symbol:a,format:o});return}var v=ko.unwrap(i.get("currency")||e.currency()||"EUR"),y=e.calculateRate(e.currency(),ko.unwrap(t())),h=ko.utils.arrayFirst(e.currencies().rates,function(n){return n.code==v}),f={precision:2,symbol:v,thousand:",",decimal:".",format:o};if(typeof h!="undefined"&&y>0)if(IBE.Config.showCurrencyCode)if(l)f.format=o;else switch(h.positivePattern){case"SymbolAlignLeft":case"SymbolAlignLeftWithSpace":f.format="%s %v";break;case"SymbolAlignRight":case"SymbolAlignRightWithSpace":f.format="%v %s";break;default:f.format="%s %v"}else if(f.symbol=h.symbol||h.code,l)f.format=o;else switch(h.positivePattern){case"SymbolAlignLeft":f.format="%s%v";break;case"SymbolAlignRight":f.format="%v%s";break;case"SymbolAlignLeftWithSpace":f.format="%s %v";break;case"SymbolAlignRightWithSpace":f.format="%v %s";break;default:f.format="%s%v"}if(typeof e.lang!="undefined"){p=1.1;f.decimal=Globalize.format(p,"n2",e.lang()).substring(1,2);switch(f.decimal){case".":f.thousand=",";break;case",":f.thousand=".";break;default:f.thousand=","}}if(s=accounting.formatMoney(y,f),s.toString().length>14){n.innerHTML="<span class='smaller'>"+s+"<\/span>";return}if(s.toString().length>10){n.innerHTML="<span class='small'>"+s+"<\/span>";return}n.innerHTML=s}};ko.bindingHandlers.numeric={init:function(n,t){$(n).numeric({negative:!1});ko.utils.registerEventHandler(n,"change",function(){var i=t();i(parseInt($(n).val()))})},update:function(n,t){ko.bindingHandlers.value.update(n,t)}};ko.bindingHandlers.dailyRateBreakDown={init:function(n,t,i,r){if(r.rateBreakDown()){var o=ko.unwrap(t()),e=o.weeks(),f="",u="";u+='<tr><th class="week"><\/th>';ko.utils.arrayForEach(e[0],function(n){u+="<th>"+n.date.format("ddd")+"<\/th>"});u+="<\/tr>";f+="<thead>"+u+"<\/thead>";u="";ko.utils.arrayForEach(e,function(n){u+="<tr>";ko.utils.arrayForEach(n,function(n){u+="<td>"+n.date.format("DD")+"<\/td>"});u+="<\/tr>"});f+="<tbody>"+u+"<\/tbody>";$(n).append(f)}}};ko.bindingHandlers.preventBubble={init:function(n,t){var i=ko.utils.unwrapObservable(t());ko.utils.registerEventHandler(n,i,function(n){n.cancelBubble=!0;n.stopPropagation&&n.stopPropagation()})}};ko.bindingHandlers.map={init:function(n,t){var i=ko.utils.unwrapObservable(t()),u=new google.maps.LatLng(ko.utils.unwrapObservable(i.latitude),ko.utils.unwrapObservable(i.longitude)),r,f;i.map=new google.maps.Map(n,{center:u,zoom:i.zoom,scrollwheel:!1,mapTypeId:google.maps.MapTypeId.ROADMAP});r=new google.maps.Marker({map:i.map,position:u,title:i.marker().title});f=new google.maps.InfoWindow({content:"<p>"+i.marker().title+"<br /><small>"+i.marker().street+"<\/small><\/p>"});google.maps.event.addListener(r,"click",function(){f.open(i.map,r)})}};ko.bindingHandlers.directionsMap={init:function(n,t){function e(n){var t={origin:n.coords?new google.maps.LatLng(n.lat,n.lng):n.address,destination:u,travelMode:google.maps.DirectionsTravelMode.DRIVING},e={center:u,zoom:i.zoom,mapTypeId:google.maps.MapTypeId.ROADMAP},o=new google.maps.Map(document.getElementById("map"),e);r.setMap(o);r.setPanel(document.getElementById("map-directions"));f.route(t,function(n,t){t===google.maps.DirectionsStatus.OK&&r.setDirections(n)})}var i=ko.utils.unwrapObservable(t()),u=new google.maps.LatLng(ko.utils.unwrapObservable(i.latitude),ko.utils.unwrapObservable(i.longitude)),f=new google.maps.DirectionsService,r=new google.maps.DirectionsRenderer;navigator.geolocation&&navigator.geolocation.getCurrentPosition(function(n){e({coords:!0,lat:n.coords.latitude,lng:n.coords.longitude})})}};ko.bindingHandlers.reservationStatus={update:function(n,t){var i=ko.utils.unwrapObservable(t()),r="";switch(IBE.Config.reservationStatus[i]){case 1:r+=" success "+i.toLowerCase();break;case 2:case 6:r+=" error "+i.toLowerCase();break;case 4:r+=" notice "+i.toLowerCase()}$(n).addClass(r)}};ko.bindingHandlers.popover={update:function(n,t){var i=ko.utils.unwrapObservable(t());i=$.extend(!0,{},{placement:"bottom",toggle:"popover",trigger:"focus",html:!0,exclusive:!1},i);i.title=function(){return t().title};i.content=function(){return t().content};$(n).popover(i)}};ko.bindingHandlers.toJSON={update:function(n,t){return ko.bindingHandlers.text.update(n,function(){return ko.toJSON(t(),null,2)})}};ko.bindingHandlers.logger={update:function(n,t,i){var r=ko.utils.domData.get(n,"_ko_logger")||0,u=ko.toJS(t()||i());ko.utils.domData.set(n,"_ko_logger",++r);window.console&&console.log&&console.log(r,n,u)}};ko.bindingHandlers.cycle={update:function(n,t){var i=$(n),f=ko.unwrap(t()),r={},u=i.data();for(key in u)key.indexOf("cycle")!=-1&&(r[key]=u[key]);i.cycle(r);ko.bindingHandlers.cycle.hover(n);ko.utils.domNodeDisposal.addDisposeCallback(n,function(){i.cycle("destroy")})},hover:function(n){$(n).hover(function(){var n=$(this);$(document).keydown(function(t){if(t.keyCode==37){n.cycle("prev");return}if(t.keyCode==39){n.cycle("next");return}})},function(){$(document).unbind("keydown")})}};ko.bindingHandlers.modal={init:function(n,t){var r=$(n),u=ko.utils.extend({},ko.unwrap(t())),i=$(u.target);i.on("show.bs.modal",function(){$("html").addClass("modal-open");$(".modal-backdrop").height($(document).height())});i.on("shown.bs.modal",function(){$("html").addClass("modal-open");$(".modal-backdrop").height($(document).height())});i.on("hidden.bs.modal",function(){i.data("modal",null)});r.on("click",function(){i.modal({show:!0})});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){i.data("modal",null)})},update:function(){}};ko.bindingHandlers.readMore={init:function(n,t,i){var r=i().readmoreOptions;$(n).html(t());window.setTimeout(function(){$(n).readmore({speed:75,moreLink:'<div class="readmore-js-toggle">'+IBE.Utils.translate("readMore")+"<\/div>",lessLink:'<div class="readmore-js-toggle">'+IBE.Utils.translate("close")+"<\/div>"})},50);ko.utils.domNodeDisposal.addDisposeCallback(n,function(){$(n).readmore("destroy")})}};ko.bindingHandlers.slick={init:function(n){var t=$(n);window.setTimeout(function(){t.slick({infinite:!1,dots:!1,arrows:!0,speed:277,swipe:!0,slidesToShow:1,draggable:!0,fade:!0,cssEase:"linear",accessibility:!0})},50)}};ko.bindingHandlers.select2={init:function(n,t,i){var r={},f=i.get("data"),u;typeof f!="undefined"&&(r.data=f);r.minimumInputLength=i.get("minimumInputLength")||0;var h=i.get("showSearch")?1:-1,e=i.get("width"),o=i.get("selectTemplate"),s=i.get("optionTemplateFunction"),c=$(n).siblings("#option").html();if(r.minimumResultsForSearch=h,s&&(r.formatResult=function(n){return s.call(n,c)}),o&&(r.formatSelection=o),e&&(r.width=e),u=$(n),u.select2(r),i.get("textNval")===!0)u.on("change",function(n){var i=t();i(n.added)});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){$(n).select2("destroy")})},update:function(n,t,i){var r=i.get("data");typeof r!="undefined"&&$(n).select2({data:r})}};ko.bindingHandlers.hidden=function(){function n(n,t){var i=ko.unwrap(t());$(n).css("visibility",i?"hidden":"visible")}return{init:n,update:n}};ko.components.register("passwordstrength-widget",{viewModel:function(n){this.password=ko.observable(n&&n.value||"");self.validatePasswordStrength=ko.computed(function(){return IBE.Utils.passwordStrength(n.value)})},template:'<div class="password-strength" data-bind="visible: password"><span data-bind="value:validatePasswordStrength()"><\/span>            <div class="background" data-bind="css: { success: validatePasswordStrength() > 60, error : validatePasswordStrength() <= 60}, style: { width: validatePasswordStrength()+ \'%\'}">            <\/div>        <\/div>'});ko.bindingHandlers.singleDatepicker={init:function(n,t,i){var r,u;n=$(n);r=i().datepickerOptions||{};n.datepick({firstDay:1,changeMonth:!0,yearRange:"-100:+0",defaultDate:null,monthsToShow:r.monthsToShow||1,showTrigger:'<i class="material-icons icon-date">&#xE616;<\/i>',dateFormat:"yyyy-mm-dd",pickerClass:r.pickerClass||"",rangeSelect:!1,todayText:"",clearText:"",closeText:"",onSelect:function(n){if(typeof n!="undefined"){var i=t();i(moment(n[0]))}}});ko.utils.registerEventHandler(n,"mousedown",function(){selectedDatepicker=n.attr("id")});ko.utils.domNodeDisposal.addDisposeCallback(n,function(){n.datepick("destroy")});u=ko.unwrap(i().lang)||IBE.Config.lang;ko.bindingHandlers.datepicker.changeLanguage(n,u)},changeLanguage:function(n,t){t&&(t.length>2&&t!=="en-US"&&(t=t.substring(0,2)),n.datepick("option").lang!==t&&$.datepick.regionalOptions.hasOwnProperty(t)&&($.datepick.regionalOptions[t].prevText='<i class="material-icons">&#xE314;<\/i>',$.datepick.regionalOptions[t].nextText='<i class="material-icons">&#xE315;<\/i>',n.datepick("option",$.datepick.regionalOptions[t]),n.datepick("option",{lang:t})))},displayNotAvailable:""};ko.bindingHandlers.timePicker={init:function(n,t,i){var r=i().timepickerOptions||{};$(n).timepicker(r);ko.utils.registerEventHandler(n,"change",function(){var i=t();i($(n).timepicker("getTime"))})},update:function(n,t){var i=ko.utils.unwrapObservable(t()),r=$(n).timepicker("getTime");i-r!=0&&$(n).timepicker("setTime",i)}};ko.bindingHandlers.modifyRoomSelectionTabs={total:0,getDisabled:function(n){for(var i=[],t=n+1;t<=ko.bindingHandlers.roomSelectionTabs.total-1;t++)i.push(t);return i},init:function(n,t,i){var u=$(n),r=i().tabOptions||{},f=r.active;ko.bindingHandlers.roomSelectionTabs.total=u.find(t()+" li").length;r.disabled=ko.bindingHandlers.roomSelectionTabs.getDisabled(f);u.tabs(r)},update:function(n,t,i){var r=$(n),e=ko.utils.unwrapObservable(i().tabOptions),f=e.viewmodel,u=f.activeTabIndex(),o=r.tabs("option","active");r.tabs({disabled:ko.bindingHandlers.roomSelectionTabs.getDisabled(u)});r.tabs("enable",u);r.tabs("option","active",u);f.activeRoomIndex(u+1)}};ko.bindingHandlers.addFiledsAuthorizeNet=function(){$("#CustomerCardHolder").after('<input type="hidden" name="dataValue" id="dataValue" />');$("#CustomerCardHolder").after('<input type="hidden" name="dataDescriptor" id="dataDescriptor" />')};ko.bindingHandlers.mountStripe={init:function(n,t){typeof t().externalPaymentGateway()!="undefined"&&t().externalPaymentGateway().initStripe()}};IBE.Models.Language=function(n){var t=this;n=n||{};t.country=n.country;t.culture=n.culture||"";t.description=n.description;t.locale=n.locale};IBE.Models.Hotel=function(n){var t=this;t.info=n.info||{};t.availability=n.availability||{};t.settings=n.settings||{};t.offers=n.offers||[];t.conditions=n.conditions||{};t.defaults=n.defaults||{};t.memberships=[];typeof n.memberships!="undefined"&&n.memberships!=null&&ko.utils.arrayForEach(n.memberships,function(n){t.memberships.push(new IBE.Models.Membership(n))});t.hasMembership=t.memberships.length>0;t.visibleOffers=ko.computed(function(){return ko.utils.arrayFilter(t.offers,function(n){return n.showOffer})});IBE.Data.Settings=IBE.Utils.populateSettings(t.settings);t.customerRegistrationMode=parseInt(t.settings.customerRegistrationMode)};IBE.Models.RequestedRoom=function(n){var t=this;t.guests=ko.observableArray([]);t.roomResults=ko.observableArray([]);t.roomIndex=ko.observable(n||1);t.rank=0;t.isBestValue=ko.computed({read:function(){var n={},i=[],r=1e15;return ko.utils.arrayForEach(t.roomResults(),function(n){n.minPrice()>0&&i.push({id:n.roomId(),minPrice:n.minPrice()})}),ko.utils.arrayForEach(i,function(t){t.minPrice<=r&&(n=t,r=t.minPrice)}),n},deferEvaluation:!0});t.preferredBoard=ko.observable("");t.orderedRoomsPrices=function(){var n=[];return ko.utils.arrayForEach(t.roomResults(),function(t){t.minPrice()>0&&n.push({availability:t.availability,roomId:t.roomId(),price:t.minPrice(),averageDailyRate:t.averageDailyRate(),name:t.info().name})}),n.sort(function(n,t){return n.price-t.price}),n};t.isVisible=ko.computed({read:function(){var n=!1;return ko.utils.arrayForEach(t.roomResults(),function(t){if(t.isVisible()){n=!0;return}}),n},deferEvaluation:!0});t.sortRoomResults=function(n){for(var r=[],i=0;i<n.length;i++)r.push(n[i].split("."));t.roomResults.sortByProperty(r)};t.canAddGuest=function(n){var i=0;return ko.utils.arrayForEach(t.guests,function(n){if(n.ageCategory()!==IBE.Config.guestType.Infant){var t=ko.utils.unwrapObservable(n.pax);isNaN(parseInt(t))||(i+=parseInt(t))}}),i<n}};IBE.Models.GuestType=function(n){var t=this;n=n||{};t.ageCategory=n.ageCategory||"";t.fromAge=n.fromAge||"";t.toAge=n.toAge||"";t.max=n.max||"";t.min=n.min||"";t.pax=ko.observable(n.pax||0)};IBE.Models.Photo=function(n){var t=this;t.id=n.id;t.type=n.imageType;t.description=n.description;t.title=n.title;t.rank=n.rank;t.url=ko.computed({read:function(){var t=ko.utils.arrayFilter(n.transformations,function(n){return n.key.toLocaleLowerCase().indexOf("original")>-1});return t.length===1?t[0].url:""},deferEvaluation:!0});t.valid=ko.computed({read:function(){var t=ko.utils.arrayFilter(n.transformations,function(n){return n.key.toLocaleLowerCase().indexOf("original")>0});return t.length===1},deferEvaluation:!0})};IBE.Models.Offer=function(n,t){var i=this,r;i.id=n.id;i.hotelId=n.hotelId;i.name=n.name;i.abstract=n.abstract;i.description=n.description;i.rules=n.rules;i.photos=IBE.Utils.populatePhotos(n.photos);i.showOffer=n.showOffer||!1;i.minStay=1;i.cancellationPolicy=n.cancellationRules;i.paymentRules=n.paymentRules;i.havePhoto=ko.computed(function(){return i.photos.length>0});i.info=ko.computed({read:function(){var n=[],r;if(typeof t=="undefined"||typeof t.offers=="undefined")if(IBE.Data.HotelInfo[i.hotelId])n=IBE.Data.HotelInfo[i.hotelId].offers;else return{};else n=t.offers();return r=ko.utils.arrayFirst(n,function(n){return i.offerId===n.id}),r||{}},deferEvaluation:!0});r=[];n.membershipLevels&&n.membershipLevels.length>0&&(r=n.membershipLevels);i.membershipLevels=ko.observableArray(r)};IBE.Models.ReservationSettings=function(n){var t=this;t.items=n||{}};IBE.Models.RequestedRoomGuestType=function(n){var t=this;n=n||{};t.ages=ko.observableArray(n.ages);t.ageCategory=ko.observable(n.ageCategory);n.fromAge===""&&(n.fromAge=0);n.min===""&&(n.min=0);t.fromAge=ko.observable(n.fromAge);t.toAge=ko.observable(n.toAge);t.pax=ko.observable(ko.unwrap(n.pax));t.minValue=ko.observable(n.min);t.maxValue=ko.observable(n.max);t.label=ko.computed(function(){return t.ageCategory()===IBE.Config.guestType.Adult?"":t.fromAge()+"-"+t.toAge()});t.options=ko.computed(function(){for(var i=[],n=t.minValue();n<=t.maxValue();n++)i.push(n);return i});t.increase=function(){t.pax()!=t.maxValue()&&t.pax(t.pax()+1)};t.decrease=function(){t.pax()!=t.minValue()&&t.pax(t.pax()-1)}};IBE.Models.HotelInfo=function(n){var t=this;n=n||{};t.hotelId=n.id||n.hotelId||0;t.name=n.name;t.hotelType=n.hotelType;t.email=n.email;n.website&&n.website.indexOf("http")===-1&&(n.website="http://"+n.website);t.website=n.website;t.abstract=n.abstract;t.cancellationPolicy=n.cancellationPolicy;t.paymentPolicy=n.paymentPolicy;t.stars=n.stars;t.address=new IBE.Models.HotelAddress(n.address);t.logo=n.logo;t.termsConditions=n.termsConditions;typeof n.acceptedCards!="undefined"&&(t.acceptedCards=n.acceptedCards==="All"&&IBEConfig.allCreditCards?IBEConfig.allCreditCards.split(","):n.acceptedCards.split(", "));t.photos=IBE.Utils.populatePhotos(n.photos);t.guestTypes=IBE.Utils.populateGuestTypes(n.guestTypes);t.boardTypes=IBE.Utils.populateBoardTypes(n.boardTypes);t.defaultBoardType=ko.computed({read:function(){return ko.utils.arrayFirst(t.boardTypes,function(n){return n.isDefault}).boardType},deferEvaluation:!0});t.closedDates=[];typeof n.closedDates!="undefined"&&ko.utils.arrayForEach(n.closedDates,function(n){t.closedDates.push({from:new Date(n.closedFrom),to:new Date(n.closedTo)})})};IBE.Models.Terms=function(n){var t=this;t.id=n.id||-1;t.terms=n.terms||"";t.privacy=n.privacyPolicy||"";t.value=ko.observable(!1).extend({checkbox:{message:IBE.Utils.translate("acceptTerms")}})};IBE.Models.Consents=function(n){var t=this;t.id=n.id||-1;t.title=n.title||"";t.value=ko.observable(!1)};IBE.Models.Membership=function(n){var t=this;t.name=n.name||"";t.id=n.id||0};IBE.Models.HotelAddress=function(n){var t=this;t.latitude=n.latitude;t.longitude=n.longitude;t.street=n.street;t.region=n.region;t.city=n.city;t.country=n.country;t.countryCode="";t.phone=n.phone;t.timezone=n.timezone;t.email=n.email};IBE.Models.BoardType=function(n){var t=this;t.name=n.name===""?IBE.Utils.translate(n.boardType):n.name;t.boardType=n.boardType;t.description=n.description;t.isDefault=n.isDefault};IBE.Models.OfferInfo=function(n){var t=this;t.id=n.id;t.name=n.name;t.hotelId=n.hotelId;t.abstract=n.abstract;t.description=n.description;t.showOffer=n.showOffer;t.paymentRules=n.paymentRules||{};t.photos=n.photos||[]};IBE.Models.RatePlanInfo=function(n,t){var i=this,r;if(i.id=n.id,i.defaultName=n.name,i.description=n.description,i.paymentPocily=n.paymentPolicy,i.hideStandardRate=n.hideStandardRate,i.paymentRules=n.paymentRules||{},i.cancellationRules=ko.utils.arrayMap(n.cancellationRules,function(n){return new IBE.Models.CancellationRule(n)}),r=-1,i.paymentRules=ko.utils.arrayMap(n.paymentRules,function(n){return r+=1,n.Index=r,new IBE.Models.PaymentRule(n,t)}),i.paymentRules.length===0){if(!IBE.Data.HotelInfo[n.hotelId])return;i.paymentRules.push({text:IBE.Data.HotelInfo[n.hotelId].info.paymentPolicy})}i.isFreeCancellation=ko.computed({read:function(){var n=!0;return ko.utils.arrayForEach(i.cancellationRules,function(t){(t.penalty>0||t.minimumPenalty>0)&&(t.daysBeforeCheckIn>=0||t.daysBeforeCheckIn===-1)&&(n=!1)}),n},deferEvaluation:!0});i.name=ko.computed({write:function(n){i.defaultName(n)},read:function(){return i.id===0?IBE.Utils.translate("standardRate"):i.defaultName},deferEvaluation:!0});i.photos=n.photos};IBE.Models.RoomInfo=function(n){var t=this;t.id=n.id;t.name=n.name;t.description=n.description;t.alwaysOnRequest=n.alwaysOnRequest;t.availability=n.availability;t.minGuests=n.minGuests;t.maxGuests=n.maxGuests;t.bedrooms=n.bedrooms;t.photos=IBE.Utils.populatePhotos(n.photos);t.facilities=ko.utils.arrayMap(n.facilities,function(n){return new IBE.Models.Facility(n)});t.attributes=ko.utils.arrayMap(n.attributes,function(n){return new IBE.Models.Attribute(n)})};IBE.Models.Request=function(){var n=this;n.hotelResults=ko.observableArray([]);n.checkIn=ko.observable();n.checkOut=ko.observable();n.couponCode=ko.observable("");n.preferredBoard=ko.observable();n.ratePlanId=ko.observable(0);n.nights=ko.pureComputed({read:function(){return moment(n.checkOut()).diff(moment(n.checkIn()),"days")},deferEvaluation:!0});n.preferredBoard.subscribe(function(t){IBE.Utils.calculateRoomBoard(n);IBE.Utils.claculateRateplanId(n,t)},n)};IBE.Models.AvailabilityRestriction=function(n){var t=this;t.id=n.id;t.rules=[];t.text=[];n.rules=sameRule(n.rules);ko.utils.arrayForEach(n.rules,function(n){switch(n.ruleType){case"ReservationDaysMoreThanX":t.text.push(IBE.Utils.translate("restriction.ReservationDaysMoreThanX").format(n.value));reservationDaysMoreThanX="The maximum stay is {0} nights.";break;case"DayMinStayThrough":t.text.push(IBE.Utils.translate("restriction.RoomNightsLessThanX").format(n.value));roomNightsLessThanX="A minimum stay of {0} nights is required.";break;case"ReservationDaysLessThanX":t.text.push(IBE.Utils.translate("restriction.ReservationDaysLessThanX").format(n.value+1));reservationDaysLessThanX="A minimum stay of {0} nights is required.";break;case"RoomNightsMoreThanX":t.text.push(IBE.Utils.translate("restriction.RoomNightsMoreThanX").format(n.value));roomNightsMoreThanX="The maximum stay is {0} nights.";break;case"RoomNightsLessThanX":t.text.push(IBE.Utils.translate("restriction.RoomNightsLessThanX").format(n.value+1));roomNightsLessThanX="A minimum stay of {0} nights is required.";break;case"RoomsMoreThanX":t.text.push(IBE.Utils.translate("restriction.RoomsMoreThanX").format(n.value));roomsMoreThanX="The maximum number of rooms allowed is {0} .";break;case"RoomsLessThanX":t.text.push(IBE.Utils.translate("restriction.RoomsLessThanX").format(n.value+1));roomsLessThanX="The minimum number of rooms is {0} .";break;case"RequestedLessThanXDaysBeforeCheckIn":t.text.push(IBE.Utils.translate("restriction.RequestedLessThanX").format(n.value+1));requestedLessThanX="You can only make a reservation at least {0} days prior check-in date.";break;case"DayClosedDeparture":t.text.push(IBE.Utils.translate("restriction.DayClosedDeparture"));break;case"DayClosedArrival":t.text.push(IBE.Utils.translate("restriction.DayClosedArrival"));break;case"DayClosed":t.text.push(IBE.Utils.translate("restriction.DayClosed"))}})};IBE.Models.RoomResult=function(n){var t=this,r=[];t.rateplans=ko.computed({write:function(n){r(n)},read:function(){return r.sort(function(n,t){return n.price()>t.price()})},deferEvaluation:!0});t.roomId=ko.observable(0);t.hotelId=ko.observable(0);t.roomIndex=ko.observable(1);t.availability=0;t.availabilityStatus="";t.availabilityRestrictions=[];t.viewAvailability=ko.observable(!1);t.isFiltered=ko.observable(!1);t.availableRooms=0;t.supportedBoards=0;t.alternativeBoard=ko.computed({read:function(){return t.boardType()===""?!1:t.boardType()!==n.request().preferredBoard()},deferEvaluation:!0});t.availabilitySorting=ko.computed({read:function(){switch(t.availability){case-3:return.3;default:return t.availability}},deferEvaluation:!0});t.minPrice=ko.computed({read:function(){var n=1e13;return(ko.utils.arrayForEach(t.rateplans(),function(t){t.price()<=n&&(n=t.price())}),n===1e13)?null:n},deferEvaluation:!0});t.info=ko.computed({read:function(){var i=ko.utils.arrayFilter(n.rooms(),function(n){return t.roomId()===n.id});if(i.length===1)return i[0]},deferEvaluation:!0});t.defaultPriceAction=IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayWithoutPrices")];t.isVisible=ko.computed({read:function(){var i=!0,r=0,u=0;if(t.rateplans().length===0&&IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayWithoutPrices")]!==0)return!0;if(ko.utils.arrayForEach(t.rateplans(),function(t){ko.utils.arrayForEach(t.roomBoards(),function(t){u+=t.bookingAction();t.insteadOfBoard()===n.request().preferredBoard()&&t.price()>0&&(r+=t.price())})}),u===0)return!1;if(r<=0)switch(t.defaultPriceAction){case 0:i=!1;break;case 1:i=!0}return i},deferEvaluation:!0},this);t.ratePlanId=ko.observable(0);t.setRatePlanId=function(n){t.ratePlanId(n.ratePlanId())};t.averageDailyRate=ko.computed({read:function(){var n=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()===n.ratePlanId()});return n.length===1?n[0].averageDailyRate():0},deferEvaluation:!0},this);t.showPrices=ko.computed({read:function(){return!(t.availabilityStatus.toLowerCase()==="noprices")},deferEvaluation:!0});t.price=ko.computed({read:function(){var n=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()===n.ratePlanId()});return n.length===1?n[0].price():0},deferEvaluation:!0},this);t.bookingAction=ko.computed({read:function(){var n=0;return $.each(t.rateplans(),function(t,i){if(i.bookingAction()!==0){n=i.bookingAction();return}}),n},deferEvaluation:!0},this);t.hidePrices=ko.computed({read:function(){return IBE.Utils.getReservationSetting(n,"displayNotAvailable")==="HideRoomRates"&&t.bookingAction()!==3},deferEvaluation:!0});t.boardType=ko.computed({read:function(){var n=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()===n.ratePlanId()});return n.length===1?n[0].boardType():""},deferEvaluation:!0},this);t.boardName=ko.computed({read:function(){var i=ko.utils.arrayFirst(n.hotelInfo().boardTypes,function(n){return t.boardType()===n.boardType});return i!=null?i.name:t.boardType()},deferEvaluation:!0});t.bestRatePlanId=ko.computed({read:function(){function u(n,t){var i=n.map(function(n){return ko.unwrap(n[t])});return Math.min.apply(Math,i)}var f=t.rateplans(),n=[],r,i;return(ko.utils.arrayForEach(f,function(i){var r=ko.utils.arrayFirst(i.roomBoards(),function(n){return n.boardType()===t.boardType()&&n.averageDailyRate()>0});r!=null&&n.push(r)}),r=u(n,"price"),i=ko.utils.arrayFilter(n,function(n){return n.price()===r}),i.length>0)?i[0].ratePlanId:0},deferEvaluation:!0},this);t.upsales=ko.computed({read:function(){var r=!1;return ko.utils.arrayForEach(n.roomsPrices(),function(u,f){var e,o,s;if(u.roomId===t.roomId()){if(f===n.roomsPrices().length-1)return;if(e=n.roomsPrices()[f].averageDailyRate-t.averageDailyRate(),r=n.roomsPrices()[f],r.diffAmount=n.roomsPrices()[f].averageDailyRate-t.averageDailyRate(),e<=0)for(o=f+1,s=n.roomsPrices().length,i=o;i<s;i++)if(n.roomsPrices()[i].averageDailyRate-t.averageDailyRate()>0){r=n.roomsPrices()[i];r.diffAmount=n.roomsPrices()[i].averageDailyRate-t.averageDailyRate();return}}}),r},deferEvaluation:!0});t.downsale=ko.computed({read:function(){var r=!1,u=!1,i=[];return ko.utils.arrayForEach(n.request().hotelResults()[0].requestedRooms()[0].roomResults(),function(n){u||(n.roomId()!==t.roomId()&&n.minPrice()<t.minPrice()&&n.availability==IBE.Config.roomAvailability.Available?i.push(n):u=!0)}),i.length>0&&(r=i[i.length-1]),r},deferEvaluation:!0});t.discountPercent=ko.computed({read:function(){var n=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()===n.ratePlanId()});return n.length===1?n[0].discountPercent():0},deferEvaluation:!0},this)};IBE.Models.RatePlan=function(n){var t=this;t.roomBoards=ko.observableArray([]);t.ratePlanId=ko.observable(0);t.info=ko.computed({read:function(){var i=ko.utils.arrayFilter(n.rateplans(),function(n){return t.ratePlanId()===n.id});return i.length===1?i[0]:{}},deferEvaluation:!0});t.defaultPriceAction=IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayWithoutPrices")];t.isVisible=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(n){return n.price()>0}),r,u;if(i==null)switch(t.defaultPriceAction){case 0:return!1;case 1:return!0}return i.ratePlanId==0&&(r=ko.utils.arrayFirst(n.request().hotelResults()[0].requestedRooms()[0].roomResults(),function(n){return n.roomId()==i.roomId}),u=!1,r!=null&&ko.utils.arrayForEach(r.rateplans(),function(n){if(n.info().hideStandardRate){u=!0;return}}),u)?!1:!0},deferEvaluation:!0});t.showPrices=ko.computed({read:function(){var t=IBE.Utils.getReservationSetting(n,"hideRatePlanPrice");return t=t==="True"?!0:!1,!t}});t.averageDailyRate=ko.computed({read:function(){var i=0;return ko.utils.arrayForEach(t.roomBoards(),function(t){if(t.insteadOfBoard()===n.request().preferredBoard()){i=t.price()/n.request().nights();return}}),i},deferEvaluation:!0},this);t.price=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(t){return t.insteadOfBoard()===n.request().preferredBoard()&&t.price()>0});return i!=null?i.price():0},deferEvaluation:!0},this);t.priceWithoutDiscount=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(t){return t.insteadOfBoard()===n.request().preferredBoard()&&t.priceWithoutDiscount()>0});return i!=null?i.priceWithoutDiscount():0},deferEvaluation:!0},this);t.bookingAction=ko.computed({read:function(){var i=0;return $.each(t.roomBoards(),function(t,r){if(r.insteadOfBoard()===n.request().preferredBoard()){i=r.bookingAction();return}}),i},deferEvaluation:!0},this);t.boardType=ko.computed({read:function(){var i="";return $.each(t.roomBoards(),function(t,r){if(r.insteadOfBoard()===n.request().preferredBoard()&&r.price()>0){i=r.boardType();return}}),i},deferEvaluation:!0},this);t.rateBreakDown=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(t){return t.insteadOfBoard()===n.request().preferredBoard()},this);return i?i.rateBreakDown():{}},deferEvaluation:!0});t.advancePayment=ko.computed({read:function(){var r=ko.utils.arrayFirst(n.rateplans(),function(n){return t.ratePlanId()===n.id});if(!r)return!0;var f=moment(),e=moment(n.bookingProcess().checkIn()),u=f.diff(e,"days",!0),i=0;return(ko.utils.arrayForEach(ko.utils.unwrapObservable(r.paymentRules),function(n){n.daysUntilCheckInMax>=u&&n.daysUntilCheckInMin<u&&(i=n.charge,n.minimumCharge>i&&(i=n.minimumCharge))}),i===0)?!1:!0},deferEvaluation:!0});t.discountPercent=ko.computed({read:function(){var i=ko.utils.arrayFirst(t.roomBoards(),function(t){return t.insteadOfBoard()===n.request().preferredBoard()&&t.discountPercent()>0});return i!=null?i.discountPercent():0},deferEvaluation:!0},this)};IBE.Models.RoomBoard=function(n){var t=this;t.rateBreakDown=ko.observable(new IBE.Models.RateBreakDown);t.roomIndex=n.activeRoomIndex();t.roomId=0;t.ratePlanId=ko.observable(0);t.boardType=ko.observable("");t.insteadOfBoard=ko.observable("");t.price=ko.observable(0);t.priceWithoutDiscount=ko.observable(0);t.isSelected=ko.observable(!1);t.discountPercent=ko.computed({read:function(){return 100*(t.priceWithoutDiscount()-t.price())/t.priceWithoutDiscount()},deferEvaluation:!0});t.discount=ko.computed({read:function(){return t.priceWithoutDiscount()-t.price()},deferEvaluation:!0});t.showPrices=ko.computed({write:function(n){t.priceWithoutDiscount(n)},read:function(){return t.price()<0?!1:!0},deferEvaluation:!0});t.notAvailableAction=ko.observable(IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayNotAvailable")]);t.bookingAction=ko.computed({read:function(){var i=this,r,u;return i.roomIndex!==n.activeRoomIndex()?IBE.Config.displayResults.Hide:i.price()<=0?IBE.Utils.getReservationSetting(n,"displayWithoutPrices")=="Show"?t.notAvailableAction():IBE.Config.displayResults.Hide:(r=[],ko.utils.arrayForEach(n.request().hotelResults(),function(n){r=n.alternatives;return}),u=!1,ko.utils.arrayForEach(r,function(r){var e=0,f;if(n.selectedRooms().length>0)for(f=0;f<t.roomIndex-1;f++)typeof n.selectedRooms()[f]!="undefined"&&r[f]===ko.utils.unwrapObservable(n.selectedRooms()[f].roomId)&&e++;if(r[t.roomIndex-1]===i.roomId&&e++,e===t.roomIndex){u=!0;return}}),u?IBE.Config.displayResults.Online:t.notAvailableAction())},deferEvaluation:!0},this);t.info=ko.computed({read:function(){return ko.utils.arrayFirst(n.boards(),function(n){return t.boardType()===n.boardType})},deferEvaluation:!0});t._offerIds=[];t.offers=ko.computed({read:function(){return t.ratePlanId===0?ko.utils.arrayFilter(n.offers(),function(n){return t._offerIds.indexOf(n.id)!==-1}):[]},write:function(n){t.ratePlanId===0&&(t._offerIds=ko.unwrap(n))},deferEvaluation:!0});t.averageDailyRate=ko.computed({read:function(){return t.price()/n.request().nights()},deferEvaluation:!0},this)};IBE.Models.Daily=function(n){var t=this;t.date=ko.observable(n.date);t.status=ko.observable(n.status||"");t.price=ko.observable(n.price);t.priceWithoutDiscount=ko.observable(n.priceWithoutDiscount)};IBE.Models.RateBreakDown=function(n){var t=this;t.daily=ko.observableArray([]);n&&t.daily(ko.utils.arrayMap(n,function(n){return new IBE.Models.Daily(n)}));t.weeks=ko.computed({read:function(){return IBE.Utils.weekdayRates(t.daily())},deferEvaluation:!0})};IBE.Models.SelectedRoom=function(){var n=this;n.roomIndex=ko.observable(1);n.roomId=ko.observable(0);n.ratePlanId=ko.observable(0);n.boardType=ko.observable("");n.board=ko.observable();n.availability=ko.observable("");n.guestTypes=ko.observableArray([]);n.roomInfo=ko.observable();n.cost=ko.observable();n.costWithoutDiscount=ko.observable();n.ratePlan=ko.computed({read:function(){return ko.utils.arrayFirst(IBE.Data.RatePlanInfo,function(t){return t.id===n.ratePlanId()})},deferEvaluation:!0});n.discountPercent=ko.computed({read:function(){return 100*(n.costWithoutDiscount()-n.cost())/n.costWithoutDiscount()},deferEvaluation:!0});n.discount=ko.computed({read:function(){return n.costWithoutDiscount()-n.cost()},deferEvaluation:!0})};IBE.Models.BookingRoom=function(){var n=this;n.roomIndex=1;n.roomId=1;n.ratePlanId=0;n.boardType="";n.guestTypes=ko.observableArray([])};IBE.Models.Transformation=function(n){var t=this;t.width=n.width;t.height=n.height;t.url=n.url;t.key=n.key};IBE.Models.Facility=function(n){var t=this;t.id=n.id;t.name=n.name;t.url=n.url};IBE.Models.Attribute=function(n){var t=this;t.code=n.code;t.value=n.value};IBE.Models.Supplement=function(n){var t=this;n=n||{};t.supplementId=ko.observable(n.id||0);t.category=n.category||"";t.name=n.name||"";t.description=n.description||"";t.units=ko.observable(0);t.isUnique=ko.observable(n.isUnique||0);t.isMandatory=n.isMandatory;t.isVisible=n.isVisible;t.ratePlanId=ko.observable(0);t.setRatePlanId=function(n){t.ratePlanId(n)};t.rateplans=ko.observableArray(ko.utils.arrayMap(n.ratePlans,function(n){return new IBE.Models.SupplementRatePlan(n,t.isMandatory)}));t.prices=ko.computed({read:function(){var i=ko.utils.arrayFilter(t.rateplans(),function(n){return t.ratePlanId()==n.ratePlanId}),n;return i.length==1?i[0].prices():(n=ko.utils.arrayFilter(t.rateplans(),function(n){return n.ratePlanId==0}),n.length==1?n[0].prices():[])},deferEvaluation:!0},this);t.isFree=ko.computed({read:function(){var n=0,i=0;return ko.utils.arrayForEach(t.prices(),function(t){n+=t.price;i+=t.quantity()}),n===0&&i>0},deferEvaluation:!0}).extend({notify:"always"});t.photos=ko.utils.arrayMap(n.photos,function(n){return new IBE.Models.Photo(n)});t.visible=ko.computed({read:function(){return t.prices().length>0&&t.isVisible},deferEvaluation:!0});t.pricingType=ko.observable(n.pricingType);t.timePricingType=ko.observable(n.timePricingType);t.timePricingUnit=ko.observable(n.timePricingUnit);t.roomIndex=ko.computed({read:function(){return IBE.Config.supplementPricingType[t.pricingType()]==IBE.Config.supplementPricingType.PerReservation?0:1},deferEvaluation:!0}).extend({notify:"always"});t.totalPrice=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.prices(),function(t){n+=t.price*t.quantity()}),n},deferEvaluation:!0}).extend({notify:"always"});t.totalPriceWithoutDiscount=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.prices(),function(t){n+=t.priceWithoutDiscount*t.quantity()}),n},deferEvaluation:!0}).extend({notify:"always"});t.quantity=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.prices(),function(t){n+=t.quantity()}),n},deferEvaluation:!0});t.discountAppliedRooms=ko.utils.arrayMap(n.discountAppliedRooms,function(n){return new IBE.Models.SupplementDiscountAppliedRooms(n)})};IBE.Models.SupplementRatePlan=function(n,t){var i=this;n=n||{};i.ratePlanId=n.ratePlanId||0;i.prices=ko.observableArray(ko.utils.arrayMap(n.prices,function(n){return new IBE.Models.SupplementPrice(n,t)}))};IBE.Models.SupplementPrice=function(n,t){var i=this;n=n||{};i.isMandatory=t;i.isVisible=n.isVisible||!0;i.quantity=ko.observable(n.quantity||0);i.price=n.price||0;i.priceWithoutDiscount=n.priceWithoutDiscount||0;i.guestType=n.guestType!=null?new IBE.Models.GuestType(n.guestType):{};i.minQuantity=ko.observable(0);(ko.unwrap(i.isMandatory)||i.price==0)&&(i.minQuantity(n.quantity||1),i.quantity(i.minQuantity()));i.maxQuantity=10;i.isSelected=ko.computed({read:function(){return i.quantity()>0},write:function(n){n||i.isMandatory?i.quantity(1):i.quantity(0)}}).extend({notify:"always"});i.addSupplement=function(){i.quantity()>=i.maxQuantity||i.quantity(parseInt(i.quantity())+1)};i.removeSupplement=function(){i.quantity()>i.minQuantity()&&i.quantity(parseInt(i.quantity())-1)}};IBE.Models.SupplementDiscountAppliedRooms=function(n){var t=this;n=n||{};t.ratePlanId=n.rateplanId||0;t.roomIds=n.roomIds};IBE.Models.BookingSupplement=function(){var n=this;n.supplementId=0;n.guestType={};n.quantity=0;n.roomIndex=0;n.categoryName="";n.ratePlanId=0;n.info={}};IBE.Models.Currencies=function(){var n=this;n.base="";n.rates=[]};IBE.Models.CurrencyRate=function(n){var t=this;t.code=n.code;t.rate=n.rate;t.name=n.name;t.positivePattern=n.positivePattern;t.symbol=n.symbol||n.code};IBE.Models.HotelResult=function(){var n=this;n.requestedRooms=ko.observableArray([]);n.hotelId=ko.observable(parseInt(IBE.Config.hotelId));n.availability=ko.observable();n.selectedSupplements=ko.observableArray([]);n.supplements={}};IBE.Models.Country=function(n){var t=this;t.code=ko.observable(n.code);t.name=ko.observable(n.name)};IBE.Models.CreditCard=function(){function i(n){var t={visa:/^4/,mastercard:/^5[1-5][0-9]/,amex:/^3[47][0-9]/,diners:/^3(?:0[0-5]|[68][0-9])[0-9]/,discover:/^6(?:011|5[0-9]{2})[0-9]/,jcb:/^(?:2131|1800|35\d{3})\d/};return t.visa.test(n)?"visa":t.mastercard.test(n)?"mastercard":t.amex.test(n)?"amex":t.diners.test(n)?"dinersclub":t.discover.test(n)?"discover":t.jcb.test(n)?"jcb":void 0}var n=this,t;n.acceptedCards=ko.observableArray();t=function(){$.when(IBE.Utils.loadHotelInfo()).then(function(t){t.info.acceptedCards==="All"?n.acceptedCards(IBEConfig.allCreditCards.split(",")):n.acceptedCards(t.info.acceptedCards.replace(/,/g,"").split(" "))})};t();n.id=ko.observable(0);n.cardHolder=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredCardHolder")}});n.cardNumber=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredCardNumber")},creditCard:{message:IBE.Utils.translate("validation.invalidCreditCard")}});n.cardExpirationYear=ko.observable("");n.cardExpirationMonth=ko.observable("");n.monthOptions=ko.computed(function(){for(var t=[],n=1;n<=12;n++)t.push(("0"+n).slice(-2));return t});n.yearOptions=ko.computed(function(){for(var r=new Date,t=r.getFullYear(),i=[],n=t;n<=t+15;n++)i.push(n);return i});n.cardVerification=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredCardVerification")},number:!0});n.cardType=ko.observable("");n.getCardType=ko.computed({write:function(){n.cardType(i(n.cardNumber()))},read:function(){return n.cardType(i(n.cardNumber())),n.cardType()},deferEvaluation:!0})};IBE.Models.Company=function(){var n=this;n.name=ko.observable("");n.vatNumber=ko.observable("");n.industry=ko.observable("");n.address=ko.observable("");n.zipCode=ko.observable("");n.phone=ko.observable("")};IBE.Models.Customer=function(n){var t=this,i,r,u;if(n=n||{},t.customerMandatoryFields=ko.observable(),t.customerMandatoryFields.subscribe(function(n){jQuery.isEmptyObject(n)||(n=JSON.parse(n),t.mandatoryAddress(n.MandatoryAddress),t.mandatoryZip(n.MandatoryZip),t.mandatoryPhone(n.MandatoryPhone),t.mandatoryTitle(n.MandatoryTitle),t.mandatoryPhone(n.MandatoryTelephone),t.mandatoryCity(n.MandatoryCity))}),t.mandatoryAddress=ko.observable(),t.mandatoryZip=ko.observable(),t.mandatoryPhone=ko.observable(),t.mandatoryTitle=ko.observable(),t.mandatoryCity=ko.observable(),t.consents=ko.observableArray([]),t.titleOptions=[{key:"Mr",text:IBE.Utils.translate("title-mr")},{key:"Mrs",text:IBE.Utils.translate("title-mrs")},{key:"Miss",text:IBE.Utils.translate("title-miss")},{key:"Ms",text:IBE.Utils.translate("title-ms")},{key:"Dr",text:IBE.Utils.translate("title-dr")}],t.title=ko.observable(n.title),t.firstName=ko.observable(n.firstName).extend({required:{message:IBE.Utils.translate("requiredFirstName")}}),t.lastName=ko.observable(n.lastName).extend({required:{message:IBE.Utils.translate("requiredLastName")}}),t.fullName=ko.computed(function(){return t.firstName()+" "+t.lastName()}),t.email=ko.observable(n.email).extend({required:{message:IBE.Utils.translate("requiredEmail")},email:!0}),t.country=ko.observable(n.country).extend({required:{message:IBE.Utils.translate("requiredCountry")}}),t.region=ko.observable(n.region),t.city=ko.observable(n.city).extend({required:{message:IBE.Utils.translate("requiredCity"),onlyIf:function(){return t.mandatoryCity()===!0}}}),t.address=ko.observable(n.address).extend({required:{message:IBE.Utils.translate("requiredAddress"),onlyIf:function(){return t.mandatoryAddress()===!0}}}),t.zip=ko.observable(n.zip).extend({required:{message:IBE.Utils.translate("requiredZip"),onlyIf:function(){return t.mandatoryZip()===!0}}}),t.fax=ko.observable(n.fax),t.mobile=ko.observable(n.mobilePhone),t.birthdate=ko.observable(n.birthdate),t.phone=ko.observable(n.telephones).extend({required:{message:IBE.Utils.translate("requiredTelephone"),onlyIf:function(){return t.mandatoryPhone()===!0}}}),t.acceptNewsletter=ko.observable(n.acceptNewsletter||!1),t.id=ko.observable(n.customerId||0),t.resetHash=n.resetHash||"",t.reservations=ko.observableArray([]),n.reservations){for(r=[],i=0;i<n.reservations.length;i++)r.push(new IBE.Models.Reservation(n.reservations[i]));t.reservations(r)}if(t.offers=ko.observableArray([]),n.offers){for(u=[],i=0;i<n.offers.length;i++)u.push(new IBE.Models.Offer(n.offers[i]));t.offers(u)}t._data=n;t.toJSON=function(){var n={};return n.customerId=t.id(),n.firstName=t.firstName(),n.lastName=t.lastName(),n.title=t.title(),n.email=t.email(),n.country=t.country(),n.region=t.region(),n.city=t.city(),n.address=t.address(),n.zip=t.zip(),n.fax=t.fax(),n.mobilePhone=t.mobile(),n.telephones=t.phone(),n.birthdate=t.birthdate(),n.acceptNewsletter=t.acceptNewsletter(),n.consents=t.consents(),ko.toJSON(n)}};IBE.Models.Reservation=function(n){var t=this,i,r,u;ko.utils.extend(t,new IBE.ViewModels.Taxes(t));typeof n=="undefined"&&(n={});t.id=n.id||0;t.code=n.code||"";t.orderId=n.orderId||"";t.currencyCode=n.currencyCode||"";t.status=ko.observable(n.status||"");t.hotelId=n.hotelId||0;t.hotelName=n.hotelName||"";t.checkIn=n.checkIn||"";t.checkOut=n.checkOut||"";t.couponCode=n.couponCode||"";t.created=n.created||"";t.cancelled=n.cancellationDate||"";t.lastModified=n.modified||"";t.notes=ko.observable(n.notes||"");t.arrivalNotes=ko.observable(n.arrivalNotes||"");t.totalCost=ko.observable(n.totalCost||"");t.totalCostWithoutDiscount=ko.observable(n.totalCostWithoutDiscount||"");t.advancePayment=ko.observable(n.advancePayment||"");t.reservationTerms=n.reservationTerms||"";t.reservationType=n.reservationType||"";t.sourceName=n.sourceName||"";t.sourceType=n.sourceType||"";t.webCheckIn=ko.observable(n.webCheckIn||!1);t.webCheckInDate=ko.observable(moment(n.webCheckInDate)||null);t.webCheckInActive=ko.observable(n.webCheckInActive||!1);t.payments=ko.observable(n.payments||[]);t.cancellationNotes=ko.observable("");t.pmsOwner=n.pmsOnwer||!1;t.pmsCode=n.pmsCode||"";t.headerText=ko.computed({read:function(){switch(t.status()){case"ConfirmedReservation":return IBE.Utils.translate("reservationSuccessful");case"NewRequest":return IBE.Utils.translate("requestSuccessful");default:return""}},deferEvaluation:!0});t.availableActions=ko.observableArray([]);typeof n.availableActions!="undefined"&&ko.utils.arrayForEach(n.availableActions,function(n){switch(n){case"ConfirmedReservation":case"CancelledReservation":case"CancelledRequest":t.availableActions().push(n)}});t.rooms=ko.utils.arrayMap(n.rooms,function(n){return new IBE.Models.ReservationRoom(n)})||[];t.supplements=ko.utils.arrayMap(n.supplements,function(n){return new IBE.Models.ReservationSupplement(n)})||[];t.cancellationRules=ko.utils.arrayMap(n.cancellationRules,function(n){return new IBE.Models.CancellationRule(n)})||[];t.customer=new IBE.Models.Customer(n.customer);t.cancellationCost=ko.computed(function(){var i=moment(),n=ko.utils.arrayFirst(t.cancellationRules,function(n){var t=i.diff(n.cancelBefore,"days",!0);return t>0});return n!=null?n.cancelAmount:0});t.guests=ko.observableArray([]);n.guests=n.guests||[];ko.utils.arrayForEach(n.guests,function(n){t.guests.push(new IBE.Models.ReservationGuest(n))});r=0;n.guests.length===0&&(u=t.rooms.sort(function(n,t){return n.roomIndex>t.roomIndex?1:-1}),ko.utils.arrayForEach(u,function(u,f){var e=0;for(f!==0||n.webCheckIn||(n.customer.index=r++,n.customer.roomIndex=u.roomIndex,t.guests.push(new IBE.Models.ReservationGuest(n.customer)),e=1),i=e;i<u.adults;i++)u.index=r++,t.guests.push(new IBE.Models.ReservationGuest(u));for(i=0;i<u.children;i++)u.index=r++,t.guests.push(new IBE.Models.ReservationGuest(u));for(i=0;i<u.infants;i++)u.index=r++,t.guests.push(new IBE.Models.ReservationGuest(u))}));t.canUpdateReservation=function(){return t.status()!=="ConfirmedReservation"?!1:t.sourceName!=="Direct"?!1:moment(t.checkIn).endOf("day").diff(moment().endOf("day"),"days")<=0?!1:!0};t.canModifyReservation=function(){return t.status()!=="ConfirmedReservation"?!1:t.sourceName!=="Direct"?!1:moment(t.checkIn).endOf("day").diff(moment().endOf("day"),"days")<=0?!1:t.availableActions().length?!0:!1};t.refresh=function(n){t.id=n.id||0;t.code=n.code||"";t.orderId=n.orderId||"";t.currencyCode=n.currencyCode||"";t.status(n.status);t.hotelId=n.hotelId||0;t.hotelName=n.hotelName||"";t.checkIn=n.checkIn||"";t.checkOut=n.checkOut||"";t.couponCode=n.couponCode||"";t.created=n.created||"";t.cancelled=n.cancellationDate||"";t.lastModified=n.modified||"";t.notes(n.notes);t.arrivalNotes(n.arrivalNotes);t.totalCost(n.totalCost);t.totalCostWithoutDiscount(n.totalCostWithoutDiscount);t.advancePayment(n.advancePayment);t.sourceName=n.sourceName||"";t.sourceType=n.sourceType||"";t.availableActions(n.availableActions)}};IBE.Models.ReservationGuest=function(n){var t=this;n=n||{};t.index=ko.observable(n.index);t.customerId=n.customerId||null;t.providerId=n.providerId||null;t.roomIndex=ko.observable(n.roomIndex);t.guestType=n.guestType;t.firstName=ko.observable(n.firstName);t.lastName=ko.observable(n.lastName);t.birthday=ko.observable(n.birthday);t.telephone=ko.observable(n.telephone).extend({required:{message:IBE.Utils.translate("requiredTelephone")}});t.address=ko.observable(n.address);t.citizenshipCountry=ko.observable(n.citizenshipCountry);t.email=ko.observable(n.email);t.idNumber=ko.observable(n.idNumber);t.documentNumber=ko.observable(n.documentNumber);t.documentType=ko.observable(n.documentType);t.title=ko.observable(n.title);t.gender=ko.observable(n.gender);t.occupation=ko.observable(n.occupation)};IBE.Models.ReservationRoom=function(n){var t=this;t.id=n.id||n.roomId||0;t.roomIndex=n.roomIndex;t.adults=n.adults;t.children=n.children;t.infants=n.infants;t.childrenAges=[];n.roomGuests&&ko.utils.arrayForEach(n.roomGuests,function(n){if(n.ageCategory===IBE.Config.guestType.Children)for(var i=0;i<n.ages.length;i++)t.childrenAges.push(n.ages[i])});t.name=n.name;t.board={name:n.boardName,type:n.boardType,price:n.boardCost,priceBeforeDiscount:n.boardCostBeforeDiscount};t.ratePlanId=n.ratePlanId;t.ratePlanName=n.ratePlanName;t.totalCost=n.totalCost;t.totalCostBeforeDiscount=n.totalCostBeforeDiscount;t.roomCost=n.roomCost;t.roomCostBeforeDiscount=n.roomCostBeforeDiscount;t.payments=ko.utils.arrayMap(n.payments,function(n){return new IBE.Models.Payment(n)});t.roomPhoto=n.roomPhoto||"https://app.bookwize.com/admin/PHOTOS/no-image-466-275.png"};IBE.Models.Payment=function(n){var t=this;t.amount=n.amount;t.datePaid=n.datePaid;t.dateToPay=n.dateToPay;t.id=n.id;t.paymentType=n.paymentType;t.status=n.status;t.transactionId=n.transactionId};IBE.Models.CancellationRule=function(n){var t=this;n=n||{};t.daysBeforeCheckIn=n.daysBeforeCheckIn||0;t.minimumPenalty=n.minimumPenalty||0;t.minimumPenaltyType=n.minimumPenaltyType||"";t.penalty=n.penalty||0;t.penaltyType=n.penaltyType||"";t.text=n.text};IBE.Models.PaymentRule=function(n,t){var i=this;n=n||{};i.index=n.index||0;i.charge=n.charge||0;i.chargeType=n.chargeType||"";i.daysUntilCheckInMax=n.daysUntilCheckInMax||0;i.daysUntilCheckInMin=n.daysUntilCheckInMin||0;i.minimumCharge=n.minimumCharge||0;i.minimumChargeType=n.minimumChargeType||"";i.ruleType=n.ruleType||"";i.text=ko.computed(function(){var n="",f="",r="",u;switch(i.chargeType){case"Percentage":n="%";break;case"FixedPrice":n="";break;case"RoomNight":i.charge>t&&(i.charge=t);n=i.charge>1?IBE.Utils.translate("roomNights"):IBE.Utils.translate("roomNight")}switch(i.minimumChargeType){case"Percentage":f="%";break;case"FixedPrice":f="";break;case"RoomNight":i.minimumCharge>t&&(i.minimumCharge=t);f=i.minimumCharge>1?IBE.Utils.translate("roomNights"):IBE.Utils.translate("roomNight")}if(u="",(i.minimumChargeType!=i.chargeType||i.minimumCharge>i.charge)&&i.minimumCharge>0&&(u="("+i.minimumCharge+" "+f+" "+IBE.Utils.translate("minimum")+") "),i.charge==0)r=IBE.Utils.translate("noAdvancePayment");else if(i.charge==100&&i.chargeType==0)r=IBE.Utils.translate("fullPrepaymentRequired");else switch(i.ruleType){case"OnRequest":r=IBE.Utils.translate("advancePaymentRequiredReservationPlacement").format(i.charge,n,u);break;case"PriorToArrival":r=i.index===0?IBE.Utils.translate("advancePaymentRequiredDaysBeforeArrivalSingle").format(i.charge,n,u,i.daysUntilCheckInMin):IBE.Utils.translate("advancePaymentRequiredDaysBeforeArrival").format(i.charge,n,u,i.daysUntilCheckInMin);break;case"FromRequestUntilCheckIn":r=IBE.Utils.translate("advancePaymentRequiredDaysAfterRequest").format(i.charge,n,u,i.daysUntilCheckInMin);break;case"OnCheckOut":r=IBE.Utils.translate("advancePaymentRequiredDaysAfterRequest").format(i.charge,n,u,i.daysUntilCheckInMin)}return r})};IBE.Models.ReservationSupplement=function(n){var t=this;n=n||{};t.supplementId=ko.observable(n.id||0);t.category=n.category||"";t.name=n.name||"";t.description=n.description||"";t.quantity=ko.observable(n.quantity||0);t.isUnique=ko.observable(n.isUnique||!1);t.pricingType=ko.observable(n.pricingType||"");t.timePricingType=ko.observable(n.timePricingType||"");t.timePricingUnit=ko.observable(n.timePricingUnit||"");t.roomIndex=ko.observable(n.roomIndex||0);t.unitCost=ko.observable(n.unitCost||0);t.unitCostBeforeDiscount=ko.observable(n.unitCostBeforeDiscount||0);t.totalPrice=ko.computed(function(){return t.quantity()*t.unitCost()});t.totalPriceBeforeDiscount=ko.computed(function(){return t.quantity()&t.unitCostBeforeDiscount()});t.photos=IBE.Utils.populatePhotos(n.photos)};IBE.Models.RoomGuest=function(){var n=this;ko.utils.extend(n,IBE.Models.RequestedRoomGuestType);n.ages=ko.observableArray([])};IBE.Models.GoogleMap=function(n){var t=this;t.zoom=n.address.zoom||10;t.latitude=ko.observable(n.address.latitude);t.longitude=ko.observable(n.address.longitude);t.marker=ko.observable({title:n.name,street:n.address.street})};IBE.Models.Message=function(n){var t=this;n=n||{};t.id=ko.observable(n.id||0);t.severity=ko.observable(n.severity||"");t.text=ko.observable(n.text||"")};IBE.Models.Contact=function(){var n=this;n.firstName=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.lastName=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.email=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.subject=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.text=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}})};IBE.ViewModels.Message=function(){var n=this;n._msg=ko.observable(new IBE.Models.Message);n.message=ko.computed({write:function(t){n._msg(new IBE.Models.Message(t))},read:function(){return n._msg()},deferEvaluation:!0});n.clearMessage=function(){n.message({id:0,severity:"",text:""})};n.hasMessage=function(){return n.message().text()!==""}};IBE.Models.Hop=function(n){var t=this;n=n||{};t.checkIn=ko.observable(n.checkIn||"");t.checkOut=ko.observable(n.checkOut||"");t.couponCode=ko.observable(n.couponCode||"");t.minCheckInDate=ko.observable(n.minCheckInDate||"");t.guests=n.guests||[];t.destination=n.destination||null;t.current=ko.observable(n.current||!1)};IBE.Models.Referrer=function(n){var t=this;n=n||{};t.name=n.name||"";t.campaign=n.campaign;t.params=n.params||{}},function(n){n.datepick.regionalOptions.da={monthNames:["Januar","Februar","Marts","April","Maj","Juni","Juli","August","September","Oktober","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec"],dayNames:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"],dayNamesShort:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],dayNamesMin:["Sø","Ma","Ti","On","To","Fr","Lø"],dateFormat:"dd-mm-yyyy",firstDay:0,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Forrige",prevStatus:"Vis forrige måned",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Næste&#x3e;",nextStatus:"Vis næste måned",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Idag",currentStatus:"Vis aktuel måned",todayText:"Idag",todayStatus:"Vis aktuel måned",clearText:"Nulstil",clearStatus:"Nulstil den aktuelle dato",closeText:"Luk",closeStatus:"Luk uden ændringer",yearStatus:"Vis et andet år",monthStatus:"Vis en anden måned",weekText:"Uge",weekStatus:"Årets uge",dayStatus:"Vælg D, M d",defaultStatus:"Vælg en dato",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.da)}(jQuery),function(n){n.datepick.regionalOptions.cs={monthNames:["leden","únor","březen","duben","květen","červen","červenec","srpen","září","říjen","listopad","prosinec"],monthNamesShort:["led","úno","bře","dub","kvě","čer","čvc","srp","zář","říj","lis","pro"],dayNames:["neděle","pondělí","úterý","středa","čtvrtek","pátek","sobota"],dayNamesShort:["ne","po","út","st","čt","pá","so"],dayNamesMin:["ne","po","út","st","čt","pá","so"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Dříve",prevStatus:"Přejít na předchozí měsí",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Později&#x3e;",nextStatus:"Přejít na další měsíc",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Nyní",currentStatus:"Přejde na aktuální měsíc",todayText:"Nyní",todayStatus:"Přejde na aktuální měsíc",clearText:"Vymazat",clearStatus:"Vymaže zadané datum",closeText:"Zavřít",closeStatus:"Zavře kalendář beze změny",yearStatus:"Přejít na jiný rok",monthStatus:"Přejít na jiný měsíc",weekText:"Týd",weekStatus:"Týden v roce",dayStatus:"'Vyber' DD, M d",defaultStatus:"Vyberte datum",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.cs)}(jQuery),function(n){n.datepick.regionalOptions.de={monthNames:["Januar","Februar","März","April","Mai","Juni","Juli","August","September","Oktober","November","Dezember"],monthNamesShort:["Jan","Feb","Mär","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Dez"],dayNames:["Sonntag","Montag","Dienstag","Mittwoch","Donnerstag","Freitag","Samstag"],dayNamesShort:["So","Mo","Di","Mi","Do","Fr","Sa"],dayNamesMin:["So","Mo","Di","Mi","Do","Fr","Sa"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;zurück",prevStatus:"letzten Monat zeigen",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Vor&#x3e;",nextStatus:"nächsten Monat zeigen",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"heute",currentStatus:"",todayText:"heute",todayStatus:"",clearText:"löschen",clearStatus:"aktuelles Datum löschen",closeText:"schließen",closeStatus:"ohne Änderungen schließen",yearStatus:"anderes Jahr anzeigen",monthStatus:"anderen Monat anzeigen",weekText:"Wo",weekStatus:"Woche des Monats",dayStatus:"Wähle D, M d",defaultStatus:"Wähle ein Datum",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.de)}(jQuery),function(n){n.datepick.regionalOptions["el-GR"]={monthNames:["Ιανουαριος","Φεβρουαριος","Μαρτιος","Απριλιος","Μαιος","Ιουνιος","Ιουλιος","Αυγουστος","Σεπτεμβριος","Οκτωβριος","Νοεμβριος","Δεκεμβριος"],monthNamesShort:["Ιαν","Φεβ","Μαρ","Απρ","Μαι","Ιουν","Ιουλ","Αυγ","Σεπ","Οκτ","Νοε","Δεκ"],dayNames:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"],dayNamesShort:["Κυρ","Δευ","Τρι","Τετ","Πεμ","Παρ","Σαβ"],dayNamesMin:["Κυ","Δε","Τρ","Τε","Πε","Πα","Σα"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"Προηγούμενος",prevStatus:"Επισκόπηση προηγούμενου μήνα",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Επόμενος",nextStatus:"Επισκόπηση επόμενου μήνα",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Τρέχων Μήνας",currentStatus:"Επισκόπηση τρέχοντος μήνα",todayText:"Τρέχων Μήνας",todayStatus:"Επισκόπηση τρέχοντος μήνα",clearText:"Σβήσιμο",clearStatus:"Σβήσιμο της επιλεγμένης ημερομηνίας",closeText:"Κλείσιμο",closeStatus:"Κλείσιμο χωρίς αλλαγή",yearStatus:"Επισκόπηση άλλου έτους",monthStatus:"Επισκόπηση άλλου μήνα",weekText:"Εβδ",weekStatus:"",dayStatus:"Επιλογή DD d MM",defaultStatus:"Επιλέξτε μια ημερομηνία",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions["el-GR"])}(jQuery),function(n){n.datepick.regionalOptions.el={monthNames:["Ιανουαριος","Φεβρουαριος","Μαρτιος","Απριλιος","Μαιος","Ιουνιος","Ιουλιος","Αυγουστος","Σεπτεμβριος","Οκτωβριος","Νοεμβριος","Δεκεμβριος"],monthNamesShort:["Ιαν","Φεβ","Μαρ","Απρ","Μαι","Ιουν","Ιουλ","Αυγ","Σεπ","Οκτ","Νοε","Δεκ"],dayNames:["Κυριακή","Δευτέρα","Τρίτη","Τετάρτη","Πέμπτη","Παρασκευή","Σάββατο"],dayNamesShort:["Κυρ","Δευ","Τρι","Τετ","Πεμ","Παρ","Σαβ"],dayNamesMin:["Κυ","Δε","Τρ","Τε","Πε","Πα","Σα"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"Προηγούμενος",prevStatus:"Επισκόπηση προηγούμενου μήνα",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Επόμενος",nextStatus:"Επισκόπηση επόμενου μήνα",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Τρέχων Μήνας",currentStatus:"Επισκόπηση τρέχοντος μήνα",todayText:"Τρέχων Μήνας",todayStatus:"Επισκόπηση τρέχοντος μήνα",clearText:"Σβήσιμο",clearStatus:"Σβήσιμο της επιλεγμένης ημερομηνίας",closeText:"Κλείσιμο",closeStatus:"Κλείσιμο χωρίς αλλαγή",yearStatus:"Επισκόπηση άλλου έτους",monthStatus:"Επισκόπηση άλλου μήνα",weekText:"Εβδ",weekStatus:"",dayStatus:"Επιλογή DD d MM",defaultStatus:"Επιλέξτε μια ημερομηνία",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.el)}(jQuery),function(n){n.datepick.regionalOptions.es={monthNames:["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"],monthNamesShort:["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"],dayNames:["Domingo","Lunes","Martes","Miércoles","Jueves","Viernes","Sábado"],dayNamesShort:["Dom","Lun","Mar","Mié","Juv","Vie","Sáb"],dayNamesMin:["Do","Lu","Ma","Mi","Ju","Vi","Sá"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Ant",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Sig&#x3e;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Hoy",currentStatus:"",todayText:"Hoy",todayStatus:"",clearText:"Limpiar",clearStatus:"",closeText:"Cerrar",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Sm",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.es)}(jQuery),function(n){n.datepick.regionalOptions.fi={monthNames:["Tammikuu","Helmikuu","Maaliskuu","Huhtikuu","Toukokuu","Kes&auml;kuu","Hein&auml;kuu","Elokuu","Syyskuu","Lokakuu","Marraskuu","Joulukuu"],monthNamesShort:["Tammi","Helmi","Maalis","Huhti","Touko","Kes&auml;","Hein&auml;","Elo","Syys","Loka","Marras","Joulu"],dayNamesShort:["Su","Ma","Ti","Ke","To","Pe","Su"],dayNames:["Sunnuntai","Maanantai","Tiistai","Keskiviikko","Torstai","Perjantai","Lauantai"],dayNamesMin:["Su","Ma","Ti","Ke","To","Pe","La"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&laquo;Edellinen",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Seuraava&raquo;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"T&auml;n&auml;&auml;n",currentStatus:"",todayText:"T&auml;n&auml;&auml;n",todayStatus:"",clearText:"Tyhjenn&auml;",clearStatus:"",closeText:"Sulje",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Vk",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.fi)}(jQuery),function(n){n.datepick.regionalOptions.fr={monthNames:["Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre"],monthNamesShort:["Jan","Fév","Mar","Avr","Mai","Jun","Jul","Aoû","Sep","Oct","Nov","Déc"],dayNames:["Dimanche","Lundi","Mardi","Mercredi","Jeudi","Vendredi","Samedi"],dayNamesShort:["Dim","Lun","Mar","Mer","Jeu","Ven","Sam"],dayNamesMin:["Di","Lu","Ma","Me","Je","Ve","Sa"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Préc",prevStatus:"Voir le mois précédent",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"Voir l'année précédent",nextText:"Suiv&#x3e;",nextStatus:"Voir le mois suivant",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"Voir l'année suivant",currentText:"Courant",currentStatus:"Voir le mois courant",todayText:"Aujourd'hui",todayStatus:"Voir aujourd'hui",clearText:"Effacer",clearStatus:"Effacer la date sélectionnée",closeText:"Fermer",closeStatus:"Fermer sans modifier",yearStatus:"Voir une autre année",monthStatus:"Voir un autre mois",weekText:"Sm",weekStatus:"Semaine de l'année",dayStatus:"'Choisir' le DD d MM",defaultStatus:"Choisir la date",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.fr)}(jQuery),function(n){n.datepick.regionalOptions.it={monthNames:["Gennaio","Febbraio","Marzo","Aprile","Maggio","Giugno","Luglio","Agosto","Settembre","Ottobre","Novembre","Dicembre"],monthNamesShort:["Gen","Feb","Mar","Apr","Mag","Giu","Lug","Ago","Set","Ott","Nov","Dic"],dayNames:["Domenica","Lunedì","Martedì","Mercoledì","Giovedì","Venerdì","Sabato"],dayNamesShort:["Dom","Lun","Mar","Mer","Gio","Ven","Sab"],dayNamesMin:["Do","Lu","Ma","Me","Gi","Ve","Sa"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Prec",prevStatus:"Mese precedente",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"Mostra l'anno precedente",nextText:"Succ&#x3e;",nextStatus:"Mese successivo",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"Mostra l'anno successivo",currentText:"Oggi",currentStatus:"Mese corrente",todayText:"Oggi",todayStatus:"Mese corrente",clearText:"Svuota",clearStatus:"Annulla",closeText:"Chiudi",closeStatus:"Chiudere senza modificare",yearStatus:"Seleziona un altro anno",monthStatus:"Seleziona un altro mese",weekText:"Sm",weekStatus:"Settimana dell'anno",dayStatus:"'Seleziona' D, M d",defaultStatus:"Scegliere una data",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.it)}(jQuery),function(n){n.datepick.regionalOptions.pl={monthNames:["Styczeń","Luty","Marzec","Kwiecień","Maj","Czerwiec","Lipiec","Sierpień","Wrzesień","Październik","Listopad","Grudzień"],monthNamesShort:["Sty","Lu","Mar","Kw","Maj","Cze","Lip","Sie","Wrz","Pa","Lis","Gru"],dayNames:["Niedziela","Poniedzialek","Wtorek","Środa","Czwartek","Piątek","Sobota"],dayNamesShort:["Nie","Pn","Wt","Śr","Czw","Pt","So"],dayNamesMin:["N","Pn","Wt","Śr","Cz","Pt","So"],dateFormat:"yyyy-mm-dd",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Poprzedni",prevStatus:"Pokaż poprzedni miesiąc",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Następny&#x3e;",nextStatus:"Pokaż następny miesiąc",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Dziś",currentStatus:"Pokaż aktualny miesiąc",todayText:"Dziś",todayStatus:"Pokaż aktualny miesiąc",clearText:"Wyczyść",clearStatus:"Wyczyść obecną datę",closeText:"Zamknij",closeStatus:"Zamknij bez zapisywania",yearStatus:"Pokaż inny rok",monthStatus:"Pokaż inny miesiąc",weekText:"Tydz",weekStatus:"Tydzień roku",dayStatus:"'Wybierz' D, M d",defaultStatus:"Wybierz datę",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.pl)}(jQuery),function(n){n.datepick.regionalOptions.pt={monthNames:["Janeiro","Fevereiro","Março","Abril","Maio","Junho","Julho","Agosto","Setembro","Outubro","Novembro","Dezembro"],monthNamesShort:["Jan","Fev","Mar","Abr","Mai","Jun","Jul","Ago","Set","Out","Nov","Dez"],dayNames:["Domingo","Segunda-feira","Terça-feira","Quarta-feira","Quinta-feira","Sexta-feira","Sábado"],dayNamesShort:["Dom","Seg","Ter","Qua","Qui","Sex","Sáb"],dayNamesMin:["D","S","T","Q","Q","S","S"],dateFormat:"dd/mm/yyyy",firstDay:0,renderer:n.datepick.defaultRenderer,prevText:"&lt;Anterior",prevStatus:"Mês anterior",prevJumpText:"&lt;&lt;",prevJumpStatus:"Ano anterior",nextText:"Próximo&gt;",nextStatus:"Próximo mês",nextJumpText:"&gt;&gt;",nextJumpStatus:"Próximo ano",currentText:"Atual",currentStatus:"Mês atual",todayText:"Hoje",todayStatus:"Hoje",clearText:"Limpar",clearStatus:"Limpar data",closeText:"Fechar",closeStatus:"Fechar o calendário",yearStatus:"Selecionar ano",monthStatus:"Selecionar mês",weekText:"s",weekStatus:"Semana do ano",dayStatus:"DD, d 'de' M 'de' yyyy",defaultStatus:"Selecione um dia",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.pt)}(jQuery),function(n){n.datepick.regionalOptions.ru={monthNames:["Январь","Февраль","Март","Апрель","Май","Июнь","Июль","Август","Сентябрь","Октябрь","Ноябрь","Декабрь"],monthNamesShort:["Янв","Фев","Мар","Апр","Май","Июн","Июл","Авг","Сен","Окт","Ноя","Дек"],dayNames:["воскресенье","понедельник","вторник","среда","четверг","пятница","суббота"],dayNamesShort:["вск","пнд","втр","срд","чтв","птн","сбт"],dayNamesMin:["Вс","Пн","Вт","Ср","Чт","Пт","Сб"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Пред",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"След&#x3e;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Сегодня",currentStatus:"",todayText:"Сегодня",todayStatus:"",clearText:"Очистить",clearStatus:"",closeText:"Закрыть",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Не",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.ru)}(jQuery),function(n){n.datepick.regionalOptions.sk={monthNames:["Január","Február","Marec","Apríl","Máj","Jún","Júl","August","September","Október","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","Máj","Jún","Júl","Aug","Sep","Okt","Nov","Dec"],dayNames:["Nedel'a","Pondelok","Utorok","Streda","Štvrtok","Piatok","Sobota"],dayNamesShort:["Ned","Pon","Uto","Str","Štv","Pia","Sob"],dayNamesMin:["Ne","Po","Ut","St","Št","Pia","So"],dateFormat:"dd.mm.yyyy",firstDay:0,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;Predchádzajúci",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Nasledujúci&#x3e;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Dnes",currentStatus:"",todayText:"Dnes",todayStatus:"",clearText:"Zmazať",clearStatus:"",closeText:"Zavrieť",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Ty",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.sk)}(jQuery),function(n){n.datepick.regionalOptions.sq={monthNames:["Janar","Shkurt","Mars","Prill","Maj","Qershor","Korrik","Gusht","Shtator","Tetor","Nëntor","Dhjetor"],monthNamesShort:["Jan","Shk","Mar","Pri","Maj","Qer","Kor","Gus","Sht","Tet","Nën","Dhj"],dayNames:["E Diel","E Hënë","E Martë","E Mërkurë","E Enjte","E Premte","E Shtune"],dayNamesShort:["Di","Hë","Ma","Më","En","Pr","Sh"],dayNamesMin:["Di","Hë","Ma","Më","En","Pr","Sh"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&#x3c;mbrapa",prevStatus:"trego muajin e fundit",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Përpara&#x3e;",nextStatus:"trego muajin tjetër",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"sot",currentStatus:"",todayText:"sot",todayStatus:"",clearText:"fshije",clearStatus:"fshije datën aktuale",closeText:"mbylle",closeStatus:"mbylle pa ndryshime",yearStatus:"trego tjetër vit",monthStatus:"trego muajin tjetër",weekText:"Ja",weekStatus:"Java e muajit",dayStatus:"'Zgjedh' D, M d",defaultStatus:"Zgjedhe një datë",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.sq)}(jQuery),function(n){n.datepick.regionalOptions.nl={monthNames:["januari","februari","maart","april","mei","juni","juli","augustus","september","oktober","november","december"],monthNamesShort:["jan","feb","maa","apr","mei","jun","jul","aug","sep","okt","nov","dec"],dayNames:["zondag","maandag","dinsdag","woensdag","donderdag","vrijdag","zaterdag"],dayNamesShort:["zon","maa","din","woe","don","vri","zat"],dayNamesMin:["zo","ma","di","wo","do","vr","za"],dateFormat:"dd-mm-yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"←",prevStatus:"Bekijk de vorige maand",prevJumpText:"«",prevJumpStatus:"Bekijk het vorige jaar",nextText:"→",nextStatus:"Bekijk de volgende maand",nextJumpText:"»",nextJumpStatus:"Bekijk het volgende jaar",currentText:"Vandaag",currentStatus:"Bekijk de huidige maand",todayText:"Vandaag",todayStatus:"Bekijk de huidige maand",clearText:"Wissen",clearStatus:"Wis de huidige datum",closeText:"Sluiten",closeStatus:"Sluit zonder verandering",yearStatus:"Bekijk een ander jaar",monthStatus:"Bekijk een andere maand",weekText:"Wk",weekStatus:"Week van het jaar",dayStatus:"dd-mm-yyyy",defaultStatus:"Kies een datum",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.nl)}(jQuery),function(n){n.datepick.regionalOptions.no={monthNames:["Januar","Februar","Mars","April","Mai","Juni","Juli","August","September","Oktober","November","Desember"],monthNamesShort:["Jan","Feb","Mar","Apr","Mai","Jun","Jul","Aug","Sep","Okt","Nov","Des"],dayNamesShort:["Søn","Man","Tir","Ons","Tor","Fre","Lør"],dayNames:["Søndag","Mandag","Tirsdag","Onsdag","Torsdag","Fredag","Lørdag"],dayNamesMin:["Sø","Ma","Ti","On","To","Fr","Lø"],dateFormat:"dd.mm.yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&laquo;Forrige",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Neste&raquo;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"I dag",currentStatus:"",todayText:"I dag",todayStatus:"",clearText:"Tøm",clearStatus:"",closeText:"Lukk",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Uke",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.no)}(jQuery),function(n){n.datepick.regionalOptions.sv={monthNames:["Januari","Februari","Mars","April","Maj","Juni","Juli","Augusti","September","Oktober","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","Maj","Jun","Jul","Aug","Sep","Okt","Nov","Dec"],dayNames:["Söndag","Måndag","Tisdag","Onsdag","Torsdag","Fredag","Lördag"],dayNamesShort:["Sön","Mån","Tis","Ons","Tor","Fre","Lör"],dayNamesMin:["Sö","Må","Ti","On","To","Fr","Lö"],dateFormat:"yyyy-mm-dd",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"&laquo;Förra",prevStatus:"",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"",nextText:"Nästa&raquo;",nextStatus:"",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"",currentText:"Idag",currentStatus:"",todayText:"Idag",todayStatus:"",clearText:"Rensa",clearStatus:"",closeText:"Stäng",closeStatus:"",yearStatus:"",monthStatus:"",weekText:"Ve",weekStatus:"",dayStatus:"D, M d",defaultStatus:"",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions.sv)}(jQuery),function(n){n.datepick.regionalOptions.en={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],dateFormat:"dd/mm/yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"Prev",prevStatus:"Show the previous month",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"Show the previous year",nextText:"Next",nextStatus:"Show the next month",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"Show the next year",currentText:"Current",currentStatus:"Show the current month",todayText:"Today",todayStatus:"Show today's month",clearText:"Clear",clearStatus:"Erase the current date",closeText:"Done",closeStatus:"Close without change",yearStatus:"Show a different year",monthStatus:"Show a different month",weekText:"Wk",weekStatus:"Week of the year",dayStatus:"Select DD, M d",defaultStatus:"Select a date",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions["en-GB"])}(jQuery),function(n){n.datepick.regionalOptions["en-US"]={monthNames:["January","February","March","April","May","June","July","August","September","October","November","December"],monthNamesShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],dayNames:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],dayNamesShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],dayNamesMin:["Su","Mo","Tu","We","Th","Fr","Sa"],dateFormat:"dd MM yyyy",firstDay:1,renderer:n.datepick.defaultRenderer,prevText:"Prev",prevStatus:"Show the previous month",prevJumpText:"&#x3c;&#x3c;",prevJumpStatus:"Show the previous year",nextText:"Next",nextStatus:"Show the next month",nextJumpText:"&#x3e;&#x3e;",nextJumpStatus:"Show the next year",currentText:"Current",currentStatus:"Show the current month",todayText:"Today",todayStatus:"Show today's month",clearText:"Clear",clearStatus:"Erase the current date",closeText:"Done",closeStatus:"Close without change",yearStatus:"Show a different year",monthStatus:"Show a different month",weekText:"Wk",weekStatus:"Week of the year",dayStatus:"Select DD, M d",defaultStatus:"Select a date",isRTL:!1};n.datepick.setDefaults(n.datepick.regionalOptions["en-US"])}(jQuery);IBE.Models.BookingProcess=function(n){var t=this;ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Taxes(t));(typeof n=="undefined"||n==null)&&(n={});t.checkIn=ko.assignObservable(n.checkIn);t.checkOut=ko.assignObservable(n.checkOut);t.couponCode=ko.assignObservable(n.couponCode,"");t.rooms=ko.assignObservableArray(n.rooms);t.supplements=ko.observableArray([]);n.supplements&&ko.utils.arrayPushAll(t.supplements,n.supplements);t.cost=ko.assignObservable(n.cost,0);t.costWithoutDiscount=ko.assignObservable(n.costWithoutDiscount,0);t.advancePayment=ko.assignObservable(n.advancePayment,0);t.tax=ko.assignObservable(n.tax);t.reservationStatus=ko.assignObservable(n.reservationStatus);t.currency=ko.assignObservable(n.currency);t.id=ko.assignObservable(n.Id,"");t.isOnline=ko.assignObservable(n.isOnline,!1);t.cancellationPolicy=ko.assignObservable(n.cancellationPolicy,"");t.paymentPolicy=ko.assignObservable(n.paymentPolicy,"");t.paymentPolicyHotelTextOption=ko.assignObservable(n.paymentPolicyHotelTextOption,"Unknown");t.payments=ko.observableArray();t.timePolicy=ko.assignObservableArray(n.timePolicy,"");t.customer=ko.assignObservable(n.customer);t.nights=ko.computed({read:function(){return t.checkOut().diff(t.checkIn(),"days")},deferEvaluation:!0});t.totalGuests=ko.observable(n.totalGuests||0);t.lang=ko.assignObservable(n.lang);t.roomsCost=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.rooms(),function(t){n+=t.cost()}),n},deferEvaluation:!0});t.supplementsCost=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.supplements(),function(t){n+=t.totalPrice()}),n},deferEvaluation:!0});t.totalCost=ko.computed({read:function(){var n=0;return n+=t.roomsCost(),n+t.supplementsCost()},deferEvaluation:!0});t.roomsCostWithoutDiscount=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.rooms(),function(t){n+=t.costWithoutDiscount()}),n},deferEvaluation:!0});t.supplementsCostWithoutDiscount=ko.computed({read:function(){var n=0;return ko.utils.arrayForEach(t.supplements(),function(t){n+=t.totalPriceWithoutDiscount()}),n},deferEvaluation:!0});t.paymentMethodType=ko.observable(n.paymentMethod);t.totalCostWithoutDiscount=ko.computed({read:function(){var n=0;return n+=t.roomsCostWithoutDiscount(),n+t.supplementsCostWithoutDiscount()},deferEvaluation:!0});t.paymentRules=ko.computed({read:function(){var n=[],e,o;if(t.payments().length===0)return n;var i=0,u=t.checkIn(),s=t.checkOut(),f=moment().startOf("day"),r=t.totalCost();if(ko.utils.arrayForEach(t.payments(),function(i){var u=ko.toJS(i);u.amountCurrency=t.getRateText(u.amount,t.currency());n.push(u);r-=i.amount}),r>0){for(i=n.length-1,n[i].paymentDate===u.format("YYYY-MM-DD")||n[i].paymentDate===s.format("YYYY-MM-DD")?(n[i].amount+=r,n[i].amountCurrency=t.getRateText(n[i].amount,t.currency())):n.push({amount:r,paymentDate:u.format("YYYY-MM-DD"),amountCurrency:t.getRateText(r,t.currency())}),e=!1,i=0;i<n.length;i++)if(f.diff(n[i].paymentDate,"days")===0){e=!0;break}e||n.unshift({paymentDate:f.format("YYYY-MM-DD"),amount:0,amountCurrency:t.getRateText(0,t.currency()),text:IBE.Utils.translate("noAdvancePayment")})}return o=0,ko.utils.arrayForEach(n,function(n){var r=moment(n.paymentDate),i=IBE.Utils.dateIsoFormat(r),t=n.amount;if(IBE.Utils.dateIsoFormat(f)===i&&o===0){t>0?(n.text=IBE.Utils.translate("paymentRuleAdvancePayment").format(n.amountCurrency),o=t):n.text=IBE.Utils.translate("noAdvancePayment");return}if(IBE.Utils.dateIsoFormat(u)===i&&t>0){n.text=IBE.Utils.translate("paymentRulePayUponCheckIn").format(n.amountCurrency);return}if(IBE.Utils.dateIsoFormat(s)===i&&t>0){n.text=IBE.Utils.translate("paymentRulePayUponCheckOut").format(n.amountCurrency);return}if(t>0){n.text=IBE.Utils.translate("paymentRulePayOnDate").format(n.amountCurrency,moment(r).format("DD/MM/YYYY"));return}}),n},deferEvaluation:!0});t.paymentText=ko.computed({read:function(){var n="";ko.utils.arrayForEach(t.paymentRules(),function(t){t.text&&t.text!==""&&(n+="<li>"+t.text+"<\/li>")});switch(t.paymentPolicyHotelTextOption()){case"Append":return n+"<p>"+t.paymentPolicy()+"<\/p>";case"Replace":return t.paymentPolicy();default:return n}},deferEvaluation:!0});t.timePolicyText=ko.computed({read:function(){var n="";return IBE.Config.ibeTimePolicy?(ko.utils.arrayForEach(t.timePolicy(),function(t){t&&t!==""&&(n+="<li>"+t+"<\/li>")}),n=n.replace("Check-In",IBE.Utils.translate("checkIn")),n=n.replace("Check-Out",IBE.Utils.translate("checkOut")),n=n.replace("From",IBE.Utils.translate("from")),n=n.replace("From",IBE.Utils.translate("from")),n=n.replace("to",IBE.Utils.translate("to")),n=n.replace("to",IBE.Utils.translate("to"))):n},deferEvaluation:!0});t.isValidStay=ko.pureComputed({read:function(){return isNaN(t.nights())||t.nights()<=0?!1:!0}});t.bookingProcessPostData=function(){var n={checkIn:t.checkIn().format("YYYY-MM-DD"),checkOut:t.checkOut().format("YYYY-MM-DD"),couponCode:t.couponCode(),ipAddress:null,notes:"",customer:t.customer(),rooms:[],supplements:[],referrer:new IBE.Models.Referrer};return Cache.read("ref","localstorage")&&(n.referrer=Cache.read("ref","localstorage")),typeof t.customer()!="undefined"&&(n.notes=t.customer().notes()),ko.utils.arrayForEach(t.rooms(),function(t){var i={availability:ko.unwrap(t.availability),boardType:ko.unwrap(t.boardType),ratePlanId:ko.unwrap(t.ratePlanId),roomId:ko.unwrap(t.roomId),roomIndex:ko.unwrap(t.roomIndex),guestTypes:[]};ko.utils.arrayForEach(ko.unwrap(t.guestTypes),function(n){i.guestTypes.push({ageCategory:ko.unwrap(n.ageCategory),fromAge:ko.unwrap(n.fromAge),pax:ko.unwrap(n.pax)})});n.rooms.push(i)}),ko.utils.arrayForEach(t.supplements(),function(t){ko.utils.arrayForEach(t.prices(),function(i){if(i.quantity()>0){IBE.Config.supplementPricingType[t.pricingType()]!==IBE.Config.supplementPricingType.PerGuest&&(i.guestType=0);var r={roomIndex:t.roomIndex(),supplementId:t.supplementId(),quantity:i.quantity(),isMandatory:t.isMandatory,pricingType:t.supplementPricingType,guestType:i.guestType};n.supplements.push(r)}})}),n};$.when(t.currenciesPartialInit()).then(function(){})};IBE.ViewModels.Contact=function(){var n=this;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.Models.Contact);n.errors=ko.validation.group(n);n.submit=function(){if(n.clearMessage(),n.errors().length>0)return n.errors.showAllMessages(),!1;n.ready(!1);n.events.notifySubscribers(!1,"ready");var t={message:"Sender: "+n.firstName()+" "+n.lastName()+", <em>"+n.email()+"<\/em><br /><p>"+n.text()+"<\/p>",subject:n.subject()};$.ajax({type:"POST",data:t,url:IBE.Config.apiBaseUrl+"/system/sendmail/?apikey="+IBE.Config.apiKey,success:function(){n.clearMessage();var t={id:200,severity:"success",text:IBE.Utils.translate("contactSendSuccess")};n.message(t);ko.utils.extend(n,new IBE.Models.Contact);n.ready(!0);n.events.notifySubscribers(!0,"ready")},error:function(t){n.clearMessage();var i={id:t.status,severity:"error",text:IBE.Utils.translate("contactSendFailed")};n.message(i);n.ready(!0);n.events.notifySubscribers(!0,"ready")}})};n.init=function(){n.clearMessage();n.ready(!0);n.events.notifySubscribers(!0,"ready")}};IBE.ViewModels.CurrenciesPartialViewModel=function(n){function t(t){if(t.length===0)return!1;var i=new IBE.Models.Currencies;return i.base=t[0].base,ko.utils.arrayForEach(t,function(n){n.Name!=="ERR"&&i.rates.push(new IBE.Models.CurrencyRate(n))}),n.currencies(i),typeof n.currency()=="undefined"&&n.currency(n.baseCurrency),!0}n.baseCurrency=IBE.Config.currency;n.currency=ko.observable();n.currencies=ko.observableArray([]);n.isDifferentCurrency=ko.computed({read:function(){return!(n.currency()===n.baseCurrency)},deferEvaluation:!0}).extend({notify:"always"});n.calculateRate=function(t,i){var r,u;if(n.currencies().length===0)return!1;r=1;try{n.currencies().base!==n.baseCurrency&&(r=ko.utils.arrayFirst(n.currencies().rates,function(t){return t.code==n.baseCurrency}).rate)}catch(f){r=1}u=1;try{u=ko.utils.arrayFirst(n.currencies().rates,function(n){return n.code==t}).rate}catch(f){u=1}return r==1&&u==1?(n.currency(n.baseCurrency),i):u/r*i};n.getRateText=function(t,i,r){var u=i,f;return n.currencies().rates.forEach(function(n){if(n.code==i){u=n.symbol;return}}),f=r||{precision:2,symbol:u,format:"%v %s"},accounting.formatMoney(n.calculateRate(i,t),f)};n.currenciesPartialInit=function(){return $.when(IBE.Utils.loadExchangeRates()).then(function(n){n&&t(n)}),$.when(IBE.Utils.loadExchangeRates())};var i=function(n){n&&t(n)};$.when(IBE.Utils.loadExchangeRates()).then(i)};IBE.ViewModels.CustomerPartialViewModel=function(n){var t=this;ko.utils.extend(t,new IBE.Models.Customer(n));t.paymentReceipt=ko.observable("");t.paymentReceiptOptions=ko.observableArray([{name:"personalInvoice",text:IBE.Utils.translate("personalInvoice")},{name:"companyInvoice",text:IBE.Utils.translate("companyInvoice")}]);t.notes=ko.observable("");t.flightNumber=ko.observable("");t.arrivalTime=ko.observable("");t.arrivalTimeOptions=ko.computed(function(){for(var i,t,r,u=[{name:"",value:""}],n=0;n<24;n++)for(i=n,n<10&&(i="0"+n),t=0;t<2;t++)r=t===0?"0"+t:"30",u.push({name:i+":"+r,value:i+":"+r});return u});t.creditCard=ko.observable(new IBE.Models.CreditCard);t.company=ko.observable(new IBE.Models.Company);t.errors=ko.observable({customer:ko.validation.group(t),creditCard:ko.validation.group(t.creditCard)})};IBE.ViewModels.ExternalPaymentGateway=function(n,t,i){var r=this,e,u,f,o;r.events=new ko.subscribable;ko.utils.extend(r,new IBE.ViewModels.Message);r.ready=ko.observable(!1);r.gateway=ko.observable("");r.paymentToken=ko.observable("");r.externalPaymentGatewayData=ko.observable("");r.redirectPaymentGatewayData=ko.observableArray([]);r.externalPaymentGatewayMessage=ko.observable("");r.externalPaymentGatewayErrors=ko.observable(!1);r.notStoreCreditCard=ko.observable(!1);r.paymentMethod=ko.observable("");r.paymentMethod.subscribe(function(n){r.externalPaymentGatewayData(n)});r.init=function(){r.gateway(t);switch(t){case"Braintree":if(i===""||typeof i=="undefined")return;r.paymentToken(i);break;case"AlphaBankRedirect":break;case"Omise":if(typeof Omise=="undefined")return;Omise.setPublicKey(i);break;case"AuthorizeNet":if(i===""||typeof i=="undefined")return;r.paymentToken(i);break;case"Stripe":if(i===""||typeof i=="undefined")return;r.paymentToken(i);break;case"Payout":if(i===""||typeof i=="undefined")return;r.externalPaymentGatewayData(i);break;default:return}};r.paymentToken.subscribe(function(n){n&&r.paymentToken&&r.initBraintree()});r.initBraintree=function(){var n=r.paymentToken();typeof braintree!="undefined"&&braintree.client.create({authorization:n,threeDSecure:!0},function(n,t){n||(braintree.hostedFields.create({client:t,styles:{"input.invalid":{color:"red"},"input.valid":{color:"green"}},fields:{number:{selector:"#card-number",placeholder:"4111 1111 1111 1111"},cvv:{selector:"#cvv",placeholder:"123"},expirationDate:{selector:"#expiration-date",placeholder:moment(new Date).format("MM/YY")}}},function(n,t){if(e=t,n){r.externalPaymentGatewayErrors(!0);r.events.notifySubscribers(IBE.Utils.translate("correctCreditCard"),"externalPaymentValidation");return}t.on("validityChange",function(){r.externalPaymentGatewayErrors(!1)});r.ready(!0)}),braintree.threeDSecure.create({version:2,client:t},function(n,t){n||(threeDSecure=t)}))})};r.initStripe=function(){var n,t,i;(data=JSON.parse(r.paymentToken()),n=data.publicKey,o=data.clientSecret,typeof Stripe!="undefined")&&(u=Stripe(n,{locale:IBE.Config.lang.split("-",1)[0]}),t=u.elements(),i={base:{color:"#333333",fontFamily:'"ProximaNova-Regular", Helvetica, sans-serif',fontSmoothing:"antialiased",fontSize:"16px","::placeholder":{color:"#999999"}},invalid:{color:"#cd4c2b",iconColor:"#fa755a"}},f=t.create("card",{style:i}),f.mount("#stripe-card"),f.addEventListener("change",function(n){var t=document.getElementById("card-errors");t.textContent=n.error?n.error.message:""}))};r.externalPaymentGatewayErrors.subscribe(function(n){n&&r.externalPaymentGatewayMessage("")});r.beforeSubmit=function(){var c,s,t,i,h;if(typeof braintree!="undefined"&&typeof e!="undefined"&&e.tokenize({cardholderName:$("#cardholder-name").val()},function(t,i){if(t){r.externalPaymentGatewayErrors(!0);r.externalPaymentGatewayMessage(IBE.Utils.translate("correctCreditCard"));return}threeDSecureParameters=r.create3DSobject(i);threeDSecure.verifyCard(threeDSecureParameters,function(t,i){if(t){r.externalPaymentGatewayErrors(!0);return}r.externalPaymentGatewayErrors(!1);r.externalPaymentGatewayData(i.nonce);r.notStoreCreditCard(!0);n.makeReservation()})}),typeof Omise!="undefined"&&(c={name:$("#CustomerCardHolder").val(),number:$("#CustomerNumber").val(),expiration_month:$("#CardExpirationMonth").val(),expiration_year:$("#CardExpirationYear").val(),security_code:$("#CardVerification").val()},Omise.createToken("card",c,function(t,i){t==200?(r.externalPaymentGatewayErrors(!1),r.externalPaymentGatewayData(i.id),r.notStoreCreditCard(!0),n.makeReservation()):(r.externalPaymentGatewayErrors(!0),r.externalPaymentGatewayMessage(i.message))})),typeof Accept!="undefined"){if(s={},t=r.paymentToken().split("-"),t[0]==="undefined"||t[1]==="undefined"||t[0]===""||t[1]===""){n.makeReservation();return}ko.bindingHandlers.addFiledsAuthorizeNet();s.clientKey=t[1];s.apiLoginID=t[0];i={};i.cardNumber=n.customer().creditCard().cardNumber();i.month=n.customer().creditCard().cardExpirationMonth();i.year=n.customer().creditCard().cardExpirationYear();i.cardCode=n.customer().creditCard().cardVerification();h={};h.authData=s;h.cardData=i;Accept.dispatchData(h,l);function l(n){var i=[],t;if(n.messages.resultCode==="Error"){for(t=0;t<n.messages.message.length;)i.push(n.messages.message[t].text),t=t+1;r.externalPaymentGatewayErrors(!0);r.externalPaymentGatewayMessage(i)}else a(n.opaqueData)}function a(t){document.getElementById("dataDescriptor").value=t.dataDescriptor;document.getElementById("dataValue").value=t.dataValue;r.externalPaymentGatewayErrors(!1);r.externalPaymentGatewayData(t.dataDescriptor+","+t.dataValue);r.notStoreCreditCard(!0);n.makeReservation()}}r.gateway()==="AlphaBankRedirect"&&(n.bookingProcess().advancePayment()>0&&r.notStoreCreditCard(!0),n.makeReservation());typeof Stripe!="undefined"&&typeof u!="undefined"&&(r.externalPaymentGatewayData()==""?u.confirmCardSetup(o,{payment_method:{card:f}}).then(function(t){if(t.error){r.externalPaymentGatewayErrors(!0);switch(t.error.code){case"card_declined":r.externalPaymentGatewayMessage(IBE.Utils.translate("cc_"+t.error.code+"_"+t.error.decline_code));break;case"expired_card":case"incorrect_cvc":case"processing_error":case"incorrect_number":case"incorrect_zip":case"invalid_card_type":case"invalid_cvc":case"invalid_expiry_month":case"invalid_expiry_year":case"invalid_number":case"setup_intent_authentication_failure":r.externalPaymentGatewayMessage(IBE.Utils.translate("cc_"+t.error.code));break;default:r.externalPaymentGatewayMessage(IBE.Utils.translate(IBE.Utils.translate("correctCreditCard")))}return}r.externalPaymentGatewayErrors(!1);r.externalPaymentGatewayData(t.setupIntent.payment_method);r.notStoreCreditCard(!0);n.makeReservation()}):n.makeReservation());r.gateway()==="Payout"&&(n.bookingProcess().advancePayment()>0&&r.notStoreCreditCard(!0),n.makeReservation());typeof r.gateway()!="undefined"&&r.gateway()!=="0"&&r.gateway()!=="Braintree"&&r.gateway()!=="AlphaBankRedirect"&&r.gateway()!=="Omise"&&r.gateway()!=="AuthorizeNet"&&r.gateway()!=="Stripe"&&r.gateway()!=="Payout"&&n.makeReservation()};r.create3DSobject=function(t){return{amount:n.bookingProcess().totalCost(),nonce:t.nonce,bin:t.bin,email:n.customer().email(),billingAddress:{givenName:n.customer().firstName(),surname:n.customer().lastName(),phoneNumber:n.customer().phone(),streetAddress:n.customer().address(),locality:n.customer().country().name(),region:n.customer().city(),postalCode:n.customer().zip(),countryCodeAlpha2:n.customer().country().code()},additionalInformation:{workPhoneNumber:n.customer().phone(),shippingGivenName:n.customer().firstName(),shippingSurname:n.customer().lastName(),shippingPhone:n.customer().phone(),shippingAddress:{streetAddress:n.customer().address(),locality:n.customer().country().name(),region:n.customer().city(),postalCode:n.customer().zip(),countryCodeAlpha2:n.customer().country().code()}},onLookupComplete:function(n,t){t()}}};r.init()};IBE.ViewModels.FooterViewModel=function(){function i(t){n.name(t.info.name);n.logo(t.info.logo);n.address(new IBE.Models.HotelAddress(t.info.address));var i=new IBE.Models.Terms(t.info.termsAndPrivacy);n.privacy(i.privacy||"");t.settings.adwordsConversionId&&n.cookieUsed.push('<a href="https://policies.google.com/technologies/cookies" target="_blank"> Adwords <\/span>');t.settings.facebook_TrackId&&n.cookieUsed.push('<a href="https://www.facebook.com/policies/cookies/" target="_blank"> Facebook <\/span>');t.settings.bingCode&&n.cookieUsed.push('<a href="https://www.bink.com/terms/" target="_blank"> Bing <\/span>');t.settings.triptease&&n.cookieUsed.push('<a href="https://www.triptease.com/en/cookie-policy/" target="_blank"> Triptease <\/span>');t.settings.sojern&&n.cookieUsed.push('<a href="https://www.sojern.com/privacy/product-privacy-policy/" target="_blank"> Sojern <\/span>');t.settings.trivagoId&&n.cookieUsed.push('<a href="https://www.trivago.com/privacy-policy" target="_blank"> Trivago <\/span>');n.ready(!0);n.events.notifySubscribers(!0,"ready")}var n=this,t;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));n.name=ko.observable("");n.logo=ko.observable("");n.address=ko.observable();n.privacy=ko.observable();n.cookieUsed=ko.observableArray([]);n.showLogo=ko.computed(function(){return n.logo().length!==0});n.acceptTracking=ko.observable(!1);n.acceptTrackingCookies=ko.observable(!IBE.Config.showCookieAcceptance);n.allowAllCookies=function(){n.acceptTrackingCookies(!0)};n.saveSetting=function(){};t=[];t.push(n.lang.subscribe(function(){n.init()},n));n.dispose=function(){for(var n in t)t[n].dispose()};n.init=function(){$.when(n.languagePartialInit(),n.currenciesPartialInit()).then(function(){var t=function(t){if(t){if(i(t),IBE.Config.paymentGatewayType[t.settings.externalPaymentGateway]===3){var u=document.getElementById("Cookie"),r=document.createElement("IMG");r.setAttribute("src","https://bookwizecdn.azureedge.net/images/Horizontal_Banner_White_trans.png");r.setAttribute("class","bookwize-alphabank-image");u.after(r)}n.acceptTrackingCookies.valueHasMutated()}};$.when(IBE.Utils.loadHotelInfo(t)).then(t)})}};IBE.ViewModels.HeaderViewModel=function(){function i(t){n.name(t.info.name);n.logo(t.info.logo);n.hotel(new IBE.Models.HotelInfo(t.info));n.website(n.hotel().website);typeof t.settings.ibeBackgroundImage!="undefined"&&n.backgroundImage(t.settings.ibeBackgroundImage);n.ready(!0);n.events.notifySubscribers(!0,"ready")}var n=this,t;n.view=ko.observable();n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));n.name=ko.observable("");n.logo=ko.observable("");n.website=ko.observable("");n.backgroundImage=ko.observable("");n.hotel=ko.observable();n.showLogo=ko.computed(function(){return n.logo().length!==0});t=[];t.push(n.lang.subscribe(function(){n.init()},n));n.dispose=function(){for(var n in t)t[n].dispose()};n.init=function(){$.when(n.languagePartialInit(),n.currenciesPartialInit()).then(function(){var n=function(n){n&&typeof n!="undefined"&&i(n)};$.when(IBE.Utils.loadHotelInfo(n)).then(n)})};n.openInNewTab=function(){window.open(n.hotel().website,"_blank")}};IBE.ViewModels.LanguagePartialViewModel=function(n){function t(t){var i,r;t.languages&&(n.languages().length>0||(i=[],typeof IBE.Config.languages=="undefined"&&(IBE.Config.languages=[]),r=[],typeof IBE.Data.HotelInfo[t.id]!="undefined"&&IBE.Data.HotelInfo[t.id]!=null&&typeof IBE.Data.HotelInfo[t.id].settings.languages!="undefined"&&(r=IBE.Data.HotelInfo[t.id].settings.languages.split(",")),ko.utils.arrayForEach(t.languages,function(n){(IBE.Config.languages.length===0||IBE.Config.languages.indexOf(n.culture)!==-1)&&(r.length>0?r.indexOf(n.locale)>=0&&i.push(new IBE.Models.Language(n)):i.push(new IBE.Models.Language(n)))}),i.length===0&&i.push(new IBE.Models.Language({locale:IBE.Config.lang})),i.sort(function(n,t){return n.description==t.description?0:n.description<t.description?-1:1}),n.languages(i)))}n.languages=ko.observableArray([]);n._lang=ko.observable();n.lang=ko.computed({read:function(){return n._lang()},write:function(t){if(typeof t!="undefined"){var i=function(i){typeof i!="undefined"&&(IBE.Config.ajaxConfig=$.extend(IBE.Config.ajaxConfig,{beforeSend:function(n){n.setRequestHeader("Accept-Language",i)}}),$.ajaxSetup(IBE.Config.ajaxConfig),moment.locale(t),n._lang(i),n.events.notifySubscribers(t,"loadTranslations"))};$.when(IBE.Utils.loadTranslations(t,i)).then(i)}},deferEvaluation:!0});n.lang(IBE.Config.lang);n.languagePartialInit=function(n){var i=$.Deferred(),r=function(n){n&&typeof n!="undefined"&&(t(n),i.resolve(n))};return $.when(IBE.Utils.loadHotelInfo(r,n)).then(r),i.promise()}};IBE.ViewModels.Map=function(){function t(t){n.googleMap(new IBE.Models.GoogleMap(t.info));n.clearMessage();n.ready(!0);n.events.notifySubscribers(!0,"ready")}var n=this;n.events=new ko.subscribable;n.ready=ko.observable(!1);n.googleMap=ko.observable();ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);n.init=function(){var n=function(n){n&&t(n)};$.when(IBE.Utils.loadHotelInfo()).then(n)}};IBE.ViewModels.PartialMemberViewModel=function(n,t){typeof n.events=="undefined"&&(n.events=new ko.subscribable);typeof n.message=="undefined"&&ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.PartialAuthenticateMembership(n));t&&n.customer(new IBE.Models.Customer(t));n.logout=function(){n.username("");n.password("");n.customer(null);IBE.Utils.deleteAuthenticationCookie();n.clearMessage();n.events.notifySubscribers({success:!0},"logout")};n.login=function(){var t=$.Deferred();return n.username()===""||n.password()===""?t.resolve():$.ajax({type:"GET",url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()));t.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")},success:function(i){n.customer(new IBE.Models.Customer(i));t.resolve(i);n.events.notifySubscribers({success:!0},"login")},error:function(i){var r={id:i.status,severity:"error",text:i.responseText};i.status===401?(r.text="Wrong email or password.",IBE.Utils.deleteAuthenticationCookie(),n.customer(null)):r.text="An error occurred.";n.message(r);t.resolve(i)}}),t.promise()};n.isAuthenticated=ko.computed(function(){return n.customer()!=null}).extend({notify:"always"});n.customerAuthenticate=function(){var t=$.Deferred();return IBE.Utils.haveAuthenticationCookie()?$.ajax({type:"GET",url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie());n.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")},success:function(i){n.customer(new IBE.ViewModels.CustomerPartialViewModel(i));t.resolve(i)},error:function(i){IBE.Utils.deleteAuthenticationCookie();n.customer(null);t.resolve(i)}}):t.resolve(),t.promise()}};IBE.ViewModels.PartialAuthenticateMembership=function(n,t){n.customer=ko.observable(null);n.username=ko.observable("");n.password=ko.observable("");typeof t!="undefined"&&t!=null&&t.email!==""&&t.code!==""&&(n.username(t.email),n.password(t.code));n.consents=ko.observableArray([]);n.customerConsents=ko.observableArray([]);n.isAuthenticated=ko.computed(function(){return n.customer()!=null});n.customerConsents=ko.computed({read:function(){return n.customer()==null?[]:(ko.utils.arrayForEach(n.consents(),function(t){var i=ko.utils.arrayFirst(n.customer().consents(),function(n){return t.id===n.id});i&&t.value(!0)}),n.consents())},deferEvaluation:!0});n.createRecoveryLink=function(){if(n.clearMessage(),n.username()===""){var t={id:501,severity:"error",text:IBE.Utils.translate("customerUsernameIsEmpty")};return n.message(t),!1}return $.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/createRecoveryLink/?apikey="+IBE.Config.apiKey,data:ko.toJSON({username:n.username()}),beforeSend:function(){n.ready(!1)},success:function(){var t={id:200,severity:"success",text:IBE.Utils.translate("recoveryLinkSuccessfullySent")};n.message(t);n.events.notifySubscribers(t,"hash-sent")},error:function(t){n.events.notifySubscribers(!0,"ready");var i={id:t.status,severity:"error",text:t.responseText};i.text=t.status===404?"Wrong email.":"An error occurred.";n.message(i);n.events.notifySubscribers(i,"error")},complete:function(){n.ready(!0)}}),!0}};IBE.ViewModels.Membership=function(){function i(t){var i=$.Deferred();return t||i.resolve(0),$.ajax({type:"GET",url:"{0}/members/exist?apikey={1}&email={2}".format(IBE.Config.apiBaseUrl,IBE.Config.apiKey,t),beforeSend:function(){n.ready(!1)},success:function(n){i.resolve(n)},error:function(){i.resolve(!1)},complete:function(){n.events.notifySubscribers(!0,"ready");n.ready(!0)}}),i.promise()}var n=this,t;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.PartialAuthenticateMembership(n));n.countries=ko.observableArray([]);n.claimMembership=new IBE.ViewModels.ClaimMembership;n.termsVisible=ko.observable(!0);n.acceptTerms=ko.observable(!1).extend({checkbox:{message:IBE.Utils.translate("acceptTerms")}});n.memberBenefits=ko.computed(function(){if(n.customer()==null)return[];var t=ko.utils.arrayFilter(n.customer().offers(),function(n){return n.membershipLevels().length>0});return t||[]});t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.edit=ko.observable(!1);n._customerData=null;n.startEdit=function(){n._customerData=ko.toJS(n.customer());n.edit(!0)};n.cancelEdit=function(){n.customer(new IBE.Models.Customer(n._customerData));n._customerData=null;n.edit(!1)};n.save=function(){var i=ko.utils.arrayFilter(n.customerConsents(),function(n){return n.value()}),t;n.customer().consents(i);t=n.customer().toJSON();n.ready(!1);$.ajax({type:"POST",data:t,url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey+"&hotelId="+IBE.Config.hotelId,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()));t.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")},success:function(){n.edit(!1);n.clearMessage();var t={id:200,severity:"success",text:IBE.Utils.translate("customerEditSuccess")};n.message(t);n.ready(!0);n.events.notifySubscribers(!0,"ready")},error:function(t){n.clearMessage();var i={id:t.status,severity:"error",text:IBE.Utils.translate("customerEditFailed")};n.message(i);n.events.notifySubscribers(i,"error");n.ready(!0);n.events.notifySubscribers(!0,"ready")}})};n.oldPassword=ko.observable(null).extend({required:{message:IBE.Utils.translate("validation.required")}});n.newPassword=ko.observable(null).extend({required:{message:IBE.Utils.translate("validation.required")}});n.retypePassword=ko.observable(null).extend({required:{message:IBE.Utils.translate("validation.required")}});n.validatePasswordStrength=ko.computed(function(){return IBE.Utils.passwordStrength(n.newPassword())});n.isPasswordValid=ko.computed(function(){return IBE.Utils.passwordStrength(n.newPassword())>=60&&n.newPassword()==n.retypePassword()});n.passwordMessage=ko.computed(function(){var t=[];return IBE.Utils.passwordStrength(n.newPassword())<60&&t.push("weakPassword"),n.newPassword()!=n.retypePassword()&&t.push("customerPasswordMismatch"),t});n.changePassword=function(){var t,i;if(n.newPassword()!==n.retypePassword()||n.newPassword()==="")return n.clearMessage(),t={id:501,severity:"error",text:IBE.Utils.translate("customerPasswordMismatch")},n.message(t),!1;if(IBE.Utils.passwordStrength(n.newPassword()<60))return n.clearMessage(),t={id:502,severity:"error",text:IBE.Utils.translate("weakPassword")},n.message(t),!1;i={oldPassword:n.oldPassword(),newPassword:n.newPassword()};n.ready(!1);$.ajax({type:"POST",data:ko.toJSON(i),url:IBE.Config.apiBaseUrl+"/members/changepassword?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()))},success:function(){n.clearMessage();var t={id:200,severity:"success",text:IBE.Utils.translate("customerPasswordChangeSuccess")};n.message(t);n.ready(!0);n.events.notifySubscribers(!0,"ready");n.events.notifySubscribers(t,"password-change-success")},error:function(t){n.clearMessage();var i={id:t.status,severity:"error",text:IBE.Utils.translate("customerPasswordChangeFailure")};n.message(i);n.events.notifySubscribers(i,"error");n.ready(!0);n.events.notifySubscribers(!0,"ready")}})};n.show=ko.observable(!1);n.toggleChangePassword=ko.observable();n.toggleChangePassword=function(){n.show(!n.show())};n.resetpasswordShow=ko.observable(!1);n.resetPasswordDisplay=function(){n.resetpasswordShow(!0)};n.creditCard=ko.observable(null);n.errors=ko.observable({customer:ko.validation.group(n.customer),password:ko.validation.group(n),creditCard:ko.validation.group(n.creditCard)});n.login=function(){if(n.ready(!1),n.clearMessage(),n.errors().length>0&&IBE.Utils.haveAuthenticationCookie()===!1)return n.errors.showAllMessages(),n.events.notifySubscribers({id:401,severity:"error",text:"Wrong email or password."},"error"),n.ready(!0),!1;$.ajax({type:"GET",url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()));t.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US");n.ready(!1)},success:function(t){n.customer(new IBE.Models.Customer(t));n.initCustomerData();t.consents&&ko.utils.arrayForEach(t.consents,function(t){n.customer().consents.push(new IBE.Models.Consents(t))});n.ready(!0);IBE.Utils.authenticationHeader(n.username(),n.password());n.events.notifySubscribers({success:!0,email:n.username(),code:n.password()},"login");n.events.notifySubscribers(!0,"ready");n.ready(!0)},error:function(t){n.ready(!1);n.events.notifySubscribers(!0,"ready");var i={id:t.status,severity:"error",text:t.responseText};i.text=t.status===401?"Wrong email or password.":"An error occurred.";IBE.Utils.deleteAuthenticationCookie();n.customer(null);n.message(i);n.events.notifySubscribers(i,"error");n.ready(!0)}})};n.logout=function(){n.ready(!1);n.username("");n.password("");n.customer(null);IBE.Utils.deleteAuthenticationCookie();n.clearMessage();n.events.notifySubscribers({success:!0},"logout");n.ready(!0)};n.confirmAction=function(t,i){var e={id:n.currentReservation().reservation().id,newStatus:t,creditCard:{},cancellationNotes:n.currentReservation().reservation().cancellationNotes(),notes:n.currentReservation().reservation().notes()},r=!1,f,u;switch(t){case"CancelledReservation":case"CancelledRequest":n.cancelCode()!=n.currentReservation().reservation().code&&(f={id:5001,severity:"error",text:IBE.Utils.translate("wrongReservationCode")},n.message(f),n.events.notifySubscribers(f,"error"),r=!0);break;case"ConfirmedReservation":n.errors().creditCard().length>0&&(r=!0,n.events.notifySubscribers("","error"),n.errors().creditCard().length==1&&n.errors().creditCard()[0]==null?r=!1:n.errors().creditCard.showAllMessages());u=n.creditCard().cardExpirationYear()+"";u=u.substring(2);e.creditCard={holder:n.creditCard().cardHolder(),expireYear:u,expireMonth:n.creditCard().cardExpirationMonth(),number:n.creditCard().cardNumber(),verification:n.creditCard().cardVerification()}}if(r)return!1;n.clearMessage();IBE.Utils.request({type:"POST",data:ko.toJSON(e),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.username(),n.password()))}}).done(function(r){if(n.cancelCode(""),n.currentReservation().reservation(new IBE.Models.Reservation(r)),n.customer(new IBE.ViewModels.CustomerPartialViewModel),n.events.notifySubscribers(!0,t),n.events.notifySubscribers(!0,t),i==="UpdateCreditCard"){var u={id:200,severity:"success",text:IBE.Utils.translate("creditCardUpdated")};n.message(u)}}).fail(function(){var t={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};n.message(t);n.events.notifySubscribers(t,"error")})};n.resetPassword=function(){var i,t,r;return(n.clearMessage(),i=IBE.Utils.getParam("hash"),!i)?(t={id:501,severity:"error",text:IBE.Utils.translate("invalidHash")},n.message(t),!1):n.newPassword()!==n.retypePassword()||n.newPassword()===""?(t={id:501,severity:"error",text:IBE.Utils.translate("customerPasswordMismatch")},n.message(t),!1):(r={password:n.newPassword(),passwordConfirm:n.retypePassword(),hash:i},$.ajax({type:"POST",data:ko.toJSON(r),url:IBE.Config.apiBaseUrl+"/members/resetpassword?apikey="+IBE.Config.apiKey,beforeSend:function(){n.ready(!1)},success:function(){var t={id:200,severity:"success",text:IBE.Utils.translate("customerResetPasswordSuccess")};n.message(t);n.events.notifySubscribers(t,"password-changed")},error:function(t){var i={id:t.status,severity:"error",text:IBE.Utils.translate("customerResetPasswordFailure")};n.message(i);n.events.notifySubscribers(i,"password-error")},complete:function(){n.events.notifySubscribers(!0,"ready");n.ready(!0)}}),!0)};n.createPassword=function(){var t,i,r;return(n.clearMessage(),n.ready(!1),i=n.customer().resetHash,!i)?(t={id:501,severity:"error",text:IBE.Utils.translate("invalidHash")},n.message(t),!1):n.newPassword()!==n.retypePassword()||n.newPassword()===""?(t={id:501,severity:"error",text:IBE.Utils.translate("customerPasswordMismatch")},n.message(t),!1):(r={password:n.newPassword(),passwordConfirm:n.retypePassword(),hash:i},$.ajax({type:"POST",data:ko.toJSON(r),url:IBE.Config.apiBaseUrl+"/members/resetpassword?apikey="+IBE.Config.apiKey,beforeSend:function(){n.ready(!1)},success:function(){t={id:200,severity:"success",text:IBE.Utils.translate("customerCreatePasswordSuccess")};n.message(t);n.events.notifySubscribers(t,"password-created")},error:function(i){t={id:i.status,severity:"error",text:IBE.Utils.translate("customerCreatePasswordFailure")};n.message(t);n.events.notifySubscribers(t,"password-error")},complete:function(){n.events.notifySubscribers(!0,"ready");n.ready(!0)}}),!0)};n.init=function(){n.ready(!1);$.when(n.languagePartialInit(),n.currenciesPartialInit(),IBE.Utils.loadCountries()).then(function(i,r,u){var f,e,o;(n._populateCountries(u),n.dispose(),t.push(n.lang.subscribe(function(){n.init()})),f=i.info.id,f)&&(n.consents([]),IBE.Data.HotelInfo[f].info.consents&&(e=IBE.Data.HotelInfo[f].info.consents,ko.utils.arrayForEach(e,function(t){n.consents.push(new IBE.Models.Consents(t))})),IBE.Data.HotelInfo[f].info.termsAndPrivacy&&(o=IBE.Data.HotelInfo[f].info.termsAndPrivacy,n.terms=new IBE.Models.Terms(o)),n.clearMessage(),IBE.Utils.haveAuthenticationCookie()?n.login():n.username()===""||n.password()===""?(n.customer(null),n.ready(!0),n.events.notifySubscribers(!0,"ready")):n.login())})};n.customerDataRequest=function(t){var i={hotelId:IBE.Config.hotelId,requestType:t};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/personalDataRequest/?apikey="+IBE.Config.apiKey,data:ko.toJSON(i),beforeSend:function(n){IBE.Utils.haveAuthenticationCookie()&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())},success:function(){var t={id:200,severity:"success",text:IBE.Utils.translate("customerDataRequestSuccess")};n.message(t);n.customerEdit(!1);n.ready(!0)},error:function(t){n.events.notifySubscribers(!0,"ready");var i={id:t.status,severity:"error",text:t.responseText};i.text=t.text;n.message(i);n.events.notifySubscribers(i,"error");n.ready(!0)},complete:function(){n.ready(!0)}})};n.customerDataRequest=function(t){var i={hotelId:IBE.Config.hotelId,requestType:t};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/personalDataRequest/?apikey="+IBE.Config.apiKey,data:ko.toJSON(i),beforeSend:function(t){IBE.Utils.haveAuthenticationCookie()&&t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie());n.ready(!1)},success:function(){var t={id:200,severity:"success",text:IBE.Utils.translate("customerDataRequestSuccess")};n.message(t)},error:function(t){n.events.notifySubscribers(!0,"ready");var i={id:t.status,severity:"error",text:t.responseText};i.text=t.text;n.message(i);n.events.notifySubscribers(i,"error")},complete:function(){n.ready(!0)}})};n.isMember=ko.observable(0);n.memberEmailExists=function(){n.username()!==""&&i(n.username()).then(function(t){n.isMember(t);t<0&&n.events.notifySubscribers(!0,"memberNotExist")})};n._populateCountries=function(t){n.countries.removeAll();t.sort(function(n,t){return n.name>t.name?1:-1});ko.utils.arrayPushAll(n.countries,ko.utils.arrayMap(t,function(n){return new IBE.Models.Country(n)}))};n._populateAcceptedCreditCards=function(){};n.getCustomerCountry=function(){if(!n.countries().length)return"";var t=ko.utils.arrayFirst(n.countries(),function(t){if(n.customer())return t.code()===n.customer().country()});return t===null?"":t.name()};n.showUpdateMessage=ko.observable(!1);n.currentReservation=ko.observable(null);n.currentReservation.subscribe(function(t){t!=null&&(n.clearMessage(),t.events.subscribe(function(t){n.message(t);n.events.notifySubscribers(t,"webcheckinSave")},this,"webcheckinSave"),t.events.subscribe(function(t){n.message(t);n.events.notifySubscribers(t,"reservationstatus");n.showUpdateMessage(!0)},this,"reservationstatus"),t.events.subscribe(function(t){n.message(t);n.events.notifySubscribers(t,"error")},this,"error"))});n.cancelCode=ko.observable("");n.cancelCodeIsValid=ko.computed(function(){return n.currentReservation()==null?!1:n.cancelCode()===n.currentReservation().reservation().code});n.showCheckin=function(t){n.currentReservation(new IBE.ViewModels.Reservation(t));n.events.notifySubscribers(!0,"showCheckin")};n.showReservation=function(t){n.currentReservation(new IBE.ViewModels.Reservation(t));n.events.notifySubscribers(!0,"showReservation")};n.initCustomerData=function(){n.customer().reservations().sort(function(n,t){return n.webCheckInActive()===t.webCheckInActive()?0:n.webCheckInActive()?-1:1});n.creditCard=ko.observable(new IBE.Models.CreditCard)};n.webCheckInIsActive=function(){var t=ko.utils.arrayFirst(n.customer().reservations(),function(n){return n.webCheckInActive()});return t!==null};n.genders=[{name:"",value:IBE.Config.gender.Unknown},{name:"male",value:IBE.Config.gender.Male},{name:"female",value:IBE.Config.gender.Female},];n.idDocumentTypes=[{name:"",value:IBE.Config.idDocumentType.Unknown},{name:"identityCard",value:IBE.Config.idDocumentType.IdentityCard},{name:"passport",value:IBE.Config.idDocumentType.Passport},{name:"drivingLicense",value:IBE.Config.idDocumentType.DrivingLicense}];n.titles=[{name:"",value:IBE.Config.titles.Unknown},{name:"mr",value:IBE.Config.titles.Mr},{name:"mrs",value:IBE.Config.titles.Mrs},{name:"miss",value:IBE.Config.titles.Miss},{name:"ms",value:IBE.Config.titles.Ms},{name:"dr",value:IBE.Config.titles.Dr},]};IBE.ViewModels.ClaimMembership=function(){var n=this;n.events=new ko.subscribable;n.ready=ko.observable(!0);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);n.useNotesValidation=ko.observable(!1);n.firstName=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.lastName=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.email=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.telephone=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required")}});n.notes=ko.observable("").extend({required:{message:IBE.Utils.translate("validation.required"),onlyIf:function(){return n.useNotesValidation()}}});n.dateOfArrival=ko.observable(moment());n.reservationCode=ko.observable("");n.apiResponse=ko.observable(null);n.submit=function(){var t,i;if(n.apiResponse(null),t=ko.validation.group(n,{deep:!0}),t().length){t.showAllMessages(!0);return}i={firstName:n.firstName(),lastName:n.lastName(),email:n.email(),telephone:n.telephone(),dateOfArrival:n.dateOfArrival()===""?null:IBE.Utils.dateIsoFormat(n.dateOfArrival()),reservationCode:n.reservationCode(),notes:n.notes()};$.ajax({type:"POST",data:ko.toJSON(i),url:"{0}/members/claim?apikey={1}&hotelId={2}".format(IBE.Config.apiBaseUrl,IBE.Config.apiKey,IBE.Config.hotelId),beforeSend:function(){n.ready(!1)},success:function(t){n.apiResponse(t);n.clearModel()},error:function(n){IBE.Utils.consoleLog(n.responseJSON.message)},complete:function(){n.ready(!0)}})};n.clearModel=function(){n.firstName("");n.lastName("");n.email("");n.telephone("");n.dateOfArrival("");n.reservationCode("");n.firstName.clearError();n.lastName.clearError();n.email.clearError();n.telephone.clearError();n.dateOfArrival.clearError();n.reservationCode.clearError()}};IBE.ViewModels.ModifyReservation=function(n){function f(n){n&&(t.ready(!1),n.reservationId=t.reservation().id,allowForward=!0,t.currentStep()==="Step1-Rooms"?t.setStep("Step2-Rooms",n):t.setStep("Step2-Dates",n))}function r(n){n&&(n.reservationId=t.reservation().id,allowForward=!0,t.ready(!1),t.setStep("Step3",n))}function u(n){n&&(n.reservationId=t.reservation().id,allowForward=!0,t.ready(!1),t.setStep("Step4",n))}var t=this,i;t.events=new ko.subscribable;t.ready=ko.observable(!1);t.ready.subscribe(function(n){loader.visible(!n)});t.tabsCount=1;t.activeTabIndex=ko.observable(0);t.activeRoomIndex=ko.observable(1);t.activeRooms=ko.observableArray([]);t.modifiedRoomsNotAvailable=ko.observable(!1);t.reservation=ko.observable(n);t.reservation().customer=new IBE.ViewModels.CustomerPartialViewModel;ko.utils.extend(t,new IBE.ViewModels.LanguagePartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Message);ko.utils.extend(t,new IBE.ViewModels.PartialAuthenticateMembership(t));t.countries=ko.observableArray([]);i=[];t.dispose=function(){for(var n in i)i[n].dispose()};t.init=function(){t.ready(!1);$.when(t.languagePartialInit(),t.currenciesPartialInit(),IBE.Utils.loadCountries()).then(function(n,r,u){t.countries.removeAll();ko.utils.arrayPushAll(t.countries,ko.utils.arrayMap(u,function(n){return new IBE.Models.Country(n)}));t.dispose();i.push(t.lang.subscribe(function(){t.init()}));t.clearMessage();IBE.Utils.haveAuthenticationCookie()?(t.ready(!0),t.setStep("Wizard"),t.events.notifySubscribers(!0,"ready")):t.ready(!1)})};t.step1=new IBE.ViewModels.Step1ViewModel;t.currentStep=ko.observable("");t.setStep=function(n,i){switch(n){case"Wizard":IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Cancel");IBE.Utils.destroyView("Payment");t.currentStep("Wizard");IBE.Utils.bindTemplate("Wizard",t);break;case"Step1-Dates":t.ready(!1);IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step1-Dates");t.initStep1();break;case"Step1-Rooms":t.ready(!1);IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step1-Rooms");t.initStep1();break;case"Step2-Rooms":t.ready(!1);IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step2-Rooms");t.initStep2(i);break;case"Step2-Dates":t.ready(!1);IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");IBE.Utils.destroyView("Step4-Modify");t.currentStep("Step2-Dates");t.initStep2(i);break;case"Step3":IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step3");t.initStep3(i);break;case"Step4":IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Payment");IBE.Utils.destroyView("Cancel");t.currentStep("Step4");t.initStep4(i);break;case"cancelReservation":IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Payment");t.currentStep("Cancel");t.initCancel(i);break;case"modifyPaymentMethod":IBE.Utils.destroyView("Wizard");IBE.Utils.destroyView("Step1-Dates");IBE.Utils.destroyView("Step1-Rooms");IBE.Utils.destroyView("Step2-Dates");IBE.Utils.destroyView("Step2-Rooms");IBE.Utils.destroyView("Step3-Modify");IBE.Utils.destroyView("Step4-Modify");IBE.Utils.destroyView("Cancel");t.currentStep("Payment");t.initModifyPayment(i)}};t.initStep1=function(){t.step1.init()};t.initStep2=function(n){if(typeof t.step2=="undefined"&&(t.step2=new IBE.ViewModels.Step2ViewModel,t.step2.events.subscribe(function(n){r(n)},this,"call"),t.step2.events.subscribe(function(n){r(n)},this,"submit"),t.step2.events.subscribe(function(){t.currentStep()==="Step2-Rooms"?$.when(IBE.Utils.bindTemplate("Step2-Rooms",t)).then(function(){t.ready(!0)}):$.when(IBE.Utils.bindTemplate("Step2-Dates",t)).then(function(){t.ready(!0)})},this,"ready"),t.step2.events.subscribe(function(n){n.severity==="Forbidden"&&t.ready(!1);loader.title("Failed to initialize booking engine :(");loader.message(n);IBE.Utils.logEvent(n)},this,"error")),t.step2.lang=t.lang,t.step2.currency=t.currency,typeof n!="undefined")try{t.step2.init(n);t.activeTabIndex(0);t.activeRoomIndex(1);t.activeRooms([]);t.step2.selectedRooms([]);t.modifiedRoomsNotAvailable(!1)}catch(i){return t.step1.message(i.message),IBE.Utils.logEvent(i),t.ready(!0),!1}return!0};t.initStep3=function(n){return typeof step3=="undefined"&&(t.step3=new IBE.ViewModels.modifyStep3ViewModel,t.step3.events.subscribe(function(n){u(n)},this,"submit"),t.step3.events.subscribe(function(){IBE.Utils.bindTemplate("Step3-Modify",t);t.step3.paymentPolicyRules(t.getPaymentRulesText(n.bookingInfo.payments,n.bookingInfo.cost,n.bookingInfo.checkIn,n.bookingInfo.checkOut));t.ready(!0)},this,"ready"),t.step3.events.subscribe(function(n){loader.title("Failed to initialize booking engine :(");loader.message(n);loader.visible(!0);IBE.Utils.logEvent(n)},this,"error")),t.step3.lang=t.lang,t.step3.paymentPolicyRules=ko.observableArray([]),t.step3.init(n),t.step3.currency=t.currency,!0};t.initStep4=function(n){t.currentStep=4;typeof t.step4=="undefined"&&(t.step4=new IBE.ViewModels.ModifyStep4ViewModel,t.step4.events.subscribe(function(n){u(n)},this,"call"),t.step4.events.subscribe(function(n){u(n)},this,"submit"),t.step4.events.subscribe(function(){t.reservation(t.step4.reservation());IBE.Utils.destroyView("Step3-Modify");t.ready(!0);IBE.Utils.bindTemplate("Step4-Modify",t)},this,"ready"),t.step4.events.subscribe(function(n){t.ready(!0);t.step3.clearMessage();t.step3.message(n);n.severity=="critical"&&(loader.title("Failed to submit booking :("),loader.message(n),loader.visible(!0));IBE.Utils.logEvent(n)},this,"error"));t.step4.lang=t.lang;t.step4.currency=t.currency;try{t.step4.init(n)}catch(i){t.step3.clearMessage();var r={id:"4001",severity:i.severity,text:i.text||i.message};return t.step3.message(r),IBE.Utils.logEvent(r),t.ready(!0),!1}return!0};t.initCancel=function(){IBE.Utils.bindTemplate("Cancel",t)};t.initModifyPayment=function(){IBE.Utils.bindTemplate("Payment",t);t.events.subscribe(function(n){console.log(n)},this,"reservationstatus")};t.step1.ready.subscribe(function(n){if(n){t.ready(!1);t.step1.checkIn(moment(t.reservation().checkIn));t.step1.checkOut(moment(t.reservation().checkOut));t.step1.couponCode(t.reservation().couponCode);t.step1.boardType(t.reservation().rooms[0].board.type);t.reservation().rooms=t.reservation().rooms.sort(function(n,t){return n>t?1:0});var i=[],r=1;ko.utils.arrayForEach(t.reservation().rooms,function(n){var u=new IBE.Models.RequestedRoom(r++);u.guests=t.createGuestTypes(n);i.push(u)});t.step1.requestedRooms(i);ko.utils.arrayForEach(t.step1.requestedRooms(),function(n,i){n.preferredBoard(t.reservation().rooms[i].board.type)});t.currentStep()==="Step1-Rooms"?$.when(IBE.Utils.bindTemplate("Step1-Rooms",t)).then(function(){t.ready(!0)}):$.when(IBE.Utils.bindTemplate("Step1-Dates",t)).then(function(){t.ready(!0)})}});t.step1.events.subscribe(function(n){n.success&&f(n.success);n.failure&&(IBE.Utils.consoleLog("Failed to submit step 1"),IBE.Utils.consoleLog(n.failure))},this,"submit");t.boardChanged=function(n,i){var r=t.step2.selectedRooms()[i-1]};t.checkRoomAvailability=function(n,i){var r={roomExist:!1,rooms:[],selectedRoom:ko.observable(null),selectedRoomResult:ko.observable(null),selectedRateplan:ko.observable(null),selectedBoard:ko.observable(null),selectedRoomRateplans:ko.observableArray([])},f,u;return(r.selectedRoom.subscribe(function(i){if(i){var u=t.constructSelectedRoom(i);r.selectedRoomRateplans(i.rateplans);r.selectedRoomResult(i);u.rateplans=i.rateplans;t.activeRooms()[n-1]?t.activeRooms.replace(t.activeRooms()[n-1],u):t.activeRooms.push(u)}}),r.selectedRateplan.subscribe(function(i){var u=JSON.parse(JSON.stringify(ko.toJS(r.selectedRoom()))),f;u.ratePlanId=i;r.selectedBoard()!==null&&(u.boardType=r.selectedBoard().boardType);f=t.constructSelectedRoom(u);f.rateplans=r.selectedRoomRateplans();t.activeRooms.replace(t.activeRooms()[n-1],f)}),r.selectedBoard.subscribe(function(i){var u=JSON.parse(JSON.stringify(ko.toJS(r.selectedRoom()))),f;u.boardType=i.boardType;u.ratePlanId=r.selectedRateplan();f=t.constructSelectedRoom(u);f.rateplans=r.selectedRoomRateplans();t.activeRooms.replace(t.activeRooms()[n-1],f)}),f=ko.utils.arrayFirst(t.reservation().rooms,function(t){return t.roomIndex===n}),u=ko.utils.arrayFilter(i,function(n){return t.reservationRoomIsAvailable(n)}),!u.length)?r:(r.rooms=u,r)};t.hasAvailabilty=function(n){var i=[],r;return ko.utils.arrayForEach(n,function(n){var r=!1;ko.utils.arrayForEach(n.roomResults(),function(n){t.reservationRoomIsAvailable(n)&&(r=!0)});i.push(r)}),r=ko.utils.arrayFirst(i,function(n){return!n}),r==null};t.selectRoom=function(){t.modifiedRoomsNotAvailable(!1);t.pushToSelectedRooms(t.activeRooms()[t.activeRoomIndex()-1]);var n=t.activeTabIndex()+1,r=n+1,i=!1;if(ko.utils.arrayForEach(t.step2.request().hotelResults(),function(n){var t=ko.utils.arrayFilter(n.requestedRooms(),function(n){return r==n.roomIndex()});t.length>0&&(i=!0)}),i)return t.activeTabIndex(n),t.activeRoomIndex(t.activeRoomIndex()+1),!0;t.modifiedRoomsAreAvailable()&&t.step2Submit();t.modifiedRoomsNotAvailable(!0)};t.pushToSelectedRooms=function(n){var i=t.constructSelectedRoom(n);t.step2.selectedRooms.push(i)};t.constructSelectedRoom=function(n){var i=new IBE.Models.SelectedRoom,f,e,r,u;return i.roomIndex(ko.unwrap(n.roomIndex)),i.roomId(ko.unwrap(n.roomId)),i.ratePlanId(ko.unwrap(n.ratePlanId)),i.boardType(ko.unwrap(n.boardType)),f=ko.utils.arrayFirst(t.step2.boards(),function(n){return n.boardType===i.boardType()}),i.board(f),i.availability(ko.unwrap(n.availability)),i.guestTypes=ko.observableArray([]),ko.utils.arrayForEach(t.step2.request().hotelResults(),function(t){ko.utils.arrayForEach(t.requestedRooms(),function(t){if(ko.unwrap(n.roomIndex)===ko.unwrap(t.roomIndex)){i.guestTypes(t.guests());return}})}),e=ko.utils.arrayFirst(ko.unwrap(n.rateplans),function(n){return ko.unwrap(n.ratePlanId)===i.ratePlanId()}),r=ko.utils.arrayFirst(ko.unwrap(e.roomBoards),function(n){return ko.unwrap(n.boardType)===i.boardType()}),typeof r!="undefined"&&r!=null&&(i.cost(ko.unwrap(r.price)),i.costWithoutDiscount(ko.unwrap(r.priceWithoutDiscount))),i.roomInfo=ko.observable(),u=t.step2.rooms.filterByProperty("id",ko.unwrap(n.roomId)),u().length>0&&i.roomInfo(u()[0]),i};t.reservationRoomIsAvailable=function(n){return n.availability>0&&n.availableRooms>0};t.step2Submit=function(){t.step2.selectedRooms().length<t.step1.requestedRooms().length&&ko.utils.arrayForEach(t.reservation().rooms,function(n){ko.utils.arrayForEach(t.step2.selectedRooms(),function(i){var r,f,u;n.roomIndex!==i.roomIndex()&&(r=new IBE.Models.SelectedRoom,r.roomIndex(n.roomIndex),r.roomId(n.id),r.ratePlanId(n.ratePlanId),r.boardType(n.board.type),f=ko.utils.arrayFirst(t.step2.boards(),function(n){return n.boardType===r.boardType()}),r.board(f),r.guestTypes=t.createGuestTypes(n),r.cost(n.totalCost),r.costWithoutDiscount(n.roomCostBeforeDiscount),r.roomInfo=ko.observable(),u=t.step2.rooms.filterByProperty("id",ko.unwrap(n.id)),u().length>0&&r.roomInfo(u()[0]),t.step2.selectedRooms.push(r))})});var n={};n.bookingInfo={checkIn:moment(t.step2.request().checkIn()).format("YYYY-MM-DD"),checkOut:moment(t.step2.request().checkOut()).format("YYYY-MM-DD"),rooms:t.step2.selectedRooms(),reservationId:t.reservation().id};r(n)};t.createGuestTypes=function(n){var t;if(!n)return[];var f=IBE.Data.HotelInfo[IBEConfig.hotelId].info.guestTypes,u=[],r=ko.utils.arrayFirst(f,function(n){return n.ageCategory===IBE.Config.guestType.Adult}),e=ko.utils.arrayFilter(f,function(n){return n.ageCategory===IBE.Config.guestType.Children}),i=ko.utils.arrayFirst(f,function(n){return n.ageCategory===IBE.Config.guestType.Infant});return IBE.Config.guestType.Adult&&(t=new IBE.Models.RequestedRoomGuestType,t.pax(n.adults||0),t.ageCategory(r.ageCategory),t.fromAge(r.fromAge),t.toAge(r.toAge),t.minValue(r.min),t.maxValue(r.max),u.push(t)),IBE.Config.guestType.Children&&e&&ko.utils.arrayForEach(e,function(t){var i=new IBE.Models.RequestedRoomGuestType;i.ageCategory(IBE.Config.guestType.Children);i.fromAge(t.fromAge);i.toAge(t.toAge);i.minValue(t.min);i.maxValue(t.max);i.pax(0);n.childrenAges&&t.fromAge<=n.childrenAges[0]&&t.toAge>=n.childrenAges[0]&&i.pax(n.children);u.push(i)}),IBE.Config.guestType.Infant&&i&&(t=new IBE.Models.RequestedRoomGuestType,t.pax(n.infants||0),t.ageCategory(i.ageCategory),t.fromAge(i.fromAge),t.toAge(i.toAge),t.minValue(i.min),t.maxValue(i.max),u.push(t)),u};t.getPaymentRulesText=function(n,i,r,u){var f=[],h;if(n.length===0)return f;var e=0,s=moment().startOf("day"),o=ko.unwrap(i);if(ko.utils.arrayForEach(n,function(n){var i=ko.toJS(n);i.amountCurrency=t.getRateText(i.amount,t.currency());f.push(i);o-=n.amount}),o>0){for(e=f.length-1,f[e].paymentDate===r.format("YYYY-MM-DD")||f[e].paymentDate===u.format("YYYY-MM-DD")?(f[e].amount+=o,f[e].amountCurrency=t.getRateText(f[e].amount,t.currency())):f.push({text:"",amount:o,paymentDate:r.format("YYYY-MM-DD"),amountCurrency:t.getRateText(o,t.currency())}),h=!1,e=0;e<f.length-1;e++)if(s.diff(f[e].paymentDate,"days")===0){h=!0;break}h||f.unshift({paymentDate:s.format("YYYY-MM-DD"),amount:0,amountCurrency:t.getRateText(0,t.currency()),text:IBE.Utils.translate("noAdvancePayment")})}return ko.utils.arrayForEach(f,function(n){var t=moment(n.paymentDate),i=n.amount;if(s.diff(t,"days")===0){n.text=i>0?IBE.Utils.translate("paymentRuleAdvancePayment").format(n.amountCurrency):IBE.Utils.translate("noAdvancePayment");return}if(r.diff(t,"days")===0&&n.amount>0){n.text=IBE.Utils.translate("paymentRulePayUponCheckIn").format(n.amountCurrency);return}if(u.diff(t,"days")===0&&n.amount>0){n.text=IBE.Utils.translate("paymentRulePayUponCheckOut").format(n.amountCurrency);return}if(i>0){n.text=IBE.Utils.translate("paymentRulePayOnDate").format(n.amountCurrency,moment(t).format("DD/MM/YYYY"));return}}),f};t.getRoomsForChangeDates=function(n,i){var r=ko.utils.arrayFirst(n,function(n){return n.roomId()===i.id});return r!=null&&ko.utils.arrayForEach(r.rateplans(),function(n){n.ratePlanId()===i.ratePlanId&&r.ratePlanId(i.ratePlanId)}),r==null,r&&!t.activeRooms()[i.roomIndex-1]&&t.activeRooms.push(r),r};t.modifiedRoomsAreAvailable=function(){var i=!0,n={};return t.activeRooms().map(function(n){return n.roomId()}).forEach(function(t){n[t]=(n[t]||0)+1}),t.step2.request().hotelResults()[0].requestedRooms()[0].roomResults().map(function(n){return{roomId:n.roomId(),availableRooms:n.availableRooms}}).forEach(function(t){n[t.roomId]&&(i&=n[t.roomId]<=t.availableRooms)}),i}};IBE.ViewModels.modifyStep3ViewModel=function(n){function r(n){t.modifyProcess.id=n.id;t.modifyProcess.baseCurrency=n.currency;t.modifyProcess.checkIn=moment.utc(n.checkIn);t.modifyProcess.checkOut=moment.utc(n.checkOut);t.modifyProcess.advancePayment=n.advancePayment;t.modifyProcess.cancellationPolicy=n.cancellationPolicy;t.modifyProcess.paymentPolicy=n.paymentPolicy;t.modifyProcess.paymentPolicyHotelTextOption=n.paymentPolicyHotelTextOption;t.modifyProcess.payments=n.payments;t.modifyProcess.cost=ko.observable(n.totalAmount);t.modifyProcess.costWithoutDiscount=ko.observable(n.totalAmountBeforeDiscount);t.modifyProcess.lang=t.lang;IBE.Data.modifyProcess=t.modifyProcess}var t=this,i;t.events=new ko.subscribable;t.ready=ko.observable(!1);ko.utils.extend(t,new IBE.ViewModels.LanguagePartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Message);ko.utils.extend(t,new IBE.ViewModels.PartialMemberViewModel(t));t.modifyProcess=ko.observable();t.hotelInfo=ko.observable();t.allowSubmit=ko.observable(!0);t.termsVisible=ko.observable(!0);i=[];t.dispose=function(){for(var n in i)i[n].dispose()};t.countries=ko.observableArray([]);t.makeReservation=function(){var n;return n={},n.checkIn=t.modifyProcess.checkIn,n.checkOut=t.modifyProcess.checkOut,n.customer=[],n.rooms=ko.utils.arrayMap(t.modifyProcess.rooms,function(n){return{boardType:n.boardType,ratePlanId:n.ratePlanId,roomIndex:n.roomIndex,roomId:n.roomId,guestTypes:n.guestTypes}}),n.cost=t.modifyProcess.cost(),n.advancePayment=t.modifyProcess.advancePayment,t.events.notifySubscribers(n,"submit"),!1};t.init=function(u,f){var e=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},f);$.when(t.languagePartialInit(e),t.currenciesPartialInit(e),t.customerAuthenticate()).then(function(){IBE.Data.Step3InitData=u;i.push(t.lang.subscribe(function(){t.init(IBE.Data.Step3InitData)}));var f=function(n){n&&t.hotelInfo(new IBE.Models.HotelInfo(n.info))};$.when(IBE.Utils.loadHotelInfo(f,e)).then(f);t.customer(new IBE.ViewModels.CustomerPartialViewModel(n));$.when(IBE.Utils.lookupCountry()).then(function(n){var i=ko.utils.arrayFirst(t.countries(),function(t){return t.code()===n});i!=null&&t.customer().country(i)});t.modifyProcess=u.bookingInfo;IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/BookingProcess/"+e.hotelId+"?apikey="+e.apiKey,data:ko.toJSON(t.modifyProcess),headers:{"Content-Type":"application/json"}}).done(function(n){if(t.clearMessage(),n===!1){t.ready(!0);t.events.notifySubscribers(!0,"ready");t.message({id:4001,severity:"error",text:"An error occured. Please try again"});t.events.notifySubscribers(t.message(),"error");return}r(n);t.ready(!0);t.events.notifySubscribers(!0,"ready")}).fail(function(n){t.ready(!0);t.clearMessage();var i={id:n.status,severity:"critical",text:n.statusText+": "+n.responseText};t.message(i);t.events.notifySubscribers(i,"error")})})}};IBE.ViewModels.ModifyStep4ViewModel=function(){function i(t){n.reservation(new IBE.Models.Reservation(t));n.membership.customer(n.reservation().customer);n.bookingProcess=IBE.Data.modifyProcess;n.ready(!0);n.events.notifySubscribers(!0,"ready")}function r(t){n.hotel(new IBE.Models.HotelInfo(t.info));n.reservationSettings=new IBE.Models.ReservationSettings(t.settings);n.googleMap(new IBE.Models.GoogleMap(t.info))}function u(t){function u(n){var t="Basic "+$.base64.encode(n.username+":"+n.password);return document.cookie="Authorization: "+t,t}function f(n){var r="Authorization=",i=document.cookie.indexOf(r),t;return i!==-1?(t=document.cookie.indexOf(";",i+1),t===-1&&(t=document.cookie.length),unescape(document.cookie.substring(i+r.length,t))):u(n)}var r=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n.options);IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/reservation/?apikey="+r.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",f(t));n.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")}}).done(function(t){n.clearMessage();i(t)}).fail(function(t){var i,r;n.ready(!0);n.clearMessage();i="critical";(t.status===400||t.status===500)&&(i="error");r={id:t.status,severity:i,text:t.responseJSON.Message};n.events.notifySubscribers(r,"error")})}function f(t){var r=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n.options);t.checkIn=moment(t.checkIn).format("YYYY-MM-DD");t.checkOut=moment(t.checkOut).format("YYYY-MM-DD");IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/amendreservation/"+r.hotelId+"?apikey="+r.apiKey,data:ko.toJSON(t),headers:{"Content-Type":"application/json"}}).done(function(t){if(n.clearMessage(),t.error){var r={id:t.statusCode(),severity:"error",text:t.responseJSON.message};n.message(r);n.events.notifySubscribers(r,"error");throw r;}i(t)}).fail(function(t){var i,r;n.ready(!0);n.clearMessage();i="critical";(t.status==400||t.status==500)&&(i="error");r={id:t.status,severity:i,text:t.responseJSON.message};n.events.notifySubscribers(r,"error")})}var n=this,t;n.options={};n.events=new ko.subscribable;n.reservation=ko.observable();n.modifyProcess=ko.observable();n.hotel=ko.observable();n.googleMap=ko.observable();n.ready=ko.observable(!1);n.customer=ko.observable();n.membership=new IBE.ViewModels.Membership;ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.ecommerce=ko.observable(!1);n.adWordsSent=ko.observable(!1);n.trackAdWords=function(){var i,t;if(!n.adWordsSent()){if(google_conversion_id=IBE.Utils.getReservationSetting(n,"adwordsConversionId"),IBE.Config.reservationStatus[n.reservation().status()]===3?(i=IBE.Utils.getReservationSetting(n,"adwordsRequestLabel"),i!==""&&(google_conversion_label=i)):google_conversion_label=IBE.Utils.getReservationSetting(n,"adwordsConversionLabel"),google_conversion_value=ko.unwrap(n.reservation().totalCost),google_remarketing_only=!1,google_conversion_id===0||google_conversion_id===""){console.log("IBE: google_conversion_id is not valid");return}n.options.appendAdwordsImage&&(t=document.createElement("img"),t.height=1,t.width=1,t.border=0,t.src="//www.googleadservices.com/pagead/conversion/"+google_conversion_id+"/?value="+ko.unwrap(n.reservation().totalCost)+"&amp;currency_code="+n.currency()+"&amp;label="+google_conversion_label+"&amp;guid=ON&amp;script=0",$("body").append(t));n.options.trackAdwordsAsync&&typeof google_trackConversion!="undefined"&&window.google_trackConversion({google_conversion_id:google_conversion_id,google_conversion_language:"en",google_conversion_format:"3",google_conversion_color:"ffffff",google_conversion_label:google_conversion_label,google_conversion_value:google_conversion_value,google_conversion_currency:n.currency(),google_remarketing_only:!1});n.adWordsSent(!0)}};n.trackTrivagoConversion=function(){var t=Cache.read("ref","localstorage"),u,i,r,f,e;if((t==="Trivago"||t==="trivago"||t&&t.name&&(t.name==="Trivago"||t.name==="trivago"))&&IBE.Config.userCookieAcceptance===!0){if(u=IBE.Utils.getReservationSetting(n,"trivagoTrackingId"),typeof u=="undefined")return;i=IBE.Utils.getReservationSetting(n,"trivagoConversionKey");r=IBE.Utils.getReservationSetting(n,"trivagoSupplierId");t&&t.params&&t.params.trv_reference&&r&&i&&(f=t.params.trv_reference,e={trv_reference:f,advertiser_id:r,hotel:n.reservation().hotelId,arrival:n.reservation().checkIn.format("YYYY-MM-DD"),departure:n.reservation().checkOut.format("YYYY-MM-DD"),volume:n.reservation().totalCost(),booking_id:n.reservation().id,currency:n.reservation().currencyCode,date_format:"Y-m-d",booking_date:moment(n.reservation().created).format("YYYYMMDD-HHmmss"),booking_date_format:"Ymd-His"},IBE.Utils.request({type:"POST",url:"https://secde.trivago.com/tracking/booking",data:JSON.stringify(e),dataType:"json",headers:{"Content-Type":"application/json","X-Trv-Ana-Key":i}}).done(function(){}).fail(function(){}))}};n.trackEcommerce=function(){var i,r,t;if(!n.ecommerce()&&typeof ga!="undefined"){ga("ecommerce:addTransaction",{id:""+n.reservation().id,affiliation:n.reservation().hotelName,revenue:""+ko.unwrap(n.reservation().totalCost),shipping:"0",tax:"0"});i=1;ko.utils.arrayForEach(n.reservation().rooms,function(t){var r=ko.unwrap(t);ga("ecommerce:addItem",{id:""+n.reservation().id,name:r.name+" "+r.board.name,sku:"#"+i+"-"+r.id+" -- "+n.reservation().status(),category:"Rooms",price:r.totalCost,quantity:"1",currency:n.currency()});i+=1});ko.utils.arrayForEach(n.reservation().supplements,function(t){var i=ko.unwrap(t);ga("ecommerce:addItem",{id:""+n.reservation().id,name:i.name,sku:i.supplementId()+" -- "+n.reservation().status(),category:"Supplements",price:i.unitCost(),quantity:i.quantity(),currency:n.currency()})});ga("ecommerce:send");r=[];ko.utils.arrayForEach(n.reservation().rooms,function(t){var u=ko.unwrap(t);r.push({id:""+n.reservation().id,name:u.name+" "+u.board.name,category:"Rooms",quantity:"1",price:u.totalCost});i+=1});ko.utils.arrayForEach(n.reservation().supplements,function(t){var i=ko.unwrap(t);r.push({id:""+n.reservation().id,name:i.name,category:"Supplements",quantity:i.quantity(),price:i.unitCost()})});var u=IBE.Utils.getReservationSetting(n,"adwordsConversionId"),f="",e=IBE.Utils.getReservationSetting(n,"globalAdwordsConversionId"),o=IBE.Utils.getReservationSetting(n,"globalAdwordsConversionLabel"),s=IBE.Utils.getReservationSetting(n,"googleConversionTrackingPartnerId");u&&typeof gtag!="undefined"&&IBE.Config.userCookieAcceptance===!0||(u="");IBE.Config.reservationStatus[n.reservation().status()]===3?f=IBE.Utils.getReservationSetting(n,"adwordsRequestLabel"):IBE.Config.reservationStatus[n.reservation().status()]===1&&(f=IBE.Utils.getReservationSetting(n,"adwordsConversionLabel"));t=[];u&&f&&t.push("AW-"+u+"/"+f);e&&o&&t.push("AW-"+e+"/"+o);s&&t.push("HA-"+s);gtag("event","purchase",{send_to:t.length>0?t:undefined,transaction_id:n.reservation().id,affiliation:n.reservation().hotelName,value:ko.unwrap(n.reservation().totalCost),currency:n.currency(),items:r,checkout_step:4,id:n.reservation().hotelId,start_date:n.reservation().checkIn.format("YYYY-MM-DD"),end_date:n.reservation().checkOut.format("YYYY-MM-DD")});n.ecommerce(!0)}};n.trackBingCode=function(){if(IBE.Config.debug){console.log("IBE: In debug mode bing is disabled");return}window.uetq&&window.uetq.push({ec:"Booking",ea:ko.unwrap(n.reservation().status),el:"",ev:""+ko.unwrap(n.reservation().totalCost)})};n.updateReservation=function(){var t={id:n.reservation().id,newStatus:n.reservation().status(),supplements:_bookingSupplements(),creditCard:{},cancellationNotes:n.reservation().cancellationNotes()};n.clearMessage();IBE.Utils.request({type:"POST",data:ko.toJSON(t),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.reservation().customer.email(),n.reservation().code))}}).done(function(){}).fail(function(t){var i={id:t.status,severity:"critical",text:t.statusText+": "+t.responseText};n.message(i)})};n.init=function(t,i){n.options=ko.utils.extend({trackAdwords:!0,trackAdwordsAsync:!0,appendAdwordsImage:!0,reservationSubmitted:!1,apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},i);$.when(n.languagePartialInit(n.options),n.currenciesPartialInit()).then(function(){n.options.reservationSubmitted=!1;var i=function(n){n&&(r(n),typeof t.username!="undefined"&&typeof t.password!="undefined"?u(t):f(t))};$.when(IBE.Utils.loadHotelInfo(i,n.options)).then(i)})}};IBE.ViewModels.MyReservation=function(n){function r(n){t.hotel(new IBE.Models.HotelInfo(n.info));t.reservationSettings=new IBE.Models.ReservationSettings(n.settings);t.googleMap(new IBE.Models.GoogleMap(n.info))}function u(n){t.countries.removeAll();ko.utils.arrayPushAll(t.countries,ko.utils.arrayMap(n,function(n){return new IBE.Models.Country(n)}))}function f(n){typeof n.info.acceptedCards!="undefined"&&t.acceptedCards(n.info.acceptedCards.split(", "))}var t=this,i;t.events=new ko.subscribable;t.ready=ko.observable(!1);ko.utils.extend(t,new IBE.ViewModels.LanguagePartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Message);t.genders=[{name:"",value:IBE.Config.gender.Unknown},{name:"male",value:IBE.Config.gender.Male},{name:"female",value:IBE.Config.gender.Female},];t.idDocumentTypes=[{name:"",value:IBE.Config.idDocumentType.Unknown},{name:"identityCard",value:IBE.Config.idDocumentType.IidentityCard},{name:"passport",value:IBE.Config.idDocumentType.Passport},{name:"drivingLicense",value:IBE.Config.idDocumentType.DrivingLicense}];t.titles=[{name:"",value:IBE.Config.titles.Unknown},{name:"mr",value:IBE.Config.titles.Mr},{name:"mrs",value:IBE.Config.titles.Mrs},{name:"miss",value:IBE.Config.titles.Miss},{name:"ms",value:IBE.Config.titles.Ms},{name:"dr",value:IBE.Config.titles.Dr},];t.username=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredUsername")}});t.password=ko.observable("").extend({required:{message:IBE.Utils.translate("requiredPassword")}});t.cancelCode=ko.observable("");t.reservation=ko.observable();t.customer=ko.observable();t.acceptedCards=ko.observableArray([]);t.hotel=ko.observable();t.googleMap=ko.observable();t.countries=ko.observableArray([]);t.terms=ko.observable();t.consents=ko.observableArray([]);t.customerConsents=ko.observableArray([]);t.guests=ko.observableArray([]);t.isWebCheckedIn=ko.observable(!1);t.errors=ko.validation.group(t);i=[];t.dispose=function(){for(var n=0;n<i.length;n++)i[n].dispose()};t.customerConsents=ko.computed({read:function(){return ko.utils.arrayForEach(t.consents(),function(n){var i=ko.utils.arrayFirst(t.reservation().customer.consents(),function(t){return n.id===t.id});i&&n.value(!0)}),t.consents()},write:function(){return t.consents([])},deferEvaluation:!0});typeof n!="undefined"&&n.email!==""&&n.code!==""&&(t.username(n.email),t.password(n.code));t.isAuthenticated=ko.observable(!1);t.options={};t.reservationAction=ko.observable("view");t.login=function(n){if(t.options=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n),t.ready(!1),t.clearMessage(),t.errors().length>0&&IBE.Utils.haveAuthenticationCookie()===!1)return t.errors.showAllMessages(),t.events.notifySubscribers({id:401,severity:"error",text:"Wrong email or reservation code."},"error"),t.ready(!0),!1;IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/reservation/?apikey="+IBE.Config.apiKey,beforeSend:function(n){t.username()!==""&&t.password()!==""&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(t.username(),t.password()))}}).done(function(n){var i,r;(t.reservation(new IBE.Models.Reservation(n)),t.reservation().taxes(n.taxes||[]),t.customer(new IBE.ViewModels.CustomerPartialViewModel),t.isWebCheckedIn(t.reservation().webCheckIn()),ko.utils.arrayForEach(t.reservation().rooms,function(n){for(var i=0;i<n.adults;i++)n.guestType=IBE.Config.guestType.Adult,t.guests.push(new IBE.Models.ReservationGuest(n));for(i=0;i<n.children;i++)n.guestType=IBE.Config.guestType.Children,t.guests.push(new IBE.Models.ReservationGuest(n));for(i=0;i<n.infants;i++)n.guestType=IBE.Config.guestType.Infant,t.guests.push(new IBE.Models.ReservationGuest(n))}),t.hotel().hotelId)&&(IBE.Data.HotelInfo[t.hotel().hotelId].info.consents&&(i=IBE.Data.HotelInfo[t.hotel().hotelId].info.consents,ko.utils.arrayForEach(i,function(n){t.consents.push(new IBE.Models.Consents(n))})),n.customer.consents&&ko.utils.arrayForEach(n.customer.consents,function(n){t.reservation().customer.consents.push(new IBE.Models.Consents(n))}),IBE.Data.HotelInfo[t.hotel().hotelId].info.termsAndPrivacy&&(r=IBE.Data.HotelInfo[t.hotel().hotelId].info.termsAndPrivacy,t.terms=new IBE.Models.Terms(r)),$.when(IBE.Utils.loadCountries()).then(function(n){u(n);var i=ko.utils.arrayFilter(t.countries(),function(n){return t.reservation().customer.country()==n.code()})[0];i.name&&(t.reservation().customer.countryName=i.name());t.clearMessage();t.events.notifySubscribers({email:t.username(),code:t.password()},"login");t.events.notifySubscribers(!0,"ready");t.ready(!0);t.isAuthenticated(!0);window.location.href.indexOf("#reservation")>-1&&$("#IBE-MyReservation-ViewReservation").length!=0?t.setView("reservation"):$("#IBE-MyReservation-Welcome").length!=0&&t.setView("welcome")}))}).fail(function(n){if(t.events.notifySubscribers(!0,"ready"),IBE.Utils.haveAuthenticationCookie()&&t.username()===""){t.isAuthenticated(!1);IBE.Utils.deleteAuthenticationCookie();return}var i={id:n.status,severity:"error",text:n.responseText};i.text=n.status===401?"Wrong email or reservation code.":"An error occurred.";t.isAuthenticated(!1);IBE.Utils.deleteAuthenticationCookie();t.events.notifySubscribers(i,"error")})};t.logout=function(){t.username("");t.password("");IBE.Utils.deleteAuthenticationCookie();t.clearMessage();t.isAuthenticated(!1);t.customerConsents([]);t.errors.showAllMessages(!1);t.ready(!0);t.events.notifySubscribers(!0,"logout")};t.displayExternalPayment=ko.observable(!1);t.init=function(){$.when(t.languagePartialInit(),t.currenciesPartialInit()).then(function(n){t.dispose();i.push(t.lang.subscribe(function(){t.init()}));t.ready(!1);t.clearMessage();r(n);f(n);IBE.Utils.haveAuthenticationCookie()?t.login():t.username()===""||t.password()===""?(t.isAuthenticated(!1),t.ready(!0),t.events.notifySubscribers(!0,"ready")):t.login()})};t.setReservationAction=function(n){t.reservationAction(n)};t.customerEdit=ko.observable(!1);t.startEdit=function(){t.customerEdit(!0)};t.cancelEdit=function(){t.customerEdit(!1)};t.setView=function(n){switch(n){case"welcome":IBE.Utils.destroyView("IBE-MyReservation-Account");IBE.Utils.destroyView("IBE-MyReservation-ViewReservation");IBE.Utils.bindTemplate("IBE-MyReservation-Welcome",t);$(".bookwize-nav").removeClass("active");$(".nav-"+n).addClass("active");break;case"account":IBE.Utils.destroyView("IBE-MyReservation-Welcome");IBE.Utils.destroyView("IBE-MyReservation-ViewReservation");IBE.Utils.bindTemplate("IBE-MyReservation-Account",t);$(".bookwize-nav").removeClass("active");$(".nav-"+n).addClass("active");$("#request-personal-data").click(function(){t.customerDataRequest("Export")});$("#delete-personal-data").click(function(){t.customerDataRequest("Delete")});break;case"reservation":IBE.Utils.destroyView("IBE-MyReservation-Account");IBE.Utils.destroyView("IBE-MyReservation-Welcome");IBE.Utils.bindTemplate("IBE-MyReservation-ViewReservation",t);$(".bookwize-nav").removeClass("active");$(".nav-"+n).addClass("active");break;default:t.ready(!0)}};t.customerDataRequest=function(n){var i={hotelId:IBE.Config.hotelId,requestType:n};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/personalDataRequest/?apikey="+IBE.Config.apiKey,data:ko.toJSON(i),beforeSend:function(n){IBE.Utils.haveAuthenticationCookie()&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())},success:function(){var n={id:200,severity:"success",text:IBE.Utils.translate("customerDataRequestSuccess")};t.message(n);t.customerEdit(!1);t.ready(!0)},error:function(n){t.events.notifySubscribers(!0,"ready");var i={id:n.status,severity:"error",text:n.responseText};i.text=n.text;t.message(i);t.events.notifySubscribers(i,"error");t.ready(!0)},complete:function(){t.ready(!0)}})};t.showUpdateCreditCard=function(n){var i,r,u;return!n&&typeof n!="undefined"?!1:(i=moment(),r=moment(t.reservation().checkOut),i.diff(r,"days")>=0)?!1:(u=ko.utils.arrayFirst(t.reservation().availableActions(),function(n){return n==="ConfirmedReservation"}),u)?!1:t.reservation().status()==="NewRequest"||t.reservation().status()==="CancelledReservation"||t.reservation().status()==="CancelledReservationPaymentExpired"?!1:!0};t.confirmAction=function(n,i){var f={id:t.reservation().id,newStatus:n,creditCard:{},cancellationNotes:t.reservation().cancellationNotes(),notes:t.reservation().notes()},r=!1,e,u;switch(n){case"CancelledReservation":case"CancelledRequest":t.cancelCode()!=t.reservation().code&&(e={id:5001,severity:"error",text:IBE.Utils.translate("wrongReservationCode")},t.message(e),t.events.notifySubscribers(e,"error"),r=!0);break;case"ConfirmedReservation":if(t.displayExternalPayment()){f.creditCard=null;break}t.customer().errors().creditCard().length>0&&(r=!0,t.events.notifySubscribers("","error"),t.customer().errors().creditCard().length==1&&t.customer().errors().creditCard()[0]==null?r=!1:t.customer().errors().creditCard.showAllMessages());u=t.customer().creditCard().cardExpirationYear()+"";u=u.substring(2);f.creditCard={holder:t.customer().creditCard().cardHolder(),expireYear:u,expireMonth:t.customer().creditCard().cardExpirationMonth(),number:t.customer().creditCard().cardNumber(),verification:t.customer().creditCard().cardVerification()}}if(r)return!1;t.clearMessage();IBE.Utils.request({type:"POST",data:ko.toJSON(f),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(t.username(),t.password()))}}).done(function(r){if(t.cancelCode(""),t.reservation(new IBE.Models.Reservation(r)),t.customer(new IBE.ViewModels.CustomerPartialViewModel),t.events.notifySubscribers(!0,n),(n=="CancelledReservation"||n=="CancelledRequest")&&t.trackTrivagoConversion(),t.events.notifySubscribers(!0,n),i==="UpdateCreditCard"){var u={id:200,severity:"success",text:IBE.Utils.translate("creditCardUpdated")};t.message(u)}}).fail(function(){var n={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};t.message(n);t.events.notifySubscribers(n,"error")})};t.webCheckIn=function(){var n={code:t.reservation().code,guests:t.guests()};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/reservation/checkin/?apikey="+IBE.Config.apiKey,data:ko.toJSON(n),beforeSend:function(n){t.username()!==""&&t.password()!==""&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(t.username(),t.password()));t.ready(!1)},success:function(n){var i={id:200,severity:"success",text:IBE.Utils.translate("webCheckInSave")};t.isWebCheckedIn(n.webCheckIn);t.message(i)},error:function(n){t.events.notifySubscribers(!0,"ready");var i={id:n.status,severity:"error",text:n.responseText};i.text=n.text;t.message(i);t.events.notifySubscribers(i,"error")},complete:function(){t.ready(!0)}})};t.updateCustomer=function(){var i=ko.utils.arrayFilter(t.customerConsents(),function(n){return n.value()}),n;t.reservation().customer.consents(i);n=t.reservation().customer.toJSON();$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/members/member/?apikey="+IBE.Config.apiKey+"&hotelId="+IBE.Config.hotelId,data:n,beforeSend:function(n){IBE.Utils.haveAuthenticationCookie()&&n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie());t.ready(!1)},success:function(){var n={id:200,severity:"success",text:IBE.Utils.translate("customerEditSuccess")};t.message(n);t.ready(!0);t.setView("account");t.customerEdit(!1)},error:function(n){t.events.notifySubscribers(!0,"ready");var i={id:n.status,severity:"error",text:n.responseText};t.ready(!0);i.text=n.text;t.message(i);t.events.notifySubscribers(i,"error")},complete:function(){t.ready(!0)}})};t.trackTrivagoConversion=function(){var n=Cache.read("ref","localstorage"),u,i,r,f,e;if((n==="Trivago"||n==="trivago"||n&&n.name&&(n.name==="Trivago"||n.name==="trivago"))&&IBE.Config.userCookieAcceptance===!0){if(u=IBE.Utils.getReservationSetting(t,"trivagoTrackingId"),typeof u=="undefined")return;i=IBE.Utils.getReservationSetting(t,"trivagoConversionKey");r=IBE.Utils.getReservationSetting(t,"trivagoSupplierId");n&&n.params&&n.params.trv_reference&&r&&i&&(f=n.params.trv_reference,e={trv_reference:f,advertiser_id:r,hotel:t.reservation().hotelId,arrival:t.reservation().checkIn.format("YYYY-MM-DD"),departure:t.reservation().checkOut.format("YYYY-MM-DD"),volume:t.reservation().totalCost(),booking_id:t.reservation().id,currency:t.reservation().currencyCode,date_format:"Y-m-d",booking_date:moment(t.reservation().created).format("YYYYMMDD-HHmmss"),booking_date_format:"Ymd-His"},IBE.Utils.request({type:"DELETE",url:"https://secde.trivago.com/tracking/booking",data:JSON.stringify(e),dataType:"json",headers:{"Content-Type":"application/json","X-Trv-Ana-Key":i}}).done(function(){}).fail(function(){}))}}};IBE.ViewModels.PopUpPartialViewModel=function(n){function i(){var n=t.roomId(),f=ko.utils.arrayFilter(t.request().hotelResults(),function(n){return n.hotelId()===t.hotelId()})[0],e=ko.utils.arrayFilter(f.requestedRooms(),function(n){return n.roomIndex()===t.roomIndex()})[0],i=ko.utils.arrayFilter(e.roomResults(),function(n){return n.roomIndex()===t.roomIndex()&&n.roomId()===t.roomId()})[0],u,r;n!==0&&(u=[IBE.Config.apiBaseUrl,"/hotels/availability/",IBE.Config.hotelId,"/",n,"/?apikey=",IBE.Config.apiKey].join(""),r=["RoomAvailability_",t.hotelId(),"_",n,"_",MD5([t.bookingProcess().checkIn(),"_",t.bookingProcess().checkOut()].join(""))].join(""),IBE.Data.RoomAvailability[n]?(i.availability=IBE.Data.RoomAvailability[n],t.data(i)):Cache.read(r)!==!1?(IBE.Data.RoomAvailability[n]=Cache.read(r),i.availability=IBE.Data.RoomAvailability[n],t.data(i)):IBE.Utils.request({url:u}).done(function(u){IBE.Data.RoomAvailability[n]=u;Cache.write(r,IBE.Data.RoomAvailability[n]);i.availability=IBE.Data.RoomAvailability[n];t.data(i)}))}var t=this;ko.utils.extend(t,n);t.roomIndex=ko.observable(1);t.roomId=ko.observable(0);t.ratePlanId=ko.observable(0);t.toggle=function(n,r){t.roomIndex(ko.unwrap(n.roomIndex));t.roomId(n.roomId());t.ratePlanId(n.ratePlanId());i();switch(r){case"availability":case"rateplan":t.activeMenu(r);break;default:t.activeMenu("info")}};t.activeMenu=ko.observable("info");t.selectMenu=ko.computed({write:function(n){t.activeMenu(n)},read:function(){return t.activeMenu()},deferEvaluation:!0});t.data=ko.observable(!1);t.hasFloorplan=ko.computed({read:function(){var i="floorplan",n;return t.data()===!1?!1:t.data().info().photos.length===0||typeof t.data().info().photos=="undefined"?!1:(n=ko.utils.arrayFilter(t.data().info().photos,function(n){return n.type.toLowerCase().indexOf(i)!==-1}),n.length>0?!0:!1)},deferEvaluation:!0})};IBE.ViewModels.Reservation=function(n){var t=this;ko.utils.extend(t,new IBE.ViewModels.Message);ko.utils.extend(t,new IBE.ViewModels.Taxes(t));t.events=new ko.subscribable;t.reservation=ko.observable(n);t.reservationAction=ko.observable("");t.ready=ko.observable(!1);t.creditCard=ko.observable();t.errors=ko.observable({creditCard:ko.validation.group(t.creditCard)});t.setReservationAction=function(n){t.reservationAction(n)};t.save=function(){var n={id:t.reservation().id,code:t.reservation().code,newStatus:t.reservation().status,notes:t.reservation().notes(),cancellactionNotes:t.reservation().cancellactionNotes()};IBE.Utils.request({type:"POST",data:ko.toJSON(n),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())}}).done(function(n){var i=t.reservation().id,r={id:1e3,severity:"info",reservationId:i};t.reservation().refresh(n);t.events.notifySubscribers(r,"reservationinfo")}).fail(function(){var n={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};t.events.notifySubscribers(n,"error");t.message(n)})};t.webCheckIn=function(){var n={code:t.reservation().code,guests:t.reservation().guests()};$.ajax({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/reservation/checkin/?apikey="+IBE.Config.apiKey,data:ko.toJSON(n),beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie());t.ready(!1)},success:function(n){t.clearMessage();var i={id:200,severity:"success",text:IBE.Utils.translate("webCheckInSave")};t.reservation().webCheckIn(n.webCheckIn);t.reservation().webCheckInActive(n.webCheckInActive);t.message(i);t.events.notifySubscribers(i,"webcheckinSave")},error:function(n){t.clearMessage();t.events.notifySubscribers(!0,"ready");var i={id:n.status,severity:"error",text:JSON.parse(n.responseText)};t.message(i);t.events.notifySubscribers(i,"error")},complete:function(){t.ready(!0)}})};t.confirmReservationAction=function(n,i,r){var o={id:t.reservation().id,newStatus:n,creditCard:{},code:t.reservation().code,cancellationNotes:t.reservation().cancellationNotes()},u=!1,e,f;switch(n){case"CancelledReservation":case"CancelledRequest":i.code!=t.reservation().code&&(e={id:5001,severity:"error",text:IBE.Utils.translate("wrongReservationCode")},t.message(e),t.events.notifySubscribers(e,"error"),u=!0);break;case"ConfirmedReservation":t.errors().creditCard().length>0&&(u=!0,t.errors().creditCard().length===1&&t.errors().creditCard()[0]==null?u=!1:t.errors().creditCard.showAllMessages());f=r.cardExpirationYear()+"";f=f.substring(2);o.creditCard={holder:r.cardHolder(),expireYear:f,expireMonth:r.cardExpirationMonth(),number:r.cardNumber(),verification:r.cardVerification()}}if(u)return!1;IBE.Utils.request({type:"POST",data:ko.toJSON(o),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",IBE.Utils.authenticationCookie())}}).done(function(i){var r=t.reservation().id,u={id:1e3,severity:"info",text:n,reservationId:r};t.reservation().refresh(i);t.events.notifySubscribers(u,"reservationstatus")}).fail(function(){var n={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};t.events.notifySubscribers(n,"error");t.message(n)})}};IBE.ViewModels.ResponseViewModel=function(){var n=this;n.successTransaction=ko.observable(!1);n.reservationId=ko.observable("");n.authorizationNumber=ko.observable("");n.status=ko.observable("");n.myReservation=ko.observable(null);n.ready=ko.observable(!1);n.statusUpdated=!1;n.events=new ko.subscribable;n.mid=ko.observable("");n.paymentTotal=ko.observable("");n.message=ko.observable("");n.payMethod=ko.observable("");n.paymentRef=ko.observable("");n.orderAmount=ko.observable("");n.txId=ko.observable("");ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));n.status.subscribe(function(t){n.fetchReservation(t)});n.init=function(){$.when(n.languagePartialInit()).then(function(){n.status()===""?n.events.notifySubscribers(!0,"error"):n.events.notifySubscribers(!0,"ready")})};n.events.subscribe(function(){IBEStepsMain.setStep(1)},this,"error");n.events.subscribe(function(){n.ready(!0)},this,"ready");n.fetchReservation=function(){var t=Cache.read("authenticationKey"),r,i;if(t)t=atob(t);else{IBEStepsMain.setStep(1);$("#Header").show();return}r={email:t,code:n.reservationId()};i=new IBE.ViewModels.MyReservation(r);i.reservation.subscribe(function(){n.myReservation(i);n.setConfirmed()});i.init();Cache.clear()};n.setConfirmed=function(){n.statusUpdated||(n.status()==="CAPTURED"?n.confirmAction("ConfirmedReservation"):n.confirmAction("CancelledReservationPaymentExpired"),n.statusUpdated=!0)};n.beforeConfirmAction=function(t,i,r){typeof r=="undefined"&&(r=i);hp.disable($(r.currentTarget));n.confirmAction(t,r)};n.cancelCode=ko.observable("");n.confirmAction=function(t){var i=ko.utils.arrayFirst(n.myReservation().reservation().payments(),function(n){return moment().diff(n.dateToPay,"days")==0&&n.paymentType==="ExternalGateway"}),r="",f;i&&(r=i.id);var i={reservationId:n.myReservation().reservation().id,amount:n.paymentTotal(),transactionId:n.txId(),merchantId:n.mid(),notes:n.message(),transactionLog:" paymentTotal:"+n.paymentTotal()+" payMethod:"+n.payMethod()+" paymentRef:"+n.paymentRef()+" orderAmount:"+n.orderAmount()+" tcID:"+n.txId(),id:r},e={id:n.myReservation().reservation().id,newStatus:t,creditCard:[],cancellationNotes:n.myReservation().reservation().cancellationNotes(),notes:n.myReservation().reservation().notes(),payment:i},u=!1;switch(t){case"CancelledReservation":case"CancelledRequest":n.cancelCode()!=n.myReservation().reservation().code&&(f={id:5001,severity:"error",text:IBE.Utils.translate("wrongReservationCode")},n.events.notifySubscribers(f,"error"),u=!0)}if(u)return!1;IBE.Utils.request({type:"POST",data:ko.toJSON(e),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey}).done(function(i){n.cancelCode("");n.myReservation().reservation(new IBE.Models.Reservation(i));n.events.notifySubscribers(!0,t)}).fail(function(){var t={id:5002,severity:"error",text:IBE.Utils.translate("updateReservationFailed")};n.message(t);n.events.notifySubscribers(t,"error")})}};IBE.ViewModels.Step1ViewModel=function(){function r(t){var i=new IBE.Models.Hotel({info:new IBE.Models.HotelInfo(t.info),availability:t.availability,settings:t.settings,conditions:t.conditions,defaults:t.defaults,memberships:t.memberships,offers:ko.utils.arrayMap(t.offers,function(t){return new IBE.Models.Offer(t,n)})}),u=moment(),r;i.conditions.firstAvailableDate&&IBE.Utils.getReservationSetting(n,"displayNotAvailable")==0&&(u=moment(i.conditions.firstAvailableDate));i.conditions.minCheckInDate&&(r=moment(i.conditions.minCheckInDate),n.minCheckInDate(r),n.checkIn().diff(r,"days")<=0?n.checkIn(r):n.checkIn().diff(u,"days")<=0&&n.checkIn(u));i.conditions.maxStay>0?n.maxStay(i.conditions.maxStay):n.maxStay(IBE.Config.maxStay);IBE.Config.ibeEnforceMLOS&&n.minStay(parseInt(IBE.Config.minStay));n.maxStay(i.conditions.maxStay);i.settings.maxStay=n.maxStay();n.reservationSettings=new IBE.Models.ReservationSettings(t.settings);n.groupText=IBE.Config.groupText;n.couponExists(t.info.couponExists);n.maxRequestedRooms(i.conditions.maxRequestedRooms);n.boardTypes.removeAll();IBE.Config.ibeShowBoard||n.showBoard(!1);n.boardTypes(i.info.boardTypes);n.boardType(i.info.defaultBoardType());n.rooms=ko.observableArray(ko.utils.arrayMap(t.info.rooms,function(n){return new IBE.Models.RoomInfo(n)}));n.hotel(i);n.requestedRooms().length===0&&n.addRequestedRoom();Cache.read("ref","localstorage")&&n.referrer(new IBE.Models.Referrer(Cache.read("ref","localstorage")));n.ready(!0);n.events.notifySubscribers(!0,"ready")}function i(){var t=[];return ko.utils.arrayForEach(n.requestedRooms(),function(n){var i=[];ko.utils.arrayForEach(n.guests,function(n){i.push({ageCategory:n.ageCategory(),fromAge:n.fromAge(),pax:n.pax(),ages:n.ages()})});t.push(i)}),{checkIn:IBE.Utils.dateIsoFormat(n.checkIn()),checkOut:IBE.Utils.dateIsoFormat(n.checkOut()),rooms:t,couponCode:n.couponCode(),rateplan:n.rateplan,board:n.boardType(),referrer:n.referrer()}}var n=this,t;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.PartialMemberViewModel(n));t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.referrer=ko.observable(new IBE.Models.Referrer);n.allowSubmit=ko.observable(!0);n.rateplan=ko.observable(new IBE.Models.Offer({},n));n.hotel=ko.observable();n.boardTypes=ko.observableArray([]);n.boardType=ko.observable("");n.showBoard=ko.observable(!0);n.board=ko.computed({read:function(){if(!n.hotel())return{};var t=ko.utils.arrayFirst(n.hotel().info.boardTypes,function(t){return t.boardType===n.boardType()});return t==null&&(t=n.hotel().info.boardTypes[0]),t},deferEvaluation:!0});n.rooms=ko.observableArray([]);n.activeRoom=ko.observable(1);n.addGuest=function(t,i){if(t.pax()>t.options().length-1)return!1;if(n.hotel()){if(t.ageCategory()!==IBE.Config.guestType.Infant&&!i.canAddGuest(n.hotel().conditions.maxGuests))return!1;t.pax(t.pax()+1)}};n.addVisible=function(t){return n.hotel()?t.canAddGuest(n.hotel().conditions.maxGuests):{}};n.removeGuest=function(n){if(n.pax()===1&&n.ageCategory()===IBE.Config.guestType.Adult)return!1;n.pax()<=0||n.pax(n.pax()-1)};n.requestedRooms=ko.observableArray([]);n.maxRequestedRooms=ko.observable(1);n.totalGuests=ko.computed({read:function(){var t=0;return ko.utils.arrayForEach(n.requestedRooms(),function(n){ko.utils.arrayForEach(n.guests,function(n){var i=ko.utils.unwrapObservable(n.pax);isNaN(parseInt(i))||(t+=parseInt(i))})}),t},deferEvaluation:!0});n.totalGuestsNoInfants=ko.computed({read:function(){var t=0;return ko.utils.arrayForEach(n.requestedRooms(),function(n){ko.utils.arrayForEach(n.guests,function(n){if(n.ageCategory()!==IBE.Config.guestType.Infant){var i=ko.utils.unwrapObservable(n.pax);isNaN(parseInt(i))||(t+=parseInt(i))}})}),t},deferEvaluation:!0});n.minStay=ko.observable(1);n.maxStay=ko.observable(IBE.Config.maxStay);n.nightOptions=ko.computed({read:function(){for(var i=[],t=1;t<n.maxStay();t++)i.push(t);return i},deferEvaluation:!0});n.nights=ko.computed({write:function(t){var i=moment(n.checkIn());i.add(t,"days");n.checkOut(i)},read:function(){try{return n.checkOut().startOf("day").diff(n.checkIn().startOf("day"),"days")}catch(t){return IBE.Utils.logEvent({message:t.message,hotelId:0,severity:"error"}),1}},deferEvaluation:!0});n._checkIn=ko.observable(moment());n.checkIn=ko.pureComputed({write:function(t){n._checkIn().startOf("day").diff(moment(t).startOf("day"),"days")!==0&&n._checkIn(moment(t))},read:function(){return n._checkIn()}});n.checkIn.subscribe(function(t){var i=moment(t).add(1,"days");n.checkOut()-i<=0&&n.checkOut(i)});n.minCheckInDate=ko.observable(moment());n.maxCheckInDate=moment().add(2,"years");n.minCheckOutDate=ko.computed(function(){var t=moment(n.checkIn());return t.add(n.minStay(),"days"),t});n._checkOut=ko.observable(n.minCheckOutDate());n.checkOut=ko.computed({write:function(t){var i=n.minCheckOutDate(),r;typeof t=="undefined"?i=n.minCheckOutDate():(r=moment(t),r>n.minCheckOutDate()?(i=r,n._checkOut(r)):(i=n.minCheckOutDate(),n._checkOut(n.minCheckOutDate())));n._checkOut().diff(i,"days")!==0&&n._checkOut(i)},read:function(){return n._checkOut()},deferEvaluation:!0});n.dateRange=ko.observable([moment().subtract(1,"days"),moment(),"day"]);n.couponCode=ko.observable("");n.couponValid=ko.observable(!0);n.couponExists=ko.observable(!1);n.bookingProcess=ko.observable(new IBE.Models.BookingProcess({checkIn:n.checkIn,checkOut:n.checkOut,couponCode:n.couponCode,reservationStatus:"Unknown",lang:n.lang,currency:n.currency()}));n.setBoardType=function(t){n.boardType(t.boardType)};n.setRateplan=function(t){IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/offer/"+IBE.Config.hotelId+"/"+t+"?apikey="+IBE.Config.apiKey}).done(function(t){t!==!1&&(n.rateplan(new IBE.Models.Offer(t,n)),n.events.notifySubscribers(!0,"ready"))}).fail(function(){throw{id:"1001",severity:"error",text:"An error occurred"};})};n.canAddRequestedRoom=function(){if(n.hotel())return n.requestedRooms().length<=n.hotel().conditions.maxRequestedRooms-1};n.addRequestedRoom=function(){if(!n.canAddRequestedRoom())return!1;var i=n.requestedRooms().length+1,t=new IBE.Models.RequestedRoom(i);return t.guests=ko.utils.arrayMap(n.hotel().info.guestTypes,function(t){var i=new IBE.Models.RequestedRoomGuestType(t);return t.ageCategory===IBE.Config.guestType.Adult&&i.pax(n.hotel().conditions.defaultAdults),i}),n.requestedRooms.push(t),!0};n.removeRequestedRoom=function(t,i){if(n.requestedRooms().length>1)n.requestedRooms.remove(t);else return!1;if(typeof i!="undefined")try{i.cancelBubble=!0;i.stopImmediatePropagation()}catch(i){}for(var r=0;r<n.requestedRooms().length;r++)n.requestedRooms()[r].roomIndex(r+1);return!0};n.getHotelSettings=function(t){var i="";return $.each(n.hotel().settings,function(n,r){r.Key===t&&(i=r.Value)}),i};n.isDateActive=function(t){var i=IBE.Utils.dateIsoFormat(t);return n.hotel().availability.hasOwnProperty(i)?n.hotel().availability[i]>0:!1};n.isValidCoupon=function(){var t=$.Deferred();return(n.couponCode(n.couponCode().trim()),n.couponCode().length===0)?(n.couponValid(!0),t.resolve(!0),t.promise()):(IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/validateCoupon/"+IBE.Config.hotelId+"/"+encodeURI(n.couponCode())+"?apikey="+IBE.Config.apiKey}).done(function(i){var r=!1;i===!1?(n.message({id:3001,severity:"warning",text:"Coupon is not valid"}),n.couponCode(""),r=!1):r=!0;n.couponValid(r);t.resolve(r)}).fail(function(){n.message({id:"1001",severity:"error",text:"Failed to validate the coupon"});n.couponValid(!1);t.resolve(!1)}),t.promise())};n.validate=function(){if(!n.isValidStay())return n.message({id:3002,severity:"error",text:"invalidDateRange"}),n.events.notifySubscribers({failure:n.message()},"submit"),!1;if(n.couponExists())n.allowSubmit(!1),$.when(n.isValidCoupon()).then(function(t){t?n.events.notifySubscribers({success:i()},"submit"):(n.message({id:3001,severity:"error",text:"invalidPromoCode"}),n.events.notifySubscribers({failure:n.message()},"submit"));n.allowSubmit(!0)});else return n.allowSubmit(!1),n.events.notifySubscribers({success:i()},"submit"),n.allowSubmit(!0),!0;return!0};n.isValidStay=ko.computed({read:function(){return n.nights()>0&&n.nights()<=n.maxStay()},deferEvaluation:!0});n.initTriptease=function(){var n=IBE.Config.tripteaseHotelId,t=IBE.Config.tripteaseClientKey;n&&t&&IBE.Config.userCookieAcceptance===!0&&$("body").append('<script src="https://static.triptease.io/paperboy/'+t+".js?hotelKey="+n+'" defer><\/script>')};n.init=function(i){var u=$.Deferred(),f=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},i);return n.ready(!1),n.dispose(),t.push(n.lang.subscribe(function(){n.init()})),$.when(n.languagePartialInit(f),n.currenciesPartialInit(),n.customerAuthenticate()).then(function(){var t=function(t){t&&typeof t!="undefined"&&(r(t),n.initTriptease(),u.resolve(!0))};$.when(IBE.Utils.loadHotelInfo(t,f)).then(t)}),u.promise()}};IBE.ViewModels.Step2ViewModel=function(){function u(t){var i=!1,r=ko.utils.arrayFirst(n.request().hotelResults(),function(t){return t.hotelId()===n.hotelId()},n),u=ko.utils.unwrapObservable(t);return(ko.utils.arrayForEach(r.requestedRooms(),function(n){i=ko.utils.arrayFirst(n.roomResults(),function(n){return u===n.roomId()})}),i!==!1)?i.availability:!1}function r(r,u){var o=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},u),e,c,f,s,l,h;n.clearMessage();n.baseCurrency=r.currency;n.reservationSettings=new IBE.Models.ReservationSettings(r.settings);IBE.Data.HotelInfo[o.hotelId]&&(IBE.Data.HotelInfo[o.hotelId].info.paymentPolicy=r.hotelInfo[0].paymentPolicy);e=ko.utils.arrayFilter(r.hotelInfo,function(n){return n.hotelId===o.hotelId})[0];n.boards(ko.utils.arrayMap(e.boardTypes,function(n){return new IBE.Models.BoardType(n)}));n.offers(ko.utils.arrayMap(e.offerInfo,function(n){return new IBE.Models.OfferInfo(n)}));c=moment(r.request.checkOut).diff(moment(r.request.checkIn),"days");n.rateplans(ko.utils.arrayMap(e.ratePlanInfo,function(n){return new IBE.Models.RatePlanInfo(n,c)}));n.rooms(ko.utils.arrayMap(e.roomInfo,function(n){return new IBE.Models.RoomInfo(n)}));n.hotelInfo(new IBE.Models.HotelInfo(e));n.hotelInfo().minCheckInDate=new Date(n.reservationSettings.items.MinCheckInDate);f=new IBE.Models.Request;f.checkIn(moment(r.request.checkIn));f.checkOut(moment(r.request.checkOut));f.couponCode(r.request.couponCode);f.preferredBoard(r.request.preferredBoard);f.ratePlanId(r.request.rateplanId);s=[];ko.utils.arrayForEach(r.request.hotelResults,function(t){var i=new IBE.Models.HotelResult,u;i.hotelId(t.hotelId);i.alternatives=t.alternatives;i.availability(IBE.Config.hotelAvailability[t.availability]);n.hotelId(t.hotelId);n.apiKey(o.apiKey);n.tabsCount=t.requestedRooms.length;u=[];ko.utils.arrayForEach(t.requestedRooms,function(t){var i=new IBE.Models.RequestedRoom(n),r,f;i.roomIndex(t.roomIndex);r=[];f=[];ko.utils.arrayForEach(t.guestTypes,function(n){var t=new IBE.Models.RequestedRoomGuestType;t.ageCategory(n.ageCategory);t.fromAge(n.fromAge);t.toAge(n.toAge);t.pax(n.pax);t.minValue(n.min);t.maxValue(n.max);f.push(t)});i.guests=ko.observableArray(f);f=[];ko.utils.arrayForEach(t.roomResults,function(i){var u=new IBE.Models.RoomResult(n),f;u.roomId(i.roomId);u.hotelId(n.hotelId());u.roomIndex(t.roomIndex);u.rank=i.rank;u.availability=IBE.Config.roomAvailability[i.availability];u.availabilityStatus=i.availability;u.availableRooms=i.availableRooms;u.availabilityRestrictions=ko.utils.arrayMap(i.availabilityRestrictions,function(n){return new IBE.Models.AvailabilityRestriction(n)});u.supportedBoards=i.supportedBoards;f=[];ko.utils.arrayForEach(i.ratePlans,function(i){var r=new IBE.Models.RatePlan(n),e;r.ratePlanId(i.ratePlanId);r.offers=ko.observableArray([]);e=[];ko.utils.arrayForEach(i.roomBoards,function(i){var f=new IBE.Models.RoomBoard(n);f.roomIndex=t.roomIndex;f.roomId=u.roomId();f.ratePlanId=r.ratePlanId();f.boardType(i.boardType);f.offers(i.specialOfferList);f.price(i.price);f.priceWithoutDiscount(i.priceWithoutDiscount);f.rateBreakDown=ko.observable(new IBE.Models.RateBreakDown(i.daily));e.push(f)});e.sort(function(n,t){return n.price()>t.price()?1:-1});r.roomBoards=ko.observableArray(e);e=[];f.push(r)});u.rateplans=ko.observableArray(f);f=[];r.push(u)});i.roomResults=ko.observableArray(r);r=[];u.push(i)});i.requestedRooms=ko.observableArray(u);u=[];ko.utils.extend(i,new IBE.ViewModels.SupplementPartialViewModel(t.supplements,r.request.rateplanId));s.push(i)});f.hotelResults=ko.observableArray(s);s=[];n.request(f);IBE.Utils.calculateRoomBoard(n.request());l=new IBE.Models.BookingProcess({checkIn:n.request().checkIn,checkOut:n.request().checkOut,rooms:n.selectedRooms,couponCode:n.request().couponCode(),reservationStatus:"Unknown",lang:n.lang,currency:n.currency,totalGuests:n.request().totalGuests,supplements:ko.observableArray([])});n.bookingProcess(l);h=ko.utils.arrayFilter(n.request().hotelResults(),function(n){return n.hotelId()===o.hotelId})[0];t.push(h.selectedSupplements.subscribe(function(){n.bookingProcess().supplements(ko.unwrap(h.selectedSupplements))}));IBE.Data.RatePlanInfo=IBE.Data.RatePlanInfo.concat(ko.toJS(n.rateplans()));ko.utils.arrayForEach(n.request().hotelResults(),function(t){ko.utils.arrayForEach(t.requestedRooms(),function(t){var r,u,f;ko.utils.arrayForEach(t.roomResults(),function(n){n.rateplans.sort(function(n,t){return n.price()>t.price()?1:-1});n.ratePlanId(n.bestRatePlanId())});r=[];IBE.Config.sortRoomsBy&&IBE.Config.sortRoomsBy.length>0&&(r=IBE.Config.sortRoomsBy);typeof IBE.Data.Settings.ibeRoomSorting!="undefined"&&(r=IBE.Data.Settings.ibeRoomSorting.split(","));r.length>0&&t.sortRoomResults(r);i.hasOwnProperty("roomId")&&(u=[],f=t.roomResults(),ko.utils.arrayFirst(f,function(n,t){if(n.roomId()===i.roomId)return u.push(n),f.splice(t,1),!0}),u.length>0&&(u[0].isFiltered(!0),f.unshift(u[0])));n.roomsPrices(t.orderedRoomsPrices())})});n.popup(new IBE.ViewModels.PopUpPartialViewModel(n));n.ready(!0);n.trackSojernSearch();n.trackSojernProduct();n.showTriptease();n.events.notifySubscribers(!0,"ready")}var n=this,i,t;n.events=new ko.subscribable;n.ready=ko.observable(!1);ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.PartialMemberViewModel(n));n.referrer=new IBE.Models.Referrer;n.preferencesChanged=ko.observable(!1);n.hotelId=ko.observable(parseInt(IBE.Config.hotelId));n.apiKey=ko.observable(parseInt(IBE.Config.apiKey));n.bookingProcess=ko.observable();n.rooms=ko.observableArray([]);n.selectedRooms=ko.observableArray([]);n.tabsCount=1;n.activeTabIndex=ko.observable(0);n.activeRoomIndex=ko.observable(1);n.showTabs=ko.computed({read:function(){switch(n.hotel().availability()){case IBE.Config.hotelAvailability.AvailableOnline:return!0;case IBE.Config.hotelAvailability.AvailableOnRequest:return IBE.Config.displayResults[IBE.Utils.getReservationSetting(n,"displayNotAvailable")]==0?!1:!0;default:return!1}},deferEvaluation:!0});n.groupText=IBE.Config.groupText;n.hotel=ko.computed({read:function(){return ko.utils.arrayFirst(n.request().hotelResults(),function(t){return t.hotelId()===n.hotelId()},n)},deferEvaluation:!0});i={};n.rateplans=ko.observableArray([]);n.offers=ko.observableArray([]);n.boards=ko.observableArray([]);n.boardTypeInfo=ko.computed({read:function(){var t=n.request().preferredBoard();return ko.utils.arrayFirst(n.boards(),function(n){return n.boardType===t},n)},deferEvaluation:!0});n.hotelInfo=ko.observable();n.request=ko.observable();n.roomsPrices=ko.observableArray();n.popup=ko.observable(new IBE.ViewModels.PopUpPartialViewModel(n));n.roomImageWidth=ko.observable(390);n.roomImageHeight=ko.observable(310);n.selectRoom=function(t){var h,r,f,e,c;if(n.selectedRooms().length>=n.tabsCount)return!0;if(ko.unwrap(t.bookingAction)===IBE.Config.displayResults.Show)return n.events.notifySubscribers(ko.unwrap(t),"call"),!0;var i=new IBE.Models.SelectedRoom,o=n.activeTabIndex()+1,l=o+1,s=!1;return(ko.utils.arrayForEach(n.request().hotelResults(),function(n){var t=ko.utils.arrayFilter(n.requestedRooms(),function(n){return l==n.roomIndex()});t.length>0&&(s=!0)}),i.roomIndex(ko.unwrap(t.roomIndex)),i.roomId(ko.unwrap(t.roomId)),i.ratePlanId(ko.unwrap(t.ratePlanId)),i.boardType(ko.unwrap(t.boardType)),i.availability(ko.unwrap(u(t.roomId))),h=ko.utils.arrayFirst(n.boards(),function(n){return n.boardType===i.boardType()}),i.board(ko.unwrap(h)),i.guestTypes=ko.observableArray([]),ko.utils.arrayForEach(n.request().hotelResults(),function(n){ko.utils.arrayForEach(n.requestedRooms(),function(n){if(ko.unwrap(t.roomIndex)===ko.unwrap(n.roomIndex())){i.guestTypes(n.guests());return}})}),t instanceof IBE.Models.RoomResult?(r=ko.utils.arrayFirst(t.rateplans(),function(n){return n.ratePlanId()===i.ratePlanId()}),typeof r!="undefined"&&r!=null&&(i.cost(r.price()),i.costWithoutDiscount(r.priceWithoutDiscount()))):t instanceof IBE.Models.RoomBoard&&(i.cost(t.price()),i.costWithoutDiscount(t.priceWithoutDiscount())),i.roomInfo=ko.observable(),f=n.rooms.filterByProperty("id",ko.unwrap(t.roomId)),f().length>0&&i.roomInfo(f()[0]),e=ko.utils.arrayFirst(n.selectedRooms(),function(n){return i.roomIndex===n.roomIndex}),e!==null&&ko.utils.arrayRemoveItem(n.selectedRooms(),e),typeof gtag!="undefined"&&gtag("event","select_room",{event_category:"Step2 Select Room",content_type:"room",items:[{id:i.roomId(),name:i.roomInfo().name,list_name:"Search Results",brand:n.hotelInfo().name,quantity:1,price:i.cost()}]}),n.selectedRooms().push(i),n.bookingProcess.valueHasMutated(),n.bookingProcess().rooms.valueHasMutated(),s)?(n.activeTabIndex(o),!0):n.selectedRooms().length>0?(c=n.prepareData(),n.events.notifySubscribers(c,"submit"),!0):void 0};n.viewAvailability=ko.observable(!1);n.availabilityCalender=function(t,i){var r=t,e=i,s=ko.utils.arrayFilter(n.request().hotelResults(),function(t){return t.hotelId()===n.hotelId()})[0],h=ko.utils.arrayFilter(s.requestedRooms(),function(n){return n.roomIndex()===e})[0],u=ko.utils.arrayFilter(h.roomResults(),function(n){return n.roomIndex()===e&&n.roomId()===r})[0],o,f;r!==0&&(o=[IBE.Config.apiBaseUrl,"/hotels/availability/",IBE.Config.hotelId,"/",r,"/?apikey=",IBE.Config.apiKey].join(""),f=["RoomAvailability_",n.hotelId(),"_",r,"_",MD5([n.bookingProcess().checkIn(),"_",n.bookingProcess().checkOut()].join(""))].join(""),IBE.Data.RoomAvailability[r]?(u.availability=IBE.Data.RoomAvailability[r],u.viewAvailability(!0)):Cache.read(f)!==!1?(IBE.Data.RoomAvailability[r]=Cache.read(f),u.availability=IBE.Data.RoomAvailability[r],u.viewAvailability(!0)):IBE.Utils.request({url:o}).done(function(n){IBE.Data.RoomAvailability[r]=n[0].availability;Cache.write(f,IBE.Data.RoomAvailability[r]);u.availability=IBE.Data.RoomAvailability[r];u.viewAvailability(!0)}))};n.trackSojernSearch=function(){var u=IBE.Config.sojernSearchId,i;if(u&&IBE.Config.userCookieAcceptance===!0){i=0;ko.utils.arrayForEach(n.request().hotelResults()[0].requestedRooms(),function(n){ko.utils.arrayForEach(n.guests(),function(n){n.pax()>0&&(i=i+n.pax())})});var t={hd1:n.bookingProcess().checkIn().format("YYYY-MM-DD"),hd2:n.bookingProcess().checkOut().format("YYYY-MM-DD"),hc1:"",hs1:"",hpr:n.hotelId(),hr:n.request().hotelResults()[0].requestedRooms().length,hpid:n.hotelId(),t:i},f=[],e=[],o=[],r=document.createElement("script"),s={vid:"hot",et:"hs"};for(key in s)t[key]=s[key];for(key in o)f.push(t[o[key]]);t.cid=f.join("|");for(key in t)e.push(key+"="+encodeURIComponent(t[key]));r.type="text/javascript";r.async=!0;r.src="https://beacon.sojern.com/pixel/p/"+u+"?f_v=v6_js&p_v=1&"+e.join("&");(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(r)}};n.trackSojernProduct=function(){var u=IBE.Config.sojernProductId,i;if(u&&IBE.Config.userCookieAcceptance===!0){i=0;ko.utils.arrayForEach(n.request().hotelResults()[0].requestedRooms(),function(n){ko.utils.arrayForEach(n.guests(),function(n){n.pax()>0&&(i=i+n.pax())})});var t={hd1:n.bookingProcess().checkIn().format("YYYY-MM-DD"),hd2:n.bookingProcess().checkOut().format("YYYY-MM-DD"),hc1:"",hs1:"",hpr:n.hotelId(),hr:n.request().hotelResults()[0].requestedRooms().length,hpid:n.hotelId(),t:i},f=[],e=[],o=[],r=document.createElement("script"),s={vid:"hot",et:"hpr"};for(key in s)t[key]=s[key];for(key in o)f.push(t[o[key]]);t.cid=f.join("|");for(key in t)e.push(key+"="+encodeURIComponent(t[key]));r.type="text/javascript";r.async=!0;r.src="https://beacon.sojern.com/pixel/p/"+u+"?f_v=v6_js&p_v=1&"+e.join("&");(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(r)}};n.showTriptease=function(){var t=IBE.Config.tripteaseHotelId,i=IBE.Config.tripteaseClientKey,r=IBE.Config.tripteaseWidgetClosed,u=ko.utils.arrayFirst(n.request().hotelResults(),function(t){return t.hotelId()===n.hotelId()},n);t&&i&&IBE.Config.userCookieAcceptance===!0&&typeof Paperboy!="undefined"&&Paperboy.ready(function(){setTimeout(function(){$(".bookwize-sidebar")&&$(".bookwize-sidebar-vertical").append($(".price-fighter-widget"));var i=0,r=[];ko.utils.arrayForEach(u.requestedRooms(),function(u,f){var e=u.guests()[0].pax();ko.utils.arrayForEach(u.guests(),function(n){n.ageCategory()!=="Adult"&&(i=i+n.pax(),r.push(n.fromAge()))});$(".price-fighter-widget#atr"+(f+1)).attr({"data-pf-hotelkey":t,"data-pf-checkin":moment(ko.unwrap(n.bookingProcess().checkIn())).format("YYYY-MM-DD"),"data-pf-checkout":moment(ko.unwrap(n.bookingProcess().checkOut())).format("YYYY-MM-DD"),"data-pf-direct-price":u.roomResults()[0].price(),"data-pf-room-rate":u.roomResults()[0].rateplans()[0].info().defaultName,"data-pf-currency":n.currency(),"data-pf-layout":"skeleton-1","data-pf-language":n.lang().substr(0,2),"data-pf-adults":e,"data-pf-children":i,"data-pf-children-ages":r})});Paperboy.PriceCheck.activate()},500);r==="True"&&setTimeout(function(){Paperboy.PriceCheck.close()},3e3)})};n.updateTriptease=function(n,t){var i=IBE.Config.tripteaseHotelId,r=IBE.Config.tripteaseClientKey;i&&r&&typeof Paperboy!="undefined"&&Paperboy.ready(function(){$(".price-fighter-widget").attr(n,t);setTimeout(function(){Paperboy.PriceCheck.reset()},500)})};n.removeLastRoom=function(){n.selectedRooms().pop();typeof n.bookingProcess()!="undefined"&&(n.bookingProcess.valueHasMutated(),n.bookingProcess().rooms.valueHasMutated())};n.closedDates=function(n,t){var i=ko.utils.arrayFirst(IBE.Data.HotelInfo[t].info.closedDates,function(t){return moment(t.closedTo).diff(n,"day")>=0});if(i)return IBE.Utils.translate("hotelIsClosedFromTo").format(moment(i.closedFrom).format("LL"),moment(i.closedTo).format("LL"))};n.setRoomIndex=function(t){var f=n.activeTabIndex()+1,i=t.roomIndex()-1,r=!1,u=!1;u=ko.utils.arrayFilter(n.selectedRooms(),function(n){return t.roomIndex()===n.roomIndex()});u.length>0&&(r=!0,n.selectedRooms().splice(i,n.selectedRooms().length));r&&n.activeTabIndex(i);n.bookingProcess.valueHasMutated();n.bookingProcess().rooms.valueHasMutated()};t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.init=function(u,f){n.ready(!1);var e=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang,referrer:new IBE.Models.Referrer},f);i=u;n.referrer=u.ref||u.referrer||u.referer||new IBE.Models.Referrer;n.dispose();t.push(n.lang.subscribe(function(t){n.init(i);n.updateTriptease("data-pf-language",t)}));t.push(n.currency.subscribe(function(t){n.updateTriptease("data-pf-currency",t)}));$.when(n.languagePartialInit(),n.currenciesPartialInit(),n.customerAuthenticate()).then(function(){var f={checkIn:u.checkIn,checkOut:u.checkOut,rooms:u.rooms,ratePlan:u.ratePlan,couponCode:u.couponCode,board:u.board,ipAddress:null,lang:n.lang()||IBE.Config.lang||IBE.Config.defaultLang,hotelId:parseInt(IBE.Config.hotelId),reservationId:u.reservationId||0,referrer:n.referrer||new IBE.Models.Referrer},i=ko.toJSON(f),t="HotelRates_"+e.hotelId+"_"+MD5(i);if(typeof IBE.Data.HotelRates[e.hotelId]=="undefined"&&(IBE.Data.HotelRates[e.hotelId]={}),IBE.Data.HotelRates[e.hotelId].hasOwnProperty(t))return r(IBE.Data.HotelRates[e.hotelId][t]);if(Cache.read(t)!==!1)return r(Cache.read(t),e);IBE.Utils.request({type:"POST",contentType:"application/json",url:IBE.Config.apiBaseUrl+"/hotels/rates/"+e.hotelId+"/?apikey="+e.apiKey,data:i}).done(function(n){IBE.Data.HotelRates[e.hotelId][t]=n;Cache.write(t,IBE.Data.HotelRates[e.hotelId][t]);r(IBE.Data.HotelRates[e.hotelId][t],e);typeof gtag!="undefined"&&gtag("event","send",{event_category:"step1",event_label:"submit"})}).fail(function(t){n.ready(!0);var i={id:t.status,severity:"critical",text:t.statusText+": "+t.responseText};return n.events.notifySubscribers(!1,"ready"),n.events.notifySubscribers(i,"error"),n.message(i),i})}).fail(function(t){console.error(t);var i={id:t.status,severity:"critical",text:t.statusText+": "+t.responseText};return n.events.notifySubscribers(!1,"ready"),n.events.notifySubscribers(i,"error"),n.message(i),i})};n.prepareData=function(){var t={};return t.bookingInfo={checkIn:moment(n.request().checkIn()).format("YYYY-MM-DD"),checkOut:moment(n.request().checkOut()).format("YYYY-MM-DD"),rooms:n.selectedRooms(),couponCode:n.request().couponCode(),supplements:n.request().hotelResults()[0].supplements,notes:"",totalGuests:n.totalGuests,referrer:n.referrer},t.bookingProcess=n.bookingProcess,t}};IBE.ViewModels.Step3ViewModel=function(n){function u(n){t.bookingProcess().id(n.id);t.bookingProcess().baseCurrency=n.currency;t.bookingProcess().isOnline(n.isOnline);t.bookingProcess().checkIn(moment.utc(n.checkIn));t.bookingProcess().checkOut(moment.utc(n.checkOut));t.bookingProcess().couponCode(n.couponCode);t.bookingProcess().paymentMethodType(n.paymentMethod);t.externalPaymentGatewayData(n.externalPaymentGatewayData);t.typePaymentGateway(n.typePaymentGateway);t.bookingProcess().advancePayment(n.advancePayment);t.bookingProcess().cancellationPolicy(n.cancellationPolicy);t.bookingProcess().paymentPolicy(n.paymentPolicy);t.bookingProcess().paymentPolicyHotelTextOption(n.paymentPolicyHotelTextOption);t.bookingProcess().timePolicy(n.timePolicy);t.bookingProcess().payments(n.payments);n.supplements.length>0&&ko.utils.arrayForEach(t.supplements(),function(t){ko.utils.arrayForEach(t.supplementResults(),function(t){var i=ko.utils.arrayFilter(n.supplements,function(n){return n.id===t.supplementId()&&n.roomIndex===t.roomIndex()});ko.utils.arrayForEach(i,function(n){if(n!=null)switch(IBE.Config.supplementPricingType[t.pricingType()]){case IBE.Config.supplementPricingType.PerGuest:ko.utils.arrayForEach(t.prices(),function(i){i.guestType.ageCategory()===n.ageCategory&&(i.quantity(n.quantity),t.isMandatory&&i.minQuantity(n.quantity))});break;default:t.prices()[0].quantity(n.quantity);t.isMandatory&&t.prices()[0].minQuantity(n.quantity)}})})});t.groupText=IBE.Config.groupText;t.bookingProcess().supplements(t.selectedSupplements());i.push(t.selectedSupplements.subscribe(function(){t.bookingProcess().supplements(ko.unwrap(t.selectedSupplements))}));t.bookingProcess().cost=ko.observable(n.totalAmount);t.bookingProcess().costWithoutDiscount=ko.observable(n.totalAmountBeforeDiscount);t.bookingProcess().reservationStatus("Unknown");t.bookingProcess().lang=t.lang;t.bookingProcess().taxes(n.reservationTaxes||[]);IBE.Data.bookingProcess=t.bookingProcess}function f(n){n.sort(function(n,t){return n.name>t.name?1:-1});t.countries.removeAll();ko.utils.arrayPushAll(t.countries,ko.utils.arrayMap(n,function(n){return new IBE.Models.Country(n)}))}function e(n){t.reservationSettings=new IBE.Models.ReservationSettings(n.settings);typeof n.info.acceptedCards!="undefined"&&n.info.acceptedCards!=="All"&&t.acceptedCards(n.info.acceptedCards.split(", "))}var t=this,r,i;t.events=new ko.subscribable;t.ready=ko.observable(!1);ko.utils.extend(t,new IBE.ViewModels.LanguagePartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.CurrenciesPartialViewModel(t));ko.utils.extend(t,new IBE.ViewModels.Message);ko.utils.extend(t,new IBE.ViewModels.PartialMemberViewModel(t));t.referrer=new IBE.Models.Referrer;t.hotelInfo=ko.observable();t.bookingProcess=ko.observable();t.allowSubmit=ko.observable(!0);t.acceptedCards=ko.observableArray([]);t.externalPaymentGateway=ko.observable();t.typePaymentGateway=ko.observable();t.externalPaymentGatewayMessage=ko.observable("");t.externalPaymentGatewayData=ko.observable("");t.redirectPaymentGatewayData=ko.observable("");t.consents=ko.observableArray([]);t.terms=ko.observable();i=[];t.dispose=function(){for(var n in i)i[n].dispose()};t.countries=ko.observableArray([]);t.creditCardChargeText=ko.computed({read:function(){return typeof t.bookingProcess()=="undefined"?"":t.bookingProcess().advancePayment()===0?IBE.Utils.translate("creditCardChargeNoteNoCharge"):IBE.Utils.translate("creditCardChargeNoteAmount").format(t.getRateText(t.bookingProcess().advancePayment(),t.currency()))},deferEvaluation:!0});t.disableButton=ko.observable(!1);t.displayExternalPayment=ko.computed(function(){switch(t.typePaymentGateway()){case"Braintree":return!0;default:return!1}});t.requiredCreditCard=function(){return t.bookingProcess().isOnline()?typeof t.externalPaymentGateway()!="undefined"&&t.typePaymentGateway()==="Braintree"?!1:typeof t.externalPaymentGateway()!="undefined"&&t.typePaymentGateway()==="Stripe"?!1:typeof t.externalPaymentGateway()!="undefined"&&t.typePaymentGateway()==="Payout"&&t.bookingProcess().advancePayment()>0?!1:typeof t.externalPaymentGateway()!="undefined"&&t.typePaymentGateway()==="AlphaBankRedirect"&&t.bookingProcess().advancePayment()>0?!1:typeof t.externalPaymentGateway()!="undefined"&&t.externalPaymentGateway().notStoreCreditCard()?!1:t.displayExternalPayment()?!1:t.bookingProcess().paymentMethodType()==="NoPaymentInfo"?!1:!0:!1};t.disableButton=ko.observable(!1);t.makeReservation=function(){var i,n,f,u;return(t.ready(!1),i=!1,t.disableButton(!0),t.customer().errors().customer().length>0&&t.customer().errors().customer()[0]!==null&&(t.customer().errors().customer.showAllMessages(),i=!0),t.requiredCreditCard()&&t.customer().errors().creditCard().length>0&&(t.customer().errors().creditCard()[0]!==null||!t.customer().creditCard().cardNumber.isValid())&&(t.customer().errors().creditCard.showAllMessages(),i=!0),t.terms.value()||t.terms.id===-1||(t.customer().errors().customer.showAllMessages(),t.terms.value.notifySubscribers(),i=!0),i)?(t.disableButton(!1),typeof t.externalPaymentGateway()!="undefined"&&t.externalPaymentGateway().notStoreCreditCard(!1),t.ready(!0),!1):(r&&r.dispose(),n={},f=[],ko.utils.arrayForEach(t.consents(),function(n){n.value()&&f.push(n.id)}),n.referrer=t.referrer||new IBE.Models.Referrer,n.checkIn=t.bookingProcess().checkIn(),n.checkOut=t.bookingProcess().checkOut(),n.consents=f,n.termsAndPrivacyAcceptedVersion=t.terms.id,n.customer={firstName:t.customer().firstName(),lastName:t.customer().lastName(),email:t.customer().email(),address:t.customer().address(),city:t.customer().city(),zip:t.customer().zip(),telephones:t.customer().phone(),mobile:t.customer().mobile(),fax:t.customer().fax(),birthdate:t.customer().birthdate()&&t.customer().birthdate()!==""?moment(t.customer().birthdate()).format("YYYY-MM-DD"):null},typeof t.externalPaymentGateway()!="undefined"&&(n.externalPaymentGatewayData=t.externalPaymentGateway().externalPaymentGatewayData()),typeof t.customer().title()!="undefined"&&(n.customer.title=t.customer().title().key),typeof t.customer().country()!="undefined"&&(n.customer.country=t.customer().country().code()),t.requiredCreditCard()?(IBE.Config.ibeShowCVC||t.customer().creditCard().cardVerification("000"),u=t.customer().creditCard().cardExpirationYear()+"",u=u.substring(2),n.creditCard={holder:t.customer().creditCard().cardHolder(),expireYear:u,expireMonth:t.customer().creditCard().cardExpirationMonth(),number:t.customer().creditCard().cardNumber(),verification:t.customer().creditCard().cardVerification()}):n.creditCard=null,t.customer().paymentReceipt().name==="companyInvoice"&&(n.company={name:t.customer().company().name(),vatNumber:t.customer().company().vatNumber(),industry:t.customer().company().industry(),address:t.customer().company().address(),zipCode:t.customer().company().zipCode(),phone:t.customer().company().phone()}),n.supplements=[],ko.utils.arrayForEach(t.selectedSupplements(),function(t){ko.utils.arrayForEach(t.prices(),function(i){if(i.quantity()>0){var r=new IBE.Models.BookingSupplement,f=ko.utils.unwrapObservable(t.roomIndex),u=i.guestType;switch(IBE.Config.supplementPricingType[t.pricingType()]){case IBE.Config.supplementPricingType.PerReservation:u=0;f=0;break;case IBE.Config.supplementPricingType.PerRoom:u=0}r.roomIndex=f;r.supplementId=ko.utils.unwrapObservable(t.supplementId);r.quantity=ko.utils.unwrapObservable(i.quantity);r.guestType=u;r.categoryName=t.category();r.ratePlanId=ko.utils.unwrapObservable(t.ratePlanId);n.supplements.push(r)}})}),n.rooms=ko.utils.arrayMap(t.bookingProcess().rooms(),function(n){return{boardType:n.boardType,ratePlanId:n.ratePlanId,roomIndex:n.roomIndex,roomId:n.roomId,guestTypes:n.guestTypes}}),n.couponCode=t.bookingProcess().couponCode(),n.notes=t.customer().notes(),n.cost=t.bookingProcess().cost(),n.advancePayment=t.bookingProcess().advancePayment(),t.events.notifySubscribers(n,"submit"),!1)};t.init=function(r,o){var s=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},o);t.referrer=r.bookingInfo.referrer||new IBE.Models.Referrer;t.customer(new IBE.ViewModels.CustomerPartialViewModel(n));$.when(t.languagePartialInit(s),t.currenciesPartialInit(s),t.customerAuthenticate()).then(function(){IBE.Data.Step3InitData=r;i.push(t.lang.subscribe(function(){t.init(IBE.Data.Step3InitData)}));$.when(IBE.Utils.loadCountries()).then(function(n){f(n)});var n=function(n){n&&(t.hotelInfo(new IBE.Models.HotelInfo(n.info)),t.customer().customerMandatoryFields(n.settings.customerMandatoryFields||{}),e(n),t.consents([]),ko.utils.arrayForEach(n.info.consents,function(n){t.consents.push(new IBE.Models.Consents(n))}),t.terms=new IBE.Models.Terms(n.info.termsAndPrivacy))};$.when(IBE.Utils.loadHotelInfo(n,s)).then(n);t.paymentOptionsRadio=ko.observable(!0);t.paymentOptionsRadio.ForEditing=ko.computed({read:function(){return t.customer().paymentReceipt(t.paymentOptionsRadio()),t.paymentOptionsRadio().toString()},write:function(n){t.paymentOptionsRadio(n==="true")},owner:t});$.when(IBE.Utils.lookupCountry()).then(function(n){var i=ko.utils.arrayFirst(t.countries(),function(t){return t.code()===n});i!=null&&t.customer().country(i)});ko.utils.extend(t,new IBE.ViewModels.SupplementPartialViewModel(r.bookingInfo.supplements(),r.bookingInfo.rooms[0].ratePlanId()));t.bookingProcess=r.bookingProcess;t.currency=t.bookingProcess().currency;t.lang=t.bookingProcess().lang;IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/BookingProcess/"+s.hotelId+"?apikey="+s.apiKey,data:ko.toJSON(t.bookingProcess().bookingProcessPostData()),headers:{"Content-Type":"application/json"}}).done(function(n){if(t.clearMessage(),n===!1){t.ready(!0);t.events.notifySubscribers(!0,"ready");t.message({id:4001,severity:"error",text:"An error occured. Please try again"});t.events.notifySubscribers(t.message(),"error");return}u(n);t.trackSojernCart();t.ready(!0);typeof gtag!="undefined"&&gtag("event","send",{event_category:"step2",event_label:"submit"});t.events.notifySubscribers(!0,"ready")}).fail(function(n){t.ready(!0);t.clearMessage();var i={id:n.status,severity:"critical",text:n.statusText+": "+n.responseText};t.message(i);t.events.notifySubscribers(!1,"ready");t.events.notifySubscribers(i,"error")})})};t.typePaymentGateway.subscribe(function(n){t.bookingProcess().paymentMethodType()==="ExternalPaymentGateway"&&t.externalPaymentGateway(new IBE.ViewModels.ExternalPaymentGateway(t,n,t.externalPaymentGatewayData()))});t.flightInformation=ko.observable(!1);t.showFlightInformationDetails=ko.computed({read:function(){return ko.utils.arrayFirst(t.bookingSupplements(),function(n){return n.categoryName==="transfers"}).length},deferEvaluation:!0});t.flightInformationDetails={flightNumber:ko.observable(""),airportOfArrival:ko.observable(""),estimatedTime:ko.observable("")};t.trackSojernCart=function(){var u=IBE.Config.sojernCartId,i;if(u&&IBE.Config.userCookieAcceptance===!0){if(i=0,typeof t.bookingProcess()=="undefined")return;ko.utils.arrayForEach(t.bookingProcess().rooms(),function(n){ko.utils.arrayForEach(n.guestTypes(),function(n){n.pax()>0&&(i=i+n.pax())})});var n={hd1:t.bookingProcess().checkIn().format("YYYY-MM-DD"),hd2:t.bookingProcess().checkOut().format("YYYY-MM-DD"),hc1:"",hs1:"",hpr:t.hotelInfo().hotelId,hr:t.bookingProcess().rooms().length,hpid:t.hotelInfo().hotelId,t:i,hp:t.bookingProcess().totalCost(),hcu:t.bookingProcess().currency(),hconfno:""},f=[],e=[],o=[],r=document.createElement("script"),s={vid:"hot",et:"hpr"};for(key in s)n[key]=s[key];for(key in o)f.push(n[o[key]]);n.cid=f.join("|");for(key in n)e.push(key+"="+encodeURIComponent(n[key]));r.type="text/javascript";r.async=!0;r.src="https://beacon.sojern.com/pixel/p/"+u+"?f_v=v6_js&p_v=1&"+e.join("&");(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(r)}};t.events.subscribe(function(n){t.externalPaymentGatewayMessage(n)},this,"externalPaymentValidation");t.events.subscribe(function(){t.makeReservation()},this,"makeReservation")};IBE.ViewModels.Step4ViewModel=function(){function i(t){n.reservation(new IBE.Models.Reservation(t));n.membership.customer(n.reservation().customer);typeof IBE.Data.Step3InitData!="undefined"&&ko.utils.extend(n,new IBE.ViewModels.SupplementPartialViewModel(IBE.Data.Step3InitData.bookingInfo.supplements()));n.bookingProcess=IBE.Data.bookingProcess;n.reservation().taxes(t.taxes||[]);n.options.reservationSubmitted||(n.ecommerce(!0),n.trackEcommerce(),n.trackAdwords(),n.trackBingCode(),n.trackTrivagoConversion(),n.trackSojernConversion(),n.trackFacebookConversion(),n.initTriptease(),n.googleAds(),n.events.notifySubscribers(t,"track-conversion"));n.ready(!0);n.events.notifySubscribers(!0,"ready")}function r(t){n.hotel(new IBE.Models.HotelInfo(t.info));n.reservationSettings=new IBE.Models.ReservationSettings(t.settings);n.googleMap(new IBE.Models.GoogleMap(t.info))}function u(){var t=[];return ko.utils.arrayForEach(n.selectedSupplements(),function(n){ko.utils.arrayForEach(n.prices(),function(i){if(i.quantity()>0){var r=new IBE.Models.BookingSupplement,f=ko.utils.unwrapObservable(n.roomIndex),u=i.guestType;switch(IBE.Config.supplementPricingType[n.pricingType()]){case IBE.Config.supplementPricingType.PerReservation:u=0;f=0;break;case IBE.Config.supplementPricingType.PerRoom:u=0}r.roomIndex=f;r.supplementId=ko.utils.unwrapObservable(n.supplementId);r.quantity=ko.utils.unwrapObservable(i.quantity);r.guestType=u;t.push(r)}})}),ko.toJS(t)}function f(t){function u(n){var t="Basic "+$.base64.encode(n.username+":"+n.password);return document.cookie="Authorization: "+t,t}function f(n){var r="Authorization=",i=document.cookie.indexOf(r),t;return i!==-1?(t=document.cookie.indexOf(";",i+1),t===-1&&(t=document.cookie.length),unescape(document.cookie.substring(i+r.length,t))):u(n)}var r=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n.options);IBE.Utils.request({url:IBE.Config.apiBaseUrl+"/hotels/reservation/?apikey="+r.apiKey,beforeSend:function(n){n.setRequestHeader("Authorization",f(t));n.setRequestHeader("Accept-Language",IBE.Config.lang||"en-US")}}).done(function(t){n.clearMessage();i(t)}).fail(function(t){var i,r;n.ready(!0);n.clearMessage();i="critical";(t.status===400||t.status===500)&&(i="error");r={id:t.status,severity:i,text:t.responseJSON.Message};n.events.notifySubscribers(r,"error")})}function e(t){var r=ko.utils.extend({apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},n.options);t.checkIn=moment(t.checkIn).format("YYYY-MM-DD");t.checkOut=moment(t.checkOut).format("YYYY-MM-DD");IBE.Utils.request({type:"POST",url:IBE.Config.apiBaseUrl+"/hotels/makereservation/"+r.hotelId+"?apikey="+r.apiKey,data:ko.toJSON(t),headers:{"Content-Type":"application/json"}}).done(function(t){if(n.clearMessage(),t.error){var r={id:t.statusCode(),severity:"error",text:t.responseJSON.message};n.message(r);n.events.notifySubscribers(r,"error");throw r;}if(IBE.Config.externalPaymentGateway==="AlphaBankRedirect"&&IBE.Config.reservationStatus[t.status]===2&&t.redirectPaymentGatewayData!=="undefined"){IBE.Utils.authenticationHeader(t.customer.email,t.code);IBE.Utils.createFormAlphaBankRedirect(t,n);n.ready(!1);return}if(IBE.Config.externalPaymentGateway==="Payout"&&IBE.Config.reservationStatus[t.status]===2&&t.redirectPaymentGatewayData!=="undefined"&&t.redirectPaymentGatewayData!==null){IBE.Utils.authenticationHeader(t.customer.email,t.code);window.location.href=t.redirectPaymentGatewayData;n.ready(!1);return}i(t);IBE.Config.insightParticipantId=""}).fail(function(t){var i,r;n.ready(!0);n.clearMessage();i="critical";(t.status===400||t.status===500)&&(i="error");r={id:t.status,severity:i,text:t.responseJSON.message};n.events.notifySubscribers(r,"error")})}var n=this,t;n.options={};n.events=new ko.subscribable;n.reservation=ko.observable();n.bookingProcess=ko.observable();n.hotel=ko.observable();n.googleMap=ko.observable();n.ready=ko.observable(!1);n.customer=ko.observable();n.ecommerce=ko.observable(!1);n.membership=new IBE.ViewModels.Membership;ko.utils.extend(n,new IBE.ViewModels.LanguagePartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));ko.utils.extend(n,new IBE.ViewModels.Message);ko.utils.extend(n,new IBE.ViewModels.Taxes(n));t=[];n.dispose=function(){for(var n in t)t[n].dispose()};n.adWordsSent=ko.observable(!1);n.trackAdwords=function(){var t=IBE.Utils.getReservationSetting(n,"adwordsConversionId"),i,r;if(t&&typeof gtag!="undefined"&&IBE.Config.userCookieAcceptance===!0)if(IBE.Config.reservationStatus[n.reservation().status()]===3)i=IBE.Utils.getReservationSetting(n,"adwordsRequestLabel"),i!==""&&(google_conversion_label=i,gtag("event","conversion",{send_to:"AW-"+t+"/"+google_conversion_label,value:n.reservation().totalCost(),currency:n.currency(),transaction_id:n.reservation().id}));else if(IBE.Config.reservationStatus[n.reservation().status()]===1){if(r=IBE.Utils.getReservationSetting(n,"adwordsConversionLabel"),!r)return;gtag("event","conversion",{send_to:"AW-"+t+"/"+r,value:n.reservation().totalCost(),currency:n.currency(),transaction_id:n.reservation().id})}};n.initTriptease=function(){var t=IBE.Config.tripteaseHotelId,i=IBE.Config.tripteaseClientKey;t&&i&&IBE.Config.userCookieAcceptance===!0&&setTimeout(function(){$("body").append('<script defer src="https://static.triptease.io/paperboy/confirm?hotelkey='+t+"&bookingValue="+n.reservation().totalCost()+"&bookingCurrency="+n.reservation().currency()+"&bookingReference="+n.reservation().id+'"><\/script>')},500)};n.trackSojernConversion=function(){if(sojernConversionId=IBE.Config.sojernConversionId,sojernConversionId&&IBE.Config.userCookieAcceptance===!0){var t={hd1:n.reservation().checkIn.format("YYYY-MM-DD"),hd2:n.reservation().checkOut.format("YYYY-MM-DD"),hc1:"",hs1:"",hpr:n.reservation().hotelName,hr:n.reservation().rooms.length,hpid:n.reservation().hotelId,t:n.reservation().guests().length,hp:n.reservation().totalCost(),hcu:n.reservation().currencyCode,hconfno:n.reservation().id},r=[],u=[],f=[],i=document.createElement("script"),e={vid:"hot",et:"hc"};for(key in e)t[key]=e[key];for(key in f)r.push(t[f[key]]);t.cid=r.join("|");for(key in t)u.push(key+"="+encodeURIComponent(t[key]));i.type="text/javascript";i.async=!0;i.src="https://beacon.sojern.com/pixel/p/"+sojernConversionId+"?f_v=v6_js&p_v=1&"+u.join("&");(document.getElementsByTagName("head")[0]||document.getElementsByTagName("body")[0]).appendChild(i)}};n.googleAds=function(){var t=document.createElement("img");t.height=1;t.width=1;t.border=0;t.className="google-ads-image";t.src="https://www.googletraveladservices.com/travel/clk/pagead/conversion/2097807373/?label=HPA&guid=ON&script=0&ord="+n.reservation().id+"&data=hct_partner_hotel_id%3D"+n.hotel().hotelId+"%3Bhct_base_price%3D"+ko.unwrap(n.reservation().totalCost)+"%3Bhct_total_price%3D"+ko.unwrap(n.reservation().totalCost)+"%3Bhct_currency_code%3D"+n.currency()+"%3Bhct_checkin_date%3D"+n.reservation().checkIn.format("YYYY-MM-DD")+"%3Bhct_checkout_date%3D"+n.reservation().checkOut.format("YYYY-MM-DD")+"%3Bhct_length_of_stay%3D"+moment(n.reservation().checkOut.format("YYYY-MM-DD")).diff(moment(n.reservation().checkIn.format("YYYY-MM-DD")),"days")+"%3Bhct_date_format%3D%Y-%m-%d%3Bhct_booking_xref%3D"+n.reservation().code+"%3Bhct_ver%3D1.0.i";$("body").append(t)};n.trackFacebookConversion=function(){var t=IBE.Utils.getReservationSetting(n,"facebook_TrackId");t&&typeof fbq!="undefined"&&IBE.Config.userCookieAcceptance===!0&&fbq("track","Purchase",{value:n.reservation().totalCost(),currency:n.currency()})};n.trackTrivagoConversion=function(){var t=Cache.read("ref","localstorage"),u,i,r,f,e;if((t==="Trivago"||t==="trivago"||t&&t.name&&(t.name==="Trivago"||t.name==="trivago"))&&IBE.Config.userCookieAcceptance===!0){if(u=IBE.Utils.getReservationSetting(n,"trivagoTrackingId"),typeof u=="undefined")return;i=IBE.Utils.getReservationSetting(n,"trivagoConversionKey");r=IBE.Utils.getReservationSetting(n,"trivagoSupplierId");t&&t.params&&t.params.trv_reference&&r&&i&&(f=t.params.trv_reference,e={trv_reference:f,advertiser_id:r,hotel:n.reservation().hotelId,arrival:n.reservation().checkIn.format("YYYY-MM-DD"),departure:n.reservation().checkOut.format("YYYY-MM-DD"),volume:n.reservation().totalCost(),booking_id:n.reservation().id,currency:n.reservation().currencyCode,date_format:"Y-m-d",booking_date:moment(n.reservation().created).format("YYYYMMDD-HHmmss"),booking_date_format:"Ymd-His"},IBE.Utils.request({type:"POST",url:"https://secde.trivago.com/tracking/booking",data:JSON.stringify(e),dataType:"json",headers:{"Content-Type":"application/json","X-Trv-Ana-Key":i}}).done(function(){}).fail(function(){}))}};n.trackEcommerce=function(){var f,i,t;if(n.ecommerce()&&typeof gtag!="undefined"&&IBE.Config.reservationStatus[n.reservation().status()]===1){f=1;i=[];ko.utils.arrayForEach(n.reservation().rooms,function(t){var r=ko.unwrap(t);i.push({id:""+n.reservation().id,name:r.name+" "+r.board.name,category:"Rooms",quantity:"1",price:r.totalCost});f+=1});ko.utils.arrayForEach(n.reservation().supplements,function(t){var r=ko.unwrap(t);i.push({id:""+n.reservation().id,name:r.name,category:"Supplements",quantity:r.quantity(),price:r.unitCost()})});var r=IBE.Utils.getReservationSetting(n,"adwordsConversionId"),u="",e=IBE.Utils.getReservationSetting(n,"globalAdwordsConversionId"),o=IBE.Utils.getReservationSetting(n,"globalAdwordsConversionLabel"),s=IBE.Utils.getReservationSetting(n,"googleConversionTrackingPartnerId"),h=IBE.Utils.getReservationSetting(n,"googleAnalyticsKey");r&&typeof gtag!="undefined"&&IBE.Config.userCookieAcceptance===!0||(r="");IBE.Config.reservationStatus[n.reservation().status()]===3?u=IBE.Utils.getReservationSetting(n,"adwordsRequestLabel"):IBE.Config.reservationStatus[n.reservation().status()]===1&&(u=IBE.Utils.getReservationSetting(n,"adwordsConversionLabel"));t=[];r&&u&&t.push("AW-"+r+"/"+u);e&&o&&t.push("AW-"+e+"/"+o);s&&t.push("HA-"+s);h&&t.push(h);gtag("event","purchase",{send_to:t.length>0?t:undefined,transaction_id:n.reservation().id,affiliation:n.reservation().hotelName,value:ko.unwrap(n.reservation().totalCost),currency:n.currency(),items:i,checkout_step:4,id:n.reservation().hotelId,start_date:n.reservation().checkIn.format("YYYY-MM-DD"),end_date:n.reservation().checkOut.format("YYYY-MM-DD")})}};n.trackBingCode=function(){if(IBE.Config.debug){console.log("IBE: In debug mode bing is disabled");return}window.uetq&&IBE.Config.userCookieAcceptance===!0&&window.uetq.push({ec:"Booking",ea:ko.unwrap(n.reservation().status),el:"",ev:""+ko.unwrap(n.reservation().totalCost)})};n.updateReservation=function(){var t={id:n.reservation().id,newStatus:n.reservation().status(),supplements:u(),creditCard:{}};n.clearMessage();IBE.Utils.request({type:"POST",data:ko.toJSON(t),url:IBE.Config.apiBaseUrl+"/hotels/reservation/update/?apikey="+IBE.Config.apiKey,beforeSend:function(t){t.setRequestHeader("Authorization",IBE.Utils.authenticationCookie(n.reservation().customer.email(),n.reservation().code))}}).done(function(){}).fail(function(t){var i={id:t.status,severity:"critical",text:t.statusText+": "+t.responseText};n.message(i)})};n.init=function(t,i){n.options=ko.utils.extend({trackAdwords:!0,trackAdwordsAsync:!0,appendAdwordsImage:!0,reservationSubmitted:!1,apiKey:IBE.Config.apiKey,hotelId:parseInt(IBE.Config.hotelId),lang:IBE.Config.lang},i);$.when(n.languagePartialInit(n.options),n.currenciesPartialInit()).then(function(){n.options.reservationSubmitted=!1;var i=function(n){n&&(r(n),typeof t.username!="undefined"&&typeof t.password!="undefined"?f(t):e(t))};$.when(IBE.Utils.loadHotelInfo(i,n.options)).then(i)})}};IBE.ViewModels.SupplementPartialViewModel=function(n,t){var i=this;i.supplements=ko.observableArray([]);i.selectedSupplements=ko.computed({read:function(){var n=[];return ko.utils.arrayForEach(i.supplements(),function(t){ko.utils.arrayForEach(t.supplementResults(),function(t){var i=!1;ko.utils.arrayForEach(t.prices(),function(n){if(n.quantity()>0){i=!0;return}});i&&n.push(t)})}),n},deferEvaluation:!0});i.bookingSupplements=ko.computed({read:function(){var n=[];return ko.utils.arrayForEach(i.supplements(),function(t){ko.utils.arrayForEach(t.supplementResults(),function(t){ko.utils.arrayForEach(t.prices(),function(i){if(i.quantity()>0){var r=new IBE.Models.BookingSupplement;r.roomIndex=ko.utils.unwrapObservable(t.roomIndex);r.supplementId=ko.utils.unwrapObservable(t.supplementId);r.quantity=ko.utils.unwrapObservable(i.quantity);r.guestType=i.guestType;r.categoryName=t.category();n.push(r)}})})}),n},deferEvaluation:!0});i.showSupplements=ko.computed({read:function(){var n=!1;return ko.utils.arrayForEach(i.supplements(),function(t){ko.utils.arrayForEach(t.supplementResults(),function(t){if(t.isVisible()){var i=0;if(ko.utils.arrayForEach(t.prices(),function(n){i+=n.price()}),i>=0){n=!0;return}}})}),n},deferEvaluation:!0});typeof n!="undefined"&&n!==null&&(t==undefined&&(t=0),n.length>0?(ko.utils.arrayForEach(n,function(n){ko.utils.arrayForEach(n.supplementResults(),function(n){n.setRatePlanId(t)})}),i.supplements=ko.mapping.fromJS(n),i.supplements.valueHasMutated()):$.each(n,function(n,r){var u={categoryName:r.category,supplementResults:ko.observable([])};ko.utils.arrayForEach(r.supplementResults,function(n){var i=new IBE.Models.Supplement(n);i.setRatePlanId(t);u.supplementResults().push(i)});i.supplements.push(u)}))};IBE.ViewModels.Taxes=function(n){n.taxes=ko.observableArray([]);ko.utils.extend(n,new IBE.ViewModels.CurrenciesPartialViewModel(n));n.excludedTaxes=ko.computed({read:function(){return n.taxes().filter(function(n){return n.payable==="CheckIn"||n.payable==="CheckOut"})},deferEvaluation:!0});n.excludedTaxesCheckIn=ko.computed({read:function(){return n.excludedTaxes().filter(function(n){return n.payable==="CheckIn"}).map(function(n){return n.category=n.category.charAt(0).toLowerCase()+n.category.slice(1),n})},deferEvaluation:!0});n.excludedTaxesCheckOut=ko.computed({read:function(){return n.excludedTaxes().filter(function(n){return n.payable==="CheckOut"}).map(function(n){return n.category=n.category.charAt(0).toLowerCase()+n.category.slice(1),n})},deferEvaluation:!0});n.totalExcludedTaxes=ko.computed({read:function(){return n.excludedTaxes().map(function(n){return n.amount}).reduce(function(n,t){return n+t},0)},deferEvaluation:!0});n.excludedTaxesText=ko.computed({read:function(){var t,i,r,u;return n.excludedTaxes().length?(t=[],i=[],n.excludedTaxes().forEach(function(r){var u=r.category.charAt(0).toLowerCase()+r.category.slice(1);r.payable==="CheckIn"?t.push("{0} {1}".format(n.getRateText(r.amount,n.currency()),IBE.Utils.translate(u))):i.push("{0} {1}".format(n.getRateText(r.amount,n.currency()),IBE.Utils.translate(u)))}),r=[],u=" {0} ".format(IBE.Utils.translate("and")),t.length&&r.push("<li>{0}<\/li>".format(IBE.Utils.translate("excludedTaxText").format(t.join(u),IBE.Utils.translate("checkIn")))),i.length&&r.push("<li>{0}<\/li>".format(IBE.Utils.translate("excludedTaxText").format(i.join(u),IBE.Utils.translate("checkOut")))),r.join("")):""},deferEvaluation:!0})}
Note: See TracChangeset for help on using the changeset viewer.