export const VIRAL_SCAN_PIPELINE_STEPS = [
  { id: 'viral_crawl', title: '爆款海巡', hint: '依關鍵字搜尋 Threads 熱門貼文' },
] as const

const ACTIVE_COPY_PERSONA_KEY = 'haixun.copyPersonaId'
export const COPY_PERSONA_CHANGED_EVENT = 'haixun.copy-persona-changed'

export function rememberCopyPersonaId(personaId: string) {
  const id = personaId.trim()
  if (!id) return
  try {
    sessionStorage.setItem(ACTIVE_COPY_PERSONA_KEY, id)
    window.dispatchEvent(new CustomEvent(COPY_PERSONA_CHANGED_EVENT, { detail: { id } }))
  } catch {
    // ignore
  }
}

export function getActiveCopyPersonaId(): string {
  try {
    return sessionStorage.getItem(ACTIVE_COPY_PERSONA_KEY)?.trim() ?? ''
  } catch {
    return ''
  }
}