import type { Bot, SystemPortalPane } from '@casual-simulation/aux-common';
import type { SimulationManager } from '@casual-simulation/aux-vm';
import type { SubscriptionLike } from 'rxjs';
import { Observable } from 'rxjs';
import type { BrowserSimulation } from './BrowserSimulation';
/**
 * Defines a class that is able to manage the state of the system portal.
 */
export declare class SystemPortalCoordinator<TSim extends BrowserSimulation> implements SubscriptionLike {
    private _sub;
    private _simulationManager;
    private _itemsUpdated;
    private _selectionUpdated;
    private _recentsUpdated;
    private _searchUpdated;
    private _diffUpdated;
    private _diffSelectionUpdated;
    private _systemPortalPaneUpdated;
    private _buffer;
    private _recentTags;
    private _recentTagsListSize;
    private _tagSortMode;
    private _extraTags;
    get tagSortMode(): TagSortMode;
    set tagSortMode(mode: TagSortMode);
    get items(): SystemPortalUpdate;
    unsubscribe(): void;
    get closed(): boolean;
    get onItemsUpdated(): Observable<SystemPortalUpdate>;
    get onSelectionUpdated(): Observable<SystemPortalSelectionUpdate>;
    get onRecentsUpdated(): Observable<SystemPortalRecentsUpdate>;
    get onSearchResultsUpdated(): Observable<SystemPortalSearchUpdate>;
    get onDiffUpdated(): Observable<SystemPortalDiffUpdate>;
    get onDiffSelectionUpdated(): Observable<SystemPortalDiffSelectionUpdate>;
    get onSystemPortalPaneUpdated(): Observable<SystemPortalPane>;
    /**
     * Creates a new system portal coorindator.
     * @param simulationManager The simulation manager that should be used.
     * @param bufferEvents Whether to buffer the update events.
     */
    constructor(simulationManager: SimulationManager<TSim>, bufferEvents?: boolean);
    addTag(tag: string): Promise<void>;
    /**
     * Adds the given tag as a pinned tag.
     * Pinned tags are a separate list of tags that are persisted across multiple selections.
     * @param tag The name of the tag to pin.
     */
    addPinnedTag(tag: string): Promise<void>;
    removePinnedTag(tag: SystemPortalSelectionTag): void;
    private _updateSelection;
    private _calculateItemsUpdated;
    private _findMatchingItems;
    private _calculateSelectionUpdated;
    private _findSelection;
    private _calculateRecentsUpdated;
    private _updateRecentsList;
    private _calculateDiffUpdated;
    private _findDiff;
    private _calculateDiffSelectionUpdated;
    private _findDiffSelection;
    private _calculateSearchResults;
    private _searchResultsUpdate;
    private _calculateSystemPortalPaneUpdated;
}
/**
 * Finds the "area" for the given system identifier.
 * System identifiers are dot-separated (.) strings. (like "core.ui.menu")
 * The area includes the first two sections sections of a system ID except for the last section.
 * (the area of "core.ui.menu" is "core.menu" and the area of "core.ui" is "core")
 * @param system
 * @returns
 */
export declare function getSystemArea(system: string): string;
/**
 * Finds the title for the bot given the system identifier and area.
 * @param system The system identifier.
 * @param area The area for the system.
 */
export declare function getBotTitle(system: string, area: string): string;
/**
 * Searches the given tag for matches to the given query.
 * @param tag The name of the tag that is being searched.
 * @param space The space that the tag is in.
 * @param value The value of the tag.
 * @param query The value to search for.
 */
export declare function searchTag(tag: string, space: string, value: unknown, query: string, prefixes: string[]): SystemPortalSearchTag | null;
/**
 * Searches the given value for matches of the given query.
 * @param value The value to search.
 * @param indexOffset The offset that should be added to absolute indexes in the matches.
 * @param query The value to search for.
 * @param isTagName Whether the match is for a tag name.
 * @returns
 */
export declare function searchValue(value: string, indexOffset: number, query: string, isTagName?: boolean): SystemPortalSearchMatch[];
export type SystemPortalUpdate = SystemPortalEmptyUpdate | SystemPortalItemsUpdate;
export interface SystemPortalEmptyUpdate {
    hasPortal: false;
}
export interface SystemPortalItemsUpdate {
    hasPortal: true;
    selectedBotSimulationId: string;
    selectedBot: string;
    items: SystemPortalItem[];
}
export interface SystemPortalItem {
    simulationId: string;
    areas: SystemPortalArea[];
}
export interface SystemPortalArea {
    area: string;
    bots: SystemPortalBot[];
}
export interface SystemPortalBot {
    bot: Bot;
    title: string;
    system: string;
}
export type SystemPortalSelectionUpdate = SystemPortalHasSelectionUpdate | SystemPortalNoSelectionUpdate;
export interface SystemPortalHasSelectionUpdate {
    hasSelection: true;
    simulationId: string;
    bot: Bot;
    tag?: string;
    space?: string;
    sortMode: TagSortMode;
    tags: SystemPortalSelectionTag[];
    /**
     * The list of tags that should be pinned to a section at the bottom of the tags list.
     */
    pinnedTags?: SystemPortalSelectionTag[];
}
export interface SystemPortalSelectionTag {
    name: string;
    space?: string;
    isScript?: boolean;
    isFormula?: boolean;
    isLink?: boolean;
    prefix?: string;
    /**
     * Whether the tag value should be focused once rendered into view.
     */
    focusValue?: boolean;
}
export interface SystemPortalNoSelectionUpdate {
    hasSelection: false;
}
export type TagSortMode = 'alphabetical' | 'scripts-first';
export type SystemPortalRecentsUpdate = SystemPortalHasRecentsUpdate | SystemPortalNoRecentsUpdate;
export interface SystemPortalHasRecentsUpdate {
    hasRecents: true;
    recentTags: SystemPortalRecentTag[];
}
export interface SystemPortalNoRecentsUpdate {
    hasRecents: false;
}
export interface SystemPortalRecentTag {
    hint: string;
    system: string;
    isScript: boolean;
    isFormula: boolean;
    isLink: boolean;
    simulationId: string;
    botId: string;
    tag: string;
    space: string;
    prefix?: string;
}
export interface SystemPortalSearchUpdate {
    numMatches: number;
    numBots: number;
    items: SystemPortalSearchItem[];
}
export interface SystemPortalSearchItem {
    simulationId: string;
    areas: SystemPortalSearchArea[];
}
export interface SystemPortalSearchArea {
    /**
     * The system area that the matches ocurred for.
     */
    area: string;
    /**
     * The bots that the match ocurred for.
     */
    bots: SystemPortalSearchBot[];
}
export interface SystemPortalSearchBot {
    /**
     * The bot that the match ocurred for.
     */
    bot: Bot;
    /**
     * The title for the bot.
     */
    title: string;
    /**
     * The tags that were matched.
     */
    tags: SystemPortalSearchTag[];
}
export interface SystemPortalSearchTag {
    /**
     * The tag that the matches occurred for.
     */
    tag: string;
    /**
     * The space that the tag is in.
     */
    space?: string;
    /**
     * Whether the tag is a script.
     */
    isScript?: boolean;
    /**
     * Whether the tag is a formula.
     */
    isFormula?: boolean;
    /**
     * Whether the tag is a link.
     */
    isLink?: boolean;
    /**
     * Whether the search is actually matching a tag name.
     */
    isTagName?: boolean;
    /**
     * The prefix that the tag has.
     */
    prefix?: string;
    /**
     * The list of matches.
     */
    matches: SystemPortalSearchMatch[];
}
export interface SystemPortalSearchMatch {
    /**
     * The text that should be shown for the match.
     */
    text: string;
    /**
     * The index that the match starts at inside the tag value.
     */
    index: number;
    /**
     * The index that the match ends at inside the tag value.
     */
    endIndex: number;
    /**
     * The index that the match starts at inside this object's text.
     */
    highlightStartIndex: number;
    /**
     * The index that the match ends at inside this object's text.
     */
    highlightEndIndex: number;
    /**
     * Whether the match is for the tag name and not the tag value.
     */
    isTagName?: boolean;
}
export type SystemPortalDiffUpdate = SystemPortalDiffEmptyUpdate | SystemPortalDiffItemsUpdate;
export interface SystemPortalDiffEmptyUpdate {
    hasPortal: false;
}
export interface SystemPortalDiffItemsUpdate {
    hasPortal: true;
    selectedKey: string;
    items: SystemPortalDiffArea[];
}
export interface SystemPortalDiffArea {
    area: string;
    bots: SystemPortalDiffBot[];
}
export type SystemPortalDiffBot = SystemPortalDiffAddedBot | SystemPortalDiffRemovedBot | SystemPortalDiffUpdatedBot;
export interface SystemPortalDiffAddedBot {
    key: string;
    title: string;
    addedBot: Bot;
    addedBotSimulationId: string;
}
export interface SystemPortalDiffRemovedBot {
    key: string;
    title: string;
    removedBot: Bot;
    removedBotSimulationId: string;
}
export interface SystemPortalDiffUpdatedBot {
    key: string;
    title: string;
    originalBotSimulationId: string;
    originalBot: Bot;
    newBot: Bot;
    newBotSimulationId: string;
    changedTags: SystemPortalDiffTag[];
}
export interface SystemPortalDiffTag {
    tag: string;
    space?: string;
}
export type SystemPortalDiffSelectionUpdate = SystemPortalHasDiffSelectionUpdate | SystemPortalNoDiffSelectionUpdate;
export interface SystemPortalHasDiffSelectionUpdate {
    hasSelection: true;
    originalBotSimulationId: string;
    originalBot: Bot;
    newBotSimulationId: string;
    newBot: Bot;
    tag?: string;
    space?: string;
    tags: SystemPortalDiffSelectionTag[];
}
export interface SystemPortalDiffSelectionTag {
    name: string;
    space?: string;
    prefix?: string;
    status: 'added' | 'removed' | 'changed' | 'none';
}
export interface SystemPortalNoDiffSelectionUpdate {
    hasSelection: false;
}
//# sourceMappingURL=SystemPortalCoordinator.d.ts.map