package git

import "strings"

var rootDocFiles = map[string]struct{}{
	"readme.md":        {},
	"architecture.md":  {},
	"contributing.md":  {},
	"deployment.md":    {},
	"onboarding.md":    {},
	"changelog.md":     {},
	"features.md":      {},
	"overview.md":      {},
}

var recursiveDocDirs = []string{"docs", "adr", "runbooks", "guides", "doc"}

// IsParseableDocPath reports whether docs-ingestion can ingest a markdown path.
func IsParseableDocPath(path string) bool {
	normalized := strings.ReplaceAll(path, `\`, "/")
	normalized = strings.Trim(normalized, "/")
	if normalized == "" {
		return false
	}

	lowered := strings.ToLower(normalized)
	if !strings.HasSuffix(lowered, ".md") {
		return false
	}

	if !strings.Contains(lowered, "/") {
		_, ok := rootDocFiles[lowered]
		return ok
	}

	for _, prefix := range recursiveDocDirs {
		if strings.HasPrefix(lowered, prefix+"/") {
			return true
		}
	}
	return false
}
