(window.webpackJsonp=window.webpackJsonp||[]).push([[17],{1244:function(e,t,n){"use strict";n.r(t);var i=n(0),r=n(490);t.default=i.memo(function(e){return i.createElement(r.a,{messagePrefix:"Sign up with Civil",onOuterClicked:e.onOuterClicked,onSignUpContinue:e.onSignUpContinue,onSignUpUserAlreadyExists:e.onSignUpUserAlreadyExists,onUserSelectLogIn:e.onUserSelectLogIn})})},353:function(e,t,n){"use strict";function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=[],i=!0,r=!1,o=void 0;try{for(var a,l=e[Symbol.iterator]();!(i=(a=l.next()).done)&&(n.push(a.value),!t||n.length!==t);i=!0);}catch(s){r=!0,o=s}finally{try{i||null==l.return||l.return()}finally{if(r)throw o}}return n}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance")}()}n.d(t,"a",function(){return i})},490:function(e,t,n){"use strict";var i=n(15),r=n.n(i),o=n(25),a=n(353),l=n(0),s=n(178),u=n(575),c=n(6),d=c.default.div.withConfig({displayName:"authStyledComponents__StyledAuthHeader",componentId:"pz7gvh-0"})(["font-size:24px;font-weight:bold;line-height:29px;margin:0 0 24px;"]),g=(c.default.div.withConfig({displayName:"authStyledComponents__StyledAuthHeaderCopy",componentId:"pz7gvh-1"})(["font-size:16px;line-height:26px;margin:0 0 24px;"]),c.default.div.withConfig({displayName:"authStyledComponents__StyledAuthAltOption",componentId:"pz7gvh-2"})(["font-size:14px;line-height:17px;margin:37px 0 0;"]),"GraphQL error: User already exists with this identifier"),p="GraphQL error: signature invalid or not signed up",h="cancelled",f="switch to sign up",y="switch to log in";t.a=function(e){var t=l.useContext(s.CivilContext),n=l.useContext(u.KirbyEthereumContext),i=l.useState(!1),c=Object(a.a)(i,2),w=c[0],m=c[1],S=l.useState(void 0),v=Object(a.a)(S,2),x=v[0],C=v[1],b=l.useState(void 0),U=Object(a.a)(b,2),k=U[0],E=U[1];function A(){return(A=Object(o.a)(r.a.mark(function i(){var o;return r.a.wrap(function(i){for(;;)switch(i.prev=i.next){case 0:if(i.prev=0,"Log in to Civil"!==e.messagePrefix){i.next=9;break}return i.next=4,n.kirby.plugins.identity.login("Civil");case 4:return o=i.sent,i.next=7,t.auth.authenticate(o);case 7:i.next=14;break;case 9:return i.next=11,n.kirby.plugins.identity.signup("Civil");case 11:return o=i.sent,i.next=14,t.auth.signup(o);case 14:e.onAuthenticated&&e.onAuthenticated(o.signer),e.onSignUpContinue&&e.onSignUpContinue(),i.next=21;break;case 18:i.prev=18,i.t0=i.catch(0),i.t0.toString().includes(g)?(C(i.t0),E({cb:e.onSignUpUserAlreadyExists})):i.t0.toString().includes(p)?(C(i.t0),E({cb:e.onLogInNoUserExists})):i.t0.toString().includes(h)?(E({cb:e.onOuterClicked}),e.onOuterClicked&&e.onOuterClicked()):i.t0.toString().includes(f)?e.onUserSelectSignUp&&e.onUserSelectSignUp():i.t0.toString().includes(y)?e.onUserSelectLogIn&&e.onUserSelectLogIn():(C(i.t0),E({cb:e.onOuterClicked}));case 21:case"end":return i.stop()}},i,null,[[0,18]])}))).apply(this,arguments)}return l.useEffect(function(){(function(){return A.apply(this,arguments)})().catch(function(e){console.log("error",e)})},[]),l.createElement(l.Fragment,null,w?l.createElement(s.MetaMaskModal,{waiting:!1,denied:!0,denialText:"To authenticate that you own your wallet address, you need to sign the message in your MetaMask wallet.",cancelTransaction:O},l.createElement(s.ModalHeading,null,"Failed to authenticate your wallet address")):null,function(){if(!x)return null;console.log("rendering error message",x);var e=x.toString(),t="Something went wrong when authenticating your wallet address (".concat(x,"). Please try again later.");return e.includes(g)?t="A user with this Ethereum address already exists. You will now be redirected to Log In.":e.includes(p)&&(t="No user with this Ethereum address was found. You will now be redirected to Sign Up."),l.createElement("div",null,l.createElement(d,null,"Log in to Civil"),l.createElement(s.MetaMaskModal,{alert:!0,bodyText:t,cancelTransaction:O},l.createElement(s.ModalHeading,null,"Failed to save your wallet address")))}());function O(){console.log("calling cancelTransaction"),k&&k.cb(),C(void 0),E(void 0),m(!1)}}}}]);