"use strict";var animations=angular.module("myCallPlusAnimations",["ngAnimate"]),controllers;animations.animation(".splash-screen",function(){return{addClass:function(n,t,i){setTimeout(function(){n.remove();i()},500)}}});controllers=angular.module("myCallPlusControllers",["cgBusy"]);controllers.controller("PageWrapperController",["$scope","$location","$route","$anchorScroll","$q","authService","messages","callplusAPI",function(n,t,i,r,u,f,e,o){try{n.loadingPromise=o.getDefaultAccountClaim().then(function(t){return n.Claim=t.Claim,n.AccountClaimSelection=n.Claim,u.all([o.Manage.GetProducts(t.Claim.AccountCode).then(function(t){(t.data.ProductBundles&&t.data.ProductBundles.length>0||t.data.CoreProducts&&t.data.CoreProducts.length>0)&&(n.isPlanInformationAvailable=!0)}),o.getAllAccountClaims().then(function(t){n.AccountClaims=[];angular.isArray(t)?angular.extend(n.AccountClaims,t):n.AccountClaims.push(t)}),o.Manage.GetContactInformation(t.Claim.AccountCode).then(function(t){n.ContactName=t.data.ContactInformation.AccountName})])}).catch(scExceptionHandler);n.logout=function(){n.loadingPromise=f.logout().then(function(){t.path("/login")})};n.changePlan=function(){t.path("/changeplan")};n.displayOrderStatus=t.path()==="/";n.rebuildAccountClaim=function(){var t=n.AccountClaimSelection;n.loadingPromise=o.setDefaultAccountClaim(t.AccountCode).then(function(){i.reload()})};n.messages=e.messages;r.yOffset=60}catch(s){scExceptionHandler(s)}}]);controllers.controller("LoginController",["$scope","$location","$animate","$routeParams","callplusAPI","authService",function(n,t,i,r,u,f){function e(){var n=r.redirect||"/";t.search("redirect",null);t.url(n)}try{n.isRedirectFromSetPassword=r.setpassword;n.user={RememberMe:!0};n.loadingPromise=f.isAuth().then(function(){e()});n.errorsVisible=function(t){return n.loginForm[t].$touched||n.loginForm.$submitted};n.submit=function(){n.loginForm&&n.loginForm.$invalid||(n.failedAuth=!1,n.loadingPromise=f.login(n.user.Username,n.user.Password,n.user.RememberMe),n.loadingPromise.then(function(){e()},function(t){n.failedAuth=t||!0}).catch(scExceptionHandler))}}catch(o){scExceptionHandler(o)}}]);controllers.controller("ForgotPasswordController",["$scope","$location","backService","authService",function(n,t,i,r){try{n.errorsVisible=function(t){return n.forgotPasswordForm[t].$touched||n.forgotPasswordForm.$submitted};n.submit=function(){if(!n.forgotPasswordForm||!n.forgotPasswordForm.$invalid){n.response=null;var t=n.passwordrestemail;n.loadingPromise=r.resetPassword(t).then(function(){n.resetSuccessful=!0}).catch(scExceptionHandler)}}}catch(u){scExceptionHandler(u)}}]);controllers.controller("MainController",["$scope","LayoutPromiseFacory","callplusAPI","$q",function(n,t,i){try{n.loadingPromise=i.getDefaultAccountClaim();n.layoutPromise=t();n.layoutPromise.waitFor(n.loadingPromise)}catch(r){scExceptionHandler(r)}}]);controllers.controller("BillingInformationController",["$scope","$location","callplusAPI","$q","$filter","webConfigUrls",function(n,t,i,r,u){try{n.chartMonths=13;n.invoiceAmounts=[[],[]];n.invoiceMonths=[];n.invoiceNumbers=[];var f=0,e=0;n.loadingPromise=i.getDefaultAccountClaim().then(function(t){return n.Claim=t.Claim,r.all([i.Payments.GetBillingInformation(t.Claim.AccountCode).then(function(t){var i,r;n.BillingInformation=t.data.BillingInformation;i=u("number")(n.BillingInformation.OverdueBalance,"2").split(".");n.OverdueBalanceDollarVal=i[0];n.OverdueBalanceCentsVal=i[1];r=u("number")(n.BillingInformation.AccountBalance,"2").split(".");n.AccountBalanceDollarVal=Math.abs(parseFloat(r[0].replace(/,/g,"")));n.AccountBalanceCentsVal=r[1];n.PaymentDueDaysLeft=moment(n.BillingInformation.CurrentInvoicePaymentDue).fromNow(!0)}),i.Payments.GetPaymentMethod(n.Claim.AccountCode).then(function(t){angular.equals(t.status,200)&&(n.PaymentMethod=t.data)}),i.Payments.GetInvoiceHeaders(n.Claim.AccountCode).then(function(t){n.InvoiceHeaders=t.data.InvoiceHeaders;angular.isUndefined(n.InvoiceHeaders)||n.InvoiceHeaders.slice(-n.chartMonths).forEach(function(t,i){t.Total>f&&(f=t.Total);t.Total<e&&(e=t.Total);n.invoiceAmounts[0].push([i+1,t.Total]);n.invoiceMonths.push([i+1,u("date")(t.BillDate,"d MMM")]);n.invoiceNumbers.push(t.InvoiceNumber)});n.LastInvoiceURL="#/invoice/"+n.invoiceNumbers[n.invoiceNumbers.length-1];n.chartMaxY=Math.ceil(f/20)*20+10;n.chartMinY=Math.floor(e/20)*20-10;n.flotrOptions={xaxis:{min:0,max:14,ticks:n.invoiceMonths},yaxis:{max:n.chartMaxY,min:n.chartMinY,noTicks:6,tickFormatter:function(n){return u("currency")(n,"$","0")}},mouse:{trackFormatter:function(n){return u("currency")(n.y)+" - Click for more details"}},grid:{color:"#e5e5e5",outline:"s",verticalLines:!1}}})])}).catch(scExceptionHandler);n.isPaymentMethod=function(t){return!angular.isUndefined(n.PaymentMethod)&&t===n.PaymentMethod.RecurringPaymentType};n.flotrClick=function(i){if(i.hit&&i.hit.x){var r=i.hit.x;n.invoiceNumbers.length>=r&&(t.path("/invoice/"+n.invoiceNumbers[r-1]),n.$apply())}}}catch(o){scExceptionHandler(o)}}]);controllers.controller("MyPlanController",["$scope","callplusAPI",function(n,t){try{n.loadingPromise=t.getDefaultAccountClaim().then(function(n){return t.Manage.GetProducts(n.Claim.AccountCode)}).then(function(t){n.hasBundle=!1;n.bundles=t.data.ProductBundles;n.bundles&&n.bundles.length>0&&(n.hasBundle=!0,n.BundleName=n.bundles[0].ProductBundleBillingDescription,n.BundlePrice=n.bundles[0].ChargeExcludingGST,n.ProductBundleComponents=n.bundles[0].ProductBundleComponents);n.AdditionalProducts=t.data.AdditionalProducts;t.data.CoreProducts.length>0&&angular.forEach(t.data.CoreProducts,function(t){t.CoreProductKey.toLowerCase()==="electricity"&&t.CoreProductComponents.length&&t.CoreProductComponents[0].CoreProductComponentPlan&&(n.ElectricityPlan=t.CoreProductComponents[0].CoreProductComponentPlan.PlanDescription)})}).catch(scExceptionHandler);n.layoutPromise.waitFor(n.loadingPromise)}catch(i){scExceptionHandler(i)}}]);controllers.controller("MyDetailsController",["$scope","callplusAPI","userInformation",function(n,t,i){try{n.loadingPromise=t.getDefaultAccountClaim().then(function(n){return t.Manage.GetContactInformation(n.Claim.AccountCode)}).then(function(t){n.ContactInformation=t.data.ContactInformation;n.userName=i.getUsername()}).catch(scExceptionHandler)}catch(r){scExceptionHandler(r)}}]);controllers.controller("PaymentOverviewController",["$scope","PaymentInformation",function(n,t){try{n.loadingPromise=t.update().then(function(){n.payment=t;n.db=t.db}).catch(scExceptionHandler)}catch(i){scExceptionHandler(i)}}]);controllers.controller("PaymentRemoveController",["$scope","$location","backService","callplusAPI","PaymentInformation","$q",function(n,t,i,r,u){try{i.setBackPath("/paymentmethod");n.loadingPromise=u.update().then(function(){n.payment=u;n.doRemove=function(){n.error=!1;r.Payments.SetPaymentMethod(u.db.AccountCode,{RecurringPaymentType:"Manual"}).then(function(){t.path("/paymentmethod/remove/done")},function(){n.error=!0})}}).catch(scExceptionHandler)}catch(f){scExceptionHandler(f)}}]);controllers.controller("PaymentCreditCardController",["$scope","$location","callplusAPI","PaymentInformation","messages",function(n,t,i,r,u){try{n.loadIFrame=function(){return n.showPaymentForm&&r.hasInit()};n.loadingPromise=r.update().then(function(){n.payment=r;n.showPaymentForm=!0;n.paymentCallback=function(f,e,o){if(f){n.showPaymentForm=!1;var s={RecurringPaymentType:"PreviousDPSTransaction",RecurringPaymentDetail:{TransactionID:o}};n.loadingPromise=i.Payments.SetPaymentMethod(r.db.AccountCode,s).then(function(){t.path("/paymentmethod/credit-card/done")},function(t){scExceptionHandler(t);n.showPaymentForm=!0})}else u.clear(),u.showMessage("Recurring payment cancelled or failed.")}}).catch(scExceptionHandler)}catch(f){scExceptionHandler(f)}}]);controllers.controller("PaymentChangeDoneController",["$scope","$location","callplusAPI","PaymentInformation","$q",function(n,t,i,r){try{n.redirect=function(){console.log("REDIRECT");t.search("redirect",null);t.url("/")};n.loadingPromise=r.update().then(function(){n.payment=r}).catch(scExceptionHandler)}catch(u){scExceptionHandler(u)}}]);controllers.controller("PaymentDirectDebitController",["$scope","$location","callplusAPI","PaymentInformation","$q",function(n,t,i,r){try{n.errorsVisible=function(t){return n.paymentMethodForm[t].$touched||n.paymentMethodForm.$submitted};n.showNumberError=function(t){return n.errorsVisible(t)&&!angular.equals(n.paymentMethodForm[t].$error,{})};n.loadingPromise=r.update().then(function(){n.BankAccountDetail={};n.Names={};n.ContactInformation=r.db.ContactInformation;n.paperlessDDConditions={};n.FailedReasonServerError;n.FailedReasonCommon;n.payment=r;n.submit=function(){var u,f,e;(n.paymentMethodForm.$submitted=!0,n.paymentMethodForm&&n.paymentMethodForm.$invalid)||(u=n.paperlessDDConditions,f=u.condition1&&u.condition2&&u.condition3,f)&&(e={RecurringPaymentType:"PaperlessDirectDebit",RecurringPaymentDetail:{BankName:n.Names.BankName,AccountName:n.Names.AccountName,BankAccountDetail:n.BankAccountDetail,ConfirmAccountAuthority:f}},n.loadingPromise=i.Payments.SetPaymentMethod(r.db.AccountCode,e,n.ContactInformation).then(function(){t.path("/paymentmethod/direct-debit/done")},function(t){!angular.isUndefined(t.Code)&&angular.equals(t.Code,"InvalidBankAccount")?n.FailedReasonCommon="Invalid bank account number. Please double check the bank account number and try again.":n.FailedReasonServerError="Whoops, looks like something went wrong. Please try again later"}).catch(scExceptionHandler))}}).catch(scExceptionHandler)}catch(u){scExceptionHandler(u)}}]);controllers.controller("ChangeDetailsController",["$scope","$q","$location","backService","callplusAPI",function(n,t,i,r,u){try{n.errors={};n.UpdateFailedReasons=[];n.isUpdateFailed=!1;n.errorsVisible=function(t){return n.changeContactInformationForm[t].$touched||n.changeContactInformationForm.$submitted};n.loadingPromise=u.getDefaultAccountClaim().then(function(t){return n.Claim=t.Claim,u.Manage.GetContactInformation(n.Claim.AccountCode)}).then(function(t){n.ContactInformation=t.data.ContactInformation;n.originalMobile=n.ContactInformation.ContactMobile;n.originalPhone=n.ContactInformation.ContactPhone}).catch(scExceptionHandler);n.invalidPostalAddress=function(){return!(angular.equals(n.changeContactInformationForm.contactAddress1.$error,{})&&angular.equals(n.changeContactInformationForm.contactAddress2.$error,{})&&angular.equals(n.changeContactInformationForm.contactAddress3.$error,{})&&angular.equals(n.changeContactInformationForm.contactAddressPC.$error,{}))};n.submit=function(){n.changeContactInformationForm&&n.changeContactInformationForm.$invalid||(n.isMobileUpdateSuccess=!1,n.isPhoneUpdateSuccess=!1,n.loadingPromise=t.all([u.Manage.ChangeMobileNumber(n.Claim.AccountCode,n.ContactInformation.ContactMobile).then(function(){n.isMobileUpdateSuccess=!0},function(){n.changeContactInformationForm.contactMobile.$error.contactMobile=!0}).catch(scExceptionHandler),n.changeContactPromise=u.Manage.ChangePhoneNumber(n.Claim.AccountCode,n.ContactInformation.ContactPhone).then(function(){n.isPhoneUpdateSuccess=!0},function(){n.changeContactInformationForm.contactPhone.$error.contactPhone=!0}).catch(scExceptionHandler)]).then(function(){if(n.isMobileUpdateSuccess&&n.isPhoneUpdateSuccess)i.path("/changedetails-done");else return}))}}catch(f){scExceptionHandler(f)}}]);controllers.controller("ChangeDetailsDoneController",["$scope","$location","callplusAPI","$q",function(){try{}catch(n){scExceptionHandler(n)}}]);controllers.controller("ChangePasswordController",["$scope","$location","backService","authService","callplusAPI","messages",function(n,t,i,r,u,f){try{n.input={};n.updatestatus;n.errorsVisible=function(t){return n.changePasswordForm[t].$touched||n.changePasswordForm.$submitted};n.submit=function(){n.changePasswordForm&&n.changePasswordForm.$invalid||!n.input.validComplexity||(n.updatestatus=undefined,n.loadingPromise=r.updatePassword(n.input.currentPassword,n.input.newPassword).then(function(){f.setMessage("Password successfully changed.");t.path("/")},function(t){n.updatestatus=t.status===403?"Unauthorised":"Failure"}).catch(scExceptionHandler))}}catch(e){scExceptionHandler(e)}}]);controllers.controller("SendMessageController",["$scope","$location","$q","backService","callplusAPI","messages",function(n,t,i,r,u,f){function e(n){var t=moment(n.TimeslotStart),i=moment(n.TimeslotEnd),r="",u;return r=t.format("D/MM/YY")===i.format("D/MM/YY")?t.format("h:mm a"):t.format("h:mm a D/MM/YY"),u=i.format("h:mm a D/MM/YY"),r+" - "+u}try{n.callbackTimeslots={};n.reasonKeys={};n.input={ReasonKey:"",ReasonComment:"",CallbackRequestedOn:""};n.loadingPromise=i.all([u.Manage.GetMessageReasons().then(function(t){angular.forEach(t.data.Reasons,function(t){n.input.ReasonKey||(n.input.ReasonKey=t.ReasonKey);n.reasonKeys[t.ReasonKey]=t.ReasonDescription})}),u.Manage.GetCallbackTimeSlots().then(function(t){angular.forEach(t.data.Timeslots,function(t){t.FreeSlots>0&&(n.input.CallbackRequestedOn||(n.input.CallbackRequestedOn=t.TimeslotStart),n.callbackTimeslots[t.TimeslotStart]=e(t))})}),u.getDefaultAccountClaim().then(function(t){return n.input.AccountCode=t.Claim.AccountCode,u.Manage.GetContactInformation(n.input.AccountCode)}).then(function(t){n.input.ContactName=t.data.ContactInformation.ContactName;n.input.ContactNumber=t.data.ContactInformation.ContactPhone})]);n.errorsVisible=function(t){return n.sendMessageForm[t].$touched||n.sendMessageForm.$submitted};n.submit=function(){n.sendMessageForm&&n.sendMessageForm.$invalid||(n.loadingPromise=u.Manage.CustomerRequestCallback(n.input).then(function(n){f.setMessage("Message successfully sent. Reference ID: "+n.data.ReferenceID);t.path("/")}))}}catch(o){scExceptionHandler(o)}}]);controllers.controller("BillController",["$scope","$location","backService","callplusAPI","$q","$timeout","BillInformation",function(n,t,i,r,u,f,e){try{n.loadingPromise=e.getFinancialHistory().then(function(t){n.financialHistory=t})}catch(o){scExceptionHandler(o)}}]);controllers.controller("LatestInvoiceController",["$scope","$location","callplusAPI",function(n,t,i){try{n.loadingPromise=i.getDefaultAccountClaim().then(function(n){return i.Payments.GetInvoiceHeaders(n.Claim.AccountCode)}).then(function(n){var i=moment(0),r;angular.forEach(n.data.InvoiceHeaders,function(n){moment(n.BillDate).isAfter(i)&&(i=n.BillDate,r=n.InvoiceNumber)});t.replace().path("/invoice/"+r)})}catch(r){scExceptionHandler(r)}}]);controllers.controller("ResetPasswordController",["$scope","$location","backService","authService","$routeParams",function(n,t,i,r,u){try{var f=u.code,e=u.value,o=u.type;angular.isUndefined(o)||(n.isSetReqeust=angular.equals(o.toUpperCase(),"SET"));n.resetSuccess=!1;n.resetError=!1;n.errorsVisible=function(t){return n.resetPasswordForm[t].$touched||n.resetPasswordForm.$submitted};n.submit=function(){n.resetPasswordForm&&n.resetPasswordForm.$invalid||!n.validComplexity||angular.isUndefined(f)||angular.isUndefined(e)||(n.response=null,n.loadingPromise=r.completeResetPassword(n.newPassword,f,e).then(function(){n.resetSuccess=!0},function(){n.resetError={humanMessage:"It can be because your password reset request is expired. Please try again by using 'Forgotten Password' link."}}).catch(scExceptionHandler))}}catch(s){scExceptionHandler(s)}}]);controllers.controller("SetPasswordController",["$scope","$location","backService","authService","$routeParams",function(n,t,i,r,u){try{var f=u.token,e=u.orderId;n.resetSuccess=!1;n.resetError=!1;n.errorsVisible=function(t){return n.resetPasswordForm[t].$touched||n.resetPasswordForm.$submitted};n.submit=function(){n.resetPasswordForm&&n.resetPasswordForm.$invalid||!n.validComplexity||angular.isUndefined(f)||angular.isUndefined(e)||(n.response=null,n.loadingPromise=r.setPassword(n.newPassword,f,e).then(function(){n.resetSuccess=!0;t.path("/login").search({setpassword:!0})},function(){n.resetError={humanMessage:"It can be because your set password request is expired. Please try again by using 'Forgotten Password' link."}}).catch(scExceptionHandler))}}catch(o){scExceptionHandler(o)}}]),function(){var n=angular.module("callplus.invoice.controllers",["cgBusy","callplus.invoice.services"]);n.controller("InvoiceController",["$scope","$location","$q","$injector","$routeParams","$filter","callplusAPI","pdfService","userSession","invoiceOrganiser","$window","webConfigUrls",function(n,t,i,r,u,f,e,o,s,h){var c=function(){try{return r.get("messages")}catch(n){return{setMessage:angular.noop}}}();n.redirectToMyOrconHome=function(){t.search("redirect",null);t.path("/myaccount/#/")};n.redirectToPaymentMethod=function(){t.search("redirect",null);t.path("/paymentmethod")};n.redirectToBillingInformation=function(){t.search("redirect",null);t.path("/billinformation")};try{n.showBundleSection=!1;n.showBroadbandSection=!1;n.showElectricitySection=!1;n.showMoreInfo=!0;n.toggleSlider=function(){n.showMoreInfo=n.showMoreInfo?!1:!0};n.Statement={};n.pdfDownloader=function(){var t={};angular.copy(n.Statement,t);o.downloadPDF(t)};n.loadingPromise=e.getDefaultAccountClaim().then(function(r){return n.Claim=r.Claim,i.all([e.Payments.GetInvoiceHeaders(n.Claim.AccountCode).then(function(t){n.InvoiceHeaders=t.data.InvoiceHeaders;n.InvoiceHeaders.sort(function(n,t){var i=new Date(n.BillDate).getTime(),r=new Date(t.BillDate).getTime();return r-i})}).catch(scExceptionHandler),e.Payments.GetInvoice(n.Claim.AccountCode,u.invoice_number).then(function(n){return(angular.isUndefined(n.data.Invoice)||n.data.Invoice===null)&&(c.setMessage("Unknown invoice: "+u.invoice_number),t.path("/billinformation")),n.data.Invoice},function(n){c.setMessage("Unknown invoice: "+u.invoice_number);t.path("/billinformation");throw n;}).then(function(n){return h(n)}).then(function(t){n.Statement.Invoice=t.Invoice;n.Statement.TaxInvoice=t.TaxInvoice;$.extend(n.Statement,t.Statement);n.Statement.BillPeriodStart=n.Statement.LastBillDate;n.Statement.BillPeriodEnd=f("date")(n.Statement.Invoice.InvoiceHeader.BillDate,"dd MMM yyyy");n.showBundleSection=!angular.equals(n.Statement.TaxInvoice.BundleInfo,{});n.showBroadbandSection=!angular.equals(n.Statement.TaxInvoice.BroadbandInfo,{});n.showElectricitySection=!angular.equals(n.Statement.TaxInvoice.ElectricityInfo,{})}).catch(scExceptionHandler),e.Payments.GetPaymentMethod(n.Claim.AccountCode).then(function(t){n.PaymentMethod=t.data;n.Statement.PaymentMethod=n.PaymentMethod.RecurringPaymentType;n.Statement.PaidByCreditCard=n.Statement.PaymentMethod==="CreditCard";n.Statement.PaidByDirectDebit=n.Statement.PaymentMethod==="DirectDebit";angular.isUndefined(n.PaymentMethod)||n.PaymentMethod.RecurringPaymentType||(n.Statement.PaymentMethod=n.PaymentMethod.RecurringPaymentType)}).catch(scExceptionHandler)])}).catch(scExceptionHandler);n.changeInvoice=function(){t.path("/invoice/"+n.Statement.Invoice.InvoiceHeader.InvoiceNumber)}}catch(l){scExceptionHandler(l)}}])}(),function(){var n=angular.module("callplus.payment.controllers",[]);n.controller("PayController",["$scope","$q","$location","paymentsAPI","dpsAPI","messages","pxFusionService",function(n,t,i,r,u,f,e){function o(){i.path("/paynow/done")}function s(){f.showMessage("Payment cancelled or failed.")}function h(){i.path("/paynow/pending")}try{n.loading=!0;n.input={amount:0};n.dps={show:!1,initFrame:!1,amount:-1,callback:function(n,t){n?o(t):s()}};n.existingCreditCard=!1;var c=r.getBillingInformation().then(function(t){var i=t.AccountBalance;n.input.amount=i<0?0:i}),l=r.isPaymentMethodCreditCard().then(function(t){if(n.existingCreditCard=t,t)return n.input.paymentType=undefined,r.getPaymentMethod().then(function(t){var i=t.GetRecurringPaymentDetail.MaskedCardDetail;n.card={number:i.MaskedNumber,type:i.Type,expiry:moment(i.Expiry,"MMYY")}});n.input.paymentType="new"});n.loadingPromise=t.all([c,l]);n.submit=function(){if(f.clear(),!n.input.amount||!n.input.paymentType||n.input.amount<=0){n.showNumberError=!0;return}if(n.input.paymentType==="existing"){var t=n.input.amount;n.loadingPromise=u.createExistingPayment(undefined,t).then(u.waitForConfirm).then(function(){o(t)},function(n){angular.equals(n,"Timeout")?h():s()},function(n){console.log(" INFO ******* "+n)})}else return n.dps.show=!0,n.dps.amount=n.input.amount,r.getStandardReference().then(function(t){var i=e.requestTypes.PURCHASE;return e.createTransaction(!1,i,t,n.dps.amount).then(function(t){n.ResponseDetail=t.data.ResponseDetail},function(){})})};n.radioExistingClicked=function(){n.input.paymentType="existing";n.isExistingChecked=!0;n.isNewChecked=!1};n.radioNewClicked=function(){n.input.paymentType="new";n.isNewChecked=!0;n.isExistingChecked=!1}}catch(a){scExceptionHandler(a)}}])}(),function(){var n=angular.module("callplus.usage.controllers",["cgBusy","callplus.usage.services","callplus.usage.directives"]);n.controller("UsageController",["$scope","$q","$timeout","$routeParams","$location","$anchorScroll","usageInformationService","callplusAPI",function(n,t,i,r,u,f,e,o){function h(){if(!n.layoutPromise)return i(h,1);n.layoutPromise.waitFor(s).then(function(){(n.isVoiceServiceAvailable||n.isDataServiceAvailable)&&r.usage&&(r.usage==="voice"&&n.isVoiceServiceAvailable?(n.showVoiceTab=!0,u.hash("usage")):r.usage==="voice-table"&&n.isVoiceServiceAvailable?(n.showVoiceTab=!0,u.hash("voice-table")):r.usage==="data"&&n.isDataServiceAvailable&&(n.showVoiceTab=!1,u.hash("usage")))})}var s,c;n.isDataServiceAvailable=!0;n.isVoiceServiceAvailable=!0;n.isPowerServiceAvailable=!1;n.showVoiceTab=!0;n.monthTicks={};n.billingDatesLookup={};n.billingDates=[];n.billingYears=[];n.billingDatesPromise=e.getBillingDates().then(function(t){angular.forEach(t,function(t){var i=t.year(),r=t.month();n.monthTicks[i]||(n.monthTicks[i]=[]);n.billingDatesLookup[i]||(n.billingDatesLookup[i]={});n.monthTicks[i].push([r,t.format("D MMM")]);n.billingDatesLookup[i][r]=t});n.billingDates=angular.copy(t).sort(function(n,t){return moment(n).diff(moment(t),"days")}).reverse();n.billingYears=Object.keys(n.monthTicks).sort().reverse()});s=t.all([]);n.loadingPromise=t.all([n.billingDatesPromise,s,h()]);c=function(n){var i=n.filter(function(n){return n.CoreProductKey=="ELECTRICITY"}),t=[];return angular.forEach(i,function(n){t.push(n.CoreProductComponents[0].CoreProductComponentServiceID)}),t};n.layoutPromise=e.getAccountCode().then(function(t){return o.Manage.GetProducts(t).then(function(t){var i=c(t.data.CoreProducts);i.length>0?n.isPowerServiceAvailable=!0:(n.isPowerServiceAvailable=!1,n.showVoiceTab=!0)})})}]);n.controller("DataUsageController",["$scope","$q","$timeout","$filter","usageInformationService","dailyDataUsageGraphHelper","monthlyDataUsageOpts",function(n,t,i,r,u,f,e){n.fadeinUsage=function(){$("#datausageinfo").fadeIn("1000",function(){})};n.showMonthlyTab=0;n.flotrClick=function(t){var i;if(t.hit&&t.hit.x&&(i=t.hit.x,n.showMonthlyTab)){var u=n.DataMonthlyUsageSelection,f=i,r=n.billingDatesLookup[u][f];r&&(n.DataDailyUsageBillDateMillis=r.valueOf(),n.updateDataBillMonth(!0))}};n.DataMonthlyUsages={};n.updateDataBillMonth=function(t){var u=moment(n.DataDailyUsageBillDateMillis);return n.isCurrentBillingPeriod=moment().isBefore(u),n.dailyGraphLoadingPromise=f(u).then(function(u){n.DailyFlotrOptions=u.graphOptions;n.DailyUsages=u.graphData;var f=r("flotrDataAverage")(n.DailyUsages),e=u.billingPeriodDurationInDays;return n.PredictedUse=f*e,t?(n.showMonthlyTab=!1,i(function(){jcf.refresh($("#data-daily-usage")[0])},50)):void 0})};n.updateDataMonthlyUsage=function(){n.DataMonthlyFlotrOptions.xaxis.ticks=n.monthTicks[n.DataMonthlyUsageSelection]};n.DataMonthlyFlotrOptions=e();var o=t.all([t.all([u.getBillingDates(),u.getMonthlyDataUsage()]).then(function(t){var r=t[0],i=t[1];angular.forEach(r,function(t){var r=t.year(),f;n.DataMonthlyUsages[r]||(n.DataMonthlyUsages[r]=[[],[]]);f=t.month();u.isCurrentBillSync(t)?(n.DataMonthlyUsages[r][0].push([f,"0"]),n.DataMonthlyUsages[r][1].push([f,i[r][f]])):(n.DataMonthlyUsages[r][0].push([f,i[r][f]]),n.DataMonthlyUsages[r][1].push([f,"0"]))})}),n.billingDatesPromise.then(function(){n.DataDailyUsageBillDateMillis=n.billingDates[0].valueOf();n.DataMonthlyUsageSelection=n.billingYears[0]}),u.getCurrentMonthDataUsageStat().then(function(t){n.currentData=t.current;n.predictedData=t.predicted})]).then(function(){return n.updateDataMonthlyUsage(),n.updateDataBillMonth(!0)});n.loadingPromise=t.when(n.loadingPromise).then(o).then(function(){return i(function(){},50)})}]);n.controller("VoiceUsageController",["$scope","$q","$timeout","$routeParams","usageInformationService","dailyVoiceUsageGraphHelper","monthlyVoiceUsageGraphHelper","callplusAPI","$filter",function(n,t,i,r,u,f,e,o,s){try{n.showMonthlyTab=!1;n.flotrClick=function(t){var i;if(t.hit&&t.hit.x&&(i=t.hit.x,n.showMonthlyTab)){var u=n.VoiceMonthlyUsageSelection,f=Math.round(i),r=n.billingDatesLookup[u][f];r&&(n.VoiceDailyUsageSelection=r.valueOf(),n.buildDailyVoiceData(!0,n.VoiceDailyUsageSelection,n.billedNumberSelection))}};n.buildMonthlyVoiceData=function(t,r){return n.monthlyGraphLoadingPromise=undefined,i(function(){return n.monthlyGraphLoadingPromise=e(t,r).then(function(t){n.MonthlyFlotrOptions=t.graphOptions;n.MonthlyUsages=t.graphData})},0)};n.buildDailyVoiceData=function(t,r,e){var r=n.VoiceDailyUsageSelection;return n.dailyGraphLoadingPromise=undefined,i(function(){return n.dailyGraphLoadingPromise=f(r,e).then(function(i){n.DailyFlotrOptions=i.graphOptions;n.DailyUsages=i.graphData;t&&(n.showMonthlyTab=!1)}).then(function(){u.getBilledNumbers(r).then(function(t){n.billedNumbers=t})}),n.dailyGraphLoadingPromise},0)};n.billedNumberChange=function(){i(function(){n.buildMonthlyVoiceData(n.VoiceMonthlyUsageSelection,n.selectedBilledNumber);n.buildDailyVoiceData(!1,n.VoiceDailyUsageSelection,n.selectedBilledNumber)},0)};var h=t.all([n.billingDatesPromise.then(function(){var t=r.invoice,i=r.calltype;if(i&&(n.selectedCallType=i),t)return u.getInvoiceBillingDate(t).then(function(i){i?(n.linkedInvoiceNumber=t,n.VoiceDailyUsageSelection=moment(i).valueOf(),n.VoiceMonthlyUsageSelection=moment(i).format("YYYY")):(n.linkedInvoiceNumber=undefined,n.VoiceDailyUsageSelection=n.billingDates[0].valueOf(),n.VoiceMonthlyUsageSelection=n.billingYears[0])});n.VoiceDailyUsageSelection=n.billingDates[0].valueOf();n.VoiceMonthlyUsageSelection=n.billingYears[0]}).then(function(){i(function(){n.buildMonthlyVoiceData(n.VoiceMonthlyUsageSelection,"");n.buildDailyVoiceData(!1,n.VoiceDailyUsageSelection,"")},0)})]);n.loadingPromise=t.when(n.loadingPromise).then(h).then(function(){return i(function(){},50)});n.navigateToCallingUsage=function(){n.linesShown+=10};n.loadingPromise=o.getDefaultAccountClaim().then(function(n){return o.Manage.GetProducts(n.Claim.AccountCode)}).then(function(t){n.AdditionalProducts=t.data.AdditionalProducts;n.isCallingPackAvailable=!1;var r=s("filter")(n.AdditionalProducts,{AdditionalProductService:"callingpack"}),i=[];n.billingDatesPromise.then(function(){n.DataDailyUsageBillDateMillis=n.billingDates[0].valueOf();angular.forEach(r,function(t){f(n.billingDates[0].valueOf(),"",{callingPackName:t.AdditionalProductKey}).then(function(n){i.push({callingPackKey:t.AdditionalProductKey,callingPackName:t.AdditionalProductDescription,dailyUsages:n.graphData})})})});n.CallingPacks=i;n.isCallingPackAvailable=i.length>0}).catch(scExceptionHandler)}catch(c){scExceptionHandler(c)}}]);n.controller("PowerUsageController",["$scope","$q","$timeout","$routeParams","usageInformationService","callplusAPI","dailyPowerUsageOpts","monthlyPowerUsageOpts","powerMonthlyService","powerDailyUsage",function(n,t,i,r,u,f,e,o,s,h){function a(){n.PowerPromise=f.Manage.GetPowerMonthlyUsage(n.AccCode,n.IcpSelection).then(function(t){if(!t.data.fixedCharges){n.PowerMonthlyUsage=[];c();return}n.PowerMonthlyUsage=s.GetPowerMonthlyUsage(t.data);var r=s.GetPowerUsageBillDates(n.PowerMonthlyUsage),u=r.BillingDates,i=r.BillingYears;n.PowerBillingDates=u;n.PowerDailySelection=u.length?n.PowerBillingDates[0]:null;n.PowerMonthlyBillingYears=i;n.PowerMonthlyBillingYearSelection=i.length?i[0]:null}).then(function(){return c()})}function c(){var t=s.GetPowerMonthlyProps(n.PowerMonthlyBillingYearSelection,n.PowerMonthlyUsage);return n.TotalMonthlySpend=t.TotalMonthlySpend,n.TotalMonthlyUsage=t.TotalMonthlyUsage,n.PowerMonthlyGraphOptions=p(t.GraphXticks,t.GraphYticks),n.PowerMonthlyGraphData=[null,t.MonthlyGraphData],t}function l(){n.PowerMonthlyPromise=f.Manage.GetPowerDailyUsage(n.AccCode,n.IcpSelection,moment(n.PowerDailySelection).format("YYYY-MM-DD")).then(function(t){return n.PowerDailyUsage=t.data.fixedCharges?h.GetPowerDailyUsage(t.data):[],t}).then(function(){y()})}function y(){var t=h.GetPowerDailyProps(n.PowerDailySelection,n.PowerDailyUsage);return n.TotalSpendToDate=t.SpendToDate,n.TotalUsageToDate=t.UsageToDate,n.PowerDailyGraphData=[null,t.GraphData],n.PowerDailyGraphOptions=w(t.GraphXticks,t.GraphYticks,t.MinDay,t.MaxDay),t}function p(n,t){var i=o();return i.xaxis.ticks=n,i.xaxis.min=0,i.xaxis.max=13,i.yaxis.ticks=t,i}function w(n,t){var i=e();return i.xaxis.ticks=n,i.xaxis.min=0,i.xaxis.max=32,i.yaxis.ticks=t,i}n.IcpList=[];n.IcpSelection="";n.togglePowerMonthlyTab=!0;n.PowerDailySelection=0;n.PowerBillingDates=[];n.PowerMonthlyBillingYears=[];n.PowerMonthlyBillingYearSelection=0;n.PowerMonthlyBillingYearSelectionChanged=function(){c()};n.PowerDailySelectionChange=function(){l()};n.IcpSelectionChanged=function(){n.togglePowerMonthlyTab=!0;a()};var v=function(n){var i=n.filter(function(n){return n.CoreProductKey=="ELECTRICITY"}),t=[];return angular.forEach(i,function(n){t.push(n.CoreProductComponents[0].CoreProductComponentServiceID)}),t};n.PowerPromise=u.getAccountCode().then(function(t){n.AccCode=t}).then(function(){return f.Manage.GetProducts(n.AccCode).then(function(t){n.IcpList=v(t.data.CoreProducts);n.IcpSelection=n.IcpList[0]})}).then(function(){n.IcpList.length&&a()});n.UpdateMonthlyGraph=function(){n.togglePowerMonthlyTab=!0;c()};n.UpdateDailyGraph=function(){n.togglePowerMonthlyTab=!1;l()};n.PowerDailyGraphClick=function(n){if(n.hit&&n.hit.x)var t=n.hit.x};n.PowerMonthlyGraphClick=function(t){if(t.hit){var i=t.hit.series.data[t.hit.index][2];n.togglePowerMonthlyTab=!1;n.PowerDailySelection=i;l()}}}])}()