package style8d

import "strings"

// AnalyzeMode selects how reference samples are interpreted.
type AnalyzeMode string

const (
	AnalyzeModeBenchmark AnalyzeMode = "benchmark"
	AnalyzeModeManual    AnalyzeMode = "manual"
)

// AnalyzeInput groups prompt + storage options for one 8D run.
type AnalyzeInput struct {
	Mode        AnalyzeMode
	Username    string
	SourceLabel string
	Brief       string
	Posts       []Post
}

func (in AnalyzeInput) BuildUserPrompt() string {
	if in.Mode == AnalyzeModeManual || strings.TrimSpace(in.Username) == "" {
		return BuildUserPromptFromTexts(in.SourceLabel, in.Brief, in.Posts)
	}
	return BuildUserPrompt(in.Username, in.Posts)
}

func (in AnalyzeInput) BuildStoredProfile(out LLMOutput) StoredProfile {
	if in.Mode == AnalyzeModeManual || strings.TrimSpace(in.Username) == "" {
		return BuildStoredProfileFromTexts(in.SourceLabel, in.Posts, out)
	}
	return BuildStoredProfile(in.Username, in.Posts, out)
}

func (in AnalyzeInput) StyleBenchmark() string {
	if in.Mode == AnalyzeModeManual || strings.TrimSpace(in.Username) == "" {
		return ManualStyleBenchmark(in.SourceLabel)
	}
	return strings.TrimPrefix(strings.TrimSpace(in.Username), "@")
}
