text: !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("react"),require("@reach/dialog"),require("@reach/visually-hidden"),require("react-netlify-identity"),require("@reach/tabs")):"function"==typeof define&&define.amd?define(["exports","react","@reach/dialog","@reach/visually-hidden","react-netlify-identity","@reach/tabs"],t):(e=e||self,t(e["react-netlify-identity-widget"]={},e.React,e.dialog,e.VisuallyHidden,e.reactNetlifyIdentity,e.tabs))}(this,function(e,t,n,r,a,l){"use strict";function o(){const[e,n]=t.useState(!1),r=t.useRef(!1);return t.useEffect(()=>(r.current=!0,()=>void(r.current=!1)),[]),[e,function(e){return n(!0),e.finally(()=>r.current&&n(!1))}]}function s(){const{loginUser:e}=a.useIdentityContext(),n=t.useRef(null),[l,s]=t.useState(""),[i,c]=o();return t.createElement("form",{ref:n,className:"form",onSubmit:t=>{t.preventDefault();const n=t.target,r=n.email.value,a=n.password.value;c(e(r,a,!0)).then(e=>{console.log("Success! Logged in",e)}).catch(e=>void console.error(e)||s("Error: "+e.message))}},t.createElement("div",{className:"formGroup",key:"email"},t.createElement("label",null,t.createElement(r,null,"Enter your email"),t.createElement("input",{className:"formControl",type:"email",name:"email",placeholder:"Email",autoCapitalize:"off",required:!0}),t.createElement("div",{className:"inputFieldIcon inputFieldEmail"}))),t.createElement("div",{className:"formGroup",key:"password"},t.createElement("label",null,t.createElement(r,null,"Enter your password"),t.createElement("input",{className:"formControl",type:"password",name:"password",placeholder:"Password",required:!0}),t.createElement("div",{className:"inputFieldIcon inputFieldPassword"}))),t.createElement("div",null,t.createElement("button",{type:"submit",className:i?"btn saving":"btn"},"Log in"),l&&t.createElement("pre",{style:{background:"salmon",padding:10}},l)),t.createElement("button",{type:"button",className:"btnLink forgotPasswordLink"},"Forgot password?"))}function i(){const e=a.useIdentityContext(),n=e&&e.user&&e.user.user_metadata&&e.user.user_metadata.full_name||"NoName",[r,l]=o();return t.createElement(t.Fragment,null,t.createElement("div",{className:"header"},t.createElement("button",{className:"btn btnHeader active"},"Logged in")),t.createElement("form",{className:"form "},t.createElement("p",{className:"infoText"},"Logged in as ",t.createElement("br",null),t.createElement("span",{className:"infoTextEmail"},n)),t.createElement("button",{type:"submit",className:r?"btn saving":"btn",onClick:()=>l(e.logoutUser())},"Log out")))}function c(){const{signupUser:e}=a.useIdentityContext(),n=t.useRef(null),[l,s]=t.useState(""),[i,c]=o();return t.createElement("form",{ref:n,className:"form",onSubmit:t=>{t.preventDefault(),(()=>{if(!n.current)return;const t=n.current.username.value,r=n.current.email.value,a=n.current.password.value,l={signupSource:"react-netlify-identity-widget",full_name:t};c(e(r,a,l)).then(e=>{console.log("Success! Signed up",e)}).catch(e=>void console.error(e)||s("Error: "+e.message))})()}},t.createElement("div",{className:"formGroup",key:"username"},t.createElement("label",null,t.createElement(r,null,"Enter your name"),t.createElement("input",{id:"username",className:"formControl",type:"name",name:"username",placeholder:"Name",autoCapitalize:"off",required:!0}),t.createElement("div",{className:"inputFieldIcon inputFieldName"}))),t.createElement("div",{className:"formGroup",key:"email"},t.createElement("label",null,t.createElement(r,null,"Enter your email"),t.createElement("input",{className:"formControl",type:"email",name:"email",placeholder:"Email",autoCapitalize:"off",required:!0}),t.createElement("div",{className:"inputFieldIcon inputFieldEmail"}))),t.createElement("div",{className:"formGroup",key:"password"},t.createElement("label",null,t.createElement(r,null,"Enter your password"),t.createElement("input",{className:"formControl",type:"password",name:"password",placeholder:"Password",required:!0}),t.createElement("div",{className:"inputFieldIcon inputFieldPassword"}))),t.createElement("div",null,t.createElement("button",{type:"submit",className:i?"btn saving":"btn"},"Sign Up"),l&&t.createElement("pre",{style:{background:"salmon",padding:10}},l)))}function u(){const{settings:e}=a.useIdentityContext(),n=Object.entries(e.external).some(([e,t])=>["github","gitlab","bitbucket","google"].includes(e)&&t);if(!n)return null;let r=!1;return"undefined"!=typeof window&&(r=Boolean("localhost"===window.location.hostname||"[::1]"===window.location.hostname||window.location.hostname.match(/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/))),t.createElement("div",{className:"providersGroup"},r&&t.createElement("pre",null,"⚠️Testing providers on localhost won't work because OAuth redirects to your production site"),t.createElement("hr",{className:"hr"}),t.createElement(m,{settings:e,provider:"Google"}),t.createElement(m,{settings:e,provider:"GitHub"}),t.createElement(m,{settings:e,provider:"GitLab"}),t.createElement(m,{settings:e,provider:"Bitbucket"}))}function m({settings:e,provider:n}){const r=e.external;if(!r[n.toLowerCase()])return null;const{loginProvider:l}=a.useIdentityContext();return t.createElement("button",{onClick:()=>l(n.toLowerCase()),className:`provider${n} btn btnProvider`},"Continue with ",n)}function d(){return t.createElement("div",null,t.createElement(l.Tabs,{defaultIndex:0},t.createElement(l.TabList,{className:"header"},t.createElement(l.Tab,{className:"btn btnHeader"},"Login"),t.createElement(l.Tab,{className:"btn btnHeader"},"Sign Up")),t.createElement(l.TabPanels,null,t.createElement(l.TabPanel,null,t.createElement(s,null)),t.createElement(l.TabPanel,null,t.createElement(c,null)))),t.createElement(u,null))}function p(){return t.createElement(i,null)}function E({}){const e=a.useIdentityContext(),n=Boolean(e&&e.user);return t.createElement(n?p:d,null)}function f({onCloseDialog:e}){return t.createElement(E,{onCloseDialog:e})}t=t&&t.hasOwnProperty("default")?t.default:t,r=r&&r.hasOwnProperty("default")?r.default:r;class b extends t.Component{constructor(e){super(e),this.state={hasError:!1}}static getDerivedStateFromError(){return{hasError:!0}}render(){return this.state.hasError?t.createElement("h1",null,"Something went loading the widget."):this.props.children}}const g=a.IdentityContextProvider,y=a.useIdentityContext;function h({showDialog:e,onCloseDialog:a}){return t.createElement(n.Dialog,{isOpen:e,onDismiss:a,style:{border:"solid 5px hsla(0, 0%, 0%, 0.5)",borderRadius:"10px",position:"relative",maxWidth:400}},t.createElement("button",{className:"btn btnClose",onClick:a},t.createElement(r,null,"Close")),t.createElement(b,null,t.createElement(t.Suspense,{fallback:t.createElement("div",null,"Loading...")},t.createElement(f,{onCloseDialog:a}))))}Object.defineProperty(e,"useNetlifyIdentity",{enumerable:!0,get:function(){return a.useNetlifyIdentity}}),e.IdentityContextProvider=g,e.IdentityModal=h,e.default=h,e.useIdentityContext=y});
  //# sourceMappingURL=react-netlify-identity-widget.umd.production.js.map
  