var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
    if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
    if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
    return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var _TemporalRuntime_instances, _TemporalRuntime_genericTemporalFunc;
// Copyright Metatype OÜ, licensed under the Mozilla Public License Version 2.0.
// SPDX-License-Identifier: MPL-2.0
import "../_dnt.polyfills.js";
import { Runtime } from "../runtimes/mod.js";
import { runtimes } from "../wit.js";
import { Func } from "../types.js";
export class TemporalRuntime extends Runtime {
    constructor({ name, hostSecret, namespaceSecret, }) {
        const id = runtimes.registerTemporalRuntime({
            name,
            hostSecret,
            namespaceSecret,
        });
        super(id);
        _TemporalRuntime_instances.add(this);
        Object.defineProperty(this, "name", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
        Object.defineProperty(this, "hostSecret", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
        Object.defineProperty(this, "namespaceSecret", {
            enumerable: true,
            configurable: true,
            writable: true,
            value: void 0
        });
        this.name = name;
        this.hostSecret = hostSecret;
        this.namespaceSecret = namespaceSecret;
    }
    /** create a function to start a workflow */
    startWorkflow(workflowType, arg) {
        return __classPrivateFieldGet(this, _TemporalRuntime_instances, "m", _TemporalRuntime_genericTemporalFunc).call(this, {
            tag: "start-workflow",
        }, workflowType, arg);
    }
    /** create a function to signal a workflow */
    signalWorkflow(signalName, arg) {
        return __classPrivateFieldGet(this, _TemporalRuntime_instances, "m", _TemporalRuntime_genericTemporalFunc).call(this, {
            tag: "signal-workflow",
        }, signalName, arg);
    }
    /** create a function to query a workflow */
    queryWorkflow(queryType, arg, out) {
        return __classPrivateFieldGet(this, _TemporalRuntime_instances, "m", _TemporalRuntime_genericTemporalFunc).call(this, {
            tag: "query-workflow",
        }, queryType, arg, out);
    }
    /** create a function that describes a workflow */
    describeWorkflow() {
        return __classPrivateFieldGet(this, _TemporalRuntime_instances, "m", _TemporalRuntime_genericTemporalFunc).call(this, { tag: "describe-workflow" });
    }
}
_TemporalRuntime_instances = new WeakSet(), _TemporalRuntime_genericTemporalFunc = function _TemporalRuntime_genericTemporalFunc(operation, matArg, funcArg, funcOut) {
    const data = {
        matArg,
        funcArg: funcArg?._id,
        funcOut: funcOut?._id,
        operation,
    };
    const dataFunc = runtimes.generateTemporalOperation(this._id, data);
    return Func.fromTypeFunc(dataFunc);
};
