import{r as t,h as e,H as o,a as s}from"./p-d55626d1.js";import{c as r}from"./p-2fd22ed9.js";import"./p-0bc4f624.js";import"./p-9bfc48ee.js";import{r as i}from"./p-097729d8.js";import{a}from"./p-c1c5b589.js";import{s as c}from"./p-62c3d279.js";import{c as l}from"./p-c7f96882.js";const n=class{constructor(e){t(this,e),this.display="flex",this.justify="center",this.outline="none",this.hoverOutline="none",this.focusOutline="none",this.type="button"}async componentWillLoad(){await this.computeStyles()}async computeStyles(){const t=await(await import("./p-a272a252.js").then((function(t){return t.s}))).calculateStyles(this);this.hash=t}render(){return e(this.type,{class:this.hash},e("slot",null))}static get watchers(){return{display:["computeStyles"],w:["computeStyles"],smW:["computeStyles"],mdW:["computeStyles"],lgW:["computeStyles"],xlW:["computeStyles"],bg:["computeStyles"],hoverBg:["computeStyles"],focusBg:["computeStyles"],color:["computeStyles"],hoverColor:["computeStyles"],focusColor:["computeStyles"],p:["computeStyles"],pl:["computeStyles"],pr:["computeStyles"],pt:["computeStyles"],pb:["computeStyles"],outline:["computeStyles"],hoverOutline:["computeStyles"],focusOutline:["computeStyles"],transition:["computeStyles"]}}},m=class{constructor(e){t(this,e)}render(){return e("svg",{class:"self-end",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",width:"24",height:"24"},e("path",{class:"heroicon-ui",d:"M12 12a5 5 0 1 1 0-10 5 5 0 0 1 0 10zm0-2a3 3 0 1 0 0-6 3 3 0 0 0 0 6zm9 11a1 1 0 0 1-2 0v-2a3 3 0 0 0-3-3H8a3 3 0 0 0-3 3v2a1 1 0 0 1-2 0v-2a5 5 0 0 1 5-5h8a5 5 0 0 1 5 5v2z"}))}},p=class{constructor(e){t(this,e),this.formId="identity",this.loginLink="/login/",this.registerLink="/register/",this.dropdown=!1,this.toggleMenu=()=>{this.dropdown=!this.dropdown},this.logOut=()=>{this.toggleMenu(),a.identity=null}}handleClick(t){let e=!0;this.dropdown&&(t.composedPath().forEach((t=>{t===this.element&&(e=!1)})),e&&this.toggleMenu())}componentWillLoad(){this.setRefreshTimer()}setRefreshTimer(){setTimeout((()=>{console.log("Refreshing token")}),1e4)}async formEventHandler({detail:t}){if(t.formId!=this.formId||a.identity)return;const e=await r.client.mutate({mutation:c(l),variables:{email:t.email.value,password:t.password.value}});e.data.userAuthenticate&&(this.toggleMenu(),a.identity=e.data.userAuthenticate,i.router.push("/"))}render(){return e(o,null,e("corejam-box",{position:"relative",flex:!0,direction:"row",justify:"end"},a.identity?e("corejam-box",{pr:3},e("corejam-type",{"data-cy":"identity-email"},a.identity.user.email)):null,e("corejam-icons-account",{onClick:()=>this.toggleMenu()}),e("corejam-box",{bg:"white",shadow:"0px 0px 10px rgba(0, 0, 0, 0.1)",position:"absolute",top:30,right:5,p:4,rounded:"md",w:"250px",style:{display:this.dropdown?"initial":"none"}},a.identity?e("corejam-box",{w:"12",flex:!0,direction:"col"},e("corejam-box",null,e("corejam-base-link",{href:"/account"},"My Account")),e("corejam-box",{onClick:()=>{this.logOut()}},"Log out")):e("corejam-form-container",{name:this.formId},e("corejam-flash",{"data-flash":"isolated"}),e("corejam-box",{pb:3,flex:!0,direction:"col"},e("corejam-box",{w:"12"},e("corejam-form-input",{name:"email",type:"text",formId:this.formId,label:"Email"}),e("corejam-form-input",{name:"password",type:"password",formId:this.formId,label:"Password"})),e("corejam-box",{flex:!0,direction:"row",w:"12",mt:4},e("corejam-box",{w:"6",bg:"gray-200",rounded:"md",flex:!0,justify:"center"},e("corejam-form-submit",{formId:this.formId},e("corejam-button",{type:"button",color:"gray-900",pl:"5",pr:"5",pt:"3",pb:"3"},e("corejam-type",null,"Login")))),e("corejam-box",{w:"6",flex:!0,justify:"center",items:"center"},e("corejam-base-link",{href:"/register"},"Register"))))))))}get element(){return s(this)}};export{n as corejam_button,m as corejam_icons_account,p as corejam_identity}