import { r as registerInstance, h as h$1 } from './index-38ad4957.js';
import './global-96c14d63.js';
import { i as d, n as h } from './dom-context-hooks.module-50442785.js';
import { i as isDemo } from './index.module-b23fdad8.js';
import { c as cjs } from './cjs-bdfb4486.js';
import { a as getMissingProps, g as getProps } from './utils-334c1e34.js';
import './JSS-67b5cff8.js';
import { L as LEAD_FORM_STATE_CONTEXT, R as RequiredPropsError } from './useLeadFormState-dd4e8b08.js';
import { L as LeadCheckboxFieldView } from './sqm-lead-checkbox-field-view-7928db07.js';

function useLeadCheckboxField() {
  const leadFormState = d(LEAD_FORM_STATE_CONTEXT);
  return {
    states: {
      leadFormState,
    },
  };
}

const LeadCheckboxField = class {
  constructor(hostRef) {
    registerInstance(this, hostRef);
    this.ignored = true;
    /**
     * @uiName Checkbox label
     * @uiWidget textArea
     */
    this.checkboxLabel = "By signing up you agree to the {labelLink}";
    /**
     * Used with link text if the checkbox label contains {labelLink}
     *
     * @uiName Checkbox label link
     */
    this.checkboxLabelLink = "https://example.com";
    /**
     * @uiName Checkbox label link lext
     */
    this.checkboxLabelLinkText = "Terms and Conditions";
    /**
     * @uiName Unchecked error message
     */
    this.errorMessage = "Must be checked";
    /**
     * @uiName Optional
     */
    this.checkboxOptional = false;
    h(this);
  }
  disconnectedCallback() { }
  render() {
    const missingProps = getMissingProps([
      {
        attribute: "checkbox-name",
        value: this.checkboxName,
      },
    ]);
    if (!isDemo() && missingProps) {
      return (h$1(RequiredPropsError, { missingProps: missingProps, heading: "An error occured while loading this form", subheading: "A technical problem prevented this checkbox field from loading. Please contact us with the link to this page.", description: "Values for the following attributes are missing:" }));
    }
    const content = {
      ...getProps(this),
    };
    const { states } = isDemo()
      ? useLeadCheckboxFieldDemo(this)
      : useLeadCheckboxField();
    return (h$1(LeadCheckboxFieldView, { states: states, content: content }));
  }
};
function useLeadCheckboxFieldDemo(props) {
  return cjs({
    states: {
      leadFormState: {},
    },
  }, props.demoData || {}, { arrayMerge: (_, a) => a });
}

export { LeadCheckboxField as sqm_lead_checkbox_field };
