/**
 * Centrally handles variable resolution for the framework.
 */
export class VariableResolver {
    /**
     * Resolves {{variable}} patterns in a string using ExecutionContext (inputs and store).
     */
    static resolve(text, context) {
        if (!text || typeof text !== "string")
            return text || "";
        return text.replace(/\{\{(.+?)\}\}/g, (match, key) => {
            const trimmedKey = key.trim();
            // 1. Check Dynamic Store (Scraped values during runtime)
            const val = context.store.get(trimmedKey);
            if (val !== undefined) {
                return String(val);
            }
            // 2. Check Scenario Inputs (Static Filters/Data Files)
            if (context.inputs && context.inputs[trimmedKey] !== undefined) {
                return String(context.inputs[trimmedKey]);
            }
            // 3. Fallback to original match if not found
            return match;
        });
    }
}
