(function(n){n.constant("_",window._);n.constant("saProductArray",window.PRODUCTARRAY||{brandid:1,products:[{key:"void",label:"no products available"}]});n.constant("saHideContactBefore",!!window.HideContactBefore);n.constant("saHideRetailer",!!window.HideRetailer);n.constant("saApiVer",window.ApiVer||7);n.constant("saSafetyVer",window.SafetyVer||"");n.config(["$logProvider","$provide",function(n,t){n.debugEnabled(!0);t.decorator("$log",["$delegate",function(t){var i=t.info,r=t.log,u=t.warn,f=t.error,e=t.debug;return t.info=function(){n.debugEnabled()&&i.apply(null,arguments)},t.log=function(){n.debugEnabled()&&r.apply(null,arguments)},t.warn=function(){n.debugEnabled()&&u.apply(null,arguments)},t.debug=function(){n.debugEnabled()&&e.apply(null,arguments)},t.error=function(){n.debugEnabled()&&f.apply(null,arguments)},t}])}]);n.config(["usSpinnerConfigProvider",function(){}]);n.config(["$stateProvider","$urlRouterProvider",function(n,t){var i=window.FormName||"/templates/checkform";n.state("check",{url:"/check",abstract:!0,template:"<ui-view><\/ui-view>"}).state("check.precheck",{url:"/precheck",templateUrl:"/templates/precheck"}).state("check.form",{url:"/form",templateUrl:i}).state("check.complete",{url:"/complete",templateUrl:"/templates/complete"}).state("check.serviceerror",{url:"/serviceerror",templateUrl:"/Scripts/SafetyApp/app/js/common/views/servicerror.html"});t.when("","/check/precheck");t.when("/check","/check/precheck");t.otherwise(function(n){var t=n.get("$state"),i=n.get("saStateService");t.go("check.serviceerror")})}]);n.filter("sanitize",["$sce",function(n){return function(t){return n.trustAsHtml(t)}}]);n.filter("sanitizeurl",["$sce",function(n){return function(t){return n.trustAsResourceUrl(t)}}]);n.filter("filterbreadcrumb",function(){return function(n){if(n){var t=n.trim().toLowerCase().split("-").join(" > ");return t.trim()}return""}});n.filter("keywordbreadcrumb",function(){return function(n){return n?n.trim().toLowerCase():""}});n.filter("DateStrToDte",function(){return function(n){return new Date(n)}});n.directive("validateEmail",function(){var n=/^[_A-Za-z0-9]+(\.[_A-Za-z0-9]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,4})$/;return{require:"ngModel",restrict:"",link:function(t,i,r,u){u&&u.$validators.email&&(u.$validators.email=function(t){return u.$isEmpty(t)||n.test(t)})}}});n.directive("notEmail",function(){var n=/^[_A-Za-z0-9]+(\.[_A-Za-z0-9]+)*@[A-Za-z0-9-]+(\.[A-Za-z0-9-]+)*(\.[A-Za-z]{2,4})$/;return{require:"ngModel",restrict:"",link:function(t,i,r,u){u.$validators.notEmail=function(t){return!n.test(t)}}}});n.directive("complexPassword",function(){return{require:"ngModel",link:function(n,t,i,r){r.$parsers.unshift(function(n){var t=/[A-Z]/.test(n),i=/[a-z]/.test(n),u=/\d/.test(n),f=t+i+u;return n.length>=8&&f>=3?(r.$setValidity("complexity",!0),n):(r.$setValidity("complexity",!1),undefined)})}}});n.directive("compareTo",[function(){return{require:"ngModel",scope:{otherModelValue:"=compareTo"},link:function(n,t,i,r){r.$validators.compareTo=function(t){return t===n.otherModelValue};n.$watch("otherModelValue",function(){r.$validate()})}}}]);n.run(["$rootScope","$log","$state","$stateParams","saStateService",function(n,t,i,r,u){n.$state=i;n.$stateParams=r;n._=window._;n.$on("$stateChangeSuccess",function(n,i,r,u,f){t.debug("event",n);t.debug("toState",i);t.debug("toParams",r);t.debug("fromState",u);t.debug("fromParams",f)});n.$on("$stateNotFound",function(n,i){t.error("The requested state was not found: ",i)});n.$on("$stateChangeError",function(n,i,r,u,f,e){t.error("An error occured while changing states: ",e);t.debug("event",n);t.debug("toState",i);t.debug("toParams",r);t.debug("fromStart",u);t.debug("fromParams",f)});n.$on("$stateChangeStart",function(r,f,e,o,s){t.debug("event",r);t.debug("toState",f);t.debug("toParams",e);t.debug("fromState",o);t.debug("fromParams",s);(n.firstrun===!0||u.statedata.PrecheckisComplete===!1)&&(n.firstrun=!1,f.name!=="check.precheck"&&(r.preventDefault(),i.go("check.precheck",e,{location:"replace"})));u.statedata.CheckisComplete===!1&&f.name==="check.complete"&&(u.statedata.PrecheckisComplete===!1?i.go("check.precheck"):i.go("check.form"))});(n.firstrun===!0||u.statedata.PrecheckisComplete===!1)&&(n.firstrun=!1,i.go("check.precheck"));t.debug(" SafetyApp is running","")}])})(angular.module("safetyApp",["ui.router","angularSpinner","ngSanitize","ngMessages"])),function(n){"use strict";n.provider("saStateService",["_",function(n){this.statedata={precheck:{hwcu:"",location:""},form:{},check:{product:""},PrecheckisComplete:!1,CheckisComplete:!1,result:{message:"Oops something has not happened yet",payload:{}}};n.bindAll(this.statedata);this.$get=function(){var n=this.statedata;return{statedata:n}}}])}(angular.module("safetyApp")),function(n){"use strict";n.factory("saInterceptorService",["$q","$location",function(n,t){var i={},r=function(n){return n.headers=n.headers||{},n},u=function(i){return i.status===401&&t.path("/check/serviceerror"),n.reject(i)};return i.request=r,i.responseError=u,i}]);n.factory("saFormService",["saStateService","_","$state","$q","$http","usSpinnerService",function(n,t,i,r,u,f){var e=function(){var t=r.defer(),i;return typeof n.statedata.check!="undefined"?(f.spin("searchspinner"),i=$.param(n.statedata.check),u.post("/api/safety/submit",i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){n.data?(f.stop("searchspinner"),t.resolve(n.data)):(f.stop("searchspinner"),t.reject([]))},function(n){f.stop("searchspinner");t.reject(n)})):($log.debug("Unable to post data - data not assigned correctly",n.statedata),t.reject([])),t.promise},o=function(n){var t=r.defer();return f.spin("searchspinner"),u.post("/api/cs/flatsearchpicklist",n).then(function(n){n.data?(f.stop("searchspinner"),t.resolve(n.data)):(f.stop("searchspinner"),t.reject([]))},function(n){f.stop("searchspinner");t.reject(n)}),t.promise},s=function(n){var t=r.defer();return f.spin("searchspinner"),u.post("/api/cs/FlatAddress",n).then(function(n){n.data?(f.stop("searchspinner"),t.resolve(n.data)):(f.stop("searchspinner"),t.reject([]))},function(n){f.stop("searchspinner");t.reject(n)}),t.promise},h=function(){var t=r.defer(),e,i;return typeof n.statedata.check!="undefined"&&(e={email:n.statedata.check.email,name:n.statedata.result.yourname},i=$.param(n.statedata.check),u.post("/api/safety/email",i,{headers:{"Content-Type":"application/x-www-form-urlencoded"}}).then(function(n){n.data?(f.stop("searchspinner"),t.resolve(n.data)):(f.stop("searchspinner"),t.reject([]))},function(n){f.stop("searchspinner");t.reject(n)})),t.promise};return{SendFormData:function(){return e()},AddressLookup:function(n){return o(n)},FlatAddress:function(n){return s(n)},SendEmail:function(){return h()}}}])}(angular.module("safetyApp")),function(n){"use strict";n.controller("saCheckController",["saStateService","_","$state","saFormService","$log","saProductArray","saHideContactBefore","saApiVer","saSafetyVer",function(n,t,i,r,u,f,e,o,s){console.log("saCheckController1");var h=this;h.state=n.statedata;h.products=f.products;h.defaultchecked=!1;h.showvalidation=!1;h.btn={clicked:!1};h.set_hwcu=function(n){typeof n!="undefined"&&(h.state.precheck.hwcu=n?"Yes":"No")};e&&(h.state.precheck.hwcu="No");h.set_location=function(n){typeof n!="undefined"&&(h.state.precheck.location=n?"UK":"Eire",h.state.precheck.country=n?"GBR":"IRL")};h.precheck_valid=function(){return h.state.precheck.registrationRequest=h.state.precheck.hwcu!=="Yes",h.state.precheck.location!==""&&h.state.precheck.hwcu!==""&&(h.state.PrecheckisComplete=!0),h.state.PrecheckisComplete};h.addreq=function(){return h.state.precheck.hwcu==="No"};h.precheck_application=function(){h.precheck_valid()&&i.go("check.form")};h.processForm=function(){h.state.check.whereAreYouFrom=h.state.precheck.country==="GBR"?"UK":"Eire";h.state.check.contactedBefore=h.state.precheck.hwcu==="Yes";h.state.check.pending=!0;h.state.check.api=o;h.state.check.safetyVer=s;r.SendFormData().then(function(n){h.state.pending=!1;h.state.result.payload=n;h.set_resultstate(h.state.result.payload.finalStatus);h.state.result.message="Your product has been checked successfully";h.state.result.emailbuttondisabled=!1;h.state.result.emailbuttontext="Send Email";h.state.check.yourname=h.state.check.Title+" "+h.state.check.Initial+" "+h.state.check.Surname;h.state.check.modelCode=h.lookupProductBySKU(h.state.check.product).label;h.state.check.finalMessage=n.finalMessage;h.state.check.shortMessage=n.shortMessage;h.state.check.finalStatus=n.finalStatus;h.state.check.registrationRequest=h.state.precheck.hwcu!=="Yes";h.state.result.resultstate!=="recheck"&&(h.state.CheckisComplete=!0,i.go("check.complete"))},function(n){h.state.check.pending=!1;u.debug("SendFormData Failed eror message =>",n);i.go("check.serviceerror")})};h.sendEmail=function(){h.state.result.emailbuttondisabled=!0;h.state.result.emailbuttontext="Sending...";r.SendEmail().then(function(){h.state.result.emailbuttontext="Email Sent"},function(n){h.state.result.message=n;u.debug("SendEmail Failed eror message =>",n);i.go("check.serviceerror");h.state.result.emailbuttondisabled=!1;h.state.result.emailbuttontext="Retry?"})};h.check_application=function(){typeof h.state.precheck.location!=""&&typeof(h.state.precheck.hwcu!=="")&&(alert("you make a good choice :) "),i.go("check.form"))};h.show_validation=function(){h.showvalidation=!0};h.isBad=function(){return typeof h.state.result.payload.finalStatus=="undefined"?!0:!1};h.set_resultstate=function(n){switch(n){case 1:h.state.result.resultstate="recheck";break;case 2:h.state.result.resultstate="mod";break;case 3:h.state.result.resultstate="ok";break;case 4:h.state.result.resultstate="recheck";break;case 7:h.state.result.resultstate="mod";break;default:h.state.result.resultstate="other"}};h.QASButtons=1;h.lookupaddress=function(){var n,t;h.state.check.pending=!0;h.thiserr="";n=[];h.state.check.building&&n.push(h.state.check.building);h.state.check.street&&n.push(h.state.check.street);h.state.check.town&&n.push(h.state.check.town);h.state.check.postcode&&n.push(h.state.check.postcode);t={dataId:h.state.precheck.country,asLines:n};r.AddressLookup(t).then(function(n){h.state.check.pending=!1;h.addressItems=n.Items;n.Items.length===1?(h.selectedaddress=n.Items[0],h.selectaddress()):h.QASButtons=2},function(n){h.state.check.pending=!1;u.debug("Addresslookup Failed",n)})["catch"](function(){h.QASButtons=1;h.state.check.pending=!1})};h.canceladdress=function(){h.QASButtons=1};h.manualaddress=function(){return h.QASButtons=4,!1};h.selectaddress=function(n){if(h.thiserr="",h.state.check.pending=!0,h.selectedaddress){var t={dataId:h.state.check.country,moniker:h.selectedaddress.Moniker,route:"Okay"};r.FlatAddress(t).then(function(n){h.state.check.pending=!1;h.QASdisplayFinalAddress(n,h)},function(n){h.state.check.pending=!1;u.debug("FlatAddress lookup Failed",n)})["catch"](function(){h.state.check.pending=!1;h.QASButtons=4})}else n.selectedaddress.$setValidity("PickAddress",!1)};h.QASdisplayFinalAddress=function(n){var i="",t="",r="",f="",e="",o="",u=!1;jQuery(n).each(function(n,s){s.Label=="Postcode"?f=s.Line:s.Label=="Town"?(t=s.Line,u=!0):s.Label=="City"?(t=s.Line,u=!0):s.Label=="County"&&(r=s.Line,u=!0);s.Line&&(u||(i=i+s.Line+"\n"),s.Line.indexOf("Co ")==0?(r=s.Line,n>1&&(t=t||e)):s.Line.indexOf("DUBLIN ")==0&&(r=s.Line.replace("DUBLIN","Dublin"),o=s.Line,t=t||"DUBLIN"),e=s.Line)});i=i.replace("\n"+t+"\n","\n").replace("\n"+r+"\n","\n").replace("\n"+o+"\n","\n");h.state.check.address=i;h.state.check.town=t;h.state.check.postcode=f;h.state.check.county=r;h.QASButtons=3;h.state.check.pending=!1};h.IsProductOK=function(){return h.state.result.resultstate==="ok"};h.IsArrangeMod=function(){return h.state.result.resultstate==="mod"};h.IsReCheck=function(){return h.state.result.resultstate==="recheck"};h.ArrangeModification=function(){alert("todo")};h.ReEnterForm=function(){h.state.CheckisComplete=!1;i.go("check.form")};h.StartAgain=function(){h.state.PrecheckisComplete=!1;h.state.CheckisComplete=!1;i.go("check.precheck")};h.lookupProductBySKU=function(n){return t.find(h.products,{key:n})};h.lookupDefaultProduct=function(){return t.find(h.products,{"default":!0})};h.setDefault=function(){if(h.state.check.product===""&&h.defaultchecked===!1){var n=h.lookupDefaultProduct();typeof n!="undefined"&&(h.state.check.product=n.key);h.defaultchecked=!0}};h.setDefault()}])}(angular.module("safetyApp")),function(n){"use strict";n.directive("saPreCheck",["saProductArray","saHideContactBefore",function(n,t){var i=function(n){return(console.log("saPreCheck2 inside"+n),n)?"/Scripts/SafetyApp/app/js/check/views/precheck.hide.html":"/Scripts/SafetyApp/app/js/check/views/precheck.html"};return{restrict:"E",templateUrl:i(t),scope:{},controller:"saCheckController",controllerAs:"CheckCtlr"}}]);n.directive("saCheckForm",["saProductArray","saHideRetailer",function(n,t){var i=function(n){return n?"/Scripts/SafetyApp/app/js/check/views/form.hide.html":"/Scripts/SafetyApp/app/js/check/views/form.html"};return{restrict:"E",templateUrl:i(t),scope:{},controller:"saCheckController",controllerAs:"CheckCtlr"}}]);n.directive("saComplete",["saProductArray","saHideRetailer",function(n,t){var i=function(){return"/Scripts/SafetyApp/app/js/check/views/complete.html"};return{restrict:"E",templateUrl:i(t),scope:{},controller:"saCheckController",controllerAs:"CheckCtlr"}}]);n.directive("saProductInfo",[function(){return{restrict:"E",templateUrl:"/Scripts/SafetyApp/app/js/check/views/productinfo.html",scope:{product:"="}}}])}(angular.module("safetyApp"))