paracosm 0.9.1170 → 0.9.1173
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dashboard/dist/assets/LibraryTab-C8Hi8IPE.js +5 -0
- package/dist/dashboard/dist/assets/ReportView-tf-eX_cN.js +3 -0
- package/dist/dashboard/dist/assets/SettingsPanel-CvZBFQ6q.js +3 -0
- package/dist/dashboard/dist/assets/StudioTab-98nbLLsT.js +46 -0
- package/dist/dashboard/dist/assets/{SubTabNav-_V8N1C-8.js → SubTabNav-DT8T_8_D.js} +1 -1
- package/dist/dashboard/dist/assets/SwarmViz-DEsEoS0_.js +18 -0
- package/dist/dashboard/dist/assets/index-BPO4i_k0.js +92 -0
- package/dist/dashboard/dist/assets/index-CnhiHNIX.css +1 -0
- package/dist/dashboard/dist/index.html +2 -2
- package/dist/dashboard/landing.html +1 -1
- package/package.json +1 -1
- package/dist/dashboard/dist/assets/LibraryTab-CBR9Hc-b.js +0 -5
- package/dist/dashboard/dist/assets/ReportView-LCfJU1V1.js +0 -3
- package/dist/dashboard/dist/assets/SettingsPanel-BJhnVqOO.js +0 -3
- package/dist/dashboard/dist/assets/StudioTab-LlAKYWym.js +0 -46
- package/dist/dashboard/dist/assets/SwarmViz-JWA24rsk.js +0 -18
- package/dist/dashboard/dist/assets/index-DB91aqrG.js +0 -92
- package/dist/dashboard/dist/assets/index-fNwAQa2Q.css +0 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{Wt as t,_n as n,_t as r,dn as i,dt as a,it as o,nt as s,rt as c,vt as l,x as u,xt as d}from"./index-BPO4i_k0.js";var f=e(n(),1),p={tab:`_tab_llsfj_1`,header:`_header_llsfj_12`,title:`_title_llsfj_18`,viewToggle:`_viewToggle_llsfj_28`,viewBtn:`_viewBtn_llsfj_37`,viewActive:`_viewActive_llsfj_38`,error:`_error_llsfj_59`},m=24;function h(){let e=new URLSearchParams(window.location.search),t=e.get(`mode`),n=t===`turn-loop`||t===`batch-trajectory`||t===`batch-point`?t:void 0;return{q:e.get(`q`)??void 0,mode:n,scenarioId:e.get(`scenario`)??void 0,actorConfigHash:e.get(`leader`)??void 0,limit:Number(e.get(`limit`))||m,offset:Number(e.get(`offset`))||0}}var g=[`q`,`mode`,`scenario`,`leader`,`limit`,`offset`];function _(e){let t=new URLSearchParams;return e.q&&t.set(`q`,e.q),e.mode&&t.set(`mode`,e.mode),e.scenarioId&&t.set(`scenario`,e.scenarioId),e.actorConfigHash&&t.set(`leader`,e.actorConfigHash),e.limit!==void 0&&t.set(`limit`,String(e.limit)),e.offset!==void 0&&t.set(`offset`,String(e.offset)),t.toString()}function v(){let[e,t]=f.useState(h),[n,r]=f.useState([]),[i,a]=f.useState(0),[o,s]=f.useState(!1),[c,l]=f.useState(!1),[u,d]=f.useState(null),[p,v]=f.useState(0);return f.useEffect(()=>{if(typeof fetch>`u`)return;let t=new AbortController;return l(!0),d(null),fetch(`/api/v1/runs?`+_(e),{signal:t.signal}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>{r(e.runs),a(e.total),s(e.hasMore),l(!1)}).catch(e=>{e.name!==`AbortError`&&(d(e.message),l(!1))}),()=>t.abort()},[e,p]),{filters:e,setFilters:f.useCallback(e=>{t(e);let n=_({...e,limit:e.limit??m,offset:e.offset??0}),r=new URL(window.location.href);for(let e of g)r.searchParams.delete(e);new URLSearchParams(n).forEach((e,t)=>r.searchParams.append(t,e)),window.history.replaceState({},``,r.toString())},[]),runs:n,total:i,hasMore:o,loading:c,error:u,refetch:()=>v(e=>e+1)}}var y=`paracosm-library-recent`,b=5;function x(){let[e,t]=f.useState(()=>{if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(y);return e?JSON.parse(e):[]}catch{return[]}});return f.useEffect(()=>{if(typeof window>`u`||e.length===0)return;let n=!1;return(async()=>{let r=await Promise.all(e.map(async e=>{try{return(await fetch(`/api/v1/runs/${encodeURIComponent(e.runId)}`,{method:`HEAD`})).status===404?{id:e.runId,alive:!1}:{id:e.runId,alive:!0}}catch{return{id:e.runId,alive:!0}}}));if(n)return;let i=new Set(r.filter(e=>!e.alive).map(e=>e.id));i.size!==0&&t(e=>{let t=e.filter(e=>!i.has(e.runId));try{t.length===0?window.localStorage.removeItem(y):window.localStorage.setItem(y,JSON.stringify(t))}catch{}return t})})(),()=>{n=!0}},[]),{records:e,push:f.useCallback(e=>{t(t=>{let n=[e,...t.filter(t=>t.runId!==e.runId)].slice(0,b);try{window.localStorage.setItem(y,JSON.stringify(n))}catch{}return n})},[]),remove:f.useCallback(e=>{t(t=>{let n=t.filter(t=>t.runId!==e);if(n.length===t.length)return t;try{n.length===0?window.localStorage.removeItem(y):window.localStorage.setItem(y,JSON.stringify(n))}catch{}return n})},[]),clear:f.useCallback(()=>{t([]);try{window.localStorage.removeItem(y)}catch{}},[])}}function S(e){let{enabled:t,cardSelector:n,searchInputRef:r,onOpenFocused:i,onClose:a}=e;f.useEffect(()=>{if(!t||typeof window>`u`)return;function e(e){let t=e.target,o=!(!t||t.tagName!==`INPUT`&&t.tagName!==`TEXTAREA`&&!t.isContentEditable);if((e.key===`/`||e.key===`k`&&(e.metaKey||e.ctrlKey))&&!o)e.preventDefault(),r.current?.focus();else if(!o){if(e.key===`Escape`)e.preventDefault(),a();else if(e.key===`j`||e.key===`ArrowDown`)e.preventDefault(),C(n,1);else if(e.key===`k`||e.key===`ArrowUp`)e.preventDefault(),C(n,-1);else if(e.key===`Enter`){let t=document.activeElement;t&&t.matches(n)&&(e.preventDefault(),i(t))}}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t,n,r,i,a])}function C(e,t){let n=Array.from(document.querySelectorAll(e));if(n.length===0)return;let r=document.activeElement;(n[((r?n.indexOf(r):-1)+t+n.length)%n.length]??n[0]).focus()}var w={searchBar:`_searchBar_1bd6o_1`,icon:`_icon_1bd6o_15`,input:`_input_1bd6o_20`,kbd:`_kbd_1bd6o_36`},T=i();function E(e){let{value:t,onChange:n,inputRef:r}=e;return(0,T.jsxs)(`div`,{className:w.searchBar,children:[(0,T.jsx)(`span`,{className:w.icon,"aria-hidden":`true`,children:`⌕`}),(0,T.jsx)(`input`,{ref:r,type:`text`,value:t,onChange:e=>n(e.target.value),placeholder:`search runs by scenario, leader, archetype…`,"aria-label":`Search runs`,className:w.input}),(0,T.jsx)(`kbd`,{className:w.kbd,children:`⌘K`})]})}var D={row:`_row_1q7yx_1`,chip:`_chip_1q7yx_8`,chipRemove:`_chipRemove_1q7yx_23`},O={wrapper:`_wrapper_aushb_1`,addBtn:`_addBtn_aushb_6`,popover:`_popover_aushb_24`,section:`_section_aushb_42`};function k(e){let{currentFilters:t,onAdd:n,scenarioOptions:r,leaderOptions:i}=e,[a,o]=f.useState(!1),s=f.useRef(null);return f.useEffect(()=>{if(!a)return;function e(e){s.current&&!s.current.contains(e.target)&&o(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a]),(0,T.jsxs)(`div`,{className:O.wrapper,ref:s,children:[(0,T.jsx)(`button`,{onClick:()=>o(e=>!e),className:O.addBtn,"aria-expanded":a,children:`+ Filter`}),a&&(0,T.jsxs)(`div`,{className:O.popover,role:`dialog`,"aria-label":`Add filter`,children:[!t.mode&&(0,T.jsxs)(`fieldset`,{className:O.section,children:[(0,T.jsx)(`legend`,{children:`Mode`}),(0,T.jsx)(`button`,{onClick:()=>{n({mode:`turn-loop`}),o(!1)},children:`turn-loop`}),(0,T.jsx)(`button`,{onClick:()=>{n({mode:`batch-trajectory`}),o(!1)},children:`batch-trajectory`}),(0,T.jsx)(`button`,{onClick:()=>{n({mode:`batch-point`}),o(!1)},children:`batch-point`})]}),!t.scenarioId&&r.length>0&&(0,T.jsxs)(`fieldset`,{className:O.section,children:[(0,T.jsx)(`legend`,{children:`Scenario`}),r.map(e=>(0,T.jsx)(`button`,{onClick:()=>{n({scenarioId:e.id}),o(!1)},children:e.name},e.id))]}),!t.actorConfigHash&&i.length>0&&(0,T.jsxs)(`fieldset`,{className:O.section,children:[(0,T.jsx)(`legend`,{children:`Leader`}),i.map(e=>(0,T.jsx)(`button`,{onClick:()=>{n({actorConfigHash:e.hash}),o(!1)},children:e.label},e.hash))]})]})]})}function A(e){let{filters:t,onChange:n,scenarioOptions:r,leaderOptions:i}=e;function a(e){let r={...t,offset:0};delete r[e],n(r)}return(0,T.jsxs)(`div`,{className:D.row,children:[t.mode&&(0,T.jsx)(j,{label:`mode: ${t.mode}`,onRemove:()=>a(`mode`)}),t.scenarioId&&(0,T.jsx)(j,{label:`scenario: ${t.scenarioId}`,onRemove:()=>a(`scenarioId`)}),t.actorConfigHash&&(0,T.jsx)(j,{label:`leader: ${t.actorConfigHash.slice(0,16)}…`,onRemove:()=>a(`actorConfigHash`)}),(0,T.jsx)(k,{currentFilters:t,onAdd:e=>n({...t,...e,offset:0}),scenarioOptions:r,leaderOptions:i})]})}function j(e){return(0,T.jsxs)(`span`,{className:D.chip,children:[e.label,(0,T.jsx)(`button`,{onClick:e.onRemove,"aria-label":`Remove ${e.label}`,className:D.chipRemove,children:`×`})]})}var M={strip:`_strip_103ww_1`,stat:`_stat_103ww_7`,skeleton:`_skeleton_103ww_8`,statLabel:`_statLabel_103ww_19`,statValue:`_statValue_103ww_28`,ok:`_ok_103ww_39`,warn:`_warn_103ww_43`,critical:`_critical_103ww_47`,neutral:`_neutral_103ww_51`,pulse:`_pulse_103ww_1`,error:`_error_103ww_67`};function N(e={},t=0){let[n,r]=f.useState(null),[i,a]=f.useState(!1),[o,s]=f.useState(null),c=JSON.stringify(e),l=f.useRef(c);return f.useEffect(()=>{if(typeof fetch>`u`)return;let t=new AbortController;l.current!==c&&(l.current=c,r(null)),a(!0),s(null);let n=new URLSearchParams;return e.mode&&n.set(`mode`,e.mode),e.scenario&&n.set(`scenario`,e.scenario),e.leader&&n.set(`leader`,e.leader),fetch(`/api/v1/runs/aggregate?`+n.toString(),{signal:t.signal}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>{r(e),a(!1)}).catch(e=>{e.name!==`AbortError`&&(s(e.message),a(!1))}),()=>t.abort()},[c,t]),{stats:n,loading:i,error:o}}var P=e=>e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(2)}`,ee=e=>{let t=e/6e4;return t>=60?`${(t/60).toFixed(1)}h`:t>=1?`${t.toFixed(1)}m`:`${(e/1e3).toFixed(1)}s`};function F(e){let{stats:t,loading:n,error:r}=N(e.filters,e.refreshKey);if(n&&!t)return(0,T.jsx)(`div`,{className:M.strip,children:Array.from({length:5}).map((e,t)=>(0,T.jsx)(`div`,{className:M.skeleton},t))});if(r||!t)return(0,T.jsx)(`div`,{className:M.strip,children:(0,T.jsxs)(`div`,{className:M.error,children:[`Stats unavailable: `,r??`unknown`]})});let i=t.replaysAttempted>0?Math.round(t.replaysMatched/t.replaysAttempted*100):null,a=i===null?M.neutral:i>=95?M.ok:i>=80?M.warn:M.critical;return(0,T.jsxs)(`div`,{className:M.strip,children:[(0,T.jsx)(I,{label:`Runs`,value:String(t.totalRuns)}),(0,T.jsx)(I,{label:`Spent`,value:P(t.totalCostUSD)}),(0,T.jsx)(I,{label:`Avg / run`,value:P(t.totalCostUSD/Math.max(t.totalRuns,1))}),(0,T.jsx)(I,{label:`Total time`,value:ee(t.totalDurationMs)}),(0,T.jsx)(I,{label:`Replay match`,value:i===null?`n/a`:`${i}%`,valueClassName:a})]})}function I(e){return(0,T.jsxs)(`div`,{className:M.stat,children:[(0,T.jsx)(`span`,{className:M.statLabel,children:e.label}),(0,T.jsx)(`span`,{className:[M.statValue,e.valueClassName??``].filter(Boolean).join(` `),children:e.value})]})}var L={strip:`_strip_38max_1`,head:`_head_38max_8`,title:`_title_38max_15`,toggle:`_toggle_38max_24`,row:`_row_38max_34`,card:`_card_38max_41`,cardScenario:`_cardScenario_38max_60`,cardLeader:`_cardLeader_38max_66`,cardMode:`_cardMode_38max_71`};function R(e){let{records:t}=x(),[n,r]=f.useState(!0);return t.length===0?null:(0,T.jsxs)(`section`,{className:L.strip,children:[(0,T.jsxs)(`header`,{className:L.head,children:[(0,T.jsx)(`span`,{className:L.title,children:`Recently viewed`}),(0,T.jsx)(`button`,{className:L.toggle,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-label":n?`Collapse recently viewed`:`Expand recently viewed`,children:n?`−`:`+`})]}),n&&(0,T.jsx)(`div`,{className:L.row,children:t.map(t=>(0,T.jsx)(z,{record:t,onClick:()=>e.onSelect(t.runId)},t.runId))})]})}function z(e){let{record:t,onClick:n}=e;return(0,T.jsxs)(`button`,{className:L.card,onClick:n,children:[(0,T.jsx)(`span`,{className:L.cardScenario,children:t.scenarioId}),(0,T.jsx)(`span`,{className:L.cardLeader,children:t.actorName??`Unknown leader`}),(0,T.jsx)(`span`,{className:L.cardMode,"data-mode":t.mode??`unknown`,children:t.mode??`unknown`})]})}var B={gallery:`_gallery_z947m_1`,head:`_head_z947m_7`,grid:`_grid_z947m_18`,skeletonGrid:`_skeletonGrid_z947m_19`,cardSkeleton:`_cardSkeleton_z947m_25`,pulse:`_pulse_z947m_1`,foot:`_foot_z947m_46`},V={card:`_card_1wi83_1`,actions:`_actions_1wi83_18`,compact:`_compact_1wi83_38`,head:`_head_1wi83_43`,modeBadge:`_modeBadge_1wi83_52`,cost:`_cost_1wi83_79`,time:`_time_1wi83_84`,scenario:`_scenario_1wi83_89`,leader:`_leader_1wi83_99`,actionBtn:`_actionBtn_1wi83_114`};function H(e){let{record:t,onOpen:n,onReplay:i,variant:a=`gallery`}=e,o=l(),s=!!t.sessionId;return(0,T.jsxs)(`article`,{className:[V.card,a===`compact`?V.compact:``].filter(Boolean).join(` `),"aria-label":`Run ${t.scenarioId} by ${t.actorName??`unknown leader`}`,"data-run-card":!0,"data-run-id":t.runId,onClick:n,children:[(0,T.jsxs)(`header`,{className:V.head,children:[(0,T.jsx)(`span`,{className:V.modeBadge,"data-mode":t.mode??`unknown`,children:t.mode??`unknown`}),(0,T.jsx)(`span`,{className:V.cost,children:t.costUSD==null?`-`:`$${t.costUSD.toFixed(2)}`}),(0,T.jsx)(`span`,{className:V.time,children:U(t.createdAt)})]}),(0,T.jsx)(`h3`,{className:V.scenario,children:t.scenarioId}),(0,T.jsxs)(`p`,{className:V.leader,children:[t.actorName??`Unknown`,t.actorArchetype?` · ${t.actorArchetype}`:``]}),(0,T.jsxs)(`div`,{className:V.actions,children:[(0,T.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:V.actionBtn,children:`Open`}),(0,T.jsx)(`button`,{onClick:e=>{e.stopPropagation(),i()},className:V.actionBtn,"aria-label":`Replay`,children:`Replay`}),s&&(0,T.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t.sessionId&&o.share(d(window.location.origin,t.sessionId,`viz`))},className:V.actionBtn,"aria-label":`Copy a deep link that opens this run on the visualization tab`,title:`Copy viz share link`,children:`Share`})]}),o.shared&&(0,T.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,T.jsx)(r,{shared:o.shared,onClose:o.clear})})]})}function U(e){let t=Date.now()-Date.parse(e);if(Number.isNaN(t))return`-`;let n=t/1e3;if(n<60)return`${Math.floor(n)}s ago`;let r=n/60;if(r<60)return`${Math.floor(r)}m ago`;let i=r/60;if(i<24)return`${Math.floor(i)}h ago`;let a=i/24;return a<30?`${Math.floor(a)}d ago`:e.slice(0,10)}var W={card:`_card_1rtg6_1`,head:`_head_1rtg6_28`,bundleBadge:`_bundleBadge_1rtg6_37`,count:`_count_1rtg6_50`,cost:`_cost_1rtg6_55`,time:`_time_1rtg6_60`,scenario:`_scenario_1rtg6_64`,actors:`_actors_1rtg6_74`,actor:`_actor_1rtg6_74`,archetype:`_archetype_1rtg6_88`,more:`_more_1rtg6_92`,actions:`_actions_1rtg6_98`,actionBtn:`_actionBtn_1rtg6_104`};function G({entry:e,onOpen:t}){return(0,T.jsxs)(`article`,{className:W.card,"aria-label":`Bundle ${e.bundleId} · ${e.memberCount} actors against ${e.scenarioId}`,"data-bundle-card":!0,"data-bundle-id":e.bundleId,onClick:t,children:[(0,T.jsxs)(`header`,{className:W.head,children:[(0,T.jsx)(`span`,{className:W.bundleBadge,children:`BUNDLE`}),(0,T.jsxs)(`span`,{className:W.count,children:[e.memberCount,` actors`]}),(0,T.jsx)(`span`,{className:W.cost,children:e.totalCostUSD>0?`$${e.totalCostUSD.toFixed(2)}`:`—`}),(0,T.jsx)(`span`,{className:W.time,children:K(e.earliestCreatedAt)})]}),(0,T.jsx)(`h3`,{className:W.scenario,children:e.scenarioId}),(0,T.jsxs)(`ul`,{className:W.actors,"aria-label":`Bundle members`,children:[e.members.filter(e=>e.actorName).slice(0,5).map(e=>(0,T.jsxs)(`li`,{className:W.actor,children:[e.actorName,e.actorArchetype?(0,T.jsxs)(`span`,{className:W.archetype,children:[` · `,e.actorArchetype]}):null]},e.runId)),(()=>{let t=e.members.filter(e=>e.actorName),n=e.members.length-t.length;return t.length>5?(0,T.jsxs)(`li`,{className:W.more,children:[`+ `,t.length-5,` more`]}):t.length===0&&n>0?(0,T.jsxs)(`li`,{className:W.more,children:[n,` actor`,n===1?``:`s`,` · names not recorded`]}):null})()]}),(0,T.jsx)(`div`,{className:W.actions,children:(0,T.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t()},className:W.actionBtn,children:`Compare`})})]})}function K(e){let t=Date.now()-new Date(e).getTime();return t<6e4?`just now`:t<36e5?`${Math.floor(t/6e4)}m ago`:t<864e5?`${Math.floor(t/36e5)}h ago`:`${Math.floor(t/864e5)}d ago`}function q(e){let t=new Map,n=[];for(let r of e)if(r.bundleId){let e=t.get(r.bundleId)??[];e.push(r),t.set(r.bundleId,e)}else n.push(r);let r=[];for(let[e,n]of t)n.sort((e,t)=>e.createdAt.localeCompare(t.createdAt)),r.push({kind:`bundle`,bundleId:e,scenarioId:n[0].scenarioId,memberCount:n.length,totalCostUSD:n.reduce((e,t)=>e+(t.costUSD??0),0),earliestCreatedAt:n[0].createdAt,members:n});for(let e of n)r.push({kind:`solo`,record:e});return r.sort((e,t)=>{let n=e.kind===`solo`?e.record.createdAt:e.earliestCreatedAt,r=t.kind===`solo`?t.record.createdAt:t.earliestCreatedAt;return n.localeCompare(r)}),r}function J(e){let{runs:t,total:n,hasMore:r,loading:i,onOpen:a,onReplay:o,onOpenBundle:s,onPageChange:c,currentOffset:l,pageSize:u}=e,d=Math.floor(l/u)+1,p=Math.max(1,Math.ceil(n/u)),m=f.useMemo(()=>[...q(t)].reverse(),[t]);return(0,T.jsxs)(`section`,{className:B.gallery,children:[(0,T.jsx)(`header`,{className:B.head,children:(0,T.jsxs)(`span`,{children:[`All runs · `,i?`loading…`:`${n} results`]})}),i&&t.length===0?(0,T.jsx)(`div`,{className:B.skeletonGrid,children:Array.from({length:8}).map((e,t)=>(0,T.jsx)(`div`,{className:B.cardSkeleton},t))}):(0,T.jsx)(`div`,{className:B.grid,children:m.map(e=>e.kind===`bundle`?(0,T.jsx)(G,{entry:e,onOpen:()=>s(e.bundleId)},`bundle:${e.bundleId}`):(0,T.jsx)(H,{record:e.record,onOpen:()=>a(e.record.runId),onReplay:()=>o(e.record.runId)},e.record.runId))}),(0,T.jsxs)(`footer`,{className:B.foot,children:[(0,T.jsx)(`button`,{disabled:l===0,onClick:()=>c(Math.max(0,l-u)),children:`‹ Prev`}),(0,T.jsxs)(`span`,{children:[`page `,d,` of `,p]}),(0,T.jsx)(`button`,{disabled:!r,onClick:()=>c(l+u),children:`Next ›`})]})]})}var Y={wrapper:`_wrapper_qouu6_1`,table:`_table_qouu6_12`,modeCell:`_modeCell_qouu6_46`,actionsCell:`_actionsCell_qouu6_60`};function X(e){let{runs:t,onOpen:n,onReplay:r}=e;return(0,T.jsx)(`div`,{className:Y.wrapper,role:`region`,"aria-label":`Runs table`,tabIndex:0,children:(0,T.jsxs)(`table`,{className:Y.table,children:[(0,T.jsx)(`thead`,{children:(0,T.jsxs)(`tr`,{children:[(0,T.jsx)(`th`,{children:`Scenario`}),(0,T.jsx)(`th`,{children:`Mode`}),(0,T.jsx)(`th`,{children:`Leader`}),(0,T.jsx)(`th`,{children:`Cost`}),(0,T.jsx)(`th`,{children:`Time`}),(0,T.jsx)(`th`,{children:`Started`}),(0,T.jsx)(`th`,{"aria-label":`Actions`})]})}),(0,T.jsx)(`tbody`,{children:t.map(e=>(0,T.jsxs)(`tr`,{onClick:()=>n(e.runId),tabIndex:0,"data-run-card":!0,"data-run-id":e.runId,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),n(e.runId))},children:[(0,T.jsx)(`td`,{"data-label":`Scenario`,children:e.scenarioId}),(0,T.jsx)(`td`,{"data-label":`Mode`,children:(0,T.jsx)(`span`,{"data-mode":e.mode??`unknown`,className:Y.modeCell,children:e.mode??`-`})}),(0,T.jsx)(`td`,{"data-label":`Leader`,children:e.actorName??`-`}),(0,T.jsx)(`td`,{"data-label":`Cost`,children:e.costUSD==null?`-`:`$${e.costUSD.toFixed(2)}`}),(0,T.jsx)(`td`,{"data-label":`Time`,children:e.durationMs==null?`-`:`${(e.durationMs/1e3).toFixed(0)}s`}),(0,T.jsx)(`td`,{"data-label":`Started`,children:e.createdAt.slice(0,19).replace(`T`,` `)}),(0,T.jsxs)(`td`,{"data-label":`Actions`,className:Y.actionsCell,children:[(0,T.jsx)(`button`,{onClick:t=>{t.stopPropagation(),n(e.runId)},children:`Open`}),(0,T.jsx)(`button`,{onClick:t=>{t.stopPropagation(),r(e.runId)},"aria-label":`Replay`,children:`Replay`})]})]},e.runId))})]})})}var Z={empty:`_empty_1asmk_1`,icon:`_icon_1asmk_13`,list:`_list_1asmk_36`,cta:`_cta_1asmk_55`};function te(e){let{filtersActive:t,onClearFilters:n}=e;return t?(0,T.jsxs)(`section`,{className:Z.empty,children:[(0,T.jsx)(`div`,{className:Z.icon,"aria-hidden":`true`,children:`⌕`}),(0,T.jsx)(`h2`,{children:`No runs match these filters.`}),(0,T.jsx)(`p`,{children:`Clear filters to see all runs in the library.`}),(0,T.jsx)(`button`,{onClick:n,className:Z.cta,children:`Clear filters`})]}):(0,T.jsxs)(`section`,{className:Z.empty,children:[(0,T.jsx)(`div`,{className:Z.icon,"aria-hidden":`true`,children:`∎`}),(0,T.jsx)(`h2`,{children:`No runs in your library yet.`}),(0,T.jsx)(`p`,{children:`Try one of these to get started:`}),(0,T.jsxs)(`ul`,{className:Z.list,children:[(0,T.jsx)(`li`,{children:(0,T.jsx)(`a`,{href:`?tab=sim`,children:`Run a Mars Genesis demo`})}),(0,T.jsx)(`li`,{children:(0,T.jsx)(`a`,{href:`?tab=quickstart`,children:`Quickstart from a prompt or URL`})}),(0,T.jsx)(`li`,{children:(0,T.jsx)(`a`,{href:`?tab=sim`,children:`Compile a custom scenario`})})]})]})}var Q={section:`_section_13fyx_1`,list:`_list_13fyx_33`,row:`_row_13fyx_41`,savedRun:`_savedRun_13fyx_42`};function $(e){return e==null?``:`${e} turn${e===1?``:`s`}`}function ne(e){let t=Math.round((e.durationMs??0)/1e3),n=t>0?t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`:``,r=e.totalCostUSD,i=r==null?``:r<.005?`<$0.01`:`$${r.toFixed(2)}`;return[new Date(e.createdAt).toLocaleString(),n,i].filter(Boolean).join(` · `)}function re({history:e,onRestore:n,onClear:r,runOpen:i,runLive:o=!1}){let{sessions:c,status:l,refresh:d}=t(),p=(0,f.useId)();return(0,T.jsxs)(T.Fragment,{children:[(0,T.jsxs)(`section`,{className:Q.section,"aria-label":u,children:[(0,T.jsx)(`h3`,{children:u}),l===`loading`&&(0,T.jsx)(`p`,{role:`status`,children:`Trying…`}),l===`ready`&&!c.length&&(0,T.jsx)(`p`,{children:`No saved runs yet.`}),(l===`error`||l===`unavailable`)&&(0,T.jsxs)(`div`,{className:Q.row,children:[(0,T.jsx)(`p`,{role:`status`,children:`Your saved runs did not load.`}),(0,T.jsx)(`button`,{type:`button`,onClick:d,children:`Try again`})]}),c.length>0&&(0,T.jsx)(`ul`,{className:Q.list,children:c.map(e=>(0,T.jsx)(`li`,{children:(0,T.jsxs)(`a`,{className:Q.savedRun,href:s(window.location.href,e.id),children:[(0,T.jsx)(`strong`,{children:e.title||a(e)||e.scenarioName||`Saved runs`}),(0,T.jsx)(`span`,{children:[e.title?a(e):``,e.scenarioName,$(e.turnCount)].filter(Boolean).join(` · `)}),(0,T.jsx)(`span`,{children:ne(e)})]})},e.id))})]}),e.length>0&&(0,T.jsxs)(`section`,{className:Q.section,"aria-label":`Kept in this browser`,children:[(0,T.jsx)(`h3`,{children:`Kept in this browser`}),o&&(0,T.jsx)(`p`,{id:p,children:`Restore opens once the run on screen ends.`}),(0,T.jsx)(`ul`,{className:Q.list,children:e.map(e=>(0,T.jsxs)(`li`,{className:Q.row,children:[(0,T.jsxs)(`div`,{children:[(0,T.jsx)(`strong`,{children:(e.summary.actorNames??[]).join(` vs `)||e.scenarioShortName}),(0,T.jsx)(`p`,{children:[$(e.summary.turnCount),new Date(e.createdAt).toLocaleString()].filter(Boolean).join(` · `)})]}),(0,T.jsx)(`button`,{type:`button`,disabled:o,"aria-describedby":o?p:void 0,onClick:()=>{(!i||window.confirm(`Replace the run on screen with this one?`))&&n(e)},children:`Restore`})]},e.id))}),(0,T.jsx)(`button`,{type:`button`,onClick:()=>{window.confirm(`Clear the runs kept in this browser?
|
|
2
|
+
|
|
3
|
+
This also clears the run on screen and its cached events. It lets go of this browser's run on the server, and stops it if it is running.
|
|
4
|
+
|
|
5
|
+
Server run records, saved replays and output files are kept.`)&&r()},children:`Clear this list`})]})]})}function ie({savedRuns:e}={}){let t=f.useRef(null),{filters:n,setFilters:r,runs:i,total:a,hasMore:s,loading:l,error:u}=v(),{records:d,push:m,remove:h}=x(),[g,_]=f.useState(0),y=f.useCallback(()=>_(e=>e+1),[]),[b,C]=f.useState(()=>new URLSearchParams(window.location.search).get(`view`)===`table`?`table`:`gallery`);f.useEffect(()=>{let e=new URL(window.location.href);b===`table`?e.searchParams.set(`view`,`table`):e.searchParams.delete(`view`),window.history.replaceState({},``,e.toString())},[b]);let[w,D]=f.useState(()=>new URLSearchParams(window.location.search).get(`runId`)),[O,k]=f.useState(()=>new URLSearchParams(window.location.search).get(`bundleId`));f.useEffect(()=>{let e=new URL(window.location.href);w?e.searchParams.set(`runId`,w):e.searchParams.delete(`runId`),window.history.replaceState({},``,e.toString())},[w]),f.useEffect(()=>{let e=new URL(window.location.href);O?e.searchParams.set(`bundleId`,O):e.searchParams.delete(`bundleId`),window.history.replaceState({},``,e.toString())},[O]);let j=f.useMemo(()=>{let e=new Map;return i.forEach(t=>e.set(t.scenarioId,t.scenarioId)),[...e.entries()].map(([e,t])=>({id:e,name:t})).sort((e,t)=>e.name.localeCompare(t.name))},[i]),M=f.useMemo(()=>{let e=new Map;return i.forEach(t=>{if(t.actorConfigHash){let n=t.actorName?`${t.actorName} (${t.actorConfigHash.slice(0,12)})`:t.actorConfigHash.slice(0,16);e.set(t.actorConfigHash,n)}}),[...e.entries()].map(([e,t])=>({hash:e,label:t})).sort((e,t)=>e.label.localeCompare(t.label))},[i]);S({enabled:!0,cardSelector:`[data-run-card]`,searchInputRef:t,onOpenFocused:e=>{let t=e.getAttribute(`data-run-id`);t&&D(t)},onClose:()=>D(null)});let N=!!(n.q||n.mode||n.scenarioId||n.actorConfigHash);return(0,T.jsxs)(`div`,{className:p.tab,children:[(0,T.jsxs)(`header`,{className:p.header,children:[(0,T.jsx)(`h2`,{className:p.title,children:`Library`}),(0,T.jsxs)(`div`,{className:p.viewToggle,role:`group`,"aria-label":`View mode`,children:[(0,T.jsx)(`button`,{className:b===`gallery`?p.viewActive:p.viewBtn,onClick:()=>C(`gallery`),"aria-pressed":b===`gallery`,children:`Gallery`}),(0,T.jsx)(`button`,{className:b===`table`?p.viewActive:p.viewBtn,onClick:()=>C(`table`),"aria-pressed":b===`table`,children:`Table`})]})]}),e&&(0,T.jsx)(re,{...e}),(0,T.jsx)(F,{filters:{mode:n.mode,scenario:n.scenarioId,leader:n.actorConfigHash},refreshKey:g}),(0,T.jsx)(E,{value:n.q??``,onChange:e=>r({...n,q:e||void 0,offset:0}),inputRef:t}),(0,T.jsx)(A,{filters:n,onChange:r,scenarioOptions:j,leaderOptions:M}),(0,T.jsx)(R,{onSelect:e=>D(e)}),u?(0,T.jsxs)(`div`,{className:p.error,children:[`Failed to load runs: `,u]}):!l&&i.length===0?(0,T.jsx)(te,{filtersActive:N,onClearFilters:()=>r({limit:n.limit,offset:0})}):b===`gallery`?(0,T.jsx)(J,{runs:i,total:a,hasMore:s,loading:l,onOpen:e=>D(e),onReplay:e=>D(e),onOpenBundle:e=>k(e),currentOffset:n.offset??0,pageSize:n.limit??24,onPageChange:e=>r({...n,offset:e})}):(0,T.jsx)(X,{runs:i,onOpen:e=>D(e),onReplay:e=>D(e)}),(0,T.jsx)(o,{runId:w,open:w!==null,onClose:()=>D(null),onArtifactLoaded:m,onRunMissing:h,onReplayed:y}),O&&(0,T.jsx)(c,{bundleId:O,open:!0,onClose:()=>k(null)}),(0,T.jsx)(`span`,{hidden:!0,"aria-hidden":`true`,children:d.length})]})}export{ie as LibraryTab};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{A as t,F as n,G as r,St as i,T as a,U as o,_n as s,a as c,bt as l,cn as u,d,dn as f,fn as p,ft as m,gt as h,ht as g,i as _,in as ee,j as te,k as ne,ln as v,mt as re,n as ie,o as ae,pt as y,q as oe,r as se,s as ce,t as le,u as ue,ut as de,w as fe}from"./index-BPO4i_k0.js";var b=e(s(),1);function x(e){let t=t=>{let n=e[t];return Number.isFinite(n)?n:.5};return{openness:t(`openness`),conscientiousness:t(`conscientiousness`),extraversion:t(`extraversion`),agreeableness:t(`agreeableness`),emotionality:t(`emotionality`),honestyHumility:t(`honestyHumility`)}}function pe(e,t=[]){return[...(e.presets?.[0]?.leaders??[]).map(e=>({...e,unit:`Forked Branch`,hexaco:x(e.hexaco),...e.aiAuthorship?{aiAuthorship:{...e.aiAuthorship,fields:e.aiAuthorship.fields.filter(e=>e!==`unit`)}}:{}})),...t].map(oe)}var S={openai:{quality:.3,economy:.1},anthropic:{quality:.75,economy:.6}};function C(e,t,n,r){let i=Math.max(0,t-e)*S[r][n];return`~$${(Math.ceil(i*10)/10).toFixed(2)}`}function me(e){let t=[];for(let n of e.split(`
|
|
2
|
+
`)){let e=n.trim();if(!e)continue;let r=/^(\d+)\s*:\s*([^:]+?)\s*:\s*(.+)$/.exec(e);if(!r)continue;let i=parseInt(r[1],10),a=r[2].trim(),o=r[3].trim();a&&t.push({turn:i,title:a,description:o})}return t}var he=new Set([`kernelSnapshotAtStart`,`kernelSnapshotsAfterProgression`]);function ge(e){let t=e.scenarioExtensions;if(!t||typeof t!=`object`)return e;let n=Object.fromEntries(Object.entries(t).filter(([e])=>!he.has(e)));return{...e,scenarioExtensions:n}}function w(e){let t=e.scenarioExtensions?.kernelSnapshotsPerTurn;return Array.isArray(t)?t.map(e=>e?.turn).filter(e=>typeof e==`number`&&Number.isFinite(e)):[]}function _e(e){let t=e.trajectory?.timepoints?.length??0,n=w(e),r=Math.max(t,...n);return r>0?r:6}function ve(e,t){return w(e).includes(t)&&t<_e(e)}var T={forkButton:`_forkButton_14oeq_1`,backdrop:`_backdrop_14oeq_28`,dialog:`_dialog_14oeq_40`,header:`_header_14oeq_58`,closeButton:`_closeButton_14oeq_75`,field:`_field_14oeq_92`,hint:`_hint_14oeq_122`,warning:`_warning_14oeq_128`,advanced:`_advanced_14oeq_139`,costEstimate:`_costEstimate_14oeq_173`,costDetail:`_costDetail_14oeq_191`,footer:`_footer_14oeq_196`,cancelButton:`_cancelButton_14oeq_224`,confirmButton:`_confirmButton_14oeq_228`},E=f();function ye(e){let{parentArtifact:t,atTurn:r,maxTurns:i,costPreset:a,provider:o,sessionCustomLeaders:s=[],onConfirm:c,onClose:u}=e,d=se(),f=n(),p=l(!0),m=pe(d,s),[h,g]=(0,b.useState)(0),[_,ee]=(0,b.useState)(``),[te,ne]=(0,b.useState)(``);(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&u()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[u]);let v=C(r,i,a,o),re=Math.max(0,i-r),ie=t.metadata.seed;return(0,E.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`fork-modal-title`,className:T.backdrop,onClick:u,children:(0,E.jsxs)(`div`,{ref:p,tabIndex:-1,className:T.dialog,onClick:e=>e.stopPropagation(),children:[(0,E.jsxs)(`header`,{className:T.header,children:[(0,E.jsxs)(`h3`,{id:`fork-modal-title`,children:[`Fork at `,f.Time,` `,r]}),(0,E.jsx)(`button`,{type:`button`,className:T.closeButton,onClick:u,"aria-label":`Close fork modal`,children:`×`})]}),(0,E.jsxs)(`div`,{className:T.field,children:[(0,E.jsx)(`label`,{htmlFor:`fork-leader-select`,children:`Override leader`}),m.length===0?(0,E.jsx)(`p`,{className:T.warning,children:`No preset leaders available for this scenario. Add leaders in Settings or pick a scenario with presets to continue.`}):(0,E.jsx)(`select`,{id:`fork-leader-select`,value:h,onChange:e=>g(parseInt(e.target.value,10)),children:m.map((e,t)=>(0,E.jsxs)(`option`,{value:t,children:[e.name,` (`,e.archetype,`)`]},`${e.name}-${t}`))})]}),(0,E.jsxs)(`div`,{className:T.field,children:[(0,E.jsx)(`label`,{htmlFor:`fork-seed`,children:`Seed override (optional)`}),(0,E.jsx)(`input`,{id:`fork-seed`,type:`number`,placeholder:ie===void 0?`(use parent seed)`:`Parent seed: ${ie}`,value:_,onChange:e=>ee(e.target.value)}),(0,E.jsx)(`span`,{className:T.hint,children:`Leave blank to resume from the parent's RNG state.`})]}),(0,E.jsxs)(`details`,{className:T.advanced,children:[(0,E.jsx)(`summary`,{children:`Advanced: custom events`}),(0,E.jsx)(`textarea`,{rows:4,placeholder:`One event per line, format: "turn: title: description"
|
|
3
|
+
Example: 5: Supply drop: Relief arrives with 3 months of food.`,value:te,onChange:e=>ne(e.target.value)})]}),(0,E.jsxs)(`div`,{className:T.costEstimate,role:`status`,children:[(0,E.jsx)(`span`,{children:`Estimated cost`}),(0,E.jsx)(`strong`,{children:v}),(0,E.jsxs)(`span`,{className:T.costDetail,children:[`for `,re,` more `,re===1?f.time:f.times]})]}),(0,E.jsxs)(`footer`,{className:T.footer,children:[(0,E.jsx)(`button`,{type:`button`,onClick:u,className:T.cancelButton,children:`Cancel`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>{let e=m[h];if(!e)return;let n=_.trim()?parseInt(_,10):void 0,i=n!==void 0&&Number.isFinite(n)?n:void 0,a=te.trim()?me(te):void 0;c({parentArtifact:t,atTurn:r,leader:e,seedOverride:i,customEvents:a})},disabled:m.length===0,className:T.confirmButton,children:`Fork`})]})]})})}var be=`/retry-stats`;function xe(e=!0){let[t,n]=(0,b.useState)(null),[r,i]=(0,b.useState)(!1),[a,o]=(0,b.useState)(null),s=(0,b.useCallback)(async()=>{i(!0),o(null);try{let e=await fetch(be,{credentials:`same-origin`});if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();n(t)}catch(e){o(e instanceof Error?e.message:String(e))}finally{i(!1)}},[]);return(0,b.useEffect)(()=>{e&&s()},[e,s]),{data:t,loading:r,error:a,refresh:s}}var D={backdrop:`_backdrop_vajsn_1`,dialog:`_dialog_vajsn_12`,titleRow:`_titleRow_vajsn_27`,title:`_title_vajsn_27`,escBtn:`_escBtn_vajsn_43`,totalLine:`_totalLine_vajsn_54`,totalAmount:`_totalAmount_vajsn_60`,cacheBlock:`_cacheBlock_vajsn_66`,cacheLabel:`_cacheLabel_vajsn_74`,cacheVerdict:`_cacheVerdict_vajsn_83`,cacheSubLine:`_cacheSubLine_vajsn_91`,cacheTokenRow:`_cacheTokenRow_vajsn_98`,cacheMultiplier:`_cacheMultiplier_vajsn_107`,emptyState:`_emptyState_vajsn_111`,table:`_table_vajsn_118`,tableSm:`_tableSm_vajsn_125`,headRow:`_headRow_vajsn_132`,th:`_th_vajsn_139`,thRight:`_thRight_vajsn_144`,bodyRow:`_bodyRow_vajsn_150`,stageCell:`_stageCell_vajsn_154`,stageLabel:`_stageLabel_vajsn_158`,stageDescription:`_stageDescription_vajsn_164`,bar:`_bar_vajsn_171`,barFill:`_barFill_vajsn_180`,numericCell:`_numericCell_vajsn_187`,numericCellGreen:`_numericCellGreen_vajsn_193`,numericCellMuted:`_numericCellMuted_vajsn_201`,section:`_section_vajsn_208`,sectionLabel:`_sectionLabel_vajsn_214`,sectionFootnote:`_sectionFootnote_vajsn_222`,sectionFootnoteTight:`_sectionFootnoteTight_vajsn_229`,subBlock:`_subBlock_vajsn_236`,subBlockLabel:`_subBlockLabel_vajsn_240`,cellSchemaName:`_cellSchemaName_vajsn_247`,cellNumericTight:`_cellNumericTight_vajsn_252`,cellAvgAttempts:`_cellAvgAttempts_vajsn_258`,cellFallback:`_cellFallback_vajsn_265`,cellRight1:`_cellRight1_vajsn_272`,cellRightGreen:`_cellRightGreen_vajsn_278`,cellRightRust:`_cellRightRust_vajsn_285`,cellRightMuted:`_cellRightMuted_vajsn_291`,cellRateColor:`_cellRateColor_vajsn_297`,cellConfColor:`_cellConfColor_vajsn_304`,statusInline:`_statusInline_vajsn_311`,statusErrorTag:`_statusErrorTag_vajsn_320`,rejectionWrap:`_rejectionWrap_vajsn_324`,rejectionLabel:`_rejectionLabel_vajsn_328`,rejectionCell:`_rejectionCell_vajsn_335`,perLeaderRow:`_perLeaderRow_vajsn_342`,leaderCard:`_leaderCard_vajsn_349`,leaderName:`_leaderName_vajsn_357`,leaderCost:`_leaderCost_vajsn_363`,leaderMeta:`_leaderMeta_vajsn_369`,perActorList:`_perActorList_vajsn_378`,perActorRow:`_perActorRow_vajsn_386`,perActorBarTrack:`_perActorBarTrack_vajsn_412`,perActorCost:`_perActorCost_vajsn_417`,perActorMeta:`_perActorMeta_vajsn_421`,perActorRank:`_perActorRank_vajsn_426`,perActorName:`_perActorName_vajsn_433`,perActorBarFill:`_perActorBarFill_vajsn_448`},O={director:{label:`Event Director`,description:`Generates events each turn based on world state`},commander:{label:`Commander`,description:`Reads dept reports, picks options, promotes department heads`},departments:{label:`Department Analysis`,description:`5 specialists analyzing each event in parallel`},judge:{label:`Forge Judge`,description:`LLM safety + correctness review of every forged tool`},reactions:{label:`Agent Reactions`,description:`~100 colonists reacting to each turn's outcome`},other:{label:`Other`,description:`Uncategorized calls`}};function k(e){return e<1e-4?`$0.0000`:`$${e<.01?e.toFixed(4):e.toFixed(2)}`}function A(e){return e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Se(e){return e>1.5?`var(--rust)`:e>1.1?`var(--amber)`:`var(--text-1)`}function j(e){return e>.01?`var(--rust)`:e>0?`var(--amber)`:`var(--text-3)`}function Ce({combined:e,leaderA:t,leaderB:n,leaderAName:r,leaderBName:i,actors:a,onClose:o}){(0,b.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let s=l(!0),c=xe(!0),u=e.breakdown??{},d=Object.entries(u).map(([e,t])=>({site:e,...t})).sort((e,t)=>t.totalCostUSD-e.totalCostUSD),f=e.totalCostUSD||d.reduce((e,t)=>e+t.totalCostUSD,0),p=d[0]?.totalCostUSD??0;return(0,E.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Cost breakdown`,onClick:o,className:D.backdrop,children:(0,E.jsxs)(`div`,{ref:s,tabIndex:-1,onClick:e=>e.stopPropagation(),className:D.dialog,children:[(0,E.jsxs)(`div`,{className:D.titleRow,children:[(0,E.jsx)(`h3`,{className:D.title,children:`COST BREAKDOWN`}),(0,E.jsx)(`button`,{onClick:o,"aria-label":`Close cost breakdown`,className:D.escBtn,children:`ESC`})]}),(0,E.jsxs)(`div`,{className:D.totalLine,children:[`Total: `,(0,E.jsx)(`span`,{className:D.totalAmount,children:k(f)}),` · `,e.llmCalls.toLocaleString(),` calls`,` · `,A(e.totalTokens),` tokens`]}),e.cacheReadTokens||e.cacheCreationTokens?(()=>{let t=e.cacheReadTokens??0,n=e.cacheCreationTokens??0,r=e.cacheSavingsUSD??0,i=t+n,a=i>0?t/i:0,o=`var(--text-3)`,s;return r>.001?(o=`var(--green)`,s=`Saved ${k(r)} via prompt caching`):r<-.001?(o=`var(--amber)`,s=`Cache priming cost ${k(-r)} so far · reuse will repay this`):t>0?(o=`var(--green)`,s=`Cache reuse breaking even with priming cost`):(o=`var(--amber)`,s=`Cache filled but nothing reused yet · retry run or check prompt stability`),(0,E.jsxs)(`div`,{className:D.cacheBlock,children:[(0,E.jsx)(`div`,{className:D.cacheLabel,children:`PROMPT CACHING`}),(0,E.jsx)(`div`,{className:D.cacheVerdict,style:{"--cache-verdict-color":o},children:s}),(0,E.jsxs)(`div`,{className:D.cacheSubLine,children:[Math.round(a*100),`% hit rate on cached input (`,A(t),` reused / `,A(i),` cache tokens)`]}),(0,E.jsxs)(`div`,{className:D.cacheTokenRow,children:[(0,E.jsxs)(`span`,{children:[`reads `,A(t),` `,(0,E.jsx)(`span`,{className:D.cacheMultiplier,children:`@0.10×`})]}),(0,E.jsxs)(`span`,{children:[`creates `,A(n),` `,(0,E.jsx)(`span`,{className:D.cacheMultiplier,children:`@1.25×`})]})]})]})})():null,d.length===0?(0,E.jsx)(`div`,{className:D.emptyState,children:`No LLM calls have been billed yet. Start a simulation to see spend by pipeline stage.`}):(0,E.jsxs)(`table`,{className:D.table,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:D.headRow,children:[(0,E.jsx)(`th`,{className:D.th,children:`STAGE`}),(0,E.jsx)(`th`,{className:D.thRight,children:`CALLS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`TOKENS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`COST`}),(0,E.jsx)(`th`,{className:D.thRight,children:`%`})]})}),(0,E.jsx)(`tbody`,{children:d.map(e=>{let t=O[e.site]??{label:e.site,description:``},n=f>0?e.totalCostUSD/f*100:0,r=p>0?e.totalCostUSD/p*100:0;return(0,E.jsxs)(`tr`,{className:D.bodyRow,children:[(0,E.jsxs)(`td`,{className:D.stageCell,children:[(0,E.jsx)(`div`,{className:D.stageLabel,children:t.label}),(0,E.jsx)(`div`,{className:D.stageDescription,children:t.description}),(0,E.jsx)(`div`,{"aria-hidden":`true`,className:D.bar,children:(0,E.jsx)(`div`,{className:D.barFill,style:{"--bar-pct":`${r}%`}})})]}),(0,E.jsx)(`td`,{className:D.numericCell,children:e.calls.toLocaleString()}),(0,E.jsx)(`td`,{className:D.numericCell,children:A(e.totalTokens)}),(0,E.jsx)(`td`,{className:D.numericCellGreen,children:k(e.totalCostUSD)}),(0,E.jsxs)(`td`,{className:D.numericCellMuted,children:[n.toFixed(0),`%`]})]},e.site)})})]}),e.schemaRetries&&Object.keys(e.schemaRetries).length>0&&(0,E.jsxs)(`div`,{className:D.section,children:[(0,E.jsx)(`div`,{className:D.sectionLabel,children:`SCHEMA RELIABILITY`}),(0,E.jsxs)(`table`,{className:D.tableSm,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:D.headRow,children:[(0,E.jsx)(`th`,{className:D.th,children:`SCHEMA`}),(0,E.jsx)(`th`,{className:D.thRight,children:`CALLS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`AVG ATTEMPTS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`FALLBACKS`})]})}),(0,E.jsx)(`tbody`,{children:Object.entries(e.schemaRetries).sort((e,t)=>t[1].calls-e[1].calls).map(([e,t])=>{let n=t.calls>0?t.attempts/t.calls:0,r=Se(n),i=t.fallbacks>0?`var(--rust)`:`var(--text-3)`;return(0,E.jsxs)(`tr`,{className:D.bodyRow,children:[(0,E.jsx)(`td`,{className:D.cellSchemaName,children:e}),(0,E.jsx)(`td`,{className:D.cellNumericTight,children:t.calls}),(0,E.jsx)(`td`,{className:D.cellAvgAttempts,style:{"--avg-color":r},children:n.toFixed(2)}),(0,E.jsx)(`td`,{className:D.cellFallback,style:{"--fb-color":i,"--fb-weight":t.fallbacks>0?`700`:`400`},children:t.fallbacks})]},e)})})]}),(0,E.jsxs)(`div`,{className:D.sectionFootnote,children:[`1.00 = first-try success. Higher = model retrying on validation failures. Tune `,(0,E.jsx)(`code`,{className:`mono`,children:`maxRetries`}),` or tighten schema if a row stays above 1.3.`]})]}),e.forgeStats&&e.forgeStats.attempts>0&&(0,E.jsxs)(`div`,{className:D.section,children:[(0,E.jsx)(`div`,{className:D.sectionLabel,children:`FORGE RELIABILITY`}),(()=>{let t=e.forgeStats,n=t.attempts>0?t.approved/t.attempts:0,r=t.approved>0?t.approvedConfidenceSum/t.approved:0,i=n<.5?`var(--rust)`:n<.75?`var(--amber)`:`var(--green)`,a=r>0&&r<.6?`var(--amber)`:`var(--text-1)`;return(0,E.jsxs)(`table`,{className:D.tableSm,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:D.headRow,children:[(0,E.jsx)(`th`,{className:D.thRight,children:`ATTEMPTS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`APPROVED`}),(0,E.jsx)(`th`,{className:D.thRight,children:`REJECTED`}),(0,E.jsx)(`th`,{className:D.thRight,children:`APPROVAL RATE`}),(0,E.jsx)(`th`,{className:D.thRight,children:`AVG CONF`})]})}),(0,E.jsx)(`tbody`,{children:(0,E.jsxs)(`tr`,{className:D.bodyRow,children:[(0,E.jsx)(`td`,{className:D.cellRight1,children:t.attempts}),(0,E.jsx)(`td`,{className:D.cellRightGreen,children:t.approved}),(0,E.jsx)(`td`,{className:t.rejected>0?D.cellRightRust:D.cellRightMuted,children:t.rejected}),(0,E.jsxs)(`td`,{className:D.cellRateColor,style:{"--rate-color":i},children:[(n*100).toFixed(0),`%`]}),(0,E.jsx)(`td`,{className:D.cellConfColor,style:{"--conf-color":a},children:r>0?r.toFixed(2):`—`})]})})]})})(),(0,E.jsx)(`div`,{className:D.sectionFootnote,children:`Rejections come from shape check OR judge verdict. Retry-with-feedback usually recovers; persistent low approval rate suggests the department model is weak at writing schema-compliant code.`})]}),(()=>{let e=c.data;if(c.loading&&!e)return(0,E.jsx)(`div`,{className:D.statusInline,children:`RECENT RUNS — loading…`});if(c.error)return(0,E.jsxs)(`div`,{className:D.statusInline,children:[`RECENT RUNS — `,(0,E.jsxs)(`span`,{className:D.statusErrorTag,children:[`fetch failed (`,c.error,`)`]})]});if(!e||e.runCount===0)return null;let t=Object.entries(e.schemas).filter(([e])=>!e.startsWith(`compile:`)),n=Object.entries(e.schemas).filter(([e])=>e.startsWith(`compile:`)).map(([e,t])=>[e.replace(/^compile:/,``),t]),r=e.forges,i=e.caches,a=e.providerErrors,o=([e,t])=>{let n=Se(t.avgAttempts),r=j(t.fallbackRate);return(0,E.jsxs)(`tr`,{className:D.bodyRow,children:[(0,E.jsx)(`td`,{className:D.cellSchemaName,children:e}),(0,E.jsx)(`td`,{className:D.cellNumericTight,children:t.calls}),(0,E.jsx)(`td`,{className:D.cellAvgAttempts,style:{"--avg-color":n},children:t.avgAttempts.toFixed(2)}),(0,E.jsxs)(`td`,{className:D.cellFallback,style:{"--fb-color":r,"--fb-weight":t.fallbacks>0?`700`:`400`},children:[(t.fallbackRate*100).toFixed(2),`%`]})]},e)};return(0,E.jsxs)(`div`,{className:D.section,children:[(0,E.jsxs)(`div`,{className:D.sectionLabel,children:[`RECENT RUNS (last `,e.runCount,`)`]}),t.length>0&&(0,E.jsxs)(`div`,{className:D.subBlock,children:[(0,E.jsx)(`div`,{className:D.subBlockLabel,children:`RUNTIME SCHEMAS`}),(0,E.jsxs)(`table`,{className:D.tableSm,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:D.headRow,children:[(0,E.jsx)(`th`,{className:D.th,children:`SCHEMA`}),(0,E.jsx)(`th`,{className:D.thRight,children:`CALLS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`AVG ATT`}),(0,E.jsx)(`th`,{className:D.thRight,children:`FALLBACK %`})]})}),(0,E.jsx)(`tbody`,{children:t.sort((e,t)=>t[1].calls-e[1].calls).map(o)})]})]}),n.length>0&&(0,E.jsxs)(`div`,{className:D.subBlock,children:[(0,E.jsx)(`div`,{className:D.subBlockLabel,children:`COMPILE HOOKS`}),(0,E.jsxs)(`table`,{className:D.tableSm,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:D.headRow,children:[(0,E.jsx)(`th`,{className:D.th,children:`HOOK`}),(0,E.jsx)(`th`,{className:D.thRight,children:`CALLS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`AVG ATT`}),(0,E.jsx)(`th`,{className:D.thRight,children:`FALLBACK %`})]})}),(0,E.jsx)(`tbody`,{children:n.sort((e,t)=>t[1].calls-e[1].calls).map(o)})]})]}),r&&r.runsPresent>0&&(0,E.jsxs)(`div`,{className:D.subBlock,children:[(0,E.jsx)(`div`,{className:D.subBlockLabel,children:`FORGES`}),(0,E.jsxs)(`table`,{className:D.tableSm,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:D.headRow,children:[(0,E.jsx)(`th`,{className:D.thRight,children:`RUNS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`ATTEMPTS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`ATTEMPT RATE`}),(0,E.jsx)(`th`,{className:D.thRight,children:`UNIQUE TOOLS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`EVENTUALLY APPROVED`}),(0,E.jsx)(`th`,{className:D.thRight,children:`TERMINAL FAILS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`AVG CONF`})]})}),(0,E.jsx)(`tbody`,{children:(0,E.jsxs)(`tr`,{className:D.bodyRow,children:[(0,E.jsx)(`td`,{className:D.cellRight1,children:r.runsPresent}),(0,E.jsx)(`td`,{className:D.cellRight1,children:r.totalAttempts}),(0,E.jsxs)(`td`,{className:D.cellRateColor,style:{"--rate-color":r.approvalRate<.5?`var(--rust)`:r.approvalRate<.75?`var(--amber)`:`var(--green)`},children:[(r.approvalRate*100).toFixed(1),`%`]}),(0,E.jsx)(`td`,{className:D.cellRight1,children:r.totalUniqueNames}),(0,E.jsxs)(`td`,{className:D.cellRateColor,style:{"--rate-color":r.uniqueApprovalRate<.8?`var(--rust)`:r.uniqueApprovalRate<.95?`var(--amber)`:`var(--green)`},children:[r.totalUniqueApproved,` (`,(r.uniqueApprovalRate*100).toFixed(0),`%)`]}),(0,E.jsx)(`td`,{className:D.cellFallback,style:{"--fb-color":r.totalUniqueTerminalRejections>0?`var(--rust)`:`var(--text-3)`,"--fb-weight":r.totalUniqueTerminalRejections>0?`700`:`400`},children:r.totalUniqueTerminalRejections}),(0,E.jsx)(`td`,{className:D.cellRight1,style:{fontWeight:700},children:r.avgApprovedConfidence>0?r.avgApprovedConfidence.toFixed(2):`—`})]})})]}),(0,E.jsx)(`div`,{className:D.sectionFootnoteTight,children:`ATTEMPT RATE counts every forge call including retries. EVENTUALLY APPROVED is the real quality signal — tools that landed in the toolbox. TERMINAL FAILS are tools the retry loop never recovered.`}),(()=>{let e=r.rejectionReasons,t=e.schema_extra_field+e.shape_check+e.parse_error+e.judge_correctness+e.other;if(t===0)return null;let n=e=>t>0?Math.round(e/t*100):0,i=(e,t)=>({"--rj-color":e>0?t:`var(--text-3)`,"--rj-weight":e>0?`700`:`400`});return(0,E.jsxs)(`div`,{className:D.rejectionWrap,children:[(0,E.jsxs)(`div`,{className:D.rejectionLabel,children:[`REJECTION REASONS (last `,r.runsPresent,` run`,r.runsPresent===1?``:`s`,`)`]}),(0,E.jsxs)(`table`,{className:D.tableSm,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:D.headRow,children:[(0,E.jsx)(`th`,{className:D.thRight,children:`SCHEMA EXTRA FIELD`}),(0,E.jsx)(`th`,{className:D.thRight,children:`SHAPE CHECK`}),(0,E.jsx)(`th`,{className:D.thRight,children:`PARSE ERROR`}),(0,E.jsx)(`th`,{className:D.thRight,children:`JUDGE CORRECTNESS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`OTHER`})]})}),(0,E.jsx)(`tbody`,{children:(0,E.jsxs)(`tr`,{className:D.bodyRow,children:[(0,E.jsxs)(`td`,{className:D.rejectionCell,style:i(e.schema_extra_field,`var(--amber)`),children:[e.schema_extra_field,` (`,n(e.schema_extra_field),`%)`]}),(0,E.jsxs)(`td`,{className:D.rejectionCell,style:i(e.shape_check,`var(--amber)`),children:[e.shape_check,` (`,n(e.shape_check),`%)`]}),(0,E.jsxs)(`td`,{className:D.rejectionCell,style:i(e.parse_error,`var(--rust)`),children:[e.parse_error,` (`,n(e.parse_error),`%)`]}),(0,E.jsxs)(`td`,{className:D.rejectionCell,style:i(e.judge_correctness,`var(--rust)`),children:[e.judge_correctness,` (`,n(e.judge_correctness),`%)`]}),(0,E.jsxs)(`td`,{className:D.cellRightMuted,children:[e.other,` (`,n(e.other),`%)`]})]})})]}),(0,E.jsx)(`div`,{className:D.sectionFootnoteTight,children:`SCHEMA EXTRA FIELD dominating means the LLM's return-keys don't match its declared outputSchema.properties — the target of the 2026-04-18 forge-guidance prompt fix. JUDGE CORRECTNESS = real logic bugs the judge caught.`})]})})()]}),a&&a.runsPresent>0&&(0,E.jsxs)(`div`,{className:D.subBlock,children:[(0,E.jsx)(`div`,{className:D.subBlockLabel,children:`PROVIDER ERRORS`}),(0,E.jsxs)(`table`,{className:D.tableSm,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:D.headRow,children:[(0,E.jsx)(`th`,{className:D.thRight,children:`RUNS W/ ERRORS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`TOTAL`}),(0,E.jsx)(`th`,{className:D.thRight,children:`AUTH`}),(0,E.jsx)(`th`,{className:D.thRight,children:`QUOTA`}),(0,E.jsx)(`th`,{className:D.thRight,children:`RATE`}),(0,E.jsx)(`th`,{className:D.thRight,children:`NET`}),(0,E.jsx)(`th`,{className:D.thRight,children:`OTHER`})]})}),(0,E.jsx)(`tbody`,{children:(0,E.jsxs)(`tr`,{className:D.bodyRow,children:[(0,E.jsx)(`td`,{className:D.cellRight1,children:a.runsPresent}),(0,E.jsx)(`td`,{className:D.cellRight1,style:{fontWeight:700},children:a.total}),(0,E.jsx)(`td`,{className:D.cellFallback,style:{"--fb-color":a.auth>0?`var(--rust)`:`var(--text-3)`,"--fb-weight":a.auth>0?`700`:`400`},children:a.auth}),(0,E.jsx)(`td`,{className:D.cellFallback,style:{"--fb-color":a.quota>0?`var(--rust)`:`var(--text-3)`,"--fb-weight":a.quota>0?`700`:`400`},children:a.quota}),(0,E.jsx)(`td`,{className:a.rate_limit>0?D.cellFallback:D.cellRightMuted,style:a.rate_limit>0?{"--fb-color":`var(--amber)`,"--fb-weight":`400`}:void 0,children:a.rate_limit}),(0,E.jsx)(`td`,{className:a.network>0?D.cellFallback:D.cellRightMuted,style:a.network>0?{"--fb-color":`var(--amber)`,"--fb-weight":`400`}:void 0,children:a.network}),(0,E.jsx)(`td`,{className:a.unknown>0?D.cellFallback:D.cellRightMuted,style:a.unknown>0?{"--fb-color":`var(--amber)`,"--fb-weight":`400`}:void 0,children:a.unknown})]})})]}),(0,E.jsx)(`div`,{className:D.sectionFootnoteTight,children:`AUTH/QUOTA are terminal (run aborts). RATE/NET/OTHER are non-terminal — the retry layer handles them.`})]}),i&&i.runsPresent>0&&(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:D.subBlockLabel,children:`PROMPT CACHE`}),(0,E.jsxs)(`table`,{className:D.tableSm,children:[(0,E.jsx)(`thead`,{children:(0,E.jsxs)(`tr`,{className:D.headRow,children:[(0,E.jsx)(`th`,{className:D.thRight,children:`RUNS WITH CACHE`}),(0,E.jsx)(`th`,{className:D.thRight,children:`READ TOKENS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`CREATE TOKENS`}),(0,E.jsx)(`th`,{className:D.thRight,children:`READ RATIO`}),(0,E.jsx)(`th`,{className:D.thRight,children:`SAVINGS`})]})}),(0,E.jsx)(`tbody`,{children:(0,E.jsxs)(`tr`,{className:D.bodyRow,children:[(0,E.jsx)(`td`,{className:D.cellRight1,children:i.runsPresent}),(0,E.jsx)(`td`,{className:D.cellRight1,children:A(i.totalReadTokens)}),(0,E.jsx)(`td`,{className:D.cellNumericTight,children:A(i.totalCreationTokens)}),(0,E.jsxs)(`td`,{className:D.cellRateColor,style:{"--rate-color":i.readRatio>=.7?`var(--green)`:i.readRatio>=.4?`var(--amber)`:`var(--rust)`},children:[(i.readRatio*100).toFixed(0),`%`]}),(0,E.jsx)(`td`,{className:D.cellRateColor,style:{"--rate-color":i.totalSavingsUSD>0?`var(--green)`:`var(--text-2)`},children:k(i.totalSavingsUSD)})]})})]}),(0,E.jsx)(`div`,{className:D.sectionFootnoteTight,children:`Read ratio >= 70% is healthy. Lower ratios mean the cache keeps getting invalidated.`})]})]})})(),a&&a.length>2&&(0,E.jsxs)(`div`,{className:D.section,children:[(0,E.jsxs)(`div`,{className:D.sectionLabel,children:[`PER ACTOR · `,a.length,` ACTORS`]}),(()=>{let e=[...a].sort((e,t)=>t.cost.totalCostUSD-e.cost.totalCostUSD),t=e[0]?.cost.totalCostUSD??0,n=e.reduce((e,t)=>e+t.cost.totalCostUSD,0);return(0,E.jsx)(`div`,{className:D.perActorList,children:e.map((e,r)=>{let i=t>0?e.cost.totalCostUSD/t*100:0,a=n>0?e.cost.totalCostUSD/n*100:0;return(0,E.jsxs)(`div`,{className:D.perActorRow,children:[(0,E.jsxs)(`div`,{className:D.perActorRank,children:[`#`,r+1]}),(0,E.jsx)(`div`,{className:D.perActorName,title:e.name,children:e.name}),(0,E.jsx)(`div`,{className:D.perActorBarTrack,"aria-hidden":`true`,children:(0,E.jsx)(`div`,{className:D.perActorBarFill,style:{width:`${i}%`}})}),(0,E.jsx)(`div`,{className:D.perActorCost,children:k(e.cost.totalCostUSD)}),(0,E.jsxs)(`div`,{className:D.perActorMeta,children:[e.cost.llmCalls,` calls · `,A(e.cost.totalTokens),` tok · `,a.toFixed(1),`%`]})]},e.actorId)})})})()]}),t&&n&&(t.totalCostUSD>0||n.totalCostUSD>0)&&(0,E.jsxs)(`div`,{className:D.section,children:[(0,E.jsx)(`div`,{className:D.sectionLabel,children:`PER LEADER`}),(0,E.jsxs)(`div`,{className:D.perLeaderRow,children:[(0,E.jsxs)(`div`,{className:D.leaderCard,children:[(0,E.jsx)(`div`,{className:D.leaderName,style:{"--leader-color":`var(--vis)`},children:r||`Leader A`}),(0,E.jsx)(`div`,{className:D.leaderCost,children:k(t.totalCostUSD)}),(0,E.jsxs)(`div`,{className:D.leaderMeta,children:[t.llmCalls,` calls · `,A(t.totalTokens),` tok`]})]}),(0,E.jsxs)(`div`,{className:D.leaderCard,children:[(0,E.jsx)(`div`,{className:D.leaderName,style:{"--leader-color":`var(--eng)`},children:i||`Leader B`}),(0,E.jsx)(`div`,{className:D.leaderCost,children:k(n.totalCostUSD)}),(0,E.jsxs)(`div`,{className:D.leaderMeta,children:[n.llmCalls,` calls · `,A(n.totalTokens),` tok`]})]})]})]})]})})}var M={card:`_card_mk5ry_1`,headerRow:`_headerRow_mk5ry_11`,title:`_title_mk5ry_18`,range:`_range_mk5ry_24`,legend:`_legend_mk5ry_28`,legendItem:`_legendItem_mk5ry_35`,legendSwatch:`_legendSwatch_mk5ry_41`,legendLabel:`_legendLabel_mk5ry_48`,legendValue:`_legendValue_mk5ry_52`},N=[`openness`,`conscientiousness`,`extraversion`,`agreeableness`,`emotionality`,`honestyHumility`],P={openness:`var(--side-a, #e8b44a)`,conscientiousness:`var(--teal, #4ca8a8)`,extraversion:`#c44a1e`,agreeableness:`#6b9a6b`,emotionality:`#a86cb5`,honestyHumility:`#d2b48c`},F={openness:`O`,conscientiousness:`C`,extraversion:`E`,agreeableness:`A`,emotionality:`Em`,honestyHumility:`HH`};function I(e){if(e){for(let t of[`openness`,`conscientiousness`,`extraversion`,`agreeableness`,`emotionality`,`honestyHumility`])if(typeof e[t]!=`number`)return;return e}}function we(e,t){let n=[];for(let r of e){if(r.type!==`personality_drift`||!r.data||r.leader!==void 0&&r.leader!==t)continue;let e=r.data.commander,i=r.data.turn;e&&typeof i==`number`&&n.push({turn:i,hexaco:e})}return n.sort((e,t)=>e.turn-t.turn)}function Te({events:e,actorName:t,baselineHexaco:n}){let r=I(n),i=we(e,t);if(i.length===0&&!r)return null;let a=r?[{turn:0,hexaco:r},...i]:i;if(a.length<2)return null;let o=a[0].turn,s=a[a.length-1].turn,c=Math.max(1,s-o),l=e=>6+68*(1-(Math.max(.05,Math.min(.95,e))-.05)/.9),u=e=>6+248*((e-o)/c);return(0,E.jsxs)(`div`,{className:M.card,children:[(0,E.jsxs)(`div`,{className:M.headerRow,children:[(0,E.jsx)(`span`,{className:M.title,children:`PERSONALITY ARC`}),(0,E.jsxs)(`span`,{className:M.range,children:[`turn `,o,` → `,s]})]}),(0,E.jsxs)(`svg`,{viewBox:`0 0 260 80`,width:`100%`,height:80,role:`img`,"aria-label":`HEXACO trajectory for ${t}`,children:[(0,E.jsx)(`line`,{x1:6,y1:l(.5),x2:254,y2:l(.5),stroke:`var(--border)`,strokeWidth:`0.5`,strokeDasharray:`2,3`}),N.map(e=>{let t=a.map(t=>`${u(t.turn)},${l(t.hexaco[e])}`).join(` `);return(0,E.jsx)(`polyline`,{points:t,fill:`none`,stroke:P[e],strokeWidth:`1.25`,strokeLinejoin:`round`,strokeLinecap:`round`,opacity:.85},e)})]}),(0,E.jsx)(`div`,{className:M.legend,children:N.map(e=>(0,E.jsxs)(`span`,{className:M.legendItem,children:[(0,E.jsx)(`span`,{"aria-hidden":`true`,className:M.legendSwatch,style:{"--trait-color":P[e]}}),(0,E.jsx)(`span`,{className:M.legendLabel,children:F[e]}),(0,E.jsx)(`span`,{className:M.legendValue,children:a[a.length-1].hexaco[e].toFixed(2)})]},e))})]})}var Ee={crisis:`Crisis`,departments:`Department analysis`,decision:`Decision`,outcome:`Outcome`,quotes:`Agent voices`,causality:`Causality`},De={timeline:`Turn timeline`,verdict:`Verdict`,trajectory:`Commander arcs`,cost:`Cost breakdown`,toolbox:`Forged toolbox`,references:`References`},L=[`crisis`,`departments`,`decision`,`outcome`],R=[`crisis`,`departments`,`decision`,`outcome`,`causality`];function Oe(e){return e===`crisis`||e===`departments`||e===`decision`||e===`outcome`||e===`quotes`||e===`causality`}function z(e){return e!==`quotes`}function B(e){let t=[];for(let n of e??[])Oe(n)&&!t.includes(n)&&t.push(n);return t}function ke(e){let t=B(e.configuredSections),n=t.length>0?t:L,r=n.filter(z);for(let t of R)t===`causality`&&!e.hasCausality||r.includes(t)||r.push(t);let i=e.hasQuotes?[`quotes`]:[],a=[`timeline`];return e.hasVerdict&&a.push(`verdict`),e.hasTrajectories&&a.push(`trajectory`),e.hasCost&&a.push(`cost`),e.hasToolbox&&a.push(`toolbox`),e.hasReferences&&a.push(`references`),{focusSections:n,eventSections:r,footerSections:i,artifacts:a}}var V={section:`_section_36gyg_1`,header:`_header_36gyg_10`,kicker:`_kicker_36gyg_16`,winner:`_winner_36gyg_25`,headline:`_headline_36gyg_33`,divergence:`_divergence_36gyg_40`,body:`_body_36gyg_48`,bodyHeader:`_bodyHeader_36gyg_52`,nameA:`_nameA_36gyg_64`,nameB:`_nameB_36gyg_68`,statRow:`_statRow_36gyg_72`,statRowHead:`_statRowHead_36gyg_76`,statValueA:`_statValueA_36gyg_85`,statValueB:`_statValueB_36gyg_90`,statLabel:`_statLabel_36gyg_95`,bar:`_bar_36gyg_99`,barLeftWrap:`_barLeftWrap_36gyg_105`,barRightWrap:`_barRightWrap_36gyg_111`,barLeftFill:`_barLeftFill_36gyg_115`,barRightFill:`_barRightFill_36gyg_122`,viewWrap:`_viewWrap_36gyg_129`,viewBtn:`_viewBtn_36gyg_134`,empty:`_empty_36gyg_147`},H=[{key:`population`,label:`Population`,format:`int`},{key:`morale`,label:`Morale`,format:`percent`},{key:`food`,label:`Food (mo)`,format:`decimal`},{key:`power`,label:`Power (kW)`,format:`decimal`},{key:`modules`,label:`Modules`,format:`decimal`},{key:`science`,label:`Science`,format:`int`},{key:`tools`,label:`Tools Forged`,format:`int`}];function U(e,t){return t===`percent`?`${Math.round(e*100)}%`:t===`decimal`?e.toFixed(1):String(Math.round(e))}function W({a:e,b:t,winner:n}){let r=Math.max(Math.abs(e),Math.abs(t),1),i=Math.max(0,e/r*100),a=Math.max(0,t/r*100),o=n===`a`?`var(--vis)`:`var(--border-hl)`,s=n===`b`?`var(--eng)`:`var(--border-hl)`;return(0,E.jsxs)(`div`,{className:V.bar,children:[(0,E.jsx)(`div`,{className:V.barLeftWrap,children:(0,E.jsx)(`div`,{className:V.barLeftFill,style:{"--bar-pct":`${i}%`,"--bar-fill":o}})}),(0,E.jsx)(`div`,{className:V.barRightWrap,children:(0,E.jsx)(`div`,{className:V.barRightFill,style:{"--bar-pct":`${a}%`,"--bar-fill":s}})})]})}function Ae(e){let t=e.verdict;if(t?.mode===`cohort`)return null;let n=t?.winnerName||``,r=t?.headline||t?.summary||``,i=t?.keyDivergence||``,a=t?.finalStats?.a,o=t?.finalStats?.b,s=g(t?.finalStats),c=a&&o?s?[...s.map(e=>({key:e.id,label:re(e),a:e.a,b:e.b,text:t=>y(t,e.format,e.currency),better:e.better})),{key:`tools`,label:`Tools Forged`,a:Number(a.tools??0),b:Number(o.tools??0),text:e=>U(e??0,`int`)}]:H.map(e=>({key:e.key,label:e.label,a:Number(a[e.key]??0),b:Number(o[e.key]??0),text:t=>U(t??0,e.format)})):[],l=e.onViewFullVerdict??(()=>{typeof document<`u`&&document.getElementById(`verdict`)?.scrollIntoView({behavior:`smooth`,block:`start`})});return(0,E.jsxs)(`section`,{"aria-label":`Run summary`,className:V.section,children:[(0,E.jsxs)(`div`,{className:V.header,children:[(0,E.jsx)(`div`,{className:V.kicker,children:`Run Summary`}),n&&(0,E.jsxs)(`div`,{className:V.winner,children:[n,` wins`]}),r&&(0,E.jsx)(u,{as:`div`,className:V.headline,authored:!0,children:r}),i&&(0,E.jsx)(`div`,{className:V.divergence,children:i})]}),a&&o?(0,E.jsxs)(`div`,{className:V.body,children:[(0,E.jsxs)(`div`,{className:V.bodyHeader,children:[(0,E.jsx)(`span`,{className:V.nameA,children:e.leaderAName}),(0,E.jsx)(`span`,{children:`Final stats`}),(0,E.jsx)(`span`,{className:V.nameB,children:e.leaderBName})]}),c.map(e=>{let{a:t,b:n}=e,r=h(t,n,e.better)??`tie`;return(0,E.jsxs)(`div`,{className:V.statRow,children:[(0,E.jsxs)(`div`,{className:V.statRowHead,children:[(0,E.jsx)(`span`,{className:V.statValueA,style:{"--val-color":r===`a`?`var(--vis)`:`var(--text-2)`,"--val-weight":r===`a`?`700`:`500`},children:e.text(t)}),(0,E.jsx)(`span`,{className:V.statLabel,children:e.label}),(0,E.jsx)(`span`,{className:V.statValueB,style:{"--val-color":r===`b`?`var(--eng)`:`var(--text-2)`,"--val-weight":r===`b`?`700`:`500`},children:e.text(n)})]}),(0,E.jsx)(W,{a:t??0,b:n??0,winner:r})]},e.key)}),(0,E.jsx)(`div`,{className:V.viewWrap,children:(0,E.jsx)(`button`,{type:`button`,onClick:l,className:V.viewBtn,children:`View full verdict ›`})})]}):(0,E.jsx)(`div`,{className:V.empty,children:`Simulation in progress. Scoreboard will populate when the verdict arrives.`})]})}var G={morale:`higher`,population:`higher`,deaths:`lower`,tools:`higher`,turn:`higher`};function K(e,t){if(e.length===0)return 0;if(e.length===1)return e[0];let n=Math.max(0,Math.min(1,t))*(e.length-1),r=Math.floor(n),i=Math.ceil(n);if(r===i)return e[r];let a=n-r;return e[r]*(1-a)+e[i]*a}function q(e,t){switch(t){case`morale`:return e.morale;case`population`:return e.population;case`deaths`:return e.deaths;case`tools`:return e.tools;case`turn`:return e.turn}}function J(e,t,n){let r=n??G[t];if(e.length===0)return{metric:t,direction:r,top:[],middle:[],bottom:[],median:0};let i=[...e.map(e=>q(e,t))].sort((e,t)=>e-t),a=K(i,.25),o=K(i,.75),s=K(i,.5),c=[],l=[],u=[],d=a===o;for(let n of e){if(d){l.push(n);continue}let e=q(n,t);r===`higher`?e>o?c.push(n):e<a?u.push(n):l.push(n):e<a?c.push(n):e>o?u.push(n):l.push(n)}return{metric:t,direction:r,top:c,middle:l,bottom:u,median:s}}function je(e,t){if(e.length===0||t.length===0)return{frontIds:[],dominationCount:{}};let n=(e,t,n)=>{let r=q(e,n),i=q(t,n);return G[n]===`higher`?r>=i:r<=i},r=(e,t,n)=>{let r=q(e,n),i=q(t,n);return G[n]===`higher`?r>i:r<i},i=(e,i)=>{let a=!1;for(let o of t){if(!n(e,i,o))return!1;r(e,i,o)&&(a=!0)}return a},a={};for(let t of e)a[t.id]=0;for(let t of e)for(let n of e)t.id!==n.id&&i(t,n)&&a[t.id]++;let o=[];for(let t of e){let n=!1;for(let r of e)if(t.id!==r.id&&i(r,t)){n=!0;break}n||o.push(t.id)}return{frontIds:o,dominationCount:a}}function Me(e,t){if(e.length===0)return{metric:t,median:0,deltas:{}};let n=K([...e.map(e=>q(e,t))].sort((e,t)=>e-t),.5),r={},i=G[t]===`higher`?1:-1;for(let a of e){let e=(q(a,t)-n)*i;r[a.id]=e+0}return{metric:t,median:n,deltas:r}}function Ne(e,t=0){if(Math.abs(e)<.5/10**t)return`±0`;let n=e.toFixed(t);return e>0?`+${n}`:n}var Y={panel:`_panel_1c1w0_1`,header:`_header_1c1w0_12`,heading:`_heading_1c1w0_18`,subhead:`_subhead_1c1w0_26`,section:`_section_1c1w0_34`,sectionTitle:`_sectionTitle_1c1w0_40`,sectionHint:`_sectionHint_1c1w0_51`,quartileGrid:`_quartileGrid_1c1w0_59`,quartileBlock:`_quartileBlock_1c1w0_65`,metricHead:`_metricHead_1c1w0_75`,metricLabel:`_metricLabel_1c1w0_82`,metricMedian:`_metricMedian_1c1w0_89`,quartileRow:`_quartileRow_1c1w0_96`,quartileTag:`_quartileTag_1c1w0_102`,actorList:`_actorList_1c1w0_114`,actorPill:`_actorPill_1c1w0_124`,actorPillTop:`_actorPillTop_1c1w0_134`,actorPillBottom:`_actorPillBottom_1c1w0_140`,actorListEmpty:`_actorListEmpty_1c1w0_146`,paretoList:`_paretoList_1c1w0_153`,paretoItem:`_paretoItem_1c1w0_162`,paretoName:`_paretoName_1c1w0_176`,paretoArchetype:`_paretoArchetype_1c1w0_181`,paretoDominates:`_paretoDominates_1c1w0_185`,medianTable:`_medianTable_1c1w0_191`,medianHeaderRow:`_medianHeaderRow_1c1w0_201`,medianBodyRow:`_medianBodyRow_1c1w0_202`,medianActorCol:`_medianActorCol_1c1w0_215`,medianActorName:`_medianActorName_1c1w0_223`,medianActorArchetype:`_medianActorArchetype_1c1w0_228`,medianMetricCol:`_medianMetricCol_1c1w0_233`,deltaPositive:`_deltaPositive_1c1w0_252`,deltaNegative:`_deltaNegative_1c1w0_256`,deltaNeutral:`_deltaNeutral_1c1w0_260`},X=[{metric:`morale`,label:`Morale`,suffix:`%`},{metric:`population`,label:`Population`,suffix:``},{metric:`deaths`,label:`Deaths`,suffix:``},{metric:`tools`,label:`Tools`,suffix:``}],Pe=[`morale`,`population`,`deaths`,`tools`],Fe=[{metric:`morale`,label:`Morale`,suffix:`%`,decimals:0},{metric:`population`,label:`Population`,suffix:``,decimals:0},{metric:`deaths`,label:`Deaths`,suffix:``,decimals:0}];function Ie({state:e}){let t=(0,b.useMemo)(()=>c(e),[e]);if(t.length<3)return null;let n=(0,b.useMemo)(()=>X.map(({metric:e,label:n,suffix:r})=>({metric:e,label:n,suffix:r,ranking:J(t,e)})),[t]),r=(0,b.useMemo)(()=>je(t,Pe),[t]),i=r.frontIds.map(e=>t.find(t=>t.id===e)).filter(e=>!!e),a=(0,b.useMemo)(()=>Fe.map(({metric:e,label:n,suffix:r,decimals:i})=>({metric:e,label:n,suffix:r,decimals:i,benchmark:Me(t,e)})),[t]);return(0,E.jsxs)(`section`,{className:Y.panel,"aria-labelledby":`cohort-verdict-heading`,children:[(0,E.jsxs)(`header`,{className:Y.header,children:[(0,E.jsx)(`h3`,{id:`cohort-verdict-heading`,className:Y.heading,children:`Cohort verdict`}),(0,E.jsxs)(`p`,{className:Y.subhead,children:[t.length,` actors · ranked across morale, population, deaths, and forged tools. A single winner doesn't generalize past two — this is the cohort-aware reading.`]})]}),(0,E.jsxs)(`div`,{className:Y.section,children:[(0,E.jsx)(`h4`,{className:Y.sectionTitle,children:`Quartile rankings`}),(0,E.jsx)(`div`,{className:Y.quartileGrid,children:n.map(({metric:e,label:t,suffix:n,ranking:r})=>(0,E.jsxs)(`div`,{className:Y.quartileBlock,children:[(0,E.jsxs)(`div`,{className:Y.metricHead,children:[(0,E.jsx)(`span`,{className:Y.metricLabel,children:t}),(0,E.jsxs)(`span`,{className:Y.metricMedian,children:[`median `,Math.round(r.median),n]})]}),(0,E.jsxs)(`div`,{className:Y.quartileRow,children:[(0,E.jsx)(`span`,{className:Y.quartileTag,children:`Top 25%`}),(0,E.jsxs)(`ul`,{className:Y.actorList,children:[r.top.map(e=>(0,E.jsx)(`li`,{className:`${Y.actorPill} ${Y.actorPillTop}`,children:e.name},e.id)),r.top.length===0&&(0,E.jsx)(`li`,{className:Y.actorListEmpty,children:`—`})]})]}),(0,E.jsxs)(`div`,{className:Y.quartileRow,children:[(0,E.jsx)(`span`,{className:Y.quartileTag,children:`Bottom 25%`}),(0,E.jsxs)(`ul`,{className:Y.actorList,children:[r.bottom.map(e=>(0,E.jsx)(`li`,{className:`${Y.actorPill} ${Y.actorPillBottom}`,children:e.name},e.id)),r.bottom.length===0&&(0,E.jsx)(`li`,{className:Y.actorListEmpty,children:`—`})]})]})]},e))})]}),(0,E.jsxs)(`div`,{className:Y.section,children:[(0,E.jsx)(`h4`,{className:Y.sectionTitle,children:`Pareto front · trade-off candidates`}),(0,E.jsxs)(`p`,{className:Y.sectionHint,children:[i.length,` actor`,i.length===1?``:`s`,` not dominated by any other across all four metrics. Off-front actors are strictly worse than someone on it.`]}),(0,E.jsx)(`ul`,{className:Y.paretoList,children:i.map(e=>{let t=r.dominationCount[e.id]??0;return(0,E.jsxs)(`li`,{className:Y.paretoItem,children:[(0,E.jsx)(`span`,{className:Y.paretoName,children:e.name}),(0,E.jsx)(`span`,{className:Y.paretoArchetype,children:e.archetype}),(0,E.jsxs)(`span`,{className:Y.paretoDominates,children:[`dominates `,t,` other`,t===1?``:`s`]})]},e.id)})})]}),(0,E.jsxs)(`div`,{className:Y.section,children:[(0,E.jsx)(`h4`,{className:Y.sectionTitle,children:`Median benchmark · per-actor deltas`}),(0,E.jsx)(`p`,{className:Y.sectionHint,children:`Sign-normalized so positive = better than median. Lower deaths and higher morale both read as positive deltas.`}),(0,E.jsxs)(`div`,{className:Y.medianTable,role:`table`,"aria-label":`Per-actor delta-from-median`,children:[(0,E.jsxs)(`div`,{className:Y.medianHeaderRow,role:`row`,children:[(0,E.jsx)(`span`,{className:Y.medianActorCol,role:`columnheader`,children:`Actor`}),a.map(e=>(0,E.jsx)(`span`,{className:Y.medianMetricCol,role:`columnheader`,children:e.label},e.metric))]}),t.map(e=>(0,E.jsxs)(`div`,{className:Y.medianBodyRow,role:`row`,children:[(0,E.jsxs)(`span`,{className:Y.medianActorCol,role:`cell`,children:[(0,E.jsx)(`span`,{className:Y.medianActorName,children:e.name}),(0,E.jsx)(`span`,{className:Y.medianActorArchetype,children:e.archetype})]}),a.map(t=>{let n=t.benchmark.deltas[e.id]??0,r=n>0?Y.deltaPositive:n<0?Y.deltaNegative:Y.deltaNeutral;return(0,E.jsxs)(`span`,{className:`${Y.medianMetricCol} ${r}`,role:`cell`,children:[Ne(n,t.decimals),t.suffix]},t.metric)})]},e.id))]})]})]})}function Le(e){switch(e){case`conservative_success`:return`var(--green)`;case`risky_success`:return`var(--amber)`;case`conservative_failure`:return`var(--rust-dim, var(--rust))`;case`risky_failure`:return`var(--rust)`;default:return`var(--text-3)`}}function Re(e,t){return!e||!t?`divergent`:e===t?`shared`:`divergent`}var ze=[{id:`population`,label:`Population`},{id:`morale`,label:`Morale`},{id:`foodMonthsReserve`,label:`Food`,unit:`mo`},{id:`powerKw`,label:`Power`,unit:`kW`},{id:`infrastructureModules`,label:`Modules`},{id:`scienceOutput`,label:`Science`}];function Be(e,t){let n=[],r=new Set;for(let i of e){let e=i.data?.metrics;if(!e||typeof i.turn!=`number`)continue;let a=e[t];if(typeof a==`number`){if(r.has(i.turn)){let e=n.findIndex(e=>e.turn===i.turn);e>=0&&(n[e]={turn:i.turn,value:a})}else r.add(i.turn),n.push({turn:i.turn,value:a})}}return n}function Ve(e,t,n){let r=t??e.actorIds[0],i=n??e.actorIds[1],a=r?e.actors[r]?.events:void 0,o=i?e.actors[i]?.events:void 0;return ze.map(e=>({id:e.id,label:e.label,unit:e.unit,a:a?Be(a,e.id):[],b:o?Be(o,e.id):[]}))}function He(e,t){let n=e.actorIds.map((n,r)=>{let i=e.actors[n]?.events;return{actorId:n,idx:r,name:e.actors[n]?.leader?.name??n,color:t(r),events:i}});return ze.map(e=>({id:e.id,label:e.label,unit:e.unit,a:[],b:[],series:n.map(t=>({actorId:t.actorId,name:t.name,color:t.color,points:t.events?Be(t.events,e.id):[]}))}))}function Ue(e){return e.map(([e,t])=>{let n=t.a.events.get(0),r=t.b.events.get(0);return{turn:e,time:t.a.time??t.b.time,diverged:Re(n?.title,r?.title)===`divergent`,a:{title:n?.title,outcome:n?.outcome,category:n?.category},b:{title:r?.title,outcome:r?.outcome,category:r?.category}}})}var Z={section:`_section_5eeou_1`,title:`_title_5eeou_10`,grid:`_grid_5eeou_20`,cell:`_cell_5eeou_26`,diverged:`_diverged_5eeou_40`,cellHead:`_cellHead_5eeou_45`,cellTurn:`_cellTurn_5eeou_53`,badge:`_badge_5eeou_57`,legend:`_legend_5eeou_71`},We={conservative_success:`SAFE WIN`,risky_success:`RISKY WIN`,conservative_failure:`SAFE LOSS`,risky_failure:`RISKY LOSS`},Ge={conservative_success:`S✓`,risky_success:`R✓`,conservative_failure:`S✗`,risky_failure:`R✗`};function Ke(e,t=!1){return e?t?Ge[e]??`·`:We[e]??e.replace(/_/g,` `).toUpperCase():`·`}function qe({outcome:e,sideColor:t,compact:n}){let r=Le(e);return(0,E.jsx)(`div`,{className:Z.badge,style:{"--side-color":t,"--outcome-color":r,"--badge-size":n?`11px`:`9px`,"--badge-spacing":n?`0`:`0.04em`},children:Ke(e,n)})}function Je(e){let{turns:t,leaderAName:n,leaderBName:i,onJumpToTurn:a}=e,s=r(o);if(t.length===0)return null;let c=e=>{a?a(e):typeof document<`u`&&document.getElementById(`turn-${e}`)?.scrollIntoView({behavior:`smooth`,block:`start`})};return(0,E.jsxs)(`section`,{"aria-label":`Run timeline strip`,className:Z.section,children:[(0,E.jsx)(`div`,{className:Z.title,children:`Run Strip`}),(0,E.jsx)(`div`,{role:`list`,className:Z.grid,style:{"--turn-count":String(t.length)},children:t.map(e=>(0,E.jsxs)(`button`,{type:`button`,role:`listitem`,onClick:()=>c(e.turn),"aria-label":`Jump to turn ${e.turn}${e.time?`, time `+e.time:``}${e.diverged?`, divergent`:``}`,className:[Z.cell,e.diverged?Z.diverged:``].filter(Boolean).join(` `),children:[(0,E.jsxs)(`div`,{className:Z.cellHead,children:[(0,E.jsxs)(`span`,{className:Z.cellTurn,children:[`T`,e.turn]}),e.time&&!s&&(0,E.jsxs)(`span`,{children:[`Y`,e.time]})]}),(0,E.jsx)(qe,{outcome:e.a.outcome,sideColor:`var(--vis)`,compact:s}),(0,E.jsx)(qe,{outcome:e.b.outcome,sideColor:`var(--eng)`,compact:s})]},e.turn))}),(0,E.jsxs)(`div`,{className:Z.legend,children:[(0,E.jsx)(`span`,{children:n}),(0,E.jsx)(`span`,{children:i})]})]})}var Q={section:`_section_1aa2r_1`,sectionHeader:`_sectionHeader_1aa2r_10`,sectionTitle:`_sectionTitle_1aa2r_17`,legend:`_legend_1aa2r_26`,legendA:`_legendA_1aa2r_32`,legendB:`_legendB_1aa2r_37`,grid:`_grid_1aa2r_42`,card:`_card_1aa2r_48`,cardHeader:`_cardHeader_1aa2r_58`,cardLabel:`_cardLabel_1aa2r_65`,cardRange:`_cardRange_1aa2r_70`,cardFooter:`_cardFooter_1aa2r_74`,lastA:`_lastA_1aa2r_81`,lastB:`_lastB_1aa2r_86`,cardFooterCohort:`_cardFooterCohort_1aa2r_94`,lastCohort:`_lastCohort_1aa2r_103`,legendCohort:`_legendCohort_1aa2r_112`,legendCohortEntry:`_legendCohortEntry_1aa2r_122`,legendCohortSlot:`_legendCohortSlot_1aa2r_141`,lastCohortSlot:`_lastCohortSlot_1aa2r_153`};function Ye(e,t){return t===`mo`||t===`kW`?`${e.toFixed(1)}${t?` `+t:``}`:e>0&&e<1?`${Math.round(e*100)}%`:`${Math.round(e)}${t?` `+t:``}`}function Xe(e){let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return n}function Ze({metric:e,sideAColor:t,sideBColor:n}){let r=Array.isArray(e.series)&&e.series.length>=2,i=r?e.series.flatMap(e=>e.points):[...e.a,...e.b];if(i.length===0)return null;let a=1/0,o=-1/0,s=1/0,c=-1/0;for(let e of i)e.turn<a&&(a=e.turn),e.turn>o&&(o=e.turn),e.value<s&&(s=e.value),e.value>c&&(c=e.value);let l=Math.max(1e-6,c-s),u=Math.max(1,o-a),d=e=>4+192*((e-a)/u),f=e=>6+38*(1-(e-s)/l);if(r)return(0,E.jsxs)(`div`,{className:Q.card,children:[(0,E.jsxs)(`div`,{className:Q.cardHeader,children:[(0,E.jsx)(`span`,{className:Q.cardLabel,children:e.label}),(0,E.jsxs)(`span`,{className:Q.cardRange,children:[`T`,a,` → T`,o]})]}),(0,E.jsxs)(`svg`,{viewBox:`0 0 200 50`,width:`100%`,height:50,role:`img`,"aria-label":`${e.label} sparkline (${e.series.length} actors)`,children:[(0,E.jsx)(`line`,{x1:4,y1:25,x2:196,y2:25,stroke:`var(--border)`,strokeWidth:`0.5`,strokeDasharray:`2,3`}),e.series.map(e=>{let t=e.points.map(e=>`${d(e.turn)},${f(e.value)}`).join(` `);return t?(0,E.jsx)(`polyline`,{points:t,fill:`none`,stroke:e.color,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`,opacity:.78,children:(0,E.jsx)(`title`,{children:e.name})},e.actorId):null})]}),(0,E.jsx)(`div`,{className:Q.cardFooterCohort,children:e.series.map((t,n)=>{let r=t.points[t.points.length-1]?.value,i=Xe(n);return(0,E.jsxs)(`span`,{className:Q.lastCohort,style:{"--actor-color":t.color},title:t.name,children:[(0,E.jsx)(`span`,{className:Q.lastCohortSlot,"aria-hidden":`true`,children:i}),r==null?`·`:Ye(r,e.unit)]},t.actorId)})})]});let p=e.a.map(e=>`${d(e.turn)},${f(e.value)}`).join(` `),m=e.b.map(e=>`${d(e.turn)},${f(e.value)}`).join(` `),h=e.a[e.a.length-1]?.value,g=e.b[e.b.length-1]?.value;return(0,E.jsxs)(`div`,{className:Q.card,children:[(0,E.jsxs)(`div`,{className:Q.cardHeader,children:[(0,E.jsx)(`span`,{className:Q.cardLabel,children:e.label}),(0,E.jsxs)(`span`,{className:Q.cardRange,children:[`T`,a,` → T`,o]})]}),(0,E.jsxs)(`svg`,{viewBox:`0 0 200 50`,width:`100%`,height:50,role:`img`,"aria-label":`${e.label} sparkline`,children:[(0,E.jsx)(`line`,{x1:4,y1:25,x2:196,y2:25,stroke:`var(--border)`,strokeWidth:`0.5`,strokeDasharray:`2,3`}),p&&(0,E.jsx)(`polyline`,{points:p,fill:`none`,stroke:t,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`,opacity:.9}),m&&(0,E.jsx)(`polyline`,{points:m,fill:`none`,stroke:n,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`,opacity:.9})]}),(0,E.jsxs)(`div`,{className:Q.cardFooter,children:[(0,E.jsx)(`span`,{className:Q.lastA,children:h==null?`·`:Ye(h,e.unit)}),(0,E.jsx)(`span`,{className:Q.lastB,children:g==null?`·`:Ye(g,e.unit)})]})]})}function Qe(e){let{metrics:t,leaderAName:n,leaderBName:r}=e,i=e.sideAColor??`var(--vis)`,a=e.sideBColor??`var(--eng)`,o=t.length>0&&Array.isArray(t[0].series)&&t[0].series.length>=2,s=t.filter(e=>o?(e.series??[]).some(e=>e.points.length>0):e.a.length>0||e.b.length>0);if(s.length===0)return null;let c={"--side-a-color":i,"--side-b-color":a};return(0,E.jsxs)(`section`,{"aria-label":`Metric sparklines`,className:Q.section,style:c,children:[(0,E.jsxs)(`div`,{className:Q.sectionHeader,children:[(0,E.jsx)(`span`,{className:Q.sectionTitle,children:`Metric Trajectories`}),o?(0,E.jsx)(`span`,{className:Q.legendCohort,children:(s[0].series??[]).map((e,t)=>(0,E.jsxs)(`span`,{className:Q.legendCohortEntry,style:{"--actor-color":e.color},children:[(0,E.jsx)(`span`,{className:Q.legendCohortSlot,"aria-hidden":`true`,children:Xe(t)}),e.name]},e.actorId))}):(0,E.jsxs)(`span`,{className:Q.legend,children:[(0,E.jsx)(`span`,{className:Q.legendA,children:n}),` · `,(0,E.jsx)(`span`,{className:Q.legendB,children:r})]})]}),(0,E.jsx)(`div`,{className:`responsive-grid-3 ${Q.grid}`,children:s.map(e=>(0,E.jsx)(Ze,{metric:e,sideAColor:i,sideBColor:a},e.id))})]})}function $e(e,t){let[n,r]=(0,b.useState)(()=>typeof window<`u`?window.matchMedia(e).matches:t);return(0,b.useEffect)(()=>{if(typeof window>`u`)return;let t=window.matchMedia(e),n=()=>r(t.matches);return t.addEventListener(`change`,n),()=>t.removeEventListener(`change`,n)},[e]),n}function et(e){let{items:t,scrollRoot:n}=e,[r,i]=(0,b.useState)(t[0]?.id),a=$e(`(min-width: 1024px)`,!0),o=$e(`(max-width: 767.98px)`,!1);(0,b.useEffect)(()=>{if(typeof window>`u`||t.length===0)return;let e=t.map(e=>document.getElementById(e.id)).filter(e=>e!=null);if(e.length===0)return;let r=new IntersectionObserver(e=>{let t=e.filter(e=>e.isIntersecting).sort((e,t)=>t.intersectionRatio-e.intersectionRatio);t[0]&&i(t[0].target.id)},{root:n??null,rootMargin:`-80px 0px -60% 0px`,threshold:[0,.25,.5,.75,1]});return e.forEach(e=>r.observe(e)),()=>r.disconnect()},[t,n]);let s=(0,b.useMemo)(()=>({display:`block`,padding:`4px 10px`,fontSize:`var(--font-xs)`,fontFamily:`var(--mono)`,fontWeight:700,letterSpacing:`0.04em`,textTransform:`uppercase`,color:`var(--text-3)`,textDecoration:`none`,borderRadius:3}),[]);return t.length===0?null:a?(0,E.jsx)(`nav`,{"aria-label":`Report sections`,style:{position:`sticky`,top:12,alignSelf:`flex-start`,width:160,marginLeft:12,padding:`10px 6px`,background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:8,maxHeight:`calc(100vh - 40px)`,overflowY:`auto`},children:t.map(e=>(0,E.jsx)(`a`,{href:`#${e.id}`,style:{...s,color:r===e.id?`var(--amber)`:`var(--text-3)`,background:r===e.id?`color-mix(in srgb, var(--bg-canvas) 80%, var(--amber) 20%)`:`transparent`},children:e.label},e.id))}):(0,E.jsx)(`nav`,{"aria-label":`Report sections`,style:{background:`var(--bg-panel)`,borderBottom:`1px solid var(--border)`,padding:o?`8px 10px`:`6px 8px`,marginBottom:12,overflowX:`auto`,WebkitOverflowScrolling:`touch`,display:`flex`,gap:o?6:4,flexShrink:0},children:t.map(e=>{let t=r===e.id,n={...s,flexShrink:0,padding:`8px 12px`,borderRadius:4,border:`1px solid ${t?`var(--amber)`:`var(--border)`}`,background:t?`var(--amber)`:`var(--bg-card)`,color:t?`var(--bg-deep)`:`var(--text-3)`},i={...s,flexShrink:0,color:t?`var(--amber)`:`var(--text-3)`,borderBottom:t?`2px solid var(--amber)`:`2px solid transparent`};return(0,E.jsx)(`a`,{href:`#${e.id}`,style:o?n:i,children:e.label},e.id)})})}var $={empty:`_empty_1pipo_1`,emptyMsg:`_emptyMsg_1pipo_8`,emptyMsgRunning:`_emptyMsgRunning_1pipo_15`,emptySpinner:`_emptySpinner_1pipo_23`,reportEmptySpinnerRotate:`_reportEmptySpinnerRotate_1pipo_1`,layout:`_layout_1pipo_43`,scroll:`_scroll_1pipo_50`,tldr:`_tldr_1pipo_58`,tldrTopRow:`_tldrTopRow_1pipo_69`,tldrTag:`_tldrTag_1pipo_76`,tldrHeadline:`_tldrHeadline_1pipo_85`,tldrSub:`_tldrSub_1pipo_92`,tldrStats:`_tldrStats_1pipo_99`,tldrStatLabel:`_tldrStatLabel_1pipo_108`,tldrStatValue:`_tldrStatValue_1pipo_113`,headerRow:`_headerRow_1pipo_118`,headerTitle:`_headerTitle_1pipo_127`,jumpBtn:`_jumpBtn_1pipo_134`,actorPairPicker:`_actorPairPicker_1pipo_149`,actorPairPickerLabel:`_actorPairPickerLabel_1pipo_164`,actorPairPickerToggle:`_actorPairPickerToggle_1pipo_172`,actorPairPickerToggleText:`_actorPairPickerToggleText_1pipo_209`,actorPairPickerSelect:`_actorPairPickerSelect_1pipo_218`,actorPairPickerVs:`_actorPairPickerVs_1pipo_237`,actorPairPickerHint:`_actorPairPickerHint_1pipo_245`,jumpInlineBtn:`_jumpInlineBtn_1pipo_251`,trajectoryGrid:`_trajectoryGrid_1pipo_262`,costBar:`_costBar_1pipo_269`,costLabel:`_costLabel_1pipo_282`,costAmount:`_costAmount_1pipo_289`,costMeta:`_costMeta_1pipo_295`,costBtn:`_costBtn_1pipo_299`,turnSection:`_turnSection_1pipo_312`,diverged:`_diverged_1pipo_321`,turnHeader:`_turnHeader_1pipo_326`,turnTitle:`_turnTitle_1pipo_333`,turnEventCount:`_turnEventCount_1pipo_340`,turnHeaderRight:`_turnHeaderRight_1pipo_348`,divergenceFlag:`_divergenceFlag_1pipo_354`,eventGrid:`_eventGrid_1pipo_367`,eventGridSpaced:`_eventGridSpaced_1pipo_373`,footerGrid:`_footerGrid_1pipo_380`,nActorEventTrack:`_nActorEventTrack_1pipo_387`,nActorEventTrackSpaced:`_nActorEventTrackSpaced_1pipo_397`,nActorFooterTrack:`_nActorFooterTrack_1pipo_408`,summarySection:`_summarySection_1pipo_426`,summaryLabel:`_summaryLabel_1pipo_430`,summaryVerdictWrap:`_summaryVerdictWrap_1pipo_442`,aboutDetails:`_aboutDetails_1pipo_446`,aboutSummary:`_aboutSummary_1pipo_457`,aboutBody:`_aboutBody_1pipo_465`,aboutBlockTitle:`_aboutBlockTitle_1pipo_472`,aboutChips:`_aboutChips_1pipo_478`,aboutChip:`_aboutChip_1pipo_478`,aboutChipNeutral:`_aboutChipNeutral_1pipo_494`,eventCard:`_eventCard_1pipo_504`,eventHeading:`_eventHeading_1pipo_511`,eventSubLabel:`_eventSubLabel_1pipo_519`,eventAwaiting:`_eventAwaiting_1pipo_526`,eventTitle:`_eventTitle_1pipo_531`,categoryPill:`_categoryPill_1pipo_538`,emergentPill:`_emergentPill_1pipo_548`,eventDescription:`_eventDescription_1pipo_556`,eventDecision:`_eventDecision_1pipo_564`,eventOutcomeRow:`_eventOutcomeRow_1pipo_571`,eventPolicies:`_eventPolicies_1pipo_578`,eventDetails:`_eventDetails_1pipo_584`,eventDetailsSummary:`_eventDetailsSummary_1pipo_588`,eventRationale:`_eventRationale_1pipo_596`,deptList:`_deptList_1pipo_606`,deptItem:`_deptItem_1pipo_613`,deptHead:`_deptHead_1pipo_621`,deptName:`_deptName_1pipo_627`,deptMeta:`_deptMeta_1pipo_632`,deptSummary:`_deptSummary_1pipo_638`,footerCard:`_footerCard_1pipo_644`,footerDetails:`_footerDetails_1pipo_651`,footerDetailsLast:`_footerDetailsLast_1pipo_655`,footerSummary:`_footerSummary_1pipo_659`,systemsRow:`_systemsRow_1pipo_667`,systemItem:`_systemItem_1pipo_676`,systemKey:`_systemKey_1pipo_680`,systemValue:`_systemValue_1pipo_684`,reactionsList:`_reactionsList_1pipo_689`,reactionItem:`_reactionItem_1pipo_696`,reactionHead:`_reactionHead_1pipo_704`,reactionName:`_reactionName_1pipo_711`,moodPill:`_moodPill_1pipo_716`,reactionQuote:`_reactionQuote_1pipo_726`,reactionRole:`_reactionRole_1pipo_731`,forkNotice:`_forkNotice_1pipo_737`};function tt(e,t){let[n,r]=(0,b.useState)(()=>{if(typeof window>`u`)return t;try{let n=window.localStorage.getItem(e);return n===null?t:n===`1`}catch{return t}});return[n,(0,b.useCallback)(t=>{r(t);try{window.localStorage.setItem(e,t?`1`:`0`)}catch{}},[e])]}function nt(){return{events:new Map,reactions:[],totalReactions:0}}function rt(e,t,n){let r=e.events.get(t);return r||(r={eventIndex:t,totalEvents:n,depts:{}},e.events.set(t,r)),n>r.totalEvents&&(r.totalEvents=n),r}function it(e){let t=new Map;if(!e)return t;let n=new Map;for(let r of e){let e=r.turn;if(typeof e!=`number`)continue;let i=t.get(e);i||(i=nt(),t.set(e,i));let a=Number(r.data?.eventIndex??0),o=Number(r.data?.totalEvents??1);if(r.type===`turn_start`&&(r.data?.time!=null&&(i.time=r.data.time),r.data?.metrics&&(i.metrics=r.data.metrics),r.data?.title&&r.data?.title!==`Director generating...`&&!r.data?.totalEvents)){let e=rt(i,0,1);e.title=r.data.title,e.category=r.data.category,e.emergent=r.data.emergent,e.description=r.data.crisis||r.data.turnSummary||``}if(r.type===`event_start`){let e=rt(i,a,o);e.title=r.data?.title,e.eventAuthorship={aiWrittenFields:r.data?.aiWrittenFields},e.category=r.data?.category,e.emergent=r.data?.emergent,e.description=r.data?.description||r.data?.turnSummary||``}if(r.type===`decision_made`&&n.set(a,{decision:String(r.data?.decision||``),rationale:String(r.data?.rationale||``),aiWrittenFields:r.data?.aiWrittenFields,policies:Array.isArray(r.data?.selectedPolicies)?r.data.selectedPolicies.map(e=>typeof e==`string`?e:JSON.stringify(e)):[]}),r.type===`outcome`){let e=rt(i,a,o);e.outcome=String(r.data?.outcome||``);let t=n.get(a);t?(e.decision=t.decision,e.rationale=t.rationale,e.policies=t.policies,e.decisionAuthorship=t):r.data?._decision&&(e.decision=String(r.data._decision),e.rationale=String(r.data._rationale||``),e.policies=r.data._policies||[],e.decisionAuthorship={aiWrittenFields:r.data.aiWrittenFields},n.delete(a))}if(r.type===`specialist_done`){let e=rt(i,a,o),t=r.data?.department;if(t){let n=(r.data?._filteredTools||[]).filter(e=>e?.approved!==!1).length;e.depts[t]={aiWrittenFields:r.data?.aiWrittenFields,summary:r.data?.summary||``,tools:n,citations:Number(r.data?.citations??0),citationList:r.data?.citationList||[]}}}r.type===`agent_reactions`&&(i.reactions=(r.data?.reactions||[]).slice(0,3),i.totalReactions=Number(r.data?.totalReactions??0))}return t}function at(e){return e===`pos`?`var(--green)`:e===`neg`?`var(--rust)`:`var(--text-1)`}function ot({state:e,verdict:r,shownRun:o,reportSections:s}){let c=te(),l=t(),[d,f]=tt(`paracosm-reports-refs-open`,!1),[p,h]=tt(`paracosm-reports-tools-open`,!1),[g,v]=(0,b.useState)(!1),{state:re,dispatch:y}=de(),oe=le(),ue=ie(),x=n(),[pe,S]=(0,b.useState)(null),C=re.parent,me=se(),he=_(),w=C?.metadata?.scenario,be=typeof w?.id==`string`&&w.id!==me.id,xe=(0,b.useCallback)(t=>!C||e.isRunning||!he||be?!1:ve(C,t),[C,e.isRunning,he,be]),D=(0,b.useCallback)(async e=>{S(null);let t=`branch-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;y({type:`BRANCH_OPTIMISTIC`,localId:t,forkedAtTurn:e.atTurn,actorName:e.leader.name,actorArchetype:e.leader.archetype});let n=_e(e.parentArtifact),r=e.seedOverride??e.parentArtifact.metadata.seed??42;try{let i=await fetch(`/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({actors:[e.leader],turns:n,seed:r,captureSnapshots:!0,customEvents:e.customEvents,forkFrom:{parentArtifact:ge(e.parentArtifact),atTurn:e.atTurn}})});if(!i.ok){let e=await i.json().catch(()=>({}));y({type:`BRANCH_ERROR`,localId:t,message:e.error??`HTTP ${i.status}`});return}let a=await i.json().catch(()=>({}));ue(typeof a.runKey==`string`?a.runKey:void 0),ee(window,a.visitorId),oe(`studio`)}catch(e){y({type:`BRANCH_ERROR`,localId:t,message:String(e)})}},[y,oe,ue]),O=e.actorIds[0]??null,k=e.actorIds[1]??null,[A,Se]=(0,b.useState)(O),[j,M]=(0,b.useState)(k);(0,b.useEffect)(()=>{A&&!e.actorIds.includes(A)&&Se(O),j&&!e.actorIds.includes(j)&&M(k)},[e.actorIds,A,j,O,k]);let N=A??O,P=j??k,F=e.actorIds.length>2,[I,we]=(0,b.useState)(!F);(0,b.useEffect)(()=>{we(!F)},[F]);let L=(0,b.useMemo)(()=>{let t=new Map;for(let n of e.actorIds)t.set(n,it(e.actors[n]?.events));return t},[e]),R=(0,b.useMemo)(()=>{let e=N&&L.get(N)||new Map,t=P&&L.get(P)||new Map;return[...new Set([...e.keys(),...t.keys()])].sort((e,t)=>e-t).map(n=>[n,{a:e.get(n)??nt(),b:t.get(n)??nt()}])},[L,N,P]),Oe=(0,b.useMemo)(()=>{if(!F)return[];let t=new Set;for(let e of L.values())for(let n of e.keys())t.add(n);return[...t].sort((e,t)=>e-t).map(t=>{let n=new Map;for(let r of e.actorIds)n.set(r,L.get(r)?.get(t)??nt());return[t,n]})},[F,L,e.actorIds]),z=N,B=P,V=z?e.actors[z]:null,H=B?e.actors[B]:null,U=V?.leader?.name||`Leader A`,W=H?.leader?.name||`Leader B`,G=(V?.events.some(e=>e.type===`personality_drift`)??!1)||(H?.events.some(e=>e.type===`personality_drift`)??!1),K=R.some(([,e])=>e.a.reactions.length>0||e.b.reactions.length>0),q=R.some(([,e])=>[...e.a.events.values(),...e.b.events.values()].some(e=>!!e.rationale)),J=(0,b.useMemo)(()=>ke({configuredSections:s,hasQuotes:K,hasCausality:q,hasVerdict:!!r,hasTrajectories:G,hasCost:!!(e.cost&&e.cost.llmCalls>0),hasToolbox:l.list.length>0,hasReferences:c.list.length>0}),[s,K,q,r,G,e.cost,l.list.length,c.list.length]),je=(0,b.useMemo)(()=>Ue(R),[R]),Me=(0,b.useMemo)(()=>Ve(e,N,P),[e,N,P]),Ne=(0,b.useMemo)(()=>F?He(e,i):null,[F,e]),Y=(0,b.useMemo)(()=>{let e=[];je.length>0&&e.push({id:`strip`,label:`Strip`}),Me.some(e=>e.a.length>0||e.b.length>0)&&e.push({id:`sparklines`,label:`Metrics`}),G&&e.push({id:`trajectory`,label:`Trajectory`});for(let[t]of R)e.push({id:`turn-${t}`,label:`Turn ${t}`});return l.list.length>0&&e.push({id:`toolbox`,label:`Toolbox`}),e.push({id:`summary`,label:r?`Verdict`:`Summary`}),c.list.length>0&&e.push({id:`references`,label:`References`}),e},[r,je.length,Me,G,R,l.list.length,c.list.length]),X=(0,b.useRef)(null),Pe=(0,b.useRef)(!0);return(0,b.useEffect)(()=>{Pe.current&&X.current&&R.length>0&&X.current.scrollTo({top:X.current.scrollHeight,behavior:`smooth`})},[R.length]),!(V?.events.length??0)&&!(H?.events.length??0)?e.isRunning?(0,E.jsx)(`div`,{className:$.empty,children:(0,E.jsxs)(`div`,{className:`${$.emptyMsg} ${$.emptyMsgRunning??``}`,role:`status`,"aria-live":`polite`,children:[(0,E.jsx)(`span`,{className:$.emptySpinner,"aria-hidden":`true`}),(0,E.jsx)(`span`,{children:`Awaiting first turn — the report populates once the kernel reports an event.`})]})}):(0,E.jsx)(ae,{kind:`reports`}):(0,E.jsxs)(`div`,{className:`reports-layout ${$.layout}`,children:[(0,E.jsxs)(`div`,{ref:X,onScroll:()=>{let e=X.current;e&&(Pe.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},className:`reports-content ${$.scroll}`,role:`region`,"aria-label":`Turn-by-turn report`,children:[he&&be&&(0,E.jsxs)(`p`,{className:$.forkNotice,role:`note`,children:[`This run is in `,w?.name??w?.id,`, and a fork runs in its parent's scenario. Switch to `,w?.name??w?.id,` to fork it.`]}),(()=>{let e=r,t=e?.winnerName||``,n=e?.headline||e?.summary||``;if(!r&&R.length===0)return null;let i=R.length,a=R[R.length-1],o=R[0],s=(e,t)=>{let n=e?.[t];return typeof n==`number`?n:0},c=s(a?.[1]?.a?.metrics,`population`),l=s(a?.[1]?.b?.metrics,`population`),d=s(a?.[1]?.a?.metrics,`morale`),f=s(a?.[1]?.b?.metrics,`morale`),p=s(o?.[1]?.a?.metrics,`population`)||c,m=s(o?.[1]?.b?.metrics,`population`)||l,h=V?.events.filter(e=>e.type===`forge_attempt`&&e.data?.approved===!0).length??0,g=H?.events.filter(e=>e.type===`forge_attempt`&&e.data?.approved===!0).length??0,_=[{label:`Turns`,value:String(i)},{label:`Final pop`,value:`A ${c}${c<p?` (↓${p-c})`:``} · B ${l}${l<m?` (↓${m-l})`:``}`,tone:c+l<p+m?`neg`:`neutral`},{label:`Final morale`,value:`A ${Math.round(d*100)}% · B ${Math.round(f*100)}%`,tone:Math.min(d,f)<.3?`neg`:Math.min(d,f)>=.6?`pos`:`neutral`},{label:`Tools forged`,value:`A ${h} · B ${g}`}];return(0,E.jsxs)(`div`,{className:$.tldr,children:[(0,E.jsxs)(`div`,{className:$.tldrTopRow,children:[(0,E.jsx)(`span`,{className:$.tldrTag,children:`TL;DR`}),t?(0,E.jsxs)(`span`,{className:$.tldrHeadline,children:[t,` wins`]}):i>0?(0,E.jsxs)(`span`,{className:$.tldrHeadline,children:[`Run `,i,` turn`,i===1?``:`s`,` — verdict pending`]}):null,n&&(0,E.jsx)(u,{className:$.tldrSub,authored:!0,children:n})]}),(0,E.jsx)(`div`,{className:$.tldrStats,children:_.map(e=>(0,E.jsxs)(`span`,{children:[(0,E.jsxs)(`span`,{className:$.tldrStatLabel,children:[e.label,`:`]}),(0,E.jsx)(`span`,{className:$.tldrStatValue,style:{"--tone-color":at(e.tone)},children:e.value})]},e.label))})]})})(),(0,E.jsxs)(`div`,{className:$.headerRow,children:[(0,E.jsx)(`h2`,{className:$.headerTitle,children:`Turn-by-Turn Report`}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>{let e=document.getElementById(`summary`);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})},className:$.jumpBtn,children:r?`↓ See verdict + full summary`:`↓ Jump to summary`})]}),F&&(0,E.jsxs)(`div`,{className:$.actorPairPicker,role:`region`,"aria-label":`Pair focus toggle`,children:[(0,E.jsxs)(`label`,{className:$.actorPairPickerToggle,children:[(0,E.jsx)(`input`,{type:`checkbox`,checked:I,onChange:e=>we(e.target.checked),"aria-label":`Toggle pair-focus view for strip, sparklines, and trajectory`}),(0,E.jsx)(`span`,{className:$.actorPairPickerToggleText,children:`Focus pair`})]}),I?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsx)(`select`,{"aria-label":`Left side actor`,className:$.actorPairPickerSelect,value:N??``,onChange:e=>Se(e.target.value||null),children:e.actorIds.map(t=>(0,E.jsx)(`option`,{value:t,disabled:t===P,children:e.actors[t]?.leader?.name??t},t))}),(0,E.jsx)(`span`,{className:$.actorPairPickerVs,children:`vs`}),(0,E.jsx)(`select`,{"aria-label":`Right side actor`,className:$.actorPairPickerSelect,value:P??``,onChange:e=>M(e.target.value||null),children:e.actorIds.map(t=>(0,E.jsx)(`option`,{value:t,disabled:t===N,children:e.actors[t]?.leader?.name??t},t))}),(0,E.jsxs)(`span`,{className:$.actorPairPickerHint,children:[`strip + metrics + trajectory show this pair only · turn-by-turn below shows all `,e.actorIds.length,` actors`]})]}):(0,E.jsxs)(`span`,{className:$.actorPairPickerHint,children:[`Showing all `,e.actorIds.length,` actors. Toggle on to focus on a 2-actor head-to-head view in the strip, sparklines, and trajectory cards.`]})]}),(!F||I)&&(0,E.jsx)(`section`,{id:`strip`,children:(0,E.jsx)(Je,{turns:je,leaderAName:U,leaderBName:W})}),(0,E.jsx)(`section`,{id:`sparklines`,children:!F||I?(0,E.jsx)(Qe,{metrics:Me,leaderAName:U,leaderBName:W}):Ne&&(0,E.jsx)(Qe,{metrics:Ne,leaderAName:``,leaderBName:``})}),(0,E.jsxs)(`section`,{id:`trajectory`,children:[G&&I&&(0,E.jsxs)(`div`,{className:`responsive-grid-2 ${$.trajectoryGrid}`,children:[(0,E.jsx)(Te,{events:V?.events??[],actorName:U,baselineHexaco:V?.leader?.hexaco}),(0,E.jsx)(Te,{events:H?.events??[],actorName:W,baselineHexaco:H?.leader?.hexaco})]}),G&&!I&&(0,E.jsx)(`div`,{className:`responsive-grid-2 ${$.trajectoryGrid}`,children:e.actorIds.map(t=>{let n=e.actors[t];return n?.events.length?(0,E.jsx)(Te,{events:n.events,actorName:n.leader?.name||t,baselineHexaco:n.leader?.hexaco},t):null})})]}),e.cost&&e.cost.llmCalls>0&&(0,E.jsxs)(`div`,{className:$.costBar,children:[(0,E.jsx)(`span`,{className:$.costLabel,children:`Run cost`}),(0,E.jsxs)(`span`,{className:$.costAmount,children:[`$`,e.cost.totalCostUSD<.01?e.cost.totalCostUSD.toFixed(4):e.cost.totalCostUSD.toFixed(2)]}),(0,E.jsxs)(`span`,{className:$.costMeta,children:[`· `,e.cost.llmCalls,` LLM calls · `,(e.cost.totalTokens/1e3).toFixed(1),`k tokens`]}),(0,E.jsx)(`button`,{type:`button`,onClick:()=>v(!0),className:$.costBtn,children:`Per-stage breakdown ›`})]}),g&&e.cost&&e.cost.llmCalls>0&&(0,E.jsx)(Ce,{combined:e.cost,leaderA:(z?e.costByActor[z]:void 0)??{totalTokens:0,totalCostUSD:0,llmCalls:0},leaderB:(B?e.costByActor[B]:void 0)??{totalTokens:0,totalCostUSD:0,llmCalls:0},leaderAName:V?.leader?.name,leaderBName:H?.leader?.name,actors:F?e.actorIds.map(t=>({actorId:t,name:e.actors[t]?.leader?.name||t,cost:e.costByActor[t]??{totalTokens:0,totalCostUSD:0,llmCalls:0}})):void 0,onClose:()=>v(!1)}),!F&&R.map(([e,t])=>{let n=t.a,r=t.b,i=n.time||r.time||`?`,a=Math.max(...[...n.events.values()].map(e=>e.totalEvents),...[...r.events.values()].map(e=>e.totalEvents),1),o=n.events.get(0)?.title,s=r.events.get(0)?.title,c=!!(o&&s&&o!==s);return(0,E.jsxs)(`section`,{id:`turn-${e}`,className:[$.turnSection,c?$.diverged:``].filter(Boolean).join(` `),children:[(0,E.jsxs)(`div`,{className:$.turnHeader,children:[(0,E.jsxs)(`span`,{className:$.turnTitle,children:[`Turn `,e,` — Y`,i,a>1&&(0,E.jsxs)(`span`,{className:$.turnEventCount,children:[a,` events`]})]}),(0,E.jsxs)(`div`,{className:$.turnHeaderRight,children:[(0,E.jsx)(`span`,{className:[$.divergenceFlag,c?$.diverged:``].filter(Boolean).join(` `),children:c?`DIVERGENT`:`SHARED`}),xe(e)&&(0,E.jsxs)(`button`,{type:`button`,className:T.forkButton,onClick:()=>S(e),"aria-label":`Fork at ${x.time} ${e}`,children:[`↳ Fork at `,x.Time,` `,e]})]})]}),Array.from({length:a}).map((e,t)=>(0,E.jsxs)(`div`,{className:`responsive-grid-2 ${t<a-1?$.eventGridSpaced:$.eventGrid}`,children:[(0,E.jsx)(ct,{block:n.events.get(t),eventIndex:t,totalEvents:a,name:U,sideColor:`var(--vis)`,sections:J.eventSections}),(0,E.jsx)(ct,{block:r.events.get(t),eventIndex:t,totalEvents:a,name:W,sideColor:`var(--eng)`,sections:J.eventSections})]},t)),(0,E.jsxs)(`div`,{className:`responsive-grid-2 ${$.footerGrid}`,children:[(0,E.jsx)(lt,{data:n,name:U,sideColor:`var(--vis)`,showQuotes:J.footerSections.includes(`quotes`)}),(0,E.jsx)(lt,{data:r,name:W,sideColor:`var(--eng)`,showQuotes:J.footerSections.includes(`quotes`)})]})]},e)}),F&&Oe.map(([t,n])=>{let r=[],i,a=1;for(let t of e.actorIds){let e=n.get(t);if(!e)continue;i??=e.time;for(let t of e.events.values())t.totalEvents>a&&(a=t.totalEvents);let o=e.events.get(0)?.title;o&&r.push(o)}let o=new Set(r).size>1,s=i??`?`;return(0,E.jsxs)(`section`,{id:`turn-${t}`,className:[$.turnSection,o?$.diverged:``].filter(Boolean).join(` `),children:[(0,E.jsxs)(`div`,{className:$.turnHeader,children:[(0,E.jsxs)(`span`,{className:$.turnTitle,children:[`Turn `,t,` — Y`,s,a>1&&(0,E.jsxs)(`span`,{className:$.turnEventCount,children:[a,` events`]})]}),(0,E.jsxs)(`div`,{className:$.turnHeaderRight,children:[(0,E.jsx)(`span`,{className:[$.divergenceFlag,o?$.diverged:``].filter(Boolean).join(` `),children:o?`DIVERGENT`:`SHARED`}),xe(t)&&(0,E.jsxs)(`button`,{type:`button`,className:T.forkButton,onClick:()=>S(t),"aria-label":`Fork at ${x.time} ${t}`,children:[`↳ Fork at `,x.Time,` `,t]})]})]}),Array.from({length:a}).map((t,r)=>(0,E.jsx)(`div`,{className:r<a-1?$.nActorEventTrackSpaced:$.nActorEventTrack,children:e.actorIds.map((t,i)=>{let o=n.get(t)?.events.get(r),s=e.actors[t]?.leader?.name??t;return(0,E.jsx)(ct,{block:o,eventIndex:r,totalEvents:a,name:s,sideColor:i===0?`var(--vis)`:i===1?`var(--eng)`:`var(--amber)`,sections:J.eventSections},t)})},r)),(0,E.jsx)(`div`,{className:$.nActorFooterTrack,children:e.actorIds.map((t,r)=>{let i=n.get(t);if(!i)return null;let a=e.actors[t]?.leader?.name??t;return(0,E.jsx)(lt,{data:i,name:a,sideColor:r===0?`var(--vis)`:r===1?`var(--eng)`:`var(--amber)`,showQuotes:J.footerSections.includes(`quotes`)},t)})})]},t)}),(0,E.jsx)(`section`,{id:`toolbox`,children:l.list.length>0&&(0,E.jsxs)(`details`,{open:p,onToggle:e=>{let t=e.currentTarget.open;t&&!p&&ne({name:`forge_toolbox_open`,from:`reports`}),h(t)},className:a.pageFold,children:[(0,E.jsx)(`summary`,{className:a.pageFoldSummary,children:`FORGED TOOLBOX`}),(0,E.jsx)(fe,{inPage:!0})]})}),(0,E.jsxs)(`section`,{id:`summary`,className:$.summarySection,children:[(0,E.jsx)(`div`,{className:$.summaryLabel,children:`Run Summary · Verdict · Winner`}),(0,E.jsx)(Ae,{verdict:r,leaderAName:U,leaderBName:W}),(0,E.jsx)(Ie,{state:e}),r&&(0,E.jsx)(`div`,{className:$.summaryVerdictWrap,children:(0,E.jsx)(m,{verdict:r,shownRun:o})})]}),(0,E.jsx)(`section`,{id:`references`,children:c.list.length>0&&(0,E.jsx)(ce,{registry:c,title:`References`,collapsible:!0,defaultOpen:d,onToggle:f})}),(0,E.jsxs)(`details`,{className:$.aboutDetails,children:[(0,E.jsx)(`summary`,{className:$.aboutSummary,children:`What's in this report?`}),(0,E.jsxs)(`div`,{className:$.aboutBody,children:[(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:$.aboutBlockTitle,children:`Scenario focus`}),(0,E.jsx)(`div`,{className:$.aboutChips,children:J.focusSections.map(e=>(0,E.jsx)(`span`,{className:$.aboutChip,children:Ee[e]},e))})]}),(0,E.jsxs)(`div`,{children:[(0,E.jsx)(`div`,{className:$.aboutBlockTitle,children:`This run produced`}),(0,E.jsx)(`div`,{className:$.aboutChips,children:J.artifacts.map(e=>(0,E.jsx)(`span`,{className:$.aboutChipNeutral,children:De[e]},e))})]})]})]})]}),(0,E.jsx)(et,{items:Y,scrollRoot:X.current}),pe!==null&&C&&(0,E.jsx)(ye,{parentArtifact:C,atTurn:pe,maxTurns:_e(C),costPreset:`economy`,provider:`openai`,onConfirm:D,onClose:()=>S(null)})]})}var st={positive:`var(--green)`,negative:`var(--rust)`,anxious:`var(--amber)`,defiant:`var(--rust)`,hopeful:`var(--green)`,resigned:`var(--text-3)`,neutral:`var(--text-2)`};function ct({block:e,eventIndex:t,totalEvents:n,name:r,sideColor:i,sections:a}){let o={"--side-color":i};if(!e||!e.title)return(0,E.jsxs)(`div`,{className:$.eventCard,children:[(0,E.jsxs)(`h4`,{className:$.eventHeading,style:o,children:[r,n>1&&(0,E.jsxs)(`span`,{className:$.eventSubLabel,children:[`Event `,t+1,`/`,n]})]}),(0,E.jsx)(`span`,{className:$.eventAwaiting,children:`Awaiting data...`})]});let s={crisis:(0,E.jsxs)(`div`,{children:[(0,E.jsxs)(`div`,{className:$.eventTitle,children:[(0,E.jsx)(u,{authored:!!e.title&&v(e.eventAuthorship,`title`),children:e.title}),e.category&&(0,E.jsx)(`span`,{className:$.categoryPill,children:e.category}),e.emergent&&(0,E.jsx)(`span`,{className:$.emergentPill,children:`EMERGENT`})]}),e.description&&(0,E.jsx)(u,{as:`div`,className:$.eventDescription,authored:v(e.eventAuthorship,`description`),children:e.description})]},`crisis`),decision:e.decision?(0,E.jsx)(u,{as:`div`,className:$.eventDecision,authored:p(e.decisionAuthorship,`decision`,e.decision),children:e.decision},`decision`):null,outcome:e.outcome?(0,E.jsxs)(`div`,{className:$.eventOutcomeRow,children:[(0,E.jsx)(d,{outcome:e.outcome}),Array.isArray(e.policies)&&e.policies.length>0&&(0,E.jsx)(`span`,{className:$.eventPolicies,children:e.policies.map(e=>String(e)).join(` / `)})]},`outcome`):null,causality:e.rationale?(0,E.jsxs)(`details`,{className:$.eventDetails,children:[(0,E.jsx)(`summary`,{className:$.eventDetailsSummary,style:o,children:`Rationale`}),(0,E.jsx)(u,{as:`div`,className:$.eventRationale,style:o,authored:p(e.decisionAuthorship,`rationale`,e.rationale),children:e.rationale})]},`causality`):null,departments:Object.keys(e.depts).length>0?(0,E.jsxs)(`details`,{className:$.eventDetails,open:!0,children:[(0,E.jsxs)(`summary`,{className:$.eventDetailsSummary,style:o,children:[`Departments (`,Object.keys(e.depts).length,`)`]}),(0,E.jsx)(`div`,{className:$.deptList,children:Object.entries(e.depts).map(([e,t])=>(0,E.jsxs)(`div`,{className:$.deptItem,style:o,children:[(0,E.jsxs)(`div`,{className:$.deptHead,children:[(0,E.jsx)(`span`,{className:$.deptName,children:e.charAt(0).toUpperCase()+e.slice(1)}),(0,E.jsxs)(`span`,{className:$.deptMeta,children:[t.citations,`c `,t.tools,`t`]})]}),t.summary&&(0,E.jsx)(u,{as:`div`,className:$.deptSummary,authored:p(t,`summary`,t.summary),children:t.summary}),(0,E.jsx)(ue,{citations:t.citationList,label:``})]},e))})]},`departments`):null};return(0,E.jsxs)(`div`,{className:$.eventCard,children:[(0,E.jsxs)(`h4`,{className:$.eventHeading,style:o,children:[r,n>1&&(0,E.jsxs)(`span`,{className:$.eventSubLabel,children:[`Event `,t+1,`/`,n]})]}),a.map(e=>s[e]).filter(Boolean)]})}function lt({data:e,name:t,sideColor:n,showQuotes:r}){let i=e.metrics;if(!i&&(!r||e.reactions.length===0))return(0,E.jsx)(`div`,{});let a={"--side-color":n};return(0,E.jsxs)(`div`,{className:$.footerCard,children:[i&&(0,E.jsxs)(`details`,{className:e.reactions.length?$.footerDetails:$.footerDetailsLast,children:[(0,E.jsxs)(`summary`,{className:$.footerSummary,style:a,children:[t,` · Systems State`]}),(0,E.jsx)(`div`,{className:$.systemsRow,children:Object.entries(i).map(([e,t])=>(0,E.jsxs)(`span`,{className:$.systemItem,children:[(0,E.jsxs)(`span`,{className:$.systemKey,children:[e,`: `]}),(0,E.jsx)(`span`,{className:$.systemValue,children:typeof t==`number`?Number.isInteger(t)?t:t.toFixed(2):String(t)})]},e))})]}),r&&e.reactions.length>0&&(0,E.jsxs)(`details`,{open:!0,children:[(0,E.jsxs)(`summary`,{className:$.footerSummary,style:a,children:[`Agent Voices (`,e.totalReactions||e.reactions.length,`)`]}),(0,E.jsx)(`div`,{className:$.reactionsList,children:e.reactions.map((e,t)=>(0,E.jsxs)(`div`,{className:$.reactionItem,children:[(0,E.jsxs)(`div`,{className:$.reactionHead,children:[(0,E.jsx)(`span`,{className:$.reactionName,style:a,children:String(e.name)}),(0,E.jsx)(`span`,{className:$.moodPill,style:{"--mood-color":st[String(e.mood)]||`var(--text-3)`},children:String(e.mood||``).toUpperCase()})]}),(0,E.jsxs)(u,{as:`div`,className:$.reactionQuote,authored:!!e.quote,children:[`“`,String(e.quote||``),`”`]}),!!e.role&&(0,E.jsxs)(`div`,{className:$.reactionRole,children:[String(e.role),` `,e.department?`in ${String(e.department)}`:``]})]},t))})]})]})}export{ot as ReportView};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{$ as t,$t as n,B as r,Cn as i,F as a,Gt as o,J as s,Jt as c,K as l,Kt as u,Q as d,Qt as ee,S as te,Sn as ne,St as re,Wt as f,X as ie,Xt as p,Y as m,Yt as h,Z as g,Zt as ae,_n as _,an as oe,bn as se,cn as v,ct as ce,dn as y,dt as b,en as x,et as S,fn as C,hn as le,i as w,in as T,ln as ue,lt as de,n as fe,on as pe,q as me,qt as E,r as he,sn as ge,st as _e,t as ve,tt as D,vn as ye,xn as be,yn as xe,z as O}from"./index-BPO4i_k0.js";import{t as Se}from"./SubTabNav-DT8T_8_D.js";var k=e(_(),1),A={group:`_group_p35hb_1`},j=y();function Ce({onClearLocal:e,onWipeServer:t,onOpen:n}){return(0,k.useEffect)(()=>n?.(),[n]),(0,j.jsxs)(`fieldset`,{className:A.group,children:[(0,j.jsx)(`legend`,{children:te}),(0,j.jsx)(`button`,{type:`button`,onClick:e,children:`Clear local data`}),t&&(0,j.jsx)(`button`,{type:`button`,onClick:t,children:`Delete server data`})]})}function we(e,t){return e===`O`?t>.7?`creative`:t<.3?`conventional`:``:e===`C`?t>.7?`disciplined`:t<.3?`flexible`:``:e===`E`?t>.7?`charismatic`:t<.3?`reserved`:``:e===`A`?t>.7?`cooperative`:t<.3?`competitive`:``:e===`Em`?t>.7?`empathetic`:t<.3?`calm`:``:e===`HH`?t>.7?`sincere`:t<.3?`strategic`:``:``}function M({label:e,shortLabel:t,value:n,onChange:r,sideColor:i}){let a=we(t,n),o=i||`var(--amber)`,s={flex:1,accentColor:o,"--pc-range-fill":o,"--pc-range-pct":`${Math.round(n*100)}%`};return(0,j.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,j.jsx)(`label`,{style:{fontSize:`var(--font-sm)`,color:`var(--text-2)`,minWidth:`32px`,fontWeight:700},children:t}),(0,j.jsx)(`input`,{type:`range`,min:`0`,max:`1`,step:`0.05`,value:n,onChange:e=>r(parseFloat(e.target.value)),className:`pc-range`,style:s,"aria-label":e,"aria-valuetext":n.toFixed(2)}),(0,j.jsx)(`span`,{style:{fontSize:`var(--font-md)`,fontFamily:`var(--mono)`,minWidth:`36px`,textAlign:`right`,color:`var(--text-1)`,fontWeight:600},children:n.toFixed(2)}),(0,j.jsx)(`span`,{style:{fontSize:`var(--font-3xs)`,color:`var(--text-3)`,minWidth:`55px`,fontFamily:`var(--mono)`},children:a})]})}var N={notice:`_notice_9kjix_1`,badge:`_badge_9kjix_16`,body:`_body_9kjix_30`,headline:`_headline_9kjix_35`,copy:`_copy_9kjix_43`,links:`_links_9kjix_56`,link:`_link_9kjix_56`};function Te(){return(0,j.jsxs)(`div`,{className:N.notice,role:`note`,"aria-label":`Pluggable trait models`,children:[(0,j.jsx)(`span`,{className:N.badge,"aria-hidden":`true`,children:`NEW`}),(0,j.jsxs)(`div`,{className:N.body,children:[(0,j.jsx)(`div`,{className:N.headline,children:`Leaders accept pluggable trait models.`}),(0,j.jsxs)(`p`,{className:N.copy,children:[`The dashboard form below configures HEXACO leaders today. The API also accepts `,(0,j.jsx)(`code`,{children:`ai-agent`}),` leaders (six axes for AI-system decision-makers: exploration, verification-rigor, deference, risk-tolerance, transparency, instruction-following). Slider generalization for non-HEXACO models is queued; in the meantime, supply a`,` `,(0,j.jsx)(`code`,{children:`traitProfile`}),` field via`,` `,(0,j.jsx)(`code`,{children:`runSimulation(leader, ...)`}),` directly.`]}),(0,j.jsxs)(`div`,{className:N.links,children:[(0,j.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/blob/master/docs/COOKBOOK.md#pluggable-traits-ai-agent-end-to-end`,target:`_blank`,rel:`noopener`,className:N.link,children:`Captured ai-agent end-to-end run`}),(0,j.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/blob/master/docs/COOKBOOK.md#pluggable-traits-ai-agent-end-to-end`,target:`_blank`,rel:`noopener`,className:N.link,children:`Trait-model cookbook`})]})]})]})}var P={root:`_root_5ydsz_1`,heading:`_heading_5ydsz_11`,fieldRow:`_fieldRow_5ydsz_23`,field:`_field_5ydsz_23`,label:`_label_5ydsz_33`,presetLabel:`_presetLabel_5ydsz_33`,input:`_input_5ydsz_44`,presetSelect:`_presetSelect_5ydsz_44`,textarea:`_textarea_5ydsz_44`,textareaBlock:`_textareaBlock_5ydsz_61`,presetRow:`_presetRow_5ydsz_72`,hexacoGrid:`_hexacoGrid_5ydsz_91`},Ee=[{key:`openness`,label:`Openness`,short:`O`},{key:`conscientiousness`,label:`Conscientiousness`,short:`C`},{key:`extraversion`,label:`Extraversion`,short:`E`},{key:`agreeableness`,label:`Agreeableness`,short:`A`},{key:`emotionality`,label:`Emotionality`,short:`Em`},{key:`honestyHumility`,label:`Honesty-Humility`,short:`HH`}],De=[{id:`visionary`,label:`The Visionary (high O, low C)`,hexaco:{openness:.95,conscientiousness:.35,extraversion:.85,agreeableness:.55,emotionality:.3,honestyHumility:.65}},{id:`engineer`,label:`The Engineer (high C, low O)`,hexaco:{openness:.25,conscientiousness:.97,extraversion:.3,agreeableness:.6,emotionality:.7,honestyHumility:.9}},{id:`diplomat`,label:`The Diplomat (high A, high HH)`,hexaco:{openness:.6,conscientiousness:.55,extraversion:.7,agreeableness:.9,emotionality:.5,honestyHumility:.85}},{id:`maverick`,label:`The Maverick (high O, high E, low A)`,hexaco:{openness:.9,conscientiousness:.4,extraversion:.95,agreeableness:.25,emotionality:.2,honestyHumility:.4}},{id:`guardian`,label:`The Guardian (high C, high Em, high HH)`,hexaco:{openness:.3,conscientiousness:.85,extraversion:.4,agreeableness:.7,emotionality:.85,honestyHumility:.95}},{id:`strategist`,label:`The Strategist (balanced, low Em)`,hexaco:{openness:.65,conscientiousness:.75,extraversion:.5,agreeableness:.45,emotionality:.2,honestyHumility:.55}},{id:`balanced`,label:`Balanced (all 0.50)`,hexaco:{openness:.5,conscientiousness:.5,extraversion:.5,agreeableness:.5,emotionality:.5,honestyHumility:.5}}];function Oe({label:e,sideColor:t,data:n,onChange:r}){let i=(0,k.useId)(),a=`${i}-name`,o=`${i}-archetype`,s=`${i}-unit`,c=`${i}-instructions`,l=`${i}-preset`,u=e=>{if(!n.aiAuthorship)return;let t=n.aiAuthorship.fields.filter(t=>t!==e);return t.length?{...n.aiAuthorship,fields:t}:void 0},d=(e,t)=>r({...n,[e]:t,aiAuthorship:n[e]===t?n.aiAuthorship:u(e)}),ee=(e,t)=>r({...n,hexaco:{...n.hexaco,[e]:t},aiAuthorship:u(`hexaco`)});return(0,j.jsxs)(`div`,{className:P.root,style:{"--side-color":t},children:[(0,j.jsx)(`h3`,{className:P.heading,children:e}),(0,j.jsxs)(`div`,{className:`responsive-stack ${P.fieldRow}`,children:[(0,j.jsxs)(`div`,{className:P.field,children:[(0,j.jsx)(`label`,{htmlFor:a,className:P.label,children:`Name`}),(0,j.jsx)(`input`,{id:a,value:n.name,onChange:e=>d(`name`,e.target.value),className:P.input})]}),(0,j.jsxs)(`div`,{className:P.field,children:[(0,j.jsx)(`label`,{htmlFor:o,className:P.label,children:`Archetype`}),(0,j.jsx)(`input`,{id:o,value:n.archetype,onChange:e=>d(`archetype`,e.target.value),className:P.input})]}),(0,j.jsxs)(`div`,{className:P.field,children:[(0,j.jsx)(`label`,{htmlFor:s,className:P.label,children:`Unit`}),(0,j.jsx)(`input`,{id:s,value:n.unit,onChange:e=>d(`unit`,e.target.value),className:P.input})]})]}),(0,j.jsxs)(`div`,{className:P.textareaBlock,children:[(0,j.jsx)(`label`,{htmlFor:c,className:P.label,children:`Instructions`}),(0,j.jsx)(`textarea`,{id:c,value:n.instructions??``,onChange:e=>d(`instructions`,e.target.value),rows:3,className:P.textarea})]}),(0,j.jsx)(Te,{}),(0,j.jsxs)(`div`,{className:P.presetRow,children:[(0,j.jsx)(`label`,{htmlFor:l,className:P.presetLabel,children:`Personality`}),(0,j.jsxs)(`select`,{id:l,className:`pc-select ${P.presetSelect}`,onChange:e=>{let t=De.find(t=>t.id===e.target.value);t&&r({...n,hexaco:{...t.hexaco},aiAuthorship:u(`hexaco`)})},defaultValue:``,children:[(0,j.jsx)(`option`,{value:``,disabled:!0,children:`Apply preset...`}),De.map(e=>(0,j.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,j.jsx)(`div`,{className:`responsive-grid-3 ${P.hexacoGrid}`,children:Ee.map(e=>(0,j.jsx)(M,{label:e.label,shortLabel:e.short,value:n.hexaco[e.key]??.5,onChange:t=>ee(e.key,t),sideColor:t},e.key))})]})}function F(e){let t={scenario:e.scenario,webSearch:e.webSearch},n=e.seedUrl.trim(),r=e.seedText.trim(),i=e.provider?.trim(),a=e.model?.trim(),o=Number.parseInt(e.maxSearches,10);return n?t.seedUrl=n:r&&(t.seedText=r),Number.isFinite(o)&&o>0&&(t.maxSearches=o),i&&(t.provider=i),a&&(t.model=a),t}async function I(e){if(e.ok)return null;try{let t=await e.json();if(typeof t.error==`string`&&t.error.length>0)return t.error}catch{}return`The compile was refused (HTTP ${e.status}).`}var L={card:`_card_m5xbp_1`,header:`_header_m5xbp_10`,title:`_title_m5xbp_20`,lead:`_lead_m5xbp_28`,btnRow:`_btnRow_m5xbp_34`,btn:`_btn_m5xbp_34`,amber:`_amber_m5xbp_53`,fileInput:`_fileInput_m5xbp_58`,editorWrap:`_editorWrap_m5xbp_62`,editor:`_editor_m5xbp_62`,statusBar:`_statusBar_m5xbp_83`,seedDetails:`_seedDetails_m5xbp_93`,seedSummary:`_seedSummary_m5xbp_97`,seedBody:`_seedBody_m5xbp_105`,input:`_input_m5xbp_112`,textarea:`_textarea_m5xbp_123`,checkboxLabel:`_checkboxLabel_m5xbp_136`,fineprint:`_fineprint_m5xbp_144`,progressWrap:`_progressWrap_m5xbp_151`,progressRow:`_progressRow_m5xbp_157`,progressStatus:`_progressStatus_m5xbp_166`,result:`_result_m5xbp_170`,actions:`_actions_m5xbp_178`,actionBtn:`_actionBtn_m5xbp_186`,primary:`_primary_m5xbp_203`,spacer:`_spacer_m5xbp_214`,memCount:`_memCount_m5xbp_218`},ke={id:`my-scenario`,version:`1.0.0`,engineArchetype:`closed_turn_based_settlement`,labels:{name:`My Scenario`,shortName:`custom`,populationNoun:`agents`,settlementNoun:`settlement`,currency:`credits`},theme:{primaryColor:`#6366f1`,accentColor:`#818cf8`},setup:{defaultTurns:8,defaultSeed:100,defaultStartTime:2040,defaultPopulation:50,configurableSections:[`actors`,`departments`,`models`]},departments:[{id:`operations`,label:`Operations`,role:`Operations Lead`,icon:``,defaultModel:`gpt-5.4-mini`,instructions:`You analyze operations.`},{id:`research`,label:`Research`,role:`Head of Research`,icon:``,defaultModel:`gpt-5.4-mini`,instructions:`You analyze research.`}],metrics:[{id:`population`,label:`Population`,source:`metrics.population`,format:`number`}],effects:{environmental:{morale:.08},resource:{morale:.05}},ui:{headerMetrics:[{id:`population`,format:`number`}],tooltipFields:[],reportSections:[`crisis`],departmentIcons:{},setupSections:[`actors`]},policies:{toolForging:{enabled:!0},liveSearch:{enabled:!1,mode:`off`},bulletin:{enabled:!0},characterChat:{enabled:!0},sandbox:{timeoutMs:1e4,memoryMB:128}},presets:[]},Ae=`paracosm:editorCompileResult`;function je(){try{let e=window.sessionStorage.getItem(Ae);if(!e)return null;let t=JSON.parse(e);return typeof t.message==`string`?{success:t.success===!0,message:t.message}:null}catch{return null}}function Me({onAdminWrite:e}){let[t,n]=(0,k.useState)({adminWrite:!1,memoryScenarios:[]}),[r,i]=(0,k.useState)(``),[a,o]=(0,k.useState)(null),[s,l]=(0,k.useState)(``),[d,te]=(0,k.useState)(``),[ne,re]=(0,k.useState)(``),[f,ie]=(0,k.useState)(!0),[m,h]=(0,k.useState)(`5`),[g,_]=(0,k.useState)(``),[se,v]=(0,k.useState)(``),[ce,y]=(0,k.useState)(!1),[b,x]=(0,k.useState)(!1),[S,C]=(0,k.useState)([]),[w,T]=(0,k.useState)(()=>je()),ue=(0,k.useRef)(null),de=(0,k.useRef)(null);(0,k.useEffect)(()=>{fetch(`/admin-config`).then(e=>e.json()).then(t=>{n(t),e?.(t.adminWrite===!0)}).catch(()=>{});try{window.sessionStorage.removeItem(Ae)}catch{}},[]);let fe=(0,k.useCallback)(()=>{fetch(`/scenario`).then(e=>e.ok?e.json():null).then(e=>{e?.id&&(o(e.provenance?.models?.compiler?{id:e.id,provenance:e.provenance}:null),i(JSON.stringify(e,null,2)))}).catch(()=>{})},[]);(0,k.useEffect)(()=>(fe(),ge(window,fe)),[fe]),(0,k.useEffect)(()=>{if(!r.trim())l(``);else try{JSON.parse(r),l(``)}catch(e){l(String(e).replace(`SyntaxError: `,``))}},[r]);let me=()=>{o(null),i(JSON.stringify(ke,null,2))},E=(0,k.useCallback)(async()=>{try{let e=await(await fetch(`/scenario`)).json();o(e.provenance?.models?.compiler?{id:e.id,provenance:e.provenance}:null),i(JSON.stringify(e,null,2)),T({success:!0,message:`Loaded active scenario: ${e.labels?.name||e.id}`})}catch(e){T({success:!1,message:`Failed to load: ${e}`})}},[]),he=()=>ue.current?.click(),_e=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{let e=n.result;o(null),i(e);try{JSON.parse(e),T({success:!0,message:`Imported ${t.name} (${(t.size/1024).toFixed(1)}KB)`})}catch{T({success:!1,message:`Imported ${t.name} but JSON is invalid`})}},n.readAsText(t),e.target.value=``},ve=()=>{if(r.trim())try{let e=JSON.parse(r),t=e.id||`scenario`,n=a&&a.id===e.id?{...e,provenance:a.provenance}:e;le(JSON.stringify(n,null,2),`${t}.json`),T({success:!0,message:`Exported ${t}.json`})}catch{T({success:!1,message:`Fix JSON errors before exporting`})}},D=(0,k.useCallback)(async()=>{if(r.trim()&&!s){x(!0);try{let e=JSON.parse(r),t=await(await fetch(`/scenario/store`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({scenario:e,saveToDisk:!1})})).json();t.stored?(oe(window),T({success:!0,message:t.switchable?`Stored "${t.id}" in memory and added it to the scenario selector.`:`Stored "${t.id}" as draft JSON in memory. Compile it to make it runnable and switchable.`}),n(e=>({...e,memoryScenarios:[...new Set([...e.memoryScenarios,t.id])]}))):T({success:!1,message:t.error||`Store failed`})}catch(e){T({success:!1,message:String(e)})}x(!1)}},[r,s]),ye=(0,k.useCallback)(async()=>{if(r.trim()&&!s&&t.adminWrite)try{let e=JSON.parse(r),t=ee(),n=ae(t);if(n){T({success:!1,message:n});return}let i=await fetch(`/scenario/store`,{method:`POST`,headers:{"Content-Type":`application/json`,...t?{[u]:t}:{}},body:JSON.stringify({scenario:e,saveToDisk:!0})}),a=await i.json();a.savedToDisk?(oe(window),T({success:!0,message:a.switchable?`Saved "${a.id}" to disk at scenarios/${a.id}.json and loaded it into the live scenario catalog.`:`Saved "${a.id}" draft JSON to disk at scenarios/${a.id}.json. Compile it to make it runnable after restart.`})):i.status===401?(p(t),T({success:!1,message:`Disk write refused: the admin token is missing or wrong. ${c}`})):T({success:!1,message:a.error||`Disk write refused (HTTP ${i.status})`})}catch(e){T({success:!1,message:String(e)})}},[r,s,t.adminWrite]),be=(0,k.useCallback)(async()=>{if(!r.trim()||s)return;let e;try{e=JSON.parse(r)}catch{T({success:!1,message:`Fix JSON errors before compiling`});return}y(!0),C([]),T(null);try{let t=F({scenario:e,seedText:d,seedUrl:ne,webSearch:f,maxSearches:m,provider:g,model:se}),n=await fetch(`/compile`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await I(n);if(r!==null){T({success:!1,message:r}),y(!1);return}let i=n.body?.getReader();if(!i)throw Error(`No response stream`);let a=new TextDecoder,o=``;for(;;){let{done:e,value:t}=await i.read();if(e)break;o+=a.decode(t,{stream:!0});let n=o.split(`
|
|
2
|
+
`);o=n.pop()||``;for(let e of n)if(e.startsWith(`data: `))try{let t=JSON.parse(e.slice(6));if(t.hook&&C(e=>{let n=e.findIndex(e=>e.hook===t.hook);if(n>=0){let r=[...e];return r[n]=t,r}return[...e,t]}),t.id){let e=null;try{let n=await fetch(`/scenario/switch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t.id})});n.ok||(e=(await n.json().catch(()=>({}))).error??`HTTP ${n.status}`)}catch(t){e=String(t)}if(e){T({success:!1,message:`Compiled ${t.id}, but switching to it failed: ${e}`});continue}try{window.sessionStorage.setItem(Ae,JSON.stringify({success:!0,message:`Compiled: ${t.id} (${t.departments} departments, ${t.hooks} hooks). Configure actors below and launch.`}))}catch{}pe(),window.location.reload();return}t.error&&T({success:!1,message:t.error})}catch{}}}catch(e){T({success:!1,message:String(e)})}y(!1)},[r,s,d,ne,f,m,g,se]),xe=r.split(`
|
|
3
|
+
`).length,Se=new Blob([r]).size;return(0,j.jsxs)(`div`,{className:L.card,children:[(0,j.jsxs)(`div`,{className:L.header,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`h3`,{className:L.title,children:`Scenario Editor`}),(0,j.jsxs)(`p`,{className:L.lead,children:[`Write or import a scenario JSON draft. Add seed text or a URL to ground it, then compile or export.`,!t.adminWrite&&` Disk saves are disabled on this instance.`]})]}),(0,j.jsxs)(`div`,{className:L.btnRow,children:[(0,j.jsx)(`button`,{onClick:E,className:[L.btn,L.amber].join(` `),"aria-label":`Load active scenario JSON`,children:`Load Active`}),(0,j.jsx)(`button`,{onClick:me,className:L.btn,"aria-label":`Load example scenario`,children:`Template`}),(0,j.jsx)(`button`,{onClick:he,className:L.btn,"aria-label":`Import JSON file`,children:`Import`}),(0,j.jsx)(`button`,{onClick:ve,className:L.btn,disabled:!r.trim()||!!s,"aria-label":a?`Export as JSON file`:`Save source JSON`,children:a?`Export`:`Save source JSON`}),(0,j.jsx)(`input`,{ref:ue,type:`file`,accept:`.json,application/json`,onChange:_e,className:L.fileInput})]})]}),(0,j.jsxs)(`div`,{className:L.editorWrap,children:[(0,j.jsx)(`textarea`,{ref:de,value:r,onChange:e=>i(e.target.value),placeholder:`{\\n "id": "my-scenario",\\n "labels": { "name": "My World" },\\n "departments": [...]\\n}`,spellCheck:!1,"aria-label":`Scenario JSON editor`,className:L.editor}),(0,j.jsxs)(`div`,{className:L.statusBar,style:{"--status-color":s?`var(--rust)`:`var(--text-3)`},children:[(0,j.jsx)(`span`,{children:s||(r.trim()?`Valid JSON`:`Empty`)}),(0,j.jsxs)(`span`,{children:[xe,` lines, `,(Se/1024).toFixed(1),`KB`]})]})]}),(0,j.jsxs)(`details`,{className:L.seedDetails,children:[(0,j.jsx)(`summary`,{className:L.seedSummary,children:`Seed Enrichment (optional)`}),(0,j.jsxs)(`div`,{className:L.seedBody,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{style:O,children:`Seed Text`}),(0,j.jsx)(`textarea`,{value:d,onChange:e=>te(e.target.value),placeholder:`Paste a prompt, notes, a brief, or source text to turn into research facts and category mapping.`,className:L.textarea})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{style:O,children:`Seed URL (fetched via Firecrawl)`}),(0,j.jsx)(`input`,{value:ne,onChange:e=>re(e.target.value),placeholder:`https://example.com/article`,className:L.input})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{style:O,children:`Max Web Searches`}),(0,j.jsx)(`input`,{value:m,onChange:e=>h(e.target.value),inputMode:`numeric`,placeholder:`5`,className:L.input})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{style:O,children:`Compile Provider Override`}),(0,j.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),placeholder:`anthropic or openai (optional)`,className:L.input})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{style:O,children:`Compile Model Override`}),(0,j.jsx)(`input`,{value:se,onChange:e=>v(e.target.value),placeholder:`gpt-5.4-mini, claude-sonnet-4-6, etc. (optional)`,className:L.input})]}),(0,j.jsxs)(`label`,{className:L.checkboxLabel,children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:f,onChange:e=>ie(e.target.checked)}),`Web search enrichment (requires Serper/Tavily/Firecrawl API keys)`]}),(0,j.jsx)(`p`,{className:L.fineprint,children:`If both seed text and a seed URL are provided, the URL takes precedence and the compiler ingests the fetched page.`})]})]}),S.length>0&&(0,j.jsx)(`div`,{className:L.progressWrap,children:S.map(e=>(0,j.jsxs)(`div`,{className:L.progressRow,children:[(0,j.jsx)(`span`,{children:e.status===`done`?`✔`:e.status===`generating`?`⏳`:e.status===`cached`?`✔`:`•`}),(0,j.jsx)(`span`,{children:e.hook}),(0,j.jsx)(`span`,{className:L.progressStatus,children:e.status})]},e.hook))}),w&&(0,j.jsx)(`div`,{className:L.result,style:{"--result-color":w.success?`var(--green)`:`var(--rust)`,"--result-bg":w.success?`rgba(106,173,72,.06)`:`rgba(224,101,48,.06)`},children:w.message}),(0,j.jsxs)(`div`,{className:L.actions,children:[(0,j.jsx)(`button`,{onClick:D,disabled:!r.trim()||!!s||b,className:L.actionBtn,"aria-label":`Store scenario in memory`,children:b?`Storing...`:`Store in Memory`}),(0,j.jsx)(`button`,{onClick:be,disabled:!r.trim()||!!s||ce,className:[L.actionBtn,L.primary].join(` `),"aria-label":`Compile scenario`,children:ce?`Compiling...`:`Compile Scenario`}),t.adminWrite&&(0,j.jsx)(`button`,{onClick:ye,disabled:!r.trim()||!!s,className:[L.actionBtn,L.amber].join(` `),"aria-label":`Save scenario to disk`,children:`Save to Disk`}),(0,j.jsx)(`span`,{className:L.spacer}),t.memoryScenarios.length>0&&(0,j.jsxs)(`span`,{className:L.memCount,children:[t.memoryScenarios.length,` in memory`]})]})]})}var R={intro:`_intro_v1quw_1`,label:`_label_v1quw_13`,row:`_row_v1quw_24`,input:`_input_v1quw_31`,btn:`_btn_v1quw_45`,amber:`_amber_v1quw_65`,status:`_status_v1quw_70`,refusal:`_refusal_v1quw_77`},Ne={none:`No token is saved in this browser.`,stored:`A token is saved in this browser. It is not shown back.`,held:`This browser could not store the token, so it is kept only until this page reloads.`};function Pe(){let e=(0,k.useRef)(null),[t,r]=(0,k.useState)(!1),[i,a]=(0,k.useState)(()=>h()),[o,s]=(0,k.useState)(null);(0,k.useEffect)(()=>x(()=>a(h())),[]);let c=()=>{e.current&&(e.current.value=``),r(!1)},l=()=>{let t=e.current?.value??``;if(!t.trim())return;let r=n(t);r===`unsendable`?s(E):(s(null),a(r),c())};return(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`p`,{className:R.intro,children:[`Admin writes on this server take its `,(0,j.jsx)(`code`,{children:`ADMIN_TOKEN`}),`: Save to Disk in the scenario editor below, Delete server data in the run actions menu, and Rename and Delete in a scenario's details. Enter the token once. The dashboard sends it only on those requests, as the `,(0,j.jsx)(`code`,{children:`X-Admin-Token`}),` header, and keeps it in this browser.`]}),(0,j.jsx)(`label`,{htmlFor:`admin-token`,className:R.label,children:`Token for this server`}),(0,j.jsxs)(`div`,{className:R.row,children:[(0,j.jsx)(`input`,{id:`admin-token`,type:`password`,autoComplete:`off`,spellCheck:!1,ref:e,onChange:e=>{r(e.target.value.trim()!==``),s(null)},onKeyDown:e=>{e.key===`Enter`&&l()},placeholder:i===`none`?`Not entered`:`Saved`,"aria-describedby":`admin-token-status`,className:R.input}),(0,j.jsx)(`button`,{type:`button`,onClick:l,disabled:!t,className:[R.btn,R.amber].join(` `),"aria-label":`Save admin token`,children:`Save`}),(0,j.jsx)(`button`,{type:`button`,onClick:()=>{p(),a(`none`),s(null),c()},disabled:i===`none`&&!t,className:R.btn,"aria-label":`Clear admin token`,children:`Clear`})]}),(0,j.jsx)(`div`,{id:`admin-token-status`,role:`status`,className:R.status,children:Ne[i]}),o&&(0,j.jsx)(`p`,{role:`alert`,className:R.refusal,children:o})]})}var z={card:`_card_1bn52_1`,empty:`_empty_1bn52_14`,headerRow:`_headerRow_1bn52_18`,kicker:`_kicker_1bn52_26`,lead:`_lead_1bn52_40`,leadMuted:`_leadMuted_1bn52_50`,leadCount:`_leadCount_1bn52_54`,refreshBtn:`_refreshBtn_1bn52_58`,grid:`_grid_1bn52_72`,tile:`_tile_1bn52_78`,tileTitle:`_tileTitle_1bn52_99`,tileMeta:`_tileMeta_1bn52_106`,tileCost:`_tileCost_1bn52_112`,tileCta:`_tileCta_1bn52_118`,moreNote:`_moreNote_1bn52_127`};function Fe({hideWhenUnavailable:e=!0}={}){let{sessions:t,status:n,refresh:r}=f(),i=(0,k.useRef)(null),a=(0,k.useMemo)(()=>t.slice(0,3),[t]);if(n===`loading`||n===`unavailable`&&e)return null;let o=e=>{let t=new URL(window.location.href);t.searchParams.set(`replay`,e),t.searchParams.set(`tab`,`sim`),t.hash=``,window.location.assign(t.toString())},s=e=>new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`}),c=t.length===0,l=[z.card,c?z.empty:``].filter(Boolean).join(` `),u=[z.kicker,c?z.empty:``].filter(Boolean).join(` `),d=[z.lead,c?z.empty:``].filter(Boolean).join(` `);return(0,j.jsxs)(`div`,{ref:i,className:l,children:[(0,j.jsxs)(`div`,{className:z.headerRow,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`div`,{className:u,children:[`▶ `,c?`Replay from cache`:`Watch a prior run`]}),c?(0,j.jsxs)(`div`,{className:d,children:[`No saved runs yet.`,` `,(0,j.jsxs)(`span`,{className:z.leadMuted,children:[`Once any simulation completes it`,`'`,`s auto-cached here, so you can replay the full turn-by-turn playback — every decision, tool forge, and divergence — without re-spending credits.`]})]}):(0,j.jsxs)(`div`,{className:d,children:[`Don`,`'`,`t want to spend credits?`,` `,(0,j.jsxs)(`span`,{className:z.leadMuted,children:[`Replay any of `,(0,j.jsx)(`strong`,{className:z.leadCount,children:t.length}),` `,`cached simulation`,t.length===1?``:`s`,` turn-by-turn, complete with every decision, tool forge, and divergence.`]})]})]}),(0,j.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Refresh prior runs list`,title:`Refresh list`,className:z.refreshBtn,children:`↻ Refresh`})]}),!c&&(0,j.jsx)(`div`,{className:z.grid,children:a.map(e=>(0,j.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-label":`Replay ${e.title||e.scenarioName||e.scenarioId||e.id}`,className:z.tile,children:[(0,j.jsx)(`span`,{className:z.tileTitle,children:e.title||e.scenarioName||e.scenarioId||`Simulation`}),(0,j.jsxs)(`span`,{className:z.tileMeta,children:[e.title&&e.scenarioName?`${e.scenarioName} · `:``,typeof e.turnCount==`number`?`${e.turnCount} turns · `:``,b(e)?`${b(e)} · `:``,s(e.createdAt)]}),typeof e.totalCostUSD==`number`&&e.totalCostUSD>0&&(0,j.jsxs)(`span`,{className:z.tileCost,children:[`$`,e.totalCostUSD.toFixed(2)]}),(0,j.jsx)(`span`,{className:z.tileCta,children:`Replay →`})]},e.id))}),!c&&t.length>3&&(0,j.jsxs)(`div`,{className:z.moreNote,children:[`+ `,t.length-3,` more — use the `,(0,j.jsx)(`strong`,{children:`LOAD`}),` button in the top bar to browse the full list.`]})]})}var B={bar:`_bar_127em_1`,topRow:`_topRow_127em_15`,searchWrap:`_searchWrap_127em_22`,searchIcon:`_searchIcon_127em_30`,searchInput:`_searchInput_127em_35`,resetButton:`_resetButton_127em_50`,facetsRow:`_facetsRow_127em_76`,facetLabel:`_facetLabel_127em_83`,checkboxGroup:`_checkboxGroup_127em_93`,checkbox:`_checkbox_127em_93`,active:`_active_127em_115`,leaderSelect:`_leaderSelect_127em_128`,rangeWrap:`_rangeWrap_127em_142`,rangeInput:`_rangeInput_127em_151`,toolChip:`_toolChip_127em_162`,chipClear:`_chipClear_127em_176`,emptyHint:`_emptyHint_127em_188`};function V(e){return e.query!==``||e.types.size>0||e.leader!==null||e.turnRange!==null||e.toolHash!==``}function Ie({events:e,filters:n,onFiltersChange:r}){let i=(0,k.useMemo)(()=>t(e),[e]),a=V(n),o=e=>{r({...n,...e})},s=e=>{let t=new Set(n.types);t.has(e)?t.delete(e):t.add(e),o({types:t})},c=e=>n.types.size===0||n.types.has(e);return(0,j.jsxs)(`div`,{className:B.bar,children:[(0,j.jsxs)(`div`,{className:B.topRow,children:[(0,j.jsxs)(`div`,{className:B.searchWrap,children:[(0,j.jsx)(`span`,{"aria-hidden":`true`,className:B.searchIcon,children:`🔍`}),(0,j.jsx)(`input`,{type:`search`,"aria-label":`Filter log by text (type, leader, department, title, summary)`,placeholder:`Search type, leader, department, title, summary...`,value:n.query,onChange:e=>o({query:e.target.value}),className:B.searchInput})]}),n.toolHash&&(0,j.jsxs)(`span`,{className:B.toolChip,children:[`tool: `,n.toolHash,(0,j.jsx)(`button`,{type:`button`,"aria-label":`Clear tool filter`,className:B.chipClear,onClick:()=>o({toolHash:``,toolExact:!1}),children:`×`})]}),(0,j.jsx)(`button`,{type:`button`,className:B.resetButton,disabled:!a,onClick:()=>r(d()),children:`Reset filters`})]}),i.types.length>0&&(0,j.jsxs)(`div`,{className:B.facetsRow,children:[(0,j.jsx)(`span`,{className:B.facetLabel,children:`types`}),(0,j.jsx)(`div`,{className:B.checkboxGroup,children:i.types.map(e=>{let t=c(e);return(0,j.jsxs)(`label`,{className:[B.checkbox,t?B.active:``].filter(Boolean).join(` `),children:[(0,j.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>s(e)}),e]},e)})})]}),(i.actors.length>1||i.maxTurn>3)&&(0,j.jsxs)(`div`,{className:B.facetsRow,children:[i.actors.length>1&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:B.facetLabel,children:`leader`}),(0,j.jsxs)(`select`,{"aria-label":`Filter by leader`,className:B.leaderSelect,value:n.leader??``,onChange:e=>o({leader:e.target.value||null}),children:[(0,j.jsx)(`option`,{value:``,children:`all`}),i.actors.map(e=>(0,j.jsx)(`option`,{value:e,children:e},e))]})]}),i.maxTurn>3&&(0,j.jsxs)(j.Fragment,{children:[(0,j.jsx)(`span`,{className:B.facetLabel,children:`turns`}),(0,j.jsxs)(`div`,{className:B.rangeWrap,children:[(0,j.jsx)(`input`,{type:`number`,"aria-label":`Min turn`,min:0,max:i.maxTurn,value:n.turnRange?n.turnRange[0]:0,onChange:e=>{let t=Number(e.target.value);if(!Number.isFinite(t))return;let r=n.turnRange?.[1]??i.maxTurn;o({turnRange:[t,Math.max(t,r)]})},className:B.rangeInput}),(0,j.jsx)(`span`,{children:`to`}),(0,j.jsx)(`input`,{type:`number`,"aria-label":`Max turn`,min:0,max:i.maxTurn,value:n.turnRange?n.turnRange[1]:i.maxTurn,onChange:e=>{let t=Number(e.target.value);if(!Number.isFinite(t))return;let r=n.turnRange?.[0]??0;o({turnRange:[Math.min(r,t),t]})},className:B.rangeInput}),n.turnRange&&(0,j.jsx)(`button`,{type:`button`,className:B.chipClear,"aria-label":`Clear turn range`,onClick:()=>o({turnRange:null}),children:`×`})]})]})]}),n.types.size>0&&n.types.size===i.types.length&&(0,j.jsx)(`div`,{className:B.emptyHint,children:`All types selected — filter is a no-op on this axis.`})]})}var H={panel:`_panel_aavxx_1`,header:`_header_aavxx_6`,heading:`_heading_aavxx_15`,filterBar:`_filterBar_aavxx_26`,filterLabel:`_filterLabel_aavxx_34`,filterValue:`_filterValue_aavxx_38`,emptyState:`_emptyState_aavxx_43`,event:`_event_aavxx_48`,eventSummary:`_eventSummary_aavxx_53`,index:`_index_aavxx_61`,type:`_type_aavxx_67`,leader:`_leader_aavxx_73`,turn:`_turn_aavxx_81`,title:`_title_aavxx_85`,department:`_department_aavxx_89`,outcome:`_outcome_aavxx_93`,dataBlock:`_dataBlock_aavxx_98`},U={status:`var(--teal)`,turn_start:`var(--rust)`,turn_done:`var(--rust)`,specialist_start:`var(--text-3)`,specialist_done:`var(--green)`,decision_pending:`var(--amber)`,decision_made:`var(--amber)`,outcome:`#e8b44a`,drift:`var(--teal)`,agent_reactions:`#6aad48`,bulletin:`var(--text-2)`,promotion:`var(--teal)`};function Le(){return typeof window>`u`?D(``,``):D(window.location.search,window.location.hash)}function Re({events:e}){let t=(0,k.useRef)(null),n=(0,k.useRef)(!1),[r,i]=(0,k.useState)(Le);(0,k.useEffect)(()=>{let e=()=>i(Le());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let a=(0,k.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},[]);(0,k.useEffect)(()=>{if(!n.current)return;let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e.length]);let o=(0,k.useCallback)(e=>{i(t=>{try{let n=t.toolHash!==``&&e.toolHash===``;window.history.replaceState({},``,S(window.location.href,e,n))}catch{}return e})},[]),s=g(e,r),c=r.query!==``||r.types.size>0||r.leader!==null||r.turnRange!==null||r.toolHash!==``;return(0,j.jsxs)(`div`,{ref:t,onScroll:a,className:`flex-1 overflow-y-auto p-4 font-mono text-xs ${H.panel}`,role:`log`,"aria-label":`Event log`,"aria-live":`polite`,children:[(0,j.jsx)(`div`,{className:H.header,children:(0,j.jsxs)(`h2`,{className:H.heading,children:[`Event Log (`,s.length,c?` of ${e.length}`:``,` events)`]})}),(0,j.jsx)(Ie,{events:e,filters:r,onFiltersChange:o}),s.length===0&&(0,j.jsx)(`div`,{className:H.emptyState,children:c?`No events matched the current filter. Adjust or press Reset.`:`No events yet. Run a simulation to see the raw SSE event stream.`}),s.map((e,t)=>{let n=U[e.type]||`var(--text-3)`,r=e.data??{},i=Object.keys(r).length>0,a=Array.isArray(r.aiWrittenFields)?r.aiWrittenFields.length>0:e.type===`decision_made`?C(r,`decision`,r.decision):e.type===`specialist_done`&&C(r,`summary`,r.summary);return(0,j.jsxs)(`details`,{className:H.event,style:{"--log-type-color":n},children:[(0,j.jsxs)(`summary`,{className:H.eventSummary,children:[(0,j.jsx)(`span`,{className:H.index,children:t}),(0,j.jsx)(`span`,{className:H.type,children:e.type}),(0,j.jsx)(`span`,{className:H.leader,children:e.leader}),e.data?.turn!=null&&(0,j.jsxs)(`span`,{className:H.turn,children:[`T`,String(e.data.turn)]}),!!e.data?.title&&(0,j.jsx)(v,{className:H.title,authored:ue(e.data,`title`),children:String(e.data.title)}),!!e.data?.department&&(0,j.jsx)(`span`,{className:H.department,children:String(e.data.department)}),!!e.data?.outcome&&(0,j.jsx)(`span`,{className:H.outcome,children:String(e.data.outcome)})]}),i&&(0,j.jsx)(v,{as:`div`,authored:a,children:(0,j.jsx)(`pre`,{className:H.dataBlock,children:JSON.stringify(r,null,2)})})]},t)})]})}var ze=[{value:`economy`,label:`Economy`,description:`Cheapest path: gated research, cheap verdicts, tighter spend controls.`},{value:`balanced`,label:`Balanced`,description:`Current default mix for good quality per dollar on normal runs.`},{value:`quality`,label:`Quality`,description:`Push strategic roles and verdict synthesis upward when quality matters more than spend.`},{value:`deterministic_first`,label:`Deterministic First`,description:`Skip verdict synthesis and live-search escalation to reduce variance and cost.`}];function Be(e){switch(e){case`hosted_demo`:return{label:`Hosted demo`,description:`Host-billed runs are capped and forced onto the economy guardrails.`};case`platform_api`:return{label:`Platform API`,description:"Authenticated `/api/v1/*` routes are enabled; demo-only assumptions are off."};default:return{label:`Local demo`,description:`Single-process local server. Good for product exploration, not a hosted control plane.`}}}var W={root:`_root_34x3m_1`,content:`_content_34x3m_9`,scenarioRow:`_scenarioRow_34x3m_17`,scenarioLabel:`_scenarioLabel_34x3m_29`,scenarioSelect:`_scenarioSelect_34x3m_34`,scenarioActiveTag:`_scenarioActiveTag_34x3m_45`,scenarioActiveValue:`_scenarioActiveValue_34x3m_51`,h2:`_h2_34x3m_55`,lead:`_lead_34x3m_62`,scenarioTagline:`_scenarioTagline_34x3m_68`,scenarioSourceLink:`_scenarioSourceLink_34x3m_77`,leadHint:`_leadHint_34x3m_92`,leadStrong:`_leadStrong_34x3m_99`,leadersGrid:`_leadersGrid_34x3m_103`,leaderCardWrap:`_leaderCardWrap_34x3m_120`,leaderRemoveBtn:`_leaderRemoveBtn_34x3m_124`,leadersAddRow:`_leadersAddRow_34x3m_153`,leaderAddBtn:`_leaderAddBtn_34x3m_162`,leaderAddCap:`_leaderAddCap_34x3m_191`,fieldset:`_fieldset_34x3m_199`,legend:`_legend_34x3m_208`,demoBanner:`_demoBanner_34x3m_212`,demoBannerLabel:`_demoBannerLabel_34x3m_223`,simRow5:`_simRow5_34x3m_227`,grid3:`_grid3_34x3m_233`,grid2:`_grid2_34x3m_240`,input:`_input_34x3m_246`,locked:`_locked_34x3m_258`,lockTag:`_lockTag_34x3m_263`,fieldHint:`_fieldHint_34x3m_270`,keysIntro:`_keysIntro_34x3m_277`,keysIntroPara:`_keysIntroPara_34x3m_284`,keysIntroParaLast:`_keysIntroParaLast_34x3m_288`,keysIntroBoldNeutral:`_keysIntroBoldNeutral_34x3m_292`,keysIntroBoldGreen:`_keysIntroBoldGreen_34x3m_296`,keysIntroBoldAmber:`_keysIntroBoldAmber_34x3m_300`,keysIntroBoldRust:`_keysIntroBoldRust_34x3m_304`,keyEnvTag:`_keyEnvTag_34x3m_308`,modelTiersIntro:`_modelTiersIntro_34x3m_316`,demoMode:`_demoMode_34x3m_323`,demoModeStrong:`_demoModeStrong_34x3m_333`,launchRow:`_launchRow_34x3m_337`,launchBtn:`_launchBtn_34x3m_346`,launchStatus:`_launchStatus_34x3m_364`},Ve=[{id:`config`,label:`Settings`},{id:`log`,label:`Event Log`}],He={openness:.5,conscientiousness:.5,extraversion:.5,agreeableness:.5,emotionality:.5,honestyHumility:.5},Ue={openai:[{value:`gpt-5.4-nano`,label:`gpt-5.4-nano ($0.20 / $1.25 per 1M)`},{value:`gpt-5.4-mini`,label:`gpt-5.4-mini ($0.75 / $4.50 per 1M)`},{value:`gpt-5.4`,label:`gpt-5.4 ($2.50 / $15.00 per 1M)`},{value:`gpt-5.4-pro`,label:`gpt-5.4-pro ($30 / $180 per 1M — avoid)`}],anthropic:[{value:`claude-haiku-4-5-20251001`,label:`Haiku 4.5 ($1 / $5 per 1M)`},{value:`claude-sonnet-4-6`,label:`Sonnet 4.6 ($3 / $15 per 1M)`},{value:`claude-opus-4-7`,label:`Opus 4.7 ($5 / $25 per 1M)`}]},We={openai:{departments:`gpt-5.4`,commander:`gpt-5.4-mini`,director:`gpt-5.4-mini`,judge:`gpt-5.4-mini`,agentReactions:`gpt-5.4-nano`},anthropic:{departments:`claude-sonnet-4-6`,commander:`claude-haiku-4-5-20251001`,director:`claude-haiku-4-5-20251001`,judge:`claude-haiku-4-5-20251001`,agentReactions:`claude-haiku-4-5-20251001`}},Ge={departments:{label:`Departments (forges)`,help:`Writes code, schemas, test cases. Quality matters — cheap tier produces broken forges.`},commander:{label:`Commander`,help:`Picks option from department reports. Mid-tier is fine.`},director:{label:`Event Director`,help:`Generates crisis events as structured JSON batches.`},judge:{label:`Judge (code review)`,help:`Reviews forged tool code for safety + correctness.`},agentReactions:{label:`Agent Reactions`,help:`One to two sentences per colonist per turn. Highest volume — pick cheapest.`}},G=[`The Visionary`,`The Engineer`,`The Diplomat`,`The Maverick`,`The Guardian`,`The Strategist`,`The Steward`,`The Innovator`];function Ke(e,t){return{name:`Actor ${String.fromCharCode(65+e%26)}`,archetype:G[e]??`The Strategist`,unit:o(t,e),hexaco:{...He}}}function qe(e){let t=e.presets.find(e=>e.id==="default");return t?.leaders??t?.actors}function Je(e,t,n,r,i){let a=qe(n);return e.map((e,s)=>{let c=i[s],l=a?.[s],u=e.unit===o(t,s);if(!l)return(a!==void 0&&r!==n.id||u)&&c?.unit===void 0?{...e,unit:o(n,s)}:e;let d=r===n.id&&!!e.unit&&!u;return{name:l.name,archetype:l.archetype,unit:d?e.unit:l.unit??o(n,s),instructions:l.instructions,description:l.description,aiAuthorship:l.aiAuthorship,hexaco:{...l.hexaco},...c}})}var Ye=2,K=8,Xe=!1;function q(){try{let e=decodeURIComponent(window.location.hash.slice(1));return/^[A-Za-z][\w-]*$/.test(e)?e:null}catch{return null}}function Ze(){(0,k.useEffect)(()=>{let e=q();if(Xe||!e)return;let t=()=>{let t=document.getElementById(e);return t?(Xe=!0,t.scrollIntoView({block:`center`}),!0):!1};if(t())return;let n=new MutationObserver(()=>{t()&&n.disconnect()});n.observe(document.body,{childList:!0,subtree:!0});let r=window.setTimeout(()=>n.disconnect(),1e4);return()=>{n.disconnect(),window.clearTimeout(r)}},[])}function Qe({events:e=[],initialSubTab:t=`config`,onClearLocal:n,onWipeServer:c,onOpenStoredData:u}={}){let[d,ee]=(0,k.useState)(t);Ze();let te=(0,k.useCallback)(e=>{ee(e),ie(e===`config`?null:e)},[]),f=he(),p=w(),h=a(),g=ve(),ae=fe(),_=l(),oe=_?xe(_):null,[v]=(0,k.useState)(()=>_?se(_):null),[y,b]=(0,k.useState)(()=>{let e=Math.max(Ye,Math.min(K,Math.max(qe(f)?.length??0,oe?.length??0)));return Je(Array.from({length:e},(e,t)=>{let n=oe?.[t];return n?.name?{name:n.name,archetype:n.archetype??``,unit:n.unit??o(f,t),instructions:n.instructions,description:n.description,aiAuthorship:n.aiAuthorship,hexaco:{...n.hexaco??He}}:Ke(t,f)}),f,f,v,[])}),x=(0,k.useRef)([]),S=(0,k.useRef)(f);(0,k.useEffect)(()=>{let e=S.current;S.current=f,b(t=>Je(t,e,f,v,x.current))},[f.id,f.presets.length]);let C=(0,k.useCallback)((e,t)=>{b(n=>n.map((n,r)=>{if(r!==e)return n;let i=Object.keys(t).filter(e=>t[e]!==n[e]);return x.current[e]={...x.current[e],...Object.fromEntries(i.map(e=>[e,t[e]]))},t}))},[]),le=(0,k.useCallback)(()=>{b(e=>e.length<K?[...e,Ke(e.length,f)]:e)},[f]),ue=(0,k.useCallback)(e=>{x.current.splice(e,1),b(t=>t.length>Ye?t.filter((t,n)=>n!==e):t)},[]),[E,D]=(0,k.useState)(f.setup.defaultTurns),[A,we]=(0,k.useState)(f.setup.defaultSeed),[M,N]=(0,k.useState)(f.setup.defaultStartTime),[Te,P]=(0,k.useState)(f.setup.defaultTimePerTurn||0),[Ee,De]=(0,k.useState)(f.setup.defaultPopulation),F=(0,k.useRef)(new Set);(0,k.useEffect)(()=>{let e=F.current;e.has(`turns`)||D(f.setup.defaultTurns),e.has(`seed`)||we(f.setup.defaultSeed),e.has(`startTime`)||N(f.setup.defaultStartTime),e.has(`timePerTurn`)||P(f.setup.defaultTimePerTurn||0),e.has(`population`)||De(f.setup.defaultPopulation)},[f.id,f.setup.defaultTurns,f.setup.defaultSeed,f.setup.defaultStartTime,f.setup.defaultTimePerTurn,f.setup.defaultPopulation]);let[I,L]=(0,k.useState)(`openai`),[ke,Ae]=(0,k.useState)(!1),[je,R]=(0,k.useState)(`balanced`),[Ne,z]=(0,k.useState)(!1),[B,V]=(0,k.useState)(``),[Ie,H]=(0,k.useState)([]),[U,Le]=(0,k.useState)(f.id),[G,Xe]=(0,k.useState)({}),[q,Qe]=(0,k.useState)(!1),[$e,et]=(0,k.useState)(!1),[tt,nt]=(0,k.useState)(`local_demo`),[J,rt]=(0,k.useState)({maxTurns:6,maxPopulation:30,maxActiveDepartments:3}),[Y,it]=(0,k.useState)(be),[at,ot]=(0,k.useState)(null),[st,ct]=(0,k.useState)(!1),[lt,ut]=(0,k.useState)(``),dt=de();function ft(e,t){let n={...Y,[e]:t};i(n),it(n),ut(``)}async function pt(){ct(!0),ye(),it({}),ut(``);try{if(!(await fetch(`/forget-keys`,{method:`POST`})).ok)throw Error(`Server cleanup failed`);ut(`Keys forgotten. Your held run and chat agents have been cleared.`)}catch{ut(`Keys cleared from this tab. Select Forget my keys again to retry server cleanup.`)}finally{ct(!1)}}let[mt,ht]=(0,k.useState)(We[I]??We.openai);(0,k.useEffect)(()=>{let e=I;We[e]&&ht(We[e])},[I]);let X=_e(Y),gt=!!G.openai||!!G.anthropic,_t=X||!q&>,vt=X||!q&>,Z=q&&!X?`economy`:je,yt=Be(tt),Q=q&&!X,bt=Q?`openai`:I,xt=(0,k.useCallback)(()=>{fetch(`/scenarios`).then(e=>e.json()).then(e=>{H(e.scenarios||[]),Le(e.active)}).catch(()=>{})},[]);(0,k.useEffect)(()=>(xt(),fetch(`/admin-config`).then(e=>e.json()).then(e=>{e.keys&&Xe(e.keys),typeof e.visitorKeyIdleMinutes==`number`&&ot(e.visitorKeyIdleMinutes),typeof e.hostedDemo==`boolean`&&Qe(e.hostedDemo),typeof e.adminWrite==`boolean`&&et(e.adminWrite),typeof e.serverMode==`string`&&nt(e.serverMode),e.demoCaps&&typeof e.demoCaps.maxTurns==`number`&&rt({maxTurns:e.demoCaps.maxTurns,maxPopulation:e.demoCaps.maxPopulation??30,maxActiveDepartments:e.demoCaps.maxActiveDepartments??3})}).catch(()=>{}),ge(window,xt)),[xt]);let St=async e=>{if(e!==U)try{(await fetch(`/scenario/switch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:e})})).ok&&(pe(),window.location.reload())}catch{}},Ct=(0,k.useCallback)(async()=>{if(!p)return;let e={...ce(Y)};Y.serper&&(e.serperKey=Y.serper),Y.firecrawl&&(e.firecrawlKey=Y.firecrawl),Y.tavily&&(e.tavilyKey=Y.tavily),Y.cohere&&(e.cohereKey=Y.cohere);let t=de(e);if(t)V(t);else{z(!0),V(`Starting...`);try{let t={actors:y.map(me),provider:bt,turns:E,seed:A,startTime:M,timePerTurn:Te||void 0,population:Ee,liveSearch:ke,activeDepartments:f.departments.map(e=>e.id),economics:{profileId:Z},scenarioId:f.id};try{localStorage.setItem(`paracosm:lastLaunchConfig`,JSON.stringify(t))}catch{}let n=l();n&&ne(n,y,f.id),vt&&(t.models={...mt});let r=await fetch(`/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,...e,captureSnapshots:!0})}),i=await r.json();if(r.status===429){V(`Rate limited: ${i.error||`too many simulations`}`),z(!1);return}if(i.redirect){ae(typeof i.runKey==`string`?i.runKey:void 0),V(`Running...`),T(window,i.visitorId);let e=m(window.location.href,i.redirect),t=s(e);g(t===`about`?`sim`:t)}else V(`Error: ${i.error||`unknown`}`),z(!1)}catch(e){V(`Failed: ${e}`),z(!1)}}},[y,E,A,M,Te,Ee,bt,ke,g,ae,f,p,Y,mt,vt,Z]),$=e=>[W.input,e?W.locked:``].filter(Boolean).join(` `);return(0,j.jsxs)(`div`,{className:W.root,children:[(0,j.jsx)(Se,{options:Ve,active:d,onChange:te,ariaLabel:`Settings sub-navigation`}),d===`log`&&(0,j.jsx)(Re,{events:e}),d===`config`&&(0,j.jsxs)(`div`,{className:`settings-content ${W.content}`,children:[(0,j.jsx)(Fe,{}),Ie.length>0&&(0,j.jsxs)(`div`,{className:`responsive-stack ${W.scenarioRow}`,children:[(0,j.jsx)(`label`,{htmlFor:`scenario-select`,style:O,className:W.scenarioLabel,children:`Scenario`}),(0,j.jsx)(`select`,{id:`scenario-select`,className:`pc-select ${W.scenarioSelect}`,value:U,onChange:e=>St(e.target.value),children:Ie.map(e=>{let t=e.description?.includes(`(memory)`)?` [memory]`:e.description?.includes(`(disk)`)?` [disk]`:e.description?.includes(`compiled`)?` [compiled]`:``;return(0,j.jsxs)(`option`,{value:e.id,children:[e.id===U?`● `:``,e.name,` (`,e.departments,` depts)`,t]},e.id)})}),(0,j.jsxs)(`span`,{className:W.scenarioActiveTag,children:[`Active: `,(0,j.jsx)(`strong`,{className:W.scenarioActiveValue,children:U})]})]}),(0,j.jsx)(`h2`,{className:W.h2,children:f.labels.name}),f.labels.tagline&&(0,j.jsx)(`p`,{className:W.scenarioTagline,children:f.labels.tagline}),(0,j.jsxs)(`p`,{className:W.lead,children:[`Configure your leaders and launch. `,f.departments.length,` departments: `,f.departments.map(e=>e.label).join(`, `),`.`]}),f.sourceUrl&&(0,j.jsx)(`p`,{className:W.scenarioSourceLink,children:(0,j.jsx)(`a`,{href:f.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,children:`View scenario JSON on GitHub →`})}),(0,j.jsxs)(`p`,{className:W.leadHint,children:[`Server mode: `,(0,j.jsx)(`strong`,{className:W.leadStrong,children:yt.label}),`. `,yt.description]}),(0,j.jsx)(`div`,{className:`${y.length>2?`responsive-grid-cohort`:`responsive-grid-2`} ${W.leadersGrid}`,children:y.map((e,t)=>(0,j.jsxs)(`div`,{className:W.leaderCardWrap,style:{position:`relative`},children:[(0,j.jsx)(Oe,{label:`Commander ${String.fromCharCode(65+t%26)}`,sideColor:re(t),data:e,onChange:e=>C(t,e)}),y.length>Ye&&(0,j.jsx)(`button`,{type:`button`,onClick:()=>ue(t),className:W.leaderRemoveBtn,"aria-label":`Remove ${e.name||`actor ${t+1}`} from the cohort`,title:`Remove this actor`,children:`✕`})]},t))}),(0,j.jsx)(`div`,{className:W.leadersAddRow,children:y.length<K?(0,j.jsxs)(`button`,{type:`button`,onClick:le,className:W.leaderAddBtn,"aria-label":`Add another actor to the cohort`,children:[`+ Add actor (`,y.length,`/`,K,`)`]}):(0,j.jsxs)(`span`,{className:W.leaderAddCap,children:[`Max `,K,` actors from Settings · use Quickstart's generate-N flow for larger cohorts.`]})}),(0,j.jsxs)(`fieldset`,{className:W.fieldset,children:[(0,j.jsx)(`legend`,{style:r,className:W.legend,children:`Simulation`}),Q&&(0,j.jsxs)(`div`,{className:W.demoBanner,children:[(0,j.jsx)(`strong`,{className:W.demoBannerLabel,children:`Demo caps will apply:`}),` `,`turns clamped to `,J.maxTurns,`, population to `,J.maxPopulation,`, active departments to `,J.maxActiveDepartments,`. Values you enter below are honored up to those ceilings. Add a session API key above to lift the caps.`]}),(0,j.jsxs)(`div`,{className:`responsive-grid-4 ${W.simRow5}`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`label`,{htmlFor:`turns-input`,style:O,children:[`Turns`,Q&&(0,j.jsxs)(`span`,{className:W.lockTag,title:`Hosted demo caps turns at ${J.maxTurns}. Add a session API key to unlock.`,children:[`🔒 demo:`,J.maxTurns]})]}),(0,j.jsx)(`input`,{id:`turns-input`,type:`number`,value:Q?J.maxTurns:E,onChange:e=>{F.current.add(`turns`),D(parseInt(e.target.value)||f.setup.defaultTurns)},min:1,max:20,disabled:Q,className:$(Q),title:Q?`Locked at ${J.maxTurns} in hosted demo mode. Add your own OpenAI or Anthropic key above to unlock full scope.`:``})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`label`,{htmlFor:`ypt-input`,style:O,children:[h.Times,`/Turn`]}),(0,j.jsx)(`input`,{id:`ypt-input`,type:`number`,value:Te,onChange:e=>{F.current.add(`timePerTurn`),P(parseInt(e.target.value)||0)},min:0,max:50,placeholder:`auto`,title:`${h.Times} per turn. 0 = accelerating schedule (default). 1 = 1 ${h.time} per turn. 5 = 5 ${h.times} per turn.`,className:W.input})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`seed-input`,style:O,children:`Seed`}),(0,j.jsx)(`input`,{id:`seed-input`,type:`number`,value:A,onChange:e=>{F.current.add(`seed`),we(parseInt(e.target.value)||f.setup.defaultSeed)},className:W.input})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`label`,{htmlFor:`time-input`,style:O,children:[`Start `,h.Time]}),(0,j.jsx)(`input`,{id:`time-input`,type:`number`,value:M,onChange:e=>{F.current.add(`startTime`),N(parseInt(e.target.value)||f.setup.defaultStartTime)},className:W.input})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`label`,{htmlFor:`pop-input`,style:O,children:[`Population`,Q&&(0,j.jsx)(`span`,{className:W.lockTag,title:`Hosted demo caps population at 30. Add a session API key to unlock.`,children:`🔒 demo:30`})]}),(0,j.jsx)(`input`,{id:`pop-input`,type:`number`,value:Q?30:Ee,onChange:e=>{F.current.add(`population`),De(parseInt(e.target.value)||f.setup.defaultPopulation)},disabled:Q,className:$(Q),title:Q?`Locked at 30 in hosted demo mode. Add your own OpenAI or Anthropic key above to unlock full scope.`:``})]})]}),(0,j.jsxs)(`div`,{className:`responsive-grid-3 ${W.grid3}`,children:[(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`label`,{htmlFor:`provider-select`,style:O,children:[`Provider`,Q&&(0,j.jsx)(`span`,{className:W.lockTag,children:`🔒 demo:openai`})]}),(0,j.jsxs)(`select`,{id:`provider-select`,className:`pc-select ${$(Q)}`,value:bt,onChange:e=>L(e.target.value),disabled:Q,title:Q?`Locked to OpenAI in hosted demo mode. Add your own OpenAI or Anthropic key above to choose the provider.`:``,children:[(0,j.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,j.jsx)(`option`,{value:`anthropic`,children:`Anthropic`})]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`search-select`,style:O,children:`Live Search`}),(0,j.jsxs)(`select`,{id:`search-select`,className:`pc-select ${W.input}`,value:String(ke),onChange:e=>Ae(e.target.value===`true`),children:[(0,j.jsx)(`option`,{value:`false`,children:`Off`}),(0,j.jsx)(`option`,{value:`true`,children:`On (requires search API keys)`})]})]}),(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`label`,{htmlFor:`economics-select`,style:O,children:[`Economics`,Q&&(0,j.jsx)(`span`,{className:W.lockTag,children:`🔒 forced:economy`})]}),(0,j.jsx)(`select`,{id:`economics-select`,className:`pc-select ${$(Q)}`,value:Z,onChange:e=>R(e.target.value),disabled:Q,title:ze.find(e=>e.value===Z)?.description,children:ze.map(e=>(0,j.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,j.jsx)(`div`,{className:W.fieldHint,children:ze.find(e=>e.value===Z)?.description})]})]})]}),(0,j.jsxs)(`fieldset`,{className:W.fieldset,children:[(0,j.jsx)(`legend`,{style:r,className:W.legend,children:`API Keys`}),(0,j.jsxs)(`div`,{className:W.keysIntro,children:[(0,j.jsxs)(`p`,{className:W.keysIntroPara,children:[(0,j.jsx)(`strong`,{className:W.keysIntroBoldNeutral,children:`How key resolution works:`}),` The server checks for keys in this order: this tab's keys below, then the server .env file.`]}),(0,j.jsxs)(`p`,{className:W.keysIntroPara,children:[(0,j.jsx)(`strong`,{className:W.keysIntroBoldGreen,children:`Rate limiting:`}),` The hosted demo limits simulations per IP per day when using the server's API keys. Provide your own `,(0,j.jsx)(`strong`,{children:`OpenAI`}),` or `,(0,j.jsx)(`strong`,{children:`Anthropic`}),` key to bypass the rate limit and run unlimited simulations. Only one LLM provider key is required. If both are provided, the simulation uses whichever you select as the provider.`]}),(0,j.jsxs)(`p`,{className:W.keysIntroPara,children:[(0,j.jsx)(`strong`,{className:W.keysIntroBoldAmber,children:`Research and citations:`}),` Live web search requires at least one search key (Serper, Firecrawl, Tavily). Without any search key, departments fall back to the scenario's built-in research bundle. Cohere enables neural reranking of search results for higher-quality citations. These are optional enhancements, not required to run a simulation.`]}),(0,j.jsxs)(`p`,{className:W.keysIntroParaLast,children:[(0,j.jsx)(`strong`,{className:W.keysIntroBoldRust,children:`No keys at all?`}),` If neither a server .env key nor a session override exists for any LLM provider, the simulation cannot run. You need at least one OpenAI or Anthropic key configured somewhere.`]})]}),dt&&(0,j.jsx)(`p`,{role:`status`,className:W.launchStatus,children:dt}),(0,j.jsx)(`div`,{className:`responsive-grid-2 ${W.grid2}`,children:[[`openai`,`OpenAI`,`Required (or Anthropic). Powers commander, departments, crisis director.`],[`anthropic`,`Anthropic`,`Required (or OpenAI). Alternative LLM provider for all simulation roles.`],[`serper`,`Serper (search)`,`Optional. Enables live Google search for department research citations.`],[`firecrawl`,`Firecrawl (scrape)`,`Optional. Enables web page scraping for deeper research context.`],[`tavily`,`Tavily (search)`,`Optional. Additional search provider. Multiple providers improve coverage.`],[`cohere`,`Cohere (rerank)`,`Optional. Neural reranking of search results for citation quality.`]].map(([e,t,n])=>(0,j.jsxs)(`div`,{children:[(0,j.jsxs)(`label`,{htmlFor:`key-${e}`,style:O,children:[t,G[e]&&(0,j.jsx)(`span`,{className:W.keyEnvTag,children:`(.env active)`})]}),(0,j.jsx)(`input`,{id:`key-${e}`,type:`password`,autoComplete:`off`,"data-clarity-mask":`True`,value:Y[e]??``,disabled:st,onChange:t=>ft(e,t.target.value),placeholder:G[e]?`Using .env value`:`Not configured`,className:`${W.input} ph-no-capture ph-mask`}),(0,j.jsx)(`div`,{className:W.fieldHint,children:n})]},e))}),(0,j.jsx)(`button`,{type:`button`,className:W.leaderAddBtn,disabled:st,onClick:pt,children:`Forget my keys`}),lt&&(0,j.jsx)(`p`,{className:W.fieldHint,role:`status`,children:lt}),(0,j.jsxs)(`div`,{className:W.keysIntro,"data-testid":`visitor-key-notes`,children:[(0,j.jsx)(`p`,{className:W.keysIntroPara,children:`Runs on your key are billed to your OpenAI or Anthropic account, under your agreement with them.`}),at!==null&&(0,j.jsxs)(`p`,{className:W.keysIntroPara,children:[`We send your key to our server for each run and chat you start. It stays in our server's memory while they are in use, for `,at,` minutes at most after you stop, and is never written to disk or to a log.`]}),(0,j.jsx)(`p`,{className:W.keysIntroPara,children:`This browser tab keeps your key until you close it. "Forget my keys" removes it now.`}),(0,j.jsx)(`p`,{className:W.keysIntroPara,children:`Use a separate key with a spending limit, and delete it at your provider when you are done.`}),(0,j.jsxs)(`p`,{className:W.keysIntroParaLast,children:[`Or `,(0,j.jsx)(`a`,{href:`/#get-started`,children:`run paracosm on your own computer`}),`, and your key never leaves it.`]})]})]}),_t&&(I===`openai`||I===`anthropic`)&&(0,j.jsxs)(`fieldset`,{className:W.fieldset,children:[(0,j.jsx)(`legend`,{style:r,className:W.legend,children:`Model Tiers`}),(0,j.jsx)(`div`,{className:W.modelTiersIntro,children:`Assign a model to each agent tier. Departments do the forging and benefit most from the flagship class. Agent reactions fan out to hundreds of parallel calls per turn and should be the cheapest class available. These overrides are only used when you run against your own API key.`}),(0,j.jsx)(`div`,{className:`responsive-grid-2 ${W.grid2}`,children:Object.keys(Ge).map(e=>(0,j.jsxs)(`div`,{children:[(0,j.jsx)(`label`,{htmlFor:`model-${e}`,style:O,children:Ge[e].label}),(0,j.jsx)(`select`,{id:`model-${e}`,className:`pc-select ${W.input}`,value:mt[e],onChange:t=>ht(n=>({...n,[e]:t.target.value})),children:Ue[I].map(e=>(0,j.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,j.jsx)(`div`,{className:W.fieldHint,children:Ge[e].help})]},e))})]}),!_t&&(0,j.jsxs)(`div`,{className:W.demoMode,children:[(0,j.jsx)(`strong`,{className:W.demoModeStrong,children:`Demo mode.`}),` `,q?`Runs against the host API keys are capped to ${J.maxTurns} turns, ${J.maxPopulation} colonists, ${J.maxActiveDepartments} departments, and the cheapest model class. Add your own OpenAI or Anthropic key above to unlock full scope and per-tier model selection.`:`No API key configured. Add an OpenAI or Anthropic key above or set one in .env to enable simulations and the per-tier model picker.`]}),$e&&(0,j.jsxs)(`fieldset`,{className:W.fieldset,children:[(0,j.jsx)(`legend`,{style:r,className:W.legend,children:`Admin Token`}),(0,j.jsx)(Pe,{})]}),n&&(0,j.jsx)(Ce,{onClearLocal:n,onWipeServer:c,onOpen:u}),(0,j.jsx)(Me,{onAdminWrite:et}),(0,j.jsxs)(`div`,{className:`responsive-stack ${W.launchRow}`,children:[(0,j.jsx)(`button`,{onClick:Ct,disabled:Ne||!p,"aria-label":Ne?`Simulation running`:p?`Launch simulation`:`Loading scenario`,className:W.launchBtn,children:Ne?`Running...`:p?`Launch Simulation`:`Loading scenario…`}),B&&(0,j.jsx)(`span`,{role:`status`,className:W.launchStatus,children:B})]})]})]})}export{Qe as SettingsPanel};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import{n as e}from"./rolldown-runtime-WkwZ5CU-.js";import{At as t,Bt as n,Ct as r,Dt as i,Et as a,F as o,Ft as s,Ht as c,It as l,Lt as u,M as d,Mt as f,N as p,Nt as m,Ot as h,Pt as g,Rt as _,Tt as v,Ut as ee,Vt as y,X as b,_n as x,at as S,dn as C,jt as w,kt as T,ot as E,rt as D,t as O,ut as k,wt as A,zt as j}from"./index-BPO4i_k0.js";import{t as te}from"./SubTabNav-DT8T_8_D.js";var M=e(x(),1),N={tab:`_tab_130zt_1`,dropZone:`_dropZone_130zt_10`,dropZoneActive:`_dropZoneActive_130zt_20`,dropZoneError:`_dropZoneError_130zt_25`,dropZoneHint:`_dropZoneHint_130zt_30`,fileInput:`_fileInput_130zt_36`,errorBanner:`_errorBanner_130zt_40`,errorHint:`_errorHint_130zt_48`,loadedBar:`_loadedBar_130zt_54`,artifactView:`_artifactView_130zt_64`,artifactHead:`_artifactHead_130zt_70`,artifactScenario:`_artifactScenario_130zt_76`,artifactActor:`_artifactActor_130zt_81`,artifactActions:`_artifactActions_130zt_86`,promoteBtn:`_promoteBtn_130zt_91`,compareBtn:`_compareBtn_130zt_92`,artifactBody:`_artifactBody_130zt_105`,bundleGrid:`_bundleGrid_130zt_110`,bundleCard:`_bundleCard_130zt_116`,bundleCardTitle:`_bundleCardTitle_130zt_129`,bundleCardMeta:`_bundleCardMeta_130zt_133`,bundleIdChip:`_bundleIdChip_130zt_139`,bundleActions:`_bundleActions_130zt_152`,bundleDrillBack:`_bundleDrillBack_130zt_158`,guide:`_guide_130zt_167`,guideHead:`_guideHead_130zt_177`,guideTitle:`_guideTitle_130zt_183`,guideSub:`_guideSub_130zt_194`,guideSteps:`_guideSteps_130zt_208`,guideCtaRow:`_guideCtaRow_130zt_226`,guideCta:`_guideCta_130zt_226`,guideCtaSecondary:`_guideCtaSecondary_130zt_250`,guideExample:`_guideExample_130zt_266`,guideExampleCode:`_guideExampleCode_130zt_281`,guideExampleNote:`_guideExampleNote_130zt_299`,openRunFile:`_openRunFile_130zt_313`},P=n({name:c().min(1),department:c().optional(),description:c().optional(),approved:_(),confidence:j().min(0).max(1).optional()}),F=n({metadata:T,provenance:t.optional(),overview:c().optional(),assumptions:u(c()).optional(),leveragePoints:u(c()).optional(),disclaimer:c().optional(),trajectory:s.optional(),subject:m.optional(),intervention:a.optional(),specialistNotes:u(f).optional(),riskFlags:u(h).optional(),decisions:u(v).optional(),finalState:l.optional(),finalSwarm:g.optional(),fingerprint:y(c(),ee([j(),c()])).optional(),citations:u(r).optional(),forgedTools:u(P).optional(),cost:A.optional(),providerError:i.nullable().optional(),aborted:_().optional(),scenarioExtensions:w}),I=50;function L(e){let t=F.safeParse(e);return t.success?{ok:!0,artifact:e}:{ok:!1,issues:t.error.issues.slice(0,3).map(e=>`${e.path.join(`.`)||`<root>`}: ${e.message}`)}}function R(e){let t;try{t=JSON.parse(e)}catch(e){return{kind:`error`,message:`File is not valid JSON`,hint:e instanceof Error?e.message:String(e)}}if(t&&typeof t==`object`&&!Array.isArray(t)&&Array.isArray(t.artifacts)){let e=t;return z(e.artifacts,e.bundleId)}if(Array.isArray(t))return z(t,void 0);let n=L(t);return n.ok?{kind:`single`,artifact:n.artifact}:{kind:`error`,message:`Not a paracosm RunArtifact: ${n.issues[0]??`invalid shape`}`,hint:n.issues.slice(1).join(`; `)||void 0}}function z(e,t){if(e.length===0)return{kind:`error`,message:`Bundle is empty`};if(e.length>I)return{kind:`error`,message:`Bundle exceeds the ${I}-artifact cap (got ${e.length})`};let n=[];for(let t=0;t<e.length;t+=1){let r=e[t],i=L(r);if(!i.ok)return{kind:`error`,message:`Bundle item ${t}: ${i.issues[0]??`invalid shape`}`,hint:i.issues.slice(1).join(`; `)||void 0};n.push(i.artifact)}let r={kind:`bundle`,artifacts:n};return t&&(r.bundleId=t),r}var B=C(),V=10485760;function H({onLoaded:e}){let[t,n]=M.useState(!1),[r,i]=M.useState(null),a=M.useRef(null),o=M.useCallback(async t=>{if(i(null),t.size>V){i({message:`File is too large (max ${V/1024/1024} MB)`,hint:`Got ${Math.round(t.size/1024/1024)} MB`});return}let n;try{n=await t.text()}catch(e){i({message:`Failed to read file`,hint:e instanceof Error?e.message:String(e)});return}let r=R(n);r.kind===`error`?i({message:r.message,hint:r.hint}):e(r,t.name)},[e]),s=M.useCallback(e=>{e.preventDefault(),n(!1);let t=e.dataTransfer.files?.[0];t&&o(t)},[o]),c=M.useCallback(e=>{e.preventDefault(),n(!0)},[]),l=M.useCallback(()=>n(!1),[]),u=M.useCallback(()=>a.current?.click(),[]),d=M.useCallback(e=>{let t=e.target.files?.[0];t&&o(t),e.target.value=``},[o]),f=[N.dropZone,t?N.dropZoneActive:``,r?N.dropZoneError:``].filter(Boolean).join(` `);return(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:f,onDrop:s,onDragOver:c,onDragLeave:l,onClick:u,role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u())},children:[(0,B.jsx)(`div`,{children:`Drop a paracosm RunArtifact JSON here, or click to browse`}),(0,B.jsx)(`div`,{className:N.dropZoneHint,children:`Single artifact or bundle (array of artifacts), max 10 MB`}),(0,B.jsx)(`input`,{ref:a,type:`file`,accept:`.json,application/json`,className:N.fileInput,onChange:d})]}),r&&(0,B.jsxs)(`div`,{className:N.errorBanner,role:`alert`,children:[(0,B.jsx)(`div`,{children:r.message}),r.hint&&(0,B.jsx)(`div`,{className:N.errorHint,children:r.hint})]})]})}var U=`{
|
|
2
|
+
"schemaVersion": "1.0.0",
|
|
3
|
+
"artifactId": "01J2A8R0K9P3F7HXC4ZDM3WQYV",
|
|
4
|
+
"scenario": {
|
|
5
|
+
"id": "frontier-ai-lab",
|
|
6
|
+
"name": "Frontier AI Lab",
|
|
7
|
+
"departments": 4
|
|
8
|
+
},
|
|
9
|
+
"setup": {
|
|
10
|
+
"turns": 20,
|
|
11
|
+
"seed": 42,
|
|
12
|
+
"startTime": "2025-04-30T09:00:00Z",
|
|
13
|
+
"timePerTurn": 86400,
|
|
14
|
+
"population": 18
|
|
15
|
+
},
|
|
16
|
+
"actor": {
|
|
17
|
+
"kind": "openai",
|
|
18
|
+
"model": "gpt-4o-mini"
|
|
19
|
+
},
|
|
20
|
+
"events": [
|
|
21
|
+
{
|
|
22
|
+
"turn": 1,
|
|
23
|
+
"kind": "actor.action",
|
|
24
|
+
"actorId": "alice",
|
|
25
|
+
"summary": "Reviews Q1 budget; flags compute overrun",
|
|
26
|
+
"ts": "2025-04-30T09:00:00Z"
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"turn": 1,
|
|
30
|
+
"kind": "actor.message",
|
|
31
|
+
"actorId": "bob",
|
|
32
|
+
"to": ["alice"],
|
|
33
|
+
"text": "Confirming the H100 cluster spend. We are 18% over plan."
|
|
34
|
+
}
|
|
35
|
+
],
|
|
36
|
+
"results": {
|
|
37
|
+
"kpis": { "morale": 0.74, "throughput": 0.61 },
|
|
38
|
+
"completed": true
|
|
39
|
+
},
|
|
40
|
+
"verdict": {
|
|
41
|
+
"kind": "judge.verdict",
|
|
42
|
+
"label": "plausible",
|
|
43
|
+
"score": 0.82,
|
|
44
|
+
"rationale": "Roles consistent with departmental authority; arithmetic checks out."
|
|
45
|
+
}
|
|
46
|
+
}`;function W(e){e.preventDefault();let t=new URL(window.location.href);t.searchParams.set(`tab`,`settings`),t.searchParams.delete(`sub`),window.history.replaceState({},``,t.toString()),window.dispatchEvent(new PopStateEvent(`popstate`))}function G(){return(0,B.jsxs)(`section`,{className:N.guide,"aria-label":`How to author a RunArtifact JSON`,children:[(0,B.jsxs)(`div`,{className:N.guideHead,children:[(0,B.jsx)(`h3`,{className:N.guideTitle,children:`How to get a RunArtifact JSON`}),(0,B.jsxs)(`p`,{className:N.guideSub,children:[`Studio takes a deterministic Paracosm `,(0,B.jsx)(`code`,{children:`RunArtifact`}),` — the JSON that a single sim run produces — and lets you inspect, promote to the Library, branch, or compare. Four steps to author one.`]})]}),(0,B.jsxs)(`ol`,{className:N.guideSteps,children:[(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`Configure a scenario in Settings.`}),` Pick a built-in (Frontier AI Lab, Submarine, Corporate Quarterly, T2D Protocol) or load your own. Set turns, seed, population, time-per-turn.`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`Run the sim.`}),` Switch to the Sim tab, hit Run. The runtime emits events deterministically, the actor LLM produces dialogue and decisions, and the judge attaches a verdict at the end.`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`Download the artifact.`}),` Sim output panel has a Save button — that JSON is the RunArtifact. You can also produce one from the CLI: `,(0,B.jsx)(`code`,{children:`paracosm run scenarios/frontier-ai-lab.json --turns 20 --out run.json`}),`.`]}),(0,B.jsxs)(`li`,{children:[(0,B.jsx)(`strong`,{children:`Drop it in the zone below.`}),` Single artifact or a bundle (array of artifacts, e.g. for branch comparisons). Max 10\xA0MB. A bundle over the server’s request limit (5\xA0MiB unless `,(0,B.jsx)(`code`,{children:`MAX_REQUEST_BODY_BYTES`}),` sets another) is promoted in parts of whole runs, snapshots included, into one Library bundle; a run that alone passes the limit is refused.`]})]}),(0,B.jsxs)(`div`,{className:N.guideCtaRow,children:[(0,B.jsx)(`a`,{href:`?tab=settings`,onClick:W,className:N.guideCta,children:`Open Settings →`}),(0,B.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/blob/master/docs/COOKBOOK.md`,target:`_blank`,rel:`noopener noreferrer`,className:N.guideCtaSecondary,children:`Read the cookbook`}),(0,B.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/tree/master/scenarios`,target:`_blank`,rel:`noopener noreferrer`,className:N.guideCtaSecondary,children:`Browse example scenarios`})]}),(0,B.jsxs)(`details`,{className:N.guideExample,children:[(0,B.jsx)(`summary`,{children:`Show an example RunArtifact`}),(0,B.jsx)(`pre`,{className:N.guideExampleCode,children:(0,B.jsx)(`code`,{children:U})}),(0,B.jsxs)(`p`,{className:N.guideExampleNote,children:[`Real artifacts include the full event log, the per-turn snapshot of every actor, KPIs, and the judge verdict. The shape matches the `,(0,B.jsx)(`code`,{children:`RunArtifact`}),` Zod schema in `,(0,B.jsx)(`code`,{children:`schema/index.ts`}),`; bundles are a JSON array of artifacts.`]})]})]})}function K(e){let{artifact:t,inline:n,onPromote:r,onCompare:i,promoteBusy:a,alreadyExisted:o}=e,s=t.metadata.mode,c=t.leader?.name??`<unnamed actor>`,l=t.metadata.scenario.name??t.metadata.scenario.id,u=M.useMemo(()=>{let e={},n=(t.trajectory?.timepoints?.[0])?.worldSnapshot?.metrics??{};for(let t of Object.keys(n))e[t]={id:t,label:t,range:[0,1]};return e},[t]);return(0,B.jsxs)(`div`,{className:N.artifactView,children:[(0,B.jsxs)(`header`,{className:N.artifactHead,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:N.artifactScenario,children:l}),(0,B.jsxs)(`div`,{className:N.artifactActor,children:[c,` · `,s]})]}),!n&&(0,B.jsxs)(`div`,{className:N.artifactActions,children:[(0,B.jsx)(`button`,{type:`button`,className:N.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote to Library`}),(0,B.jsx)(`button`,{type:`button`,className:N.compareBtn,onClick:i,children:`Compare`})]})]}),(0,B.jsx)(`div`,{className:N.artifactBody,children:s===`turn-loop`?(0,B.jsx)(S,{artifact:t}):(0,B.jsx)(E,{artifact:t,metricSpecs:u})})]})}function ne(e){let{artifacts:t,bundleId:n,onPromote:r,onCompare:i,promoteBusy:a,alreadyExisted:o}=e,[s,c]=M.useState(null);if(s!==null&&t[s]){let e=t[s];return(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`button`,{type:`button`,className:N.bundleDrillBack,onClick:()=>c(null),children:`← Back to bundle`}),(0,B.jsx)(K,{artifact:e,inline:!0,onPromote:()=>{},onCompare:()=>{}})]})}return(0,B.jsxs)(`div`,{children:[n&&(0,B.jsx)(`div`,{className:N.bundleIdChip,title:n,children:n.length>32?`${n.slice(0,28)}…`:n}),(0,B.jsxs)(`div`,{className:N.bundleActions,children:[(0,B.jsx)(`button`,{type:`button`,className:N.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote bundle (${t.length})`}),(0,B.jsx)(`button`,{type:`button`,className:N.compareBtn,onClick:i,children:`Compare bundle`})]}),(0,B.jsx)(`div`,{className:N.bundleGrid,children:t.map((e,t)=>{let n=e.leader,r=e.cost?.totalUSD,i=e.trajectory?.timepoints?.length??0;return(0,B.jsxs)(`button`,{type:`button`,className:N.bundleCard,onClick:()=>c(t),children:[(0,B.jsx)(`div`,{className:N.bundleCardTitle,children:n?.name??`<unnamed>`}),(0,B.jsxs)(`div`,{className:N.bundleCardMeta,children:[n?.archetype??``,` · `,i,` turn`,i===1?``:`s`,typeof r==`number`?` · $${r.toFixed(3)}`:``]})]},e.metadata.runId)})})]})}var q=5242880,J=`/api/v1/library/import`,Y=new TextEncoder,X=e=>Y.encode(e).length,Z=X(JSON.stringify({addToBundle:`bundle_00000000-0000-0000-0000-000000000000`,artifacts:[]}));function re(e){return Z+e.reduce((e,t)=>e+t.bytes,0)+Math.max(0,e.length-1)}function ie(e,t){let n=Z,r=0;for(let i of e){let e=i.bytes+ +(r>0);if(r>0&&n+e>t)break;n+=e,r+=1}return e.slice(0,r)}function ae(e,t){return`${t===void 0?`{"artifacts":[`:`{"addToBundle":${JSON.stringify(t)},"artifacts":[`}${e.map(e=>e.json).join(`,`)}]}`}function oe(e){let t=typeof e==`string`?/Maximum (\d+) bytes/.exec(e):null;return t?Number(t[1]):void 0}function se(){let e=crypto.getRandomValues(new Uint8Array(16));e[6]=e[6]&15|64,e[8]=e[8]&63|128;let t=Array.from(e,e=>e.toString(16).padStart(2,`0`)).join(``);return`bundle_${t.slice(0,8)}-${t.slice(8,12)}-${t.slice(12,16)}-${t.slice(16,20)}-${t.slice(20)}`}var Q=e=>`${(e/1048576).toFixed(1)} MiB`,ce=e=>/[.!?]$/.test(e.trim())?e.trim():`${e.trim()}.`;async function le(e,t={}){let n=e.map(e=>{let t=JSON.stringify(e);return{runId:e.metadata.runId,json:t,bytes:X(t)}}),r=[],i=[],a=t.addToBundle??se(),o=0,s=q,c=!1,l=e=>{let t=n.slice(o).map(e=>e.runId);return r.length===0?{ok:!1,error:e,bundleId:a,imported:[],notImported:t}:{ok:!1,error:`Imported ${r.length} of ${n.length} runs into ${a}: ${r.join(`, `)}. Not imported: ${t.join(`, `)}. ${ce(e)} Promote again to add the rest to the same bundle.`,bundleId:a,imported:[...r],notImported:t}};for(;o<n.length;){let e=n.slice(o),u=e.filter(e=>re([e])>s);if(u.length>0&&c){let e=u.map(e=>`${e.runId} (${Q(e.bytes)})`).join(`, `),n=u.length===1;return l(`The server takes at most ${Q(s)} in one request (MAX_REQUEST_BODY_BYTES), and ${n?`this run passes`:`these runs pass`} that on ${n?`its`:`their`} own: ${e}.`+(r.length===0&&t.addToBundle===void 0?` Nothing was imported.`:``))}let d=u.length>0?e:ie(e,s),f;try{f=await fetch(J,{method:`POST`,headers:{"Content-Type":`application/json`},body:ae(d,a)})}catch(e){return l(e instanceof Error?e.message:String(e))}let p=await f.json().catch(()=>({}));if(f.status===201&&p.bundleId&&p.runIds&&p.alreadyExisted){a=p.bundleId,r.push(...p.runIds),i.push(...p.alreadyExisted),o+=d.length;continue}if(f.status===413){let e=oe(p.error);if(e!==void 0&&(!c||e<s)){s=e,c=!0;continue}}let m=p.insertedSoFar?.runIds??[];return m.length>0&&p.bundleId&&(a=p.bundleId,r.push(...m),i.push(...p.insertedSoFar?.alreadyExisted??m.map(()=>!1)),o+=m.length),l(p.error??`Promote failed: HTTP ${f.status}`)}return{ok:!0,bundleId:a,runIds:r,alreadyExisted:i}}function ue(){let[e,t]=M.useState(!1),[n,r]=M.useState(null),[i,a]=M.useState(null),o=M.useRef(null);return{promoteSingle:M.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(J,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({artifact:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return a(e.error??`Promote failed: HTTP ${t.status}`),null}let n={kind:`single`,...await t.json()};return r(n),n}catch(e){return a(e instanceof Error?e.message:String(e)),null}finally{t(!1)}},[]),promoteBundle:M.useCallback(async e=>{t(!0),a(null);try{let t=e.map(e=>e.metadata.runId),n=await le(e,{addToBundle:o.current!==null&&o.current.runIds.length===t.length&&o.current.runIds.every((e,n)=>e===t[n])?o.current.bundleId:void 0});if(!n.ok)return o.current={runIds:t,bundleId:n.bundleId},a(n.error),null;o.current=null;let i={kind:`bundle`,bundleId:n.bundleId,runIds:n.runIds,alreadyExisted:n.alreadyExisted};return r(i),i}catch(e){return a(e instanceof Error?e.message:String(e)),null}finally{t(!1)}},[]),busy:e,lastResult:n,error:i}}var $={tab:`_tab_e8hr7_1`,emptyState:`_emptyState_e8hr7_11`,parentCard:`_parentCard_e8hr7_48`,branchCard:`_branchCard_e8hr7_48`,branchList:`_branchList_e8hr7_77`,cardHeader:`_cardHeader_e8hr7_83`,branchMeta:`_branchMeta_e8hr7_91`,parentTitle:`_parentTitle_e8hr7_99`,branchTitle:`_branchTitle_e8hr7_99`,archetype:`_archetype_e8hr7_111`,meta:`_meta_e8hr7_117`,badge:`_badge_e8hr7_129`,status:`_status_e8hr7_143`,status_running:`_status_running_e8hr7_153`,status_complete:`_status_complete_e8hr7_158`,status_aborted:`_status_aborted_e8hr7_163`,status_error:`_status_error_e8hr7_168`,metrics:`_metrics_e8hr7_174`,metric:`_metric_e8hr7_174`,deltas:`_deltas_e8hr7_208`,delta:`_delta_e8hr7_208`,direction_up:`_direction_up_e8hr7_225`,direction_down:`_direction_down_e8hr7_229`,direction_changed:`_direction_changed_e8hr7_233`,more:`_more_e8hr7_238`,identical:`_identical_e8hr7_245`,error:`_error_e8hr7_253`};function de(){let{state:e}=k(),t=o(),n=O();return!e.parent&&e.branches.length===0?(0,B.jsxs)(`div`,{className:$.emptyState,role:`region`,"aria-label":`Branches (empty)`,children:[(0,B.jsx)(`h2`,{children:`No branches yet`}),(0,B.jsxs)(`p`,{children:[`Run a simulation with snapshot capture enabled (default for dashboard runs), then open the `,(0,B.jsx)(`strong`,{children:`Reports`}),` tab and click`,` `,(0,B.jsxs)(`code`,{children:[`↳ Fork at `,t.Time,` N`]}),` on any completed turn to branch with a different leader.`]})]}):(0,B.jsxs)(`div`,{className:$.tab,role:`region`,"aria-label":`Branches`,children:[e.parent&&(0,B.jsx)(fe,{artifact:e.parent,labels:t}),(0,B.jsx)(`div`,{className:$.branchList,children:e.branches.map(r=>(0,B.jsx)(pe,{branch:r,parent:e.parent,labels:t,onOpen:()=>n(`reports`)},r.localId))})]})}function fe({artifact:e,labels:t}){let n=e.finalState?.metrics??{},r=e.trajectory?.timepoints?.length??0;return(0,B.jsxs)(`section`,{className:$.parentCard,"aria-label":`Parent run`,children:[(0,B.jsx)(`header`,{className:$.cardHeader,children:(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`h3`,{className:$.parentTitle,children:[e.metadata.scenario.name,` (parent)`]}),(0,B.jsxs)(`span`,{className:$.meta,children:[r,` `,r===1?t.time:t.times,` completed · run`,` `,(0,B.jsx)(`code`,{children:e.metadata.runId})]})]})}),(0,B.jsx)(`dl`,{className:$.metrics,children:Object.entries(n).slice(0,6).map(([e,t])=>(0,B.jsxs)(`div`,{className:$.metric,children:[(0,B.jsx)(`dt`,{children:e}),(0,B.jsx)(`dd`,{children:me(t)})]},e))})]})}function pe({branch:e,parent:t,labels:n,onOpen:r}){let i=(0,M.useMemo)(()=>t&&e.artifact?d(t,e.artifact):[],[t,e.artifact]),a=e.status===`running`?`Running · ${n.Time} ${e.currentTurn}`:e.status.charAt(0).toUpperCase()+e.status.slice(1);return(0,B.jsxs)(`article`,{className:$.branchCard,onClick:r,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),r())},tabIndex:0,role:`button`,"aria-label":`Branch ${e.actorName}, forked at ${n.time} ${e.forkedAtTurn}`,children:[(0,B.jsxs)(`header`,{className:$.cardHeader,children:[(0,B.jsxs)(`div`,{className:$.branchMeta,children:[(0,B.jsxs)(`span`,{className:$.badge,children:[`Forked at `,n.Time,` `,e.forkedAtTurn]}),(0,B.jsxs)(`h4`,{className:$.branchTitle,children:[e.actorName,` `,(0,B.jsxs)(`span`,{className:$.archetype,children:[`(`,e.actorArchetype,`)`]})]})]}),(0,B.jsx)(`span`,{className:`${$.status} ${$[`status_${e.status}`]}`,children:a})]}),e.status===`complete`&&i.length>0&&(0,B.jsxs)(`ul`,{className:$.deltas,"aria-label":`Delta vs parent`,children:[i.slice(0,4).map(e=>(0,B.jsx)(`li`,{className:`${$.delta} ${$[`direction_${e.direction}`]}`,title:`${e.bag}: parent=${e.parentValue}, branch=${e.branchValue}`,children:p(e)},`${e.bag}.${e.key}`)),i.length>4&&(0,B.jsxs)(`li`,{className:$.more,children:[`+`,i.length-4,` more`]})]}),e.status===`complete`&&i.length===0&&(0,B.jsx)(`p`,{className:$.identical,children:`Identical final state. Leader overrides did not diverge.`}),e.status===`error`&&e.errorMessage&&(0,B.jsx)(`p`,{className:$.error,role:`alert`,children:e.errorMessage})]})}function me(e){return typeof e==`number`?Number.isInteger(e)?e.toString():(Math.round(e*100)/100).toString():String(e)}var he=[{id:`author`,label:`Author`},{id:`branches`,label:`Branches`}];function ge({initialSubTab:e=`author`,onOpenRunFile:t}={}){let[n,r]=M.useState(e),i=M.useCallback(e=>{r(e),b(e===`author`?null:e)},[]),[a,o]=M.useState(null),[s,c]=M.useState(!1),l=ue(),u=M.useCallback((e,t)=>{e.kind!==`error`&&o({input:e,filename:t,promote:null})},[]),d=M.useCallback(async()=>{if(!a||a.input.kind!==`single`)return;let e=await l.promoteSingle(a.input.artifact);e&&o(t=>t&&{...t,promote:e})},[a,l]),f=M.useCallback(async()=>{if(!a||a.input.kind!==`bundle`)return;let e=await l.promoteBundle(a.input.artifacts);e&&o(t=>t&&{...t,promote:e})},[a,l]),p=M.useCallback(()=>c(!0),[]),m=M.useCallback(()=>{o(null),c(!1)},[]),h=(()=>{if(a)return a.input.kind===`single`?[a.input.artifact]:a.input.artifacts})(),g=a?.promote?.kind===`bundle`?a.promote.bundleId:null;return(0,B.jsxs)(`div`,{className:N.tab,children:[(0,B.jsx)(te,{options:he,active:n,onChange:i,ariaLabel:`Studio sub-navigation`}),n===`branches`&&(0,B.jsx)(de,{}),n===`author`&&!a&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(G,{}),t&&(0,B.jsxs)(`div`,{className:N.openRunFile,children:[(0,B.jsx)(`button`,{type:`button`,onClick:t,children:`Open a run file`}),(0,B.jsx)(`p`,{children:`A run you saved with Save in the run actions menu, as a .json file.`})]}),(0,B.jsx)(H,{onLoaded:u})]}),n===`author`&&a&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)(`div`,{className:N.loadedBar,children:[(0,B.jsxs)(`span`,{children:[(0,B.jsx)(`strong`,{children:a.filename}),` · `,a.input.kind===`single`?`single artifact`:`bundle of ${a.input.artifacts.length}`,a.promote&&(a.promote.kind===`single`?a.promote.alreadyExisted?` · already in Library`:` · added to Library`:` · added to Library (${a.promote.runIds.length} runs)`)]}),(0,B.jsx)(`button`,{type:`button`,className:N.bundleDrillBack,onClick:m,children:`Drop another`})]}),l.error&&(0,B.jsx)(`div`,{className:N.errorBanner,role:`alert`,children:l.error}),a.input.kind===`single`&&(0,B.jsx)(K,{artifact:a.input.artifact,onPromote:d,onCompare:p,promoteBusy:l.busy,alreadyExisted:a.promote?.kind===`single`&&a.promote.alreadyExisted}),a.input.kind===`bundle`&&(0,B.jsx)(ne,{artifacts:a.input.artifacts,bundleId:a.input.bundleId,onPromote:f,onCompare:p,promoteBusy:l.busy,alreadyExisted:a.promote?.kind===`bundle`&&a.promote.alreadyExisted.every(Boolean)})]}),(0,B.jsx)(D,{bundleId:g,extraArtifacts:h,open:s,onClose:()=>c(!1)})]})}export{ge as StudioTab};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./rolldown-runtime-WkwZ5CU-.js";import{
|
|
1
|
+
import"./rolldown-runtime-WkwZ5CU-.js";import{_n as e,dn as t}from"./index-BPO4i_k0.js";e();var n={tablist:`_tablist_iq6lf_1`,tab:`_tab_iq6lf_1`,tabActive:`_tabActive_iq6lf_39`},r=t();function i({options:e,active:t,onChange:i,ariaLabel:a}){return(0,r.jsx)(`div`,{role:`tablist`,"aria-label":a,className:n.tablist,children:e.map(e=>{let a=e.id===t,o=a?`${n.tab} ${n.tabActive}`:n.tab;return(0,r.jsx)(`button`,{role:`tab`,"aria-selected":a,onClick:()=>i(e.id),type:`button`,className:o,children:e.label},e.id)})})}export{i as t};
|