'use strict';

const index = require('./index-8277cbb3.js');
const index_module = require('./index.module-f8c8495f.js');
const JSS = require('./JSS-8503a151.js');
const mixins = require('./mixins-4761d472.js');
const sqmTextSpanView = require('./sqm-text-span-view-b9e10f5d.js');

const vanillaStyle = `
:host {
  display: block;
}
:host([hidden]): {
  display: none;
}
`;
function PortalForgotPasswordView(props) {
  const { states, callbacks, content } = props;
  const style = {
    FormWrapper: {
      ...mixins.AuthWrapper,
      background: content.backgroundColor || "var(--sqm-portal-background)",
      borderRadius: content.borderRadius || "var(--sqm-border-radius-normal)",
      border: content.border ||
        "var(--sqm-border-thickness) solid var(--sqm-border-color)",
    },
    Column: { ...mixins.AuthColumn },
    ButtonsContainer: mixins.AuthButtonsContainer,
    SecondaryButton: {
      margin: "auto",
      display: "block",
      cursor: "pointer",
    },
  };
  const sheet = JSS.createStyleSheet(style);
  const styleString = sheet.toString();
  return (index.h("div", { class: sheet.classes.FormWrapper, part: "sqm-base" },
    index.h("style", { type: "text/css" },
      vanillaStyle,
      styleString),
    index.h(sqmTextSpanView.TextSpanView, { type: "h3" }, content.messageSlot),
    index.h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit },
      props.states.error && (index.h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
        index.h("div", { part: "erroralert-text" }, props.states.error))),
      props.states.success && (index.h("sqm-form-message", { type: "success", exportparts: "successalert-icon" },
        index.h("div", { part: "successalert-text" }, content.successAlertText))),
      index.h("sl-input", { exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading, required: true }),
      index.h("div", { class: sheet.classes.ButtonsContainer },
        index.h("sl-button", { submit: true, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Reset Password"),
        index.h("sl-button", { type: "secondary", exportparts: "base: secondarybutton-base", class: sheet.classes.SecondaryButton, disabled: states.loading, onClick: () => index_module.jn.push(states.loginPath) }, content.loginText)))));
}

const style = {
  Wrapper: mixins.AuthWrapper,
  Column: mixins.AuthColumn,
  ForgotButtonContainer: {
    display: "inline",
    cursor: "pointer",
    "font-size": "13px",
    "font-weight": "600",
    color: "var(--sqm-text-subdued)",
    margin: "0",
  },
  ButtonsContainer: {
    ...mixins.AuthButtonsContainer,
    gap: "var(--sl-spacing-medium)",
    "& > *": {
      margin: "0 !important",
    },
  },
};
const vanillaStyle$1 = `
:host {
  display: block;
}
:host([hidden]): {
  display: none;
}
`;
const sheet = JSS.createStyleSheet(style);
const styleString = sheet.toString();
function PortalLoginView(props) {
  const { states, callbacks, content } = props;
  return (index.h("div", { class: sheet.classes.Wrapper, part: "sqm-base" },
    index.h("style", { type: "text/css" },
      vanillaStyle$1,
      styleString),
    index.h(sqmTextSpanView.TextSpanView, { type: "h3" }, content.pageLabel),
    index.h("sl-form", { class: sheet.classes.Column, "onSl-submit": callbacks.submit },
      props.states.error && (index.h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
        index.h("div", { part: "erroralert-text" }, props.states.error))),
      index.h("sl-input", { exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading, required: true }),
      index.h("div", null,
        index.h("sl-input", { exportparts: "label: input-label, base: input-base", type: "password", name: "/password", label: content.passwordLabel || "Password", disabled: states.loading, required: true }),
        index.h("div", { class: sheet.classes.ForgotButtonContainer }, content.forgotPasswordButton)),
      index.h("div", { class: sheet.classes.ButtonsContainer },
        index.h("sl-button", { submit: true, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Login"),
        content.googleButton && index.h("sl-menu-divider", null),
        content.googleButton,
        content.secondaryButton))));
}

const style$1 = {
  Wrapper: { ...mixins.AuthWrapper, "max-width": "600px" },
  Column: mixins.AuthColumn,
  HostBlock: mixins.HostBlock,
  ":host": {
    margin: "0 auto",
    width: "100%",
  },
  ButtonsContainer: mixins.AuthButtonsContainer,
  ErrorStyle: mixins.ErrorStyles,
};
const vanillaStyle$2 = `
sqm-portal-register {
  margin: 0 auto;
  width: 100%;
  display: block;
}

:host{
  display: block;
}

:host([hidden]) {
  display: none;
}
`;
const sheet$1 = JSS.createStyleSheet(style$1);
const styleString$1 = sheet$1.toString();
function PortalRegisterView(props) {
  var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o;
  const { states, refs, callbacks, content } = props;
  if (states.error) {
    window.scrollTo({ top: 0, left: 0, behavior: "smooth" });
  }
  return (index.h("div", { class: sheet$1.classes.Wrapper, part: "sqm-base" },
    index.h("style", { type: "text/css" },
      vanillaStyle$2,
      styleString$1),
    index.h(sqmTextSpanView.TextSpanView, { type: "h3" }, content.pageLabel),
    index.h("sl-form", { class: sheet$1.classes.Column, "onSl-submit": callbacks.submit, ref: (el) => (refs.formRef.current = el), novalidate: true },
      states.error && (index.h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
        index.h("div", { part: "erroralert-text" }, props.states.error))),
      content.formData,
      !states.hideInputs && (index.h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "email", name: "/email", label: content.emailLabel || "Email", disabled: states.loading, required: true, validationError: ({ value }) => {
          if (!value) {
            return content.requiredFieldErrorMessage;
          }
          // this matches shoelace validation, but could be better
          if (!value.includes("@")) {
            return content.invalidEmailErrorMessage;
          }
        } }, (((_b = (_a = states.registrationFormState) === null || _a === void 0 ? void 0 : _a.validationErrors) === null || _b === void 0 ? void 0 : _b.email) ? {
        class: sheet$1.classes.ErrorStyle,
        helpText: ((_d = (_c = states.registrationFormState) === null || _c === void 0 ? void 0 : _c.validationErrors) === null || _d === void 0 ? void 0 : _d.email) ||
          content.requiredFieldErrorMessage,
      }
        : [])))),
      !states.hideInputs && (index.h("sqm-password-field", { fieldLabel: content.passwordLabel, "disable-validation": states.disablePasswordValidation, meetsRequirementsText: content.meetsRequirementsText, doesNotMeetRequirementsText: content.doesNotMeetRequirementsText, minErrorText: content.minErrorText, uppercaseErrorText: content.uppercaseErrorText, lowercaseErrorText: content.lowercaseErrorText, hasErrorText: content.hasErrorText })),
      content.passwordField,
      !states.hideInputs && states.confirmPassword && (index.h("sl-input", Object.assign({ exportparts: "label: input-label, base: input-base", type: "password", name: "/confirmPassword", label: content.confirmPasswordLabel, disabled: states.loading || ((_e = states.registrationFormState) === null || _e === void 0 ? void 0 : _e.disabled), required: true }, (((_g = (_f = states.registrationFormState) === null || _f === void 0 ? void 0 : _f.initialData) === null || _g === void 0 ? void 0 : _g.confirmPassword) ? {
        value: (_j = (_h = states.registrationFormState) === null || _h === void 0 ? void 0 : _h.initialData) === null || _j === void 0 ? void 0 : _j.confirmPassword,
      }
        : {}), (((_l = (_k = states.registrationFormState) === null || _k === void 0 ? void 0 : _k.validationErrors) === null || _l === void 0 ? void 0 : _l.confirmPassword) ? {
        class: sheet$1.classes.ErrorStyle,
        helpText: ((_o = (_m = states.registrationFormState) === null || _m === void 0 ? void 0 : _m.validationErrors) === null || _o === void 0 ? void 0 : _o.confirmPassword) || content.requiredFieldErrorMessage,
      }
        : [])))),
      content.terms,
      index.h("div", { class: sheet$1.classes.ButtonsContainer },
        index.h("sl-button", { submit: true, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.submitLabel || "Register"),
        content.secondaryButton))));
}

const style$2 = {
  Wrapper: mixins.AuthWrapper,
  Column: mixins.AuthColumn,
  ContinueButton: {
    width: "100%",
  },
};
const vanillaStyle$3 = `
:host {
  display: block;
}
:host([hidden]): {
  display: none;
}
`;
const sheet$2 = JSS.createStyleSheet(style$2);
const styleString$2 = sheet$2.toString();
function PortalVerifyEmailView(props) {
  const { states, data, callbacks, content } = props;
  if (states.loading)
    return;
  if (states.success) {
    return (index.h("div", { class: sheet$2.classes.Wrapper, part: "sqm-base" },
      index.h("style", { type: "text/css" },
        vanillaStyle$3,
        styleString$2),
      index.h(sqmTextSpanView.TextSpanView, { type: "h3" }, content.verifyEmailText),
      index.h("sqm-form-message", { exportparts: "success-icon" },
        index.h("div", { part: "successalert-text" }, content.verifySuccessText)),
      index.h("sl-button", { class: sheet$2.classes.ContinueButton, onClick: callbacks.gotoNextPage, loading: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.continueText)));
  }
  if (states.error || !data.oobCode) {
    return (index.h("div", { class: sheet$2.classes.Wrapper, part: "sqm-base" },
      index.h("style", { type: "text/css" }, styleString$2),
      index.h(sqmTextSpanView.TextSpanView, { type: "h3" }, content.verifyEmailText),
      index.h("sqm-form-message", { type: "error", exportparts: "erroralert-icon" },
        index.h("div", { part: "erroralert-text" }, content.verifyInvalidText)),
      index.h("sl-button", { class: sheet$2.classes.ContinueButton, onClick: callbacks.failed, disabled: states.loading, exportparts: "base: primarybutton-base", type: "primary" }, content.continueText)));
  }
}

exports.PortalForgotPasswordView = PortalForgotPasswordView;
exports.PortalLoginView = PortalLoginView;
exports.PortalRegisterView = PortalRegisterView;
exports.PortalVerifyEmailView = PortalVerifyEmailView;
