(function(){"use strict";function n(n,t,i,r,u){function e(){var i=JSON.parse(ct.customer.clientStore.getItem(ct.utls.storageKeys.SignInResponse)),r;return i?(r={userReference:i.profile.sub,userName:i.profile.username,userId:i.profile.contactuserid,email:i.profile.email,market:i.profile.contactmarketid,firstName:i.profile.firstname,familyName:i.profile.lastname,fullName:i.profile.firstname+" "+i.profile.lastname,middleName:i.profile.middlename,phoneNo:i.profile.phoneno,usertype:i.profile.usertype,personTitle:i.profile.persontitle},t.currentUser=r,t.accessToken=i.access_token||{},n.defaults.headers.common[ct.utls.headerKeys.Authorization]="Bearer "+t.accessToken,!0):(console.log("User not signed in"),!1)}function o(){var n=JSON.parse(ct.customer.clientStore.getItem(ct.utls.storageKeys.SignInResponse));return n?!0:!1}function s(n,t){var r=JSON.parse(ct.customer.clientStore.getItem(ct.utls.storageKeys.SignInResponse)),u;r.profile.contactuserid=n;r.profile.contactmarketid=t;r.profile.isFirstTimeUser=!0;r.profile.usertype=i.userType.Customer;ct.customer.clientStore.setItem(ct.utls.storageKeys.SignInResponse,JSON.stringify(r));u=ct.customer.clientStore.getItem(ct.customer.storageKeys.PostLoginRedirectUrl);ct.customer.clientStore.removeItem(ct.customer.storageKeys.PostLoginRedirectUrl);u===undefined||u===null?window.location.replace("/account/dashboard"):window.location.replace(decodeURIComponent(u))}function h(i){n.get(t.WebApiUrl+"GetUserTitle").then(function(n){ct.utls.hideOverlay();i(n.data)},function(n){i(ct.utls.buildErrorMessage(n.statusText))})}function c(){var t=JSON.parse(ct.customer.clientStore.getItem(ct.utls.storageKeys.SignInResponse)),u=window.location.search.length>0,n,i,r;u&&(n=!1,i=ct.utls.getUrlParameterByName("firstName",window.location.href),i&&(t.profile.firstname=i,n=!0),r=ct.utls.getUrlParameterByName("familyName",window.location.href),r&&(t.profile.lastname=r,n=!0),n&&ct.customer.clientStore.setItem(ct.utls.storageKeys.SignInResponse,JSON.stringify(t)),window.location.replace(window.location.origin+window.location.pathname));initSigninResponse()}function l(i){n.get(t.WebApiUrl+"GetCustomClaims").then(function(n){i(n.data)},function(n){i(ct.utls.buildErrorMessage(n.statusText))})}function a(t){var i=JSON.parse(ct.customer.clientStore.getItem(ct.utls.storageKeys.SignInResponse)),r;i.profile.contactuserid=t;ct.customer.clientStore.setItem(ct.utls.storageKeys.SignInResponse,JSON.stringify(i));r={userReference:i.profile.sub,UserId:i.profile.contactuserid};n.defaults.headers.common[ct.utls.headerKeys.FirstTimeUser]=JSON.stringify(r)}function v(){y(function(n){$log.log("Cache Cleared : "+n)});ct.customer.clientStore.removeItem(ct.customer.storageKeys.CustomerFirstTimeUser);ct.customer.clientStore.removeItem(ct.customer.storageKeys.PostLoginRedirectUrl);ct.customer.clientStore.removeItem(ct.customer.storageKeys.BookingsNavigationInfo);ct.customer.clientStore.removeItem(ct.customer.storageKeys.Traveller);u.remove(ct.utls.cookieKeys.ShowPopUpBlockerAlert,{path:"/"});t.currentUser={};t.accessToken={};n.defaults.headers.common.Authorization="Basic";removeCustomerLocalStorage()}function y(n){r.post("ClearUserCache",n)}function p(i,r){n.post(t.WebApiUrl+"customer/UpdateContactByUserProfile",i).then(function(n){r(n.data)})}var f={};return f.InitSignInResponse=e,f.IsUserLoggedIn=o,f.GetCustomClaims=l,f.UpdateFirstTimeUser=a,f.SetFirstTimeCustomer=s,f.RefreshCustomer=c,f.ClearCustomerCache=v,f.GetUserTitle=h,f.UpdateContactByUserProfile=p,f}angular.module("ct.customerPortal").factory("headerService",n);n.$inject=["$http","$rootScope","globalConstants","webApiRequest","$cookies"]})(),function(){"use strict";function n(n,t,i,r,u,f,e,o,s){function h(){if(!u.IsUserLoggedIn()){t.showLogin=!0;return}}t.showLogin=!1,function(){f.log("init mediateHeaderController");h()}();t.signOut=function(){s.signOutCustomer()};t.signIn=function(){s.signInCustomer()}}angular.module("ct.customerPortal").controller("mediateHeaderController",n);n.$inject=["$rootScope","$scope","$http","$location","headerService","$log","$state","$cookies","authService"]}(),function(){"use strict";function n(n,t,i,r,u,f,e,o,s,h){function c(){if(!u.IsUserLoggedIn()){s.signInCustomer();return}n.currentUser&&n.currentUser.userName===undefined&&u.InitSignInResponse();l()&&a()}function l(){if(window.location.search.indexOf("firstTimeUser")===-1){if(n.currentUser.market!==undefined&&n.currentUser.market!==ct.utls.getMarketId())return window.location.replace("/Error?error=invalidMarket"),!1;if(!n.isAmValidUserOfType(h.userType.Customer))return window.location.replace("/Error?error=isNotCustomer"),!1}return!0}function a(){}(function(){console.log("init headerController");c()})();t.signOut=function(){s.signOutCustomer()}}angular.module("ct.customerPortal").controller("headerController",n);n.$inject=["$rootScope","$scope","$http","$location","headerService","$log","$state","$cookies","authService","globalConstants"]}(),function(){"use strict";function n(n,t,i,r,u,f,e,o){angular.extend(t,{bookings:[]}),function(){console.log("init accountSettingsController")}();t.signOut=function(){o.signOutCustomer()};t.loadNotificationBookings=function(){t.bookings=JSON.parse(ct.customer.clientStore.getItem(ct.customer.storageKeys.LinkedBookings));!ct.utls.isNullOrEmpty(t.bookings)&&t.bookings.length>1&&(t.bookings=t.bookings.slice(0,2))}}angular.module("ct.customerPortal").controller("accountSettingsController",n);n.$inject=["$rootScope","$scope","$http","$location","$log","$state","$cookies","authService"]}(),function(){"use strict";function n(n,t,i,r,u,f,e,o,s){(function(){console.log("init homeHeaderController")})();t.logInCustomer=function(){s.signInCustomer()};t.logInAgent=function(){s.signInAgent()}}angular.module("ct.customerPortal").controller("homeHeaderController",n);n.$inject=["$rootScope","$scope","$http","$location","headerService","$log","$state","$cookies","authService","globalConstants"]}()