package persona

import (
	domusecase "haixun-backend/internal/model/persona/domain/usecase"
	"haixun-backend/internal/types"
)

func toPersonaData(item domusecase.PersonaSummary) types.PersonaData {
	return types.PersonaData{
		ID:              item.ID,
		DisplayName:     item.DisplayName,
		Persona:         item.Persona,
		Brief:           item.Brief,
		StyleProfile:    item.StyleProfile,
		StyleBenchmark:  item.StyleBenchmark,
		SeedQuery:       item.SeedQuery,
		CopyResearchMap: toCopyResearchMapData(item.CopyResearchMap),
		CreateAt:        item.CreateAt,
		UpdateAt:        item.UpdateAt,
	}
}

func toCopyResearchMapData(item domusecase.CopyResearchMapSummary) types.CopyResearchMapData {
	return types.CopyResearchMapData{
		AudienceSummary: item.AudienceSummary,
		ContentGoal:     item.ContentGoal,
		Questions:       item.Questions,
		Pillars:         item.Pillars,
		Exclusions:      item.Exclusions,
		SuggestedTags:   item.SuggestedTags,
		BenchmarkNotes:  item.BenchmarkNotes,
	}
}

func toListData(result *domusecase.ListResult) *types.ListPersonasData {
	if result == nil {
		return &types.ListPersonasData{List: []types.PersonaData{}}
	}
	list := make([]types.PersonaData, 0, len(result.List))
	for _, item := range result.List {
		list = append(list, toPersonaData(item))
	}
	return &types.ListPersonasData{List: list}
}

func toPersonaPatch(req *types.UpdatePersonaReq) domusecase.PersonaPatch {
	if req == nil {
		return domusecase.PersonaPatch{}
	}
	return domusecase.PersonaPatch{
		DisplayName:    req.DisplayName,
		Persona:        req.Persona,
		Brief:          req.Brief,
		StyleProfile:   req.StyleProfile,
		StyleBenchmark: req.StyleBenchmark,
	}
}
