import { doesUserOwnApplicationForm, getAnswersState, getApplicationFormState, getCurrentActiveQuestionSet, getEligibilityResults, getFormId, getPartnerEngineConfig, getQuestionPoolState, getQuestionSetState, pushAnswer, removeActiveAnswerId, saveQuestionSet, selectIsActiveQuestionSetPendingProcess, selectQuestionSetsState, switchActiveQuestionSet, updateErrors, userHasPermission, selectAddressGroupIdsThatNeedValidation, setAddressValidationStatus, selectAddressValidationStatuses, selectAddressValidationTriggerWasOverridden, setAddressValidationTriggerOverridden, selectIsActiveQuestionSetBeingValidated, } from "@boldpenguin/sdk-redux";
import { AnalyticsTrackingEventName, BpSdkPermissionAction, BpSdkPermissions, LoadingStates, ValidationStatus, } from "@boldpenguin/sdk-types";
import { areAnswersValid, calculateParentAnchorValue, containsOnlyQuestionPoolAnchorQuestions, focusErrors, getErrors, getParentAnchorAnswer, isValidAnswer, updateAnswerValue, } from "@boldpenguin/sdk-utility";
import { h } from "@stencil/core";
import store from "../../services/redux-store.service";
export class BpSdkNextButtonContainer {
    constructor() {
        this.handleSubscriptions = () => {
            if (this.storeUnsubscribe) {
                this.storeUnsubscribe();
            }
            store.mapDispatchToProps(this, {
                saveQuestionSet,
                updateErrors,
                removeActiveAnswerId,
                switchActiveQuestionSet,
                pushAnswer,
                getEligibilityResults,
                setAddressValidationStatus,
                setAddressValidationTriggerOverridden,
            });
            this.storeUnsubscribe = store.mapStateToProps(this, this.mapStateToProps);
        };
        this.mapStateToProps = (state) => ({
            activeQuestionSet: getCurrentActiveQuestionSet(state),
            applicationId: getFormId(state),
            config: getPartnerEngineConfig(state),
            answersResourceState: getAnswersState(state),
            applicationFormResourceState: getApplicationFormState(state),
            pendingProcesses: state.application.pendingProcesses,
            questionPoolResourceState: getQuestionPoolState(state),
            questionSetResourceState: getQuestionSetState(state),
            questionSetState: selectQuestionSetsState(state),
            queue: state.queues.answers.queue,
            enableUserApplicationGuard: !!state.config.options.enableUserApplicationGuard,
            locked: state.application.form.locked,
            isActiveQuestionSetPendingProcess: selectIsActiveQuestionSetPendingProcess(state),
            isOwner: doesUserOwnApplicationForm(state),
            hasPermissionToEdit: userHasPermission(state, {
                permission: BpSdkPermissions.ApplicationForms,
                action: BpSdkPermissionAction.Update,
            }),
            addressValidationStatuses: selectAddressValidationStatuses(state),
            addressIdsToBeValidated: selectAddressGroupIdsThatNeedValidation(state),
            isValidationTriggerOverridden: selectAddressValidationTriggerWasOverridden(state),
            isActiveQuestionSetBeingValidated: selectIsActiveQuestionSetBeingValidated(state, this.activeQuestionSet),
        });
        this.activeQuestionSet = undefined;
        this.buttonDisabled = false;
        this.config = undefined;
        this.queue = undefined;
        this.shouldDisableIfIncomplete = false;
        this.answersResourceState = undefined;
        this.applicationFormResourceState = undefined;
        this.questionPoolResourceState = undefined;
        this.questionSetResourceState = undefined;
        this.questionSetState = undefined;
        this.locked = undefined;
        this.pendingProcesses = undefined;
        this.isOwner = undefined;
        this.hasPermissionToEdit = undefined;
        this.isActiveQuestionSetPendingProcess = undefined;
        this.enableUserApplicationGuard = undefined;
        this.applicationId = undefined;
        this.addressValidationStatuses = undefined;
        this.addressIdsToBeValidated = undefined;
        this.isValidationTriggerOverridden = undefined;
        this.useExternal = false;
        this.canSave = true;
        this.areResourcesReady = true;
        this.isDisabled = false;
        this.caDisabled = false;
        this.isReady = true;
        this.isLocked = false;
        this.isFirstRun = true;
        this.classes = '';
        this.isActiveQuestionSetBeingValidated = undefined;
    }
    resetState() {
        this.isReady = true;
        this.isFirstRun = true;
    }
    connectedCallback() {
        this.resetState();
        this.handleSubscriptions();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-next-button-container');
        customElements.whenDefined('bp-sdk-external-next-button-container').then(() => {
            this.useExternal = true;
        });
        this.handleSubscriptions();
        this.onShouldDisableIfIncompleteChange(this.shouldDisableIfIncomplete);
        this.onAnswersResourcesStateChange(this.answersResourceState);
        this.onApplicationFormResourceStateChange(this.applicationFormResourceState);
        this.onHasPermissionToEdit(this.hasPermissionToEdit);
        this.onEnableUserApplicationGuard(this.enableUserApplicationGuard);
        this.onIsFirstRun(this.isFirstRun);
        this.onIsOwner(this.isOwner);
        this.onIsReady(this.isReady);
        this.onLocked(this.locked);
        this.onQuestionPoolResourcesStateChange(this.questionPoolResourceState);
        this.onQuestionSetResourcesStateChange(this.questionSetResourceState);
        this.onQueueChange(this.queue);
        this.onIsActiveQuestionSetPendingProcess(this.isActiveQuestionSetPendingProcess);
        this.onAddressValidationStatusChange(this.addressValidationStatuses);
    }
    onEnableUserApplicationGuard(enableUserApplicationGuard) {
        this.updateIsLocked(this.locked, this.isOwner, this.hasPermissionToEdit, enableUserApplicationGuard);
    }
    onHasPermissionToEdit(hasPermission) {
        this.updateIsLocked(this.locked, this.isOwner, hasPermission, this.enableUserApplicationGuard);
    }
    onIsOwner(isOwner) {
        this.updateIsLocked(this.locked, isOwner, this.hasPermissionToEdit, this.enableUserApplicationGuard);
    }
    onLocked(locked) {
        this.updateIsLocked(locked, this.isOwner, this.hasPermissionToEdit, this.enableUserApplicationGuard);
    }
    updateIsLocked(locked, isOwner, hasPermission, enableUserApplicationGuard) {
        this.isLocked = locked || (enableUserApplicationGuard && (!isOwner || !hasPermission));
    }
    onIsFirstRun(isFirstRun) {
        this.updateAreResourcesReady(isFirstRun, this.isReady);
    }
    onIsReady(isReady) {
        this.updateAreResourcesReady(this.isFirstRun, isReady);
    }
    updateAreResourcesReady(isFirstRun, isReady) {
        this.areResourcesReady = isFirstRun || isReady;
    }
    onAnswersResourcesStateChange(state) {
        this.isReady = this.calculateResourcesReady({
            answers: state,
            applicationForm: this.applicationFormResourceState,
            questionPools: this.questionPoolResourceState,
            questionSets: this.questionSetResourceState,
        });
    }
    onApplicationFormResourceStateChange(state) {
        if (this.isFirstRun && state === LoadingStates.Loaded) {
            this.isFirstRun = false;
        }
        this.isReady = this.calculateResourcesReady({
            answers: this.answersResourceState,
            applicationForm: state,
            questionPools: this.questionPoolResourceState,
            questionSets: this.questionSetResourceState,
        });
    }
    onQuestionPoolResourcesStateChange(state) {
        this.isReady = this.calculateResourcesReady({
            answers: this.answersResourceState,
            applicationForm: this.applicationFormResourceState,
            questionPools: state,
            questionSets: this.questionSetResourceState,
        });
    }
    onQuestionSetResourcesStateChange(state) {
        this.isReady = this.calculateResourcesReady({
            answers: this.answersResourceState,
            applicationForm: this.applicationFormResourceState,
            questionPools: this.questionPoolResourceState,
            questionSets: state,
        });
    }
    calculateResourcesReady(resources = {}) {
        if (!resources ||
            resources.applicationForm !== LoadingStates.Loaded ||
            resources.answers === LoadingStates.Loading ||
            resources.questionPools === LoadingStates.Loading ||
            resources.questionSets === LoadingStates.Loading) {
            return false;
        }
        return true;
    }
    onShouldDisableIfIncompleteChange(shouldDisableIfIncomplete) {
        this.updateOnDisableIfIncomplete(shouldDisableIfIncomplete, this.activeQuestionSet);
    }
    onActiveQuestionSetChange(activeQuestionSet) {
        this.updateOnDisableIfIncomplete(this.shouldDisableIfIncomplete, activeQuestionSet);
        this.disableIfCAQuestionSet(this.shouldDisableIfIncomplete, activeQuestionSet);
    }
    onQueueChange(queue) {
        this.canSave = !(queue === null || queue === void 0 ? void 0 : queue.length) && !this.isActiveQuestionSetPendingProcess;
    }
    onAddressValidationStatusChange(statuses) {
        if (statuses &&
            this.activeQuestionSet &&
            Object.values(statuses).some((status) => status === ValidationStatus.PROCEED_NEXT || status === ValidationStatus.VALIDATION_ERROR) &&
            !this.isValidationTriggerOverridden) {
            const filteredIds = Object.keys(statuses).filter((id) => this.activeQuestionSet.answers.map((answer) => answer.answer_pool_id).includes(id) ||
                this.activeQuestionSet.question_set.question_groups.map((group) => group.id).includes(id));
            if (filteredIds.every((id) => statuses[id] === ValidationStatus.PROCEED_NEXT ||
                statuses[id] === ValidationStatus.COMPLETED ||
                statuses[id] === ValidationStatus.VALIDATION_ERROR)) {
                this.saveQuestionSetAndProceed();
                filteredIds
                    .filter((id) => statuses[id] === ValidationStatus.PROCEED_NEXT)
                    .forEach((addressValidationId) => this.setAddressValidationStatus({ validationStatus: ValidationStatus.COMPLETED, addressValidationId }));
                filteredIds
                    .filter((id) => statuses[id] === ValidationStatus.VALIDATION_ERROR)
                    .forEach((addressValidationId) => this.setAddressValidationStatus({ validationStatus: ValidationStatus.REQUIRED, addressValidationId }));
            }
        }
    }
    onIsActiveQuestionSetPendingProcess(isQSPending) {
        this.canSave = !isQSPending;
    }
    disableIfCAQuestionSet(shouldDisableIfIncomplete, activeQuestionSet) {
        let shouldDisable = false;
        if (shouldDisableIfIncomplete && activeQuestionSet) {
            shouldDisable = containsOnlyQuestionPoolAnchorQuestions(activeQuestionSet);
        }
        if (this.caDisabled !== shouldDisable) {
            this.caDisabled = shouldDisable;
        }
    }
    updateOnDisableIfIncomplete(shouldDisableIfIncomplete, activeQuestionSet) {
        this.isDisabled = shouldDisableIfIncomplete && this.isDisabledStatusByActiveQuestionSet(activeQuestionSet);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (h("bp-sdk-external-next-button-container", { activeQuestionSet: this.activeQuestionSet, answersResourceState: this.answersResourceState, applicationFormResourceState: this.applicationFormResourceState, applicationId: this.applicationId, buttonDisabled: this.buttonDisabled, config: this.config, enableUserApplicationGuard: this.enableUserApplicationGuard, hasPermissionToEdit: this.hasPermissionToEdit, isOwner: this.isOwner, locked: this.locked, pendingProcesses: this.pendingProcesses, questionPoolResourceState: this.questionPoolResourceState, questionSetResourceState: this.questionSetResourceState, questionSetState: this.questionSetState, queue: this.queue, shouldDisableIfIncomplete: this.shouldDisableIfIncomplete, isActiveQuestionSetPendingProcess: this.isActiveQuestionSetPendingProcess }));
    }
    handleNavigateNext() {
        if (this.isAddressValidationRequired()) {
            this.handleValidation();
        }
        else {
            this.saveQuestionSetAndProceed();
        }
    }
    renderInternal() {
        return (h("bp-sdk-next-button", { buttonDisabled: !this.isNextButtonClickable() || this.isActiveQuestionSetBeingValidated, cssClasses: !this.areResourcesReady || !this.canSave ? 'loading' : 'not-loading' }));
    }
    parentQuestionSetCanSave() {
        const parentQuestionSet = this.questionSetState.parentQuestionSets.find((pqs) => pqs.id === this.activeQuestionSet.parentQuestionSetId);
        if (parentQuestionSet) {
            return this.questionSetState.list
                .filter((qs) => qs.parentQuestionSetId === parentQuestionSet.id)
                .every((qs) => areAnswersValid(qs.answers));
        }
    }
    saveQuestionSetAndProceed() {
        if (this.shouldCallSaveQuestionSet()) {
            const invalidAnswers = this.activeQuestionSet.answers.filter((answer) => !isValidAnswer(answer));
            if (!invalidAnswers.length && this.isNextButtonClickable()) {
                this.removeActiveAnswerId();
                if (!this.activeQuestionSet.parentQuestionSetId) {
                    this.callSaveQuestionSet();
                }
                else {
                    if (this.parentQuestionSetCanSave()) {
                        this.callSaveQuestionSet(true);
                    }
                    else {
                        this.handleStep();
                    }
                }
            }
            else {
                invalidAnswers.forEach((answer) => {
                    this.updateErrors({ answer, errors: getErrors(answer) });
                });
                focusErrors();
            }
        }
        else if (this.isNextButtonClickable()) {
            this.switchActiveQuestionSet('forward');
        }
    }
    callSaveQuestionSet(useParent = false) {
        this.saveQuestionSet({
            config: this.config,
            appFormQuestionSet: this.activeQuestionSet,
            navigationDirection: 'forward',
            parentQuestionSet: useParent
                ? this.questionSetState.parentQuestionSets.find((pqs) => pqs.id === this.activeQuestionSet.parentQuestionSetId)
                : undefined,
        });
        this.bpAnalyticsTrack.emit({
            eventName: AnalyticsTrackingEventName.QuestionSetSaved,
            eventPayload: {
                applicationFormQuestionSetId: this.activeQuestionSet.id,
                questionSetId: this.activeQuestionSet.question_set_id,
                questionSetCode: this.activeQuestionSet.question_set.code,
            },
        });
    }
    handleStep() {
        const parent = getParentAnchorAnswer(this.activeQuestionSet, this.questionSetState);
        const newValue = calculateParentAnchorValue(this.activeQuestionSet);
        if (parent.value !== newValue) {
            this.pushAnswer(updateAnswerValue(parent, newValue));
        }
        this.getEligibilityResults({ appId: this.applicationId, config: this.config });
        this.switchActiveQuestionSet('forward');
    }
    isDisabledStatusByActiveQuestionSet(activeQuestionSet) {
        var _a;
        // If missing active question set then default to disable.
        if (!activeQuestionSet) {
            return true;
        }
        // If missing answers then default to enabled
        if (!activeQuestionSet.answers || ((_a = activeQuestionSet.answers) === null || _a === void 0 ? void 0 : _a.length) === 0) {
            return false;
        }
        // Else state determined by if all required answers are completed
        return activeQuestionSet.answers.some((answer) => !answer.is_completed && answer.required);
    }
    shouldCallSaveQuestionSet() {
        if (this.isLocked) {
            return false;
        }
        return !this.activeQuestionSet.is_completed || !!this.activeQuestionSet.parentQuestionSetId;
    }
    isNextButtonClickable() {
        return !this.buttonDisabled && this.areResourcesReady && this.canSave && !this.isDisabled && !this.caDisabled;
    }
    isAddressValidationRequired() {
        return Object.keys(this.addressValidationStatuses).some((id) => this.activeQuestionSet.answers.map((answer) => answer.answer_pool_id).includes(id) ||
            this.activeQuestionSet.question_set.question_groups.map((group) => group.id).includes(id));
    }
    handleValidation() {
        if (this.isValidationTriggerOverridden) {
            this.setAddressValidationTriggerOverridden(false);
        }
        const presentRequiredIds = this.addressIdsToBeValidated.filter((id) => this.activeQuestionSet.answers.map((answer) => answer.answer_pool_id).includes(id) ||
            this.activeQuestionSet.question_set.question_groups.map((group) => group.id).includes(id));
        if (!!presentRequiredIds.length) {
            presentRequiredIds.forEach((addressValidationId) => {
                this.setAddressValidationStatus({ validationStatus: ValidationStatus.READY_TO_VALIDATE, addressValidationId });
            });
        }
        else {
            const filteredIds = Object.keys(this.addressValidationStatuses).filter((id) => this.activeQuestionSet.answers.map((answer) => answer.answer_pool_id).includes(id) ||
                this.activeQuestionSet.question_set.question_groups.map((group) => group.id).includes(id));
            if (filteredIds.every((id) => this.addressValidationStatuses[id] === ValidationStatus.COMPLETED ||
                this.addressValidationStatuses[id] === ValidationStatus.VALIDATION_ERROR)) {
                this.saveQuestionSetAndProceed();
            }
        }
    }
    static get is() { return "bp-sdk-next-button-container"; }
    static get originalStyleUrls() {
        return {
            "$": ["./bp-sdk-next-button-container.css"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["bp-sdk-next-button-container.css"]
        };
    }
    static get properties() {
        return {
            "activeQuestionSet": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "IApplicationFormQuestionSet",
                    "resolved": "IApplicationFormQuestionSet",
                    "references": {
                        "IApplicationFormQuestionSet": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IApplicationFormQuestionSet"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                }
            },
            "buttonDisabled": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Controls disabled state of button"
                },
                "attribute": "button-disabled",
                "reflect": false,
                "defaultValue": "false"
            },
            "config": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "IPartnerEngineConfig",
                    "resolved": "IPartnerEngineConfig",
                    "references": {
                        "IPartnerEngineConfig": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IPartnerEngineConfig"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "IPartnerEngineConfig injected from redux"
                }
            },
            "queue": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "IAnswer[]",
                    "resolved": "IAnswer[]",
                    "references": {
                        "IAnswer": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IAnswer"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Answer queue"
                }
            },
            "shouldDisableIfIncomplete": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Disable navigation if active question set is incomplete"
                },
                "attribute": "should-disable-if-incomplete",
                "reflect": false,
                "defaultValue": "false"
            },
            "answersResourceState": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "LoadingStates",
                    "resolved": "LoadingStates.Error | LoadingStates.Loaded | LoadingStates.Loading | LoadingStates.NotLoaded",
                    "references": {
                        "LoadingStates": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::LoadingStates"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Answer resource states injected from redux"
                },
                "attribute": "answers-resource-state",
                "reflect": false
            },
            "applicationFormResourceState": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "LoadingStates",
                    "resolved": "LoadingStates.Error | LoadingStates.Loaded | LoadingStates.Loading | LoadingStates.NotLoaded",
                    "references": {
                        "LoadingStates": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::LoadingStates"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Application form resource states injected from redux"
                },
                "attribute": "application-form-resource-state",
                "reflect": false
            },
            "questionPoolResourceState": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "LoadingStates",
                    "resolved": "LoadingStates.Error | LoadingStates.Loaded | LoadingStates.Loading | LoadingStates.NotLoaded",
                    "references": {
                        "LoadingStates": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::LoadingStates"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Question pool resource states injected from redux"
                },
                "attribute": "question-pool-resource-state",
                "reflect": false
            },
            "questionSetResourceState": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "LoadingStates",
                    "resolved": "LoadingStates.Error | LoadingStates.Loaded | LoadingStates.Loading | LoadingStates.NotLoaded",
                    "references": {
                        "LoadingStates": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::LoadingStates"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Question set resource states injected from redux"
                },
                "attribute": "question-set-resource-state",
                "reflect": false
            },
            "questionSetState": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "IQuestionSetState",
                    "resolved": "IQuestionSetState",
                    "references": {
                        "IQuestionSetState": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IQuestionSetState"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Question Set State from Store"
                }
            },
            "locked": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Application form state injected from redux"
                },
                "attribute": "locked",
                "reflect": false
            },
            "pendingProcesses": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "IApplicationFormProcesses[]",
                    "resolved": "IApplicationFormProcesses[]",
                    "references": {
                        "IApplicationFormProcesses": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IApplicationFormProcesses"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Pending processes of application form state injected from redux"
                }
            },
            "isOwner": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is owner of application"
                },
                "attribute": "is-owner",
                "reflect": false
            },
            "hasPermissionToEdit": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Has permission to edit application"
                },
                "attribute": "has-permission-to-edit",
                "reflect": false
            },
            "isActiveQuestionSetPendingProcess": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Does the active question have a pending process"
                },
                "attribute": "is-active-question-set-pending-process",
                "reflect": false
            },
            "enableUserApplicationGuard": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Enabled user check for application"
                },
                "attribute": "enable-user-application-guard",
                "reflect": false
            },
            "applicationId": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Current application form id"
                },
                "attribute": "application-id",
                "reflect": false
            },
            "addressValidationStatuses": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "{ [key: string]: ValidationStatus }",
                    "resolved": "{ [key: string]: ValidationStatus; }",
                    "references": {
                        "ValidationStatus": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::ValidationStatus"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "A list of address validation statuses"
                }
            },
            "addressIdsToBeValidated": {
                "type": "unknown",
                "mutable": true,
                "complexType": {
                    "original": "AddressValidationId[]",
                    "resolved": "string[]",
                    "references": {
                        "AddressValidationId": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::AddressValidationId"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "A list of address group IDs that are pending validation"
                }
            },
            "isValidationTriggerOverridden": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean | null",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Is true when validation has been triggered elsewhere"
                },
                "attribute": "is-validation-trigger-overridden",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "useExternal": {},
            "canSave": {},
            "areResourcesReady": {},
            "isDisabled": {},
            "caDisabled": {},
            "isReady": {},
            "isLocked": {},
            "isFirstRun": {},
            "classes": {},
            "isActiveQuestionSetBeingValidated": {}
        };
    }
    static get events() {
        return [{
                "method": "bpAnalyticsTrack",
                "name": "bpAnalyticsTrack",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Emits an analytics tracking event, see `AnalyticsTrackingEventName` (sdk-types) for event names"
                },
                "complexType": {
                    "original": "IAnalyticsTrackEventDetail",
                    "resolved": "IAnalyticsTrackEventDetail",
                    "references": {
                        "IAnalyticsTrackEventDetail": {
                            "location": "import",
                            "path": "@boldpenguin/sdk-types",
                            "id": "../sdk-types/dist/types.d.ts::IAnalyticsTrackEventDetail"
                        }
                    }
                }
            }];
    }
    static get watchers() {
        return [{
                "propName": "enableUserApplicationGuard",
                "methodName": "onEnableUserApplicationGuard"
            }, {
                "propName": "hasPermissionToEdit",
                "methodName": "onHasPermissionToEdit"
            }, {
                "propName": "isOwner",
                "methodName": "onIsOwner"
            }, {
                "propName": "locked",
                "methodName": "onLocked"
            }, {
                "propName": "isFirstRun",
                "methodName": "onIsFirstRun"
            }, {
                "propName": "isReady",
                "methodName": "onIsReady"
            }, {
                "propName": "answersResourceState",
                "methodName": "onAnswersResourcesStateChange"
            }, {
                "propName": "applicationFormResourceState",
                "methodName": "onApplicationFormResourceStateChange"
            }, {
                "propName": "questionPoolResourceState",
                "methodName": "onQuestionPoolResourcesStateChange"
            }, {
                "propName": "questionSetResourceState",
                "methodName": "onQuestionSetResourcesStateChange"
            }, {
                "propName": "shouldDisableIfIncomplete",
                "methodName": "onShouldDisableIfIncompleteChange"
            }, {
                "propName": "activeQuestionSet",
                "methodName": "onActiveQuestionSetChange"
            }, {
                "propName": "queue",
                "methodName": "onQueueChange"
            }, {
                "propName": "addressValidationStatuses",
                "methodName": "onAddressValidationStatusChange"
            }, {
                "propName": "isActiveQuestionSetPendingProcess",
                "methodName": "onIsActiveQuestionSetPendingProcess"
            }];
    }
    static get listeners() {
        return [{
                "name": "navigateNext",
                "method": "handleNavigateNext",
                "target": undefined,
                "capture": false,
                "passive": false
            }];
    }
}
