'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

const index = require('./index-ceff47a0.js');
const debounce = require('./debounce-8072e2b4.js');
const index_esm_min = require('./index.esm.min-2e158fd8.js');
const index_esm_min$1 = require('./index.esm.min-f57d151c.js');
const reduxStore_service = require('./redux-store.service-10b7725a.js');
const index_esm_min$2 = require('./index.esm.min-1101deb1.js');
const isEqual = require('./isEqual-c7b6d94e.js');
const vehicleVin_service = require('./vehicle-vin.service-621890f4.js');
require('./_commonjsHelpers-b3309d7b.js');

const bpSdkAddItemContainerCss = "";
const BpSdkAddItemContainerStyle0 = bpSdkAddItemContainerCss;

const BpSdkAddItemContainer = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.addItem = index.createEvent(this, "addItem", 7);
        this.handleClick = () => {
            this.addItem.emit();
        };
        this.answerPoolId = undefined;
        this.helpText = '';
        this.text = '+';
        this.canAddMore = true;
        this.icon = undefined;
        this.questionId = undefined;
        this.questionSetId = undefined;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-add-item-container');
        customElements.whenDefined('bp-sdk-external-add-item-container').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return [
            index.h("slot", null),
            index.h("bp-sdk-external-add-item-container", { answerPoolId: this.answerPoolId, helpText: this.helpText, text: this.text, canAddMore: this.canAddMore, icon: this.icon, questionId: this.questionId, questionSetId: this.questionSetId }),
        ];
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-add-item__container" }, index.h("slot", null), this.canAddMore && (index.h("div", { class: "bp-sdk-add-item__wrapper" }, index.h("bp-sdk-icon-container", { name: this.icon }), this.helpText && index.h("h4", { class: "bp-sdk-add-item__help-text" }, this.helpText), index.h("bp-sdk-button", { onClick: this.handleClick, text: this.text })))));
    }
};
BpSdkAddItemContainer.style = BpSdkAddItemContainerStyle0;

const bpSdkAutocompleteInputCss = "bp-sdk-autocomplete-input .bp-sdk-autocomplete-container{position:relative;min-width:10rem;max-width:100vw}.bp-sdk-label-content{font-size:26px;color:rgba(100, 100, 100, 0.6)}.bp-sdk-no-selection{user-select:none}.bp-sdk-visually-hidden{display:none}.bp-sdk-align-right{margin-left:auto}.bp-sdk-autocomplete__button-arrow{font-size:20px}.bp-sdk-autocomplete__input{width:100%;height:2rem;padding:0.25rem;margin-bottom:0;display:flex;justify-items:center;align-items:flex-start}.bp-sdk-autocomplete__list{background:white;border:1px solid #aaa;left:0;margin:0;max-height:15rem;min-width:10rem;overflow-y:auto;padding-left:0;position:absolute;width:calc(100% - 2px);z-index:1}.bp-sdk-no-results{position:absolute;left:0;right:-2px;font-size:1rem;background:white;border:1px solid #aaa;color:#707070;padding-left:0.2rem}.bp-sdk-autocomplete__list-item{display:block;position:relative;font-size:16px;padding-left:1rem;padding-right:1rem;cursor:pointer}";
const BpSdkAutocompleteInputStyle0 = bpSdkAutocompleteInputCss;

const keyboardNavigation$1 = {
    next: ['ArrowDown'],
    previous: ['ArrowUp'],
    select: ['Enter'],
};
const BpSdkAutocompleteInput = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.valueUpdate = index.createEvent(this, "valueUpdate", 7);
        this.filterUpdate = index.createEvent(this, "filterUpdate", 7);
        this.removeActiveAnswer = index.createEvent(this, "removeActiveAnswer", 7);
        this.updateActiveAnswer = index.createEvent(this, "updateActiveAnswer", 7);
        this.hideChoices = () => {
            this._showChoices = false;
        };
        this.onFocus = () => {
            this.isFocused = true;
        };
        this.onBlur = () => {
            if (!this.disableDropdown) {
                this.el.querySelector('input').value = this.getText(this.choice);
            }
            this.isFocused = false;
        };
        this.debounceFilterChoices = debounce.debounce_1(this.filterChoices, 300);
        this.choiceSelected = (choice) => {
            var _a;
            this._showChoices = false;
            if (choice) {
                this.choice = choice;
                this.value = choice.id;
            }
            else if (this.allowFallthrough) {
                this.value = this.filterText;
            }
            (_a = this.el.querySelector('.bp-sdk-autocomplete__input')) === null || _a === void 0 ? void 0 : _a.focus();
            this.removeActiveAnswer.emit();
        };
        this.onKeydown = (event) => {
            const key = event.key;
            if (event.metaKey || event.altKey) {
                return;
            }
            switch (key) {
                case 'ArrowUp':
                case 'ArrowDown':
                case 'Enter':
                    event.preventDefault();
                    this.handleKeyEvent(key);
                    break;
                case 'Tab':
                case 'Escape':
                    this._showChoices = false;
                    break;
                case 'Meta':
                case 'Control':
                case 'Alt':
                    break;
                default:
                    this.debounceFilterChoices();
                    break;
            }
        };
        this.onOptionClick = (choice) => (e) => {
            e.preventDefault();
            this.choiceSelected(choice);
        };
        this.answerId = undefined;
        this.questionId = undefined;
        this.fieldType = undefined;
        this.choiceId = undefined;
        this.choices = [];
        this.code = undefined;
        this.placeholder = '';
        this.required = false;
        this.errors = undefined;
        this.errorText = undefined;
        this.labelId = undefined;
        this.showChoices = false;
        this.touched = false;
        this.pristine = true;
        this.isCompleted = false;
        this.isReadOnly = false;
        this.label = undefined;
        this.labelledBy = undefined;
        this.disableDropdown = false;
        this.allowFallthrough = false;
        this.showNoChoicesFallback = true;
        this.helpText = undefined;
        this.answeredBySource = undefined;
        this._choices = [];
        this._labelledBy = undefined;
        this._showChoices = false;
        this.filterText = '';
        this.value = undefined;
        this.choice = undefined;
        this.choiceText = '';
        this.focusedIndex = 0;
        this.useExternal = false;
        this.isFocused = false;
        this.text = '';
    }
    resetState() {
        this._showChoices = false;
        this.focusedIndex = 0;
        this.isFocused = false;
    }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-autocomplete-input');
        customElements.whenDefined('bp-sdk-external-autocomplete-input').then(() => {
            this.useExternal = true;
        });
        this.onChoicesChange(this.choices);
        this.onChoiceIdChange(this.choiceId);
        this.onShowChoicesChange(this.showChoices);
        this.onChoiceChange(this.choice);
        this.onAriaLabelledByChange(this.labelId);
        this.onLabelledByChange(this.labelledBy);
        this.checkForSelectedChoice();
    }
    onAriaLabelledByChange(labelId) {
        this.updateLabelledBy(labelId, this.labelledBy);
    }
    onLabelledByChange(labelledBy) {
        this.updateLabelledBy(this.labelId, labelledBy);
    }
    updateLabelledBy(aria, ids) {
        const prefix = ids ? `${ids} ` : '';
        this._labelledBy = `${prefix}${aria !== null && aria !== void 0 ? aria : ''}` || undefined;
    }
    onChoicesChange(choices) {
        if (JSON.stringify(choices) !== JSON.stringify(this._choices)) {
            this._choices = choices;
        }
        this.onChoiceIdChange(this.choiceId);
    }
    onChoiceIdChange(choiceId) {
        this.choice = this._choices.find((choice) => choice.id === choiceId);
    }
    onShowChoicesChange(newValue) {
        this._showChoices = this.isFocused && newValue;
    }
    getText(choice) {
        return choice ? this.displayChoice(choice) : '';
    }
    onChoiceChange(choice) {
        this.choiceText = this.getText(choice);
    }
    onChoiceTextChange(text) {
        this.text = text;
    }
    onValueChange(newValue, oldValue) {
        this._showChoices = false;
        if (newValue !== this.choiceId && index_esm_min.j(newValue, oldValue)) {
            this.valueUpdate.emit([newValue]);
        }
    }
    filterChoices() {
        const input = this.el.querySelector('input');
        this.text = this.filterText = input.value;
        this._showChoices = this.isFocused && !!this.filterText;
    }
    onFilterChange(value) {
        this._showChoices = this.isFocused;
        this.updateActiveAnswer.emit(this.answerId);
        this.filterUpdate.emit({
            id: this.questionId,
            value,
        });
    }
    checkForSelectedChoice() {
        if (this.choiceId) {
            this._choices.map((choice) => {
                if (this.choiceId === choice.id) {
                    this.value = choice.id;
                    this.choice = choice;
                }
            });
        }
    }
    displayChoice(choice) {
        return choice === null || choice === void 0 ? void 0 : choice.value;
    }
    handleKeyEvent(keyName) {
        const options = this.getKeyEventOptions(keyName);
        const indexToSelect = this.getIndexToSelect(keyName, options);
        this.mapKeyEventToAction(indexToSelect, options);
    }
    getKeyEventOptions(keyName) {
        const goToNext = keyboardNavigation$1.next.includes(keyName);
        const goToPrevious = keyboardNavigation$1.previous.includes(keyName);
        const isOpenOrSelectKey = keyboardNavigation$1.select.includes(keyName);
        return {
            goToNext,
            goToPrevious,
            shouldMoveIndex: this._showChoices && (goToPrevious || goToNext),
            isOpenOrSelectKey,
        };
    }
    getIndexToSelect(keyName, { goToPrevious, shouldMoveIndex, isOpenOrSelectKey }) {
        let indexToSelect;
        if (isOpenOrSelectKey && this._showChoices) {
            indexToSelect = this.focusedIndex;
        }
        else if (keyName === 'Escape') {
            this._showChoices = false;
        }
        else if (shouldMoveIndex && !this._showChoices) {
            indexToSelect = this.focusedIndex == null ? 0 : this.focusedIndex + (goToPrevious ? -1 : 1);
        }
        return indexToSelect;
    }
    mapKeyEventToAction(indexToSelect, { shouldMoveIndex, goToPrevious, goToNext, }) {
        if (typeof indexToSelect === 'number') {
            this.selectOptionByIndex(indexToSelect);
        }
        else if (shouldMoveIndex && this._showChoices) {
            this.focusOption(this.focusedIndex + (goToPrevious ? -1 : 1));
        }
        else if (goToNext || goToPrevious) {
            this.filterText = this.displayChoice(this.choice);
            this.focusOption(0);
        }
    }
    focusOption(index) {
        this._showChoices = this.isFocused;
        this.focusedIndex = this.getSelectableIndex(index);
    }
    selectOptionByIndex(index) {
        const selectableIndex = this.getSelectableIndex(index);
        this.focusedIndex = selectableIndex;
        const choice = this._choices[this.focusedIndex];
        this.choiceSelected(choice);
    }
    getSelectableIndex(index) {
        const lastIndex = this._choices.length - 1;
        const selectableIndex = index <= 0 ? 0 : index > lastIndex ? lastIndex : index;
        return selectableIndex;
    }
    handleOutsideClick() {
        this.hideChoices();
    }
    handleClick(e) {
        if (this.useExternal) {
            return;
        }
        e.stopPropagation();
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-autocomplete-input", { allowFallthrough: this.allowFallthrough, answerId: this.answerId, choiceId: this.choiceId, choices: this._choices, code: this.code, disableDropdown: this.disableDropdown, errorText: this.errorText, errors: this.errors, fieldType: this.fieldType, helpText: this.helpText, answeredBySource: this.answeredBySource, isCompleted: this.isCompleted, isReadOnly: this.isReadOnly, labelId: this.labelId, label: this.label, labelledBy: this.labelledBy, placeholder: this.placeholder, pristine: this.pristine, questionId: this.questionId, required: this.required, showChoices: this.showChoices, showNoChoicesFallback: this.showNoChoicesFallback, touched: this.touched }));
    }
    renderInternal() {
        var _a;
        let input;
        if (this.isReadOnly) {
            input = this.renderReadOnlyElement(this.text);
        }
        else {
            input = [
                index.h("input", { id: `bp-sdk-autocomplete__${this.answerId}`, class: "bp-sdk-autocomplete__input", "aria-controls": `bp-sdk-autocomplete__${this.answerId}-listbox`, "aria-autocomplete": "list", placeholder: this.placeholder, "aria-labelledby": this._labelledBy, type: "text", value: this.text, onBlur: this.onBlur, onFocus: this.onFocus, onKeyDown: this.onKeydown }),
                this.renderOptions(),
            ];
        }
        return (index.h("div", { class: "bp-sdk-autocomplete__container", "aria-expanded": this._showChoices, "aria-owns": `bp-sdk-autocomplete__${this.answerId}-listbox`, "aria-haspopup": "listbox", onBlur: this.hideChoices }, index.h("label", { id: this.labelId, htmlFor: `bp-sdk-autocomplete__${this.answerId}`, class: "bp-sdk-label bp-sdk-autocomplete__label", innerHTML: this.label }), input, this.touched && !this.pristine && ((this.errorText && !this.isCompleted) || !!((_a = this.errors) === null || _a === void 0 ? void 0 : _a.length)) && (index.h("bp-sdk-errors-container", { answerId: this.answerId, questionId: this.questionId, fieldType: this.fieldType, errors: this.errors, errorText: this.errorText }))));
    }
    renderOptions() {
        var _a;
        if (this.disableDropdown) {
            return;
        }
        else if ((_a = this._choices) === null || _a === void 0 ? void 0 : _a.length) {
            return (index.h("ul", { class: index_esm_min.zh('bp-sdk-autocomplete__list', {
                    'bp-sdk-visually-hidden': !this._showChoices,
                }), id: `bp-sdk-autocomplete__${this.answerId}-listbox`, role: "listbox", "aria-labelledby": this.labelId, tabindex: "-1" }, this._choices.map((choice, i) => (index.h("li", { onClick: this.onOptionClick(choice), "aria-labelledby": this.labelId, class: index_esm_min.zh(`bp-sdk-autocomplete__list-item bp-sdk-autocomplete__item-${choice.id}`, {
                    'bp-sdk-autocomplete__list-item--selected': this.choiceId === choice.id,
                }), role: "option", "aria-selected": (this.focusedIndex == i).toString(), tabindex: "1" }, index.h("span", { class: `bp-sdk-autocomplete__list-item-text bp-sdk-autocomplete__list-item-text-${choice.id}` }, this.displayChoice(choice)))))));
        }
        else if (this.showNoChoicesFallback) {
            return (index.h("div", { class: index_esm_min.zh('bp-sdk-no-results', {
                    'bp-sdk-visually-hidden': !this._showChoices,
                }) }, index.h("span", null, "No Results")));
        }
    }
    renderReadOnlyElement(value) {
        return index.h("span", { class: "read-only-value" }, value);
    }
    get el() { return index.getElement(this); }
    static get watchers() { return {
        "labelId": ["onAriaLabelledByChange"],
        "labelledBy": ["onLabelledByChange"],
        "choices": ["onChoicesChange"],
        "choiceId": ["onChoiceIdChange"],
        "showChoices": ["onShowChoicesChange"],
        "choice": ["onChoiceChange"],
        "choiceText": ["onChoiceTextChange"],
        "value": ["onValueChange"],
        "filterText": ["onFilterChange"]
    }; }
};
BpSdkAutocompleteInput.style = BpSdkAutocompleteInputStyle0;

const bpSdkBusinessClassificationSelectorCardBodyCss = "";
const BpSdkBusinessClassificationSelectorCardBodyStyle0 = bpSdkBusinessClassificationSelectorCardBodyCss;

const BpSdkBusinessClassificationSelectorCardBody = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.explanation = undefined;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-card-body');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-card-body').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-business-classification-selector-card-body", { explanation: this.explanation });
    }
    renderInternal() {
        return (index.h("div", { class: "'bp-sdk-business-classification-selector-card-body__container'" }, index.h("div", { class: "bp-sdk-business-classification-selector-card-body__text", innerHTML: this.explanation || '' })));
    }
};
BpSdkBusinessClassificationSelectorCardBody.style = BpSdkBusinessClassificationSelectorCardBodyStyle0;

const bpSdkBusinessClassificationSelectorCardContentCss = "";
const BpSdkBusinessClassificationSelectorCardContentStyle0 = bpSdkBusinessClassificationSelectorCardContentCss;

const BpSdkBusinessClassificationSelectorCardContent = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.alias = undefined;
        this.value = undefined;
        this.highlights = undefined;
        this.confidence = undefined;
        this.explanation = undefined;
        this.showExplanation = true;
        this.showConfidence = undefined;
        this.showNaicsCode = undefined;
        this.showDetailedRelevanceChip = undefined;
        this.isSelected = undefined;
        this.isBestMatch = undefined;
        this.isoCodes = undefined;
        this.sicCodes = undefined;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-card-content');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-card-content').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-business-classification-selector-card-content", { alias: this.alias, value: this.value, highlights: this.highlights, confidence: this.confidence, explanation: this.explanation, showExplanation: this.showExplanation, showConfidence: this.showConfidence, showNaicsCode: this.showNaicsCode, showDetailedRelevanceChip: this.showDetailedRelevanceChip, isSelected: this.isSelected, isBestMatch: this.isBestMatch, isoCodes: this.isoCodes, sicCodes: this.sicCodes }));
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-business-classification-selector-card-content__container" }, index.h("bp-sdk-business-classification-selector-card-header", { alias: this.alias, confidence: this.confidence, showConfidence: this.showConfidence, showNaicsCode: this.showNaicsCode, value: this.value, highlights: this.highlights }), index.h("bp-sdk-business-classification-selector-card-body", { explanation: this.explanation }), this.showDetailedRelevanceChip && index.h("bp-sdk-business-classification-selector-relevance-chip", { confidence: this.confidence })));
    }
};
BpSdkBusinessClassificationSelectorCardContent.style = BpSdkBusinessClassificationSelectorCardContentStyle0;

const bpSdkBusinessClassificationSelectorCardHeaderCss = "";
const BpSdkBusinessClassificationSelectorCardHeaderStyle0 = bpSdkBusinessClassificationSelectorCardHeaderCss;

const BpSdkBusinessClassificationSelectorCardHeader = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.confidence = undefined;
        this.alias = undefined;
        this.showNaicsCode = undefined;
        this.showConfidence = undefined;
        this.value = undefined;
        this.highlights = undefined;
        this.highlightFilters = ['synonyms', 'value'];
        this.highlight = undefined;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-card-header');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-card-header').then(() => {
            this.useExternal = true;
        });
        this.onHightLightsChange(this.highlights);
        this.onHighlightFilterChanges(this.highlightFilters);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    onHightLightsChange(highlights) {
        this.updateHighlight(this.highlightFilters, highlights);
    }
    onHighlightFilterChanges(filters) {
        this.updateHighlight(filters, this.highlights);
    }
    updateHighlight(filters, highlights = []) {
        const valueHighlight = Array.isArray(highlights) && (highlights === null || highlights === void 0 ? void 0 : highlights.find(({ field }) => filters.includes(field)));
        this.highlight = !!valueHighlight ? valueHighlight.text : this.value;
    }
    renderExternal() {
        return (index.h("bp-sdk-external-business-classification-selector-card-header", { alias: this.alias, confidence: this.confidence, showConfidence: this.showConfidence, showNaicsCode: this.showNaicsCode, value: this.value, highlights: this.highlights, highlightFilters: this.highlightFilters }));
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-business-classification-selector-card-header__container" }, index.h("span", { class: "bp-sdk-business-classification-selector-card-header__text" }, this.highlight && (index.h("span", { class: "bp-sdk-business-classification-selector-card-header__highlight", innerHTML: this.highlight })), this.showNaicsCode && index.h("span", { class: "bp-sdk-business-classification-selector-card-header__alias" }, " - ", this.alias)), this.showConfidence && index.h("bp-sdk-class-selector-relevance-chip", { confidence: this.confidence })));
    }
    static get watchers() { return {
        "highlights": ["onHightLightsChange"],
        "highlightFilters": ["onHighlightFilterChanges"]
    }; }
};
BpSdkBusinessClassificationSelectorCardHeader.style = BpSdkBusinessClassificationSelectorCardHeaderStyle0;

const bpSdkBusinessClassificationSelectorListCss = "";
const BpSdkBusinessClassificationSelectorListStyle0 = bpSdkBusinessClassificationSelectorListCss;

const BpSdkBusinessClassificationSelectorList = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.calculateGroupedChoices = (choices = []) => {
            var _a, _b;
            const topChoices = [...choices]
                .sort((a, b) => (b.score || 0) - (a.score || 0))
                .slice(0, ((_a = this.groupedChoicesConfig) === null || _a === void 0 ? void 0 : _a.maxResults) || 7);
            this.groupedChoices = index_esm_min.oy(topChoices);
            this.highestChoiceScore = ((_b = this.groupedChoices[0]) === null || _b === void 0 ? void 0 : _b.score) || 1000;
        };
        this.choiceId = undefined;
        this.choices = [];
        this.showConfidence = undefined;
        this.showNaicsCode = undefined;
        this.groupedChoicesConfig = undefined;
        this.useExternal = false;
        this.groupedChoices = [];
        this.highestChoiceScore = undefined;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-list');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-list').then(() => {
            this.useExternal = true;
        });
        this.calculateGroupedChoices(this.choices);
    }
    onChoicesChange(choices) {
        this.calculateGroupedChoices(choices);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-business-classification-selector-list", { choices: this.choices, choiceId: this.choiceId, showConfidence: this.showConfidence, showNaicsCode: this.showNaicsCode, groupedChoicesConfig: this.groupedChoicesConfig }));
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-business-classification-selector-list__container" }, this.groupedChoices.map((choiceGroup) => {
            var _a, _b;
            return (index.h("bp-sdk-business-classification-selector-naics-group", { showNaicsCode: this.showNaicsCode, showConfidence: this.showConfidence, naicsCode: choiceGroup.alias, naicsExplanation: ((_a = choiceGroup.choices[0]) === null || _a === void 0 ? void 0 : _a.explanation) || '', naicsDescription: ((_b = choiceGroup.choices[0]) === null || _b === void 0 ? void 0 : _b.national_industry_description) || '', choices: choiceGroup.choices, choiceId: this.choiceId, highestChoiceScore: this.highestChoiceScore }));
        })));
    }
    static get watchers() { return {
        "choices": ["onChoicesChange"]
    }; }
};
BpSdkBusinessClassificationSelectorList.style = BpSdkBusinessClassificationSelectorListStyle0;

const bpSdkBusinessClassificationSelectorListContainerCss = "";
const BpSdkBusinessClassificationSelectorListContainerStyle0 = bpSdkBusinessClassificationSelectorListContainerCss;

const BpSdkBusinessClassificationSelectorListContainer = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            this.storeUnsubscribe = reduxStore_service.store.mapStateToProps(this, this.mapStateToProps);
        };
        this.mapStateToProps = (state) => {
            return {
                groupedChoicesConfig: { maxResults: index_esm_min$1.Te(state).bcsChoiceLimit },
            };
        };
        this.choiceId = undefined;
        this.choices = [];
        this.showConfidence = undefined;
        this.showNaicsCode = undefined;
        this.groupedChoicesConfig = { maxResults: 7 };
        this.useExternal = false;
    }
    resetState() {
        this.groupedChoicesConfig = { maxResults: 7 };
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-list-container');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-list-container').then(() => {
            this.useExternal = true;
        });
    }
    connectedCallback() {
        this.resetState();
        this.handleSubscriptions();
    }
    disconnectedCallback() {
        this.storeUnsubscribe && this.storeUnsubscribe();
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-business-classification-selector-list-container", { choices: this.choices, choiceId: this.choiceId, showConfidence: this.showConfidence, showNaicsCode: this.showNaicsCode, groupedChoicesConfig: this.groupedChoicesConfig }));
    }
    renderInternal() {
        return (index.h("bp-sdk-business-classification-selector-list", { choices: this.choices, choiceId: this.choiceId, showConfidence: this.showConfidence, showNaicsCode: this.showNaicsCode, groupedChoicesConfig: this.groupedChoicesConfig }));
    }
    get el() { return index.getElement(this); }
};
BpSdkBusinessClassificationSelectorListContainer.style = BpSdkBusinessClassificationSelectorListContainerStyle0;

const bpSdkBusinessClassificationSelectorListItemCss = "";
const BpSdkBusinessClassificationSelectorListItemStyle0 = bpSdkBusinessClassificationSelectorListItemCss;

const BpSdkBusinessClassificationSelectorListItem = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.valueUpdate = index.createEvent(this, "valueUpdate", 7);
        this.onSelection = (e) => {
            e.preventDefault();
            if (!this.locked) {
                this.valueUpdate.emit([this.choiceId]);
            }
        };
        this.onKeyPress = (e) => {
            if (e.key === 'Enter' || e.key === ' ') {
                this.onSelection(e);
            }
        };
        this.alias = undefined;
        this.value = undefined;
        this.highlights = undefined;
        this.isSelected = false;
        this.showExplanation = true;
        this.confidence = undefined;
        this.showConfidence = undefined;
        this.choiceId = undefined;
        this.showDetailedRelevanceChip = undefined;
        this.locked = undefined;
        this.isBestMatch = undefined;
        this.isoCodes = undefined;
        this.sicCodes = undefined;
        this.useExternal = false;
        this.isExpanded = false;
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-list-item');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-list-item').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-business-classification-selector-list-item", { alias: this.alias, isSelected: this.isSelected, showExplanation: this.showExplanation, confidence: this.confidence, choiceId: this.choiceId, showConfidence: this.showConfidence, value: this.value, highlights: this.highlights, showDetailedRelevanceChip: this.showDetailedRelevanceChip, isBestMatch: this.isBestMatch, locked: this.locked }));
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-business-classification-selector-list-item__container" }, index.h("bp-sdk-business-classification-selector-card-content", { alias: this.alias, confidence: this.confidence, onClick: this.onSelection, showConfidence: this.showConfidence, showDetailedRelevanceChip: this.showDetailedRelevanceChip, value: this.value, highlights: this.highlights, isSelected: this.isSelected, isBestMatch: this.isBestMatch, isoCodes: this.isoCodes, sicCodes: this.sicCodes, tabIndex: 0, role: "button", onKeyPress: this.onKeyPress })));
    }
};
BpSdkBusinessClassificationSelectorListItem.style = BpSdkBusinessClassificationSelectorListItemStyle0;

const bpSdkBusinessClassificationSelectorListItemContainerCss = "";
const BpSdkBusinessClassificationSelectorListItemContainerStyle0 = bpSdkBusinessClassificationSelectorListItemContainerCss;

const BpSdkBusinessClassificationSelectorListItemContainer = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            this.storeUnsubscribe = reduxStore_service.store.mapStateToProps(this, this.mapStateToProps);
        };
        this.mapStateToProps = (state) => {
            return {
                showDetailedRelevanceChip: index_esm_min$1.nN(state),
                enableUserApplicationGuard: !!state.config.options.enableUserApplicationGuard,
                locked: state.application.form.locked,
                isOwner: index_esm_min$1.MN(state),
                hasPermissionToEdit: index_esm_min$1.VN(state, {
                    permission: index_esm_min$2.T.ApplicationForms,
                    action: index_esm_min$2.O.Update,
                }),
            };
        };
        this.alias = undefined;
        this.value = undefined;
        this.isSelected = false;
        this.showExplanation = true;
        this.confidence = undefined;
        this.showConfidence = undefined;
        this.choiceId = undefined;
        this.highlights = undefined;
        this.showDetailedRelevanceChip = false;
        this.locked = undefined;
        this.isOwner = undefined;
        this.hasPermissionToEdit = undefined;
        this.enableUserApplicationGuard = undefined;
        this.isBestMatch = undefined;
        this.isoCodes = undefined;
        this.sicCodes = undefined;
        this.useExternal = false;
        this.isLocked = false;
    }
    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));
    }
    resetState() {
        this.showDetailedRelevanceChip = false;
    }
    connectedCallback() {
        this.resetState();
        this.handleSubscriptions();
    }
    disconnectedCallback() {
        this.storeUnsubscribe && this.storeUnsubscribe();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-list-item-container');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-list-item-container').then(() => {
            this.useExternal = true;
        });
        this.handleSubscriptions();
        this.updateIsLocked(this.locked, this.isOwner, this.hasPermissionToEdit, this.enableUserApplicationGuard);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-business-classification-selector-list-item-container", { alias: this.alias, choiceId: this.choiceId, confidence: this.confidence, isSelected: this.isSelected, showConfidence: this.showConfidence, showExplanation: this.showExplanation, value: this.value, highlights: this.highlights, showDetailedRelevanceChip: this.showDetailedRelevanceChip, isBestMatch: this.isBestMatch, locked: this.locked, isOwner: this.isOwner, hasPermissionToEdit: this.hasPermissionToEdit, enableUserApplicationGuard: this.enableUserApplicationGuard }));
    }
    renderInternal() {
        return (index.h("bp-sdk-business-classification-selector-list-item", { alias: this.alias, choiceId: this.choiceId, confidence: this.confidence, isSelected: this.isSelected, showConfidence: this.showConfidence, showExplanation: this.showExplanation, value: this.value, highlights: this.highlights, showDetailedRelevanceChip: this.showDetailedRelevanceChip, locked: this.isLocked, isBestMatch: this.isBestMatch, isoCodes: this.isoCodes, sicCodes: this.sicCodes }));
    }
    static get watchers() { return {
        "enableUserApplicationGuard": ["onEnableUserApplicationGuard"],
        "hasPermissionToEdit": ["onHasPermissionToEdit"],
        "isOwner": ["onIsOwner"],
        "locked": ["onLocked"]
    }; }
};
BpSdkBusinessClassificationSelectorListItemContainer.style = BpSdkBusinessClassificationSelectorListItemContainerStyle0;

const bpSdkBusinessClassificationSelectorNaicsGroupCss = "";
const BpSdkBusinessClassificationSelectorNaicsGroupStyle0 = bpSdkBusinessClassificationSelectorNaicsGroupCss;

const BpSdkBusinessClassificationSelectorNaicsGroup = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.choices = [];
        this.showConfidence = undefined;
        this.showNaicsCode = undefined;
        this.naicsCode = '';
        this.naicsExplanation = '';
        this.naicsDescription = '';
        this.choiceId = undefined;
        this.highestChoiceScore = undefined;
        this.useExternal = false;
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-naics-group');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-naics-group').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-business-classification-selector-naics-group", { choices: this.choices, showConfidence: this.showNaicsCode, showNaicsCode: this.showNaicsCode, naicsCode: this.naicsCode, naicsDescription: this.naicsDescription, naicsExplanation: this.naicsExplanation, highestChoiceScore: this.highestChoiceScore, choiceId: this.choiceId }));
    }
    renderInternal() {
        var _a;
        return (index.h("div", { class: "bp-sdk-business-classification-selector-naics-group__container" }, index.h("bp-sdk-business-classification-selector-naics-group-header", { naicsCode: this.showNaicsCode ? this.naicsCode : undefined, naicsDescription: this.naicsDescription, naicsExplanation: this.naicsExplanation }), (_a = this.choices) === null || _a === void 0 ? void 0 :
            _a.map((choice) => (index.h("bp-sdk-business-classification-selector-list-item-container", { alias: choice.alias, choiceId: choice.id, confidence: choice.confidence, isSelected: choice.id === this.choiceId, showConfidence: this.showConfidence, showExplanation: choice.showExplanation, value: choice.value, highlights: choice.highlights, isBestMatch: choice.score === this.highestChoiceScore, isoCodes: choice.iso_codes, sicCodes: choice.sic_codes })))));
    }
};
BpSdkBusinessClassificationSelectorNaicsGroup.style = BpSdkBusinessClassificationSelectorNaicsGroupStyle0;

const bpSdkBusinessClassificationSelectorNaicsGroupHeaderCss = ".bp-sdk-business-classification-selector-naics-group-header__heading--popover{display:none}";
const BpSdkBusinessClassificationSelectorNaicsGroupHeaderStyle0 = bpSdkBusinessClassificationSelectorNaicsGroupHeaderCss;

const BpSdkBusinessClassificationSelectorNaicsGroupHeader = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.naicsCode = undefined;
        this.naicsDescription = '';
        this.naicsExplanation = '';
        this.useExternal = false;
    }
    resetState() { }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-naics-group-header');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-naics-group-header').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-business-classification-selector-naics-group-header", { naicsCode: this.naicsCode, naicsExplanation: this.naicsExplanation, naicsDescription: this.naicsDescription }));
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-business-classification-selector-naics-group-header__container" }, index.h("h2", { class: "bp-sdk-business-classification-selector-naics-group-header__heading" }, this.naicsDescription, this.naicsCode && (index.h("span", { class: "bp-sdk-business-classification-selector-naics-group-header__heading--code" }, " - ", this.naicsCode)), this.naicsExplanation && (index.h("span", { class: "bp-sdk-business-classification-selector-naics-group-header__heading--popover" }, this.naicsExplanation)))));
    }
};
BpSdkBusinessClassificationSelectorNaicsGroupHeader.style = BpSdkBusinessClassificationSelectorNaicsGroupHeaderStyle0;

const bpSdkBusinessClassificationSelectorRelevanceChipCss = "";
const BpSdkBusinessClassificationSelectorRelevanceChipStyle0 = bpSdkBusinessClassificationSelectorRelevanceChipCss;

const BpSdkBusinessClassificationSelectorRelevanceChip = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.confidence = undefined;
        this.useExternal = false;
        this.relevance = 'high';
    }
    onConfidenceChange(confidence) {
        let relevance = 'High';
        if (confidence === 1) {
            relevance = 'Medium';
        }
        else if (confidence <= 0) {
            relevance = 'Low';
        }
        this.relevance = relevance;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-business-classification-selector-relevance-chip');
        customElements.whenDefined('bp-sdk-external-business-classification-selector-relevance-chip').then(() => {
            this.useExternal = true;
        });
        this.onConfidenceChange(this.confidence);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-business-classification-selector-relevance-chip", { confidence: this.confidence });
    }
    renderInternal() {
        return (index.h("span", { class: "bp-sdk-business-classification-selector-relevance-chip__container" }, index.h("span", { class: "bp-sdk-business-classification-selector-relevance-chip__wrapper" }, index.h("span", { class: "bp-sdk-business-classification-selector-relevance-chip__content" }, this.relevance, " Relevance"))));
    }
    static get watchers() { return {
        "confidence": ["onConfidenceChange"]
    }; }
};
BpSdkBusinessClassificationSelectorRelevanceChip.style = BpSdkBusinessClassificationSelectorRelevanceChipStyle0;

const bpSdkDeleteButtonCss = "";
const BpSdkDeleteButtonStyle0 = bpSdkDeleteButtonCss;

const BpSdkDeleteButton = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.useExternal = false;
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-delete-button');
        customElements.whenDefined('bp-sdk-external-delete-button').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-delete-button", null);
    }
    renderInternal() {
        return (index.h("button", { class: "bp-sdk-delete-button" }, index.h("bp-sdk-icon-container", { name: "trashcan" }, index.h("slot", null, "Delete"))));
    }
};
BpSdkDeleteButton.style = BpSdkDeleteButtonStyle0;

const bpSdkDialogCloseButtonCss = "";
const BpSdkDialogCloseButtonStyle0 = bpSdkDialogCloseButtonCss;

const BpSdkDialogCloseButton = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-dialog-close-button');
        customElements.whenDefined('bp-sdk-external-dialog-close-button').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-dialog-close-button", null);
    }
    renderInternal() {
        return (index.h("bp-sdk-button", null, index.h("bp-sdk-icon-container", { name: "times" })));
    }
};
BpSdkDialogCloseButton.style = BpSdkDialogCloseButtonStyle0;

const bpSdkIconContainerCss = "";
const BpSdkIconContainerStyle0 = bpSdkIconContainerCss;

const BpSdkIconContainer = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.name = undefined;
        this.cssClasses = '';
        this.useExternal = false;
        this.iconDefined = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-icon-container');
        customElements.whenDefined('bp-sdk-external-icon-container').then(() => {
            this.useExternal = true;
        });
        this.iconDefined = !!customElements.get('bp-sdk-icon');
        customElements.whenDefined('bp-sdk-external-icon').then(() => {
            this.iconDefined = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-icon-container", { name: this.name, cssClasses: this.cssClasses });
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-icon__container" }, this.iconDefined && index.h("bp-sdk-icon", { name: this.name, cssClasses: this.cssClasses }), !this.iconDefined && index.h("span", { class: "bp-sdk-icon__container--fallback" }, this.name)));
    }
};
BpSdkIconContainer.style = BpSdkIconContainerStyle0;

const bpSdkMaskedInputButtonCss = "";
const BpSdkMaskedInputButtonStyle0 = bpSdkMaskedInputButtonCss;

const BpSdkMaskedInputButton = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.label = undefined;
        this.useExternal = false;
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-masked-input-button');
        customElements.whenDefined('bp-sdk-external-masked-input-button').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-masked-input-button", { label: this.label });
    }
    renderInternal() {
        return (index.h("button", { "aria-label": this.label, class: "bp-sdk-masked-input-button__container" }, index.h("slot", null)));
    }
};
BpSdkMaskedInputButton.style = BpSdkMaskedInputButtonStyle0;

const bpSdkParentQuestionPoolSelectorCss = "bp-sdk-parent-question-pool-selector .bp-sdk-parent-question-pool-selector__container{position:relative;min-width:10 rem;max-width:100vw}.bp-sdk-hidden{position:fixed;top:-100rem}.bp-sdk-align-right{margin-left:auto}.bp-sdk-select__button-arrow{font-size:20px}.bp-sdk-select__list{background:white;border:1px solid #aaa;left:0;overflow-y:auto;margin:0;max-height:15rem;padding-left:0;position:absolute;width:100%;z-index:1}.bp-sdk-select__button{width:100%;height:2.5rem;background-color:white;display:flex;padding:0.5rem;justify-items:center;align-items:center;cursor:pointer}.bp-sdk-select__list-item{display:block;position:relative;font-size:16px;padding-left:1rem;padding-right:1rem;cursor:pointer}";
const BpSdkParentQuestionPoolSelectorStyle0 = bpSdkParentQuestionPoolSelectorCss;

const BpSdkParentQuestionPoolSelector = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.selectedAnswerPoolId = index.createEvent(this, "selectedAnswerPoolId", 7);
        this.selectValueUpdate = (ev) => {
            ev.stopPropagation();
            this.selectedChoiceId = ev.detail[0];
        };
        this.handleSubmit = () => {
            if (this.selectedChoiceId) {
                this.selectedAnswerPoolId.emit(this.selectedChoiceId);
                this.selectedChoiceId = undefined;
            }
        };
        this.choices = [];
        this.label = undefined;
        this.useExternal = false;
        this.selectedChoiceId = '';
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-parent-question-pool-selector');
        customElements.whenDefined('bp-sdk-external-parent-question-pool-selector').then(() => {
            this.useExternal = true;
        });
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return index.h("bp-sdk-external-parent-question-pool-selector", { choices: this.choices, label: this.label });
    }
    renderInternal() {
        return (index.h("div", { class: "bp-sdk-parent-question-pool-selector__container" }, index.h("bp-sdk-select-input", { choices: this.choices, label: this.label, onValueUpdate: this.selectValueUpdate, choiceId: this.selectedChoiceId }), this.selectedChoiceId && this.renderSubmitButton()));
    }
    renderSubmitButton() {
        if (!!this.selectedChoiceId) {
            return index.h("bp-sdk-button", { class: "bp-sdk-parent-pool-selector__submit-button", onClick: this.handleSubmit, text: "Next" });
        }
    }
};
BpSdkParentQuestionPoolSelector.style = BpSdkParentQuestionPoolSelectorStyle0;

const bpSdkSelectInputCss = "bp-sdk-select-input .bp-sdk-select__container{position:relative;min-width:10rem;max-width:100vw}.bp-sdk-hidden{position:fixed;top:-100rem}.bp-sdk-no-selection{user-select:none}.bp-sdk-visually-hidden{display:none}.bp-sdk-align-right{margin-left:auto}.bp-sdk-select__button-arrow{font-size:20px}.bp-sdk-select__list{background:white;border:1px solid #aaa;left:0;overflow-y:auto;margin:0;max-height:15rem;padding-left:0;position:absolute;width:100%;z-index:1}.bp-sdk-select__button{width:100%;height:2.5rem;background-color:white;display:flex;padding:0.5rem;justify-items:center;align-items:center;cursor:pointer}.bp-sdk-select__list-item{display:block;position:relative;font-size:16px;padding-left:1rem;padding-right:1rem;cursor:pointer}";
const BpSdkSelectInputStyle0 = bpSdkSelectInputCss;

const selectButtonIdPrefix = 'select-btn-';
const keyboardNavigation = {
    next: ['ArrowRight', 'ArrowDown'],
    previous: ['ArrowLeft', 'ArrowUp'],
    select: ['Enter', ' '],
};
const BpSdkSelectInput = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.valueUpdate = index.createEvent(this, "valueUpdate", 7);
        this.removeActiveAnswer = index.createEvent(this, "removeActiveAnswer", 7);
        this.updateActiveAnswer = index.createEvent(this, "updateActiveAnswer", 7);
        this.onKeydown = (event) => {
            const key = event.key;
            const isTab = key === 'Tab';
            if ((key !== 'Shift' && key !== 'Meta' && key !== 'Alt' && key !== 'Control' && !isTab) || (isTab && this.showSelectList)) {
                event.preventDefault();
                this.handleKeyEvent(key);
            }
        };
        this.onChange = (event) => {
            event.preventDefault();
            this.updateTextDisplayed(event.target.value);
        };
        this.clickSelectItem = (choiceId) => {
            let ctrlValue = choiceId || this.choice;
            if (this.multiple) {
                ctrlValue = this.getControlValue(choiceId);
            }
            else {
                this.clickSelectButton();
            }
            this.removeActiveAnswer.emit();
            this.choice = this._value = Array.isArray(ctrlValue) ? ctrlValue : [ctrlValue];
            this.updateTextDisplayed(ctrlValue);
        };
        this.delayedClickSelectItem = debounce.debounce_1(this.clickSelectItem, 8);
        this.updateTextDisplayed = debounce.debounce_1((choiceValue) => {
            if (this.multiple && Array.isArray(choiceValue) && choiceValue.length > 0) {
                this.updateMultiSelectText(choiceValue);
            }
            else if (choiceValue && typeof choiceValue === 'string') {
                this.updateSingleSelectText(choiceValue);
            }
            else {
                this.selectText = this.placeholder || '';
            }
        }, 20);
        this.listenToTextFilter = debounce.debounce_1((newValue) => this.handleTextEntry(newValue), 500);
        this.onSubmitButtonClick = ($event) => this.selectFocus($event);
        this.onAutocomplete = (e) => {
            const value = e.target.value;
            const choice = this.choices.find((choice) => choice.value === value);
            this.delayedClickSelectItem(choice.id);
        };
        this.onListBlur = () => {
            this.showSelectList = false;
        };
        this.onChoiceClick = (choice) => (e) => {
            e.stopPropagation();
            e.preventDefault();
            this.delayedClickSelectItem(choice.id);
        };
        this.answerId = undefined;
        this.autoComplete = undefined;
        this.placeholder = '';
        this.useAlias = false;
        this.code = undefined;
        this.choiceId = undefined;
        this.choiceIds = [];
        this.multiple = false;
        this.choices = [];
        this.value = undefined;
        this.labelId = undefined;
        this.errors = undefined;
        this.errorText = undefined;
        this.touched = false;
        this.pristine = true;
        this.isCompleted = false;
        this.isReadOnly = false;
        this.questionId = undefined;
        this.fieldType = undefined;
        this.required = undefined;
        this.label = undefined;
        this.labelledBy = undefined;
        this.helpText = undefined;
        this.answeredBySource = undefined;
        this.choice = [];
        this._value = [];
        this._labelledBy = undefined;
        this.showSelectList = false;
        this.selectText = '';
        this.focusedIndex = 0;
        this.selectButtonId = `${selectButtonIdPrefix}${index_esm_min.e$(8)}`;
        this.accumulateFilter = true;
        this.currentFilterText = '';
        this.useExternal = false;
    }
    onAriaLabelledByChange(labelId) {
        this.updateLabelledBy(labelId, this.labelledBy);
    }
    onLabelledByChange(labelledBy) {
        this.updateLabelledBy(this.labelId, labelledBy);
    }
    updateLabelledBy(aria, ids) {
        const prefix = ids ? `${ids} ` : '';
        this._labelledBy = `${prefix}${aria !== null && aria !== void 0 ? aria : ''}` || undefined;
    }
    onCodeChange(newValue) {
        this.selectButtonId = `${selectButtonIdPrefix}${newValue}`;
    }
    onChoiceIdChange(choice) {
        this.choice = [choice];
        this.updateTextDisplayed(choice);
    }
    onChoiceIdsChange(choiceIds, oldIds) {
        if (isEqual.isEqual_1(choiceIds, oldIds)) {
            return;
        }
        this.choice = choiceIds;
        this.updateTextDisplayed(choiceIds);
    }
    onShowSelectListChange(showList) {
        if (showList) {
            this.el.dispatchEvent(new FocusEvent('focusin', { bubbles: true }));
            this.updateActiveAnswer.emit(this.answerId);
        }
        else {
            this.removeActiveAnswer.emit();
        }
    }
    resetState() {
        this.showSelectList = false;
        this.accumulateFilter = true;
        this.currentFilterText = '';
    }
    connectedCallback() {
        this.resetState();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-select-input');
        customElements.whenDefined('bp-sdk-external-select-input').then(() => {
            this.useExternal = true;
        });
        this.onChoiceIdChange(this.choiceId);
        this.onChoiceIdsChange(this.choiceIds, []);
        this.onAriaLabelledByChange(this.labelId);
        this.onLabelledByChange(this.labelledBy);
    }
    focusOption(index) {
        this.showSelectList = true;
        this.focusedIndex = this.getSelectableIndex(index);
        setTimeout(() => {
            const optionList = this.el.querySelector('.bp-sdk-select__list');
            const element = optionList.children[this.focusedIndex];
            element.focus();
        }, 0);
    }
    selectFocus(e) {
        e.stopPropagation();
        e.preventDefault();
        if (!this.showSelectList) {
            this.focusElement();
        }
        else {
            this.showSelectList = false;
        }
    }
    focusElement() {
        this.showSelectList = true;
        this.el.dispatchEvent(new FocusEvent('focusin'));
        let focusIndex = 0;
        if (!this.multiple && this.choice.length) {
            const choiceId = this.choice[0];
            focusIndex = this.choices.findIndex((choice) => choice.id === choiceId);
        }
        this.focusOption(focusIndex);
    }
    choiceText(choice) {
        return this.useAlias && choice.alias ? choice.alias : choice.value;
    }
    getControlValue(choiceId) {
        if (this.isChosen(choiceId)) {
            return this.choice.filter((id) => id !== choiceId);
        }
        else {
            return [...this.choice, choiceId];
        }
    }
    clickSelectButton() {
        this.showSelectList = false;
        const selectButton = this.el.querySelector('.bp-sdk-select__button');
        selectButton === null || selectButton === void 0 ? void 0 : selectButton.focus();
    }
    isChosen(choiceId) {
        return (this.choice || []).includes(choiceId);
    }
    handleKeyEvent(keyName) {
        const options = this.getKeyEventOptions(keyName);
        const indexToSelect = this.getIndexToSelect(keyName, options);
        this.mapKeyEventToAction(keyName, indexToSelect, options);
    }
    getKeyEventOptions(keyName) {
        const goToNext = keyboardNavigation.next.includes(keyName);
        const goToPrevious = keyboardNavigation.previous.includes(keyName);
        const addToFilter = !goToNext && !goToPrevious && !!keyName && keyName !== ' ';
        const isOpenOrSelectKey = keyboardNavigation.select.includes(keyName) || (keyName === 'Tab' && this.showSelectList);
        const openSelectList = isOpenOrSelectKey && !this.showSelectList;
        return {
            goToNext,
            goToPrevious,
            shouldMoveIndex: goToPrevious || goToNext,
            addToFilter,
            isOpenOrSelectKey,
            openSelectList,
        };
    }
    getIndexToSelect(keyName, { goToPrevious, shouldMoveIndex, isOpenOrSelectKey }) {
        let indexToSelect;
        if (isOpenOrSelectKey && this.showSelectList) {
            indexToSelect = this.focusedIndex;
        }
        else if (keyName === 'Escape') {
            this.showSelectList = false;
        }
        else if (shouldMoveIndex && !this.showSelectList) {
            indexToSelect = !this.choice ? 0 : this.focusedIndex + (goToPrevious ? -1 : 1);
        }
        return indexToSelect;
    }
    mapKeyEventToAction(keyName, indexToSelect, { openSelectList, shouldMoveIndex, goToPrevious, addToFilter, }) {
        if (openSelectList) {
            this.focusOption(this.focusedIndex);
        }
        else if (typeof indexToSelect === 'number') {
            this.selectOptionByIndex(indexToSelect);
        }
        else if (shouldMoveIndex && this.showSelectList) {
            this.focusOption(this.focusedIndex + (goToPrevious ? -1 : 1));
        }
        else if (addToFilter) {
            this.filterText(keyName);
        }
    }
    selectOptionByIndex(index) {
        const selectableIndex = this.getSelectableIndex(index);
        this.focusedIndex = selectableIndex;
        const choice = this.choices[this.focusedIndex];
        this.delayedClickSelectItem(choice.id);
    }
    updateMultiSelectText(choiceIds) {
        const selectedChoices = this.choices.filter((c) => choiceIds.findIndex((id) => id === c.id) > -1);
        if (selectedChoices.length > 0) {
            this.selectText = selectedChoices.map((c) => (this.useAlias ? c.alias : c.value)).join(', ');
        }
    }
    updateSingleSelectText(choiceValue) {
        const choice = this.choices.find((c) => c.id === choiceValue);
        if (choice) {
            this.selectText = this.useAlias ? choice.alias : choice.value;
        }
    }
    onValueChange(newValue, oldValue) {
        if (index_esm_min.j(newValue, oldValue)) {
            this.valueUpdate.emit(newValue);
        }
    }
    filterText(newValue) {
        let result = newValue;
        if (!this.accumulateFilter) {
            this.accumulateFilter = true;
        }
        else {
            result = this.currentFilterText + newValue;
        }
        this.currentFilterText = result;
        this.listenToTextFilter(result);
    }
    handleTextEntry(text) {
        var _a;
        this.accumulateFilter = false;
        const indexToFocus = (_a = (text && this.choices.findIndex((choice) => this.choiceText(choice).toLowerCase().startsWith(text.toLowerCase())))) !== null && _a !== void 0 ? _a : -1;
        const choice = this.choices[indexToFocus];
        if (this.showSelectList) {
            this.focusOption(indexToFocus);
        }
        else if (choice) {
            this.delayedClickSelectItem(choice.id);
        }
    }
    getSelectableIndex(index) {
        const lastIndex = this.choices.length - 1;
        const selectableIndex = index <= 0 ? 0 : index > lastIndex ? lastIndex : index;
        return selectableIndex;
    }
    handleOutsideClick() {
        this.showSelectList = false;
    }
    renderSubmitButton() {
        return (index.h("button", { type: "button", class: index_esm_min.zh('bp-sdk-select__button', {
                'bp-sdk-touched': this.touched,
                'bp-sdk-pristine': this.pristine,
            }), "aria-haspopup": "listbox", disabled: !this.choices.length, "aria-labelledby": this._labelledBy || '' + ' ' + this.selectButtonId, onClick: this.onSubmitButtonClick, id: this.selectButtonId, "aria-label": this.selectText || this.placeholder, "aria-describedby": index_esm_min.Wh(index_esm_min.n$(this.errors)) || undefined }, this.selectText || this.placeholder, index.h("span", { class: "bp-sdk-align-right bp-sdk-select__button-arrow" }, "\u25BE")));
    }
    renderHiddenOptions() {
        return (index.h("select", { "aria-hidden": true, tabindex: "-1", class: "bp-sdk-hidden", autocomplete: this.autoComplete, multiple: this.multiple, onInput: this.onAutocomplete }, this.choices.map((choice) => (index.h("option", { onClick: this.onChoiceClick(choice), selected: this.isChosen(choice.id), value: choice.value }, choice.alias)))));
    }
    renderMultiSelectChoices(choice) {
        return (index.h("label", { htmlFor: `bp-sdk-select__list-${this.answerId}-item__input-${choice.id}`, id: `bp-sdk-select__list-${this.answerId}-item__label-${choice.id}`, class: "bp-sdk-select-list-item-label" }, index.h("span", { class: "bp-sdk-no-selection" }, this.choiceText(choice)), index.h("input", { id: `bp-sdk-select__list-${this.answerId}-item__input-${choice.id}`, class: `bp-sdk-select__list-item-content bp-sdk-select__list-item-input bp-sdk-select__list-item-content-${this.code} bp-sdk-select__list-item-input-${this.code}`, type: "checkbox", checked: this.isChosen(choice.id), placeholder: this.choiceText(choice) })));
    }
    renderSingleSelectChoices(choice) {
        return (index.h("span", { class: `bp-sdk-select__list-item-content bp-sdk-select__list-item-text bp-sdk-select__list-item-content-${this.code} bp-sdk-select__list-item-text-${choice.id}` }, this.choiceText(choice)));
    }
    renderChoice(choice) {
        return [this.multiple && this.renderMultiSelectChoices(choice), !this.multiple && this.renderSingleSelectChoices(choice)];
    }
    renderChoices() {
        return this.choices.map((choice, i) => (index.h("li", { onClick: this.onChoiceClick(choice), "aria-labelledby": this.labelId, class: index_esm_min.zh(`bp-sdk-select__list-item bp-sdk-select__list-item-${choice.id}`, {
                'bp-sdk-select__list-item-selected': this.isChosen(choice.id),
            }), role: "option", "aria-selected": (this.focusedIndex === i).toString(), tabindex: "1" }, this.renderChoice(choice))));
    }
    renderVisibleOptions() {
        return (index.h("ul", { class: index_esm_min.zh('bp-sdk-select__list', {
                'bp-sdk-visually-hidden': !this.showSelectList,
            }), "aria-expanded": this.showSelectList, role: "listbox", "aria-labelledby": this.labelId, tabindex: "-1", onBlur: this.onListBlur }, this.renderChoices()));
    }
    renderOptions() {
        return [this.renderHiddenOptions(), this.renderVisibleOptions()];
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-select-input", { answerId: this.answerId, autoComplete: this.autoComplete, choiceId: this.choiceId, choiceIds: this.choiceIds, choices: this.choices, code: this.code, errorText: this.errorText, errors: this.errors, fieldType: this.fieldType, helpText: this.helpText, answeredBySource: this.answeredBySource, isCompleted: this.isCompleted, isReadOnly: this.isReadOnly, labelId: this.labelId, label: this.label, labelledBy: this.labelledBy, multiple: this.multiple, placeholder: this.placeholder, pristine: this.pristine, questionId: this.questionId, required: this.required, touched: this.touched, useAlias: this.useAlias, value: this.value }));
    }
    renderInternal() {
        var _a;
        let input;
        if (this.isReadOnly) {
            const selectedIds = [this.choiceId, ...(this.choiceIds || [])];
            const selectedChoices = (this.choices || [])
                .filter((choice) => selectedIds.includes(choice.id))
                .map((choice) => this.choiceText(choice))
                .join(', ');
            input = this.renderReadOnlyElement(selectedChoices);
        }
        else {
            input = [this.renderSubmitButton(), this.renderOptions()];
        }
        return (index.h("div", { class: "bp-sdk-select__container", onKeyDown: this.onKeydown }, index.h("label", { id: this.labelId, htmlFor: this.selectButtonId, class: "bp-sdk-label bp-sdk-select__label", innerHTML: this.label }), input, this.touched && !this.pristine && ((this.errorText && !this.isCompleted) || !!((_a = this.errors) === null || _a === void 0 ? void 0 : _a.length)) && (index.h("bp-sdk-errors-container", { answerId: this.answerId, questionId: this.questionId, fieldType: this.fieldType, errors: this.errors, errorText: this.errorText }))));
    }
    renderReadOnlyElement(value) {
        return index.h("span", { class: "read-only-value" }, value);
    }
    get el() { return index.getElement(this); }
    static get watchers() { return {
        "labelId": ["onAriaLabelledByChange"],
        "labelledBy": ["onLabelledByChange"],
        "code": ["onCodeChange"],
        "choiceId": ["onChoiceIdChange"],
        "choiceIds": ["onChoiceIdsChange"],
        "showSelectList": ["onShowSelectListChange"],
        "_value": ["onValueChange"]
    }; }
};
BpSdkSelectInput.style = BpSdkSelectInputStyle0;

const bpSdkTextInputCss = "";
const BpSdkTextInputStyle0 = bpSdkTextInputCss;

const BpSdkTextInput = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.valueUpdate = index.createEvent(this, "valueUpdate", 7);
        this.onChange = () => {
            const input = this.el.querySelector('.bp-sdk-text__input');
            this.valueUpdate.emit(input.value);
        };
        this.answerId = undefined;
        this.autoComplete = undefined;
        this.questionId = undefined;
        this.text = undefined;
        this.labelId = undefined;
        this.fieldType = 'text';
        this.placeholder = '';
        this.pattern = undefined;
        this.code = undefined;
        this.required = false;
        this.min = -1;
        this.max = -1;
        this.errors = [];
        this.errorText = undefined;
        this.touched = false;
        this.pristine = true;
        this.isCompleted = false;
        this.isReadOnly = false;
        this.label = undefined;
        this.labelledBy = undefined;
        this.isEnabled = true;
        this.helpText = undefined;
        this.answeredBySource = undefined;
        this._labelledBy = undefined;
        this._pattern = '';
        this._fieldType = 'text';
        this.useExternal = false;
    }
    updatePattern(fieldType, pattern) {
        if (fieldType === index_esm_min$2.t.Number && !pattern) {
            pattern = '^\\d*';
        }
        else if (!pattern) {
            pattern = undefined;
        }
        this._pattern = pattern;
    }
    onAriaLabelledByChange(labelId) {
        this.updateLabelledBy(labelId, this.labelledBy);
    }
    onLabelledByChange(labelledBy) {
        this.updateLabelledBy(this.labelId, labelledBy);
    }
    updateLabelledBy(aria, ids) {
        const prefix = ids ? `${ids} ` : '';
        this._labelledBy = `${prefix}${aria !== null && aria !== void 0 ? aria : ''}` || undefined;
    }
    onFieldTypeChange(fieldType) {
        let type;
        if (fieldType === index_esm_min$2.t.Number) {
            type = 'tel';
        }
        else {
            type = fieldType !== null && fieldType !== void 0 ? fieldType : 'text';
        }
        this._fieldType = type;
        this.updatePattern(fieldType, this.pattern);
    }
    onPatternChange(pattern) {
        this.updatePattern(this.fieldType, pattern);
    }
    resetState() { }
    connectedCallback() {
        this.resetState();
    }
    handleExternalComponents() {
        this.useExternal = !!customElements.get('bp-sdk-external-text-input');
        customElements.whenDefined('bp-sdk-external-text-input').then(() => {
            this.useExternal = true;
        });
    }
    componentWillLoad() {
        this.handleExternalComponents();
        this.onFieldTypeChange(this.fieldType);
        this.onPatternChange(this.pattern);
        this.onAriaLabelledByChange(this.labelId);
        this.onLabelledByChange(this.labelledBy);
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderTextInput() {
        var _a, _b;
        return (index.h("input", { "aria-describedby": index_esm_min.Wh(index_esm_min.n$(this.errors)) || undefined, "aria-label": this.placeholder && !this.label ? this.placeholder : null, "aria-labelledby": this._labelledBy, autocomplete: this.autoComplete, class: "bp-sdk-text__input", disabled: !this.isEnabled, id: `bp-sdk-text-${this.labelId}__input-${this.answerId}`, maxLength: (_a = this.max) !== null && _a !== void 0 ? _a : -1, minLength: (_b = this.min) !== null && _b !== void 0 ? _b : -1, name: this.code, onChange: this.onChange, onInput: this.onChange, onPaste: this.onChange, pattern: this._pattern, placeholder: this.placeholder || '', required: this.required, type: this._fieldType, value: this.text }));
    }
    renderNumberInput() {
        var _a, _b;
        return (index.h("input", { "aria-describedby": index_esm_min.Wh(index_esm_min.n$(this.errors)) || undefined, "aria-label": this.placeholder && !this.label ? this.placeholder : null, "aria-labelledby": this._labelledBy, autocomplete: this.autoComplete, class: "bp-sdk-text__input", disabled: !this.isEnabled, id: `bp-sdk-text-${this.labelId}__input-${this.answerId}`, max: (_a = this.max) !== null && _a !== void 0 ? _a : Number.MAX_VALUE, min: (_b = this.min) !== null && _b !== void 0 ? _b : Number.MIN_VALUE, name: this.code, onChange: this.onChange, onInput: this.onChange, onPaste: this.onChange, pattern: this._pattern, placeholder: this.placeholder || '', required: this.required, type: this._fieldType, value: this.text }));
    }
    renderInputElement() {
        return this.fieldType === index_esm_min$2.t.Number ? this.renderNumberInput() : this.renderTextInput();
    }
    renderExternal() {
        return (index.h("bp-sdk-external-text-input", { answerId: this.answerId, autoComplete: this.autoComplete, code: this.code, errorText: this.errorText, errors: this.errors, fieldType: this.fieldType, helpText: this.helpText, answeredBySource: this.answeredBySource, isCompleted: this.isCompleted, isEnabled: this.isEnabled, isReadOnly: this.isReadOnly, labelId: this.labelId, label: this.label, labelledBy: this.labelledBy, max: this.max, min: this.min, pattern: this.pattern, placeholder: this.placeholder, pristine: this.pristine, questionId: this.questionId, readonly: this.isReadOnly, required: this.required, text: this.text, touched: this.touched }));
    }
    renderLabel() {
        return (this.label && (index.h("label", { id: this.labelId, htmlFor: `bp-sdk-text__${this.labelId}__input}-${this.answerId}`, class: "bp-sdk-label bp-sdk-text__label", innerHTML: this.label })));
    }
    renderErrors() {
        var _a;
        return (this.touched &&
            !this.pristine &&
            ((this.errorText && !this.isCompleted) || !!((_a = this.errors) === null || _a === void 0 ? void 0 : _a.length)) && (index.h("bp-sdk-errors-container", { questionId: this.questionId, fieldType: this.fieldType, pattern: this.pattern, min: this.min, max: this.max, errors: this.errors, errorText: this.errorText })));
    }
    renderInternal() {
        const element = this.isReadOnly ? this.renderReadOnlyElement(this.text) : this.renderInputElement();
        return (index.h("span", { class: "bp-sdk-text__container" }, this.renderLabel(), element, this.renderErrors()));
    }
    renderReadOnlyElement(value) {
        return index.h("span", { class: "read-only-value" }, value);
    }
    get el() { return index.getElement(this); }
    static get watchers() { return {
        "labelId": ["onAriaLabelledByChange"],
        "labelledBy": ["onLabelledByChange"],
        "fieldType": ["onFieldTypeChange"],
        "pattern": ["onPatternChange"]
    }; }
};
BpSdkTextInput.style = BpSdkTextInputStyle0;

const bpSdkTextInputContainerCss = "";
const BpSdkTextInputContainerStyle0 = bpSdkTextInputContainerCss;

const BpSdkTextInputContainer = class {
    constructor(hostRef) {
        index.registerInstance(this, hostRef);
        this.handleSubscriptions = () => {
            this.storeUnsubscribe && this.storeUnsubscribe();
            this.storeUnsubscribe = reduxStore_service.store.mapStateToProps(this, this.mapStateToProps);
        };
        this.mapStateToProps = (state) => {
            return {
                isAutocompleteEnabled: index_esm_min$1.tN(state),
            };
        };
        this.answerId = undefined;
        this.questionId = undefined;
        this.text = undefined;
        this.labelId = undefined;
        this.fieldType = 'text';
        this.placeholder = '';
        this.pattern = undefined;
        this.code = undefined;
        this.required = false;
        this.min = -1;
        this.max = -1;
        this.errors = [];
        this.errorText = undefined;
        this.touched = false;
        this.pristine = true;
        this.isCompleted = false;
        this.isReadOnly = false;
        this.label = undefined;
        this.labelledBy = undefined;
        this.isEnabled = true;
        this.referenceType = undefined;
        this.isAutocompleteEnabled = undefined;
        this.helpText = undefined;
        this.answeredBySource = undefined;
        this.autoComplete = undefined;
        this.useExternal = false;
        this._vinErrors = [];
    }
    resetState() {
        this._vinErrors = [];
    }
    connectedCallback() {
        this.resetState();
        this.handleSubscriptions();
    }
    componentWillLoad() {
        this.useExternal = !!customElements.get('bp-sdk-external-text-input-container');
        customElements.whenDefined('bp-sdk-external-text-input-container').then(() => {
            this.useExternal = true;
        });
        this.handleSubscriptions();
        this.updateAutocomplete({
            referenceType: this.referenceType,
            code: this.code,
            fieldType: this.fieldType,
            isAutocompleteEnabled: this.isAutocompleteEnabled,
        });
        this.onValueUpdate({
            detail: this.text,
        });
    }
    onValueUpdate(evt) {
        if (this.referenceType === index_esm_min$2.l.CommercialAutoVIN) {
            if (vehicleVin_service.VehicleVinService.isValidVin(evt.detail)) {
                this._vinErrors = [];
                this.errorText = undefined;
            }
            else {
                this.touched = true;
                this.pristine = false;
                this._vinErrors = [vehicleVin_service.VehicleVinService.getValidationErrorMessage(evt.detail)];
                this.errorText = vehicleVin_service.VehicleVinService.getValidationErrorMessage(evt.detail);
            }
        }
    }
    onReferenceTypeChange(referenceType) {
        this.updateAutocomplete({
            referenceType,
            code: this.code,
            fieldType: this.fieldType,
            isAutocompleteEnabled: this.isAutocompleteEnabled,
        });
    }
    onCodeChange(code) {
        this.updateAutocomplete({
            referenceType: this.referenceType,
            code,
            fieldType: this.fieldType,
            isAutocompleteEnabled: this.isAutocompleteEnabled,
        });
    }
    onFieldTypeChange(fieldType) {
        this.updateAutocomplete({
            referenceType: this.referenceType,
            code: this.code,
            fieldType,
            isAutocompleteEnabled: this.isAutocompleteEnabled,
        });
    }
    onIsAutocompleteEnabledChange(isAutocompleteEnabled) {
        this.updateAutocomplete({
            referenceType: this.referenceType,
            code: this.code,
            fieldType: this.fieldType,
            isAutocompleteEnabled,
        });
    }
    updateAutocomplete({ code, fieldType, referenceType, isAutocompleteEnabled, }) {
        this.autoComplete = isAutocompleteEnabled ? index_esm_min.hw({ referenceType, code, fieldType }) : undefined;
    }
    disconnectedCallback() {
        this.storeUnsubscribe && this.storeUnsubscribe();
    }
    render() {
        return [this.useExternal && this.renderExternal(), !this.useExternal && this.renderInternal()];
    }
    renderExternal() {
        return (index.h("bp-sdk-external-text-input-container", { answerId: this.answerId, code: this.code, errorText: this.errorText, errors: [...this._vinErrors, ...this.errors], fieldType: this.fieldType, helpText: this.helpText, answeredBySource: this.answeredBySource, isAutocompleteEnabled: this.isAutocompleteEnabled, isCompleted: this.isCompleted, isEnabled: this.isEnabled, isReadOnly: this.isReadOnly, labelId: this.labelId, label: this.label, labelledBy: this.labelledBy, max: this.max, min: this.min, pattern: this.pattern, placeholder: this.placeholder, pristine: this.pristine, questionId: this.questionId, referenceType: this.referenceType, required: this.required, text: this.text, touched: this.touched }));
    }
    renderInternal() {
        return [
            index.h("bp-sdk-text-input", { answerId: this.answerId, autoComplete: this.autoComplete, code: this.code, errorText: this.errorText, errors: [...this._vinErrors, ...this.errors], fieldType: this.fieldType, helpText: this.helpText, answeredBySource: this.answeredBySource, isCompleted: this.isCompleted, isEnabled: this.isEnabled, isReadOnly: this.isReadOnly, labelId: this.labelId, label: this.label, labelledBy: this.labelledBy, max: this.max, min: this.min, pattern: this.pattern, placeholder: this.placeholder, pristine: this.pristine, questionId: this.questionId, required: this.required, text: this.text, touched: this.touched }),
        ];
    }
    get el() { return index.getElement(this); }
    static get watchers() { return {
        "referenceType": ["onReferenceTypeChange"],
        "code": ["onCodeChange"],
        "fieldType": ["onFieldTypeChange"],
        "isAutocompleteEnabled": ["onIsAutocompleteEnabledChange"]
    }; }
};
BpSdkTextInputContainer.style = BpSdkTextInputContainerStyle0;

exports.bp_sdk_add_item_container = BpSdkAddItemContainer;
exports.bp_sdk_autocomplete_input = BpSdkAutocompleteInput;
exports.bp_sdk_business_classification_selector_card_body = BpSdkBusinessClassificationSelectorCardBody;
exports.bp_sdk_business_classification_selector_card_content = BpSdkBusinessClassificationSelectorCardContent;
exports.bp_sdk_business_classification_selector_card_header = BpSdkBusinessClassificationSelectorCardHeader;
exports.bp_sdk_business_classification_selector_list = BpSdkBusinessClassificationSelectorList;
exports.bp_sdk_business_classification_selector_list_container = BpSdkBusinessClassificationSelectorListContainer;
exports.bp_sdk_business_classification_selector_list_item = BpSdkBusinessClassificationSelectorListItem;
exports.bp_sdk_business_classification_selector_list_item_container = BpSdkBusinessClassificationSelectorListItemContainer;
exports.bp_sdk_business_classification_selector_naics_group = BpSdkBusinessClassificationSelectorNaicsGroup;
exports.bp_sdk_business_classification_selector_naics_group_header = BpSdkBusinessClassificationSelectorNaicsGroupHeader;
exports.bp_sdk_business_classification_selector_relevance_chip = BpSdkBusinessClassificationSelectorRelevanceChip;
exports.bp_sdk_delete_button = BpSdkDeleteButton;
exports.bp_sdk_dialog_close_button = BpSdkDialogCloseButton;
exports.bp_sdk_icon_container = BpSdkIconContainer;
exports.bp_sdk_masked_input_button = BpSdkMaskedInputButton;
exports.bp_sdk_parent_question_pool_selector = BpSdkParentQuestionPoolSelector;
exports.bp_sdk_select_input = BpSdkSelectInput;
exports.bp_sdk_text_input = BpSdkTextInput;
exports.bp_sdk_text_input_container = BpSdkTextInputContainer;
