paracosm 0.9.1082 → 0.9.1083

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.
@@ -106,7 +106,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
106
106
  "score": 0.82,
107
107
  "rationale": "Roles consistent with departmental authority; arithmetic checks out."
108
108
  }
109
- }`;function Bp(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 Vp(){return(0,x.jsxs)(`section`,{className:Oi.guide,"aria-label":`How to author a RunArtifact JSON`,children:[(0,x.jsxs)(`div`,{className:Oi.guideHead,children:[(0,x.jsx)(`h3`,{className:Oi.guideTitle,children:`How to get a RunArtifact JSON`}),(0,x.jsxs)(`p`,{className:Oi.guideSub,children:[`Studio takes a deterministic Paracosm `,(0,x.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,x.jsxs)(`ol`,{className:Oi.guideSteps,children:[(0,x.jsxs)(`li`,{children:[(0,x.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,x.jsxs)(`li`,{children:[(0,x.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,x.jsxs)(`li`,{children:[(0,x.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,x.jsx)(`code`,{children:`paracosm run scenarios/frontier-ai-lab.json --turns 20 --out run.json`}),`.`]}),(0,x.jsxs)(`li`,{children:[(0,x.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.`]})]}),(0,x.jsxs)(`div`,{className:Oi.guideCtaRow,children:[(0,x.jsx)(`a`,{href:`?tab=settings`,onClick:Bp,className:Oi.guideCta,children:`Open Settings →`}),(0,x.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/blob/master/docs/COOKBOOK.md`,target:`_blank`,rel:`noopener noreferrer`,className:Oi.guideCtaSecondary,children:`Read the cookbook`}),(0,x.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/tree/master/scenarios`,target:`_blank`,rel:`noopener noreferrer`,className:Oi.guideCtaSecondary,children:`Browse example scenarios`})]}),(0,x.jsxs)(`details`,{className:Oi.guideExample,children:[(0,x.jsx)(`summary`,{children:`Show an example RunArtifact`}),(0,x.jsx)(`pre`,{className:Oi.guideExampleCode,children:(0,x.jsx)(`code`,{children:zp})}),(0,x.jsxs)(`p`,{className:Oi.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,x.jsx)(`code`,{children:`RunArtifact`}),` Zod schema in `,(0,x.jsx)(`code`,{children:`schema/index.ts`}),`; bundles are a JSON array of artifacts.`]})]})]})}function Hp(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=b.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,x.jsxs)(`div`,{className:Oi.artifactView,children:[(0,x.jsxs)(`header`,{className:Oi.artifactHead,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:Oi.artifactScenario,children:l}),(0,x.jsxs)(`div`,{className:Oi.artifactActor,children:[c,` · `,s]})]}),!n&&(0,x.jsxs)(`div`,{className:Oi.artifactActions,children:[(0,x.jsx)(`button`,{type:`button`,className:Oi.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote to Library`}),(0,x.jsx)(`button`,{type:`button`,className:Oi.compareBtn,onClick:i,children:`Compare`})]})]}),(0,x.jsx)(`div`,{className:Oi.artifactBody,children:s===`turn-loop`?(0,x.jsx)(Ir,{artifact:t}):(0,x.jsx)(Pr,{artifact:t,metricSpecs:u})})]})}function Up(e){let{artifacts:t,bundleId:n,onPromote:r,onCompare:i,promoteBusy:a,alreadyExisted:o}=e,[s,c]=b.useState(null);if(s!==null&&t[s]){let e=t[s];return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`button`,{type:`button`,className:Oi.bundleDrillBack,onClick:()=>c(null),children:`← Back to bundle`}),(0,x.jsx)(Hp,{artifact:e,inline:!0,onPromote:()=>{},onCompare:()=>{}})]})}return(0,x.jsxs)(`div`,{children:[n&&(0,x.jsx)(`div`,{className:Oi.bundleIdChip,title:n,children:n.length>32?`${n.slice(0,28)}…`:n}),(0,x.jsxs)(`div`,{className:Oi.bundleActions,children:[(0,x.jsx)(`button`,{type:`button`,className:Oi.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote bundle (${t.length})`}),(0,x.jsx)(`button`,{type:`button`,className:Oi.compareBtn,onClick:i,children:`Compare bundle`})]}),(0,x.jsx)(`div`,{className:Oi.bundleGrid,children:t.map((e,t)=>{let n=e.leader,r=e.cost?.totalUSD,i=e.trajectory?.timepoints?.length??0;return(0,x.jsxs)(`button`,{type:`button`,className:Oi.bundleCard,onClick:()=>c(t),children:[(0,x.jsx)(`div`,{className:Oi.bundleCardTitle,children:n?.name??`<unnamed>`}),(0,x.jsxs)(`div`,{className:Oi.bundleCardMeta,children:[n?.archetype??``,` · `,i,` turn`,i===1?``:`s`,typeof r==`number`?` · $${r.toFixed(3)}`:``]})]},e.metadata.runId)})})]})}function Wp(){let[e,t]=b.useState(!1),[n,r]=b.useState(null),[i,a]=b.useState(null);return{promoteSingle:b.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(`/api/v1/library/import`,{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:b.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(`/api/v1/library/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({artifacts:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return a(e.error??`Promote failed: HTTP ${t.status}`),null}let n={kind:`bundle`,...await t.json()};return r(n),n}catch(e){return a(e instanceof Error?e.message:String(e)),null}finally{t(!1)}},[]),busy:e,lastResult:n,error:i}}function Gp(){let e=zw();return(0,b.useMemo)(()=>de(e),[e.labels?.populationNoun,e.labels?.settlementNoun,e.labels?.timeUnitNoun,e.labels?.timeUnitNounPlural])}function Kp(e,t){return typeof e==`number`&&typeof t==`number`?t>e?`up`:t<e?`down`:`unchanged`:e===t?`unchanged`:`changed`}function qp(e,t){let n=[`metrics`,`capacities`,`statuses`,`environment`,`politics`],r=[],i=e.finalState,a=t.finalState;if(!i||!a)return r;for(let e of n){let t=i[e],n=a[e];if(t&&n)for(let i of Object.keys(t)){if(!(i in n))continue;let a=t[i],o=n[i],s=Kp(a,o);if(s===`unchanged`)continue;let c=typeof a==`number`&&typeof o==`number`?o-a:void 0;r.push({bag:e,key:i,parentValue:a,branchValue:o,delta:c,direction:s})}}return r.sort((e,t)=>e.delta!==void 0&&t.delta!==void 0?Math.abs(t.delta)-Math.abs(e.delta):e.delta===void 0?t.delta===void 0?0:1:-1)}function Jp(e){if(e.delta!==void 0){let t=e.delta>0?`+`:``,n=Math.round(e.delta*10)/10;return`${e.key} ${t}${n}`}return`${e.key}: ${e.parentValue} → ${e.branchValue}`}var Yp={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 Xp(){let{state:e}=mn(),t=Gp(),n=Uw();return!e.parent&&e.branches.length===0?(0,x.jsxs)(`div`,{className:Yp.emptyState,role:`region`,"aria-label":`Branches (empty)`,children:[(0,x.jsx)(`h2`,{children:`No branches yet`}),(0,x.jsxs)(`p`,{children:[`Run a simulation with snapshot capture enabled (default for dashboard runs), then open the `,(0,x.jsx)(`strong`,{children:`Reports`}),` tab and click`,` `,(0,x.jsxs)(`code`,{children:[`↳ Fork at `,t.Time,` N`]}),` on any completed turn to branch with a different leader.`]})]}):(0,x.jsxs)(`div`,{className:Yp.tab,role:`region`,"aria-label":`Branches`,children:[e.parent&&(0,x.jsx)(Zp,{artifact:e.parent,labels:t}),(0,x.jsx)(`div`,{className:Yp.branchList,children:e.branches.map(r=>(0,x.jsx)(Qp,{branch:r,parent:e.parent,labels:t,onOpen:()=>n(`reports`)},r.localId))})]})}function Zp({artifact:e,labels:t}){let n=e.finalState?.metrics??{},r=e.trajectory?.timepoints?.length??0;return(0,x.jsxs)(`section`,{className:Yp.parentCard,"aria-label":`Parent run`,children:[(0,x.jsx)(`header`,{className:Yp.cardHeader,children:(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:Yp.parentTitle,children:[e.metadata.scenario.name,` (parent)`]}),(0,x.jsxs)(`span`,{className:Yp.meta,children:[r,` `,r===1?t.time:t.times,` completed · run`,` `,(0,x.jsx)(`code`,{children:e.metadata.runId})]})]})}),(0,x.jsx)(`dl`,{className:Yp.metrics,children:Object.entries(n).slice(0,6).map(([e,t])=>(0,x.jsxs)(`div`,{className:Yp.metric,children:[(0,x.jsx)(`dt`,{children:e}),(0,x.jsx)(`dd`,{children:$p(t)})]},e))})]})}function Qp({branch:e,parent:t,labels:n,onOpen:r}){let i=(0,b.useMemo)(()=>t&&e.artifact?qp(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,x.jsxs)(`article`,{className:Yp.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,x.jsxs)(`header`,{className:Yp.cardHeader,children:[(0,x.jsxs)(`div`,{className:Yp.branchMeta,children:[(0,x.jsxs)(`span`,{className:Yp.badge,children:[`Forked at `,n.Time,` `,e.forkedAtTurn]}),(0,x.jsxs)(`h4`,{className:Yp.branchTitle,children:[e.actorName,` `,(0,x.jsxs)(`span`,{className:Yp.archetype,children:[`(`,e.actorArchetype,`)`]})]})]}),(0,x.jsx)(`span`,{className:`${Yp.status} ${Yp[`status_${e.status}`]}`,children:a})]}),e.status===`complete`&&i.length>0&&(0,x.jsxs)(`ul`,{className:Yp.deltas,"aria-label":`Delta vs parent`,children:[i.slice(0,4).map(e=>(0,x.jsx)(`li`,{className:`${Yp.delta} ${Yp[`direction_${e.direction}`]}`,title:`${e.bag}: parent=${e.parentValue}, branch=${e.branchValue}`,children:Jp(e)},`${e.bag}.${e.key}`)),i.length>4&&(0,x.jsxs)(`li`,{className:Yp.more,children:[`+`,i.length-4,` more`]})]}),e.status===`complete`&&i.length===0&&(0,x.jsx)(`p`,{className:Yp.identical,children:`Identical final state. Leader overrides did not diverge.`}),e.status===`error`&&e.errorMessage&&(0,x.jsx)(`p`,{className:Yp.error,role:`alert`,children:e.errorMessage})]})}function $p(e){return typeof e==`number`?Number.isInteger(e)?e.toString():(Math.round(e*100)/100).toString():String(e)}var em={tablist:`_tablist_iq6lf_1`,tab:`_tab_iq6lf_1`,tabActive:`_tabActive_iq6lf_39`};function tm({options:e,active:t,onChange:n,ariaLabel:r}){return(0,x.jsx)(`div`,{role:`tablist`,"aria-label":r,className:em.tablist,children:e.map(e=>{let r=e.id===t,i=r?`${em.tab} ${em.tabActive}`:em.tab;return(0,x.jsx)(`button`,{role:`tab`,"aria-selected":r,onClick:()=>n(e.id),type:`button`,className:i,children:e.label},e.id)})})}var nm=[`quickstart`,`sim`,`viz`,`settings`,`reports`,`chat`,`library`,`studio`,`about`],rm={branches:{tab:`studio`,sub:`branches`},log:{tab:`settings`,sub:`log`}};function im(e){return!!e&&nm.includes(e)}function am(e){let{tab:t}=om(e);return t}function om(e){let t=new URL(e),n=t.searchParams.get(`tab`),r=t.searchParams.get(`sub`);if(n&&rm[n])return rm[n];if(im(n))return{tab:n,sub:r??void 0};let i=t.hash.replace(/^#/,``);return i&&rm[i]?rm[i]:im(i)?{tab:i,sub:r??void 0}:{tab:`quickstart`}}function sm(e,t){let n=new URL(e);return n.searchParams.set(`tab`,t),n.searchParams.delete(`sub`),n.hash=``,n.toString()}function cm(e){if(typeof window>`u`)return;let t=new URL(window.location.href);e?t.searchParams.set(`sub`,e):t.searchParams.delete(`sub`),window.history.replaceState({},``,t.toString())}function lm(e,t){if(!t)return sm(e,`sim`);let n=new URL(e),r=new URL(t,n.origin);return r.pathname===`/sim`&&!r.searchParams.has(`tab`)&&r.searchParams.set(`tab`,`sim`),r.hash=``,r.toString()}var um=[{id:`author`,label:`Author`},{id:`branches`,label:`Branches`}];function dm({initialSubTab:e=`author`}={}){let[t,n]=b.useState(e),r=b.useCallback(e=>{n(e),cm(e===`author`?null:e)},[]),[i,a]=b.useState(null),[o,s]=b.useState(!1),c=Wp(),l=b.useCallback((e,t)=>{e.kind!==`error`&&a({input:e,filename:t,promote:null})},[]),u=b.useCallback(async()=>{if(!i||i.input.kind!==`single`)return;let e=await c.promoteSingle(i.input.artifact);e&&a(t=>t&&{...t,promote:e})},[i,c]),d=b.useCallback(async()=>{if(!i||i.input.kind!==`bundle`)return;let e=await c.promoteBundle(i.input.artifacts);e&&a(t=>t&&{...t,promote:e})},[i,c]),f=b.useCallback(()=>s(!0),[]),p=b.useCallback(()=>{a(null),s(!1)},[]),m=(()=>{if(i)return i.input.kind===`single`?[i.input.artifact]:i.input.artifacts})(),h=i?.promote?.kind===`bundle`?i.promote.bundleId:null;return(0,x.jsxs)(`div`,{className:Oi.tab,children:[(0,x.jsx)(tm,{options:um,active:t,onChange:r,ariaLabel:`Studio sub-navigation`}),t===`branches`&&(0,x.jsx)(Xp,{}),t===`author`&&!i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Vp,{}),(0,x.jsx)(Rp,{onLoaded:l})]}),t===`author`&&i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:Oi.loadedBar,children:[(0,x.jsxs)(`span`,{children:[(0,x.jsx)(`strong`,{children:i.filename}),` · `,i.input.kind===`single`?`single artifact`:`bundle of ${i.input.artifacts.length}`,i.promote&&(i.promote.kind===`single`?i.promote.alreadyExisted?` · already in Library`:` · added to Library`:` · added to Library (${i.promote.runIds.length} runs)`)]}),(0,x.jsx)(`button`,{type:`button`,className:Oi.bundleDrillBack,onClick:p,children:`Drop another`})]}),c.error&&(0,x.jsx)(`div`,{className:Oi.errorBanner,role:`alert`,children:c.error}),i.input.kind===`single`&&(0,x.jsx)(Hp,{artifact:i.input.artifact,onPromote:u,onCompare:f,promoteBusy:c.busy,alreadyExisted:i.promote?.kind===`single`&&i.promote.alreadyExisted}),i.input.kind===`bundle`&&(0,x.jsx)(Up,{artifacts:i.input.artifacts,bundleId:i.input.bundleId,onPromote:d,onCompare:f,promoteBusy:c.busy,alreadyExisted:i.promote?.kind===`bundle`&&i.promote.alreadyExisted.every(Boolean)})]}),(0,x.jsx)(wi,{bundleId:h,extraArtifacts:m,open:o,onClose:()=>s(!1)})]})}function fm(e){let t=e.trim();if(!t)return{ok:!1,error:`URL is empty.`};if(t.length>2048)return{ok:!1,error:`URL exceeds 2048 characters.`};let n;try{n=new URL(t)}catch{return{ok:!1,error:`Not a valid URL.`}}return n.protocol!==`http:`&&n.protocol!==`https:`?{ok:!1,error:`Unsupported scheme ${n.protocol}. Use http or https.`}:{ok:!0,url:n}}function pm(e,t=200,n=5e4){let r=e.trim();return r?r.length<t?{ok:!1,reason:`too-short`}:r.length>n?{ok:!1,reason:`too-long`}:{ok:!0}:{ok:!1,reason:`empty`}}function mm(e,t){let n=[`metrics`,`capacities`,`statuses`,`environment`,`politics`],r=e.finalState;if(!r||t.length===0)return[];let i=[];for(let e of n){let n=r[e];if(n)for(let r of Object.keys(n)){let a=n[r],o=t.map(t=>t.finalState?.[e]?.[r]).filter(e=>e!==void 0);if(o.length!==0){if(typeof a==`number`&&o.every(e=>typeof e==`number`)){let t=[...o].sort((e,t)=>e-t),n=t.length%2==0?(t[t.length/2-1]+t[t.length/2])/2:t[(t.length-1)/2],s=a-n;if(s===0)continue;i.push({bag:e,key:r,parentValue:n,branchValue:a,delta:s,direction:s>0?`up`:`down`})}else{let t=o.find(e=>e!==a);if(t===void 0)continue;i.push({bag:e,key:r,parentValue:t,branchValue:a,direction:`changed`})}}}}return i.sort((e,t)=>e.delta!==void 0&&t.delta!==void 0?Math.abs(t.delta)-Math.abs(e.delta):e.delta===void 0?t.delta===void 0?0:1:-1)}function hm(e,t,n=`viz`){return ct(e,t,n)}function gm(e,t){let n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}var _m=`/assets/pdf.worker.min-CjEcRF4W.mjs`,vm=`modulepreload`,ym=function(e){return`/`+e},bm={},xm=function(e){return e.pathname.endsWith(`.css`)},Sm=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Cm=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ym(t,n);let r=s(t),i=xm(r);return Sm(bm,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:vm,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function wm(){if(typeof window>`u`)return _m;try{return new URL(_m,window.location.origin).toString()}catch{return _m}}var Tm=null;async function Em(){if(Tm)return Tm;let e=await Cm(()=>import(`./pdf-BHx8b9rl.js`),[]);return e.GlobalWorkerOptions.workerSrc=wm(),Tm=e,e}async function Dm(e,t={}){let{maxBytes:n=5e4,maxPages:r=100}=t;if(!e.name.toLowerCase().endsWith(`.pdf`)&&e.type!==`application/pdf`)throw Error(`File is not a PDF: ${e.name}`);let i=await Em(),a=await e.arrayBuffer(),o=i.getDocument({data:a}),s=[],c=0,l=!1;try{let e=await o.promise,t=Math.min(e.numPages,r);for(let r=1;r<=t;r++){let t=(await(await e.getPage(r)).getTextContent()).items.map(e=>e.str??``).join(` `).replace(/\s+/g,` `).trim(),i=new Blob([t]).size;if(c+i>n){let e=n-c;if(e>0){let r=new TextEncoder().encode(t).slice(0,e),i=new TextDecoder(`utf-8`,{fatal:!1}).decode(r).replace(/�$/,``);s.push(i),c=n}l=!0;break}s.push(t),c+=i}let i=s.join(`
109
+ }`;function Bp(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 Vp(){return(0,x.jsxs)(`section`,{className:Oi.guide,"aria-label":`How to author a RunArtifact JSON`,children:[(0,x.jsxs)(`div`,{className:Oi.guideHead,children:[(0,x.jsx)(`h3`,{className:Oi.guideTitle,children:`How to get a RunArtifact JSON`}),(0,x.jsxs)(`p`,{className:Oi.guideSub,children:[`Studio takes a deterministic Paracosm `,(0,x.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,x.jsxs)(`ol`,{className:Oi.guideSteps,children:[(0,x.jsxs)(`li`,{children:[(0,x.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,x.jsxs)(`li`,{children:[(0,x.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,x.jsxs)(`li`,{children:[(0,x.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,x.jsx)(`code`,{children:`paracosm run scenarios/frontier-ai-lab.json --turns 20 --out run.json`}),`.`]}),(0,x.jsxs)(`li`,{children:[(0,x.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.`]})]}),(0,x.jsxs)(`div`,{className:Oi.guideCtaRow,children:[(0,x.jsx)(`a`,{href:`?tab=settings`,onClick:Bp,className:Oi.guideCta,children:`Open Settings →`}),(0,x.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/blob/master/docs/COOKBOOK.md`,target:`_blank`,rel:`noopener noreferrer`,className:Oi.guideCtaSecondary,children:`Read the cookbook`}),(0,x.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/tree/master/scenarios`,target:`_blank`,rel:`noopener noreferrer`,className:Oi.guideCtaSecondary,children:`Browse example scenarios`})]}),(0,x.jsxs)(`details`,{className:Oi.guideExample,children:[(0,x.jsx)(`summary`,{children:`Show an example RunArtifact`}),(0,x.jsx)(`pre`,{className:Oi.guideExampleCode,children:(0,x.jsx)(`code`,{children:zp})}),(0,x.jsxs)(`p`,{className:Oi.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,x.jsx)(`code`,{children:`RunArtifact`}),` Zod schema in `,(0,x.jsx)(`code`,{children:`schema/index.ts`}),`; bundles are a JSON array of artifacts.`]})]})]})}function Hp(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=b.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,x.jsxs)(`div`,{className:Oi.artifactView,children:[(0,x.jsxs)(`header`,{className:Oi.artifactHead,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`div`,{className:Oi.artifactScenario,children:l}),(0,x.jsxs)(`div`,{className:Oi.artifactActor,children:[c,` · `,s]})]}),!n&&(0,x.jsxs)(`div`,{className:Oi.artifactActions,children:[(0,x.jsx)(`button`,{type:`button`,className:Oi.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote to Library`}),(0,x.jsx)(`button`,{type:`button`,className:Oi.compareBtn,onClick:i,children:`Compare`})]})]}),(0,x.jsx)(`div`,{className:Oi.artifactBody,children:s===`turn-loop`?(0,x.jsx)(Ir,{artifact:t}):(0,x.jsx)(Pr,{artifact:t,metricSpecs:u})})]})}function Up(e){let{artifacts:t,bundleId:n,onPromote:r,onCompare:i,promoteBusy:a,alreadyExisted:o}=e,[s,c]=b.useState(null);if(s!==null&&t[s]){let e=t[s];return(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`button`,{type:`button`,className:Oi.bundleDrillBack,onClick:()=>c(null),children:`← Back to bundle`}),(0,x.jsx)(Hp,{artifact:e,inline:!0,onPromote:()=>{},onCompare:()=>{}})]})}return(0,x.jsxs)(`div`,{children:[n&&(0,x.jsx)(`div`,{className:Oi.bundleIdChip,title:n,children:n.length>32?`${n.slice(0,28)}…`:n}),(0,x.jsxs)(`div`,{className:Oi.bundleActions,children:[(0,x.jsx)(`button`,{type:`button`,className:Oi.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote bundle (${t.length})`}),(0,x.jsx)(`button`,{type:`button`,className:Oi.compareBtn,onClick:i,children:`Compare bundle`})]}),(0,x.jsx)(`div`,{className:Oi.bundleGrid,children:t.map((e,t)=>{let n=e.leader,r=e.cost?.totalUSD,i=e.trajectory?.timepoints?.length??0;return(0,x.jsxs)(`button`,{type:`button`,className:Oi.bundleCard,onClick:()=>c(t),children:[(0,x.jsx)(`div`,{className:Oi.bundleCardTitle,children:n?.name??`<unnamed>`}),(0,x.jsxs)(`div`,{className:Oi.bundleCardMeta,children:[n?.archetype??``,` · `,i,` turn`,i===1?``:`s`,typeof r==`number`?` · $${r.toFixed(3)}`:``]})]},e.metadata.runId)})})]})}function Wp(){let[e,t]=b.useState(!1),[n,r]=b.useState(null),[i,a]=b.useState(null);return{promoteSingle:b.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(`/api/v1/library/import`,{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:b.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(`/api/v1/library/import`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({artifacts:e})});if(!t.ok){let e=await t.json().catch(()=>({}));return a(e.error??`Promote failed: HTTP ${t.status}`),null}let n={kind:`bundle`,...await t.json()};return r(n),n}catch(e){return a(e instanceof Error?e.message:String(e)),null}finally{t(!1)}},[]),busy:e,lastResult:n,error:i}}function Gp(){let e=zw();return(0,b.useMemo)(()=>de(e),[e.labels?.populationNoun,e.labels?.settlementNoun,e.labels?.timeUnitNoun,e.labels?.timeUnitNounPlural])}function Kp(e,t){return typeof e==`number`&&typeof t==`number`?t>e?`up`:t<e?`down`:`unchanged`:e===t?`unchanged`:`changed`}function qp(e,t){let n=[`metrics`,`capacities`,`statuses`,`environment`,`politics`],r=[],i=e.finalState,a=t.finalState;if(!i||!a)return r;for(let e of n){let t=i[e],n=a[e];if(t&&n)for(let i of Object.keys(t)){if(!(i in n))continue;let a=t[i],o=n[i],s=Kp(a,o);if(s===`unchanged`)continue;let c=typeof a==`number`&&typeof o==`number`?o-a:void 0;r.push({bag:e,key:i,parentValue:a,branchValue:o,delta:c,direction:s})}}return r.sort((e,t)=>e.delta!==void 0&&t.delta!==void 0?Math.abs(t.delta)-Math.abs(e.delta):e.delta===void 0?t.delta===void 0?0:1:-1)}function Jp(e){if(e.delta!==void 0){let t=e.delta>0?`+`:``,n=Math.round(e.delta*10)/10;return`${e.key} ${t}${n}`}return`${e.key}: ${e.parentValue} → ${e.branchValue}`}var Yp={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 Xp(){let{state:e}=mn(),t=Gp(),n=Uw();return!e.parent&&e.branches.length===0?(0,x.jsxs)(`div`,{className:Yp.emptyState,role:`region`,"aria-label":`Branches (empty)`,children:[(0,x.jsx)(`h2`,{children:`No branches yet`}),(0,x.jsxs)(`p`,{children:[`Run a simulation with snapshot capture enabled (default for dashboard runs), then open the `,(0,x.jsx)(`strong`,{children:`Reports`}),` tab and click`,` `,(0,x.jsxs)(`code`,{children:[`↳ Fork at `,t.Time,` N`]}),` on any completed turn to branch with a different leader.`]})]}):(0,x.jsxs)(`div`,{className:Yp.tab,role:`region`,"aria-label":`Branches`,children:[e.parent&&(0,x.jsx)(Zp,{artifact:e.parent,labels:t}),(0,x.jsx)(`div`,{className:Yp.branchList,children:e.branches.map(r=>(0,x.jsx)(Qp,{branch:r,parent:e.parent,labels:t,onOpen:()=>n(`reports`)},r.localId))})]})}function Zp({artifact:e,labels:t}){let n=e.finalState?.metrics??{},r=e.trajectory?.timepoints?.length??0;return(0,x.jsxs)(`section`,{className:Yp.parentCard,"aria-label":`Parent run`,children:[(0,x.jsx)(`header`,{className:Yp.cardHeader,children:(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`h3`,{className:Yp.parentTitle,children:[e.metadata.scenario.name,` (parent)`]}),(0,x.jsxs)(`span`,{className:Yp.meta,children:[r,` `,r===1?t.time:t.times,` completed · run`,` `,(0,x.jsx)(`code`,{children:e.metadata.runId})]})]})}),(0,x.jsx)(`dl`,{className:Yp.metrics,children:Object.entries(n).slice(0,6).map(([e,t])=>(0,x.jsxs)(`div`,{className:Yp.metric,children:[(0,x.jsx)(`dt`,{children:e}),(0,x.jsx)(`dd`,{children:$p(t)})]},e))})]})}function Qp({branch:e,parent:t,labels:n,onOpen:r}){let i=(0,b.useMemo)(()=>t&&e.artifact?qp(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,x.jsxs)(`article`,{className:Yp.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,x.jsxs)(`header`,{className:Yp.cardHeader,children:[(0,x.jsxs)(`div`,{className:Yp.branchMeta,children:[(0,x.jsxs)(`span`,{className:Yp.badge,children:[`Forked at `,n.Time,` `,e.forkedAtTurn]}),(0,x.jsxs)(`h4`,{className:Yp.branchTitle,children:[e.actorName,` `,(0,x.jsxs)(`span`,{className:Yp.archetype,children:[`(`,e.actorArchetype,`)`]})]})]}),(0,x.jsx)(`span`,{className:`${Yp.status} ${Yp[`status_${e.status}`]}`,children:a})]}),e.status===`complete`&&i.length>0&&(0,x.jsxs)(`ul`,{className:Yp.deltas,"aria-label":`Delta vs parent`,children:[i.slice(0,4).map(e=>(0,x.jsx)(`li`,{className:`${Yp.delta} ${Yp[`direction_${e.direction}`]}`,title:`${e.bag}: parent=${e.parentValue}, branch=${e.branchValue}`,children:Jp(e)},`${e.bag}.${e.key}`)),i.length>4&&(0,x.jsxs)(`li`,{className:Yp.more,children:[`+`,i.length-4,` more`]})]}),e.status===`complete`&&i.length===0&&(0,x.jsx)(`p`,{className:Yp.identical,children:`Identical final state. Leader overrides did not diverge.`}),e.status===`error`&&e.errorMessage&&(0,x.jsx)(`p`,{className:Yp.error,role:`alert`,children:e.errorMessage})]})}function $p(e){return typeof e==`number`?Number.isInteger(e)?e.toString():(Math.round(e*100)/100).toString():String(e)}var em={tablist:`_tablist_iq6lf_1`,tab:`_tab_iq6lf_1`,tabActive:`_tabActive_iq6lf_39`};function tm({options:e,active:t,onChange:n,ariaLabel:r}){return(0,x.jsx)(`div`,{role:`tablist`,"aria-label":r,className:em.tablist,children:e.map(e=>{let r=e.id===t,i=r?`${em.tab} ${em.tabActive}`:em.tab;return(0,x.jsx)(`button`,{role:`tab`,"aria-selected":r,onClick:()=>n(e.id),type:`button`,className:i,children:e.label},e.id)})})}var nm=[`quickstart`,`sim`,`viz`,`settings`,`reports`,`chat`,`library`,`studio`,`about`],rm={branches:{tab:`studio`,sub:`branches`},log:{tab:`settings`,sub:`log`}};function im(e){return!!e&&nm.includes(e)}function am(e){let{tab:t}=om(e);return t}function om(e){let t=new URL(e),n=t.searchParams.get(`tab`),r=t.searchParams.get(`sub`);if(n&&rm[n])return rm[n];if(im(n))return{tab:n,sub:r??void 0};let i=t.hash.replace(/^#/,``);return i&&rm[i]?rm[i]:im(i)?{tab:i,sub:r??void 0}:{tab:`quickstart`}}function sm(e,t){let n=new URL(e);return n.searchParams.set(`tab`,t),n.searchParams.delete(`sub`),n.hash=``,n.toString()}function cm(e){if(typeof window>`u`)return;let t=new URL(window.location.href);e?t.searchParams.set(`sub`,e):t.searchParams.delete(`sub`),window.history.replaceState({},``,t.toString())}function lm(e,t){if(!t)return sm(e,`sim`);let n=new URL(e),r=new URL(t,n.origin);return r.pathname===`/sim`&&!r.searchParams.has(`tab`)&&r.searchParams.set(`tab`,`sim`),r.hash=``,r.toString()}var um=[{id:`author`,label:`Author`},{id:`branches`,label:`Branches`}];function dm({initialSubTab:e=`author`}={}){let[t,n]=b.useState(e),r=b.useCallback(e=>{n(e),cm(e===`author`?null:e)},[]),[i,a]=b.useState(null),[o,s]=b.useState(!1),c=Wp(),l=b.useCallback((e,t)=>{e.kind!==`error`&&a({input:e,filename:t,promote:null})},[]),u=b.useCallback(async()=>{if(!i||i.input.kind!==`single`)return;let e=await c.promoteSingle(i.input.artifact);e&&a(t=>t&&{...t,promote:e})},[i,c]),d=b.useCallback(async()=>{if(!i||i.input.kind!==`bundle`)return;let e=await c.promoteBundle(i.input.artifacts);e&&a(t=>t&&{...t,promote:e})},[i,c]),f=b.useCallback(()=>s(!0),[]),p=b.useCallback(()=>{a(null),s(!1)},[]),m=(()=>{if(i)return i.input.kind===`single`?[i.input.artifact]:i.input.artifacts})(),h=i?.promote?.kind===`bundle`?i.promote.bundleId:null;return(0,x.jsxs)(`div`,{className:Oi.tab,children:[(0,x.jsx)(tm,{options:um,active:t,onChange:r,ariaLabel:`Studio sub-navigation`}),t===`branches`&&(0,x.jsx)(Xp,{}),t===`author`&&!i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(Vp,{}),(0,x.jsx)(Rp,{onLoaded:l})]}),t===`author`&&i&&(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:Oi.loadedBar,children:[(0,x.jsxs)(`span`,{children:[(0,x.jsx)(`strong`,{children:i.filename}),` · `,i.input.kind===`single`?`single artifact`:`bundle of ${i.input.artifacts.length}`,i.promote&&(i.promote.kind===`single`?i.promote.alreadyExisted?` · already in Library`:` · added to Library`:` · added to Library (${i.promote.runIds.length} runs)`)]}),(0,x.jsx)(`button`,{type:`button`,className:Oi.bundleDrillBack,onClick:p,children:`Drop another`})]}),c.error&&(0,x.jsx)(`div`,{className:Oi.errorBanner,role:`alert`,children:c.error}),i.input.kind===`single`&&(0,x.jsx)(Hp,{artifact:i.input.artifact,onPromote:u,onCompare:f,promoteBusy:c.busy,alreadyExisted:i.promote?.kind===`single`&&i.promote.alreadyExisted}),i.input.kind===`bundle`&&(0,x.jsx)(Up,{artifacts:i.input.artifacts,bundleId:i.input.bundleId,onPromote:d,onCompare:f,promoteBusy:c.busy,alreadyExisted:i.promote?.kind===`bundle`&&i.promote.alreadyExisted.every(Boolean)})]}),(0,x.jsx)(wi,{bundleId:h,extraArtifacts:m,open:o,onClose:()=>s(!1)})]})}function fm(e){let t=e.trim();if(!t)return{ok:!1,error:`URL is empty.`};if(t.length>2048)return{ok:!1,error:`URL exceeds 2048 characters.`};let n;try{n=new URL(t)}catch{return{ok:!1,error:`Not a valid URL.`}}return n.protocol!==`http:`&&n.protocol!==`https:`?{ok:!1,error:`Unsupported scheme ${n.protocol}. Use http or https.`}:{ok:!0,url:n}}function pm(e,t=200,n=5e4){let r=e.trim();return r?r.length<t?{ok:!1,reason:`too-short`}:r.length>n?{ok:!1,reason:`too-long`}:{ok:!0}:{ok:!1,reason:`empty`}}function mm(e,t){let n=[`metrics`,`capacities`,`statuses`,`environment`,`politics`],r=e.finalState;if(!r||t.length===0)return[];let i=[];for(let e of n){let n=r[e];if(n)for(let r of Object.keys(n)){let a=n[r],o=t.map(t=>t.finalState?.[e]?.[r]).filter(e=>e!==void 0);if(o.length!==0){if(typeof a==`number`&&o.every(e=>typeof e==`number`)){let t=[...o].sort((e,t)=>e-t),n=t.length%2==0?(t[t.length/2-1]+t[t.length/2])/2:t[(t.length-1)/2],s=a-n;if(s===0)continue;i.push({bag:e,key:r,parentValue:n,branchValue:a,delta:s,direction:s>0?`up`:`down`})}else{let t=o.find(e=>e!==a);if(t===void 0)continue;i.push({bag:e,key:r,parentValue:t,branchValue:a,direction:`changed`})}}}}return i.sort((e,t)=>e.delta!==void 0&&t.delta!==void 0?Math.abs(t.delta)-Math.abs(e.delta):e.delta===void 0?t.delta===void 0?0:1:-1)}function hm(e,t,n=`viz`){return ct(e,t,n)}function gm(e,t){let n=new Blob([JSON.stringify(e,null,2)],{type:`application/json`}),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=t,document.body.appendChild(i),i.click(),i.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}var _m=`/assets/pdf.worker.min-CIqJB0yW.mjs`,vm=`modulepreload`,ym=function(e){return`/`+e},bm={},xm=function(e){return e.pathname.endsWith(`.css`)},Sm=function(e,t,n){if(t in e)return e[t];let r=n();if(!r){e[t]=void 0;return}let i=r.then(()=>{e[t]=void 0},n=>{throw e[t]=void 0,n});return e[t]=i,i},Cm=function(e,t,n){let r=Promise.resolve();if(t&&t.length>0){let e,i=document.querySelector(`meta[property=csp-nonce]`),a=i?.nonce||i?.getAttribute(`nonce`);function o(e){return Promise.all(e.map(e=>Promise.resolve(e).then(e=>({status:`fulfilled`,value:e}),e=>({status:`rejected`,reason:e}))))}function s(e){return import.meta.resolve?new URL(import.meta.resolve(e)):new URL(e,import.meta.url)}r=o(t.map(t=>{t=ym(t,n);let r=s(t),i=xm(r);return Sm(bm,r.href,()=>{if(e===void 0){e={all:new Set,styles:new Set};let t=document.getElementsByTagName(`link`);for(let n=t.length-1;n>=0;n--){let r=t[n];e.all.add(r.href),r.rel===`stylesheet`&&e.styles.add(r.href)}}if((i?e.styles:e.all).has(r.href))return;let t=document.createElement(`link`);if(t.rel=i?`stylesheet`:vm,i||(t.as=`script`),t.crossOrigin=``,t.href=r.href,a&&t.setAttribute(`nonce`,a),document.head.appendChild(t),i)return new Promise((e,n)=>{t.addEventListener(`load`,e),t.addEventListener(`error`,()=>n(Error(`Unable to preload CSS for ${r}`)))})})}).filter(e=>e!==void 0))}function i(e){let t=new Event(`vite:preloadError`,{cancelable:!0});if(t.payload=e,window.dispatchEvent(t),!t.defaultPrevented)throw e}return r.then(t=>{for(let e of t||[])e.status===`rejected`&&i(e.reason);return e().catch(i)})};function wm(){if(typeof window>`u`)return _m;try{return new URL(_m,window.location.origin).toString()}catch{return _m}}var Tm=null;async function Em(){if(Tm)return Tm;let e=await Cm(()=>import(`./pdf-D9w_HAjp.js`),[]);return e.GlobalWorkerOptions.workerSrc=wm(),Tm=e,e}async function Dm(e,t={}){let{maxBytes:n=5e4,maxPages:r=100}=t;if(!e.name.toLowerCase().endsWith(`.pdf`)&&e.type!==`application/pdf`)throw Error(`File is not a PDF: ${e.name}`);let i=await Em(),a=await e.arrayBuffer(),o=i.getDocument({data:a}),s=[],c=0,l=!1;try{let e=await o.promise,t=Math.min(e.numPages,r);for(let r=1;r<=t;r++){let t=(await(await e.getPage(r)).getTextContent()).items.map(e=>e.str??``).join(` `).replace(/\s+/g,` `).trim(),i=new Blob([t]).size;if(c+i>n){let e=n-c;if(e>0){let r=new TextEncoder().encode(t).slice(0,e),i=new TextDecoder(`utf-8`,{fatal:!1}).decode(r).replace(/�$/,``);s.push(i),c=n}l=!0;break}s.push(t),c+=i}let i=s.join(`
110
110
 
111
111
  `);if(i.trim().length===0){let e=Error(`PDF contains no extractable text. It may be a scanned image without OCR.`);throw e.code=`PDF_NO_TEXT`,e}return{text:i,pages:e.numPages,truncated:l}}finally{try{await o.destroy()}catch{}}}function Om(e){let t=km(e.seedText.length>0?e.seedText:`<paste your scenario above>`),n=[];return n.push(`// Recreate this Quickstart run from your code.`),n.push(`import { runMany } from 'paracosm';`),n.push(``),e.sourceUrl&&e.sourceUrl.length>0?(n.push(`const { runs } = await runMany(`),n.push(` new URL('${Am(e.sourceUrl)}'),`),n.push(` { count: ${e.actorCount} },`),n.push(`);`)):(n.push(`const { runs } = await runMany(`),n.push(` \`${t}\`,`),n.push(` { count: ${e.actorCount} },`),n.push(`);`)),n.push(``),n.push(`runs.forEach(({ actor, artifact }) => console.log(actor.name, artifact.fingerprint));`),n.join(`
112
112
  `)}function km(e){return e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function Am(e){return e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}function jm(e){let t={seedText:e.seedText.length>0?e.seedText:`<paste your scenario above>`};e.domainHint&&e.domainHint.trim().length>0&&(t.domainHint=e.domainHint),e.actorCount!==2&&(t.actorCount=e.actorCount);let n=`'${JSON.stringify(t).replace(/'/g,`'\\''`)}'`,r=[];return r.push(`# This compiles a typed ScenarioPackage from your prompt.`),r.push(`# For the full flow (auto-generate HEXACO leaders + simulate),`),r.push(`# install paracosm and use the TypeScript tab.`),r.push(`curl -X POST https://paracosm.agentos.sh/api/quickstart/compile-from-seed \\`),r.push(` -H 'Content-Type: application/json' \\`),r.push(` -d ${n}`),r.join(`