constructor(elementOrOptions, options = undefined) {
        let element, formOptions;
        if (elementOrOptions instanceof HTMLElement || options) {
            element = elementOrOptions;
            formOptions = options || {};
        } else {
            formOptions = elementOrOptions || {};
        }
        super(null, getOptions(formOptions));

        this.setElement(element);

        // Keep track of all available forms globally.
        Formio.forms[this.id] = this;

        // Set the base url.
        if (this.options.baseUrl) {
            Formio.setBaseUrl(this.options.baseUrl);
        }

        /**
         * The type of this element.
         * @type {string}
         */
        this.type = 'form';
        this._src = '';
        this._loading = false;
        this._form = {};
        this.draftEnabled = false;
        this.savingDraft = false;
        if (this.options.saveDraftThrottle) {
            this.triggerSaveDraft = _.throttle(
                this.saveDraft.bind(this),
                this.options.saveDraftThrottle
            );
        } else {
            this.triggerSaveDraft = this.saveDraft.bind(this);
        }

        /**
         * Determines if this form should submit the API on submit.
         * @type {boolean}
         */
        this.nosubmit = false;

        /**
         * Determines if the form has tried to be submitted, error or not.
         * @type {boolean}
         */
        this.submitted = false;

        /**
         * Determines if the form is being submitted at the moment.
         * @type {boolean}
         */
        this.submitting = false;

        /**
         * The Formio instance for this form.
         * @type {Formio}
         */
        this.formio = null;

        /**
         * The loader HTML element.
         * @type {HTMLElement}
         */
        this.loader = null;

        /**
         * The alert HTML element
         * @type {HTMLElement}
         */
        this.alert = null;

        /**
         * Promise that is triggered when the submission is done loading.
         * @type {Promise}
         */
        this.onSubmission = null;

        /**
         * Determines if this submission is explicitly set.
         * @type {boolean}
         */
        this.submissionSet = false;

        /**
         * Promise that executes when the form is ready and rendered.
         * @type {Promise}
         * @example
         * import Webform from '@formio/js/Webform';
         * let form = new Webform(document.getElementById('formio'));
         * form.formReady.then(() => {
         *   console.log('The form is ready!');
         * });
         * form.src = 'https://examples.form.io/example';
         */
        this.formReady = new Promise((resolve, reject) => {
            /**
             * Called when the formReady state of this form has been resolved.
             * @type {Function}
             */
            this.formReadyResolve = resolve;

            /**
             * Called when this form could not load and is rejected.
             * @type {Function}
             */
            this.formReadyReject = reject;
        });

        /**
         * Promise that executes when the submission is ready and rendered.
         * @type {Promise}
         * @example
         * import Webform from '@formio/js/Webform';
         * let form = new Webform(document.getElementById('formio'));
         * form.submissionReady.then(() => {
         *   console.log('The submission is ready!');
         * });
         * form.src = 'https://examples.form.io/example/submission/234234234234234243';
         */
        this.submissionReady = new Promise((resolve, reject) => {
            /**
             * Called when the formReady state of this form has been resolved.
             * @type {Function}
             */
            this.submissionReadyResolve = resolve;

            /**
             * Called when this form could not load and is rejected.
             * @type {Function}
             */
            this.submissionReadyReject = reject;
        });

        this.shortcuts = [];

        // Set language after everything is established.
        this.language = this.i18next.language;

        // See if we need to restore the draft from a user.
        if (this.options.saveDraft) {
            if (this.options.skipDraftRestore) {
                this.draftEnabled = true;
                this.savingDraft = false;
            }
            else {
                this.formReady.then(() => {
                    const user = Formio.getUser();
                    // Only restore a draft if the submission isn't explicitly set.
                    if (user && !this.submissionSet) {
                        this.restoreDraft(user._id);
                    }
                });
            }
        }

        this.component.clearOnHide = false;

        // Ensure the root is set to this component.
        this.root = this;
        this.localRoot = this;
    }
Creates a new Form instance.
@param {HTMLElement | object | import('Form').FormOptions} [elementOrOptions] - The DOM element to render this form within or the options to create this form instance.
@param {import('Form').FormOptions} [options] - The options to create a new form instance.