import { HashMap, ReadonlyHashMap, ReadonlyHashSet } from '../coreUtils/hashMap';
import { ElementModel, ElementIri, LinkKey, LinkModel } from '../data/model';
/**
 * Immutable graph authoring state: added, deleted or changed
 * graph entities and/or relations.
 *
 * @category Core
 */
export interface AuthoringState {
    /**
     * Authoring state for the graph entities.
     */
    readonly elements: ReadonlyMap<ElementIri, AuthoredEntity>;
    /**
     * Authoring state for the graph relations.
     */
    readonly links: ReadonlyHashMap<LinkKey, AuthoredRelation>;
}
/**
 * Represents a modification to an entity or relation
 * in graph authoring (add, change or delete).
 *
 * @category Core
 */
export type AuthoringEvent = AuthoredEntity | AuthoredRelation;
/**
 * Graph authoring state for an entity.
 */
export type AuthoredEntity = AuthoredEntityAdd | AuthoredEntityChange | AuthoredEntityDelete;
/**
 * Graph authoring state for a relation.
 */
export type AuthoredRelation = AuthoredRelationAdd | AuthoredRelationChange | AuthoredRelationDelete;
/**
 * Represents added entity in the graph authoring state.
 *
 * @see {@link AuthoredEntity}
 */
export interface AuthoredEntityAdd {
    /**
     * Authoring event type.
     */
    readonly type: 'entityAdd';
    /**
     * Added entity data.
     */
    readonly data: ElementModel;
}
/**
 * Represents changed entity in the graph authoring state.
 *
 * @see {@link AuthoredEntity}
 */
export interface AuthoredEntityChange {
    /**
     * Authoring event type.
     */
    readonly type: 'entityChange';
    /**
     * Original entity data before the change.
     */
    readonly before: ElementModel;
    /**
     * Modified entity data after the change.
     */
    readonly data: ElementModel;
    /**
     * Specifies that the entity has a modified IRI.
     */
    readonly newIri?: ElementIri;
}
/**
 * Represents deleted entity in the graph authoring state.
 *
 * @see {@link AuthoredEntity}
 */
export interface AuthoredEntityDelete {
    /**
     * Authoring event type.
     */
    readonly type: 'entityDelete';
    /**
     * Data of the deleted entity (unchanged).
     */
    readonly data: ElementModel;
}
/**
 * Represents added relation in the graph authoring state.
 *
 * @see {@link AuthoredRelation}
 */
export interface AuthoredRelationAdd {
    /**
     * Authoring event type.
     */
    readonly type: 'relationAdd';
    /**
     * Added relation data.
     */
    readonly data: LinkModel;
}
/**
 * Represents changed relation in the graph authoring state.
 *
 * @see {@link AuthoredRelation}
 */
export interface AuthoredRelationChange {
    /**
     * Authoring event type.
     */
    readonly type: 'relationChange';
    /**
     * Original relation data before the change.
     */
    readonly before: LinkModel;
    /**
     * Modified relation data after the change.
     *
     * Note: only property changes are supported by the graph authoring,
     * so if relation identity changes it should be deleted and re-created
     * as separate relation.
     */
    readonly data: LinkModel;
}
/**
 * Represents deleted relation in the graph authoring state.
 *
 * @see {@link AuthoredRelation}
 */
export interface AuthoredRelationDelete {
    /**
     * Authoring event type.
     */
    readonly type: 'relationDelete';
    /**
     * Data of the deleted relation (unchanged).
     */
    readonly data: LinkModel;
}
/**
 * A mutable clone of the graph authoring state.
 *
 * @see {@link AuthoringState.clone}
 */
export interface MutableAuthoringState extends AuthoringState {
    readonly elements: Map<ElementIri, AuthoredEntity>;
    readonly links: HashMap<LinkKey, AuthoredRelation>;
}
/**
 * Utility functions to operate on graph authoring state.
 *
 * @category Core
 */
export declare namespace AuthoringState {
    /**
     * Empty graph authoring state.
     */
    const empty: AuthoringState;
    /**
     * Returns `true` is specified graph authoring state is empty;
     * otherwise `false`.
     */
    function isEmpty(state: AuthoringState): boolean;
    /**
     * Creates a mutable clone of the specified graph authoring state.
     */
    function clone(index: AuthoringState): MutableAuthoringState;
    /**
     * Returns `true` if `event` is an entity authoring event; otherwise `false`.
     */
    function isEntityEvent(event: AuthoringEvent): event is AuthoredEntity;
    /**
     * Returns `true` if `event` is an relation authoring event; otherwise `false`.
     */
    function isLinkEvent(event: AuthoringEvent): event is AuthoredRelation;
    /**
     * Returns `true` if a graph authoring state contains specified `event`;
     * otherwise `false`.
     */
    function has(state: AuthoringState, event: AuthoringEvent): boolean;
    /**
     * Discards the specified event from the graph authoring state if the state contains it.
     */
    function discard(state: AuthoringState, discarded: AuthoringEvent): AuthoringState;
    /**
     * Marks the entity as added in the graph authored state.
     */
    function addEntity(state: AuthoringState, data: ElementModel): AuthoringState;
    /**
     * Marks the relation as added in the graph authored state.
     */
    function addRelation(state: AuthoringState, data: LinkModel): AuthoringState;
    /**
     * Marks the entity as changed in the graph authored state.
     */
    function changeEntity(state: AuthoringState, before: ElementModel, after: ElementModel): AuthoringState;
    /**
     * Marks the relation as changed in the graph authored state.
     */
    function changeRelation(state: AuthoringState, before: LinkModel, after: LinkModel): AuthoringState;
    /**
     * Marks the entity as deleted in the graph authored state.
     */
    function deleteEntity(state: AuthoringState, data: ElementModel): AuthoringState;
    /**
     * Marks the relation as deleted in the graph authored state.
     */
    function deleteRelation(state: AuthoringState, data: LinkModel): AuthoringState;
    /**
     * Discards marked as added relations connected to the specified entities.
     */
    function discardAddedRelations(state: AuthoringState, connectedEntities: ReadonlySet<ElementIri>): AuthoringState;
    /**
     * Returns `true` if target entity is marked as added in the graph authoring state;
     * otherwise `false`.
     */
    function isAddedEntity(state: AuthoringState, target: ElementIri): boolean;
    /**
     * Returns `true` if target entity is marked as deleted in the graph authoring state;
     * otherwise `false`.
     */
    function isDeletedEntity(state: AuthoringState, target: ElementIri): boolean;
    /**
     * Returns `true` if target entity is marked as changed and have modified IRI
     * in the graph authoring state; otherwise `false`.
     */
    function hasEntityChangedIri(state: AuthoringState, target: ElementIri): boolean;
    /**
     * Returns `true` if target relation is marked as added in the graph authoring state;
     * otherwise `false`.
     */
    function isAddedRelation(state: AuthoringState, key: LinkKey): boolean;
    /**
     * Returns `true` if target relation is marked as deleted in the graph authoring state;
     * otherwise `false`.
     */
    function isDeletedRelation(state: AuthoringState, key: LinkKey): boolean;
}
/**
 * Immutable temporary (transient) state for the graph authoring.
 *
 * Represents a set of temporary entities and relations which are
 * discarded from the diagram if a graph authoring operation gets
 * cancelled.
 *
 * @category Core
 */
export interface TemporaryState {
    /**
     * A set of temporary entities.
     */
    readonly elements: ReadonlySet<ElementIri>;
    /**
     * A set of temporary relations.
     */
    readonly links: ReadonlyHashSet<LinkKey>;
}
/**
 * Utility functions to operate on temporary state for the graph authoring.
 *
 * @category Core
 */
export declare namespace TemporaryState {
    /**
     * Empty temporary state for the graph authoring.
     */
    const empty: TemporaryState;
    /**
     * Marks the entity as temporary.
     */
    function addEntity(state: TemporaryState, element: ElementModel): TemporaryState;
    /**
     * Discards the entity from temporary state.
     */
    function removeEntity(state: TemporaryState, element: ElementModel): TemporaryState;
    /**
     * Marks the relation as temporary.
     */
    function addRelation(state: TemporaryState, link: LinkKey): TemporaryState;
    /**
     * Discards the relation from temporary state.
     */
    function removeRelation(state: TemporaryState, link: LinkKey): TemporaryState;
}
//# sourceMappingURL=authoringState.d.ts.map