// PRE-GENERATED (design session). Picks the live writer if APO is present, else preview mode.
// Resolution order: user-set path (settings) -> default install location -> null (preview).
using System.IO;
using DansoriEQ.Core.Apo;

namespace DansoriEQ.App.Apo;

public static class ApoWriterFactory
{
    public static string? ResolveConfigDir()
    {
        var s = AppSettings.Load();
        if (!string.IsNullOrEmpty(s.ApoConfigDir) && Directory.Exists(s.ApoConfigDir))
            return s.ApoConfigDir;
        return ApoLocator.FindConfigDir();
    }

    public static IApoWriter Create()
    {
        var dir = ResolveConfigDir();
        return dir != null ? new ApoIncludeWriter(dir) : new NullApoWriter();
    }
}
