using PowderCoating.Application.DTOs.Company;

namespace PowderCoating.Application.Interfaces;

public interface ICustomFormulaAiService
{
    /// <summary>
    /// Generates a NCalc formula, field list, and notes from a natural-language description
    /// and an optional diagram image. Returns a <see cref="GenerateFormulaFromAiResponse"/>
    /// ready to pre-fill the template editor.
    /// </summary>
    Task<GenerateFormulaFromAiResponse> GenerateFormulaAsync(
        GenerateFormulaFromAiRequest request,
        byte[]? imageBytes = null,
        string? imageContentType = null);

    /// <summary>
    /// Evaluates a NCalc formula with the supplied variable map and returns the numeric result.
    /// Safe server-side only — no user-controlled code execution.
    /// </summary>
    EvaluateFormulaResponse EvaluateFormula(EvaluateFormulaRequest request);

    /// <summary>
    /// Normalizes NCalc built-in function names to lowercase (IF→if, Abs→abs, etc.) then
    /// attempts a parse-only evaluation to catch syntax errors before the formula is saved.
    /// Returns the normalized formula string and a null error on success, or the original
    /// formula and an error message on failure.
    /// </summary>
    (string NormalizedFormula, string? Error) NormalizeAndValidate(string formula);
}
