"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.$getSetup = exports.$getAnimations = exports.$refParentChildContainer = exports.$refParentRootContainer = exports.$refChildContainer = exports.$refChild = exports.$children = exports.$child = exports.$hasChild = exports.$removeChild = exports.$appendChild = void 0;
const proxyWrap_1 = require("../proxyWrap");
const Async_1 = require("../types/interface/async/Async");
function $appendChild(component, Class, callback) {
    const i = component.appendChild(Class);
    callback(i);
}
exports.$appendChild = $appendChild;
function $removeChild(component, { at }, callback) {
    try {
        const child = component.removeChild(at);
        const bundle = child.getUnitBundleSpec();
        const specId = bundle.unit.id;
        callback({ specId });
    }
    catch (err) {
        callback(undefined, err.message);
    }
}
exports.$removeChild = $removeChild;
function $hasChild(component, { at }, callback) {
    const has = component.hasChild(at);
    callback(has);
}
exports.$hasChild = $hasChild;
function $child(component, { at }, callback) {
    const child = component.refChild(at);
    // @ts-ignore
    const id = child.constructor.id;
    callback(id);
}
exports.$child = $child;
function $children(component, {}, callback) {
    const children = component.refChildren();
    const _children = children.map((c) => {
        return { bundle: c.getUnitBundleSpec() };
    });
    callback(_children);
}
exports.$children = $children;
function $refChild(component, { at, _ }) {
    const child = component.refChild(at);
    const $child = (0, Async_1.Async)(child, _);
    return (0, proxyWrap_1.proxyWrap)($child, _);
}
exports.$refChild = $refChild;
function $refChildContainer(component, { at, _ }) {
    const container = component.refChildContainer(at);
    const $container = (0, Async_1.Async)(container, _);
    return (0, proxyWrap_1.proxyWrap)($container, _);
}
exports.$refChildContainer = $refChildContainer;
function $refParentRootContainer(component, { at, _ }) {
    const container = component.refParentRootContainer(at);
    const local_child = (0, Async_1.Async)(container, _);
    return (0, proxyWrap_1.proxyWrap)(local_child, _);
}
exports.$refParentRootContainer = $refParentRootContainer;
function $refParentChildContainer(component, { at, _ }) {
    const container = component.refParentChildContainer(at);
    const local_child = (0, Async_1.Async)(container, _);
    return (0, proxyWrap_1.proxyWrap)(local_child, _);
}
exports.$refParentChildContainer = $refParentChildContainer;
function $getAnimations(component, data, callback) {
    const animations = component.getAnimations();
    callback(animations);
}
exports.$getAnimations = $getAnimations;
function $getSetup(component, data, callback) {
    const setup = component.getSetup();
    callback(setup);
}
exports.$getSetup = $getSetup;
//# sourceMappingURL=$component.js.map