"use strict";
/**
 * Copyright (c) Microsoft Corporation.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
Object.defineProperty(exports, "__esModule", { value: true });
exports.InspectorController = void 0;
const recorderSupplement_1 = require("./recorderSupplement");
const debugLogger_1 = require("../../utils/debugLogger");
const debugger_1 = require("./debugger");
class InspectorController {
    async onContextCreated(context) {
        const contextDebugger = debugger_1.ContextDebugger.lookup(context);
        if (contextDebugger.isPaused())
            recorderSupplement_1.RecorderSupplement.show(context, {}).catch(() => { });
        contextDebugger.on(debugger_1.ContextDebugger.Events.PausedStateChanged, () => {
            recorderSupplement_1.RecorderSupplement.show(context, {}).catch(() => { });
        });
    }
    async onBeforeCall(sdkObject, metadata) {
        const recorder = await recorderSupplement_1.RecorderSupplement.lookup(sdkObject.attribution.context);
        recorder === null || recorder === void 0 ? void 0 : recorder.onBeforeCall(sdkObject, metadata);
    }
    async onAfterCall(sdkObject, metadata) {
        const recorder = await recorderSupplement_1.RecorderSupplement.lookup(sdkObject.attribution.context);
        recorder === null || recorder === void 0 ? void 0 : recorder.onAfterCall(sdkObject, metadata);
    }
    async onBeforeInputAction(sdkObject, metadata) {
        const recorder = await recorderSupplement_1.RecorderSupplement.lookup(sdkObject.attribution.context);
        recorder === null || recorder === void 0 ? void 0 : recorder.onBeforeInputAction(sdkObject, metadata);
    }
    async onCallLog(logName, message, sdkObject, metadata) {
        debugLogger_1.debugLogger.log(logName, message);
        const recorder = await recorderSupplement_1.RecorderSupplement.lookup(sdkObject.attribution.context);
        recorder === null || recorder === void 0 ? void 0 : recorder.updateCallLog([metadata]);
    }
}
exports.InspectorController = InspectorController;
//# sourceMappingURL=inspectorController.js.map