package worker

import "strings"

const scriptAnalysisOutputRules = `将分析目标能够对应到标准字段的结果写入标准字段；无法对应到标准字段的目标写入 custom_analysis；因原文信息不足或目标不适用于剧本而无法完成的目标写入 unmatched_objectives。不得为了填充标准字段而曲解分析目标。

必须只返回一个合法 JSON 对象，不得输出 Markdown、代码围栏、解释或额外文字。所有字段均须存在并严格符合以下结构：
{
  "tags": {
    "drama_tags": ["标签"],
    "applicable_scene_tags": ["适用场景标签"]
  },
  "selling_point": {
    "summary": "一句话总结",
    "highlights": [
      {"type": "爽点|痛点|卖点|看点", "content": "具体内容"}
    ]
  },
  "story_structure": {
    "synopsis": "短剧简介",
    "story_outline": ["按故事阶段组织的大纲"],
    "emotion_outline": [
      {"stage": "情绪阶段", "emotion": "主导情绪", "description": "情绪变化"}
    ],
    "episode_outlines": [
      {"episode_no": 1, "title": "集标题", "outline": "本集大纲", "emotion": "本集情绪"}
    ],
    "characters": [
      {"name": "人物名", "faction": "正派|反派|中立派", "biography": "人物小传", "motivation": "核心动机", "relationship": "关键人物关系"}
    ]
  },
  "opening_hook": {
    "first_scene": "开篇第一个画面或场景",
    "first_line": "第一句台词",
    "attention_methods": ["悬念前置|激烈冲突|视觉奇观|其他明确手法"],
    "analysis": "为什么能或不能抓住观众",
    "optimization": "必要时给出优化建议"
  },
  "episode_hooks": [
    {"episode_no": 1, "hook_type": "钩子类型", "hook": "本集结尾或关键卡点钩子", "basis": "对应的原文依据或信息不足说明"}
  ],
  "episode_10_paywall_hooks": [
    {"hook_type": "钩子类型", "content": "付费卡点候选", "appeal": "促使继续付费观看的原因"}
  ],
  "custom_analysis": [
    {"objective": "无法对应标准字段的分析目标", "conclusion": "分析结论", "evidence": ["剧本原文依据"]}
  ],
  "unmatched_objectives": [
    {"objective": "无法完成的分析目标", "reason": "无法完成的原因"}
  ]
}

仅当分析目标要求逐集钩子时，episode_hooks 必须按 episode_no 从1到10排列且恰好返回10项；仅当分析目标要求第10集付费卡点时，episode_10_paywall_hooks 返回3至5项。其他情况下对应数组返回空数组。`

func scriptAnalysisSystemPrompt(analysisGoal string) string {
	goal := strings.TrimSpace(analysisGoal)
	if goal == "" {
		return scriptAnalysisOutputRules
	}
	return goal + "\n\n" + scriptAnalysisOutputRules
}
