import { VTableSheetEventType, SPREADSHEET_EVENT_TYPES } from "../ts-types/spreadsheet-events";

import { BaseEventManager } from "./base-event-manager";

export class SpreadSheetEventManager extends BaseEventManager {
    constructor(spreadsheet) {
        super(spreadsheet.getEventBus()), this.spreadsheet = spreadsheet;
    }
    getEventTypes() {
        return Array.from(SPREADSHEET_EVENT_TYPES);
    }
    emitReady() {
        this.emit(VTableSheetEventType.SPREADSHEET_READY, void 0);
    }
    emitDestroyed() {
        this.emit(VTableSheetEventType.SPREADSHEET_DESTROYED, void 0);
    }
    emitResized(width, height) {
        this.emit(VTableSheetEventType.SPREADSHEET_RESIZED, {
            width: width,
            height: height
        });
    }
    emitSheetAdded(sheetKey, sheetTitle, index) {
        const event = {
            sheetKey: sheetKey,
            sheetTitle: sheetTitle,
            index: index
        };
        this.emit(VTableSheetEventType.SHEET_ADDED, event);
    }
    emitSheetRemoved(sheetKey, sheetTitle, index) {
        const event = {
            sheetKey: sheetKey,
            sheetTitle: sheetTitle,
            index: index
        };
        this.emit(VTableSheetEventType.SHEET_REMOVED, event);
    }
    emitSheetRenamed(sheetKey, oldTitle, newTitle) {
        const event = {
            sheetKey: sheetKey,
            oldTitle: oldTitle,
            newTitle: newTitle
        };
        this.emit(VTableSheetEventType.SHEET_RENAMED, event);
    }
    emitSheetActivated(sheetKey, sheetTitle, previousSheetKey, previousSheetTitle) {
        const event = {
            sheetKey: sheetKey,
            sheetTitle: sheetTitle,
            previousSheetKey: previousSheetKey,
            previousSheetTitle: previousSheetTitle
        };
        this.emit(VTableSheetEventType.SHEET_ACTIVATED, event);
    }
    emitSheetDeactivated(sheetKey, sheetTitle) {
        const event = {
            sheetKey: sheetKey,
            sheetTitle: sheetTitle
        };
        this.emit(VTableSheetEventType.SHEET_DEACTIVATED, event);
    }
    emitSheetMoved(sheetKey, fromIndex, toIndex) {
        const event = {
            sheetKey: sheetKey,
            fromIndex: fromIndex,
            toIndex: toIndex
        };
        this.emit(VTableSheetEventType.SHEET_MOVED, event);
    }
    emitSheetVisibilityChanged(sheetKey, visible) {
        const event = {
            sheetKey: sheetKey,
            visible: visible
        };
        this.emit(VTableSheetEventType.SHEET_VISIBILITY_CHANGED, event);
    }
    emitImportStart(fileType) {
        const event = {
            fileType: fileType
        };
        this.emit(VTableSheetEventType.IMPORT_START, event);
    }
    emitImportCompleted(fileType, sheetCount) {
        const event = {
            fileType: fileType,
            sheetCount: sheetCount
        };
        this.emit(VTableSheetEventType.IMPORT_COMPLETED, event);
    }
    emitImportError(fileType, error) {
        const event = {
            fileType: fileType,
            error: error
        };
        this.emit(VTableSheetEventType.IMPORT_ERROR, event);
    }
    emitExportStart(fileType, allSheets) {
        const event = {
            fileType: fileType,
            allSheets: allSheets
        };
        this.emit(VTableSheetEventType.EXPORT_START, event);
    }
    emitExportCompleted(fileType, allSheets, sheetCount) {
        const event = {
            fileType: fileType,
            allSheets: allSheets,
            sheetCount: sheetCount
        };
        this.emit(VTableSheetEventType.EXPORT_COMPLETED, event);
    }
    emitExportError(fileType, allSheets, error) {
        const event = {
            fileType: fileType,
            allSheets: allSheets,
            error: error
        };
        this.emit(VTableSheetEventType.EXPORT_ERROR, event);
    }
    emitCrossSheetReferenceUpdated(sourceSheetKey, targetSheetKeys, affectedFormulaCount) {
        const event = {
            sourceSheetKey: sourceSheetKey,
            targetSheetKeys: targetSheetKeys,
            affectedFormulaCount: affectedFormulaCount
        };
        this.emit(VTableSheetEventType.CROSS_SHEET_REFERENCE_UPDATED, event);
    }
    emitCrossSheetFormulaCalculateStart() {
        this.emit(VTableSheetEventType.CROSS_SHEET_FORMULA_CALCULATE_START, void 0);
    }
    emitCrossSheetFormulaCalculateEnd() {
        this.emit(VTableSheetEventType.CROSS_SHEET_FORMULA_CALCULATE_END, void 0);
    }
}
//# sourceMappingURL=spreadsheet-event-manager.js.map