"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getChainId = void 0;
const getChainId = (tree, targetValue) => {
    const chainId = [];
    const targetId = targetValue && typeof targetValue === 'object'
        ? targetValue.id
        : targetValue;
    const findChain = (node) => {
        chainId.push(node.id);
        if (node.id === targetId) {
            return true;
        }
        if (node.children) {
            for (const child of node.children) {
                if (findChain(child)) {
                    return true;
                }
            }
        }
        chainId.pop();
        return false;
    };
    for (const node of tree) {
        if (findChain(node)) {
            return chainId;
        }
    }
    return [];
};
exports.getChainId = getChainId;
