import { useHost } from "@saasquatch/component-boilerplate";
import { useDomContextState } from "@saasquatch/dom-context-hooks";
import { useDomContext } from "@saasquatch/stencil-hooks";
export const REGISTRATION_FORM_STATE_CONTEXT = "sq:registration-form-state";
const REGISTRATION_FORM_STATE_CONTEXT_INTERNAL = "sq:registration-form-state-internal";
export function useRegistrationForm() {
  const parent = useDomContext(REGISTRATION_FORM_STATE_CONTEXT_INTERNAL);
  const parentValue = useDomContext(REGISTRATION_FORM_STATE_CONTEXT);
  if (!parent)
    return [undefined, undefined];
  return [parentValue, parent[1]];
}
export function useRegistrationFormState(formState) {
  const host = useHost();
  const [registrationFormState, setRegistrationFormState] = useDomContextState(host, REGISTRATION_FORM_STATE_CONTEXT, formState);
  useDomContextState(host, REGISTRATION_FORM_STATE_CONTEXT_INTERNAL, [
    registrationFormState,
    setRegistrationFormState,
  ]);
  return { registrationFormState, setRegistrationFormState };
}
