/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
import { IChannelAttributes, IChannelStorageService, IFluidDataStoreRuntime } from "@fluidframework/datastore-definitions";
import { ISequencedDocumentMessage } from "@fluidframework/protocol-definitions";
import { ITelemetryContext, ISummaryTreeWithStats, IGarbageCollectionData, IExperimentalIncrementalSummaryContext } from "@fluidframework/runtime-definitions";
import { IFluidSerializer, SharedObject } from "@fluidframework/shared-object-base";
import { ICodecOptions } from "../codec/index.js";
import { ChangeFamily, ChangeFamilyEditor } from "../core/index.js";
import { JsonCompatibleReadOnly } from "../util/index.js";
import { SchemaAndPolicy } from "../feature-libraries/index.js";
import { SharedTreeBranch } from "./branch.js";
/**
 * Generic shared tree, which needs to be configured with indexes, field kinds and a history policy to be used.
 *
 * TODO: actually implement
 * TODO: is history policy a detail of what indexes are used, or is there something else to it?
 */
export declare class SharedTreeCore<TEditor extends ChangeFamilyEditor, TChange> extends SharedObject {
    private readonly editManager;
    private readonly summarizables;
    /**
     * The sequence number that this instance is at.
     * This number is artificial in that it is made up by this instance as opposed to being provided by the runtime.
     * Is `undefined` after (and only after) this instance is attached.
     */
    private detachedRevision;
    /**
     * Used to edit the state of the tree. Edits will be immediately applied locally to the tree.
     * If there is no transaction currently ongoing, then the edits will be submitted to Fluid immediately as well.
     */
    get editor(): TEditor;
    /**
     * Used to encode/decode messages sent to/received from the Fluid runtime.
     *
     * @remarks Since there is currently only one format, this can just be cached on the class.
     * With more write formats active, it may make sense to keep around the "usual" format codec
     * (the one for the current persisted configuration) and resolve codecs for different versions
     * as necessary (e.g. an upgrade op came in, or the configuration changed within the collab window
     * and an op needs to be interpreted which isn't written with the current configuration).
     */
    private readonly messageCodec;
    private readonly idCompressor;
    private readonly schemaAndPolicy;
    /**
     * @param summarizables - Summarizers for all indexes used by this tree
     * @param changeFamily - The change family
     * @param editManager - The edit manager
     * @param id - The id of the shared object
     * @param runtime - The IFluidDataStoreRuntime which contains the shared object
     * @param attributes - Attributes of the shared object
     * @param telemetryContextPrefix - the context for any telemetry logs/errors emitted
     */
    constructor(summarizables: readonly Summarizable[], changeFamily: ChangeFamily<TEditor, TChange>, options: ICodecOptions, id: string, runtime: IFluidDataStoreRuntime, attributes: IChannelAttributes, telemetryContextPrefix: string, schemaAndPolicy: SchemaAndPolicy);
    protected summarizeCore(serializer: IFluidSerializer, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): ISummaryTreeWithStats;
    protected loadCore(services: IChannelStorageService): Promise<void>;
    /**
     * Submits an op to the Fluid runtime containing the given commit
     * @param commit - the commit to submit
     */
    private submitCommit;
    protected processCore(message: ISequencedDocumentMessage, local: boolean, localOpMetadata: unknown): void;
    /**
     * @returns the head commit of the root local branch
     */
    protected getLocalBranch(): SharedTreeBranch<TEditor, TChange>;
    protected onDisconnect(): void;
    protected didAttach(): void;
    protected reSubmitCore(content: JsonCompatibleReadOnly, localOpMetadata: unknown): void;
    protected applyStashedOp(content: JsonCompatibleReadOnly): void;
    getGCData(fullGC?: boolean): IGarbageCollectionData;
}
/**
 * Specifies the behavior of a component that puts data in a summary.
 */
export interface Summarizable {
    /**
     * Field name in summary json under which this element stores its data.
     */
    readonly key: string;
    /**
     * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).getAttachSummary}
     * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.
     */
    getAttachSummary(stringify: SummaryElementStringifier, fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext, incrementalSummaryContext?: IExperimentalIncrementalSummaryContext): ISummaryTreeWithStats;
    /**
     * {@inheritDoc @fluidframework/datastore-definitions#(IChannel:interface).summarize}
     * @param stringify - Serializes the contents of the component (including {@link (IFluidHandle:interface)}s) for storage.
     */
    summarize(stringify: SummaryElementStringifier, fullTree?: boolean, trackState?: boolean, telemetryContext?: ITelemetryContext): Promise<ISummaryTreeWithStats>;
    /**
     * {@inheritDoc (ISharedObject:interface).getGCData}
     */
    getGCData(fullGC?: boolean): IGarbageCollectionData;
    /**
     * Allows the component to perform custom loading. The storage service is scoped to this component and therefore
     * paths in this component will not collide with those in other components, even if they are the same string.
     * @param service - Storage used by the component
     * @param parse - Parses serialized data from storage into runtime objects for the component
     */
    load(service: IChannelStorageService, parse: SummaryElementParser): Promise<void>;
}
/**
 * Serializes the given contents into a string acceptable for storing in summaries, i.e. all
 * Fluid handles have been replaced appropriately by an IFluidSerializer
 */
export type SummaryElementStringifier = (contents: unknown) => string;
/**
 * Parses a serialized/summarized string into an object, rehydrating any Fluid handles as necessary
 */
export type SummaryElementParser = (contents: string) => unknown;
//# sourceMappingURL=sharedTreeCore.d.ts.map