"use strict";var N=Object.create;var d=Object.defineProperty;var g=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var S=Object.getPrototypeOf;var W=Object.prototype.hasOwnProperty;var k=(s,o)=>d(s,"name",{value:o,configurable:true});var B=(s,o)=>{for(var e in o)d(s,e,{get:o[e],enumerable:true})};var w=(s,o,e,r)=>{if(o&&typeof o==="object"||typeof o==="function"){for(let t of U(o))if(!W.call(s,t)&&t!==e)d(s,t,{get:()=>o[t],enumerable:!(r=g(o,t))||r.enumerable})}return s};var f=(s,o,e)=>(e=s!=null?N(S(s)):{},w(o||!s||!s.__esModule?d(e,"default",{value:s,enumerable:true}):e,s));var D=s=>w(d({},"__esModule",{value:true}),s);var I=(s,o,e,r)=>{var t=r>1?void 0:r?g(o,e):o;for(var l=s.length-1,n;l>=0;l--)if(n=s[l])t=(r?n(o,e,t):n(t))||t;if(r&&t)d(o,e,t);return t};var E={};B(E,{default:()=>x});module.exports=D(E);var a=require("react/jsx-runtime");var h=require("@electron/remote");var u=require("lodash");var _=require("mobx-react");var M=require("react");var p=require("react-intl");var P=require("../../environment");var v=f(require("../../lib/Form"));var c=f(require("../ui/button"));var C=require("../ui/headline");var T=f(require("../ui/input/index"));const i=(0,p.defineMessages)({headline:{id:"locked.headline",defaultMessage:"Locked"},touchId:{id:"locked.touchId",defaultMessage:"Unlock with Touch ID"},passwordLabel:{id:"locked.password.label",defaultMessage:"Password"},submitButtonLabel:{id:"locked.submit.label",defaultMessage:"Unlock"},unlockWithPassword:{id:"locked.unlockWithPassword",defaultMessage:"Unlock with Password"},invalidCredentials:{id:"locked.invalidCredentials",defaultMessage:"Password invalid"}});let m=class extends M.Component{form;constructor(o){super(o);this.form=new v.default({fields:{password:{label:this.props.intl.formatMessage(i.passwordLabel),value:"",type:"password"}}})}submit(o){o.preventDefault();this.form.submit({onSuccess:e=>{this.props.onSubmit(e.values())},onError:u.noop})}touchIdUnlock(){const{intl:o}=this.props;h.systemPreferences.promptTouchID(o.formatMessage(i.touchId)).then(()=>{this.props.unlock()})}render(){const{form:o}=this;const{isSubmitting:e,error:r,useTouchIdToUnlock:t,intl:l}=this.props;const n=P.isMac?t&&h.systemPreferences.canPromptTouchID():false;const b=n?l.formatMessage(i.unlockWithPassword):l.formatMessage(i.submitButtonLabel);return(0,a.jsx)("div",{className:"auth__container",children:(0,a.jsxs)("form",{className:"franz-form auth__form",onSubmit:y=>this.submit(y),children:[(0,a.jsx)("img",{src:"./assets/images/logo.svg",className:"auth__logo",alt:""}),(0,a.jsx)(C.H1,{children:l.formatMessage(i.headline)}),n&&(0,a.jsxs)(a.Fragment,{children:[(0,a.jsx)(c.default,{className:"auth__button touchid__button",label:l.formatMessage(i.touchId),onClick:()=>this.touchIdUnlock(),type:"button"}),(0,a.jsx)("hr",{className:"locked__or_line"})]}),(0,a.jsx)(T.default,{...o.$("password").bind(),showPasswordToggle:true,focus:true}),r&&(0,a.jsx)("p",{className:"error-message center",children:l.formatMessage(i.invalidCredentials)}),e?(0,a.jsx)(c.default,{className:"auth__button is-loading",buttonType:"secondary",label:`${b} ...`,loaded:false,onClick:u.noop,disabled:true}):(0,a.jsx)(c.default,{type:"submit",className:"auth__button",label:b,onClick:u.noop})]})})}};k(m,"Locked");m=I([_.observer],m);var x=(0,p.injectIntl)(m);
