"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDisplayOnlyFieldNames = exports.EditorLanguage = exports.InputDataType = exports.FormItemTransformation = exports.TooltipIconType = exports.DisplayUnsupportedState = exports.FormComponentType = exports.getRowItemsFromSectionItem = exports.isDropdownFormItem = exports.isFormItem = exports.FormSectionLayout = void 0;
var FormSectionLayout;
(function (FormSectionLayout) {
    FormSectionLayout["TABS"] = "TABS";
})(FormSectionLayout || (exports.FormSectionLayout = FormSectionLayout = {}));
const isFormItem = (item) => {
    return item.rowItems === undefined;
};
exports.isFormItem = isFormItem;
const isDropdownFormItem = (item) => {
    return (0, exports.isFormItem)(item) && item.componentType === FormComponentType.DROPDOWN;
};
exports.isDropdownFormItem = isDropdownFormItem;
const getRowItemsFromSectionItem = (sectionItem) => {
    const isRow = !(0, exports.isFormItem)(sectionItem);
    const rowItems = isRow ? sectionItem.rowItems : [sectionItem];
    return rowItems;
};
exports.getRowItemsFromSectionItem = getRowItemsFromSectionItem;
var FormComponentType;
(function (FormComponentType) {
    FormComponentType["ALERT"] = "ALERT";
    FormComponentType["INPUT_TEXT"] = "INPUT_TEXT";
    FormComponentType["INPUT_AREA"] = "INPUT_AREA";
    FormComponentType["DYNAMIC_INPUT_TEXT"] = "DYNAMIC_INPUT_TEXT";
    FormComponentType["CODE_EDITOR"] = "CODE_EDITOR";
    FormComponentType["FIELD_LIST"] = "FIELD_LIST";
    FormComponentType["FIELD_LIST_FORM"] = "FIELD_LIST_FORM";
    FormComponentType["DYNAMIC_FIELD_LIST"] = "DYNAMIC_FIELD_LIST";
    FormComponentType["DROPDOWN"] = "DROPDOWN";
    FormComponentType["DYNAMIC_DROPDOWN"] = "DYNAMIC_DROPDOWN";
    FormComponentType["METADATA_DROPDOWN"] = "METADATA_DROPDOWN";
    FormComponentType["CHECKBOX"] = "CHECKBOX";
    FormComponentType["SWITCH"] = "SWITCH";
    FormComponentType["RADIO"] = "RADIO";
    FormComponentType["PRIMARY_KEY_DISPLAY"] = "PRIMARY_KEY_DISPLAY";
    FormComponentType["KEY_MAPPING"] = "KEY_MAPPING";
    FormComponentType["FILTER_COLUMNS"] = "FILTER_COLUMNS";
    FormComponentType["SQL_PREVIEW"] = "SQL_PREVIEW";
    FormComponentType["SQL_PREVIEW_WITH_INSERT_DELETE"] = "SQL_PREVIEW_WITH_INSERT_DELETE";
    // for openAPI
    FormComponentType["OPENAPI_ACTION_DROPDOWN"] = "OPENAPI_ACTION_DROPDOWN";
    // enable the dynamic text to autocomplete with a set of options from metadata
    FormComponentType["DYNAMIC_INPUT_WITH_METADATA_OPTIONS"] = "DYNAMIC_INPUT_WITH_METADATA_OPTIONS";
    // combines base url and relative path
    FormComponentType["URL_INPUT_TEXT"] = "URL_INPUT_TEXT";
    FormComponentType["BUTTON"] = "BUTTON";
    FormComponentType["ONEOF_ACTION_DROPDOWN"] = "ONEOF_ACTION_DROPDOWN";
    FormComponentType["COPY_BOX"] = "COPY_BOX";
})(FormComponentType || (exports.FormComponentType = FormComponentType = {}));
var DisplayUnsupportedState;
(function (DisplayUnsupportedState) {
    // TODO(taha) We can potentially add mixed states
    // for when incompatibilty occurs due to a not yet
    // supported field vs a deprecated field
    DisplayUnsupportedState["HIDE"] = "hide";
    DisplayUnsupportedState["DISABLE"] = "disable";
})(DisplayUnsupportedState || (exports.DisplayUnsupportedState = DisplayUnsupportedState = {}));
var TooltipIconType;
(function (TooltipIconType) {
    TooltipIconType["WARNING"] = "warning";
    TooltipIconType["INFO"] = "info";
})(TooltipIconType || (exports.TooltipIconType = TooltipIconType = {}));
var FormItemTransformation;
(function (FormItemTransformation) {
    FormItemTransformation["BYTE_ARRAY"] = "BYTE_ARRAY";
})(FormItemTransformation || (exports.FormItemTransformation = FormItemTransformation = {}));
var InputDataType;
(function (InputDataType) {
    InputDataType["NUMBER"] = "NUMBER";
    InputDataType["PASSWORD"] = "PASSWORD";
})(InputDataType || (exports.InputDataType = InputDataType = {}));
var EditorLanguage;
(function (EditorLanguage) {
    EditorLanguage["TEXT"] = "TEXT";
    EditorLanguage["SQL"] = "SQL";
    EditorLanguage["JSON"] = "JSON";
    EditorLanguage["JAVASCRIPT"] = "JAVASCRIPT";
    EditorLanguage["PYTHON"] = "PYTHON";
})(EditorLanguage || (exports.EditorLanguage = EditorLanguage = {}));
const DISPLAY_ONLY_COMPONENT_TYPES = new Set([FormComponentType.ALERT, FormComponentType.BUTTON]);
/**
 * Returns the set of field names from a form template that are display-only
 * and should not be persisted. This includes ALERT and BUTTON components
 * (which render informational banners or action triggers) and disabled
 * immutable fields (e.g. the OAuth callback URL display).
 */
const getDisplayOnlyFieldNames = (template) => {
    const names = new Set();
    for (const section of template.sections) {
        for (const sectionItem of section.items) {
            for (const item of (0, exports.getRowItemsFromSectionItem)(sectionItem)) {
                if (DISPLAY_ONLY_COMPONENT_TYPES.has(item.componentType) || (item.disabled && item.immutable)) {
                    names.add(item.name);
                }
            }
        }
    }
    return names;
};
exports.getDisplayOnlyFieldNames = getDisplayOnlyFieldNames;
//# sourceMappingURL=form.js.map