import { Expands } from '@taotieh/cesium_extend';
import CesiumControl from '../controls/Cesium';
import LoopControl from '../controls/Loop';
import SceneControl from '../controls/Scene';
import PointerControl from '../controls/Pointer';
import CameraControl from '../controls/Camera';
import AnimaControl from '../controls/Anima';
import SWControl from '../controls/SWControl';
import StageControl from '../controls/Stage';
import MenuControl from '../controls/Menu';
import Clock from './Clock';
import VPointControl from '../controls/VPoint';
import WorkerControl from '../controls/Worker';
import ClipControl from '../controls/Clip';
import MeasureControl from '../controls/Measure';
import StateControl from '../controls/State';
import TransitionControl from '../controls/Transition';
import BizControl from '../controls/Biz/inedx';
import Bridge from '../bridge';
var Instance = /** @class */ (function () {
    function Instance() {
        this._cm = new Map();
        this.cmp = new Map();
    }
    Instance.prototype.resetInstance = function () {
        this._cm.clear();
    };
    Instance.prototype.getInstanceClock = function () {
        var cacheKey = "Clock";
        var con = this._cm.get(cacheKey);
        if (con) {
            return con;
        }
        // return this._cm.set(cacheKey, new CesiumControl(container)).get(cacheKey);
        return this._cm.set(cacheKey, new Clock(this)).get(cacheKey);
    };
    Instance.prototype.getInstanceSWControl = function () {
        var cacheKey = "SWControl";
        var con = this._cm.get(cacheKey);
        if (con) {
            return con;
        }
        // return this._cm.set(cacheKey, new CesiumControl(container)).get(cacheKey);
        return this._cm.set(cacheKey, new SWControl()).get(cacheKey);
    };
    Instance.prototype.getInstanceCesiumControl = function (container) {
        var cacheKey = "CesiumControl";
        var con = this.cmp.get(cacheKey);
        if (con || !container) {
            return con;
        }
        // 初始化 Cesium 对象前需要给其扩展包注入依赖
        // debugger;
        var cSt = this.getInstanceStateControl();
        var bridge = new Bridge(cSt.state);
        Expands.update(bridge);
        // return this._cm.set(cacheKey, new CesiumControl(container)).get(cacheKey);
        return this.cmp
            .set(cacheKey, new CesiumControl(this, container))
            .get(cacheKey);
    };
    Instance.prototype.getInstanceLoopControl = function () {
        var cacheKey = "LoopControl";
        var con = this._cm.get(cacheKey);
        if (con) {
            return con;
        }
        return this._cm.set(cacheKey, new LoopControl()).get(cacheKey);
    };
    Instance.prototype.getInstanceSceneControl = function (viewer) {
        var cacheKey = "SceneControl";
        var con = this.cmp.get(cacheKey);
        if (con || !viewer) {
            return con;
        }
        return this.cmp.set(cacheKey, new SceneControl(this, viewer)).get(cacheKey);
    };
    Instance.prototype.getInstancePointerControl = function (viewer) {
        var cacheKey = "PointerControl";
        var con = this.cmp.get(cacheKey);
        if (con || !viewer) {
            return con;
        }
        return this.cmp
            .set(cacheKey, new PointerControl(this, viewer))
            .get(cacheKey);
    };
    Instance.prototype.getInstanceCameraControl = function (viewer) {
        var cacheKey = "CameraControl";
        var con = this.cmp.get(cacheKey);
        if (con || !viewer) {
            return con;
        }
        return this.cmp
            .set(cacheKey, new CameraControl(this, viewer))
            .get(cacheKey);
    };
    Instance.prototype.getInstanceAnimaControl = function () {
        var cacheKey = "AnimaControl";
        var con = this._cm.get(cacheKey);
        if (con) {
            return con;
        }
        return this._cm.set(cacheKey, new AnimaControl(this)).get(cacheKey);
    };
    Instance.prototype.getInstanceStageControl = function (viewer) {
        var cacheKey = "StageControl";
        var con = this.cmp.get(cacheKey);
        if (con || !viewer) {
            return con;
        }
        return this.cmp.set(cacheKey, new StageControl(viewer)).get(cacheKey);
    };
    Instance.prototype.getInstanceMenuControl = function (viewer) {
        var cacheKey = "MenuControl";
        var con = this.cmp.get(cacheKey);
        if (con || !viewer) {
            return con;
        }
        return this.cmp.set(cacheKey, new MenuControl(viewer)).get(cacheKey);
    };
    Instance.prototype.getInstanceVPointControl = function (viewer) {
        var cacheKey = "VPointControl";
        var con = this.cmp.get(cacheKey);
        if (con || !viewer) {
            return con;
        }
        return this.cmp
            .set(cacheKey, new VPointControl(this, viewer))
            .get(cacheKey);
    };
    Instance.prototype.getInstanceWorkerControl = function () {
        var cacheKey = "WorkerControl";
        var con = this._cm.get(cacheKey);
        if (con) {
            return con;
        }
        return this._cm.set(cacheKey, new WorkerControl()).get(cacheKey);
    };
    Instance.prototype.getInstanceClipControl = function (viewer, instance) {
        var cacheKey = "ClipControl";
        var con = this.cmp.get(cacheKey);
        if (con || !viewer) {
            return con;
        }
        return this.cmp
            .set(cacheKey, new ClipControl(viewer, instance))
            .get(cacheKey);
    };
    Instance.prototype.getInstanceStateControl = function () {
        var con = this._cm.get('StateControl');
        if (con) {
            return con;
        }
        return this._cm.set('StateControl', new StateControl()).get('StateControl');
    };
    Instance.prototype.getInstanceTransitionControl = function (scene) {
        var cacheKey = "TransitionControl";
        var con = this._cm.get(cacheKey);
        if (con || !scene) {
            return con;
        }
        return this._cm.set(cacheKey, new TransitionControl(scene)).get(cacheKey);
    };
    Instance.prototype.getInstanceMeasureControl = function (viewer, instance) {
        var cacheKey = "MeasureControl";
        var con = this.cmp.get(cacheKey);
        if (con || !viewer) {
            return con;
        }
        return this.cmp
            .set(cacheKey, new MeasureControl(viewer, instance))
            .get(cacheKey);
    };
    Instance.prototype.getInstanceBizControl = function (instance) {
        var cacheKey = "BizControl";
        return this._cm.set(cacheKey, new BizControl(instance)).get(cacheKey);
    };
    return Instance;
}());
export default Instance;
