"use strict";
/*!
 * Copyright (c) Microsoft Corporation and contributors. All rights reserved.
 * Licensed under the MIT License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.SharedTree = exports.TreeFactory = void 0;
const shared_tree_1 = require("./shared-tree");
/**
 * A channel factory that creates an {@link ITree}.
 * @alpha
 */
class TreeFactory {
    constructor(options) {
        this.options = options;
        this.type = `https://graph.microsoft.com/types/tree/${options.subtype ?? "default"}`;
        this.attributes = {
            type: this.type,
            snapshotFormatVersion: "0.0.0",
            packageVersion: "0.0.0",
        };
    }
    async load(runtime, id, services, channelAttributes) {
        const tree = new shared_tree_1.SharedTree(id, runtime, channelAttributes, this.options, "SharedTree");
        await tree.load(services);
        return tree;
    }
    create(runtime, id) {
        const tree = new shared_tree_1.SharedTree(id, runtime, this.attributes, this.options, "SharedTree");
        tree.initializeLocal();
        return tree;
    }
}
exports.TreeFactory = TreeFactory;
/**
 * SharedTree is a hierarchical data structure for collaboratively editing JSON-like trees
 * of objects, arrays, and other data types.
 *
 * @internal
 */
class SharedTree {
    // The IFluidContainer ContainerSchema currently requires a constructable class that
    // implements the union of IChannel and the interface to be returned to the user.
    //
    // Temporarily, we provide one until the following work items is addressed:
    // https://dev.azure.com/fluidframework/internal/_workitems/edit/6458
    static getFactory() {
        return new TreeFactory({});
    }
    schematize(config) {
        return this.useFactory();
    }
    useFactory() {
        throw new Error("Use factory to create instance.");
    }
    get id() {
        return this.useFactory();
    }
    get attributes() {
        return this.useFactory();
    }
    get handle() {
        return this.useFactory();
    }
    get IFluidLoadable() {
        return this.useFactory();
    }
    getAttachSummary(fullTree, trackState, telemetryContext) {
        return this.useFactory();
    }
    async summarize(fullTree, trackState, telemetryContext, incrementalSummaryContext) {
        return this.useFactory();
    }
    isAttached() {
        return this.useFactory();
    }
    connect(services) {
        return this.useFactory();
    }
    getGCData(fullGC) {
        return this.useFactory();
    }
}
exports.SharedTree = SharedTree;
//# sourceMappingURL=treeFactory.js.map