'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-22fd9091.js');
const core = require('./core-787915c4.js');
require('./_commonjsHelpers-5cfcba41.js');
require('./index-a20d8492.js');
require('./runStore-bfd81991.js');
const authStore = require('./authStore-cabcfab4.js');
require('./index-66ca60fa.js');
const Mutations = require('./Mutations-7f7eb38b.js');

const Account = class {
  constructor(hostRef) {
    index.registerInstance(this, hostRef);
    this.profileFormId = "profile";
  }
  async formEventHandler({ detail }) {
    if (detail.formId != this.profileFormId)
      return;
    return this.updateProfile(detail);
  }
  async updateProfile(detail) {
    const userInput = {};
    Object.keys(detail).map((value) => {
      if (detail[value].key) {
        userInput[detail[value].key] = detail[value].value;
      }
    });
    await core.coreState.client.mutate(Mutations.userUpdateGQL, {
      userInput,
    });
  }
  render() {
    var _a, _b;
    return ((_a = authStore.authStore.identity) === null || _a === void 0 ? void 0 : _a.user) ? (index.h("corejam-box", { max: "xl", mx: "auto", mt: 12, px: 4, lgPx: 0 }, index.h("corejam-box", { mb: 16 }, index.h("corejam-type", { as: "h2", size: "3xl", align: "center", weight: "bold" }, "My Account")), index.h("corejam-box", { flex: true }, index.h("corejam-box", { w: "3", pt: 8, bWidthTop: 1, bColor: "gray-500", mr: 24 }, index.h("corejam-box", { flex: true, direction: "col" }, index.h("corejam-box", { mb: 4 }, index.h("corejam-base-link", { href: "#", class: "py-4 mb-1" }, "Account details")), index.h("corejam-box", { mb: 4 }, index.h("corejam-base-link", { href: "#", class: "py-4 mb-1" }, "Settings")))), index.h("corejam-box", { w: "9", pt: 8, bWidthTop: 1, bColor: "gray-500" }, index.h("corejam-form-container", { name: this.profileFormId }, index.h("corejam-box", { flex: true, mb: 8 }, index.h("corejam-box", { w: "6", pl: 4 }, index.h("corejam-form-input", { name: "email", type: "email", formId: this.profileFormId, required: true, label: "Email Address", value: (_b = authStore.authStore.identity) === null || _b === void 0 ? void 0 : _b.user.email, placeholder: "Email" }))), index.h("corejam-form-submit", { formId: this.profileFormId }, index.h("corejam-type", { size: "sm", weight: "bold", transform: "uppercase", decoration: "underline" }, "Save"))), index.h("auth-reset-password-form", null))))) : (index.h("div", null, "Login"));
  }
};

exports.auth_account = Account;
