"use strict";var E=Object.create;var l=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var $=Object.getPrototypeOf;var A=Object.prototype.hasOwnProperty;var I=(t,e)=>l(t,"name",{value:e,configurable:true});var F=(t,e)=>{for(var i in e)l(t,i,{get:e[i],enumerable:true})};var S=(t,e,i,o)=>{if(e&&typeof e==="object"||typeof e==="function"){for(let a of P(e))if(!A.call(t,a)&&a!==i)l(t,a,{get:()=>e[a],enumerable:!(o=_(e,a))||o.enumerable})}return t};var m=(t,e,i)=>(i=t!=null?E($(t)):{},S(e||!t||!t.__esModule?l(i,"default",{value:t,enumerable:true}):i,t));var q=t=>S(l({},"__esModule",{value:true}),t);var M=(t,e,i,o)=>{var a=o>1?void 0:o?_(e,i):e;for(var d=t.length-1,c;d>=0;d--)if(c=t[d])a=(o?c(e,i,a):c(a))||a;if(o&&a)l(e,i,a);return a};var D={};F(D,{default:()=>z});module.exports=q(D);var s=require("react/jsx-runtime");var L=m(require("classnames"));var b=require("lodash");var y=require("mobx-react");var N=require("react");var u=require("react-intl");var k=require("react-router-dom");var p=require("../../helpers/validation-helpers");var w=m(require("../../lib/Form"));var C=m(require("../ui/Infobox"));var H=m(require("../ui/button"));var B=m(require("../ui/effects/Appear"));var h=require("../ui/headline");var g=m(require("../ui/input/index"));const r=(0,u.defineMessages)({settingsHeadline:{id:"settings.invite.headline",defaultMessage:"Invite Friends"},headline:{id:"invite.headline.friends",defaultMessage:"Invite 3 of your friends or colleagues"},nameLabel:{id:"invite.name.label",defaultMessage:"Name"},emailLabel:{id:"invite.email.label",defaultMessage:"Email address"},submitButtonLabel:{id:"invite.submit.label",defaultMessage:"Send invites"},skipButtonLabel:{id:"invite.skip.label",defaultMessage:"I want to do this later"},inviteSuccessInfo:{id:"invite.successInfo",defaultMessage:"Invitations sent successfully"}});let f=class extends N.Component{form;constructor(e){super(e);this.state={showSuccessInfo:false};this.form=new w.default({fields:{invite:[...Array.from({length:3}).fill({fields:{name:{label:this.props.intl.formatMessage(r.nameLabel),placeholder:this.props.intl.formatMessage(r.nameLabel),onChange:()=>{this.setState({showSuccessInfo:false})},validators:[p.required]},email:{label:this.props.intl.formatMessage(r.emailLabel),placeholder:this.props.intl.formatMessage(r.emailLabel),onChange:()=>{this.setState({showSuccessInfo:false})},validators:[p.email]}}})]}})}componentDidMount(){const e=document.querySelector("input:first-child");if(e){e.focus()}}submit(e){e.preventDefault();this.form?.submit({onSuccess:i=>{this.props.onSubmit({invites:i.values().invite});this.form?.clear();const o=document.querySelector("input:first-child");if(o){o.focus()}this.setState({showSuccessInfo:true})},onError:b.noop})}render(){const{form:e}=this;const{intl:i}=this.props;const{embed:o=false,isInviteSuccessful:a=false,isLoadingInvite:d=false}=this.props;const c=e.$("invite").map(n=>n.$("email").value).some(n=>n.trim()!=="");const x=(0,L.default)({auth__button:true,"invite__embed--button":o});const v=(0,s.jsxs)(s.Fragment,{children:[this.state.showSuccessInfo&&a&&(0,s.jsx)(B.default,{children:(0,s.jsx)(C.default,{type:"success",icon:"checkbox-marked-circle-outline",dismissible:true,children:i.formatMessage(r.inviteSuccessInfo)})}),(0,s.jsxs)("form",{className:"franz-form auth__form",onSubmit:n=>this.submit(n),children:[!o&&(0,s.jsx)("img",{src:"./assets/images/logo.svg",className:"auth__logo",alt:""}),(0,s.jsx)(h.H1,{className:o?"invite__embed":"",children:i.formatMessage(r.headline)}),e.$("invite").map(n=>(0,s.jsx)("div",{className:"grid",children:(0,s.jsxs)("div",{className:"grid__row",children:[(0,s.jsx)(g.default,{...n.$("name").bind(),showLabel:false}),(0,s.jsx)(g.default,{...n.$("email").bind(),showLabel:false})]})},n.key)),(0,s.jsx)(H.default,{type:"submit",className:x,disabled:!c,label:i.formatMessage(r.submitButtonLabel),loaded:!d,onClick:b.noop}),!o&&(0,s.jsx)(k.Link,{to:"/",className:"franz-form__button franz-form__button--secondary auth__button auth__button--skip",children:i.formatMessage(r.skipButtonLabel)})]})]});return(0,s.jsxs)("div",{className:o?"settings__main":"auth__container auth__container--signup",children:[o&&(0,s.jsx)("div",{className:"settings__header",children:(0,s.jsx)(h.H1,{children:i.formatMessage(r.settingsHeadline)})}),o?(0,s.jsx)("div",{className:"settings__body invite__form",children:v}):(0,s.jsx)("div",{children:v})]})}};I(f,"Invite");f=M([y.observer],f);var z=(0,u.injectIntl)(f);
