"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ObjectFactory = void 0;
exports.CreateEmptyCustomSort = CreateEmptyCustomSort;
exports.CreateAdaptableComment = CreateAdaptableComment;
exports.CreateEmptyCalculatedColumn = CreateEmptyCalculatedColumn;
exports.CreateEmptyNamedQuery = CreateEmptyNamedQuery;
exports.CreateEmptyPlusMinusNudge = CreateEmptyPlusMinusNudge;
exports.CreateGenericAlert = CreateGenericAlert;
exports.CreateCellChangedAlert = CreateCellChangedAlert;
exports.CreateRowChangedAlert = CreateRowChangedAlert;
exports.CreateEmptyAlertDefinition = CreateEmptyAlertDefinition;
exports.CreateEmptyFlashingCellDefinition = CreateEmptyFlashingCellDefinition;
exports.CreateInternalAlertDefinitionForMessages = CreateInternalAlertDefinitionForMessages;
exports.CreateEmptyReport = CreateEmptyReport;
exports.CreateEmptyBaseSchedule = CreateEmptyBaseSchedule;
exports.CreateEmptyReminderSchedule = CreateEmptyReminderSchedule;
exports.CreateEmptyReportSchedule = CreateEmptyReportSchedule;
exports.CreateEmptyIPushPullReport = CreateEmptyIPushPullReport;
exports.CreateEmptyOpenFinReport = CreateEmptyOpenFinReport;
exports.CreateEmptyIPushPullSchedule = CreateEmptyIPushPullSchedule;
exports.CreateEmptyOpenFinSchedule = CreateEmptyOpenFinSchedule;
exports.CreateIPushPullSchedule = CreateIPushPullSchedule;
exports.CreateReportSchedule = CreateReportSchedule;
exports.CreateEmptySchedule = CreateEmptySchedule;
exports.CreateEmptyShortcut = CreateEmptyShortcut;
exports.CreateEmptyFormatColumn = CreateEmptyFormatColumn;
exports.CreateEmptyFreeTextColumn = CreateEmptyFreeTextColumn;
exports.CreateEmptyPivotLayout = CreateEmptyPivotLayout;
exports.CreateEmptyTableLayout = CreateEmptyTableLayout;
exports.CreateEmptyLayout = CreateEmptyLayout;
exports.CreateEmptyStyle = CreateEmptyStyle;
exports.CreateSystemStatusMessageInfo = CreateSystemStatusMessageInfo;
exports.CreateEmptyCellSummmary = CreateEmptyCellSummmary;
exports.CreateColumnFilter = CreateColumnFilter;
exports.CreateEmptyStyledColumn = CreateEmptyStyledColumn;
exports.CreateDefaultStyledColumnBadge = CreateDefaultStyledColumnBadge;
exports.CreateEmptyChartDefinition = CreateEmptyChartDefinition;
exports.CreateCustomDisplayFormatterContext = CreateCustomDisplayFormatterContext;
exports.CreateEmptyTheme = CreateEmptyTheme;
exports.CreateEmptyCommentThread = CreateEmptyCommentThread;
exports.CreateToastOptions = CreateToastOptions;
const Enums_1 = require("../AdaptableState/Common/Enums");
const Uuid_1 = require("../AdaptableState/Uuid");
const GeneralConstants_1 = require("./Constants/GeneralConstants");
const ObjectDefaultConstants_1 = require("./Constants/ObjectDefaultConstants");
const Toastify_1 = require("../components/Toastify");
const UIHelper_1 = require("../View/UIHelper");
const LayoutHelpers_1 = require("../Api/Implementation/LayoutHelpers");
function CreateEmptyCustomSort() {
    return { Uuid: (0, Uuid_1.createUuid)(), Name: GeneralConstants_1.EMPTY_STRING, ColumnId: GeneralConstants_1.EMPTY_STRING, SortedValues: [] };
}
function CreateAdaptableComment(text, api) {
    const comment = {
        Value: text,
        AdaptableId: api.optionsApi.getAdaptableId(),
        Author: {
            UserName: api.optionsApi.getUserName(),
        },
        Timestamp: Date.now(),
        Uuid: (0, Uuid_1.createUuid)(),
    };
    return comment;
}
function CreateEmptyCalculatedColumn(defaultSpecialColumnSettings) {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        ColumnId: GeneralConstants_1.EMPTY_STRING,
        Query: {
            ScalarExpression: GeneralConstants_1.EMPTY_STRING,
        },
        // need to create some defaults - which we will change later
        CalculatedColumnSettings: {
            ...defaultSpecialColumnSettings,
            DataType: undefined,
        },
    };
}
function CreateEmptyNamedQuery(expression) {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        BooleanExpression: expression || GeneralConstants_1.EMPTY_STRING,
    };
}
function CreateEmptyPlusMinusNudge() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        Scope: undefined,
        Rule: undefined,
        NudgeValue: ObjectDefaultConstants_1.PLUS_MINUS_DEFAULT_NUDGE_VALUE,
    };
}
function CreateGenericAlert(alertHeader, alertMessage, alertDefinition) {
    return {
        alertType: 'generic',
        Uuid: (0, Uuid_1.createUuid)(),
        header: alertHeader,
        message: alertMessage,
        alertDefinition: alertDefinition,
    };
}
function CreateCellChangedAlert(alertHeader, alertMessage, alertDefinition, cellDataChangedInfo) {
    return {
        alertType: 'cellChanged',
        Uuid: (0, Uuid_1.createUuid)(),
        header: alertHeader,
        message: alertMessage,
        alertDefinition,
        cellDataChangedInfo: cellDataChangedInfo,
    };
}
function CreateRowChangedAlert(alertHeader, alertMessage, alertDefinition, rowDataChangedInfo) {
    return {
        alertType: 'rowChanged',
        Uuid: (0, Uuid_1.createUuid)(),
        header: alertHeader,
        message: alertMessage,
        alertDefinition,
        rowDataChangedInfo: rowDataChangedInfo,
    };
}
function CreateEmptyAlertDefinition() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        Scope: { All: true },
        Rule: {
            Predicates: [],
        },
        MessageType: ObjectDefaultConstants_1.ALERT_DEFAULT_MESSAGE_TYPE,
        AlertProperties: {},
    };
}
function CreateEmptyFlashingCellDefinition() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        Scope: { ColumnIds: [] },
        Rule: {
            Predicates: [
                {
                    PredicateId: 'AnyChange',
                },
            ],
        },
    };
}
function CreateInternalAlertDefinitionForMessages(messageType, alertProperties) {
    alertProperties = alertProperties ?? {
        DisplayNotification: ObjectDefaultConstants_1.ALERT_DEFAULT_SHOW_POPUP,
    };
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        Scope: undefined,
        Rule: {
            Predicates: [],
        },
        MessageType: messageType,
        AlertProperties: alertProperties,
    };
}
function CreateEmptyReport() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        Scope: undefined,
        ReportColumnScope: 'AllColumns',
        ReportRowScope: 'AllRows',
        Query: undefined,
    };
}
function CreateEmptyBaseSchedule(scheduleType) {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        ScheduleType: scheduleType,
        Schedule: CreateEmptySchedule(),
    };
}
function CreateEmptyReminderSchedule() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        ScheduleType: Enums_1.ScheduleType.Reminder,
        Schedule: CreateEmptySchedule(),
        Header: GeneralConstants_1.EMPTY_STRING,
        Message: GeneralConstants_1.EMPTY_STRING,
        MessageType: 'Info',
        DisplayNotification: true,
        DisplaySystemStatusMessage: false,
    };
}
function CreateEmptyReportSchedule() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        ScheduleType: Enums_1.ScheduleType.Report,
        Schedule: CreateEmptySchedule(),
        ReportName: GeneralConstants_1.EMPTY_STRING,
        ReportFormat: GeneralConstants_1.EMPTY_STRING,
        ExportDestination: 'Download',
    };
}
function CreateEmptyIPushPullReport() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        ReportName: GeneralConstants_1.EMPTY_STRING,
        Folder: GeneralConstants_1.EMPTY_STRING,
        Page: GeneralConstants_1.EMPTY_STRING,
    };
}
function CreateEmptyOpenFinReport() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        ReportName: GeneralConstants_1.EMPTY_STRING,
    };
}
function CreateEmptyIPushPullSchedule() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        ScheduleType: Enums_1.ScheduleType.ipushpull,
        Schedule: CreateEmptySchedule(),
        IPushPullReport: CreateEmptyIPushPullReport(),
        Transmission: 'Snapshot',
    };
}
function CreateEmptyOpenFinSchedule() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        ScheduleType: Enums_1.ScheduleType.OpenFin,
        Schedule: CreateEmptySchedule(),
        OpenFinReport: CreateEmptyOpenFinReport(),
        Transmission: 'Live Data',
    };
}
function CreateIPushPullSchedule(iPushPullReport) {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        ScheduleType: Enums_1.ScheduleType.ipushpull,
        Schedule: CreateEmptySchedule(),
        IPushPullReport: iPushPullReport,
        Transmission: 'Snapshot',
    };
}
function CreateReportSchedule(reportName, reportFormat) {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        ScheduleType: Enums_1.ScheduleType.Report,
        Schedule: CreateEmptySchedule(),
        ReportName: reportName,
        ReportFormat: reportFormat,
    };
}
function CreateEmptySchedule() {
    return {
        OneOffDate: undefined,
        DaysOfWeek: [],
        Hour: 0,
        Minute: 0,
    };
}
function CreateEmptyShortcut() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        Scope: undefined,
        ShortcutKey: GeneralConstants_1.EMPTY_STRING,
        ShortcutValue: undefined,
        ShortcutOperation: Enums_1.MathOperation.Multiply,
    };
}
function CreateEmptyFormatColumn() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: GeneralConstants_1.EMPTY_STRING,
        Scope: undefined,
        Style: CreateEmptyStyle(),
        DisplayFormat: undefined,
        RowScope: undefined,
        Target: 'cell',
    };
}
function CreateEmptyFreeTextColumn(defaultSpecialColumnSettings) {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        ColumnId: GeneralConstants_1.EMPTY_STRING,
        DefaultValue: GeneralConstants_1.EMPTY_STRING,
        FreeTextStoredValues: [],
        TextEditor: 'Inline',
        FreeTextColumnSettings: {
            ...defaultSpecialColumnSettings,
            DataType: 'text',
        },
    };
}
function CreateEmptyPivotLayout(pivotLayout) {
    const result = {
        ...pivotLayout,
        Uuid: (0, Uuid_1.createUuid)(),
        ColumnSizing: pivotLayout.ColumnSizing || {},
        ColumnHeaders: pivotLayout.ColumnHeaders || {},
        ColumnPinning: pivotLayout.ColumnPinning || {},
        ColumnSorts: pivotLayout.ColumnSorts || [],
        ColumnFilters: pivotLayout.ColumnFilters || [],
        PivotColumns: pivotLayout.PivotColumns || [],
        PivotAggregationColumns: pivotLayout.PivotAggregationColumns || [],
        PivotGroupedColumns: pivotLayout.PivotGroupedColumns || [],
    };
    return result;
}
function CreateEmptyTableLayout(tableLayout) {
    const result = {
        ...tableLayout,
        Uuid: (0, Uuid_1.createUuid)(),
        ColumnSizing: tableLayout.ColumnSizing || {},
        ColumnHeaders: tableLayout.ColumnHeaders || {},
        ColumnPinning: tableLayout.ColumnPinning || {},
        ColumnSorts: tableLayout.ColumnSorts || [],
        ColumnFilters: tableLayout.ColumnFilters || [],
        TableColumns: tableLayout.TableColumns || [],
        RowGroupedColumns: tableLayout.RowGroupedColumns || [],
    };
    return result;
}
function CreateEmptyLayout(layout) {
    if ((0, LayoutHelpers_1.isPivotLayout)(layout)) {
        return CreateEmptyPivotLayout(layout);
    }
    else {
        return CreateEmptyTableLayout(layout);
    }
}
function CreateEmptyStyle() {
    return {
        BackColor: undefined,
        ForeColor: undefined,
        BorderColor: undefined,
        FontWeight: undefined,
        FontStyle: undefined,
        FontSize: undefined,
        ClassName: undefined,
        Alignment: undefined,
    };
}
function CreateSystemStatusMessageInfo(message, type, furtherInfo) {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        statusMessage: message,
        statusFurtherInformation: furtherInfo,
        statusType: type,
        timestamp: new Date(),
    };
}
function CreateEmptyCellSummmary() {
    return {
        Sum: undefined,
        Average: undefined,
        Median: undefined,
        Mode: undefined,
        Distinct: undefined,
        Max: undefined,
        Min: undefined,
        Count: undefined,
        Std_Deviation: undefined,
        Only: undefined,
    };
}
function CreateColumnFilter(ColumnId, PredicateId, Inputs) {
    return {
        ColumnId,
        Predicates: [
            {
                PredicateId: PredicateId,
                Inputs,
            },
        ],
    };
}
function CreateEmptyStyledColumn() {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        ColumnId: GeneralConstants_1.EMPTY_STRING,
    };
}
function CreateDefaultStyledColumnBadge() {
    return {
        Style: {
            BackColor: (0, UIHelper_1.getHexForName)(UIHelper_1.LIGHT_GRAY),
            ForeColor: (0, UIHelper_1.getHexForName)(UIHelper_1.BLACK),
            BorderRadius: 6,
        },
    };
}
function CreateEmptyChartDefinition(chartDefinition) {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        ...chartDefinition,
    };
}
function CreateCustomDisplayFormatterContext(value, node, abColumn, api) {
    return {
        adaptableColumn: abColumn,
        cellValue: value,
        rowNode: node,
        ...api.internalApi.buildBaseContext(),
    };
}
function CreateEmptyTheme(name) {
    return {
        Uuid: (0, Uuid_1.createUuid)(),
        Name: name || 'Custom Theme',
        Description: name || 'Custom Theme',
    };
}
function CreateEmptyCommentThread(cellAddress) {
    return {
        ...cellAddress,
        Comments: [],
    };
}
function getToastPosition(position) {
    switch (position) {
        case 'BottomLeft':
            return 'bottom-left';
        case 'BottomCenter':
            return 'bottom-center';
        case 'BottomRight':
            return 'bottom-right';
        case 'TopLeft':
            return 'top-left';
        case 'TopCenter':
            return 'top-center';
        case 'TopRight':
            return 'top-right';
    }
}
function getToastTransition(transition) {
    switch (transition) {
        case 'Bounce':
            return Toastify_1.Bounce;
        case 'Slide':
            return Toastify_1.Slide;
        case 'Zoom':
            return Toastify_1.Zoom;
        case 'Flip':
            return Toastify_1.Flip;
        default:
            return Toastify_1.Bounce;
    }
}
function CreateToastOptions(notificationsOptions, { onClose, containerId }, overides) {
    const adaptableToastPosition = notificationsOptions.position;
    const position = getToastPosition(adaptableToastPosition);
    const duration = overides.duration ?? notificationsOptions.duration;
    const showProgressBar = notificationsOptions.showProgressBar;
    const closeWhenClicked = notificationsOptions.closeWhenClicked;
    const pauseWhenHovering = notificationsOptions.pauseWhenHovering;
    const isDraggable = notificationsOptions.isDraggable;
    const transition = getToastTransition(notificationsOptions.transition);
    const toastProps = {
        containerId,
        position,
        autoClose: duration == 'always' ? false : duration,
        hideProgressBar: !showProgressBar,
        closeOnClick: closeWhenClicked,
        pauseOnHover: pauseWhenHovering,
        draggable: isDraggable,
        transition: transition,
        draggablePercent: 75,
        onClose,
        // progress: undefined,
    };
    return toastProps;
}
exports.ObjectFactory = {
    CreateEmptyCustomSort,
    CreateEmptyCalculatedColumn,
    CreateEmptyNamedQuery,
    CreateEmptyPlusMinusNudge,
    CreateGenericAlert,
    CreateCellChangedAlert,
    CreateRowChangedAlert,
    CreateEmptyAlertDefinition,
    CreateEmptyFlashingCellDefinition,
    CreateInternalAlertDefinitionForMessages,
    CreateEmptyReport,
    CreateEmptyBaseSchedule,
    CreateEmptyReminderSchedule,
    CreateEmptyReportSchedule,
    CreateEmptyIPushPullSchedule,
    CreateEmptyIPushPullReport,
    CreateIPushPullSchedule,
    CreateReportSchedule,
    CreateEmptyOpenFinReport,
    CreateEmptyOpenFinSchedule,
    CreateEmptySchedule,
    CreateEmptyShortcut,
    CreateEmptyFormatColumn,
    CreateEmptyFreeTextColumn,
    CreateEmptyLayout,
    CreateEmptyPivotLayout,
    CreateEmptyTableLayout,
    CreateColumnFilter,
    CreateEmptyStyle,
    CreateEmptyCellSummmary,
    CreateSystemStatusMessageInfo,
    CreateToastOptions,
    CreateCustomDisplayFormatterContext,
    CreateEmptyStyledColumn,
    CreateDefaultStyledColumnBadge,
    CreateEmptyChartDefinition,
    CreateEmptyTheme,
    CreateEmptyCommentThread,
    CreateAdaptableComment,
};
exports.default = exports.ObjectFactory;
