// Shared illustrative data for all three Arca dashboard variations.
// Everything here maps to real Arca concepts: soul, memory, skills, sessions,
// tools, channels, tasks, token spend. No made-up spy/ops vocabulary.

const ARCA_NOW = '2026-04-22 14:07:33 EDT';

const ARCA_AGENTS = [
  { id: 'arca-0', name: 'arca',            role: 'orchestrator', state: 'thinking',  parent: null,      turns: 4817, tokensIn: 1_284_912, tokensOut: 312_804, spend: 12.41, session: 's-4819', pid: 28471, started: '72h 14m ago',  model: 'sonnet-4.6', skills: ['soul'] },
  { id: 'arca-1', name: 'code-reviewer',   role: 'subagent',    state: 'tool-call',  parent: 'arca-0', turns: 12,   tokensIn: 18_402,    tokensOut: 4_211,  spend: 0.28,  session: 's-4819', pid: 31902, started: '00h 03m ago',  model: 'sonnet-4.6', skills: ['code_review'] },
  { id: 'arca-2', name: 'research-scout',  role: 'subagent',    state: 'streaming',  parent: 'arca-0', turns: 7,    tokensIn: 9_018,     tokensOut: 2_109,  spend: 0.14,  session: 's-4819', pid: 31941, started: '00h 01m ago',  model: 'haiku-4.5',  skills: ['research'] },
  { id: 'arca-3', name: 'structural-eng',  role: 'subagent',    state: 'idle',       parent: 'arca-0', turns: 3,    tokensIn: 4_880,     tokensOut: 1_204,  spend: 0.09,  session: 's-4812', pid: 29118, started: '01h 42m ago',  model: 'sonnet-4.6', skills: ['structural_eng'] },
  { id: 'arca-4', name: 'sysadmin-probe',  role: 'subagent',    state: 'paused',     parent: 'arca-0', turns: 1,    tokensIn: 1_812,     tokensOut: 402,    spend: 0.03,  session: 's-4812', pid: 29141, started: '01h 44m ago',  model: 'haiku-4.5',  skills: ['sysadmin'] },
  { id: 'arca-5', name: 'journal-writer',  role: 'scheduled',   state: 'dormant',    parent: 'arca-0', turns: 31,   tokensIn: 62_113,    tokensOut: 14_002, spend: 0.74,  session: 'cron',  pid: null,  started: 'next run 22:00', model: 'haiku-4.5',  skills: [] },
  { id: 'arca-6', name: 'memory-auditor',  role: 'scheduled',   state: 'dormant',    parent: 'arca-0', turns: 4,    tokensIn: 8_200,     tokensOut: 1_811,  spend: 0.11,  session: 'cron',  pid: null,  started: 'next run Sun 09:00', model: 'sonnet-4.6', skills: [] },
];

const AGENT_STATE_COLOR = {
  thinking: '#f7b500',
  'tool-call': '#00d4ff',
  streaming: '#34d17a',
  idle: '#8a857c',
  paused: '#c27a00',
  dormant: '#555048',
  error: '#ff4a3d',
};

// Current turn — Claude Agent SDK loop steps
const ARCA_TURN = {
  id: 't-00042',
  sessionId: 's-4819',
  channel: 'web',
  user: 'dan',
  prompt: 'review the new deck-calc joist module and verify ASCE 7-22 snow load path; if clean, commit and log it',
  tokensIn: 9142,
  tokensOut: 0,
  model: 'claude-sonnet-4-6',
  elapsedMs: 4210,
  skillsLoaded: ['code_review', 'structural_eng'],
  steps: [
    { k:'thought',  at:'+0.02s',  text:'Need to inspect deck-calc/joist.py, confirm ASCE 7-22 refs, then decide commit.' },
    { k:'tool',     at:'+0.41s',  name:'Read',      args:{path:'/home/odin/deck-calc/joist.py'},           ok:true,  ms:38,  out:'412 lines' },
    { k:'tool',     at:'+0.89s',  name:'Bash',      args:{cmd:'pytest deck-calc/tests/test_joist.py -q'}, ok:true,  ms:1820, out:'14 passed, 0 failed' },
    { k:'thought',  at:'+2.74s',  text:'Tests pass. Spot-checking snow load formula against ASCE 7-22 §7.3 — looks right. Checking for edge cases at low pitch.' },
    { k:'tool',     at:'+3.10s',  name:'Grep',      args:{pattern:'pg\\s*=',path:'deck-calc/'},           ok:true,  ms:22,  out:'3 matches in joist.py' },
    { k:'tool',     at:'+3.44s',  name:'mcp__arca__search_memory', args:{query:'ASCE 7-22'},              ok:true,  ms:14,  out:'2 hits in preferences.md' },
    { k:'tool',     at:'+3.78s',  name:'Spawn',     args:{agent:'structural-eng',prompt:'verify §7.3 formula in joist.py'}, ok:true, ms:12, out:'pid 29118' },
    { k:'waiting',  at:'+3.90s',  text:'Awaiting structural-eng subagent …' },
    { k:'thought',  at:'+4.18s',  text:'Subagent returned: formula matches 7-22 §7.3.4. Safe to proceed with commit.', active:true },
  ]
};

const ARCA_MEMORY = {
  facts: [
    { t:'2025-11-01', line:'Dan is a licensed Professional Engineer (PE)' },
    { t:'2025-11-01', line:'Barron Engineering handles site plan reviews and structural analysis' },
    { t:'2025-12-15', line:'Arki-AI targets small-to-mid-sized municipalities' },
    { t:'2026-01-10', line:'Cocoon Homes model: lump sum initial + per-unit certification fees' },
    { t:'2026-01-20', line:'Oneida Lake and Bantam Lake are the primary ice fishing spots' },
    { t:'2026-02-01', line:'ShellCity uses parametric primitives for agent-built 3D buildings' },
    { t:'2026-03-18', line:'Avon zoning board meets on Tuesdays' },
    { t:'2026-04-02', line:'Preferred commit message style: imperative present tense, no prefix' },
  ],
  preferences: [
    'Code style: plain Python or JS, no TypeScript, no React unless asked',
    'Database: always SQLite, never Postgres/Mongo for personal tools',
    'Build pattern: phased Claude Code prompts, CLAUDE.md + README.md specs',
    'File structure: minimal, six-file apps preferred',
    'Communication: direct, no fluff, technical depth welcome',
    'Structural codes: ASCE 7, IBC, AISC, NDS — knows these well',
    '3D printing: Ender 3 Pro, PLA primarily, PETG for functional parts',
  ],
  journal: [
    { t:'2026-04-22 09:15', line:'Helped draft Arki-AI pilot outreach email to Town of Avon' },
    { t:'2026-04-22 11:44', line:'Reviewed ShellCity Phase 3 spec, suggested WebGPU upgrade path' },
    { t:'2026-04-22 12:30', line:'Spawned structural-eng subagent for joist §7.3 verification' },
    { t:'2026-04-22 13:02', line:'Memory audit: 2 duplicate facts flagged, 1 merged' },
    { t:'2026-04-22 14:07', line:'Code-reviewer subagent currently running on deck-calc/joist.py' },
  ],
};

const ARCA_SKILLS = [
  { file:'code_review.md',      triggers:['code','review','refactor','python','bug','lint'],       desc:'Python code review and refactoring', lastFired:'00:03 ago', matches24h:12, hitRate:0.91, lines:68 },
  { file:'research.md',         triggers:['research','search','summarize','article','paper'],      desc:'Deep research and synthesis',         lastFired:'00:01 ago', matches24h:7,  hitRate:0.74, lines:54 },
  { file:'sysadmin.md',         triggers:['server','deploy','nginx','systemd','cron','ssh'],       desc:'Linux system administration',          lastFired:'01:44 ago', matches24h:3,  hitRate:0.88, lines:71 },
  { file:'structural_eng.md',   triggers:['structural','beam','joist','load','ASCE','IBC','NDS'],  desc:'Structural engineering analysis',      lastFired:'00:04 ago', matches24h:5,  hitRate:0.96, lines:92 },
  { file:'tiny_house.md',       triggers:['tiny house','ADU','foundation','zoning'],               desc:'Tiny house / ADU domain expertise',    lastFired:'6h ago',    matches24h:1,  hitRate:0.82, lines:47 },
];

const ARCA_CHANNELS = [
  { id:'cli',       state:'connected',  sessions:1, msgs24h:38,  bind:'pty/3',              latencyMs:8  },
  { id:'web',       state:'connected',  sessions:2, msgs24h:71,  bind:'127.0.0.1:7777',     latencyMs:21 },
  { id:'telegram',  state:'connected',  sessions:1, msgs24h:14,  bind:'bot @arca_dan',       latencyMs:184 },
];

const ARCA_TASKS = [
  { name:'daily_journal_summary', cron:'0 22 * * *',   next:'22:00 today',    lastRun:'yesterday 22:00', lastStatus:'done',   durMs:4112  },
  { name:'weekly_memory_review',  cron:'0 9 * * 0',    next:'Sun 09:00',      lastRun:'3 days ago',      lastStatus:'done',   durMs:9201  },
  { name:'morning_brief',         cron:'30 7 * * *',   next:'07:30 tomorrow', lastRun:'today 07:30',     lastStatus:'done',   durMs:2304  },
  { name:'cold_storage_sync',     cron:'0 3 * * *',    next:'03:00 tomorrow', lastRun:'today 03:00',     lastStatus:'failed', durMs:14021 },
];

const ARCA_TOOLCALLS_24H = [
  { tool:'Read',                          count:412, avgMs:12  },
  { tool:'Bash',                          count:87,  avgMs:1420 },
  { tool:'Edit',                          count:64,  avgMs:41   },
  { tool:'Write',                         count:19,  avgMs:38   },
  { tool:'Grep',                          count:142, avgMs:18   },
  { tool:'mcp__arca__search_memory',      count:56,  avgMs:9    },
  { tool:'mcp__arca__remember_fact',      count:8,   avgMs:11   },
  { tool:'mcp__arca__log_event',          count:23,  avgMs:10   },
];

const ARCA_SESSIONS = [
  { id:'s-4819', ch:'web',      start:'13:58', msgs:14, tokens:41_204, spend:0.62, topic:'deck-calc joist verification' },
  { id:'s-4818', ch:'cli',      start:'13:02', msgs:8,  tokens:18_900, spend:0.28, topic:'memory audit dup-merge' },
  { id:'s-4817', ch:'telegram', start:'12:14', msgs:3,  tokens:2_104,  spend:0.03, topic:'reminder: avon zoning meeting' },
  { id:'s-4816', ch:'web',      start:'11:44', msgs:22, tokens:68_812, spend:1.09, topic:'ShellCity phase 3 webgpu notes' },
  { id:'s-4815', ch:'web',      start:'09:15', msgs:11, tokens:29_400, spend:0.44, topic:'Arki-AI Avon pilot outreach draft' },
  { id:'s-4814', ch:'cli',      start:'08:22', msgs:4,  tokens:6_018,  spend:0.09, topic:'rebuild shared venv, pin claude-agent-sdk' },
];

// Token burn over last 24h, per hour (illustrative)
const ARCA_BURN_24H = [1200, 800, 400, 200, 180, 220, 1800, 4200, 6100, 5400, 3900, 4700, 7200, 8800, 6400, 5100, 3800, 2900, 2100, 1400, 1100, 900, 600, 400];

const ARCA_COSTS = { today: 12.41, week: 78.22, month: 241.08, budget: 400.00 };

// Assembled system prompt for the current turn (illustrative)
const ARCA_PROMPT = {
  soulBytes: 2857,
  memoryBytes: 4118,
  skillsBytes: 3402,
  totalTokens: 3812,
  budget: 4000,
  sections: [
    { k:'soul',         label:'soul.md',                lines:64, tokens:712 },
    { k:'facts',        label:'memory/facts.md',        lines:8,  tokens:214 },
    { k:'preferences',  label:'memory/preferences.md',  lines:7,  tokens:182 },
    { k:'journal',      label:'memory/journal.md (tail 50)', lines:50, tokens:1180 },
    { k:'skill',        label:'skills/code_review.md',  lines:68, tokens:612, matched:['review','refactor'] },
    { k:'skill',        label:'skills/structural_eng.md', lines:92, tokens:912, matched:['joist','ASCE'] },
  ]
};

Object.assign(window, {
  ARCA_NOW, ARCA_AGENTS, AGENT_STATE_COLOR, ARCA_TURN, ARCA_MEMORY,
  ARCA_SKILLS, ARCA_CHANNELS, ARCA_TASKS, ARCA_TOOLCALLS_24H,
  ARCA_SESSIONS, ARCA_BURN_24H, ARCA_COSTS, ARCA_PROMPT,
});
