text: "use strict";!function(){angular.module("app").controller("ChangePinCtrl",function($scope,snackbars,translate,USBModemUtil){function saveCb(response){var isSuccess=_.find(response.result.ParameterList,{Name:"Success"});isSuccess.Value?$scope.closeThisDialog({change:!0}):errorPIN()}function errorPIN(){snackbars.add("usb_modem_pin_request_wrong");var input={modem:data.modem,sim:data.sim,param:"PIN"};util.updateSIMInfo(input).then(function(response){data.pin=response,0==data.pin.PIN&&$scope.closeThisDialog(),$scope.Attempts=getAttempts()},errorPush)}function errorPush(){snackbars.add("msg_rpc_write_error")}function getAttempts(){return translate("usb_modem_pin_attempt")+": "+(-1!=data.pin.PIN?data.pin.PIN:translate("unknown"))}$scope.PIN="",$scope.NewPIN="",$scope.Reset=!0,$scope.isConfirm=!0;var data=angular.copy($scope.ngDialogData.data);$scope.Attempts=getAttempts();var util=USBModemUtil;$scope.validationPIN=function(pin,type){if(!pin)return null;var compactPIN,re=/^[0-9]{4,8}$/g;return re.test(pin)?"NewPIN"!=type||(compactPIN=$scope.PIN,_.isEmpty(compactPIN)||compactPIN!=pin)?null:"usb_modem_pin_old_new_same":"usb_modem_pin_code_wrong"},$scope.checkPINConfirm=function(value){$scope.isConfirm=value},$scope.isButtonDisabled=function(){return $scope.changePIN.$invalid||!$scope.isConfirm||""==$scope.PIN||""==$scope.NewPIN},$scope.save=function(){var overlay=$scope.overlay.circular,overlayId=overlay.start(),input={modem:data.modem,sim:data.sim,pin:$scope.PIN,newPin:$scope.NewPIN};util.changePIN(input).then(saveCb)["catch"](errorPush)["finally"](overlay.stop.bind(overlay,overlayId))}})}();