package catalog import ( "crypto/sha256" "encoding/hex" "strings" "github.com/descrybe/descrybe-v2/apps/api/internal/company" ) // DefaultPromptHash versions platform translations by the exact English formula. // Editing a built-in formula therefore cannot accidentally apply stale translations. func DefaultPromptHash(source string) string { sum := sha256.Sum256([]byte(source)) return hex.EncodeToString(sum[:]) } // IsUntouchedDefaultPrompt ensures tenant-authored prompts are NEVER translated, // modified, or mistaken for the platform's default. A language override is // eligible only when it is an exact copy of a previously seeded default. func IsUntouchedDefaultPrompt(prompts company.LangPromptMap, source string, seeded company.LangPromptMap) bool { if strings.TrimSpace(source) == "" { return false } for code, value := range prompts { value = strings.TrimSpace(value) if value == "" { continue } if code == "*" || code == "en" { if value != source { return false } continue } if !company.IsAllowedLanguage(code) || strings.TrimSpace(seeded[code]) != value { return false } } return true }