import { isDemo } from "@saasquatch/component-boilerplate";
import { withHooks } from "@saasquatch/stencil-hooks";
import { Component, h, Prop, State } from "@stencil/core";
import deepmerge from "deepmerge";
import { getProps } from "../../utils/utils";
import { CheckboxFieldView, } from "../sqm-checkbox-field/sqm-checkbox-field-view";
import { useCheckboxField } from "../sqm-checkbox-field/useCheckboxField";
/**
 * @uiName Marketing Emails Checkbox Field
 * @validParents ["sqm-portal-register","sqm-portal-registration-form", "sqm-portal-google-registration-form"]
 * @requiredFeatures ["MARKETING_EMAILS"]
 */
export class MarketingEmailsCheckbox {
  constructor() {
    this.ignored = true;
    /**
     * @uiName Checkbox label
     * @uiWidget textArea
     */
    this.checkboxLabel = "I would like to receive marketing and promotional emails for this referral program";
    /**
     * @undocumented
     */
    this.checkboxName = "marketingEmailOptIn";
    withHooks(this);
  }
  disconnectedCallback() { }
  render() {
    const content = {
      ...getProps(this),
    };
    const { states, callbacks } = isDemo()
      ? useCheckboxFieldDemo(this)
      : useCheckboxField(this);
    return (h(CheckboxFieldView, { states: states, content: content, callbacks: callbacks }));
  }
  static get is() { return "sqm-marketing-emails-checkbox"; }
  static get properties() { return {
    "checkboxLabel": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": "Checkbox label",
            "name": "uiName"
          }, {
            "text": "textArea",
            "name": "uiWidget"
          }],
        "text": ""
      },
      "attribute": "checkbox-label",
      "reflect": false,
      "defaultValue": "\"I would like to receive marketing and promotional emails for this referral program\""
    },
    "checkboxName": {
      "type": "string",
      "mutable": false,
      "complexType": {
        "original": "string",
        "resolved": "string",
        "references": {}
      },
      "required": false,
      "optional": false,
      "docs": {
        "tags": [{
            "text": undefined,
            "name": "undocumented"
          }],
        "text": ""
      },
      "attribute": "checkbox-name",
      "reflect": false,
      "defaultValue": "\"marketingEmailOptIn\""
    },
    "demoData": {
      "type": "unknown",
      "mutable": false,
      "complexType": {
        "original": "DemoData<CheckboxFieldViewProps>",
        "resolved": "{ states?: { registrationFormState?: RegistrationFormState; checked: boolean; }; content?: { checkboxName: string; checkboxLabel: string; checkboxLabelLink?: string; checkboxLabelLinkText?: string; checkboxOptional?: boolean; errorMessage?: string; }; }",
        "references": {
          "DemoData": {
            "location": "import",
            "path": "../../global/demo"
          },
          "CheckboxFieldViewProps": {
            "location": "import",
            "path": "../sqm-checkbox-field/sqm-checkbox-field-view"
          }
        }
      },
      "required": false,
      "optional": true,
      "docs": {
        "tags": [{
            "text": undefined,
            "name": "undocumented"
          }, {
            "text": "object",
            "name": "uiType"
          }],
        "text": ""
      }
    }
  }; }
  static get states() { return {
    "ignored": {}
  }; }
}
function useCheckboxFieldDemo(props) {
  return deepmerge({
    states: {
      registrationFormState: {},
      checked: false,
    },
    callbacks: {
      setChecked: () => { },
    },
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
}
