"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getDefaultAdaptableOptions = exports.applyDefaultAdaptableOptions = void 0;
const tslib_1 = require("tslib");
const GeneralConstants = tslib_1.__importStar(require("../Utilities/Constants/GeneralConstants"));
const UIHelper_1 = tslib_1.__importStar(require("../View/UIHelper"));
const GeneralConstants_1 = require("../Utilities/Constants/GeneralConstants");
const AdaptablePredicate_1 = require("../AdaptableState/Common/AdaptablePredicate");
const ModuleConstants = tslib_1.__importStar(require("../Utilities/Constants/ModuleConstants"));
const AdaptableHelper_1 = require("../Utilities/Helpers/AdaptableHelper");
const DefaultAdaptableOptions = {
    adaptableId: GeneralConstants.ADAPTABLE_ID,
    adaptableStateKey: undefined,
    primaryKey: GeneralConstants_1.EMPTY_STRING,
    autogeneratePrimaryKey: false,
    userName: 'anonymous',
    initialState: undefined,
    adaptableContext: {},
    actionColumnOptions: {
        actionColumns: undefined,
    },
    alertOptions: {
        alertForms: undefined,
        maxAlertsInStore: 20,
        cellHighlightDuration: 2000,
        rowHighlightDuration: 4000,
        statusbarHighlightDuration: 2000,
        dataChangeDetectionPolicy: 'rawValue',
        commandHandlers: undefined,
        alertMessageText: undefined,
        showMissingPrimaryKeyAlert: false,
    },
    calendarOptions: { holidays: undefined },
    cellSummaryOptions: {
        customCellSummaryOperations: undefined,
        numericDisplayFormat: {
            FractionDigits: 2,
        },
    },
    chartingOptions: {
        saveChartBehaviour: 'none',
        agGridContainerName: GeneralConstants.AG_GRID_CHART_WINDOW,
        externalChartingOptions: {},
    },
    columnOptions: {
        columnFriendlyName: undefined,
        columnTypes: GeneralConstants_1.EMPTY_ARRAY,
        showMissingColumnsWarning: true,
        addColumnGroupToColumnFriendlyName: false,
    },
    columnMenuOptions: {
        customColumnMenu: undefined,
    },
    commentOptions: {
        showPopupCloseButton: true,
        dateFormat: GeneralConstants_1.DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME,
    },
    containerOptions: {
        adaptableContainer: 'adaptable',
        agGridContainer: 'grid',
        modalContainer: undefined,
        systemStatusContainer: undefined,
        alertContainer: undefined,
    },
    contextMenuOptions: {
        customContextMenu: undefined,
    },
    customSortOptions: { customSortComparers: undefined },
    dashboardOptions: {
        canFloat: true,
        showQuickSearchInHeader: true,
        customDashboardButtons: undefined,
        customToolbars: undefined,
        buttonsLocation: 'right',
    },
    dataChangeHistoryOptions: {
        activeByDefault: false,
        showDataChange: undefined,
        changeHistoryButton: undefined,
        showLastDataChangeOnly: true,
    },
    dataImportOptions: {
        fileHandlers: undefined,
    },
    dataSetOptions: { dataSets: GeneralConstants_1.EMPTY_ARRAY },
    editOptions: {
        validateOnServer: undefined,
        displayServerValidationMessages: true,
        isCellEditable: undefined,
        smartEditCustomOperations: undefined,
        customEditColumnValues: undefined,
    },
    entitlementOptions: {
        defaultAccessLevel: 'Full',
        moduleEntitlements: undefined,
    },
    exportOptions: {
        exportDataFormat: 'rawValue',
        exportDateFormat: undefined,
        customDestinations: undefined,
        processExport: undefined,
        appendFileTimestamp: false,
        systemReportNames: GeneralConstants_1.SYSTEM_REPORT_NAMES,
        systemReportFormats: GeneralConstants_1.SYSTEM_REPORT_FORMATS,
        systemExportDestinations: GeneralConstants_1.SYSTEM_EXPORT_DESTINATIONS,
        reportFilename: undefined,
        csvSeparator: ',',
        skipColumnHeaders: false,
    },
    expressionOptions: {
        evaluateAdaptableQLExternally: undefined,
        displayColumnFriendlyNamesForExpressions: true,
        systemBooleanFunctions: undefined,
        systemScalarFunctions: undefined,
        systemObservableFunctions: undefined,
        systemAggregatedBooleanFunctions: undefined,
        systemAggregatedScalarFunctions: undefined,
        moduleExpressionFunctions: undefined,
        performExpressionValidation: true,
        maxTimeframeSize: 28800000, // 8 hours
        caseSensitiveExpressions: false,
    },
    fdc3Options: {
        enableLogging: false,
        actionColumnDefaultConfiguration: {
            columnId: 'fdc3ActionColumn',
            headerName: 'FDC3 Actions',
            width: 200,
            resizable: true,
            movable: false,
            rowScope: {
                ExcludeDataRows: false,
                ExcludeGroupRows: true,
                ExcludeSummaryRows: true,
            },
        },
        uiControlsDefaultConfiguration: {
            // default config is set in FDC3 Service, to make it easier to overview
            contexts: {},
            intents: {},
        },
    },
    filterOptions: {
        filterActionOnDataChange: {
            applyFilter: 'Always',
            throttleDelay: 0,
        },
        clearFiltersOnStartUp: false,
        enableFilterOnSpecialColumns: true,
        useAdaptableFiltering: true,
        showDatePicker: true,
        columnFilterOptions: {
            indicateFilteredColumns: true,
            autoApplyColumnFilter: true,
            defaultNumericColumnFilter: 'Equals',
            defaultTextColumnFilter: 'Contains',
            defaultDateColumnFilter: 'On',
            hideQuickFilterDropdown: undefined,
            hideQuickFilterInput: undefined,
            quickFilterDebounce: 250,
            quickFilterHeight: null,
            showQuickFilter: true,
            quickFilterWildcards: {},
        },
        gridFilterOptions: {
            availableFilterEditors: ['ExpressionEditor', 'QueryBuilder'],
        },
    },
    flashingCellOptions: {
        defaultFlashDuration: 500,
        defaultFlashTarget: 'cell',
        defaultDownChangeStyle: {
            BackColor: (0, UIHelper_1.getHexForName)(UIHelper_1.RED),
        },
        defaultUpChangeStyle: {
            BackColor: (0, UIHelper_1.getHexForName)(UIHelper_1.GREEN),
        },
        defaultNeutralChangeStyle: {
            BackColor: (0, UIHelper_1.getHexForName)(UIHelper_1.GRAY),
        },
    },
    formatColumnOptions: {
        customDisplayFormatters: undefined,
    },
    layoutOptions: {
        layoutViewOptions: {
            maxColumnsToDisplay: 10,
        },
        layoutTagOptions: {
            autoGenerateTagsForLayouts: false,
            isObjectAvailableInLayout: undefined,
            autoCheckTagsForLayouts: false,
        },
    },
    noteOptions: {
        showPopupCloseButton: true,
        dateFormat: GeneralConstants_1.DEFAULT_DATE_FORMAT_PATTERN_WITH_TIME,
    },
    notificationsOptions: {
        maxNotifications: 3,
        position: 'BottomRight',
        duration: 3000,
        showProgressBar: false,
        closeWhenClicked: false,
        pauseWhenHovering: false,
        isDraggable: false,
        transition: 'Slide',
        showApplicationIcon: false,
        showSystemStatusMessageNotifications: false,
        maxSystemMessagesInStore: 100,
    },
    predicateOptions: {
        customPredicateDefs: [],
        systemFilterPredicates: AdaptablePredicate_1.SystemFilterPredicateIds,
        systemAlertPredicates: AdaptablePredicate_1.SystemAlertPredicateIds,
        systemFormatColumnPredicates: AdaptablePredicate_1.SystemFormatColumnPredicateIds,
        systemFlashingCellPredicates: AdaptablePredicate_1.SystemFlashingCellPredicateIds,
        systemBadgeStylePredicates: AdaptablePredicate_1.SystemBadgeStylePredicateIds,
        caseSensitivePredicates: false,
        evaluateValuesPredicateUsingTime: true,
    },
    quickSearchOptions: {
        clearQuickSearchOnStartUp: false,
        quickSearchPlaceholder: 'Search',
        filterGridAfterQuickSearch: false,
        isQuickSearchCaseSensitive: false,
        runCustomQuickSearch: undefined,
    },
    rowFormOptions: {
        autoHandle: true,
        disableInlineEditing: false,
        setPrimaryKeyValue: undefined,
        rowFormTitle: undefined,
        rowFormDescription: undefined,
        rowFormFieldLabel: undefined,
        rowFormButtons: undefined,
        onRowFormSubmit: undefined,
        includeColumnInRowForm: undefined,
    },
    settingsPanelOptions: {
        popupType: 'modal',
        title: ModuleConstants.SettingsPanelFriendlyName,
        icon: 'ConfigurationIcon',
        navigation: {},
        alwaysShowInDashboard: false,
        alwaysShowInToolPanel: false,
        showModuleIcons: true,
    },
    stateOptions: {
        debounceStateDelay: 400,
        applyState: (state) => state,
        saveState: (state) => state,
        loadState: undefined,
        persistState: undefined,
        clearState: undefined,
        autoMigrateState: true,
    },
    teamSharingOptions: {
        enableTeamSharing: false,
        persistSharedEntities: undefined,
        loadSharedEntities: undefined,
        applySharedEntities: (sharedEntities) => sharedEntities,
        saveSharedEntities: (sharedEntities) => sharedEntities,
        updateInterval: 0,
        updateNotification: undefined,
        suppressOverrideConfigWarning: false,
        showUpdateNotificationOncePerUpdate: false,
    },
    toolPanelOptions: {
        showToolPanelsDropdown: true,
        customButtons: undefined,
        customToolPanels: undefined,
    },
    userInterfaceOptions: {
        alternativeModuleNames: undefined,
        applicationIcon: undefined,
        useCustomMacLikeScrollbars: false,
        loadingScreenOptions: {
            showLoadingScreen: true,
            loadingScreenDelay: 200,
            loadingScreenTitle: 'Initialising Grid',
            loadingScreenText: 'Retrieving your settings and setting up the grid...',
        },
        englishVariant: 'GB',
        disableDeleteConfirmation: false,
        dateInputOptions: {
            useNativeInput: false,
            dateFormat: 'yyyy-MM-dd',
            // locale is not explicitly defaulted to 'en-US' as this is already done by the react-day-picker
            showWeekNumber: false,
            showOutsideDays: true,
            datepickerButtons: ['close', 'today'],
        },
        colorPalette: UIHelper_1.default.getDefaultColors(),
        editableCellStyle: undefined,
        readOnlyCellStyle: undefined,
        editedCellStyle: undefined,
        styleClassNames: GeneralConstants_1.EMPTY_ARRAY,
        showDocumentationLinks: true,
        showAdapTableVersion: true,
        showAgGridVersion: true,
    },
};
function applyDefaultAdaptableOptions(adaptableOptions) {
    const adaptableOptsWithDefaults = Object.assign({}, DefaultAdaptableOptions, adaptableOptions);
    adaptableOptsWithDefaults.adaptableStateKey =
        adaptableOptsWithDefaults.adaptableStateKey ?? adaptableOptsWithDefaults.adaptableId;
    // action column options
    adaptableOptsWithDefaults.actionColumnOptions = Object.assign({}, DefaultAdaptableOptions.actionColumnOptions, adaptableOptions.actionColumnOptions);
    // action column options
    adaptableOptsWithDefaults.rowFormOptions = Object.assign({}, DefaultAdaptableOptions.rowFormOptions, adaptableOptions.rowFormOptions);
    // alert options
    adaptableOptsWithDefaults.alertOptions = Object.assign({}, DefaultAdaptableOptions.alertOptions, adaptableOptions.alertOptions);
    // calendar options
    adaptableOptsWithDefaults.calendarOptions = Object.assign({}, DefaultAdaptableOptions.calendarOptions, adaptableOptions.calendarOptions);
    // cell summary options
    adaptableOptsWithDefaults.cellSummaryOptions = Object.assign({}, DefaultAdaptableOptions.cellSummaryOptions, adaptableOptions.cellSummaryOptions);
    // charting options
    adaptableOptsWithDefaults.chartingOptions = Object.assign({}, DefaultAdaptableOptions.chartingOptions, adaptableOptions.chartingOptions);
    adaptableOptsWithDefaults.chartingOptions.externalChartingOptions = Object.assign({}, DefaultAdaptableOptions.chartingOptions.externalChartingOptions, adaptableOptsWithDefaults.chartingOptions.externalChartingOptions);
    // column options
    adaptableOptsWithDefaults.columnOptions = Object.assign({}, DefaultAdaptableOptions.columnOptions, adaptableOptions.columnOptions);
    // TEMP filter options
    adaptableOptsWithDefaults.filterOptions = Object.assign({}, DefaultAdaptableOptions.filterOptions, adaptableOptions.filterOptions);
    adaptableOptsWithDefaults.filterOptions.columnFilterOptions = Object.assign({}, DefaultAdaptableOptions.filterOptions.columnFilterOptions, adaptableOptsWithDefaults.filterOptions.columnFilterOptions);
    adaptableOptsWithDefaults.filterOptions.gridFilterOptions = Object.assign({}, DefaultAdaptableOptions.filterOptions.gridFilterOptions, adaptableOptsWithDefaults.filterOptions.gridFilterOptions);
    // column menu options
    adaptableOptsWithDefaults.columnMenuOptions = Object.assign({}, DefaultAdaptableOptions.columnMenuOptions, adaptableOptions.columnMenuOptions);
    // comment options
    adaptableOptsWithDefaults.commentOptions = Object.assign({}, DefaultAdaptableOptions.commentOptions, adaptableOptions.commentOptions);
    // container options
    adaptableOptsWithDefaults.containerOptions = Object.assign({}, DefaultAdaptableOptions.containerOptions, adaptableOptions.containerOptions);
    // context menu options
    adaptableOptsWithDefaults.contextMenuOptions = Object.assign({}, DefaultAdaptableOptions.contextMenuOptions, adaptableOptions.contextMenuOptions);
    // custom sort options
    adaptableOptsWithDefaults.customSortOptions = Object.assign({}, DefaultAdaptableOptions.customSortOptions, adaptableOptions.customSortOptions);
    // dashboard options
    adaptableOptsWithDefaults.dashboardOptions = Object.assign({}, DefaultAdaptableOptions.dashboardOptions, adaptableOptions.dashboardOptions);
    // data import options
    adaptableOptsWithDefaults.dataImportOptions = Object.assign({}, DefaultAdaptableOptions.dataImportOptions, adaptableOptions.dataImportOptions);
    // data change history options
    adaptableOptsWithDefaults.dataChangeHistoryOptions = Object.assign({}, DefaultAdaptableOptions.dataChangeHistoryOptions, adaptableOptions.dataChangeHistoryOptions);
    // data set options
    adaptableOptsWithDefaults.dataSetOptions = Object.assign({}, DefaultAdaptableOptions.dataSetOptions, adaptableOptions.dataSetOptions);
    // edit options
    adaptableOptsWithDefaults.editOptions = Object.assign({}, DefaultAdaptableOptions.editOptions, adaptableOptions.editOptions);
    // entitlement options
    adaptableOptsWithDefaults.entitlementOptions = Object.assign({}, DefaultAdaptableOptions.entitlementOptions, adaptableOptions.entitlementOptions);
    // export options
    adaptableOptsWithDefaults.exportOptions = Object.assign({}, DefaultAdaptableOptions.exportOptions, adaptableOptions.exportOptions);
    // expression options
    adaptableOptsWithDefaults.expressionOptions = Object.assign({}, DefaultAdaptableOptions.expressionOptions, adaptableOptions.expressionOptions);
    // fdc3 options
    adaptableOptsWithDefaults.fdc3Options = Object.assign({}, DefaultAdaptableOptions.fdc3Options, adaptableOptions.fdc3Options);
    adaptableOptsWithDefaults.fdc3Options.actionColumnDefaultConfiguration = Object.assign({}, DefaultAdaptableOptions.fdc3Options.actionColumnDefaultConfiguration, adaptableOptsWithDefaults.fdc3Options.actionColumnDefaultConfiguration);
    adaptableOptsWithDefaults.fdc3Options.uiControlsDefaultConfiguration = Object.assign({}, DefaultAdaptableOptions.fdc3Options.uiControlsDefaultConfiguration, adaptableOptsWithDefaults.fdc3Options.uiControlsDefaultConfiguration);
    // flashing cell options
    adaptableOptsWithDefaults.flashingCellOptions = Object.assign({}, DefaultAdaptableOptions.flashingCellOptions, adaptableOptions.flashingCellOptions);
    // format column options
    adaptableOptsWithDefaults.formatColumnOptions = Object.assign({}, DefaultAdaptableOptions.formatColumnOptions, adaptableOptions.formatColumnOptions);
    // layout options
    adaptableOptsWithDefaults.layoutOptions = Object.assign({}, DefaultAdaptableOptions.layoutOptions, adaptableOptions.layoutOptions);
    adaptableOptsWithDefaults.layoutOptions.layoutTagOptions = Object.assign({}, DefaultAdaptableOptions.layoutOptions.layoutTagOptions, adaptableOptsWithDefaults.layoutOptions.layoutTagOptions);
    adaptableOptsWithDefaults.layoutOptions.layoutViewOptions = Object.assign({}, DefaultAdaptableOptions.layoutOptions.layoutViewOptions, adaptableOptsWithDefaults.layoutOptions.layoutViewOptions);
    // note options
    adaptableOptsWithDefaults.noteOptions = Object.assign({}, DefaultAdaptableOptions.noteOptions, adaptableOptions.noteOptions);
    // notification options
    adaptableOptsWithDefaults.notificationsOptions = Object.assign({}, DefaultAdaptableOptions.notificationsOptions, adaptableOptions.notificationsOptions);
    // predicate options
    adaptableOptsWithDefaults.predicateOptions = Object.assign({}, DefaultAdaptableOptions.predicateOptions, adaptableOptsWithDefaults.predicateOptions);
    // quick search options
    adaptableOptsWithDefaults.quickSearchOptions = Object.assign({}, DefaultAdaptableOptions.quickSearchOptions, adaptableOptions.quickSearchOptions);
    // settings panel options
    adaptableOptsWithDefaults.settingsPanelOptions = Object.assign({}, DefaultAdaptableOptions.settingsPanelOptions, adaptableOptions.settingsPanelOptions);
    // state optoins
    adaptableOptsWithDefaults.stateOptions = Object.assign({}, DefaultAdaptableOptions.stateOptions, adaptableOptions.stateOptions);
    // team sharing options
    adaptableOptsWithDefaults.teamSharingOptions = Object.assign({}, DefaultAdaptableOptions.teamSharingOptions, adaptableOptions.teamSharingOptions);
    // tool panel
    adaptableOptsWithDefaults.toolPanelOptions = Object.assign({}, DefaultAdaptableOptions.toolPanelOptions, adaptableOptions.toolPanelOptions);
    // user interface options
    adaptableOptsWithDefaults.userInterfaceOptions = Object.assign({}, DefaultAdaptableOptions.userInterfaceOptions, adaptableOptions.userInterfaceOptions);
    adaptableOptsWithDefaults.userInterfaceOptions.loadingScreenOptions = Object.assign({}, DefaultAdaptableOptions.userInterfaceOptions.loadingScreenOptions, adaptableOptsWithDefaults.userInterfaceOptions.loadingScreenOptions);
    adaptableOptsWithDefaults.userInterfaceOptions.dateInputOptions = Object.assign({}, DefaultAdaptableOptions.userInterfaceOptions.dateInputOptions, adaptableOptsWithDefaults.userInterfaceOptions.dateInputOptions);
    const { initialState } = adaptableOptsWithDefaults;
    adaptableOptsWithDefaults.initialState = (0, AdaptableHelper_1.addUuidsToInitialState)(initialState);
    return adaptableOptsWithDefaults;
}
exports.applyDefaultAdaptableOptions = applyDefaultAdaptableOptions;
const getDefaultAdaptableOptions = () => DefaultAdaptableOptions;
exports.getDefaultAdaptableOptions = getDefaultAdaptableOptions;
