import { Component, h, Prop, State } from "@stencil/core";
import { withHooks } from "@saasquatch/stencil-hooks";
import { PortalChangePasswordView, } from "./sqm-portal-change-password-view";
import { usePortalChangePassword } from "./usePortalChangePassword";
import { isDemo } from "@saasquatch/component-boilerplate";
import deepmerge from "deepmerge";
import { useState } from "@saasquatch/universal-hooks";
/**
 * @uiName Microsite Password Change
 * @validParents ["sqm-portal-container","div","sqm-divided-layout","sqm-brand"]
 */
export class PortalChangePassword {
  constructor() {
    this.ignored = true;
    /**
     * @uiName Change password modal header
     */
    this.modalChangePasswordHeader = "Change Password";
    /**
     * Found in modal
     *
     * @uiName Cancel button text
     */
    this.cancelText = "Cancel";
    /**
     * Found in modal
     *
     * @uiName Change password button text
     */
    this.changePasswordButtonText = "Change Password";
    /**
     * Found in modal
     *
     * @uiName New password field label
     */
    this.passwordFieldLabel = "New Password";
    /**
     * Found in modal
     *
     * @uiName Confirm password Label
     */
    this.confirmPasswordFieldLabel = "Confirm New Password";
    /**
     * Successful password change message
     *
     * @uiName Successful password change message
     * @uiWidget textArea
     */
    this.successMessage = "Your password has been updated.";
    /**
     * Portal change password section header
     *
     * @uiName Change password header
     */
    this.portalChangePasswordHeader = "Password";
    /**
     * @uiName Change password button text
     */
    this.portalChangePasswordButtonText = "Change your password...";
    /**
     * @uiName Password requirement met
     */
    this.meetsRequirementsText = "Password has met all requirements";
    /**
     * @uiName Password requirement failed
     */
    this.doesNotMeetRequirementsText = "Password must meet the following requirements:";
    /**
     * @uiName Minimum length text
     */
    this.minErrorText = "be a minimum of 8 characters";
    /**
     * @uiName Missing uppercase text
     */
    this.uppercaseErrorText = "contain at least 1 uppercase character";
    /**
     * @uiName Missing lowercase text
     */
    this.lowercaseErrorText = "contain at least 1 lowercase character";
    /**
     * @uiName Passwords don’t match error message
     */
    this.nonMatchingPasswordErrorText = "contain at least 1 lowercase character";
    /**
     * @uiName Invalid user session error message
     */
    this.invalidSessionErrorText = "Please log in again to change your password.";
    /**
     * @uiName Missing number or symbol text
     */
    this.hasErrorText = "contain at least 1 number or symbol";
    withHooks(this);
  }
  disconnectedCallback() { }
  render() {
    const { states, callbacks } = isDemo()
      ? usePortalChangePasswordDemo(this)
      : usePortalChangePassword(this);
    return h(PortalChangePasswordView, { states: states, callbacks: callbacks });
  }
  static get is() { return "sqm-portal-change-password"; }
  static get encapsulation() { return "shadow"; }
  static get properties() { return {
    "modalChangePasswordHeader": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Change password modal header",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "modal-change-password-header",
      "reflect": false,
      "defaultValue": "\"Change Password\""
    },
    "cancelText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Cancel button text",
            "name": "uiName"
          }],
        "text": "Found in modal"
      },
      "attribute": "cancel-text",
      "reflect": false,
      "defaultValue": "\"Cancel\""
    },
    "changePasswordButtonText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Change password button text",
            "name": "uiName"
          }],
        "text": "Found in modal"
      },
      "attribute": "change-password-button-text",
      "reflect": false,
      "defaultValue": "\"Change Password\""
    },
    "passwordFieldLabel": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "New password field label",
            "name": "uiName"
          }],
        "text": "Found in modal"
      },
      "attribute": "password-field-label",
      "reflect": false,
      "defaultValue": "\"New Password\""
    },
    "confirmPasswordFieldLabel": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Confirm password Label",
            "name": "uiName"
          }],
        "text": "Found in modal"
      },
      "attribute": "confirm-password-field-label",
      "reflect": false,
      "defaultValue": "\"Confirm New Password\""
    },
    "successMessage": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Successful password change message",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": "Successful password change message"
      },
      "attribute": "success-message",
      "reflect": false,
      "defaultValue": "\"Your password has been updated.\""
    },
    "portalChangePasswordHeader": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Change password header",
            "name": "uiName"
          }],
        "text": "Portal change password section header"
      },
      "attribute": "portal-change-password-header",
      "reflect": false,
      "defaultValue": "\"Password\""
    },
    "portalChangePasswordButtonText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Change password button text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "portal-change-password-button-text",
      "reflect": false,
      "defaultValue": "\"Change your password...\""
    },
    "meetsRequirementsText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Password requirement met",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "meets-requirements-text",
      "reflect": false,
      "defaultValue": "\"Password has met all requirements\""
    },
    "doesNotMeetRequirementsText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Password requirement failed",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "does-not-meet-requirements-text",
      "reflect": false,
      "defaultValue": "\"Password must meet the following requirements:\""
    },
    "minErrorText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Minimum length text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "min-error-text",
      "reflect": false,
      "defaultValue": "\"be a minimum of 8 characters\""
    },
    "uppercaseErrorText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Missing uppercase text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "uppercase-error-text",
      "reflect": false,
      "defaultValue": "\"contain at least 1 uppercase character\""
    },
    "lowercaseErrorText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Missing lowercase text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "lowercase-error-text",
      "reflect": false,
      "defaultValue": "\"contain at least 1 lowercase character\""
    },
    "nonMatchingPasswordErrorText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Passwords don\u2019t match error message",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "non-matching-password-error-text",
      "reflect": false,
      "defaultValue": "\"contain at least 1 lowercase character\""
    },
    "invalidSessionErrorText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Invalid user session error message",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "invalid-session-error-text",
      "reflect": false,
      "defaultValue": "\"Please log in again to change your password.\""
    },
    "hasErrorText": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Missing number or symbol text",
            "name": "uiName"
          }],
        "text": ""
      },
      "attribute": "has-error-text",
      "reflect": false,
      "defaultValue": "\"contain at least 1 number or symbol\""
    },
    "demoData": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "DemoData<PortalChangePasswordViewProps>",
        "resolved": "{ states?: { open: boolean; error: string; loading: boolean; success: boolean; content: { modalChangePasswordHeader: string; cancelText: string; changePasswordButtonText: string; passwordFieldLabel: string; confirmPasswordFieldLabel: string; successMessage: string; portalChangePasswordHeader: string; portalChangePasswordButtonText: string; meetsRequirementsText?: string; doesNotMeetRequirementsText?: string; minErrorText?: string; uppercaseErrorText?: string; lowercaseErrorText?: string; hasErrorText?: string; }; }; borderRadius?: string; background?: string; }",
        "references": {
          "DemoData": {
            "location": "import",
            "path": "../../global/demo"
          },
          "PortalChangePasswordViewProps": {
            "location": "import",
            "path": "./sqm-portal-change-password-view"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": undefined,
            "name": "undocumented"
          }, {
            "text": "object",
            "name": "uiType"
          }],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "ignored": {}
  }; }
}
function usePortalChangePasswordDemo(props) {
  const [open, setOpen] = useState(false);
  return deepmerge({
    states: {
      open,
      error: "",
      content: {
        modalChangePasswordHeader: props.modalChangePasswordHeader,
        cancelText: props.cancelText,
        changePasswordButtonText: props.changePasswordButtonText,
        passwordFieldLabel: props.passwordFieldLabel,
        confirmPasswordFieldLabel: props.confirmPasswordFieldLabel,
        successMessage: props.successMessage,
        portalChangePasswordHeader: props.portalChangePasswordHeader,
        portalChangePasswordButtonText: props.portalChangePasswordButtonText,
        meetsRequirementsText: props.meetsRequirementsText,
        doesNotMeetRequirementsText: props.doesNotMeetRequirementsText,
        minErrorText: props.minErrorText,
        uppercaseErrorText: props.uppercaseErrorText,
        lowercaseErrorText: props.lowercaseErrorText,
        hasErrorText: props.hasErrorText,
      },
    },
    callbacks: {
      setOpen: (update) => setOpen(update),
      submit: (e) => console.log("Submit", e),
    },
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
}
