"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.AsyncJ = exports.AsyncJRef = exports.AsyncJWatch = exports.AsyncJCall = void 0;
const evaluate_1 = require("../../../spec/evaluate");
const AsyncJCall = (value) => {
    return {
        $get({ name }, callback) {
            ;
            (() => __awaiter(this, void 0, void 0, function* () {
                let data;
                try {
                    data = yield value.get(name);
                }
                catch (err) {
                    callback(undefined, err.message);
                }
                callback(data);
            }))();
        },
        $set({ name, data }, callback) {
            ;
            (() => __awaiter(this, void 0, void 0, function* () {
                try {
                    const _data = (0, evaluate_1.evaluate)(data, {}, {});
                    yield value.set(name, _data);
                }
                catch (err) {
                    callback(undefined, err.message);
                }
                callback();
            }))();
        },
    };
};
exports.AsyncJCall = AsyncJCall;
const AsyncJWatch = (value) => {
    return {};
};
exports.AsyncJWatch = AsyncJWatch;
const AsyncJRef = (value) => {
    return {};
};
exports.AsyncJRef = AsyncJRef;
const AsyncJ = (value) => {
    return Object.assign(Object.assign(Object.assign({}, (0, exports.AsyncJCall)(value)), (0, exports.AsyncJWatch)(value)), (0, exports.AsyncJRef)(value));
};
exports.AsyncJ = AsyncJ;
//# sourceMappingURL=AsyncJ.js.map