// witness-i18n.jsx — translations + t() helper.
// Two languages: English and Traditional Chinese. The active language lives on
// window.__witnessLang and is rendered through React state held in App, so a
// switch triggers a full re-render (same paint key as the metal swap).

const I18N = {
  en: {
    // Mode toggle
    mode_list: "LIST",
    mode_goals: "GOALS",

    // List-mode segments
    cat_overdue: "Overdue",
    cat_today: "Today",
    cat_next7: "Next 7 Days",
    cat_inbox: "Inbox",
    cat_abandoned: "Abandoned",

    // Goal-mode default
    cat_all_axes: "All Axes",

    // Header date
    day_serial: "DAY",
    of_365: "/ 365",
    cohort: "COHORT",
    week: "W",

    // Confession copy
    statement_1: "I am witnessing",
    statement_2: "myself become.",
    statement_you_are: "You are",
    statement_what_time: "what time confirms.",

    // Accumulated panel
    accum_mass: "ACCUMULATED MASS · TODAY",
    sessions: "SESSIONS",
    target: "TARGET",
    now: "NOW",

    // Buttons / capsules
    btn_lock_focus: "Lock & Focus",
    label_strict: "STRICT MODE · 6 APPS WILL BE SEALED",
    btn_settle: "▸ Settle the Day ◂",
    label_all_logged: "ALL ENTRIES LOGGED",
    btn_abandon: "Abandon",
    btn_log_seal: "Log & Seal Entry",
    btn_seal: "Seal",
    btn_proof_recorded: "Today\u2019s Proof Is Recorded",
    label_no_reward: "NO REWARD · NO PRAISE · ONLY RECORD",
    hint_etch: "PRESSING WILL ETCH THIS DAY INTO YOUR LIFETIME LEDGER",

    // Section labels
    today_ledger: "TODAY · LEDGER ENTRIES",
    est: "EST",
    lifetime_total: "LIFETIME ACCUMULATED · ALL AXES",
    days_recorded: "DAYS RECORDED",
    witness_index: "WITNESS INDEX",
    broken_seals: "BROKEN SEALS",
    identity_axes: "IDENTITY AXES",
    active: "ACTIVE",
    mass: "MASS",
    axis: "AXIS",
    streak: "STREAK",
    today_short: "TODAY",
    h: "h",
    h_caps: "H",
    of: "of",
    cap: "CAP",

    // Timer
    // Timer
    pomo: "Pomo",
    stopwatch: "Stopwatch",
    stopwatch_running: "STOPWATCH · RUNNING",
    focus_phase: "FOCUS PHASE",
    break_phase: "BREAK · REST",
    cycle: "cycle",
    mins_acc: "min logged",
    pause: "Pause",
    resume: "Resume",
    skip: "Skip",
    save_and_log: "Save & Log",
    select_task: "Select a task …",
    pick_task: "PICK A TASK",
    search: "Search tasks",
    no_matches: "No matches.",
    focusing: "FOCUSING · STRICT MODE",
    focusing_on: "FOCUSING ON",
    session_no: "SESSION",
    witnessing_id: "WITNESSING IDENTITY",
    remaining: "REMAINING",
    elapsed: "ELAPSED",
    being_etched: "BEING ETCHED · SESSION MASS",
    apps_sealed: "6 APPS SEALED",
    apps_sealed_short: "sealed",
    apps_released: "released today",
    to_clear: "left to clear",
    empty_list: "No tasks in this category.",
    section_incomplete: "Incomplete",
    section_complete: "Completed",
    section_overdue: "Overdue",
    section_today: "Today",
    section_future: "Upcoming",
    break_warning: "BREAK = LOG BROKEN SEAL",

    // App lock
    lock_config: "SEAL · APP LOCK CONFIG",
    what_costs: "What costs you",
    your_hours: "your hours.",
    apps_to_seal: "APPS TO SEAL",
    of_total: "/ TOTAL",
    lifetime_cost: "EST · LIFETIME COST",
    unlock_cond: "UNLOCK CONDITION",
    cond_all_tasks: "All today\u2019s entries logged",
    cond_all_sub: "Default · earn unlock by completion",
    cond_hours: "After 4h of recorded mass",
    cond_hours_sub: "Time-based · strictest",
    cond_midnight: "Until 00:00 of next day",
    cond_midnight_sub: "Locked all day, no exceptions",
    installed_tap: "INSTALLED · TAP TO SEAL",
    locked: "LOCKED",
    will_be_sealed: "WILL BE SEALED",
    permitted: "PERMITTED",

    // Settlement
    settlement: "DAILY SETTLEMENT · SEAL",
    due_result_en: "The Due Result.",
    due_result_zh: "應得的結果",
    statement_today: "TODAY, YOU ARE SOMEONE WHO",
    invested_word: "invested",
    of_time: "of his time into",
    becoming: "becoming who he wants to be.",
    on_identity: "ON IDENTITY",
    off_friction: "OFF / FRICTION",
    time_dist: "TIME DISTRIBUTION · 24:00:00 LEDGER",
    invested: "INVESTED",
    etched_into: "ETCHED INTO LIFETIME AXES TODAY",
    idle_friction: "IDLE / FRICTION",

    // Bottom sheet
    sheet_lists: "LISTS",
    sheet_axes: "YOUR IDENTITY AXES",
    sheet_swipe: "SWIPE OR TAP TO SWITCH",
    add_category: "New Topic",
    settings: "Settings",
    app_lock: "App Lock",
  },

  zh: {
    mode_list: "列表",
    mode_goals: "目標",

    cat_overdue: "已過期",
    cat_today: "今天",
    cat_next7: "未來七天",
    cat_inbox: "蒐集箱",
    cat_abandoned: "已放棄",
    cat_all_axes: "全部身分軸",

    day_serial: "第",
    of_365: "/ 365 天",
    cohort: "群組",
    week: "週",

    statement_1: "我正在見證",
    statement_2: "自己的成形。",
    statement_you_are: "你即是",
    statement_what_time: "時間所確認之物。",

    accum_mass: "累計專注時間 · 今日",
    sessions: "專注場次",
    target: "目標",
    now: "當下",

    btn_lock_focus: "鎖定 · 專注",
    label_strict: "進入嚴格模式 · 6 個 APP 將被封印",
    btn_settle: "▸ 結算今日 ◂",
    label_all_logged: "今日全部已登入分類帳",
    btn_abandon: "放棄",
    btn_log_seal: "登入並封存",
    btn_seal: "封印",
    btn_proof_recorded: "今日之證已被記錄",
    label_no_reward: "不獎勵 · 不誇讚 · 僅留下記錄",
    hint_etch: "按下後將把此日刻入你的終身分類帳",

    today_ledger: "今日 · 分類帳條目",
    est: "預估",
    lifetime_total: "終身累積 · 全部身分軸",
    days_recorded: "記錄天數",
    witness_index: "見證指數",
    broken_seals: "失敗封印",
    identity_axes: "身分軸",
    active: "活躍",
    mass: "累積",
    axis: "軸",
    streak: "連續",
    today_short: "今日",
    h: "時",
    h_caps: "時",
    of: "共",
    cap: "上限",

    // Timer
    pomo: "蕕茄鐘",
    stopwatch: "計時表",
    stopwatch_running: "計時表 · 計時中",
    focus_phase: "專注階段",
    break_phase: "休息 · 調息",
    cycle: "一輪",
    mins_acc: "分鐘已記錄",
    pause: "暫停",
    resume: "繼續",
    skip: "結束",
    save_and_log: "結束",
    select_task: "選擇項目 …",
    pick_task: "選擇項目",
    search: "搜尋項目",
    no_matches: "無符合項目。",
    focusing: "專注中 · 嚴格模式",
    focusing_on: "正在專注",
    session_no: "場次",
    witnessing_id: "見證之身分",
    remaining: "剩餘",
    elapsed: "已過",
    being_etched: "正在刻入 · 本次專注量",
    apps_sealed: "6 個 APP 已封印",
    apps_sealed_short: "已封印",
    apps_released: "今日已解封",
    to_clear: "項未清",
    empty_list: "此分類下無任務。",
    section_incomplete: "未完成",
    section_complete: "已完成",
    section_overdue: "已過期",
    section_today: "今天",
    section_future: "未來",
    break_warning: "中斷將記錄為破封",

    lock_config: "封印 · 應用程式鎖設定",
    what_costs: "什麼正在消耗",
    your_hours: "你的時間。",
    apps_to_seal: "將被封印的 APP",
    of_total: "/ 全部",
    lifetime_cost: "預估 · 終身耗損",
    unlock_cond: "解封條件",
    cond_all_tasks: "今日全部條目皆已登入",
    cond_all_sub: "預設 · 以完成換取解封",
    cond_hours: "累積專注 4 小時後",
    cond_hours_sub: "以時長為準 · 最嚴格",
    cond_midnight: "至次日 00:00",
    cond_midnight_sub: "整日封印 · 無例外",
    installed_tap: "已安裝 · 點擊以封印",
    locked: "已封印",
    will_be_sealed: "將被封印",
    permitted: "允許",

    settlement: "今日結算 · 封印",
    due_result_en: "應得的結果。",
    due_result_zh: "THE DUE RESULT",
    statement_today: "今日的你，是一個",
    invested_word: "投入了",
    of_time: "的時間，以",
    becoming: "成為自己想成為的人。",
    on_identity: "於身分",
    off_friction: "損耗 / 摩擦",
    time_dist: "時間分佈 · 24:00:00 分類帳",
    invested: "已投入",
    etched_into: "今日刻入終身身分軸",
    idle_friction: "閒置 / 摩擦",

    sheet_lists: "列表",
    sheet_axes: "你的身分軸",
    sheet_swipe: "滑動或點擊以切換",
    add_category: "新增主題",
    settings: "設定",
    app_lock: "應用程式鎖",
  },
};

// Live lang lives on window so non-React code (status bar, etc.) can read it.
if (typeof window !== "undefined")
  window.__witnessLang = window.__witnessLang || "en";

function t(key) {
  const lang = (typeof window !== "undefined" && window.__witnessLang) || "en";
  return (I18N[lang] && I18N[lang][key]) || I18N.en[key] || key;
}

function setLang(name) {
  if (typeof window !== "undefined")
    window.__witnessLang = I18N[name] ? name : "en";
}

Object.assign(window, { I18N, t, setLang });
