import { IFreeze, IInterceptor, Injector, IRange, IRangeWithCoord, ISelectionCell, ISelectionCellWithMergeInfo, ISelectionWithCoord, Nullable, ThemeService, Disposable, InterceptorManager, RANGE_TYPE } from '@univerjs/core';
import { IMouseEvent, IPointerEvent, IRenderModule, Scene, SpreadsheetSkeleton, Viewport, ScrollTimer, ScrollTimerType } from '@univerjs/engine-render';
import { ISelectionStyle, ISelectionWithCoordAndStyle, ISelectionWithStyle } from '@univerjs/sheets';
import { IShortcutService } from '@univerjs/ui';
import { Observable, Subscription, BehaviorSubject, Subject } from 'rxjs';
import { SheetSkeletonManagerService } from '../sheet-skeleton-manager.service';
import { SelectionControl } from './selection-shape';
export interface IControlFillConfig {
    oldRange: IRange;
    newRange: IRange;
}
export interface ISheetSelectionRenderService {
    readonly selectionMoveEnd$: Observable<ISelectionWithCoordAndStyle[]>;
    readonly controlFillConfig$: Observable<IControlFillConfig | null>;
    readonly selectionMoving$: Observable<ISelectionWithCoordAndStyle[]>;
    readonly selectionMoveStart$: Observable<ISelectionWithCoordAndStyle[]>;
    get selectionMoving(): boolean;
    interceptor: InterceptorManager<{
        RANGE_MOVE_PERMISSION_CHECK: IInterceptor<boolean, null>;
        RANGE_FILL_PERMISSION_CHECK: IInterceptor<boolean, {
            x: number;
            y: number;
            skeleton: SpreadsheetSkeleton;
            scene: Scene;
        }>;
    }>;
    /** @deprecated This should not be provided by the selection render service. */
    getViewPort(): Viewport;
    getSkeleton(): SpreadsheetSkeleton;
    getSelectionControls(): SelectionControl[];
    /** @deprecated Use the function `attachSelectionWithCoord` instead. */
    attachSelectionWithCoord(selectionWithStyle: ISelectionWithStyle): ISelectionWithCoordAndStyle;
    /** @deprecated Use the function `attachPrimaryWithCoord` instead`. */
    attachPrimaryWithCoord(primary: Nullable<Partial<ISelectionCell>>): Nullable<ISelectionCellWithMergeInfo>;
    getSelectionCellByPosition(x: number, y: number): Nullable<ISelectionCellWithMergeInfo>;
    setSingleSelectionEnabled(enabled: boolean): void;
}
export declare const ISheetSelectionRenderService: import('@univerjs/core').IdentifierDecorator<ISheetSelectionRenderService>;
/**
 * The basic implementation of selection rendering logics. It is designed to be reused for different purposes.
 */
export declare class BaseSelectionRenderService extends Disposable implements ISheetSelectionRenderService, IRenderModule {
    protected readonly _injector: Injector;
    protected readonly _themeService: ThemeService;
    protected readonly _shortcutService: IShortcutService;
    protected readonly _sheetSkeletonManagerService: SheetSkeletonManagerService;
    private _downObserver;
    protected _scenePointerMoveSub: Nullable<Subscription>;
    protected _scenePointerUpSub: Nullable<Subscription>;
    private _controlFillConfig$;
    readonly controlFillConfig$: Observable<IControlFillConfig | null>;
    protected _selectionControls: SelectionControl[];
    protected _startRangeWhenPointerDown: IRangeWithCoord;
    /**
     * the posX of viewport when the pointer down
     */
    protected _startViewportPosX: number;
    /**
     * the posY of viewport when the pointer down
     */
    protected _startViewportPosY: number;
    protected _scrollTimer: ScrollTimer;
    private _cancelDownSubscription;
    private _cancelUpSubscription;
    protected _skeleton: SpreadsheetSkeleton;
    protected _scene: Scene;
    protected _isHeaderHighlight: boolean;
    protected _shouldDetectMergedCells: boolean;
    protected _selectionStyle: ISelectionStyle;
    protected _remainLastEnabled: boolean;
    protected _skipLastEnabled: boolean;
    protected _singleSelectionEnabled: boolean;
    protected readonly _selectionMoveEnd$: BehaviorSubject<ISelectionWithCoordAndStyle[]>;
    readonly selectionMoveEnd$: Observable<ISelectionWithCoordAndStyle[]>;
    protected readonly _selectionMoving$: Subject<ISelectionWithCoordAndStyle[]>;
    readonly selectionMoving$: Observable<ISelectionWithCoordAndStyle[]>;
    protected readonly _selectionMoveStart$: Subject<ISelectionWithCoordAndStyle[]>;
    readonly selectionMoveStart$: Observable<ISelectionWithCoordAndStyle[]>;
    private _selectionMoving;
    get selectionMoving(): boolean;
    protected _activeViewport: Nullable<Viewport>;
    readonly interceptor: InterceptorManager<{
        RANGE_MOVE_PERMISSION_CHECK: IInterceptor<boolean, null>;
        RANGE_FILL_PERMISSION_CHECK: IInterceptor<boolean, {
            x: number;
            y: number;
            skeleton: SpreadsheetSkeleton;
            scene: Scene;
        }>;
    }>;
    private _escapeShortcutDisposable;
    constructor(_injector: Injector, _themeService: ThemeService, _shortcutService: IShortcutService, _sheetSkeletonManagerService: SheetSkeletonManagerService);
    private _initMoving;
    protected _setSelectionStyle(style: ISelectionStyle): void;
    /**
     * Reset this._selectionStyle to default normal selection style
     */
    protected _resetSelectionStyle(): void;
    /** @deprecated This should not be provided by the selection render service. */
    getViewPort(): Viewport;
    setSingleSelectionEnabled(enabled?: boolean): void;
    /**
     * Add a selection in spreadsheet, create a new SelectionControl and then update this control by range derives from selection.
     * @param {ISelectionWithCoordAndStyle} selection
     */
    protected _addSelectionControlBySelectionData(selection: ISelectionWithCoordAndStyle): void;
    newSelectionControl(scene: Scene, _rangeType: RANGE_TYPE, skeleton: SpreadsheetSkeleton): SelectionControl;
    /**
     * Update the corresponding selectionControl based on selectionsData.
     * selectionData[i] syncs selectionControls[i]
     * @param selections
     */
    updateControlForCurrentByRangeData(selections: ISelectionWithCoordAndStyle[]): void;
    refreshSelectionMoveStart(): void;
    protected _changeRuntime(skeleton: SpreadsheetSkeleton, scene: Scene, viewport?: Viewport): void;
    getSkeleton(): SpreadsheetSkeleton;
    /**
     * Generate selectionData from this._selectionControls.model .
     * @returns {ISelectionWithCoordAndStyle[]} {range, primary, style}[]
     */
    getSelectionDataWithStyle(): ISelectionWithCoordAndStyle[];
    getSelectionControls(): SelectionControl[];
    protected _clearSelectionControls(): void;
    protected _getFreeze(): Nullable<IFreeze>;
    protected _getViewportByCell(row?: number, column?: number): Nullable<Viewport>;
    /**
     * Returns the selected range in the active sheet, or null if there is no active range. If multiple ranges are selected this method returns only the last selected range.
     */
    getActiveRange(): Nullable<IRange>;
    /**
     * get active selection control
     * @returns T extends SelectionControl
     */
    getActiveSelectionControl<T extends SelectionControl = SelectionControl>(): Nullable<T>;
    endSelection(): void;
    /**
     * Clear existed selections.
     */
    protected _reset(): void;
    resetAndEndSelection(): void;
    /**
     *
     * @param evt component point event
     * @param style selection style, Styles for user-customized selectors
     * @param _zIndex Stacking order of the selection object
     * @param rangeType Determines whether the selection is made normally according to the range or by rows and columns
     */
    protected _onPointerDown(evt: IPointerEvent | IMouseEvent, _zIndex: number | undefined, rangeType: RANGE_TYPE | undefined, viewport: Nullable<Viewport>, scrollTimerType?: ScrollTimerType): void;
    /**
     * Init pointer move listener in each pointer down, unbind in each pointer up.
     * Both cell selections and row-column selections are supported by this method.
     * @param viewportMain
     * @param activeSelectionControl
     * @param rangeType
     * @param scrollTimerType
     * @param moveStartPosX
     * @param moveStartPosY
     */
    protected _setupPointerMoveListener(viewportMain: Nullable<Viewport>, activeSelectionControl: SelectionControl, rangeType: RANGE_TYPE, scrollTimerType: ScrollTimerType | undefined, moveStartPosX: number, moveStartPosY: number): void;
    /** @deprecated Use the function `attachSelectionWithCoord` instead`. */
    attachSelectionWithCoord(selectionWithStyle: ISelectionWithStyle): ISelectionWithCoordAndStyle;
    /** @deprecated Use the function `attachPrimaryWithCoord` instead`. */
    attachPrimaryWithCoord(primary: ISelectionCell): ISelectionCellWithMergeInfo;
    getSelectionCellByPosition(x: number, y: number): Nullable<ISelectionCellWithMergeInfo>;
    /**
     * When mousedown and mouseup need to go to the coordination and undo stack, when mousemove does not need to go to the coordination and undo stack
     */
    protected _movingHandler(offsetX: number, offsetY: number, activeSelectionControl: Nullable<SelectionControl>, rangeType: RANGE_TYPE): void;
    /**
     * Update the selection control by range.
     * @param control
     * @param newSelectionRange
     * @param highlight
     */
    protected _updateSelectionControlByRange(control: SelectionControl, newSelectionRange: IRangeWithCoord, highlight: Nullable<ISelectionCellWithMergeInfo>): void;
    protected _clearUpdatingListeners(): void;
    protected _addEndingListeners(): void;
    protected _getCellRangeByCursorPosition(offsetX: number, offsetY: number, scaleX: number, scaleY: number, scrollXY: {
        x: number;
        y: number;
    }): Nullable<ISelectionWithCoord>;
    protected _checkClearPreviousControls(evt: IPointerEvent | IMouseEvent): void;
    private _performSelectionByTwoCells;
    /**
     * Reset all this.selectionControls by selectionsData.
     * @param selectionsData
     */
    protected _refreshSelectionControl(selectionsData: readonly ISelectionWithStyle[]): void;
}
export declare function getAllSelection(skeleton: SpreadsheetSkeleton): ISelectionWithStyle;
export declare function getTopLeftSelection(skeleton: SpreadsheetSkeleton): Nullable<ISelectionWithStyle>;
