"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.MablSymbol = exports.SINGLE_VARIABLE_PATTERN_REGEX = exports.VARIABLE_PATTERN_REGEX = void 0;
exports.formatSymbol = formatSymbol;
exports.isMablSymbolObject = isMablSymbolObject;
exports.VARIABLE_PATTERN_REGEX = /{{@([_.a-zA-Z0-9\[\]]+)}}/g;
exports.SINGLE_VARIABLE_PATTERN_REGEX = /^{{@([_.a-zA-Z0-9\[\]]+)}}$/;
class MablSymbol {
    name;
    tokens;
    constructor(fullyQualifiedName) {
        this.name = fullyQualifiedName;
        this.tokens = fullyQualifiedName.split('.');
    }
    static fromString(formatted) {
        const regEx = '{{@(?<name>.*)}}';
        const found = formatted.match(regEx);
        if (!found?.groups) {
            throw new Error(`Invalid MablSymbol format: ${formatted}`);
        }
        const name = found.groups.name;
        return new MablSymbol(name);
    }
    toString() {
        return formatSymbol(this);
    }
}
exports.MablSymbol = MablSymbol;
function formatSymbol(symbol) {
    if (isMablSymbolObject(symbol)) {
        return '{{@' + symbol.name + '}}';
    }
    return '{{@' + symbol + '}}';
}
function isMablSymbolObject(value) {
    return !!(value?.name && value?.tokens);
}
