"use strict";app.controller("indexController",["$scope","$location","authService",function(n,t,i){n.logOut=function(){i.logOut();t.path("/home")};n.authentication=i.authentication}]);app.controller("homeController",["$scope","$location","authService",function(n,t,i){n.authentication=i.authentication;i.authentication.isAuth&&t.path("/bookings")}]);app.controller("loginController",["$scope","$window","$location","$document","authService","ngAuthSettings",function(n,t,i,r,u,f){n.loginData={userName:"",password:"",useRefreshTokens:!1};n.message="";n.login=function(){u.login(n.loginData).then(function(){var n=r[0].referrer.indexOf("blackbowchauffeur.com.au"),i=r[0].referrer.indexOf("localhost");t.location.href=n>=0||i>=0?r[0].referrer:"/"},function(t){n.message=t.error_description})};n.authExternalProvider=function(t){var i=location.protocol+"//"+location.host+"/spa/authcomplete.html",r=f.apiServiceBaseUri+"api/Account/ExternalLogin?provider="+t+"&response_type=token&client_id="+f.clientId+"&redirect_uri="+i,u;window.$windowScope=n;u=window.open(r,"Authenticate Account","location=0,status=0,width=600,height=750")};n.authCompletedCB=function(f){n.$apply(function(){if(f.haslocalaccount=="False")u.logOut(),u.externalAuthData={provider:f.provider,userName:f.external_user_name,externalAccessToken:f.external_access_token},i.path("/associate");else{var e={provider:f.provider,externalAccessToken:f.external_access_token};u.obtainAccessToken(e).then(function(){var n=r[0].referrer.indexOf("blackbowchauffeur.com.au"),i=r[0].referrer.indexOf("localhost");t.location.href=n>=0||i>=0?r[0].referrer:"/"},function(t){n.message=t.error_description})}})}}]);app.controller("signupController",["$scope","$window","$location","$document","$timeout","authService","ngAuthSettings",function(n,t,i,r,u,f,e){n.savedSuccessfully=!1;n.message="";n.registration={firstName:"",lastName:"",password:"",confirmPassword:"",email:"",contactNumber:""};n.signUp=function(){f.saveRegistration(n.registration).then(function(){n.savedSuccessfully=!0;n.message="User has been registered successfully, Please check mail to confirm email address and login system."},function(t){var r=[],u,i;for(u in t.data.modelState)for(i=0;i<t.data.modelState[u].length;i++)r.push(t.data.modelState[u][i]);n.message=r.length!=0?"Failed to register user due to:"+r.join(" "):"Failed to register user due to:"+t.message})};n.authExternalProvider=function(t){var i=location.protocol+"//"+location.host+"/spa/authcomplete.html",r=e.apiServiceBaseUri+"api/Account/ExternalLogin?provider="+t+"&response_type=token&client_id="+e.clientId+"&redirect_uri="+i,u;window.$windowScope=n;u=window.open(r,"Authenticate Account","location=0,status=0,width=600,height=750")};n.authCompletedCB=function(u){n.$apply(function(){if(u.haslocalaccount=="False")f.logOut(),f.externalAuthData={provider:u.provider,userName:u.external_user_name,externalAccessToken:u.external_access_token},i.path("/associate");else{var e={provider:u.provider,externalAccessToken:u.external_access_token};f.obtainAccessToken(e).then(function(){var n=r[0].referrer.indexOf("blackbowchauffeur.com.au"),i=r[0].referrer.indexOf("localhost");t.location.href=n>=0||i>=0?r[0].referrer:"/"},function(t){n.message=t.error_description})}})};var o=function(){var n=u(function(){u.cancel(n);i.path("/login")},2e3)}}]);app.controller("signupOurPartnersController",["$scope","$location","authService",function(n,t,i){n.savedSuccessfully=!1;n.message="";n.registration={firstName:"",lastName:"",businessName:"",abnNumber:"",password:"",confirmPassword:"",email:"",contactNumber:""};n.signupPartners=function(){i.saveRegistrationPartners(n.registration).then(function(){n.savedSuccessfully=!0;n.message="User has been registered successfully, Please check mail to confirm email address and login syatem."},function(t){var r=[],u,i;for(u in t.data.modelState)for(i=0;i<t.data.modelState[u].length;i++)r.push(t.data.modelState[u][i]);n.message=r.length!=0?"Failed to register user due to:"+r.join(" "):"Failed to register user due to:"+t.message})}}]);app.controller("bookingsController",["$scope","bookingService",function(n,t){n.tab=1;n.parentTab=1;n.selectBookingTab=function(t){n.tab=t};n.isBookingSelected=function(n){return this.tab===n};n.bookings==null&&($("#processing").show(),t.getBooking().then(function(t){n.bookings=t.data},function(n){alert(n.data.message)}),$("#processing").hide());n.downloadInvoice=function(n){t.getInvoice(n).then(function(){},function(n){alert(n.data.message)})}}]);app.controller("myInformationController",["$scope","authService",function(n,t){n.infoTab=1;n.passwordUpdateSuccessfully=!0;n.passwordUpdateMessage="";n.personalUpdateSuccessfully=!0;n.personalMessage="";n.userInfo={username:"",oldPassword:"",newPassword:"",confirmPassword:"",firstName:"",lastName:"",businessName:"",abnNumber:"",contactNumber:""};n.accountInfo={accountHolderName:"",accountNumber:"",bankName:"",bsbNumber:"",id:"",accountInfoSuccessfully:!0,accountInfoMessage:""};n.authentication=t.authentication;n.selectInfoTab=function(t){n.infoTab=t};n.isInfoSelected=function(n){return this.infoTab===n};n.resetPasswordUser=function(){n.chkUpdatePassword=!1};n.userInfo.username==""&&t.getUserInfo().then(function(t){n.userInfo=t.data.contactInfo;t.data.userBankInfo!=null&&(n.accountInfo=t.data.userBankInfo);n.accountInfo.accountInfoSuccessfully=!0;n.accountInfo.accountInfoMessage=""});n.changePasswordUser=function(){var i={oldPassword:n.userInfo.oldPassword,newPassword:n.userInfo.newPassword,confirmPassword:n.userInfo.confirmPassword};t.changePasswordUser(i).then(function(){n.savedSuccessfully=!0;n.passwordUpdateMessage="";n.chkUpdatePassword=!1},function(t){var u=[],r,i;for(r in t.data.modelState)for(i=0;i<t.data.modelState[r].length;i++)u.push(t.data.modelState[r][i]);n.passwordUpdateMessage="Failed request due to:"+u.join(" ");n.passwordUpdateSuccessfully=!1})};n.updatePersonalInfo=function(){var i={firstName:n.userInfo.firstName,lastName:n.userInfo.lastName,businessName:n.userInfo.businessName,abnNumber:n.userInfo.abnNumber,contactNumber:n.userInfo.contactNumber,role:n.authentication.role};t.updatePersonalInfo(i).then(function(){n.accountInfoSuccessfully=!0;n.personalMessage=""},function(t){var u=[],r,i;for(r in t.data.modelState)for(i=0;i<t.data.modelState[r].length;i++)u.push(t.data.modelState[r][i]);n.personalMessage="Failed request due to:"+u.join(" ");n.personalUpdateSuccessfully=!1})};n.saveBankAccountInfo=function(){var i={accountHolderName:n.accountInfo.accountHolderName,accountNumber:n.accountInfo.accountNumber,bankName:n.accountInfo.bankName,bsbNumber:n.accountInfo.bsbNumber,id:n.accountInfo.id};t.saveBankAccountInfo(i).then(function(){n.accountInfo.accountInfoSuccessfully=!0;n.accountInfo.accountInfoMessage="Save successfully."},function(t){var u=[],r,i;for(r in t.data.modelState)for(i=0;i<t.data.modelState[r].length;i++)u.push(t.data.modelState[r][i]);n.accountInfo.accountInfoMessage="Failed request due to:"+u.join(" ");n.accountInfo.accountInfoSuccessfully=!1})}}]);app.controller("settingsController",["$scope",function(n){n.settingTab=1;n.passwordUpdateMessage="";n.passwordUpdateSuccessfully=!1;n.changePassword={password:"",confirmPassword:""};n.selectSettingTab=function(t){n.infoTab=t};n.isSettingSelected=function(n){return this.settingTab===n}}]);app.controller("refreshController",["$scope","$location","authService",function(n,t,i){n.authentication=i.authentication;n.tokenRefreshed=!1;n.tokenResponse=null;n.refreshToken=function(){i.refreshToken().then(function(t){n.tokenRefreshed=!0;n.tokenResponse=t},function(){t.path("/login")})}}]);app.controller("tokensManagerController",["$scope","tokensManagerService",function(n,t){n.refreshTokens=[];t.getRefreshTokens().then(function(t){n.refreshTokens=t.data},function(n){alert(n.data.message)});n.deleteRefreshTokens=function(i,r){r=window.encodeURIComponent(r);t.deleteRefreshTokens(r).then(function(){n.refreshTokens.splice(i,1)},function(n){alert(n.data.message)})}}]);app.controller("associateController",["$scope","$location","$timeout","authService",function(n,t,i,r){n.savedSuccessfully=!1;n.message="";n.registerData={provider:r.externalAuthData.provider,externalAccessToken:r.externalAuthData.externalAccessToken};n.registerExternal=function(){r.registerExternal(n.registerData).then(function(){n.savedSuccessfully=!0;n.message="User has been registered successfully, you will be redicted to orders page in 2 seconds.";u()},function(t){var i,r;i=[];for(r in t.modelState)i.push(t.modelState[r]);n.message=i.length!=0?"Failed to register user due to:"+i.join(" "):"Failed to register user due to:"+t.message})};var u=function(){var n=i(function(){i.cancel(n);t.path("/bookings")},2e3)}}]);app.controller("userSigninVerifyController",["$scope","$location","$routeParams","authService","ngAuthSettings",function(n,t,i,r){n.verifySignData={userId:i.id,code:i.code,useRefreshTokens:!1};n.message="";r.userVerifySignin(n.verifySignData).then(function(){t.path("/bookings")},function(t){var r=[],u,i;for(u in t.modelState)for(i=0;i<t.modelState[u].length;i++)r.push(t.modelState[u][i]);n.message=r.length!=0?"Failed to register user due to:"+r.join(" "):"Failed to register user due to:"+t.message})}]);app.controller("forgetPasswordController",["$scope","$location","$timeout","authService",function(n,t,i,r){n.savedSuccessfully=!1;n.message="";n.forgetPassword={email:""};n.forgetPasswordUser=function(){r.forgetPasswordUser(n.forgetPassword).then(function(){n.savedSuccessfully=!0;n.message="Password forget request sent to your register email address."},function(t){var r=[],u,i;for(u in t.data.modelState)for(i=0;i<t.data.modelState[u].length;i++)r.push(t.data.modelState[u][i]);n.message=r.length!=0?"Failed to register user due to:"+r.join(" "):"Failed to register user due to:"+t.message})}}]);app.controller("resetPasswordController",["$scope","$location","$routeParams","$timeout","authService",function(n,t,i,r,u){n.savedSuccessfully=!1;n.message="";n.resetPassword={userId:i.id,token:i.code,password:"",confirmPassword:""};n.resetPasswordUser=function(){if(n.resetPassword.userId==""||n.resetPassword.token==""){t.path("/login");return}u.resetPasswordUser(n.resetPassword).then(function(){n.savedSuccessfully=!0;n.message="Password successfully reset. After 5 second page redirect to login.";f()},function(t){var u=[],r,i;for(r in t.data.modelState)for(i=0;i<t.data.modelState[r].length;i++)u.push(t.data.modelState[r][i]);n.message="Failed request due to: "+u.join(" ")})};var f=function(){var n=r(function(){r.cancel(n);t.path("/login")},5e3)}}]);app.controller("myRewardsController",["$scope","bookingService",function(n,t){n.balancePoint=0;n.amountBalance="$0.00";n.points==null&&t.getRewardPoints().then(function(t){t==null||t.data==null?(n.isPointAvailable=!1,n.points=null):(n.points=t.data,n.balancePoint=t.data[0].balancePoint,n.amountBalance=t.data[0].amountBalance,n.isPointAvailable=!0)},function(n){alert(n.data.message)})}]);app.controller("myDealController",["$scope","authService",function(){}])