var __extends=(this&&this.__extends)||(function(){var extendStatics=function(d,b){extendStatics=Object.setPrototypeOf||({__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b;})||function(d,b){for(var p in b)if(b.hasOwnProperty(p))d[p]=b[p];};return extendStatics(d,b);};return function(d,b){extendStatics(d,b);function __(){this.constructor=d;} d.prototype=b===null?Object.create(b):(__.prototype=b.prototype,new __());};})();var __assign=(this&&this.__assign)||function(){__assign=Object.assign||function(t){for(var s,i=1,n=arguments.length;i=0;i--)if(d=decorators[i])r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r;return c>3&&r&&Object.defineProperty(target,key,r),r;};var __awaiter=(this&&this.__awaiter)||function(thisArg,_arguments,P,generator){function adopt(value){return value instanceof P?value:new P(function(resolve){resolve(value);});} return new(P||(P=Promise))(function(resolve,reject){function fulfilled(value){try{step(generator.next(value));}catch(e){reject(e);}} function rejected(value){try{step(generator["throw"](value));}catch(e){reject(e);}} function step(result){result.done?resolve(result.value):adopt(result.value).then(fulfilled,rejected);} step((generator=generator.apply(thisArg,_arguments||[])).next());});};var __generator=(this&&this.__generator)||function(thisArg,body){var _={label:0,sent:function(){if(t[0]&1)throw t[1];return t[1];},trys:[],ops:[]},f,y,t,g;return g={next:verb(0),"throw":verb(1),"return":verb(2)},typeof Symbol==="function"&&(g[Symbol.iterator]=function(){return this;}),g;function verb(n){return function(v){return step([n,v]);};} function step(op){if(f)throw new TypeError("Generator is already executing.");while(_)try{if(f=1,y&&(t=op[0]&2?y["return"]:op[0]?y["throw"]||((t=y["return"])&&t.call(y),0):y.next)&&!(t=t.call(y,op[1])).done)return t;if(y=0,t)op=[op[0]&2,t.value];switch(op[0]){case 0:case 1:t=op;break;case 4:_.label++;return{value:op[1],done:false};case 5:_.label++;y=op[1];op=[0];continue;case 7:op=_.ops.pop();_.trys.pop();continue;default:if(!(t=_.trys,t=t.length>0&&t[t.length-1])&&(op[0]===6||op[0]===2)){_=0;continue;} if(op[0]===3&&(!t||(op[1]>t[0]&&op[1]4){_this.setState({submit_clicked:true},function(){_this.submitButtonOnClick({});});}}}},this.state[Login_args_enum.email+"_error"])),name:"email"}))),React.createElement(material_ui_components_1.Grid,{container:true,spacing:24},React.createElement(material_ui_components_1.Grid,{item:true,xs:12},React.createElement(mui_field_1.default,{handler:Object.assign(this.props.utils,common_utils_1.default),owner:this,component:React.createElement(material_ui_components_1.TextField,__assign({fullWidth:true,disabled:this.state.submit_clicked,type:this.state.show_password?'text':'password',label:"Password",InputProps:{id:"password_box",className:styles.password,endAdornment:(React.createElement("div",{className:"adornment-container",style:{cursor:'pointer',pointerEvents:'all'},onClick:function(){_this.setState({show_password:!_this.state.show_password});}},React.createElement("div",{className:"right-adornment-inner"},React.createElement("div",{className:"right-adornment-inner-separator"}),this.state.show_password?React.createElement("i",{className:'fa fa-eye'}):React.createElement("i",{className:'fa fa-eye-slash'}))))},onChange:function(e){_this.handleChange(Login_args_enum.password)(e);},onBlur:function(e){_this.validatePasswordTextFields();},onKeyDown:function(e){if(e.keyCode==13){_this.setState({submit_clicked:true},function(){_this.submitButtonOnClick({});});}}},this.state[Login_args_enum.password+"_error"])),name:"password"}))),React.createElement(material_ui_components_1.Grid,{container:true,spacing:24},React.createElement(material_ui_components_1.Grid,{item:true,xs:12,md:6})),React.createElement(material_ui_components_1.Grid,{container:true,spacing:24},React.createElement(material_ui_components_1.Grid,{item:true,xs:12,style:{position:'relative'}},React.createElement(material_ui_components_1.Button,{fullWidth:true,variant:"contained",color:"primary",disabled:this.state.submit_clicked,onClick:function(){_this.setState({submit_clicked:true},function(){_this.submitButtonOnClick({});});}},React.createElement("i",{className:'fa fa-lock'}),"\u00A0 Log In "),this.state.submit_clicked&&React.createElement(material_ui_components_1.CircularProgress,{size:24,className:styles.button_progress}))),React.createElement(material_ui_components_1.Grid,{container:true,spacing:24},React.createElement(material_ui_components_1.Grid,{item:true,xs:12,md:6})),React.createElement(material_ui_components_1.Grid,{container:true,spacing:24,style:{textAlign:'left'}},React.createElement(material_ui_components_1.Grid,{item:true,xs:12},React.createElement(material_ui_components_1.Button,{variant:"flat",color:"primary",onClick:function(){_this.props.state_manager.setRunState(initial_state_interface_1.Initial_state_enum.page,'forgot-password');}},"Forgot Password"))),!client_id?React.createElement(React.Fragment,null,React.createElement(base_components_1.DividerWithCenteredText,{marginTop:24},"or log in with"),React.createElement(material_ui_components_1.Grid,{container:true,spacing:16,style:{marginTop:24}},React.createElement(material_ui_components_1.Grid,{item:true,xs:12},React.createElement(material_ui_components_1.Button,{style:{width:'100%'},variant:"outlined",onClick:function(){utils_1.showLoader(_this);gapi.load('auth2',function(){var auth2=gapi.auth2.init({client_id:'1014704240806-sgoh2hmob49243ba286hs3fj8v11djj9.apps.googleusercontent.com',});auth2.signIn().then(function(evt){_this.setState({google_id_token:evt.getAuthResponse().id_token},function(){_this.google_form.submit();});},function(err){console.error(err);utils_1.hideLoader(_this);});});}},React.createElement("img",{draggable:false,src:"../../../../../../assets/imgs/google_g.svg",style:{height:20},alt:"Google"}),"\u00A0Google")),React.createElement(material_ui_components_1.Grid,{item:true,xs:6},React.createElement(material_ui_components_1.Button,{style:{width:'100%'},variant:"outlined",onClick:function(){window.location='/app/intuit-oauth-init';}},React.createElement("img",{draggable:false,src:"../../../../../../assets/imgs/Intuit1.png",style:{height:12},alt:"Intuit"}),"\u00A0Intuit")),React.createElement(material_ui_components_1.Grid,{item:true,xs:6},React.createElement(material_ui_components_1.Button,{style:{width:'100%'},variant:"outlined",onClick:function(){window.location='/app/xero-oauth-init';}},React.createElement("img",{draggable:false,src:"../../../../../../assets/imgs/xero-logo.svg",style:{height:18},alt:"Xero"}),"\u00A0Xero")))):null))))),init.organization_cobrand&&init.organization_cobrand_type==="full"&&init.organization_logo?React.createElement("tr",{style:{textAlign:'center'}},React.createElement("td",{style:{paddingTop:16}},"Powered by",React.createElement("br",null),React.createElement("img",{draggable:false,src:"../../../../assets/imgs/logo-onpay-2020.svg",width:120}))):null,init.organization_cobrand||client_id?null:React.createElement("tr",{style:{textAlign:'center'}},React.createElement("td",null,React.createElement("div",{className:'login-footer'}),React.createElement("br",null),React.createElement("br",null),React.createElement("span",null,React.createElement(material_ui_components_1.Typography,{variant:"subtitle1"},"Are you an employer looking to get started?"),React.createElement("a",{className:'font-medium',href:"javascript:void(0)",style:{textDecoration:"underline"},onClick:function(){window.location='https://onpay.com/get-started?channel=login';return;_this.props.state_manager.setRunState(initial_state_interface_1.Initial_state_enum.page,'create-account');}},"Sign up and get one month free"),React.createElement(material_ui_components_1.Divider,{style:{width:100,margin:'32px auto 24px'}}),React.createElement(material_ui_components_1.Typography,{variant:"body1"},"If you're an employee without an account ",React.createElement("br",null),React.createElement(base_components_1.AHREF,{link:"https://help.onpay.com/hc/en-us/articles/4406432366363"},"click here")," to learn how to request access from your employer.")))))))));};Login.prototype.listMessage=function(){var _this=this;if(this.state.errorMessage) return(React.createElement(material_ui_components_1.Grid,{container:true,spacing:24},React.createElement(material_ui_components_1.Grid,{item:true,xs:12},React.createElement(base_components_1.AlertErrorSmallSquare,null,"There was an error processing your request."))));if(!this.state.message) return null;if(this.state.message.substr(0,1)==="E") return(React.createElement(material_ui_components_1.Grid,{container:true,spacing:24},React.createElement(material_ui_components_1.Grid,{item:true,xs:12},React.createElement(base_components_1.AlertErrorSmallSquare,null,errors_1.ERRORS.find(function(message){return message.id===_this.state.message;})?errors_1.ERRORS.find(function(message){return message.id===_this.state.message;}).text:'There was an error processing your request.'))));if(this.state.message.substr(0,1)==="A") return(React.createElement(material_ui_components_1.Grid,{container:true,spacing:24},React.createElement(material_ui_components_1.Grid,{item:true,xs:12},React.createElement(base_components_1.AlertInfoSmallSquare,null,alerts_1.ALERTS.find(function(message){return message.id===_this.state.message;})?alerts_1.ALERTS.find(function(message){return message.id===_this.state.message;}).text:''))));return(React.createElement(material_ui_components_1.Grid,{container:true,spacing:24},React.createElement(material_ui_components_1.Grid,{item:true,xs:12},React.createElement(base_components_1.AlertErrorSmallSquare,null,"There was an error processing your request."))));};Login.prototype.onSignInGoogle=function(googleUser){var profile=googleUser.getBasicProfile();console.log('ID: '+profile.getId());console.log('Name: '+profile.getName());console.log('Image URL: '+profile.getImageUrl());console.log('Email: '+profile.getEmail());};Login.prototype.validatePasswordTextFields=function(){common_utils_1.default.validateProperty(this,common_utils_1.default,Login_args_enum.password);};Login.prototype.submitButtonOnClick=function(args){var _this=this;if(_app.environment!=='production'){this.submitForm();return;} grecaptcha.ready(function(){grecaptcha.execute(recaptcha_site_key,{action:'submit'}).then(function(token){return __awaiter(_this,void 0,void 0,function(){var _this=this;return __generator(this,function(_a){this.setState({re_token:token},function(){_this.submitForm();});return[2];});});});});};Login.prototype.submitForm=function(){this.form.submit();};Login.prototype.validateView=function(props,required){if(required===void 0){required=[];} var validator=new Validator({});var val=validator.validateParams({"obj":props,"schema":{required:required,properties:{}},"view":null});this.setState({missing_params:val.missingParams,invalid_params:val.invalidParams,error_messages:val.errorMessages,error_messages_with_property:val.errorMessagesWithProperty});return val;};Login=__decorate([with_state_manager_1.default],Login);return Login;}(module_abstract_1.default));exports.default=Login;});