import json

# Helper to build YT script
def yt_script(yt):
    parts = []
    parts.append("HOOK: " + yt['hook_section'])
    parts.append("\nOPEN: " + yt['open_section'])
    for sec in yt['sections']:
        sec_lines = ["\n" + sec['name']]
        for pt in sec['points']:
            sec_lines.append("- " + pt)
        parts.append('\n'.join(sec_lines))
    parts.append("\nPROOF: " + yt['proof_section'])
    parts.append("\nCTA: " + yt['close_cta'])
    return '\n\n'.join(parts)

# Helper for short-form clip script
def short_script(clip):
    return "HOOK: " + clip['hook'] + "\n\n" + clip['core_message'] + "\n\nCTA: " + clip['cta']

# Read source JSON
with open('/Users/bryce/FLSM/.tmp/briefs/nurse-charles-2026-04-20/content_data_scripts.json') as f:
    data = json.load(f)

yt1 = data['yt1']
yt2 = data['yt2']
yt3 = data['yt3']
yt4 = data['yt4']
shorts = data['shorts']

# Read HTML files
def read_html(path):
    with open(path) as f:
        return f.read()

blog1_html = read_html('/Users/bryce/FLSM/.tmp/briefs/nurse-charles-2026-04-20/pieces/blog1.html')
blog2_html = read_html('/Users/bryce/FLSM/.tmp/briefs/nurse-charles-2026-04-20/pieces/blog2.html')
blog3_html = read_html('/Users/bryce/FLSM/.tmp/briefs/nurse-charles-2026-04-20/pieces/blog3.html')
email1_html = read_html('/Users/bryce/FLSM/.tmp/briefs/nurse-charles-2026-04-20/pieces/email1.html')
email2_html = read_html('/Users/bryce/FLSM/.tmp/briefs/nurse-charles-2026-04-20/pieces/email2.html')

# YT captions
yt1_caption = yt1['description_lines']
yt2_caption = yt2['description_lines']
yt3_caption = yt3['description_lines']
yt4_caption = yt4['description_lines']

pieces = [
    # --- WEEK 1 ---
    {
        "piece_id": "yt1",
        "title": "What 2,000mg Gas-Station Gummies Actually Do to a Teenager",
        "type": "YouTube Long-Form",
        "platforms": "YouTube",
        "week": 1,
        "day": "Monday",
        "date": "2026-04-20",
        "script": yt_script(yt1),
        "caption": yt1_caption,
        "status": "Draft",
        "notes": "mode: TEACH | proof: proof_dose_confusion_600mg",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short1-li-a",
        "title": shorts['short1']['clips']['linkedin_a']['screen_headline'],
        "type": "Short-Form",
        "platforms": "LinkedIn",
        "week": 1,
        "day": "Tuesday",
        "date": "2026-04-21",
        "script": short_script(shorts['short1']['clips']['linkedin_a']),
        "caption": shorts['short1']['clips']['linkedin_a']['caption'],
        "status": "Draft",
        "notes": "parent: yt1",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short1-li-b",
        "title": shorts['short1']['clips']['linkedin_b']['screen_headline'],
        "type": "Short-Form",
        "platforms": "LinkedIn",
        "week": 1,
        "day": "Tuesday",
        "date": "2026-04-21",
        "script": short_script(shorts['short1']['clips']['linkedin_b']),
        "caption": shorts['short1']['clips']['linkedin_b']['caption'],
        "status": "Draft",
        "notes": "parent: yt1",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short1-reels",
        "title": shorts['short1']['clips']['reels']['screen_headline'],
        "type": "Short-Form",
        "platforms": "Instagram Reels",
        "week": 1,
        "day": "Tuesday",
        "date": "2026-04-21",
        "script": short_script(shorts['short1']['clips']['reels']),
        "caption": shorts['short1']['clips']['reels']['caption'],
        "status": "Draft",
        "notes": "parent: yt1",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short1-tiktok",
        "title": shorts['short1']['clips']['tiktok']['screen_headline'],
        "type": "Short-Form",
        "platforms": "TikTok",
        "week": 1,
        "day": "Tuesday",
        "date": "2026-04-21",
        "script": short_script(shorts['short1']['clips']['tiktok']),
        "caption": shorts['short1']['clips']['tiktok']['caption'],
        "status": "Draft",
        "notes": "parent: yt1",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short1-yt",
        "title": shorts['short1']['clips']['youtube_shorts']['screen_headline'],
        "type": "Short-Form",
        "platforms": "YouTube Shorts",
        "week": 1,
        "day": "Tuesday",
        "date": "2026-04-21",
        "script": short_script(shorts['short1']['clips']['youtube_shorts']),
        "caption": shorts['short1']['clips']['youtube_shorts']['caption'],
        "status": "Draft",
        "notes": "parent: yt1",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "li1",
        "title": "LinkedIn Carousel #1",
        "type": "LinkedIn Carousel",
        "platforms": "LinkedIn",
        "week": 1,
        "day": "Wednesday",
        "date": "2026-04-22",
        "script": "[See: .tmp/briefs/nurse-charles-2026-04-20/pieces/li1.html]",
        "caption": "[See li1.html for caption]",
        "status": "Draft",
        "notes": "proof: proof_2000mg_math_confusion",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "blog1",
        "title": "Delta-8 THC Dangers for Teenagers: What Parents Don't Know",
        "type": "Blog Post",
        "platforms": "Blog",
        "week": 1,
        "day": "Thursday",
        "date": "2026-04-23",
        "script": blog1_html,
        "caption": "[Blog — no caption]",
        "status": "Draft",
        "notes": "",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "blog2",
        "title": "How to Talk to Your Teenager About Drugs: A 4-Step Framework",
        "type": "Blog Post",
        "platforms": "Blog",
        "week": 1,
        "day": "Thursday",
        "date": "2026-04-23",
        "script": blog2_html,
        "caption": "[Blog — no caption]",
        "status": "Draft",
        "notes": "",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "yt3",
        "title": "She Called 911 for a 'Bad Trip.' Here's What the ER Team Actually Found.",
        "type": "YouTube Long-Form",
        "platforms": "YouTube",
        "week": 1,
        "day": "Thursday",
        "date": "2026-04-23",
        "script": yt_script(yt3),
        "caption": yt3_caption,
        "status": "Draft",
        "notes": "mode: TEACH | proof: proof_loss_son_nov18",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short3-li-a",
        "title": shorts['short3']['clips']['linkedin_a']['screen_headline'],
        "type": "Short-Form",
        "platforms": "LinkedIn",
        "week": 1,
        "day": "Thursday",
        "date": "2026-04-23",
        "script": short_script(shorts['short3']['clips']['linkedin_a']),
        "caption": shorts['short3']['clips']['linkedin_a']['caption'],
        "status": "Draft",
        "notes": "parent: yt3",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short3-li-b",
        "title": shorts['short3']['clips']['linkedin_b']['screen_headline'],
        "type": "Short-Form",
        "platforms": "LinkedIn",
        "week": 1,
        "day": "Thursday",
        "date": "2026-04-23",
        "script": short_script(shorts['short3']['clips']['linkedin_b']),
        "caption": shorts['short3']['clips']['linkedin_b']['caption'],
        "status": "Draft",
        "notes": "parent: yt3",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short3-reels",
        "title": shorts['short3']['clips']['reels']['screen_headline'],
        "type": "Short-Form",
        "platforms": "Instagram Reels",
        "week": 1,
        "day": "Thursday",
        "date": "2026-04-23",
        "script": short_script(shorts['short3']['clips']['reels']),
        "caption": shorts['short3']['clips']['reels']['caption'],
        "status": "Draft",
        "notes": "parent: yt3",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short3-tiktok",
        "title": shorts['short3']['clips']['tiktok']['screen_headline'],
        "type": "Short-Form",
        "platforms": "TikTok",
        "week": 1,
        "day": "Thursday",
        "date": "2026-04-23",
        "script": short_script(shorts['short3']['clips']['tiktok']),
        "caption": shorts['short3']['clips']['tiktok']['caption'],
        "status": "Draft",
        "notes": "parent: yt3",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short3-yt",
        "title": shorts['short3']['clips']['youtube_shorts']['screen_headline'],
        "type": "Short-Form",
        "platforms": "YouTube Shorts",
        "week": 1,
        "day": "Thursday",
        "date": "2026-04-23",
        "script": short_script(shorts['short3']['clips']['youtube_shorts']),
        "caption": shorts['short3']['clips']['youtube_shorts']['caption'],
        "status": "Draft",
        "notes": "parent: yt3",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "igtt1",
        "title": "IG/TikTok Carousel #1",
        "type": "IG/TikTok Carousel",
        "platforms": "Instagram, TikTok",
        "week": 1,
        "day": "Friday",
        "date": "2026-04-24",
        "script": "[See: .tmp/briefs/nurse-charles-2026-04-20/pieces/igtt1.html]",
        "caption": "[See igtt1.html for caption]",
        "status": "Draft",
        "notes": "paired mode",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "email1",
        "title": "The text I got at 2am",
        "type": "Nurture Email",
        "platforms": "Email",
        "week": 1,
        "day": "Saturday",
        "date": "2026-04-25",
        "script": email1_html,
        "caption": "[Email — no social caption]",
        "status": "Draft",
        "notes": "",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    # --- WEEK 2 ---
    {
        "piece_id": "yt2",
        "title": "The Shift That Changed How I Think About My Job as an ER Nurse",
        "type": "YouTube Long-Form",
        "platforms": "YouTube",
        "week": 2,
        "day": "Monday",
        "date": "2026-04-27",
        "script": yt_script(yt2),
        "caption": yt2_caption,
        "status": "Draft",
        "notes": "mode: DOCUMENT | proof: proof_emory_30yrs",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short2-li-a",
        "title": shorts['short2']['clips']['linkedin_a']['screen_headline'],
        "type": "Short-Form",
        "platforms": "LinkedIn",
        "week": 2,
        "day": "Tuesday",
        "date": "2026-04-28",
        "script": short_script(shorts['short2']['clips']['linkedin_a']),
        "caption": shorts['short2']['clips']['linkedin_a']['caption'],
        "status": "Draft",
        "notes": "parent: yt2",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short2-li-b",
        "title": shorts['short2']['clips']['linkedin_b']['screen_headline'],
        "type": "Short-Form",
        "platforms": "LinkedIn",
        "week": 2,
        "day": "Tuesday",
        "date": "2026-04-28",
        "script": short_script(shorts['short2']['clips']['linkedin_b']),
        "caption": shorts['short2']['clips']['linkedin_b']['caption'],
        "status": "Draft",
        "notes": "parent: yt2",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short2-reels",
        "title": shorts['short2']['clips']['reels']['screen_headline'],
        "type": "Short-Form",
        "platforms": "Instagram Reels",
        "week": 2,
        "day": "Tuesday",
        "date": "2026-04-28",
        "script": short_script(shorts['short2']['clips']['reels']),
        "caption": shorts['short2']['clips']['reels']['caption'],
        "status": "Draft",
        "notes": "parent: yt2",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short2-tiktok",
        "title": shorts['short2']['clips']['tiktok']['screen_headline'],
        "type": "Short-Form",
        "platforms": "TikTok",
        "week": 2,
        "day": "Tuesday",
        "date": "2026-04-28",
        "script": short_script(shorts['short2']['clips']['tiktok']),
        "caption": shorts['short2']['clips']['tiktok']['caption'],
        "status": "Draft",
        "notes": "parent: yt2",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short2-yt",
        "title": shorts['short2']['clips']['youtube_shorts']['screen_headline'],
        "type": "Short-Form",
        "platforms": "YouTube Shorts",
        "week": 2,
        "day": "Tuesday",
        "date": "2026-04-28",
        "script": short_script(shorts['short2']['clips']['youtube_shorts']),
        "caption": shorts['short2']['clips']['youtube_shorts']['caption'],
        "status": "Draft",
        "notes": "parent: yt2",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "li2",
        "title": "LinkedIn Carousel #2",
        "type": "LinkedIn Carousel",
        "platforms": "LinkedIn",
        "week": 2,
        "day": "Wednesday",
        "date": "2026-04-29",
        "script": "[See: .tmp/briefs/nurse-charles-2026-04-20/pieces/li2.html]",
        "caption": "[See li2.html for caption]",
        "status": "Draft",
        "notes": "CONTRARIAN | proof: proof_federal_rescheduling",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "blog3",
        "title": "Cannabis Overdose: What an ER Nurse Sees That the Safety Debate Misses",
        "type": "Blog Post",
        "platforms": "Blog",
        "week": 2,
        "day": "Thursday",
        "date": "2026-04-30",
        "script": blog3_html,
        "caption": "[Blog — no caption]",
        "status": "Draft",
        "notes": "",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "yt4",
        "title": "The 4-Step Clinical Framework for Talking to Your Teenager About Substances",
        "type": "YouTube Long-Form",
        "platforms": "YouTube",
        "week": 2,
        "day": "Thursday",
        "date": "2026-04-30",
        "script": yt_script(yt4),
        "caption": yt4_caption,
        "status": "Draft",
        "notes": "mode: TEACH | proof: proof_parents_talk_11yrs",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short4-li-a",
        "title": shorts['short4']['clips']['linkedin_a']['screen_headline'],
        "type": "Short-Form",
        "platforms": "LinkedIn",
        "week": 2,
        "day": "Thursday",
        "date": "2026-04-30",
        "script": short_script(shorts['short4']['clips']['linkedin_a']),
        "caption": shorts['short4']['clips']['linkedin_a']['caption'],
        "status": "Draft",
        "notes": "parent: yt4",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short4-li-b",
        "title": shorts['short4']['clips']['linkedin_b']['screen_headline'],
        "type": "Short-Form",
        "platforms": "LinkedIn",
        "week": 2,
        "day": "Thursday",
        "date": "2026-04-30",
        "script": short_script(shorts['short4']['clips']['linkedin_b']),
        "caption": shorts['short4']['clips']['linkedin_b']['caption'],
        "status": "Draft",
        "notes": "parent: yt4",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short4-reels",
        "title": shorts['short4']['clips']['reels']['screen_headline'],
        "type": "Short-Form",
        "platforms": "Instagram Reels",
        "week": 2,
        "day": "Thursday",
        "date": "2026-04-30",
        "script": short_script(shorts['short4']['clips']['reels']),
        "caption": shorts['short4']['clips']['reels']['caption'],
        "status": "Draft",
        "notes": "parent: yt4",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short4-tiktok",
        "title": shorts['short4']['clips']['tiktok']['screen_headline'],
        "type": "Short-Form",
        "platforms": "TikTok",
        "week": 2,
        "day": "Thursday",
        "date": "2026-04-30",
        "script": short_script(shorts['short4']['clips']['tiktok']),
        "caption": shorts['short4']['clips']['tiktok']['caption'],
        "status": "Draft",
        "notes": "parent: yt4",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "short4-yt",
        "title": shorts['short4']['clips']['youtube_shorts']['screen_headline'],
        "type": "Short-Form",
        "platforms": "YouTube Shorts",
        "week": 2,
        "day": "Thursday",
        "date": "2026-04-30",
        "script": short_script(shorts['short4']['clips']['youtube_shorts']),
        "caption": shorts['short4']['clips']['youtube_shorts']['caption'],
        "status": "Draft",
        "notes": "parent: yt4",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "igtt2",
        "title": "IG/TikTok Carousel #2",
        "type": "IG/TikTok Carousel",
        "platforms": "Instagram, TikTok",
        "week": 2,
        "day": "Friday",
        "date": "2026-05-01",
        "script": "[See: .tmp/briefs/nurse-charles-2026-04-20/pieces/igtt2.html]",
        "caption": "[See igtt2.html for caption]",
        "status": "Draft",
        "notes": "independent mode",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
    {
        "piece_id": "email2",
        "title": "The 11 comments that convinced me to make something free",
        "type": "Nurture Email",
        "platforms": "Email",
        "week": 2,
        "day": "Saturday",
        "date": "2026-05-02",
        "script": email2_html,
        "caption": "[Email — no social caption]",
        "status": "Draft",
        "notes": "value CTA only",
        "images": "",
        "platform_schedule": "",
        "post_link": ""
    },
]

output = {
    "cycle_id": "nurse-charles-2026-04-20",
    "generated_at": "2026-04-24",
    "pieces": pieces
}

out_path = '/Users/bryce/FLSM/.tmp/briefs/nurse-charles-2026-04-20/sheet_staging.json'
with open(out_path, 'w') as f:
    json.dump(output, f, indent=2, ensure_ascii=False)

print("Written to " + out_path)
print("Total pieces: " + str(len(pieces)))
