package placement

import "strings"

func ResolveReplyTargetID(externalID, permalink string) string {
	if id := strings.TrimSpace(externalID); id != "" {
		return id
	}
	permalink = normalizeThreadsPermalink(permalink)
	if permalink == "" {
		return ""
	}
	match := threadsPostURLRe.FindStringSubmatch(permalink)
	if len(match) < 3 {
		return ""
	}
	return strings.TrimSpace(match[2])
}
