"use strict";var directives=angular.module("myCallPlusDirectives",[]);directives.directive("notImplemented",function(){function n(n){alert("Coming soon!");n.stopImmediatePropagation()}return{link:function(t,i){i.on("click",n);i.on("touch",n)}}});directives.directive("inSystemBrowser",function(){var n=function(n){return n&&n.toElement&&n.toElement.href&&(window.open(n.toElement.href,"_system"),n.preventDefault()),!1};return{link:function(t,i){i.on("click",n);i.on("touch",n)}}});directives.directive("shPageWrapper",function(){return{restrict:"E",templateUrl:"Pages/page-wrapper.html",controller:"PageWrapperController",replace:!0,transclude:!0}});directives.directive("shLoading",["$animate","$timeout",function(n,t){function i(){t(function(){n.addClass(angular.element(document.getElementById("splash-screen")),"fade")},700)}return{link:i}}]);directives.directive("match",function(){return{restrict:"A",require:"ngModel",scope:{toMatch:"=match"},link:function(n,t,i,r){r.$validators.match=function(t){return t===n.toMatch?!0:!1}}}});directives.directive("contactPhone",function(){return{restrict:"A",require:"ngModel",link:function(n,t,i,r){r.$validators.contactPhone=function(n){if(n===undefined)return!1;var i=n.replace(/\s/g,""),t=i.replace(/^0+/,"");return isNaN(parseFloat(t))?!1:t.length<8||t.length>10?!1:!0}}}});directives.directive("contactMobile",function(){return{restrict:"A",require:"ngModel",link:function(n,t,i,r){r.$validators.contactMobile=function(n){var i,t,r,u;return n===undefined?!1:(i=n.replace(/\s/g,""),t=i.replace(/^0+/,""),isNaN(parseFloat(t)))?!1:t.length<8||t.length>10?!1:(r=t.substring(0,2),u=["20","21","22","26","27","28","29"],u.indexOf(r)!=-1)}}}});directives.directive("passwordStrength",["callplusAPI","$timeout","$q",function(n){var t=n.Identity.PasswordComplexity;return{restrict:"E",templateUrl:"Pages/directives/password_strength.html",scope:{password:"=password",complexity:"=?complexity",isComplexEnough:"=?isComplexEnough",isLoading:"=?isLoading",showRawComplexity:"=?showRawComplexity"},link:function(n){function i(t){t?(n.complexity=t.percent,n.actual=t.actual,n.required=t.required,n.isComplexEnough=t.percent>=100):(n.complexity=0,n.isComplexEnough=!1);n.progressBarWidth=(n.complexity>=200?200:n.complexity)/2;n.complexityLow=!n.complexity||n.complexity<100;n.complexityMed=!n.complexityLow&&n.complexity<150;n.complexityHigh=n.complexity>=150}function f(){n.password?(n.isLoading=!0,r=!0,t(n.password||"").then(function(n){i(n)},function(){i(!1)})["finally"](function(){n.isLoading=!1;r=!1;u&&(u=!1,f())})):i()}var r=!1,u=!1;n.$watch("password",function(n,t){n!==t&&(u=!0,r||f())});i()}}}]);directives.directive("flotr",["$filter","$timeout",function(n,t){return{restrict:"E",template:'<div class="flotr-chart"><\/div>',scope:{dataset:"=dataset",options:"=options",click:"=click",redraw:"=redraw"},link:function(i,r,u){function o(n,t){var i=angular.copy(n);return angular.forEach(t,function(n,t){i[t]=!(n instanceof Object)||n instanceof Array||n instanceof Function?n:o(i[t],n)}),i}var h={colors:["#C4E8FA"],HtmlText:!0,legend:{position:"ne",labelBoxBorderColor:"#fff",backgroundColor:"#fff"},bars:{show:!0,stacked:!1,horizontal:!1,shadowSize:0,barWidth:.94,lineWidth:.9,fillOpacity:.9},mouse:{track:!0,relative:!0,trackDecimals:2,trackFormatter:function(t){return n("number")(t.y)}},xaxis:{ticks:[],axisLabelFontSizePixels:16,axisLabelFontFamily:"verdana",autoscale:!1,min:0,mode:"time"},yaxis:{titleAngle:90,autoscale:!0,min:0,noTicks:10,tickFormatter:function(t){return n("number")(t)}},grid:{color:"#e5e5e5",verticalLines:!0,outline:"s",outlineWidth:1,labelMargin:3}},s=angular.noop,e=$(r.children()[0]),f;$(r).css("display","block");e.css({width:u.width||"100%",height:u.height||"100%"});f=function(){if($(r).is(":visible")){var n=i.dataset||[],t=o(h,i.options),u={data:n[0]},f={data:n[1]};Flotr.draw(e[0],[u,f],t);i.click&&(s(),Flotr.EventAdapter.observe(e[0],"flotr:click",i.click),s=function(){Flotr.EventAdapter.stopObserving(e[0],"flotr:click",i.click)})}};f();i.$watch("dataset",f,!0);i.$watch("options",f,!0);i.$watch("click",f,!0);i.$watch("redraw",function(){t(f,0)},!0)}}}]),function(){var n=angular.module("callplus.payment.directives",["callplus.payment.services"]);n.directive("pxFusionForm",[function(){return{restrict:"E",scope:{transectionType:"=",amountToPay:"="},templateUrl:"Pages/directives/dps-fusion-form.html",controller:["$q","$scope","$location","$timeout","callplusAPI","pxFusionService","webConfigUrls",function(n,t,i,r,u,f){function h(){angular.equals(e,f.requestTypes.AUTH)?c():v()}function a(){i.path("/paynow/done")}function v(){i.path("/paynow/failed")}function y(){i.path("/paynow/pending")}function p(){i.path("/paymentmethod/credit-card/done")}function c(){i.path("/paymentmethod/credit-card/failed")}function w(){i.path("/paymentmethod/credit-card/allDone")}function b(){i.path("/paymentmethod/credit-card/setFailed")}function k(n,i){var r={RecurringPaymentType:"PreviousDPSTransaction",RecurringPaymentDetail:{TransactionID:i}};t.loadingPromise=u.Payments.SetPaymentMethod(n,r).then(function(){angular.equals(e,f.requestTypes.PURCHASE)?w():p()},function(){angular.equals(e,f.requestTypes.PURCHASE)?b():c()})}var l,s,e,o;t.card={amount:0,cardNumber:"",cardName:"",expiryMonth:"",expiryYear:"",secCode:"",isRecurring:!1};t.isCreatePayment=!1;t.isChangePaymentMethod=!1;switch(t.transectionType){case"PURCHASE":t.isCreatePayment=!0;e=f.requestTypes.PURCHASE;break;case"AUTH":t.isChangePaymentMethod=!0;t.card.amount=1;t.card.isRecurring=!0;e=f.requestTypes.AUTH;break;default:throw new Error("requestType should be defined");}for(t.amountToPay&&t.amountToPay>0&&(t.card.amount=t.amountToPay),t.expiryMonths=moment.monthsShort(),t.expiryYears=[],o=0;o<20;o++)t.expiryYears.push(moment().add(o,"year").year());t.errorsVisible=function(n){return t.dpsPxFusionForm[n].$touched||t.dpsPxFusionForm.$submitted};t.invalidPaymentAmount=function(){var n=t.card.amount;return angular.isUndefined(n)};t.showNumberError=function(n){return t.errorsVisible(n)&&!angular.equals(t.dpsPxFusionForm[n].$error,{})};t.submit=function(){t.dpsPxFusionForm&&t.dpsPxFusionForm.$invalid||t.invalidPaymentAmount()||(t.loadingPromise=u.getDefaultAccountClaim().then(function(n){t.Claim=n.Claim;var i="AN"+t.Claim.AccountCode+"/"+Date.now();return l=t.Claim.AccountCode,f.createTransaction(t.card.isRecurring,e,i,t.card.amount)}).then(function(n){var i=n.data.ResponseDetail.PaymentUrl,r=n.data.ResponseDetail.TransactionDetail.ProviderTransactionID;return s=n.data.ResponseDetail.TransactionDetail.TransactionID,f.doDpsPxFusionPost(i,r,t.card,s)},function(){t.FailedReasonServerError="Whoops, looks like something went wrong. Please try again later"}).then(function(n){return f.checkTransactionStatus(n)},function(){h()}).then(function(n){n&&(angular.equals(n.Status,"Pending")?angular.equals(e,f.requestTypes.AUTH)?c():y():angular.equals(n.Status,"Successful")?t.card.isRecurring?k(l,s):a():h())},function(){h()}))}}]}}])}(),function(){var n=angular.module("callplus.usage.directives",["callplus.usage.services"]);n.directive("callingTable",[function(){return{restrict:"E",scope:{billDate:"=",linkedInvoiceNumber:"=",callType:"=",billedNumber:"="},templateUrl:"Pages/directives/voice-usage-details.html",controller:["$scope","$location","$timeout","$filter","usageInformationService",function(n,t,i,r,u){function f(){n.billDate&&(n.loadingPromise=u.getCallUsageForBill(n.billDate,n.billedNumberSelection).then(function(t){return n.unFilterdCallRecords=t,angular.forEach(t,function(t){var i={Category:t.destinationCategory,Origin:t.numberBilled,Destination:t.numberCalled,Day:t.dateTime.format("YYYY-MM-DD"),Time:t.dateTime.format("HH:mm:ss"),Duration:r("momentToDisplay")(t.duration_m),Charge:r("number")(t.charge,"2"),CallingPack:t.callingPackName};n.csvCallRecords.push(i)}),n.callTypes=s(t),n.callRecords=o(t),n.linesAvailable=n.unFilterdCallRecords.length,i(function(){},50)}))}function o(t){var i=[];return angular.isUndefined(n.callTypeFromInvoice)||n.callTypeFromInvoice===""?e(!0):(e(!1),n.callFilters[n.callTypeFromInvoice]=!0,n.callTypeFromInvoice=""),angular.forEach(t,function(t){(n.callFilters[t.destinationCategory]||n.callFilters[t.callingPackBillingDescription])&&i.push(t)}),i}function s(n){var t=[];return angular.forEach(n,function(n){n.destinationCategory&&n.destinationCategory!="Calling Pack"&&t.indexOf(n.destinationCategory)<0?t.push(n.destinationCategory):n.callingPackBillingDescription&&t.indexOf(n.callingPackBillingDescription)<0&&t.push(n.callingPackBillingDescription)}),t}function e(t){angular.forEach(n.callTypes,function(i){if(angular.isUndefined(n.callFilters[i])){var r={};r[i]=t;$.extend(n.callFilters,r)}})}n.backToInvoice=function(){t.path("/invoice/"+n.linkedInvoiceNumber)};n.showMore=function(){n.linesShown+=10};n.includeCalls=function(){f()};n.linesShown=0;n.linesAvailable=0;n.callRecords=[];n.csvCallRecords=[{Category:"Calling Category",Origin:"Origin",Destination:"Destination",Day:"Day",Time:"Time",Duration:"Call Durations",Charge:"Call Charge",CallingPack:"Calling Pack Name"},];n.callFilters={};n.callTypes=[];n.voiceTableSortType="dateTime";n.voiceTableSortReverse=!1;n.$watch("billDate",function(t){t&&(n.linesShown=10);i(f,1)});n.billedNumberChange=function(){i(f,1)};n.$watch("callType",function(t){t&&(n.callTypeFromInvoice=t);i(f,1)});n.$watch("billedNumber",function(t){(t||angular.equals(t,""))&&(n.billedNumberSelection=t);i(f,1)})}]}}]);n.directive("exportVoiceUsage",function(){return{restrict:"A",link:function(n,t){var i=t[0];t.bind("click",function(n){for(var e=n.target.nextElementSibling,t="Origin, Destination, Category, Day, Time, Duration, Charge, Calling Pack\n",u,r,f,i=1;i<e.rows.length;i++){for(u=e.rows[i].cells,r=0;r<u.length;r++)t=t+u[r].innerHTML+",";t=t.substring(0,t.length-1);t=t+"\n"}t=t.substring(0,t.length-1);f=$("<a/>",{style:"display:none",href:"data:application/octet-stream;base64,"+btoa(t),download:"VoiceCallUsage.csv"}).appendTo("body");f[0].click();f.remove()})}}});n.directive("usageTable",[function(){return{restrict:"E",scope:{billDate:"=",linkedInvoiceNumber:"="},templateUrl:"Pages/directives/data-usage-details.html",controller:["$scope","$location","$timeout","usageInformationService",function(n,t,i,r){function u(){n.billDate&&(n.loadingPromise=r.getDailyDataUsageForPeriod(n.billDate).then(function(t){n.dataUsageRecords=t;n.linesAvailable=n.dataUsageRecords.length}))}n.backToInvoice=function(){t.path("/invoice/"+n.linkedInvoiceNumber)};n.showMore=function(){n.linesShown+=10};n.linesShown=0;n.linesAvailable=0;n.callRecords=[];n.$watch("billDate",function(t){t&&(n.linesShown=10);i(u,1)});n.fadeoutUsage=function(){$("#datausageinfo").fadeOut("1000",function(){})}}]}}])}()