angular.module("app",["ngMessages","ngSanitize","ng-currency","ui.router","ct.ui.router.extras","froala","ng.shims.placeholder","client.config","cfp.hotkeys","stp.core.dataServices","stp.core.forms","stp.core.exception","stp.core.charts","app.forms","app.security","app.profile","app.unauthenticated","app.dataServices","app.infrastructure"]);angular.module("froala",[]);angular.module("ngFileUpload",[]).service("Upload",[function(){return{}}]);angular.module("app.profile",[]);angular.module("app.unauthenticated",[]);angular.module("app.dataServices",["ngCookies","client.config","app.security","restangular","ngFileUpload","stp.core.dataServices"]);angular.module("app.forms",["ui.select","stp.core.forms"]);angular.module("app.security",["ngCookies"]);angular.module("app").config(["$urlRouterProvider",function(n){n.otherwise(function(n){return n.get("authenticationService").isAuthenticated()?"/profile/dashboard":"/login"})}]).config(["$modalProvider",function(n){n.options.backdrop="static"}]).config(["$httpProvider",function(n){n.interceptors.push(["$q","$window","messageBoxService",function(n){return{responseError:function(t){return angular.isUndefined(t)?n.reject("adal:blockedRequiringAuthentication"):t.status<=0?n.reject("stp:offlineOrRequestCancelled"):n.reject(t)}}}])}]).config(["applicationConfigurationProvider","stpRaygunServiceProvider",function(n,t){t.init(n.config.raygunAPIKey)}]).config([function(){(function(){try{localStorage.setItem("_storage_test","test");localStorage.removeItem("_storage_test")}catch(i){var n={},t="__unique__";Storage.prototype.setItem=function(i,r){n[t+i]=r};Storage.prototype.getItem=function(i){return n[t+i]===undefined?null:n[t+i]};Storage.prototype.removeItem=function(i){delete n[t+i]};Storage.prototype.clear=function(){n={}}}})()}]);angular.module("app").run(function(){FastClick.attach(document.body)}).run(["uiMaskConfig",function(n){var i=/(android)/i.test(navigator.userAgent),t;i&&(t=n.eventsToHandle.indexOf("input"),n.eventsToHandle.splice(t,1))}]);angular.module("app").config(["$stateProvider",function(n){n.state("root",{abstract:!0,template:"<ui-view />"})}]);angular.module("app.profile").config(["$stateProvider",function(n){n.state("profile",{parent:"root",abstract:!0,url:"/profile",template:"<div profile-master-page stp-scroll-to-top><div ui-view><\/div><\/div>",params:{showSidebar:!0}}).state("profile.dashboard",{url:"/dashboard",templateUrl:"/app/areas/profile/dashboard/dashboard.html",controller:"DashboardController",controllerAs:"ctrl",params:{siteTextKey:null,siteTextType:null,transaction:null},resolve:{autoTopup:["autoTopupService",function(n){return n.get()}],cardDetails:["cardService",function(n){return n.getCardDetails()}]}}).state("profile.blockCard",{url:"/blockcard",templateUrl:"/app/areas/profile/blockcard/blockcard.html",controller:"BlockCardController",controllerAs:"ctrl"}).state("profile.topup",{url:"/topup",templateUrl:"/app/areas/profile/topup/topup.html",controllerAs:"ctrl",controller:"TopupController",resolve:{cardDetails:["cardService",function(n){return n.getCardDetails()}]}}).state("profile.topupresult",{url:"/topupresult/{transactionId}",controller:"TopupResultController",controllerAs:"ctrl",resolve:{transaction:["$stateParams","dpsTransactionService",function(n,t){return t.getById(n.transactionId)}]}}).state("profile.autotopup",{url:"/autotopup",templateUrl:"/app/areas/profile/autotopup/autotopup.html",controllerAs:"ctrl",controller:"AutoTopupController",resolve:{autoTopup:["autoTopupService",function(n){return n.get()}]}}).state("profile.autotopupresult",{url:"/autotopupresult/{transactionId}",controller:"AutoTopupResultController",controllerAs:"ctrl",resolve:{transaction:["$stateParams","dpsTransactionService",function(n,t){return t.getById(n.transactionId)}]}}).state("profile.changePassword",{url:"/changePassword",templateUrl:"/app/areas/profile/changepassword/changepassword.html",controller:"ChangePasswordController",controllerAs:"ctrl"}).state("profile.changeProfile",{url:"/changeProfile",templateUrl:"/app/areas/profile/changeprofile/changeprofile.html",controller:"ChangeProfileController",controllerAs:"ctrl",resolve:{profile:["profileService",function(n){return n.getProfile()}]}}).state("profile.journeyHistory",{url:"/journeyHistory",templateUrl:"/app/areas/profile/journeyhistory/journeyhistory.html",controller:"JourneyHistoryController",controllerAs:"ctrl"})}]);angular.module("app.profile").controller("AutoTopupController",["$window","autoTopup","autoTopupFieldsService","autoTopupService","enums","messageBoxService","$state",function(n,t,i,r,u,f,e){function v(){l(!0)}function y(){l(!1)}function p(){a()}function l(n){o.original.amount=o.autoTopup.amount;o.original.thresholdAmount=o.autoTopup.thresholdAmount;o.showStatus=!1;o.showAmountsForm=!0;o.amountsFormSubmitText=n?"Authorise Your Credit Card":"Save";h=n;o.showAuthorisationFields=n}function w(){o.showStatus=!0;o.showAmountsForm=!1}function b(){o.autoTopup.amount=o.original.amount;o.autoTopup.thresholdAmount=o.original.thresholdAmount;w()}function k(n){if(n.$valid&&nt()){c();var t=r.save(o.autoTopup);h?t.then(a):t.then(function(){e.go("profile.dashboard",{siteTextKey:"auto_top_up_amount_changed"})});t.catch(s)}}function a(){c();r.getAuthorisationUrl(o.autoTopup).then(d).catch(s)}function d(t){t.success&&t.paymentExpressTopupUrl?n.location=t.paymentExpressTopupUrl:(o.errorMessage="Auto top up card authorisation could not be started at this time. Please try again in a few moments.",s())}function g(){c();r.disable(o.autoTopup).then(function(){e.go("profile.dashboard",{siteTextKey:"auto_top_up_stopped"})}).catch(s)}function nt(){return o.autoTopup.amount>=100?f.confirm("Please confirm you want to turn on auto topups for $"+o.autoTopup.amount+"?"):!0}function c(){o.busy=!0}function s(){o.busy=!1}var o=this,h;o.autoTopup=t;o.autoTopupStatuses=u.autoTopupStatus;o.formFields=i.getFields();o.formAuthorisationFields=i.getAuthorisationFields();o.showStatus=!0;o.showAmountsForm=!1;o.showAuthorisationFields=!0;o.amountsFormSubmitText="";o.original={};o.setupNowClick=v;o.changeAmountsClick=y;o.changeCardDetailsClick=p;o.stopClick=g;o.saveAmountsClick=k;o.cancelAmountsClick=b;h=!1}]);angular.module("app.profile").service("autoTopupFieldsService",["fieldsService",function(n){function i(){return n.createRows([{key:"thresholdAmount",type:"currency",templateOptions:{required:!0,label:"When my balance falls below",min:5,minValidationMessage:"Minimum amount is $5.00"}},{key:"amount",type:"currency",templateOptions:{label:"Top-up my card with",required:!0,min:10,max:200,minValidationMessage:"Minimum topup amount is $10.00",maxValidationMessage:"Maximum topup amount is $200.00"}}],[1])}function r(){return n.createRows([{template:"<metrocard-site-text site-text-key=\"'auto_topup_dps_payment_disclaimer'\"><\/metrocard-site-text>"},{key:"confirmAutoTopup",type:"checkbox",templateOptions:{required:!0,requiredValidationMessage:"Please acknowledge the DPS instructions.",label:"I have read and understood this."}}],[1])}var t=this;t.getFields=i;t.getAuthorisationFields=r}]);angular.module("app.profile").controller("AutoTopupResultController",["$state","transaction","enums",function(n,t,i){function r(){var r,u;t.status===i.dpsTransactionStatus.paymentSucceeded?r="payment_details_updated":(r="unsuccessful_auto_topup_authorisation",u="danger");n.go("profile.dashboard",{siteTextKey:r,siteTextType:u})}r()}]);angular.module("app.profile").controller("BlockCardController",["blockCardFieldsService","$uibModal",function(n,t){function r(n){n.$valid&&t.open({templateUrl:"/app/areas/profile/blockcard/blockcardconfirmation.html",controller:"BlockCardConfirmationController",controllerAs:"ctrl"})}var i=this;i.formFields=n.getFields();i.submit=r}]);angular.module("app.unauthenticated").service("blockCardFieldsService",["fieldsService",function(n){function i(){return n.createRows([{key:"confirmBlock",type:"checkbox",templateOptions:{required:!0,requiredValidationMessage:"Please confirm you want to block your card.",label:"Yes"}}],[1])}var t=this;t.getFields=i}]);angular.module("app.profile").controller("BlockCardConfirmationController",["authenticationService","cardService","$uibModalInstance",function(n,t,i){function u(){r.busy=!0;t.blockCard().then(f).finally(function(){i.close();r.busy=!1})}function f(){n.logout()}var r=this;r.confirmBlockCard=u}]);angular.module("app.profile").controller("ChangePasswordController",["$state","changePasswordFieldsService","accountService",function(n,t,i){function f(n){n.$valid&&(r.busy=!0,i.changePassword(r.formModel.currentPassword,r.formModel.newPassword).then(e).catch(o).finally(function(){r.busy=!1}))}function e(t){t.success?n.go("profile.dashboard",{siteTextKey:"change_password_success"}):u(t.error)}function o(){u("There was an error communicating with the system. Please check your connection and try again.")}function u(n){r.errorMessage=n}var r=this;r.formModel={currentPassword:"",newPassword:"",confirmPassword:""};r.formFields=t.getFields();r.submit=f;r.busy=!1;r.errorMessage=null}]);angular.module("app.unauthenticated").service("changePasswordFieldsService",["fieldsService","passwordFieldsService",function(n,t){function r(){return n.createRows([{key:"currentPassword",type:"password-noLabel",templateOptions:{placeholder:"Current password",focus:!0,required:!0}},t.newPasswordField(),t.confirmPasswordField(),{template:'<div class="form-group"><metrocard-site-text site-text-key="\'password_guidelines\'"><\/metrocard-site-text> <br /><div/>'}],[1])}var i=this;i.getFields=r}]);angular.module("app.profile").controller("ChangeProfileController",["$state","changeProfileFieldsService","profile","profileService",function(n,t,i,r){function f(n){n.$valid&&(u.busy=!0,r.save(i).then(o).catch(e).finally(function(){u.busy=!1}))}function e(){u.errorMessage="There was an error communicating with the system. Please check your connection and try again."}function o(t){t.success?t.emailHasChange?n.go("profile.dashboard",{siteTextKey:"update_email_success"}):n.go("profile.dashboard",{siteTextKey:"update_profile_success"}):u.errorMessage="Please check your password and try again"}var u=this;u.profile=i;u.formFields=t.getFields(i.email);u.submit=f;u.busy=!1;u.errorMessage=null}]);angular.module("app.unauthenticated").service("changeProfileFieldsService",["fieldsService",function(n){function i(t){var i=n.createRows([{key:"fullName",type:"text-noLabel",expressionProperties:{"templateOptions.disabled":"true"},templateOptions:{placeholder:"Full Name"}},{key:"dateOfBirth",type:"date-noLabel",expressionProperties:{"templateOptions.disabled":"true"}},{key:"phoneNumber",type:"text-noLabel",templateOptions:{required:!0,patternValidationMessage:"Please enter numbers and spaces only",placeholder:"Phone number"},validators:{pattern:{expression:function(n,t){var i=t||n;return i&&!!i.match(/^[0-9 ]+$/)}}}},{key:"email",type:"text-noLabel",templateOptions:{required:!0,patternValidationMessage:"Please enter a valid email address",placeholder:"Email"},validators:{pattern:{expression:function(n,t){var i=t||n;return i&&!!i.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)}}}},{key:"password",type:"password-noLabel",templateOptions:{placeholder:"Password",requiredValidationMessage:"You must enter your password in order to change your email address."},watcher:{expression:"model.email",listener:function(n,i,r){i!==r&&i!==t?(n.templateOptions.required=!0,n.hideExpression=function(){return!1}):(n.templateOptions.required=!1,n.hideExpression=function(){return!0})}}},{key:"apartmentOrFlat",type:"text-noLabel",templateOptions:{placeholder:"Apartment or flat"}},{key:"streetNumber",type:"text-noLabel",templateOptions:{placeholder:"Street Number"}},{key:"streetName",type:"text-noLabel",templateOptions:{required:!0,placeholder:"Street Name"}},{key:"suburb",type:"text-noLabel",templateOptions:{placeholder:"Suburb"}},{key:"townOrCity",type:"text-noLabel",templateOptions:{required:!0,placeholder:"Town or city"}}],[1]);return i.push(n.createRow([{key:"postCode",type:"text-noLabel",templateOptions:{patternValidationMessage:"Please enter numbers only",placeholder:"Post code"},validators:{pattern:{expression:function(n,t){var i=t||n;return i&&!!i.match(/^[0-9 ]+$/)}}}},{template:"<div class=\"col-md-3\"><a href='https://www.nzpost.co.nz/tools/address-postcode-finder' target='_blank'>Postcode Finder<\/a><\/div>",className:"postcode"}],4),{key:"newsFromMetro",type:"checkbox",templateOptions:{label:"I'd like to receive service information and Metro offers."}}),i}var t=this;t.getFields=i}]);angular.module("app.profile").controller("DashboardController",["$stateParams","autoTopup","cardDetails","enums",function(n,t,i,r){var u=this;u.cardDetails=i;u.autoTopup=t;u.autoTopupStatuses=r.autoTopupStatus;u.transaction=n.transaction;u.siteTextMessageKey=n.siteTextKey;u.siteTextAlertType=n.siteTextType||"info"}]);angular.module("app.profile").controller("JourneyHistoryController",["journeyHistoryService","arrayDataSourceFactory","enums",function(n,t,i){function f(n){r.numberOfDays=n;u()}function e(){u()}function u(){return r.busy=!0,n.getJourneyHistory(r.numberOfDays).then(function(n){n=_(n).reverse().value();r.dataSource=t(n)}).finally(function(){r.busy=!1})}var r=this;r.numberOfDays=7;r.applyFilter=f;r.options=[{id:7,name:"1 Week"},{id:30,name:"1 Month"},{id:90,name:"3 Months"}];r.journeyHistoryType=i.journeyHistoryType;e()}]);angular.module("app.profile").directive("profileMasterPage",[function(){return{restrict:"EA",transclude:!0,scope:{},templateUrl:"/app/areas/profile/masterpage/profilemasterpage.html",controllerAs:"masterPage",controller:["$rootScope","$state","$stateParams","authenticationService",function(n,t,i,r){function e(){n.$on("$stateChangeStart",o);n.$on("$stateChangeSuccess",s)}function o(){u.busy=!0;f()}function s(){u.busy=!1}function f(){u.sidebarOpen=!1}function h(){u.sidebarOpen=!u.sidebarOpen}function c(){r.logout()}function l(){return r.isAuthenticated()}var u=this;u.busy=!1;u.sidebarOpen=!1;u.logout=c;u.isAuthenticated=l;u.closeSidebar=f;u.toggleSidebar=h;e()}]}}]);angular.module("app.profile").controller("TopupController",["$window","topupFieldsService","topupService","cardDetails","messageBoxService",function(n,t,i,r,u){function o(n){n.$valid&&c()&&(s(),i.createTopup(f.topup.amount).then(h).catch(e))}function s(){f.busy=!0}function e(){f.busy=!1}function h(t){t.success&&t.paymentExpressTopupUrl?n.location=t.paymentExpressTopupUrl:(f.errorMessage="Your top up could not be processed at this time. Please try again in a few moments.",e())}function c(){return f.topup.amount>=100?u.confirm("Please confirm you want to top up $"+f.topup.amount+"?"):!0}var f=this;f.cardDetails=r;f.formFields=t.getFields();f.submit=o;f.topup={amount:10}}]);angular.module("app.profile").service("topupFieldsService",["fieldsService",function(n){function i(){return n.createRows([{template:"<span>How much would you like to add to your card?<\/span>"},{key:"amount",type:"currency-noLabel",templateOptions:{placeholder:"Amount",required:!0,min:10,max:200,minValidationMessage:"Minimum top up amount is $10.00",maxValidationMessage:"Maximum top up amount is $200.00"}}],[1,6])}var t=this;t.getFields=i}]);angular.module("app.profile").controller("TopupResultController",["$state","transaction",function(n,t){function i(){n.go("profile.dashboard",{transaction:t})}i()}]);angular.module("app.unauthenticated").config(["$stateProvider",function(n){n.state("unauthenticated",{parent:"root",templateUrl:"/app/areas/unauthenticated/unauthenticated.html",abstract:!0,data:{allowAnonymous:!0}}).state("unauthenticated.login",{url:"/login",templateUrl:"/app/areas/unauthenticated/login/login.html",controller:"loginController",controllerAs:"ctrl",params:{metrocardNo:null}}).state("unauthenticated.forgotPassword",{url:"/forgotPassword",templateUrl:"/app/areas/unauthenticated/forgotpassword/forgotpassword.html",controller:"forgotPasswordController",controllerAs:"ctrl"}).state("unauthenticated.resetPassword",{url:"/resetPassword?token",templateUrl:"/app/areas/unauthenticated/resetpassword/resetpassword.html",controller:"resetPasswordController",controllerAs:"ctrl"}).state("unauthenticated.registration",{template:"<ui-view/>",abstract:!0}).state("unauthenticated.registration.new",{url:"/registration",templateUrl:"/app/areas/unauthenticated/registration/newregistration.html",controller:"newRegistrationController",controllerAs:"ctrl",resolve:{registration:["registrationService",function(n){return n.getNewRegistration()}]}}).state("unauthenticated.registration.personalDetails",{url:"/personalDetails",templateUrl:"/app/areas/unauthenticated/registration/personaldetails.html",controller:"personalDetailsController",controllerAs:"ctrl",params:{registrationData:null}}).state("unauthenticated.registration.success",{url:"/success",templateUrl:"/app/areas/unauthenticated/registration/registrationsuccess.html",controller:"registrationSuccessController",controllerAs:"ctrl",params:{successfully:!1}}).state("unauthenticated.registration.confirmation",{url:"/confirmation?token",templateUrl:"/app/areas/unauthenticated/registration/confirmation.html",controller:"confirmationController",controllerAs:"ctrl"}).state("terms",{parent:"root",url:"/terms",templateUrl:"/app/areas/unauthenticated/registration/terms.html",data:{allowAnonymous:!0}}).state("unauthenticated.confirmEmail",{url:"/confirmEmail?token",templateUrl:"/app/areas/unauthenticated/confirmemail/confirmemail.html",controller:"confirmEmailController",controllerAs:"ctrl"})}]);angular.module("app.profile").controller("confirmEmailController",["$stateParams","profileService",function(n,t){function f(n){n?(i.showSuccessMessage=!0,i.showErrorMessage=!1):u()}function u(){i.showSuccessMessage=!1;i.showErrorMessage=!0}var r=n.token,i=this;i.busy=!0;i.showSuccessMessage=!1;i.showErrorMessage=!1;r?t.confirmEmailChange(r).then(f,u).finally(function(){i.busy=!1}):(i.busy=!1,i.showErrorMessage=!0)}]);angular.module("app.profile").controller("forgotPasswordController",["$state","forgotPasswordFieldsService","anonymousAccountService",function(n,t,i){function u(n){n.$valid&&(r.busy=!0,i.forgotPassword(r.formModel.metrocardNo).then(e,f).finally(function(){r.busy=!1}))}function f(){r.errorMessage="There was an error communicating with the system. Please check your connection and try again."}function e(){r.success=!0}var r=this;r.formModel={};r.formFields=t.getFields();r.submit=u;r.busy=!1;r.success=!1}]);angular.module("app.unauthenticated").service("forgotPasswordFieldsService",["fieldsService",function(n){function i(){return n.createRows([{key:"metrocardNo",type:"integer-noLabel",templateOptions:{focus:!0,required:!0,placeholder:"Metrocard number"}}],[1])}var t=this;t.getFields=i}]);angular.module("app.profile").controller("loginController",["$state","loginFieldsService","authenticationService","$stateParams",function(n,t,i,r){function f(){r.metrocardNo&&(u.formModel.metrocardNo=parseInt(r.metrocardNo+"",10))}function e(n){u.loginError=null;n.$valid&&(u.busy=!0,i.login(u.formModel.metrocardNo,u.formModel.password).then(o,s))}function o(t){t?n.go("profile.dashboard"):(u.loginError="Your card number or password are not correct. Please check them and try again.",u.busy=!1)}function s(){u.loginError="There was an error while trying to log you in. Please check your connection and try again.";u.busy=!1}var u=this;u.formModel={};u.formFields=t.getFields();u.login=e;u.busy=!1;f()}]);angular.module("app.unauthenticated").service("loginFieldsService",["fieldsService",function(n){function i(){return n.createRows([{key:"metrocardNo",type:"integer-noLabel",templateOptions:{placeholder:"Metrocard number",focus:!0,required:!0}},{key:"password",type:"password-noLabel",templateOptions:{placeholder:"Password",required:!0}},{template:'<div class="form-group"><a href="" ui-sref="unauthenticated.forgotPassword">Forgot Password?<\/a><\/div>'}],[1])}var t=this;t.getFields=i}]);angular.module("app.profile").controller("confirmationController",["$stateParams","registrationService","$state",function(n,t,i){function e(n){n.isValid?(r.showSuccessMessage=!0,r.showErrorMessage=!1,u=n.metrocardNo):f()}function f(){r.showSuccessMessage=!1;r.showErrorMessage=!0}function o(){i.go("unauthenticated.login",{metrocardNo:u})}var r=this,u;r.busy=!0;r.showSuccessMessage=!1;r.showErrorMessage=!1;r.loginClick=o;n.token?t.confirmRegistration(n.token).then(e,f).finally(function(){r.busy=!1}):(r.busy=!1,r.showErrorMessage=!0)}]);angular.module("app.profile").controller("newRegistrationController",["newRegistrationFieldsService","registrationService","registration","$state",function(n,t,i,r){function f(n){n.$valid&&(u.busy=!0,t.checkCardAvailability(u.registration).then(e).finally(function(){u.busy=!1}))}function e(n){n.errorMessage!=null?o(n.errorMessage):n.hasUserProfile?r.go("unauthenticated.registration.success",{successfully:!0}):r.go("unauthenticated.registration.personalDetails",{registrationData:u.registration})}function o(n){u.errorMessage=n}var u=this;u.registration=i;u.formFields=n.getFields();u.submit=f}]);angular.module("app.profile").service("newRegistrationFieldsService",["fieldsService","passwordFieldsService",function(n,t){function r(){return n.createRows([{template:"<h2>Create online account<\/h2>"},{key:"metrocardNumber",type:"integer-noLabel",templateOptions:{focus:!0,label:"Metrocard Number",min:0,required:!0,placeholder:"Metrocard number",requiredValidationMessage:"Please enter your Metrocard number"}},{template:'<div class="form-group"><metrocard-site-text site-text-key="\'metrocard_number_info\'"><\/metrocard-site-text><\/div>'},{key:"registrationCode",type:"text-noLabel",templateOptions:{required:!0,placeholder:"Registration code",requiredValidationMessage:"Please enter the registration code provided"}},{template:'<div class="form-group"><metrocard-site-text site-text-key="\'registration_code_info\'"><\/metrocard-site-text><\/div>'},{key:"email",type:"text-noLabel",templateOptions:{required:!0,placeholder:"Email address",onChange:function(n,t,i){var r=_.find(_.keys(i.form),function(n){return n.indexOf("formly_")===0&&n.indexOf("confirmEmail")>0});r&&i.form[r].$validate()},patternValidationMessage:"Please enter a valid email address",requiredValidationMessage:"Please enter your email address"},validators:{pattern:{expression:function(n,t){var i=t||n;return i&&!!i.match(/^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/)}}}},{key:"confirmEmail",type:"text-noLabel",templateOptions:{required:!0,confirmValidationMessage:"Email and Confirm Email do not match",requiredValidationMessage:"Please re-enter your email address",placeholder:"Confirm email"},validators:{confirm:{expression:function(n,t,i){return(t||n)===i.model.email}}}},{template:"<br/>"},t.newPasswordField("password","confirmPassword","Password"),t.confirmPasswordField("confirmPassword","password","Confirm Password"),{template:'<div class="form-group"><metrocard-site-text site-text-key="\'password_guidelines\'"><\/metrocard-site-text> <br /><div/>'},{template:"<br/>"},{key:"newsFromMetro",type:"checkbox",templateOptions:{label:"I'd like to receive service information and Metro offers."}},{key:"agreeTermsAndConditions",type:"checkbox",templateOptions:{required:!0,requiredValidationMessage:"Please agree to the terms and conditions",label:'I agree to the Metrocard <a href="#/terms" target="_blank">terms and conditions<\/a>.',labelIsHtml:!0}}],[1])}var i=this;i.getFields=r}]);angular.module("app.profile").controller("personalDetailsController",["$stateParams","personalDetailsFieldsService","registrationService","$state",function(n,t,i,r){function f(n){n.$valid&&(u.busy=!0,i.save(u.registration).then(e).finally(function(){u.busy=!1}))}function e(){r.go("unauthenticated.registration.success",{successfully:!0})}var u=this;u.registration=n.registrationData;u.registration||r.go("unauthenticated.registration.new");u.formFields=t.getFields();u.submit=f}]);angular.module("app.profile").service("personalDetailsFieldsService",["fieldsService",function(n){function i(){return n.createRows([{template:"<h2>Your details<\/h2>"},{type:"text-noLabel",key:"fullName",templateOptions:{placeholder:"Full name",focus:!0}},{key:"dateOfBirth",type:"date-noLabel",templateOptions:{placeholder:"Date of birth"}},{type:"text-noLabel",key:"phoneNumber",templateOptions:{placeholder:"Phone number",required:!0,patternValidationMessage:"Please enter numbers and spaces only"},validators:{pattern:{expression:function(n,t){var i=t||n;return i&&!!i.match(/^[0-9 ]+$/)}}}},{template:"<h2>Address<\/h2>"},{key:"apartmentOrFlat",type:"text-noLabel",templateOptions:{placeholder:"Apartment or flat"}},{key:"streetNumber",type:"text-noLabel",templateOptions:{placeholder:"Street number"}},{key:"streetName",type:"text-noLabel",templateOptions:{placeholder:"Street name",required:!0}},{key:"suburb",type:"text-noLabel",templateOptions:{placeholder:"Suburb"}},{key:"townOrCity",type:"text-noLabel",templateOptions:{placeholder:"Town or city",required:!0}},{key:"postCode",type:"text-noLabel",templateOptions:{placeholder:"Postcode",patternValidationMessage:"Please enter numbers only"},validators:{pattern:{expression:function(n,t){var i=t||n;return i&&!!i.match(/^[0-9 ]+$/)}}}},{template:"<a href='https://www.nzpost.co.nz/tools/address-postcode-finder' target='_blank'>Postcode finder<\/a>"}],[1,1,1,1,1,1,1,1,1,1,2])}var t=this;t.getFields=i}]);angular.module("app.profile").controller("registrationSuccessController",["$stateParams","$state",function(n,t){_this=this;n.successfully||t.go("unauthenticated.registration.new")}]);angular.module("app.profile").controller("resetPasswordController",["$state","resetPasswordFieldsService","$stateParams","anonymousAccountService",function(n,t,i,r){function e(n){n.$valid&&(u.busy=!0,r.resetPassword(u.formModel.metrocardNo,u.formModel.newPassword,i.token).then(s).catch(o).finally(function(){u.busy=!1}))}function o(n){n.status===404?f():c("There was an error communicating with the system. Please check your connection and try again.")}function s(n){n.success?h():f()}function h(){u.success=!0;u.standardError=!1;u.specificError=null}function f(){u.success=!1;u.standardError=!0;u.specificError=null}function c(n){u.success=!1;u.standardError=!1;u.specificError=n}var u=this;u.formModel={email:"",newPassword:"",confirmPassword:""};u.formFields=t.getFields();u.submit=e;u.busy=!1;u.success=!1;u.standardError=!1;u.specificError=null}]);angular.module("app.unauthenticated").service("resetPasswordFieldsService",["fieldsService","passwordFieldsService",function(n,t){function r(){return n.createRows([{key:"metrocardNo",type:"integer-noLabel",templateOptions:{focus:!0,required:!0,placeholder:"Metrocard number"}},t.newPasswordField(),t.confirmPasswordField(),{template:'<div class="form-group"><metrocard-site-text site-text-key="\'password_guidelines\'"><\/metrocard-site-text> <br /><div/>'}],[1])}var i=this;i.getFields=r}]);angular.module("app.dataServices").service("accountService",["Restangular",function(n){function i(t,i){return n.one("account").customPOST({currentPassword:t,newPassword:i},"changepassword")}var t=this;t.changePassword=i}]);angular.module("app.dataServices").service("autoTopupService",["Restangular","restangularAdapterFactory","enums",function(n,t,i){function f(){return n.one("autotopup").get()}function u(n){return t(n).save()}function e(n){return n.status=i.autoTopupStatus.disabled,u(n)}function o(t){return n.one("autotopup",t.id).one("authorisationurl").get()}var r=this;r.get=f;r.save=u;r.disable=e;r.getAuthorisationUrl=o}]);angular.module("app.dataServices").service("cardService",["Restangular",function(n){function i(){return n.one("card").get()}function r(){return n.one("card").customPOST({},"block")}var t=this;t.getCardDetails=i;t.blockCard=r}]);angular.module("app.dataServices").config(["RestangularProvider","applicationConfigurationProvider",function(n,t){n.setBaseUrl(t.config.apiBaseUrl);n.addRequestInterceptor(function(n,t){return t==="remove"?null:(n&&n.computedFields&&delete n.computedFields,n)})}]);angular.module("app.dataServices").service("dpsTransactionService",["Restangular",function(n){function i(t){return n.one("dpstransaction",t).get()}var t=this;t.getById=i}]);angular.module("app.dataServices").service("journeyHistoryService",["Restangular",function(n){function i(t){return n.all("journeyHistory").getList({numberOfDays:t})}var t=this;t.getJourneyHistory=i}]);angular.module("app.dataServices").service("profileService",["Restangular",function(n){function i(){return n.one("profile").get()}function r(n){return n.save()}function u(t){return n.one("account").customPOST({token:t},"confirmEmailChange")}var t=this;t.getProfile=i;t.confirmEmailChange=u;t.save=r}]);angular.module("stp.core.dataServices").service("siteSectionStatusService",["$q","$timeout","Restangular","siteSections",function(n,t,i,r){function f(n){return _.find(u,function(t){return t.key===n})}function e(){t(s,18e4)}function s(){i.one("websitesectionstatus").getList().then(h)}function h(n){_.each(n,function(n){var t=f(n.key);t&&(t.enabled=n.enabled,t.message=n.message)});e()}var o=this,u;o.getSiteSectionStatusByKey=f;u=r;e()}]);angular.module("stp.core.dataServices").service("siteTextService",["siteTexts",function(n){function r(){t=n;_.each(n,u)}function u(n){!n.isHtml&&n.content.indexOf("\n")>=0&&(n.plainText=n.content,n.content=n.content.replace(/\n/g,"<br/>"),n.isHtml=!0)}function f(n){return _.find(t,function(t){return t.key===n})}var i=this,t;i.getSiteText=f;r()}]);angular.module("app.dataServices").service("topupService",["Restangular",function(n){function i(t){return n.one("topup").customPOST({amount:t})}var t=this;t.createTopup=i}]);angular.module("app.dataServices").service("anonymousAccountService",["Restangular",function(n){function i(t){return n.one("account",t).customPOST(null,"forgotpassword")}function r(t,i,r){return n.one("account",t).customPOST({newPassword:i,token:r},"resetpassword")}var t=this;t.forgotPassword=i;t.resetPassword=r}]);angular.module("app.dataServices").service("registrationService",["dataSourceFactory","Restangular",function(n,t){function u(){return r.one("new").get()}function f(n){return r.one("new").customPUT(n)}function e(n){return r.one("new").customPOST(n)}function o(n){return t.one("registration").customPOST({token:n},"confirm")}var i=this,r;i.getNewRegistration=u;i.checkCardAvailability=f;i.save=e;i.confirmRegistration=o;r=t.all("registration")}]);angular.module("app.forms").controller("BodyController",["$rootScope","$stateParams","authenticationService",function(n,t,i){function u(){n.$on("$stateChangeSuccess",function(){f();r.initialising=!1})}function f(){r.showSidebar=t.showSidebar===!0}function e(){return i.isAuthenticated()}var r=this;r.showSidebar=!1;r.isAuthenticated=e;r.initialising=!0;u()}]);angular.module("app.forms").run(["formlyConfig",function(){}]);angular.module("app.forms").controller("AutoTopUpDetailsController",["enums",function(n){var t=this;t.autoTopupStatuses=n.autoTopupStatus}]);angular.module("app.forms").directive("autoTopUpDetails",[function(){return{restrict:"E",scope:{autoTopup:"="},templateUrl:"/app/forms/components/autotopupdetails/autotopupdetails.html",controller:"AutoTopUpDetailsController",controllerAs:"ctrl",bindToController:!0,transclude:!0}}]);angular.module("app.forms").controller("CardDetailsController",[function(){function t(){n.showTopupDelaysDisclaimer=!n.showTopupDelaysDisclaimer}var n=this;n.showTopupDelaysDisclaimer=!1;n.toggleDisclaimer=t}]);angular.module("app.forms").directive("metrocardCardDetails",[function(){return{restrict:"E",scope:{cardDetails:"="},templateUrl:"/app/forms/components/carddetails/carddetails.html",controller:"CardDetailsController",controllerAs:"ctrl",bindToController:!0}}]);angular.module("app.forms").controller("TransactionResultController",["enums",function(n){var t=this;t.transactionStatuses=n.dpsTransactionStatus}]);angular.module("app.forms").directive("transactionResult",[function(){return{restrict:"E",scope:{transaction:"="},templateUrl:"/app/forms/components/transactionresult/transactionresult.html",controller:"TransactionResultController",controllerAs:"ctrl",bindToController:!0}}]);angular.module("app").service("passwordFieldsService",[function(){function r(i,r,u){return{key:i||n,type:"password-noLabel",templateOptions:{requiredValidationMessage:"Please enter a valid password",placeholder:u||"New password",required:!0,patternValidationMessage:"Password does not meet security requirements",onChange:function(n,i,u){var f=_.find(_.keys(u.form),function(n){return n.indexOf("formly_")===0&&n.indexOf(r||t)>0});f&&u.form[f].$validate()}},validators:{pattern:{expression:function(n,t){var i=t||n;return i?i.length<8?!1:!!i.match("(?=.*[a-z])(?=.*[A-Z])(?=.*[^a-zA-Z])"):!1}}}}}function u(i,r,u){return{type:"password-noLabel",key:i||t,templateOptions:{requiredValidationMessage:"Please re-enter the password",placeholder:u||"Confirm password",required:!0,confirmValidationMessage:"Password and Confirm Password do not match"},validators:{confirm:{expression:function(t,i,u){var f=i||t;return f===u.model[r||n]}}}}}var i=this,n,t;i.newPasswordField=r;i.confirmPasswordField=u;n="newPassword";t="confirmPassword"}]);angular.module("app.forms").filter("firstName",function(){return function(n){if(n){var t=n.split(" ");if(t&&t.length>0)return t[0]}return n}});angular.module("stp.core.forms").controller("SiteSectionController",["siteSectionStatusService",function(n){function i(){var i=n.getSiteSectionStatusByKey(t.sectionKey);t.status.enabled=i.enabled;t.status.message=i.message}var t=this;t.status={enabled:!1,message:""};i()}]);angular.module("app.forms").directive("metrocardSiteSection",[function(){return{restrict:"E",scope:{sectionKey:"@"},transclude:!0,templateUrl:"/app/forms/sitesection/sitesection.html",controller:"SiteSectionController",controllerAs:"ctrl",bindToController:!0}}]);angular.module("stp.core.forms").controller("SiteTextController",["siteTextService",function(n){function i(){if(!t.siteTextKey){t.siteText.content='no site text key. Check for attribute "site-text-key"';return}var i=n.getSiteText(t.siteTextKey);i?(t.siteText.isHtml=i.isHtml,t.siteText.content=i.content):t.siteText.content="error getting site text for key ["+t.siteTextKey+"]. Check key in database"}var t=this;t.siteText={content:"",isHtml:!1};i()}]);angular.module("app.forms").directive("metrocardSiteText",[function(){return{restrict:"E",scope:{siteTextKey:"="},templateUrl:"/app/forms/sitetext/sitetext.html",controller:"SiteTextController",controllerAs:"ctrl",bindToController:!0}}]);angular.module("app.security").service("authenticationService",["$q","$injector","applicationConfiguration",function(n,t,i){function h(){return!!e()}function c(){sessionStorage.removeItem("metrocard-access_token");sessionStorage.removeItem("metrocard-refresh_token");f=f||t.get("$state");f.go("unauthenticated.login")}function e(){return sessionStorage.getItem("metrocard-access_token")}function l(t,i){var r=n.defer();return s("grant_type=password&username="+t+"&password="+i).success(function(n){o(n);r.resolve(!0)}).error(function(n){n&&n.error==="invalid_grant"?r.resolve(!1):r.reject()}),r.promise}function a(){var t=n.defer(),i=sessionStorage.getItem("metrocard-refresh_token");return i?s("grant_type=refresh_token&refresh_token="+i).success(function(n){o(n);t.resolve(n)}).error(function(n){t.reject(n)}):t.reject(),t.promise}function o(n){sessionStorage.setItem("metrocard-access_token",n.access_token);sessionStorage.setItem("metrocard-refresh_token",n.refresh_token)}function s(n){var r=i.apiBaseUrl+"/token";return u=u||t.get("$http"),u.post(r,n,{headers:{"Content-Type":"application/x-www-form-urlencoded"}})}var r=this,u,f;r.isAuthenticated=h;r.getBearerToken=e;r.refreshToken=a;r.logout=c;r.login=l}]);angular.module("app.security").config(["$httpProvider",function(n){n.interceptors.push(["$q","$injector","$window","$timeout","authenticationService",function(n,t,i,r,u){function e(n,i){f=f||t.get("$http");f(n).then(function(n){i.resolve(n)},function(n){i.reject(n)})}function o(n){return u.isAuthenticated()&&(n.headers.Authorization="Bearer "+u.getBearerToken()),n}function s(t){var i=n.defer();return t.status===401?u.refreshToken().then(function(){e(t.config,i)},function(){u.logout();i.reject(t)}):i.reject(t),i.promise}var f;return{request:o,responseError:s}}])}]).run(["$rootScope","$state","authenticationService","httpUtilityService",function(n,t,i){n.$on("$stateChangeStart",function(n,r){var u=i.isAuthenticated()||r.data&&r.data.allowAnonymous;u||(n.preventDefault(),t.go("unauthenticated.login"))})}])