paracosm 0.9.1157 → 0.9.1159
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/index-4vHPoqxc.js +184 -0
- package/dist/dashboard/dist/assets/index-D8euwBCO.css +1 -0
- package/dist/dashboard/dist/index.html +2 -2
- package/dist/server/server-app.d.ts.map +1 -1
- package/dist/server/server-app.js +4 -1
- package/dist/server/server-app.js.map +1 -1
- package/package.json +1 -1
- package/dist/dashboard/dist/assets/index-BxJFu9kt.js +0 -189
- package/dist/dashboard/dist/assets/index-zyHPjQas.css +0 -1
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,o)=>(o=n==null?{}:e(i(n)),s(r||!n||!n.__esModule||!a.call(n,`default`)?t(o,`default`,{value:n,enumerable:!0}):o,n));(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var l=`paracosm:lastLaunchConfig`,u=[`apiKey`,`anthropicKey`,`serperKey`,`firecrawlKey`,`tavilyKey`,`cohereKey`];function d(e){let t={...e};for(let e of u)delete t[e];return t}var f=`paracosm:keyOverrides`,p=`paracosm:activeRunActors`,m=`paracosm:activeRunScenarioId`,h=950;function g(e){try{let t=e.getItem(l);if(!t)return null;let n=JSON.parse(t);return n&&typeof n==`object`&&!Array.isArray(n)?d(n):null}catch{return null}}function _(e,t){return e.scenarioId===t}function v(e,t){try{e.setItem(l,JSON.stringify(d(t)))}catch{}}function y(e,t,n){try{e.setItem(p,JSON.stringify(t)),n?e.setItem(m,n):e.removeItem?.(m)}catch{}}function b(e){let t=null,n=null;try{t=e.getItem(p),n=e.getItem(m)}catch{return()=>void 0}return()=>{try{t===null?e.removeItem?.(p):e.setItem(p,t),n===null?e.removeItem?.(m):e.setItem(m,n)}catch{}}}function x(e){try{return e.getItem(`paracosm:activeRunScenarioId`)||null}catch{return null}}function S(e){try{let t=e.getItem(p);if(!t)return null;let n=JSON.parse(t);return Array.isArray(n)?n.filter(e=>!!e&&typeof e==`object`&&!Array.isArray(e)):null}catch{return null}}function C(e){try{let t=e.getItem(f);if(!t)return{};let n=JSON.parse(t);if(!n||typeof n!=`object`||Array.isArray(n))return{};let r={};for(let e of[`openai`,`anthropic`,`serper`,`firecrawl`,`tavily`,`cohere`])typeof n[e]==`string`&&(r[e]=n[e]);return r}catch{return{}}}function w(e){let t=e.getItem(l),n=g(e);t!==null&&n!==null&&t!==JSON.stringify(n)&&v(e,n)}function T(){try{let e=window.localStorage;if(w(e),e.getItem(`paracosm:keyOverrides`)===null)return;try{D({...C(e),...E()})}finally{e.removeItem(f)}}catch{}}function E(){try{return C(window.sessionStorage)}catch{return{}}}function D(e){try{let t=window.sessionStorage,n=Object.fromEntries(Object.entries(e).filter(([,e])=>typeof e==`string`&&e!==``));Object.keys(n).length?t.setItem(f,JSON.stringify(n)):t.removeItem(f)}catch{}}function O(){D({});try{window.localStorage.removeItem(f),w(window.localStorage)}catch{}}function k(e,t){let n=(typeof e.seed==`number`?e.seed:h)+1,r={...e,seed:n};return t.openai&&(r.apiKey=t.openai),t.anthropic&&(r.anthropicKey=t.anthropic),t.serper&&(r.serperKey=t.serper),t.firecrawl&&(r.firecrawlKey=t.firecrawl),t.tavily&&(r.tavilyKey=t.tavily),t.cohere&&(r.cohereKey=t.cohere),r}var ee=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.portal`),r=Symbol.for(`react.fragment`),i=Symbol.for(`react.strict_mode`),a=Symbol.for(`react.profiler`),o=Symbol.for(`react.consumer`),s=Symbol.for(`react.context`),c=Symbol.for(`react.forward_ref`),l=Symbol.for(`react.suspense`),u=Symbol.for(`react.memo`),d=Symbol.for(`react.lazy`),f=Symbol.for(`react.activity`),p=Symbol.for(`react.view_transition`),m=Symbol.iterator;function h(e){return typeof e!=`object`||!e?null:(e=m&&e[m]||e[`@@iterator`],typeof e==`function`?e:null)}var g={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},_=Object.assign,v={};function y(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}y.prototype.isReactComponent={},y.prototype.setState=function(e,t){if(typeof e!=`object`&&typeof e!=`function`&&e!=null)throw Error(`takes an object of state variables to update or a function which returns an object of state variables.`);this.updater.enqueueSetState(this,e,t,`setState`)},y.prototype.forceUpdate=function(e){this.updater.enqueueForceUpdate(this,e,`forceUpdate`)};function b(){}b.prototype=y.prototype;function x(e,t,n){this.props=e,this.context=t,this.refs=v,this.updater=n||g}var S=x.prototype=new b;S.constructor=x,_(S,y.prototype),S.isPureReactComponent=!0;var C=Array.isArray;function w(){}var T={H:null,A:null,T:null,S:null},E=Object.prototype.hasOwnProperty;function D(e,n,r){var i=r.ref;return{$$typeof:t,type:e,key:n,ref:i===void 0?null:i,props:r}}function O(e,t){return D(e.type,t,e.props)}function k(e){return typeof e==`object`&&!!e&&e.$$typeof===t}function ee(e){var t={"=":`=0`,":":`=2`};return`$`+e.replace(/[=:]/g,function(e){return t[e]})}var A=/\/+/g;function j(e,t){return typeof e==`object`&&e&&e.key!=null?ee(``+e.key):t.toString(36)}function M(e){switch(e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason;default:switch(typeof e.status==`string`?e.then(w,w):(e.status=`pending`,e.then(function(t){e.status===`pending`&&(e.status=`fulfilled`,e.value=t)},function(t){e.status===`pending`&&(e.status=`rejected`,e.reason=t)})),e.status){case`fulfilled`:return e.value;case`rejected`:throw e.reason}}throw e}function N(e,r,i,a,o){var s=typeof e;(s===`undefined`||s===`boolean`)&&(e=null);var c=!1;if(e===null)c=!0;else switch(s){case`bigint`:case`string`:case`number`:c=!0;break;case`object`:switch(e.$$typeof){case t:case n:c=!0;break;case d:return c=e._init,N(c(e._payload),r,i,a,o)}}if(c)return o=o(e),c=a===``?`.`+j(e,0):a,C(o)?(i=``,c!=null&&(i=c.replace(A,`$&/`)+`/`),N(o,r,i,``,function(e){return e})):o!=null&&(k(o)&&(o=O(o,i+(o.key==null||e&&e.key===o.key?``:(``+o.key).replace(A,`$&/`)+`/`)+c)),r.push(o)),1;c=0;var l=a===``?`.`:a+`:`;if(C(e))for(var u=0;u<e.length;u++)a=e[u],s=l+j(a,u),c+=N(a,r,i,s,o);else if(u=h(e),typeof u==`function`)for(e=u.call(e),u=0;!(a=e.next()).done;)a=a.value,s=l+j(a,u++),c+=N(a,r,i,s,o);else if(s===`object`){if(typeof e.then==`function`)return N(M(e),r,i,a,o);throw r=String(e),Error(`Objects are not valid as a React child (found: `+(r===`[object Object]`?`object with keys {`+Object.keys(e).join(`, `)+`}`:r)+`). If you meant to render a collection of children, use an array instead.`)}return c}function te(e,t,n){if(e==null)return e;var r=[],i=0;return N(e,r,``,``,function(e){return t.call(n,e,i++)}),r}function P(e){if(e._status===-1){var t=e._result,n=t();n.then(function(t){(e._status===0||e._status===-1)&&(e._status=1,e._result=t,n.status===void 0&&(n.status=`fulfilled`,n.value=t))},function(t){(e._status===0||e._status===-1)&&(e._status=2,e._result=t,n.status===void 0&&(n.status=`rejected`,n.reason=t))}),e._status===-1&&(e._status=0,e._result=n)}if(e._status===1)return e._result.default;throw e._result}var F=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)};function I(e){var t=T.T,n={};n.types=t===null?null:t.types,T.T=n;try{var r=e(),i=T.S;i!==null&&i(n,r),typeof r==`object`&&r&&typeof r.then==`function`&&r.then(w,F)}catch(e){F(e)}finally{t!==null&&n.types!==null&&(t.types=n.types),T.T=t}}function ne(e){var t=T.T;if(t!==null){var n=t.types;n===null?t.types=[e]:n.indexOf(e)===-1&&n.push(e)}else I(ne.bind(null,e))}var re={map:te,forEach:function(e,t,n){te(e,function(){t.apply(this,arguments)},n)},count:function(e){var t=0;return te(e,function(){t++}),t},toArray:function(e){return te(e,function(e){return e})||[]},only:function(e){if(!k(e))throw Error(`React.Children.only expected to receive a single React element child.`);return e}};e.Activity=f,e.Children=re,e.Component=y,e.Fragment=r,e.Profiler=a,e.PureComponent=x,e.StrictMode=i,e.Suspense=l,e.ViewTransition=p,e.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=T,e.__COMPILER_RUNTIME={__proto__:null,c:function(e){return T.H.useMemoCache(e)}},e.addTransitionType=ne,e.cache=function(e){return function(){return e.apply(null,arguments)}},e.cacheSignal=function(){return null},e.cloneElement=function(e,t,n){if(e==null)throw Error(`The argument must be a React element, but you passed `+e+`.`);var r=_({},e.props),i=e.key;if(t!=null)for(a in t.key!==void 0&&(i=``+t.key),t)!E.call(t,a)||a===`key`||a===`__self`||a===`__source`||a===`ref`&&t.ref===void 0||(r[a]=t[a]);var a=arguments.length-2;if(a===1)r.children=n;else if(1<a){for(var o=Array(a),s=0;s<a;s++)o[s]=arguments[s+2];r.children=o}return D(e.type,i,r)},e.createContext=function(e){return e={$$typeof:s,_currentValue:e,_currentValue2:e,_threadCount:0,Provider:null,Consumer:null},e.Provider=e,e.Consumer={$$typeof:o,_context:e},e},e.createElement=function(e,t,n){var r,i={},a=null;if(t!=null)for(r in t.key!==void 0&&(a=``+t.key),t)E.call(t,r)&&r!==`key`&&r!==`__self`&&r!==`__source`&&(i[r]=t[r]);var o=arguments.length-2;if(o===1)i.children=n;else if(1<o){for(var s=Array(o),c=0;c<o;c++)s[c]=arguments[c+2];i.children=s}if(e&&e.defaultProps)for(r in o=e.defaultProps,o)i[r]===void 0&&(i[r]=o[r]);return D(e,a,i)},e.createRef=function(){return{current:null}},e.forwardRef=function(e){return{$$typeof:c,render:e}},e.isValidElement=k,e.lazy=function(e){return{$$typeof:d,_payload:{_status:-1,_result:e},_init:P}},e.memo=function(e,t){return{$$typeof:u,type:e,compare:t===void 0?null:t}},e.startTransition=I,e.unstable_useCacheRefresh=function(){return T.H.useCacheRefresh()},e.use=function(e){return T.H.use(e)},e.useActionState=function(e,t,n){return T.H.useActionState(e,t,n)},e.useCallback=function(e,t){return T.H.useCallback(e,t)},e.useContext=function(e){return T.H.useContext(e)},e.useDebugValue=function(){},e.useDeferredValue=function(e,t){return T.H.useDeferredValue(e,t)},e.useEffect=function(e,t){return T.H.useEffect(e,t)},e.useEffectEvent=function(e){return T.H.useEffectEvent(e)},e.useId=function(){return T.H.useId()},e.useImperativeHandle=function(e,t,n){return T.H.useImperativeHandle(e,t,n)},e.useInsertionEffect=function(e,t){return T.H.useInsertionEffect(e,t)},e.useLayoutEffect=function(e,t){return T.H.useLayoutEffect(e,t)},e.useMemo=function(e,t){return T.H.useMemo(e,t)},e.useOptimistic=function(e,t){return T.H.useOptimistic(e,t)},e.useReducer=function(e,t,n){return T.H.useReducer(e,t,n)},e.useRef=function(e){return T.H.useRef(e)},e.useState=function(e){return T.H.useState(e)},e.useSyncExternalStore=function(e,t,n){return T.H.useSyncExternalStore(e,t,n)},e.useTransition=function(){return T.H.useTransition()},e.version=`19.3.1`})),A=o(((e,t)=>{t.exports=ee()})),j=o((e=>{function t(e,t){var n=e.length;e.push(t);a:for(;0<n;){var r=n-1>>>1,a=e[r];if(0<i(a,t))e[r]=t,e[n]=a,n=r;else break a}}function n(e){return e.length===0?null:e[0]}function r(e){if(e.length===0)return null;var t=e[0],n=e.pop();if(n!==t){e[0]=n;a:for(var r=0,a=e.length,o=a>>>1;r<o;){var s=2*(r+1)-1,c=e[s],l=s+1,u=e[l];if(0>i(c,n))l<a&&0>i(u,c)?(e[r]=u,e[l]=n,r=l):(e[r]=c,e[s]=n,r=s);else if(l<a&&0>i(u,n))e[r]=u,e[l]=n,r=l;else break a}}return t}function i(e,t){var n=e.sortIndex-t.sortIndex;return n===0?e.id-t.id:n}if(e.unstable_now=void 0,typeof performance==`object`&&typeof performance.now==`function`){var a=performance;e.unstable_now=function(){return a.now()}}else{var o=Date,s=o.now();e.unstable_now=function(){return o.now()-s}}var c=[],l=[],u=1,d=null,f=3,p=!1,m=!1,h=!1,g=!1,_=typeof setTimeout==`function`?setTimeout:null,v=typeof clearTimeout==`function`?clearTimeout:null,y=typeof setImmediate<`u`?setImmediate:null;function b(e){for(var i=n(l);i!==null;){if(i.callback===null)r(l);else if(i.startTime<=e)r(l),i.sortIndex=i.expirationTime,t(c,i);else break;i=n(l)}}function x(e){if(h=!1,b(e),!m){if(n(c)!==null)m=!0,S||(S=!0,O());else{var t=n(l);t!==null&&A(x,t.startTime-e)}}}var S=!1,C=-1,w=5,T=-1;function E(){return g?!0:!(e.unstable_now()-T<w)}function D(){if(g=!1,S){var t=e.unstable_now();T=t;var i=!0;try{a:{m=!1,h&&(h=!1,v(C),C=-1),p=!0;var a=f;try{b:{for(b(t),d=n(c);d!==null&&!(d.expirationTime>t&&E());){var o=d.callback;if(typeof o==`function`){d.callback=null,f=d.priorityLevel;var s=o(d.expirationTime<=t);if(t=e.unstable_now(),typeof s==`function`){d.callback=s,b(t),i=!0;break b}d===n(c)&&r(c),b(t)}else r(c);d=n(c)}if(d!==null)i=!0;else{var u=n(l);u!==null&&A(x,u.startTime-t),i=!1}}break a}finally{d=null,f=a,p=!1}i=void 0}}finally{i?O():S=!1}}}var O;if(typeof y==`function`)O=function(){y(D)};else if(typeof MessageChannel<`u`){var k=new MessageChannel,ee=k.port2;k.port1.onmessage=D,O=function(){ee.postMessage(null)}}else O=function(){_(D,0)};function A(t,n){C=_(function(){t(e.unstable_now())},n)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(e){e.callback=null},e.unstable_forceFrameRate=function(e){0>e||125<e?console.error(`forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported`):w=0<e?Math.floor(1e3/e):5},e.unstable_getCurrentPriorityLevel=function(){return f},e.unstable_next=function(e){switch(f){case 1:case 2:case 3:var t=3;break;default:t=f}var n=f;f=t;try{return e()}finally{f=n}},e.unstable_requestPaint=function(){g=!0},e.unstable_runWithPriority=function(e,t){switch(e){case 1:case 2:case 3:case 4:case 5:break;default:e=3}var n=f;f=e;try{return t()}finally{f=n}},e.unstable_scheduleCallback=function(r,i,a){var o=e.unstable_now();switch(typeof a==`object`&&a?(a=a.delay,a=typeof a==`number`&&0<a?o+a:o):a=o,r){case 1:var s=-1;break;case 2:s=250;break;case 5:s=1073741823;break;case 4:s=1e4;break;default:s=5e3}return s=a+s,r={id:u++,callback:i,priorityLevel:r,startTime:a,expirationTime:s,sortIndex:-1},a>o?(r.sortIndex=a,t(l,r),n(c)===null&&r===n(l)&&(h?(v(C),C=-1):h=!0,A(x,a-o))):(r.sortIndex=s,t(c,r),m||p||(m=!0,S||(S=!0,O()))),r},e.unstable_shouldYield=E,e.unstable_wrapCallback=function(e){var t=f;return function(){var n=f;f=t;try{return e.apply(this,arguments)}finally{f=n}}}})),M=o(((e,t)=>{t.exports=j()})),N=o((e=>{var t=A();function n(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function r(){}var i={d:{f:r,r:function(){throw Error(n(522))},D:r,C:r,L:r,m:r,X:r,S:r,M:r},p:0,findDOMNode:null},a=Symbol.for(`react.portal`),o=Symbol.for(`react.recoverable`),s=Symbol.for(`react.optimistic_key`);function c(e,t,n){var r=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:a,key:r==null?null:r===s?s:``+r,children:e,containerInfo:t,implementation:n}}var l=t.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;function u(e,t){if(e===`font`)return``;if(typeof t==`string`)return t===`use-credentials`?t:``}e.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i,e.browser=function(e){return{$$typeof:o,_reason:e}},e.createPortal=function(e,t){var r=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!t||t.nodeType!==1&&t.nodeType!==9&&t.nodeType!==11)throw Error(n(299));return c(e,t,null,r)},e.flushSync=function(e){var t=l.T,n=i.p;try{if(l.T=null,i.p=2,e)return e()}finally{l.T=t,i.p=n,i.d.f()}},e.preconnect=function(e,t){typeof e==`string`&&(t?(t=t.crossOrigin,t=typeof t==`string`?t===`use-credentials`?t:``:void 0):t=null,i.d.C(e,t))},e.prefetchDNS=function(e){typeof e==`string`&&i.d.D(e)},e.preinit=function(e,t){if(typeof e==`string`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin),a=typeof t.integrity==`string`?t.integrity:void 0,o=typeof t.fetchPriority==`string`?t.fetchPriority:void 0;n===`style`?i.d.S(e,typeof t.precedence==`string`?t.precedence:void 0,{crossOrigin:r,integrity:a,fetchPriority:o}):n===`script`&&i.d.X(e,{crossOrigin:r,integrity:a,fetchPriority:o,nonce:typeof t.nonce==`string`?t.nonce:void 0})}},e.preinitModule=function(e,t){if(typeof e==`string`){if(typeof t==`object`&&t){if(t.as==null||t.as===`script`){var n=u(t.as,t.crossOrigin);i.d.M(e,{crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}}else t??i.d.M(e)}},e.preload=function(e,t){if(typeof e==`string`&&typeof t==`object`&&t&&typeof t.as==`string`){var n=t.as,r=u(n,t.crossOrigin);i.d.L(e,n,{crossOrigin:r,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,type:typeof t.type==`string`?t.type:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0,referrerPolicy:typeof t.referrerPolicy==`string`?t.referrerPolicy:void 0,imageSrcSet:typeof t.imageSrcSet==`string`?t.imageSrcSet:void 0,imageSizes:typeof t.imageSizes==`string`?t.imageSizes:void 0,media:typeof t.media==`string`?t.media:void 0})}},e.preloadModule=function(e,t){if(typeof e==`string`){if(t){var n=u(t.as,t.crossOrigin);i.d.m(e,{as:typeof t.as==`string`&&t.as!==`script`?t.as:void 0,crossOrigin:n,integrity:typeof t.integrity==`string`?t.integrity:void 0,nonce:typeof t.nonce==`string`?t.nonce:void 0,fetchPriority:typeof t.fetchPriority==`string`?t.fetchPriority:void 0})}else i.d.m(e)}},e.requestFormReset=function(e){i.d.r(e)},e.unstable_batchedUpdates=function(e,t){return e(t)},e.useFormState=function(e,t,n){return l.H.useFormState(e,t,n)},e.useFormStatus=function(){return l.H.useHostTransitionStatus()},e.version=`19.3.1`})),te=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=N()})),P=o((e=>{var t=M(),n=A(),r=te();function i(e){var t=`https://react.dev/errors/`+e;if(1<arguments.length){t+=`?args[]=`+encodeURIComponent(arguments[1]);for(var n=2;n<arguments.length;n++)t+=`&args[]=`+encodeURIComponent(arguments[n])}return`Minified React error #`+e+`; visit `+t+` for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`}function a(e){return!(!e||e.nodeType!==1&&e.nodeType!==9&&e.nodeType!==11)}function o(e){for(var t=e,n=t;n&&!n.alternate;)t=n,t.flags&4098&&(e=t.return),n=t.return;for(;t.return;)t=t.return;return t.tag===3?e:null}function s(e){if(e.tag===13){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function c(e){if(e.tag===31){var t=e.memoizedState;if(t===null&&(e=e.alternate,e!==null&&(t=e.memoizedState)),t!==null)return t.dehydrated}return null}function l(e){if(o(e)!==e)throw Error(i(188))}function u(e){var t=e.alternate;if(!t){if(t=o(e),t===null)throw Error(i(188));return t===e?e:null}for(var n=e,r=t;;){var a=n.return;if(a===null)break;var s=a.alternate;if(s===null){if(r=a.return,r!==null){n=r;continue}break}if(a.child===s.child){for(s=a.child;s;){if(s===n)return l(a),e;if(s===r)return l(a),t;s=s.sibling}throw Error(i(188))}if(n.return!==r.return)n=a,r=s;else{for(var c=!1,u=a.child;u;){if(u===n){c=!0,n=a,r=s;break}if(u===r){c=!0,r=a,n=s;break}u=u.sibling}if(!c){for(u=s.child;u;){if(u===n){c=!0,n=s,r=a;break}if(u===r){c=!0,r=s,n=a;break}u=u.sibling}if(!c)throw Error(i(189))}}if(n.alternate!==r)throw Error(i(190))}if(n.tag!==3)throw Error(i(188));return n.stateNode.current===n?e:t}function d(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e;for(e=e.child;e!==null;){if(t=d(e),t!==null)return t;e=e.sibling}return null}function f(e,t,n,r,i,a){for(;e!==null;){if((e.tag===5||e.tag===27||e.tag===6)&&n(e,r,i,a)||(e.tag!==22||e.memoizedState===null)&&(t||e.tag!==5&&e.tag!==27)&&f(e.child,t,n,r,i,a))return!0;e=e.sibling}return!1}function p(e){for(e=e.return;e!==null;){if(e.tag===3||e.tag===5||e.tag===27)return e;e=e.return}return null}function m(e){var t=!1;for(e=e.return;e!==null&&(e.tag===4&&(t=!0),e.tag!==3&&e.tag!==5&&e.tag!==27);)e=e.return;return t}function h(e){var t=[null,null],n=p(e);return n===null||g(t,e,n.child,{foundSelf:!1}),t}function g(e,t,n,r){for(;n!==null;){if(n===t)r.foundSelf=!0;else if(n.tag===5||n.tag===27||n.tag===6){if(r.foundSelf)return e[1]=n,!0;e[0]=n}else if((n.tag!==22||n.memoizedState===null)&&g(e,t,n.child,r))return!0;n=n.sibling}return!1}function _(e){switch(e.tag){case 5:case 27:case 6:return e.stateNode;case 3:return e.stateNode.containerInfo;default:throw Error(i(559))}}var v=null,y=null;function b(e,t,n){return e===n||e===t&&(v=e,!0)}function x(e,t,n){return e===n?(y=e,!1):e===t&&(y!==null&&(v=e),!0)}function S(e){if(e===null)return null;do e=e===null?null:e.return;while(e&&e.tag!==5&&e.tag!==27&&e.tag!==3);return e||null}function C(e,t,n){for(var r=0,i=e;i;i=n(i))r++;i=0;for(var a=t;a;a=n(a))i++;for(;0<r-i;)e=n(e),r--;for(;0<i-r;)t=n(t),i--;for(;r--;){if(e===t||t!==null&&e===t.alternate)return e;e=n(e),t=n(t)}return null}var w=Object.assign,T=Symbol.for(`react.element`),E=Symbol.for(`react.transitional.element`),D=Symbol.for(`react.portal`),O=Symbol.for(`react.fragment`),k=Symbol.for(`react.strict_mode`),ee=Symbol.for(`react.profiler`),j=Symbol.for(`react.consumer`),N=Symbol.for(`react.context`),P=Symbol.for(`react.forward_ref`),F=Symbol.for(`react.suspense`),I=Symbol.for(`react.suspense_list`),ne=Symbol.for(`react.memo`),re=Symbol.for(`react.lazy`),L=Symbol.for(`react.activity`),R=Symbol.for(`react.legacy_hidden`),z=Symbol.for(`react.memo_cache_sentinel`),B=Symbol.for(`react.view_transition`),ie=Symbol.for(`react.recoverable`),ae=Symbol.iterator;function oe(e){return typeof e!=`object`||!e?null:(e=ae&&e[ae]||e[`@@iterator`],typeof e==`function`?e:null)}var se=Symbol.for(`react.client.reference`);function ce(e){if(e==null)return null;if(typeof e==`function`)return e.$$typeof===se?null:e.displayName||e.name||null;if(typeof e==`string`)return e;switch(e){case O:return`Fragment`;case ee:return`Profiler`;case k:return`StrictMode`;case F:return`Suspense`;case I:return`SuspenseList`;case L:return`Activity`;case B:return`ViewTransition`}if(typeof e==`object`)switch(e.$$typeof){case D:return`Portal`;case N:return e.displayName||`Context`;case j:return(e._context.displayName||`Context`)+`.Consumer`;case P:var t=e.render;return e=e.displayName,e||=(e=t.displayName||t.name||``,e===``?`ForwardRef`:`ForwardRef(`+e+`)`),e;case ne:return t=e.displayName||null,t===null?ce(e.type)||`Memo`:t;case re:t=e._payload,e=e._init;try{return ce(e(t))}catch{}}return null}var le=Array.isArray,V=n.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,ue=r.__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,de={pending:!1,data:null,method:null,action:null},fe=[],pe=-1;function me(e){return{current:e}}function he(e){0>pe||(e.current=fe[pe],fe[pe]=null,pe--)}function ge(e,t){pe++,fe[pe]=e.current,e.current=t}var _e=me(null),ve=me(null),ye=me(null),be=me(null);function xe(e,t){switch(ge(ye,t),ge(ve,e),ge(_e,null),t.nodeType){case 9:case 11:e=(e=t.documentElement)&&(e=e.namespaceURI)?xp(e):0;break;default:if(e=t.tagName,t=t.namespaceURI)t=xp(t),e=Sp(t,e);else switch(e){case`svg`:e=1;break;case`math`:e=2;break;default:e=0}}he(_e),ge(_e,e)}function Se(){he(_e),he(ve),he(ye)}function Ce(e){var t=e.memoizedState;t!==null&&(_h._currentValue=t.memoizedState,ge(be,e)),t=_e.current;var n=Sp(t,e.type);t!==n&&(ge(ve,e),ge(_e,n))}function we(e){ve.current===e&&(he(_e),he(ve)),be.current===e&&(he(be),_h._currentValue=de)}var Te,Ee;function De(e){if(Te===void 0)try{throw Error()}catch(e){var t=e.stack.trim().match(/\n( *(at )?)/);Te=t&&t[1]||``,Ee=-1<e.stack.indexOf(`
|
|
2
|
+
at`)?` (<anonymous>)`:-1<e.stack.indexOf(`@`)?`@unknown:0:0`:``}return`
|
|
3
|
+
`+Te+e+Ee}var Oe=!1;function ke(e,t){if(!e||Oe)return``;Oe=!0;var n=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{var r={DetermineComponentFrameRoot:function(){try{if(t){var n=function(){throw Error()};if(Object.defineProperty(n.prototype,"props",{set:function(){throw Error()}}),typeof Reflect==`object`&&Reflect.construct){try{Reflect.construct(n,[])}catch(e){var r=e}Reflect.construct(e,[],n)}else{try{n.call()}catch(e){r=e}n=!1;try{var i=Object.getOwnPropertyDescriptor(e.prototype,`props`);Object.defineProperty(e.prototype,"props",{configurable:!0,set:function(){throw Error()}}),n=!0,new e}finally{n&&(i===void 0?delete e.prototype.props:Object.defineProperty(e.prototype,"props",i))}}}else{try{throw Error()}catch(e){r=e}(n=e())&&typeof n.catch==`function`&&n.catch(function(){})}}catch(e){if(e&&r&&typeof e.stack==`string`)return[e.stack,r.stack]}return[null,null]}};r.DetermineComponentFrameRoot.displayName=`DetermineComponentFrameRoot`;var i=Object.getOwnPropertyDescriptor(r.DetermineComponentFrameRoot,`name`);i&&i.configurable&&Object.defineProperty(r.DetermineComponentFrameRoot,"name",{value:`DetermineComponentFrameRoot`});var a=r.DetermineComponentFrameRoot(),o=a[0],s=a[1];if(o&&s){var c=o.split(`
|
|
4
|
+
`),l=s.split(`
|
|
5
|
+
`);for(i=r=0;r<c.length&&!c[r].includes(`DetermineComponentFrameRoot`);)r++;for(;i<l.length&&!l[i].includes(`DetermineComponentFrameRoot`);)i++;if(r===c.length||i===l.length)for(r=c.length-1,i=l.length-1;1<=r&&0<=i&&c[r]!==l[i];)i--;for(;1<=r&&0<=i;r--,i--)if(c[r]!==l[i]){if(r!==1||i!==1)do if(r--,i--,0>i||c[r]!==l[i]){var u=`
|
|
6
|
+
`+c[r].replace(` at new `,` at `);return e.displayName&&u.includes(`<anonymous>`)&&(u=u.replace(`<anonymous>`,e.displayName)),u}while(1<=r&&0<=i);break}}}finally{Oe=!1,Error.prepareStackTrace=n}return(n=e?e.displayName||e.name:``)?De(n):``}function Ae(e,t){switch(e.tag){case 26:case 27:case 5:return De(e.type);case 16:return De(`Lazy`);case 13:return e.child!==t&&t!==null?De(`Suspense Fallback`):De(`Suspense`);case 19:return De(`SuspenseList`);case 0:case 15:return ke(e.type,!1);case 11:return ke(e.type.render,!1);case 1:return ke(e.type,!0);case 31:return De(`Activity`);case 30:return De(`ViewTransition`);default:return``}}function je(e){try{var t=``,n=null;do t+=Ae(e,n),n=e,e=e.return;while(e);return t}catch(e){return`
|
|
7
|
+
Error generating stack: `+e.message+`
|
|
8
|
+
`+e.stack}}var Me=Object.prototype.hasOwnProperty,Ne=t.unstable_scheduleCallback,Pe=t.unstable_cancelCallback,Fe=t.unstable_shouldYield,Ie=t.unstable_requestPaint,Le=t.unstable_now,Re=t.unstable_getCurrentPriorityLevel,ze=t.unstable_ImmediatePriority,Be=t.unstable_UserBlockingPriority,Ve=t.unstable_NormalPriority,He=t.unstable_LowPriority,Ue=t.unstable_IdlePriority,We=t.log,Ge=t.unstable_setDisableYieldValue,Ke=null,qe=null;function Je(e){if(typeof We==`function`&&Ge(e),qe&&typeof qe.setStrictMode==`function`)try{qe.setStrictMode(Ke,e)}catch{}}var Ye=Math.clz32?Math.clz32:Qe,Xe=Math.log,Ze=Math.LN2;function Qe(e){return e>>>=0,e===0?32:31-(Xe(e)/Ze|0)|0}var $e=256,et=262144,tt=4194304;function nt(e){var t=e&42;if(t!==0)return t;switch(e&-e){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:return 64;case 128:return 128;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:return e&-e;case 262144:case 524288:case 1048576:case 2097152:return e&3932160;case 4194304:case 8388608:case 16777216:case 33554432:return e&62914560;case 67108864:return 67108864;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 0;default:return e}}function rt(e,t,n){var r=e.pendingLanes;if(r===0)return 0;var i=0,a=e.suspendedLanes,o=e.pingedLanes;e=e.warmLanes;var s=r&134217727;return s===0?(s=r&~a,s===0?o===0?n||(n=r&~e,n!==0&&(i=nt(n))):i=nt(o):i=nt(s)):(r=s&~a,r===0?(o&=s,o===0?n||(n=s&~e,n!==0&&(i=nt(n))):i=nt(o)):i=nt(r)),i===0?0:t!==0&&t!==i&&(t&a)===0&&(a=i&-i,n=t&-t,a>=n||a===32&&n&4194048)?t:i}function it(e,t){return(e.pendingLanes&~(e.suspendedLanes&~e.pingedLanes)&t)===0}function at(e,t){t&8&&(t|=t&32);var n=e.entangledLanes;if(n!==0)for(e=e.entanglements,n&=t;0<n;){var r=31-Ye(n),i=1<<r;t|=e[r],n&=~i}return t}function ot(e,t){switch(e){case 1:case 2:case 4:case 8:case 64:return t+250;case 16:case 32:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return t+5e3;case 4194304:case 8388608:case 16777216:case 33554432:return-1;case 67108864:case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function st(){var e=tt;return tt<<=1,!(tt&62914560)&&(tt=4194304),e}function ct(e){for(var t=[],n=0;31>n;n++)t.push(e);return t}function lt(e,t){e.pendingLanes|=t,t!==268435456&&(e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0)}function ut(e,t,n,r,i,a){var o=e.pendingLanes;e.pendingLanes=n,e.suspendedLanes=0,e.pingedLanes=0,e.warmLanes=0,e.expiredLanes&=n,e.entangledLanes&=n,e.errorRecoveryDisabledLanes&=n,e.shellSuspendCounter=0;var s=e.entanglements,c=e.expirationTimes,l=e.hiddenUpdates;for(n=o&~n;0<n;){var u=31-Ye(n),d=1<<u;s[u]=0,c[u]=-1;var f=l[u];if(f!==null)for(l[u]=null,u=0;u<f.length;u++){var p=f[u];p!==null&&(p.lane&=-536870913)}n&=~d}r!==0&&dt(e,r,0),a!==0&&i===0&&e.tag!==0&&(e.suspendedLanes|=a&~(o&~t))}function dt(e,t,n){e.pendingLanes|=t,e.suspendedLanes&=~t;var r=31-Ye(t);e.entangledLanes|=t,e.entanglements[r]=e.entanglements[r]|1073741824|n&261930}function ft(e,t){var n=e.entangledLanes|=t;for(e=e.entanglements;n;){var r=31-Ye(n),i=1<<r;i&t|e[r]&t&&(e[r]|=t),n&=~i}}function pt(e,t){var n=t&-t;return n=n&42?1:mt(n),(n&(e.suspendedLanes|t))===0?n:0}function mt(e){switch(e){case 2:e=1;break;case 8:e=4;break;case 32:e=16;break;case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:e=128;break;case 268435456:e=134217728;break;default:e=0}return e}function ht(e){return e&=-e,2<e?8<e?e&134217727?32:268435456:8:2}function gt(){var e=ue.p;return e===0?(e=window.event,e===void 0?32:Nh(e.type)):e}function _t(e,t){var n=ue.p;try{return ue.p=e,t()}finally{ue.p=n}}var vt=Math.random().toString(36).slice(2),yt=`__reactFiber$`+vt,bt=`__reactProps$`+vt,xt=`__reactContainer$`+vt,St=`__reactEvents$`+vt,Ct=`__reactListeners$`+vt,wt=`__reactHandles$`+vt,Tt=`__reactResources$`+vt,Et=`__reactMarker$`+vt,Dt=`__reactLoad$`+vt;function Ot(e){delete e[yt],delete e[bt],delete e[Ct],delete e[wt]}function kt(e){var t;if(t=e[yt])return t;for(var n=e.parentNode;n;){if(t=n[xt]||n[yt]){if(n=t.alternate,t.child!==null||n!==null&&n.child!==null)for(e=Cm(e);e!==null;){if(n=e[yt])return n;e=Cm(e)}return t}e=n,n=e.parentNode}return null}function At(e){if(e=e[yt]||e[xt]){var t=e.tag;if(t===5||t===6||t===13||t===31||t===26||t===27||t===3)return e}return null}function jt(e){var t=e.tag;if(t===5||t===26||t===27||t===6)return e.stateNode;throw Error(i(33))}function Mt(e){var t=e[Tt];return t||=e[Tt]={hoistableStyles:new Map,hoistableScripts:new Map},t}function Nt(e){e[Et]=!0}function Pt(e){e[Dt]=void 0}var Ft=new Set,It={};function Lt(e,t){Rt(e,t),Rt(e+`Capture`,t)}function Rt(e,t){for(It[e]=t,e=0;e<t.length;e++)Ft.add(t[e])}var zt=RegExp(`^[:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][:A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD\\-.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*$`),Bt={},Vt={};function Ht(e){return Me.call(Vt,e)?!0:Me.call(Bt,e)?!1:zt.test(e)?Vt[e]=!0:(Bt[e]=!0,!1)}var Ut=!1;function Wt(){var e=Ut;return Ut=!1,e}function Gt(e,t,n){if(Ht(t)){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:e.removeAttribute(t);return;case`boolean`:var r=t.toLowerCase().slice(0,5);if(r!==`data-`&&r!==`aria-`){e.removeAttribute(t);return}}e.setAttribute(t,n)}}}function Kt(e,t,n){if(n===null)e.removeAttribute(t);else{switch(typeof n){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(t);return}e.setAttribute(t,n)}}function qt(e,t,n,r){if(r===null)e.removeAttribute(n);else{switch(typeof r){case`undefined`:case`function`:case`symbol`:case`boolean`:e.removeAttribute(n);return}e.setAttributeNS(t,n,r)}}function Jt(e){switch(typeof e){case`bigint`:case`boolean`:case`number`:case`string`:case`undefined`:return e;case`object`:return e;default:return``}}function Yt(e){var t=e.type;return(e=e.nodeName)&&e.toLowerCase()===`input`&&(t===`checkbox`||t===`radio`)}function Xt(e,t,n){var r=Object.getOwnPropertyDescriptor(e.constructor.prototype,t);if(!e.hasOwnProperty(t)&&r!==void 0&&typeof r.get==`function`&&typeof r.set==`function`){var i=r.get,a=r.set;return Object.defineProperty(e,t,{configurable:!0,get:function(){return i.call(this)},set:function(e){n=``+e,a.call(this,e)}}),Object.defineProperty(e,t,{enumerable:r.enumerable}),{getValue:function(){return n},setValue:function(e){n=``+e},stopTracking:function(){e._valueTracker=null,delete e[t]}}}}function Zt(e){if(!e._valueTracker){var t=Yt(e)?`checked`:`value`;e._valueTracker=Xt(e,t,``+e[t])}}function Qt(e){if(!e)return!1;var t=e._valueTracker;if(!t)return!0;var n=t.getValue(),r=``;return e&&(r=Yt(e)?e.checked?`true`:`false`:e.value),e=r,e!==n&&(t.setValue(e),!0)}var $t=/[\n"\\]/g;function en(e){return e.replace($t,function(e){return`\\`+e.charCodeAt(0).toString(16)+` `})}function tn(e,t,n,r,i,a,o,s){e.name=``,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`?e.type=o:e.removeAttribute(`type`),t==null?o!==`submit`&&o!==`reset`||e.removeAttribute(`value`):o===`number`?(t===0&&e.value===``||e.value!=t)&&(e.value=``+Jt(t)):e.value!==``+Jt(t)&&(e.value=``+Jt(t)),t==null?n==null?r!=null&&e.removeAttribute(`value`):rn(e,Jt(n)):o===`number`&&e.value==t?rn(e,Jt(e.value)):rn(e,Jt(t)),i==null&&a!=null&&(e.defaultChecked=!!a),i!=null&&(e.checked=i&&typeof i!=`function`&&typeof i!=`symbol`),s!=null&&typeof s!=`function`&&typeof s!=`symbol`&&typeof s!=`boolean`?e.name=``+Jt(s):e.removeAttribute(`name`)}function nn(e,t,n,r,i,a,o,s){if(a!=null&&typeof a!=`function`&&typeof a!=`symbol`&&typeof a!=`boolean`&&(e.type=a),t!=null||n!=null){if(!(a!==`submit`&&a!==`reset`||t!=null)){Zt(e);return}n=n==null?``:``+Jt(n),t=t==null?n:``+Jt(t),s||t===e.value||(e.value=t),e.defaultValue=t}r??=i,r=typeof r!=`function`&&typeof r!=`symbol`&&!!r,e.checked=s?e.checked:!!r,e.defaultChecked=!!r,o!=null&&typeof o!=`function`&&typeof o!=`symbol`&&typeof o!=`boolean`&&(e.name=o),Zt(e)}function rn(e,t){e.defaultValue!==``+t&&(e.defaultValue=``+t)}function an(e,t,n,r){if(e=e.options,t){t={};for(var i=0;i<n.length;i++)t[`$`+n[i]]=!0;for(n=0;n<e.length;n++)i=t.hasOwnProperty(`$`+e[n].value),e[n].selected!==i&&(e[n].selected=i),i&&r&&(e[n].defaultSelected=!0)}else{for(n=``+Jt(n),t=null,i=0;i<e.length;i++){if(e[i].value===n){e[i].selected=!0,r&&(e[i].defaultSelected=!0);return}t!==null||e[i].disabled||(t=e[i])}t!==null&&(t.selected=!0)}}function on(e,t,n){t!=null&&(t=``+Jt(t),t!==e.value&&(e.value=t),n==null)?e.defaultValue!==t&&(e.defaultValue=t):e.defaultValue=n==null?``:``+Jt(n)}function sn(e,t,n,r){if(t==null){if(r!=null){if(n!=null)throw Error(i(92));if(le(r)){if(1<r.length)throw Error(i(93));r=r[0]}n=r}n??=``,t=n}n=Jt(t),e.defaultValue=n,r=e.textContent,r===n&&r!==``&&r!==null&&(e.value=r),Zt(e)}function cn(e,t){if(t){var n=e.firstChild;if(n&&n===e.lastChild&&n.nodeType===3){n.nodeValue=t;return}}e.textContent=t}var ln=new Set(`animationIterationCount aspectRatio borderImageOutset borderImageSlice borderImageWidth boxFlex boxFlexGroup boxOrdinalGroup columnCount columns flex flexGrow flexPositive flexShrink flexNegative flexOrder gridArea gridRow gridRowEnd gridRowSpan gridRowStart gridColumn gridColumnEnd gridColumnSpan gridColumnStart fontWeight lineClamp lineHeight opacity order orphans scale tabSize widows zIndex zoom fillOpacity floodOpacity stopOpacity strokeDasharray strokeDashoffset strokeMiterlimit strokeOpacity strokeWidth MozAnimationIterationCount MozBoxFlex MozBoxFlexGroup MozLineClamp msAnimationIterationCount msFlex msZoom msFlexGrow msFlexNegative msFlexOrder msFlexPositive msFlexShrink msGridColumn msGridColumnSpan msGridRow msGridRowSpan WebkitAnimationIterationCount WebkitBoxFlex WebKitBoxFlexGroup WebkitBoxOrdinalGroup WebkitColumnCount WebkitColumns WebkitFlex WebkitFlexGrow WebkitFlexPositive WebkitFlexShrink WebkitLineClamp`.split(` `));function un(e,t,n){var r=t.indexOf(`--`)===0;n==null||typeof n==`boolean`||n===``?r?e.setProperty(t,``):t===`float`?e.cssFloat=``:e[t]=``:r?e.setProperty(t,n):typeof n!=`number`||n===0||ln.has(t)?t===`float`?e.cssFloat=n:e[t]=(``+n).trim():e[t]=n+`px`}function dn(e,t,n){if(t!=null&&typeof t!=`object`)throw Error(i(62));if(e=e.style,n!=null){for(var r in n)!n.hasOwnProperty(r)||t!=null&&t.hasOwnProperty(r)||(r.indexOf(`--`)===0?e.setProperty(r,``):r===`float`?e.cssFloat=``:e[r]=``,Ut=!0);for(var a in t)r=t[a],t.hasOwnProperty(a)&&n[a]!==r&&(un(e,a,r),Ut=!0)}else for(var o in t)t.hasOwnProperty(o)&&un(e,o,t[o])}function fn(e){if(e.indexOf(`-`)===-1)return!1;switch(e){case`annotation-xml`:case`color-profile`:case`font-face`:case`font-face-src`:case`font-face-uri`:case`font-face-format`:case`font-face-name`:case`missing-glyph`:return!1;default:return!0}}var pn=new Map([[`acceptCharset`,`accept-charset`],[`htmlFor`,`for`],[`httpEquiv`,`http-equiv`],[`crossOrigin`,`crossorigin`],[`accentHeight`,`accent-height`],[`alignmentBaseline`,`alignment-baseline`],[`arabicForm`,`arabic-form`],[`baselineShift`,`baseline-shift`],[`capHeight`,`cap-height`],[`clipPath`,`clip-path`],[`clipRule`,`clip-rule`],[`colorInterpolation`,`color-interpolation`],[`colorInterpolationFilters`,`color-interpolation-filters`],[`colorProfile`,`color-profile`],[`colorRendering`,`color-rendering`],[`dominantBaseline`,`dominant-baseline`],[`enableBackground`,`enable-background`],[`fillOpacity`,`fill-opacity`],[`fillRule`,`fill-rule`],[`floodColor`,`flood-color`],[`floodOpacity`,`flood-opacity`],[`fontFamily`,`font-family`],[`fontSize`,`font-size`],[`fontSizeAdjust`,`font-size-adjust`],[`fontStretch`,`font-stretch`],[`fontStyle`,`font-style`],[`fontVariant`,`font-variant`],[`fontWeight`,`font-weight`],[`glyphName`,`glyph-name`],[`glyphOrientationHorizontal`,`glyph-orientation-horizontal`],[`glyphOrientationVertical`,`glyph-orientation-vertical`],[`horizAdvX`,`horiz-adv-x`],[`horizOriginX`,`horiz-origin-x`],[`imageRendering`,`image-rendering`],[`letterSpacing`,`letter-spacing`],[`lightingColor`,`lighting-color`],[`markerEnd`,`marker-end`],[`markerMid`,`marker-mid`],[`markerStart`,`marker-start`],[`maskType`,`mask-type`],[`overlinePosition`,`overline-position`],[`overlineThickness`,`overline-thickness`],[`paintOrder`,`paint-order`],[`panose-1`,`panose-1`],[`pointerEvents`,`pointer-events`],[`renderingIntent`,`rendering-intent`],[`shapeRendering`,`shape-rendering`],[`stopColor`,`stop-color`],[`stopOpacity`,`stop-opacity`],[`strikethroughPosition`,`strikethrough-position`],[`strikethroughThickness`,`strikethrough-thickness`],[`strokeDasharray`,`stroke-dasharray`],[`strokeDashoffset`,`stroke-dashoffset`],[`strokeLinecap`,`stroke-linecap`],[`strokeLinejoin`,`stroke-linejoin`],[`strokeMiterlimit`,`stroke-miterlimit`],[`strokeOpacity`,`stroke-opacity`],[`strokeWidth`,`stroke-width`],[`textAnchor`,`text-anchor`],[`textDecoration`,`text-decoration`],[`textRendering`,`text-rendering`],[`transformOrigin`,`transform-origin`],[`underlinePosition`,`underline-position`],[`underlineThickness`,`underline-thickness`],[`unicodeBidi`,`unicode-bidi`],[`unicodeRange`,`unicode-range`],[`unitsPerEm`,`units-per-em`],[`vAlphabetic`,`v-alphabetic`],[`vHanging`,`v-hanging`],[`vIdeographic`,`v-ideographic`],[`vMathematical`,`v-mathematical`],[`vectorEffect`,`vector-effect`],[`vertAdvY`,`vert-adv-y`],[`vertOriginX`,`vert-origin-x`],[`vertOriginY`,`vert-origin-y`],[`wordSpacing`,`word-spacing`],[`writingMode`,`writing-mode`],[`xmlnsXlink`,`xmlns:xlink`],[`xHeight`,`x-height`]]),mn=/^[\u0000-\u001F ]*j[\r\n\t]*a[\r\n\t]*v[\r\n\t]*a[\r\n\t]*s[\r\n\t]*c[\r\n\t]*r[\r\n\t]*i[\r\n\t]*p[\r\n\t]*t[\r\n\t]*:/i;function hn(e){return mn.test(``+e)?`javascript:throw new Error('React has blocked a javascript: URL as a security precaution.')`:e}function gn(){}var _n=null;function vn(e){return e=e.target||e.srcElement||window,e.correspondingUseElement&&(e=e.correspondingUseElement),e.nodeType===3?e.parentNode:e}var yn=null,bn=null;function xn(e){var t=At(e);if(t&&(e=t.stateNode)){var n=e[bt]||null;a:switch(e=t.stateNode,t.type){case`input`:if(tn(e,n.value,n.defaultValue,n.defaultValue,n.checked,n.defaultChecked,n.type,n.name),t=n.name,n.type===`radio`&&t!=null){for(n=e;n.parentNode;)n=n.parentNode;for(n=n.querySelectorAll(`input[name="`+en(``+t)+`"][type="radio"]`),t=0;t<n.length;t++){var r=n[t];if(r!==e&&r.form===e.form){var a=r[bt]||null;if(!a)throw Error(i(90));tn(r,a.value,a.defaultValue,a.defaultValue,a.checked,a.defaultChecked,a.type,a.name)}}for(t=0;t<n.length;t++)r=n[t],r.form===e.form&&Qt(r)}break a;case`textarea`:on(e,n.value,n.defaultValue);break a;case`select`:t=n.value,t!=null&&an(e,!!n.multiple,t,!1)}}}var Sn=!1;function Cn(e,t,n){if(Sn)return e(t,n);Sn=!0;try{return e(t)}finally{if(Sn=!1,(yn!==null||bn!==null)&&(qd(),yn&&(t=yn,e=bn,bn=yn=null,xn(t),e)))for(t=0;t<e.length;t++)xn(e[t])}}function wn(e,t){var n=e.stateNode;if(n===null)return null;var r=n[bt]||null;if(r===null)return null;n=r[t];a:switch(t){case`onClick`:case`onClickCapture`:case`onDoubleClick`:case`onDoubleClickCapture`:case`onMouseDown`:case`onMouseDownCapture`:case`onMouseMove`:case`onMouseMoveCapture`:case`onMouseUp`:case`onMouseUpCapture`:case`onMouseEnter`:(r=!r.disabled)||(e=e.type,r=e!==`button`&&e!==`input`&&e!==`select`&&e!==`textarea`),e=!r;break a;default:e=!1}if(e)return null;if(n&&typeof n!=`function`)throw Error(i(231,t,typeof n));return n}var Tn=typeof window<`u`&&window.document!==void 0&&window.document.createElement!==void 0,En=!1;if(Tn)try{var Dn={};Object.defineProperty(Dn,"passive",{get:function(){En=!0}}),window.addEventListener(`test`,Dn,Dn),window.removeEventListener(`test`,Dn,Dn)}catch{En=!1}var On=null,kn=null,An=null;function jn(){if(An)return An;var e,t=kn,n=t.length,r,i=`value`in On?On.value:On.textContent,a=i.length;for(e=0;e<n&&t[e]===i[e];e++);var o=n-e;for(r=1;r<=o&&t[n-r]===i[a-r];r++);return An=i.slice(e,1<r?1-r:void 0)}function Mn(e){var t=e.keyCode;return`charCode`in e?(e=e.charCode,e===0&&t===13&&(e=13)):e=t,e===10&&(e=13),32<=e||e===13?e:0}function Nn(){return!0}function Pn(){return!1}function Fn(e){function t(t,n,r,i,a){for(var o in this._reactName=t,this._targetInst=r,this.type=n,this.nativeEvent=i,this.target=a,this.currentTarget=null,e)e.hasOwnProperty(o)&&(t=e[o],this[o]=t?t(i):i[o]);return this.isDefaultPrevented=(i.defaultPrevented==null?!1===i.returnValue:i.defaultPrevented)?Nn:Pn,this.isPropagationStopped=Pn,this}return w(t.prototype,{preventDefault:function(){this.defaultPrevented=!0;var e=this.nativeEvent;e&&(e.preventDefault?e.preventDefault():typeof e.returnValue!=`unknown`&&(e.returnValue=!1),this.isDefaultPrevented=Nn)},stopPropagation:function(){var e=this.nativeEvent;e&&(e.stopPropagation?e.stopPropagation():typeof e.cancelBubble!=`unknown`&&(e.cancelBubble=!0),this.isPropagationStopped=Nn)},persist:function(){},isPersistent:Nn}),t}var In={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(e){return e.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ln=Fn(In),Rn=w({},In,{view:0,detail:0}),zn=Fn(Rn),Bn,Vn,Hn,Un=w({},Rn,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:er,button:0,buttons:0,relatedTarget:function(e){return e.relatedTarget===void 0?e.fromElement===e.srcElement?e.toElement:e.fromElement:e.relatedTarget},movementX:function(e){return`movementX`in e?e.movementX:(e!==Hn&&(Hn&&e.type===`mousemove`?(Bn=e.screenX-Hn.screenX,Vn=e.screenY-Hn.screenY):Vn=Bn=0,Hn=e),Bn)},movementY:function(e){return`movementY`in e?e.movementY:Vn}}),Wn=Fn(Un),Gn=Fn(w({},Un,{dataTransfer:0})),Kn=Fn(w({},Rn,{relatedTarget:0})),qn=Fn(w({},In,{animationName:0,elapsedTime:0,pseudoElement:0})),Jn=Fn(w({},In,{clipboardData:function(e){return`clipboardData`in e?e.clipboardData:window.clipboardData}})),Yn=Fn(w({},In,{data:0})),Xn={Esc:`Escape`,Spacebar:` `,Left:`ArrowLeft`,Up:`ArrowUp`,Right:`ArrowRight`,Down:`ArrowDown`,Del:`Delete`,Win:`OS`,Menu:`ContextMenu`,Apps:`ContextMenu`,Scroll:`ScrollLock`,MozPrintableKey:`Unidentified`},Zn={8:`Backspace`,9:`Tab`,12:`Clear`,13:`Enter`,16:`Shift`,17:`Control`,18:`Alt`,19:`Pause`,20:`CapsLock`,27:`Escape`,32:` `,33:`PageUp`,34:`PageDown`,35:`End`,36:`Home`,37:`ArrowLeft`,38:`ArrowUp`,39:`ArrowRight`,40:`ArrowDown`,45:`Insert`,46:`Delete`,112:`F1`,113:`F2`,114:`F3`,115:`F4`,116:`F5`,117:`F6`,118:`F7`,119:`F8`,120:`F9`,121:`F10`,122:`F11`,123:`F12`,144:`NumLock`,145:`ScrollLock`,224:`Meta`},Qn={Alt:`altKey`,Control:`ctrlKey`,Meta:`metaKey`,Shift:`shiftKey`};function $n(e){var t=this.nativeEvent;return t.getModifierState?t.getModifierState(e):(e=Qn[e])?!!t[e]:!1}function er(){return $n}var tr=Fn(w({},Rn,{key:function(e){if(e.key){var t=Xn[e.key]||e.key;if(t!==`Unidentified`)return t}return e.type===`keypress`?(e=Mn(e),e===13?`Enter`:String.fromCharCode(e)):e.type===`keydown`||e.type===`keyup`?Zn[e.keyCode]||`Unidentified`:``},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:er,charCode:function(e){return e.type===`keypress`?Mn(e):0},keyCode:function(e){return e.type===`keydown`||e.type===`keyup`?e.keyCode:0},which:function(e){return e.type===`keypress`?Mn(e):e.type===`keydown`||e.type===`keyup`?e.keyCode:0}})),nr=Fn(w({},Un,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0})),rr=Fn(w({},In,{submitter:0})),ir=Fn(w({},Rn,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:er})),ar=Fn(w({},In,{propertyName:0,elapsedTime:0,pseudoElement:0})),or=Fn(w({},Un,{deltaX:function(e){return`deltaX`in e?e.deltaX:`wheelDeltaX`in e?-e.wheelDeltaX:0},deltaY:function(e){return`deltaY`in e?e.deltaY:`wheelDeltaY`in e?-e.wheelDeltaY:`wheelDelta`in e?-e.wheelDelta:0},deltaZ:0,deltaMode:0})),sr=Fn(w({},In,{newState:0,oldState:0,source:0})),cr=[9,13,27,32],lr=Tn&&`CompositionEvent`in window,ur=null;Tn&&`documentMode`in document&&(ur=document.documentMode);var dr=Tn&&`TextEvent`in window&&!ur,fr=Tn&&(!lr||ur&&8<ur&&11>=ur),pr=` `,mr=!1;function hr(e,t){switch(e){case`keyup`:return cr.indexOf(t.keyCode)!==-1;case`keydown`:return t.keyCode!==229;case`keypress`:case`mousedown`:case`focusout`:return!0;default:return!1}}function gr(e){return e=e.detail,typeof e==`object`&&`data`in e?e.data:null}var _r=!1;function vr(e,t){switch(e){case`compositionend`:return gr(t);case`keypress`:return t.which===32?(mr=!0,pr):null;case`textInput`:return e=t.data,e===pr&&mr?null:e;default:return null}}function yr(e,t){if(_r)return e===`compositionend`||!lr&&hr(e,t)?(e=jn(),An=kn=On=null,_r=!1,e):null;switch(e){case`paste`:return null;case`keypress`:if(!(t.ctrlKey||t.altKey||t.metaKey)||t.ctrlKey&&t.altKey){if(t.char&&1<t.char.length)return t.char;if(t.which)return String.fromCharCode(t.which)}return null;case`compositionend`:return fr&&t.locale!==`ko`?null:t.data;default:return null}}var br={color:!0,date:!0,datetime:!0,"datetime-local":!0,email:!0,month:!0,number:!0,password:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0};function xr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t===`input`?!!br[e.type]:t===`textarea`}function Sr(e,t,n,r){yn?bn?bn.push(r):bn=[r]:yn=r,t=ip(t,`onChange`),0<t.length&&(n=new Ln(`onChange`,`change`,null,n,r),e.push({event:n,listeners:t}))}var Cr=null,wr=null;function Tr(e){Xf(e,0)}function Er(e){if(Qt(jt(e)))return e}function Dr(e,t){if(e===`change`)return t}var Or=!1;if(Tn){var kr;if(Tn){var Ar=`oninput`in document;if(!Ar){var jr=document.createElement(`div`);jr.setAttribute(`oninput`,`return;`),Ar=typeof jr.oninput==`function`}kr=Ar}else kr=!1;Or=kr&&(!document.documentMode||9<document.documentMode)}function Mr(){Cr&&(Cr.detachEvent(`onpropertychange`,Nr),wr=Cr=null)}function Nr(e){if(e.propertyName===`value`&&Er(wr)){var t=[];Sr(t,wr,e,vn(e)),Cn(Tr,t)}}function Pr(e,t,n){e===`focusin`?(Mr(),Cr=t,wr=n,Cr.attachEvent(`onpropertychange`,Nr)):e===`focusout`&&Mr()}function Fr(e){if(e===`selectionchange`||e===`keyup`||e===`keydown`)return Er(wr)}function Ir(e,t){if(e===`click`)return Er(t)}function Lr(e,t){if(e===`input`||e===`change`)return Er(t)}function Rr(e,t){return e===t&&(e!==0||1/e==1/t)||e!==e&&t!==t}var zr=typeof Object.is==`function`?Object.is:Rr;function Br(e,t){if(zr(e,t))return!0;if(typeof e!=`object`||!e||typeof t!=`object`||!t)return!1;var n=Object.keys(e),r=Object.keys(t);if(n.length!==r.length)return!1;for(r=0;r<n.length;r++){var i=n[r];if(!Me.call(t,i)||!zr(e[i],t[i]))return!1}return!0}function Vr(e){if(e||=typeof document<`u`?document:void 0,e===void 0)return null;try{return e.activeElement||e.body}catch{return e.body}}function Hr(e){for(;e&&e.firstChild;)e=e.firstChild;return e}function Ur(e,t){var n=Hr(e);e=0;for(var r;n;){if(n.nodeType===3){if(r=e+n.textContent.length,e<=t&&r>=t)return{node:n,offset:t-e};e=r}a:{for(;n;){if(n.nextSibling){n=n.nextSibling;break a}n=n.parentNode}n=void 0}n=Hr(n)}}function Wr(e,t){return e&&t?e===t?!0:e&&e.nodeType===3?!1:t&&t.nodeType===3?Wr(e,t.parentNode):`contains`in e?e.contains(t):e.compareDocumentPosition?!!(e.compareDocumentPosition(t)&16):!1:!1}function Gr(e){e=e!=null&&e.ownerDocument!=null&&e.ownerDocument.defaultView!=null?e.ownerDocument.defaultView:window;for(var t=Vr(e.document);t instanceof e.HTMLIFrameElement;){try{var n=typeof t.contentWindow.location.href==`string`}catch{n=!1}if(n)e=t.contentWindow;else break;t=Vr(e.document)}return t}function Kr(e){var t=e&&e.nodeName&&e.nodeName.toLowerCase();return t&&(t===`input`&&(e.type===`text`||e.type===`search`||e.type===`tel`||e.type===`url`||e.type===`password`)||t===`textarea`||e.contentEditable===`true`)}var qr=Tn&&`documentMode`in document&&11>=document.documentMode,Jr=null,Yr=null,Xr=null,Zr=!1;function Qr(e,t,n){var r=n.window===n?n.document:n.nodeType===9?n:n.ownerDocument;Zr||Jr==null||Jr!==Vr(r)||(r=Jr,`selectionStart`in r&&Kr(r)?r={start:r.selectionStart,end:r.selectionEnd}:(r=(r.ownerDocument&&r.ownerDocument.defaultView||window).getSelection(),r={anchorNode:r.anchorNode,anchorOffset:r.anchorOffset,focusNode:r.focusNode,focusOffset:r.focusOffset}),Xr&&Br(Xr,r)||(Xr=r,r=ip(Yr,`onSelect`),0<r.length&&(t=new Ln(`onSelect`,`select`,null,t,n),e.push({event:t,listeners:r}),t.target=Jr)))}function $r(e,t){var n={};return n[e.toLowerCase()]=t.toLowerCase(),n[`Webkit`+e]=`webkit`+t,n[`Moz`+e]=`moz`+t,n}var ei={animationend:$r(`Animation`,`AnimationEnd`),animationiteration:$r(`Animation`,`AnimationIteration`),animationstart:$r(`Animation`,`AnimationStart`),transitionrun:$r(`Transition`,`TransitionRun`),transitionstart:$r(`Transition`,`TransitionStart`),transitioncancel:$r(`Transition`,`TransitionCancel`),transitionend:$r(`Transition`,`TransitionEnd`)},ti={},ni={};Tn&&(ni=document.createElement(`div`).style,`AnimationEvent`in window||(delete ei.animationend.animation,delete ei.animationiteration.animation,delete ei.animationstart.animation),`TransitionEvent`in window||delete ei.transitionend.transition);function ri(e){if(ti[e])return ti[e];if(!ei[e])return e;var t=ei[e],n;for(n in t)if(t.hasOwnProperty(n)&&n in ni)return ti[e]=t[n];return e}var ii=ri(`animationend`),ai=ri(`animationiteration`),oi=ri(`animationstart`),si=ri(`transitionrun`),ci=ri(`transitionstart`),li=ri(`transitioncancel`),ui=ri(`transitionend`),di=new Map,fi=`abort auxClick beforeToggle cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error fullscreenChange fullscreenError gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel`.split(` `);fi.push(`scrollEnd`);function pi(e,t){di.set(e,t),Lt(t,[e])}var mi=0;function hi(e,t){if(e.name!=null&&e.name!==`auto`)return e.name;if(t.autoName!==null)return t.autoName;e=Od.identifierPrefix;var n=mi++;return e=`_`+e+`t_`+n.toString(32)+`_`,t.autoName=e}function gi(e){if(e==null||typeof e==`string`)return e;var t=null,n=Id;if(n!==null)for(var r=0;r<n.length;r++){var i=e[n[r]];if(i!=null){if(i===`none`)return`none`;t=t==null?i:t+(` `+i)}}return t??e.default}function _i(e,t){return e=gi(e),t=gi(t),t==null?e===`auto`?null:e:t===`auto`?null:t}var vi=typeof reportError==`function`?reportError:function(e){if(typeof window==`object`&&typeof window.ErrorEvent==`function`){var t=new window.ErrorEvent(`error`,{bubbles:!0,cancelable:!0,message:typeof e==`object`&&e&&typeof e.message==`string`?String(e.message):String(e),error:e});if(!window.dispatchEvent(t))return}else if(typeof process==`object`&&typeof process.emit==`function`){process.emit(`uncaughtException`,e);return}console.error(e)},yi=[],bi=0,xi=0;function Si(){for(var e=bi,t=xi=bi=0;t<e;){var n=yi[t];yi[t++]=null;var r=yi[t];yi[t++]=null;var i=yi[t];yi[t++]=null;var a=yi[t];if(yi[t++]=null,r!==null&&i!==null){var o=r.pending;o===null?i.next=i:(i.next=o.next,o.next=i),r.pending=i}a!==0&&Ei(n,i,a)}}function Ci(e,t,n,r){yi[bi++]=e,yi[bi++]=t,yi[bi++]=n,yi[bi++]=r,xi|=r,e.lanes|=r,e=e.alternate,e!==null&&(e.lanes|=r)}function wi(e,t,n,r){return Ci(e,t,n,r),Di(e)}function Ti(e,t){return Ci(e,null,null,t),Di(e)}function Ei(e,t,n){e.lanes|=n;var r=e.alternate;r!==null&&(r.lanes|=n);for(var i=!1,a=e.return;a!==null;)a.childLanes|=n,r=a.alternate,r!==null&&(r.childLanes|=n),a.tag===22&&(e=a.stateNode,e===null||e._visibility&1||(i=!0)),e=a,a=a.return;return e.tag===3?(a=e.stateNode,i&&t!==null&&(i=31-Ye(n),e=a.hiddenUpdates,r=e[i],r===null?e[i]=[t]:r.push(t),t.lane=n|536870912),a):null}function Di(e){if(50<Ld)throw Ld=0,Rd=null,Error(i(185));for(var t=e.return;t!==null;)e=t,t=e.return;return e.tag===3?e.stateNode:null}var Oi={};function ki(e,t,n,r){this.tag=e,this.key=n,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.refCleanup=this.ref=null,this.pendingProps=t,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=r,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Ai(e,t,n,r){return new ki(e,t,n,r)}function ji(e){return e=e.prototype,!(!e||!e.isReactComponent)}function Mi(e,t){var n=e.alternate;return n===null?(n=Ai(e.tag,t,e.key,e.mode),n.elementType=e.elementType,n.type=e.type,n.stateNode=e.stateNode,n.alternate=e,e.alternate=n):(n.pendingProps=t,n.type=e.type,n.flags=0,n.subtreeFlags=0,n.deletions=null),n.flags=e.flags&1206910976,n.childLanes=e.childLanes,n.lanes=e.lanes,n.child=e.child,n.memoizedProps=e.memoizedProps,n.memoizedState=e.memoizedState,n.updateQueue=e.updateQueue,t=e.dependencies,n.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext},n.sibling=e.sibling,n.index=e.index,n.ref=e.ref,n.refCleanup=e.refCleanup,n}function Ni(e,t){e.flags&=1206910978;var n=e.alternate;return n===null?(e.childLanes=0,e.lanes=t,e.child=null,e.subtreeFlags=0,e.memoizedProps=null,e.memoizedState=null,e.updateQueue=null,e.dependencies=null,e.stateNode=null):(e.childLanes=n.childLanes,e.lanes=n.lanes,e.child=n.child,e.subtreeFlags=0,e.deletions=null,e.memoizedProps=n.memoizedProps,e.memoizedState=n.memoizedState,e.updateQueue=n.updateQueue,e.type=n.type,t=n.dependencies,e.dependencies=t===null?null:{lanes:t.lanes,firstContext:t.firstContext}),e}function Pi(e,t,n,r,a,o){var s=0;if(r=e,typeof r==`function`)ji(r)&&(s=1);else if(typeof r==`string`)s=rh(e,n,_e.current)?26:e===`html`||e===`head`||e===`body`?27:5;else a:switch(r){case L:return e=Ai(31,n,t,a),e.elementType=L,e.lanes=o,e;case O:return Fi(n.children,a,o,t);case k:s=8,a|=24;break;case ee:return e=Ai(12,n,t,a|2),e.elementType=ee,e.lanes=o,e;case F:return e=Ai(13,n,t,a),e.elementType=F,e.lanes=o,e;case I:return e=Ai(19,n,t,a),e.elementType=I,e.lanes=o,e;case R:case B:return e=a|32,e=Ai(30,n,t,e),e.elementType=B,e.lanes=o,e.stateNode={autoName:null,paired:null,clones:null,ref:null},e;default:if(typeof r==`object`&&r)switch(r.$$typeof){case N:s=10;break a;case j:s=9;break a;case P:s=11;break a;case ne:s=14;break a;case re:s=16,r=null;break a}s=29,n=Error(i(130,e===null?`null`:typeof e,``)),r=null}return t=Ai(s,n,t,a),t.elementType=e,t.type=r,t.lanes=o,t}function Fi(e,t,n,r){return e=Ai(7,e,r,t),e.lanes=n,e}function Ii(e,t,n){return e=Ai(6,e,null,t),e.lanes=n,e}function Li(e){var t=Ai(18,null,null,0);return t.stateNode=e,t}function Ri(e,t,n){return t=Ai(4,e.children===null?[]:e.children,e.key,t),t.lanes=n,t.stateNode={containerInfo:e.containerInfo,pendingChildren:null,implementation:e.implementation},t}var zi=new WeakMap;function Bi(e,t){if(typeof e==`object`&&e){var n=zi.get(e);return n===void 0?(t={value:e,source:t,stack:je(t)},zi.set(e,t),t):n}return{value:e,source:t,stack:je(t)}}var Vi=[],Hi=0,Ui=null,Wi=0,Gi=[],Ki=0,qi=null,Ji=1,Yi=``;function Xi(e,t){Vi[Hi++]=Wi,Vi[Hi++]=Ui,Ui=e,Wi=t}function Zi(e,t,n){Gi[Ki++]=Ji,Gi[Ki++]=Yi,Gi[Ki++]=qi,qi=e;var r=Ji;e=Yi;var i=32-Ye(r)-1;r&=~(1<<i),n+=1;var a=32-Ye(t)+i;if(30<a){var o=i-i%5;a=(r&(1<<o)-1).toString(32),r>>=o,i-=o,Ji=1<<32-Ye(t)+i|n<<i|r,Yi=a+e}else Ji=1<<a|n<<i|r,Yi=e}function Qi(e){e.return!==null&&(Xi(e,1),Zi(e,1,0))}function $i(e){for(;e===Ui;)Ui=Vi[--Hi],Vi[Hi]=null,Wi=Vi[--Hi],Vi[Hi]=null;for(;e===qi;)qi=Gi[--Ki],Gi[Ki]=null,Yi=Gi[--Ki],Gi[Ki]=null,Ji=Gi[--Ki],Gi[Ki]=null}function ea(e,t){Gi[Ki++]=Ji,Gi[Ki++]=Yi,Gi[Ki++]=qi,Ji=t.id,Yi=t.overflow,qi=e}var ta=null,na=null,ra=!1,ia=null,aa=!1,oa=Error(i(519));function sa(e){throw pa(Bi(Error(i(418,1<arguments.length&&arguments[1]!==void 0&&arguments[1]?`text`:`HTML`,``)),e)),oa}function ca(e){var t=e.stateNode,n=e.type,r=e.memoizedProps;switch(t[yt]=e,t[bt]=r,n){case`dialog`:Zf(`cancel`,t),Zf(`close`,t);break;case`iframe`:case`object`:case`embed`:Zf(`load`,t);break;case`video`:case`audio`:for(n=0;n<Jf.length;n++)Zf(Jf[n],t);break;case`source`:Zf(`error`,t);break;case`img`:case`image`:case`link`:Zf(`error`,t),Zf(`load`,t);break;case`details`:Zf(`toggle`,t);break;case`input`:Zf(`invalid`,t),nn(t,r.value,r.defaultValue,r.checked,r.defaultChecked,r.type,r.name,!0);break;case`select`:Zf(`invalid`,t);break;case`textarea`:Zf(`invalid`,t),sn(t,r.value,r.defaultValue,r.children)}n=r.children,typeof n!=`string`&&typeof n!=`number`&&typeof n!=`bigint`||t.textContent===``+n||!0===r.suppressHydrationWarning||up(t.textContent,n)?(r.popover!=null&&(Zf(`beforetoggle`,t),Zf(`toggle`,t)),r.onScroll!=null&&Zf(`scroll`,t),r.onScrollEnd!=null&&Zf(`scrollend`,t),r.onClick!=null&&(t.onclick=gn),t=!0):t=!1,t||sa(e,!0)}function la(e){for(ta=e.return;ta;)switch(ta.tag){case 5:case 31:case 13:aa=!1;return;case 27:case 3:aa=!0;return;default:ta=ta.return}}function ua(e){if(e!==ta)return!1;if(!ra)return la(e),ra=!0,!1;var t=e.tag,n;if((n=t!==3&&t!==27)&&((n=t===5)&&(n=e.type,n=n===`form`||n===`button`||wp(e.type,e.memoizedProps)),n=!n),n&&na&&sa(e),la(e),t===13){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));na=Sm(e)}else if(t===31){if(e=e.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(317));na=Sm(e)}else t===27?(t=na,Np(e.type)?(e=xm,xm=null,na=e):na=t):na=ta?bm(e.stateNode.nextSibling):null;return!0}function da(){na=ta=null,ra=!1}function fa(){var e=ia;return e!==null&&(bd===null?bd=e:bd.push.apply(bd,e),ia=null),e}function pa(e){ia===null?ia=[e]:ia.push(e)}var ma=me(null),ha=null,ga=null;function _a(e,t,n){ge(ma,t._currentValue),t._currentValue=n}function va(e){e._currentValue=ma.current,he(ma)}function ya(e,t,n){for(;e!==null;){var r=e.alternate;if((e.childLanes&t)===t?r!==null&&(r.childLanes&t)!==t&&(r.childLanes|=t):(e.childLanes|=t,r!==null&&(r.childLanes|=t)),e===n)break;e=e.return}}function ba(e,t,n,r){var a=e.child;for(a!==null&&(a.return=e);a!==null;){var o=a.dependencies;if(o!==null){var s=a.child;o=o.firstContext;a:for(;o!==null;){var c=o;o=a;for(var l=0;l<t.length;l++)if(c.context===t[l]){o.lanes|=n,c=o.alternate,c!==null&&(c.lanes|=n),ya(o.return,n,e),r||(s=null);break a}o=c.next}}else if(a.tag===18){if(s=a.return,s===null)throw Error(i(341));s.lanes|=n,o=s.alternate,o!==null&&(o.lanes|=n),ya(s,n,e),s=null}else a.tag===13&&a.memoizedState!==null&&a.memoizedState.dehydrated===null?(a.lanes|=n,s=a.alternate,s!==null&&(s.lanes|=n),ya(a.return,n,e),s=a.child,s=s===null?null:s.sibling):s=a.child;if(s!==null)s.return=a;else for(s=a;s!==null;){if(s===e){s=null;break}if(a=s.sibling,a!==null){a.return=s.return,s=a;break}s=s.return}a=s}}function xa(e,t,n,r){e=null;for(var a=t,o=!1;a!==null;){if(!o){if(a.flags&524288)o=!0;else if(a.flags&262144)break}if(a.tag===10){var s=a.alternate;if(s===null)throw Error(i(387));if(s=s.memoizedProps,s!==null){var c=a.type;zr(a.pendingProps.value,s.value)||(e===null?e=[c]:e.push(c))}}else if(a===be.current){if(s=a.alternate,s===null)throw Error(i(387));s.memoizedState.memoizedState!==a.memoizedState.memoizedState&&(e===null?e=[_h]:e.push(_h))}a=a.return}return e!==null&&ba(t,e,n,r),t.flags|=262144,e!==null}function Sa(e){for(e=e.firstContext;e!==null;){if(!zr(e.context._currentValue,e.memoizedValue))return!0;e=e.next}return!1}function Ca(e){ha=e,ga=null,e=e.dependencies,e!==null&&(e.firstContext=null)}function wa(e){return Ea(ha,e)}function Ta(e,t){return ha===null&&Ca(e),Ea(e,t)}function Ea(e,t){var n=t._currentValue;if(t={context:t,memoizedValue:n,next:null},ga===null){if(e===null)throw Error(i(308));ga=t,e.dependencies={lanes:0,firstContext:t},e.flags|=524288}else ga=ga.next=t;return n}var Da=typeof AbortController<`u`?AbortController:function(){var e=[],t=this.signal={aborted:!1,addEventListener:function(t,n){e.push(n)}};this.abort=function(){t.aborted=!0,e.forEach(function(e){return e()})}},Oa=t.unstable_scheduleCallback,ka=t.unstable_NormalPriority,Aa={$$typeof:N,Consumer:null,Provider:null,_currentValue:null,_currentValue2:null,_threadCount:0};function ja(){return{controller:new Da,data:new Map,refCount:0}}function Ma(e){e.refCount--,e.refCount===0&&Oa(ka,function(){e.controller.abort()})}function Na(e,t){if(e.pendingLanes&4194048){var n=e.transitionTypes;for(n===null&&(n=e.transitionTypes=[]),e=0;e<t.length;e++){var r=t[e];n.indexOf(r)===-1&&n.push(r)}}}var Pa=null;function Fa(e){var t=e.transitionTypes;return e.transitionTypes=null,t}var Ia=null,La=0,Ra=0,za=null;function Ba(e,t){if(Ia===null){var n=Ia=[];La=0,Ra=Uf(),za={status:`pending`,value:void 0,then:function(e){n.push(e)}}}return La++,t.then(Va,Va),t}function Va(){if(--La===0&&(Pa=null,Ia!==null)){za!==null&&(za.status=`fulfilled`);var e=Ia;Ia=null,Ra=0,za=null;for(var t=0;t<e.length;t++)(0,e[t])()}}function Ha(e,t){var n=[],r={status:`pending`,value:null,reason:null,then:function(e){n.push(e)}};return e.then(function(){r.status=`fulfilled`,r.value=t;for(var e=0;e<n.length;e++)(0,n[e])(t)},function(e){for(r.status=`rejected`,r.reason=e,e=0;e<n.length;e++)(0,n[e])(void 0)}),r}var Ua=V.S;V.S=function(e,t){if(Cd=Le(),typeof t==`object`&&t&&typeof t.then==`function`&&Ba(e,t),Pa!==null)for(var n=kf;n!==null;)Na(n,Pa),n=n.next;if(n=e.types,n!==null){for(var r=kf;r!==null;)Na(r,n),r=r.next;if(Ra!==0){r=Pa,r===null&&(r=Pa=[]);for(var i=0;i<n.length;i++){var a=n[i];r.indexOf(a)===-1&&r.push(a)}}}Ua!==null&&Ua(e,t)};var Wa=me(null);function Ga(){var e=Wa.current;return e===null?id.pooledCache:e}function Ka(e,t){t===null?ge(Wa,Wa.current):ge(Wa,t.pool)}function qa(){var e=Ga();return e===null?null:{parent:Aa._currentValue,pool:e}}var Ja=Error(i(460)),Ya=Error(i(474)),Xa=Error(i(542)),Za={then:function(){}};function Qa(e){return e=e.status,e===`fulfilled`||e===`rejected`}function $a(e,t,n){switch(n=e[n],n===void 0?e.push(t):n!==t&&(t.then(gn,gn),t=n),t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ro(e),e===void 0&&!(`reason`in t)?Error(i(600)):e;default:if(typeof t.status==`string`)t.then(gn,gn);else{if(e=id,e!==null&&100<e.shellSuspendCounter)throw Error(i(482));e=t,e.status=`pending`,e.then(function(e){if(t.status===`pending`){var n=t;n.status=`fulfilled`,n.value=e}},function(e){if(t.status===`pending`){var n=t;n.status=`rejected`,n.reason=e}})}switch(t.status){case`fulfilled`:return t.value;case`rejected`:throw e=t.reason,ro(e),e}throw to=t,Ja}}function eo(e){try{var t=e._init;return t(e._payload)}catch(e){throw typeof e==`object`&&e&&typeof e.then==`function`?(to=e,Ja):e}}var to=null;function no(){if(to===null)throw Error(i(459));var e=to;return to=null,e}function ro(e){if(e===Ja||e===Xa)throw Error(i(483))}var io=null,ao=0;function oo(e){var t=ao;return ao+=1,io===null&&(io=[]),$a(io,e,t)}function so(e,t){t=t.props.ref,e.ref=t===void 0?null:t}function co(e,t){throw t.$$typeof===T?Error(i(525)):(e=Object.prototype.toString.call(t),Error(i(31,e===`[object Object]`?`object with keys {`+Object.keys(t).join(`, `)+`}`:e)))}function lo(e){function t(t,n){if(e){var r=t.deletions;r===null?(t.deletions=[n],t.flags|=16):r.push(n)}}function n(n,r){if(!e)return null;for(;r!==null;)t(n,r),r=r.sibling;return null}function r(e){for(var t=new Map;e!==null;)e.key===null?t.set(e.index,e):t.set(e.key,e),e=e.sibling;return t}function a(e,t){return e=Mi(e,t),e.index=0,e.sibling=null,e}function o(t,n,r){return t.index=r,e?(r=t.alternate,r===null?(t.flags|=134217730,n):(r=r.index,r<n?(t.flags|=2,n):r)):(t.flags|=1048576,n)}function s(t){return e&&t.alternate===null&&(t.flags|=134217730),t}function c(e,t,n,r){return t===null||t.tag!==6?(t=Ii(n,e.mode,r),t.return=e,t):(t=a(t,n),t.return=e,t)}function l(e,t,n,r){var i=n.type;return i===O?(e=d(e,t,n.props.children,r,n.key),so(e,n),e):t!==null&&(t.elementType===i||typeof i==`object`&&i&&i.$$typeof===re&&eo(i)===t.type)?(t=a(t,n.props),so(t,n),t.return=e,t):(t=Pi(n.type,n.key,n.props,null,e.mode,r),so(t,n),t.return=e,t)}function u(e,t,n,r){return t===null||t.tag!==4||t.stateNode.containerInfo!==n.containerInfo||t.stateNode.implementation!==n.implementation?(t=Ri(n,e.mode,r),t.return=e,t):(t=a(t,n.children||[]),t.return=e,t)}function d(e,t,n,r,i){return t===null||t.tag!==7?(t=Fi(n,e.mode,r,i),t.return=e,t):(t=a(t,n),t.return=e,t)}function f(e,t,n){if(typeof t==`string`&&t!==``||typeof t==`number`||typeof t==`bigint`)return t=Ii(``+t,e.mode,n),t.return=e,t;if(typeof t==`object`&&t){switch(t.$$typeof){case E:return n=Pi(t.type,t.key,t.props,null,e.mode,n),so(n,t),n.return=e,n;case D:return t=Ri(t,e.mode,n),t.return=e,t;case re:return t=eo(t),f(e,t,n)}if(le(t)||oe(t))return t=Fi(t,e.mode,n,null),t.return=e,t;if(typeof t.then==`function`)return f(e,oo(t),n);if(t.$$typeof===N)return f(e,Ta(e,t),n);co(e,t)}return null}function p(e,t,n,r){var i=t===null?null:t.key;if(typeof n==`string`&&n!==``||typeof n==`number`||typeof n==`bigint`)return i===null?c(e,t,``+n,r):null;if(typeof n==`object`&&n){switch(n.$$typeof){case E:return n.key===i?l(e,t,n,r):null;case D:return n.key===i?u(e,t,n,r):null;case re:return n=eo(n),p(e,t,n,r)}if(le(n)||oe(n))return i===null?d(e,t,n,r,null):null;if(typeof n.then==`function`)return p(e,t,oo(n),r);if(n.$$typeof===N)return p(e,t,Ta(e,n),r);co(e,n)}return null}function m(e,t,n,r,i){if(typeof r==`string`&&r!==``||typeof r==`number`||typeof r==`bigint`)return e=e.get(n)||null,c(t,e,``+r,i);if(typeof r==`object`&&r){switch(r.$$typeof){case E:return e=e.get(r.key===null?n:r.key)||null,l(t,e,r,i);case D:return e=e.get(r.key===null?n:r.key)||null,u(t,e,r,i);case re:return r=eo(r),m(e,t,n,r,i)}if(le(r)||oe(r))return e=e.get(n)||null,d(t,e,r,i,null);if(typeof r.then==`function`)return m(e,t,n,oo(r),i);if(r.$$typeof===N)return m(e,t,n,Ta(t,r),i);co(t,r)}return null}function h(i,a,s,c){for(var l=null,u=null,d=a,h=a=0,g=null;d!==null&&h<s.length;h++){d.index>h?(g=d,d=null):g=d.sibling;var _=p(i,d,s[h],c);if(_===null){d===null&&(d=g);break}e&&d&&_.alternate===null&&t(i,d),a=o(_,a,h),u===null?l=_:u.sibling=_,u=_,d=g}if(h===s.length)return n(i,d),ra&&Xi(i,h),l;if(d===null){for(;h<s.length;h++)d=f(i,s[h],c),d!==null&&(a=o(d,a,h),u===null?l=d:u.sibling=d,u=d);return ra&&Xi(i,h),l}for(d=r(d);h<s.length;h++)g=m(d,i,h,s[h],c),g!==null&&(e&&(_=g.alternate,_!==null&&d.delete(_.key===null?h:_.key)),a=o(g,a,h),u===null?l=g:u.sibling=g,u=g);return e&&d.forEach(function(e){return t(i,e)}),ra&&Xi(i,h),l}function g(a,s,c,l){if(c==null)throw Error(i(151));for(var u=null,d=null,h=s,g=s=0,_=null,v=c.next();h!==null&&!v.done;g++,v=c.next()){h.index>g?(_=h,h=null):_=h.sibling;var y=p(a,h,v.value,l);if(y===null){h===null&&(h=_);break}e&&h&&y.alternate===null&&t(a,h),s=o(y,s,g),d===null?u=y:d.sibling=y,d=y,h=_}if(v.done)return n(a,h),ra&&Xi(a,g),u;if(h===null){for(;!v.done;g++,v=c.next())v=f(a,v.value,l),v!==null&&(s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return ra&&Xi(a,g),u}for(h=r(h);!v.done;g++,v=c.next())v=m(h,a,g,v.value,l),v!==null&&(e&&(_=v.alternate,_!==null&&h.delete(_.key===null?g:_.key)),s=o(v,s,g),d===null?u=v:d.sibling=v,d=v);return e&&h.forEach(function(e){return t(a,e)}),ra&&Xi(a,g),u}function _(e,r,o,c){if(typeof o==`object`&&o&&o.type===O&&o.key===null&&o.props.ref===void 0&&(o=o.props.children),typeof o==`object`&&o){switch(o.$$typeof){case E:a:{for(var l=o.key;r!==null;){if(r.key===l){if(l=o.type,l===O){if(r.tag===7){n(e,r.sibling),c=a(r,o.props.children),so(c,o),c.return=e,e=c;break a}}else if(r.elementType===l||typeof l==`object`&&l&&l.$$typeof===re&&eo(l)===r.type){n(e,r.sibling),c=a(r,o.props),so(c,o),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}o.type===O?(c=Fi(o.props.children,e.mode,c,o.key),so(c,o),c.return=e,e=c):(c=Pi(o.type,o.key,o.props,null,e.mode,c),so(c,o),c.return=e,e=c)}return s(e);case D:a:{for(l=o.key;r!==null;){if(r.key===l){if(r.tag===4&&r.stateNode.containerInfo===o.containerInfo&&r.stateNode.implementation===o.implementation){n(e,r.sibling),c=a(r,o.children||[]),c.return=e,e=c;break a}n(e,r);break}t(e,r),r=r.sibling}c=Ri(o,e.mode,c),c.return=e,e=c}return s(e);case re:return o=eo(o),_(e,r,o,c)}if(le(o))return h(e,r,o,c);if(oe(o)){if(l=oe(o),typeof l!=`function`)throw Error(i(150));return o=l.call(o),g(e,r,o,c)}if(typeof o.then==`function`)return _(e,r,oo(o),c);if(o.$$typeof===N)return _(e,r,Ta(e,o),c);co(e,o)}return typeof o==`string`&&o!==``||typeof o==`number`||typeof o==`bigint`?(o=``+o,r!==null&&r.tag===6?(n(e,r.sibling),c=a(r,o),c.return=e,e=c):(n(e,r),c=Ii(o,e.mode,c),c.return=e,e=c),s(e)):n(e,r)}return function(e,t,n,r){try{ao=0;var i=_(e,t,n,r);return io=null,i}catch(t){if(t===Ja||t===Xa)throw t;var a=Ai(29,t,null,e.mode);return a.lanes=r,a.return=e,a}}}var uo=lo(!0),fo=lo(!1),po=!1;function mo(e){e.updateQueue={baseState:e.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,lanes:0,hiddenCallbacks:null},callbacks:null}}function ho(e,t){e=e.updateQueue,t.updateQueue===e&&(t.updateQueue={baseState:e.baseState,firstBaseUpdate:e.firstBaseUpdate,lastBaseUpdate:e.lastBaseUpdate,shared:e.shared,callbacks:null})}function go(e){return{lane:e,tag:0,payload:null,callback:null,next:null}}function _o(e,t,n){var r=e.updateQueue;if(r===null)return null;if(r=r.shared,rd&2){var i=r.pending;return i===null?t.next=t:(t.next=i.next,i.next=t),r.pending=t,t=Di(e),Ei(e,null,n),t}return Ci(e,r,t,n),Di(e)}function vo(e,t,n){if(t=t.updateQueue,t!==null&&(t=t.shared,n&4194048)){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ft(e,n)}}function yo(e,t){var n=e.updateQueue,r=e.alternate;if(r!==null&&(r=r.updateQueue,n===r)){var i=null,a=null;if(n=n.firstBaseUpdate,n!==null){do{var o={lane:n.lane,tag:n.tag,payload:n.payload,callback:null,next:null};a===null?i=a=o:a=a.next=o,n=n.next}while(n!==null);a===null?i=a=t:a=a.next=t}else i=a=t;n={baseState:r.baseState,firstBaseUpdate:i,lastBaseUpdate:a,shared:r.shared,callbacks:r.callbacks},e.updateQueue=n}else e=n.lastBaseUpdate,e===null?n.firstBaseUpdate=t:e.next=t,n.lastBaseUpdate=t}var bo=!1;function xo(){if(bo){var e=za;if(e!==null)throw e}}function So(e,t,n,r){bo=!1;var i=e.updateQueue;po=!1;var a=i.firstBaseUpdate,o=i.lastBaseUpdate,s=i.shared.pending;if(s!==null){i.shared.pending=null;var c=s,l=c.next;c.next=null,o===null?a=l:o.next=l,o=c;var u=e.alternate;u!==null&&(u=u.updateQueue,s=u.lastBaseUpdate,s!==o&&(s===null?u.firstBaseUpdate=l:s.next=l,u.lastBaseUpdate=c))}if(a!==null){var d=i.baseState;o=0,u=l=c=null,s=a;do{var f=s.lane&-536870913,p=f!==s.lane;if(p?(od&f)===f:(r&f)===f){f!==0&&f===Ra&&(bo=!0),u!==null&&(u=u.next={lane:0,tag:s.tag,payload:s.payload,callback:null,next:null});a:{var m=e,h=s;f=t;var g=n;switch(h.tag){case 1:if(m=h.payload,typeof m==`function`){d=m.call(g,d,f);break a}d=m;break a;case 3:m.flags=m.flags&-65537|128;case 0:if(m=h.payload,f=typeof m==`function`?m.call(g,d,f):m,f==null)break a;d=w({},d,f);break a;case 2:po=!0}}f=s.callback,f!==null&&(e.flags|=64,p&&(e.flags|=8192),p=i.callbacks,p===null?i.callbacks=[f]:p.push(f))}else p={lane:f,tag:s.tag,payload:s.payload,callback:s.callback,next:null},u===null?(l=u=p,c=d):u=u.next=p,o|=f;if(s=s.next,s===null){if(s=i.shared.pending,s===null)break;p=s,s=p.next,p.next=null,i.lastBaseUpdate=p,i.shared.pending=null}}while(1);u===null&&(c=d),i.baseState=c,i.firstBaseUpdate=l,i.lastBaseUpdate=u,a===null&&(i.shared.lanes=0),md|=o,e.lanes=o,e.memoizedState=d}}function Co(e,t){if(typeof e!=`function`)throw Error(i(191,e));e.call(t)}function wo(e,t){var n=e.callbacks;if(n!==null)for(e.callbacks=null,e=0;e<n.length;e++)Co(n[e],t)}var To=me(null),Eo=me(0);function Do(e,t){e=fd,ge(Eo,e),ge(To,t),fd=e|t.baseLanes}function Oo(){ge(Eo,fd),ge(To,To.current)}function ko(){fd=Eo.current,he(To),he(Eo)}var Ao=me(null),jo=null;function Mo(e){var t=e.alternate;ge(Lo,Lo.current&1),ge(Ao,e),jo===null&&(t===null||To.current!==null||t.memoizedState!==null)&&(jo=e)}function No(e){ge(Lo,Lo.current),ge(Ao,e),jo===null&&(jo=e)}function Po(e){e.tag===22?(ge(Lo,Lo.current),ge(Ao,e),jo===null&&(jo=e)):Fo()}function Fo(){ge(Lo,Lo.current),ge(Ao,Ao.current)}function Io(e){he(Ao),jo===e&&(jo=null),he(Lo)}var Lo=me(0);function Ro(e,t){ge(Ao,Ao.current),ge(Lo,t)}function zo(e){he(Lo),he(Ao),jo===e&&(jo=null)}function Bo(e){for(var t=e;t!==null;){if(t.tag===13){var n=t.memoizedState;if(n!==null&&(n=n.dehydrated,n===null||_m(n)||vm(n)))return t}else if(t.tag===19&&t.memoizedProps.revealOrder!==`independent`){if(t.flags&128)return t}else if(t.child!==null){t.child.return=t,t=t.child;continue}if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return null;t=t.return}t.sibling.return=t.return,t=t.sibling}return null}var Vo=0,Ho=null,Uo=null,Wo=null,Go=!1,Ko=!1,qo=!1,Jo=0,Yo=0,Xo=null,Zo=0;function Qo(){throw Error(i(321))}function $o(e,t){if(t===null)return!1;for(var n=0;n<t.length&&n<e.length;n++)if(!zr(e[n],t[n]))return!1;return!0}function es(e,t,n,r,i,a){return Vo=a,Ho=t,t.memoizedState=null,t.updateQueue=null,t.lanes=0,V.H=e===null||e.memoizedState===null?_c:vc,qo=!1,a=n(r,i),qo=!1,Ko&&(a=ns(t,n,r,i)),ts(e),a}function ts(e){V.H=gc;var t=Uo!==null&&Uo.next!==null;if(Vo=0,Wo=Uo=Ho=null,Go=!1,Yo=0,Xo=null,t)throw Error(i(300));e===null||Fc||(e=e.dependencies,e!==null&&Sa(e)&&(Fc=!0))}function ns(e,t,n,r){Ho=e;var a=0;do{if(Ko&&(Xo=null),Yo=0,Ko=!1,25<=a)throw Error(i(301));if(a+=1,Wo=Uo=null,e.updateQueue!=null){var o=e.updateQueue;o.lastEffect=null,o.events=null,o.stores=null,o.memoCache!=null&&(o.memoCache.index=0)}V.H=yc,o=t(n,r)}while(Ko);return o}function rs(){var e=V.H,t=e.useState()[0];return t=typeof t.then==`function`?us(t):t,e=e.useState()[0],(Uo===null?null:Uo.memoizedState)!==e&&(Ho.flags|=1024),t}function is(){var e=Jo!==0;return Jo=0,e}function as(e,t,n){t.updateQueue=e.updateQueue,t.flags&=-2053,e.lanes&=~n}function os(e){if(Go){for(e=e.memoizedState;e!==null;){var t=e.queue;t!==null&&(t.pending=null),e=e.next}Go=!1}Vo=0,Wo=Uo=Ho=null,Ko=!1,Yo=Jo=0,Xo=null}function ss(){var e={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Wo===null?Ho.memoizedState=Wo=e:Wo=Wo.next=e,Wo}function cs(){if(Uo===null){var e=Ho.alternate;e=e===null?null:e.memoizedState}else e=Uo.next;var t=Wo===null?Ho.memoizedState:Wo.next;if(t!==null)Wo=t,Uo=e;else{if(e===null)throw Ho.alternate===null?Error(i(467)):Error(i(310));Uo=e,e={memoizedState:Uo.memoizedState,baseState:Uo.baseState,baseQueue:Uo.baseQueue,queue:Uo.queue,next:null},Wo===null?Ho.memoizedState=Wo=e:Wo=Wo.next=e}return Wo}function ls(){return{lastEffect:null,events:null,stores:null,memoCache:null}}function us(e){var t=Yo;return Yo+=1,Xo===null&&(Xo=[]),e=$a(Xo,e,t),t=Ho,(Wo===null?t.memoizedState:Wo.next)===null&&(t=t.alternate,V.H=t===null||t.memoizedState===null?_c:vc),e}function ds(e){if(typeof e==`object`&&e){if(typeof e.then==`function`)return us(e);if(e.$$typeof===ie)return;if(e.$$typeof===N)return wa(e)}throw Error(i(438,String(e)))}function fs(e){var t=null,n=Ho.updateQueue;if(n!==null&&(t=n.memoCache),t==null){var r=Ho.alternate;r!==null&&(r=r.updateQueue,r!==null&&(r=r.memoCache,r!=null&&(t={data:r.data.map(function(e){return e.slice()}),index:0})))}if(t??={data:[],index:0},n===null&&(n=ls(),Ho.updateQueue=n),n.memoCache=t,n=t.data[t.index],n===void 0)for(n=t.data[t.index]=Array(e),r=0;r<e;r++)n[r]=z;return t.index++,n}function ps(e,t){return typeof t==`function`?t(e):t}function ms(e){return hs(cs(),Uo,e)}function hs(e,t,n){var r=e.queue;if(r===null)throw Error(i(311));r.lastRenderedReducer=n;var a=e.baseQueue,o=r.pending;if(o!==null){if(a!==null){var s=a.next;a.next=o.next,o.next=s}t.baseQueue=a=o,r.pending=null}if(o=e.baseState,a===null)e.memoizedState=o;else{t=a.next;var c=s=null,l=null,u=t,d=!1;do{var f=u.lane&-536870913;if(f===u.lane?(Vo&f)===f:(od&f)===f){var p=u.revertLane;if(p===0)l!==null&&(l=l.next={lane:0,revertLane:0,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null}),f===Ra&&(d=!0);else if((Vo&p)===p){u=u.next,p===Ra&&(d=!0);continue}else f={lane:0,revertLane:u.revertLane,gesture:null,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=f,s=o):l=l.next=f,Ho.lanes|=p,md|=p;f=u.action,qo&&n(o,f),o=u.hasEagerState?u.eagerState:n(o,f)}else p={lane:f,revertLane:u.revertLane,gesture:u.gesture,action:u.action,hasEagerState:u.hasEagerState,eagerState:u.eagerState,next:null},l===null?(c=l=p,s=o):l=l.next=p,Ho.lanes|=f,md|=f;u=u.next}while(u!==null&&u!==t);if(l===null?s=o:l.next=c,!zr(o,e.memoizedState)&&(Fc=!0,d&&(n=za,n!==null)))throw n;e.memoizedState=o,e.baseState=s,e.baseQueue=l,r.lastRenderedState=o}return a===null&&(r.lanes=0),[e.memoizedState,r.dispatch]}function gs(e){var t=cs(),n=t.queue;if(n===null)throw Error(i(311));n.lastRenderedReducer=e;var r=n.dispatch,a=n.pending,o=t.memoizedState;if(a!==null){n.pending=null;var s=a=a.next;do o=e(o,s.action),s=s.next;while(s!==a);zr(o,t.memoizedState)||(Fc=!0),t.memoizedState=o,t.baseQueue===null&&(t.baseState=o),n.lastRenderedState=o}return[o,r]}function _s(e,t,n){var r=Ho,a=cs(),o=ra;if(o){if(n===void 0)throw Error(i(407));n=n()}else n=t();var s=!zr((Uo||a).memoizedState,n);if(s&&(a.memoizedState=n,Fc=!0),a=a.queue,Hs(bs.bind(null,r,a,e),[e]),e=a.getSnapshot!==t||s||Wo!==null&&!!(Wo.memoizedState.tag&1),Ls(e?9:8,{destroy:void 0},ys.bind(null,r,a,n,t),null),e){if(r.flags|=2048,id===null)throw Error(i(349));o||Vo&127||vs(r,t,n)}return n}function vs(e,t,n){e.flags|=16384,e={getSnapshot:t,value:n},t=Ho.updateQueue,t===null?(t=ls(),Ho.updateQueue=t,t.stores=[e]):(n=t.stores,n===null?t.stores=[e]:n.push(e))}function ys(e,t,n,r){t.value=n,t.getSnapshot=r,xs(t)&&Ss(e)}function bs(e,t,n){return n(function(){xs(t)&&Ss(e)})}function xs(e){var t=e.getSnapshot;e=e.value;try{var n=t();return!zr(e,n)}catch{return!0}}function Ss(e){var t=Ti(e,2);t!==null&&Hd(t,e,2)}function Cs(e){var t=ss();if(typeof e==`function`){var n=e;if(e=n(),qo){Je(!0);try{n()}finally{Je(!1)}}}return t.memoizedState=t.baseState=e,t.queue={pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:e},t}function ws(e,t,n,r){return e.baseState=n,hs(e,Uo,typeof r==`function`?r:ps)}function Ts(e,t,n,r,a){if(pc(e))throw Error(i(485));if(e=t.action,e!==null){var o={payload:a,action:e,next:null,isTransition:!0,status:`pending`,value:null,reason:null,listeners:[],then:function(e){o.listeners.push(e)}};V.T===null?o.isTransition=!1:n(!0),r(o),n=t.pending,n===null?(o.next=t.pending=o,Es(t,o)):(o.next=n.next,t.pending=n.next=o)}}function Es(e,t){var n=t.action,r=t.payload,i=e.state;if(t.isTransition){var a=V.T,o={};o.types=a===null?null:a.types,V.T=o;try{var s=n(i,r),c=V.S;c!==null&&c(o,s),Ds(e,t,s)}catch(n){ks(e,t,n)}finally{a!==null&&o.types!==null&&(a.types=o.types),V.T=a}}else try{a=n(i,r),Ds(e,t,a)}catch(n){ks(e,t,n)}}function Ds(e,t,n){typeof n==`object`&&n&&typeof n.then==`function`?n.then(function(n){Os(e,t,n)},function(n){return ks(e,t,n)}):Os(e,t,n)}function Os(e,t,n){t.status=`fulfilled`,t.value=n,As(t),e.state=n,t=e.pending,t!==null&&(n=t.next,n===t?e.pending=null:(n=n.next,t.next=n,Es(e,n)))}function ks(e,t,n){var r=e.pending;if(e.pending=null,r!==null){r=r.next;do t.status=`rejected`,t.reason=n,As(t),t=t.next;while(t!==r)}e.action=null}function As(e){e=e.listeners;for(var t=0;t<e.length;t++)(0,e[t])()}function js(e,t){return t}function Ms(e,t){if(ra){var n=id.formState;if(n!==null){a:{var r=Ho;if(ra){if(na){b:{for(var i=na,a=aa;i.nodeType!==8;)if(!a||(i=bm(i.nextSibling),i===null)){i=null;break b}a=i.data,i=a===`F!`||a===`F`?i:null}if(i){na=bm(i.nextSibling),r=i.data===`F!`;break a}}sa(r)}r=!1}r&&(t=n[0])}}return n=ss(),n.memoizedState=n.baseState=t,r={pending:null,lanes:0,dispatch:null,lastRenderedReducer:js,lastRenderedState:t},n.queue=r,n=uc.bind(null,Ho,r),r.dispatch=n,r=Cs(!1),a=fc.bind(null,Ho,!1,r.queue),r=ss(),i={state:t,dispatch:null,action:e,pending:null},r.queue=i,n=Ts.bind(null,Ho,i,a,n),i.dispatch=n,r.memoizedState=e,[t,n,!1]}function Ns(e){return Ps(cs(),Uo,e)}function Ps(e,t,n){if(t=hs(e,t,js)[0],e=ms(ps)[0],typeof t==`object`&&t&&typeof t.then==`function`)try{var r=us(t)}catch(e){throw e===Ja?Xa:e}else r=t;t=cs();var i=t.queue,a=i.dispatch;return n!==t.memoizedState&&(Ho.flags|=2048,Ls(9,{destroy:void 0},Fs.bind(null,i,n),null)),[r,a,e]}function Fs(e,t){e.action=t}function Is(e){var t=cs(),n=Uo;if(n!==null)return Ps(t,n,e);cs(),t=t.memoizedState,n=cs();var r=n.queue.dispatch;return n.memoizedState=e,[t,r,!1]}function Ls(e,t,n,r){return e={tag:e,create:n,deps:r,inst:t,next:null},t=Ho.updateQueue,t===null&&(t=ls(),Ho.updateQueue=t),n=t.lastEffect,n===null?t.lastEffect=e.next=e:(r=n.next,n.next=e,e.next=r,t.lastEffect=e),e}function Rs(){return cs().memoizedState}function zs(e,t,n,r){var i=ss();Ho.flags|=e,i.memoizedState=Ls(1|t,{destroy:void 0},n,r===void 0?null:r)}function Bs(e,t,n,r){var i=cs();r=r===void 0?null:r;var a=i.memoizedState.inst;Uo!==null&&r!==null&&$o(r,Uo.memoizedState.deps)?i.memoizedState=Ls(t,a,n,r):(Ho.flags|=e,i.memoizedState=Ls(1|t,a,n,r))}function Vs(e,t){zs(8390656,8,e,t)}function Hs(e,t){Bs(2048,8,e,t)}function Us(e){Ho.flags|=4;var t=Ho.updateQueue;if(t===null)t=ls(),Ho.updateQueue=t,t.events=[e];else{var n=t.events;n===null?t.events=[e]:n.push(e)}}function Ws(e){var t=cs().memoizedState;return Us({ref:t,nextImpl:e}),function(){if(rd&2)throw Error(i(440));return t.impl.apply(void 0,arguments)}}function Gs(e,t){return Bs(4,2,e,t)}function Ks(e,t){return Bs(4,4,e,t)}function qs(e,t){if(typeof t==`function`){e=e();var n=t(e);return function(){typeof n==`function`?n():t(null)}}if(t!=null)return e=e(),t.current=e,function(){t.current=null}}function Js(e,t,n){n=n==null?null:n.concat([e]),Bs(4,4,qs.bind(null,t,e),n)}function Ys(){}function Xs(e,t){var n=cs();t=t===void 0?null:t;var r=n.memoizedState;return t!==null&&$o(t,r[1])?r[0]:(n.memoizedState=[e,t],e)}function Zs(e,t){var n=cs();t=t===void 0?null:t;var r=n.memoizedState;if(t!==null&&$o(t,r[1]))return r[0];if(r=e(),qo){Je(!0);try{e()}finally{Je(!1)}}return n.memoizedState=[r,t],r}function Qs(e,t,n){return n===void 0||Vo&1073741824&&!(od&261930)?e.memoizedState=t:(e.memoizedState=n,e=Bd(),Ho.lanes|=e,md|=e,n)}function $s(e,t,n,r){return zr(n,t)?n:To.current===null?!(Vo&106)||Vo&1073741824&&!(od&261930)?(Fc=!0,e.memoizedState=n):(e=Bd(),Ho.lanes|=e,md|=e,t):(e=Qs(e,n,r),zr(e,t)||(Fc=!0),e)}function ec(e,t,n,r,i){var a=ue.p;ue.p=a!==0&&8>a?a:8;var o=V.T,s={};s.types=o===null?null:o.types,V.T=s,fc(e,!1,t,n);try{var c=i(),l=V.S;l!==null&&l(s,c),typeof c==`object`&&c&&typeof c.then==`function`?dc(e,t,Ha(c,r),zd(e)):dc(e,t,r,zd(e))}catch(n){dc(e,t,{then:function(){},status:`rejected`,reason:n},zd())}finally{ue.p=a,o!==null&&s.types!==null&&(o.types=s.types),V.T=o}}function tc(){}function nc(e,t,n,r){if(e.tag!==5)throw Error(i(476));var a=rc(e).queue;ec(e,a,t,de,n===null?tc:function(){return ic(e),n(r)})}function rc(e){var t=e.memoizedState;if(t!==null)return t;t={memoizedState:de,baseState:de,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:de},next:null};var n={};return t.next={memoizedState:n,baseState:n,baseQueue:null,queue:{pending:null,lanes:0,dispatch:null,lastRenderedReducer:ps,lastRenderedState:n},next:null},e.memoizedState=t,e=e.alternate,e!==null&&(e.memoizedState=t),t}function ic(e){var t=rc(e);t.next===null&&(t=e.alternate.memoizedState),dc(e,t.next.queue,{},zd())}function ac(){return wa(_h)}function oc(){return cs().memoizedState}function sc(){return cs().memoizedState}function cc(e){for(var t=e.return;t!==null;){switch(t.tag){case 24:case 3:var n=zd();e=go(n);var r=_o(t,e,n);r!==null&&(Hd(r,t,n),vo(r,t,n)),t={cache:ja()},e.payload=t;return}t=t.return}}function lc(e,t,n){var r=zd();n={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null},pc(e)?mc(t,n):(n=wi(e,t,n,r),n!==null&&(Hd(n,e,r),hc(n,t,r)))}function uc(e,t,n){dc(e,t,n,zd())}function dc(e,t,n,r){var i={lane:r,revertLane:0,gesture:null,action:n,hasEagerState:!1,eagerState:null,next:null};if(pc(e))mc(t,i);else{var a=e.alternate;if(e.lanes===0&&(a===null||a.lanes===0)&&(a=t.lastRenderedReducer,a!==null))try{var o=t.lastRenderedState,s=a(o,n);if(i.hasEagerState=!0,i.eagerState=s,zr(s,o))return Ci(e,t,i,0),id===null&&Si(),!1}catch{}if(n=wi(e,t,i,r),n!==null)return Hd(n,e,r),hc(n,t,r),!0}return!1}function fc(e,t,n,r){if(r={lane:2,revertLane:Uf(),gesture:null,action:r,hasEagerState:!1,eagerState:null,next:null},pc(e)){if(t)throw Error(i(479))}else t=wi(e,n,r,2),t!==null&&Hd(t,e,2)}function pc(e){var t=e.alternate;return e===Ho||t!==null&&t===Ho}function mc(e,t){Ko=Go=!0;var n=e.pending;n===null?t.next=t:(t.next=n.next,n.next=t),e.pending=t}function hc(e,t,n){if(n&4194048){var r=t.lanes;r&=e.pendingLanes,n|=r,t.lanes=n,ft(e,n)}}var gc={readContext:wa,use:ds,useCallback:Qo,useContext:Qo,useEffect:Qo,useImperativeHandle:Qo,useLayoutEffect:Qo,useInsertionEffect:Qo,useMemo:Qo,useReducer:Qo,useRef:Qo,useState:Qo,useDebugValue:Qo,useDeferredValue:Qo,useTransition:Qo,useSyncExternalStore:Qo,useId:Qo,useHostTransitionStatus:Qo,useFormState:Qo,useActionState:Qo,useOptimistic:Qo,useMemoCache:Qo,useCacheRefresh:Qo,useEffectEvent:Qo},_c={readContext:wa,use:ds,useCallback:function(e,t){return ss().memoizedState=[e,t===void 0?null:t],e},useContext:wa,useEffect:Vs,useImperativeHandle:function(e,t,n){n=n==null?null:n.concat([e]),zs(4194308,4,qs.bind(null,t,e),n)},useLayoutEffect:function(e,t){return zs(4194308,4,e,t)},useInsertionEffect:function(e,t){zs(4,2,e,t)},useMemo:function(e,t){var n=ss();t=t===void 0?null:t;var r=e();if(qo){Je(!0);try{e()}finally{Je(!1)}}return n.memoizedState=[r,t],r},useReducer:function(e,t,n){var r=ss();if(n!==void 0){var i=n(t);if(qo){Je(!0);try{n(t)}finally{Je(!1)}}}else i=t;return r.memoizedState=r.baseState=i,e={pending:null,lanes:0,dispatch:null,lastRenderedReducer:e,lastRenderedState:i},r.queue=e,e=e.dispatch=lc.bind(null,Ho,e),[r.memoizedState,e]},useRef:function(e){var t=ss();return e={current:e},t.memoizedState=e},useState:function(e){e=Cs(e);var t=e.queue,n=uc.bind(null,Ho,t);return t.dispatch=n,[e.memoizedState,n]},useDebugValue:Ys,useDeferredValue:function(e,t){return Qs(ss(),e,t)},useTransition:function(){var e=Cs(!1);return e=ec.bind(null,Ho,e.queue,!0,!1),ss().memoizedState=e,[!1,e]},useSyncExternalStore:function(e,t,n){var r=Ho,a=ss();if(ra){if(n===void 0)throw Error(i(407));n=n()}else{if(n=t(),id===null)throw Error(i(349));od&127||vs(r,t,n)}a.memoizedState=n;var o={value:n,getSnapshot:t};return a.queue=o,Vs(bs.bind(null,r,o,e),[e]),r.flags|=2048,Ls(9,{destroy:void 0},ys.bind(null,r,o,n,t),null),n},useId:function(){var e=ss(),t=id.identifierPrefix;if(ra){var n=Yi,r=Ji;n=(r&~(1<<32-Ye(r)-1)).toString(32)+n,t=`_`+t+`R_`+n,n=Jo++,0<n&&(t+=`H`+n.toString(32)),t+=`_`}else n=Zo++,t=`_`+t+`r_`+n.toString(32)+`_`;return e.memoizedState=t},useHostTransitionStatus:ac,useFormState:Ms,useActionState:Ms,useOptimistic:function(e){var t=ss();t.memoizedState=t.baseState=e;var n={pending:null,lanes:0,dispatch:null,lastRenderedReducer:null,lastRenderedState:null};return t.queue=n,t=fc.bind(null,Ho,!0,n),n.dispatch=t,[e,t]},useMemoCache:fs,useCacheRefresh:function(){return ss().memoizedState=cc.bind(null,Ho)},useEffectEvent:function(e){var t=ss(),n={impl:e};return t.memoizedState=n,function(){if(rd&2)throw Error(i(440));return n.impl.apply(void 0,arguments)}}},vc={readContext:wa,use:ds,useCallback:Xs,useContext:wa,useEffect:Hs,useImperativeHandle:Js,useInsertionEffect:Gs,useLayoutEffect:Ks,useMemo:Zs,useReducer:ms,useRef:Rs,useState:function(){return ms(ps)},useDebugValue:Ys,useDeferredValue:function(e,t){return $s(cs(),Uo.memoizedState,e,t)},useTransition:function(){var e=ms(ps)[0],t=cs().memoizedState;return[typeof e==`boolean`?e:us(e),t]},useSyncExternalStore:_s,useId:oc,useHostTransitionStatus:ac,useFormState:Ns,useActionState:Ns,useOptimistic:function(e,t){return ws(cs(),Uo,e,t)},useMemoCache:fs,useCacheRefresh:sc,useEffectEvent:Ws},yc={readContext:wa,use:ds,useCallback:Xs,useContext:wa,useEffect:Hs,useImperativeHandle:Js,useInsertionEffect:Gs,useLayoutEffect:Ks,useMemo:Zs,useReducer:gs,useRef:Rs,useState:function(){return gs(ps)},useDebugValue:Ys,useDeferredValue:function(e,t){var n=cs();return Uo===null?Qs(n,e,t):$s(n,Uo.memoizedState,e,t)},useTransition:function(){var e=gs(ps)[0],t=cs().memoizedState;return[typeof e==`boolean`?e:us(e),t]},useSyncExternalStore:_s,useId:oc,useHostTransitionStatus:ac,useFormState:Is,useActionState:Is,useOptimistic:function(e,t){var n=cs();return Uo===null?(n.baseState=e,[e,n.queue.dispatch]):ws(n,Uo,e,t)},useMemoCache:fs,useCacheRefresh:sc,useEffectEvent:Ws};function bc(e,t,n,r){t=e.memoizedState,n=n(r,t),n=n==null?t:w({},t,n),e.memoizedState=n,e.lanes===0&&(e.updateQueue.baseState=n)}var xc={enqueueSetState:function(e,t,n){e=e._reactInternals;var r=zd(),i=go(r);i.payload=t,n!=null&&(i.callback=n),t=_o(e,i,r),t!==null&&(Hd(t,e,r),vo(t,e,r))},enqueueReplaceState:function(e,t,n){e=e._reactInternals;var r=zd(),i=go(r);i.tag=1,i.payload=t,n!=null&&(i.callback=n),t=_o(e,i,r),t!==null&&(Hd(t,e,r),vo(t,e,r))},enqueueForceUpdate:function(e,t){e=e._reactInternals;var n=zd(),r=go(n);r.tag=2,t!=null&&(r.callback=t),t=_o(e,r,n),t!==null&&(Hd(t,e,n),vo(t,e,n))}};function Sc(e,t,n,r,i,a,o){return e=e.stateNode,typeof e.shouldComponentUpdate==`function`?e.shouldComponentUpdate(r,a,o):t.prototype&&t.prototype.isPureReactComponent?!Br(n,r)||!Br(i,a):!0}function Cc(e,t,n,r){e=t.state,typeof t.componentWillReceiveProps==`function`&&t.componentWillReceiveProps(n,r),typeof t.UNSAFE_componentWillReceiveProps==`function`&&t.UNSAFE_componentWillReceiveProps(n,r),t.state!==e&&xc.enqueueReplaceState(t,t.state,null)}function wc(e,t){var n=t;if(`ref`in t)for(var r in n={},t)r!==`ref`&&(n[r]=t[r]);if(e=e.defaultProps)for(var i in n===t&&(n=w({},n)),e)n[i]===void 0&&(n[i]=e[i]);return n}function Tc(e){vi(e)}function Ec(e){console.error(e)}function Dc(e){vi(e)}function Oc(e,t){try{var n=e.onUncaughtError;n(t.value,{componentStack:t.stack})}catch(e){setTimeout(function(){throw e})}}function kc(e,t,n){try{var r=e.onCaughtError;r(n.value,{componentStack:n.stack,errorBoundary:t.tag===1?t.stateNode:null})}catch(e){setTimeout(function(){throw e})}}function Ac(e,t,n){return n=go(n),n.tag=3,n.payload={element:null},n.callback=function(){Oc(e,t)},n}function jc(e){return e=go(e),e.tag=3,e}function Mc(e,t,n,r){var i=n.type.getDerivedStateFromError;if(typeof i==`function`){var a=r.value;e.payload=function(){return i(a)},e.callback=function(){kc(t,n,r)}}var o=n.stateNode;o!==null&&typeof o.componentDidCatch==`function`&&(e.callback=function(){kc(t,n,r),typeof i!=`function`&&(Ed===null?Ed=new Set([this]):Ed.add(this));var e=r.stack;this.componentDidCatch(r.value,{componentStack:e===null?``:e})})}function Nc(e,t,n,r,a){if(n.flags|=32768,typeof r==`object`&&r&&typeof r.then==`function`){if(t=n.alternate,t!==null&&xa(t,n,a,!0),n=Ao.current,n!==null){switch(n.tag){case 31:case 13:case 19:return jo===null?ef():n.alternate===null&&pd===0&&(pd=3),n.flags&=-257,n.flags|=65536,n.lanes=a,r===Za?n.flags|=16384:(t=n.updateQueue,t===null?n.updateQueue=new Set([r]):t.add(r),Cf(e,r,a)),!1;case 22:return n.flags|=65536,r===Za?n.flags|=16384:(t=n.updateQueue,t===null?(t={transitions:null,markerInstances:null,retryQueue:new Set([r])},n.updateQueue=t):(n=t.retryQueue,n===null?t.retryQueue=new Set([r]):n.add(r)),Cf(e,r,a)),!1}throw Error(i(435,n.tag))}return Cf(e,r,a),ef(),!1}if(ra)return t=Ao.current,t===null?(r!==oa&&(t=Error(i(423),{cause:r}),pa(Bi(t,n))),e=e.current.alternate,e.flags|=65536,a&=-a,e.lanes|=a,r=Bi(r,n),a=Ac(e.stateNode,r,a),yo(e,a),pd!==4&&(pd=2)):(!(t.flags&65536)&&(t.flags|=256),t.flags|=65536,t.lanes=a,r!==oa&&(e=Error(i(422),{cause:r}),pa(Bi(e,n)))),!1;var o=Error(i(520),{cause:r});if(o=Bi(o,n),yd===null?yd=[o]:yd.push(o),pd!==4&&(pd=2),t===null)return!0;r=Bi(r,n),n=t;do{switch(n.tag){case 3:return n.flags|=65536,e=a&-a,n.lanes|=e,e=Ac(n.stateNode,r,e),yo(n,e),!1;case 1:if(t=n.type,o=n.stateNode,!(n.flags&128)&&(typeof t.getDerivedStateFromError==`function`||o!==null&&typeof o.componentDidCatch==`function`&&(Ed===null||!Ed.has(o))))return n.flags|=65536,a&=-a,n.lanes|=a,a=jc(a),Mc(a,e,n,r),yo(n,a),!1;break;case 22:if(n.memoizedState!==null)return n.flags|=65536,!1}n=n.return}while(n!==null);return!1}var Pc=Error(i(461)),Fc=!1;function Ic(e,t,n,r){t.child=e===null?fo(t,null,n,r):uo(t,e.child,n,r)}function Lc(e,t,n,r,i){n=n.render;var a=t.ref;if(`ref`in r){var o={};for(var s in r)s!==`ref`&&(o[s]=r[s])}else o=r;return Ca(t),r=es(e,t,n,o,a,i),s=is(),e!==null&&!Fc?(as(e,t,i),ul(e,t,i)):(ra&&s&&Qi(t),t.flags|=1,Ic(e,t,r,i),t.child)}function Rc(e,t,n,r,i){if(e===null){var a=n.type;return typeof a==`function`&&!ji(a)&&a.defaultProps===void 0&&n.compare===null?(t.tag=15,t.type=a,zc(e,t,a,r,i)):(e=Pi(n.type,null,r,t,t.mode,i),e.ref=t.ref,e.return=t,t.child=e)}if(a=e.child,!dl(e,i)){var o=a.memoizedProps;if(n=n.compare,n=n===null?Br:n,n(o,r)&&e.ref===t.ref)return ul(e,t,i)}return t.flags|=1,e=Mi(a,r),e.ref=t.ref,e.return=t,t.child=e}function zc(e,t,n,r,i){if(e!==null){var a=e.memoizedProps;if(Br(a,r)&&e.ref===t.ref){if(Fc=!1,t.pendingProps=r=a,dl(e,i))e.flags&131072&&(Fc=!0);else return t.lanes=e.lanes,ul(e,t,i)}}return Kc(e,t,n,r,i)}function Bc(e,t,n,r){var i=r.children,a=e===null?null:e.memoizedState;if(e===null&&t.stateNode===null&&(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),r.mode===`hidden`){if(t.flags&128){if(a=a===null?n:a.baseLanes|n,e!==null){for(r=t.child=e.child,i=0;r!==null;)i=i|r.lanes|r.childLanes,r=r.sibling;r=i&~a}else r=0,t.child=null;return Hc(e,t,a,n,r)}if(n&536870912)t.memoizedState={baseLanes:0,cachePool:null},e!==null&&Ka(t,a===null?null:a.cachePool),a===null?Oo():Do(t,a),Po(t);else return r=t.lanes=536870912,Hc(e,t,a===null?n:a.baseLanes|n,n,r)}else a===null?(e!==null&&Ka(t,null),Oo(),Fo()):(Ka(t,a.cachePool),Do(t,a),Fo(),t.memoizedState=null);return Ic(e,t,i,n),t.child}function Vc(e,t){return e!==null&&e.tag===22||t.stateNode!==null||(t.stateNode={_visibility:1,_pendingMarkers:null,_retryCache:null,_transitions:null}),t.sibling}function Hc(e,t,n,r,i){var a=Ga();return a=a===null?null:{parent:Aa._currentValue,pool:a},t.memoizedState={baseLanes:n,cachePool:a},e!==null&&Ka(t,null),Oo(),Po(t),e!==null&&xa(e,t,r,!0),t.childLanes=i,null}function Uc(e,t){return t=tl({mode:t.mode,children:t.children},e.mode),t.ref=e.ref,e.child=t,t.return=e,t}function H(e,t,n){return uo(t,e.child,null,n),e=Uc(t,t.pendingProps),e.flags|=2,Io(t),t.memoizedState=null,e}function Wc(e,t,n){var r=t.pendingProps,a=!!(t.flags&128);if(t.flags&=-129,e===null){if(ra){if(r.mode===`hidden`)return e=Uc(t,r),t.lanes=536870912,e.memoizedState={baseLanes:0,cachePool:null},Vc(null,e);if(No(t),(e=na)?(e=gm(e,aa),e=e!==null&&e.data===`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:qi===null?null:{id:Ji,overflow:Yi},retryLane:536870912,hydrationErrors:null},n=Li(e),n.return=t,t.child=n,ta=t,na=null)):e=null,e===null)throw sa(t);return t.lanes=536870912,null}return Uc(t,r)}var o=e.memoizedState;if(o!==null){var s=o.dehydrated;if(No(t),a){if(t.flags&256)t.flags&=-257,t=H(e,t,n);else if(t.memoizedState!==null)t.child=e.child,t.flags|=128,t=null;else throw Error(i(558))}else if(Fc||xa(e,t,n,!1),a=(n&e.childLanes)!==0,Fc||a){if(To.current===null){if(r=id,r!==null&&(s=pt(r,n),s!==0&&s!==o.retryLane))throw o.retryLane=s,Ti(e,s),Hd(r,e,s),Pc;ef()}t=H(e,t,n)}else e=o.treeContext,na=bm(s.nextSibling),ta=t,ra=!0,ia=null,aa=!1,e!==null&&ea(t,e),t=Uc(t,r),t.flags|=134221824;return t}return e=Mi(e.child,{mode:r.mode,children:r.children}),e.ref=t.ref,t.child=e,e.return=t,e}function Gc(e,t){var n=t.ref;if(n===null)e!==null&&e.ref!==null&&(t.flags|=4194816);else{if(typeof n!=`function`&&typeof n!=`object`)throw Error(i(284));(e===null||e.ref!==n)&&(t.flags|=4194816)}}function Kc(e,t,n,r,i){return Ca(t),n=es(e,t,n,r,void 0,i),r=is(),e!==null&&!Fc?(as(e,t,i),ul(e,t,i)):(ra&&r&&Qi(t),t.flags|=1,Ic(e,t,n,i),t.child)}function qc(e,t,n,r,i,a){return Ca(t),t.updateQueue=null,n=ns(t,r,n,i),ts(e),r=is(),e!==null&&!Fc?(as(e,t,a),ul(e,t,a)):(ra&&r&&Qi(t),t.flags|=1,Ic(e,t,n,a),t.child)}function Jc(e,t,n,r,i){if(Ca(t),t.stateNode===null){var a=Oi,o=n.contextType;typeof o==`object`&&o&&(a=wa(o)),a=new n(r,a),t.memoizedState=a.state!==null&&a.state!==void 0?a.state:null,a.updater=xc,t.stateNode=a,a._reactInternals=t,a=t.stateNode,a.props=r,a.state=t.memoizedState,a.refs={},mo(t),o=n.contextType,a.context=typeof o==`object`&&o?wa(o):Oi,a.state=t.memoizedState,o=n.getDerivedStateFromProps,typeof o==`function`&&(bc(t,n,o,r),a.state=t.memoizedState),typeof n.getDerivedStateFromProps==`function`||typeof a.getSnapshotBeforeUpdate==`function`||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(o=a.state,typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount(),o!==a.state&&xc.enqueueReplaceState(a,a.state,null),So(t,r,a,i),xo(),a.state=t.memoizedState),typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!0}else if(e===null){a=t.stateNode;var s=t.memoizedProps,c=wc(n,s);a.props=c;var l=a.context,u=n.contextType;o=Oi,typeof u==`object`&&u&&(o=wa(u));var d=n.getDerivedStateFromProps;u=typeof d==`function`||typeof a.getSnapshotBeforeUpdate==`function`,s=t.pendingProps!==s,u||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(s||l!==o)&&Cc(t,a,r,o),po=!1;var f=t.memoizedState;a.state=f,So(t,r,a,i),xo(),l=t.memoizedState,s||f!==l||po?(typeof d==`function`&&(bc(t,n,d,r),l=t.memoizedState),(c=po||Sc(t,n,c,r,f,l,o))?(u||typeof a.UNSAFE_componentWillMount!=`function`&&typeof a.componentWillMount!=`function`||(typeof a.componentWillMount==`function`&&a.componentWillMount(),typeof a.UNSAFE_componentWillMount==`function`&&a.UNSAFE_componentWillMount()),typeof a.componentDidMount==`function`&&(t.flags|=4194308)):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),t.memoizedProps=r,t.memoizedState=l),a.props=r,a.state=l,a.context=o,r=c):(typeof a.componentDidMount==`function`&&(t.flags|=4194308),r=!1)}else{a=t.stateNode,ho(e,t),o=t.memoizedProps,u=wc(n,o),a.props=u,d=t.pendingProps,f=a.context,l=n.contextType,c=Oi,typeof l==`object`&&l&&(c=wa(l)),s=n.getDerivedStateFromProps,(l=typeof s==`function`||typeof a.getSnapshotBeforeUpdate==`function`)||typeof a.UNSAFE_componentWillReceiveProps!=`function`&&typeof a.componentWillReceiveProps!=`function`||(o!==d||f!==c)&&Cc(t,a,r,c),po=!1,f=t.memoizedState,a.state=f,So(t,r,a,i),xo();var p=t.memoizedState;o!==d||f!==p||po||e!==null&&e.dependencies!==null&&Sa(e.dependencies)?(typeof s==`function`&&(bc(t,n,s,r),p=t.memoizedState),(u=po||Sc(t,n,u,r,f,p,c)||e!==null&&e.dependencies!==null&&Sa(e.dependencies))?(l||typeof a.UNSAFE_componentWillUpdate!=`function`&&typeof a.componentWillUpdate!=`function`||(typeof a.componentWillUpdate==`function`&&a.componentWillUpdate(r,p,c),typeof a.UNSAFE_componentWillUpdate==`function`&&a.UNSAFE_componentWillUpdate(r,p,c)),typeof a.componentDidUpdate==`function`&&(t.flags|=4),typeof a.getSnapshotBeforeUpdate==`function`&&(t.flags|=1024)):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),t.memoizedProps=r,t.memoizedState=p),a.props=r,a.state=p,a.context=c,r=u):(typeof a.componentDidUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=4),typeof a.getSnapshotBeforeUpdate!=`function`||o===e.memoizedProps&&f===e.memoizedState||(t.flags|=1024),r=!1)}return a=r,Gc(e,t),r=!!(t.flags&128),a||r?(a=t.stateNode,n=r&&typeof n.getDerivedStateFromError!=`function`?null:a.render(),t.flags|=1,e!==null&&r?(t.child=uo(t,e.child,null,i),t.child=uo(t,null,n,i)):Ic(e,t,n,i),t.memoizedState=a.state,e=t.child):e=ul(e,t,i),e}function Yc(e,t,n,r){return da(),t.flags|=256,Ic(e,t,n,r),t.child}var Xc={dehydrated:null,treeContext:null,retryLane:0,hydrationErrors:null};function Zc(e){return{baseLanes:e,cachePool:qa()}}function Qc(e,t,n){return e=e===null?0:e.childLanes&~n,t&&(e|=_d),e}function $c(e,t,n){var r=t.pendingProps,i=!1,a=!!(t.flags&128),o;if((o=a)||(o=e!==null&&e.memoizedState===null?!1:!!(Lo.current&2)),o&&(i=!0,t.flags&=-129),o=!!(t.flags&32),t.flags&=-33,e===null){if(ra){if(i?Mo(t):Fo(),(e=na)?(e=gm(e,aa),e=e!==null&&e.data!==`&`?e:null,e!==null&&(t.memoizedState={dehydrated:e,treeContext:qi===null?null:{id:Ji,overflow:Yi},retryLane:536870912,hydrationErrors:null},n=Li(e),n.return=t,t.child=n,ta=t,na=null)):e=null,e===null)throw sa(t);return t.lanes=vm(e)?32:536870912,null}return a=r.children,r=r.fallback,i?(Fo(),i=t.mode,a=tl({mode:`hidden`,children:a},i),r=Fi(r,i,n,null),a.return=t,r.return=t,a.sibling=r,t.child=a,r=t.child,r.memoizedState=Zc(n),r.childLanes=Qc(e,o,n),t.memoizedState=Xc,Vc(null,r)):(Mo(t),el(t,a))}var s=e.memoizedState;if(s!==null){var c=s.dehydrated;if(c!==null)return rl(e,t,a,o,r,c,s,n)}return i?(Fo(),i=r.fallback,a=t.mode,s=e.child,c=s.sibling,r=Mi(s,{mode:`hidden`,children:r.children}),r.subtreeFlags=s.subtreeFlags&1206910976,c===null?(i=Fi(i,a,n,null),i.flags|=2):i=Mi(c,i),i.return=t,r.return=t,r.sibling=i,t.child=r,Vc(null,r),r=t.child,i=e.child.memoizedState,i===null?i=Zc(n):(a=i.cachePool,a===null?a=qa():(s=Aa._currentValue,a=a.parent===s?a:{parent:s,pool:s}),i={baseLanes:i.baseLanes|n,cachePool:a}),r.memoizedState=i,r.childLanes=Qc(e,o,n),t.memoizedState=Xc,Vc(e.child,r)):(Mo(t),n=e.child,e=n.sibling,n=Mi(n,{mode:`visible`,children:r.children}),n.return=t,n.sibling=null,e!==null&&(o=t.deletions,o===null?(t.deletions=[e],t.flags|=16):o.push(e)),t.child=n,t.memoizedState=null,n)}function el(e,t){return t=tl({mode:`visible`,children:t},e.mode),t.return=e,e.child=t}function tl(e,t){return e=Ai(22,e,null,t),e.lanes=0,e}function nl(e,t,n){return uo(t,e.child,null,n),e=el(t,t.pendingProps.children),e.flags|=2,t.memoizedState=null,e}function rl(e,t,n,r,a,o,s,c){if(n)return t.flags&256?(Mo(t),t.flags&=-257,nl(e,t,c)):t.memoizedState===null?(Fo(),o=a.fallback,s=t.mode,a=tl({mode:`visible`,children:a.children},s),o=Fi(o,s,c,null),o.flags|=2,a.return=t,o.return=t,a.sibling=o,t.child=a,uo(t,e.child,null,c),a=t.child,a.memoizedState=Zc(c),a.childLanes=Qc(e,r,c),t.memoizedState=Xc,Vc(null,a)):(Fo(),t.child=e.child,t.flags|=128,null);if(Mo(t),vm(o)){if(r=o.nextSibling&&o.nextSibling.dataset,r)var l=r.dgst;return r=l,r!==``&&(a=Error(i(419)),a.stack=``,a.digest=r,pa({value:a,source:null,stack:null})),nl(e,t,c)}if(Fc||xa(e,t,c,!1),r=(c&e.childLanes)!==0,Fc||r){if(To.current!==null)return nl(e,t,c);if(r=id,r!==null&&(a=pt(r,c),a!==0&&a!==s.retryLane))throw s.retryLane=a,Ti(e,a),Hd(r,e,a),Pc;return _m(o)||ef(),nl(e,t,c)}return _m(o)?(t.flags|=192,t.child=e.child,null):(e=s.treeContext,na=bm(o.nextSibling),ta=t,ra=!0,ia=null,aa=!1,e!==null&&ea(t,e),t=el(t,a.children),t.flags|=134221824,t)}function il(e,t,n){e.lanes|=t;var r=e.alternate;r!==null&&(r.lanes|=t),ya(e.return,t,n)}function al(e){for(var t=null;e!==null;){var n=e.alternate;n!==null&&Bo(n)===null&&(t=e),e=e.sibling}return t}function ol(e,t,n,r,i,a){var o=e.memoizedState;o===null?e.memoizedState={isBackwards:t,rendering:null,renderingStartTime:0,last:r,tail:n,tailMode:i,treeForkCount:a}:(o.isBackwards=t,o.rendering=null,o.renderingStartTime=0,o.last=r,o.tail=n,o.tailMode=i,o.treeForkCount=a)}function sl(e){var t=e.child;for(e.child=null;t!==null;){var n=t.sibling;t.sibling=e.child,e.child=t,t=n}}function cl(e,t,n){var r=t.pendingProps,i=r.revealOrder,a=r.tail;r=r.children;var o=Lo.current;if(t.flags&128)return Ro(t,o),null;var s=!!(o&2);if(s?(o=o&1|2,t.flags|=128):o&=1,Ro(t,o),i===`backwards`&&e!==null?(sl(e),Ic(e,t,r,n),sl(e)):Ic(e,t,r,n),r=ra?Wi:0,!s&&e!==null&&e.flags&128)a:for(e=t.child;e!==null;){if(e.tag===13)e.memoizedState!==null&&il(e,n,t);else if(e.tag===19)il(e,n,t);else if(e.child!==null){e.child.return=e,e=e.child;continue}if(e===t)break a;for(;e.sibling===null;){if(e.return===null||e.return===t)break a;e=e.return}e.sibling.return=e.return,e=e.sibling}switch(i){case`backwards`:n=al(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null,sl(t)),ol(t,!0,i,null,a,r);break;case`unstable_legacy-backwards`:for(n=null,i=t.child,t.child=null;i!==null;){if(e=i.alternate,e!==null&&Bo(e)===null){t.child=i;break}e=i.sibling,i.sibling=n,n=i,i=e}ol(t,!0,n,null,a,r);break;case`together`:ol(t,!1,null,null,void 0,r);break;case`independent`:t.memoizedState=null;break;default:n=al(t.child),n===null?(i=t.child,t.child=null):(i=n.sibling,n.sibling=null),ol(t,!1,i,n,a,r)}return t.child}function ll(e,t,n){var r=t.pendingProps;return _a(t,t.type,r.value),Ic(e,t,r.children,n),t.child}function ul(e,t,n){if(e!==null&&(t.dependencies=e.dependencies),md|=t.lanes,(n&t.childLanes)===0){if(e!==null){if(xa(e,t,n,!1),(n&t.childLanes)===0)return null}else return null}if(e!==null&&t.child!==e.child)throw Error(i(153));if(t.child!==null){for(e=t.child,n=Mi(e,e.pendingProps),t.child=n,n.return=t;e.sibling!==null;)e=e.sibling,n=n.sibling=Mi(e,e.pendingProps),n.return=t;n.sibling=null}return t.child}function dl(e,t){return(e.lanes&t)!==0||(e=e.dependencies,!!(e!==null&&Sa(e)))}function fl(e,t,n){switch(t.tag){case 3:xe(t,t.stateNode.containerInfo),_a(t,Aa,e.memoizedState.cache),da();break;case 27:case 5:Ce(t);break;case 4:xe(t,t.stateNode.containerInfo);break;case 10:_a(t,t.type,t.memoizedProps.value);break;case 31:if(t.memoizedState!==null)return t.flags|=128,No(t),null;break;case 13:var r=t.memoizedState;if(r!==null){if(r.dehydrated!==null)return Mo(t),t.flags|=128,null;r=xa(e,t,n,!1);var i=t.child.childLanes;return r||(n&i)!==0?$c(e,t,n):(Mo(t),e=ul(e,t,n),e===null?null:e.sibling)}Mo(t);break;case 19:if(t.flags&128)return cl(e,t,n);if(i=!!(e.flags&128),r=(n&t.childLanes)!==0,r||=(xa(e,t,n,!1),(n&t.childLanes)!==0),i){if(r)return cl(e,t,n);t.flags|=128}if(i=t.memoizedState,i!==null&&(i.rendering=null,i.tail=null,i.lastEffect=null),Ro(t,Lo.current),r)break;return null;case 22:return t.lanes=0,Bc(e,t,n,t.pendingProps);case 24:_a(t,Aa,e.memoizedState.cache)}return ul(e,t,n)}function pl(e,t,n){if(e!==null){if(e.memoizedProps!==t.pendingProps)Fc=!0;else{if(!dl(e,n)&&!(t.flags&128))return Fc=!1,fl(e,t,n);Fc=!!(e.flags&131072)}}else Fc=!1,ra&&t.flags&1048576&&Zi(t,Wi,t.index);switch(t.lanes=0,t.tag){case 16:a:{var r=t.pendingProps;if(e=eo(t.elementType),t.type=e,typeof e==`function`)ji(e)?(r=wc(e,r),t.tag=1,t=Jc(null,t,e,r,n)):(t.tag=0,t=Kc(null,t,e,r,n));else{if(e!=null){var a=e.$$typeof;if(a===P){t.tag=11,t=Lc(null,t,e,r,n);break a}if(a===ne){t.tag=14,t=Rc(null,t,e,r,n);break a}if(a===N){t.tag=10,t.type=e,t=ll(null,t,n);break a}}throw t=ce(e)||e,Error(i(306,t,``))}}return t;case 0:return Kc(e,t,t.type,t.pendingProps,n);case 1:return r=t.type,a=wc(r,t.pendingProps),Jc(e,t,r,a,n);case 3:a:{if(xe(t,t.stateNode.containerInfo),e===null)throw Error(i(387));r=t.pendingProps;var o=t.memoizedState;a=o.element,ho(e,t),So(t,r,null,n);var s=t.memoizedState;if(r=s.cache,_a(t,Aa,r),r!==o.cache&&ba(t,[Aa],n,!0),xo(),r=s.element,o.isDehydrated){if(o={element:r,isDehydrated:!1,cache:s.cache},t.updateQueue.baseState=o,t.memoizedState=o,t.flags&256){t=Yc(e,t,r,n);break a}if(r!==a){a=Bi(Error(i(424)),t),pa(a),t=Yc(e,t,r,n);break a}switch(e=t.stateNode.containerInfo,e.nodeType){case 9:e=e.body;break;default:e=e.nodeName===`HTML`?e.ownerDocument.body:e}for(na=bm(e.firstChild),ta=t,ra=!0,ia=null,aa=!0,n=fo(t,null,r,n),t.child=n;n;)n.flags=n.flags&-3|134221824,n=n.sibling}else{if(da(),r===a){t=ul(e,t,n);break a}Ic(e,t,r,n)}t=t.child}return t;case 26:return Gc(e,t),e===null?(n=Wm(t.type,null,t.pendingProps,null))?t.memoizedState=n:ra||(t.stateNode=Cp(t.type,t.pendingProps,ye.current,t)):t.memoizedState=Wm(t.type,e.memoizedProps,t.pendingProps,e.memoizedState),null;case 27:return Ce(t),e===null&&ra&&(r=t.stateNode=Em(t.type,t.pendingProps,ye.current),ta=t,aa=!0,a=na,Np(t.type)?(xm=a,na=bm(r.firstChild)):na=a),Ic(e,t,t.pendingProps.children,n),Gc(e,t),e===null&&(t.flags|=4194304),t.child;case 5:return e===null&&ra&&((a=r=na)&&(r=mm(r,t.type,t.pendingProps,aa),r===null?a=!1:(t.stateNode=r,ta=t,na=bm(r.firstChild),aa=!1,a=!0)),a||sa(t)),Ce(t),a=t.type,o=t.pendingProps,s=e===null?null:e.memoizedProps,r=o.children,wp(a,o)?r=null:s!==null&&wp(a,s)&&(t.flags|=32),t.memoizedState!==null&&(a=es(e,t,rs,null,null,n),_h._currentValue=a),Gc(e,t),Ic(e,t,r,n),t.child;case 6:return e===null&&ra&&((e=n=na)&&(n=hm(n,t.pendingProps,aa),n===null?e=!1:(t.stateNode=n,ta=t,na=null,e=!0)),e||sa(t)),null;case 13:return $c(e,t,n);case 4:return xe(t,t.stateNode.containerInfo),r=t.pendingProps,e===null?t.child=uo(t,null,r,n):Ic(e,t,r,n),t.child;case 11:return Lc(e,t,t.type,t.pendingProps,n);case 7:return r=t.pendingProps,Gc(e,t),Ic(e,t,r,n),t.child;case 8:return Ic(e,t,t.pendingProps.children,n),t.child;case 12:return Ic(e,t,t.pendingProps.children,n),t.child;case 10:return ll(e,t,n);case 9:return a=t.type._context,r=t.pendingProps.children,Ca(t),a=wa(a),r=r(a),t.flags|=1,Ic(e,t,r,n),t.child;case 14:return Rc(e,t,t.type,t.pendingProps,n);case 15:return zc(e,t,t.type,t.pendingProps,n);case 19:return cl(e,t,n);case 31:return Wc(e,t,n);case 22:return Bc(e,t,n,t.pendingProps);case 24:return Ca(t),r=wa(Aa),e===null?(a=Ga(),a===null&&(a=id,o=ja(),a.pooledCache=o,o.refCount++,o!==null&&(a.pooledCacheLanes|=n),a=o),t.memoizedState={parent:r,cache:a},mo(t),_a(t,Aa,a)):((e.lanes&n)!==0&&(ho(e,t),So(t,null,null,n),xo()),a=e.memoizedState,o=t.memoizedState,a.parent===r?(r=o.cache,_a(t,Aa,r),r!==a.cache&&ba(t,[Aa],n,!0)):(a={parent:r,cache:r},t.memoizedState=a,t.lanes===0&&(t.memoizedState=t.updateQueue.baseState=a),_a(t,Aa,r))),Ic(e,t,t.pendingProps.children,n),t.child;case 30:return t.stateNode===null&&(t.stateNode={autoName:null,paired:null,clones:null,ref:null}),r=t.pendingProps,r.name!=null&&r.name!==`auto`?t.flags|=e===null?18882560:18874368:ra&&Qi(t),e!==null&&e.memoizedProps.name!==r.name?t.flags|=4194816:Gc(e,t),Ic(e,t,r.children,n),t.child;case 29:throw t.pendingProps}throw Error(i(156,t.tag))}function ml(e){e.flags|=4}function hl(e,t,n,r,i){var a;if((a=!!(e.mode&32))&&(a=n===null?ih(t,r):ih(t,r)&&(r.src!==n.src||r.srcSet!==n.srcSet)),a){if(e.flags|=16777216,(i&335544128)===i){if(e.stateNode.complete)e.flags|=8192;else if(Zd())e.flags|=8192;else throw to=Za,Ya}}else e.flags&=-16777217}function gl(e,t){if(t.type!==`stylesheet`||t.state.loading&4)e.flags&=-16777217;else if(e.flags|=16777216,!ah(t)){if(Zd())e.flags|=8192;else throw to=Za,Ya}}function _l(e,t){t!==null&&(e.flags|=4),e.flags&16384&&(t=e.tag===22?536870912:st(),e.lanes|=t,vd|=t)}function vl(e,t){if(!ra)switch(e.tailMode){case`visible`:break;case`collapsed`:for(var n=e.tail,r=null;n!==null;)n.alternate!==null&&(r=n),n=n.sibling;r===null?t||e.tail===null?e.tail=null:e.tail.sibling=null:r.sibling=null;break;default:for(t=e.tail,n=null;t!==null;)t.alternate!==null&&(n=t),t=t.sibling;n===null?e.tail=null:n.sibling=null}}function yl(e){var t=e.alternate!==null&&e.alternate.child===e.child,n=0,r=0;if(t)for(var i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags&1206910976,r|=i.flags&1206910976,i.return=e,i=i.sibling;else for(i=e.child;i!==null;)n|=i.lanes|i.childLanes,r|=i.subtreeFlags,r|=i.flags,i.return=e,i=i.sibling;return e.subtreeFlags|=r,e.childLanes=n,t}function bl(e,t,n){var r=t.pendingProps;switch($i(t),t.tag){case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return yl(t),null;case 1:return yl(t),null;case 3:return n=t.stateNode,r=null,e!==null&&(r=e.memoizedState.cache),t.memoizedState.cache!==r&&(t.flags|=2048),va(Aa),Se(),n.pendingContext&&(n.context=n.pendingContext,n.pendingContext=null),(e===null||e.child===null)&&(ua(t)?ml(t):e===null||e.memoizedState.isDehydrated&&!(t.flags&256)||(t.flags|=1024,fa())),yl(t),null;case 26:var a=t.type,o=t.memoizedState;return e===null?(ml(t),o===null?(yl(t),hl(t,a,null,r,n)):(yl(t),gl(t,o))):o?o===e.memoizedState?(yl(t),t.flags&=-16777217):(ml(t),yl(t),gl(t,o)):(e=e.memoizedProps,e!==r&&ml(t),yl(t),hl(t,a,e,r,n)),null;case 27:if(we(t),n=ye.current,a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ml(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return yl(t),t.subtreeFlags&=-33554433,null}e=_e.current,ua(t)?ca(t,e):(e=Em(a,r,n),t.stateNode=e,ml(t))}return yl(t),t.subtreeFlags&=-33554433,null;case 5:if(we(t),a=t.type,e!==null&&t.stateNode!=null)e.memoizedProps!==r&&ml(t);else{if(!r){if(t.stateNode===null)throw Error(i(166));return yl(t),t.subtreeFlags&=-33554433,null}if(o=_e.current,ua(t))ca(t,o);else{var s=bp(ye.current);switch(o){case 1:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case 2:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;default:switch(a){case`svg`:o=s.createElementNS(`http://www.w3.org/2000/svg`,a);break;case`math`:o=s.createElementNS(`http://www.w3.org/1998/Math/MathML`,a);break;case`script`:o=s.createElement(`div`),o.innerHTML=`<script><\/script>`,o=o.removeChild(o.firstChild);break;case`select`:o=typeof r.is==`string`?s.createElement(`select`,{is:r.is}):s.createElement(`select`),r.multiple?o.multiple=!0:r.size&&(o.size=r.size);break;default:o=typeof r.is==`string`?s.createElement(a,{is:r.is}):s.createElement(a)}}o[yt]=t,o[bt]=r;a:for(s=t.child;s!==null;){if(s.tag===5||s.tag===6)o.appendChild(s.stateNode);else if(s.tag!==4&&s.tag!==27&&s.child!==null){s.child.return=s,s=s.child;continue}if(s===t)break a;for(;s.sibling===null;){if(s.return===null||s.return===t)break a;s=s.return}s.sibling.return=s.return,s=s.sibling}t.stateNode=o;a:switch(pp(o,a,r),a){case`button`:case`input`:case`select`:case`textarea`:r=!!r.autoFocus;break a;case`img`:r=!0;break a;default:r=!1}r&&ml(t)}}return yl(t),t.subtreeFlags&=-33554433,hl(t,t.type,e===null?null:e.memoizedProps,t.pendingProps,n),null;case 6:if(e&&t.stateNode!=null)e.memoizedProps!==r&&ml(t);else{if(typeof r!=`string`&&t.stateNode===null)throw Error(i(166));if(e=ye.current,ua(t)){if(e=t.stateNode,n=t.memoizedProps,r=null,a=ta,a!==null)switch(a.tag){case 27:case 5:r=a.memoizedProps}e[yt]=t,e=!!(e.nodeValue===n||r!==null&&!0===r.suppressHydrationWarning||up(e.nodeValue,n)),e||sa(t,!0)}else e=bp(e).createTextNode(r),e[yt]=t,t.stateNode=e}return yl(t),null;case 31:if(n=t.memoizedState,e===null||e.memoizedState!==null){if(r=ua(t),n!==null){if(e===null){if(!r)throw Error(i(318));if(e=t.memoizedState,e=e===null?null:e.dehydrated,!e)throw Error(i(557));e[yt]=t}else da(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;yl(t),e=!1}else n=fa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=n),e=!0;if(!e)return t.flags&256?(Io(t),t):(Io(t),null);if(t.flags&128)throw Error(i(558))}return yl(t),null;case 13:if(r=t.memoizedState,e===null||e.memoizedState!==null&&e.memoizedState.dehydrated!==null){if(a=ua(t),r!==null&&r.dehydrated!==null){if(e===null){if(!a)throw Error(i(318));if(a=t.memoizedState,a=a===null?null:a.dehydrated,!a)throw Error(i(317));a[yt]=t}else da(),!(t.flags&128)&&(t.memoizedState=null),t.flags|=4;yl(t),a=!1}else a=fa(),e!==null&&e.memoizedState!==null&&(e.memoizedState.hydrationErrors=a),a=!0;if(!a)return t.flags&256?(Io(t),t):(Io(t),null)}return Io(t),t.flags&128?(t.lanes=n,t):(n=r!==null,e=e!==null&&e.memoizedState!==null,n&&(r=t.child,a=null,r.alternate!==null&&r.alternate.memoizedState!==null&&r.alternate.memoizedState.cachePool!==null&&(a=r.alternate.memoizedState.cachePool.pool),o=null,r.memoizedState!==null&&r.memoizedState.cachePool!==null&&(o=r.memoizedState.cachePool.pool),o!==a&&(r.flags|=2048)),n!==e&&n&&(t.child.flags|=8192),_l(t,t.updateQueue),yl(t),null);case 4:return Se(),e===null&&ep(t.stateNode.containerInfo),t.flags|=67108864,yl(t),null;case 10:return va(t.type),yl(t),null;case 19:if(zo(t),r=t.memoizedState,r===null)return yl(t),null;if(a=!!(t.flags&128),o=r.rendering,o===null){if(a)vl(r,!1);else{if(pd!==0||e!==null&&e.flags&128)for(e=t.child;e!==null;){if(o=Bo(e),o!==null){for(t.flags|=128,vl(r,!1),e=o.updateQueue,t.updateQueue=e,_l(t,e),t.subtreeFlags=0,e=n,n=t.child;n!==null;)Ni(n,e),n=n.sibling;return Ro(t,Lo.current&1|2),ra&&Xi(t,r.treeForkCount),t.child}e=e.sibling}r.tail!==null&&Le()>wd&&(t.flags|=128,a=!0,vl(r,!1),t.lanes=4194304)}}else{if(!a){if(e=Bo(o),e!==null){if(t.flags|=128,a=!0,e=e.updateQueue,t.updateQueue=e,_l(t,e),vl(r,!0),r.tail===null&&r.tailMode!==`collapsed`&&r.tailMode!==`visible`&&!o.alternate&&!ra)return yl(t),null}else 2*Le()-r.renderingStartTime>wd&&n!==536870912&&(t.flags|=128,a=!0,vl(r,!1),t.lanes=4194304)}r.isBackwards?(o.sibling=t.child,t.child=o):(e=r.last,e===null?t.child=o:e.sibling=o,r.last=o)}if(r.tail!==null){e=r.tail;a:{for(n=e;n!==null;){if(n.alternate!==null){n=!1;break a}n=n.sibling}n=!0}return r.rendering=e,r.tail=e.sibling,r.renderingStartTime=Le(),e.sibling=null,o=Lo.current,o=a?o&1|2:o&1,r.tailMode===`visible`||r.tailMode===`collapsed`||!n||ra?Ro(t,o):(n=o,ge(Ao,t),ge(Lo,n),jo===null&&(jo=t)),ra&&Xi(t,r.treeForkCount),e}return yl(t),null;case 22:case 23:return Io(t),ko(),r=t.memoizedState!==null,e===null?r&&(t.flags|=8192):e.memoizedState!==null!==r&&(t.flags|=8192),r?n&536870912&&!(t.flags&128)&&(yl(t),t.subtreeFlags&6&&(t.flags|=8192)):yl(t),n=t.updateQueue,n!==null&&_l(t,n.retryQueue),n=null,e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),r=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(r=t.memoizedState.cachePool.pool),r!==n&&(t.flags|=2048),e!==null&&he(Wa),null;case 24:return n=null,e!==null&&(n=e.memoizedState.cache),t.memoizedState.cache!==n&&(t.flags|=2048),va(Aa),yl(t),null;case 25:return null;case 30:return t.flags|=33554432,yl(t),null}throw Error(i(156,t.tag))}function xl(e,t){switch($i(t),t.tag){case 1:return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 3:return va(Aa),Se(),e=t.flags,e&65536&&!(e&128)?(t.flags=e&-65537|128,t):null;case 26:case 27:case 5:return we(t),null;case 31:if(t.memoizedState!==null){if(Io(t),t.alternate===null)throw Error(i(340));da()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 13:if(Io(t),e=t.memoizedState,e!==null&&e.dehydrated!==null){if(t.alternate===null)throw Error(i(340));da()}return e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 19:return zo(t),e=t.flags,e&65536?(t.flags=e&-65537|128,e=t.memoizedState,e!==null&&(e.rendering=null,e.tail=null),t.flags|=4,t):null;case 4:return Se(),null;case 10:return va(t.type),null;case 22:case 23:return Io(t),ko(),e!==null&&he(Wa),e=t.flags,e&65536?(t.flags=e&-65537|128,t):null;case 24:return va(Aa),null;case 25:return null;default:return null}}function Sl(e,t){switch($i(t),t.tag){case 3:va(Aa),Se();break;case 26:case 27:case 5:we(t);break;case 4:Se();break;case 31:t.memoizedState!==null&&Io(t);break;case 13:Io(t);break;case 19:zo(t);break;case 10:va(t.type);break;case 22:case 23:Io(t),ko(),e!==null&&he(Wa);break;case 24:va(Aa)}}function Cl(e,t){try{var n=t.updateQueue,r=n===null?null:n.lastEffect;if(r!==null){var i=r.next;n=i;do{if((n.tag&e)===e){r=void 0;var a=n.create,o=n.inst;r=a(),o.destroy=r}n=n.next}while(n!==i)}}catch(e){Sf(t,t.return,e)}}function wl(e,t,n){try{var r=t.updateQueue,i=r===null?null:r.lastEffect;if(i!==null){var a=i.next;r=a;do{if((r.tag&e)===e){var o=r.inst,s=o.destroy;if(s!==void 0){o.destroy=void 0,i=t;var c=n,l=s;try{l()}catch(e){Sf(i,c,e)}}}r=r.next}while(r!==a)}}catch(e){Sf(t,t.return,e)}}function Tl(e){var t=e.updateQueue;if(t!==null){var n=e.stateNode;try{wo(t,n)}catch(t){Sf(e,e.return,t)}}}function El(e,t,n){n.props=wc(e.type,e.memoizedProps),n.state=e.memoizedState;try{n.componentWillUnmount()}catch(n){Sf(e,t,n)}}function Dl(e,t){try{var n=e.ref;if(n!==null){switch(e.tag){case 26:case 27:case 5:var r=e.stateNode;break;case 30:var i=e.stateNode,a=hi(e.memoizedProps,i);(i.ref===null||i.ref.name!==a)&&(i.ref=Gp(a)),r=i.ref;break;case 7:if(e.stateNode===null){var o=new Kp(e);f(e.child,!1,lm,o,void 0,void 0),e.stateNode=o}r=e.stateNode;break;default:r=e.stateNode}typeof n==`function`?e.refCleanup=n(r):n.current=r}}catch(n){Sf(e,t,n)}}function Ol(e,t){var n=e.ref,r=e.refCleanup;if(n!==null){if(typeof r==`function`)try{r()}catch(n){Sf(e,t,n)}finally{e.refCleanup=null,e=e.alternate,e!=null&&(e.refCleanup=null)}else if(typeof n==`function`)try{n(null)}catch(n){Sf(e,t,n)}else n.current=null}}function kl(e,t){if((e.tag===5||e.tag===27||e.tag===6)&&e.alternate===null&&t!==null)for(var n=0;n<t.length;n++)dm(e.stateNode,t[n])}function Al(e){for(var t=e.return;t!==null&&(Nl(t)&&dm(e.stateNode,t.stateNode),!Ml(t));)t=t.return}function jl(e){for(var t=e.return;t!==null&&(Nl(t)&&fm(e.stateNode,t.stateNode),!Ml(t));)t=t.return}function Ml(e){return e.tag===5||e.tag===3||e.tag===27}function Nl(e){return e&&e.tag===7&&e.stateNode!==null}function Pl(e){var t=e.type,n=e.memoizedProps,r=e.stateNode;try{a:switch(t){case`button`:case`input`:case`select`:case`textarea`:n.autoFocus&&r.focus();break a;case`img`:n.src?r.src=n.src:n.srcSet&&(r.srcset=n.srcSet)}}catch(t){Sf(e,e.return,t)}}function Fl(e,t,n){try{var r=e.stateNode;hp(r,e.type,n,t),r[bt]=t}catch(t){Sf(e,e.return,t)}}function Il(e){return e.tag===5||e.tag===3||e.tag===26||e.tag===27&&Np(e.type)||e.tag===4}function Ll(e){a:for(;;){for(;e.sibling===null;){if(e.return===null||Il(e.return))return null;e=e.return}for(e.sibling.return=e.return,e=e.sibling;e.tag!==5&&e.tag!==6&&e.tag!==18;){if(e.tag===27&&Np(e.type)||e.flags&2||e.child===null||e.tag===4)continue a;e.child.return=e,e=e.child}if(!(e.flags&2))return e.stateNode}}function Rl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?(n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n).insertBefore(i,t):(t=n.nodeType===9?n.body:n.nodeName===`HTML`?n.ownerDocument.body:n,t.appendChild(i),n=n._reactRootContainer,n!=null||t.onclick!==null||(t.onclick=gn)),kl(e,r),Ut=!0;else if(i!==4&&(i===27&&(kl(e,r),r=null,Np(e.type)&&(n=e.stateNode,t=null)),e=e.child,e!==null))for(Rl(e,t,n,r),e=e.sibling;e!==null;)Rl(e,t,n,r),e=e.sibling}function zl(e,t,n,r){var i=e.tag;if(i===5||i===6)i=e.stateNode,t?n.insertBefore(i,t):n.appendChild(i),kl(e,r),Ut=!0;else if(i!==4&&(i===27&&(kl(e,r),r=null,Np(e.type)&&(n=e.stateNode)),e=e.child,e!==null))for(zl(e,t,n,r),e=e.sibling;e!==null;)zl(e,t,n,r),e=e.sibling}function Bl(e){var t=e.stateNode,n=e.memoizedProps;try{for(var r=e.type,i=t.attributes;i.length;)t.removeAttributeNode(i[0]);pp(t,r,n),t[yt]=e,t[bt]=n}catch(t){Sf(e,e.return,t)}}var Vl=!1,Hl=null;function Ul(e){(e.tag===30||e.subtreeFlags&33554432)&&(Vl=!0)}var Wl=null;function Gl(){var e=Wl;return Wl=null,e}var Kl=0;function ql(e,t,n,r,i){return Kl=0,Jl(e.child,t,n,r,i)}function Jl(e,t,n,r,i){for(var a=!1;e!==null;){if(e.tag===5){var o=e.stateNode;if(r!==null){var s=zp(o);r.push(s),s.view&&(a=!0)}else a||zp(o).view&&(a=!0);Vl=!0,Ip(o,Kl===0?t:t+`_`+Kl,n),Kl++}else e.tag===22&&e.memoizedState!==null||e.tag===30&&i||Jl(e.child,t,n,r,i)&&(a=!0);e=e.sibling}return a}function Yl(e,t){for(;e!==null;)e.tag===5?Lp(e.stateNode,e.memoizedProps):e.tag===22&&e.memoizedState!==null||e.tag===30&&t||Yl(e.child,t),e=e.sibling}function Xl(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if((e.tag!==22||e.memoizedState===null)&&(Xl(e),e.tag===30&&e.flags&18874368&&e.stateNode.paired)){var t=e.memoizedProps;if(t.name==null||t.name===`auto`)throw Error(i(544));var n=t.name;t=_i(t.default,t.share),t!==`none`&&(ql(e,n,t,null,!1)||Yl(e.child,!1))}e=e.sibling}}function Zl(e,t){if(e.tag===30){var n=e.stateNode,r=e.memoizedProps,i=hi(r,n),a=_i(r.default,n.paired?r.share:r.enter);a===`none`?Xl(e):ql(e,i,a,null,!1)?(Xl(e),n.paired||t||Vd(e,r.onEnter)):Yl(e.child,!1)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)Zl(e,t),e=e.sibling;else Xl(e)}function Ql(e){if(Hl!==null&&Hl.size!==0){var t=Hl;if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var n=e.memoizedProps,r=n.name;if(r!=null&&r!==`auto`){var i=t.get(r);if(i!==void 0){var a=_i(n.default,n.share);if(a!==`none`&&(ql(e,r,a,null,!1)?(a=e.stateNode,i.paired=a,a.paired=i,Vd(e,n.onShare)):Yl(e.child,!1)),t.delete(r),t.size===0)break}}}Ql(e)}e=e.sibling}}}function $l(e){if(e.tag===30){var t=e.memoizedProps,n=hi(t,e.stateNode),r=Hl===null?void 0:Hl.get(n),i=_i(t.default,r===void 0?t.exit:t.share);i!==`none`&&(ql(e,n,i,null,!1)?r===void 0?Vd(e,t.onExit):(i=e.stateNode,r.paired=i,i.paired=r,Hl.delete(n),Vd(e,t.onShare)):Yl(e.child,!1)),Hl!==null&&Ql(e)}else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)$l(e),e=e.sibling;else Hl!==null&&Ql(e)}function eu(e){for(e=e.child;e!==null;){if(e.tag===30){var t=e.memoizedProps,n=hi(t,e.stateNode);t=_i(t.default,t.update),e.flags&=-5,t!==`none`&&ql(e,n,t,e.memoizedState=[],!1)}else e.subtreeFlags&33554432&&eu(e);e=e.sibling}}function tu(e){if(e.subtreeFlags&18874368)for(e=e.child;e!==null;){if(e.tag!==22||e.memoizedState===null){if(e.tag===30&&e.flags&18874368){var t=e.stateNode;t.paired!==null&&(t.paired=null,Yl(e.child,!1))}tu(e)}e=e.sibling}}function nu(e){if(e.tag===30)e.stateNode.paired=null,Yl(e.child,!1),tu(e);else if(e.subtreeFlags&33554432)for(e=e.child;e!==null;)nu(e),e=e.sibling;else tu(e)}function ru(e){for(e=e.child;e!==null;)e.tag===30?Yl(e.child,!1):e.subtreeFlags&33554432&&ru(e),e=e.sibling}function iu(e,t,n,r,i,a,o){for(var s=!1;t!==null;){if(t.tag===5){var c=t.stateNode;if(a!==null&&Kl<a.length){var l=a[Kl],u=zp(c);(l.view||u.view)&&(s=!0);var d;if(d=!(e.flags&4)){if(u.clip)d=!0;else{d=l.rect;var f=u.rect;d=d.y!==f.y||d.x!==f.x||d.height!==f.height||d.width!==f.width}}d&&(e.flags|=4),u.abs?u=!l.abs:(l=l.rect,u=u.rect,u=l.height!==u.height||l.width!==u.width),u&&(e.flags|=32)}else e.flags|=32;e.flags&4&&Ip(c,Kl===0?n:n+`_`+Kl,i),s&&e.flags&4||(Wl===null&&(Wl=[]),Wl.push(c,Kl===0?r:r+`_`+Kl,t.memoizedProps)),Kl++}else(t.tag!==22||t.memoizedState===null)&&(t.tag===30&&o?e.flags|=t.flags&32:iu(e,t.child,n,r,i,a,o)&&(s=!0));t=t.sibling}return s}function au(e,t){for(e=e.child;e!==null;){if(e.tag===30){var n=e.memoizedProps,r=e.stateNode,i=hi(n,r),a=_i(n.default,n.update);if(t){r=r.clones;var o=r===null?null:r.map(Bp)}else o=e.memoizedState,e.memoizedState=null;r=e;var s=e.child;Kl=0,i=iu(r,s,i,i,a,o,!1),e.flags&4&&i&&(t||Vd(e,n.onUpdate))}else e.subtreeFlags&33554432&&au(e,t);e=e.sibling}}var ou=!1,su=!1,cu=!1,lu=!1,uu=typeof WeakSet==`function`?WeakSet:Set,du=null,fu=!1,pu=!1,mu=!1,hu=!1;function gu(e,t,n){if(e=e.containerInfo,vp=Eh,e=Gr(e),Kr(e)){if(`selectionStart`in e)var r={start:e.selectionStart,end:e.selectionEnd};else a:{r=(r=e.ownerDocument)&&r.defaultView||window;var i=r.getSelection&&r.getSelection();if(i&&i.rangeCount!==0){r=i.anchorNode;var a=i.anchorOffset,o=i.focusNode;i=i.focusOffset;try{r.nodeType,o.nodeType}catch{r=null;break a}var s=0,c=-1,l=-1,u=0,d=0,f=e,p=null;b:for(;;){for(var m;f!==r||a!==0&&f.nodeType!==3||(c=s+a),f!==o||i!==0&&f.nodeType!==3||(l=s+i),f.nodeType===3&&(s+=f.nodeValue.length),(m=f.firstChild)!==null;)p=f,f=m;for(;;){if(f===e)break b;if(p===r&&++u===a&&(c=s),p===o&&++d===i&&(l=s),(m=f.nextSibling)!==null)break;f=p,p=f.parentNode}f=m}r=c===-1||l===-1?null:{start:c,end:l}}else r=null}r||={start:0,end:0}}else r=null;for(yp={focusedElem:e,selectionRange:r},Eh=!1,n=(n&335544064)===n,du=t,t=n?9270:1024;du!==null;){if(e=du,n&&(r=e.deletions,r!==null))for(a=0;a<r.length;a++)n&&$l(r[a]);if(e.alternate===null&&e.flags&2)n&&Ul(e),_u(n);else{if(e.tag===22){if(r=e.alternate,e.memoizedState!==null){r!==null&&r.memoizedState===null&&n&&$l(r),_u(n);continue}if(r!==null&&r.memoizedState!==null){n&&Ul(e),_u(n);continue}}r=e.child,(e.subtreeFlags&t)!==0&&r!==null?(r.return=e,du=r):(n&&eu(e),_u(n))}}Hl=null}function _u(e){for(;du!==null;){var t=du,n=e,r=t.alternate,a=t.flags;switch(t.tag){case 0:case 11:case 15:break;case 1:if(a&1024&&r!==null){n=void 0,a=r.memoizedProps,r=r.memoizedState;var o=t.stateNode;try{var s=wc(t.type,a);n=o.getSnapshotBeforeUpdate(s,r),o.__reactInternalSnapshotBeforeUpdate=n}catch(e){Sf(t,t.return,e)}}break;case 3:if(a&1024){if(r=t.stateNode.containerInfo,n=r.nodeType,n===9)pm(r);else if(n===1)switch(r.nodeName){case`HEAD`:case`HTML`:case`BODY`:pm(r);break;default:r.textContent=``}}break;case 5:case 26:case 27:case 6:case 4:case 17:break;case 30:n&&r!==null&&(n=hi(r.memoizedProps,r.stateNode),a=t.memoizedProps,a=_i(a.default,a.update),a!==`none`&&ql(r,n,a,r.memoizedState=[],!0));break;default:if(a&1024)throw Error(i(163))}if(r=t.sibling,r!==null){r.return=t.return,du=r;break}du=t.return}}function vu(e,t,n){var r=n.flags;switch(n.tag){case 0:case 11:case 15:Ru(e,n),r&4&&Cl(5,n);break;case 1:if(Ru(e,n),r&4){if(e=n.stateNode,t===null)try{e.componentDidMount()}catch(e){Sf(n,n.return,e)}else{var i=wc(n.type,t.memoizedProps);t=t.memoizedState;try{e.componentDidUpdate(i,t,e.__reactInternalSnapshotBeforeUpdate)}catch(e){Sf(n,n.return,e)}}}r&64&&Tl(n),r&512&&Dl(n,n.return);break;case 3:if(Ru(e,n),r&64&&(e=n.updateQueue,e!==null)){if(t=null,n.child!==null)switch(n.child.tag){case 27:case 5:t=n.child.stateNode;break;case 1:t=n.child.stateNode}try{wo(e,t)}catch(e){Sf(n,n.return,e)}}break;case 27:t===null&&r&4&&Bl(n);case 26:case 5:Ru(e,n),t===null&&r&4&&Pl(n),r&512&&Dl(n,n.return);break;case 12:Ru(e,n);break;case 31:Ru(e,n),r&4&&Du(e,n);break;case 13:Ru(e,n),r&4&&Ou(e,n),r&64&&(e=n.memoizedState,e!==null&&(e=e.dehydrated,e!==null&&(n=Ef.bind(null,n),ym(e,n))));break;case 22:if(r=n.memoizedState!==null||ou,!r){var a=t!==null&&t.memoizedState!==null||su;t=ou,i=su,ou=r,(su=a)&&!i?(r=2,n.subtreeFlags&8772&&(r|=1),Bu(e,n,r)):Ru(e,n),ou=t,su=i}break;case 30:Ru(e,n),r&512&&Dl(n,n.return);break;case 7:r&512&&Dl(n,n.return);default:Ru(e,n)}}function yu(e,t){for(e=e.child;e!==null;)bu(e,t),e=e.sibling}function bu(e,t){switch(e.tag){case 5:case 26:try{var n=e.stateNode;if(t){var r=n.style;typeof r.setProperty==`function`?r.setProperty(`display`,`none`,`important`):r.display=`none`}else{var i=e.stateNode,a=e.memoizedProps.style,o=a!=null&&a.hasOwnProperty(`display`)?a.display:null;i.style.display=o==null||typeof o==`boolean`?``:(``+o).trim()}}catch(t){Sf(e,e.return,t)}xu(e,t);break;case 6:try{e.stateNode.nodeValue=t?``:e.memoizedProps,Ut=!0}catch(t){Sf(e,e.return,t)}break;case 18:try{var s=e.stateNode;t?Fp(s,!0):Fp(e.stateNode,!1)}catch(t){Sf(e,e.return,t)}break;case 22:case 23:e.memoizedState===null&&yu(e,t);break;default:yu(e,t)}}function xu(e,t){if(e.subtreeFlags&67108864)for(e=e.child;e!==null;){a:{var n=e,r=t;switch(n.tag){case 4:bu(n,r);break a;case 22:n.memoizedState===null&&xu(n,r);break a;default:xu(n,r)}}e=e.sibling}}function Su(e){var t=e.alternate;t!==null&&(e.alternate=null,Su(t)),e.child=null,e.deletions=null,e.sibling=null,e.tag===5&&(t=e.stateNode,t!==null&&Ot(t)),e.stateNode=null,e.return=null,e.dependencies=null,e.memoizedProps=null,e.memoizedState=null,e.pendingProps=null,e.stateNode=null,e.updateQueue=null}var Cu=null,wu=!1;function Tu(e,t,n){for(n=n.child;n!==null;)Eu(e,t,n),n=n.sibling}function Eu(e,t,n){if(qe&&typeof qe.onCommitFiberUnmount==`function`)try{qe.onCommitFiberUnmount(Ke,n)}catch{}switch(n.tag){case 26:su||Ol(n,t),Tu(e,t,n),n.memoizedState?n.memoizedState.count--:n.stateNode&&!su&&(n=n.stateNode,n.parentNode.removeChild(n));break;case 27:su||Ol(n,t),jl(n);var r=Cu,i=wu;Np(n.type)&&(Cu=n.stateNode,wu=!1),Tu(e,t,n),Dm(n.stateNode,n.type,n.memoizedProps),Cu=r,wu=i;break;case 5:su||Ol(n,t),jl(n);case 6:if(n.tag===6&&jl(n),r=Cu,i=wu,Cu=null,Tu(e,t,n),Cu=r,wu=i,Cu!==null){if(wu)try{(Cu.nodeType===9?Cu.body:Cu.nodeName===`HTML`?Cu.ownerDocument.body:Cu).removeChild(n.stateNode),Ut=!0}catch(e){Sf(n,t,e)}else try{Cu.removeChild(n.stateNode),Ut=!0}catch(e){Sf(n,t,e)}}break;case 18:Cu!==null&&(wu?(e=Cu,Pp(e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,n.stateNode),Qh(e)):Pp(Cu,n.stateNode));break;case 4:r=Cu,i=wu,Cu=n.stateNode.containerInfo,wu=!0,Tu(e,t,n),Cu=r,wu=i;break;case 0:case 11:case 14:case 15:wl(2,n,t),su||wl(4,n,t),Tu(e,t,n);break;case 1:su||(Ol(n,t),r=n.stateNode,typeof r.componentWillUnmount==`function`&&El(n,t,r)),Tu(e,t,n);break;case 21:Tu(e,t,n);break;case 22:su=(r=su)||n.memoizedState!==null,Tu(e,t,n),su=r;break;case 30:Ol(n,t),Tu(e,t,n);break;case 7:su||Ol(n,t),Tu(e,t,n);break;default:Tu(e,t,n)}}function Du(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null))){e=e.dehydrated;try{Qh(e)}catch(e){Sf(t,t.return,e)}}}function Ou(e,t){if(t.memoizedState===null&&(e=t.alternate,e!==null&&(e=e.memoizedState,e!==null&&(e=e.dehydrated,e!==null))))try{Qh(e)}catch(e){Sf(t,t.return,e)}}function ku(e){switch(e.tag){case 31:case 13:case 19:var t=e.stateNode;return t===null&&(t=e.stateNode=new uu),t;case 22:return e=e.stateNode,t=e._retryCache,t===null&&(t=e._retryCache=new uu),t;default:throw Error(i(435,e.tag))}}function Au(e,t){var n=ku(e);t.forEach(function(t){if(!n.has(t)){n.add(t);var r=Df.bind(null,e,t);t.then(r,r)}})}function ju(e,t,n){var r=t.deletions;if(r!==null)for(var a=0;a<r.length;a++){var o=r[a],s=e,c=t,l=c;a:for(;l!==null;){switch(l.tag){case 27:if(Np(l.type)){Cu=l.stateNode,wu=!1;break a}break;case 5:Cu=l.stateNode,wu=!1;break a;case 3:case 4:Cu=l.stateNode.containerInfo,wu=!0;break a}l=l.return}if(Cu===null)throw Error(i(160));Eu(s,c,o),Cu=null,wu=!1,s=o.alternate,s!==null&&(s.return=null),o.return=null}if(t.subtreeFlags&13886)for(t=t.child;t!==null;)Nu(t,e,n),t=t.sibling}var Mu=null;function Nu(e,t,n){var r=e.alternate,a=e.flags;switch(e.tag){case 0:case 11:case 14:case 15:if(a&4&&(r=e.updateQueue,r=r===null?null:r.events,r!==null))for(var o=0;o<r.length;o++){var s=r[o];s.ref.impl=s.nextImpl}ju(t,e,n),Pu(e),a&4&&(wl(3,e,e.return),Cl(3,e),wl(5,e,e.return));break;case 1:ju(t,e,n),Pu(e),a&512&&(su||r===null||Ol(r,r.return)),a&64&&ou&&(e=e.updateQueue,e!==null&&(t=e.callbacks,t!==null&&(n=e.shared.hiddenCallbacks,e.shared.hiddenCallbacks=n===null?t:n.concat(t))));break;case 26:if(o=Mu,ju(t,e,n),Pu(e),a&512&&(su||r===null||Ol(r,r.return)),a&4){if(a=r===null?null:r.memoizedState,n=e.memoizedState,r===null){if(n===null){if(e.stateNode===null){if(ou)e.stateNode=Cp(e.type,e.memoizedProps,t.containerInfo,e);else{a:{t=e.type,n=e.memoizedProps,a=o.ownerDocument||o;b:switch(t){case`title`:r=a.getElementsByTagName(`title`)[0],(!r||r[Et]||r[yt]||r.namespaceURI===`http://www.w3.org/2000/svg`||r.hasAttribute(`itemprop`))&&(r=a.createElement(t),a.head.insertBefore(r,a.querySelector(`head > title`))),pp(r,t,n),r[yt]=e,Nt(r),t=r;break a;case`link`:if(o=th(`link`,`href`,a).get(t+(n.href||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`href`)===(n.href==null||n.href===``?null:n.href)&&r.getAttribute(`rel`)===(n.rel==null?null:n.rel)&&r.getAttribute(`title`)===(n.title==null?null:n.title)&&r.getAttribute(`crossorigin`)===(n.crossOrigin==null?null:n.crossOrigin)){o.splice(s,1);break b}}r=a.createElement(t),pp(r,t,n),a.head.appendChild(r);break;case`meta`:if(o=th(`meta`,`content`,a).get(t+(n.content||``))){for(s=0;s<o.length;s++)if(r=o[s],r.getAttribute(`content`)===(n.content==null?null:``+n.content)&&r.getAttribute(`name`)===(n.name==null?null:n.name)&&r.getAttribute(`property`)===(n.property==null?null:n.property)&&r.getAttribute(`http-equiv`)===(n.httpEquiv==null?null:n.httpEquiv)&&r.getAttribute(`charset`)===(n.charSet==null?null:n.charSet)){o.splice(s,1);break b}}r=a.createElement(t),pp(r,t,n),a.head.appendChild(r);break;default:throw Error(i(468,t))}r[yt]=e,Nt(r),t=r}e.stateNode=t}}else ou||nh(o,e.type,e.stateNode)}else e.stateNode=Xm(o,n,e.memoizedProps)}else a===n?n===null&&e.stateNode!==null&&Fl(e,e.memoizedProps,r.memoizedProps):(a===null?(t=r.stateNode,t===null||su||t.parentNode.removeChild(t)):a.count--,n===null?ou||nh(o,e.type,e.stateNode):Xm(o,n,e.memoizedProps))}break;case 27:ju(t,e,n),Pu(e),a&512&&(su||r===null||Ol(r,r.return)),r!==null&&a&4&&Fl(e,e.memoizedProps,r.memoizedProps);break;case 5:if(o=cu,cu=!1,ju(t,e,n),cu=o,Pu(e),a&512&&(su||r===null||Ol(r,r.return)),e.flags&32){t=e.stateNode;try{cn(t,``),Ut=!0}catch(t){Sf(e,e.return,t)}}a&4&&e.stateNode!=null&&(t=e.memoizedProps,Fl(e,t,r===null?t:r.memoizedProps)),a&1024&&(lu=!0);break;case 6:if(ju(t,e,n),Pu(e),a&4){if(e.stateNode===null)throw Error(i(162));t=e.memoizedProps,n=e.stateNode;try{n.nodeValue=t,Ut=!0}catch(t){Sf(e,e.return,t)}}break;case 3:if(Ut=!1,eh=null,o=Mu,Mu=jm(t.containerInfo),ju(t,e,n),Mu=o,Pu(e),a&4&&r!==null&&r.memoizedState.isDehydrated)try{Qh(t.containerInfo)}catch(t){Sf(e,e.return,t)}lu&&(lu=!1,Fu(e)),Ut=!1;break;case 4:a=cu,cu=ou,r=Wt(),o=Mu,Mu=jm(e.stateNode.containerInfo),ju(t,e,n),Pu(e),Mu=o,Ut&&pu&&(mu=!0),Ut=r,cu=a;break;case 12:ju(t,e,n),Pu(e);break;case 31:ju(t,e,n),Pu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Au(e,t)));break;case 13:ju(t,e,n),Pu(e),e.child.flags&8192&&e.memoizedState!==null!=(r!==null&&r.memoizedState!==null)&&(Sd=Le()),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Au(e,t)));break;case 22:o=e.memoizedState!==null,s=r!==null&&r.memoizedState!==null;var c=ou,l=su,u=cu;ou=c||o,cu=u||o,su=l||s,ju(t,e,n),su=l,cu=u,ou=c,Pu(e),a&8192&&(t=e.stateNode,t._visibility=o?t._visibility&-2:t._visibility|1,!o||r===null||s||ou||su||(t=s||su,n=ou,r=su,ou=o||ou,su=t,zu(e,2),ou=n,su=r),!o&&cu||yu(e,o)),a&4&&(t=e.updateQueue,t!==null&&(n=t.retryQueue,n!==null&&(t.retryQueue=null,Au(e,n))));break;case 19:ju(t,e,n),Pu(e),a&4&&(t=e.updateQueue,t!==null&&(e.updateQueue=null,Au(e,t)));break;case 30:a&512&&(su||r===null||Ol(r,r.return)),a=Wt(),o=pu,s=(n&335544064)===n,c=e.memoizedProps,pu=s&&_i(c.default,c.update)!==`none`,ju(t,e,n),Pu(e),s&&r!==null&&Ut&&(e.flags|=4),pu=o,Ut=a;break;case 21:break;case 7:a&512&&(su||r===null||Ol(r,r.return)),r&&r.stateNode!==null&&(r.stateNode._fragmentFiber=e);default:ju(t,e,n),Pu(e)}}function Pu(e){var t=e.flags;if(t&2){try{for(var n,r=e.return;r!==null;){if(Il(r)){n=r;break}r=r.return}r=null;for(var a=e.return;a!==null;){if(Nl(a)){var o=a.stateNode;r===null?r=[o]:r.push(o)}if(Ml(a))break;a=a.return}var s=r;if(n==null)throw Error(i(160));switch(n.tag){case 27:var c=n.stateNode;zl(e,Ll(e),c,s);break;case 5:var l=n.stateNode;n.flags&32&&(cn(l,``),n.flags&=-33),zl(e,Ll(e),l,s);break;case 3:case 4:var u=n.stateNode.containerInfo;Rl(e,Ll(e),u,s);break;default:throw Error(i(161))}}catch(t){Sf(e,e.return,t)}e.flags&=-3}t&4096&&(e.flags&=-4097)}function Fu(e){if(e.subtreeFlags&1024)for(e=e.child;e!==null;){var t=e;Fu(t),t.tag===5&&t.flags&1024&&(t=t.stateNode,Eh=!0,t.reset(),Eh=!1),e=e.sibling}}function Iu(e,t){if(t.subtreeFlags&9270)for(t=t.child;t!==null;)Lu(t,e),t=t.sibling;else au(t,!1)}function Lu(e,t){var n=e.alternate;if(n===null)Zl(e,!1);else switch(e.tag){case 3:if(hu=fu=!1,Gl(),Iu(t,e),!fu&&!mu){if(e=Wl,e!==null)for(var r=0;r<e.length;r+=3){n=e[r];var i=e[r+1];Lp(n,e[r+2]),n=n.ownerDocument.documentElement,n!==null&&n.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(`+i+`)`})}e=t.containerInfo,e=e.nodeType===9?e.documentElement:e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===``&&(e.style.viewTransitionName=`none`,e.animate({opacity:[0,0],pointerEvents:[`none`,`none`]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition-group(root)`}),e.animate({width:[0,0],height:[0,0]},{duration:0,fill:`forwards`,pseudoElement:`::view-transition`})),hu=!0}Wl=null;break;case 5:Iu(t,e);break;case 4:r=fu,fu=!1,Iu(t,e),fu&&(mu=!0),fu=r;break;case 22:e.memoizedState===null&&(n.memoizedState===null?Iu(t,e):Zl(e,!1));break;case 30:r=fu,i=Gl(),fu=!1,Iu(t,e),fu&&(e.flags|=4);var a=e.memoizedProps,o=e.stateNode;t=hi(a,o),o=hi(n.memoizedProps,o);var s=_i(a.default,a.update);s===`none`?t=!1:(a=n.memoizedState,n.memoizedState=null,n=e.child,Kl=0,t=iu(e,n,t,o,s,a,!0),Kl!==(a===null?0:a.length)&&(e.flags|=32)),e.flags&4&&t?(Vd(e,e.memoizedProps.onUpdate),Wl=i):i!==null&&(i.push.apply(i,Wl),Wl=i),fu=e.flags&32?!0:r;break;default:Iu(t,e)}}function Ru(e,t){if(t.subtreeFlags&8772)for(t=t.child;t!==null;)vu(e,t.alternate,t),t=t.sibling}function zu(e,t){for(e=e.child;e!==null;){var n=e,r=t;switch(n.tag){case 0:case 11:case 14:case 15:wl(4,n,n.return),zu(n,r);break;case 1:Ol(n,n.return);var i=n.stateNode;typeof i.componentWillUnmount==`function`&&El(n,n.return,i),zu(n,r);break;case 27:r&2&&Dm(n.stateNode,n.type,n.memoizedProps);case 5:Ol(n,n.return),n.tag!==5&&n.tag!==27||jl(n),zu(n,r);break;case 6:jl(n);break;case 26:Ol(n,n.return),i=n.stateNode,n.memoizedState!==null||i===null||su||i.parentNode.removeChild(i),zu(n,r);break;case 22:n.memoizedState===null&&zu(n,r);break;case 30:Ol(n,n.return),zu(n,r);break;case 7:Ol(n,n.return);default:zu(n,r)}e=e.sibling}}function Bu(e,t,n){for(n=t.subtreeFlags&8772?n:n&-2,t=t.child;t!==null;){var r=t.alternate,i=e,a=t,o=a.flags,s=!!(n&1);switch(a.tag){case 0:case 11:case 15:Bu(i,a,n),Cl(4,a);break;case 1:if(Bu(i,a,n),r=a,i=r.stateNode,typeof i.componentDidMount==`function`)try{i.componentDidMount()}catch(e){Sf(r,r.return,e)}if(r=a,i=r.updateQueue,i!==null){var c=r.stateNode;try{var l=i.shared.hiddenCallbacks;if(l!==null)for(i.shared.hiddenCallbacks=null,i=0;i<l.length;i++)Co(l[i],c)}catch(e){Sf(r,r.return,e)}}s&&o&64&&Tl(a),Dl(a,a.return);break;case 27:n&2&&Bl(a);case 5:a.tag!==5&&a.tag!==27||Al(a),Bu(i,a,n),s&&r===null&&o&4&&Pl(a),Dl(a,a.return);break;case 6:Al(a);break;case 26:c=a.stateNode,a.memoizedState!==null||c===null||ou||nh(jm(c.ownerDocument),a.type,c),Bu(i,a,n),s&&r===null&&o&4&&Pl(a),Dl(a,a.return);break;case 12:Bu(i,a,n);break;case 31:Bu(i,a,n),s&&o&4&&Du(i,a);break;case 13:Bu(i,a,n),s&&o&4&&Ou(i,a);break;case 22:a.memoizedState===null&&Bu(i,a,n),Dl(a,a.return);break;case 30:Bu(i,a,n),Dl(a,a.return);break;case 7:Dl(a,a.return);default:Bu(i,a,n)}t=t.sibling}}function Vu(e,t){var n=null;e!==null&&e.memoizedState!==null&&e.memoizedState.cachePool!==null&&(n=e.memoizedState.cachePool.pool),e=null,t.memoizedState!==null&&t.memoizedState.cachePool!==null&&(e=t.memoizedState.cachePool.pool),e!==n&&(e!=null&&e.refCount++,n!=null&&Ma(n))}function Hu(e,t){e=null,t.alternate!==null&&(e=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==e&&(t.refCount++,e!=null&&Ma(e))}function Uu(e,t,n,r){var i=(n&335544064)===n;if(t.subtreeFlags&(i?10262:10256))for(t=t.child;t!==null;)Wu(e,t,n,r),t=t.sibling;else i&&ru(t)}function Wu(e,t,n,r){var i=(n&335544064)===n;i&&t.alternate===null&&t.return!==null&&t.return.alternate!==null&&nu(t);var a=t.flags;switch(t.tag){case 0:case 11:case 15:Uu(e,t,n,r),a&2048&&Cl(9,t);break;case 1:Uu(e,t,n,r);break;case 3:Uu(e,t,n,r),i&&hu&&(e=e.containerInfo,e=e.nodeType===9?e.body:e.nodeName===`HTML`?e.ownerDocument.body:e,e.style.viewTransitionName===`root`&&(e.style.viewTransitionName=``),e=e.ownerDocument.documentElement,e!==null&&e.style.viewTransitionName===`none`&&(e.style.viewTransitionName=``)),a&2048&&(a=null,t.alternate!==null&&(a=t.alternate.memoizedState.cache),t=t.memoizedState.cache,t!==a&&(t.refCount++,a!=null&&Ma(a)));break;case 12:if(a&2048){Uu(e,t,n,r),a=t.stateNode;try{var o=t.memoizedProps,s=o.id,c=o.onPostCommit;typeof c==`function`&&c(s,t.alternate===null?`mount`:`update`,a.passiveEffectDuration,-0)}catch(e){Sf(t,t.return,e)}}else Uu(e,t,n,r);break;case 31:Uu(e,t,n,r);break;case 13:Uu(e,t,n,r);break;case 23:break;case 22:o=t.stateNode,s=t.alternate,t.memoizedState===null?(i&&s!==null&&s.memoizedState!==null&&nu(t),o._visibility&2?Uu(e,t,n,r):(o._visibility|=2,Gu(e,t,n,r,!!(t.subtreeFlags&10256)||!1))):(i&&s!==null&&s.memoizedState===null&&nu(s),o._visibility&2?Uu(e,t,n,r):Ku(e,t)),a&2048&&Vu(s,t);break;case 24:Uu(e,t,n,r),a&2048&&Hu(t.alternate,t);break;case 30:i&&(a=t.alternate,a!==null&&(Yl(a.child,!0),Yl(t.child,!0))),Uu(e,t,n,r);break;default:Uu(e,t,n,r)}}function Gu(e,t,n,r,i){for(i&&=!!(t.subtreeFlags&10256)||!1,t=t.child;t!==null;){var a=e,o=t,s=n,c=r,l=o.flags;switch(o.tag){case 0:case 11:case 15:Gu(a,o,s,c,i),Cl(8,o);break;case 23:break;case 22:var u=o.stateNode;o.memoizedState===null?(u._visibility|=2,Gu(a,o,s,c,i)):u._visibility&2?Gu(a,o,s,c,i):Ku(a,o),i&&l&2048&&Vu(o.alternate,o);break;case 24:Gu(a,o,s,c,i),i&&l&2048&&Hu(o.alternate,o);break;default:Gu(a,o,s,c,i)}t=t.sibling}}function Ku(e,t){if(t.subtreeFlags&10256)for(t=t.child;t!==null;){var n=e,r=t,i=r.flags;switch(r.tag){case 22:Ku(n,r),i&2048&&Vu(r.alternate,r);break;case 24:Ku(n,r),i&2048&&Hu(r.alternate,r);break;default:Ku(n,r)}t=t.sibling}}var qu=8192;function Ju(e,t,n){if(e.subtreeFlags&qu)for(e=e.child;e!==null;)Yu(e,t,n),e=e.sibling}function Yu(e,t,n){switch(e.tag){case 26:Ju(e,t,n),e.flags&qu&&(e.memoizedState===null?(e=e.stateNode,(t&335544128)===t&&sh(n,e)):ch(n,Mu,e.memoizedState,e.memoizedProps));break;case 5:Ju(e,t,n),e.flags&qu&&(e=e.stateNode,(t&335544128)===t&&sh(n,e));break;case 3:case 4:var r=Mu;Mu=jm(e.stateNode.containerInfo),Ju(e,t,n),Mu=r;break;case 22:e.memoizedState===null&&(r=e.alternate,r!==null&&r.memoizedState!==null?(r=qu,qu=16777216,Ju(e,t,n),qu=r):Ju(e,t,n));break;case 30:if((e.flags&qu)!==0&&(r=e.memoizedProps.name,r!=null&&r!==`auto`)){var i=e.stateNode;i.paired=null,Hl===null&&(Hl=new Map),Hl.set(r,i)}Ju(e,t,n);break;default:Ju(e,t,n)}}function Xu(e){var t=e.alternate;if(t!==null&&(e=t.child,e!==null)){t.child=null;do t=e.sibling,e.sibling=null,e=t;while(e!==null)}}function Zu(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];du=r,ed(r,e)}Xu(e)}if(e.subtreeFlags&10256)for(e=e.child;e!==null;)Qu(e),e=e.sibling}function Qu(e){switch(e.tag){case 0:case 11:case 15:Zu(e),e.flags&2048&&wl(9,e,e.return);break;case 3:Zu(e);break;case 12:Zu(e);break;case 22:var t=e.stateNode;e.memoizedState!==null&&t._visibility&2&&(e.return===null||e.return.tag!==13)?(t._visibility&=-3,$u(e)):Zu(e);break;default:Zu(e)}}function $u(e){var t=e.deletions;if(e.flags&16){if(t!==null)for(var n=0;n<t.length;n++){var r=t[n];du=r,ed(r,e)}Xu(e)}for(e=e.child;e!==null;){switch(t=e,t.tag){case 0:case 11:case 15:wl(8,t,t.return),$u(t);break;case 22:n=t.stateNode,n._visibility&2&&(n._visibility&=-3,$u(t));break;default:$u(t)}e=e.sibling}}function ed(e,t){for(;du!==null;){var n=du;switch(n.tag){case 0:case 11:case 15:wl(8,n,t);break;case 23:case 22:if(n.memoizedState!==null&&n.memoizedState.cachePool!==null){var r=n.memoizedState.cachePool.pool;r!=null&&r.refCount++}break;case 24:Ma(n.memoizedState.cache)}if(r=n.child,r!==null)r.return=n,du=r;else a:for(n=e;du!==null;){r=du;var i=r.sibling,a=r.return;if(Su(r),r===n){du=null;break a}if(i!==null){i.return=a,du=i;break a}du=a}}}var td={getCacheForType:function(e){var t=wa(Aa),n=t.data.get(e);return n===void 0&&(n=e(),t.data.set(e,n)),n},cacheSignal:function(){return wa(Aa).controller.signal}},nd=typeof WeakMap==`function`?WeakMap:Map,rd=0,id=null,ad=null,od=0,sd=0,cd=null,ld=!1,ud=!1,dd=!1,fd=0,pd=0,md=0,hd=0,gd=0,_d=0,vd=0,yd=null,bd=null,xd=!1,Sd=0,Cd=0,wd=1/0,Td=null,Ed=null,Dd=0,Od=null,kd=null,Ad=0,jd=0,Md=null,Nd=null,Pd=null,Fd=null,Id=null,Ld=0,Rd=null;function zd(){return rd&2&&od!==0?od&-od:V.T===null?gt():Uf()}function Bd(){if(_d===0){if(!(od&536870912)||ra){var e=et;et<<=1,!(et&3932160)&&(et=262144),_d=e}else _d=536870912}return e=Ao.current,e!==null&&(e.flags|=32),_d}function Vd(e,t){if(t!=null){var n=e.stateNode,r=n.ref;r===null&&(r=n.ref=Gp(hi(e.memoizedProps,n))),Fd===null&&(Fd=[]),Fd.push(t.bind(null,r))}}function Hd(e,t,n){(e===id&&(sd===2||sd===9)||e.cancelPendingCommit!==null)&&(Yd(e,0),Kd(e,od,_d,!1)),lt(e,n),rd&2&&e===id||(e===id&&(!(rd&2)&&(hd|=n),pd===4&&Kd(e,od,_d,!1)),Ff(e))}function Ud(e,t,n){if(rd&6)throw Error(i(327));var r=!n&&!(t&127)&&(t&e.expiredLanes)===0||it(e,t),a=r?rf(e,t):tf(e,t,!0),o=r;do{if(a===0){ud&&!r&&Kd(e,t,0,!1);break}if(n=e.current.alternate,o&&!Gd(n))a=tf(e,t,!1),o=!1;else{if(a===2){if(o=t,e.errorRecoveryDisabledLanes&o)var s=0;else s=e.pendingLanes&-536870913,s=s===0?s&536870912?536870912:0:s;if(s!==0){t=s;a:{var c=e;a=yd;var l=c.current.memoizedState.isDehydrated;if(l&&(Yd(c,s).flags|=256),s=tf(c,s,!1),s!==2&&s!==6){if(dd&&!l){c.errorRecoveryDisabledLanes|=o,hd|=o,a=4;break a}o=bd,bd=a,o!==null&&(bd===null?bd=o:bd.push.apply(bd,o))}a=s}if(o=!1,a!==2)continue}}if(a===1){Yd(e,0),Kd(e,t,0,!0);break}a:{switch(r=e,o=a,o){case 0:case 1:throw Error(i(345));case 4:if((t&4194048)!==t&&(t&62914560)!==t)break;case 6:Kd(r,t,_d,!ld);break a;case 2:bd=null;break;case 3:case 5:break;default:throw Error(i(329))}if((t&62914560)===t&&(a=Sd+300-Le(),10<a)){if(Kd(r,t,_d,!ld),rt(r,0,!0)!==0)break a;Ad=t,r.timeoutHandle=Dp(Wd.bind(null,r,n,bd,Td,xd,t,_d,hd,vd,ld,o,`Throttled`,-0,0),a);break a}Wd(r,n,bd,Td,xd,t,_d,hd,vd,ld,o,null,-0,0)}break}}while(1);Ff(e)}function Wd(e,t,n,r,i,a,o,s,c,l,u,d,f,p){e.timeoutHandle=-1;var m=t.subtreeFlags,h=(a&335544064)===a;d=null,(h||m&8192||(m&16785408)==16785408)&&(d={stylesheets:null,count:0,imgCount:0,imgBytes:0,suspenseyImages:[],waitingForImages:!0,waitingForViewTransition:!1,unsuspend:gn},Hl=null,Yu(t,a,d),h&&(m=d,h=e.containerInfo,h=(h.nodeType===9?h:h.ownerDocument).__reactViewTransition,h!=null&&(m.count++,m.waitingForViewTransition=!0,m=fh.bind(m),h.finished.then(m,m))),m=(a&62914560)===a?Sd-Le():(a&4194048)===a?Cd-Le():0,m=uh(d,m),m!==null)?(Ad=a,e.cancelPendingCommit=m(df.bind(null,e,t,a,n,r,i,o,s,c,l,u,d,null,f,p)),Kd(e,a,o,!l)):df(e,t,a,n,r,i,o,s,c,l,u,d)}function Gd(e){for(var t=e;;){var n=t.tag;if((n===0||n===11||n===15)&&t.flags&16384&&(n=t.updateQueue,n!==null&&(n=n.stores,n!==null)))for(var r=0;r<n.length;r++){var i=n[r],a=i.getSnapshot;i=i.value;try{if(!zr(a(),i))return!1}catch{return!1}}if(n=t.child,t.subtreeFlags&16384&&n!==null)n.return=t,t=n;else{if(t===e)break;for(;t.sibling===null;){if(t.return===null||t.return===e)return!0;t=t.return}t.sibling.return=t.return,t=t.sibling}}return!0}function Kd(e,t,n,r){t=at(e,t),t&=~gd,t&=~hd,e.suspendedLanes|=t,e.pingedLanes&=~t,r&&(e.warmLanes|=t),r=e.expirationTimes;for(var i=t;0<i;){var a=31-Ye(i),o=1<<a;r[a]=-1,i&=~o}n!==0&&dt(e,n,t)}function qd(){return rd&6?!0:(If(0,!1),!1)}function Jd(){if(ad!==null){if(sd===0)var e=ad.return;else e=ad,ga=ha=null,os(e),io=null,ao=0,e=ad;for(;e!==null;)Sl(e.alternate,e),e=e.return;ad=null}}function Yd(e,t){var n=e.timeoutHandle;return n!==-1&&(e.timeoutHandle=-1,Op(n)),n=e.cancelPendingCommit,n!==null&&(e.cancelPendingCommit=null,n()),Ad=0,Jd(),id=e,ad=n=Mi(e.current,null),od=t,sd=0,cd=null,ld=!1,ud=it(e,t),dd=!1,vd=_d=gd=hd=md=pd=0,bd=yd=null,xd=!1,fd=at(e,t),Si(),n}function Xd(e,t){Ho=null,V.H=gc,t===Ja||t===Xa?(t=no(),sd=3):t===Ya?(t=no(),sd=4):sd=t===Pc?8:typeof t==`object`&&t&&typeof t.then==`function`?6:1,cd=t,ad===null&&(pd=1,Oc(e,Bi(t,e.current)))}function Zd(){var e=Ao.current;return e===null?!0:(od&4194048)===od?jo===null:(od&62914560)===od||od&536870912?e===jo:!1}function Qd(){var e=V.H;return V.H=gc,e===null?gc:e}function $d(){var e=V.A;return V.A=td,e}function ef(){pd=4,ld||(od&4194048)!==od&&Ao.current!==null||(ud=!0),!(md&134217727)&&!(hd&134217727)||id===null||Kd(id,od,_d,!1)}function tf(e,t,n){var r=rd;rd|=2;var i=Qd(),a=$d();(id!==e||od!==t)&&(Td=null,Yd(e,t)),t=!1;var o=pd;a:do try{if(sd!==0&&ad!==null){var s=ad,c=cd;switch(sd){case 8:Jd(),o=6;break a;case 3:case 2:case 9:case 6:Ao.current===null&&(t=!0);var l=sd;if(sd=0,cd=null,cf(e,s,c,l),n&&ud){o=0;break a}break;default:l=sd,sd=0,cd=null,cf(e,s,c,l)}}nf(),o=pd;break}catch(t){Xd(e,t)}while(1);return t&&e.shellSuspendCounter++,ga=ha=null,rd=r,V.H=i,V.A=a,ad===null&&(id=null,od=0,Si()),o}function nf(){for(;ad!==null;)of(ad)}function rf(e,t){var n=rd;rd|=2;var r=Qd(),a=$d();id!==e||od!==t?(Td=null,wd=Le()+500,Yd(e,t)):ud=it(e,t);a:do try{if(sd!==0&&ad!==null){t=ad;var o=cd;b:switch(sd){case 1:sd=0,cd=null,cf(e,t,o,1);break;case 2:case 9:if(Qa(o)){sd=0,cd=null,sf(t);break}t=function(){sd!==2&&sd!==9||id!==e||(sd=7),Ff(e)},o.then(t,t);break a;case 3:sd=7;break a;case 4:sd=5;break a;case 7:Qa(o)?(sd=0,cd=null,sf(t)):(sd=0,cd=null,cf(e,t,o,7));break;case 5:var s=null;switch(ad.tag){case 26:s=ad.memoizedState;case 5:case 27:var c=ad;if(s?ah(s):c.stateNode.complete){sd=0,cd=null;var l=c.sibling;if(l!==null)ad=l;else{var u=c.return;u===null?ad=null:(ad=u,lf(u))}break b}}sd=0,cd=null,cf(e,t,o,5);break;case 6:sd=0,cd=null,cf(e,t,o,6);break;case 8:Jd(),pd=6;break a;default:throw Error(i(462))}}af();break}catch(t){Xd(e,t)}while(1);return ga=ha=null,V.H=r,V.A=a,rd=n,ad===null?(id=null,od=0,Si(),pd):0}function af(){for(;ad!==null&&!Fe();)of(ad)}function of(e){var t=pl(e.alternate,e,fd);e.memoizedProps=e.pendingProps,t===null?lf(e):ad=t}function sf(e){var t=e,n=t.alternate;switch(t.tag){case 15:case 0:t=qc(n,t,t.pendingProps,t.type,void 0,od);break;case 11:t=qc(n,t,t.pendingProps,t.type.render,t.ref,od);break;case 5:os(t);var r=t;r===ta&&(ra?(la(r),r.tag===5&&r.stateNode!=null&&(na=r.stateNode)):(la(r),ra=!0));default:Sl(n,t),t=ad=Ni(t,fd),t=pl(n,t,fd)}e.memoizedProps=e.pendingProps,t===null?lf(e):ad=t}function cf(e,t,n,r){ga=ha=null,os(t),io=null,ao=0;var i=t.return;try{if(Nc(e,i,t,n,od)){pd=1,Oc(e,Bi(n,e.current)),ad=null;return}}catch(t){if(i!==null)throw ad=i,t;pd=1,Oc(e,Bi(n,e.current)),ad=null;return}t.flags&32768?(ra||r===1?e=!0:ud||od&536870912?e=!1:(ld=e=!0,(r===2||r===9||r===3||r===6)&&(r=Ao.current,r!==null&&r.tag===13&&(r.flags|=16384))),uf(t,e)):lf(t)}function lf(e){var t=e;do{if(t.flags&32768){uf(t,ld);return}e=t.return;var n=bl(t.alternate,t,fd);if(n!==null){ad=n;return}if(t=t.sibling,t!==null){ad=t;return}ad=t=e}while(t!==null);pd===0&&(pd=5)}function uf(e,t){do{var n=xl(e.alternate,e);if(n!==null){n.flags&=32767,ad=n;return}if(n=e.return,n!==null&&(n.flags|=32768,n.subtreeFlags=0,n.deletions=null),!t&&(e=e.sibling,e!==null)){ad=e;return}ad=e=n}while(e!==null);pd=6,ad=null}function df(e,t,n,r,a,o,s,c,l,u,d,f){e.cancelPendingCommit=null;do yf();while(Dd!==0);if(rd&6)throw Error(i(327));if(t!==null){if(t===e.current)throw Error(i(177));e===id&&(ad=id=null,od=0),kd=t,Od=e,Ad=n,Md=a,Nd=r,ff(e,t,n,s,c,l,f)}}function ff(e,t,n,r,i,a,o){var s=t.lanes|t.childLanes;if(jd=s,s|=xi,ut(e,n,s,r,i,a),Fd=null,(n&335544064)===n?(Id=Fa(e),r=10262):(Id=null,r=10256),(t.subtreeFlags&r)!==0||(t.flags&r)!==0?(e.callbackNode=null,e.callbackPriority=0,Of(Ve,function(){return bf(),null})):(e.callbackNode=null,e.callbackPriority=0),Vl=!1,r=!!(t.flags&13878),t.subtreeFlags&13878||r){r=V.T,V.T=null,i=ue.p,ue.p=2,a=rd,rd|=4;try{gu(e,t,n)}finally{rd=a,ue.p=i,V.T=r}}Dd=1,Vl?Pd=Up(o,e.containerInfo,Id,hf,gf,mf,_f,bf,pf,null,null):(hf(),gf(),_f())}function pf(e){if(Dd!==0){var t=Od.onRecoverableError;t(e,{componentStack:null})}}function mf(){Dd===3&&(Dd=0,Lu(kd,Od),Dd=4)}function hf(){if(Dd===1){Dd=0;var e=Od,t=kd,n=Ad,r=!!(t.flags&13878);if(t.subtreeFlags&13878||r){r=V.T,V.T=null;var i=ue.p;ue.p=2;var a=rd;rd|=4;try{pu=mu=!1,Nu(t,e,n),n=yp;var o=Gr(e.containerInfo),s=n.focusedElem,c=n.selectionRange;if(o!==s&&s&&s.ownerDocument&&Wr(s.ownerDocument.documentElement,s)){if(c!==null&&Kr(s)){var l=c.start,u=c.end;if(u===void 0&&(u=l),`selectionStart`in s)s.selectionStart=l,s.selectionEnd=Math.min(u,s.value.length);else{var d=s.ownerDocument||document,f=d&&d.defaultView||window;if(f.getSelection){var p=f.getSelection(),m=s.textContent.length,h=Math.min(c.start,m),g=c.end===void 0?h:Math.min(c.end,m);!p.extend&&h>g&&(o=g,g=h,h=o);var _=Ur(s,h),v=Ur(s,g);if(_&&v&&(p.rangeCount!==1||p.anchorNode!==_.node||p.anchorOffset!==_.offset||p.focusNode!==v.node||p.focusOffset!==v.offset)){var y=d.createRange();y.setStart(_.node,_.offset),p.removeAllRanges(),h>g?(p.addRange(y),p.extend(v.node,v.offset)):(y.setEnd(v.node,v.offset),p.addRange(y))}}}}for(d=[],p=s;p=p.parentNode;)p.nodeType===1&&d.push({element:p,left:p.scrollLeft,top:p.scrollTop});for(typeof s.focus==`function`&&s.focus(),s=0;s<d.length;s++){var b=d[s];b.element.scrollLeft=b.left,b.element.scrollTop=b.top}}Eh=!!vp,yp=vp=null}finally{rd=a,ue.p=i,V.T=r}}e.current=t,Dd=2}}function gf(){if(Dd===2){Dd=0;var e=Od,t=kd,n=!!(t.flags&8772);if(t.subtreeFlags&8772||n){n=V.T,V.T=null;var r=ue.p;ue.p=2;var i=rd;rd|=4;try{vu(e,t.alternate,t)}finally{rd=i,ue.p=r,V.T=n}}Dd=3}}function _f(){if(Dd===4||Dd===3){Dd=0;var e=Pd;Pd=null,Ie();var t=Od,n=kd,r=Ad,i=Nd,a=(r&335544064)===r?10262:10256;if((n.subtreeFlags&a)!==0||(n.flags&a)!==0?Dd=5:(Dd=0,kd=Od=null,vf(t,t.pendingLanes)),a=t.pendingLanes,a===0&&(Ed=null),ht(r),n=n.stateNode,qe&&typeof qe.onCommitFiberRoot==`function`)try{qe.onCommitFiberRoot(Ke,n,void 0,(n.current.flags&128)==128)}catch{}if(i!==null){n=V.T,a=ue.p,ue.p=2,V.T=null;try{for(var o=t.onRecoverableError,s=0;s<i.length;s++){var c=i[s];o(c.value,{componentStack:c.stack})}}finally{V.T=n,ue.p=a}}if(i=Fd,o=Id,Id=null,i!==null&&(Fd=null,o===null&&(o=[]),e!==null))for(c=0;c<i.length;c++)n=(0,i[c])(o),n!==void 0&&e.finished.finally(n);Ad&3&&yf(),Ff(t),a=t.pendingLanes,r&261930&&a&42?t===Rd?Ld++:(Ld=0,Rd=t):(Ld=0,Rd=null),If(0,!1)}}function vf(e,t){(e.pooledCacheLanes&=t)===0&&(t=e.pooledCache,t!=null&&(e.pooledCache=null,Ma(t)))}function yf(){return Pd!==null&&(Pd.skipTransition(),Pd=null),hf(),gf(),_f(),bf()}function bf(){if(Dd!==5)return!1;var e=Od,t=jd;jd=0;var n=ht(Ad),r=V.T,a=ue.p;try{ue.p=32>n?32:n,V.T=null,n=Md,Md=null;var o=Od,s=Ad;if(Dd=0,kd=Od=null,Ad=0,rd&6)throw Error(i(331));var c=rd;if(rd|=4,Qu(o.current),Wu(o,o.current,s,n),rd=c,If(0,!1),qe&&typeof qe.onPostCommitFiberRoot==`function`)try{qe.onPostCommitFiberRoot(Ke,o)}catch{}return!0}finally{ue.p=a,V.T=r,vf(e,t)}}function xf(e,t,n){t=Bi(n,t),t=Ac(e.stateNode,t,2),e=_o(e,t,2),e!==null&&(lt(e,2),Ff(e))}function Sf(e,t,n){if(e.tag===3)xf(e,e,n);else for(;t!==null;){if(t.tag===3){xf(t,e,n);break}if(t.tag===1){var r=t.stateNode;if(typeof t.type.getDerivedStateFromError==`function`||typeof r.componentDidCatch==`function`&&(Ed===null||!Ed.has(r))){e=Bi(n,e),n=jc(2),r=_o(t,n,2),r!==null&&(Mc(n,r,t,e),lt(r,2),Ff(r));break}}t=t.return}}function Cf(e,t,n){var r=e.pingCache;if(r===null){r=e.pingCache=new nd;var i=new Set;r.set(t,i)}else i=r.get(t),i===void 0&&(i=new Set,r.set(t,i));i.has(n)||(dd=!0,i.add(n),e=wf.bind(null,e,t,n),t.then(e,e))}function wf(e,t,n){var r=e.pingCache;r!==null&&r.delete(t),e.pingedLanes|=e.suspendedLanes&n,e.warmLanes&=~n,id===e&&(od&n)===n&&(pd===4||pd===3&&(od&62914560)===od&&300>Le()-Sd?rd&2?gd|=n:Yd(e,0):gd|=n,vd===od&&(vd=0)),Ff(e)}function Tf(e,t){t===0&&(t=st()),e=Ti(e,t),e!==null&&(lt(e,t),Ff(e))}function Ef(e){var t=e.memoizedState,n=0;t!==null&&(n=t.retryLane),Tf(e,n)}function Df(e,t){var n=0;switch(e.tag){case 31:case 13:var r=e.stateNode,a=e.memoizedState;a!==null&&(n=a.retryLane);break;case 19:r=e.stateNode;break;case 22:r=e.stateNode._retryCache;break;default:throw Error(i(314))}r!==null&&r.delete(t),Tf(e,n)}function Of(e,t){return Ne(e,t)}var kf=null,Af=null,jf=!1,Mf=!1,Nf=!1,Pf=0;function Ff(e){e!==Af&&e.next===null&&(Af===null?kf=Af=e:Af=Af.next=e),Mf=!0,jf||(jf=!0,Hf())}function If(e,t){if(!Nf&&Mf){Nf=!0;do for(var n=!1,r=kf;r!==null;){if(!t){if(e!==0){var i=r.pendingLanes;if(i===0)var a=0;else{var o=r.suspendedLanes,s=r.pingedLanes;a=(1<<31-Ye(42|e)+1)-1,a&=i&~(o&~s),a=a&201326741?a&201326741|1:a?a|2:0}a!==0&&(n=!0,Vf(r,a))}else a=od,a=rt(r,r===id?a:0,r.cancelPendingCommit!==null||r.timeoutHandle!==-1),!(a&3)||it(r,a)||(n=!0,Vf(r,a))}r=r.next}while(n);Nf=!1}}function Lf(){Rf()}function Rf(){Mf=jf=!1;var e=0;Pf!==0&&Ep()&&(e=Pf);for(var t=Le(),n=null,r=kf;r!==null;){var i=r.next,a=zf(r,t);a===0?(r.next=null,n===null?kf=i:n.next=i,i===null&&(Af=n)):(n=r,(e!==0||a&3)&&(Mf=!0)),r=i}Dd!==0&&Dd!==5||If(e,!1),Pf!==0&&(Pf=0)}function zf(e,t){for(var n=e.suspendedLanes,r=e.pingedLanes,i=e.expirationTimes,a=e.pendingLanes&-62914561;0<a;){var o=31-Ye(a),s=1<<o,c=i[o];c===-1?((s&n)===0||(s&r)!==0)&&(i[o]=ot(s,t)):c<=t&&(e.expiredLanes|=s),a&=~s}if(t=id,n=od,n=rt(e,e===t?n:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r=e.callbackNode,n===0||e===t&&(sd===2||sd===9)||e.cancelPendingCommit!==null)return r!==null&&r!==null&&Pe(r),e.callbackNode=null,e.callbackPriority=0;if(!(n&3)||it(e,n)){if(t=n&-n,t===e.callbackPriority)return t;switch(r!==null&&Pe(r),ht(n)){case 2:case 8:n=Be;break;case 32:n=Ve;break;case 268435456:n=Ue;break;default:n=Ve}return r=Bf.bind(null,e),n=Ne(n,r),e.callbackPriority=t,e.callbackNode=n,t}return r!==null&&r!==null&&Pe(r),e.callbackPriority=2,e.callbackNode=null,2}function Bf(e,t){if(Dd!==0&&Dd!==5)return e.callbackNode=null,e.callbackPriority=0,null;var n=e.callbackNode;if(yf()&&e.callbackNode!==n)return null;var r=od;return r=rt(e,e===id?r:0,e.cancelPendingCommit!==null||e.timeoutHandle!==-1),r===0?null:(Ud(e,r,t),zf(e,Le()),e.callbackNode!=null&&e.callbackNode===n?Bf.bind(null,e):null)}function Vf(e,t){if(yf())return null;Ud(e,t,!0)}function Hf(){jp(function(){rd&6?Ne(ze,Lf):Rf()})}function Uf(){if(Pf===0){var e=Ra;e===0&&(e=$e,$e<<=1,!($e&261888)&&($e=256)),Pf=e}return Pf}function Wf(e){return e==null||typeof e==`symbol`||typeof e==`boolean`?null:typeof e==`function`?e:hn(e)}function Gf(e,t,n,r,i){if(t===`submit`&&n&&n.stateNode===i){var a=Wf((i[bt]||null).action),o=r.submitter;o&&(t=(t=o[bt]||null)?Wf(t.formAction):o.getAttribute(`formAction`),t!==null&&(a=t,o=null));var s=new Ln(`action`,`action`,null,r,i);e.push({event:s,listeners:[{instance:null,listener:function(){if(r.defaultPrevented){if(Pf!==0){var e=new FormData(i,o);nc(n,{pending:!0,data:e,method:i.method,action:a},null,e)}}else typeof a==`function`&&(s.preventDefault(),e=new FormData(i,o),nc(n,{pending:!0,data:e,method:i.method,action:a},a,e))},currentTarget:i}]})}}for(var Kf=0;Kf<fi.length;Kf++){var qf=fi[Kf];pi(qf.toLowerCase(),`on`+(qf[0].toUpperCase()+qf.slice(1)))}pi(ii,`onAnimationEnd`),pi(ai,`onAnimationIteration`),pi(oi,`onAnimationStart`),pi(`dblclick`,`onDoubleClick`),pi(`focusin`,`onFocus`),pi(`focusout`,`onBlur`),pi(si,`onTransitionRun`),pi(ci,`onTransitionStart`),pi(li,`onTransitionCancel`),pi(ui,`onTransitionEnd`),Rt(`onMouseEnter`,[`mouseout`,`mouseover`]),Rt(`onMouseLeave`,[`mouseout`,`mouseover`]),Rt(`onPointerEnter`,[`pointerout`,`pointerover`]),Rt(`onPointerLeave`,[`pointerout`,`pointerover`]),Lt(`onChange`,`change click focusin focusout input keydown keyup selectionchange`.split(` `)),Lt(`onSelect`,`focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange`.split(` `)),Lt(`onBeforeInput`,[`compositionend`,`keypress`,`textInput`,`paste`]),Lt(`onCompositionEnd`,`compositionend focusout keydown keypress keyup mousedown`.split(` `)),Lt(`onCompositionStart`,`compositionstart focusout keydown keypress keyup mousedown`.split(` `)),Lt(`onCompositionUpdate`,`compositionupdate focusout keydown keypress keyup mousedown`.split(` `));var Jf=`abort canplay canplaythrough durationchange emptied encrypted ended error loadeddata loadedmetadata loadstart pause play playing progress ratechange resize seeked seeking stalled suspend timeupdate volumechange waiting`.split(` `),Yf=new Set(`beforetoggle cancel close invalid load scroll scrollend toggle`.split(` `).concat(Jf));function Xf(e,t){t=!!(t&4);for(var n=0;n<e.length;n++){var r=e[n],i=r.event;r=r.listeners;a:{var a=void 0;if(t)for(var o=r.length-1;0<=o;o--){var s=r[o],c=s.instance,l=s.currentTarget;if(s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){vi(e)}i.currentTarget=null,a=c}else for(o=0;o<r.length;o++){if(s=r[o],c=s.instance,l=s.currentTarget,s=s.listener,c!==a&&i.isPropagationStopped())break a;a=s,i.currentTarget=l;try{a(i)}catch(e){vi(e)}i.currentTarget=null,a=c}}}}function Zf(e,t){var n=t[St];n===void 0&&(n=t[St]=new Set);var r=e+`__bubble`;n.has(r)||(tp(t,e,2,!1),n.add(r))}function Qf(e,t,n){var r=0;t&&(r|=4),tp(n,e,r,t)}var $f=`_reactListening`+Math.random().toString(36).slice(2);function ep(e){if(!e[$f]){e[$f]=!0,Ft.forEach(function(t){t!==`selectionchange`&&(Yf.has(t)||Qf(t,!1,e),Qf(t,!0,e))});var t=e.nodeType===9?e:e.ownerDocument;t===null||t[$f]||(t[$f]=!0,Qf(`selectionchange`,!1,t))}}function tp(e,t,n,r){switch(Nh(t)){case 2:var i=Dh;break;case 8:i=Oh;break;default:i=kh}n=i.bind(null,t,n,e),i=void 0,!En||t!==`touchstart`&&t!==`touchmove`&&t!==`wheel`||(i=!0),r?i===void 0?e.addEventListener(t,n,!0):e.addEventListener(t,n,{capture:!0,passive:i}):i===void 0?e.addEventListener(t,n,!1):e.addEventListener(t,n,{passive:i})}function np(e,t,n,r,i){var a=r;if(!(t&1)&&!(t&2)&&r!==null)a:for(;;){if(r===null)return;var s=r.tag;if(s===3||s===4){var c=r.stateNode.containerInfo;if(c===i)break;if(s===4)for(s=r.return;s!==null;){var l=s.tag;if((l===3||l===4)&&s.stateNode.containerInfo===i)return;s=s.return}for(;c!==null;){if(s=kt(c),s===null)return;if(l=s.tag,l===5||l===6||l===26||l===27){r=a=s;continue a}c=c.parentNode}}r=r.return}Cn(function(){var r=a,i=vn(n),s=[];a:{var c=di.get(e);if(c!==void 0){var l=Ln,u=e;switch(e){case`keypress`:if(Mn(n)===0)break a;case`keydown`:case`keyup`:l=tr;break;case`focusin`:u=`focus`,l=Kn;break;case`focusout`:u=`blur`,l=Kn;break;case`beforeblur`:case`afterblur`:l=Kn;break;case`click`:if(n.button===2)break a;case`auxclick`:case`dblclick`:case`mousedown`:case`mousemove`:case`mouseup`:case`mouseout`:case`mouseover`:case`contextmenu`:l=Wn;break;case`drag`:case`dragend`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`dragstart`:case`drop`:l=Gn;break;case`touchcancel`:case`touchend`:case`touchmove`:case`touchstart`:l=ir;break;case ii:case ai:case oi:l=qn;break;case ui:l=ar;break;case`scroll`:case`scrollend`:l=zn;break;case`wheel`:l=or;break;case`copy`:case`cut`:case`paste`:l=Jn;break;case`gotpointercapture`:case`lostpointercapture`:case`pointercancel`:case`pointerdown`:case`pointermove`:case`pointerout`:case`pointerover`:case`pointerup`:l=nr;break;case`submit`:l=rr;break;case`toggle`:case`beforetoggle`:l=sr}var d=!!(t&4),f=!d&&(e===`scroll`||e===`scrollend`),p=d?c===null?null:c+`Capture`:c;d=[];for(var m=r,h;m!==null;){var g=m;if(h=g.stateNode,g=g.tag,g!==5&&g!==26&&g!==27||h===null||p===null||(g=wn(m,p),g!=null&&d.push(rp(m,g,h))),f)break;m=m.return}0<d.length&&(c=new l(c,u,null,n,i),s.push({event:c,listeners:d}))}}if(!(t&7)){a:{if(l=e===`mouseover`||e===`pointerover`,c=e===`mouseout`||e===`pointerout`,l&&n!==_n&&(u=n.relatedTarget||n.fromElement)&&(kt(u)||u[xt]))break a;(c||l)&&(u=i.window===i?i:(l=i.ownerDocument)?l.defaultView||l.parentWindow:window,c?(l=n.relatedTarget||n.toElement,c=r,l=l?kt(l):null,l!==null&&(f=o(l),d=l.tag,l!==f||d!==5&&d!==27&&d!==6)&&(l=null)):(c=null,l=r),c!==l&&(d=Wn,g=`onMouseLeave`,p=`onMouseEnter`,m=`mouse`,(e===`pointerout`||e===`pointerover`)&&(d=nr,g=`onPointerLeave`,p=`onPointerEnter`,m=`pointer`),f=c==null?u:jt(c),h=l==null?u:jt(l),u=new d(g,m+`leave`,c,n,i),u.target=f,u.relatedTarget=h,g=null,kt(i)===r&&(d=new d(p,m+`enter`,l,n,i),d.target=h,d.relatedTarget=f,g=d),f=g,d=c&&l?C(c,l,ap):null,c!==null&&op(s,u,c,d,!1),l!==null&&f!==null&&op(s,f,l,d,!0)))}a:{if(c=r?jt(r):window,l=c.nodeName&&c.nodeName.toLowerCase(),l===`select`||l===`input`&&c.type===`file`)var _=Dr;else if(xr(c)){if(Or)_=Lr;else{_=Fr;var v=Pr}}else l=c.nodeName,!l||l.toLowerCase()!==`input`||c.type!==`checkbox`&&c.type!==`radio`?r&&fn(r.elementType)&&(_=Dr):_=Ir;if(_&&=_(e,r)){Sr(s,_,n,i);break a}v&&v(e,c,r)}switch(v=r?jt(r):window,e){case`focusin`:(xr(v)||v.contentEditable===`true`)&&(Jr=v,Yr=r,Xr=null);break;case`focusout`:Xr=Yr=Jr=null;break;case`mousedown`:Zr=!0;break;case`contextmenu`:case`mouseup`:case`dragend`:Zr=!1,Qr(s,n,i);break;case`selectionchange`:if(qr)break;case`keydown`:case`keyup`:Qr(s,n,i)}var y;if(lr)b:{switch(e){case`compositionstart`:var b=`onCompositionStart`;break b;case`compositionend`:b=`onCompositionEnd`;break b;case`compositionupdate`:b=`onCompositionUpdate`;break b}b=void 0}else _r?hr(e,n)&&(b=`onCompositionEnd`):e===`keydown`&&n.keyCode===229&&(b=`onCompositionStart`);b&&(fr&&n.locale!==`ko`&&(_r||b!==`onCompositionStart`?b===`onCompositionEnd`&&_r&&(y=jn()):(On=i,kn=`value`in On?On.value:On.textContent,_r=!0)),v=ip(r,b),0<v.length&&(b=new Yn(b,e,null,n,i),s.push({event:b,listeners:v}),y?b.data=y:(y=gr(n),y!==null&&(b.data=y)))),(y=dr?vr(e,n):yr(e,n))&&(b=ip(r,`onBeforeInput`),0<b.length&&(v=new Yn(`onBeforeInput`,`beforeinput`,null,n,i),s.push({event:v,listeners:b}),v.data=y)),Gf(s,e,r,n,i)}Xf(s,t)})}function rp(e,t,n){return{instance:e,listener:t,currentTarget:n}}function ip(e,t){for(var n=t+`Capture`,r=[];e!==null;){var i=e,a=i.stateNode;if(i=i.tag,i!==5&&i!==26&&i!==27||a===null||(i=wn(e,n),i!=null&&r.unshift(rp(e,i,a)),i=wn(e,t),i!=null&&r.push(rp(e,i,a))),e.tag===3)return r;e=e.return}return[]}function ap(e){if(e===null)return null;do e=e.return;while(e&&e.tag!==5&&e.tag!==27);return e||null}function op(e,t,n,r,i){for(var a=t._reactName,o=[];n!==null&&n!==r;){var s=n,c=s.alternate,l=s.stateNode;if(s=s.tag,c!==null&&c===r)break;s!==5&&s!==26&&s!==27||l===null||(c=l,i?(l=wn(n,a),l!=null&&o.unshift(rp(n,l,c))):i||(l=wn(n,a),l!=null&&o.push(rp(n,l,c)))),n=n.return}o.length!==0&&e.push({event:t,listeners:o})}var sp=/\r\n?/g,cp=/\u0000|\uFFFD/g;function lp(e){return(typeof e==`string`?e:``+e).replace(sp,`
|
|
9
|
+
`).replace(cp,``)}function up(e,t){return t=lp(t),lp(e)===t}function dp(e,t,n,r,a,o){switch(n){case`children`:if(typeof r==`string`)t===`body`||t===`textarea`&&r===``||cn(e,r);else if(typeof r==`number`||typeof r==`bigint`)t!==`body`&&cn(e,``+r);else return;break;case`className`:Kt(e,`class`,r);break;case`tabIndex`:Kt(e,`tabindex`,r);break;case`dir`:case`role`:case`viewBox`:case`width`:case`height`:Kt(e,n,r);break;case`style`:dn(e,r,o);return;case`data`:if(t!==`object`){Kt(e,`data`,r);break}case`src`:case`href`:if(r===``&&(t!==`a`||n!==`href`)||r==null||typeof r==`function`||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=hn(r),e.setAttribute(n,r);break;case`action`:case`formAction`:if(typeof r==`function`){e.setAttribute(n,`javascript:throw new Error('A React form was unexpectedly submitted. If you called form.submit() manually, consider using form.requestSubmit() instead. If you\\'re trying to use event.stopPropagation() in a submit event handler, consider also calling event.preventDefault().')`);break}if(typeof o==`function`&&(n===`formAction`?(t!==`input`&&dp(e,t,`name`,a.name,a,null),dp(e,t,`formEncType`,a.formEncType,a,null),dp(e,t,`formMethod`,a.formMethod,a,null),dp(e,t,`formTarget`,a.formTarget,a,null)):(dp(e,t,`encType`,a.encType,a,null),dp(e,t,`method`,a.method,a,null),dp(e,t,`target`,a.target,a,null))),r==null||typeof r==`symbol`||typeof r==`boolean`){e.removeAttribute(n);break}r=hn(r),e.setAttribute(n,r);break;case`onClick`:r!=null&&(e.onclick=gn);return;case`onScroll`:r!=null&&Zf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Zf(`scrollend`,e);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`multiple`:e.multiple=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`muted`:e.muted=r&&typeof r!=`function`&&typeof r!=`symbol`;break;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`defaultValue`:case`defaultChecked`:case`innerHTML`:case`ref`:break;case`autoFocus`:break;case`xlinkHref`:if(r==null||typeof r==`function`||typeof r==`boolean`||typeof r==`symbol`){e.removeAttribute(`xlink:href`);break}n=hn(r),e.setAttributeNS(`http://www.w3.org/1999/xlink`,`xlink:href`,n);break;case`contentEditable`:case`spellCheck`:case`draggable`:case`value`:case`autoReverse`:case`externalResourcesRequired`:case`focusable`:case`preserveAlpha`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`inert`:case`allowFullScreen`:case`async`:case`autoPlay`:case`controls`:case`credentialless`:case`default`:case`defer`:case`disabled`:case`disablePictureInPicture`:case`disableRemotePlayback`:case`formNoValidate`:case`hidden`:case`loop`:case`noModule`:case`noValidate`:case`open`:case`playsInline`:case`readOnly`:case`required`:case`reversed`:case`scoped`:case`seamless`:case`itemScope`:r&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,``):e.removeAttribute(n);break;case`capture`:case`download`:!0===r?e.setAttribute(n,``):!1!==r&&r!=null&&typeof r!=`function`&&typeof r!=`symbol`?e.setAttribute(n,r):e.removeAttribute(n);break;case`cols`:case`rows`:case`size`:case`span`:r!=null&&typeof r!=`function`&&typeof r!=`symbol`&&!isNaN(r)&&1<=r?e.setAttribute(n,r):e.removeAttribute(n);break;case`rowSpan`:case`start`:r==null||typeof r==`function`||typeof r==`symbol`||isNaN(r)?e.removeAttribute(n):e.setAttribute(n,r);break;case`popover`:Zf(`beforetoggle`,e),Zf(`toggle`,e),Gt(e,`popover`,r);break;case`xlinkActuate`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:actuate`,r);break;case`xlinkArcrole`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:arcrole`,r);break;case`xlinkRole`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:role`,r);break;case`xlinkShow`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:show`,r);break;case`xlinkTitle`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:title`,r);break;case`xlinkType`:qt(e,`http://www.w3.org/1999/xlink`,`xlink:type`,r);break;case`xmlBase`:qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:base`,r);break;case`xmlLang`:qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:lang`,r);break;case`xmlSpace`:qt(e,`http://www.w3.org/XML/1998/namespace`,`xml:space`,r);break;case`is`:Gt(e,`is`,r);break;case`innerText`:case`textContent`:return;default:if(!(2<n.length)||n[0]!==`o`&&n[0]!==`O`||n[1]!==`n`&&n[1]!==`N`)n=pn.get(n)||n,Gt(e,n,r);else return}Ut=!0}function fp(e,t,n,r,a,o){switch(n){case`style`:dn(e,r,o);return;case`dangerouslySetInnerHTML`:if(r!=null){if(typeof r!=`object`||!(`__html`in r))throw Error(i(61));if(n=r.__html,n!=null){if(a.children!=null)throw Error(i(60));o?.__html!==n&&(e.innerHTML=n)}}break;case`children`:if(typeof r==`string`)cn(e,r);else if(typeof r==`number`||typeof r==`bigint`)cn(e,``+r);else return;break;case`onScroll`:r!=null&&Zf(`scroll`,e);return;case`onScrollEnd`:r!=null&&Zf(`scrollend`,e);return;case`onClick`:r!=null&&(e.onclick=gn);return;case`suppressContentEditableWarning`:case`suppressHydrationWarning`:case`innerHTML`:case`ref`:return;case`innerText`:case`textContent`:return;default:if(!It.hasOwnProperty(n))a:{if(n[0]===`o`&&n[1]===`n`&&(a=n.endsWith(`Capture`),o=n.slice(2,a?n.length-7:void 0),t=e[bt]||null,t=t==null?null:t[n],typeof t==`function`&&e.removeEventListener(o,t,a),typeof r==`function`)){typeof t!=`function`&&t!==null&&(n in e?e[n]=null:e.hasAttribute(n)&&e.removeAttribute(n)),e.addEventListener(o,r,a);break a}Ut=!0,n in e?e[n]=r:!0===r?e.setAttribute(n,``):Gt(e,n,r)}return}Ut=!0}function pp(e,t,n){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`img`:Zf(`error`,e),Zf(`load`,e);var r=!1,a=!1,o;for(o in n)if(n.hasOwnProperty(o)){var s=n[o];if(s!=null)switch(o){case`src`:r=!0;break;case`srcSet`:a=!0;break;case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:dp(e,t,o,s,n,null)}}a&&dp(e,t,`srcSet`,n.srcSet,n,null),r&&dp(e,t,`src`,n.src,n,null);return;case`input`:Zf(`invalid`,e);var c=o=s=a=null,l=null,u=null;for(r in n)if(n.hasOwnProperty(r)){var d=n[r];if(d!=null)switch(r){case`name`:a=d;break;case`type`:s=d;break;case`checked`:l=d;break;case`defaultChecked`:u=d;break;case`value`:o=d;break;case`defaultValue`:c=d;break;case`children`:case`dangerouslySetInnerHTML`:if(d!=null)throw Error(i(137,t));break;default:dp(e,t,r,d,n,null)}}nn(e,o,c,l,u,s,a,!1);return;case`select`:for(a in Zf(`invalid`,e),r=s=o=null,n)if(n.hasOwnProperty(a)&&(c=n[a],c!=null))switch(a){case`value`:o=c;break;case`defaultValue`:s=c;break;case`multiple`:r=c;default:dp(e,t,a,c,n,null)}t=o,n=s,e.multiple=!!r,t==null?n!=null&&an(e,!!r,n,!0):an(e,!!r,t,!1);return;case`textarea`:for(s in Zf(`invalid`,e),o=a=r=null,n)if(n.hasOwnProperty(s)&&(c=n[s],c!=null))switch(s){case`value`:r=c;break;case`defaultValue`:a=c;break;case`children`:o=c;break;case`dangerouslySetInnerHTML`:if(c!=null)throw Error(i(91));break;default:dp(e,t,s,c,n,null)}sn(e,r,a,o);return;case`option`:for(l in n)if(n.hasOwnProperty(l)&&(r=n[l],r!=null))switch(l){case`selected`:e.selected=r&&typeof r!=`function`&&typeof r!=`symbol`;break;default:dp(e,t,l,r,n,null)}return;case`dialog`:Zf(`beforetoggle`,e),Zf(`toggle`,e),Zf(`cancel`,e),Zf(`close`,e);break;case`iframe`:case`object`:Zf(`load`,e);break;case`video`:case`audio`:for(r=0;r<Jf.length;r++)Zf(Jf[r],e);break;case`image`:Zf(`error`,e),Zf(`load`,e);break;case`details`:Zf(`toggle`,e);break;case`embed`:case`source`:case`link`:Zf(`error`,e),Zf(`load`,e);case`area`:case`base`:case`br`:case`col`:case`hr`:case`keygen`:case`meta`:case`param`:case`track`:case`wbr`:case`menuitem`:for(u in n)if(n.hasOwnProperty(u)&&(r=n[u],r!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:throw Error(i(137,t));default:dp(e,t,u,r,n,null)}return;default:if(fn(t)){for(d in n)n.hasOwnProperty(d)&&(r=n[d],r!==void 0&&fp(e,t,d,r,n,void 0));return}}for(c in n)n.hasOwnProperty(c)&&(r=n[c],r!=null&&dp(e,t,c,r,n,null))}var mp={};function hp(e,t,n,r){switch(t){case`div`:case`span`:case`svg`:case`path`:case`a`:case`g`:case`p`:case`li`:break;case`input`:var a=null,o=null,s=null,c=null,l=null,u=null,d=null;for(m in n){var f=n[m];if(n.hasOwnProperty(m)&&f!=null)switch(m){case`checked`:break;case`value`:break;case`defaultValue`:l=f;default:r.hasOwnProperty(m)||dp(e,t,m,null,r,f)}}for(var p in r){var m=r[p];if(f=n[p],r.hasOwnProperty(p)&&(m!=null||f!=null))switch(p){case`type`:m!==f&&(Ut=!0),o=m;break;case`name`:m!==f&&(Ut=!0),a=m;break;case`checked`:m!==f&&(Ut=!0),u=m;break;case`defaultChecked`:m!==f&&(Ut=!0),d=m;break;case`value`:m!==f&&(Ut=!0),s=m;break;case`defaultValue`:m!==f&&(Ut=!0),c=m;break;case`children`:case`dangerouslySetInnerHTML`:if(m!=null)throw Error(i(137,t));break;default:m!==f&&dp(e,t,p,m,r,f)}}tn(e,s,c,l,u,d,o,a);return;case`select`:for(o in m=s=c=p=null,n)if(l=n[o],n.hasOwnProperty(o)&&l!=null)switch(o){case`value`:break;case`multiple`:m=l;default:r.hasOwnProperty(o)||dp(e,t,o,null,r,l)}for(a in r)if(o=r[a],l=n[a],r.hasOwnProperty(a)&&(o!=null||l!=null))switch(a){case`value`:o!==l&&(Ut=!0),p=o;break;case`defaultValue`:o!==l&&(Ut=!0),c=o;break;case`multiple`:o!==l&&(Ut=!0),s=o;default:o!==l&&dp(e,t,a,o,r,l)}t=c,n=s,r=m,p==null?!!r!=!!n&&(t==null?an(e,!!n,n?[]:``,!1):an(e,!!n,t,!0)):an(e,!!n,p,!1);return;case`textarea`:for(c in m=p=null,n)if(a=n[c],n.hasOwnProperty(c)&&a!=null&&!r.hasOwnProperty(c))switch(c){case`value`:break;case`children`:break;default:dp(e,t,c,null,r,a)}for(s in r)if(a=r[s],o=n[s],r.hasOwnProperty(s)&&(a!=null||o!=null))switch(s){case`value`:a!==o&&(Ut=!0),p=a;break;case`defaultValue`:a!==o&&(Ut=!0),m=a;break;case`children`:break;case`dangerouslySetInnerHTML`:if(a!=null)throw Error(i(91));break;default:a!==o&&dp(e,t,s,a,r,o)}on(e,p,m);return;case`option`:for(var h in n)if(p=n[h],n.hasOwnProperty(h)&&p!=null&&!r.hasOwnProperty(h))switch(h){case`selected`:e.selected=!1;break;default:dp(e,t,h,null,r,p)}for(l in r)if(p=r[l],m=n[l],r.hasOwnProperty(l)&&p!==m&&(p!=null||m!=null))switch(l){case`selected`:p!==m&&(Ut=!0),e.selected=p&&typeof p!=`function`&&typeof p!=`symbol`;break;default:dp(e,t,l,p,r,m)}return;case`img`:case`link`:case`area`:case`base`:case`br`:case`col`:case`embed`:case`hr`:case`keygen`:case`meta`:case`param`:case`source`:case`track`:case`wbr`:case`menuitem`:for(var g in n)p=n[g],n.hasOwnProperty(g)&&p!=null&&!r.hasOwnProperty(g)&&dp(e,t,g,null,r,p);for(u in r)if(p=r[u],m=n[u],r.hasOwnProperty(u)&&p!==m&&(p!=null||m!=null))switch(u){case`children`:case`dangerouslySetInnerHTML`:if(p!=null)throw Error(i(137,t));break;default:dp(e,t,u,p,r,m)}return;default:if(fn(t)){for(var _ in n)p=n[_],n.hasOwnProperty(_)&&p!==void 0&&!r.hasOwnProperty(_)&&fp(e,t,_,void 0,r,p);for(d in r)p=r[d],m=n[d],!r.hasOwnProperty(d)||p===m||p===void 0&&m===void 0||fp(e,t,d,p,r,m);return}}for(var v in n)p=n[v],n.hasOwnProperty(v)&&p!=null&&!r.hasOwnProperty(v)&&dp(e,t,v,null,r,p);for(f in r)p=r[f],m=n[f],!r.hasOwnProperty(f)||p===m||p==null&&m==null||dp(e,t,f,p,r,m)}function gp(e){switch(e){case`css`:case`script`:case`font`:case`img`:case`image`:case`input`:case`link`:return!0;default:return!1}}function _p(){if(typeof performance.getEntriesByType==`function`){for(var e=0,t=0,n=performance.getEntriesByType(`resource`),r=0;r<n.length;r++){var i=n[r],a=i.transferSize,o=i.initiatorType,s=i.duration;if(a&&s&&gp(o)){for(o=0,s=i.responseEnd,r+=1;r<n.length;r++){var c=n[r],l=c.startTime;if(l>s)break;var u=c.transferSize,d=c.initiatorType;u&&gp(d)&&(c=c.responseEnd,o+=u*(c<s?1:(s-l)/(c-l)))}if(--r,t+=8*(a+o)/(i.duration/1e3),e++,10<e)break}}if(0<e)return t/e/1e6}return navigator.connection&&(e=navigator.connection.downlink,typeof e==`number`)?e:5}var vp=null,yp=null;function bp(e){return e.nodeType===9?e:e.ownerDocument}function xp(e){switch(e){case`http://www.w3.org/2000/svg`:return 1;case`http://www.w3.org/1998/Math/MathML`:return 2;default:return 0}}function Sp(e,t){if(e===0)switch(t){case`svg`:return 1;case`math`:return 2;default:return 0}return e===1&&t===`foreignObject`?0:e}function Cp(e,t,n,r){return n=bp(n).createElement(e),n[yt]=r,n[bt]=t,pp(n,e,t),Nt(n),n}function wp(e,t){return e===`textarea`||e===`noscript`||typeof t.children==`string`||typeof t.children==`number`||typeof t.children==`bigint`||typeof t.dangerouslySetInnerHTML==`object`&&t.dangerouslySetInnerHTML!==null&&t.dangerouslySetInnerHTML.__html!=null}var Tp=null;function Ep(){var e=window.event;return e&&e.type===`popstate`?e!==Tp&&(Tp=e,!0):(Tp=null,!1)}var Dp=typeof setTimeout==`function`?setTimeout:void 0,Op=typeof clearTimeout==`function`?clearTimeout:void 0,kp=typeof Promise==`function`?Promise:void 0,Ap=typeof requestAnimationFrame==`function`?requestAnimationFrame:Dp,jp=typeof queueMicrotask==`function`?queueMicrotask:kp===void 0?Dp:function(e){return kp.resolve(null).then(e).catch(Mp)};function Mp(e){setTimeout(function(){throw e})}function Np(e){return e===`head`}function Pp(e,t){var n=t,r=0;do{var i=n.nextSibling;if(e.removeChild(n),i&&i.nodeType===8){if(n=i.data,n===`/$`||n===`/&`){if(r===0){e.removeChild(i),Qh(t);return}r--}else if(n===`$`||n===`$?`||n===`$~`||n===`$!`||n===`&`)r++;else if(n===`html`)Om(e.ownerDocument.documentElement);else if(n===`head`){n=e.ownerDocument.head,Om(n);for(var a=n.firstChild;a;){var o=a.nextSibling,s=a.nodeName;a[Et]||s===`SCRIPT`||s===`STYLE`||s===`LINK`&&a.rel.toLowerCase()===`stylesheet`||n.removeChild(a),a=o}}else n===`body`&&Om(e.ownerDocument.body)}n=i}while(n);Qh(t)}function Fp(e,t){var n=e;e=0;do{var r=n.nextSibling;if(n.nodeType===1?t?(n._stashedDisplay=n.style.display,n.style.display=`none`):(n.style.display=n._stashedDisplay||``,n.getAttribute(`style`)===``&&n.removeAttribute(`style`)):n.nodeType===3&&(t?(n._stashedText=n.nodeValue,n.nodeValue=``):n.nodeValue=n._stashedText||``),r&&r.nodeType===8){if(n=r.data,n===`/$`){if(e===0)break;e--}else n!==`$`&&n!==`$?`&&n!==`$~`&&n!==`$!`||e++}n=r}while(n)}function Ip(e,t,n){if(t=CSS.escape(t)===t?t:`r-`+btoa(t).replace(/=/g,``),e.style.viewTransitionName=t,n!=null&&(e.style.viewTransitionClass=n),n=getComputedStyle(e),n.display===`inline`){if(t=e.getClientRects(),t.length===1)var r=1;else for(var i=r=0;i<t.length;i++){var a=t[i];0<a.width&&0<a.height&&r++}r===1&&(e=e.style,e.display=t.length===1?`inline-block`:`block`,e.marginTop=`-`+n.paddingTop,e.marginBottom=`-`+n.paddingBottom)}}function Lp(e,t){e=e.style,t=t.style;var n=t==null?null:t.hasOwnProperty(`viewTransitionName`)?t.viewTransitionName:t.hasOwnProperty(`view-transition-name`)?t[`view-transition-name`]:null;e.viewTransitionName=n==null||typeof n==`boolean`?``:(``+n).trim(),n=t==null?null:t.hasOwnProperty(`viewTransitionClass`)?t.viewTransitionClass:t.hasOwnProperty(`view-transition-class`)?t[`view-transition-class`]:null,e.viewTransitionClass=n==null||typeof n==`boolean`?``:(``+n).trim(),e.display===`inline-block`&&(t==null?e.display=e.margin=``:(n=t.display,e.display=n==null||typeof n==`boolean`?``:n,n=t.margin,n==null?(n=t.hasOwnProperty(`marginTop`)?t.marginTop:t[`margin-top`],e.marginTop=n==null||typeof n==`boolean`?``:n,t=t.hasOwnProperty(`marginBottom`)?t.marginBottom:t[`margin-bottom`],e.marginBottom=t==null||typeof t==`boolean`?``:t):e.margin=n))}function Rp(e,t,n){return n=n.ownerDocument.defaultView,{rect:e,abs:t.position===`absolute`||t.position===`fixed`,clip:t.clipPath!==`none`||t.overflow!==`visible`||t.filter!==`none`||t.mask!==`none`||t.mask!==`none`||t.borderRadius!==`0px`,view:0<=e.bottom&&0<=e.right&&e.top<=n.innerHeight&&e.left<=n.innerWidth}}function zp(e){return Rp(e.getBoundingClientRect(),getComputedStyle(e),e)}function Bp(e){var t=e.getBoundingClientRect();t=new DOMRect(t.x+2e4,t.y+2e4,t.width,t.height);var n=getComputedStyle(e);return Rp(t,n,e)}function Vp(e){return e.documentElement.clientHeight}function Hp(e){this.addEventListener(`load`,e),this.addEventListener(`error`,e)}function Up(e,t,n,r,i,a,o,s,c){var l=t.nodeType===9?t:t.ownerDocument;try{var u=l.startViewTransition({update:function(){var t=l.defaultView,n=t.navigation&&t.navigation.transition,o=l.fonts.status;r();var s=[];if(o===`loaded`&&(Vp(l),l.fonts.status===`loading`&&s.push(l.fonts.ready)),o=s.length,e!==null)for(var c=e.suspenseyImages,u=0,d=0;d<c.length;d++){var f=c[d];if(!f.complete){var p=f.getBoundingClientRect();if(0<p.bottom&&0<p.right&&p.top<t.innerHeight&&p.left<t.innerWidth){if(u+=oh(f),u>lh){s.length=o;break}f=new Promise(Hp.bind(f)),s.push(f)}}}if(0<s.length)return t=Promise.race([Promise.all(s),new Promise(function(e){return setTimeout(e,500)})]).then(i,i),(n?Promise.allSettled([n.finished,t]):t).then(a,a);if(i(),n)return n.finished.then(a,a);a()},types:n});l.__reactViewTransition=u;var d=[];return u.ready.then(function(){for(var e=l.documentElement.getAnimations({subtree:!0}),t=0;t<e.length;t++){var n=e[t],r=n.effect,i=r.pseudoElement;if(i!=null&&i.startsWith(`::view-transition`)){d.push(n),n=r.getKeyframes();for(var a=i=void 0,s=!0,c=0;c<n.length;c++){var u=n[c],f=u.width;if(i===void 0)i=f;else if(i!==f){s=!1;break}if(f=u.height,a===void 0)a=f;else if(a!==f){s=!1;break}delete u.width,delete u.height,u.transform===`none`&&delete u.transform}s&&i!==void 0&&a!==void 0&&(r.setKeyframes(n),s=getComputedStyle(r.target,r.pseudoElement),s.width!==i||s.height!==a)&&(s=n[0],s.width=i,s.height=a,s=n[n.length-1],s.width=i,s.height=a,r.setKeyframes(n))}}o()},function(e){l.__reactViewTransition===u&&(l.__reactViewTransition=null);try{if(typeof e==`object`&&e)switch(e.name){case`InvalidStateError`:(e.message===`View transition was skipped because document visibility state is hidden.`||e.message===`Skipping view transition because document visibility state has become hidden.`||e.message===`Skipping view transition because viewport size changed.`||e.message===`Transition was aborted because of invalid state`)&&(e=null)}e!==null&&c(e)}finally{r(),i(),o()}}),u.finished.finally(function(){for(var e=0;e<d.length;e++)d[e].cancel();l.__reactViewTransition===u&&(l.__reactViewTransition=null),s()}),u}catch{return r(),i(),o(),null}}function Wp(e,t){this._scope=document.documentElement,this._selector=`::view-transition-`+e+`(`+t+`)`}Wp.prototype.animate=function(e,t){return t=typeof t==`number`?{duration:t}:w({},t),t.pseudoElement=this._selector,this._scope.animate(e,t)},Wp.prototype.getAnimations=function(){for(var e=this._scope,t=this._selector,n=e.getAnimations({subtree:!0}),r=[],i=0;i<n.length;i++){var a=n[i].effect;a!==null&&a.target===e&&a.pseudoElement===t&&r.push(n[i])}return r},Wp.prototype.getComputedStyle=function(){return getComputedStyle(this._scope,this._selector)};function Gp(e){return{name:e,group:new Wp(`group`,e),imagePair:new Wp(`image-pair`,e),old:new Wp(`old`,e),new:new Wp(`new`,e)}}function Kp(e){this._fragmentFiber=e,this._observers=this._eventListeners=null}Kp.prototype.addEventListener=function(e,t,n){var r=null,i=null;if(!(n!=null&&typeof n!=`boolean`&&(r=n.signal||null,r!==null&&r.aborted))){this._eventListeners===null&&(this._eventListeners=[]);var a=this._eventListeners;if(Zp(a,e,t,n)===-1){var o=this,s=t;n!=null&&typeof n!=`boolean`&&!0===n.once&&(s=function(r){o.removeEventListener(e,t,n),typeof t==`function`?t.call(this,r):t.handleEvent(r)}),r!==null&&(i=o.removeEventListener.bind(o,e,t,n),r.addEventListener(`abort`,i,{once:!0}),i=r.removeEventListener.bind(r,`abort`,i)),r=Yp(n),a.push({type:e,listener:t,optionsOrUseCapture:n,attachedListener:s,cleanup:i}),f(this._fragmentFiber.child,!1,qp,e,s,r)}this._eventListeners=a}};function qp(e,t,n,r){return _(e).addEventListener(t,n,r),!1}Kp.prototype.removeEventListener=function(e,t,n){var r=this._eventListeners;if(r!==null&&(t=Zp(r,e,t,n),t!==-1)){var i=r[t];n=i.attachedListener;var a=i.cleanup;i=Yp(i.optionsOrUseCapture),f(this._fragmentFiber.child,!1,Jp,e,n,i),r.splice(t,1),a!==null&&a()}};function Jp(e,t,n,r){return _(e).removeEventListener(t,n,r),!1}function Yp(e){return e!=null&&typeof e!=`boolean`&&(!0===e.once||e.signal instanceof AbortSignal)?{capture:e.capture,passive:e.passive}:e}function Xp(e){return e==null?`c=0`:typeof e==`boolean`?`c=`+(e?`1`:`0`):`c=`+(e.capture?`1`:`0`)}function Zp(e,t,n,r){if(e.length===0)return-1;r=Xp(r);for(var i=0;i<e.length;i++){var a=e[i];if(a.type===t&&a.listener===n&&Xp(a.optionsOrUseCapture)===r)return i}return-1}Kp.prototype.dispatchEvent=function(e){var t=p(this._fragmentFiber);if(t===null)return!0;t=_(t);var n=this._eventListeners;if(n!==null&&0<n.length||!e.bubbles){var r=t.nodeType===9?t.createComment(``):document.createTextNode(``);if(n)for(var i=0;i<n.length;i++){var a=n[i];r.addEventListener(a.type,a.attachedListener,Yp(a.optionsOrUseCapture))}if(t.appendChild(r),e=r.dispatchEvent(e),n)for(i=0;i<n.length;i++)a=n[i],r.removeEventListener(a.type,a.attachedListener,Yp(a.optionsOrUseCapture));return t.removeChild(r),e}return t.dispatchEvent(e)},Kp.prototype.focus=function(e){f(this._fragmentFiber.child,!0,Qp,e,void 0,void 0)};function Qp(e,t){return e.tag!==6&&(e=_(e),wm(e,t))}Kp.prototype.focusLast=function(e){var t=[];f(this._fragmentFiber.child,!0,$p,t,void 0,void 0);for(var n=t.length-1;0<=n&&!Qp(t[n],e);n--);};function $p(e,t){return t.push(e),!1}Kp.prototype.blur=function(){var e=p(this._fragmentFiber);e!==null&&(e=_(e),e=bp(e).activeElement,e!==null&&f(this._fragmentFiber.child,!1,em,e,void 0,void 0))};function em(e,t){return e.tag!==6&&(e=_(e),e===t||e.contains(t)?(t.blur(),!0):!1)}Kp.prototype.observeUsing=function(e){this._observers===null&&(this._observers=new Set),this._observers.add(e),f(this._fragmentFiber.child,!1,tm,e,void 0,void 0)};function tm(e,t){return e.tag===6||(e=_(e),t.observe(e)),!1}Kp.prototype.unobserveUsing=function(e){var t=this._observers;if(t!==null&&t.has(e)){t.delete(e),f(this._fragmentFiber.child,!1,nm,e,void 0,void 0);for(var n=t=0;n<rm.length;n++){var r=rm[n];r.fragmentInstance===this&&r.observer===e?e.unobserve(r.instance):rm[t++]=r}rm.length=t}};function nm(e,t){return e.tag===6||(e=_(e),t.unobserve(e)),!1}var rm=[],im=!1;function am(e,t,n){rm.push({fragmentInstance:e,observer:t,instance:n}),im||(im=!0,Tm(function(){im=!1;var e=rm;rm=[];for(var t=0;t<e.length;t++){var n=e[t];n.observer.unobserve(n.instance)}}))}Kp.prototype.getClientRects=function(){var e=[];return f(this._fragmentFiber.child,!1,om,e,void 0,void 0),e};function om(e,t){if(e.tag===6){e=e.stateNode;var n=e.ownerDocument.createRange();n.selectNodeContents(e),t.push.apply(t,n.getClientRects())}else e=_(e),t.push.apply(t,e.getClientRects());return!1}Kp.prototype.getRootNode=function(e){var t=p(this._fragmentFiber);return t===null?this:_(t).getRootNode(e)},Kp.prototype.compareDocumentPosition=function(e){var t=p(this._fragmentFiber);if(t===null)return Node.DOCUMENT_POSITION_DISCONNECTED;var n=[];f(this._fragmentFiber.child,!1,$p,n,void 0,void 0);var r=_(t);if(n.length===0){if(n=r,m(this._fragmentFiber)){a:{for(t=this._fragmentFiber.return;t!==null;){if(t.tag===4){t=t.stateNode.containerInfo;break a}if(t.tag===3||t.tag===5||t.tag===27)break;t=t.return}t=null}t!=null&&(n=t)}t=this._fragmentFiber;var i=r=n.compareDocumentPosition(e);return n===e?i=Node.DOCUMENT_POSITION_CONTAINS:r&Node.DOCUMENT_POSITION_CONTAINED_BY&&(n=h(t)[1],n===null?i=Node.DOCUMENT_POSITION_PRECEDING:(e=_(n).compareDocumentPosition(e),i=e===0||e&Node.DOCUMENT_POSITION_FOLLOWING?Node.DOCUMENT_POSITION_FOLLOWING:Node.DOCUMENT_POSITION_PRECEDING)),i|=Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC}t=_(n[0]),i=_(n[n.length-1]);var a=m(this._fragmentFiber)?t.parentElement:r;if(a==null)return Node.DOCUMENT_POSITION_DISCONNECTED;r=a.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_CONTAINED_BY,a=a.compareDocumentPosition(i)&Node.DOCUMENT_POSITION_CONTAINED_BY;var o=t.compareDocumentPosition(e),s=i.compareDocumentPosition(e),c=o&Node.DOCUMENT_POSITION_CONTAINED_BY||s&Node.DOCUMENT_POSITION_CONTAINED_BY;return s=r&&a&&o&Node.DOCUMENT_POSITION_FOLLOWING&&s&Node.DOCUMENT_POSITION_PRECEDING,t=r&&t===e||a&&i===e||c||s?Node.DOCUMENT_POSITION_CONTAINED_BY:!r&&t===e||!a&&i===e?Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC:o,t&Node.DOCUMENT_POSITION_DISCONNECTED||t&Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC||sm(t,this._fragmentFiber,n[0],n[n.length-1],e)?t:Node.DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC};function sm(e,t,n,r,i){var a=kt(i);if(e&Node.DOCUMENT_POSITION_CONTAINED_BY){if(n=!!a)a:{for(;a!==null;){if(a.tag===7&&(a===t||a.alternate===t)){n=!0;break a}a=a.return}n=!1}return n}if(e&Node.DOCUMENT_POSITION_CONTAINS){if(a===null)return a=i.ownerDocument,i===a||i===a.documentElement||i===a.body;a:{for(a=t,t=p(t);a!==null;){if(!(a.tag!==5&&a.tag!==3&&a.tag!==27||a!==t&&a.alternate!==t)){a=!0;break a}a=a.return}a=!1}return a}return e&Node.DOCUMENT_POSITION_PRECEDING?((t=!!a)&&!(t=a===n)&&(t=C(n,a,S),t===null?t=!1:(f(t,!0,b,a,n),a=v,v=null,t=a!==null)),t):e&Node.DOCUMENT_POSITION_FOLLOWING?((t=!!a)&&!(t=a===r)&&(t=C(r,a,S),t===null?t=!1:(f(t,!0,x,a,r),a=v,y=v=null,t=a!==null)),t):!1}function cm(e,t){var n=e.ownerDocument.createRange();n.selectNodeContents(e),e=n.getBoundingClientRect(),window.scrollTo(window.scrollX+e.left,t?window.scrollY+e.top:window.scrollY+e.bottom-window.innerHeight)}Kp.prototype.scrollIntoView=function(e){if(typeof e==`object`)throw Error(i(566));var t=[];f(this._fragmentFiber.child,!1,$p,t,void 0,void 0);var n=!1!==e;if(t.length===0){var r=h(this._fragmentFiber);if(r=n?r[1]||r[0]||p(this._fragmentFiber):r[0]||r[1],r===null)return;if(r.tag===6){e=_(r),cm(e,n);return}if(r=_(r),r.nodeType!==9){if(r.nodeType===11){n=`host`in r?r.host:null,n!==null&&n.scrollIntoView(e);return}r.scrollIntoView(e)}}for(r=n?t.length-1:0;r!==(n?-1:t.length);){var a=t[r];a.tag===6?(a=_(a),cm(a,n)):_(a).scrollIntoView(e),r+=n?-1:1}};function lm(e,t){return e=_(e),um(e,t),!1}function um(e,t){e.reactFragments??=new Set,e.reactFragments.add(t)}function dm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.addEventListener(i.type,i.attachedListener,Yp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){for(var r=0,i=0;i<rm.length;i++){var a=rm[i];(a.fragmentInstance!==t||a.observer!==n||a.instance!==e)&&(rm[r++]=a)}rm.length=r,n.observe(e)}),um(e,t))}function fm(e,t){var n=t._eventListeners;if(n!==null)for(var r=0;r<n.length;r++){var i=n[r];e.removeEventListener(i.type,i.attachedListener,Yp(i.optionsOrUseCapture))}e.nodeType!==3&&(n=t._observers,n!==null&&n.forEach(function(n){typeof n.rootMargin==`string`?am(t,n,e):n.unobserve(e)}),e.reactFragments!=null&&e.reactFragments.delete(t))}function pm(e){var t=e.firstChild;for(t&&t.nodeType===10&&(t=t.nextSibling);t;){var n=t;switch(t=t.nextSibling,n.nodeName){case`HTML`:case`HEAD`:case`BODY`:pm(n),Ot(n);continue;case`SCRIPT`:case`STYLE`:continue;case`LINK`:if(n.rel.toLowerCase()===`stylesheet`)continue}e.removeChild(n)}}function mm(e,t,n,r){for(;e.nodeType===1;){var i=n;if(e.nodeName.toLowerCase()!==t.toLowerCase()){if(!r&&(e.nodeName!==`INPUT`||e.type!==`hidden`))break}else if(!r){if(t===`input`&&e.type===`hidden`){var a=i.name==null?null:``+i.name;if(i.type===`hidden`&&e.getAttribute(`name`)===a)return e}else return e}else if(!e[Et])switch(t){case`meta`:if(!e.hasAttribute(`itemprop`))break;return e;case`link`:if(a=e.getAttribute(`rel`),a===`stylesheet`&&e.hasAttribute(`data-precedence`)||a!==i.rel||e.getAttribute(`href`)!==(i.href==null||i.href===``?null:i.href)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin)||e.getAttribute(`title`)!==(i.title==null?null:i.title))break;return e;case`style`:if(e.hasAttribute(`data-precedence`))break;return e;case`script`:if(a=e.getAttribute(`src`),(a!==(i.src==null?null:i.src)||e.getAttribute(`type`)!==(i.type==null?null:i.type)||e.getAttribute(`crossorigin`)!==(i.crossOrigin==null?null:i.crossOrigin))&&a&&e.hasAttribute(`async`)&&!e.hasAttribute(`itemprop`))break;return e;default:return e}if(e=bm(e.nextSibling),e===null)break}return null}function hm(e,t,n){if(t===``)return null;for(;e.nodeType!==3;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!n||(e=bm(e.nextSibling),e===null))return null;return e}function gm(e,t){for(;e.nodeType!==8;)if((e.nodeType!==1||e.nodeName!==`INPUT`||e.type!==`hidden`)&&!t||(e=bm(e.nextSibling),e===null))return null;return e}function _m(e){return e.data===`$?`||e.data===`$~`}function vm(e){return e.data===`$!`||e.data===`$?`&&e.ownerDocument.readyState!==`loading`}function ym(e,t){var n=e.ownerDocument;if(e.data===`$~`)e._reactRetry=t;else if(e.data!==`$?`||n.readyState!==`loading`)t();else{var r=function(){t(),n.removeEventListener(`DOMContentLoaded`,r)};n.addEventListener(`DOMContentLoaded`,r),e._reactRetry=r}}function bm(e){for(;e!=null;e=e.nextSibling){var t=e.nodeType;if(t===1||t===3)break;if(t===8){if(t=e.data,t===`$`||t===`$!`||t===`$?`||t===`$~`||t===`&`||t===`F!`||t===`F`)break;if(t===`/$`||t===`/&`)return null}}return e}var xm=null;function Sm(e){e=e.nextSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`/$`||n===`/&`){if(t===0)return bm(e.nextSibling);t--}else n!==`$`&&n!==`$!`&&n!==`$?`&&n!==`$~`&&n!==`&`||t++}e=e.nextSibling}return null}function Cm(e){e=e.previousSibling;for(var t=0;e;){if(e.nodeType===8){var n=e.data;if(n===`$`||n===`$!`||n===`$?`||n===`$~`||n===`&`){if(t===0)return e;t--}else n!==`/$`&&n!==`/&`||t++}e=e.previousSibling}return null}function wm(e,t){function n(){r=!0}if(e.ownerDocument.activeElement===e)return!0;var r=!1;try{e.ownerDocument.addEventListener(`focus`,n,!0),(e.focus||HTMLElement.prototype.focus).call(e,t)}finally{e.ownerDocument.removeEventListener(`focus`,n,!0)}return r}function Tm(e){Ap(function(){Ap(function(t){return e(t)})})}function Em(e,t,n){switch(t=bp(n),e){case`html`:if(e=t.documentElement,!e)throw Error(i(452));return e;case`head`:if(e=t.head,!e)throw Error(i(453));return e;case`body`:if(e=t.body,!e)throw Error(i(454));return e;default:throw Error(i(451))}}function Dm(e,t,n){for(var r in n){var i=n[r];n.hasOwnProperty(r)&&i!=null&&dp(e,t,r,null,mp,i)}n.dangerouslySetInnerHTML!=null&&(e.textContent=``),e.onclick===gn&&(e.onclick=null),Ot(e)}function Om(e){for(var t=e.attributes;t.length;)e.removeAttributeNode(t[0]);Ot(e)}var km=new Map,Am=new Set;function jm(e){if(typeof e.getRootNode==`function`){var t=e.getRootNode();if(t.nodeType===9||t.nodeType===11)return t}return e.nodeType===9?e:e.ownerDocument}var Mm=ue.d;ue.d={f:Nm,r:Pm,D:Lm,C:Rm,L:zm,m:Bm,X:Hm,S:Vm,M:Um};function Nm(){var e=Mm.f(),t=qd();return e||t}function Pm(e){var t=At(e);t!==null&&t.tag===5&&t.type===`form`?ic(t):Mm.r(e)}var Fm=typeof document>`u`?null:document;function Im(e,t,n){var r=Fm;if(r&&typeof t==`string`&&t){var i=en(t);i=`link[rel="`+e+`"][href="`+i+`"]`,typeof n==`string`&&(i+=`[crossorigin="`+n+`"]`),Am.has(i)||(Am.add(i),e={rel:e,crossOrigin:n,href:t},r.querySelector(i)===null&&(t=r.createElement(`link`),pp(t,`link`,e),Nt(t),r.head.appendChild(t)))}}function Lm(e){Mm.D(e),Im(`dns-prefetch`,e,null)}function Rm(e,t){Mm.C(e,t),Im(`preconnect`,e,t)}function zm(e,t,n){Mm.L(e,t,n);var r=Fm;if(r&&e&&t){var i=`link[rel="preload"][as="`+en(t)+`"]`;t===`image`&&n&&n.imageSrcSet?(i+=`[imagesrcset="`+en(n.imageSrcSet)+`"]`,typeof n.imageSizes==`string`&&(i+=`[imagesizes="`+en(n.imageSizes)+`"]`)):i+=`[href="`+en(e)+`"]`;var a=i;switch(t){case`style`:a=Gm(e);break;case`script`:a=Jm(e)}if(!(km.has(a)||(e=w({rel:`preload`,href:t===`image`&&n&&n.imageSrcSet?void 0:e,as:t},n),km.set(a,e),r.querySelector(i)!==null||t===`style`&&r.querySelector(Km(a))||t===`script`&&r.querySelector(Ym(a))))){var o=r.createElement(`link`);pp(o,`link`,e),t===`style`&&(o[Dt]=!0,o.onload=o.onerror=function(){Pt(o)}),Nt(o),r.head.appendChild(o)}}}function Bm(e,t){Mm.m(e,t);var n=Fm;if(n&&e){var r=t&&typeof t.as==`string`?t.as:`script`,i=`link[rel="modulepreload"][as="`+en(r)+`"][href="`+en(e)+`"]`,a=i;switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:a=Jm(e)}if(!km.has(a)&&(e=w({rel:`modulepreload`,href:e},t),km.set(a,e),n.querySelector(i)===null)){switch(r){case`audioworklet`:case`paintworklet`:case`serviceworker`:case`sharedworker`:case`worker`:case`script`:if(n.querySelector(Ym(a)))return}r=n.createElement(`link`),pp(r,`link`,e),Nt(r),n.head.appendChild(r)}}}function Vm(e,t,n){Mm.S(e,t,n);var r=Fm;if(r&&e){var i=Mt(r).hoistableStyles,a=Gm(e);t||=`default`;var o=i.get(a);if(!o){var s={loading:0,preload:null};if(o=r.querySelector(Km(a)))s.loading=5;else{e=w({rel:`stylesheet`,href:e,"data-precedence":t},n),(n=km.get(a))&&Qm(e,n);var c=o=r.createElement(`link`);Nt(c),pp(c,`link`,e),c._p=new Promise(function(e,t){c.onload=e,c.onerror=t}),c.addEventListener(`load`,function(){s.loading|=1}),c.addEventListener(`error`,function(){s.loading|=2}),s.loading|=4,Zm(o,t,r)}o={type:`stylesheet`,instance:o,count:1,state:s},i.set(a,o)}}}function Hm(e,t){Mm.X(e,t);var n=Fm;if(n&&e){var r=Mt(n).hoistableScripts,i=Jm(e),a=r.get(i);a||(a=n.querySelector(Ym(i)),a||(e=w({src:e,async:!0},t),(t=km.get(i))&&$m(e,t),a=n.createElement(`script`),Nt(a),pp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Um(e,t){Mm.M(e,t);var n=Fm;if(n&&e){var r=Mt(n).hoistableScripts,i=Jm(e),a=r.get(i);a||(a=n.querySelector(Ym(i)),a||(e=w({src:e,async:!0,type:`module`},t),(t=km.get(i))&&$m(e,t),a=n.createElement(`script`),Nt(a),pp(a,`link`,e),n.head.appendChild(a)),a={type:`script`,instance:a,count:1,state:null},r.set(i,a))}}function Wm(e,t,n,r){var a=(a=ye.current)?jm(a):null;if(!a)throw Error(i(446));switch(e){case`meta`:case`title`:return null;case`style`:return typeof n.precedence==`string`&&typeof n.href==`string`?(n=Gm(n.href),t=Mt(a).hoistableStyles,r=t.get(n),r||(r={type:`style`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};case`link`:if(n.rel===`stylesheet`&&typeof n.href==`string`&&typeof n.precedence==`string`){e=Gm(n.href);var o=Mt(a).hoistableStyles,s=o.get(e);if(s||(a=a.ownerDocument||a,s={type:`stylesheet`,instance:null,count:0,state:{loading:0,preload:null}},o.set(e,s),(o=a.querySelector(Km(e)))?o._p||(s.instance=o,s.state.loading=5):(o=km.get(e),o||(o={rel:`preload`,as:`style`,href:n.href,crossOrigin:n.crossOrigin,integrity:n.integrity,media:n.media,hrefLang:n.hrefLang,referrerPolicy:n.referrerPolicy},km.set(e,o)),qm(a,e,o,s.state))),t&&r===null)throw Error(i(528,``));return s}if(t&&r!==null)throw Error(i(529,``));return null;case`script`:return t=n.async,n=n.src,typeof n==`string`&&t&&typeof t!=`function`&&typeof t!=`symbol`?(n=Jm(n),t=Mt(a).hoistableScripts,r=t.get(n),r||(r={type:`script`,instance:null,count:0,state:null},t.set(n,r)),r):{type:`void`,instance:null,count:0,state:null};default:throw Error(i(444,e))}}function Gm(e){return`href="`+en(e)+`"`}function Km(e){return`link[rel="stylesheet"][`+e+`]`}function U(e){return w({},e,{"data-precedence":e.precedence,precedence:null})}function qm(e,t,n,r){if(t=e.querySelector(`link[rel="preload"][as="style"][`+t+`]`)){if(!0!==t[Dt]){r.loading=1;return}}else t=e.createElement(`link`),t[Dt]=!0,t.onload=t.onerror=Pt.bind(null,t),pp(t,`link`,n),Nt(t),e.head.appendChild(t);r.preload=t,t.addEventListener(`load`,function(){return r.loading|=1}),t.addEventListener(`error`,function(){return r.loading|=2})}function Jm(e){return`[src="`+en(e)+`"]`}function Ym(e){return`script[async]`+e}function Xm(e,t,n){if(t.count++,t.instance===null)switch(t.type){case`style`:var r=e.querySelector(`style[data-href~="`+en(n.href)+`"]`);if(r)return t.instance=r,Nt(r),r;var a=w({},n,{"data-href":n.href,"data-precedence":n.precedence,href:null,precedence:null});return r=(e.ownerDocument||e).createElement(`style`),Nt(r),pp(r,`style`,a),Zm(r,n.precedence,e),t.instance=r;case`stylesheet`:a=Gm(n.href);var o=e.querySelector(Km(a));if(o)return t.state.loading|=4,t.instance=o,Nt(o),o;r=U(n),(a=km.get(a))&&Qm(r,a),o=(e.ownerDocument||e).createElement(`link`),Nt(o);var s=o;return s._p=new Promise(function(e,t){s.onload=e,s.onerror=t}),pp(o,`link`,r),t.state.loading|=4,Zm(o,n.precedence,e),t.instance=o;case`script`:return o=Jm(n.src),(a=e.querySelector(Ym(o)))?(t.instance=a,Nt(a),a):(r=n,(a=km.get(o))&&(r=w({},n),$m(r,a)),e=e.ownerDocument||e,a=e.createElement(`script`),Nt(a),pp(a,`link`,r),e.head.appendChild(a),t.instance=a);case`void`:return null;default:throw Error(i(443,t.type))}else t.type===`stylesheet`&&!(t.state.loading&4)&&(r=t.instance,t.state.loading|=4,Zm(r,n.precedence,e));return t.instance}function Zm(e,t,n){for(var r=n.querySelectorAll(`link[rel="stylesheet"][data-precedence],style[data-precedence]`),i=r.length?r[r.length-1]:null,a=i,o=0;o<r.length;o++){var s=r[o];if(s.dataset.precedence===t)a=s;else if(a!==i)break}a?a.parentNode.insertBefore(e,a.nextSibling):(t=n.nodeType===9?n.head:n,t.insertBefore(e,t.firstChild))}function Qm(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.title??=t.title}function $m(e,t){e.crossOrigin??=t.crossOrigin,e.referrerPolicy??=t.referrerPolicy,e.integrity??=t.integrity}var eh=null;function th(e,t,n){if(eh===null){var r=new Map,i=eh=new Map;i.set(n,r)}else i=eh,r=i.get(n),r||(r=new Map,i.set(n,r));if(r.has(e))return r;for(r.set(e,null),n=n.getElementsByTagName(e),i=0;i<n.length;i++){var a=n[i];if(!(a[Et]||a[yt]||e===`link`&&a.getAttribute(`rel`)===`stylesheet`)&&a.namespaceURI!==`http://www.w3.org/2000/svg`){var o=a.getAttribute(t)||``;o=e+o;var s=r.get(o);s?s.push(a):r.set(o,[a])}}return r}function nh(e,t,n){e=e.ownerDocument||e,e.head.insertBefore(n,t===`title`?e.querySelector(`head > title`):null)}function rh(e,t,n){if(n===1||t.itemProp!=null)return!1;switch(e){case`meta`:case`title`:return!0;case`style`:if(typeof t.precedence!=`string`||typeof t.href!=`string`||t.href===``)break;return!0;case`link`:if(typeof t.rel!=`string`||typeof t.href!=`string`||t.href===``||t.onLoad||t.onError)break;switch(t.rel){case`stylesheet`:return e=t.disabled,typeof t.precedence==`string`&&e==null;default:return!0}case`script`:if(t.async&&typeof t.async!=`function`&&typeof t.async!=`symbol`&&!t.onLoad&&!t.onError&&t.src&&typeof t.src==`string`)return!0}return!1}function ih(e,t){return e===`img`&&t.src!=null&&t.src!==``&&t.onLoad==null&&t.loading!==`lazy`}function ah(e){return!(e.type===`stylesheet`&&!(e.state.loading&3))}function oh(e){return(e.width||100)*(e.height||100)*(typeof devicePixelRatio==`number`?devicePixelRatio:1)*.25}function sh(e,t){typeof t.decode==`function`&&(e.imgCount++,t.complete||(e.imgBytes+=oh(t),e.suspenseyImages.push(t)),e=ph.bind(e),t.decode().then(e,e))}function ch(e,t,n,r){if(n.type===`stylesheet`&&(typeof r.media!=`string`||!1!==matchMedia(r.media).matches)&&!(n.state.loading&4)){if(n.instance===null){var i=Gm(r.href),a=t.querySelector(Km(i));if(a){t=a._p,typeof t==`object`&&t&&typeof t.then==`function`&&(e.count++,e=fh.bind(e),t.then(e,e)),n.state.loading|=4,n.instance=a,Nt(a);return}a=t.ownerDocument||t,r=U(r),(i=km.get(i))&&Qm(r,i),a=a.createElement(`link`),Nt(a);var o=a;o._p=new Promise(function(e,t){o.onload=e,o.onerror=t}),pp(a,`link`,r),n.instance=a}e.stylesheets===null&&(e.stylesheets=new Map),e.stylesheets.set(n,t),(t=n.state.preload)&&!(n.state.loading&3)&&(e.count++,n=fh.bind(e),t.addEventListener(`load`,n),t.addEventListener(`error`,n))}}var lh=0;function uh(e,t){return e.stylesheets&&e.count===0&&hh(e,e.stylesheets),0<e.count||0<e.imgCount?function(n){var r=setTimeout(function(){if(e.stylesheets&&hh(e,e.stylesheets),e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}},6e4+t);0<e.imgBytes&&lh===0&&(lh=62500*_p());var i=setTimeout(function(){if(e.waitingForImages=!1,e.count===0&&(e.stylesheets&&hh(e,e.stylesheets),e.unsuspend)){var t=e.unsuspend;e.unsuspend=null,t()}},(e.imgBytes>lh?50:800)+t);return e.unsuspend=n,function(){e.unsuspend=null,clearTimeout(r),clearTimeout(i)}}:null}function dh(e){if(e.count===0&&(e.imgCount===0||!e.waitingForImages)){if(e.stylesheets)hh(e,e.stylesheets);else if(e.unsuspend){var t=e.unsuspend;e.unsuspend=null,t()}}}function fh(){this.count--,dh(this)}function ph(){this.imgCount--,dh(this)}var mh=null;function hh(e,t){e.stylesheets=null,e.unsuspend!==null&&(e.count++,mh=new Map,t.forEach(gh,e),mh=null,fh.call(e))}function gh(e,t){if(!(t.state.loading&4)){var n=mh.get(e);if(n)var r=n.get(null);else{n=new Map,mh.set(e,n);for(var i=e.querySelectorAll(`link[data-precedence],style[data-precedence]`),a=0;a<i.length;a++){var o=i[a];(o.nodeName===`LINK`||o.getAttribute(`media`)!==`not all`)&&(n.set(o.dataset.precedence,o),r=o)}r&&n.set(null,r)}i=t.instance,o=i.getAttribute(`data-precedence`),a=n.get(o)||r,a===r&&n.set(null,i),n.set(o,i),this.count++,r=fh.bind(this),i.addEventListener(`load`,r),i.addEventListener(`error`,r),a?a.parentNode.insertBefore(i,a.nextSibling):(e=e.nodeType===9?e.head:e,e.insertBefore(i,e.firstChild)),t.state.loading|=4}}var _h={$$typeof:N,Provider:null,Consumer:null,_currentValue:de,_currentValue2:de,_threadCount:0};function vh(e,t,n,r,i,a,o,s,c){this.tag=1,this.containerInfo=e,this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.next=this.pendingContext=this.context=this.cancelPendingCommit=null,this.callbackPriority=0,this.expirationTimes=ct(-1),this.entangledLanes=this.shellSuspendCounter=this.errorRecoveryDisabledLanes=this.expiredLanes=this.warmLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ct(0),this.hiddenUpdates=ct(null),this.identifierPrefix=r,this.onUncaughtError=i,this.onCaughtError=a,this.onRecoverableError=o,this.pooledCache=null,this.pooledCacheLanes=0,this.formState=c,this.transitionTypes=null,this.incompleteTransitions=new Map}function yh(e,t,n,r,i,a,o,s,c,l,u,d){return e=new vh(e,t,n,o,c,l,u,d,s),t=1,!0===a&&(t|=24),a=Ai(3,null,null,t),e.current=a,a.stateNode=e,t=ja(),t.refCount++,e.pooledCache=t,t.refCount++,a.memoizedState={element:r,isDehydrated:n,cache:t},mo(a),e}function bh(e){return e?(e=Oi,e):Oi}function xh(e,t,n,r,i,a){i=bh(i),r.context===null?r.context=i:r.pendingContext=i,r=go(t),r.payload={element:n},a=a===void 0?null:a,a!==null&&(r.callback=a),n=_o(e,r,t),n!==null&&(Hd(n,e,t),vo(n,e,t))}function Sh(e,t){if(e=e.memoizedState,e!==null&&e.dehydrated!==null){var n=e.retryLane;e.retryLane=n!==0&&n<t?n:t}}function Ch(e,t){Sh(e,t),(e=e.alternate)&&Sh(e,t)}function wh(e){if(e.tag===13||e.tag===31){var t=Ti(e,67108864);t!==null&&Hd(t,e,67108864),Ch(e,67108864)}}function Th(e){if(e.tag===13||e.tag===31){var t=zd();t=mt(t);var n=Ti(e,t);n!==null&&Hd(n,e,t),Ch(e,t)}}var Eh=!0;function Dh(e,t,n,r){var i=V.T;V.T=null;var a=ue.p;try{ue.p=2,kh(e,t,n,r)}finally{ue.p=a,V.T=i}}function Oh(e,t,n,r){var i=V.T;V.T=null;var a=ue.p;try{ue.p=8,kh(e,t,n,r)}finally{ue.p=a,V.T=i}}function kh(e,t,n,r){if(Eh){var i=Ah(r);if(i===null)np(e,t,r,jh,n),Hh(e,r);else if(Wh(i,e,t,n,r))r.stopPropagation();else if(Hh(e,r),t&4&&-1<Vh.indexOf(e)){for(;i!==null;){var a=At(i);if(a!==null)switch(a.tag){case 3:if(a=a.stateNode,a.current.memoizedState.isDehydrated){var o=nt(a.pendingLanes);if(o!==0){var s=a;for(s.pendingLanes|=2,s.entangledLanes|=2;o;){var c=1<<31-Ye(o);s.entanglements[1]|=c,o&=~c}Ff(a),!(rd&6)&&(wd=Le()+500,If(0,!1))}}break;case 31:case 13:s=Ti(a,2),s!==null&&Hd(s,a,2),qd(),Ch(a,2)}if(a=Ah(r),a===null&&np(e,t,r,jh,n),a===i)break;i=a}i!==null&&r.stopPropagation()}else np(e,t,r,null,n)}}function Ah(e){return e=vn(e),Mh(e)}var jh=null;function Mh(e){if(jh=null,e=kt(e),e!==null){var t=o(e);if(t===null)e=null;else{var n=t.tag;if(n===13){if(e=s(t),e!==null)return e;e=null}else if(n===31){if(e=c(t),e!==null)return e;e=null}else if(n===3){if(t.stateNode.current.memoizedState.isDehydrated)return t.tag===3?t.stateNode.containerInfo:null;e=null}else t!==e&&(e=null)}}return jh=e,null}function Nh(e){switch(e){case`beforetoggle`:case`cancel`:case`click`:case`close`:case`contextmenu`:case`copy`:case`cut`:case`auxclick`:case`dblclick`:case`dragend`:case`dragstart`:case`drop`:case`focusin`:case`focusout`:case`input`:case`invalid`:case`keydown`:case`keypress`:case`keyup`:case`mousedown`:case`mouseup`:case`paste`:case`pause`:case`play`:case`pointercancel`:case`pointerdown`:case`pointerup`:case`ratechange`:case`reset`:case`seeked`:case`submit`:case`toggle`:case`touchcancel`:case`touchend`:case`touchstart`:case`volumechange`:case`change`:case`selectionchange`:case`textInput`:case`compositionstart`:case`compositionend`:case`compositionupdate`:case`beforeblur`:case`afterblur`:case`beforeinput`:case`blur`:case`fullscreenchange`:case`fullscreenerror`:case`focus`:case`hashchange`:case`popstate`:case`select`:case`selectstart`:return 2;case`drag`:case`dragenter`:case`dragexit`:case`dragleave`:case`dragover`:case`mousemove`:case`mouseout`:case`mouseover`:case`pointermove`:case`pointerout`:case`pointerover`:case`resize`:case`scroll`:case`touchmove`:case`wheel`:case`mouseenter`:case`mouseleave`:case`pointerenter`:case`pointerleave`:return 8;case`message`:switch(Re()){case ze:return 2;case Be:return 8;case Ve:case He:return 32;case Ue:return 268435456;default:return 32}default:return 32}}var Ph=!1,Fh=null,Ih=null,Lh=null,Rh=new Map,zh=new Map,Bh=[],Vh=`mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset`.split(` `);function Hh(e,t){switch(e){case`focusin`:case`focusout`:Fh=null;break;case`dragenter`:case`dragleave`:Ih=null;break;case`mouseover`:case`mouseout`:Lh=null;break;case`pointerover`:case`pointerout`:Rh.delete(t.pointerId);break;case`gotpointercapture`:case`lostpointercapture`:zh.delete(t.pointerId)}}function Uh(e,t,n,r,i,a){return e===null||e.nativeEvent!==a?(e={blockedOn:t,domEventName:n,eventSystemFlags:r,nativeEvent:a,targetContainers:[i]},t!==null&&(t=At(t),t!==null&&wh(t)),e):(e.eventSystemFlags|=r,t=e.targetContainers,i!==null&&t.indexOf(i)===-1&&t.push(i),e)}function Wh(e,t,n,r,i){switch(t){case`focusin`:return Fh=Uh(Fh,e,t,n,r,i),!0;case`dragenter`:return Ih=Uh(Ih,e,t,n,r,i),!0;case`mouseover`:return Lh=Uh(Lh,e,t,n,r,i),!0;case`pointerover`:var a=i.pointerId;return Rh.set(a,Uh(Rh.get(a)||null,e,t,n,r,i)),!0;case`gotpointercapture`:return a=i.pointerId,zh.set(a,Uh(zh.get(a)||null,e,t,n,r,i)),!0}return!1}function Gh(e){var t=kt(e.target);if(t!==null){var n=o(t);if(n!==null){if(t=n.tag,t===13){if(t=s(n),t!==null){e.blockedOn=t,_t(e.priority,function(){Th(n)});return}}else if(t===31){if(t=c(n),t!==null){e.blockedOn=t,_t(e.priority,function(){Th(n)});return}}else if(t===3&&n.stateNode.current.memoizedState.isDehydrated){e.blockedOn=n.tag===3?n.stateNode.containerInfo:null;return}}}e.blockedOn=null}function Kh(e){if(e.blockedOn!==null)return!1;for(var t=e.targetContainers;0<t.length;){var n=Ah(e.nativeEvent);if(n===null){n=e.nativeEvent;var r=new n.constructor(n.type,n);_n=r,n.target.dispatchEvent(r),_n=null}else return t=At(n),t!==null&&wh(t),e.blockedOn=n,!1;t.shift()}return!0}function qh(e,t,n){Kh(e)&&n.delete(t)}function Jh(){Ph=!1,Fh!==null&&Kh(Fh)&&(Fh=null),Ih!==null&&Kh(Ih)&&(Ih=null),Lh!==null&&Kh(Lh)&&(Lh=null),Rh.forEach(qh),zh.forEach(qh)}function Yh(e,n){e.blockedOn===n&&(e.blockedOn=null,Ph||(Ph=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Jh)))}var Xh=null;function Zh(e){Xh!==e&&(Xh=e,t.unstable_scheduleCallback(t.unstable_NormalPriority,function(){Xh===e&&(Xh=null);for(var t=0;t<e.length;t+=3){var n=e[t],r=e[t+1],i=e[t+2];if(typeof r!=`function`){if(Mh(r||n)===null)continue;break}var a=At(n);a!==null&&(e.splice(t,3),t-=3,nc(a,{pending:!0,data:i,method:n.method,action:r},r,i))}}))}function Qh(e){function t(t){return Yh(t,e)}Fh!==null&&Yh(Fh,e),Ih!==null&&Yh(Ih,e),Lh!==null&&Yh(Lh,e),Rh.forEach(t),zh.forEach(t);for(var n=0;n<Bh.length;n++){var r=Bh[n];r.blockedOn===e&&(r.blockedOn=null)}for(;0<Bh.length&&(n=Bh[0],n.blockedOn===null);)Gh(n),n.blockedOn===null&&Bh.shift();if(n=(e.ownerDocument||e).$$reactFormReplay,n!=null)for(r=0;r<n.length;r+=3){var i=n[r],a=n[r+1],o=i[bt]||null;if(typeof a==`function`)o||Zh(n);else if(o){var s=null;if(a&&a.hasAttribute(`formAction`)){if(i=a,o=a[bt]||null)s=o.formAction;else if(Mh(i)!==null)continue}else s=o.action;typeof s==`function`?n[r+1]=s:(n.splice(r,3),r-=3),Zh(n)}}}function $h(){function e(e){e.canIntercept&&e.info===`react-transition`&&e.intercept({handler:function(){return new Promise(function(e){return i=e})},focusReset:`manual`,scroll:`manual`})}function t(){i!==null&&(i(),i=null),r||setTimeout(n,20)}function n(){if(!r&&!navigation.transition){var e=navigation.currentEntry;e&&e.url!=null&&navigation.navigate(e.url,{state:e.getState(),info:`react-transition`,history:`replace`})}}if(typeof navigation==`object`){var r=!1,i=null;return navigation.addEventListener(`navigate`,e),navigation.addEventListener(`navigatesuccess`,t),navigation.addEventListener(`navigateerror`,t),setTimeout(n,100),function(){r=!0,navigation.removeEventListener(`navigate`,e),navigation.removeEventListener(`navigatesuccess`,t),navigation.removeEventListener(`navigateerror`,t),i!==null&&(i(),i=null)}}}function eg(e){this._internalRoot=e}tg.prototype.render=eg.prototype.render=function(e){var t=this._internalRoot;if(t===null)throw Error(i(409));var n=t.current;xh(n,zd(),e,t,null,null)},tg.prototype.unmount=eg.prototype.unmount=function(){var e=this._internalRoot;if(e!==null){this._internalRoot=null;var t=e.containerInfo;xh(e.current,2,null,e,null,null),qd(),t[xt]=null}};function tg(e){this._internalRoot=e}tg.prototype.unstable_scheduleHydration=function(e){if(e){var t=gt();e={blockedOn:null,target:e,priority:t};for(var n=0;n<Bh.length&&t!==0&&t<Bh[n].priority;n++);Bh.splice(n,0,e),n===0&&Gh(e)}};var ng=n.version;if(ng!==`19.3.1`)throw Error(i(527,ng,`19.3.1`));ue.findDOMNode=function(e){var t=e._reactInternals;if(t===void 0)throw typeof e.render==`function`?Error(i(188)):(e=Object.keys(e).join(`,`),Error(i(268,e)));return e=u(t),e=e===null?null:d(e),e=e===null?null:e.stateNode,e};var rg={bundleType:0,version:`19.3.1`,rendererPackageName:`react-dom`,currentDispatcherRef:V,reconcilerVersion:`19.3.1`};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`){var ig=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!ig.isDisabled&&ig.supportsFiber)try{Ke=ig.inject(rg),qe=ig}catch{}}e.createRoot=function(e,t){if(!a(e))throw Error(i(299));var n=!1,r=``,o=Tc,s=Ec,c=Dc;return t!=null&&(!0===t.unstable_strictMode&&(n=!0),t.identifierPrefix!==void 0&&(r=t.identifierPrefix),t.onUncaughtError!==void 0&&(o=t.onUncaughtError),t.onCaughtError!==void 0&&(s=t.onCaughtError),t.onRecoverableError!==void 0&&(c=t.onRecoverableError)),t=yh(e,1,!1,null,null,n,r,null,o,s,c,$h),e[xt]=t.current,ep(e),new eg(t)}})),F=o(((e,t)=>{function n(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<`u`&&typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE==`function`)try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(n)}catch(e){console.error(e)}}n(),t.exports=P()})),I=o((e=>{var t=Symbol.for(`react.transitional.element`),n=Symbol.for(`react.fragment`);function r(e,n,r){var i=null;if(r!==void 0&&(i=``+r),n.key!==void 0&&(i=``+n.key),`key`in n)for(var a in r={},n)a!==`key`&&(r[a]=n[a]);else r=n;return n=r.ref,{$$typeof:t,type:e,key:i,ref:n===void 0?null:n,props:r}}e.Fragment=n,e.jsx=r,e.jsxs=r})),ne=o(((e,t)=>{t.exports=I()})),re=F(),L=c(A(),1),R=ne(),z=(0,L.createContext)({theme:`dark`,resolved:`dark`,setTheme:()=>{}});function B(){return(0,L.useContext)(z)}function ie({children:e}){let[t,n]=(0,L.useState)(()=>typeof window>`u`?`dark`:localStorage.getItem(`paracosm-theme`)||`dark`);return(0,L.useEffect)(()=>{let e=document.documentElement;e.classList.toggle(`light`,t===`light`),e.style.colorScheme=t;let n=document.querySelector(`meta[name="theme-color"]`);n&&n.setAttribute(`content`,t===`dark`?`#0a0806`:`#f0e6d2`)},[t]),(0,R.jsx)(z.Provider,{value:{theme:t,resolved:t,setTheme:e=>{n(e),localStorage.setItem(`paracosm-theme`,e)}},children:e})}var ae=`paracosm:scenario-updated`;function oe(e){e.dispatchEvent(new Event(ae))}function se(e,t){let n=()=>t();return e.addEventListener(ae,n),()=>e.removeEventListener(ae,n)}var ce=`paracosm:launched`;function le(e,t){typeof t==`string`&&t.length!==0&&e.dispatchEvent(new CustomEvent(ce,{detail:{visitorId:t}}))}function V(e,t){let n=e=>{let n=e.detail?.visitorId;typeof n==`string`&&t(n)};return e.addEventListener(ce,n),()=>e.removeEventListener(ce,n)}var ue=`paracosm:scenarioSwitched`,de=()=>window.sessionStorage,fe=`paracosm:runLaunchHandoff`;function pe(e){if(typeof e==`string`&&e.length!==0)try{de().setItem(fe,e)}catch{}}function me(){try{return de().getItem(fe)}catch{return null}}function he(e){try{let t=de();t.getItem(fe)===e&&t.removeItem(fe)}catch{}}function ge(e=de){try{e().setItem(ue,`1`)}catch{}}var _e=null;function ve(e=de){if(_e!==null)return _e;let t=!1;try{let n=e();t=n.getItem(ue)===`1`,t&&n.removeItem(ue)}catch{t=!1}return _e=t,t}var ye={id:`mars-genesis`,version:`3.0.0`,labels:{name:`Mars Genesis`,shortName:`mars`,populationNoun:`colonists`,settlementNoun:`colony`,currency:`credits`},theme:{primaryColor:`#dc2626`,accentColor:`#f97316`},setup:{defaultTurns:6,defaultSeed:950,defaultStartTime:2035,defaultTimePerTurn:8,defaultPopulation:100},departments:[{id:`medical`,label:`Medical`,role:`Chief Medical Officer`,icon:`🏥`},{id:`engineering`,label:`Engineering`,role:`Chief Engineer`,icon:`⚙️`},{id:`agriculture`,label:`Agriculture`,role:`Head of Agriculture`,icon:`🌱`},{id:`psychology`,label:`Psychology`,role:`Colony Psychologist`,icon:`🧠`},{id:`governance`,label:`Governance`,role:`Governance Advisor`,icon:`🏛️`}],presets:[],ui:{headerMetrics:[{id:`population`,format:`number`},{id:`morale`,format:`percent`},{id:`foodMonthsReserve`,format:`number`},{id:`powerKw`,format:`number`},{id:`infrastructureModules`,format:`number`},{id:`scienceOutput`,format:`number`}],tooltipFields:[`boneDensityPct`,`cumulativeRadiationMsv`,`psychScore`,`marsborn`],reportSections:[`crisis`,`departments`,`decision`,`outcome`,`quotes`],departmentIcons:{medical:`🏥`,engineering:`⚙️`,agriculture:`🌱`,psychology:`🧠`,governance:`🏛️`},setupSections:[`actors`,`personnel`,`resources`,`departments`,`events`,`models`,`advanced`]},policies:{toolForging:!0,bulletin:!0,characterChat:!0}},be=2e3,xe=15e3;function Se(){let[e,t]=(0,L.useState)(ye),[n,r]=(0,L.useState)(!1),[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(()=>Promise.resolve());return(0,L.useEffect)(()=>{let e=0,n=0,i=!1,s,c=()=>{let o=++e;clearTimeout(s),r(!1);let l=()=>{o===e&&(i=!0,a(!0),s=setTimeout(c,Math.min(be*2**n,xe)),n+=1)};return fetch(`/scenario`).then(e=>e.ok?e.json():null).then(s=>{o===e&&(s?.id?(n=0,i=!1,a(!1),t(s),r(!0)):l())}).catch(l)};o.current=c;let l=()=>{i&&c()};c();let u=se(window,c);return window.addEventListener(`online`,l),()=>{e+=1,clearTimeout(s),u(),window.removeEventListener(`online`,l),o.current=()=>Promise.resolve()}},[]),{scenario:e,ready:n,failed:i,retryNow:(0,L.useCallback)(()=>o.current(),[])}}var Ce=`Watch AI leaders run the same scenario | Paracosm`,we=`SCENARIO`;function Te(e,t,n){return`${e} ${e===1?t:n}`}function Ee(e){let t=e.place?.trim()||`this scenario`,n=`${e.n<=2?`Two AI leaders`:`${e.n} AI leaders`} each run ${t} for ${Te(e.turns,`turn`,`turns`)}, each under its own orders.`,r=e.n<=2?`At the end, a verdict says who won and\xA0why.`:`At the end, a report ranks them on morale, population and\xA0deaths.`;return e.atLimit?`${n} ${r}`:`${n} Press Start to watch them decide. ${r}`}var De=`The scenario did not load. Trying again.`,Oe=`You are offline. The scenario loads when you are back online.`,ke=`Try now`,Ae=`Trying…`,je=`Scenario name`,Me=e=>`Leader ${e}`,Ne=e=>`Leader ${e}`,Pe=(e,t)=>t===void 0?`Show ${e}`:`Show leader ${t} ${e}`,Fe=`Leaders`,Ie=`SCORES`,Le=`ORDERS`,Re={openness:`Openness`,conscientiousness:`Conscientiousness`,extraversion:`Extraversion`,agreeableness:`Agreeableness`,emotionality:`Emotionality`,honestyHumility:`Honesty-humility`},ze=`Middle band 0.35\xA0to\xA00.65`,Be=`HEXACO is a six-trait personality model. The six scores above are this leader’s.`,Ve=`This scenario has no written leaders. Paracosm writes them when you press Start.`,He={name:`Leader name`,title:`The leader’s title`,orders:`You are the leader of this run. You lead in your own way and weigh every choice against what you value. You hold to your methods when the turn goes badly, you say what you see, and you carry the people with you. Your six scores shape every decision you make here.`},Ue=`TURN 0`;function We(e){return Te(e.keyPeople,`key person`,`key people`).replace(` `,`\xA0`)}function Ge(e){let t=e.leaders<=2?`Both colonies`:`All ${e.leaders} colonies`,n=e.keyPeople===1?`this\xA01`:`these ${e.keyPeople}`;return`${t} start with the same ${Te(e.population,`person`,`people`)}, ${n} among them. Each leader’s decisions make them diverge.`}function Ke(e){let t=`${e.population} ${e.population===1?`person`:`people`}`;return`The colony at turn 0: ${e.keyPeople} of its ${t}, the same for every leader`}var qe=`This scenario names no key people. Its colony is drawn when the run starts.`,Je={department:`Department`,person:`Person`,featured:`Featured person`},Ye=`LEADERS`,Xe=e=>Te(e,`leader`,`leaders`),Ze=e=>`A free run has ${Xe(e.free)}. With your own API key, a run can have up to ${e.max}.`,Qe=`Number of leaders`,$e=`Fewer leaders`,et=`More leaders`,tt=e=>`Choose ${e.min} to ${e.max} leaders.`,nt=e=>`${e} is the fewest a run takes.`,rt=e=>`${e} is the most a run takes.`,it=e=>`Paracosm writes all ${e} leaders from this scenario when the run starts, in place of these two.`,at=`Start`;function ot(e){let t=Math.floor(e),n=e-t>=.5;return t===0?n?`½`:`0`:n?`${t}½`:String(t)}function st(e){let t=Math.floor(e),n=e-t>=.5;return t===0?n?`half a minute`:`0 minutes`:n?`${t} and a half minutes`:t===1?`1 minute`:`${t} minutes`}var ct=e=>e===`own`?`on your own API key`:`on this server’s API keys`;function lt(e){let t=Te(e.turns,`turn`,`turns`);if(e.who===`host`){let n=e.minutes<=1?`minute`:`minutes`;return`${t}, about ${ot(e.minutes)} ${n}`}return`${e.size>2?`${Xe(e.size)}, `:``}${t}, ${ct(e.who)}`}function ut(e){let t=`${e.turns} ${e.turns===1?`turn`:`turns`}`;if(e.who===`host`)return`${at} ${e.scenario}: ${t}, about ${st(e.minutes)}`;let n=e.size>2?`${e.size} leaders, `:``;return`${at} ${e.scenario}: ${n}${t}, ${ct(e.who)}`}var dt=`Checking your free runs…`,ft=`Starting…`,pt=e=>`Writing ${Xe(e)}…`,mt=`You are offline`,ht=`Start works when you are back online.`,gt=`The run did not start. Press Start again.`,_t={verdict:`Verdict`,report:`Report`},vt=`This run is free: we pay for it.`,yt=`The leaders are AI agents.`;function bt(e){let t=e.resetTime?` They reset at ${e.resetTime.replace(/ /g,`\xA0`)}.`:``;return`Free runs left today on your internet address: ${e.remaining} of ${e.limit}, shared by everyone using it.${t} A new run or a fork uses one.`}var xt=e=>e?`After that, you can replay your runs for free, or add your own API key in Settings to run again today. Your provider bills you for those runs.`:`After that, add your own API key in Settings to run again today. Your provider bills you for those runs.`,St=e=>`This run uses your ${e?`${e} `:``}API key, and your provider bills you.`,Ct=e=>`${St(e)} Runs on your key skip the daily limit and do not use your free runs. They are not held to this demo’s size, so they can be larger than the free run.`,wt=`This run uses this server’s API keys.`;function Tt(e){if(e.who===`server`)return`Estimated cost: about ${e.usd} USD on this server’s keys, from the mean cost of four pair runs measured on the hosted demo’s economy models. The server’s models set the real price.`;let t=e.provider&&e.models?` Your run uses ${e.provider} (${e.models}) from your Settings, which set the real price.`:``;return`Estimated cost: about ${e.usd} USD on your key, from the mean cost of four pair runs measured on this demo’s economy models.${t}`}var Et=e=>e?`Your internet address has no free runs left today. They reset at ${e.replace(/ /g,`\xA0`)}.`:`Your internet address has no free runs left today.`,Dt=e=>`${e?`You can replay a saved run for free. `:``}To start a new run now, add your own API key in Settings: your provider bills you, and the run is not held to this demo’s size.`,Ot=`Watch your last run again`,kt=`Watch our team’s run`;function At(e){let t=e.turns===void 0?``:Te(e.turns,`turn`,`turns`);return[e.scenario,t].filter(Boolean).join(`, `)}function jt(e){let t=e.turns===void 0?``:`${e.turns} ${e.turns===1?`turn`:`turns`}`,n=[e.scenario,t].filter(Boolean).join(`, `);return n?`${kt}: ${n}`:kt}var Mt=`Add your API key in Settings`,Nt=`Could not reach the server. Check your connection and press Start again.`,Pt=`The server is busy. Press Start again in a moment.`,Ft=`Every run slot on the server is in use. Press Start again in a minute.`,It=`Your saved runs did not load.`,Lt=`Try again`,Rt=`How it works`,zt=`Close`;function Bt(e={}){let t=e.turns===void 0?`After the last turn`:`After turn ${e.turns}`,n=e.settlement?.trim().toLowerCase()||`side`,r=e.batch===void 0?``:`, ${e.batch} at a time`;return[`Each leader follows its own orders, shown on its card. “See the full prompt” shows everything it was given.`,`On each turn an AI leader reads the event and its departments’ reports, picks a bold or a safe option and writes why. Its rule is to take the bold option when that option’s chance reaches the leader’s bar, a number set by its personality. It breaks the rule only for a fact the odds leave out, and names that fact.`,`RISKY or SAFE says which option it took. WIN or LOSS says whether it paid off.`,`${t} a verdict names the winner or a tie, says why, and scores each ${n} 0 to 10 for survival, prosperity, morale and innovation.`,`With two leaders, picking a winner is optional and changes nothing in the run.`,`With 3 or more leaders, each runs the scenario on its own${r}. The report ranks them in quarters on morale, population and deaths, with no single winner.`]}var Vt=`Sample turn`,Ht=`Bar\xA036`,Ut=`Chance\xA080`,Wt=`RISKY WIN`,Gt=[[`Survival`,7],[`Prosperity`,6],[`Morale`,8],[`Innovation`,5]],Kt={bar:`A sample turn: a bar set at 36 with a chance of 80, which reaches it`,stamp:`The stamp that turn earns: ${Wt}, the bold option taken, and it paid off`,scores:`Four sample scores out of 10: ${Gt.map(([e,t])=>`${e.toLowerCase()} ${t}`).join(`, `)}`},qt=`Other scenarios`,Jt=`On screen now`,Yt=e=>`Show all ${e}`,Xt=e=>`Load ${e}`,Zt=e=>`${e}, on screen now, unavailable`,Qt=e=>`Loading ${e}…`,$t=e=>`${e} did not load.`,en=e=>Te(e,`department`,`departments`),tn=e=>`View detail for ${e}`,nn=`Write your own scenario`,rn=`Generate and run`,an=e=>`You have a draft scenario below. Run it there, or clear it to play ${e}.`,on=`Go to your draft`,sn=`Clear your draft`,cn=`Leaders are fictional characters.`,ln=`The leaders are AI agents. Everything they say is written by a language model and can be wrong.`,un=`Under 18? You need a parent's or guardian's permission to use this. Not for children under 13.`,dn=`Site links`,fn=`More links`,pn=[{label:`Docs`,href:`/docs`},{label:`GitHub`,href:`https://github.com/framerslab/paracosm`},{label:`npm`,href:`https://www.npmjs.com/package/paracosm`},{label:`Privacy`,href:`/#privacy`}],mn=`Paracosm · Apache-2.0 · Frame.dev`;function hn(e){return e?e.charAt(0).toUpperCase()+e.slice(1):``}function gn(e){let t=e.toLowerCase();return t.endsWith(`y`)&&!`aeiou`.includes(t[t.length-2])?t.slice(0,-1)+`ies`:t.endsWith(`s`)||t.endsWith(`x`)||t.endsWith(`z`)||t.endsWith(`sh`)||t.endsWith(`ch`)?t+`es`:t+`s`}function _n(e){let t=e.toLowerCase();return t.endsWith(`ies`)&&t.length>4?t.slice(0,-3)+`y`:t.endsWith(`ses`)||t.endsWith(`xes`)||t.endsWith(`zes`)||t.endsWith(`shes`)||t.endsWith(`ches`)?t.slice(0,-2):t.endsWith(`s`)&&!t.endsWith(`ss`)?t.slice(0,-1):t}var vn=[`Alpha`,`Beta`,`Gamma`,`Delta`,`Epsilon`,`Zeta`,`Eta`,`Theta`];function yn(e,t){return`${bn(e).Place} ${vn[t]??t+1}`}function bn(e){let t=(e?.labels?.populationNoun||`colonists`).toLowerCase(),n=_n(t),r=(e?.labels?.settlementNoun||`colony`).toLowerCase(),i=gn(r),a=(e?.labels?.timeUnitNoun||`tick`).toLowerCase(),o=(e?.labels?.timeUnitNounPlural||gn(a)).toLowerCase();return{people:t,person:n,People:hn(t),Person:hn(n),place:r,places:i,Place:hn(r),Places:hn(i),time:a,times:o,Time:hn(a),Times:hn(o)}}var xn=[{name:`Actor A`,archetype:`The Visionary`,hexaco:{openness:.95,conscientiousness:.35,extraversion:.85,agreeableness:.55,emotionality:.3,honestyHumility:.65},instructions:``},{name:`Actor B`,archetype:`The Engineer`,hexaco:{openness:.25,conscientiousness:.97,extraversion:.3,agreeableness:.6,emotionality:.7,honestyHumility:.9},instructions:``}];function Sn(e){let t=e.presets.find(e=>e.id==="default"),n=t?.leaders??t?.actors??[];return xn.map((t,r)=>{let i=n[r]??t;return{...i,unit:i.unit??yn(e,r)}})}function Cn(e){return{actors:Sn(e),provider:`openai`,turns:e.setup.defaultTurns,timePerTurn:e.setup.defaultTimePerTurn,seed:e.setup.defaultSeed,startTime:e.setup.defaultStartTime,population:e.setup.defaultPopulation,activeDepartments:e.departments.map(e=>e.id),scenarioId:e.id,captureSnapshots:!0}}var wn=`paracosm:adminToken`,Tn=`X-Admin-Token`,En=`Enter it in Settings, under Admin Token, and press Save.`,Dn=`This token holds a character a request header cannot carry, so it is not kept. A token may hold only printable ASCII and Latin-1 characters: U+0020 to U+007E and U+00A0 to U+00FF.`;function On(e){return/^[\x20-\x7E\xA0-\xFF]*$/.test(e)}var kn=`paracosm:admin-token-changed`,An=``;function jn(){typeof window<`u`&&window.dispatchEvent(new Event(kn))}function Mn(){try{return window.localStorage.getItem(`paracosm:adminToken`)??``}catch{return``}}function Nn(){return An||Mn()}function Pn(){return An?`held`:Mn()?`stored`:`none`}function Fn(e){let t=e.trim();if(!t)return In(),`none`;if(!On(t))return`unsendable`;let n=!1;try{window.localStorage.setItem(wn,t),n=!0}catch{try{window.localStorage.removeItem(wn)}catch{}}return An=n?``:t,jn(),n?`stored`:`held`}function In(e){if(e===void 0||Nn()===e){An=``;try{window.localStorage.removeItem(wn)}catch{}jn()}}function Ln(e){return On(e)?null:(In(e),`${Dn} ${En}`)}function Rn(e){let t=()=>e(),n=t=>{(t.key===null||t.key===`paracosm:adminToken`)&&e()};return window.addEventListener(kn,t),window.addEventListener(`storage`,n),()=>{window.removeEventListener(kn,t),window.removeEventListener(`storage`,n)}}function zn(e,t){let n=e.map(e=>{let t=e.type===`colony_snapshot`?`systems_snapshot`:e.type;if(!e.data)return{...e,type:t};let n={...e.data};return n.colony!==void 0&&n.metrics===void 0&&(n.metrics=n.colony),n.colonyDeltas!==void 0&&n.systemDeltas===void 0&&(n.systemDeltas=n.colonyDeltas),{...e,type:t,data:n}}),r=t?.map(e=>e.leader&&e.leader.colony!==void 0&&e.leader.unit===void 0?{...e,leader:{...e.leader,unit:e.leader.colony}}:e);return{events:n,...r===void 0?{}:{results:r}}}function Bn(e){let t=e.turn??e.data?.turn??``,n=e.data?.eventIndex??``,r=e.data?.department??``,i=e.data?.title??``,a=e.data?.name??``,o=e.type===`forge_attempt`?`|${String(e.data?.timestamp??``)}`:``,s=e.type===`validation_fallback`?`|${String(e.data?.site??``)}|${String(e.data?.schemaName??``)}|${e.data?.salvaged===!0?`salvaged`:``}`:``;return`${e.type}|${e.leader||``}|${t}|${n}|${r}|${i}|${a}${o}${s}`}function Vn(e){let t={sessions:[],status:`loading`},n=new Set,r=0,i=e=>{t=e;for(let e of[...n])e()};return{getSnapshot:()=>t,subscribe(e){return n.add(e),()=>{n.delete(e)}},async refresh(){let t=++r;try{let n=await e();if(t!==r)return;if(n.status===503)return i({sessions:[],status:`unavailable`});if(!n.ok)return i({sessions:[],status:`error`});let a=await n.json();if(t!==r)return;i({sessions:a.sessions??[],status:`ready`})}catch{if(t!==r)return;i({sessions:[],status:`error`})}}}}async function Hn(e,t){let n=t&&typeof t==`object`?t.status:void 0;(n===`saved`||n===`titled`)&&await e.refresh()}var Un=Vn(()=>fetch(`/sessions`));function Wn(){let e=(0,L.useSyncExternalStore)(Un.subscribe,Un.getSnapshot,Un.getSnapshot);return(0,L.useEffect)(()=>{Un.refresh()},[]),{sessions:e.sessions,status:e.status,refresh:Gn}}function Gn(){Un.refresh()}function Kn(){return{events:[],results:[],verdict:null,errors:[],isComplete:!1,isAborted:!1,abortReason:null,providerError:null,validationFallbacks:[]}}var qn=Kn();function Jn(e={}){let t=e.replaySessionId??null,n=e.replaySpeed,r=e.scenarioId??null,i=(0,L.useRef)(e.onRunCleared);i.current=e.onRunCleared;let[a,o]=(0,L.useState)({status:`connecting`,events:[],results:[],verdict:null,errors:[],isComplete:!1,isAborted:!1,abortReason:null,providerError:null,validationFallbacks:[],replayDone:!1,ownRunScenarioId:null,heldOwnRun:null,runKey:null,loadedRuns:0}),s=(0,L.useRef)(null),c=(0,L.useRef)(new Set),l=(0,L.useRef)(null);if(l.current===null){let e=typeof window<`u`&&ve();l.current=!t&&e}let u=(0,L.useRef)(null),d=(0,L.useRef)(null),f=(0,L.useRef)(null),p=(0,L.useRef)(!1),m=(0,L.useRef)(void 0),h=(0,L.useRef)(r);h.current=r;let g=(0,L.useRef)(null);(0,L.useEffect)(()=>{if(t||r===null||p.current||f.current!==null&&d.current===f.current)return;let e=u.current;e!==null&&e!==r&&(c.current.clear(),o(e=>({...e,...Kn()})))},[r,t]);let _=(0,L.useCallback)(()=>{c.current.clear();let e=u.current,t=h.current;l.current=e!==null&&t!==null&&e!==t,u.current=null,d.current=null,f.current=null,p.current=!1,o(e=>({status:e.status,events:[],results:[],verdict:null,errors:[],isComplete:!1,isAborted:!1,abortReason:null,providerError:null,validationFallbacks:[],replayDone:!0,ownRunScenarioId:null,heldOwnRun:null,runKey:null,loadedRuns:e.loadedRuns}))},[]),v=(0,L.useCallback)(async()=>{let e=d.current;_();try{await fetch(`/clear`,e?{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({runKey:e})}:{method:`POST`})}catch{}},[_]),y=(0,L.useCallback)(e=>{f.current=e},[]),b=(0,L.useCallback)(()=>{if(f.current===null)return;f.current=null;let e=u.current,t=e!==null&&e!==h.current;t&&c.current.clear(),o(e=>t?{...e,...Kn(),ownRunScenarioId:null,heldOwnRun:null}:{...e,ownRunScenarioId:null,heldOwnRun:null})},[]),x=(0,L.useCallback)((e,t,n)=>{let r=e.find(e=>e.type===`provider_error`),i=r?.data?.actionUrl,a=r?{kind:r.data?.kind??`unknown`,provider:r.data?.provider,message:String(r.data?.message??`Provider error`),actionUrl:typeof i==`string`?i:void 0,leader:r.leader}:null,s=e.find(e=>e.type===`sim_aborted`),c=!!s,l=s?{reason:String(s.data?.reason??`unknown`),turn:s.data?.turn,completedTurns:s.data?.completedTurns,leader:s.leader}:null,u=S(e);p.current=!0,f.current=null,o(r=>({status:`connected`,events:e,results:t||[],verdict:n||null,errors:[],isComplete:!0,isAborted:c,abortReason:l,providerError:a,validationFallbacks:u,replayDone:!0,ownRunScenarioId:null,heldOwnRun:null,runKey:null,loadedRuns:r.loadedRuns+1}))},[]);function S(e){let t=[];for(let n of e)n.type===`validation_fallback`&&n.data&&(t=C(t,n.data));return t}function C(e,t){let n=typeof t.schemaName==`string`&&t.schemaName.length>0?t.schemaName:`unknown`,r=t.salvaged===!0,i=[...e],a=i.findIndex(e=>e.schemaName===n&&e.salvaged===r),o=a===-1?void 0:i[a],s={schemaName:n,salvaged:r,count:(o?.count??0)+1,lastSite:typeof t.site==`string`?t.site:o?.lastSite,lastPreview:typeof t.rawTextPreview==`string`?t.rawTextPreview:o?.lastPreview};return a===-1?i.push(s):i[a]=s,i.sort((e,t)=>t.count-e.count)}(0,L.useEffect)(()=>{let e=!1,r=null,a=0,v=0,y=()=>{if(t||f.current!==null&&d.current===f.current)return!1;if(l.current===!0)return!0;let e=u.current,n=h.current;return e!==null&&n!==null&&e!==n},b=c.current,x=async()=>{if(e)return;if(t)try{let n=await fetch(`/sessions/${encodeURIComponent(t)}`);if(e)return;if(n.status===404){o(e=>({...e,status:`replay_not_found`}));return}if(!n.ok){o(e=>({...e,status:`error`})),a+=1;let e=Math.min(1e4,500*2**(a-1));r=setTimeout(()=>{x()},e);return}}catch{}let c=t?`/sessions/${encodeURIComponent(t)}/replay${n==null?``:`?speed=${encodeURIComponent(String(n))}`}`:`/events`,h=new EventSource(c);s.current=h,h.addEventListener(`connected`,e=>{a=0,v+=1;try{let t=JSON.parse(e.data);g.current=typeof t?.visitorId==`string`?t.visitorId:null}catch{g.current=null}if(u.current=null,v===1){let e=m.current!==t||p.current;m.current=t,b.clear(),p.current=!1,o(t=>({...t,status:`connected`,events:[],replayDone:!1,...e?{runKey:null,loadedRuns:t.loadedRuns+1}:{}}))}else o(e=>({...e,status:`connected`,replayDone:!1}))}),h.addEventListener(`replay_done`,()=>{o(e=>({...e,replayDone:!0}))}),h.addEventListener(`run_cleared`,e=>{let t=null;try{let n=JSON.parse(e.data);t=typeof n?.runKey==`string`?n.runKey:null}catch{}t!==null&&t===d.current&&(p.current||(_(),i.current?.(t)))}),h.addEventListener(`active_scenario`,e=>{let n=null,r=null,i=!1;try{let t=JSON.parse(e.data);n=typeof t?.id==`string`?t.id:null,r=typeof t?.runKey==`string`?t.runKey:null,i=t?.forkedFrom!=null}catch{}let a=d.current,s=a!==null&&r!==null&&r!==a,c=r!==null&&r===f.current,m=s&&a===f.current;d.current=r,u.current=n,l.current=!1,c&&o(e=>({...e,ownRunScenarioId:n}));let h=y();h?o(e=>e.events.length>0&&!e.isComplete?{...e,isComplete:!0,isAborted:!0,abortReason:e.abortReason??{reason:`another_run_started`}}:e):s&&(!i||m)&&!t&&(b.clear(),p.current=!1,o(e=>({...e,...Kn(),ownRunScenarioId:c?n:null,heldOwnRun:e.ownRunScenarioId!==null&&!c?{events:e.events,isComplete:!0}:e.heldOwnRun}))),!h&&!p.current&&o(e=>e.runKey===r?e:{...e,runKey:r})}),h.addEventListener(`status`,e=>{if(!y())try{let t={type:`status`,leader:``,data:JSON.parse(e.data)},n=`status|${d.current??``}|${e.data}`;if(b.has(n))return;b.add(n),o(e=>({...e,events:[...e.events,t]}))}catch{}}),h.addEventListener(`sim`,e=>{if(!y())try{let t=zn([JSON.parse(e.data)]).events[0],n=Bn(t);if(b.has(n))return;if(b.add(n),t.type===`provider_error`&&t.data){let e=t.data,n=e.actionUrl;o(r=>({...r,events:[...r.events,t],providerError:r.providerError??{kind:e.kind??`unknown`,provider:e.provider,message:String(e.message??`Provider error`),actionUrl:typeof n==`string`?n:void 0,leader:t.leader}}));return}if(t.type===`validation_fallback`&&t.data){let e=t.data;o(n=>({...n,events:[...n.events,t],validationFallbacks:C(n.validationFallbacks,e)}));return}if(t.type===`sim_aborted`){let e=t.data??{},n={reason:String(e.reason??`unknown`),turn:typeof e.turn==`number`?e.turn:void 0,completedTurns:typeof e.completedTurns==`number`?e.completedTurns:void 0,leader:typeof t.leader==`string`?t.leader:void 0};o(e=>({...e,events:[...e.events,t],isAborted:!0,isComplete:!0,abortReason:e.abortReason??n}));return}o(e=>({...e,events:[...e.events,t]}))}catch{}}),h.addEventListener(`result`,e=>{if(!y())try{let t=JSON.parse(e.data);o(e=>({...e,results:[...e.results,t]}))}catch{}}),h.addEventListener(`verdict`,e=>{if(!y())try{let t=JSON.parse(e.data);o(e=>({...e,verdict:{...t,mode:`pair`}}))}catch{}}),h.addEventListener(`cohort_verdict`,e=>{if(!y())try{let t=JSON.parse(e.data);o(e=>({...e,verdict:{...t,mode:`cohort`}}))}catch{}}),h.addEventListener(`verdict_skipped`,e=>{if(!y())try{let t=JSON.parse(e.data);o(e=>({...e,verdict:e.verdict??{...t,mode:`cohort`,skipped:!0}}))}catch{}}),h.addEventListener(`complete`,e=>{if(y())return;let t=!1;try{let n=e.data?JSON.parse(e.data):null;t=!!(n&&n.aborted)}catch{}o(e=>({...e,isComplete:!0,isAborted:e.isAborted||t,abortReason:e.abortReason??(t?{reason:`unknown`}:null)}))}),h.addEventListener(`sim_error`,e=>{if(!y())try{let t=JSON.parse(e.data),n=String(t.error||`Unknown simulation error`);console.error(`[SSE] Simulation error:`,n),o(e=>({...e,errors:[...e.errors,n]}))}catch{}}),h.addEventListener(`sim_saved`,e=>{if(!y())try{let t=JSON.parse(e.data),n={type:`sim_saved`,leader:``,data:t},r=`sim_saved|${t.status??``}|${t.id??``}|${t.reason??``}`;if(b.has(r))return;b.add(r),o(e=>({...e,events:[...e.events,n]})),Hn(Un,t)}catch{}}),h.onerror=()=>{o(e=>({...e,status:`error`}));try{h.close()}catch{}if(s.current=null,e)return;a+=1;let t=Math.min(1e4,500*2**(a-1));r=setTimeout(()=>{x()},t)}};x();let S=t?()=>{}:V(window,t=>{if(e||g.current===null||t===g.current)return;g.current=null,r&&=(clearTimeout(r),null);let n=s.current;if(n)try{n.close()}catch{}s.current=null,x()});return()=>{e=!0,S(),r&&clearTimeout(r);let t=s.current;if(t)try{t.close()}catch{}s.current=null}},[t,n]);let w=a.ownRunScenarioId!==null&&a.ownRunScenarioId!==r,T=a.heldOwnRun??(w?{events:a.events,isComplete:a.isComplete}:null);return{...w?{...a,...qn,providerError:a.providerError}:a,ownRun:T,reset:v,loadEvents:x,followRun:y,leaveOwnRun:b}}var Yn=[`var(--vis)`,`var(--eng)`,`var(--rust)`,`var(--green)`,`var(--violet)`,`var(--coral)`,`var(--sky)`,`var(--olive)`];function Xn(e){return Yn[(e%Yn.length+Yn.length)%Yn.length]}function Zn(){return{leader:null,metrics:null,prevMetrics:null,event:null,events:[],popHistory:[],moraleHistory:[],deaths:0,deathCauses:{},tools:0,toolNames:new Set,citations:0,decisions:0,pendingDecision:``,pendingRationale:``,pendingReasoning:``,pendingPolicies:[],outcome:null,agentSnapshots:[],currentEvents:[]}}function Qn(){return{totalTokens:0,totalCostUSD:0,llmCalls:0}}function $n(e){let t=e.artifact?.scenarioExtensions?.paracosmInternal?.leader?.name;return typeof t==`string`&&t.length>0?t:e.leader}function er(e){let t=new Map,n=e?.scenarioExtensions?.paracosmInternal?.commanderDecisions,r=Array.isArray(n)?n:[];for(let e of r){let n=e;if(!n||typeof n.turn!=`number`)continue;let r=`${n.turn}:${typeof n.eventIndex==`number`?n.eventIndex:0}`,i=n.barCheck??null;!i||typeof i.boldChance!=`number`||typeof i.bar!=`number`?t.set(r,void 0):t.set(r,{boldChance:i.boldChance,bar:i.bar,clearsBar:i.clearsBar===!0,choseBold:i.choseBold===!0,departs:i.departs===!0,departureFact:typeof i.departureFact==`string`?i.departureFact:``,unexplained:i.unexplained===!0})}return t}function tr(e,t,n){let r={actors:{},actorIds:[],turn:0,time:0,maxTurns:6,seed:950,isRunning:!1,isComplete:t,isAborted:!1,cost:Qn(),costByActor:{}},i=e=>{if(!e)return null;let t=r.actors[e];return t||(t=Zn(),r.actors[e]=t,r.actorIds.push(e)),t};for(let t=0;t<e.length;t++){let n=e[t],a=n.data||{},o=n.leader||``,s=a._cost;if(s&&o){i(o),r.costByActor[o]={totalTokens:s.totalTokens??0,totalCostUSD:s.totalCostUSD??0,llmCalls:s.llmCalls??0,cacheReadTokens:s.cacheReadTokens??0,cacheCreationTokens:s.cacheCreationTokens??0,cacheSavingsUSD:s.cacheSavingsUSD??0,breakdown:s.breakdown,schemaRetries:s.schemaRetries,forgeStats:s.forgeStats};let e=Object.values(r.costByActor),t={};for(let n of e)if(n.breakdown)for(let[e,r]of Object.entries(n.breakdown)){let n=t[e]??{totalTokens:0,totalCostUSD:0,calls:0,cacheReadTokens:0,cacheCreationTokens:0,cacheSavingsUSD:0};t[e]={totalTokens:n.totalTokens+(r?.totalTokens??0),totalCostUSD:Math.round((n.totalCostUSD+(r?.totalCostUSD??0))*1e4)/1e4,calls:n.calls+(r?.calls??0),cacheReadTokens:(n.cacheReadTokens??0)+(r?.cacheReadTokens??0),cacheCreationTokens:(n.cacheCreationTokens??0)+(r?.cacheCreationTokens??0),cacheSavingsUSD:Math.round(((n.cacheSavingsUSD??0)+(r?.cacheSavingsUSD??0))*1e4)/1e4}}let n={};for(let t of e)if(t.schemaRetries)for(let[e,r]of Object.entries(t.schemaRetries)){let t=n[e]??{attempts:0,calls:0,fallbacks:0};n[e]={attempts:t.attempts+r.attempts,calls:t.calls+r.calls,fallbacks:t.fallbacks+r.fallbacks}}let a=(()=>{let t=e.map(e=>e.forgeStats).filter(e=>!!e);if(t.length!==0)return t.reduce((e,t)=>({attempts:e.attempts+t.attempts,approved:e.approved+t.approved,rejected:e.rejected+t.rejected,approvedConfidenceSum:e.approvedConfidenceSum+t.approvedConfidenceSum}),{attempts:0,approved:0,rejected:0,approvedConfidenceSum:0})})();r.cost={totalTokens:e.reduce((e,t)=>e+t.totalTokens,0),totalCostUSD:Math.round(e.reduce((e,t)=>e+t.totalCostUSD,0)*1e4)/1e4,llmCalls:e.reduce((e,t)=>e+t.llmCalls,0),cacheReadTokens:e.reduce((e,t)=>e+(t.cacheReadTokens??0),0),cacheCreationTokens:e.reduce((e,t)=>e+(t.cacheCreationTokens??0),0),cacheSavingsUSD:Math.round(e.reduce((e,t)=>e+(t.cacheSavingsUSD??0),0)*1e4)/1e4,breakdown:Object.keys(t).length>0?t:void 0,schemaRetries:Object.keys(n).length>0?n:void 0,forgeStats:a}}if(n.type===`status`){if(a.maxTurns&&(r.maxTurns=a.maxTurns),a.phase===`parallel`&&Array.isArray(a.actors)){let e=a.actors;for(let t of e){if(!t?.name)continue;let e=i(t.name);e&&(e.leader=t)}r.isRunning=!0}continue}let c=i(o);if(!c)continue;let l={id:`${t}-${n.type}`,type:n.type,turn:a.turn,time:a.time,data:a};switch(n.type){case`event_start`:{let e={eventIndex:Number(a.eventIndex??0),totalEvents:Number(a.totalEvents??1),title:String(a.title||``),category:String(a.category||``)};c.currentEvents.push(e),e.totalEvents>1&&(c.event={turn:a.turn,time:a.time,title:`${e.eventIndex+1}/${e.totalEvents}: ${e.title}`,description:a.description||``,category:e.category,emergent:a.emergent||!1,turnSummary:a.turnSummary||``}),c.events.push(l);break}case`turn_start`:c.currentEvents=[],c.pendingDecision=``,c.pendingRationale=``,c.pendingReasoning=``,c.pendingPolicies=[],a.turn&&(r.turn=a.turn),a.time&&(r.time=a.time),a.title&&a.title!==`Director generating...`&&(c.event={turn:a.turn,time:a.time,title:a.title,description:a.crisis||``,category:a.category||``,emergent:a.emergent||!1,turnSummary:a.turnSummary||``}),a.metrics&&(c.prevMetrics=c.metrics?{...c.metrics}:null,c.metrics=a.metrics,c.popHistory.push(a.metrics.population||0),c.moraleHistory.push(Math.round((a.metrics.morale||0)*100))),a.deaths&&(c.deaths+=Number(a.deaths)||0),c.events.push(l);break;case`promotion`:case`specialist_start`:case`forge_attempt`:case`decision_pending`:case`personality_drift`:case`agent_reactions`:case`bulletin`:c.events.push(l);break;case`specialist_done`:{let e=Array.isArray(a.forgedTools)?a.forgedTools.filter(e=>e?.name&&e.name!==`unnamed`):[];for(let t of e){let e=String(t.name||``).trim();e&&t.approved!==!1&&!c.toolNames.has(e)&&c.toolNames.add(e)}c.tools=c.toolNames.size,c.citations+=Number(a.citations)||0,c.events.push({...l,data:{...a,_filteredTools:e}});break}case`decision_made`:c.pendingDecision=a.decision||``,c.pendingRationale=a.rationale||``,c.pendingReasoning=a.reasoning||``,c.pendingPolicies=a.selectedPolicies||[];break;case`outcome`:c.outcome=a.outcome||``,c.decisions++,c.events.push({...l,data:{...a,_decision:c.pendingDecision,_rationale:c.pendingRationale,_reasoning:c.pendingReasoning,_policies:c.pendingPolicies}}),c.pendingDecision=``,c.pendingRationale=``,c.pendingReasoning=``,c.pendingPolicies=[];break;case`systems_snapshot`:c.agentSnapshots.push(a.agents||[]),c.events.push(l);break;case`validation_fallback`:{let e=l.turn;for(let t=c.events.length-1;e===void 0&&t>=0;t--){let n=c.events[t].turn;typeof n==`number`&&(e=n)}c.events.push({...l,turn:e});break}case`turn_done`:if(a.metrics&&(c.prevMetrics=c.metrics?{...c.metrics}:null,c.metrics=a.metrics),a.statuses&&typeof a.statuses==`object`&&(c.statuses={...a.statuses}),a.environment&&typeof a.environment==`object`&&(c.environment={...a.environment}),a.deathCauses&&typeof a.deathCauses==`object`)for(let[e,t]of Object.entries(a.deathCauses))typeof t!=`number`||t<=0||(c.deathCauses[e]=(c.deathCauses[e]??0)+t);c.events.push(l)}}let a=e.some(e=>e.type===`sim_aborted`);if(r.isAborted=a,r.isComplete||a){r.isRunning=!1;for(let e of r.actorIds){let t=r.actors[e];t&&(t.pendingDecision||t.pendingRationale||t.pendingReasoning||t.pendingPolicies.length)&&(t.pendingDecision=``,t.pendingRationale=``,t.pendingReasoning=``,t.pendingPolicies=[])}}let o=new Map;for(let e of n??[]){let t=$n(e),n=t?r.actors[t]:void 0;if(!n)continue;let i=er(e.artifact),a=o.get(t)??new Set;o.set(t,a),n.events=n.events.map(e=>{if(e.type!==`outcome`||e.data._barCheck!==void 0)return e;let t=`${e.turn??e.data.turn}:${Number(e.data.eventIndex??0)}`;if(a.has(t))return e;let n=i.get(t);return n?{...e,data:{...e.data,_barCheck:n}}:e});for(let e of i.keys())a.add(e)}return r}function nr(e,t,n){return(0,L.useMemo)(()=>tr(e,t,n),[e,t,n])}function rr(e,t){ir(new Blob([e],{type:`application/json`}),t)}function ir(e,t){let n=document.createElement(`a`),r=URL.createObjectURL(e);try{n.href=r,n.download=t,document.body.append(n),n.click()}finally{n.remove(),setTimeout(()=>URL.revokeObjectURL(r),1e3)}}var ar=class e extends Error{fileVersion;dashboardVersion;name=`SchemaVersionTooNewError`;constructor(t,n){super(`Save file is schema v${t}; this dashboard supports up to v${n}.`),this.fileVersion=t,this.dashboardVersion=n,Object.setPrototypeOf(this,e.prototype)}},or=class e extends Error{missingFromVersion;name=`SchemaVersionGapError`;constructor(t){super(`No migration registered from schema v${t}.`),this.missingFromVersion=t,Object.setPrototypeOf(this,e.prototype)}},sr={1:e=>{let t=zn(e.events,e.results);return{...e,events:t.events,results:t.results??e.results??[],schemaVersion:2}},2:e=>({...e,events:(e.events??[]).map(e=>cr(e)),results:(e.results??[]).map(e=>cr(e)),schemaVersion:3})};function cr(e){if(typeof e!=`object`||!e)return e;if(Array.isArray(e))return e.map(e=>cr(e));let t={...e};for(let[e,n]of[[`year`,`time`],[`yearDelta`,`timeDelta`],[`startYear`,`startTime`],[`currentYear`,`currentTime`],[`birthYear`,`birthTime`],[`deathYear`,`deathTime`]])e in t&&!(n in t)&&(t[n]=t[e]);for(let e of Object.keys(t)){let n=t[e];typeof n==`object`&&n&&(t[e]=cr(n))}return t}function lr(e){let t=typeof e.schemaVersion==`number`?e.schemaVersion:1;if(t>3)throw new ar(t,3);let n=e;for(let e=t;e<3;e++){let t=sr[e];if(!t)throw new or(e);n=t(n)}return{...n,schemaVersion:3}}function ur(e,t){return`${e}-${t}`}function dr(e,t){let n=(0,L.useCallback)((n,r,i)=>{let a={config:null,events:n,results:r,verdict:i??null,startedAt:new Date().toISOString(),completedAt:new Date().toISOString(),schemaVersion:3,...t?{scenario:t}:{}};rr(JSON.stringify(a,null,2),`${e}-${n.length}events.json`)},[e,t]),r=(0,L.useCallback)(()=>new Promise(e=>{let t=document.createElement(`input`);t.type=`file`,t.accept=`.json`;let n=!1,r=t=>{n||(n=!0,window.removeEventListener(`focus`,i),e(t))},i=()=>{window.setTimeout(()=>r(null),300)};t.onchange=()=>{r(t.files?.[0]??null)},window.addEventListener(`focus`,i,{once:!0}),t.click()}),[]),i=(0,L.useCallback)(e=>new Promise(t=>{let n=new FileReader;n.onload=()=>{try{let e=JSON.parse(n.result);if(!Array.isArray(e.events)||e.events.length===0){t({ok:!1,reason:`empty`});return}let r=typeof e.schemaVersion==`number`?e.schemaVersion:1;try{t({ok:!0,data:lr(e),fromVersion:r,migrated:r<3})}catch(e){if(e instanceof ar){t({ok:!1,reason:`too-new`,fileVersion:e.fileVersion,dashboardVersion:e.dashboardVersion});return}t({ok:!1,reason:`parse-failed`})}}catch{t({ok:!1,reason:`parse-failed`})}},n.onerror=()=>t({ok:!1,reason:`parse-failed`}),n.readAsText(e)}),[]);return{save:n,load:(0,L.useCallback)(async()=>{let e=await r();if(!e)return null;let t=await i(e);return t.ok?t.data:null},[r,i]),pickFile:r,parseFile:i,cacheEvents:(0,L.useCallback)((t,n)=>{try{localStorage.setItem(ur(e,`game-data`),JSON.stringify({events:t,results:n,startedAt:new Date().toISOString()}))}catch{}},[e]),restoreFromCache:(0,L.useCallback)(()=>{try{if(localStorage.getItem(ur(e,`cleared`)))return null;let t=localStorage.getItem(ur(e,`game-data`));if(!t)return null;let n=JSON.parse(t);if(!n.events?.length)return null;let r=zn(n.events,n.results);return{...n,events:r.events,results:r.results??n.results??[]}}catch{return null}},[e]),clearCache:(0,L.useCallback)(()=>{localStorage.removeItem(ur(e,`game-data`)),localStorage.setItem(ur(e,`cleared`),Date.now().toString()),fetch(`/clear`,{method:`POST`}).catch(()=>{})},[e])}}var fr=`paracosm-local-history-v2`;function pr(e){try{let t=e.getItem(fr);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}function mr(e,t){try{e.setItem(fr,JSON.stringify(t))}catch{}}function hr(e,t,n){let r=[t,...e];return r.length<=n?r:r.slice(0,n)}function gr(e,t){return e.filter(e=>e.id!==t)}function _r(e,t){let n=[],r=new Set,i=0,a,o=e??[];for(let e of o){typeof e?.leader==`string`&&e.leader&&!r.has(e.leader)&&(r.add(e.leader),n.push(e.leader));let t=vr(e);t>i&&(i=t);let o=yr(e);o!==void 0&&(a=o)}let s={actorNames:n,turnCount:i,eventCount:o.length};return a!==void 0&&(s.totalCostUSD=a),s}function vr(e){if(typeof e?.turn==`number`)return e.turn;if(e?.data&&typeof e.data==`object`){let t=e.data.turn;if(typeof t==`number`)return t}return 0}function yr(e){if(!e?.data||typeof e.data!=`object`)return;let t=e.data._cost;if(!t||typeof t!=`object`)return;let n=t.totalCostUSD;return typeof n==`number`?n:void 0}function br(e,t){if(!e||typeof e!=`object`||Array.isArray(e))return null;let n=e,r=Array.isArray(n.events)?n.events:null;if(!r||r.length===0)return null;let i=Array.isArray(n.results)?n.results:[],a=n.verdict&&typeof n.verdict==`object`?n.verdict:null,o=typeof n.startedAt==`string`&&n.startedAt?n.startedAt:new Date().toISOString();return{id:Date.parse(o)||Cr(),createdAt:o,events:r,results:i,verdict:a,scenarioShortName:t,summary:_r(r,i)}}var xr=0,Sr=0;function Cr(){let e=Date.now();return e===Sr?(xr+=1,e+xr/1e3):(Sr=e,xr=0,e)}function wr(e){return`${e}-game-data`}function Tr(e){let t=e.storage??(typeof window<`u`?window.localStorage:{getItem:()=>null,setItem:()=>{},removeItem:()=>{}}),n=e.maxSize??5,[r,i]=(0,L.useState)(()=>pr(t));return(0,L.useEffect)(()=>{let r=t.getItem(wr(e.scenarioShortName));if(r){try{let a=br(JSON.parse(r),e.scenarioShortName);a&&i(e=>{let r=hr(e,a,n);return mr(t,r),r})}catch{}t.removeItem(wr(e.scenarioShortName))}},[e.scenarioShortName,n,t]),{entries:r,push:(0,L.useCallback)(r=>{if(!r.events||r.events.length===0)return;let a={id:Cr(),createdAt:new Date().toISOString(),events:r.events,results:r.results,verdict:r.verdict??null,scenarioShortName:e.scenarioShortName,summary:_r(r.events,r.results)};i(e=>{let r=hr(e,a,n);return mr(t,r),r})},[e.scenarioShortName,n,t]),remove:(0,L.useCallback)(e=>{i(n=>{let r=gr(n,e);return mr(t,r),r})},[t]),clear:(0,L.useCallback)(()=>{i([]),mr(t,[])},[t]),restore:(0,L.useCallback)((e,t)=>{t(e.events,e.results,e.verdict??null)},[])}}function Er(e,t,n){if(!e||typeof e!=`object`||Array.isArray(e))return null;let r=e,i=Array.isArray(r.events)?r.events:null;if(!i||i.length===0)return null;let a=[],o=new Set,s=0;for(let e of i){typeof e?.leader==`string`&&e.leader&&!o.has(e.leader)&&(o.add(e.leader),a.push(e.leader));let t=kr(e);t>s&&(s=t)}let c=typeof r.schemaVersion==`number`?r.schemaVersion:`legacy`,l=r.verdict!==null&&r.verdict!==void 0,u=typeof r.startedAt==`string`&&r.startedAt?r.startedAt:null,d=Ar(r,i),f;return n&&(f={state:Or(Dr(e),n),fileScenarioName:d,currentScenarioName:n.name}),{scenarioName:d,schemaVersion:c,actorNames:a,turnCount:s,eventCount:i.length,startedAt:u,hasVerdict:l,fileName:t?.name??``,fileSize:t?Mr(t.size):``,...f?{scenarioMatch:f}:{}}}function Dr(e){if(!e||typeof e!=`object`||Array.isArray(e))return{source:`unknown`};let t=e,n=t.scenario;if(n&&typeof n==`object`){let e=n,t=typeof e.id==`string`?e.id:void 0,r=typeof e.shortName==`string`?e.shortName:void 0;if(t||r)return{id:t,name:r,source:`declared`}}let r=Array.isArray(t.events)?t.events:[];for(let e of r){if(!e?.data||typeof e.data!=`object`)continue;let t=e.data.scenario;if(t&&typeof t==`object`){let e=t,n=typeof e.id==`string`?e.id:void 0,r=typeof e.name==`string`?e.name:void 0;if(n||r)return{id:n,name:r,source:`inferred`}}}return{source:`unknown`}}function Or(e,t){return e.source===`unknown`?`unknown`:e.id&&e.id===t.id||!e.id&&e.name&&e.name===t.name?`match`:`mismatch`}function kr(e){if(typeof e?.turn==`number`)return e.turn;if(e?.data&&typeof e.data==`object`){let t=e.data.turn;if(typeof t==`number`)return t}return 0}function Ar(e,t){for(let e of t){if(!e?.data||typeof e.data!=`object`)continue;let t=e.data.scenario;if(t&&typeof t==`object`){let e=t.name;if(typeof e==`string`&&e)return e}}let n=e.scenario;if(n&&typeof n==`object`){let e=n.shortName;if(typeof e==`string`&&e)return e;let t=n.id;if(typeof t==`string`&&t)return t}return`unknown`}function jr(e,t){return e.kind===`idle`&&t.type===`open-started`?{kind:`parsing`}:e.kind===`parsing`&&t.type===`open-succeeded`?{kind:`preview`,metadata:t.metadata,data:t.data}:e.kind===`parsing`&&t.type===`open-failed`||e.kind===`preview`&&t.type===`cancel`?{kind:`idle`}:e.kind===`preview`&&t.type===`confirm`?{kind:`dispatching`,data:e.data}:e.kind===`dispatching`&&t.type===`confirm-complete`?{kind:`idle`}:e}function Mr(e){if(e<1024)return`${e} B`;let t=e/1024;if(t<1024)return`${Math.round(t)} KB`;let n=t/1024,r=(Math.round(n*10)/10).toFixed(1);return`${r.endsWith(`.0`)?r.slice(0,-2):r} MB`}var Nr={kind:`idle`};function Pr(e){let[t,n]=(0,L.useReducer)(jr,Nr),r=(0,L.useCallback)(async t=>{n({type:`open-started`});try{let r=await e.parseFile(t);if(!r.ok){n({type:`open-failed`}),r.reason===`too-new`?e.onError?.(`This file was saved under schema v${r.fileVersion}; this dashboard supports up to v${r.dashboardVersion}. Update the dashboard to load it.`):e.onError?.(`No valid game data found in file.`);return}let i=Er(r.data,{name:t.name,size:t.size},e.currentScenario);if(!i){n({type:`open-failed`}),e.onError?.(`No valid game data found in file.`);return}n({type:`open-succeeded`,metadata:i,data:r.data})}catch{n({type:`open-failed`}),e.onError?.(`Failed to read file.`)}},[e]),i=(0,L.useCallback)(async()=>{let t=await e.pickFile();t&&await r(t)},[e,r]),a=(0,L.useCallback)(()=>{if(t.kind!==`preview`)return;let r=t.data;n({type:`confirm`});try{e.onConfirm({events:r.events??[],results:r.results??[],verdict:r.verdict??null})}finally{n({type:`confirm-complete`})}},[t,e]),o=(0,L.useCallback)(()=>{n({type:`cancel`})},[]);return{state:t,metadata:t.kind===`preview`?t.metadata:null,openPicker:i,openFromFile:r,confirm:a,cancel:o}}var Fr=new Set([`http:`,`https:`]);function Ir(e){let t;try{t=new URL(e)}catch{return{ok:!1,reason:`missing`}}let n=t.searchParams.get(`load`);if(!n)return{ok:!1,reason:`missing`};let r;try{r=new URL(n)}catch{return{ok:!1,reason:`malformed`}}return Fr.has(r.protocol)?{ok:!0,url:r}:{ok:!1,reason:`unsupported-scheme`}}var Lr=`remote-run.json`;function Rr(e){let t=e.pathname.split(`/`).filter(Boolean),n=t[t.length-1];if(!n)return Lr;try{return decodeURIComponent(n)}catch{return n}}function zr(e,t){try{let n=new URL(t);return e.origin!==n.origin}catch{return!0}}function Br(e){let t;try{t=new URL(e)}catch{return!1}let n=t.searchParams.get(`autoload`);if(!n)return!1;let r=n.toLowerCase();return r===`1`||r===`true`}function Vr(e,t){let n;try{n=new URL(e)}catch{return null}let r=n.searchParams.get(`tab`);return r&&t.includes(r)?r:null}var Hr=3e4;function Ur(e){let t=(0,L.useRef)(e);t.current=e;let[n,r]=(0,L.useState)(null),i=(0,L.useRef)(null),a=(0,L.useCallback)(e=>{let n=new AbortController,r=window.setTimeout(()=>n.abort(),Hr),a={cancelled:!1,ctrl:n,timeoutId:r};i.current=a,(async()=>{let{openFromFile:i,onInfo:o,onError:s}=t.current;zr(e,window.location.href)?o?.(`Loading remote run`,`Fetching from ${e.host}...`):o?.(`Loading run`,`Fetching ${e.pathname}...`);try{let r=await(t.current._fetchImpl??fetch)(e.toString(),{signal:n.signal});if(!r.ok)throw Error(`HTTP ${r.status}`);if(r.url){let t;try{let n=new URL(r.url);t=n.origin===e.origin?null:n.host}catch{t=`another address`}if(t!==null)throw Error(`The file redirects to ${t}, so it was not loaded.`)}let o=await r.blob();if(a.cancelled)return;await i(new File([o],Rr(e),{type:`application/json`}))}catch(e){if(a.cancelled)return;let t=e instanceof Error&&e.name===`AbortError`?`Fetch timed out after ${Hr/1e3}s.`:e instanceof Error?e.message:String(e);s?.(`Remote load failed`,t)}finally{window.clearTimeout(r),Wr()}})()},[]);(0,L.useEffect)(()=>{let e=Ir(window.location.href);if(!e.ok)(e.reason===`unsupported-scheme`||e.reason===`malformed`)&&(console.warn(`[paracosm] Ignoring ?load= param: ${e.reason}`),Wr());else return zr(e.url,window.location.href)?r(e.url):a(e.url),()=>{let e=i.current;e&&(e.cancelled=!0,e.ctrl.abort(),window.clearTimeout(e.timeoutId),i.current=null)}},[]);let o=(0,L.useCallback)(()=>{r(null),n&&a(n)},[n,a]),s=(0,L.useCallback)(()=>{r(null),Wr()},[]);return{pendingHost:n?n.host:null,confirmPending:o,cancelPending:s}}function Wr(){try{let e=new URL(window.location.href),t=e.searchParams.has(`load`),n=e.searchParams.has(`autoload`);if(!t&&!n)return;e.searchParams.delete(`load`),e.searchParams.delete(`autoload`);let r=e.pathname+(e.search?e.search:``)+e.hash;window.history.replaceState({},``,r)}catch{}}function Gr(e){try{let t=typeof navigator<`u`?navigator.clipboard:void 0;return!t||typeof t.writeText!=`function`?Promise.reject(Error(`This page has no clipboard.`)):t.writeText(e)}catch(e){return Promise.reject(e)}}function Kr(e,t,n=`viz`){let r=new URL(`/sim`,e);return r.searchParams.set(`replay`,t),r.searchParams.set(`tab`,n),r.toString()}function qr(e){for(let t=e.length-1;t>=0;t--){let n=e[t];if(n.type!==`sim_saved`)continue;let r=n.data??{};if(r.status!==`saved`)continue;let i=r.id;if(typeof i==`string`&&i.length>0)return i}return null}function Jr(e){let t;try{t=new URL(e).hostname.toLowerCase()}catch{return!1}return t.endsWith(`.`)&&(t=t.slice(0,-1)),t===`localhost`||t.endsWith(`.localhost`)||t===`[::1]`||t===`0.0.0.0`||/^127(?:\.\d{1,3}){3}$/.test(t)}function Yr(e){if(!e||e.length===0)return{kind:`empty`};let t=e[0];return!t||!t.name||!t.name.toLowerCase().endsWith(`.json`)?{kind:`unsupported`}:e.length===1?{kind:`ok`,file:t}:{kind:`ok-with-extras`,file:t,totalCount:e.length}}function Xr(e){if(!e)return!1;let t=e.types;return Array.isArray(t)?t.includes(`Files`):t&&typeof t.contains==`function`?t.contains(`Files`):!1}function Zr(e){let[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(e);return r.current=e,(0,L.useEffect)(()=>{let e=0,t=e=>{let t=e.target;return!t||typeof t.closest!=`function`?!1:!!t.closest(`[data-paracosm-local-dropzone]`)},i=r=>{Xr(r.dataTransfer)&&(t(r)||(e+=1,n(!0)))},a=e=>{Xr(e.dataTransfer)&&(t(e)||e.preventDefault())},o=r=>{Xr(r.dataTransfer)&&(t(r)||(e=Math.max(0,e-1),e===0&&n(!1)))},s=i=>{if(!Xr(i.dataTransfer))return;if(t(i)){e=0,n(!1);return}i.preventDefault(),e=0,n(!1);let a=Yr(Array.from(i.dataTransfer?.files??[])),{onFile:o,onError:s,onMultipleFiles:c}=r.current;switch(a.kind){case`ok`:o(a.file);break;case`ok-with-extras`:c?.(a.totalCount),o(a.file);break;case`unsupported`:s?.(`unsupported`)}},c=()=>{e=0,n(!1)},l=e=>{e.buttons===0&&c()};return window.addEventListener(`dragenter`,i),window.addEventListener(`dragover`,a),window.addEventListener(`dragleave`,o),window.addEventListener(`drop`,s),window.addEventListener(`drop`,c),window.addEventListener(`dragend`,c),window.addEventListener(`blur`,c),window.addEventListener(`pointerover`,l),()=>{window.removeEventListener(`dragenter`,i),window.removeEventListener(`dragover`,a),window.removeEventListener(`dragleave`,o),window.removeEventListener(`drop`,s),window.removeEventListener(`drop`,c),window.removeEventListener(`dragend`,c),window.removeEventListener(`blur`,c),window.removeEventListener(`pointerover`,l)}},[]),{isDragging:t}}function Qr(e){let t=(0,L.useRef)(null),n=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(!e)return;n.current=document.activeElement;let r=t.current;if(!r)return;let i=()=>{let e=r.querySelectorAll(`a[href], button:not([disabled]), textarea:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])`);return Array.from(e).filter(e=>e.tabIndex>=0&&!e.hasAttribute(`aria-hidden`)&&e.offsetParent!==null)},a=i()[0];a?a.focus():r.focus();let o=e=>{if(e.key!==`Tab`)return;let t=i();if(t.length===0){e.preventDefault();return}let n=t.indexOf(document.activeElement),r=t.length-1;e.shiftKey?n<=0&&(e.preventDefault(),t[r].focus()):(n===r||n===-1)&&(e.preventDefault(),t[0].focus())};return r.addEventListener(`keydown`,o),()=>{r.removeEventListener(`keydown`,o);let e=n.current;e&&typeof e.focus==`function`&&e.focus()}},[e]),t}var $r={backdrop:`_backdrop_1v1vb_1`,dialog:`_dialog_1v1vb_12`,header:`_header_1v1vb_29`,title:`_title_1v1vb_37`,closeButton:`_closeButton_1v1vb_49`,fileInfo:`_fileInfo_1v1vb_68`,fileName:`_fileName_1v1vb_74`,fileMeta:`_fileMeta_1v1vb_80`,metaTable:`_metaTable_1v1vb_86`,metaLabel:`_metaLabel_1v1vb_98`,metaValue:`_metaValue_1v1vb_108`,schemaBadge:`_schemaBadge_1v1vb_113`,legacy:`_legacy_1v1vb_123`,warning:`_warning_1v1vb_128`,warningIcon:`_warningIcon_1v1vb_142`,actions:`_actions_1v1vb_148`,button:`_button_1v1vb_154`,primary:`_primary_1v1vb_172`,warningConfirm:`_warningConfirm_1v1vb_181`};function ei(e){if(!e)return`—`;let t=new Date(e);return Number.isNaN(t.getTime())?e:`${t.getFullYear()}-${String(t.getMonth()+1).padStart(2,`0`)}-${String(t.getDate()).padStart(2,`0`)} ${String(t.getHours()).padStart(2,`0`)}:${String(t.getMinutes()).padStart(2,`0`)}`}function ti({metadata:e,showOverwriteWarning:t,currentEventCount:n,onConfirm:r,onCancel:i}){let a=Qr(!0);(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),i())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[i]);let o=e.schemaVersion===`legacy`?`legacy (pre-0.5.0)`:`v${e.schemaVersion}`,s=e.scenarioMatch?.state===`mismatch`,c=s?`Load anyway`:t?`Replace current simulation`:`Load`,l=[$r.button,s||t?$r.warningConfirm:$r.primary].join(` `);return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`load-preview-title`,onClick:i,className:$r.backdrop,children:(0,R.jsxs)(`div`,{ref:a,tabIndex:-1,onClick:e=>e.stopPropagation(),className:$r.dialog,children:[(0,R.jsxs)(`div`,{className:$r.header,children:[(0,R.jsx)(`h2`,{id:`load-preview-title`,className:$r.title,children:`Load simulation`}),(0,R.jsx)(`button`,{type:`button`,onClick:i,"aria-label":`Close load preview`,className:$r.closeButton,children:`×`})]}),e.fileName&&(0,R.jsxs)(`div`,{className:$r.fileInfo,children:[(0,R.jsx)(`div`,{className:$r.fileName,children:e.fileName}),(0,R.jsxs)(`div`,{className:$r.fileMeta,children:[e.fileSize,e.startedAt?` · saved ${ei(e.startedAt)}`:``]})]}),(0,R.jsxs)(`div`,{className:$r.metaTable,children:[(0,R.jsx)(`div`,{className:$r.metaLabel,children:`Scenario`}),(0,R.jsx)(`div`,{className:$r.metaValue,children:e.scenarioName}),(0,R.jsx)(`div`,{className:$r.metaLabel,children:`Actors`}),(0,R.jsx)(`div`,{className:$r.metaValue,children:(e.actorNames??[]).length>0?(e.actorNames??[]).join(` · `):`—`}),(0,R.jsx)(`div`,{className:$r.metaLabel,children:`Turns`}),(0,R.jsx)(`div`,{className:$r.metaValue,children:e.turnCount??`—`}),(0,R.jsx)(`div`,{className:$r.metaLabel,children:`Events`}),(0,R.jsx)(`div`,{className:$r.metaValue,children:e.eventCount}),(0,R.jsx)(`div`,{className:$r.metaLabel,children:`Schema`}),(0,R.jsx)(`div`,{className:$r.metaValue,children:(0,R.jsx)(`span`,{className:[$r.schemaBadge,e.schemaVersion===`legacy`?$r.legacy:``].filter(Boolean).join(` `),children:o})}),(0,R.jsx)(`div`,{className:$r.metaLabel,children:`Verdict`}),(0,R.jsx)(`div`,{className:$r.metaValue,children:e.hasVerdict?`yes`:`no`})]}),e.scenarioMatch?.state===`mismatch`&&(0,R.jsxs)(`div`,{role:`alert`,className:$r.warning,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:$r.warningIcon,children:`⚠`}),(0,R.jsxs)(`span`,{children:[`This file was saved under `,(0,R.jsx)(`strong`,{children:e.scenarioMatch.fileScenarioName}),`. Your dashboard's active scenario is `,(0,R.jsx)(`strong`,{children:e.scenarioMatch.currentScenarioName}),`. Labels, colors, and department names will not match. Switch scenario in Settings before loading for a clean render.`]})]}),t&&(0,R.jsxs)(`div`,{role:`alert`,className:$r.warning,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:$r.warningIcon,children:`⚠`}),(0,R.jsxs)(`span`,{children:[`This will replace the `,n,`-event run you're viewing.`]})]}),(0,R.jsxs)(`div`,{className:$r.actions,children:[(0,R.jsx)(`button`,{type:`button`,onClick:i,className:$r.button,autoFocus:t||s,children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,onClick:r,className:l,autoFocus:!t&&!s,children:c})]})]})})}function ni({host:e,onLoad:t,onCancel:n}){let r=Qr(!0);return(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),n())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[n]),(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`load-from-host-title`,"aria-describedby":`load-from-host-body`,onClick:n,className:$r.backdrop,children:(0,R.jsxs)(`div`,{ref:r,tabIndex:-1,onClick:e=>e.stopPropagation(),className:$r.dialog,children:[(0,R.jsx)(`div`,{className:$r.header,children:(0,R.jsx)(`h2`,{id:`load-from-host-title`,className:$r.title,children:`Load a run from another site?`})}),(0,R.jsxs)(`div`,{id:`load-from-host-body`,className:$r.fileInfo,children:[(0,R.jsxs)(`p`,{children:[`This link loads a saved run from `,(0,R.jsx)(`span`,{className:$r.fileName,children:e}),`, which is not this site. Nothing is fetched until you choose Load.`]}),(0,R.jsx)(`p`,{children:`Load it only if you trust where the link came from.`})]}),(0,R.jsxs)(`div`,{className:$r.actions,children:[(0,R.jsx)(`button`,{type:`button`,onClick:n,className:$r.button,autoFocus:!0,children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,onClick:t,className:[$r.button,$r.primary].join(` `),children:`Load`})]})]})})}var ri={overlay:`_overlay_pdhgc_1`,fadeIn:`_fadeIn_pdhgc_1`,card:`_card_pdhgc_15`,icon:`_icon_pdhgc_28`,heading:`_heading_pdhgc_35`,sub:`_sub_pdhgc_47`};function ii({active:e}){return e?(0,R.jsx)(`div`,{role:`status`,"aria-live":`polite`,"aria-label":`Drop zone active. Release to load a simulation file.`,className:ri.overlay,children:(0,R.jsxs)(`div`,{className:ri.card,children:[(0,R.jsx)(`div`,{"aria-hidden":`true`,className:ri.icon,children:`⬇`}),(0,R.jsx)(`p`,{className:ri.heading,children:`Drop to load`}),(0,R.jsx)(`p`,{className:ri.sub,children:`.json simulation`})]})}):null}var ai=(0,L.createContext)({toast:()=>{}});function oi(){return(0,L.useContext)(ai)}var si=0,ci={info:`var(--amber)`,error:`var(--rust)`,success:`var(--green)`,"crisis-a":`var(--vis, #e8b44a)`,"crisis-b":`var(--eng, #4ca8a8)`},li={info:`var(--amber)`,error:`var(--rust)`,success:`var(--green)`,"crisis-a":`var(--vis, #e8b44a)`,"crisis-b":`var(--eng, #4ca8a8)`},ui={info:`color-mix(in srgb, var(--amber) 8%, var(--bg-card))`,error:`color-mix(in srgb, var(--rust) 8%, var(--bg-card))`,success:`color-mix(in srgb, var(--green) 8%, var(--bg-card))`,"crisis-a":`color-mix(in srgb, var(--vis, #e8b44a) 8%, var(--bg-card))`,"crisis-b":`color-mix(in srgb, var(--eng, #4ca8a8) 8%, var(--bg-card))`};function di({children:e}){let[t,n]=(0,L.useState)([]),r=(0,L.useCallback)(e=>{n(t=>t.filter(t=>t.id!==e))},[]),i=(0,L.useCallback)((e,t,r,i)=>{let a=si++;n(n=>[...n,{id:a,type:e,title:t,message:r}]);let o=(()=>{let e=t.length+r.length;return Math.max(3e3,Math.min(15e3,2500+e*40))})();setTimeout(()=>{n(e=>e.filter(e=>e.id!==a))},i??o)},[]);return(0,R.jsxs)(ai.Provider,{value:{toast:i},children:[e,(0,R.jsx)(`div`,{role:`status`,"aria-label":`Notifications`,"aria-live":`polite`,"aria-atomic":`false`,"aria-relevant":`additions text`,style:{position:`fixed`,top:56,right:16,zIndex:1e5,display:`flex`,flexDirection:`column`,gap:8,pointerEvents:`none`,maxWidth:380},children:t.map(e=>(0,R.jsxs)(`div`,{style:{pointerEvents:`auto`,padding:`10px 14px`,borderRadius:8,fontSize:`var(--font-sm)`,background:ui[e.type],border:`1px solid ${ci[e.type]}`,borderLeft:`3px solid ${ci[e.type]}`,color:`var(--text-1)`,boxShadow:`var(--card-shadow, 0 4px 16px rgba(0,0,0,0.18))`,animation:`slideIn 0.3s ease`,position:`relative`},children:[(0,R.jsx)(`div`,{style:{fontWeight:700,fontSize:`var(--font-sm)`,marginBottom:2,color:li[e.type],paddingRight:16},children:e.title}),e.message&&(0,R.jsx)(`div`,{style:{fontSize:`var(--font-xs)`,color:`var(--text-2)`,lineHeight:1.5},children:e.message}),(0,R.jsx)(`button`,{onClick:()=>r(e.id),style:{position:`absolute`,top:4,right:8,background:`none`,border:`none`,color:`var(--text-3)`,cursor:`pointer`,fontSize:`var(--font-lg)`,lineHeight:1},"aria-label":`Dismiss`,children:`x`})]},e.id))})]})}var fi=`paracosm:seenForgeToasts`;function pi(e){let t=e.data;return`${e.leader||``}|${t?.name||``}|${t?.timestamp||``}|${t?.approved}`}var mi=`paracosm:forgeToasts`;function hi(){if(typeof window>`u`)return!1;try{return window.localStorage.getItem(mi)===`1`}catch{return!1}}function gi({events:e,replayDone:t,tourActive:n}){let r=hi(),i=(0,L.useCallback)(()=>{try{let e=sessionStorage.getItem(fi);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},[]),a=(0,L.useCallback)(e=>{try{sessionStorage.setItem(fi,JSON.stringify([...e].slice(-500)))}catch{}},[]),{toast:o}=oi(),s=(0,L.useRef)(null),c=(0,L.useRef)(new Set);(0,L.useEffect)(()=>{(n||t)&&(s.current===null||s.current>e.length)&&(s.current=e.length)},[t,e.length,n]),(0,L.useEffect)(()=>{if(!r)return;let l=i(),u=c.current,d=n||t?s.current??1/0:1/0,f=0;for(let t=0;t<e.length;t++){let n=e[t];if(n.type!==`forge_attempt`)continue;let r=pi(n);if(l.has(r)||u.has(r)||(l.add(r),t<d))continue;u.add(r);let i=n.data,a=String(i?.name||`unnamed tool`),s=String(i?.department||n.leader||``).toUpperCase(),c=i?.approved===!0,p=typeof i?.confidence==`number`?i.confidence:null,m=String(i?.errorReason||``).slice(0,220),h=f;f+=450,setTimeout(()=>{if(c){let e=p==null?``:` · conf ${p.toFixed(2)}`;o(`success`,`${s?`${s} · `:``}forged ${a}`,`Judge approved${e}`)}else o(`error`,`${s?`${s} · `:``}rejected ${a}`,m||`Judge rejected (no reason provided)`)},h)}a(l)},[r,e,o,t,n,i,a])}function _i(e,t,n){return e!==null&&Object.is(e.state,t)?e:{state:t,runKey:n}}function vi(e,t,n){return!e&&!t?``:`${t?`aborted`:`complete`}:${n}`}var yi=`paracosm:terminalToastFingerprint`,bi=`paracosm:verdictToastFingerprint`;function xi({runKey:e,isComplete:t,isAborted:n,abortReason:r,resultsCount:i,hasVerdict:a,replayDone:o,tourActive:s,userTriggeredRun:c,verdict:l}){let{toast:u}=oi(),d=(0,L.useRef)(null),f=(0,L.useRef)(null),p=vi(t,n,i),m=l??null;(0,L.useEffect)(()=>{d.current=_i(d.current,p,e),f.current=_i(f.current,m,e)},[p,m,e]),(0,L.useEffect)(()=>{if(s||!c||!t&&!n||!o)return;let l=(d.current?d.current.runKey:e)??(n?`aborted:${r?.reason??`unknown`}:${r?.leader??``}:${r?.turn??``}`:`complete:${i}:${a?`v`:`nv`}`);try{if(sessionStorage.getItem(yi)===l)return;sessionStorage.setItem(yi,l)}catch{}n?u(`info`,`Simulation ended early`,`Partial results saved. Reload to resume from the abort point.`):u(`success`,`Simulation complete`,`Open the Reports tab for the verdict + full breakdown.`)},[e,t,n,r,i,a,o,s,c,u]),(0,L.useEffect)(()=>{if(s||!c||!l||typeof l!=`object`||!o)return;let t=f.current?f.current.runKey:e;if(l.skipped===!0){let e=String(l.reason||`unknown`),n=t??`skipped:${e}`;try{if(sessionStorage.getItem(bi)===n)return;sessionStorage.setItem(bi,n)}catch{}u(`info`,`Run finished — no verdict`,(()=>{switch(e){case`generation_failed`:return`The verdict LLM call failed. Reports tab has the raw stats.`;case`cohort_too_large`:return`Cohort size exceeded the verdict cap. Reports tab has the breakdown.`;case`economics_skip`:return`Verdicts off in your economics profile. Reports tab has the run summary.`;default:return`Verdict unavailable for this run. See Reports for the breakdown.`}})());return}let n=l.winner;if(n==null)return;let r=String(n),i=String(l.headline||``).trim(),a=l.mode===`cohort`?`cohort`:`pair`,d=a===`cohort`?r:r===`tie`?`Tie`:String(l.winnerName||``).trim()||`Leader ${r}`,p=t??`${a}:${r}:${d}:${i}`;try{if(sessionStorage.getItem(bi)===p)return;sessionStorage.setItem(bi,p)}catch{}let m=r===`tie`,h=a===`cohort`?m?`Cohort tied`:`${d} leads the cohort`:m?`Verdict: tie`:`${d} wins`;u(`success`,h,i||`Click the verdict banner for the full breakdown.`)},[e,l,o,s,c,u])}var Si=`paracosm:simSavedToastFingerprint`;function Ci({events:e,tourActive:t,userTriggeredRun:n}){let{toast:r}=oi();(0,L.useEffect)(()=>{if(t||!n)return;let i=e.find(e=>e.type===`sim_saved`);if(!i)return;let a=i.data??{},o=String(a.status??`unknown`),s=`sim_saved:${o}:${a.id??``}:${a.reason??``}`;try{if(sessionStorage.getItem(Si)===s)return;sessionStorage.setItem(Si,s)}catch{}if(o===`saved`){let e=typeof a.id==`string`?a.id.slice(0,8):`run`;r(`success`,`Saved to cache`,`Run ${e}… stored. Open LOAD to replay.`)}else if(o===`failed`)r(`error`,`Cache save failed`,String(a.error??`Unknown error`));else if(o===`skipped`){let e=String(a.reason??`unknown`);e!==`below_min_turns`&&r(`info`,`Not cached`,`Skipped: ${e.replace(/_/g,` `)}.`)}},[e,t,n,r])}var wi=3e3;function Ti(){let[e,t]=(0,L.useState)(null),n=(0,L.useRef)(0),r=(0,L.useRef)(null),i=()=>{r.current!==null&&(window.clearTimeout(r.current),r.current=null)};return(0,L.useEffect)(()=>i,[]),{shared:e,share:(0,L.useCallback)(e=>{let a=++n.current;i();let o=r=>{n.current===a&&(r!==`unanswered`&&i(),t({url:e,state:r}))};t({url:e,state:`copying`});let s=typeof navigator<`u`?navigator.clipboard:void 0;if(!s||typeof s.writeText!=`function`){o(`refused`);return}r.current=window.setTimeout(()=>{r.current=null,t(t=>n.current===a&&t?.state===`copying`?{url:e,state:`unanswered`}:t)},wi);let c;try{c=s.writeText(e)}catch{o(`refused`);return}c.then(()=>o(`copied`),()=>o(`refused`))},[]),clear:(0,L.useCallback)(()=>{n.current+=1,i(),t(null)},[])}}var Ei={note:`_note_mhqal_1`,label:`_label_mhqal_23`,field:`_field_mhqal_28`,result:`_result_mhqal_40`,who:`_who_mhqal_45`,close:`_close_mhqal_50`},Di={copying:`Copying the link…`,copied:`Link copied.`,refused:`The browser refused to copy the link. Select the link and copy it.`,unanswered:`The browser did not copy the link. Select the link and copy it.`},Oi=`Anyone who has this link and can reach this dashboard can watch this run.`,ki=`This link opens only on this computer: the dashboard is served at a local address.`,Ai=`For teachers: run a simulation yourself and show it to your class, or share its replay link. A replay only plays back a finished run, and sends nothing new to an AI model. A student who starts their own run must be 13 or over and have a parent's or guardian's permission.`;function ji({shared:e,onClose:t}){let n=(0,L.useId)();return(0,R.jsxs)(`div`,{role:`status`,"aria-label":`Share link`,className:Ei.note,"data-state":e.state,children:[(0,R.jsx)(`label`,{htmlFor:n,className:Ei.label,children:`Link to this run`}),(0,R.jsx)(`input`,{id:n,className:Ei.field,type:`text`,readOnly:!0,value:e.url,onFocus:e=>e.currentTarget.select()}),(0,R.jsx)(`p`,{className:Ei.result,children:Di[e.state]}),(0,R.jsx)(`p`,{className:Ei.who,children:Jr(e.url)?ki:Oi}),(0,R.jsx)(`p`,{className:Ei.who,children:Ai}),(0,R.jsx)(`button`,{type:`button`,className:Ei.close,onClick:t,children:`Close`})]})}function Mi({launching:e,setLaunching:t,isRunning:n,isComplete:r,sseStatus:i,eventsCount:a}){let{toast:o}=oi();(0,L.useEffect)(()=>{e&&(n||r||i===`error`)&&t(!1)},[e,n,r,i,t]),(0,L.useEffect)(()=>{if(!e)try{window.localStorage.getItem(`paracosm:launchPending`)===`1`&&window.localStorage.removeItem(`paracosm:launchPending`)}catch{}},[e]),(0,L.useEffect)(()=>{if(!e)return;let i=setTimeout(()=>{t(!1),a>0||n||r||o(`error`,`Launch Stalled`,`No events received within 30 seconds. The simulation may still complete in the background.`)},3e4);return()=>clearTimeout(i)},[e,o,a,r,n,t])}var Ni={banner:`_banner_wkevp_2`,fadeUp:`_fadeUp_wkevp_1`,bannerSkipped:`_bannerSkipped_wkevp_17`,winnerNameSkipped:`_winnerNameSkipped_wkevp_24`,winnerLabel:`_winnerLabel_wkevp_29`,kicker:`_kicker_wkevp_34`,winnerName:`_winnerName_wkevp_24`,headlineColumn:`_headlineColumn_wkevp_53`,headlineButton:`_headlineButton_wkevp_60`,headlineStatic:`_headlineStatic_wkevp_78`,turnLabel:`_turnLabel_wkevp_92`,viewButton:`_viewButton_wkevp_100`,reportsChip:`_reportsChip_wkevp_117`,dismissButton:`_dismissButton_wkevp_133`};function Pi(e){return e===`A`?`var(--vis)`:e===`B`?`var(--eng)`:`var(--amber)`}function Fi(e){return{"--win-color":e,"--win-color-translucent":`color-mix(in srgb, ${e} 14%, transparent)`,"--win-color-faint":`color-mix(in srgb, ${e} 22%, transparent)`,"--win-color-border":`color-mix(in srgb, ${e} 36%, transparent)`,"--win-color-glow":`color-mix(in srgb, ${e} 42%, transparent)`}}function Ii({verdict:e,currentTurn:t,maxTurns:n,dismissedKey:r,onOpenModal:i,onDismiss:a,onNavigateTab:o}){if(!e)return null;if(e.skipped){let i=String(e.reason||`unknown`),s=(()=>{switch(i){case`generation_failed`:return`Verdict LLM call failed — open Reports for the raw run stats.`;case`cohort_too_large`:return`Cohort exceeded the verdict cap (${e.actorCount}/${e.max} actors). Open Reports for the cohort breakdown.`;case`economics_skip`:return`Verdict generation off in your economics profile. Reports tab carries the run summary.`;default:return`Verdict unavailable. Open Reports for the run breakdown.`}})(),c=`skipped|${i}`;return r===c?null:(0,R.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-label":`Verdict unavailable`,className:`${Ni.banner} ${Ni.bannerSkipped}`,style:Fi(`var(--text-3)`),children:[(0,R.jsxs)(`div`,{className:Ni.winnerLabel,children:[(0,R.jsx)(`div`,{className:Ni.kicker,children:`Run complete`}),(0,R.jsx)(`div`,{className:`${Ni.winnerName} ${Ni.winnerNameSkipped}`,children:`No verdict`})]}),(0,R.jsxs)(`div`,{className:Ni.headlineColumn,children:[(0,R.jsx)(`p`,{className:Ni.headlineStatic,children:s}),(0,R.jsxs)(`div`,{className:Ni.turnLabel,children:[`Turn `,t,`/`,n]})]}),(0,R.jsx)(`button`,{onClick:()=>o(`reports`),className:Ni.reportsChip,title:`Open the Reports tab for the full run breakdown`,children:`Reports`}),(0,R.jsx)(`button`,{onClick:()=>a(c),"aria-label":`Dismiss banner`,className:Ni.dismissButton,children:`×`})]})}if(!e.winner)return null;let s=String(e.headline||``),c=`${e.winner}|${s}`;if(r===c)return null;let l=e.mode===`cohort`?`cohort`:`pair`,u,d,f;if(l===`cohort`){u=Xn(typeof e.winnerIndex==`number`?e.winnerIndex:0);let t=Array.isArray(e.actors)?e.actors.length:0;d=`${String(e.winner)} leads`,f=t>0?`★ Cohort of ${t} complete`:`★ Cohort run complete`}else{let t=e.winner;u=Pi(t),d=t===`tie`?`Tie`:`${String(e.winnerName||`Winner`)} wins`,f=`★ Run Complete`}let p=`Turn ${t}/${n} · verdict by gpt-4o`;return(0,R.jsxs)(`div`,{role:`status`,"aria-live":`polite`,"aria-label":`Simulation verdict`,className:Ni.banner,style:Fi(u),children:[(0,R.jsxs)(`div`,{className:Ni.winnerLabel,children:[(0,R.jsx)(`div`,{className:Ni.kicker,children:f}),(0,R.jsx)(`div`,{className:Ni.winnerName,children:d})]}),(0,R.jsxs)(`div`,{className:Ni.headlineColumn,children:[(0,R.jsx)(`button`,{onClick:i,className:Ni.headlineButton,title:`Click to open the full verdict breakdown`,children:s||`Verdict delivered — click to see full breakdown.`}),(0,R.jsx)(`div`,{className:Ni.turnLabel,children:p})]}),(0,R.jsx)(`button`,{onClick:i,className:Ni.viewButton,children:`View Full Verdict →`}),(0,R.jsx)(`button`,{onClick:()=>o(`reports`),className:Ni.reportsChip,title:`Open the Reports tab for the full run breakdown`,children:`Reports`}),(0,R.jsx)(`button`,{onClick:()=>a(c),"aria-label":`Dismiss verdict banner`,className:Ni.dismissButton,children:`×`})]})}var Li={scoreBar:`_scoreBar_y24qu_1`,scoreBarLegend:`_scoreBarLegend_y24qu_5`,scoreBarLabel:`_scoreBarLabel_y24qu_14`,scoreBarTrack:`_scoreBarTrack_y24qu_19`,scoreBarLeftCol:`_scoreBarLeftCol_y24qu_25`,scoreBarRightCol:`_scoreBarRightCol_y24qu_31`,scoreBarFillLeft:`_scoreBarFillLeft_y24qu_35`,scoreBarFillRight:`_scoreBarFillRight_y24qu_42`,statRow:`_statRow_y24qu_49`,statValueA:`_statValueA_y24qu_58`,statValueB:`_statValueB_y24qu_63`,statLabel:`_statLabel_y24qu_68`,headerRow:`_headerRow_y24qu_73`,headerLeft:`_headerLeft_y24qu_80`,headerKicker:`_headerKicker_y24qu_84`,headerWinner:`_headerWinner_y24qu_93`,headerHeadline:`_headerHeadline_y24qu_101`,exportWrap:`_exportWrap_y24qu_107`,exportBtn:`_exportBtn_y24qu_112`,copied:`_copied_y24qu_125`,exportRefused:`_exportRefused_y24qu_130`,summary:`_summary_y24qu_139`,divergenceBox:`_divergenceBox_y24qu_146`,divergenceLabel:`_divergenceLabel_y24qu_155`,divergenceBody:`_divergenceBody_y24qu_163`,matchupRow:`_matchupRow_y24qu_169`,matchupSide:`_matchupSide_y24qu_176`,matchupNameA:`_matchupNameA_y24qu_180`,matchupNameB:`_matchupNameB_y24qu_187`,matchupArchetype:`_matchupArchetype_y24qu_194`,matchupVs:`_matchupVs_y24qu_199`,scoreBarsWrap:`_scoreBarsWrap_y24qu_206`,finalStats:`_finalStats_y24qu_211`,finalStatsLabel:`_finalStatsLabel_y24qu_218`,panel:`_panel_y24qu_228`,panelClose:`_panelClose_y24qu_239`,panelCollapsed:`_panelCollapsed_y24qu_264`,panelCollapsedDot:`_panelCollapsedDot_y24qu_288`,panelCollapsedText:`_panelCollapsedText_y24qu_296`,panelCollapsedHint:`_panelCollapsedHint_y24qu_302`,banner:`_banner_y24qu_307`,bannerKicker:`_bannerKicker_y24qu_324`,bannerWinner:`_bannerWinner_y24qu_333`,bannerHeadline:`_bannerHeadline_y24qu_339`,bannerCta:`_bannerCta_y24qu_349`,modalBackdrop:`_modalBackdrop_y24qu_361`,modalDialog:`_modalDialog_y24qu_372`,modalCloseAnchor:`_modalCloseAnchor_y24qu_387`,modalCloseBtn:`_modalCloseBtn_y24qu_391`};function Ri(e){let t=e?.metrics;if(!Array.isArray(t)||t.length===0)return null;let n=t.filter(e=>typeof e==`object`&&!!e&&typeof e.id==`string`);return n.length>0?n:null}function zi(e){return e.unit?`${e.label} (${e.unit})`:e.label}function Bi(e,t,n){if(typeof e!=`number`||!Number.isFinite(e))return`n/a`;if(t===`percent`)return`${Math.round(e*1e3)/10}%`;let r=Vi(e);return t===`currency`&&n?`${r} ${n}`:r}function Vi(e){if(Number.isInteger(e))return String(e);let t=Math.abs(e);return t>=100?String(Math.round(e)):t>=10?e.toFixed(1):t>=.1?e.toFixed(2):e.toFixed(3)}function Hi(e,t,n){if(typeof e!=`number`||typeof t!=`number`||e===t)return null;let r=e>t;return(n===`lower`?!r:r)?`a`:`b`}function Ui(e){return`FINAL ${(typeof e==`string`&&e.trim()?e.trim():`colony`).toUpperCase()} STATS`}function Wi({label:e,a:t,b:n}){let r=`${Math.min(100,t/10*100)}%`,i=`${Math.min(100,n/10*100)}%`;return(0,R.jsxs)(`div`,{className:Li.scoreBar,children:[(0,R.jsxs)(`div`,{className:Li.scoreBarLegend,children:[(0,R.jsx)(`span`,{children:t.toFixed(0)}),(0,R.jsx)(`span`,{className:Li.scoreBarLabel,children:e}),(0,R.jsx)(`span`,{children:n.toFixed(0)})]}),(0,R.jsxs)(`div`,{className:Li.scoreBarTrack,children:[(0,R.jsx)(`div`,{className:Li.scoreBarLeftCol,children:(0,R.jsx)(`div`,{className:Li.scoreBarFillLeft,style:{"--bar-pct":r,"--bar-color":t>=n?`var(--vis)`:`var(--border-hl)`}})}),(0,R.jsx)(`div`,{className:Li.scoreBarRightCol,children:(0,R.jsx)(`div`,{className:Li.scoreBarFillRight,style:{"--bar-pct":i,"--bar-color":n>=t?`var(--eng)`:`var(--border-hl)`}})})]})]})}function Gi({label:e,a:t,b:n,format:r,scenarioFormat:i,currency:a,direction:o}){let s=e=>{if(i)return Bi(e,i,a);let t=e??0;return r===`percent`?`${Math.round(t*100)}%`:r===`decimal`?t.toFixed(1):String(Math.round(t))},c=Hi(t,n,o);return(0,R.jsxs)(`div`,{className:Li.statRow,children:[(0,R.jsx)(`span`,{className:Li.statValueA,style:{"--stat-color":c===`a`?`var(--vis)`:`var(--text-2)`,"--stat-weight":c===`a`?`700`:`400`},children:s(t)}),(0,R.jsx)(`span`,{className:Li.statLabel,children:e}),(0,R.jsx)(`span`,{className:Li.statValueB,style:{"--stat-color":c===`b`?`var(--eng)`:`var(--text-2)`,"--stat-weight":c===`b`?`700`:`400`},children:s(n)})]})}function Ki(e){let t=[];if(t.push(`# Simulation Verdict`),t.push(``),t.push(`**Winner:** ${e.winner===`tie`?`Tie`:`${e.winnerName} (Leader ${e.winner})`}`),t.push(``),t.push(`> ${e.headline}`),t.push(``),t.push(e.summary),t.push(``),t.push(`## Key Divergence`),t.push(``),t.push(e.keyDivergence),e.scores&&(t.push(``),t.push(`## Scores`),t.push(``),t.push(`| Dimension | `+(e.leaderA?.name||`A`)+` | `+(e.leaderB?.name||`B`)+` |`),t.push(`|---|---|---|`),t.push(`| Survival | ${e.scores.a?.survival??0} | ${e.scores.b?.survival??0} |`),t.push(`| Prosperity | ${e.scores.a?.prosperity??0} | ${e.scores.b?.prosperity??0} |`),t.push(`| Morale | ${e.scores.a?.morale??0} | ${e.scores.b?.morale??0} |`),t.push(`| Innovation | ${e.scores.a?.innovation??0} | ${e.scores.b?.innovation??0} |`)),e.finalStats){let n=Ri(e.finalStats),r=Ui(e.settlementNoun).toLowerCase().replace(/(^|\s)\S/g,e=>e.toUpperCase());if(t.push(``),t.push(`## ${r}`),t.push(``),t.push(`| Stat | `+(e.leaderA?.name||`A`)+` | `+(e.leaderB?.name||`B`)+` |`),t.push(`|---|---|---|`),n)for(let e of n)t.push(`| ${zi(e)} | ${Bi(e.a,e.format,e.currency)} | ${Bi(e.b,e.format,e.currency)} |`);else t.push(`| Population | ${e.finalStats.a?.population??0} | ${e.finalStats.b?.population??0} |`),t.push(`| Morale | ${Math.round((e.finalStats.a?.morale??0)*100)}% | ${Math.round((e.finalStats.b?.morale??0)*100)}% |`),t.push(`| Food (months) | ${(e.finalStats.a?.food??0).toFixed(1)} | ${(e.finalStats.b?.food??0).toFixed(1)} |`),t.push(`| Power (kW) | ${(e.finalStats.a?.power??0).toFixed(1)} | ${(e.finalStats.b?.power??0).toFixed(1)} |`),t.push(`| Modules | ${(e.finalStats.a?.modules??0).toFixed(1)} | ${(e.finalStats.b?.modules??0).toFixed(1)} |`),t.push(`| Science | ${e.finalStats.a?.science??0} | ${e.finalStats.b?.science??0} |`);t.push(`| Tools Forged | ${e.finalStats.a?.tools??0} | ${e.finalStats.b?.tools??0} |`)}return t.push(``),t.push(`---`),t.push(`Generated by [Paracosm](https://paracosm.agentos.sh)`),t.join(`
|
|
10
|
+
`)}function qi(e){return e===`A`?`var(--vis)`:e===`B`?`var(--eng)`:`var(--amber)`}var Ji=1800;function Yi(e,t){let[n,r]=(0,L.useState)(null),i=(0,L.useRef)(0),a=(0,L.useRef)(null),o=()=>{a.current!==null&&(window.clearTimeout(a.current),a.current=null)},s=(0,L.useMemo)(()=>JSON.stringify(e),[e]);(0,L.useEffect)(()=>(i.current+=1,o(),r(null),o),[s,t]);let c=(0,L.useCallback)(()=>{let t=++i.current;o(),r(null),Gr(Ki(e)).then(()=>{i.current===t&&(r(`copied`),a.current=window.setTimeout(()=>{a.current=null,i.current===t&&r(null)},Ji))},()=>{i.current===t&&r(`refused`)})},[e]);return{copied:n===`copied`,notCopied:n===`refused`,exportVerdict:c}}function Xi({v:e,onExport:t,copied:n,notCopied:r}){let i=qi(e.winner);return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:Li.headerRow,children:[(0,R.jsxs)(`div`,{className:Li.headerLeft,children:[(0,R.jsx)(`div`,{className:Li.headerKicker,children:`SIMULATION VERDICT`}),(0,R.jsx)(`div`,{className:Li.headerWinner,style:{"--win-color":i},children:e.winner===`tie`?`TIE`:`${e.winnerName} WINS`}),(0,R.jsx)(`div`,{className:Li.headerHeadline,children:e.headline})]}),t&&(0,R.jsx)(`div`,{className:Li.exportWrap,children:(0,R.jsx)(`button`,{onClick:t,"aria-label":`Copy verdict as markdown`,className:[Li.exportBtn,n?Li.copied:``].filter(Boolean).join(` `),children:n?`COPIED ✓`:`EXPORT MD`})})]}),t&&(0,R.jsxs)(`div`,{role:`status`,"aria-label":`Verdict copy result`,children:[r&&(0,R.jsx)(`p`,{className:Li.exportRefused,children:`The browser refused to copy the verdict.`}),n&&(0,R.jsx)(`span`,{className:`sr-only`,children:`The verdict was copied as markdown.`})]}),(0,R.jsx)(`div`,{className:Li.summary,children:e.summary}),(0,R.jsxs)(`div`,{className:Li.divergenceBox,children:[(0,R.jsx)(`span`,{className:Li.divergenceLabel,children:`KEY DIVERGENCE`}),(0,R.jsx)(`div`,{className:Li.divergenceBody,children:e.keyDivergence})]}),(0,R.jsxs)(`div`,{className:Li.matchupRow,children:[(0,R.jsxs)(`div`,{className:Li.matchupSide,children:[(0,R.jsx)(`div`,{className:Li.matchupNameA,children:e.leaderA?.name||`Leader A`}),(0,R.jsx)(`div`,{className:Li.matchupArchetype,children:e.leaderA?.archetype})]}),(0,R.jsx)(`div`,{className:Li.matchupVs,children:`vs`}),(0,R.jsxs)(`div`,{className:Li.matchupSide,children:[(0,R.jsx)(`div`,{className:Li.matchupNameB,children:e.leaderB?.name||`Leader B`}),(0,R.jsx)(`div`,{className:Li.matchupArchetype,children:e.leaderB?.archetype})]})]}),(0,R.jsxs)(`div`,{className:Li.scoreBarsWrap,children:[(0,R.jsx)(Wi,{label:`Survival`,a:e.scores.a?.survival??0,b:e.scores.b?.survival??0}),(0,R.jsx)(Wi,{label:`Prosperity`,a:e.scores.a?.prosperity??0,b:e.scores.b?.prosperity??0}),(0,R.jsx)(Wi,{label:`Morale`,a:e.scores.a?.morale??0,b:e.scores.b?.morale??0}),(0,R.jsx)(Wi,{label:`Innovation`,a:e.scores.a?.innovation??0,b:e.scores.b?.innovation??0})]}),e.finalStats&&(0,R.jsxs)(`div`,{className:Li.finalStats,children:[(0,R.jsx)(`div`,{className:Li.finalStatsLabel,children:Ui(e.settlementNoun)}),Ri(e.finalStats)?.map(e=>(0,R.jsx)(Gi,{label:zi(e),a:e.a,b:e.b,scenarioFormat:e.format,currency:e.currency,direction:e.better},e.id))??(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Gi,{label:`Population`,a:e.finalStats.a?.population??0,b:e.finalStats.b?.population??0}),(0,R.jsx)(Gi,{label:`Morale`,a:e.finalStats.a?.morale??0,b:e.finalStats.b?.morale??0,format:`percent`}),(0,R.jsx)(Gi,{label:`Food (mo)`,a:e.finalStats.a?.food??0,b:e.finalStats.b?.food??0,format:`decimal`}),(0,R.jsx)(Gi,{label:`Power (kW)`,a:e.finalStats.a?.power??0,b:e.finalStats.b?.power??0,format:`decimal`}),(0,R.jsx)(Gi,{label:`Modules`,a:e.finalStats.a?.modules??0,b:e.finalStats.b?.modules??0,format:`decimal`}),(0,R.jsx)(Gi,{label:`Science`,a:e.finalStats.a?.science??0,b:e.finalStats.b?.science??0})]}),(0,R.jsx)(Gi,{label:`Tools Forged`,a:e.finalStats.a?.tools??0,b:e.finalStats.b?.tools??0})]})]})}function Zi({verdict:e,shownRun:t}){let n=e,{copied:r,notCopied:i,exportVerdict:a}=Yi(n,t),[o,s]=(0,L.useState)(!0);if(!n.winner)return null;let c=n.mode===`cohort`?`cohort`:`pair`;if(c===`pair`&&!n.scores||c===`cohort`&&!Array.isArray(n.rankings))return null;let l=c===`cohort`?Xn(typeof n.winnerIndex==`number`?n.winnerIndex:0):qi(n.winner);if(!o){let e=n.headline??(c===`cohort`?`${String(n.winner)} leads`:`${n.winner===`tie`?`Tied`:`${n.winner.toUpperCase()} wins`}`);return(0,R.jsxs)(`button`,{type:`button`,className:Li.panelCollapsed,style:{"--win-color":l},onClick:()=>s(!0),"aria-label":`Expand verdict`,children:[(0,R.jsx)(`span`,{className:Li.panelCollapsedDot,"aria-hidden":`true`}),(0,R.jsxs)(`span`,{className:Li.panelCollapsedText,children:[`Verdict: `,e]}),(0,R.jsx)(`span`,{className:Li.panelCollapsedHint,children:`(click to expand)`})]})}return(0,R.jsxs)(`div`,{className:Li.panel,style:{"--win-color":l},children:[(0,R.jsx)(`button`,{type:`button`,className:Li.panelClose,onClick:()=>s(!1),"aria-label":`Collapse verdict`,title:`Collapse verdict`,children:`×`}),c===`cohort`?(0,R.jsx)(ea,{v:n}):(0,R.jsx)(Xi,{v:n,onExport:a,copied:r,notCopied:i})]})}var Qi={backdrop:`_backdrop_1svz2_1`,dialog:`_dialog_1svz2_12`,winnerA:`_winnerA_1svz2_28`,winnerB:`_winnerB_1svz2_31`,winnerTie:`_winnerTie_1svz2_34`,closeButton:`_closeButton_1svz2_38`,cohortDialog:`_cohortDialog_1svz2_56`,cohortDetails:`_cohortDetails_1svz2_61`,cohortHeader:`_cohortHeader_1svz2_71`,cohortKicker:`_cohortKicker_1svz2_77`,cohortHeadline:`_cohortHeadline_1svz2_86`,cohortSummary:`_cohortSummary_1svz2_94`,cohortDivergence:`_cohortDivergence_1svz2_101`,cohortRankings:`_cohortRankings_1svz2_112`,cohortRankingEntry:`_cohortRankingEntry_1svz2_121`,cohortRankBadge:`_cohortRankBadge_1svz2_140`,cohortRankBody:`_cohortRankBody_1svz2_149`,cohortRankName:`_cohortRankName_1svz2_153`,cohortRankScores:`_cohortRankScores_1svz2_160`,cohortRankRationale:`_cohortRankRationale_1svz2_174`,cohortReasoning:`_cohortReasoning_1svz2_181`};function $i(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.actorName!=`string`||t.actorName.length===0||typeof t.actorIndex!=`number`||!Number.isFinite(t.actorIndex)||typeof t.rank!=`number`||!Number.isFinite(t.rank)||typeof t.rationale!=`string`||t.scores!=null&&typeof t.scores!=`object`)}function ea({v:e}){let t=String(e.headline||``),n=String(e.summary||``),r=String(e.keyDivergence||``),i=Array.isArray(e.rankings)?e.rankings.filter($i):[],a=String(e.reasoning||``),o=Math.max(1,Array.isArray(e.actors)?e.actors.length:i.length);return(0,R.jsxs)(`div`,{className:Qi.cohortDetails,children:[(0,R.jsxs)(`header`,{className:Qi.cohortHeader,children:[(0,R.jsxs)(`div`,{className:Qi.cohortKicker,children:[`★ Cohort of `,o,` · Verdict`]}),(0,R.jsx)(`h2`,{className:Qi.cohortHeadline,children:t}),n&&(0,R.jsx)(`p`,{className:Qi.cohortSummary,children:n}),r&&(0,R.jsxs)(`p`,{className:Qi.cohortDivergence,children:[(0,R.jsx)(`strong`,{children:`Key divergence:`}),` `,r]})]}),(0,R.jsx)(`ol`,{className:Qi.cohortRankings,children:i.slice().sort((e,t)=>(e.rank??999)-(t.rank??999)).map(e=>{let t=Xn(e.actorIndex);return(0,R.jsxs)(`li`,{className:Qi.cohortRankingEntry,style:{"--actor-color":t},children:[(0,R.jsxs)(`div`,{className:Qi.cohortRankBadge,children:[`#`,e.rank??`?`]}),(0,R.jsxs)(`div`,{className:Qi.cohortRankBody,children:[(0,R.jsx)(`div`,{className:Qi.cohortRankName,children:e.actorName}),(0,R.jsxs)(`div`,{className:Qi.cohortRankScores,children:[(0,R.jsxs)(`span`,{title:`Survival`,children:[`S `,e.scores?.survival??`?`]}),(0,R.jsxs)(`span`,{title:`Prosperity`,children:[`P `,e.scores?.prosperity??`?`]}),(0,R.jsxs)(`span`,{title:`Morale`,children:[`M `,e.scores?.morale??`?`]}),(0,R.jsxs)(`span`,{title:`Innovation`,children:[`I `,e.scores?.innovation??`?`]})]}),e.rationale&&(0,R.jsx)(`p`,{className:Qi.cohortRankRationale,children:e.rationale})]})]},`${e.rank??`unranked`}-${e.actorName}-${e.actorIndex}`)})}),a&&(0,R.jsxs)(`details`,{className:Qi.cohortReasoning,children:[(0,R.jsx)(`summary`,{children:`Full reasoning`}),(0,R.jsx)(`pre`,{children:a})]})]})}function ta({verdict:e,onClose:t}){let n=Qr(!0);if(e.skipped)return null;let r=e.mode===`cohort`?`cohort`:`pair`,i=e.winner,a=[Qi.dialog,r===`pair`&&i===`A`?Qi.winnerA:void 0,r===`pair`&&i===`B`?Qi.winnerB:void 0,r===`pair`&&i===`tie`?Qi.winnerTie:void 0,r===`cohort`?Qi.cohortDialog:void 0].filter(Boolean).join(` `);return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Simulation verdict full breakdown`,onClick:t,className:Qi.backdrop,children:(0,R.jsxs)(`div`,{ref:n,tabIndex:-1,onClick:e=>e.stopPropagation(),className:a,children:[(0,R.jsx)(`button`,{onClick:t,"aria-label":`Close verdict`,className:Qi.closeButton,children:`×`}),r===`cohort`?(0,R.jsx)(ea,{v:e}):(0,R.jsx)(Xi,{v:e})]})})}var na={banner:`_banner_16upe_1`,notFoundBanner:`_notFoundBanner_16upe_1`,activeBanner:`_activeBanner_16upe_1`,activeBannerHeadline:`_activeBannerHeadline_16upe_18`,activeBannerSubline:`_activeBannerSubline_16upe_24`,activeBannerCacheTag:`_activeBannerCacheTag_16upe_29`,activeBannerSeed:`_activeBannerSeed_16upe_34`,exitButton:`_exitButton_16upe_49`,returnButton:`_returnButton_16upe_67`,notFoundLabel:`_notFoundLabel_16upe_85`};function ra(e){return new Date(e).toLocaleString(void 0,{month:`short`,day:`numeric`,hour:`numeric`,minute:`2-digit`})}function ia(e,t=4){if(!e)return``;let n=e.leaders;return Array.isArray(n)&&n.length>=3?n.length<=t?n.join(`, `):`${n.slice(0,t).join(`, `)}, +${n.length-t} more`:e.leaderA&&e.leaderB?`${e.leaderA} vs ${e.leaderB}`:e.leaderA?e.leaderA:e.leaderB?e.leaderB:``}function aa({replaySessionId:e}){let[t,n]=(0,L.useState)(null);(0,L.useEffect)(()=>{let t=!1;return(async()=>{try{let r=await fetch(`/sessions/${encodeURIComponent(e)}`);if(!r.ok||t)return;let i=await r.json();!t&&i?.meta&&n(i.meta)}catch{}})(),()=>{t=!0}},[e]);let r=t?.title||t?.scenarioName||`saved run`,i=[];if(t){t.scenarioName&&i.push(t.scenarioName);let e=ia(t);e&&i.push(e),typeof t.turnCount==`number`&&t.turnCount>0&&i.push(`${t.turnCount} turns`),typeof t.totalCostUSD==`number`&&t.totalCostUSD>0&&i.push(`$${t.totalCostUSD.toFixed(2)}`),typeof t.eventCount==`number`&&t.eventCount>0&&i.push(`${t.eventCount} events`),t.createdAt&&i.push(ra(t.createdAt))}let a=t?.seedText?t.seedText.length>140?`${t.seedText.slice(0,140).trim()}…`:t.seedText.trim():null;return(0,R.jsxs)(`div`,{role:`status`,className:na.activeBanner,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{className:na.activeBannerHeadline,children:`REPLAYING`}),(0,R.jsxs)(`span`,{className:na.activeBannerSubline,children:[`· `,r]}),i.length>0&&(0,R.jsxs)(`span`,{className:na.activeBannerSubline,children:[` · `,i.join(` · `)]}),(0,R.jsx)(`span`,{className:na.activeBannerCacheTag,children:`· cached playback (no new LLM cost)`}),a&&(0,R.jsxs)(`span`,{className:na.activeBannerSeed,children:[`“`,a,`”`]})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let e=new URL(window.location.href);e.searchParams.delete(`replay`),window.history.pushState({},``,e.toString()),window.dispatchEvent(new PopStateEvent(`popstate`))},className:na.exitButton,children:`EXIT REPLAY`})]})}function oa({replaySessionId:e}){return(0,R.jsxs)(`div`,{role:`alert`,className:na.notFoundBanner,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{className:na.notFoundLabel,children:`REPLAY NOT FOUND`}),` `,`· The saved run `,(0,R.jsx)(`code`,{children:e}),` no longer exists. It may have been evicted from the 10-run cache, or the URL was mistyped.`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let e=new URL(window.location.href);e.searchParams.delete(`replay`),window.history.replaceState({},``,e.toString()),window.location.reload()},className:na.returnButton,children:`← Back to live mode`})]})}var sa={parent:void 0,branches:[]};function ca(e,t){switch(t.type){case`PARENT_COMPLETE`:return{...e,parent:t.artifact};case`PARENT_RESET`:return{parent:void 0,branches:[]};case`SET_PARENT`:return{parent:t.artifact,branches:[]};case`BRANCH_OPTIMISTIC`:return{...e,branches:[...e.branches,{localId:t.localId,forkedAtTurn:t.forkedAtTurn,actorName:t.actorName,actorArchetype:t.actorArchetype,status:`running`,currentTurn:t.forkedAtTurn}]};case`BRANCH_TURN_PROGRESS`:return{...e,branches:e.branches.map(e=>e.localId===t.localId?{...e,currentTurn:t.currentTurn}:e)};case`BRANCH_COMPLETE`:{let n=(t.artifact.metadata.forkedFrom?.atTurn??0)+(t.artifact.trajectory?.timepoints?.length??0);return{...e,branches:e.branches.map(e=>e.localId===t.localId?{...e,status:`complete`,artifact:t.artifact,currentTurn:n}:e)}}case`BRANCH_ABORTED`:return{...e,branches:e.branches.map(e=>e.localId===t.localId?{...e,status:`aborted`}:e)};case`BRANCH_ERROR`:return{...e,branches:e.branches.map(e=>e.localId===t.localId?{...e,status:`error`,errorMessage:t.message}:e)};default:return e}}var la=(0,L.createContext)(null);function ua({children:e}){let[t,n]=(0,L.useReducer)(ca,sa);return(0,R.jsx)(la.Provider,{value:{state:t,dispatch:n},children:e})}function da(){let e=(0,L.useContext)(la);if(!e)throw Error(`useBranchesContext must be used within BranchesProvider`);return e}function fa({sse:e}){let{state:t,dispatch:n}=da(),r=(0,L.useRef)(-1),i=(0,L.useRef)(0),a=(0,L.useRef)(!1),o=(0,L.useRef)({});return(0,L.useEffect)(()=>{e.events.length===0&&e.results.length===0&&(t.parent||t.branches.length>0)&&(r.current=-1,i.current=0,a.current=!1,o.current={},n({type:`PARENT_RESET`}))},[e.events.length,e.results.length,t.parent,t.branches.length,n]),(0,L.useEffect)(()=>{let i=e.results;if(!(i.length-1<=r.current)){for(let e=r.current+1;e<i.length;e++){let r=i[e];if(r.artifact){if(r.forkedFrom){let e=t.branches.find(e=>e.status===`running`&&e.forkedAtTurn===r.forkedFrom.atTurn);e&&n({type:`BRANCH_COMPLETE`,localId:e.localId,artifact:r.artifact})}else t.parent||n({type:`PARENT_COMPLETE`,artifact:r.artifact})}}r.current=i.length-1}},[e.results,t.branches,t.parent,n]),(0,L.useEffect)(()=>{let r=t.branches.find(e=>e.status===`running`);if(!r)return;let i=0;for(let t of e.events)if(t.type===`turn_done`||t.type===`turn_start`){let e=t.data?.turn;typeof e==`number`&&e>i&&(i=e)}i>(o.current[r.localId]??0)&&(o.current[r.localId]=i,i>r.currentTurn&&n({type:`BRANCH_TURN_PROGRESS`,localId:r.localId,currentTurn:i}))},[e.events,t.branches,n]),(0,L.useEffect)(()=>{let r=t.branches.find(e=>e.status===`running`);r?(e.isAborted&&!a.current&&n({type:`BRANCH_ABORTED`,localId:r.localId}),e.errors.length>i.current&&n({type:`BRANCH_ERROR`,localId:r.localId,message:e.errors[e.errors.length-1]}),a.current=e.isAborted,i.current=e.errors.length):(a.current=e.isAborted,i.current=e.errors.length)},[e.isAborted,e.errors,t.branches,n]),null}var pa={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`},ma=24;function ha(){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`))||ma,offset:Number(e.get(`offset`))||0}}var ga=[`q`,`mode`,`scenario`,`leader`,`limit`,`offset`];function _a(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 va(){let[e,t]=L.useState(ha),[n,r]=L.useState([]),[i,a]=L.useState(0),[o,s]=L.useState(!1),[c,l]=L.useState(!1),[u,d]=L.useState(null),[f,p]=L.useState(0);return L.useEffect(()=>{if(typeof fetch>`u`)return;let t=new AbortController;return l(!0),d(null),fetch(`/api/v1/runs?`+_a(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,f]),{filters:e,setFilters:L.useCallback(e=>{t(e);let n=_a({...e,limit:e.limit??ma,offset:e.offset??0}),r=new URL(window.location.href);for(let e of ga)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:()=>p(e=>e+1)}}var ya=`paracosm-library-recent`,ba=5;function xa(){let[e,t]=L.useState(()=>{if(typeof window>`u`)return[];try{let e=window.localStorage.getItem(ya);return e?JSON.parse(e):[]}catch{return[]}});return L.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(ya):window.localStorage.setItem(ya,JSON.stringify(t))}catch{}return t})})(),()=>{n=!0}},[]),{records:e,push:L.useCallback(e=>{t(t=>{let n=[e,...t.filter(t=>t.runId!==e.runId)].slice(0,ba);try{window.localStorage.setItem(ya,JSON.stringify(n))}catch{}return n})},[]),remove:L.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(ya):window.localStorage.setItem(ya,JSON.stringify(n))}catch{}return n})},[]),clear:L.useCallback(()=>{t([]);try{window.localStorage.removeItem(ya)}catch{}},[])}}function Sa(e){let{enabled:t,cardSelector:n,searchInputRef:r,onOpenFocused:i,onClose:a}=e;L.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(),Ca(n,1);else if(e.key===`k`||e.key===`ArrowUp`)e.preventDefault(),Ca(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 Ca(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 wa={searchBar:`_searchBar_1bd6o_1`,icon:`_icon_1bd6o_15`,input:`_input_1bd6o_20`,kbd:`_kbd_1bd6o_36`};function Ta(e){let{value:t,onChange:n,inputRef:r}=e;return(0,R.jsxs)(`div`,{className:wa.searchBar,children:[(0,R.jsx)(`span`,{className:wa.icon,"aria-hidden":`true`,children:`⌕`}),(0,R.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:wa.input}),(0,R.jsx)(`kbd`,{className:wa.kbd,children:`⌘K`})]})}var Ea={row:`_row_1q7yx_1`,chip:`_chip_1q7yx_8`,chipRemove:`_chipRemove_1q7yx_23`},Da={wrapper:`_wrapper_aushb_1`,addBtn:`_addBtn_aushb_6`,popover:`_popover_aushb_24`,section:`_section_aushb_42`};function Oa(e){let{currentFilters:t,onAdd:n,scenarioOptions:r,leaderOptions:i}=e,[a,o]=L.useState(!1),s=L.useRef(null);return L.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,R.jsxs)(`div`,{className:Da.wrapper,ref:s,children:[(0,R.jsx)(`button`,{onClick:()=>o(e=>!e),className:Da.addBtn,"aria-expanded":a,children:`+ Filter`}),a&&(0,R.jsxs)(`div`,{className:Da.popover,role:`dialog`,"aria-label":`Add filter`,children:[!t.mode&&(0,R.jsxs)(`fieldset`,{className:Da.section,children:[(0,R.jsx)(`legend`,{children:`Mode`}),(0,R.jsx)(`button`,{onClick:()=>{n({mode:`turn-loop`}),o(!1)},children:`turn-loop`}),(0,R.jsx)(`button`,{onClick:()=>{n({mode:`batch-trajectory`}),o(!1)},children:`batch-trajectory`}),(0,R.jsx)(`button`,{onClick:()=>{n({mode:`batch-point`}),o(!1)},children:`batch-point`})]}),!t.scenarioId&&r.length>0&&(0,R.jsxs)(`fieldset`,{className:Da.section,children:[(0,R.jsx)(`legend`,{children:`Scenario`}),r.map(e=>(0,R.jsx)(`button`,{onClick:()=>{n({scenarioId:e.id}),o(!1)},children:e.name},e.id))]}),!t.actorConfigHash&&i.length>0&&(0,R.jsxs)(`fieldset`,{className:Da.section,children:[(0,R.jsx)(`legend`,{children:`Leader`}),i.map(e=>(0,R.jsx)(`button`,{onClick:()=>{n({actorConfigHash:e.hash}),o(!1)},children:e.label},e.hash))]})]})]})}function ka(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,R.jsxs)(`div`,{className:Ea.row,children:[t.mode&&(0,R.jsx)(Aa,{label:`mode: ${t.mode}`,onRemove:()=>a(`mode`)}),t.scenarioId&&(0,R.jsx)(Aa,{label:`scenario: ${t.scenarioId}`,onRemove:()=>a(`scenarioId`)}),t.actorConfigHash&&(0,R.jsx)(Aa,{label:`leader: ${t.actorConfigHash.slice(0,16)}…`,onRemove:()=>a(`actorConfigHash`)}),(0,R.jsx)(Oa,{currentFilters:t,onAdd:e=>n({...t,...e,offset:0}),scenarioOptions:r,leaderOptions:i})]})}function Aa(e){return(0,R.jsxs)(`span`,{className:Ea.chip,children:[e.label,(0,R.jsx)(`button`,{onClick:e.onRemove,"aria-label":`Remove ${e.label}`,className:Ea.chipRemove,children:`×`})]})}var ja={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 Ma(e={},t=0){let[n,r]=L.useState(null),[i,a]=L.useState(!1),[o,s]=L.useState(null),c=JSON.stringify(e),l=L.useRef(c);return L.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 Na=e=>e>=1e3?`$${(e/1e3).toFixed(1)}K`:`$${e.toFixed(2)}`,Pa=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 Fa(e){let{stats:t,loading:n,error:r}=Ma(e.filters,e.refreshKey);if(n&&!t)return(0,R.jsx)(`div`,{className:ja.strip,children:Array.from({length:5}).map((e,t)=>(0,R.jsx)(`div`,{className:ja.skeleton},t))});if(r||!t)return(0,R.jsx)(`div`,{className:ja.strip,children:(0,R.jsxs)(`div`,{className:ja.error,children:[`Stats unavailable: `,r??`unknown`]})});let i=t.replaysAttempted>0?Math.round(t.replaysMatched/t.replaysAttempted*100):null,a=i===null?ja.neutral:i>=95?ja.ok:i>=80?ja.warn:ja.critical;return(0,R.jsxs)(`div`,{className:ja.strip,children:[(0,R.jsx)(Ia,{label:`Runs`,value:String(t.totalRuns)}),(0,R.jsx)(Ia,{label:`Spent`,value:Na(t.totalCostUSD)}),(0,R.jsx)(Ia,{label:`Avg / run`,value:Na(t.totalCostUSD/Math.max(t.totalRuns,1))}),(0,R.jsx)(Ia,{label:`Total time`,value:Pa(t.totalDurationMs)}),(0,R.jsx)(Ia,{label:`Replay match`,value:i===null?`n/a`:`${i}%`,valueClassName:a})]})}function Ia(e){return(0,R.jsxs)(`div`,{className:ja.stat,children:[(0,R.jsx)(`span`,{className:ja.statLabel,children:e.label}),(0,R.jsx)(`span`,{className:[ja.statValue,e.valueClassName??``].filter(Boolean).join(` `),children:e.value})]})}var La={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 Ra(e){let{records:t}=xa(),[n,r]=L.useState(!0);return t.length===0?null:(0,R.jsxs)(`section`,{className:La.strip,children:[(0,R.jsxs)(`header`,{className:La.head,children:[(0,R.jsx)(`span`,{className:La.title,children:`Recently viewed`}),(0,R.jsx)(`button`,{className:La.toggle,onClick:()=>r(e=>!e),"aria-expanded":n,"aria-label":n?`Collapse recently viewed`:`Expand recently viewed`,children:n?`−`:`+`})]}),n&&(0,R.jsx)(`div`,{className:La.row,children:t.map(t=>(0,R.jsx)(za,{record:t,onClick:()=>e.onSelect(t.runId)},t.runId))})]})}function za(e){let{record:t,onClick:n}=e;return(0,R.jsxs)(`button`,{className:La.card,onClick:n,children:[(0,R.jsx)(`span`,{className:La.cardScenario,children:t.scenarioId}),(0,R.jsx)(`span`,{className:La.cardLeader,children:t.actorName??`Unknown leader`}),(0,R.jsx)(`span`,{className:La.cardMode,"data-mode":t.mode??`unknown`,children:t.mode??`unknown`})]})}var Ba={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`},Va={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 Ha(e){let{record:t,onOpen:n,onReplay:r,variant:i=`gallery`}=e,a=Ti(),o=!!t.sessionId;return(0,R.jsxs)(`article`,{className:[Va.card,i===`compact`?Va.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,R.jsxs)(`header`,{className:Va.head,children:[(0,R.jsx)(`span`,{className:Va.modeBadge,"data-mode":t.mode??`unknown`,children:t.mode??`unknown`}),(0,R.jsx)(`span`,{className:Va.cost,children:t.costUSD==null?`-`:`$${t.costUSD.toFixed(2)}`}),(0,R.jsx)(`span`,{className:Va.time,children:Ua(t.createdAt)})]}),(0,R.jsx)(`h3`,{className:Va.scenario,children:t.scenarioId}),(0,R.jsxs)(`p`,{className:Va.leader,children:[t.actorName??`Unknown`,t.actorArchetype?` · ${t.actorArchetype}`:``]}),(0,R.jsxs)(`div`,{className:Va.actions,children:[(0,R.jsx)(`button`,{onClick:e=>{e.stopPropagation(),n()},className:Va.actionBtn,children:`Open`}),(0,R.jsx)(`button`,{onClick:e=>{e.stopPropagation(),r()},className:Va.actionBtn,"aria-label":`Replay`,children:`Replay`}),o&&(0,R.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t.sessionId&&a.share(Kr(window.location.origin,t.sessionId,`viz`))},className:Va.actionBtn,"aria-label":`Copy a deep link that opens this run on the visualization tab`,title:`Copy viz share link`,children:`Share`})]}),a.shared&&(0,R.jsx)(`div`,{onClick:e=>e.stopPropagation(),children:(0,R.jsx)(ji,{shared:a.shared,onClose:a.clear})})]})}function Ua(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 Wa={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 Ga({entry:e,onOpen:t}){return(0,R.jsxs)(`article`,{className:Wa.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,R.jsxs)(`header`,{className:Wa.head,children:[(0,R.jsx)(`span`,{className:Wa.bundleBadge,children:`BUNDLE`}),(0,R.jsxs)(`span`,{className:Wa.count,children:[e.memberCount,` actors`]}),(0,R.jsx)(`span`,{className:Wa.cost,children:e.totalCostUSD>0?`$${e.totalCostUSD.toFixed(2)}`:`—`}),(0,R.jsx)(`span`,{className:Wa.time,children:Ka(e.earliestCreatedAt)})]}),(0,R.jsx)(`h3`,{className:Wa.scenario,children:e.scenarioId}),(0,R.jsxs)(`ul`,{className:Wa.actors,"aria-label":`Bundle members`,children:[e.members.filter(e=>e.actorName).slice(0,5).map(e=>(0,R.jsxs)(`li`,{className:Wa.actor,children:[e.actorName,e.actorArchetype?(0,R.jsxs)(`span`,{className:Wa.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,R.jsxs)(`li`,{className:Wa.more,children:[`+ `,t.length-5,` more`]}):t.length===0&&n>0?(0,R.jsxs)(`li`,{className:Wa.more,children:[n,` actor`,n===1?``:`s`,` · names not recorded`]}):null})()]}),(0,R.jsx)(`div`,{className:Wa.actions,children:(0,R.jsx)(`button`,{onClick:e=>{e.stopPropagation(),t()},className:Wa.actionBtn,children:`Compare`})})]})}function Ka(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 qa(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 Ja(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,f=Math.max(1,Math.ceil(n/u)),p=L.useMemo(()=>[...qa(t)].reverse(),[t]);return(0,R.jsxs)(`section`,{className:Ba.gallery,children:[(0,R.jsx)(`header`,{className:Ba.head,children:(0,R.jsxs)(`span`,{children:[`All runs · `,i?`loading…`:`${n} results`]})}),i&&t.length===0?(0,R.jsx)(`div`,{className:Ba.skeletonGrid,children:Array.from({length:8}).map((e,t)=>(0,R.jsx)(`div`,{className:Ba.cardSkeleton},t))}):(0,R.jsx)(`div`,{className:Ba.grid,children:p.map(e=>e.kind===`bundle`?(0,R.jsx)(Ga,{entry:e,onOpen:()=>s(e.bundleId)},`bundle:${e.bundleId}`):(0,R.jsx)(Ha,{record:e.record,onOpen:()=>a(e.record.runId),onReplay:()=>o(e.record.runId)},e.record.runId))}),(0,R.jsxs)(`footer`,{className:Ba.foot,children:[(0,R.jsx)(`button`,{disabled:l===0,onClick:()=>c(Math.max(0,l-u)),children:`‹ Prev`}),(0,R.jsxs)(`span`,{children:[`page `,d,` of `,f]}),(0,R.jsx)(`button`,{disabled:!r,onClick:()=>c(l+u),children:`Next ›`})]})]})}var Ya={wrapper:`_wrapper_qouu6_1`,table:`_table_qouu6_12`,modeCell:`_modeCell_qouu6_46`,actionsCell:`_actionsCell_qouu6_60`};function Xa(e){let{runs:t,onOpen:n,onReplay:r}=e;return(0,R.jsx)(`div`,{className:Ya.wrapper,role:`region`,"aria-label":`Runs table`,tabIndex:0,children:(0,R.jsxs)(`table`,{className:Ya.table,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{children:`Scenario`}),(0,R.jsx)(`th`,{children:`Mode`}),(0,R.jsx)(`th`,{children:`Leader`}),(0,R.jsx)(`th`,{children:`Cost`}),(0,R.jsx)(`th`,{children:`Time`}),(0,R.jsx)(`th`,{children:`Started`}),(0,R.jsx)(`th`,{"aria-label":`Actions`})]})}),(0,R.jsx)(`tbody`,{children:t.map(e=>(0,R.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,R.jsx)(`td`,{"data-label":`Scenario`,children:e.scenarioId}),(0,R.jsx)(`td`,{"data-label":`Mode`,children:(0,R.jsx)(`span`,{"data-mode":e.mode??`unknown`,className:Ya.modeCell,children:e.mode??`-`})}),(0,R.jsx)(`td`,{"data-label":`Leader`,children:e.actorName??`-`}),(0,R.jsx)(`td`,{"data-label":`Cost`,children:e.costUSD==null?`-`:`$${e.costUSD.toFixed(2)}`}),(0,R.jsx)(`td`,{"data-label":`Time`,children:e.durationMs==null?`-`:`${(e.durationMs/1e3).toFixed(0)}s`}),(0,R.jsx)(`td`,{"data-label":`Started`,children:e.createdAt.slice(0,19).replace(`T`,` `)}),(0,R.jsxs)(`td`,{"data-label":`Actions`,className:Ya.actionsCell,children:[(0,R.jsx)(`button`,{onClick:t=>{t.stopPropagation(),n(e.runId)},children:`Open`}),(0,R.jsx)(`button`,{onClick:t=>{t.stopPropagation(),r(e.runId)},"aria-label":`Replay`,children:`Replay`})]})]},e.runId))})]})})}var Za={backdrop:`_backdrop_mmfql_1`,fade:`_fade_mmfql_1`,drawer:`_drawer_mmfql_17`,open:`_open_mmfql_35`,head:`_head_mmfql_53`,closeBtn:`_closeBtn_mmfql_64`,body:`_body_mmfql_76`,placeholder:`_placeholder_mmfql_80`,error:`_error_mmfql_85`,summary:`_summary_mmfql_101`,modeBadge:`_modeBadge_mmfql_129`,meta:`_meta_mmfql_153`,detailBody:`_detailBody_mmfql_159`};function Qa(e){let[t,n]=L.useState({record:null,artifact:null,loading:!1,error:null,status:null});return L.useEffect(()=>{if(!e||typeof fetch>`u`){n({record:null,artifact:null,loading:!1,error:null,status:null});return}let t=new AbortController;return n(e=>({...e,loading:!0,error:null})),fetch(`/api/v1/runs/${encodeURIComponent(e)}`,{signal:t.signal}).then(async e=>{let t=await e.json().catch(()=>({}));e.ok?n({record:t.record,artifact:t.artifact,loading:!1,error:null,status:`ok`}):e.status===404?n({record:null,artifact:null,loading:!1,error:`Run not found`,status:`not_found`}):e.status===410?n({record:t.record??null,artifact:null,loading:!1,error:t.message??`Artifact unavailable`,status:t.error===`artifact_unavailable`?`unavailable`:`unreadable`}):n({record:null,artifact:null,loading:!1,error:`HTTP ${e.status}`,status:`error`})}).catch(e=>{e.name!==`AbortError`&&n({record:null,artifact:null,loading:!1,error:e.message,status:`error`})}),()=>t.abort()},[e]),t}var $a={panel:`_panel_1gtin_1`,replayBtn:`_replayBtn_1gtin_10`,result:`_result_1gtin_31`,match:`_match_1gtin_44`,diverged:`_diverged_1gtin_49`,errResult:`_errResult_1gtin_54`};function eo(e){let[t,n]=L.useState({kind:`idle`}),r=L.useRef(e);return r.current=e,{result:t,replay:L.useCallback(async e=>{n({kind:`inflight`});try{let t=e.metadata?.runId;if(!t){n({kind:`error`,error:`Artifact has no runId.`});return}let i=typeof fetch<`u`?await fetch(`/api/v1/runs/${encodeURIComponent(t)}/replay`,{method:`POST`}):null;if(!i){n({kind:`error`,error:`fetch is not available in this environment.`});return}if(i.status===404){n({kind:`error`,error:`The server has no stored run with this id, so there is nothing to replay.`});return}if(i.status===422){let e=await i.json().catch(()=>({}));n({kind:`error`,error:e.message||`Replay cannot verify this run (HTTP 422).`});return}if(!i.ok){n({kind:`error`,error:`Replay request failed (HTTP ${i.status}).`});return}let a=await i.json();r.current?.(),a.matches?n({kind:`match`}):n({kind:`diverged`,divergence:a.divergence??`unknown`})}catch(e){n({kind:`error`,error:e instanceof Error?e.message:String(e)})}},[]),reset:L.useCallback(()=>n({kind:`idle`}),[])}}function to(e){let{artifact:t,onReplayed:n}=e,{result:r,replay:i}=eo(n);return(0,R.jsxs)(`div`,{className:$a.panel,children:[(0,R.jsx)(`button`,{onClick:()=>t&&void i(t),disabled:!t||r.kind===`inflight`,className:$a.replayBtn,children:r.kind===`inflight`?`Replaying…`:`Replay`}),(0,R.jsx)(no,{result:r})]})}function no({result:e}){switch(e.kind){case`idle`:case`inflight`:return null;case`match`:return(0,R.jsx)(`p`,{role:`status`,className:[$a.result,$a.match].join(` `),children:`✓ Kernel deterministic`});case`diverged`:return(0,R.jsxs)(`p`,{role:`status`,className:[$a.result,$a.diverged].join(` `),children:[`⚠ Diverged at `,e.divergence]});case`error`:return(0,R.jsxs)(`p`,{role:`status`,className:[$a.result,$a.errResult].join(` `),children:[`⚠ `,e.error]})}}var ro={panel:`_panel_17czm_1`,header:`_header_17czm_12`,title:`_title_17czm_20`,kicker:`_kicker_17czm_30`,statRow:`_statRow_17czm_37`,stat:`_stat_17czm_37`,subhead:`_subhead_17czm_72`,subheadMeta:`_subheadMeta_17czm_82`,histBlock:`_histBlock_17czm_88`,histList:`_histList_17czm_93`,deptList:`_deptList_17czm_94`,roster:`_roster_17czm_95`,histRow:`_histRow_17czm_104`,histLabel:`_histLabel_17czm_112`,histBar:`_histBar_17czm_122`,histCount:`_histCount_17czm_129`,deptRow:`_deptRow_17czm_136`,deptLabel:`_deptLabel_17czm_149`,deptCount:`_deptCount_17czm_156`,rosterRow:`_rosterRow_17czm_171`,rosterDead:`_rosterDead_17czm_184`,rosterName:`_rosterName_17czm_190`,rosterMeta:`_rosterMeta_17czm_199`,rosterMood:`_rosterMood_17czm_208`,showAllBtn:`_showAllBtn_17czm_216`};function io(e){let t=e.finalSwarm;if(!t)return{};let n={};for(let e of t.agents){let t=e.department||`unassigned`;n[t]||(n[t]=[]),n[t].push(e)}return n}function ao(e){return e.agents.filter(e=>e.alive).length}function oo(e){return e.agents.filter(e=>!e.alive).length}function so(e){let t={};for(let n of e.agents){if(!n.alive)continue;let e=n.mood;e&&(t[e]=(t[e]??0)+1)}return t}function co(e){let t={};for(let n of e.agents){if(!n.alive)continue;let e=n.department||`unassigned`;t[e]=(t[e]??0)+1}return t}function lo({artifact:e}){let t=e.finalSwarm,[n,r]=(0,L.useState)(!1),i=(0,L.useMemo)(()=>t?{alive:ao(t),dead:oo(t),moodHist:so(t),deptHeadcount:co(t),byDept:io(e)}:null,[t,e]);if(!t||!i)return null;let a=Object.entries(i.moodHist).sort((e,t)=>t[1]-e[1]),o=Object.entries(i.deptHeadcount).sort((e,t)=>t[1]-e[1]),s=a.reduce((e,[,t])=>e+t,0),c=t.agents,l=n?c:c.slice(0,12);return(0,R.jsxs)(`section`,{className:ro.panel,"aria-label":`Agent swarm snapshot`,children:[(0,R.jsxs)(`header`,{className:ro.header,children:[(0,R.jsx)(`h3`,{className:ro.title,children:`Agent swarm`}),(0,R.jsxs)(`span`,{className:ro.kicker,children:[`T`,t.turn,` · `,t.population,` alive`]})]}),(0,R.jsxs)(`dl`,{className:ro.statRow,children:[(0,R.jsxs)(`div`,{className:ro.stat,children:[(0,R.jsx)(`dt`,{children:`Alive`}),(0,R.jsx)(`dd`,{children:i.alive})]}),(0,R.jsxs)(`div`,{className:ro.stat,children:[(0,R.jsx)(`dt`,{children:`Dead`}),(0,R.jsx)(`dd`,{children:i.dead})]}),typeof t.morale==`number`&&(0,R.jsxs)(`div`,{className:ro.stat,children:[(0,R.jsx)(`dt`,{children:`Morale`}),(0,R.jsxs)(`dd`,{children:[Math.round(t.morale*100),`%`]})]}),typeof t.births==`number`&&(0,R.jsxs)(`div`,{className:ro.stat,children:[(0,R.jsx)(`dt`,{children:`Births this turn`}),(0,R.jsx)(`dd`,{children:t.births})]}),typeof t.deaths==`number`&&(0,R.jsxs)(`div`,{className:ro.stat,children:[(0,R.jsx)(`dt`,{children:`Deaths this turn`}),(0,R.jsx)(`dd`,{children:t.deaths})]})]}),a.length>0&&(0,R.jsxs)(`div`,{className:ro.histBlock,children:[(0,R.jsx)(`h4`,{className:ro.subhead,children:`Mood histogram`}),(0,R.jsx)(`ul`,{className:ro.histList,children:a.map(([e,t])=>(0,R.jsxs)(`li`,{className:ro.histRow,children:[(0,R.jsx)(`span`,{className:ro.histLabel,children:e}),(0,R.jsx)(`div`,{className:ro.histBar,style:{"--bar-pct":`${t/Math.max(1,s)*100}%`},"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:ro.histCount,children:t})]},e))})]}),o.length>0&&(0,R.jsxs)(`div`,{className:ro.histBlock,children:[(0,R.jsx)(`h4`,{className:ro.subhead,children:`Department headcount`}),(0,R.jsx)(`ul`,{className:ro.deptList,children:o.map(([e,t])=>{let n=i.byDept[e]?.length??t;return(0,R.jsxs)(`li`,{className:ro.deptRow,children:[(0,R.jsx)(`span`,{className:ro.deptLabel,children:e}),(0,R.jsxs)(`span`,{className:ro.deptCount,children:[t,`/`,n,` alive`]})]},e)})})]}),(0,R.jsxs)(`div`,{className:ro.histBlock,children:[(0,R.jsxs)(`h4`,{className:ro.subhead,children:[`Roster `,(0,R.jsxs)(`span`,{className:ro.subheadMeta,children:[`· `,c.length,` total`]})]}),(0,R.jsx)(`ul`,{className:ro.roster,children:l.map(e=>(0,R.jsx)(uo,{agent:e},e.agentId))}),c.length>12&&(0,R.jsx)(`button`,{type:`button`,className:ro.showAllBtn,onClick:()=>r(e=>!e),"aria-expanded":n,children:n?`Show top 12`:`Show all ${c.length}`})]})]})}function uo({agent:e}){return(0,R.jsxs)(`li`,{className:[ro.rosterRow,e.alive?``:ro.rosterDead].filter(Boolean).join(` `),children:[(0,R.jsx)(`span`,{className:ro.rosterName,children:e.name}),(0,R.jsxs)(`span`,{className:ro.rosterMeta,children:[e.department,e.role?` · ${e.role}`:``]}),e.mood&&e.alive&&(0,R.jsx)(`span`,{className:ro.rosterMood,children:e.mood}),!e.alive&&(0,R.jsx)(`span`,{className:ro.rosterMood,children:`deceased`})]})}var fo={batchTrajectory:`_batchTrajectory_1tyhg_1`,timepointGrid:`_timepointGrid_1tyhg_8`,batchPoint:`_batchPoint_1tyhg_14`,empty:`_empty_1tyhg_19`,header:`_header_1tyhg_26`},po={gauge:`_gauge_xcxhy_1`,sm:`_sm_xcxhy_7`,md:`_md_xcxhy_10`,lg:`_lg_xcxhy_13`,label:`_label_xcxhy_17`,value:`_value_xcxhy_26`,svg:`_svg_xcxhy_34`,fill:`_fill_xcxhy_40`};function mo(e,t){if(!e.thresholds)return`ok`;let{warn:n,critical:r}=e.thresholds;return e.inverted?r!==void 0&&t>=r?`critical`:n!==void 0&&t>=n?`warn`:`ok`:r!==void 0&&t<=r?`critical`:n!==void 0&&t<=n?`warn`:`ok`}var ho=`n/a`;function go(e,t){if(t==null||Number.isNaN(t))return ho;let n=e.unit??``;switch(n){case`pct`:return`${Math.round(t*100)}%`;case`count`:return t.toLocaleString(`en-US`);case`currency`:return t>=1e9?`$${(t/1e9).toFixed(1)}B`:t>=1e6?`$${(t/1e6).toFixed(1)}M`:t>=1e3?`$${Math.round(t/1e3)}K`:`$${Math.round(t)}`;case`time`:return`Y${Math.round(t)}`;default:return n?`${t} ${n}`:String(t)}}var _o={sm:80,md:120,lg:200};function vo(e){let{spec:t,value:n,variant:r=`linear`,size:i=`md`,className:a}=e,o=_o[i],s=!Number.isNaN(n)&&n!=null,c=s?mo(t,n):`ok`,l=go(t,n),[u,d]=t.range,f=s&&d>u?Math.max(0,Math.min(1,(n-u)/(d-u))):0;return(0,R.jsxs)(`div`,{className:[po.gauge,po[i],a].filter(Boolean).join(` `),children:[(0,R.jsx)(`span`,{className:po.label,children:t.label}),r===`linear`?(0,R.jsxs)(`svg`,{className:po.svg,viewBox:`0 0 ${o} 12`,width:o,height:12,role:`img`,"aria-label":`${t.label}: ${l}`,children:[(0,R.jsx)(`rect`,{x:0,y:0,width:o,height:12,fill:`rgba(255,255,255,0.06)`}),(0,R.jsx)(`rect`,{className:po.fill,"data-color":c,x:0,y:0,width:o*f,height:12})]}):(0,R.jsx)(`svg`,{className:po.svg,viewBox:`0 0 100 100`,width:o,height:o,role:`img`,"aria-label":`${t.label}: ${l}`,children:(0,R.jsx)(`path`,{d:yo(50,50,40,0,f*270),className:po.fill,"data-color":c,fill:`currentColor`})}),(0,R.jsx)(`span`,{className:po.value,children:l})]})}function yo(e,t,n,r,i){let a=r*Math.PI/180,o=(r+i)*Math.PI/180,s=e+n*Math.cos(a),c=t+n*Math.sin(a),l=e+n*Math.cos(o),u=t+n*Math.sin(o);return`M ${s} ${c} A ${n} ${n} 0 ${+(i>180)} 1 ${l} ${u}`}var bo={list:`_list_1jgdp_1`,empty:`_empty_1jgdp_7`,flag:`_flag_1jgdp_16`,detail:`_detail_1jgdp_44`},xo={critical:0,high:1,medium:2,low:3};function So(e){let{flags:t,expandable:n=!1,className:r}=e;if(t.length===0)return(0,R.jsx)(`div`,{className:[bo.list,r].filter(Boolean).join(` `),children:(0,R.jsx)(`span`,{className:bo.empty,children:`No risks flagged.`})});let i=[...t].sort((e,t)=>xo[e.severity]-xo[t.severity]);return(0,R.jsx)(`div`,{className:[bo.list,r].filter(Boolean).join(` `),children:i.map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:bo.flag,"data-severity":e.severity,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`●`}),(0,R.jsx)(`span`,{children:e.label})]}),n&&e.detail&&(0,R.jsx)(`div`,{className:bo.detail,children:e.detail})]},e.id))})}var Co={card:`_card_1wdvr_1`,label:`_label_1wdvr_11`,metrics:`_metrics_1wdvr_20`,highlights:`_highlights_1wdvr_26`};function wo(e,t){switch(e){case`turn-loop`:return`Turn ${t}`;case`batch-trajectory`:return`T+${t}`;case`batch-point`:return`Forecast`}}function To(e,t,n){let r=Object.entries(e).filter(([e])=>t[e]!==void 0).map(([e,n])=>({key:e,spec:t[e],value:n}));return r.sort((e,t)=>e.key.localeCompare(t.key)),r.slice(0,n)}function Eo(e){let{timepoint:t,mode:n,metrics:r,metricSpecs:i,highlights:a,riskFlags:o,className:s}=e,c=To(r,i,3);return(0,R.jsxs)(`div`,{className:[Co.card,s].filter(Boolean).join(` `),children:[(0,R.jsx)(`div`,{className:Co.label,children:wo(n,t)}),(0,R.jsx)(`div`,{className:Co.metrics,children:c.map(({key:e,spec:t,value:n})=>(0,R.jsx)(vo,{spec:t,value:n,variant:`linear`,size:`sm`},e))}),a&&a.length>0&&(0,R.jsx)(`ul`,{className:Co.highlights,children:a.map((e,t)=>(0,R.jsx)(`li`,{children:e},t))}),o&&o.length>0&&(0,R.jsx)(So,{flags:o,expandable:!1})]})}var Do={strip:`_strip_1ns6x_1`,empty:`_empty_1ns6x_11`,svgWrap:`_svgWrap_1ns6x_17`,svg:`_svg_1ns6x_17`,line:`_line_1ns6x_28`,column:`_column_1ns6x_34`,riskDot:`_riskDot_1ns6x_39`,labels:`_labels_1ns6x_52`},Oo={critical:4,high:3,medium:2,low:1};function ko(e){return!e||e.length===0?null:e.reduce((e,t)=>Oo[t.severity]>Oo[e]?t.severity:e,e[0].severity)}function Ao(e){let{timepoints:t,primaryMetric:n,width:r=600,height:i=80,className:a}=e;if(t.length===0)return(0,R.jsx)(`div`,{className:[Do.strip,a].filter(Boolean).join(` `),children:(0,R.jsx)(`span`,{className:Do.empty,children:`No trajectory data.`})});let[o,s]=n.range,c=s-o||1,l=r-16,u=i-16,d=t.map((e,r)=>{let i=8+(t.length===1?l/2:l*r/(t.length-1)),a=e.metrics[n.id]??o,s=Math.max(0,Math.min(1,(a-o)/c));return{x:i,y:8+u-s*u,tp:e,i:r}}),f=d.map(e=>`${e.x.toFixed(2)},${e.y.toFixed(2)}`).join(` `);return(0,R.jsxs)(`div`,{className:[Do.strip,a].filter(Boolean).join(` `),children:[(0,R.jsx)(`div`,{className:Do.svgWrap,children:(0,R.jsxs)(`svg`,{className:Do.svg,viewBox:`0 0 ${r} ${i}`,role:`img`,"aria-label":`${n.label} trajectory across ${t.length} timepoints`,children:[d.map(e=>(0,R.jsx)(`line`,{className:Do.column,"data-column":e.i,x1:e.x,y1:8,x2:e.x,y2:8+u},`col-${e.i}`)),(0,R.jsx)(`polyline`,{className:Do.line,points:f}),d.map(e=>{let t=ko(e.tp.riskFlags);return t?(0,R.jsx)(`circle`,{className:Do.riskDot,"data-severity":t,"data-risk-column":e.i,cx:e.x,cy:4,r:3},`risk-${e.i}`):null})]})}),(0,R.jsx)(`div`,{className:Do.labels,children:t.map((e,t)=>(0,R.jsx)(`span`,{children:e.label},t))})]})}function jo(e,t){let n=Object.keys(t);if(n.length>0)return t[n[0]];let r=e.trajectory?.timepoints??[],i=new Set;r.forEach(e=>{let t=e.worldSnapshot?.metrics;t&&Object.keys(t).forEach(e=>i.add(e))});let a=``,o=-1/0;for(let e of i){let t=r.map(t=>t.worldSnapshot?.metrics?.[e]??0),n=Math.min(...t),i=Math.max(...t),s=t.reduce((e,t)=>e+t,0)/Math.max(t.length,1),c=s===0?0:(i-n)/Math.abs(s);c>o&&(o=c,a=e)}return t[a]??{id:a||`unknown`,label:a||`Unknown`,range:[0,1]}}function Mo(e,t){return e.label?e.label:`T${e.t??e.time??t}`}function No(e){let{artifact:t,metricSpecs:n,className:r}=e,i=t.metadata.mode;if(i===`batch-trajectory`){let e=t.trajectory?.timepoints??[];if(e.length===0)return(0,R.jsx)(`div`,{className:[fo.empty,r].filter(Boolean).join(` `),children:`No timepoints in this run.`});let i=e.map((e,t)=>({label:Mo(e,t),metrics:e.worldSnapshot?.metrics??{},riskFlags:e.riskFlags}));return(0,R.jsxs)(`div`,{className:[fo.batchTrajectory,r].filter(Boolean).join(` `),children:[(0,R.jsxs)(`div`,{className:fo.header,children:[(0,R.jsx)(`span`,{children:t.metadata.scenario.name}),(0,R.jsxs)(`span`,{children:[`Batch trajectory (`,e.length,` timepoints)`]})]}),(0,R.jsx)(Ao,{timepoints:i,primaryMetric:jo(t,n)}),(0,R.jsx)(`div`,{className:fo.timepointGrid,children:e.map((e,t)=>(0,R.jsx)(Eo,{timepoint:e.t??e.time??t,mode:`batch-trajectory`,metrics:e.worldSnapshot?.metrics??{},metricSpecs:n,highlights:e.highlights,riskFlags:e.riskFlags},t))})]})}if(i===`batch-point`){let e=t.finalState,i=t.overview,a=t.riskFlags;return(0,R.jsxs)(`div`,{className:[fo.batchPoint,r].filter(Boolean).join(` `),children:[(0,R.jsxs)(`div`,{className:fo.header,children:[(0,R.jsx)(`span`,{children:t.metadata.scenario.name}),(0,R.jsx)(`span`,{children:`Batch point forecast`})]}),(0,R.jsx)(Eo,{timepoint:0,mode:`batch-point`,metrics:e?.metrics??{},metricSpecs:n,highlights:i?[i]:void 0,riskFlags:a})]})}return(0,R.jsx)(`div`,{className:fo.empty,children:`Use ReportView for turn-loop runs; this component renders batch-trajectory and batch-point only.`})}var Po={list:`_list_ctaud_1`,empty:`_empty_ctaud_8`,turn:`_turn_ctaud_14`,turnHead:`_turnHead_ctaud_21`,metrics:`_metrics_ctaud_31`,decision:`_decision_ctaud_40`};function Fo({artifact:e}){let t=e.trajectory?.timepoints??[],n=e.decisions??[];return t.length===0?(0,R.jsx)(`div`,{className:Po.empty,children:`No turns recorded for this run.`}):(0,R.jsx)(`div`,{className:Po.list,children:t.map((e,t)=>{let r=e.worldSnapshot?.metrics??{},i=n[t],a=e.t??e.time??t+1;return(0,R.jsxs)(`article`,{className:Po.turn,children:[(0,R.jsxs)(`header`,{className:Po.turnHead,children:[`Turn `,a]}),Object.keys(r).length>0&&(0,R.jsx)(`pre`,{className:Po.metrics,children:JSON.stringify(r,null,2)}),i?.label&&(0,R.jsxs)(`p`,{className:Po.decision,children:[(0,R.jsx)(`strong`,{children:`Decision:`}),` `,i.label]})]},t)})})}function Io(e){let{runId:t,open:n,onClose:r,onArtifactLoaded:i,onRunMissing:a,onReplayed:o}=e,{record:s,artifact:c,loading:l,error:u,status:d}=Qa(n?t:null),f=L.useRef(null),p=L.useRef(null),m=Ti(),h=m.clear;L.useEffect(()=>{h()},[t,n,h]),L.useEffect(()=>{s&&i?.(s)},[s,i]),L.useEffect(()=>{d===`not_found`&&t&&a?.(t)},[d,t,a]),L.useEffect(()=>{n?(p.current=document.activeElement,requestAnimationFrame(()=>{(f.current?.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`))?.focus()})):p.current?.focus()},[n]),L.useEffect(()=>{if(!n)return;function e(e){if(e.key===`Escape`)e.preventDefault(),r();else if(e.key===`Tab`){let t=Ro(f.current);if(t.length===0){e.preventDefault();return}let n=t[0],r=t[t.length-1],i=document.activeElement;!i||!f.current?.contains(i)?(e.preventDefault(),n.focus()):e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r]);let g=L.useMemo(()=>{if(!c)return{};let e={},t=(c.trajectory?.timepoints?.[0])?.worldSnapshot?.metrics??{};for(let n of Object.keys(t))e[n]={id:n,label:n,range:[0,1]};return e},[c]);return(0,R.jsxs)(R.Fragment,{children:[n&&(0,R.jsx)(`div`,{className:Za.backdrop,onClick:r,role:`presentation`}),(0,R.jsxs)(`aside`,{ref:f,className:[Za.drawer,n?Za.open:``].filter(Boolean).join(` `),role:`dialog`,"aria-label":`Run detail`,"aria-modal":n?`true`:`false`,"aria-hidden":!n,children:[(0,R.jsxs)(`header`,{className:Za.head,children:[(0,R.jsx)(`button`,{onClick:r,className:Za.closeBtn,"aria-label":`Close detail`,children:`×`}),c&&(0,R.jsx)(to,{artifact:c,onReplayed:o}),s?.sessionId&&(0,R.jsx)(Lo,{sessionId:s.sessionId,onShare:m.share})]}),m.shared&&(0,R.jsx)(ji,{shared:m.shared,onClose:m.clear}),(0,R.jsxs)(`section`,{className:Za.body,children:[l&&(0,R.jsx)(`p`,{className:Za.placeholder,children:`Loading…`}),u&&d!==`ok`&&(0,R.jsxs)(`div`,{className:Za.error,children:[(0,R.jsx)(`strong`,{children:d===`not_found`?`Run not found`:d===`unavailable`?`Artifact path not preserved`:d===`unreadable`?`Artifact file unreadable`:`Error`}),(0,R.jsx)(`p`,{children:u})]}),c&&s&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`section`,{className:Za.summary,children:[(0,R.jsx)(`span`,{className:Za.modeBadge,"data-mode":c.metadata.mode,children:c.metadata.mode}),(0,R.jsx)(`h2`,{children:c.metadata.scenario.name}),(0,R.jsxs)(`p`,{children:[s.actorName??`Unknown`,s.actorArchetype?` · ${s.actorArchetype}`:``]}),(0,R.jsxs)(`p`,{className:Za.meta,children:[c.trajectory?.timepoints?.length??0,` timepoints · `,s.costUSD==null?`-`:`$${s.costUSD.toFixed(2)}`,` · `,s.createdAt.slice(0,19).replace(`T`,` `)]})]}),(0,R.jsx)(lo,{artifact:c}),(0,R.jsx)(`section`,{className:Za.detailBody,children:c.metadata.mode===`turn-loop`?(0,R.jsx)(Fo,{artifact:c}):(0,R.jsx)(No,{artifact:c,metricSpecs:g})})]})]})]})]})}function Lo({sessionId:e,onShare:t}){return(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(Kr(window.location.origin,e,`viz`)),title:`Copy a link that opens this run on the visualization tab`,className:Za.closeBtn,children:`Share viz link`})}function Ro(e){return e?Array.from(e.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`):[]}var zo={backdrop:`_backdrop_15x8f_1`,modal:`_modal_15x8f_10`,head:`_head_15x8f_23`,title:`_title_15x8f_32`,titleAccent:`_titleAccent_15x8f_44`,closeBtn:`_closeBtn_15x8f_49`,body:`_body_15x8f_66`,placeholder:`_placeholder_15x8f_75`,error:`_error_15x8f_82`,extras:`_extras_15x8f_93`,extrasBadge:`_extrasBadge_15x8f_98`};function Bo(e){let[t,n]=L.useState({bundle:null,loading:!1,error:null});return L.useEffect(()=>{if(!e){n({bundle:null,loading:!1,error:null});return}let t=new AbortController;return n({bundle:null,loading:!0,error:null}),fetch(`/api/v1/bundles/${encodeURIComponent(e)}`,{signal:t.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}: ${await e.text().catch(()=>``)}`);return e.json()}).then(e=>n({bundle:e,loading:!1,error:null})).catch(e=>{e?.name!==`AbortError`&&n({bundle:null,loading:!1,error:String(e.message??e)})}),()=>t.abort()},[e]),t}function Vo(e){let[t,n]=L.useState({aggregate:null,loading:!1,error:null});return L.useEffect(()=>{if(!e){n({aggregate:null,loading:!1,error:null});return}let t=new AbortController;return n({aggregate:null,loading:!0,error:null}),fetch(`/api/v1/bundles/${encodeURIComponent(e)}/aggregate`,{signal:t.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>n({aggregate:e,loading:!1,error:null})).catch(e=>{e?.name!==`AbortError`&&n({aggregate:null,loading:!1,error:String(e.message??e)})}),()=>t.abort()},[e]),t}function Ho(e,t,n=3){if(e.includes(t))return[...e];let r=[...e,t];for(;r.length>n;)r.shift();return r}function Uo(e,t){return e.filter(e=>e!==t)}function Wo(e,t,n=3){return e.includes(t)?Uo(e,t):Ho(e,t,n)}function Go(){let[e,t]=L.useState([]);return{pinned:e,pin:L.useCallback(e=>{t(t=>Ho(t,e))},[]),unpin:L.useCallback(e=>{t(t=>Uo(t,e))},[]),togglePin:L.useCallback(e=>{t(t=>Wo(t,e))},[]),isPinned:L.useCallback(t=>e.includes(t),[e])}}var Ko={strip:`_strip_1s71p_1`,tile:`_tile_1s71p_8`,overlayTile:`_overlayTile_1s71p_8`,tileLabel:`_tileLabel_1s71p_22`,tileValue:`_tileValue_1s71p_31`,tileEmpty:`_tileEmpty_1s71p_40`,overlay:`_overlay_1s71p_8`,overlayCaption:`_overlayCaption_1s71p_52`};function qo({aggregate:e,members:t}){return(0,R.jsxs)(`section`,{className:Ko.strip,"aria-label":`Bundle aggregate stats`,children:[(0,R.jsx)(Jo,{label:`Actors`,value:`${e.count}`}),(0,R.jsx)(Jo,{label:`Total cost`,value:e.costTotalUSD>0?`$${e.costTotalUSD.toFixed(2)}`:`—`}),(0,R.jsx)(Jo,{label:`Mean run time`,value:Xo(e.meanDurationMs)}),(0,R.jsx)(Yo,{members:t})]})}function Jo({label:e,value:t}){return(0,R.jsxs)(`div`,{className:Ko.tile,children:[(0,R.jsx)(`div`,{className:Ko.tileLabel,children:e}),(0,R.jsx)(`div`,{className:Ko.tileValue,children:t})]})}function Yo({members:e}){let t=e.map(e=>e.summaryTrajectory??[]).filter(e=>e.length>0);if(t.length===0)return(0,R.jsxs)(`div`,{className:Ko.overlayTile,children:[(0,R.jsx)(`div`,{className:Ko.tileLabel,children:`Trajectory overlay`}),(0,R.jsx)(`div`,{className:Ko.tileEmpty,children:`no sparkline data`})]});let n=t.flat(),r=Math.min(...n),i=Math.max(...n),a=Math.max(1e-6,i-r),o=Math.max(...t.map(e=>e.length)),s=312/Math.max(1,o-1);return(0,R.jsxs)(`div`,{className:Ko.overlayTile,children:[(0,R.jsx)(`div`,{className:Ko.tileLabel,children:`Trajectory overlay (all actors)`}),(0,R.jsx)(`svg`,{className:Ko.overlay,viewBox:`0 0 320 60`,role:`img`,"aria-label":`All actors trajectory overlay`,children:t.map((e,t)=>{let n=e.map((e,t)=>`${4+t*s},${4+52*(1-(e-r)/a)}`).join(` `);return(0,R.jsx)(`polyline`,{points:n,fill:`none`,stroke:`var(--amber)`,strokeWidth:1,opacity:.45},t)})}),(0,R.jsx)(`div`,{className:Ko.overlayCaption,children:`Representative metric (population → morale → first available), normalized across the bundle. X = turn.`})]})}function Xo(e){return!e||e<1e3?`—`:e<6e4?`${Math.round(e/1e3)}s`:`${Math.floor(e/6e4)}m ${Math.round(e%6e4/1e3)}s`}var Zo={grid:`_grid_3cqcy_1`},Qo={cell:`_cell_10uu1_1`,pinned:`_pinned_10uu1_13`,head:`_head_10uu1_18`,titles:`_titles_10uu1_25`,name:`_name_10uu1_30`,archetype:`_archetype_10uu1_42`,pinLabel:`_pinLabel_10uu1_50`,sparkline:`_sparkline_10uu1_80`,sparklineEmpty:`_sparklineEmpty_10uu1_86`,foot:`_foot_10uu1_96`,cost:`_cost_10uu1_105`,duration:`_duration_10uu1_105`,openBtn:`_openBtn_10uu1_111`};function $o({record:e,pinned:t,onTogglePin:n,onOpen:r,displayIndex:i}){let a=e.actorName??`Actor ${i}`;return(0,R.jsxs)(`article`,{className:[Qo.cell,t?Qo.pinned:``].filter(Boolean).join(` `),children:[(0,R.jsxs)(`header`,{className:Qo.head,children:[(0,R.jsxs)(`div`,{className:Qo.titles,children:[(0,R.jsx)(`h4`,{className:Qo.name,children:a}),e.actorArchetype&&(0,R.jsx)(`p`,{className:Qo.archetype,children:e.actorArchetype})]}),(0,R.jsxs)(`label`,{className:Qo.pinLabel,title:t?`Unpin`:`Pin to compare side-by-side`,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:t,onChange:n,"aria-label":t?`Unpin ${a}`:`Pin ${a} to compare`}),(0,R.jsx)(`span`,{"aria-hidden":`true`,children:t?`★`:`☆`})]})]}),(0,R.jsx)(es,{values:e.summaryTrajectory??[]}),(0,R.jsxs)(`footer`,{className:Qo.foot,children:[(0,R.jsx)(`span`,{className:Qo.cost,children:e.costUSD?`$${e.costUSD.toFixed(2)}`:`—`}),(0,R.jsx)(`span`,{className:Qo.duration,children:e.durationMs?`${Math.round(e.durationMs/1e3)}s`:`—`}),(0,R.jsx)(`button`,{onClick:r,className:Qo.openBtn,"aria-label":`Open ${a} details`,children:`Open`})]})]})}function es({values:e}){if(e.length<2)return(0,R.jsx)(`div`,{className:Qo.sparklineEmpty,children:`—`});let t=Math.min(...e),n=Math.max(...e),r=Math.max(1e-6,n-t),i=e.map((n,i)=>`${2+i/(e.length-1)*216},${2+32*(1-(n-t)/r)}`).join(` `);return(0,R.jsx)(`svg`,{className:Qo.sparkline,viewBox:`0 0 220 36`,role:`img`,"aria-label":`Run trajectory sparkline`,children:(0,R.jsx)(`polyline`,{points:i,fill:`none`,stroke:`var(--amber)`,strokeWidth:1.5})})}function ts({members:e,pinnedIds:t,onTogglePin:n,onOpenRun:r}){return(0,R.jsx)(`section`,{className:Zo.grid,"aria-label":`Bundle members grid`,children:e.map((e,i)=>(0,R.jsx)($o,{record:e,displayIndex:i+1,pinned:t.includes(e.runId),onTogglePin:()=>n(e.runId),onOpen:()=>r(e.runId)},e.runId))})}var ns={panel:`_panel_v1zfa_1`,empty:`_empty_v1zfa_9`,head:`_head_v1zfa_21`,column:`_column_v1zfa_26`,archetype:`_archetype_v1zfa_44`,statusRow:`_statusRow_v1zfa_53`,loading:`_loading_v1zfa_63`,error:`_error_v1zfa_67`};function rs(e){let[t,n]=L.useState({}),[r,i]=L.useState({}),[a,o]=L.useState({}),s=JSON.stringify([...e].sort());return L.useEffect(()=>{let a=[];for(let s of e){if(t[s]!==void 0||r[s])continue;let e=new AbortController;a.push(e),i(e=>({...e,[s]:!0})),fetch(`/api/v1/runs/${encodeURIComponent(s)}`,{signal:e.signal}).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{n(t=>({...t,[s]:e})),i(e=>({...e,[s]:!1}))}).catch(e=>{e?.name!==`AbortError`&&(o(t=>({...t,[s]:String(e?.message??e)})),i(e=>({...e,[s]:!1})))})}return()=>{a.forEach(e=>e.abort())}},[s]),{artifacts:t,loading:r,errors:a}}var is={diffSection:`_diffSection_1h3na_2`,diffHead:`_diffHead_1h3na_12`,diffTitle:`_diffTitle_1h3na_18`,diffEmpty:`_diffEmpty_1h3na_28`,fingerprintRow:`_fingerprintRow_1h3na_36`,fingerprintLabel:`_fingerprintLabel_1h3na_44`,fingerprintBars:`_fingerprintBars_1h3na_50`,fingerprintBar:`_fingerprintBar_1h3na_50`,fingerprintBarFill:`_fingerprintBarFill_1h3na_63`,timelineGrid:`_timelineGrid_1h3na_71`,timelineTurn:`_timelineTurn_1h3na_77`,timelineCell:`_timelineCell_1h3na_85`,rationaleGrid:`_rationaleGrid_1h3na_95`,rationaleColumn:`_rationaleColumn_1h3na_100`,rationaleEntry:`_rationaleEntry_1h3na_110`,rationaleTurn:`_rationaleTurn_1h3na_118`,rationaleDecision:`_rationaleDecision_1h3na_126`,rationaleText:`_rationaleText_1h3na_132`,metricGrid:`_metricGrid_1h3na_139`,metricCard:`_metricCard_1h3na_145`,metricLabel:`_metricLabel_1h3na_154`,metricSparkline:`_metricSparkline_1h3na_163`};function as({artifacts:e}){let t=L.useMemo(()=>os(e),[e]);if(t.length===0)return(0,R.jsxs)(`section`,{className:is.diffSection,"aria-label":`Timeline comparison`,children:[(0,R.jsx)(`header`,{className:is.diffHead,children:(0,R.jsx)(`h5`,{className:is.diffTitle,children:`Timeline`})}),(0,R.jsx)(`p`,{className:is.diffEmpty,children:`No timepoints in any artifact.`})]});let n={gridTemplateColumns:`60px repeat(${e.length}, 1fr)`};return(0,R.jsxs)(`section`,{className:is.diffSection,"aria-label":`Timeline comparison`,children:[(0,R.jsx)(`header`,{className:is.diffHead,children:(0,R.jsx)(`h5`,{className:is.diffTitle,children:`Timeline`})}),(0,R.jsx)(`div`,{className:is.timelineGrid,style:n,children:t.map(e=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsxs)(`div`,{className:is.timelineTurn,children:[`T`,e.turn]}),e.cells.map((e,t)=>(0,R.jsx)(`div`,{className:is.timelineCell,children:e??(0,R.jsx)(`em`,{style:{color:`var(--text-3)`},children:`—`})},t))]},e.turn))})]})}function os(e){let t=new Map;for(let n=0;n<e.length;n++){let r=e[n],i=r.trajectory?.timepoints??[],a=r.trajectory?.points??[],o=new Set;for(let r of i){if(typeof r.turn!=`number`)continue;o.add(r.turn);let i=cs(r);ss(t,r.turn,e.length)[n]=i}if(i.length===0&&a.length>0)for(let r of a){let i=typeof r?.time==`number`?Math.round(r.time):void 0;i===void 0||o.has(i)||(ss(t,i,e.length)[n]=`t=${i}`)}}return[...t.entries()].sort((e,t)=>e[0]-t[0]).map(([e,t])=>({turn:e,cells:t}))}function ss(e,t,n){let r=e.get(t);return r||(r=Array.from({length:n},()=>null),e.set(t,r)),r}function cs(e){let t=e.events?.[0]?.title,n=e.decision?.decision;return t&&n?`${t} → ${n}`:t||n||(e.label?e.label:`—`)}function ls({artifacts:e}){let t=L.useMemo(()=>us(e),[e]);if(t.length===0)return(0,R.jsxs)(`section`,{className:is.diffSection,"aria-label":`Fingerprint comparison`,children:[(0,R.jsx)(`header`,{className:is.diffHead,children:(0,R.jsx)(`h5`,{className:is.diffTitle,children:`Fingerprint`})}),(0,R.jsx)(`p`,{className:is.diffEmpty,children:`No numeric fingerprint fields available.`})]});let n={gridTemplateColumns:`repeat(${e.length}, 1fr)`};return(0,R.jsxs)(`section`,{className:is.diffSection,"aria-label":`Fingerprint comparison`,children:[(0,R.jsx)(`header`,{className:is.diffHead,children:(0,R.jsx)(`h5`,{className:is.diffTitle,children:`Fingerprint`})}),t.map(t=>(0,R.jsxs)(`div`,{className:is.fingerprintRow,children:[(0,R.jsx)(`span`,{className:is.fingerprintLabel,children:t}),(0,R.jsx)(`div`,{className:is.fingerprintBars,style:n,children:e.map((e,n)=>{let r=ds(e.fingerprint?.[t]),i=Math.max(0,Math.min(100,r*100));return(0,R.jsx)(`div`,{className:is.fingerprintBar,"aria-label":`${t}: ${r.toFixed(2)}`,children:(0,R.jsx)(`div`,{className:is.fingerprintBarFill,style:{width:`${i}%`}})},n)})})]},t))]})}function us(e){let t=new Set;for(let n of e)if(n.fingerprint)for(let[e,r]of Object.entries(n.fingerprint))typeof r==`number`&&Number.isFinite(r)&&t.add(e);return[...t].sort()}function ds(e){return typeof e==`number`&&Number.isFinite(e)?e:0}function fs({artifacts:e}){let t=L.useRef([]),n=L.useCallback(e=>n=>{let r=n.currentTarget.scrollTop;t.current.forEach((t,n)=>{n!==e&&t&&Math.abs(t.scrollTop-r)>1&&(t.scrollTop=r)})},[]),r=e.map(ps);if(r.every(e=>e.length===0))return(0,R.jsxs)(`section`,{className:is.diffSection,"aria-label":`Decision rationale comparison`,children:[(0,R.jsx)(`header`,{className:is.diffHead,children:(0,R.jsx)(`h5`,{className:is.diffTitle,children:`Decision rationale`})}),(0,R.jsx)(`p`,{className:is.diffEmpty,children:`No decisions recorded (batch-point mode or no commander turns).`})]});let i={gridTemplateColumns:`repeat(${e.length}, 1fr)`};return(0,R.jsxs)(`section`,{className:is.diffSection,"aria-label":`Decision rationale comparison`,children:[(0,R.jsx)(`header`,{className:is.diffHead,children:(0,R.jsx)(`h5`,{className:is.diffTitle,children:`Decision rationale`})}),(0,R.jsx)(`div`,{className:is.rationaleGrid,style:i,children:r.map((e,r)=>(0,R.jsxs)(`div`,{className:is.rationaleColumn,ref:e=>{t.current[r]=e},onScroll:n(r),children:[e.length===0&&(0,R.jsx)(`p`,{className:is.diffEmpty,children:`—`}),e.map((e,t)=>(0,R.jsxs)(`div`,{className:is.rationaleEntry,children:[(0,R.jsxs)(`span`,{className:is.rationaleTurn,children:[`Turn `,e.turn]}),(0,R.jsx)(`p`,{className:is.rationaleDecision,children:e.decision}),(0,R.jsx)(`p`,{className:is.rationaleText,children:e.rationale})]},t))]},r))})]})}function ps(e){return(e.decisions??[]).map(e=>({turn:typeof e.time==`number`?Math.round(e.time):0,decision:typeof e.choice==`string`?e.choice:`—`,rationale:typeof e.rationale==`string`?e.rationale:typeof e.reasoning==`string`?e.reasoning:``})).sort((e,t)=>e.turn-t.turn)}var ms=[`var(--amber)`,`var(--rust)`,`var(--teal)`];function hs({artifacts:e}){let t=L.useMemo(()=>_s(e),[e]);return t.length===0?(0,R.jsxs)(`section`,{className:is.diffSection,"aria-label":`Metric trajectory comparison`,children:[(0,R.jsx)(`header`,{className:is.diffHead,children:(0,R.jsx)(`h5`,{className:is.diffTitle,children:`Metric trajectories`})}),(0,R.jsx)(`p`,{className:is.diffEmpty,children:`No timepoint metrics in any artifact.`})]}):(0,R.jsxs)(`section`,{className:is.diffSection,"aria-label":`Metric trajectory comparison`,children:[(0,R.jsx)(`header`,{className:is.diffHead,children:(0,R.jsx)(`h5`,{className:is.diffTitle,children:`Metric trajectories`})}),(0,R.jsx)(`div`,{className:is.metricGrid,children:t.map(e=>(0,R.jsxs)(`div`,{className:is.metricCard,children:[(0,R.jsx)(`span`,{className:is.metricLabel,children:e.metricId}),(0,R.jsx)(gs,{series:e.perArtifact})]},e.metricId))})]})}function gs({series:e}){let t=e.flatMap(e=>e.map(e=>e.value)).filter(e=>Number.isFinite(e));if(t.length===0)return(0,R.jsx)(`span`,{className:is.diffEmpty,children:`—`});let n=Math.min(...t),r=Math.max(...t),i=Math.max(1e-6,r-n),a=e.flatMap(e=>e.map(e=>e.turn)),o=Math.min(...a),s=Math.max(...a),c=Math.max(1,s-o);return(0,R.jsx)(`svg`,{className:is.metricSparkline,viewBox:`0 0 200 40`,role:`img`,"aria-label":`Metric over turns, one series per artifact`,children:e.map((e,t)=>{if(e.length<2)return null;let r=e.map(e=>`${2+(e.turn-o)/c*196},${2+36*(1-(e.value-n)/i)}`).join(` `);return(0,R.jsx)(`polyline`,{points:r,fill:`none`,stroke:ms[t%ms.length],strokeWidth:1.4,opacity:.85},t)})})}function _s(e){let t=new Map;for(let n=0;n<e.length;n++){let r=e[n].trajectory?.timepoints??[],i=e[n].trajectory?.points??[];if(r.length>0)for(let i of r){if(typeof i.turn!=`number`)continue;let r=i.worldSnapshot?.metrics;if(r)for(let[a,o]of Object.entries(r)){if(typeof o!=`number`||!Number.isFinite(o))continue;let r=t.get(a);r||(r=e.map(()=>[]),t.set(a,r)),r[n].push({turn:i.turn,value:o})}}else for(let r of i){if(typeof r?.time!=`number`)continue;let i=r.metrics;if(i)for(let[a,o]of Object.entries(i)){if(typeof o!=`number`||!Number.isFinite(o))continue;let i=t.get(a);i||(i=e.map(()=>[]),t.set(a,i)),i[n].push({turn:Math.round(r.time),value:o})}}}return[...t.entries()].map(([e,t])=>({metricId:e,perArtifact:t})).filter(e=>e.perArtifact.some(e=>e.length>0)).sort((e,t)=>e.metricId.localeCompare(t.metricId))}var vs={summaryGrid:`_summaryGrid_1ik11_1`,summaryCol:`_summaryCol_1ik11_6`,summaryEmpty:`_summaryEmpty_1ik11_17`,summaryStats:`_summaryStats_1ik11_23`,summaryGroup:`_summaryGroup_1ik11_36`,summaryLabel:`_summaryLabel_1ik11_42`,summaryList:`_summaryList_1ik11_51`,summaryCount:`_summaryCount_1ik11_70`,divBlock:`_divBlock_1ik11_75`,divTitle:`_divTitle_1ik11_83`,divMeta:`_divMeta_1ik11_93`,divNote:`_divNote_1ik11_99`,aliveOnlyGrid:`_aliveOnlyGrid_1ik11_106`,aliveOnlyCol:`_aliveOnlyCol_1ik11_112`,aliveOnlyHead:`_aliveOnlyHead_1ik11_124`,aliveOnlyCount:`_aliveOnlyCount_1ik11_136`,aliveOnlyList:`_aliveOnlyList_1ik11_143`,aliveOnlyMore:`_aliveOnlyMore_1ik11_155`,aliveOnlyEmpty:`_aliveOnlyEmpty_1ik11_160`,moodTable:`_moodTable_1ik11_165`,moodHead:`_moodHead_1ik11_172`,moodAgent:`_moodAgent_1ik11_183`,moodCell:`_moodCell_1ik11_193`};function ys({artifacts:e}){let t=L.useMemo(()=>e.map(xs),[e]),n=L.useMemo(()=>Ss(e),[e]);if(!t.some(e=>e.hasSwarm))return null;let r={gridTemplateColumns:`repeat(${e.length}, 1fr)`};return(0,R.jsxs)(`section`,{className:is.diffSection,"aria-label":`Swarm comparison`,children:[(0,R.jsx)(`header`,{className:is.diffHead,children:(0,R.jsx)(`h5`,{className:is.diffTitle,children:`Agent swarm`})}),(0,R.jsx)(`div`,{className:vs.summaryGrid,style:r,children:t.map((e,t)=>(0,R.jsx)(bs,{summary:e},t))}),n.aliveOnly.some(e=>e.length>0)&&(0,R.jsxs)(`div`,{className:vs.divBlock,children:[(0,R.jsx)(`h6`,{className:vs.divTitle,children:`Survivor delta`}),(0,R.jsx)(`p`,{className:vs.divNote,children:`Agents alive in one run but not the others. Same seed → same starting roster, so the delta isolates leader-driven mortality.`}),(0,R.jsx)(`div`,{className:vs.aliveOnlyGrid,style:r,children:n.aliveOnly.map((e,t)=>(0,R.jsxs)(`div`,{className:vs.aliveOnlyCol,children:[(0,R.jsxs)(`span`,{className:vs.aliveOnlyHead,children:[`Run `,String.fromCharCode(65+t),` only`,(0,R.jsxs)(`span`,{className:vs.aliveOnlyCount,children:[`· `,e.length]})]}),e.length===0?(0,R.jsx)(`span`,{className:vs.aliveOnlyEmpty,children:`—`}):(0,R.jsxs)(`ul`,{className:vs.aliveOnlyList,children:[e.slice(0,8).map(e=>(0,R.jsx)(`li`,{children:e},e)),e.length>8&&(0,R.jsxs)(`li`,{className:vs.aliveOnlyMore,children:[`+`,e.length-8,` more`]})]})]},t))})]}),n.moodDeltas.length>0&&(0,R.jsxs)(`div`,{className:vs.divBlock,children:[(0,R.jsxs)(`h6`,{className:vs.divTitle,children:[`Mood divergence `,(0,R.jsxs)(`span`,{className:vs.divMeta,children:[`· `,n.moodDeltas.length,` agents differ`]})]}),(0,R.jsxs)(`div`,{className:vs.moodTable,style:{gridTemplateColumns:`1.4fr repeat(${e.length}, 1fr)`},children:[(0,R.jsx)(`span`,{className:vs.moodHead,children:`Agent`}),e.map((e,t)=>(0,R.jsxs)(`span`,{className:vs.moodHead,children:[`Run `,String.fromCharCode(65+t)]},t)),n.moodDeltas.slice(0,12).map(e=>(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(`span`,{className:vs.moodAgent,children:e.agent}),e.moods.map((e,t)=>(0,R.jsx)(`span`,{className:vs.moodCell,children:e??`—`},t))]},e.agent))]}),n.moodDeltas.length>12&&(0,R.jsxs)(`p`,{className:vs.divNote,children:[`+`,n.moodDeltas.length-12,` more agent mood differences not shown.`]})]})]})}function bs({summary:e}){return e.hasSwarm?(0,R.jsxs)(`div`,{className:vs.summaryCol,children:[(0,R.jsxs)(`div`,{className:vs.summaryStats,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:e.alive}),` alive`]}),(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`strong`,{children:e.dead}),` dead`]}),typeof e.morale==`number`&&(0,R.jsxs)(`span`,{children:[(0,R.jsxs)(`strong`,{children:[Math.round(e.morale*100),`%`]}),` morale`]})]}),e.topMoods.length>0&&(0,R.jsxs)(`div`,{className:vs.summaryGroup,children:[(0,R.jsx)(`span`,{className:vs.summaryLabel,children:`Top moods`}),(0,R.jsx)(`ul`,{className:vs.summaryList,children:e.topMoods.map(([e,t])=>(0,R.jsxs)(`li`,{children:[e,` `,(0,R.jsx)(`span`,{className:vs.summaryCount,children:t})]},e))})]}),e.topDepts.length>0&&(0,R.jsxs)(`div`,{className:vs.summaryGroup,children:[(0,R.jsx)(`span`,{className:vs.summaryLabel,children:`Top depts`}),(0,R.jsx)(`ul`,{className:vs.summaryList,children:e.topDepts.map(([e,t])=>(0,R.jsxs)(`li`,{children:[e,` `,(0,R.jsx)(`span`,{className:vs.summaryCount,children:t})]},e))})]})]}):(0,R.jsx)(`div`,{className:vs.summaryCol,children:(0,R.jsx)(`span`,{className:vs.summaryEmpty,children:`No swarm captured`})})}function xs(e){let t=e.finalSwarm;if(!t)return{hasSwarm:!1,alive:0,dead:0,topMoods:[],topDepts:[]};let n=so(t),r=co(t);return{hasSwarm:!0,alive:ao(t),dead:oo(t),morale:t.morale,topMoods:Object.entries(n).sort((e,t)=>t[1]-e[1]).slice(0,4),topDepts:Object.entries(r).sort((e,t)=>t[1]-e[1]).slice(0,4)}}function Ss(e){let t=e.map(e=>e.finalSwarm),n=t.map(e=>e?new Set(e.agents.filter(e=>e.alive).map(e=>e.agentId)):new Set),r=new Map;for(let e of t)if(e)for(let t of e.agents)r.has(t.agentId)||r.set(t.agentId,t.name);let i=n.map((e,t)=>{let i=n.filter((e,n)=>n!==t);if(i.length===0)return[];let a=[];for(let t of e)i.every(e=>e.has(t))||a.push(r.get(t)??t);return a.sort()}),a=[];if(t.every(Boolean)){let e=new Set;for(let n of t)if(n)for(let t of n.agents)e.add(t.agentId);for(let n of e){let e=t.map(e=>e?.agents.find(e=>e.agentId===n));if(e.some(e=>!e))continue;let i=e.map(e=>e.mood);new Set(i.filter(Boolean)).size>1&&a.push({agent:r.get(n)??n,moods:i})}a.sort((e,t)=>e.agent.localeCompare(t.agent))}return{aliveOnly:i,moodDeltas:a}}function Cs({pinnedIds:e,members:t}){let{artifacts:n,loading:r,errors:i}=rs(e);if(e.length===0)return(0,R.jsx)(`section`,{className:ns.empty,"aria-label":`Pinned diff`,children:(0,R.jsx)(`p`,{children:`Pin 2-3 cells above with the ☆ toggle to compare them side-by-side.`})});let a=Object.fromEntries(t.map(e=>[e.runId,e])),o=new Map(t.map((e,t)=>[e.runId,t+1])),s=e.map(e=>a[e]).filter(Boolean),c=e.map(e=>n[e]).filter(e=>!!e),l={gridTemplateColumns:`repeat(${s.length}, 1fr)`};return(0,R.jsxs)(`section`,{className:ns.panel,"aria-label":`Pinned runs side-by-side`,children:[(0,R.jsx)(`header`,{className:ns.head,style:l,children:s.map(e=>(0,R.jsxs)(`div`,{className:ns.column,children:[(0,R.jsx)(`h4`,{children:e.actorName??`Actor ${o.get(e.runId)??`?`}`}),e.actorArchetype&&(0,R.jsx)(`span`,{className:ns.archetype,children:e.actorArchetype}),(0,R.jsxs)(`div`,{className:ns.statusRow,children:[r[e.runId]&&(0,R.jsx)(`span`,{className:ns.loading,children:`loading…`}),i[e.runId]&&(0,R.jsx)(`span`,{className:ns.error,children:i[e.runId]})]})]},e.runId))}),c.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(ls,{artifacts:c}),(0,R.jsx)(as,{artifacts:c}),(0,R.jsx)(fs,{artifacts:c}),(0,R.jsx)(hs,{artifacts:c}),(0,R.jsx)(ys,{artifacts:c})]})]})}function ws({bundleId:e,extraArtifacts:t,open:n,onClose:r}){let{bundle:i,loading:a,error:o}=Bo(n&&e?e:null),{aggregate:s}=Vo(n&&e?e:null),c=Go(),[l,u]=L.useState(null),d=Qr(n);return L.useEffect(()=>{if(n)return document.body.style.overflow=`hidden`,()=>{document.body.style.overflow=``}},[n]),L.useEffect(()=>{if(!n)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),l===null?r():u(null))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[n,r,l]),n?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:zo.backdrop,onClick:r,role:`presentation`}),(0,R.jsxs)(`div`,{ref:d,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`compare-modal-title`,tabIndex:-1,className:zo.modal,children:[(0,R.jsxs)(`header`,{className:zo.head,children:[(0,R.jsx)(`h2`,{id:`compare-modal-title`,className:zo.title,children:a?`Loading bundle…`:i?(0,R.jsxs)(R.Fragment,{children:[`Compare bundle`,(0,R.jsxs)(`span`,{className:zo.titleAccent,children:[` `,i.scenarioId,` · `,i.memberCount,` actors`]})]}):`Bundle`}),(0,R.jsx)(`button`,{onClick:r,className:zo.closeBtn,"aria-label":`Close compare`,children:`×`})]}),(0,R.jsxs)(`section`,{className:zo.body,children:[o&&(0,R.jsxs)(`p`,{className:zo.error,children:[`Failed to load bundle: `,o]}),a&&(0,R.jsx)(`p`,{className:zo.placeholder,children:`Loading bundle metadata…`}),i&&s&&(0,R.jsx)(qo,{aggregate:s,members:i.members}),i&&(0,R.jsx)(ts,{members:i.members,pinnedIds:c.pinned,onTogglePin:c.togglePin,onOpenRun:u}),i&&(0,R.jsx)(Cs,{pinnedIds:c.pinned,members:i.members}),t&&t.length>0&&(0,R.jsxs)(`section`,{className:zo.extras,"aria-label":`Uploaded artifacts`,children:[(0,R.jsxs)(`h3`,{children:[`Uploaded (`,t.length,`)`]}),(0,R.jsx)(`ul`,{children:t.map(e=>{let t=e.leader?.name??`<unnamed>`;return(0,R.jsxs)(`li`,{children:[t,` `,(0,R.jsx)(`span`,{className:zo.extrasBadge,children:`(uploaded)`})]},e.metadata.runId)})})]})]})]}),(0,R.jsx)(Io,{runId:l,open:l!==null,onClose:()=>u(null)})]}):null}var Ts={empty:`_empty_1asmk_1`,icon:`_icon_1asmk_13`,list:`_list_1asmk_36`,cta:`_cta_1asmk_55`};function Es(e){let{filtersActive:t,onClearFilters:n}=e;return t?(0,R.jsxs)(`section`,{className:Ts.empty,children:[(0,R.jsx)(`div`,{className:Ts.icon,"aria-hidden":`true`,children:`⌕`}),(0,R.jsx)(`h2`,{children:`No runs match these filters.`}),(0,R.jsx)(`p`,{children:`Clear filters to see all runs in the library.`}),(0,R.jsx)(`button`,{onClick:n,className:Ts.cta,children:`Clear filters`})]}):(0,R.jsxs)(`section`,{className:Ts.empty,children:[(0,R.jsx)(`div`,{className:Ts.icon,"aria-hidden":`true`,children:`∎`}),(0,R.jsx)(`h2`,{children:`No runs in your library yet.`}),(0,R.jsx)(`p`,{children:`Try one of these to get started:`}),(0,R.jsxs)(`ul`,{className:Ts.list,children:[(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:`?tab=sim`,children:`Run a Mars Genesis demo`})}),(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:`?tab=quickstart`,children:`Quickstart from a prompt or URL`})}),(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{href:`?tab=sim`,children:`Compile a custom scenario`})})]})]})}function Ds(){let e=L.useRef(null),{filters:t,setFilters:n,runs:r,total:i,hasMore:a,loading:o,error:s}=va(),{records:c,push:l,remove:u}=xa(),[d,f]=L.useState(0),p=L.useCallback(()=>f(e=>e+1),[]),[m,h]=L.useState(()=>new URLSearchParams(window.location.search).get(`view`)===`table`?`table`:`gallery`);L.useEffect(()=>{let e=new URL(window.location.href);m===`table`?e.searchParams.set(`view`,`table`):e.searchParams.delete(`view`),window.history.replaceState({},``,e.toString())},[m]);let[g,_]=L.useState(()=>new URLSearchParams(window.location.search).get(`runId`)),[v,y]=L.useState(()=>new URLSearchParams(window.location.search).get(`bundleId`));L.useEffect(()=>{let e=new URL(window.location.href);g?e.searchParams.set(`runId`,g):e.searchParams.delete(`runId`),window.history.replaceState({},``,e.toString())},[g]),L.useEffect(()=>{let e=new URL(window.location.href);v?e.searchParams.set(`bundleId`,v):e.searchParams.delete(`bundleId`),window.history.replaceState({},``,e.toString())},[v]);let b=L.useMemo(()=>{let e=new Map;return r.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))},[r]),x=L.useMemo(()=>{let e=new Map;return r.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))},[r]);Sa({enabled:!0,cardSelector:`[data-run-card]`,searchInputRef:e,onOpenFocused:e=>{let t=e.getAttribute(`data-run-id`);t&&_(t)},onClose:()=>_(null)});let S=!!(t.q||t.mode||t.scenarioId||t.actorConfigHash);return(0,R.jsxs)(`div`,{className:pa.tab,children:[(0,R.jsxs)(`header`,{className:pa.header,children:[(0,R.jsx)(`h2`,{className:pa.title,children:`Library`}),(0,R.jsxs)(`div`,{className:pa.viewToggle,role:`group`,"aria-label":`View mode`,children:[(0,R.jsx)(`button`,{className:m===`gallery`?pa.viewActive:pa.viewBtn,onClick:()=>h(`gallery`),"aria-pressed":m===`gallery`,children:`Gallery`}),(0,R.jsx)(`button`,{className:m===`table`?pa.viewActive:pa.viewBtn,onClick:()=>h(`table`),"aria-pressed":m===`table`,children:`Table`})]})]}),(0,R.jsx)(Fa,{filters:{mode:t.mode,scenario:t.scenarioId,leader:t.actorConfigHash},refreshKey:d}),(0,R.jsx)(Ta,{value:t.q??``,onChange:e=>n({...t,q:e||void 0,offset:0}),inputRef:e}),(0,R.jsx)(ka,{filters:t,onChange:n,scenarioOptions:b,leaderOptions:x}),(0,R.jsx)(Ra,{onSelect:e=>_(e)}),s?(0,R.jsxs)(`div`,{className:pa.error,children:[`Failed to load runs: `,s]}):!o&&r.length===0?(0,R.jsx)(Es,{filtersActive:S,onClearFilters:()=>n({limit:t.limit,offset:0})}):m===`gallery`?(0,R.jsx)(Ja,{runs:r,total:i,hasMore:a,loading:o,onOpen:e=>_(e),onReplay:e=>_(e),onOpenBundle:e=>y(e),currentOffset:t.offset??0,pageSize:t.limit??24,onPageChange:e=>n({...t,offset:e})}):(0,R.jsx)(Xa,{runs:r,onOpen:e=>_(e),onReplay:e=>_(e)}),(0,R.jsx)(Io,{runId:g,open:g!==null,onClose:()=>_(null),onArtifactLoaded:l,onRunMissing:u,onReplayed:p}),v&&(0,R.jsx)(ws,{bundleId:v,open:!0,onClose:()=>y(null)}),(0,R.jsx)(`span`,{hidden:!0,"aria-hidden":`true`,children:c.length})]})}var Os={tab:`_tab_9ap8b_1`,dropZone:`_dropZone_9ap8b_10`,dropZoneActive:`_dropZoneActive_9ap8b_20`,dropZoneError:`_dropZoneError_9ap8b_25`,dropZoneHint:`_dropZoneHint_9ap8b_30`,fileInput:`_fileInput_9ap8b_36`,errorBanner:`_errorBanner_9ap8b_40`,errorHint:`_errorHint_9ap8b_48`,loadedBar:`_loadedBar_9ap8b_54`,artifactView:`_artifactView_9ap8b_64`,artifactHead:`_artifactHead_9ap8b_70`,artifactScenario:`_artifactScenario_9ap8b_76`,artifactActor:`_artifactActor_9ap8b_81`,artifactActions:`_artifactActions_9ap8b_86`,promoteBtn:`_promoteBtn_9ap8b_91`,compareBtn:`_compareBtn_9ap8b_92`,artifactBody:`_artifactBody_9ap8b_105`,bundleGrid:`_bundleGrid_9ap8b_110`,bundleCard:`_bundleCard_9ap8b_116`,bundleCardTitle:`_bundleCardTitle_9ap8b_129`,bundleCardMeta:`_bundleCardMeta_9ap8b_133`,bundleIdChip:`_bundleIdChip_9ap8b_139`,bundleActions:`_bundleActions_9ap8b_152`,bundleDrillBack:`_bundleDrillBack_9ap8b_158`,guide:`_guide_9ap8b_167`,guideHead:`_guideHead_9ap8b_177`,guideTitle:`_guideTitle_9ap8b_183`,guideSub:`_guideSub_9ap8b_194`,guideSteps:`_guideSteps_9ap8b_208`,guideCtaRow:`_guideCtaRow_9ap8b_226`,guideCta:`_guideCta_9ap8b_226`,guideCtaSecondary:`_guideCtaSecondary_9ap8b_250`,guideExample:`_guideExample_9ap8b_266`,guideExampleCode:`_guideExampleCode_9ap8b_281`,guideExampleNote:`_guideExampleNote_9ap8b_299`};function ks(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function As(e,t=`|`){return e.map(e=>nc(e)).join(t)}function js(e,t){return typeof t==`bigint`?t.toString():t}var Ms=class{constructor(e){this._getter=e,this._value=void 0}get value(){let e=this._getter;return e!==void 0&&(this._value=e(),this._getter=void 0),this._value}};function Ns(e){return new Ms(e)}function Ps(e){return e==null}function Fs(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function Is(e,t){let n=e/t,r=Math.round(n),i=4*2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}function Ls(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function Rs(e){let t=Object.getOwnPropertyDescriptor(e,`shape`);return t?.get?t.get.raw:t?.value}function zs(e){return Rs(e._zod.def)??e._zod.def.shape}function Bs(e,t,n){Object.defineProperty(e,t,{get(){let e=n();return Ls(this,t,e),e},enumerable:!0,configurable:!0})}function Vs(e,t,n){t in e?Ls(e,t,n):e[t]=n}function Hs(e,t,n,r){let i=zs(t);for(let a of n){let n=Object.getOwnPropertyDescriptor(i,a);n.enumerable&&(n.get?Bs(e,a,()=>{let e=t._zod.def.shape[a];return r?r(e,a):e}):Vs(e,a,r?r(n.value,a):n.value))}}function Us(e,t){for(let n of Reflect.ownKeys(t)){let r=Object.getOwnPropertyDescriptor(t,n);r.enumerable&&(r.get?Bs(e,n,()=>t[n]):Vs(e,n,r.value))}}function Ws(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function Gs(e){return JSON.stringify(e)}function Ks(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var qs=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function Js(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Ys=Ns(()=>{if(Kc.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function Xs(e){if(Js(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return Js(n)!==!1&&Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)!==!1}function Zs(e){return Xs(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var Qs=new Set([`string`,`number`,`symbol`]);function $s(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function ec(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function tc(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function nc(e){return typeof e==`bigint`?e.toString()+`n`:typeof e==`string`?`"${e}"`:`${e}`}function rc(e){return Object.keys(e).filter(t=>e[t]._zod.optin!==void 0&&e[t]._zod.optout===`optional`)}var ic={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},ac={int64:[BigInt(`-9223372036854775808`),BigInt(`9223372036854775807`)],uint64:[BigInt(0),BigInt(`18446744073709551615`)]};function oc(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);let i={};return Hs(i,e,sc(e,t)),ec(e,Ws(n,{shape:i,checks:[]}))}function sc(e,t){let n=zs(e),r=[];for(let e of Reflect.ownKeys(t)){if(!Object.getOwnPropertyDescriptor(n,e)?.enumerable)throw Error(`Unrecognized key: "${String(e)}"`);t[e]&&r.push(e)}return r}function cc(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);let i=new Set(sc(e,t)),a={};return Hs(a,e,Reflect.ownKeys(zs(e)).filter(e=>!i.has(e))),ec(e,Ws(n,{shape:a,checks:[]}))}function lc(e,t){if(!Xs(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=zs(e);for(let e of Reflect.ownKeys(t))if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return ec(e,Ws(e._zod.def,{shape:uc(e,t)}))}function uc(e,t){let n={};return Hs(n,e,Reflect.ownKeys(zs(e))),Us(n,t),n}function dc(e,t){if(!Xs(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return ec(e,Ws(e._zod.def,{shape:uc(e,t)}))}function fc(e,t){if(!t?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);let n={};return Hs(n,e,Reflect.ownKeys(zs(e))),Hs(n,t,Reflect.ownKeys(zs(t))),ec(e,Ws(e._zod.def,{shape:n,get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function pc(e,t,n,r=`partial`){let i=t._zod.def.checks;if(i&&i.length>0)throw Error(`.${r}() cannot be used on object schemas containing refinements`);let a=n?new Set(sc(t,n)):void 0,o={};return Hs(o,t,Reflect.ownKeys(zs(t)),e&&((t,n)=>a&&!a.has(n)?t:new e({type:`optional`,innerType:t}))),ec(t,Ws(t._zod.def,{shape:o,checks:[]}))}function mc(e,t,n){let r=n?new Set(sc(t,n)):void 0,i={};return Hs(i,t,Reflect.ownKeys(zs(t)),(t,n)=>r&&!r.has(n)?t:new e({type:`nonoptional`,innerType:t})),ec(t,Ws(t._zod.def,{shape:i}))}function hc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function gc(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function _c(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function vc(e){return typeof e==`string`?e:e?.message}function yc(e){let t=[];for(let n of e??[]){let e=n._zod.def;if(!/_(length|size)$|_equals$/.test(e.check))break;let r=e.maximum??e.length??e.size;r>=0&&t.push([r,n])}return t}function bc(e,t,n){var r;for(let i=t;i<e.length;i++)(r=e[i]).schema??(r.schema=n)}function xc(e,t,n){var r;let i=e.inst?._zod?.traits;i?.has(`$ZodType`)&&(i.has(`$ZodCheck`)?(r=e).schema??(r.schema=e.inst):e.schema=e.inst);let a=e.schema===e.inst?void 0:e.schema?._zod.def?.error,o=e.message?e.message:vc(e.inst?._zod.def?.error?.(e))??vc(a?.(e))??vc(t?.error?.(e))??vc(n.customError?.(e))??vc(n.localeError?.(e))??`Invalid input`,s={};for(let t of Object.keys(e))t!==`inst`&&t!==`schema`&&t!==`continue`&&t!==`input`&&t!==`__proto__`&&(s[t]=e[t]);return s.path??=[],s.message=o,t?.reportInput&&(s.input=e.input),s}var Sc=/[\uD800-\uDBFF]/;function Cc(e){let t=e.length;if(!Sc.test(e))return t;let n=t;for(let r=0;r<t-1;r++)(e.charCodeAt(r)&64512)==55296&&(e.charCodeAt(r+1)&64512)==56320&&(n--,r++);return n}function wc(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function Tc(e){let t=typeof e;switch(t){case`number`:return Number.isNaN(e)?`nan`:`number`;case`object`:{if(e===null)return`null`;if(Array.isArray(e))return`array`;let t=e;if(t&&Object.getPrototypeOf(t)!==Object.prototype&&`constructor`in t&&t.constructor)return t.constructor.name}}return t}function Ec(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}function Dc(e,t){for(let n in t){let r=Object.getOwnPropertyDescriptor(t,n);r.get?Object.defineProperty(e,n,{...r,enumerable:!1}):jc(e,n,r.value)}}function Oc(e,t,n,r=!0){return Object.defineProperty(e,t,{configurable:!0,writable:!0,enumerable:r,value:n}),n}function kc(e,t,n){return Oc(e,t,n,!1)}function Ac(e,t){for(let n in e){let r=e[n];Object.defineProperty(t,n,{configurable:!0,enumerable:!0,get(){return Oc(this,n,r(this))},set(e){Oc(this,n,e)}})}return t}function jc(e,t,n){Object.defineProperty(e,t,{configurable:!0,get(){return this==null?n:Oc(this,t,n.bind(this))},set(e){Oc(this,t,e)}})}function Mc(e,t){let n=Object.getPrototypeOf(e);return t in n?void 0:n}var Nc,Pc=!1,Fc={configurable:!0,get(){Pc=!0}};function Ic(e,t,n){let r=Object.getPrototypeOf(e._zod);t in r&&Nc!==e._zod?Nc=void 0:(Nc=e._zod,Object.defineProperty(r,t,{configurable:!0,get(){Object.defineProperty(this,t,Fc);let e=Pc;Pc=!1;try{let r=n(this);return Pc?delete this[t]:Object.defineProperty(this,t,{configurable:!0,writable:!0,value:r}),Pc||=e,r}catch(n){throw delete this[t],Pc||=e,n}},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,value:e})}}))}function Lc(e,t,n,r){let i=Mc(e,t);i&&Object.defineProperty(i,t,{configurable:!0,get(){let e={configurable:!0,writable:!0,enumerable:r,value:void 0};return Object.defineProperty(this,t,e),e.value=n(this),Object.defineProperty(this,t,e),e.value},set(e){Object.defineProperty(this,t,{configurable:!0,writable:!0,enumerable:r,value:e})}})}var Rc=`~constantCatch`;function zc(e){let t=()=>e;return t[Rc]=!0,t}var Bc,Vc={value:void 0,enumerable:!1},Hc=`captureStackTrace`in Error?Error:null;function Uc(e){let t=Hc;if(t){let n=t.stackTraceLimit;if(typeof n==`number`){try{t.stackTraceLimit=0}catch{return Hc=null,new e}try{return new e}finally{t.stackTraceLimit=n}}}return new e}function H(e,t,n,r){let i={};function a(e){this.def=e,this.constr=d,this.traits=new Set}a.prototype=i;let o=n,s=o&&new WeakSet;function c(n,r){if(!n._zod){Vc.value=new a(r);try{Object.defineProperty(n,"_zod",Vc)}finally{Vc.value=void 0}}else if(n._zod.traits.has(e))return;if(n._zod.traits.add(e),t(n,r),s){let e=Object.getPrototypeOf(n),t=n._zod.constr.prototype,r=e;for(;r&&r!==t;)r=Object.getPrototypeOf(r);let i=r??e;s.has(i)||(s.add(i),Dc(i,o))}let i=d.prototype;for(let e in i)Object.prototype.hasOwnProperty.call(i,e)&&(e in n||(n[e]=i[e].bind(n)))}let l=r?.Parent??Object;class u extends l{}Object.defineProperty(u,"name",{value:e});function d(e){let t=r?.Parent?Uc(u):this;c(t,e);let n=t._zod.deferred;if(n){for(let e of n)e();t._zod.deferred=void 0}let i=globalThis.__zod_globalConfig?.postProcessor;return i&&i(t),t}return Object.defineProperty(d,"init",{value:c}),Object.defineProperty(d,Symbol.hasInstance,{value:t=>r?.Parent&&t instanceof r.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(d,"name",{value:e}),d}var Wc=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},Gc=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(Bc=globalThis).__zod_globalConfig??(Bc.__zod_globalConfig={});var Kc=globalThis.__zod_globalConfig;function qc(e){return e&&Object.assign(Kc,e),Kc}function Jc(){let e=this._zod;return e.message??=JSON.stringify(e.def,js,2),e.message}function Yc(e){this._zod.message=e}var Xc={get:Jc,set:Yc,enumerable:!0,configurable:!0},Zc={value:void 0,enumerable:!1},Qc=new WeakSet([Object.prototype,Error.prototype]),$c=H(`$ZodError`,(e,t)=>{e.name=`$ZodError`,Zc.value=t,Object.defineProperty(e,"issues",Zc),Zc.value=void 0,Object.defineProperty(e,"message",Xc);let n=Object.getPrototypeOf(e);Qc.has(n)||(Qc.add(n),Object.defineProperty(n,"toString",{configurable:!0,enumerable:!1,get(){let e=()=>this.message;return Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,"toString",{value:e,configurable:!0,writable:!0})}}))});function el(e,t,n){return Object.prototype.hasOwnProperty.call(e,t)||(t===`__proto__`?Object.defineProperty(e,t,{value:n(),writable:!0,enumerable:!0,configurable:!0}):e[t]=n()),e[t]}function tl(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?el(n,i.path[0],()=>[]).push(t(i)):r.push(t(i));return{formErrors:r,fieldErrors:n}}function nl(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i],o=i===e.length-1;if(n===`_errors`){o&&r._errors.push(t(a)),i++;continue}Object.prototype.hasOwnProperty.call(r,n)||Object.defineProperty(r,n,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let s=r[n];o&&s._errors.push(t(a)),r=s,i++}}}};return r(e),n}function rl(e,t){return{callee:t?.callee??e,Err:t?.Err}}var il=e=>{let t=(n,r,i,a)=>{let o=i?{...i,async:!1}:{async:!1},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise)throw new Wc;if(s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xc(e,o,qc())));throw qs(n,a?.callee??t),n}return s.value};return t},al=e=>{let t=async(n,r,i,a)=>{let o=i?{...i,async:!0}:{async:!0},s=n._zod.run({value:r,issues:[]},o);if(s instanceof Promise&&(s=await s),s.issues.length){let n=new((a?.Err)??e)(s.issues.map(e=>xc(e,o,qc())));throw qs(n,a?.callee??t),n}return s.value};return t},ol=e=>(t,n,r)=>{let i=r?{...r,async:!1}:{async:!1},a=t._zod.run({value:n,issues:[]},i);if(a instanceof Promise)throw new Wc;return a.issues.length?sl(e,a.issues,i):{success:!0,data:a.value}};function sl(e,t,n){let r;return{success:!1,get error(){return r||(r=new e(t.map(e=>xc(e,n,qc()))),t=void 0,n=void 0),r},set error(e){r=e,t=void 0,n=void 0}}}var cl=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?sl(e,a.issues,i):{success:!0,data:a.value}},ll=Symbol.for(`zod.compile.invalid`),ul=Symbol.for(`zod.compile.fallback`),dl=((e,t,n)=>{let r=e._zod.bag.validator;if(r!==void 0){if(r(t)!==ll)return!0;if(r.definite===!0&&n===void 0)return!1}return fl(e,t,n)});function fl(e,t,n){let r=n?{...n,async:!1,abortEarly:!0}:{async:!1,abortEarly:!0},i=e._zod.bag.fallbackRun,a;if(i?(r[ul]=!0,a=i({value:t,issues:[]},r)):a=e._zod.run({value:t,issues:[]},r),a instanceof Promise)throw new Wc;return a.issues.length===0}var pl=async(e,t,n)=>{let r=n?{...n,async:!0,abortEarly:!0}:{async:!0,abortEarly:!0},i=e._zod.run({value:t,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length===0},ml=e=>{let t=il(e),n=(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return t(e,r,o,rl(n,a))};return n},hl=e=>{let t=il(e),n=(e,r,i,a)=>t(e,r,i,rl(n,a));return n},gl=e=>{let t=al(e),n=async(e,r,i,a)=>{let o=i?{...i,direction:`backward`}:{direction:`backward`};return await t(e,r,o,rl(n,a))};return n},_l=e=>{let t=al(e),n=async(e,r,i,a)=>await t(e,r,i,rl(n,a));return n},vl=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ol(e)(t,n,i)},yl=e=>(t,n,r)=>ol(e)(t,n,r),bl=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return cl(e)(t,n,i)},xl=e=>async(t,n,r)=>cl(e)(t,n,r),Sl=/^[cC][0-9a-z]{6,}$/,Cl=/^[0-9a-z]+$/,wl=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,Tl=/^[0-9a-vA-V]{20}$/,El=/^[A-Za-z0-9]{27}$/,Dl=/^[a-zA-Z0-9_-]{21}$/;function Ol(e){return RegExp(`^[a-zA-Z0-9_-]{${e}}$`)}var kl=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Al=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,jl=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ml=/^(?:[A-Za-z0-9_'+\-]+\.)*[A-Za-z0-9_'+\-]*[A-Za-z0-9_+-]@(?:[A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Nl=`^(?=[\\s\\S]*[\\p{Extended_Pictographic}\\p{Regional_Indicator}\\u20E3])[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$`;function Pl(){return new RegExp(Nl,`u`)}var Fl=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Il=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))$/,Ll=/^((25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/([0-9]|[1-2][0-9]|3[0-2])$/,Rl=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,zl=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Bl=/^(?:[A-Za-z0-9_-]{4})*(?:[A-Za-z0-9_-]{2,3})?$/,Vl=/^https?$/,Hl=/^\+[1-9]\d{6,14}$/,Ul=`(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))`;function Wl(e){return RegExp(`^${e}$`)}var Gl=Wl(Ul);function Kl(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:e.seconds?`${t}:[0-5]\\d(?:\\.\\d+)?`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ql(e){return RegExp(`^${Kl(e)}$`)}function Jl(e){let t=[`Z`];e.offset&&t.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let n=`${Kl({precision:e.precision,seconds:!0})}(?:${t.join(`|`)})`,r=e.local?`${n}|${Kl({precision:e.precision})}`:n;return RegExp(`^${Ul}T(?:${r})$`)}var Yl=/^[\s\S]{0,}$/,Xl=/^-?\d+$/,Zl=/^-?\d+(?:\.\d+)?$/,Ql=/^(?:true|false)$/i,$l=/^[^A-Z]*$/,eu=/^[^a-z]*$/,tu=H(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),nu=e=>{let t=e.value;return!Ps(t)&&t.length!==void 0},ru={number:`number`,bigint:`bigint`,object:`date`},iu=H(`$ZodCheckLessThan`,(e,t)=>{tu.init(e,t);let n=ru[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:ru[typeof r.value]??n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),au=H(`$ZodCheckGreaterThan`,(e,t)=>{tu.init(e,t);let n=ru[typeof t.value];e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:ru[typeof r.value]??n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),ou=H(`$ZodCheckMultipleOf`,(e,t)=>{tu.init(e,t),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?t.value!==BigInt(0)&&n.value%t.value===BigInt(0):Is(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),su=H(`$ZodCheckNumberFormat`,(e,t)=>{tu.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=ic[t.format];e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),cu=H(`$ZodCheckMaxLength`,(e,t)=>{var n;tu.init(e,t),(n=e._zod.def).when??(n.when=nu),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>t.maximum?Cc(r):i)<=t.maximum)return;let a=wc(r);n.issues.push({origin:a,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),lu=H(`$ZodCheckMinLength`,(e,t)=>{var n;tu.init(e,t),(n=e._zod.def).when??(n.when=nu),e._zod.check=n=>{let r=n.value,i=r.length;if((typeof r==`string`&&i>=t.minimum&&i<t.minimum*2?Cc(r):i)>=t.minimum)return;let a=wc(r);n.issues.push({origin:a,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),uu=H(`$ZodCheckLengthEquals`,(e,t)=>{var n;tu.init(e,t),(n=e._zod.def).when??(n.when=nu),e._zod.check=n=>{let r=n.value,i=r.length,a=typeof r==`string`&&i>=t.length&&i<=t.length*2?Cc(r):i;if(a===t.length)return;let o=wc(r),s=a>t.length;n.issues.push({origin:o,...s?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),du=H(`$ZodCheckStringFormat`,(e,t)=>{var n,r;tu.init(e,t),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),fu=H(`$ZodCheckRegex`,(e,t)=>{du.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,t.pattern.test(n.value)||n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),pu=H(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=$l,du.init(e,t)}),mu=H(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=eu,du.init(e,t)}),hu=H(`$ZodCheckIncludes`,(e,t)=>{tu.init(e,t);let n=$s(t.includes);t.pattern=new RegExp(typeof t.position==`number`?`^.{${t.position},}${n}`:n),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),gu=H(`$ZodCheckStartsWith`,(e,t)=>{tu.init(e,t);let n=RegExp(`^${$s(t.prefix)}.*`);t.pattern??=n,e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),_u=H(`$ZodCheckEndsWith`,(e,t)=>{tu.init(e,t);let n=RegExp(`.*${$s(t.suffix)}$`);t.pattern??=n,e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),vu=H(`$ZodCheckOverwrite`,(e,t)=>{tu.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),yu=class{constructor(e=[],t={}){this.content=[],this.indent=0,this.args=e,this.closed=t}indented(e){this.indent+=1;try{e(this)}finally{--this.indent}}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
|
|
11
|
+
`).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.content??[``];return new e(...Object.keys(this.closed),`return function (${this.args.join(`, `)}) {\n${t.join(`
|
|
12
|
+
`)}\n};`)(...Object.values(this.closed))}},bu={major:4,minor:6,patch:7},xu=H(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=bu;let r=e._zod.def.checks,i=e._zod.traits.has(`$ZodCheck`)?[e,...r??[]]:r?.length?[...r]:[];for(let t of i)for(let n of t._zod.onattach)n(e);if(i.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(t,n,r)=>{if(t.memo)return t;let i=hc(t),a;for(let o of n){if(o._zod.def.when){if(gc(t)||!o._zod.def.when(t))continue}else if(i)continue;let n=t.issues.length,s=o._zod.check(t);if(s instanceof Promise&&r?.async===!1)throw new Wc;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,t.issues.length!==n&&(bc(t.issues,n,e),i||=hc(t,n))});else{if(t.issues.length===n)continue;bc(t.issues,n,e),i||=hc(t,n)}}return a?a.then(()=>t):t},n=(n,r,a)=>{if(hc(n))return n.aborted=!0,n;let o=t(r,i,a);if(o instanceof Promise){if(a.async===!1)throw new Wc;return o.then(t=>e._zod.parse(t,a))}return e._zod.parse(o,a)};e._zod.run=(r,a)=>{if(a.skipChecks)return e._zod.parse(r,a);if(a.direction===`backward`){let t=e._zod.parse({value:r.value,issues:[]},{...a,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,r,a)):n(t,r,a)}let o=e._zod.parse(r,a);if(o instanceof Promise){if(a.async===!1)throw new Wc;return o.then(e=>t(e,i,a))}return t(o,i,a)}}},{get"~standard"(){return kc(this,`~standard`,wu(this))},set"~standard"(e){Oc(this,`~standard`,e)}}),Su=(e,t)=>e.issues.length?{issues:e.issues.map(e=>xc(e,t,qc()))}:{value:e.value};async function Cu(e,t){let n={async:!0};return Su(await e._zod.run({value:t,issues:[]},n),n)}function wu(e){return{validate:t=>{let n={async:!1};try{let r=e._zod.run({value:t,issues:[]},n);if(!(r instanceof Promise))return Su(r,n)}catch{}return Cu(e,t)},vendor:`zod`,version:1}}var Tu=H(`$ZodString`,(e,t)=>{xu.init(e,t),e._zod.pattern=t.pattern??Yl,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),Eu=H(`$ZodStringFormat`,(e,t)=>{du.init(e,t),Tu.init(e,t)}),Du=H(`$ZodGUID`,(e,t)=>{t.pattern??=Al,Eu.init(e,t)}),Ou=H(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=jl(e)}else t.pattern??=jl();Eu.init(e,t)}),ku=H(`$ZodEmail`,(e,t)=>{t.pattern??=Ml,Eu.init(e,t)});function Au(e){try{return typeof URL<`u`&&typeof URL.canParse==`function`?URL.canParse(e):(new URL(e),!0)}catch{return!1}}function ju(e,t){return!(`normalize`in t)&&!(`hostname`in t)&&!(`protocol`in t)?Au(e)||2:Mu(e,t)}function Mu(e,t){if(!t.normalize&&t.protocol?.source===Vl.source&&!/^https?:\/\//i.test(e))return 1;try{if(typeof URL<`u`){let t=URL;if(typeof t.parse==`function`)return t.parse(e)??2}return new URL(e)}catch{return 2}}var Nu=/[\t\n\r]/g;function Pu(e){return e.replace(Nu,``)}function Fu(e,t){return t.lastIndex=0,t.test(e.hostname)}function Iu(e,t){return t.lastIndex=0,t.test(e.protocol.endsWith(`:`)?e.protocol.slice(0,-1):e.protocol)}var Lu=H(`$ZodURL`,(e,t)=>{Eu.init(e,t),e._zod.check=n=>{try{let r=n.value.trim(),i=ju(r,t);if(i===1){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}if(i===2){n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort});return}if(i===!0){n.value=Pu(r);return}t.hostname&&!Fu(i,t.hostname)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort}),t.protocol&&!Iu(i,t.protocol)&&n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort}),n.value=t.normalize?i.href:Pu(r);return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Ru=H(`$ZodEmoji`,(e,t)=>{t.pattern??=Pl(),Eu.init(e,t)}),zu=H(`$ZodNanoID`,(e,t)=>{if(t.length!==void 0&&(!Number.isInteger(t.length)||t.length<1))throw Error(`Invalid nanoid length: ${t.length}`);t.pattern??=t.length===void 0?Dl:Ol(t.length),Eu.init(e,t)}),Bu=H(`$ZodCUID`,(e,t)=>{t.pattern??=Sl,Eu.init(e,t)}),Vu=H(`$ZodCUID2`,(e,t)=>{t.pattern??=Cl,Eu.init(e,t)}),Hu=H(`$ZodULID`,(e,t)=>{t.pattern??=wl,Eu.init(e,t)}),Uu=H(`$ZodXID`,(e,t)=>{t.pattern??=Tl,Eu.init(e,t)}),Wu=H(`$ZodKSUID`,(e,t)=>{t.pattern??=El,Eu.init(e,t)}),Gu=H(`$ZodISODateTime`,(e,t)=>{t.pattern??=Jl(t),Eu.init(e,t)}),Ku=H(`$ZodISODate`,(e,t)=>{t.pattern??=Gl,Eu.init(e,t)}),qu=H(`$ZodISOTime`,(e,t)=>{t.pattern??=ql(t),Eu.init(e,t)}),Ju=H(`$ZodISODuration`,(e,t)=>{t.pattern??=kl,Eu.init(e,t)}),Yu=H(`$ZodIPv4`,(e,t)=>{t.pattern??=Fl,Eu.init(e,t)}),Xu=/^[0-9a-fA-F:.]+$/;function Zu(e){return Xu.test(e)?Au(`http://[${e}]`):!1}var Qu=H(`$ZodIPv6`,(e,t)=>{t.pattern??=Il,Eu.init(e,t),e._zod.check=n=>{Zu(n.value)||n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}),$u=H(`$ZodCIDRv4`,(e,t)=>{t.pattern??=Ll,Eu.init(e,t)});function ed(e){let t=e.split(`/`);if(t.length!==2)return!1;let[n,r]=t;if(!r)return!1;let i=Number(r);return`${i}`!==r||i<0||i>128?!1:Zu(n)}var td=H(`$ZodCIDRv6`,(e,t)=>{t.pattern??=Rl,Eu.init(e,t),e._zod.check=n=>{ed(n.value)||n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}});function nd(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var rd=/^[0-9a-zA-Z+/]*={0,2}$/,id=H(`$ZodBase64`,(e,t)=>{t.pattern??=rd,Eu.init(e,t),e._zod.check=n=>{nd(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}}),ad=/^[A-Za-z0-9_-]*$/;function od(e){if(!ad.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return nd(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var sd=H(`$ZodBase64URL`,(e,t)=>{t.pattern??=ad,Eu.init(e,t),e._zod.check=n=>{od(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),cd=H(`$ZodE164`,(e,t)=>{t.pattern??=Hl,Eu.init(e,t)});function ld(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var ud=H(`$ZodJWT`,(e,t)=>{Eu.init(e,t),e._zod.check=n=>{ld(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),dd=H(`$ZodNumber`,(e,t)=>{xu.init(e,t),e._zod.pattern=Zl,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:String(i):void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),fd=H(`$ZodNumberFormat`,(e,t)=>{su.init(e,t),dd.init(e,t)}),pd=H(`$ZodBoolean`,(e,t)=>{xu.init(e,t),e._zod.pattern=Ql,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),md=H(`$ZodUnknown`,(e,t)=>{xu.init(e,t),e._zod.parse=e=>e}),hd=H(`$ZodNever`,(e,t)=>{xu.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function gd(e,t){let n=yc(e._zod.def.checks);if(!n.length)return;let r=Math.min(...n.map(e=>e[0])),i=e._zod.parse;e._zod.parse=(n,a)=>{let o=t(n.value);if(o>r&&!a?.skipChecks&&a?.direction!==`backward`){for(let[t,r]of yc(e._zod.def.checks))if(o>t&&r._zod.def.when(n)){let t=n.issues.length;return r._zod.check(n),n.issues[t].continue=!1,bc(n.issues,t,e),n}}return i(n,a)}}var _d=e=>Array.isArray(e)?e.length:-1;function vd(e,t,n){e.issues.length&&t.issues.push(..._c(n,e.issues)),t.value[n]=e.value}var yd=H(`$ZodArray`,(e,t)=>{xu.init(e,t);let n=Kc.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Array.isArray(a))return r.issues.push({expected:`array`,code:`invalid_type`,input:a,inst:e}),r;r.value=n?n.alloc(e,r,Array(a.length),i):Array(a.length);let o=[],s=i?.abortEarly;for(let e=0;e<a.length;e++){let n=a[e],c=t.element._zod.run({value:n,issues:[]},i);if(c instanceof Promise)o.push(c.then(t=>vd(t,r,e)));else if(vd(c,r,e),s&&c.issues.length!==0&&hc(c))break}return o.length?Promise.all(o).then(()=>r):r},gd(e,_d)});function bd(e,t,n,r,i,a){let o=n in r,s=a===`optional`;if(o||!s||i!==`optional`){if(e.issues.length){if(i!==void 0&&s&&!o)return;t.issues.push(..._c(n,e.issues))}!o&&i===void 0?e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]}):e.value===void 0?(o||i===`defaulted`&&!s)&&(t.value[n]=void 0):t.value[n]=e.value}}var xd=[];function Sd(e){let t=Object.keys(e.shape),n=Object.getOwnPropertySymbols(e.shape),r=n.length?n:xd,i=r.length?[...t,...r]:t;for(let t of i)if(!e.shape?.[t]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${String(t)}": expected a Zod schema`);let a=rc(e.shape);return{...e,allKeys:i,symbolKeys:r,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(a)}}function Cd(e,t,n,r,i,a,o){let s=[],c=i.keySet,l=i.catchall._zod,u=l.def.type,d=l.optin,f=l.optout,p=0;for(let i in t){if(o&&n.issues.length!==p){if(hc(n,p))break;p=n.issues.length}if(c.has(i))continue;if(i===`__proto__`){u===`never`&&s.push(i);continue}if(u===`never`){s.push(i);continue}let a=l.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>bd(e,n,i,t,d,f))):bd(a,n,i,t,d,f)}return s.length&&n.issues.push({code:`unrecognized_keys`,keys:s,input:t,inst:a,continue:!0}),e.length?Promise.all(e).then(()=>n):n}var wd=H(`$ZodObject`,(e,t)=>{xu.init(e,t);let n=Object.getOwnPropertyDescriptor(t,`shape`),r=n?.get?n.get.raw:t.shape??{};if(r){let e=()=>{let n={...r};return Object.defineProperty(t,"shape",{value:n}),e.raw=n,n};e.raw=r,Object.defineProperty(t,"shape",{get:e})}let i=Ns(()=>Sd(t));Ic(e,`propValues`,e=>{let t=e.def.shape,n={};for(let e in t){let r=t[e]._zod;if(r.values){Object.prototype.hasOwnProperty.call(n,e)||Ls(n,e,new Set);for(let t of r.values)n[e].add(t);r.optin!==void 0&&n[e].add(void 0)}}return n});let a=Js,o=t.catchall,s,c=Kc.memoizer;c?.attach(e),e._zod.parse=(t,n)=>{s??=i.value;let r=t.value;if(!a(r))return t.issues.push({expected:`object`,code:`invalid_type`,input:r,inst:e}),t;t.value=c?c.alloc(e,t,{},n):{};let l=[],u=s.shape,d=n?.abortEarly,f=t.issues.length;for(let e of s.allKeys){if(d&&t.issues.length!==f){if(hc(t,f))break;f=t.issues.length}if(e===`__proto__`)continue;let i=u[e],a=i._zod.optin,o=i._zod.optout,s=i._zod.run({value:r[e],issues:[]},n);s instanceof Promise?l.push(s.then(n=>bd(n,t,e,r,a,o))):bd(s,t,e,r,a,o)}return o?Cd(l,r,t,n,i.value,e,d===!0):l.length?Promise.all(l).then(()=>t):t}}),Td=H(`$ZodObjectJIT`,(e,t)=>{wd.init(e,t);let n=e._zod.parse,r=Ns(()=>Sd(t)),i=Kc.memoizer,a=t=>{let n=r.value,a=n.symbolKeys,o=new yu([`payload`,`ctx`],{shape:t,inst:e,memo:i,syms:a}),s=e=>`shape[${e}]._zod.run({ value: input[${e}], issues: [] }, ctx)`,c=(e,t)=>`
|
|
13
|
+
let ${e}_ab = false;
|
|
14
|
+
for (let i = 0; i < ${e}.issues.length; i++) {
|
|
15
|
+
const iss = ${e}.issues[i];
|
|
16
|
+
iss.path = iss.path ? [${t}, ...iss.path] : [${t}];
|
|
17
|
+
payload.issues.push(iss);
|
|
18
|
+
if (iss.continue !== true) ${e}_ab = true;
|
|
19
|
+
}
|
|
20
|
+
if (${e}_ab && ctx && ctx.abortEarly) {
|
|
21
|
+
payload.value = newResult;
|
|
22
|
+
return payload;
|
|
23
|
+
}`;o.write(`const input = payload.value;`);let l=Object.create(null),u=0;for(let e of n.allKeys)l[e]=`key_${u++}`;o.write(i?`const newResult = memo.alloc(inst, payload, {}, ctx);`:`const newResult = {};`);for(let e of n.allKeys){if(e===`__proto__`)continue;let n=l[e],r=typeof e==`symbol`?`syms[${a.indexOf(e)}]`:Gs(e),i=`${r} in input`,u=t[e],d=u?._zod?.optin,f=d!==void 0,p=u?._zod?.optout===`optional`;if(o.write(`const ${n} = ${s(r)};`),f&&p){let e=d===`optional`?`${n}_present`:`${n}.value !== undefined || ${n}_present`;o.write(`
|
|
24
|
+
const ${n}_present = ${i};
|
|
25
|
+
if (!${n}.issues.length || ${n}_present) {
|
|
26
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (${e}) {
|
|
30
|
+
newResult[${r}] = ${n}.value;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
`)}else f?(o.write(`
|
|
35
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
36
|
+
}
|
|
37
|
+
`),d===`defaulted`?o.write(`newResult[${r}] = ${n}.value;`):o.write(`
|
|
38
|
+
if (${n}.value !== undefined || ${i}) {
|
|
39
|
+
newResult[${r}] = ${n}.value;
|
|
40
|
+
}
|
|
41
|
+
`)):o.write(`
|
|
42
|
+
const ${n}_present = ${i};
|
|
43
|
+
if (${n}.issues.length) {${c(n,r)}
|
|
44
|
+
}
|
|
45
|
+
if (!${n}_present && !${n}.issues.length) {
|
|
46
|
+
payload.issues.push({
|
|
47
|
+
code: "invalid_type",
|
|
48
|
+
expected: "nonoptional",
|
|
49
|
+
input: undefined,
|
|
50
|
+
path: [${r}]
|
|
51
|
+
});
|
|
52
|
+
if (ctx && ctx.abortEarly) {
|
|
53
|
+
payload.value = newResult;
|
|
54
|
+
return payload;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if (${n}_present) {
|
|
59
|
+
newResult[${r}] = ${n}.value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}return o.write(`payload.value = newResult;`),o.write(`return payload;`),o.compile()},o,s=Js,c=!Kc.jitless,l=c&&Ys.value,u=t.catchall,d;e._zod.parse=(i,f)=>{d??=r.value;let p=i.value;return s(p)?c&&l&&f?.async===!1&&f.jitless!==!0?(o||=a(t.shape),i=o(i,f),u?Cd([],p,i,f,d,e,f?.abortEarly===!0):i):n(i,f):(i.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),i)}});function Ed(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!hc(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>xc(e,r,qc())))}),t)}var Dd=H(`$ZodUnion`,(e,t)=>{xu.init(e,t),Ic(e,`optin`,e=>e.def.options.some(e=>e._zod.optin===`defaulted`)?`defaulted`:e.def.options.some(e=>e._zod.optin!==void 0)?`optional`:void 0),Ic(e,`optout`,e=>e.def.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),Ic(e,`values`,e=>{if(e.def.options.every(e=>e._zod.values))return new Set(e.def.options.flatMap(e=>Array.from(e._zod.values)))}),Ic(e,`pattern`,e=>{if(e.def.options.every(e=>e._zod.pattern)){let t=e.def.options.map(e=>e._zod.pattern);return RegExp(`^(${t.map(e=>Fs(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Ed(t,r,e,i)):Ed(o,r,e,i)}}),Od=H(`$ZodIntersection`,(e,t)=>{xu.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Ad(e,t,n)):Ad(e,i,a)}});function kd(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(Xs(e)&&Xs(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};Object.prototype.hasOwnProperty.call(i,`__proto__`)&&delete i.__proto__;for(let n of r){if(n===`__proto__`)continue;let r=kd(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=kd(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Ad(e,t,n){let r=new Map,i,a=new Map,o=(e,t)=>{let n;if(e.code===`unrecognized_keys`&&!e.path?.length)i??=e,n=e.keys;else if(e.code===`invalid_key`&&e.origin===`record`&&e.path?.length===1){let t=String(e.path[0]);a.has(t)||a.set(t,e),n=[t]}else return!1;for(let e of n)r.has(e)||r.set(e,{}),r.get(e)[t]=!0;return!0};for(let n of t.issues)o(n,`l`)||e.issues.push(n);for(let t of n.issues)o(t,`r`)||e.issues.push(t);let s=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(s.length){let t=i?s.filter(e=>i.keys.includes(e)):[];t.length&&e.issues.push({...i,keys:t});for(let n of s)!t.includes(n)&&a.has(n)&&e.issues.push(a.get(n))}let c=kd(t.value,n.value);if(!c.valid){if(hc(e))return e;throw Error(`Unmergable intersection. Error path: ${JSON.stringify(c.mergeErrorPath)}`)}return e.value=c.data,e}var jd=H(`$ZodRecord`,(e,t)=>{xu.init(e,t);let n=Kc.memoizer;n?.attach(e),e._zod.parse=(r,i)=>{let a=r.value;if(!Xs(a))return r.issues.push({expected:`record`,code:`invalid_type`,input:a,inst:e}),r;let o=[],s=t.keyType._zod.values;if(s&&!t.partial){r.value=n?n.alloc(e,r,{},i):{};let c=new Set;for(let n of s)if(typeof n==`string`||typeof n==`number`||typeof n==`symbol`){if(c.add(typeof n==`number`?n.toString():n),n===`__proto__`)continue;let s=t.keyType._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(s.issues.length){r.issues.push({code:`invalid_key`,origin:`record`,issues:s.issues.map(e=>xc(e,i,qc())),input:n,path:[n],inst:e});continue}let l=s.value;if(l===`__proto__`)continue;let u=t.valueType._zod.run({value:a[n],issues:[]},i);u instanceof Promise?o.push(u.then(e=>{e.issues.length&&r.issues.push(..._c(n,e.issues)),r.value[l]=e.value})):(u.issues.length&&r.issues.push(..._c(n,u.issues)),r.value[l]=u.value)}let l;for(let e in a)if(!c.has(e)){if(t.mode===`loose`){if(e===`__proto__`)continue;r.value[e]=a[e]}else l??=[],l.push(e)}l&&l.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:l,continue:!0})}else{r.value=n?n.alloc(e,r,{},i):{};let c;for(let n of Reflect.ownKeys(a)){if(n===`__proto__`||!Object.prototype.propertyIsEnumerable.call(a,n))continue;let l=t.keyType._zod.run({value:n,issues:[]},i);if(l instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof n==`string`&&Zl.test(n)&&l.issues.length){let e=t.keyType._zod.run({value:Number(n),issues:[]},i);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(l=e)}if(l.issues.length){t.mode===`loose`?r.value[n]=a[n]:s?(c??=[],c.push(n)):r.issues.push({code:`invalid_key`,origin:`record`,issues:l.issues.map(e=>xc(e,i,qc())),input:n,path:[n],inst:e});continue}let u=l.value;if(u===`__proto__`)continue;let d=t.valueType._zod.run({value:a[n],issues:[]},i);d instanceof Promise?o.push(d.then(e=>{e.issues.length&&r.issues.push(..._c(n,e.issues)),r.value[u]=e.value})):(d.issues.length&&r.issues.push(..._c(n,d.issues)),r.value[u]=d.value)}c&&c.length>0&&r.issues.push({code:`unrecognized_keys`,input:a,inst:e,keys:c,continue:!0})}return o.length?Promise.all(o).then(()=>r):r}}),Md=H(`$ZodEnum`,(e,t)=>{xu.init(e,t);let n=ks(t.entries),r=new Set(n);e._zod.values=r,Ic(e,`pattern`,e=>{let t=ks(e.def.entries).filter(e=>Qs.has(typeof e));return RegExp(t.length?`^(${t.map(e=>$s(e.toString())).join(`|`)})$`:`^[^\\s\\S]$`)}),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),Nd=H(`$ZodTransform`,(e,t)=>{xu.init(e,t),e._zod.optin=`optional`,Kc.memoizer?.guard(e),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Gc(e.constructor.name);let i=t.transform(n.value,n);if(r.async)return(i instanceof Promise?i:Promise.resolve(i)).then(e=>(n.value=e,n));if(i instanceof Promise)throw new Wc;return n.value=i,n}});function Pd(e,t){return e.value=t.issues.length?void 0:t.value,e}var Fd=H(`$ZodOptional`,(e,t)=>{xu.init(e,t),Ic(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),e._zod.optout=`optional`,Ic(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t,void 0]):void 0}),Ic(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Fs(t.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(e.value===void 0){if(t.innerType._zod.optin!==`defaulted`)return e;let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(t=>Pd(e,t)):Pd(e,r)}return t.innerType._zod.run(e,n)}}),Id=H(`$ZodExactOptional`,(e,t)=>{Fd.init(e,t),Ic(e,`values`,e=>e.def.innerType._zod.values),Ic(e,`pattern`,e=>e.def.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Ld=H(`$ZodNullable`,(e,t)=>{xu.init(e,t),Ic(e,`optin`,e=>e.def.innerType._zod.optin),Ic(e,`optout`,e=>e.def.innerType._zod.optout),Ic(e,`pattern`,e=>{let t=e.def.innerType._zod.pattern;return t?RegExp(`^(${Fs(t.source)}|null)$`):void 0}),Ic(e,`values`,e=>e.def.innerType._zod.values?new Set([...e.def.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Rd=H(`$ZodDefault`,(e,t)=>{xu.init(e,t),e._zod.optin=`defaulted`,Ic(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>zd(e,t)):zd(r,t)}});function zd(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Bd=H(`$ZodPrefault`,(e,t)=>{xu.init(e,t),e._zod.optin=`defaulted`,Ic(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Vd=H(`$ZodNonOptional`,(e,t)=>{xu.init(e,t),Ic(e,`values`,e=>{let t=e.def.innerType._zod.values;return t?new Set([...t].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Hd(t,e)):Hd(i,e)}});function Hd(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}function Ud(e,t,n,r){return t.issues.length?(e.value=n.catchValue({...t,value:e.value,error:{issues:t.issues.map(e=>xc(e,r,qc()))},input:e.value}),e):(e.value=t.value,t.memo&&(e.memo=!0),e)}var Wd=H(`$ZodCatch`,(e,t)=>{xu.init(e,t),Ic(e,`optin`,e=>e.def.innerType._zod.optin===`defaulted`?`defaulted`:`optional`),Ic(e,`optout`,e=>e.def.innerType._zod.optout),Ic(e,`values`,e=>e.def.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run({value:e.value,issues:[]},n);return r instanceof Promise?r.then(r=>Ud(e,r,t,n)):Ud(e,r,t,n)}}),Gd=H(`$ZodPipe`,(e,t)=>{xu.init(e,t),Ic(e,`values`,e=>e.def.in._zod.values),Ic(e,`optin`,e=>e.def.in._zod.optin),Ic(e,`optout`,e=>e.def.out._zod.optout),Ic(e,`propValues`,e=>e.def.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Kd(e,t.in,n)):Kd(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Kd(e,t.out,n)):Kd(r,t.out,n)}});function Kd(e,t,n){return e.issues.some(e=>e.code!==`unrecognized_keys`)?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},n)}var qd=H(`$ZodReadonly`,(e,t)=>{xu.init(e,t),Ic(e,`propValues`,e=>e.def.innerType._zod.propValues),Ic(e,`values`,e=>e.def.innerType._zod.values),Ic(e,`optin`,e=>e.def.innerType?._zod?.optin),Ic(e,`optout`,e=>e.def.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Jd):Jd(r)}});function Jd(e){return e.memo||(e.value=Object.freeze(e.value)),e}var Yd=H(`$ZodCustom`,(e,t)=>{tu.init(e,t),xu.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Xd(t,n,r,e));Xd(i,n,r,e)}});function Xd(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(Ec(e))}}var Zd=class extends Error{constructor(){super(`Cannot parse a reference cycle that closes through a transform`),this.name=`ZodCyclicError`}},Qd=`~memo`,$d=[];function ef(e){return typeof e==`object`&&!!e}function tf(e){return e.map(e=>e.path?{...e,path:e.path.slice()}:{...e})}var nf=new WeakMap,rf=0,af=1,of=2;function sf(e,t,n){let r=nf.get(e);if(r!==void 0)return r?of:rf;if(t.has(e))return of;t.add(e);let i=rf,a=e=>{if(i!==of&&e?._zod){let r=sf(e,t,n);r>i&&(i=r)}},o=(e,r)=>{let i=rf;for(let a of Reflect.ownKeys(e)){let o=Object.getOwnPropertyDescriptor(e,a);if(r&&!o.enumerable)continue;let s=o.get?af:o.value?._zod?sf(o.value,t,n):rf;s>i&&(i=s)}return i},s=e=>{e>i&&(i=e)},c=e._zod.def;switch(c.type){case`object`:{let e=Rs(c);s(e?o(e,!0):af),a(c.catchall);break}case`array`:a(c.element);break;case`tuple`:for(let e of c.items)a(e);a(c.rest);break;case`record`:case`map`:a(c.keyType),a(c.valueType);break;case`set`:a(c.valueType);break;case`union`:for(let e of c.options)a(e);break;case`intersection`:a(c.left),a(c.right);break;case`optional`:case`nullable`:case`default`:case`prefault`:case`catch`:case`readonly`:case`nonoptional`:case`promise`:case`success`:a(c.innerType);break;case`pipe`:a(c.in),a(c.out);break;case`function`:a(c.input),a(c.output);break;case`lazy`:{let r=c._cachedInner??(n?e._zod.innerType:void 0);s(r?sf(r,t,!1):af);break}case`template_literal`:case`string`:case`number`:case`int`:case`boolean`:case`bigint`:case`symbol`:case`undefined`:case`null`:case`void`:case`never`:case`any`:case`unknown`:case`date`:case`nan`:case`enum`:case`literal`:case`file`:case`transform`:case`custom`:break;default:for(let e in c){let t=Object.getOwnPropertyDescriptor(c,e);if(!t||t.get)continue;let n=t.value;if(n&&typeof n==`object`){if(n._zod)a(n);else if(Array.isArray(n))for(let e of n)a(e)}}}return t.delete(e),cf(e,i)}function cf(e,t){return t!==af&&nf.set(e,t===of),t}function lf(e,t){let n=e.buckets.get(t);return n||(n=new WeakMap,e.buckets.set(t,n)),n}var uf,df=[],ff={alloc(e,t,n){let r=uf;if(!r)return n;uf=void 0;let i={value:n,issues:null};return r.set(t.value,i),df.push(i),n},guard(e){var t;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,n=(e,n)=>{if(n.direction!==`backward`&&mf(n,e.value))throw new Zd;return t(e,n)};e._zod.parse=n,e._zod.run===t&&(e._zod.run=n)})},attach(e){var t;let n,r=!1,i,a;(t=e._zod).deferred??(t.deferred=[]),e._zod.deferred.push(()=>{let t=e._zod.parse,o=(s,c)=>{if(n===void 0){let i=sf(e,new Set,!1);if(i===rf)return e._zod.parse=t,e._zod.run===o&&(e._zod.run=t),t(s,c);i===of||r?n=!0:r=!0}let l=s.value;if(!ef(l))return t(s,c);let u=c[Qd];u||(u={buckets:new WeakMap,backEdges:void 0},c[Qd]=u);let d;i===c?d=a:(d=lf(u,e),i=c,a=d);let f=d.get(l);if(f)return s.value=f.value,f.issues?f.issues.length&&s.issues.push(...tf(f.issues)):(s.memo=!0,u.backEdges??(u.backEdges=new WeakSet),u.backEdges.add(f.value)),s;uf=d;let p=df.length,m=t(s,c);uf=void 0;let h=df.length>p?df.pop():void 0;return m instanceof Promise?m.then(e=>(h&&(h.issues=e.issues.length?tf(e.issues):$d),e)):(h&&(h.issues=m.issues.length?tf(m.issues):$d),m)};e._zod.parse=o,e._zod.run===t&&(e._zod.run=o)})}};function pf(){return ff}function mf(e,t){let n=e[Qd]?.backEdges;return n!==void 0&&ef(t)&&n.has(t)}var hf=()=>{let e={string:{unit:`characters`,verb:`to have`},file:{unit:`bytes`,verb:`to have`},array:{unit:`items`,verb:`to have`},set:{unit:`items`,verb:`to have`},map:{unit:`entries`,verb:`to have`}};function t(t){return e[t]??null}let n={regex:`input`,email:`email address`,url:`URL`,emoji:`emoji`,uuid:`UUID`,uuidv4:`UUIDv4`,uuidv6:`UUIDv6`,nanoid:`nanoid`,guid:`GUID`,cuid:`cuid`,cuid2:`cuid2`,ulid:`ULID`,xid:`XID`,ksuid:`KSUID`,datetime:`ISO datetime`,date:`ISO date`,time:`ISO time`,duration:`ISO duration`,ipv4:`IPv4 address`,ipv6:`IPv6 address`,mac:`MAC address`,cidrv4:`IPv4 range`,cidrv6:`IPv6 range`,base64:`base64-encoded string`,base64url:`base64url-encoded string`,json_string:`JSON string`,e164:`E.164 number`,currency_code:`currency code`,credit_card:`credit card number`,iban:`IBAN`,jwt:`JWT`,template_literal:`input`},r={nan:`NaN`};function i(e,t){return e===`number`&&typeof t==`number`&&!Number.isFinite(t)?String(t):r[e]??e}return e=>{switch(e.code){case`invalid_type`:return`Invalid input: expected ${i(e.expected)}, received ${i(Tc(e.input),e.input)}`;case`invalid_value`:return e.values.length===1?`Invalid input: expected ${nc(e.values[0])}`:`Invalid option: expected one of ${As(e.values,`|`)}`;case`too_big`:{let n=e.exact?`exactly `:e.inclusive?`<=`:`<`,r=t(e.origin);return r?`Too big: expected ${e.origin??`value`} to have ${n}${e.maximum.toString()} ${r.unit??`elements`}`:`Too big: expected ${e.origin??`value`} to be ${n}${e.maximum.toString()}`}case`too_small`:{let n=e.exact?`exactly `:e.inclusive?`>=`:`>`,r=t(e.origin);return r?`Too small: expected ${e.origin} to have ${n}${e.minimum.toString()} ${r.unit}`:`Too small: expected ${e.origin} to be ${n}${e.minimum.toString()}`}case`invalid_format`:{let t=e;return t.format===`starts_with`?`Invalid string: must start with "${t.prefix}"`:t.format===`ends_with`?`Invalid string: must end with "${t.suffix}"`:t.format===`includes`?`Invalid string: must include "${t.includes}"`:t.format===`regex`?`Invalid string: must match pattern ${t.pattern}`:`Invalid ${n[t.format]??e.format}`}case`not_multiple_of`:return`Invalid number: must be a multiple of ${e.divisor}`;case`unrecognized_keys`:return`Unrecognized key${e.keys.length>1?`s`:``}: ${As(e.keys,`, `)}`;case`invalid_key`:return`Invalid key in ${e.origin}`;case`invalid_union`:return e.options&&Array.isArray(e.options)&&e.options.length>0?`Invalid discriminator value. Expected ${e.options.map(e=>`'${e}'`).join(` | `)}`:e.inclusive===!1?`Invalid input: more than one option matched`:`Invalid input`;case`invalid_element`:return`Invalid value in ${e.origin}`;default:return`Invalid input`}}};function gf(){return{localeError:hf()}}var _f,vf=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function yf(){return new vf}(_f=globalThis).__zod_globalRegistry??(_f.__zod_globalRegistry=yf());var bf=globalThis.__zod_globalRegistry;function xf(e){return e.checks&&=[...e.checks],e}function Sf(e,t){return new e(xf({type:`string`,...tc(t)}))}function Cf(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...tc(t)})}function wf(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...tc(t)})}function Tf(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...tc(t)})}function Ef(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...tc(t)})}function Df(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...tc(t)})}function Of(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...tc(t)})}function kf(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...tc(t)})}function Af(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...tc(t)})}function jf(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...tc(t)})}function Mf(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...tc(t)})}function Nf(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...tc(t)})}function Pf(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...tc(t)})}function Ff(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...tc(t)})}function If(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...tc(t)})}function Lf(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...tc(t)})}function Rf(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...tc(t)})}function zf(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...tc(t)})}function Bf(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...tc(t)})}function Vf(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...tc(t)})}function Hf(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...tc(t)})}function Uf(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...tc(t)})}function Wf(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...tc(t)})}function Gf(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...tc(t)})}function Kf(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...tc(t)})}function qf(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...tc(t)})}function Jf(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...tc(t)})}function Yf(e,t){return new e(xf({type:`number`,checks:[],...tc(t)}))}function Xf(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...tc(t)})}function Zf(e,t){return new e({type:`boolean`,...tc(t)})}function Qf(e){return new e({type:`unknown`})}function $f(e,t){return new e({type:`never`,...tc(t)})}function ep(e,t){return new iu({check:`less_than`,...tc(t),value:e,inclusive:!1})}function tp(e,t){return new iu({check:`less_than`,...tc(t),value:e,inclusive:!0})}function np(e,t){return new au({check:`greater_than`,...tc(t),value:e,inclusive:!1})}function rp(e,t){return new au({check:`greater_than`,...tc(t),value:e,inclusive:!0})}function ip(e,t){return new ou({check:`multiple_of`,...tc(t),value:e})}function ap(e,t){return new cu({check:`max_length`,...tc(t),maximum:e})}function op(e,t){return new lu({check:`min_length`,...tc(t),minimum:e})}function sp(e,t){return new uu({check:`length_equals`,...tc(t),length:e})}function cp(e,t){return new fu({check:`string_format`,format:`regex`,...tc(t),pattern:e})}function lp(e){return new pu({check:`string_format`,format:`lowercase`,...tc(e)})}function up(e){return new mu({check:`string_format`,format:`uppercase`,...tc(e)})}function dp(e,t){return new hu({check:`string_format`,format:`includes`,...tc(t),includes:e})}function fp(e,t){return new gu({check:`string_format`,format:`starts_with`,...tc(t),prefix:e})}function pp(e,t){return new _u({check:`string_format`,format:`ends_with`,...tc(t),suffix:e})}function mp(e){return new vu({check:`overwrite`,tx:e})}function hp(e){return mp(t=>t.normalize(e))}function gp(){return mp(e=>e.trim())}function _p(){return mp(e=>e.toLowerCase())}function vp(){return mp(e=>e.toUpperCase())}function yp(){return mp(e=>Ks(e))}function bp(e,t,n){return new e({type:`array`,element:t,...tc(n)})}function xp(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...tc(n)})}function Sp(e,t){let n=Cp(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(Ec(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,`input`in r||(r.input=t.value),r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(Ec(r))}},e(t.value,t)),t);return n}function Cp(e,t){let n=new tu({check:`custom`,...tc(t)});return n._zod.check=e,n}function wp(e,...t){for(let n of t)for(let t of Reflect.ownKeys(n))Object.prototype.propertyIsEnumerable.call(n,t)&&Ls(e,t,n[t]);return e}function Tp(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??bf,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,sharedDefsExtractedFor:void 0,sharedEmitDoneFor:void 0,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,intersections:[],deferred:[],external:e?.external??void 0}}function Ep(e,t,n,r,i){let a=typeof t.unrepresentable==`function`?t.unrepresentable({zodSchema:e,path:r.path,message:i}):t.unrepresentable;if(a===`any`)return!1;if(a===void 0||a===`throw`)throw Error(i);return Object.assign(n,a),!0}function Dp(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o),t.sharedDefsExtractedFor=void 0,t.sharedEmitDoneFor=void 0;let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,Dp(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&wp(o.schema,c),t.io===`input`&&Lp(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Op(e){return e.replace(/~/g,`~0`).replace(/\//g,`~1`)}function kp(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);if(e.external&&e.sharedDefsExtractedFor===e.external)return;let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${Op(a)}`}}let i=`#/${r}/`;if(t[1]===n&&!t[1].schema.id)return{ref:`#`};let a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+Op(a)}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
|
|
63
|
+
|
|
64
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0])a(n);else{if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}(e.metadataRegistry.get(n[0])?.id||r.cycle||r.count>1&&e.reused===`ref`)&&a(n)}}e.external&&(e.sharedDefsExtractedFor=e.external)}function Ap(e){let t=e.anyOf;if(!Array.isArray(t)||t.length===0||e.type!==void 0)return;let n=[];for(let e of t){if(!e||typeof e!=`object`)return;Ap(e);let t=Object.keys(e);if(t.length!==1||t[0]!==`type`)return;let r=e.type;for(let e of Array.isArray(r)?r:[r]){if(typeof e!=`string`)return;n.includes(e)||n.push(e)}}delete e.anyOf,e.type=n.length===1?n[0]:n}var jp=new Set([`type`,`properties`,`required`,`additionalProperties`]),Mp=[`oneOf`,`anyOf`];function Np(e){let t=e.additionalProperties;return t===void 0||t===!1||typeof t!=`object`||!t?null:Object.keys(t).length?t:null}function Pp(e){let t=[];for(let n of e){if(typeof n!=`object`||n.type!==`object`)return null;for(let e in n)if(!jp.has(e))return null;t.push(n)}let n={},r=new Set;for(let e of t){for(let r in e.properties){if(Object.prototype.hasOwnProperty.call(n,r))continue;let e=[];for(let n of t){let t=n.properties?.[r]??Np(n);t!=null&&(e.some(e=>JSON.stringify(e)===JSON.stringify(t))||e.push(t))}Ls(n,r,e.length===1?e[0]:Pp(e)??{allOf:e})}for(let t of e.required??[])r.add(t)}let i={type:`object`,properties:n};if(r.size&&(i.required=[...r]),t.every(e=>e.additionalProperties===!1))i.additionalProperties=!1;else{let e=[];for(let n of t){let t=Np(n);t&&!e.some(e=>JSON.stringify(e)===JSON.stringify(t))&&e.push(t)}e.length===1?i.additionalProperties=e[0]:e.length>1&&(i.additionalProperties={allOf:e})}return i}function Fp(e){let t=e.allOf;if(!Array.isArray(t)||t.length<2)return;for(let t of jp)if(t in e)return;let n=t.filter(e=>Mp.some(t=>Array.isArray(e[t]))),r=null;if(!n.length)r=Pp(t);else{let e=n[0],i=Mp.find(t=>Array.isArray(e[t]));if(Object.keys(e).length!==1)return;let a=t.filter(t=>t!==e),o=e[i].map(e=>Pp([...a,e]));if(o.some(e=>!e))return;r={[i]:o}}r&&(delete e.allOf,wp(e,r))}function Ip(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):wp(i,s),wp(i,a),t._zod.parent===o)for(let e in i)e!==`$ref`&&e!==`allOf`&&(e in a||delete i[e]);if(s.$ref&&n.def)for(let e in i)e!==`$ref`&&e!==`allOf`&&e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e!==`$ref`&&e!==`allOf`&&e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};if(!e.external||e.sharedEmitDoneFor!==e.external){for(let t of[...e.seen.entries()].reverse())r(t[0]);if(e.target!==`openapi-3.0`)for(let t of e.seen.entries())Ap(t[1].def??t[1].schema);for(let t of e.deferred)t();if(e.intersections.length){let t=new Map;for(let n of e.seen.values())for(let e of[n.schema,n.def]){let n=e?.allOf;if(!Array.isArray(n))continue;let r=t.get(n);r?r.push(e):t.set(n,[e])}for(let n of e.intersections)for(let e of t.get(n)??[])Fp(e)}}let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}wp(i,n.defId?n.schema:n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};if(!e.external||e.sharedEmitDoneFor!==e.external)for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,Ls(o,e.defId,e.def))}e.external&&(e.sharedEmitDoneFor=e.external),e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:zp(t,`input`,e.processors),output:zp(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function Lp(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return Lp(r.element,n);if(r.type===`set`)return Lp(r.valueType,n);if(r.type===`lazy`)return Lp(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`||r.type===`catch`)return Lp(r.innerType,n);if(r.type===`intersection`)return Lp(r.left,n)||Lp(r.right,n);if(r.type===`record`||r.type===`map`)return Lp(r.keyType,n)||Lp(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:Lp(r.in,n)||Lp(r.out,n);if(r.type===`object`){for(let e in r.shape)if(Lp(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(Lp(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(Lp(e,n))return!0;return!!(r.rest&&Lp(r.rest,n))}return!1}var Rp=(e,t={})=>n=>{let r=Tp({...n,processors:t});return Dp(e,r),kp(r,e),Ip(r,e)},zp=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Tp({...i??{},target:a,io:t,processors:n});return Dp(e,o),kp(o,e),Ip(o,e)},Bp=(e,t,n)=>{(e[t]===void 0||n>e[t])&&(e[t]=n)},Vp=(e,t,n)=>{(e[t]===void 0||n<e[t])&&(e[t]=n)},Hp=(e,t)=>{Bp(e,`minimum`,t),Vp(e,`maximum`,t)},Up=(e,t)=>{e.multipleOf??=[],e.multipleOf.includes(t)||e.multipleOf.push(t)},Wp=(e,t)=>{e.patterns??=new Set,e.patterns.add(t)},Gp=(e,t)=>{e.mime=e.mime?e.mime.filter(e=>t.includes(e)):[...t]},Kp=(e,t)=>{e.format=t,t.includes(`int`)&&(e.isInt=!0)},qp=(e,t)=>Bp(e,`minimum`,t.minimum),Jp=(e,t)=>Vp(e,`maximum`,t.maximum),Yp=e=>(t,n)=>{Kp(t,n.format);let[r,i]=e[n.format];Bp(t,`minimum`,r),Vp(t,`maximum`,i)},Xp={greater_than:(e,t)=>Bp(e,t.inclusive?`minimum`:`exclusiveMinimum`,t.value),less_than:(e,t)=>Vp(e,t.inclusive?`maximum`:`exclusiveMaximum`,t.value),multiple_of:(e,t)=>Up(e,t.value),number_format:Yp(ic),bigint_format:Yp(ac),min_length:qp,max_length:Jp,length_equals:(e,t)=>Hp(e,t.length),min_size:qp,max_size:Jp,size_equals:(e,t)=>Hp(e,t.size),string_format:(e,t)=>{Kp(e,t.format),t.pattern&&Wp(e,t.pattern),(t.format===`base64`||t.format===`base64url`)&&(e.contentEncoding=t.format),(t.local||t.precision===-1)&&(e.laxFormat=!0)},mime_type:(e,t)=>Gp(e,t.mime)};function Zp(e){let t={},n=e._zod.def,r=e._zod.traits.has(`$ZodCheck`)?[e,...n.checks??[]]:n.checks??[];for(let e of r)Xp[e._zod.def.check]?.(t,e._zod.def);let i=e._zod.bag;i.minimum!==void 0&&Bp(t,`minimum`,i.minimum),i.exclusiveMinimum!==void 0&&Bp(t,`exclusiveMinimum`,i.exclusiveMinimum),i.maximum!==void 0&&Vp(t,`maximum`,i.maximum),i.exclusiveMaximum!==void 0&&Vp(t,`exclusiveMaximum`,i.exclusiveMaximum),i.multipleOf!==void 0&&Up(t,i.multipleOf),i.format!==void 0&&(t.format??=i.format,i.format.includes(`int`)&&(t.isInt=!0)),i.mime&&Gp(t,i.mime);for(let e of i.patterns??[])Wp(t,e);return t}var Qp={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},$p=new Map([[rd,zl],[ad,Bl]]),em=e=>$p.get(e)??e,tm=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l,laxFormat:u}=Zp(e);if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=Qp[s]??s,i.format===``&&delete i.format,(s===`time`||u)&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c].map(em);e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},nm=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,multipleOf:s,exclusiveMaximum:c,exclusiveMinimum:l,isInt:u}=Zp(e);i.type=u?`integer`:`number`;let d=typeof l==`number`&&l>=(a??-1/0),f=typeof c==`number`&&c<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;if(d?p?(i.minimum=l,i.exclusiveMinimum=!0):i.exclusiveMinimum=l:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=c,i.exclusiveMaximum=!0):i.exclusiveMaximum=c:typeof o==`number`&&(i.maximum=o),s){let n=new Set;for(let a of s)Number.isFinite(a)&&a!==0?n.add(Math.abs(a)):Ep(e,t,i,r,`A multipleOf divisor of ${a} cannot be represented in JSON Schema`);let[a,...o]=n;a!==void 0&&(i.multipleOf=a),o.length&&(i.allOf=[...i.allOf??[],...o.map(e=>({multipleOf:e}))])}},rm=(e,t,n,r)=>{n.type=`boolean`},im=(e,t,n,r)=>{n.not={}},am=(e,t,n,r)=>{let i=e._zod.def,a=ks(i.entries);a.length===0?n.not={}:(a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a)},om=(e,t,n,r)=>{Ep(e,t,n,r,`Custom types cannot be represented in JSON Schema`)},sm=(e,t,n,r)=>{Ep(e,t,n,r,`Transforms cannot be represented in JSON Schema`)},cm=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=Zp(e);typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=Dp(a.element,t,{...r,path:[...r.path,`items`]})};function lm(e){let t=e._zod.def;return t.type===`pipe`&&t.in._zod.traits.has(`$ZodTransform`)?lm(t.out):t.type===`catch`?lm(t.innerType):e._zod.optin}var um=(e,t,n,r)=>{let i=n,a=e._zod.def,o=a.shape;if(Object.getOwnPropertySymbols(o).length&&Ep(e,t,i,r,`Symbol keys cannot be represented in JSON Schema`))return;i.type=`object`,i.properties={};for(let e in o)Ls(i.properties,e,Dp(o[e],t,{...r,path:[...r.path,`properties`,e]}));let s=[];for(let e of Object.keys(o)){let n=a.shape[e];(t.io===`input`?lm(n)===void 0:n._zod.optout===void 0)&&s.push(e)}s.length>0&&(i.required=s),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=Dp(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},dm=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>Dp(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},fm=(e,t,n,r)=>{let i=e._zod.def,a=Dp(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=Dp(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1,c=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]];n.allOf=c,t.intersections.push(c)};function pm(e,t,n){if(t.$ref){if(n.has(t))return t;n.add(t);let r=e.get(t)?.def;if(!r)return t;let i=pm(e,r,n);return i===r?t:i}for(let r of[`anyOf`,`oneOf`]){let i=t[r];if(!Array.isArray(i))continue;let a=i.map(t=>pm(e,t,n));a.some((e,t)=>e!==i[t])&&(t={...t,[r]:a})}let r=Array.isArray(t.type)?t.type:[t.type],i=!r.includes(`string`)&&r.some(e=>e===`number`||e===`integer`),a=t.enum??(t.const===void 0?void 0:[t.const]);if(!i&&!a?.some(e=>typeof e==`number`))return t;let{minimum:o,maximum:s,exclusiveMinimum:c,exclusiveMaximum:l,multipleOf:u,format:d,id:f,...p}=t;return p.enum?p.enum=p.enum.map(e=>typeof e==`number`?String(e):e):typeof p.const==`number`&&(p.const=String(p.const)),i&&(p.type=`string`,a||(p.pattern=(r.includes(`number`)?Zl:Xl).source)),p}var mm=new WeakMap;function hm(e){let t=new Map;for(let n of e.seen.values())n.def&&!t.has(n.schema)&&t.set(n.schema,n);let n=new Map;for(let r of mm.get(e)??[]){let i=e.seen.get(r),a=(i?.def??i?.schema)?.propertyNames;if(!a||a===!0||n.has(a))continue;let o=pm(t,a,new Set);o!==a&&n.set(a,o)}if(n.size)for(let t of e.seen.values())for(let e of[t.schema,t.def]){let t=e&&n.get(e.propertyNames);t&&(e.propertyNames=t)}}var gm=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=Zp(o).patterns;if(a.mode===`loose`&&s&&s.size>0){let e=Dp(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)Ls(i.patternProperties,em(t).source,e)}else{if(t.target===`draft-07`||t.target===`draft-2020-12`){i.propertyNames=Dp(a.keyType,t,{...r,path:[...r.path,`propertyNames`]});let n=mm.get(t);n||(n=[],mm.set(t,n),t.deferred.push(()=>hm(t))),n.push(e)}i.additionalProperties=Dp(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]})}let c=o._zod.values,l=t.io===`input`&&lm(a.valueType)!==void 0;if(c&&!a.partial&&!l){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e.map(String))}},_m=(e,t,n,r)=>{let i=e._zod.def,a=Dp(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},vm=(e,t,n,r)=>{let i=e._zod.def;Dp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},ym=Symbol();function bm(e,t,n,r,i){let a=!1,o=JSON.stringify(e,(e,t)=>typeof t==`bigint`?(a=!0,null):t);return a?(Ep(t,n,r,i,`BigInt defaults cannot be represented in JSON Schema`),ym):JSON.parse(o)}var xm=(e,t,n,r)=>{let i=e._zod.def;Dp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o=bm(i.defaultValue,e,t,n,r);o!==ym&&(n.default=o)},Sm=(e,t,n,r)=>{let i=e._zod.def;Dp(i.innerType,t,r);let a=t.seen.get(e);if(a.ref=i.innerType,t.io!==`input`)return;let o=bm(i.defaultValue,e,t,n,r);o!==ym&&(n._prefault=o)},Cm=(e,t,n,r)=>{let i=e._zod.def;Dp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{Ep(e,t,n,r,`Dynamic catch values are not supported in JSON Schema`);return}n.default=o},wm=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;Dp(o,t,r);let s=t.seen.get(e);s.ref=o},Tm=(e,t,n,r)=>{let i=e._zod.def;Dp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Em=(e,t,n,r)=>{let i=e._zod.def;Dp(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Dm=new WeakSet([Object.prototype,Error.prototype]);function Om(e,t,n){Object.defineProperty(e,t,{configurable:!0,enumerable:!1,get(){let e=n(this);return Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0}),e},set(e){Object.defineProperty(this,t,{value:e,configurable:!0,writable:!0})}})}var km=H(`ZodError`,(e,t)=>{$c.init(e,t),e.name=`ZodError`;let n=Object.getPrototypeOf(e);Dm.has(n)||(Dm.add(n),Om(n,`format`,e=>t=>nl(e,t)),Om(n,`flatten`,e=>t=>tl(e,t)),Om(n,`addIssue`,e=>t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,js,2)}),Om(n,`addIssues`,e=>t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,js,2)}),Object.defineProperty(n,"isEmpty",{configurable:!0,enumerable:!1,get(){return this.issues.length===0}}))},void 0,{Parent:Error}),Am=il(km),jm=al(km),Mm=ol(km),Nm=cl(km),Pm=ml(km),Fm=hl(km),Im=gl(km),Lm=_l(km),Rm=vl(km),zm=yl(km),Bm=bl(km),Vm=xl(km);function Hm(){Kc.localeError||qc(gf())}function Um(){Kc.memoizer||qc({memoizer:pf()})}var Wm=H(`ZodType`,(e,t)=>(Hm(),xu.init(e,t),e.def=t,e.type=t.type,e),{check(...e){let t=this.def;return this.clone(Ws(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return ec(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(og(e,t))},superRefine(e,t){return this.check(sg(e,t))},overwrite(e){return this.check(mp(e))},optional(){return Hh(this)},exactOptional(){return Wh(this)},nullable(){return Kh(this)},nullish(){return Hh(Kh(this))},nonoptional(e){return Qh(this,e)},array(){return Oh(this)},or(e){return Mh([this,e])},and(e){return Ph(this,e)},transform(e){return ng(this,Bh(e))},default(e){return Jh(this,e)},prefault(e){return Xh(this,e)},catch(e){return eg(this,e)},pipe(e){return ng(this,e)},readonly(){return ig(this)},describe(e){let t=this.clone();return bf.add(t,{description:e}),t},meta(...e){if(e.length===0)return bf.get(this);let t=this.clone();return bf.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e,...t){return t.length===0?e(this):e(this,...t)},get"~standard"(){return kc(this,`~standard`,{...wu(this),jsonSchema:{input:zp(this,`input`),output:zp(this,`output`)}})},set"~standard"(e){Oc(this,`~standard`,e)},parse:function e(t,n){return Am(this,t,n,{callee:e})},parseAsync:async function e(t,n){return await jm(this,t,n,{callee:e})},safeParse(e,t){return Mm(this,e,t)},async safeParseAsync(e,t){return Nm(this,e,t)},get spa(){return this?.safeParseAsync},set spa(e){Oc(this,`spa`,e)},validate(e,t){return dl(this,e,t)},validateAsync(e,t){return pl(this,e,t)},encode:function e(t,n){return Pm(this,t,n,{callee:e})},decode:function e(t,n){return Fm(this,t,n,{callee:e})},encodeAsync:async function e(t,n){return await Im(this,t,n,{callee:e})},decodeAsync:async function e(t,n){return await Lm(this,t,n,{callee:e})},safeEncode(e,t){return Rm(this,e,t)},safeDecode(e,t){return zm(this,e,t)},async safeEncodeAsync(e,t){return Bm(this,e,t)},async safeDecodeAsync(e,t){return Vm(this,e,t)},toJSONSchema(e){return Rp(this,{})(e)},get description(){return bf.get(this)?.description},get _def(){return this._zod.def}}),Gm=H(`_ZodString`,(e,t)=>{Tu.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>tm(e,t,n,r)},Ac({format:e=>Zp(e).format??null,minLength:e=>Zp(e).minimum??null,maxLength:e=>Zp(e).maximum??null},{regex(...e){return this.check(cp(...e))},includes(...e){return this.check(dp(...e))},startsWith(...e){return this.check(fp(...e))},endsWith(...e){return this.check(pp(...e))},min(...e){return this.check(op(...e))},max(...e){return this.check(ap(...e))},length(...e){return this.check(sp(...e))},nonempty(...e){return this.check(op(1,...e))},lowercase(e){return this.check(lp(e))},uppercase(e){return this.check(up(e))},trim(){return this.check(gp())},normalize(...e){return this.check(hp(...e))},toLowerCase(){return this.check(_p())},toUpperCase(){return this.check(vp())},slugify(){return this.check(yp())}})),Km=H(`ZodString`,(e,t)=>{Tu.init(e,t),Gm.init(e,t)},{email(e){return this.check(Cf(Qm,e))},url(e){return this.check(kf(th,e))},jwt(e){return this.check(Wf(gh,e))},emoji(e){return this.check(Af(nh,e))},guid(e){return this.check(wf($m,e))},uuid(e){return this.check(Tf(eh,e))},uuidv4(e){return this.check(Ef(eh,e))},uuidv6(e){return this.check(Df(eh,e))},uuidv7(e){return this.check(Of(eh,e))},nanoid(e){return this.check(jf(rh,e))},cuid(e){return this.check(Mf(ih,e))},cuid2(e){return this.check(Nf(ah,e))},ulid(e){return this.check(Pf(oh,e))},base64(e){return this.check(Vf(ph,e))},base64url(e){return this.check(Hf(mh,e))},xid(e){return this.check(Ff(sh,e))},ksuid(e){return this.check(If(ch,e))},ipv4(e){return this.check(Lf(lh,e))},ipv6(e){return this.check(Rf(uh,e))},cidrv4(e){return this.check(zf(dh,e))},cidrv6(e){return this.check(Bf(fh,e))},e164(e){return this.check(Uf(hh,e))},datetime(e){return this.check(Gf(Jm,e))},date(e){return this.check(Kf(Ym,e))},time(e){return this.check(qf(Xm,e))},duration(e){return this.check(Jf(Zm,e))}});function U(e){return Sf(Km,e)}var qm=H(`ZodStringFormat`,(e,t)=>{Eu.init(e,t),Gm.init(e,t)}),Jm=H(`ZodISODateTime`,(e,t)=>{Gu.init(e,t),qm.init(e,t)}),Ym=H(`ZodISODate`,(e,t)=>{Ku.init(e,t),qm.init(e,t)}),Xm=H(`ZodISOTime`,(e,t)=>{qu.init(e,t),qm.init(e,t)}),Zm=H(`ZodISODuration`,(e,t)=>{Ju.init(e,t),qm.init(e,t)}),Qm=H(`ZodEmail`,(e,t)=>{ku.init(e,t),qm.init(e,t)}),$m=H(`ZodGUID`,(e,t)=>{Du.init(e,t),qm.init(e,t)}),eh=H(`ZodUUID`,(e,t)=>{Ou.init(e,t),qm.init(e,t)}),th=H(`ZodURL`,(e,t)=>{Lu.init(e,t),qm.init(e,t)}),nh=H(`ZodEmoji`,(e,t)=>{Ru.init(e,t),qm.init(e,t)}),rh=H(`ZodNanoID`,(e,t)=>{zu.init(e,t),qm.init(e,t)}),ih=H(`ZodCUID`,(e,t)=>{Bu.init(e,t),qm.init(e,t)}),ah=H(`ZodCUID2`,(e,t)=>{Vu.init(e,t),qm.init(e,t)}),oh=H(`ZodULID`,(e,t)=>{Hu.init(e,t),qm.init(e,t)}),sh=H(`ZodXID`,(e,t)=>{Uu.init(e,t),qm.init(e,t)}),ch=H(`ZodKSUID`,(e,t)=>{Wu.init(e,t),qm.init(e,t)}),lh=H(`ZodIPv4`,(e,t)=>{Yu.init(e,t),qm.init(e,t)}),uh=H(`ZodIPv6`,(e,t)=>{Qu.init(e,t),qm.init(e,t)}),dh=H(`ZodCIDRv4`,(e,t)=>{$u.init(e,t),qm.init(e,t)}),fh=H(`ZodCIDRv6`,(e,t)=>{td.init(e,t),qm.init(e,t)}),ph=H(`ZodBase64`,(e,t)=>{id.init(e,t),qm.init(e,t)}),mh=H(`ZodBase64URL`,(e,t)=>{sd.init(e,t),qm.init(e,t)}),hh=H(`ZodE164`,(e,t)=>{cd.init(e,t),qm.init(e,t)}),gh=H(`ZodJWT`,(e,t)=>{ud.init(e,t),qm.init(e,t)}),_h=H(`ZodNumber`,(e,t)=>{dd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>nm(e,t,n,r),e.isFinite=!0},Ac({minValue:e=>{let{minimum:t,exclusiveMinimum:n}=Zp(e);return Math.max(t??-1/0,n??-1/0)},maxValue:e=>{let{maximum:t,exclusiveMaximum:n}=Zp(e);return Math.min(t??1/0,n??1/0)},isInt:e=>{let{isInt:t,multipleOf:n}=Zp(e);return!!t||!!n?.some(Number.isSafeInteger)},format:e=>Zp(e).format??null},{gt(e,t){return this.check(np(e,t))},gte(e,t){return this.check(rp(e,t))},min(e,t){return this.check(rp(e,t))},lt(e,t){return this.check(ep(e,t))},lte(e,t){return this.check(tp(e,t))},max(e,t){return this.check(tp(e,t))},int(e){return this.check(bh(e))},safe(e){return this.check(bh(e))},positive(e){return this.check(np(0,e))},nonnegative(e){return this.check(rp(0,e))},negative(e){return this.check(ep(0,e))},nonpositive(e){return this.check(tp(0,e))},multipleOf(e,t){return this.check(ip(e,t))},step(e,t){return this.check(ip(e,t))},finite(){return this}}));function vh(e){return Yf(_h,e)}var yh=H(`ZodNumberFormat`,(e,t)=>{fd.init(e,t),_h.init(e,t)});function bh(e){return Xf(yh,e)}var xh=H(`ZodBoolean`,(e,t)=>{pd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>rm(e,t,n,r)});function Sh(e){return Zf(xh,e)}var Ch=H(`ZodUnknown`,(e,t)=>{md.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function wh(){return Qf(Ch)}var Th=H(`ZodNever`,(e,t)=>{hd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>im(e,t,n,r)});function Eh(e){return $f(Th,e)}var Dh=H(`ZodArray`,(e,t)=>{Um(),yd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>cm(e,t,n,r),e.element=t.element},{min(e,t){return this.check(op(e,t))},nonempty(e){return this.check(op(1,e))},max(e,t){return this.check(ap(e,t))},length(e,t){return this.check(sp(e,t))},unwrap(){return this.element}});function Oh(e,t){return bp(Dh,e,t)}var kh=H(`ZodObject`,(e,t)=>{Um(),Td.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>um(e,t,n,r),Lc(e,`shape`,e=>e._zod.def.shape,!1)},{keyof(){return Rh(Object.keys(this._zod.def.shape))},catchall(e){return this.clone(Ws(this._zod.def,{catchall:e}))},passthrough(){return this.clone(Ws(this._zod.def,{catchall:wh()}))},loose(){return this.clone(Ws(this._zod.def,{catchall:wh()}))},strict(){return this.clone(Ws(this._zod.def,{catchall:Eh()}))},strip(){return this.clone(Ws(this._zod.def,{catchall:void 0}))},extend(e){return lc(this,e)},safeExtend(e){return dc(this,e)},merge(e){return fc(this,e)},pick(e){return oc(this,e)},omit(e){return cc(this,e)},partial(...e){return pc(Vh,this,e[0])},exactPartial(...e){return pc(Uh,this,e[0],`exactPartial`)},required(...e){return mc(Zh,this,e[0])}});function Ah(e,t){return new kh({type:`object`,shape:e??{},...tc(t)})}var jh=H(`ZodUnion`,(e,t)=>{Dd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>dm(e,t,n,r),e.options=t.options});function Mh(e,t){return new jh({type:`union`,options:e,...tc(t)})}var Nh=H(`ZodIntersection`,(e,t)=>{Od.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fm(e,t,n,r)});function Ph(e,t){return new Nh({type:`intersection`,left:e,right:t})}var Fh=H(`ZodRecord`,(e,t)=>{Um(),jd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gm(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Ih(e,t,n){return!t||!t._zod?new Fh({type:`record`,keyType:U(),valueType:e,...tc(t)}):new Fh({type:`record`,keyType:e,valueType:t,...tc(n)})}var Lh=H(`ZodEnum`,(e,t)=>{Md.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>am(e,t,n,r),e.enum=t.entries,e.options=[...e._zod.values];let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Lh({...t,checks:[],...tc(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Lh({...t,checks:[],...tc(r),entries:i})}});function Rh(e,t){return new Lh({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...tc(t)})}var zh=H(`ZodTransform`,(e,t)=>{Um(),Nd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>sm(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new Gc(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(Ec(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,`input`in t||(t.input=n.value),t.inst??=e,n.issues.push(Ec(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n)):(n.value=i,n)}});function Bh(e){return new zh({type:`transform`,transform:e})}var Vh=H(`ZodOptional`,(e,t)=>{Fd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Em(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Hh(e){return new Vh({type:`optional`,innerType:e})}var Uh=H(`ZodExactOptional`,(e,t)=>{Id.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Em(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Wh(e){return new Uh({type:`optional`,innerType:e})}var Gh=H(`ZodNullable`,(e,t)=>{Ld.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_m(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Kh(e){return new Gh({type:`nullable`,innerType:e})}var qh=H(`ZodDefault`,(e,t)=>{Rd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xm(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Jh(e,t){return new qh({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():Zs(t)}})}var Yh=H(`ZodPrefault`,(e,t)=>{Bd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Sm(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Xh(e,t){return new Yh({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():Zs(t)}})}var Zh=H(`ZodNonOptional`,(e,t)=>{Vd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vm(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Qh(e,t){return new Zh({type:`nonoptional`,innerType:e,...tc(t)})}var $h=H(`ZodCatch`,(e,t)=>{Wd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Cm(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function eg(e,t){return new $h({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:zc(t)})}var tg=H(`ZodPipe`,(e,t)=>{Gd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>wm(e,t,n,r),e.in=t.in,e.out=t.out});function ng(e,t){return new tg({type:`pipe`,in:e,out:t})}var rg=H(`ZodReadonly`,(e,t)=>{qd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Tm(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function ig(e){return new rg({type:`readonly`,innerType:e})}var ag=H(`ZodCustom`,(e,t)=>{Yd.init(e,t),Wm.init(e,t),e._zod.processJSONSchema=(t,n,r)=>om(e,t,n,r)});function og(e,t={}){return xp(ag,e,t)}function sg(e,t){return Sp(e,t)}var cg=Ih(U(),wh()).optional();Ah({modelId:U().min(2).max(32).regex(/^[a-zA-Z0-9_-]+$/,`modelId must be identifier-safe`),traits:Ih(U(),vh().min(0).max(1))});var lg=Rh([`turn-loop`,`batch-trajectory`,`batch-point`]),ug=Ah({runId:U().min(1),scenario:Ah({id:U().min(1),name:U().min(1),version:U().optional()}),seed:vh().int().optional(),mode:lg,startedAt:U().datetime(),completedAt:U().datetime().optional(),forkedFrom:Ah({parentRunId:U().min(1),atTurn:vh().int().min(0)}).optional(),scenarioExtensions:cg}),dg=Ah({metrics:Ih(U(),vh()),capacities:Ih(U(),vh()).optional(),statuses:Ih(U(),Mh([U(),Sh()])).optional(),politics:Ih(U(),Mh([vh(),U(),Sh()])).optional(),environment:Ih(U(),Mh([vh(),U(),Sh()])).optional(),scenarioExtensions:cg}),fg=Ah({agentId:U().min(1),name:U().min(1),department:U().min(1),role:U().min(1),rank:Rh([`junior`,`senior`,`lead`,`chief`]).optional(),alive:Sh(),marsborn:Sh().optional(),psychScore:vh().min(0).max(1).optional(),age:vh().min(0).optional(),generation:vh().int().min(0).optional(),partnerId:U().optional(),childrenIds:Oh(U()).optional(),featured:Sh().optional(),mood:U().optional(),shortTermMemory:Oh(U()).optional()}),pg=Ah({turn:vh().int().min(0),time:vh(),agents:Oh(fg),population:vh().int().min(0),morale:vh().min(0).max(1).optional(),births:vh().int().min(0).optional(),deaths:vh().int().min(0).optional(),scenarioExtensions:cg}),mg=Ah({value:vh(),min:vh(),max:vh(),label:U().min(1)}),hg=Ah({label:U().min(1),value:U().min(1),direction:Rh([`up`,`down`,`stable`]).optional(),color:U().optional()}),gg=Ah({time:vh(),label:U().min(1),narrative:U().optional(),score:mg.optional(),highlightMetrics:Oh(hg).optional(),confidence:vh().min(0).max(1).optional(),reasoning:U().optional(),worldSnapshot:dg.optional(),scenarioExtensions:cg}),_g=Ah({time:vh(),metrics:Ih(U(),vh()),scenarioExtensions:cg}),vg=Ah({timeUnit:Ah({singular:U().min(1),plural:U().min(1)}),points:Oh(_g).optional(),timepoints:Oh(gg).optional()}),yg=Ah({text:U().min(1),url:U().min(1),doi:U().optional(),context:U().default(``)}),bg=Ah({risks:Oh(Ah({severity:Rh([`low`,`medium`,`high`,`critical`]),description:U().min(1)})).optional(),opportunities:Oh(Ah({impact:Rh([`low`,`medium`,`high`]),description:U().min(1)})).optional(),recommendedActions:Oh(U()).optional(),citations:Oh(yg).optional(),openQuestions:Oh(U()).optional()}),xg=Ah({domain:U().min(1),summary:U().min(1),trajectory:Rh([`positive`,`mixed`,`negative`,`neutral`]).optional(),confidence:vh().min(0).max(1).optional(),detail:bg.optional(),scenarioExtensions:cg}),Sg=Ah({label:U().min(1),severity:Rh([`low`,`medium`,`high`]),detail:U().min(1),scenarioExtensions:cg}),Cg=Rh([`risky_success`,`risky_failure`,`conservative_success`,`conservative_failure`]),wg=Ah({time:vh(),actor:U().optional(),choice:U().min(1),rationale:U().optional(),reasoning:U().optional(),outcome:Cg.optional(),scenarioExtensions:cg}),Tg=Ah({label:U().min(1),value:Mh([U(),vh()]),unit:U().optional(),recordedAt:U().datetime().optional()}),Eg=Ah({id:U().min(1),category:U().optional(),value:U().optional(),interpretation:U().optional()}),Dg=Ah({id:U().min(1),name:U().min(1),profile:Ih(U(),wh()).optional(),signals:Oh(Tg).optional(),markers:Oh(Eg).optional(),personality:Ih(U(),vh()).optional(),conditions:Oh(U()).optional(),scenarioExtensions:cg}),Og=Ah({id:U().min(1),name:U().min(1),description:U().min(1),category:U().optional(),mechanism:U().optional(),targetBehaviors:Oh(U()).optional(),duration:Ah({value:vh(),unit:U().min(1)}).optional(),adherenceProfile:Ah({expected:vh().min(0).max(1),risks:Oh(U()).optional()}).optional(),scenarioExtensions:cg}),kg=Ah({totalUSD:vh().min(0),llmCalls:vh().int().min(0).optional(),inputTokens:vh().int().min(0).optional(),outputTokens:vh().int().min(0).optional(),cachedReadTokens:vh().int().min(0).optional(),cacheSavingsUSD:vh().min(0).optional(),breakdown:Ih(U(),vh()).optional()}),Ag=Ah({kind:Rh([`auth`,`quota`,`rate_limit`,`network`,`unknown`]),provider:U().min(1),message:U(),actionUrl:U().url().optional()}),jg=Ah({name:U().min(1),department:U().optional(),description:U().optional(),approved:Sh(),confidence:vh().min(0).max(1).optional()}),Mg=Ah({metadata:ug,overview:U().optional(),assumptions:Oh(U()).optional(),leveragePoints:Oh(U()).optional(),disclaimer:U().optional(),trajectory:vg.optional(),subject:Dg.optional(),intervention:Og.optional(),specialistNotes:Oh(xg).optional(),riskFlags:Oh(Sg).optional(),decisions:Oh(wg).optional(),finalState:dg.optional(),finalSwarm:pg.optional(),fingerprint:Ih(U(),Mh([vh(),U()])).optional(),citations:Oh(yg).optional(),forgedTools:Oh(jg).optional(),cost:kg.optional(),providerError:Ag.nullable().optional(),aborted:Sh().optional(),scenarioExtensions:cg}),Ng=50;function Pg(e){let t=Mg.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 Fg(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 Ig(e.artifacts,e.bundleId)}if(Array.isArray(t))return Ig(t,void 0);let n=Pg(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 Ig(e,t){if(e.length===0)return{kind:`error`,message:`Bundle is empty`};if(e.length>Ng)return{kind:`error`,message:`Bundle exceeds the ${Ng}-artifact cap (got ${e.length})`};let n=[];for(let t=0;t<e.length;t+=1){let r=e[t],i=Pg(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 Lg=10485760;function Rg({onLoaded:e}){let[t,n]=L.useState(!1),[r,i]=L.useState(null),a=L.useRef(null),o=L.useCallback(async t=>{if(i(null),t.size>Lg){i({message:`File is too large (max ${Lg/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=Fg(n);r.kind===`error`?i({message:r.message,hint:r.hint}):e(r,t.name)},[e]),s=L.useCallback(e=>{e.preventDefault(),n(!1);let t=e.dataTransfer.files?.[0];t&&o(t)},[o]),c=L.useCallback(e=>{e.preventDefault(),n(!0)},[]),l=L.useCallback(()=>n(!1),[]),u=L.useCallback(()=>a.current?.click(),[]),d=L.useCallback(e=>{let t=e.target.files?.[0];t&&o(t),e.target.value=``},[o]),f=[Os.dropZone,t?Os.dropZoneActive:``,r?Os.dropZoneError:``].filter(Boolean).join(` `);return(0,R.jsxs)(`div`,{children:[(0,R.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,R.jsx)(`div`,{children:`Drop a paracosm RunArtifact JSON here, or click to browse`}),(0,R.jsx)(`div`,{className:Os.dropZoneHint,children:`Single artifact or bundle (array of artifacts), max 10 MB`}),(0,R.jsx)(`input`,{ref:a,type:`file`,accept:`.json,application/json`,className:Os.fileInput,onChange:d})]}),r&&(0,R.jsxs)(`div`,{className:Os.errorBanner,role:`alert`,children:[(0,R.jsx)(`div`,{children:r.message}),r.hint&&(0,R.jsx)(`div`,{className:Os.errorHint,children:r.hint})]})]})}var zg=`{
|
|
65
|
+
"schemaVersion": "1.0.0",
|
|
66
|
+
"artifactId": "01J2A8R0K9P3F7HXC4ZDM3WQYV",
|
|
67
|
+
"scenario": {
|
|
68
|
+
"id": "frontier-ai-lab",
|
|
69
|
+
"name": "Frontier AI Lab",
|
|
70
|
+
"departments": 4
|
|
71
|
+
},
|
|
72
|
+
"setup": {
|
|
73
|
+
"turns": 20,
|
|
74
|
+
"seed": 42,
|
|
75
|
+
"startTime": "2025-04-30T09:00:00Z",
|
|
76
|
+
"timePerTurn": 86400,
|
|
77
|
+
"population": 18
|
|
78
|
+
},
|
|
79
|
+
"actor": {
|
|
80
|
+
"kind": "openai",
|
|
81
|
+
"model": "gpt-4o-mini"
|
|
82
|
+
},
|
|
83
|
+
"events": [
|
|
84
|
+
{
|
|
85
|
+
"turn": 1,
|
|
86
|
+
"kind": "actor.action",
|
|
87
|
+
"actorId": "alice",
|
|
88
|
+
"summary": "Reviews Q1 budget; flags compute overrun",
|
|
89
|
+
"ts": "2025-04-30T09:00:00Z"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"turn": 1,
|
|
93
|
+
"kind": "actor.message",
|
|
94
|
+
"actorId": "bob",
|
|
95
|
+
"to": ["alice"],
|
|
96
|
+
"text": "Confirming the H100 cluster spend. We are 18% over plan."
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
"results": {
|
|
100
|
+
"kpis": { "morale": 0.74, "throughput": 0.61 },
|
|
101
|
+
"completed": true
|
|
102
|
+
},
|
|
103
|
+
"verdict": {
|
|
104
|
+
"kind": "judge.verdict",
|
|
105
|
+
"label": "plausible",
|
|
106
|
+
"score": 0.82,
|
|
107
|
+
"rationale": "Roles consistent with departmental authority; arithmetic checks out."
|
|
108
|
+
}
|
|
109
|
+
}`;function Bg(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 Vg(){return(0,R.jsxs)(`section`,{className:Os.guide,"aria-label":`How to author a RunArtifact JSON`,children:[(0,R.jsxs)(`div`,{className:Os.guideHead,children:[(0,R.jsx)(`h3`,{className:Os.guideTitle,children:`How to get a RunArtifact JSON`}),(0,R.jsxs)(`p`,{className:Os.guideSub,children:[`Studio takes a deterministic Paracosm `,(0,R.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,R.jsxs)(`ol`,{className:Os.guideSteps,children:[(0,R.jsxs)(`li`,{children:[(0,R.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,R.jsxs)(`li`,{children:[(0,R.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,R.jsxs)(`li`,{children:[(0,R.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,R.jsx)(`code`,{children:`paracosm run scenarios/frontier-ai-lab.json --turns 20 --out run.json`}),`.`]}),(0,R.jsxs)(`li`,{children:[(0,R.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,R.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,R.jsxs)(`div`,{className:Os.guideCtaRow,children:[(0,R.jsx)(`a`,{href:`?tab=settings`,onClick:Bg,className:Os.guideCta,children:`Open Settings →`}),(0,R.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/blob/master/docs/COOKBOOK.md`,target:`_blank`,rel:`noopener noreferrer`,className:Os.guideCtaSecondary,children:`Read the cookbook`}),(0,R.jsx)(`a`,{href:`https://github.com/framerslab/paracosm/tree/master/scenarios`,target:`_blank`,rel:`noopener noreferrer`,className:Os.guideCtaSecondary,children:`Browse example scenarios`})]}),(0,R.jsxs)(`details`,{className:Os.guideExample,children:[(0,R.jsx)(`summary`,{children:`Show an example RunArtifact`}),(0,R.jsx)(`pre`,{className:Os.guideExampleCode,children:(0,R.jsx)(`code`,{children:zg})}),(0,R.jsxs)(`p`,{className:Os.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,R.jsx)(`code`,{children:`RunArtifact`}),` Zod schema in `,(0,R.jsx)(`code`,{children:`schema/index.ts`}),`; bundles are a JSON array of artifacts.`]})]})]})}function Hg(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=L.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,R.jsxs)(`div`,{className:Os.artifactView,children:[(0,R.jsxs)(`header`,{className:Os.artifactHead,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:Os.artifactScenario,children:l}),(0,R.jsxs)(`div`,{className:Os.artifactActor,children:[c,` · `,s]})]}),!n&&(0,R.jsxs)(`div`,{className:Os.artifactActions,children:[(0,R.jsx)(`button`,{type:`button`,className:Os.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote to Library`}),(0,R.jsx)(`button`,{type:`button`,className:Os.compareBtn,onClick:i,children:`Compare`})]})]}),(0,R.jsx)(`div`,{className:Os.artifactBody,children:s===`turn-loop`?(0,R.jsx)(Fo,{artifact:t}):(0,R.jsx)(No,{artifact:t,metricSpecs:u})})]})}function Ug(e){let{artifacts:t,bundleId:n,onPromote:r,onCompare:i,promoteBusy:a,alreadyExisted:o}=e,[s,c]=L.useState(null);if(s!==null&&t[s]){let e=t[s];return(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`button`,{type:`button`,className:Os.bundleDrillBack,onClick:()=>c(null),children:`← Back to bundle`}),(0,R.jsx)(Hg,{artifact:e,inline:!0,onPromote:()=>{},onCompare:()=>{}})]})}return(0,R.jsxs)(`div`,{children:[n&&(0,R.jsx)(`div`,{className:Os.bundleIdChip,title:n,children:n.length>32?`${n.slice(0,28)}…`:n}),(0,R.jsxs)(`div`,{className:Os.bundleActions,children:[(0,R.jsx)(`button`,{type:`button`,className:Os.promoteBtn,onClick:r,disabled:a||o,children:o?`Already in Library`:a?`Promoting…`:`Promote bundle (${t.length})`}),(0,R.jsx)(`button`,{type:`button`,className:Os.compareBtn,onClick:i,children:`Compare bundle`})]}),(0,R.jsx)(`div`,{className:Os.bundleGrid,children:t.map((e,t)=>{let n=e.leader,r=e.cost?.totalUSD,i=e.trajectory?.timepoints?.length??0;return(0,R.jsxs)(`button`,{type:`button`,className:Os.bundleCard,onClick:()=>c(t),children:[(0,R.jsx)(`div`,{className:Os.bundleCardTitle,children:n?.name??`<unnamed>`}),(0,R.jsxs)(`div`,{className:Os.bundleCardMeta,children:[n?.archetype??``,` · `,i,` turn`,i===1?``:`s`,typeof r==`number`?` · $${r.toFixed(3)}`:``]})]},e.metadata.runId)})})]})}var Wg=5242880,Gg=`/api/v1/library/import`,Kg=new TextEncoder,qg=e=>Kg.encode(e).length,Jg=qg(JSON.stringify({addToBundle:`bundle_00000000-0000-0000-0000-000000000000`,artifacts:[]}));function Yg(e){return Jg+e.reduce((e,t)=>e+t.bytes,0)+Math.max(0,e.length-1)}function Xg(e,t){let n=Jg,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 Zg(e,t){return`${t===void 0?`{"artifacts":[`:`{"addToBundle":${JSON.stringify(t)},"artifacts":[`}${e.map(e=>e.json).join(`,`)}]}`}function Qg(e){let t=typeof e==`string`?/Maximum (\d+) bytes/.exec(e):null;return t?Number(t[1]):void 0}function $g(){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 e_=e=>`${(e/1048576).toFixed(1)} MiB`,t_=e=>/[.!?]$/.test(e.trim())?e.trim():`${e.trim()}.`;async function n_(e,t={}){let n=e.map(e=>{let t=JSON.stringify(e);return{runId:e.metadata.runId,json:t,bytes:qg(t)}}),r=[],i=[],a=t.addToBundle??$g(),o=0,s=Wg,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(`, `)}. ${t_(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=>Yg([e])>s);if(u.length>0&&c){let e=u.map(e=>`${e.runId} (${e_(e.bytes)})`).join(`, `),n=u.length===1;return l(`The server takes at most ${e_(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:Xg(e,s),f;try{f=await fetch(Gg,{method:`POST`,headers:{"Content-Type":`application/json`},body:Zg(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=Qg(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 r_(){let[e,t]=L.useState(!1),[n,r]=L.useState(null),[i,a]=L.useState(null),o=L.useRef(null);return{promoteSingle:L.useCallback(async e=>{t(!0),a(null);try{let t=await fetch(Gg,{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:L.useCallback(async e=>{t(!0),a(null);try{let t=e.map(e=>e.metadata.runId),n=await n_(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}}function i_(){let e=fF();return(0,L.useMemo)(()=>bn(e),[e.labels?.populationNoun,e.labels?.settlementNoun,e.labels?.timeUnitNoun,e.labels?.timeUnitNounPlural])}function a_(e,t){return typeof e==`number`&&typeof t==`number`?t>e?`up`:t<e?`down`:`unchanged`:e===t?`unchanged`:`changed`}function o_(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=a_(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 s_(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 c_={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 l_(){let{state:e}=da(),t=i_(),n=vF();return!e.parent&&e.branches.length===0?(0,R.jsxs)(`div`,{className:c_.emptyState,role:`region`,"aria-label":`Branches (empty)`,children:[(0,R.jsx)(`h2`,{children:`No branches yet`}),(0,R.jsxs)(`p`,{children:[`Run a simulation with snapshot capture enabled (default for dashboard runs), then open the `,(0,R.jsx)(`strong`,{children:`Reports`}),` tab and click`,` `,(0,R.jsxs)(`code`,{children:[`↳ Fork at `,t.Time,` N`]}),` on any completed turn to branch with a different leader.`]})]}):(0,R.jsxs)(`div`,{className:c_.tab,role:`region`,"aria-label":`Branches`,children:[e.parent&&(0,R.jsx)(u_,{artifact:e.parent,labels:t}),(0,R.jsx)(`div`,{className:c_.branchList,children:e.branches.map(r=>(0,R.jsx)(d_,{branch:r,parent:e.parent,labels:t,onOpen:()=>n(`reports`)},r.localId))})]})}function u_({artifact:e,labels:t}){let n=e.finalState?.metrics??{},r=e.trajectory?.timepoints?.length??0;return(0,R.jsxs)(`section`,{className:c_.parentCard,"aria-label":`Parent run`,children:[(0,R.jsx)(`header`,{className:c_.cardHeader,children:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`h3`,{className:c_.parentTitle,children:[e.metadata.scenario.name,` (parent)`]}),(0,R.jsxs)(`span`,{className:c_.meta,children:[r,` `,r===1?t.time:t.times,` completed · run`,` `,(0,R.jsx)(`code`,{children:e.metadata.runId})]})]})}),(0,R.jsx)(`dl`,{className:c_.metrics,children:Object.entries(n).slice(0,6).map(([e,t])=>(0,R.jsxs)(`div`,{className:c_.metric,children:[(0,R.jsx)(`dt`,{children:e}),(0,R.jsx)(`dd`,{children:f_(t)})]},e))})]})}function d_({branch:e,parent:t,labels:n,onOpen:r}){let i=(0,L.useMemo)(()=>t&&e.artifact?o_(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,R.jsxs)(`article`,{className:c_.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,R.jsxs)(`header`,{className:c_.cardHeader,children:[(0,R.jsxs)(`div`,{className:c_.branchMeta,children:[(0,R.jsxs)(`span`,{className:c_.badge,children:[`Forked at `,n.Time,` `,e.forkedAtTurn]}),(0,R.jsxs)(`h4`,{className:c_.branchTitle,children:[e.actorName,` `,(0,R.jsxs)(`span`,{className:c_.archetype,children:[`(`,e.actorArchetype,`)`]})]})]}),(0,R.jsx)(`span`,{className:`${c_.status} ${c_[`status_${e.status}`]}`,children:a})]}),e.status===`complete`&&i.length>0&&(0,R.jsxs)(`ul`,{className:c_.deltas,"aria-label":`Delta vs parent`,children:[i.slice(0,4).map(e=>(0,R.jsx)(`li`,{className:`${c_.delta} ${c_[`direction_${e.direction}`]}`,title:`${e.bag}: parent=${e.parentValue}, branch=${e.branchValue}`,children:s_(e)},`${e.bag}.${e.key}`)),i.length>4&&(0,R.jsxs)(`li`,{className:c_.more,children:[`+`,i.length-4,` more`]})]}),e.status===`complete`&&i.length===0&&(0,R.jsx)(`p`,{className:c_.identical,children:`Identical final state. Leader overrides did not diverge.`}),e.status===`error`&&e.errorMessage&&(0,R.jsx)(`p`,{className:c_.error,role:`alert`,children:e.errorMessage})]})}function f_(e){return typeof e==`number`?Number.isInteger(e)?e.toString():(Math.round(e*100)/100).toString():String(e)}var p_={tablist:`_tablist_iq6lf_1`,tab:`_tab_iq6lf_1`,tabActive:`_tabActive_iq6lf_39`};function m_({options:e,active:t,onChange:n,ariaLabel:r}){return(0,R.jsx)(`div`,{role:`tablist`,"aria-label":r,className:p_.tablist,children:e.map(e=>{let r=e.id===t,i=r?`${p_.tab} ${p_.tabActive}`:p_.tab;return(0,R.jsx)(`button`,{role:`tab`,"aria-selected":r,onClick:()=>n(e.id),type:`button`,className:i,children:e.label},e.id)})})}function h_(){return{query:``,types:new Set,leader:null,turnRange:null,toolHash:``,toolExact:!1}}function g_(e,t){let n=t.query.toLowerCase(),r=t.types.size>0,i=t.turnRange!==null,a=t.turnRange,o=t.toolHash.toLowerCase();return e.filter(e=>{if(r&&!t.types.has(e.type)||t.leader!==null&&e.leader!==t.leader)return!1;if(i&&a){let t=__(e);if(t===void 0||t<a[0]||t>a[1])return!1}return!(o&&!y_(e,o,t.toolExact)||n&&!v_(e,n))})}function __(e){let t=e.data?.turn;return typeof t==`number`?t:void 0}function v_(e,t){if(e.type.toLowerCase().includes(t)||typeof e.leader==`string`&&e.leader.toLowerCase().includes(t))return!0;let n=e.data??{};for(let e of[`title`,`summary`,`department`,`name`]){let r=n[e];if(typeof r==`string`&&r.toLowerCase().includes(t))return!0}return!1}function y_(e,t,n){let r=e=>n?e===t:e.includes(t),i=e.data??{},a=typeof i.name==`string`?i.name.trim().toLowerCase():``;if(a&&r(a))return!0;let o=Array.isArray(i.forgedTools)?i.forgedTools:[];for(let e of o){let t=e&&typeof e==`object`&&typeof e.name==`string`?e.name.trim().toLowerCase():``;if(t&&r(t))return!0}return!1}function b_(e){let t=new Set,n=[],r=new Set,i=0;for(let a of e){a.type&&t.add(a.type),typeof a.leader==`string`&&a.leader&&!r.has(a.leader)&&(r.add(a.leader),n.push(a.leader));let e=__(a);e!==void 0&&e>i&&(i=e)}return{types:[...t].sort(),actors:n,maxTurn:i}}function x_(e){let t=new URLSearchParams;e.query&&t.set(`logQuery`,e.query),e.types.size>0&&t.set(`logTypes`,[...e.types].join(`,`)),e.leader!==null&&t.set(`logLeader`,e.leader),e.turnRange&&(t.set(`logTurnMin`,String(e.turnRange[0])),t.set(`logTurnMax`,String(e.turnRange[1])));let n=t.toString();return n?`?${n}`:``}var S_=[`logQuery`,`logTypes`,`logLeader`,`logTurnMin`,`logTurnMax`];function C_(e,t,n){let r=new URL(e);for(let e of S_)r.searchParams.delete(e);return new URLSearchParams(x_(t)).forEach((e,t)=>r.searchParams.append(t,e)),n&&(r.hash=``),r.pathname+r.search+r.hash}function w_(e,t){let n=h_(),r=new URLSearchParams(e.startsWith(`?`)?e.slice(1):e),i=r.get(`logQuery`);i&&(n.query=i);let a=r.get(`logTypes`);if(a){let e=a.split(`,`).map(e=>e.trim()).filter(Boolean);n.types=new Set(e)}let o=r.get(`logLeader`);o&&(n.leader=o);let s=r.get(`logTurnMin`),c=r.get(`logTurnMax`);if(s!==null&&c!==null){let e=Number(s),t=Number(c);Number.isFinite(e)&&Number.isFinite(t)&&(n.turnRange=[Math.min(e,t),Math.max(e,t)])}let l=t.startsWith(`#`)?t.slice(1):t,u=l.match(/(?:^|&)log=([^&]+)/);if(u){try{n.toolHash=decodeURIComponent(u[1])}catch{n.toolHash=u[1]}n.toolExact=/(?:^|&)logExact=1(?:&|$)/.test(l)}return n}var T_=[`quickstart`,`sim`,`viz`,`settings`,`reports`,`chat`,`library`,`studio`,`about`],E_={branches:{tab:`studio`,sub:`branches`},log:{tab:`settings`,sub:`log`}};function D_(e){return!!e&&T_.includes(e)}function O_(e){let{tab:t}=k_(e);return t}function k_(e){let t=new URL(e),n=t.searchParams.get(`tab`),r=t.searchParams.get(`sub`);if(n&&E_[n])return E_[n];if(D_(n))return{tab:n,sub:r??void 0};let i=t.hash.replace(/^#/,``);return i&&E_[i]?E_[i]:D_(i)?{tab:i,sub:r??void 0}:{tab:`quickstart`}}function A_(e,t){let n=new URL(e);return n.searchParams.set(`tab`,t),n.searchParams.delete(`sub`),n.hash=``,n.toString()}function j_(e,t,n){let r=new URL(A_(e,`settings`));for(let e of S_)r.searchParams.delete(e);return r.searchParams.set(`sub`,`log`),n&&r.searchParams.set(`logLeader`,n),r.hash=t?`log=${encodeURIComponent(t)}&logExact=1`:``,r.toString()}function M_(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 N_(e,t){if(!t)return A_(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 P_=[{id:`author`,label:`Author`},{id:`branches`,label:`Branches`}];function F_({initialSubTab:e=`author`}={}){let[t,n]=L.useState(e),r=L.useCallback(e=>{n(e),M_(e===`author`?null:e)},[]),[i,a]=L.useState(null),[o,s]=L.useState(!1),c=r_(),l=L.useCallback((e,t)=>{e.kind!==`error`&&a({input:e,filename:t,promote:null})},[]),u=L.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=L.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=L.useCallback(()=>s(!0),[]),p=L.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,R.jsxs)(`div`,{className:Os.tab,children:[(0,R.jsx)(m_,{options:P_,active:t,onChange:r,ariaLabel:`Studio sub-navigation`}),t===`branches`&&(0,R.jsx)(l_,{}),t===`author`&&!i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Vg,{}),(0,R.jsx)(Rg,{onLoaded:l})]}),t===`author`&&i&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:Os.loadedBar,children:[(0,R.jsxs)(`span`,{children:[(0,R.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,R.jsx)(`button`,{type:`button`,className:Os.bundleDrillBack,onClick:p,children:`Drop another`})]}),c.error&&(0,R.jsx)(`div`,{className:Os.errorBanner,role:`alert`,children:c.error}),i.input.kind===`single`&&(0,R.jsx)(Hg,{artifact:i.input.artifact,onPromote:u,onCompare:f,promoteBusy:c.busy,alreadyExisted:i.promote?.kind===`single`&&i.promote.alreadyExisted}),i.input.kind===`bundle`&&(0,R.jsx)(Ug,{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,R.jsx)(ws,{bundleId:h,extraArtifacts:m,open:o,onClose:()=>s(!1)})]})}var I_={card:`_card_182vb_1`,heading:`_heading_182vb_15`,title:`_title_182vb_23`,eyebrow:`_eyebrow_182vb_35`,copy:`_copy_182vb_43`,presetRow:`_presetRow_182vb_50`,presetLabel:`_presetLabel_182vb_61`,presetButton:`_presetButton_182vb_71`,presetButtonActive:`_presetButtonActive_182vb_91`,presetClear:`_presetClear_182vb_97`,presetBlurb:`_presetBlurb_182vb_118`,formGrid:`_formGrid_182vb_126`,formCell:`_formCell_182vb_137`,formLegend:`_formLegend_182vb_152`,field:`_field_182vb_165`,fieldRow:`_fieldRow_182vb_171`,fieldThird:`_fieldThird_182vb_177`,fieldLabel:`_fieldLabel_182vb_182`,input:`_input_182vb_191`,textarea:`_textarea_182vb_212`,mono:`_mono_182vb_235`,actions:`_actions_182vb_240`,button:`_button_182vb_248`,helper:`_helper_182vb_270`,spinner:`_spinner_182vb_276`,"idc-spin":`_idc-spin_182vb_1`,timer:`_timer_182vb_288`};function L_(e){if(typeof e!=`string`)return;let t=e.trim();if(t&&!t.includes(`...`))return t}function R_(e){let t=L_(e.openai),n=L_(e.anthropic);return{...t?{apiKey:t}:{},...n?{anthropicKey:n}:{}}}function z_(e){let t=R_(e);return t.apiKey!==void 0||t.anthropicKey!==void 0}var B_={id:``,name:``,description:``,profileJson:`{}`},V_={id:``,name:``,description:``,durationValue:`12`,durationUnit:`weeks`,adherence:`0.85`},H_={medical:{label:`Patient · treatment`,blurb:`Type 2 diabetes patient on a 12-week semaglutide + lifestyle protocol.`,subject:{id:`patient-maria-2026`,name:`Maria Chen`,description:`58 y/o T2D for 4 yrs, sedentary, family hx CVD, on metformin.`,profileJson:JSON.stringify({age:58,yearsWithT2D:4,bmi:31,a1cBaseline:7.8,weightLb:178,fastingGlucose:156,sleepHoursBaseline:6.2,exerciseMinPerWeek:0,comorbidities:`hypertension, dyslipidemia`},null,2)},intervention:{id:`glp1-12wk-protocol`,name:`12-week semaglutide + lifestyle protocol`,description:`Initiate semaglutide 0.25mg weekly, titrate to 1.0mg by week 4. Pair with dietitian-led nutrition plan and 150min/wk graded exercise. Behavioral health checkpoints biweekly. Monitor for GI side effects, gallbladder, pancreatitis.`,durationValue:`84`,durationUnit:`days`,adherence:`0.85`},signalsJson:JSON.stringify([{label:`HbA1c`,value:7.8,unit:`%`,recordedAt:`2026-09-15T00:00:00Z`},{label:`Fasting glucose`,value:156,unit:`mg/dL`,recordedAt:`2026-09-15T00:00:00Z`},{label:`Weight`,value:178,unit:`lb`,recordedAt:`2026-09-15T00:00:00Z`},{label:`BMI`,value:31,unit:`kg/m²`,recordedAt:`2026-09-15T00:00:00Z`}],null,2)},policy:{label:`Jurisdiction · ordinance`,blurb:`A mid-size city pilots downtown congestion pricing for 12 months.`,subject:{id:`city-portland-2026`,name:`Portland Metro`,description:`Pacific Northwest mid-size city with dense urban core, mature transit, organized downtown business association.`,profileJson:JSON.stringify({population:65e4,downtownEmployment:11e4,modeShareTransit:.18,modeShareCar:.62,modeShareActive:.14,avgPeakSpeedMph:14.2,annualCO2Tons:182e4,unemploymentRate:.044},null,2)},intervention:{id:`congestion-pricing-12mo`,name:`Downtown congestion pricing pilot`,description:`Charge $9/peak-hour ($3 off-peak) on vehicles entering the central business district 6am-7pm Mon-Fri. Revenue funds two new BRT lines and a 30% transit fare cut for low-income riders. Pilot runs 12 months with quarterly review.`,durationValue:`12`,durationUnit:`months`,adherence:`0.78`},signalsJson:JSON.stringify([{label:`Downtown VMT`,value:1.42,unit:`million-mi/day`,recordedAt:`2026-04-01T00:00:00Z`},{label:`Transit ridership`,value:118e3,unit:`boardings/day`,recordedAt:`2026-04-01T00:00:00Z`},{label:`Peak speed`,value:14.2,unit:`mph`,recordedAt:`2026-04-01T00:00:00Z`}],null,2)},product:{label:`Market · launch`,blurb:`A SaaS launches a new mid-tier price point against a price-sensitive prosumer segment.`,subject:{id:`segment-prosumer-creators`,name:`Prosumer creators`,description:`Independent creators earning $40k-$120k/yr who self-fund their tooling. Cross-tool stackers; price-sensitive within 20% bands.`,profileJson:JSON.stringify({addressableUsers:18e5,currentPaidConversion:.034,avgARPU_USD:22,churnMonthly:.038,npsCurrent:41,topCompetitorPriceUSD:18,topCompetitorMarketShare:.31},null,2)},intervention:{id:`mid-tier-pricing-launch`,name:`New $14/mo mid-tier launch`,description:`Introduce a third pricing tier at $14/mo (between Free and the existing $29/mo Pro), unlocking 60% of Pro features. Bundle with 90-day grandfathering for current Pro subs and a quarterly migration check-in. 6-month pilot before deciding to globalize.`,durationValue:`6`,durationUnit:`months`,adherence:`0.72`},signalsJson:JSON.stringify([{label:`Free → Paid conversion`,value:.034,unit:`rate`,recordedAt:`2026-04-01T00:00:00Z`},{label:`Monthly churn`,value:.038,unit:`rate`,recordedAt:`2026-04-01T00:00:00Z`},{label:`NPS`,value:41,unit:`score`,recordedAt:`2026-04-01T00:00:00Z`}],null,2)}};function U_(e,t){if(!e||!e.trim())return t;try{return JSON.parse(e)}catch{return t}}function W_(){return globalThis.crypto?.randomUUID?.()??`run-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,12)}`}function G_({onResult:e,onError:t,onRunStart:n}){let[r,i]=(0,L.useState)(B_),[a,o]=(0,L.useState)(V_),[s,c]=(0,L.useState)(`[]`),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(0),[p,m]=(0,L.useState)(null),h=e=>{let t=H_[e];t&&(i(t.subject),o(t.intervention),c(t.signalsJson),m(e))},g=()=>{i(B_),o(V_),c(`[]`),m(null)},_=r.id.trim().length>0&&r.name.trim().length>0&&a.id.trim().length>0&&a.name.trim().length>0&&a.description.trim().length>0;return(0,R.jsxs)(`div`,{className:I_.card,children:[(0,R.jsxs)(`div`,{className:I_.heading,children:[(0,R.jsx)(`h3`,{className:I_.title,children:`Run a digital twin`}),(0,R.jsx)(`span`,{className:I_.eyebrow,children:`any subject · any intervention`})]}),(0,R.jsx)(`p`,{className:I_.copy,children:`Define a subject (patient, market segment, jurisdiction, vehicle, anything) and an intervention to apply to it. Paracosm runs a real LLM-driven simulation across a five-department analysis team and returns a typed RunArtifact with the trajectory.`}),(0,R.jsxs)(`div`,{className:I_.presetRow,children:[(0,R.jsx)(`span`,{className:I_.presetLabel,children:`Examples`}),Object.entries(H_).map(([e,t])=>(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(e),className:`${I_.presetButton} ${p===e?I_.presetButtonActive:``}`,disabled:l,children:t.label},e)),(0,R.jsx)(`button`,{type:`button`,onClick:g,className:I_.presetClear,disabled:l,children:`Clear`})]}),p&&(0,R.jsx)(`p`,{className:I_.presetBlurb,children:H_[p].blurb}),(0,R.jsxs)(`div`,{className:I_.formGrid,children:[(0,R.jsxs)(`fieldset`,{className:I_.formCell,disabled:l,children:[(0,R.jsx)(`legend`,{className:I_.formLegend,children:`Subject`}),(0,R.jsxs)(`label`,{className:I_.field,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`ID`}),(0,R.jsx)(`input`,{type:`text`,value:r.id,onChange:e=>i(t=>({...t,id:e.target.value})),placeholder:`patient-001`,className:I_.input})]}),(0,R.jsxs)(`label`,{className:I_.field,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`Name`}),(0,R.jsx)(`input`,{type:`text`,value:r.name,onChange:e=>i(t=>({...t,name:e.target.value})),placeholder:`Maria Chen`,className:I_.input})]}),(0,R.jsxs)(`label`,{className:I_.field,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`Description`}),(0,R.jsx)(`textarea`,{value:r.description,onChange:e=>i(t=>({...t,description:e.target.value})),placeholder:`Age, key attributes, baseline state.`,className:I_.textarea,rows:3})]}),(0,R.jsxs)(`label`,{className:I_.field,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`Profile (JSON)`}),(0,R.jsx)(`textarea`,{value:r.profileJson,onChange:e=>i(t=>({...t,profileJson:e.target.value})),placeholder:`{"age": 58, "bmi": 31}`,className:`${I_.textarea} ${I_.mono}`,rows:5,spellCheck:!1})]}),(0,R.jsxs)(`label`,{className:I_.field,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`Signals (JSON)`}),(0,R.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`[{"label":"HbA1c","value":7.8,"unit":"%"}]`,className:`${I_.textarea} ${I_.mono}`,rows:4,spellCheck:!1})]})]}),(0,R.jsxs)(`fieldset`,{className:I_.formCell,disabled:l,children:[(0,R.jsx)(`legend`,{className:I_.formLegend,children:`Intervention`}),(0,R.jsxs)(`label`,{className:I_.field,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`ID`}),(0,R.jsx)(`input`,{type:`text`,value:a.id,onChange:e=>o(t=>({...t,id:e.target.value})),placeholder:`semaglutide-12wk`,className:I_.input})]}),(0,R.jsxs)(`label`,{className:I_.field,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`Name`}),(0,R.jsx)(`input`,{type:`text`,value:a.name,onChange:e=>o(t=>({...t,name:e.target.value})),placeholder:`12-week semaglutide protocol`,className:I_.input})]}),(0,R.jsxs)(`label`,{className:I_.field,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`Description`}),(0,R.jsx)(`textarea`,{value:a.description,onChange:e=>o(t=>({...t,description:e.target.value})),placeholder:`What is being applied, by whom, with what monitoring.`,className:I_.textarea,rows:5})]}),(0,R.jsxs)(`div`,{className:I_.fieldRow,children:[(0,R.jsxs)(`label`,{className:`${I_.field} ${I_.fieldThird}`,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`Duration`}),(0,R.jsx)(`input`,{type:`number`,min:`1`,value:a.durationValue,onChange:e=>o(t=>({...t,durationValue:e.target.value})),className:I_.input})]}),(0,R.jsxs)(`label`,{className:`${I_.field} ${I_.fieldThird}`,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`Unit`}),(0,R.jsxs)(`select`,{value:a.durationUnit,onChange:e=>o(t=>({...t,durationUnit:e.target.value})),className:I_.input,children:[(0,R.jsx)(`option`,{value:`days`,children:`days`}),(0,R.jsx)(`option`,{value:`weeks`,children:`weeks`}),(0,R.jsx)(`option`,{value:`months`,children:`months`}),(0,R.jsx)(`option`,{value:`quarters`,children:`quarters`}),(0,R.jsx)(`option`,{value:`years`,children:`years`})]})]}),(0,R.jsxs)(`label`,{className:`${I_.field} ${I_.fieldThird}`,children:[(0,R.jsx)(`span`,{className:I_.fieldLabel,children:`Adherence`}),(0,R.jsx)(`input`,{type:`number`,min:`0`,max:`1`,step:`0.05`,value:a.adherence,onChange:e=>o(t=>({...t,adherence:e.target.value})),className:I_.input})]})]})]})]}),(0,R.jsxs)(`div`,{className:I_.actions,children:[(0,R.jsx)(`button`,{onClick:async()=>{if(l||!_)return;let i=U_(r.profileJson,{}),o=U_(s,[]),c={id:r.id.trim(),name:r.name.trim(),profile:r.description.trim()?{...i,description:r.description.trim()}:i,signals:o,markers:[]},d=Number(a.durationValue),p=Number(a.adherence),m={id:a.id.trim(),name:a.name.trim(),description:a.description.trim(),duration:Number.isFinite(d)&&d>0?{value:d,unit:a.durationUnit.trim()||`weeks`}:void 0,adherenceProfile:Number.isFinite(p)?{expected:Math.max(0,Math.min(1,p))}:void 0};u(!0),f(0);let h=Date.now(),g=window.setInterval(()=>{f(Math.round((Date.now()-h)/1e3))},500),v=W_();await n?.({runKey:v,subject:{id:c.id,name:c.name,profile:c.profile},intervention:{id:m.id,name:m.name,description:m.description,duration:m.duration}});try{let t=await fetch(`/api/quickstart/simulate-intervention`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({subject:c,intervention:m,runKey:v,options:{maxTurns:2,seed:11,costPreset:`economy`},...R_(E())})});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Digital twin run failed: HTTP ${t.status}`)}let n=await t.json();le(window,n.visitorId),e(n.artifact,v)}catch(e){t?.(e instanceof Error?e.message:String(e),v)}finally{window.clearInterval(g),u(!1)}},disabled:l||!_,className:I_.button,children:l?`Running…`:`Run digital twin`}),l?(0,R.jsxs)(`span`,{className:I_.timer,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:I_.spinner,"aria-hidden":`true`}),d,`s elapsed · 2 turns × LLM decisions, typically 40-90s`]}):(0,R.jsx)(`span`,{className:I_.helper,children:`2 turns · seed 11 · economy preset`})]})]})}function K_(e,t){return e===`loading`?`loading`:e===`error`?`error`:e===`unavailable`?`unavailable`:t.length===0?`empty`:`cards`}function q_(e,t){let n=new URL(e);return n.searchParams.set(`replay`,t),n.searchParams.set(`tab`,`sim`),n.toString()}var J_={card:`_card_1qdw6_1`,eyebrow:`_eyebrow_1qdw6_27`,row:`_row_1qdw6_36`,actor:`_actor_1qdw6_45`,arrow:`_arrow_1qdw6_56`,meta:`_meta_1qdw6_62`};function Y_(){let{sessions:e}=Wn(),t=e[0]?.id?e[0]:null;if(!t)return null;let n=typeof window<`u`?q_(window.location.href,t.id):`?replay=${encodeURIComponent(t.id)}`,r=t.seedText?t.seedText.length>70?`${t.seedText.slice(0,70).trim()}…`:t.seedText.trim():null,i=ia(t,3),a=t.title||t.scenarioName||i||r||t.id,o=[t.scenarioName&&t.scenarioName!==a?t.scenarioName:null,typeof t.eventCount==`number`?`${t.eventCount} events`:null,typeof t.durationMs==`number`?`${Math.round(t.durationMs/1e3)}s`:null,typeof t.createdAt==`number`?new Date(t.createdAt).toISOString().slice(0,10):null].filter(e=>typeof e==`string`&&e.length>0).join(` · `);return(0,R.jsxs)(`a`,{className:J_.card,href:n,"aria-label":`Replay last run: ${a}`,children:[(0,R.jsx)(`span`,{className:J_.eyebrow,children:`Replay last run`}),(0,R.jsxs)(`span`,{className:J_.row,children:[(0,R.jsx)(`span`,{className:J_.actor,children:a}),(0,R.jsx)(`span`,{className:J_.arrow,"aria-hidden":`true`,children:`▶`})]}),o&&(0,R.jsx)(`span`,{className:J_.meta,children:o})]})}function X_(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 Z_(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 Q_(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 $_(e,t,n=`viz`){return Kr(e,t,n)}function ev(e,t){rr(JSON.stringify(e,null,2),t)}var tv=`/assets/pdf.worker.min-CIqJB0yW.mjs`,nv=`modulepreload`,rv=function(e){return`/`+e},iv={},av=function(e){return e.pathname.endsWith(`.css`)},ov=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},sv=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=rv(t,n);let r=s(t),i=av(r);return ov(iv,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`:nv,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)=>{let i=a=>{t.removeEventListener(`load`,i),t.removeEventListener(`error`,i),a.type===`error`?n(Error(`Unable to preload CSS for ${r}`)):e(a)};t.addEventListener(`load`,i),t.addEventListener(`error`,i)})})}).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 cv(){if(typeof window>`u`)return tv;try{return new URL(tv,window.location.origin).toString()}catch{return tv}}var lv=null;async function uv(){if(lv)return lv;let e=await sv(()=>import(`./pdf-YwugTw7Y.js`),[]);return e.GlobalWorkerOptions.workerSrc=cv(),lv=e,e}async function dv(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 uv(),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
|
+
|
|
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 fv(e){let t=pv(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('${mv(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
|
+
`)}function pv(e){return e.replace(/\\/g,`\\\\`).replace(/`/g,"\\`").replace(/\$\{/g,"\\${")}function mv(e){return e.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`)}function hv(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(`
|
|
113
|
+
`)}var gv={wrap:`_wrap_5ldo7_1`,toggle:`_toggle_5ldo7_6`,panel:`_panel_5ldo7_34`,tabRow:`_tabRow_5ldo7_42`,tabPill:`_tabPill_5ldo7_51`,copyBtn:`_copyBtn_5ldo7_74`,code:`_code_5ldo7_97`};function _v(e){let{disabled:t,initiallyExpanded:n=!1,initialTab:r=`ts`,...i}=e,[a,o]=(0,L.useState)(n),[s,c]=(0,L.useState)(r),[l,u]=(0,L.useState)(`idle`),d=(0,L.useMemo)(()=>fv(i),[i.seedText,i.domainHint,i.sourceUrl,i.actorCount]),f=(0,L.useMemo)(()=>hv(i),[i.seedText,i.domainHint,i.sourceUrl,i.actorCount]),p=s===`ts`?d:f,m=(0,L.useCallback)(async()=>{try{await navigator.clipboard.writeText(p),u(`ok`)}catch{u(`fail`)}window.setTimeout(()=>u(`idle`),1500)},[p]),h=`quickstart-view-as-code-panel`,g=`quickstart-view-as-code-tab-ts`,_=`quickstart-view-as-code-tab-curl`,v=s===`ts`?g:_;return(0,R.jsxs)(`div`,{className:gv.wrap,children:[(0,R.jsx)(`button`,{type:`button`,className:gv.toggle,"aria-expanded":a,"aria-controls":h,disabled:t,onClick:()=>o(e=>!e),children:a?`▾ Hide code`:`▸ View as code`}),a&&(0,R.jsxs)(`div`,{id:h,role:`tabpanel`,"aria-labelledby":v,className:gv.panel,children:[(0,R.jsxs)(`div`,{className:gv.tabRow,role:`tablist`,"aria-label":`Recipe language`,children:[(0,R.jsx)(`button`,{type:`button`,id:g,role:`tab`,"aria-pressed":s===`ts`,"aria-selected":s===`ts`,"aria-controls":h,className:gv.tabPill,onClick:()=>c(`ts`),children:`TypeScript`}),(0,R.jsx)(`button`,{type:`button`,id:_,role:`tab`,"aria-pressed":s===`curl`,"aria-selected":s===`curl`,"aria-controls":h,className:gv.tabPill,onClick:()=>c(`curl`),children:`curl`}),(0,R.jsx)(`button`,{type:`button`,className:gv.copyBtn,onClick:m,"aria-label":`Copy ${s===`ts`?`TypeScript`:`curl`} recipe`,children:l===`ok`?`Copied ✓`:l===`fail`?`Press ⌘C`:`Copy`})]}),(0,R.jsx)(`pre`,{className:gv.code,children:(0,R.jsx)(`code`,{children:p})})]})]})}var vv={card:`_card_srwu8_2`,heading:`_heading_srwu8_15`,subline:`_subline_srwu8_25`,scenarioPickerRow:`_scenarioPickerRow_srwu8_34`,scenarioPickerLabel:`_scenarioPickerLabel_srwu8_45`,scenarioPickerSelect:`_scenarioPickerSelect_srwu8_54`,scenarioPickerHint:`_scenarioPickerHint_srwu8_66`,actorRow:`_actorRow_srwu8_73`,actorLabel:`_actorLabel_srwu8_82`,actorSlider:`_actorSlider_srwu8_91`,actorValue:`_actorValue_srwu8_96`,runButton:`_runButton_srwu8_102`,runButtonFull:`_runButtonFull_srwu8_134`,runButtonCompact:`_runButtonCompact_srwu8_138`,tagline:`_tagline_srwu8_144`,tradeoff:`_tradeoff_srwu8_154`};function yv(e){let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=Date.now()-t;if(n<0)return`just now`;let r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<7)return`${a}d ago`;let o=Math.floor(a/7);if(o<5)return`${o}w ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:new Date(e).getFullYear().toString()}function bv({onRunStart:e,disabled:t=!1,initialActorCount:n=2}){let r=fF(),i=!mF()||t,[a,o]=(0,L.useState)(n),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)([]),[d,f]=(0,L.useState)(!1),p=(0,L.useRef)(!0);(0,L.useEffect)(()=>{let e=!1;return fetch(`/scenarios`).then(e=>e.ok?e.json():null).then(t=>{e||u(t?.scenarios??[])}).catch(()=>{}),()=>{e=!0,p.current=!1}},[]);let m=async e=>{if(!(e===r.id||d)){f(!0);try{(await fetch(`/scenario/switch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:e})})).ok?(ge(),window.location.reload()):p.current&&f(!1)}catch{p.current&&f(!1)}}},h=r.presets[0]?.leaders??r.presets[0]?.actors??[],g=h.length,_=g>=2,v=a>g,y=r.labels.name,b=r.labels.tagline?.trim(),x=_?`${h[0].name} (${h[0].archetype}) vs ${h[1].name} (${h[1].archetype})`:`Auto-generated leaders (no preset)`,S=`loaded-scenario-cta-heading`,C=`loaded-scenario-actor-count`,w=()=>{s||i||(c(!0),e(a))},T=`${a} ${a===1?`actor`:`actors`}`,E=s?`Launching...`:`Run ${T} against ${y}`,D=s?`Launching...`:`${E} ->`,O=s?`Launching...`:`Run ${T}`,k=`loaded-scenario-cta-picker`;return(0,R.jsxs)(`section`,{className:vv.card,"aria-labelledby":S,children:[(0,R.jsxs)(`h2`,{className:vv.heading,id:S,children:[`▶ Run with the loaded scenario: `,y]}),b&&(0,R.jsx)(`p`,{className:vv.tagline,children:b}),(0,R.jsx)(`div`,{className:vv.subline,children:x}),l.length>=2&&(()=>{let e=l.some(e=>e.id===r.id)?l:[...l,{id:r.id,name:r.labels.name||r.id,source:`active`}];return(0,R.jsxs)(`div`,{className:vv.scenarioPickerRow,children:[(0,R.jsx)(`label`,{className:vv.scenarioPickerLabel,htmlFor:k,children:`Scenario`}),(0,R.jsx)(`select`,{id:k,className:vv.scenarioPickerSelect,value:r.id,onChange:e=>m(e.target.value),disabled:i||s||d,"aria-label":`Switch active scenario`,children:e.map(e=>{let t=e.source===`builtin`?`[builtin]`:e.source===`disk`?`[disk]`:e.source===`compiled`?`[compiled]`:e.source===`active`?`[active]`:``,n=[];if(t&&n.push(t),typeof e.runCount==`number`&&e.runCount>0&&n.push(`${e.runCount} run${e.runCount===1?``:`s`}`),e.compiledAt){let t=yv(e.compiledAt);t&&n.push(t)}let r=n.length>0?` · ${n.join(` · `)}`:``;return(0,R.jsxs)(`option`,{value:e.id,children:[e.name,r]},e.id)})}),d&&(0,R.jsx)(`span`,{className:vv.scenarioPickerHint,children:`Switching…`})]})})(),(0,R.jsxs)(`div`,{className:vv.actorRow,children:[(0,R.jsx)(`label`,{className:vv.actorLabel,htmlFor:C,children:`Actors`}),(0,R.jsx)(`input`,{id:C,type:`range`,min:1,max:300,value:a,onChange:e=>o(parseInt(e.target.value,10)),disabled:i||s,className:vv.actorSlider,"aria-label":`Number of parallel actors`}),(0,R.jsx)(`span`,{className:vv.actorValue,children:a})]}),(0,R.jsxs)(`button`,{type:`button`,className:vv.runButton,onClick:w,disabled:i||s,"aria-busy":s,"aria-label":E,children:[(0,R.jsx)(`span`,{className:vv.runButtonFull,"aria-hidden":`true`,children:D}),(0,R.jsx)(`span`,{className:vv.runButtonCompact,"aria-hidden":`true`,children:O})]}),(0,R.jsxs)(`div`,{className:vv.tradeoff,children:[_&&!v&&`Same scenario, fresh seed: skips the compile step.`,_&&v&&`Same scenario; ${a} LLM-generated actors replace the preset leaders for this run (~30s for generation).`,!_&&`Same scenario; ~30s for actor generation since no preset is defined.`]})]})}var W={backdrop:`_backdrop_nucmo_1`,backdropFadeIn:`_backdropFadeIn_nucmo_1`,drawer:`_drawer_nucmo_17`,open:`_open_nucmo_34`,header:`_header_nucmo_38`,closeBtn:`_closeBtn_nucmo_50`,sourceBadge:`_sourceBadge_nucmo_63`,summary:`_summary_nucmo_86`,nameRow:`_nameRow_nucmo_94`,name:`_name_nucmo_94`,nameEditBtn:`_nameEditBtn_nucmo_110`,nameEditForm:`_nameEditForm_nucmo_129`,nameEditInput:`_nameEditInput_nucmo_135`,nameEditActions:`_nameEditActions_nucmo_150`,nameEditSave:`_nameEditSave_nucmo_155`,nameEditCancel:`_nameEditCancel_nucmo_173`,nameEditError:`_nameEditError_nucmo_195`,description:`_description_nucmo_202`,metaGrid:`_metaGrid_nucmo_209`,meta:`_meta_nucmo_209`,sectionHeading:`_sectionHeading_nucmo_235`,seedSection:`_seedSection_nucmo_245`,seedHint:`_seedHint_nucmo_250`,seedBody:`_seedBody_nucmo_257`,presetsSection:`_presetsSection_nucmo_273`,departmentsSection:`_departmentsSection_nucmo_274`,sectionHint:`_sectionHint_nucmo_279`,sectionCount:`_sectionCount_nucmo_287`,presetList:`_presetList_nucmo_294`,presetCard:`_presetCard_nucmo_303`,presetHeader:`_presetHeader_nucmo_313`,presetName:`_presetName_nucmo_320`,presetArchetype:`_presetArchetype_nucmo_327`,presetUnit:`_presetUnit_nucmo_340`,hexacoList:`_hexacoList_nucmo_347`,hexacoRow:`_hexacoRow_nucmo_356`,hexacoAxis:`_hexacoAxis_nucmo_364`,hexacoBar:`_hexacoBar_nucmo_372`,hexacoFill:`_hexacoFill_nucmo_380`,hexacoValue:`_hexacoValue_nucmo_386`,presetInstructions:`_presetInstructions_nucmo_393`,deptChips:`_deptChips_nucmo_401`,deptChip:`_deptChip_nucmo_401`,deptIcon:`_deptIcon_nucmo_423`,deptRole:`_deptRole_nucmo_427`,recentSection:`_recentSection_nucmo_431`,statusLine:`_statusLine_nucmo_438`,error:`_error_nucmo_445`,recentList:`_recentList_nucmo_449`,recentRow:`_recentRow_nucmo_458`,recentTitle:`_recentTitle_nucmo_468`,recentArchetype:`_recentArchetype_nucmo_475`,recentMeta:`_recentMeta_nucmo_480`,footer:`_footer_nucmo_486`,actorRow:`_actorRow_nucmo_497`,actorLabel:`_actorLabel_nucmo_505`,actorSlider:`_actorSlider_nucmo_514`,actorValue:`_actorValue_nucmo_519`,runButton:`_runButton_nucmo_527`,deleteButton:`_deleteButton_nucmo_549`,deleteError:`_deleteError_nucmo_572`},xv=`Admin token refused and cleared. ${En}`,Sv=(e,t)=>`The server refused the admin token this ${e} was sent with. A newer token is saved in this browser; press ${t} to try again with it.`,Cv=`scenario-rename-error`;function wv(e){let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=Date.now()-t;if(n<0)return`just now`;let r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<7)return`${a}d ago`;let o=Math.floor(a/7);if(o<5)return`${o}w ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:new Date(e).getFullYear().toString()}function Tv(e){return typeof e!=`number`||!Number.isFinite(e)?`—`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Ev(e){if(typeof e!=`number`||!Number.isFinite(e)||e<=0)return`—`;let t=Math.round(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60),r=t%60;return r>0?`${n}m ${r}s`:`${n}m`}function Dv(e){return e?Array.from(e.querySelectorAll(`button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`)).filter(e=>!e.hasAttribute(`disabled`)&&e.getAttribute(`aria-hidden`)!==`true`):[]}function Ov(e){let{scenario:t,disabled:n=!1,initialActorCount:r=2,onRunScenario:i,showRun:a=!0,onClose:o,onDeleted:s,onRenamed:c}=e,l=t!==null,[u,d]=(0,L.useState)(r),[f,p]=(0,L.useState)([]),[m,h]=(0,L.useState)(!1),[g,_]=(0,L.useState)(null),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(!1),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(null),[E,D]=(0,L.useState)(!1),[O,k]=(0,L.useState)(``),[ee,A]=(0,L.useState)(!1),[j,M]=(0,L.useState)(null),[N,te]=(0,L.useState)(null);(0,L.useEffect)(()=>{te(null),D(!1),M(null)},[t?.id]);let[P,F]=(0,L.useState)(null);(0,L.useEffect)(()=>{if(l)return T(null),F(Nn()||null),Rn(()=>F(Nn()||null))},[l]);let I=!!P&&t?.source===`compiled`,ne=!!P&&t?.source===`compiled`,re=(0,L.useRef)(null),z=(0,L.useRef)(null);if((0,L.useEffect)(()=>{if(!t){p([]),_(null),y(null);return}let e=!1;return h(!0),_(null),x(!0),y(null),fetch(`/api/v1/runs?scenario=${encodeURIComponent(t.id)}&limit=5`).then(async t=>{if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();e||p(n.runs??[])}).catch(t=>{e||(_(t instanceof Error?t.message:String(t)),p([]))}).finally(()=>{e||h(!1)}),fetch(`/scenarios/${encodeURIComponent(t.id)}`).then(async e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{e||y(t)}).catch(()=>{e||y(null)}).finally(()=>{e||x(!1)}),()=>{e=!0}},[t?.id]),(0,L.useEffect)(()=>{l?(z.current=document.activeElement,requestAnimationFrame(()=>{(re.current?.querySelector(`button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])`))?.focus()})):z.current?.focus()},[l]),(0,L.useEffect)(()=>{if(!l)return;function e(e){if(e.key===`Escape`)e.preventDefault(),o();else if(e.key===`Tab`){let t=Dv(re.current);if(t.length===0){e.preventDefault();return}let n=t[0],r=t[t.length-1],i=document.activeElement;!i||!re.current?.contains(i)?(e.preventDefault(),n.focus()):e.shiftKey&&i===n?(e.preventDefault(),r.focus()):!e.shiftKey&&i===r&&(e.preventDefault(),n.focus())}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[l,o]),!t)return null;let B=`scenario-detail-actor-count`,ie=()=>{t&&ne&&(k(N??t.name),D(!0),M(null))},ae=()=>{D(!1),k(``),M(null)},oe=async()=>{if(!t||!P||ee)return;let e=O.trim();if(e.length===0){M(`Name cannot be empty.`);return}if(e===(N??t.name)){D(!1);return}let n=Ln(P);if(n)M(n),F(Nn()||null);else{A(!0),M(null);try{let n=await fetch(`/scenarios/${encodeURIComponent(t.id)}/rename`,{method:`POST`,headers:{"Content-Type":`application/json`,[Tn]:P},body:JSON.stringify({name:e})});if(n.status===401){In(P);let e=Nn()||null;F(e),M(e?Sv(`rename`,`Save`):xv);return}if(!n.ok){let e=await n.json().catch(()=>({}));M(e.message??e.error??`Rename failed: HTTP ${n.status}`);return}let r=(await n.json()).name??e;te(r),D(!1),k(``),c?.(t.id,r)}catch(e){M(e instanceof Error?e.message:String(e))}finally{A(!1)}}};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:W.backdrop,onClick:o,role:`presentation`}),(0,R.jsxs)(`aside`,{ref:re,className:`${W.drawer} ${l?W.open:``}`,role:`dialog`,"aria-label":`Scenario detail: ${t.name}`,"aria-modal":`true`,children:[(0,R.jsxs)(`header`,{className:W.header,children:[(0,R.jsx)(`button`,{type:`button`,onClick:o,className:W.closeBtn,"aria-label":`Close scenario detail`,children:`×`}),(0,R.jsx)(`span`,{className:W.sourceBadge,"data-source":t.source??`other`,children:kv(t.source)})]}),(0,R.jsxs)(`section`,{className:W.summary,children:[E?(0,R.jsxs)(`form`,{className:W.nameEditForm,onSubmit:e=>{e.preventDefault(),oe()},children:[(0,R.jsx)(`input`,{type:`text`,value:O,onChange:e=>k(e.target.value),onKeyDown:e=>{e.key===`Escape`&&(e.preventDefault(),e.stopPropagation(),ae())},disabled:ee,maxLength:100,autoFocus:!0,className:W.nameEditInput,"aria-label":`New scenario name`}),(0,R.jsxs)(`div`,{className:W.nameEditActions,children:[(0,R.jsx)(`button`,{type:`submit`,className:W.nameEditSave,disabled:ee||!P||O.trim().length===0,"aria-describedby":j?Cv:void 0,children:ee?`Saving…`:`Save`}),(0,R.jsx)(`button`,{type:`button`,className:W.nameEditCancel,onClick:ae,disabled:ee,children:`Cancel`})]}),j&&(0,R.jsx)(`p`,{id:Cv,className:W.nameEditError,role:`alert`,children:j})]}):(0,R.jsxs)(`div`,{className:W.nameRow,children:[(0,R.jsx)(`h2`,{className:W.name,children:N??t.name}),ne&&(0,R.jsx)(`button`,{type:`button`,className:W.nameEditBtn,onClick:ie,"aria-label":`Rename ${N??t.name}`,title:`Rename scenario`,children:`✎`})]}),t.description&&(0,R.jsx)(`p`,{className:W.description,children:t.description}),(0,R.jsxs)(`dl`,{className:W.metaGrid,children:[typeof t.runCount==`number`&&(0,R.jsxs)(`div`,{className:W.meta,children:[(0,R.jsx)(`dt`,{children:`Total runs`}),(0,R.jsx)(`dd`,{children:t.runCount.toLocaleString()})]}),typeof t.departments==`number`&&(0,R.jsxs)(`div`,{className:W.meta,children:[(0,R.jsx)(`dt`,{children:`Departments`}),(0,R.jsx)(`dd`,{children:t.departments})]}),t.compiledAt&&(0,R.jsxs)(`div`,{className:W.meta,children:[(0,R.jsx)(`dt`,{children:`Compiled`}),(0,R.jsx)(`dd`,{title:t.compiledAt,children:wv(t.compiledAt)})]}),(0,R.jsxs)(`div`,{className:W.meta,children:[(0,R.jsx)(`dt`,{children:`Source`}),(0,R.jsx)(`dd`,{children:kv(t.source)})]})]})]}),t.seedText&&(0,R.jsxs)(`section`,{className:W.seedSection,"aria-labelledby":`scenario-detail-seed-heading`,children:[(0,R.jsx)(`h3`,{className:W.sectionHeading,id:`scenario-detail-seed-heading`,children:`Seed prompt`}),(0,R.jsx)(`p`,{className:W.seedHint,children:`Original brief that compile-from-seed turned into this scenario. Truncated to 1KB at persist time so very long sources read as their leading section.`}),(0,R.jsx)(`pre`,{className:W.seedBody,children:t.seedText})]}),v&&v.presets.length>0&&v.presets[0].leaders.length>0&&(0,R.jsxs)(`section`,{className:W.presetsSection,"aria-labelledby":`scenario-detail-presets-heading`,children:[(0,R.jsx)(`h3`,{className:W.sectionHeading,id:`scenario-detail-presets-heading`,children:`Leader presets`}),(0,R.jsx)(`p`,{className:W.sectionHint,children:`Default leader pair the scenario ships with. Picking Run with the slot count below fills these in first; extra slots beyond the preset get LLM-generated.`}),(0,R.jsx)(`ul`,{className:W.presetList,role:`list`,children:v.presets[0].leaders.map((e,t)=>(0,R.jsxs)(`li`,{className:W.presetCard,children:[(0,R.jsxs)(`div`,{className:W.presetHeader,children:[(0,R.jsx)(`span`,{className:W.presetName,children:e.name}),e.archetype&&(0,R.jsx)(`span`,{className:W.presetArchetype,children:e.archetype})]}),e.unit&&(0,R.jsx)(`span`,{className:W.presetUnit,children:e.unit}),e.hexaco&&Object.keys(e.hexaco).length>0&&(0,R.jsx)(`ul`,{className:W.hexacoList,"aria-label":`HEXACO profile for ${e.name}`,children:Object.entries(e.hexaco).slice(0,6).map(([e,t])=>{let n=Math.round((Number(t)||0)*100);return(0,R.jsxs)(`li`,{className:W.hexacoRow,children:[(0,R.jsx)(`span`,{className:W.hexacoAxis,children:e.length>6?e.slice(0,6):e}),(0,R.jsx)(`span`,{className:W.hexacoBar,role:`img`,"aria-label":`${e} ${n}%`,children:(0,R.jsx)(`span`,{className:W.hexacoFill,style:{width:`${n}%`}})}),(0,R.jsx)(`span`,{className:W.hexacoValue,children:n})]},e)})}),e.instructions&&(0,R.jsx)(`p`,{className:W.presetInstructions,title:e.instructions,children:e.instructions.length>220?`${e.instructions.slice(0,220)}…`:e.instructions})]},`${e.name}-${t}`))})]}),v&&v.departments.length>0&&(0,R.jsxs)(`section`,{className:W.departmentsSection,"aria-labelledby":`scenario-detail-depts-heading`,children:[(0,R.jsxs)(`h3`,{className:W.sectionHeading,id:`scenario-detail-depts-heading`,children:[`Departments `,(0,R.jsxs)(`span`,{className:W.sectionCount,children:[`· `,v.departments.length]})]}),(0,R.jsx)(`ul`,{className:W.deptChips,role:`list`,children:v.departments.map(e=>(0,R.jsxs)(`li`,{className:W.deptChip,children:[e.icon&&(0,R.jsx)(`span`,{className:W.deptIcon,"aria-hidden":`true`,children:e.icon}),(0,R.jsx)(`span`,{children:e.label}),e.role&&(0,R.jsxs)(`span`,{className:W.deptRole,children:[`· `,e.role]})]},e.id))})]}),b&&!v&&(0,R.jsx)(`p`,{className:W.statusLine,style:{padding:`0 18px`},children:`Loading scenario detail…`}),(0,R.jsxs)(`section`,{className:W.recentSection,"aria-labelledby":`scenario-detail-recent-heading`,children:[(0,R.jsx)(`h3`,{className:W.sectionHeading,id:`scenario-detail-recent-heading`,children:`Recent runs`}),m&&(0,R.jsx)(`p`,{className:W.statusLine,children:`Loading recent runs…`}),g&&!m&&(0,R.jsxs)(`p`,{className:`${W.statusLine} ${W.error}`,role:`alert`,children:[`Failed to load recent runs: `,g]}),!m&&!g&&f.length===0&&(0,R.jsx)(`p`,{className:W.statusLine,children:`No runs yet on this scenario.`}),f.length>0&&(0,R.jsx)(`ul`,{className:W.recentList,role:`list`,children:f.map(e=>(0,R.jsxs)(`li`,{className:W.recentRow,children:[(0,R.jsxs)(`span`,{className:W.recentTitle,children:[e.actorName??`Unknown leader`,e.actorArchetype&&(0,R.jsxs)(`span`,{className:W.recentArchetype,children:[` · `,e.actorArchetype]})]}),(0,R.jsxs)(`span`,{className:W.recentMeta,children:[wv(e.createdAt),` · `,Tv(e.costUSD),` · `,Ev(e.durationMs)]})]},e.runId))})]}),(0,R.jsxs)(`footer`,{className:W.footer,children:[a&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:W.actorRow,children:[(0,R.jsx)(`label`,{htmlFor:B,className:W.actorLabel,children:`Actors`}),(0,R.jsx)(`input`,{id:B,type:`range`,min:1,max:300,value:u,onChange:e=>d(parseInt(e.target.value,10)),disabled:n,className:W.actorSlider,"aria-label":`Number of parallel actors`}),(0,R.jsx)(`span`,{className:W.actorValue,children:u})]}),(0,R.jsxs)(`button`,{type:`button`,className:W.runButton,onClick:()=>i(t.id,u),disabled:n||S,"aria-label":`Run ${u} actor${u===1?``:`s`} against ${t.name}`,children:[`Run `,u,` `,u===1?`actor`:`actors`,` →`]})]}),I&&(0,R.jsx)(`button`,{type:`button`,className:W.deleteButton,onClick:async()=>{if(!t||!P||S||!(typeof window<`u`&&window.confirm(`Delete this scenario?\n\n"${t.name}"\n\nRemoves the scenario from disk + the live catalog. Past runs are kept (they live in run-history). Cannot be undone.`)))return;let e=Ln(P);if(e)T(e),F(Nn()||null);else{C(!0),T(null);try{let e=await fetch(`/admin/scenarios/${encodeURIComponent(t.id)}`,{method:`DELETE`,headers:{[Tn]:P}});if(e.status===401){In(P);let e=Nn()||null;F(e),T(e?Sv(`delete`,`Delete`):xv);return}if(!e.ok){let t=await e.json().catch(()=>({}));T(t.message??t.error??`Delete failed: HTTP ${e.status}`);return}s?.(t.id),o()}catch(e){T(e instanceof Error?e.message:String(e))}finally{C(!1)}}},disabled:S||n,"aria-label":`Delete scenario ${t.name}`,children:S?`Deleting…`:`Delete (admin)`}),w&&(0,R.jsx)(`p`,{className:W.deleteError,role:`alert`,children:w})]})]})]})}function kv(e){return e===`builtin`?`Built-in`:e===`disk`?`Saved`:e===`compiled`?`Custom`:e===`memory`?`Memory`:e??`Unknown`}var Av={section:`_section_1l91i_1`,header:`_header_1l91i_5`,heading:`_heading_1l91i_14`,count:`_count_1l91i_24`,statusLine:`_statusLine_1l91i_32`,error:`_error_1l91i_39`,actorRow:`_actorRow_1l91i_43`,actorLabel:`_actorLabel_1l91i_54`,actorSlider:`_actorSlider_1l91i_63`,actorValue:`_actorValue_1l91i_68`,filterRow:`_filterRow_1l91i_76`,searchLabel:`_searchLabel_1l91i_84`,searchInput:`_searchInput_1l91i_90`,chipGroup:`_chipGroup_1l91i_108`,chip:`_chip_1l91i_108`,chipActive:`_chipActive_1l91i_133`,chipCount:`_chipCount_1l91i_139`,sortLabel:`_sortLabel_1l91i_145`,sortSelect:`_sortSelect_1l91i_150`,emptyMatches:`_emptyMatches_1l91i_165`,clearFiltersBtn:`_clearFiltersBtn_1l91i_176`,grid:`_grid_1l91i_187`,card:`_card_1l91i_196`,cardBody:`_cardBody_1l91i_211`,cardActive:`_cardActive_1l91i_231`,cardHeader:`_cardHeader_1l91i_236`,sourceBadge:`_sourceBadge_1l91i_243`,badge_builtin:`_badge_builtin_1l91i_254`,badge_disk:`_badge_disk_1l91i_258`,badge_compiled:`_badge_compiled_1l91i_262`,badge_memory:`_badge_memory_1l91i_262`,badge_other:`_badge_other_1l91i_266`,activeBadge:`_activeBadge_1l91i_270`,cardName:`_cardName_1l91i_282`,cardSeed:`_cardSeed_1l91i_292`,cardStats:`_cardStats_1l91i_303`,stat:`_stat_1l91i_32`,statKey:`_statKey_1l91i_317`,statValue:`_statValue_1l91i_324`,runButton:`_runButton_1l91i_331`};function jv(e){let t=Date.parse(e);if(!Number.isFinite(t))return``;let n=Date.now()-t;if(n<0)return`just now`;let r=Math.floor(n/6e4);if(r<1)return`just now`;if(r<60)return`${r}m ago`;let i=Math.floor(r/60);if(i<24)return`${i}h ago`;let a=Math.floor(i/24);if(a<7)return`${a}d ago`;let o=Math.floor(a/7);if(o<5)return`${o}w ago`;let s=Math.floor(a/30);return s<12?`${s}mo ago`:new Date(e).getFullYear().toString()}function Mv(e){return e===`builtin`?`builtin`:e===`disk`?`disk`:e===`compiled`?`compiled`:e===`memory`?`memory`:`other`}function Nv(e){return e===`builtin`?`Built-in`:e===`disk`?`Saved`:e===`compiled`?`Custom`:e===`memory`?`Memory`:e??`Unknown`}function Pv(e){let{disabled:t=!1,onRunScenario:n}=e,r=fF(),i=!mF()||t,a=r.id,[o,s]=(0,L.useState)([]),[c,l]=(0,L.useState)(2),[u,d]=(0,L.useState)(!0),[f,p]=(0,L.useState)(null),[m,h]=(0,L.useState)(``),[g,_]=(0,L.useState)(``);(0,L.useEffect)(()=>{let e=setTimeout(()=>_(m),120);return()=>clearTimeout(e)},[m]);let[v,y]=(0,L.useState)(`all`),[b,x]=(0,L.useState)(`curated`),[S,C]=(0,L.useState)(null);if((0,L.useEffect)(()=>{let e=!1,t=null,n=async()=>{try{let t=await fetch(`/scenarios`);if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();if(e)return;s(n.scenarios??[]),p(null)}catch(t){if(e)return;p(t instanceof Error?t.message:String(t))}finally{e||d(!1)}};return n(),t=setInterval(n,3e4),()=>{e=!0,t&&clearInterval(t)}},[]),u&&o.length===0)return(0,R.jsxs)(`section`,{className:Av.section,"aria-labelledby":`scenario-catalog-heading`,children:[(0,R.jsx)(`h3`,{className:Av.heading,id:`scenario-catalog-heading`,children:`All scenarios`}),(0,R.jsx)(`p`,{className:Av.statusLine,children:`Loading catalog…`})]});if(f&&o.length===0)return(0,R.jsxs)(`section`,{className:Av.section,"aria-labelledby":`scenario-catalog-heading`,children:[(0,R.jsx)(`h3`,{className:Av.heading,id:`scenario-catalog-heading`,children:`All scenarios`}),(0,R.jsxs)(`p`,{className:`${Av.statusLine} ${Av.error}`,role:`alert`,children:[`Failed to load catalog: `,f]})]});if(o.length<2)return null;let w=`scenario-catalog-actor-count`,T=`scenario-catalog-search`,E=g.trim().length>0||v!==`all`,D=g.trim().toLowerCase(),O=[...o.filter(e=>e.id===a?!0:v!==`all`&&e.source!==v?!1:D.length===0||[e.name,e.id,e.seedText??``,e.description??``].join(` `).toLowerCase().includes(D))].sort((e,t)=>{if(e.id===a)return-1;if(t.id===a)return 1;if(b===`most-runs`){let n=(t.runCount??0)-(e.runCount??0);if(n!==0)return n}else if(b===`newest`){let n=e.compiledAt?Date.parse(e.compiledAt):0,r=t.compiledAt?Date.parse(t.compiledAt):0;if(n!==r)return r-n}else if(b===`alphabetical`)return e.name.localeCompare(t.name);else{let n=(t.runCount??0)-(e.runCount??0);if(n!==0)return n;if(e.compiledAt&&t.compiledAt){let n=Date.parse(e.compiledAt),r=Date.parse(t.compiledAt);if(Number.isFinite(n)&&Number.isFinite(r)&&n!==r)return r-n}}return e.name.localeCompare(t.name)}),k=o.reduce((e,t)=>{let n=t.source??`other`;return e[n]=(e[n]??0)+1,e},{});return(0,R.jsxs)(`section`,{className:Av.section,"aria-labelledby":`scenario-catalog-heading`,children:[(0,R.jsxs)(`header`,{className:Av.header,children:[(0,R.jsxs)(`h3`,{className:Av.heading,id:`scenario-catalog-heading`,children:[`All scenarios`,` `,(0,R.jsxs)(`span`,{className:Av.count,children:[`· `,E?`${O.length} of ${o.length}`:o.length]})]}),(0,R.jsxs)(`div`,{className:Av.actorRow,children:[(0,R.jsx)(`label`,{className:Av.actorLabel,htmlFor:w,children:`Actors`}),(0,R.jsx)(`input`,{id:w,type:`range`,min:1,max:300,value:c,onChange:e=>l(parseInt(e.target.value,10)),disabled:i,className:Av.actorSlider,"aria-label":`Number of parallel actors per scenario run`}),(0,R.jsx)(`span`,{className:Av.actorValue,children:c})]})]}),(0,R.jsxs)(`div`,{className:Av.filterRow,children:[(0,R.jsxs)(`label`,{className:Av.searchLabel,htmlFor:T,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`Search scenarios`}),(0,R.jsx)(`input`,{id:T,type:`search`,value:m,onChange:e=>h(e.target.value),placeholder:`Search by name or seed text…`,className:Av.searchInput,"aria-label":`Filter catalog by name or seed text`})]}),(0,R.jsx)(`div`,{className:Av.chipGroup,role:`group`,"aria-label":`Filter by scenario source`,children:[{key:`all`,label:`All`},{key:`builtin`,label:`Built-in`},{key:`disk`,label:`Saved`},{key:`compiled`,label:`Custom`}].map(e=>{let t=e.key===`all`?o.length:k[e.key]??0,n=v===e.key;return e.key!==`all`&&t===0?null:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>y(e.key),className:`${Av.chip} ${n?Av.chipActive:``}`,"aria-pressed":n,children:[e.label,` `,(0,R.jsx)(`span`,{className:Av.chipCount,children:t})]},e.key)})}),(0,R.jsxs)(`label`,{className:Av.sortLabel,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:`Sort scenarios`}),(0,R.jsxs)(`select`,{value:b,onChange:e=>x(e.target.value),className:Av.sortSelect,"aria-label":`Sort catalog`,children:[(0,R.jsx)(`option`,{value:`curated`,children:`Sort: Curated`}),(0,R.jsx)(`option`,{value:`most-runs`,children:`Sort: Most runs`}),(0,R.jsx)(`option`,{value:`newest`,children:`Sort: Newest first`}),(0,R.jsx)(`option`,{value:`alphabetical`,children:`Sort: A → Z`})]})]})]}),O.length===0?(0,R.jsxs)(`div`,{className:Av.emptyMatches,role:`status`,"aria-live":`polite`,children:[`No scenarios match your filter.`,` `,(0,R.jsx)(`button`,{type:`button`,className:Av.clearFiltersBtn,onClick:()=>{h(``),y(`all`)},children:`Clear filters`})]}):(0,R.jsx)(`ul`,{className:Av.grid,role:`list`,children:O.map(e=>{let t=Mv(e.source),r=e.id===a;return(0,R.jsxs)(`li`,{className:`${Av.card} ${Av[`tone_${t}`]??``} ${r?Av.cardActive:``}`.trim(),children:[(0,R.jsxs)(`button`,{type:`button`,className:Av.cardBody,onClick:()=>C(e),"aria-label":`View detail for ${e.name}`,children:[(0,R.jsxs)(`div`,{className:Av.cardHeader,children:[(0,R.jsx)(`span`,{className:`${Av.sourceBadge} ${Av[`badge_${t}`]??``}`,children:Nv(e.source)}),r&&(0,R.jsx)(`span`,{className:Av.activeBadge,children:`Loaded`})]}),(0,R.jsx)(`h4`,{className:Av.cardName,children:e.name}),e.seedText&&(0,R.jsxs)(`p`,{className:Av.cardSeed,title:e.seedText,children:[e.seedText.slice(0,140),e.seedText.length>140?`…`:``]}),(0,R.jsxs)(`dl`,{className:Av.cardStats,children:[typeof e.runCount==`number`&&e.runCount>0&&(0,R.jsxs)(`div`,{className:Av.stat,children:[(0,R.jsx)(`dt`,{className:Av.statKey,children:`Runs`}),(0,R.jsx)(`dd`,{className:Av.statValue,children:e.runCount.toLocaleString()})]}),typeof e.departments==`number`&&e.departments>0&&(0,R.jsxs)(`div`,{className:Av.stat,children:[(0,R.jsx)(`dt`,{className:Av.statKey,children:`Depts`}),(0,R.jsx)(`dd`,{className:Av.statValue,children:e.departments})]}),e.compiledAt&&(0,R.jsxs)(`div`,{className:Av.stat,children:[(0,R.jsx)(`dt`,{className:Av.statKey,children:`Compiled`}),(0,R.jsx)(`dd`,{className:Av.statValue,children:jv(e.compiledAt)||e.compiledAt.slice(0,10)})]})]})]}),(0,R.jsxs)(`button`,{type:`button`,className:Av.runButton,onClick:t=>{t.stopPropagation(),n(e.id,c)},disabled:i,"aria-label":`Run ${c} actor${c===1?``:`s`} against ${e.name}`,children:[`Run `,c,` `,c===1?`actor`:`actors`,` →`]})]},e.id)})}),(0,R.jsx)(Ov,{scenario:S,disabled:i,initialActorCount:c,onRunScenario:(e,t)=>{C(null),n(e,t)},onClose:()=>C(null),onDeleted:e=>{s(t=>t.filter(t=>t.id!==e))},onRenamed:(e,t)=>{s(n=>n.map(n=>n.id===e?{...n,name:t}:n)),C(n=>n&&n.id===e?{...n,name:t}:n)}})]})}var Fv=[{id:`hurricane-evacuation`,label:`What if a coastal mayor has 36 hours to evacuate before a hurricane?`,seedText:`A coastal metro of 800,000 has 36 hours before a Category 4 hurricane landfall. The mayor must decide a phased evacuation across three districts served by a single causeway bridge, with a regional hospital, a fuel depot, and an aging levee system in play. Departments involved: emergency management, public health, transportation, utilities, communications.`},{id:`saas-mid-tier`,label:`What if a developer-tools SaaS adds a $14 mid-tier?`,seedText:`StackPulse, a developer-focused observability SaaS (logs + metrics + tracing aimed at series-B-to-D startup engineering teams of 5-50 people), introduces a new $14/month "Builder" tier between the free Sandbox plan and the existing $29 Pro plan. The 180,000-user paid base is mostly engineering managers and SREs at venture-backed startups; their #1 jobs-to-be-done are debugging production incidents under 15 minutes and proving reliability SLAs to enterprise customers. Builder caps log retention at 7 days (Pro keeps 30) and limits trace sampling to 10% (Pro is full). Existing Pro subs get 90-day grandfathering. Competitors: Datadog (incumbent, 10x the price), Honeycomb (premium tier), self-hosted Grafana stacks. Test the impact on Free-to-Paid conversion, Pro downgrade rate, net ARPU, and churn over six months. Departments: pricing, growth, success, finance, engineering.`},{id:`ai-lab-early-release`,label:`What if an AI lab releases a frontier model six weeks early?`,seedText:`An AI lab decides whether to release a frontier multimodal model six weeks early. Two evaluators flag a 4.2% specification-gaming rate on long-horizon agentic tasks and early mesa-objective signals under DPO. A rival lab's weaker model ships on schedule, capturing $240M ARR in enterprise deals. Council: alignment, capability, policy, infra, comms.`},{id:`generation-ship-fuel-leak`,label:`What if a generation ship discovers a fuel leak at year 18?`,seedText:`A generation ship with 2,400 passengers at year 18 of a 40-year interstellar transit discovers a slow fuel leak on the main reactor. Reactor crew wants to EVA-repair (non-zero fatality risk); bridge wants to coast at reduced thrust and accept a 14-year transit extension. Departments: engineering, life support, medical, psych, command.`},{id:`city-congestion-pricing`,label:`What if a city pilots congestion pricing for 12 months?`,seedText:`A mid-size city of 650,000 pilots downtown congestion pricing for 12 months. $9 peak / $3 off-peak on vehicles entering the central business district 6am-7pm Mon-Fri. Revenue funds two BRT lines and a 30% transit fare cut for low-income riders. Test VMT, transit ridership, small-business revenue, equity outcomes.`}];function Iv(e){return .1+.6*e}var Lv={pendingSeedNotice:`_pendingSeedNotice_15vcr_1`,dividerWrap:`_dividerWrap_15vcr_15`,dividerLine:`_dividerLine_15vcr_27`,seedInput:`_seedInput_15vcr_33`,templatePicker:`_templatePicker_15vcr_48`,templatePickerLabel:`_templatePickerLabel_15vcr_55`,templatePickerSelect:`_templatePickerSelect_15vcr_65`,tabs:`_tabs_15vcr_90`,tab:`_tab_15vcr_90`,tabActive:`_tabActive_15vcr_119`,textarea:`_textarea_15vcr_124`,input:`_input_15vcr_125`,urlRow:`_urlRow_15vcr_142`,fetchButton:`_fetchButton_15vcr_150`,runButton:`_runButton_15vcr_151`,dropZone:`_dropZone_15vcr_185`,hint:`_hint_15vcr_205`,charCount:`_charCount_15vcr_218`,error:`_error_15vcr_225`,actorCountRow:`_actorCountRow_15vcr_235`,actorCountLabel:`_actorCountLabel_15vcr_246`,actorCountSlider:`_actorCountSlider_15vcr_257`,actorCountPreview:`_actorCountPreview_15vcr_313`,pasteOnly:`_pasteOnly_15vcr_320`,atLimit:`_atLimit_15vcr_416`,settingsLink:`_settingsLink_15vcr_425`};function Rv(){if(typeof window>`u`)return``;try{let e=new URLSearchParams(window.location.search).get(`prompt`);return e?e.trim():``}catch{return``}}function zv({onSeedReady:e,onLoadedScenarioRunStart:t,onCatalogRunStart:n,disabled:r=!1,variant:i=`full`,payer:a,atLimit:o=null,seedText:s,onSeedTextChange:c,registerGoToDraft:l,locked:u=!1}){let d=i===`pasteOnly`,f=a===`host`,p=f&&o!==null,[m,h]=(0,L.useState)(`paste`),[g,_]=(0,L.useState)(Rv),v=s??g,y=c??_,b=(0,L.useRef)(null),[x,S]=(0,L.useState)(0);(0,L.useEffect)(()=>{l?.(()=>{h(`paste`),S(e=>e+1)})},[l]),(0,L.useEffect)(()=>{if(x===0)return;let e=b.current;e&&(e.focus(),e.scrollIntoView({block:`center`}))},[x]);let[C,w]=(0,L.useState)(``),[T,E]=(0,L.useState)(void 0),[D,O]=(0,L.useState)(``),[k,ee]=(0,L.useState)(null),[A,j]=(0,L.useState)(!1),[M,N]=(0,L.useState)(2),te=(0,L.useRef)(null),P=(0,L.useCallback)(()=>{if(u||p)return;let t=v.trim(),n=Z_(t);n.ok?(ee(null),e({seedText:t,sourceUrl:T,domainHint:D.trim()||void 0,actorCount:f?2:M})):ee(n.reason===`too-short`?`Paste at least 200 characters of source material.`:n.reason===`too-long`?`Source material exceeds 50 000 characters.`:`Source material is empty.`)},[v,T,D,M,e,p,f,u]),F=(0,L.useCallback)(async()=>{let e=X_(C);if(!e.ok)ee(e.error);else{j(!0),ee(null);try{let t=await fetch(`/api/quickstart/fetch-seed`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({url:e.url.toString()})});if(!t.ok){let e=await t.json().catch(()=>({}));ee(e.error??`Fetch failed: HTTP ${t.status}`);return}let n=await t.json();y(n.text),E(n.sourceUrl??e.url.toString()),h(`paste`)}catch(e){let t=e?.message??String(e),n=/Failed to fetch|NetworkError|ERR_/i.test(t)?`Couldn't reach the server. Check your connection and try again.`:`URL fetch failed: ${t}`;ee(n)}finally{j(!1)}}},[C,y]),I=(0,L.useCallback)(async e=>{if(e.size>10485760)ee(`PDF exceeds 10 MB limit.`);else if(e.type!==`application/pdf`&&!e.name.toLowerCase().endsWith(`.pdf`))ee(`File is not a PDF: ${e.name}`);else{j(!0),ee(null);try{let{text:t,truncated:n}=await dv(e);y(n?`${t}\n\n[Truncated to first 50 KB.]`:t),E(void 0),h(`paste`)}catch(e){let t=e?.code,n=String(e?.message??e),r;r=t===`PDF_NO_TEXT`?`No text found in this PDF. It looks like a scanned image — try a text-based PDF, or paste the content into WRITE.`:/InvalidPDFException|invalid pdf|corrupt/i.test(n)?`This PDF appears to be corrupted or password-protected. Try a different file or paste the text directly.`:/worker|GlobalWorkerOptions/i.test(n)?`Couldn't load the PDF parser (${n}). Try a different file, or paste the text into WRITE.`:`Couldn't read this PDF (${n}). Try paste-text or a different file.`,ee(r)}finally{j(!1)}}},[y]),ne={paste:`WRITE`,url:`URL`,pdf:`PDF`},re=v.trim().length>=200;return(0,R.jsxs)(`div`,{className:d?`${Lv.seedInput} ${Lv.pasteOnly}`:Lv.seedInput,children:[!d&&t&&(0,R.jsxs)(R.Fragment,{children:[re&&(0,R.jsx)(`p`,{className:Lv.pendingSeedNotice,role:`status`,"aria-live":`polite`,children:`You have draft seed text below. Submit it to compile a new scenario, or clear it to run the loaded one.`}),(0,R.jsx)(bv,{onRunStart:t,disabled:r||A||re}),n&&(0,R.jsx)(Pv,{onRunScenario:n,disabled:r||A||re}),(0,R.jsxs)(`div`,{className:Lv.dividerWrap,children:[(0,R.jsx)(`span`,{className:Lv.dividerLine,"aria-hidden":`true`}),(0,R.jsx)(`span`,{children:`or paste a new scenario`}),(0,R.jsx)(`span`,{className:Lv.dividerLine,"aria-hidden":`true`})]})]}),(0,R.jsxs)(`label`,{className:Lv.templatePicker,children:[(0,R.jsx)(`span`,{className:Lv.templatePickerLabel,children:`Try a template`}),(0,R.jsxs)(`select`,{className:Lv.templatePickerSelect,value:``,disabled:r,onChange:e=>{let t=e.target.value;if(!t)return;let n=Fv.find(e=>e.id===t);n&&(h(`paste`),y(n.seedText),ee(null),e.target.value=``)},children:[(0,R.jsx)(`option`,{value:``,children:`Pick a sample scenario…`}),Fv.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,R.jsx)(`div`,{className:Lv.tabs,role:`tablist`,children:[`paste`,`url`,`pdf`].map(e=>(0,R.jsx)(`button`,{role:`tab`,"aria-selected":m===e,className:`${Lv.tab} ${m===e?Lv.tabActive:``}`,onClick:()=>{h(e),ee(null)},disabled:r,type:`button`,children:ne[e]},e))}),m===`paste`&&(0,R.jsx)(`textarea`,{ref:b,id:`quickstart-seed-field`,"data-quickstart-seed":!0,className:Lv.textarea,placeholder:`Type or paste a brief, article, meeting notes, or any domain-specific source material (at least 200 characters).`,value:v,onChange:e=>y(e.target.value),rows:6,disabled:r,readOnly:u,"aria-disabled":u?`true`:void 0}),m===`url`&&(0,R.jsxs)(`div`,{className:Lv.urlRow,children:[(0,R.jsx)(`input`,{type:`url`,className:Lv.input,placeholder:`https://example.com/article`,value:C,onChange:e=>w(e.target.value),disabled:r||A}),(0,R.jsx)(`button`,{type:`button`,className:Lv.fetchButton,onClick:F,disabled:r||A||!C,children:A?`Fetching...`:`Fetch`})]}),m===`pdf`&&(0,R.jsxs)(`div`,{className:Lv.dropZone,"data-paracosm-local-dropzone":`pdf`,onClick:()=>{r||te.current?.click()},onDragOver:e=>e.preventDefault(),onDrop:e=>{if(e.preventDefault(),r)return;let t=e.dataTransfer.files[0];t&&I(t)},role:`button`,tabIndex:r?-1:0,"aria-disabled":r,onKeyDown:e=>{r||(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),te.current?.click())},children:[(0,R.jsx)(`input`,{ref:te,type:`file`,accept:`application/pdf,.pdf`,onChange:e=>{let t=e.target.files?.[0];t&&I(t)},hidden:!0}),A?`Extracting text...`:`Drop a PDF or click to upload (max 10 MB, first 50 KB of text used)`]}),(0,R.jsxs)(`div`,{className:Lv.hint,children:[(0,R.jsx)(`label`,{htmlFor:`quickstart-domain-hint`,children:`Domain hint (optional)`}),(0,R.jsx)(`input`,{id:`quickstart-domain-hint`,className:Lv.input,type:`text`,placeholder:`e.g., "clinical trial decision" or "startup growth"`,value:D,onChange:e=>O(e.target.value),maxLength:80,disabled:r})]}),k&&(0,R.jsx)(`p`,{className:Lv.error,role:`alert`,children:k}),(0,R.jsxs)(`div`,{className:Lv.charCount,children:[v.length.toLocaleString(),` / 50,000 characters`]}),!f&&(0,R.jsxs)(`div`,{className:Lv.actorCountRow,children:[(0,R.jsxs)(`label`,{htmlFor:`quickstart-actor-count`,className:Lv.actorCountLabel,children:[`Actors: `,(0,R.jsx)(`strong`,{children:M})]}),(0,R.jsx)(`input`,{id:`quickstart-actor-count`,type:`range`,min:1,max:300,value:M,onChange:e=>N(parseInt(e.target.value,10)),disabled:r,className:Lv.actorCountSlider,"aria-label":`Number of parallel actors to run`}),(0,R.jsxs)(`span`,{className:Lv.actorCountPreview,"aria-live":`polite`,children:[`~$`,Iv(M).toFixed(2),` · `,Vv(M)]})]}),(0,R.jsx)(_v,{seedText:v,domainHint:D,sourceUrl:T,actorCount:M,disabled:r}),p&&(0,R.jsxs)(`div`,{className:Lv.atLimit,"data-testid":`paste-at-limit`,children:[(0,R.jsx)(`p`,{children:Et(o?.resetTime)}),(0,R.jsx)(`p`,{children:Dt(!1)}),(0,R.jsx)(`a`,{className:Lv.settingsLink,href:Bv(),children:`Add your API key in Settings`})]}),(0,R.jsx)(`button`,{type:`button`,className:Lv.runButton,onClick:P,disabled:!p&&(r||v.trim().length<200),"aria-disabled":p?`true`:void 0,children:f?rn:(0,R.jsxs)(R.Fragment,{children:[`Generate + Run `,M,` `,M===1?`Actor`:`Actors`,` (~$`,Iv(M).toFixed(2),`)`]})})]})}function Bv(){return typeof window>`u`?`?tab=settings#key-openai`:`${A_(window.location.href,`settings`)}#key-openai`}function Vv(e){if(e<=0)return`—`;let t=2+5*Math.max(1,Math.ceil(e/8));return`${t}–${Math.ceil(t*1.5)} min`}var Hv=100,Uv=2,Wv=3,Gv=e=>typeof e==`number`&&Number.isInteger(e)&&e>0;function Kv(){try{return typeof window>`u`?null:window.localStorage}catch{return null}}function qv(e){return{overrides:E(),lastLaunch:e?g(e):null}}function Jv(e,t){return z_(t)?`own`:e.adminConfig.hostedDemo===!0?`host`:`server`}function Yv(e,t,n,r){let i=t.setup.defaultTurns;if(r===`host`){let t=e.adminConfig.demoCaps?.maxTurns;return Gv(t)?Math.min(i,t):i}let a=n.lastLaunch;if(a&&_(a,t.id)){let e=a.turns;if(Gv(e)&&e<=Hv)return e}return i}var Xv=100;function Zv(e,t,n){let r=Math.max(t.setup.defaultPopulation??Xv,t.departments.length);if(n!==`host`)return r;let i=e.adminConfig.demoCaps?.maxPopulation;return Gv(i)?Math.min(r,i):r}function Qv(e,t,n){let r=t.departments.length,i=e.adminConfig.demoCaps?.maxActiveDepartments,a=n===`host`&&Gv(i)?Math.min(r,i):r;return a>0?a:void 0}function $v(e){let t=e.setup.maxEventsPerTurn;return Gv(t)?Math.min(t,Wv):Uv}function ey(e){return[Te(e.people,`person`,`people`),...e.departments===void 0?[]:[Te(e.departments,`department`,`departments`)],Te(e.turns,`turn`,`turns`),`up to ${e.events} ${e.events===1?`event`:`events`} a turn`]}function ty(e){return ey(e).join(`, `)}var ny=42,ry=34,iy=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function ay(e){return e.presets[0]?.leaders??e.presets[0]?.actors??[]}function oy(e){if(!iy(e))return;let t={};for(let[n,r]of Object.entries(e))typeof r==`string`&&r.trim()&&(t[n]=r);return Object.keys(t).length>0?t:void 0}function sy(e,t,n,r,i){let a=Yv(e,t,n,i),o=n.lastLaunch,{overrides:s}=n,c={...R_(s)};s.serper&&(c.serperKey=s.serper),s.firecrawl&&(c.firecrawlKey=s.firecrawl),s.tavily&&(c.tavilyKey=s.tavily),s.cohere&&(c.cohereKey=s.cohere);let l=o?.provider,u=o?.models,d=o?.economics;l&&(c.provider=l),iy(u)&&(c.models=u),iy(d)&&(c.economics=d);let f=ay(t);f.length>=r&&(c.actors=f.slice(0,r).map(e=>({name:e.name,archetype:e.archetype,hexaco:e.hexaco,instructions:e.instructions}))),c.turns=a,c.seed=t.setup.defaultSeed??ny,c.captureSnapshots=!0,c.quickstart={scenarioId:t.id};let p=R_(s),m=p.apiKey&&!p.anthropicKey?`openai`:p.anthropicKey&&!p.apiKey?`anthropic`:void 0,h=typeof l==`string`&&l.trim()?l:void 0,g=i!==`host`&&(m===void 0||h?.trim().toLowerCase()===m),_=g?h:void 0,v=g?oy(u):void 0,y=iy(d)?d.batch:void 0,b=iy(y)?y.maxConcurrency:void 0;return{payer:i,size:r,turns:a,people:Zv(e,t,i),departments:Qv(e,t,i),events:$v(t),..._?{provider:_}:{},...v?{models:v}:{},...Gv(b)?{batch:b}:{},body:c}}function cy(e){return Math.round(e*ry/60*2)/2}function ly(e){return{openai:`OpenAI`,anthropic:`Anthropic`}[e.trim().toLowerCase()]??e}function uy(e){return[...new Set(Object.values(e))].join(`, `)}function dy(e){let t=R_(e.overrides);if(t.apiKey&&!t.anthropicKey)return ly(`openai`);if(t.anthropicKey&&!t.apiKey)return ly(`anthropic`);let n=e.lastLaunch?.provider;if(t.apiKey&&t.anthropicKey&&(n===`openai`||n===`anthropic`))return ly(n)}var fy={note:`_note_q6n1e_1`,notes:`_notes_q6n1e_10`};function py(){return(0,R.jsx)(`p`,{className:fy.note,"data-text":`body`,"data-testid":`note-fictional`,children:cn})}function my(){return(0,R.jsxs)(`div`,{className:fy.notes,"data-testid":`first-screen-notes`,children:[(0,R.jsx)(`p`,{className:fy.note,"data-text":`body`,"data-testid":`note-ai`,children:ln}),(0,R.jsx)(`p`,{className:fy.note,"data-text":`body`,"data-testid":`note-adults`,children:un})]})}function hy(e){if(e.networkError||e.online===!1)return{kind:`offline`};let t=e.body?.remaining,n=e.body?.maxRuns;return e.status===429&&t===0?{kind:e.request===`leaders`?`other`:`limit`}:e.status===503&&typeof n==`number`&&Number.isFinite(n)?{kind:`slots`}:e.status===429||e.status===503?{kind:`busy`}:{kind:`other`}}var gy=e=>Array.isArray(e.leaders)?e.leaders.length===2:!!(e.leaderA&&e.leaderB);function _y(e,t){let n;for(let r of e)t(r)&&(!n||(r.createdAt??-1/0)>(n.createdAt??-1/0))&&(n=r);return n}function vy(e){let t=_y(e,e=>e.pinned!==!0);if(t)return{kind:`own`,row:t};let n=_y(e,e=>e.pinned===!0&&gy(e));return n?{kind:`team`,row:n}:{kind:`neither`}}function yy(e,t,n){if(!Number.isFinite(e))return``;try{return new Intl.DateTimeFormat(t,{hour:`numeric`,minute:`2-digit`,timeZoneName:`short`,...n?{timeZone:n}:{}}).format(new Date(e))}catch{return``}}function by(e,t){if(!Number.isFinite(e))return null;try{let n={},r=new Intl.DateTimeFormat(`en-US`,{hour:`numeric`,minute:`numeric`,hourCycle:`h23`,...t?{timeZone:t}:{}});for(let t of r.formatToParts(new Date(e)))n[t.type]=t.value;let i=Number(n.hour)%24,a=Number(n.minute);return Number.isInteger(i)&&Number.isInteger(a)?{hour:i,minute:a}:null}catch{return null}}function xy(e){return{hour:e.hour%12*30+e.minute/2,minute:e.minute*6}}function Sy(e,t=!1){let[n,r]=(0,L.useState)(()=>typeof window>`u`||!window.matchMedia?t:window.matchMedia(e).matches);return(0,L.useEffect)(()=>{if(typeof window>`u`||!window.matchMedia)return;let t=window.matchMedia(e),n=e=>r(e.matches);return t.addEventListener(`change`,n),r(t.matches),()=>t.removeEventListener(`change`,n)},[e]),n}var Cy=`(max-width: 768px)`,wy=`(max-width: 480px)`,Ty=`(max-width: 899.98px)`,Ey=`(prefers-reduced-motion: reduce)`;function Dy({className:e}){return(0,R.jsx)(`svg`,{className:e,style:{color:`var(--amber)`},width:`12`,height:`12`,viewBox:`0 0 12 12`,"aria-hidden":`true`,focusable:`false`,"data-glyph":`section`,children:(0,R.jsx)(`path`,{d:`M3 1.5 10.5 6 3 10.5Z`,fill:`currentColor`})})}function Oy({className:e}){return(0,R.jsxs)(`svg`,{className:e,style:{color:`var(--text-1)`},width:`24`,height:`24`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,"data-mark":`broken-link`,children:[(0,R.jsx)(`path`,{d:`M10 14.5 7.2 17.3a3 3 0 0 1-4.24-4.24L5.8 10.2a3 3 0 0 1 4.2-.05`}),(0,R.jsx)(`path`,{d:`M14 9.5 16.8 6.7a3 3 0 0 1 4.24 4.24L18.2 13.8a3 3 0 0 1-4.2.05`}),(0,R.jsx)(`path`,{d:`M8.5 2.5v2.5M2.5 8.5H5M15.5 21.5V19M21.5 15.5H19`})]})}function ky({className:e}){return(0,R.jsxs)(`svg`,{className:e,style:{color:`var(--amber)`},width:`20`,height:`20`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,focusable:`false`,"data-mark":`warning`,children:[(0,R.jsx)(`path`,{d:`M10 2.5 18 17H2Z`}),(0,R.jsx)(`path`,{d:`M10 8v4`}),(0,R.jsx)(`path`,{d:`M10 14.5h.01`})]})}var Ay={rows:`_rows_1tldq_1`,row:`_row_1tldq_1`,name:`_name_1tldq_19`,figure:`_figure_1tldq_20`,track:`_track_1tldq_41`,short:`_short_1tldq_51`,fill:`_fill_1tldq_56`,tick:`_tick_1tldq_68`,tickLow:`_tickLow_1tldq_77`,tickHigh:`_tickHigh_1tldq_81`},jy=[`openness`,`conscientiousness`,`extraversion`,`agreeableness`,`emotionality`,`honestyHumility`];function My(e){return e===`conscientiousness`?`Conscientiousness`:Re[e]}var Ny={low:.35,high:.65};function Py(e){return e<Ny.low||e>Ny.high}function Fy(e){return e.toFixed(2)}function Iy(e){if(!e)return null;let t={};for(let n of jy){let r=e[n];typeof r==`number`&&Number.isFinite(r)&&r>=0&&r<=1&&(t[n]=r)}return Object.keys(t).length>0?t:null}function Ly({score:e,short:t}){return(0,R.jsxs)(`span`,{className:[Ay.track,t?Ay.short:``].filter(Boolean).join(` `),"data-score-track":!0,"aria-hidden":`true`,children:[e!==void 0&&(0,R.jsx)(`span`,{className:Ay.fill,"data-meter-fill":!0,"data-outside":Py(e)?`true`:`false`,style:{"--score":String(Math.round(e*1e3)/10)}}),(0,R.jsx)(`span`,{className:`${Ay.tick} ${Ay.tickLow}`,"data-band-tick":!0}),(0,R.jsx)(`span`,{className:`${Ay.tick} ${Ay.tickHigh}`,"data-band-tick":!0})]})}function Ry({scores:e,label:t,stackWide:n}){return(0,R.jsx)(`ul`,{className:Ay.rows,"aria-label":t,"data-testid":`score-rows`,"data-stack-wide":n?`true`:void 0,children:jy.map(t=>{let n=e?.[t];return(0,R.jsxs)(`li`,{className:Ay.row,"data-score":t,children:[(0,R.jsx)(`span`,{className:Ay.name,"data-testid":`score-name`,children:My(t)}),n!==void 0&&(0,R.jsx)(`span`,{className:`sr-only`,children:`, `}),(0,R.jsx)(Ly,{score:n}),n!==void 0&&(0,R.jsx)(`span`,{className:Ay.figure,"data-testid":`score-figure`,children:Fy(n)})]},t)})})}var zy={leaders:`_leaders_u1r34_9`,pair:`_pair_u1r34_18`,card:`_card_u1r34_26`,shown:`_shown_u1r34_37`,head:`_head_u1r34_55`,place:`_place_u1r34_68`,name:`_name_u1r34_81`,title:`_title_u1r34_92`,scores:`_scores_u1r34_105`,orders:`_orders_u1r34_106`,mark:`_mark_u1r34_113`,triangle:`_triangle_u1r34_126`,band:`_band_u1r34_132`,note:`_note_u1r34_133`,ordersText:`_ordersText_u1r34_144`,noLeaders:`_noLeaders_u1r34_154`,writesAll:`_writesAll_u1r34_163`,switch:`_switch_u1r34_172`,key:`_key_u1r34_181`,keyPlace:`_keyPlace_u1r34_216`,headPlace:`_headPlace_u1r34_217`,table:`_table_u1r34_224`,corner:`_corner_u1r34_231`,colHead:`_colHead_u1r34_235`,rowHead:`_rowHead_u1r34_236`,cell:`_cell_u1r34_251`,cellInner:`_cellInner_u1r34_271`,cellFigure:`_cellFigure_u1r34_278`,shape:`_shape_u1r34_304`,loadingShapeTone:`_loadingShapeTone_u1r34_1`},By=`(min-width: 1100px)`;function Vy(e){let t=e.presets[0]?.leaders??e.presets[0]?.actors??[];return[0,1].map(e=>{let n=t[e],r=e+1;return n?{place:r,name:n.name,written:!0,title:n.archetype??``,scores:Iy(n.hexaco),orders:n.instructions??``}:{place:r,name:Ne(r),written:!1,title:``,scores:null,orders:``}})}function Hy({id:e,children:t}){return(0,R.jsxs)(`h3`,{id:e,className:zy.mark,children:[(0,R.jsx)(Dy,{className:zy.triangle}),(0,R.jsx)(`span`,{children:t})]})}function Uy({leader:e,noneWritten:t}){return e.written?e.orders?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(Hy,{children:Le}),(0,R.jsx)(`blockquote`,{className:zy.ordersText,"data-text":`body`,"data-testid":`leader-orders`,children:e.orders}),e.scores&&(0,R.jsx)(`p`,{className:zy.note,"data-testid":`hexaco-note`,children:`HEXACO is a six-trait personality model. The six scores above are this leader’s.`})]}):null:t?(0,R.jsx)(`p`,{className:zy.noLeaders,"data-text":`body`,"data-testid":`no-written-leaders`,children:Ve}):null}function Wy({leader:e,noneWritten:t}){let n=(0,L.useId)();return(0,R.jsxs)(`article`,{className:zy.card,"aria-labelledby":n,children:[(0,R.jsxs)(`header`,{className:zy.head,"data-testid":`leader-head`,children:[(0,R.jsx)(`span`,{className:zy.place,"data-testid":`leader-place`,"aria-hidden":`true`,children:e.written?e.place:``}),e.written&&(0,R.jsx)(`span`,{className:`sr-only`,children:Me(e.place)}),(0,R.jsx)(`h2`,{id:n,className:zy.name,"data-text":`heading`,translate:`no`,children:e.name}),e.title&&(0,R.jsx)(`p`,{className:zy.title,"data-testid":`leader-title`,children:e.title})]}),(0,R.jsxs)(`div`,{className:zy.scores,children:[(0,R.jsx)(Hy,{children:Ie}),(0,R.jsx)(`p`,{className:zy.band,"data-testid":`middle-band`,children:ze}),(0,R.jsx)(Ry,{scores:e.scores,label:`${e.name}, ${Ie.toLowerCase()}`,stackWide:!0})]}),(0,R.jsx)(`div`,{className:zy.orders,children:(0,R.jsx)(Uy,{leader:e,noneWritten:t})})]})}function Gy({pair:e,shown:t,onShow:n,tabId:r,panelId:i}){let a=(0,L.useRef)([]),o=(t,r)=>{let i=e.length-1,o=t.key===`ArrowRight`||t.key===`ArrowDown`?r===i?0:r+1:t.key===`ArrowLeft`||t.key===`ArrowUp`?r===0?i:r-1:t.key===`Home`?0:t.key===`End`?i:-1;o<0||(t.preventDefault(),n(o),a.current[o]?.focus())};return(0,R.jsx)(`div`,{className:zy.switch,role:`tablist`,"data-row":`leader switch`,children:e.map((e,s)=>(0,R.jsxs)(`button`,{ref:e=>{a.current[s]=e},type:`button`,role:`tab`,id:r(s),className:zy.key,"aria-selected":t===s,"aria-controls":i,"aria-label":Pe(e.name,e.written?e.place:void 0),"data-shown":t===s?`true`:`false`,onClick:()=>n(s),onKeyDown:e=>o(e,s),children:[e.written&&(0,R.jsx)(`span`,{className:zy.keyPlace,children:e.place}),e.written&&` `,(0,R.jsx)(`span`,{className:zy.keyName,translate:`no`,children:e.name})]},e.place))})}function Ky({pair:e,shape:t=!1}){let n=(0,L.useId)(),r=e=>t?(0,R.jsx)(`span`,{className:zy.shape,"data-shape":!0,children:e}):e;return(0,R.jsxs)(`div`,{className:zy.scores,children:[t?(0,R.jsx)(`p`,{className:zy.mark,children:r(Ie)}):(0,R.jsx)(Hy,{id:n,children:Ie}),(0,R.jsx)(`p`,{className:zy.band,"data-testid":t?void 0:`middle-band`,children:r(ze)}),(0,R.jsxs)(`table`,{className:zy.table,"aria-labelledby":t?void 0:n,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`td`,{className:zy.corner}),e.map(e=>(0,R.jsxs)(`th`,{scope:`col`,className:zy.colHead,children:[!t&&e.written&&(0,R.jsx)(`span`,{className:zy.headPlace,children:e.place}),!t&&e.written&&` `,(0,R.jsx)(`span`,{translate:`no`,children:r(e.name)})]},e.place))]})}),(0,R.jsx)(`tbody`,{children:jy.map(n=>(0,R.jsxs)(`tr`,{"data-score":n,children:[(0,R.jsx)(`th`,{scope:`row`,className:zy.rowHead,children:r(My(n))}),e.map(e=>{let i=e.scores?.[n];return(0,R.jsx)(`td`,{className:zy.cell,children:(0,R.jsxs)(`span`,{className:zy.cellInner,children:[i!==void 0&&(0,R.jsx)(`span`,{className:zy.cellFigure,"data-testid":`score-figure`,children:Fy(i)}),i===void 0&&t&&(0,R.jsx)(`span`,{className:zy.cellFigure,children:r(`0.00`)}),(0,R.jsx)(Ly,{score:i,short:!0})]})},e.place)})]},n))})]})]})}var qy=[1,2].map(e=>({place:e,name:He.name,written:!1,title:He.title,scores:null,orders:``}));function Jy({sideBySide:e}){let t=e=>(0,R.jsx)(`span`,{className:zy.shape,"data-shape":!0,children:e});return(0,R.jsxs)(`div`,{className:`${zy.card} ${e?``:zy.shown}`,"data-leader-shape":!0,"aria-hidden":`true`,children:[(0,R.jsxs)(`div`,{className:zy.head,children:[e&&(0,R.jsx)(`span`,{className:zy.place,children:t(`0`)}),e&&(0,R.jsx)(`p`,{className:zy.name,children:t(He.name)}),(0,R.jsx)(`p`,{className:zy.title,children:t(He.title)})]}),e?(0,R.jsxs)(`div`,{className:zy.scores,children:[(0,R.jsx)(`p`,{className:zy.mark,children:t(Ie)}),(0,R.jsx)(`p`,{className:zy.band,children:t(ze)}),(0,R.jsx)(Ry,{scores:null,label:``,stackWide:!0})]}):(0,R.jsx)(Ky,{pair:qy,shape:!0}),(0,R.jsxs)(`div`,{className:zy.orders,children:[(0,R.jsx)(`p`,{className:zy.mark,children:t(Le)}),(0,R.jsx)(`p`,{className:zy.ordersText,children:t(He.orders)}),(0,R.jsx)(`p`,{className:zy.note,children:t(Be)})]})]})}function Yy({size:e=2}){let t=fF(),n=mF(),r=Sy(By),[i,a]=(0,L.useState)(0),o=(0,L.useId)(),s=e=>`${o}-leader-${e+1}`,c=`${o}-card`;if(!n)return(0,R.jsx)(`section`,{className:zy.leaders,"data-testid":`leaders`,"aria-label":Fe,"data-loading":!0,children:r?(0,R.jsxs)(`div`,{className:zy.pair,children:[(0,R.jsx)(Jy,{sideBySide:!0}),(0,R.jsx)(Jy,{sideBySide:!0})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:zy.switch,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:zy.key,children:(0,R.jsx)(`span`,{className:zy.shape,"data-shape":!0,children:He.name})}),(0,R.jsx)(`span`,{className:zy.key,children:(0,R.jsx)(`span`,{className:zy.shape,"data-shape":!0,children:He.name})})]}),(0,R.jsx)(Jy,{sideBySide:!1})]})});let l=Vy(t),u=l.every(e=>!e.written),d=e>2?(0,R.jsx)(`p`,{className:zy.writesAll,"data-text":`body`,"data-testid":`writes-all`,children:it(e)}):null;if(r)return(0,R.jsxs)(`section`,{className:zy.leaders,"data-testid":`leaders`,"aria-label":Fe,children:[d,(0,R.jsx)(`div`,{className:zy.pair,children:l.map(e=>(0,R.jsx)(Wy,{leader:e,noneWritten:u},e.place))})]});let f=Math.min(i,l.length-1),p=l[f];return(0,R.jsxs)(`section`,{className:zy.leaders,"data-testid":`leaders`,"aria-label":Fe,children:[d,(0,R.jsx)(Gy,{pair:l,shown:f,onShow:a,tabId:s,panelId:c}),(0,R.jsxs)(`div`,{className:`${zy.card} ${zy.shown}`,role:`tabpanel`,id:c,"aria-label":p.name,children:[p.title&&(0,R.jsx)(`div`,{className:zy.head,"data-testid":`leader-head`,children:(0,R.jsx)(`p`,{className:zy.title,"data-testid":`leader-title`,children:p.title})}),(0,R.jsx)(Ky,{pair:l}),(0,R.jsx)(`div`,{className:zy.orders,children:(0,R.jsx)(Uy,{leader:p,noneWritten:u})})]})]})}function Xy(e){return e.limitMet||e.rateLimit.status===`ready`&&e.rateLimit.answer?.remaining===0}var Zy=e=>typeof e==`object`&&!!e&&!Array.isArray(e),Qy=e=>typeof e==`number`&&Number.isInteger(e)&&e>=0;function $y(e){if(!Zy(e))return{status:`error`};if(e.unlimited===!0)return{status:`unlimited`};let{allowed:t,remaining:n,limit:r,resetAt:i}=e;return typeof t!=`boolean`||!Qy(n)||!Qy(r)||!Qy(i)?{status:`error`}:{status:`ready`,answer:{allowed:t,remaining:n,limit:r,resetAt:i}}}function eb(e){if(!Zy(e))return{status:`error`};let t={status:`ready`},n=e.hostedDemo;typeof n==`boolean`&&(t.hostedDemo=n);let r=e.demoCaps;if(Zy(r)){let e={};for(let t of[`maxTurns`,`maxPopulation`,`maxActiveDepartments`]){let n=r[t];Qy(n)&&n>0&&(e[t]=n)}t.demoCaps=e}return t}var tb=(0,L.createContext)(null),nb=1e3,rb=2147483647,ib=2e3,ab=15e3,ob=2e3,sb=15e3;async function cb(){try{let e=await fetch(`/rate-limit`,{cache:`no-store`});return e.ok?$y(await e.json()):{status:`error`}}catch{return{status:`error`}}}function lb({children:e}){let[t,n]=(0,L.useState)({status:`loading`}),[r,i]=(0,L.useState)({status:`loading`}),[a,o]=(0,L.useState)(!1),s=Wn(),c=(0,L.useRef)(void 0),l=(0,L.useCallback)(e=>{c.current=e,o(!0)},[]),u=(0,L.useCallback)(()=>Un.refresh(),[]),d=(0,L.useCallback)(async()=>{let e=await cb();return n(e),e},[]);(0,L.useEffect)(()=>{d()},[d]);let f=a||t.status===`ready`&&t.answer?.remaining===0,p=t.status===`ready`?t.answer:void 0,m=(0,L.useRef)(ob);(0,L.useEffect)(()=>{if(f||(m.current=ob),!f||p===void 0)return;let e=p.resetAt-Date.now(),t;if(e>0){if(m.current=ob,t=e+nb,t>rb)return}else t=m.current,m.current=Math.min(t*2,sb);let r=!1,i=ob,a,s=()=>{cb().then(e=>{r||(e.status===`error`?(a=window.setTimeout(s,i),i=Math.min(i*2,sb)):(n(e),e.status===`ready`&&(e.answer?.remaining??0)>0&&o(!1)))})};return a=window.setTimeout(s,t),()=>{r=!0,a!==void 0&&window.clearTimeout(a)}},[f,p]),(0,L.useEffect)(()=>{if(!a)return;let e=c.current,n=t.status===`ready`?t.answer:void 0;n&&e!==void 0&&n.resetAt>e&&n.remaining>0&&o(!1)},[a,t]);let h=a&&t.status===`error`;(0,L.useEffect)(()=>{if(!h)return;let e=!1,t,n=ob,r=()=>{d().then(i=>{i.status!==`error`||e||(t=window.setTimeout(r,n),n=Math.min(n*2,sb))})};return t=window.setTimeout(r,n),n=Math.min(n*2,sb),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[h,d]),(0,L.useEffect)(()=>{let e=!1,t,n=ib,r=()=>{fetch(`/admin-config`,{cache:`no-store`}).then(async e=>e.ok?eb(await e.json()):{status:`error`}).catch(()=>({status:`error`})).then(a=>{e||(i(a),a.status===`error`&&(t=window.setTimeout(r,n),n=Math.min(n*2,ab)))})};return r(),()=>{e=!0,t!==void 0&&window.clearTimeout(t)}},[]);let g=(0,L.useMemo)(()=>({rateLimit:{...t,refresh:d},adminConfig:r,sessions:{status:s.status,rows:s.sessions,refresh:u},limitMet:a,markLimitMet:l}),[t,d,r,s.status,s.sessions,u,a,l]);return(0,R.jsx)(tb.Provider,{value:g,children:e})}function ub(){let e=(0,L.useContext)(tb);if(!e)throw Error(`useServerFacts must be used within ServerFactsProvider`);return e}var db={part:`_part_4346k_9`,heading:`_heading_4346k_16`,subheading:`_subheading_4346k_24`,grid:`_grid_4346k_32`,row:`_row_4346k_56`,card:`_card_4346k_63`,name:`_name_4346k_100`,state:`_state_4346k_107`,figures:`_figures_4346k_108`,line:`_line_4346k_119`,problem:`_problem_4346k_126`,mark:`_mark_4346k_138`,tryAgain:`_tryAgain_4346k_142`,showAll:`_showAll_4346k_143`,detail:`_detail_4346k_185`,shape:`_shape_4346k_205`,loadingShapeTone:`_loadingShapeTone_4346k_1`},fb=[`lunar-outpost`,`mars-genesis`,`deep-ocean-station`],pb=`paracosm:focusScenarioHeading`,mb=3,hb=e=>e.source===`compiled`||e.source===`memory`;function gb(e){let t=e=>{let t=fb.indexOf(e.id);return t<0?fb.length:t};return{bundled:e.filter(e=>!hb(e)).sort((e,n)=>t(e)-t(n)),yours:e.filter(hb)}}function _b(){let e=Sy(`(min-width: 600px)`),t=Sy(`(min-width: 1100px)`);return Sy(`(min-width: 1440px)`)?4:t?3:e?4:3}function vb({locked:e=!1}={}){let t=fF(),n=mF(),r=ub(),i=_b(),[a,o]=(0,L.useState)({status:`loading`}),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),h=(0,L.useCallback)(async()=>{try{let e=await fetch(`/scenarios`);if(!e.ok)throw Error(`HTTP ${e.status}`);let t=await e.json();o({status:`ready`,rows:Array.isArray(t.scenarios)?t.scenarios:[]})}catch{o({status:`error`})}},[]);(0,L.useEffect)(()=>{h()},[h]),(0,L.useEffect)(()=>{if(!n)return;let e=!1;try{e=sessionStorage.getItem(pb)===`1`,e&&sessionStorage.removeItem(pb)}catch{return}if(!e)return;let t=document.querySelector(`[data-testid="run-first-screen"] h1`);t&&(t.setAttribute(`tabindex`,`-1`),t.focus())},[n]);let g=Jv(r,qv(Kv()).overrides)===`host`?r.adminConfig.demoCaps?.maxActiveDepartments:void 0,_=e=>{let t=typeof e.departments==`number`?e.departments:0;return typeof g==`number`&&g>0?Math.min(t,g):t},v=async t=>{if(!(e||d?.kind===`loading`)){if(typeof navigator<`u`&&navigator.onLine===!1)f({id:t.id,kind:`offline`});else{f({id:t.id,kind:`loading`});try{let e=await fetch(`/scenario/switch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:t.id})});if(!e.ok)throw Error(`HTTP ${e.status}`);ge();try{sessionStorage.setItem(pb,`1`)}catch{}window.location.reload()}catch{f({id:t.id,kind:`failed`})}}}},y=()=>{s||(c(!0),h().finally(()=>c(!1)))},b=a.status===`ready`?a.rows:[];if(a.status===`ready`&&b.length<2)return null;let x=gb(b),S=[...x.bundled,...x.yours],C=n?t.id:null,w=S.filter(e=>e.id!==C).length,T=new Set((l?S:S.slice(0,i)).map(e=>e.id)),E=d?.kind===`loading`,D=!n||a.status===`loading`,O=t=>{let n=t.name||t.id,r=_(t),i=r>0?en(r):null,a=d?.id===t.id?d.kind:null,o=t.id===C;return(0,R.jsxs)(`li`,{className:db.row,"data-testid":`scenario-row`,"data-scenario":t.id,"data-state":o?`on-screen`:a??`rest`,children:[o?(0,R.jsxs)(`div`,{className:`${db.card} ${db.onScreen}`,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:Zt(n)}),(0,R.jsx)(`span`,{className:db.name,"data-testid":`row-name`,"aria-hidden":`true`,children:n}),(0,R.jsx)(`span`,{className:db.state,"data-testid":`row-state`,"aria-hidden":`true`,children:Jt}),i&&(0,R.jsx)(`span`,{className:db.figures,"data-testid":`row-figures`,"aria-hidden":`true`,children:i})]}):(0,R.jsxs)(`button`,{type:`button`,className:db.card,"aria-label":Xt(n),"aria-disabled":E||e||a===`failed`?`true`:void 0,onClick:()=>{E||e||a===`failed`||v(t)},children:[(0,R.jsx)(`span`,{className:db.name,"data-testid":`row-name`,children:n}),i&&(0,R.jsx)(`span`,{className:db.figures,"data-testid":`row-figures`,children:i})]}),a===`loading`&&(0,R.jsx)(`p`,{className:db.line,role:`status`,children:Qt(n)}),a===`failed`&&(0,R.jsxs)(`div`,{className:db.problem,children:[(0,R.jsx)(Oy,{className:db.mark}),(0,R.jsx)(`p`,{className:db.line,role:`status`,children:$t(n)}),(0,R.jsx)(`button`,{type:`button`,className:db.tryAgain,onClick:()=>{v(t)},children:`Try again`})]}),a===`offline`&&(0,R.jsxs)(`div`,{className:db.problem,children:[(0,R.jsx)(Oy,{className:db.mark}),(0,R.jsx)(`p`,{className:db.line,role:`status`,children:`You are offline. Choose it again when you are back online.`})]}),hb(t)&&(0,R.jsx)(`button`,{type:`button`,className:db.detail,"aria-label":tn(n),onClick:()=>m(t),children:`View detail`})]},t.id)},k=x.bundled.filter(e=>T.has(e.id)),ee=x.yours.filter(e=>T.has(e.id));return(0,R.jsxs)(`section`,{className:db.part,"data-testid":`other-scenarios`,"aria-labelledby":`other-scenarios-heading`,children:[(0,R.jsx)(`h2`,{className:db.heading,id:`other-scenarios-heading`,"data-text":`heading`,children:qt}),!D&&a.status===`error`&&(0,R.jsxs)(`div`,{className:db.problem,"data-testid":`scenarios-failed`,children:[(0,R.jsx)(Oy,{className:db.mark}),(0,R.jsx)(`p`,{className:db.line,role:`status`,children:`The other scenarios did not load.`}),(0,R.jsx)(`button`,{type:`button`,className:db.tryAgain,onClick:y,"aria-disabled":s?`true`:void 0,children:s?`Trying…`:`Try again`})]}),D&&(0,R.jsx)(`ul`,{className:db.grid,"aria-hidden":`true`,children:Array.from({length:mb},(e,t)=>(0,R.jsx)(`li`,{className:db.shape,"data-shape":!0},t))}),!D&&a.status===`ready`&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`ul`,{className:db.grid,children:k.map(O)}),ee.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`h3`,{className:db.subheading,"data-text":`heading`,children:`Yours`}),(0,R.jsx)(`ul`,{className:db.grid,children:ee.map(O)})]}),S.length>i&&(0,R.jsx)(`button`,{type:`button`,className:db.showAll,"data-testid":`show-all`,"aria-expanded":l,onClick:()=>u(e=>!e),children:l?`Show fewer`:Yt(w)})]}),(0,R.jsx)(Ov,{scenario:p,showRun:!1,onRunScenario:()=>void 0,onClose:()=>m(null),onDeleted:e=>{m(null),o(t=>t.status===`ready`?{status:`ready`,rows:t.rows.filter(t=>t.id!==e)}:t)},onRenamed:(e,t)=>{o(n=>n.status===`ready`?{status:`ready`,rows:n.rows.map(n=>n.id===e?{...n,name:t}:n)}:n),m(n=>n&&n.id===e?{...n,name:t}:n)}})]})}var yb=[],bb=null,xb=e=>e.offsetParent!==null;function Sb(){for(let e=yb.length-1;e>=0;--e)if(xb(yb[e]))return yb[e];return yb[yb.length-1]}function Cb(){bb=document.getElementById(`pcc-reopen`)??bb;let e=bb,t=document.getElementById(`pcc-shell`),n=Sb()??t;e&&n&&e.parentElement!==n&&n.appendChild(e)}function wb(){return typeof document<`u`&&document.getElementById(`paracosm-consent-config`)!==null}function Tb(){let e=(0,L.useRef)(null);return(0,L.useEffect)(()=>{let t=e.current;if(t)return yb.push(t),Cb(),()=>{let e=yb.lastIndexOf(t);e>=0&&yb.splice(e,1),Cb()}},[]),e}var Eb={foot:`_foot_1gsmx_1`,adults:`_adults_1gsmx_13`,parts:`_parts_1gsmx_20`,nav:`_nav_1gsmx_35`,choices:`_choices_1gsmx_39`,licence:`_licence_1gsmx_44`,links:`_links_1gsmx_67`,link:`_link_1gsmx_67`,measure:`_measure_1gsmx_104`,fullRow:`_fullRow_1gsmx_115`,more:`_more_1gsmx_119`,moreKey:`_moreKey_1gsmx_123`,menu:`_menu_1gsmx_149`,menuItem:`_menuItem_1gsmx_164`},Db=pn.slice(0,-1),Ob=pn.slice(-1);function kb(e,t){let[n,r]=(0,L.useState)(!1);return(0,L.useLayoutEffect)(()=>{let n=e.current,i=t.current;if(!n||!i)return;let a=()=>r(i.getBoundingClientRect().width>n.clientWidth+.5);if(a(),typeof ResizeObserver>`u`)return;let o=new ResizeObserver(a);return o.observe(n),o.observe(i),()=>o.disconnect()},[e,t]),n}function Ab({links:e}){let[t,n]=(0,L.useState)(!1),r=(0,L.useRef)(null),i=(0,L.useRef)(null),a=(0,L.useId)();return(0,L.useEffect)(()=>{if(!t)return;i.current?.querySelector(`[role="menuitem"]`)?.focus();let e=e=>{let t=e.target;t&&(i.current?.contains(t)||r.current?.contains(t))||n(!1)};return document.addEventListener(`pointerdown`,e),()=>document.removeEventListener(`pointerdown`,e)},[t]),(0,R.jsxs)(`li`,{className:Eb.more,children:[(0,R.jsx)(`button`,{ref:r,type:`button`,className:Eb.moreKey,"aria-haspopup":`menu`,"aria-expanded":t,"aria-controls":t?a:void 0,onClick:()=>n(e=>!e),children:fn}),t&&(0,R.jsx)(`ul`,{ref:i,id:a,role:`menu`,"aria-label":`More links`,className:Eb.menu,onKeyDown:e=>{let t=Array.from(i.current?.querySelectorAll(`[role="menuitem"]`)??[]),a=t.indexOf(document.activeElement),o=n=>{e.preventDefault(),t[(n+t.length)%t.length]?.focus()};switch(e.key){case`ArrowDown`:o(a+1);break;case`ArrowUp`:o(a-1);break;case`Home`:o(0);break;case`End`:o(t.length-1);break;case`Escape`:e.preventDefault(),n(!1),r.current?.focus();break;case`Tab`:n(!1)}},children:e.map(e=>(0,R.jsx)(`li`,{role:`none`,children:(0,R.jsx)(`a`,{role:`menuitem`,className:Eb.menuItem,href:e.href,onClick:()=>n(!1),children:e.label})},e.label))})]})}function jb(){let e=wb(),t=Tb(),n=(0,L.useRef)(null),r=(0,L.useRef)(null),i=kb(n,r),a=i?Ob:pn;return(0,R.jsxs)(`footer`,{className:Eb.foot,role:`contentinfo`,"data-testid":`page-foot`,children:[(0,R.jsx)(`p`,{className:Eb.adults,"data-testid":`foot-adults`,children:un}),(0,R.jsxs)(`div`,{className:Eb.parts,children:[(0,R.jsxs)(`nav`,{ref:n,className:Eb.nav,"aria-label":dn,children:[(0,R.jsxs)(`ul`,{className:Eb.links,"data-row":`site links`,children:[a.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(`a`,{className:Eb.link,href:e.href,children:e.label})},e.label)),i&&(0,R.jsx)(Ab,{links:Db})]}),(0,R.jsx)(`div`,{className:Eb.measure,"aria-hidden":`true`,children:(0,R.jsx)(`ul`,{ref:r,className:`${Eb.links} ${Eb.fullRow}`,children:pn.map(e=>(0,R.jsx)(`li`,{children:(0,R.jsx)(`span`,{className:Eb.link,children:e.label})},e.label))})})]}),e&&(0,R.jsx)(`span`,{ref:t,className:Eb.choices}),(0,R.jsx)(`p`,{className:Eb.licence,"data-testid":`foot-licence`,children:mn})]})]})}var Mb={min:2,max:300};function Nb(e,t=Mb,n=2){let r=e.trim();if(!/^\d+$/.test(r))return{value:n,refused:!0};let i=Number(r);return!Number.isSafeInteger(i)||i>t.max?{value:t.max,refused:!0}:i<t.min?{value:t.min,refused:!0}:{value:i,refused:!1}}function Pb(e,t,n=Mb){return Math.min(n.max,Math.max(n.min,e+t))}function Fb(e,t=Mb,n=2){let r=new URLSearchParams(e).get(`size`);if(r===null)return n;let{value:i,refused:a}=Nb(r,t,n);return a?n:i}function Ib(e,t){let n=new URLSearchParams(e);t===2?n.delete(`size`):n.set(`size`,String(t));let r=n.toString();return r?`?${r}`:``}function Lb(e){return e.payer===`host`||e.payer===`server`&&e.adminConfig!==`ready`?`pair`:e.adminConfig===`loading`||e.rateLimit===`loading`?`waiting`:`control`}var Rb={size:`_size_455mt_9`,row:`_row_455mt_18`,mark:`_mark_455mt_29`,triangle:`_triangle_455mt_43`,value:`_value_455mt_49`,control:`_control_455mt_58`,step:`_step_455mt_66`,glyph:`_glyph_455mt_96`,field:`_field_455mt_101`,line:`_line_455mt_122`,refusal:`_refusal_455mt_133`,warning:`_warning_455mt_143`,shape:`_shape_455mt_147`,loadingShapeTone:`_loadingShapeTone_455mt_1`};function zb({plus:e}){return(0,R.jsxs)(`svg`,{className:Rb.glyph,width:`16`,height:`16`,viewBox:`0 0 16 16`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,"aria-hidden":`true`,focusable:`false`,children:[(0,R.jsx)(`path`,{d:`M3 8h10`}),e&&(0,R.jsx)(`path`,{d:`M8 3v10`})]})}function Bb({size:e,onSize:t,locked:n=!1}){let r=ub(),i=(0,L.useId)(),a=(0,L.useId)(),[o,s]=(0,L.useState)(null),[c,l]=(0,L.useState)(!1),u=Jv(r,qv(Kv()).overrides),d=Lb({payer:u,adminConfig:r.adminConfig.status,rateLimit:r.rateLimit.status}),f=Mb,p=(0,R.jsxs)(`p`,{className:Rb.mark,"data-testid":`leaders-mark`,children:[(0,R.jsx)(Dy,{className:Rb.triangle}),(0,R.jsx)(`span`,{children:Ye})]});if(d!==`control`){let t=d===`pair`?2:e,n=u===`host`,i=d===`pair`&&!n&&r.adminConfig.status===`loading`;return(0,R.jsxs)(`div`,{className:Rb.size,"data-testid":`run-size`,children:[(0,R.jsxs)(`div`,{className:Rb.row,"data-row":`leaders heading`,children:[p,(0,R.jsx)(`p`,{className:Rb.value,"data-testid":`run-size-value`,children:Xe(t)})]}),n&&(0,R.jsx)(`p`,{className:Rb.line,"data-testid":`run-size-line`,children:Ze({free:2,max:f.max})}),i&&(0,R.jsx)(`p`,{className:Rb.line,"aria-hidden":`true`,children:(0,R.jsx)(`span`,{className:Rb.shape,"data-shape":!0,children:Ze({free:2,max:f.max})})})]})}let m=e<=f.min,h=e>=f.max,g=n=>{s(null),l(!1),n!==e&&t(n)},_=r=>{if(n)return;let i=r.target.value;s(i);let a=Nb(i,f,e);l(a.refused),!a.refused&&a.value!==e&&t(a.value)},v=()=>{if(o===null)return;let n=Nb(o,f,e);s(null),n.value!==e&&t(n.value)},y=t=>{if(n)return;let r=t.key===`ArrowUp`?Pb(e,1,f):t.key===`ArrowDown`?Pb(e,-1,f):t.key===`PageUp`?Pb(e,10,f):t.key===`PageDown`?Pb(e,-10,f):t.key===`Home`?f.min:t.key===`End`?f.max:null;r!==null&&(t.preventDefault(),g(r))},b=m?nt(f.min):h?rt(f.max):null;return(0,R.jsxs)(`div`,{className:Rb.size,"data-testid":`run-size`,children:[(0,R.jsxs)(`div`,{className:Rb.row,"data-row":`leaders heading`,children:[p,(0,R.jsxs)(`div`,{className:Rb.control,children:[(0,R.jsx)(`button`,{type:`button`,className:Rb.step,"aria-label":$e,"aria-disabled":m||n?`true`:void 0,"aria-describedby":m?i:void 0,onClick:()=>{!m&&!n&&g(Pb(e,-1,f))},children:(0,R.jsx)(zb,{})}),(0,R.jsx)(`input`,{type:`text`,inputMode:`numeric`,autoComplete:`off`,role:`spinbutton`,className:Rb.field,"aria-label":Qe,"aria-valuemin":f.min,"aria-valuemax":f.max,"aria-valuenow":e,"aria-invalid":c&&o!==null?`true`:void 0,"aria-describedby":c?a:void 0,"aria-disabled":n?`true`:void 0,readOnly:n,value:o??String(e),onChange:_,onBlur:v,onKeyDown:y}),(0,R.jsx)(`button`,{type:`button`,className:Rb.step,"aria-label":et,"aria-disabled":h||n?`true`:void 0,"aria-describedby":h?i:void 0,onClick:()=>{!h&&!n&&g(Pb(e,1,f))},children:(0,R.jsx)(zb,{plus:!0})})]})]}),b&&(0,R.jsx)(`p`,{id:i,className:Rb.line,"data-testid":`run-size-bound`,children:b}),c&&(0,R.jsxs)(`p`,{id:a,className:Rb.refusal,"aria-live":`polite`,"data-testid":`run-size-error`,children:[(0,R.jsx)(ky,{className:Rb.warning}),(0,R.jsx)(`span`,{children:tt(f)})]}),r.adminConfig.status===`error`&&(0,R.jsx)(`p`,{className:Rb.line,"data-testid":`run-size-settings`,children:`The server’s settings could not be read. The server checks the size when you press Start.`})]})}var Vb=(0,L.createContext)({turns:null,tell:()=>{}});function Hb({children:e}){let[t,n]=(0,L.useState)(null),r=(0,L.useMemo)(()=>({turns:t,tell:n}),[t]);return(0,R.jsx)(Vb.Provider,{value:r,children:e})}function Ub(){return(0,L.useContext)(Vb).turns}function Wb(e){let{tell:t}=(0,L.useContext)(Vb);(0,L.useEffect)(()=>{t(e)},[t,e])}function Gb(){let[e,t]=(0,L.useState)(()=>typeof navigator>`u`||navigator.onLine!==!1);return(0,L.useEffect)(()=>{let e=()=>t(!0),n=()=>t(!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,n),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,n)}},[]),e}var Kb={line:`_line_1lgjn_1`,title:`_title_1lgjn_9`,mark:`_mark_1lgjn_16`,triangle:`_triangle_1lgjn_29`,heading:`_heading_1lgjn_35`,body:`_body_1lgjn_46`,sentences:`_sentences_1lgjn_53`,figures:`_figures_1lgjn_62`,cells:`_cells_1lgjn_75`,cell:`_cell_1lgjn_75`,dot:`_dot_1lgjn_86`,failure:`_failure_1lgjn_98`,brokenLink:`_brokenLink_1lgjn_108`,failureText:`_failureText_1lgjn_114`,tryNow:`_tryNow_1lgjn_122`,shape:`_shape_1lgjn_155`,shapeTone:`_shapeTone_1lgjn_1`},qb={people:30,departments:3,turns:6,events:2};function Jb({figures:e,loading:t}){let n=ey(e),r=(0,R.jsx)(`span`,{className:Kb.cells,"aria-hidden":`true`,"data-testid":t?void 0:`scenario-figures`,children:n.map((e,n)=>(0,R.jsxs)(L.Fragment,{children:[n>0&&(0,R.jsx)(`span`,{className:Kb.dot,children:` · `}),t?(0,R.jsx)(`span`,{className:Kb.cell,children:(0,R.jsx)(`span`,{className:Kb.shape,"data-shape":!0,children:e})}):(0,R.jsx)(`span`,{className:Kb.cell,"data-figure":!0,children:e})]},n))});return(0,R.jsxs)(`p`,{className:Kb.figures,children:[!t&&(0,R.jsx)(`span`,{className:`sr-only`,children:ty(e)}),r]})}function Yb({size:e=2}){let t=fF(),n=mF(),{failed:r,retryNow:i}=gF(),a=ub(),o=Gb(),[s,c]=(0,L.useState)(!1),l=qv(Kv()),u=Jv(a,l.overrides),d=u===`own`||a.adminConfig.status!==`loading`,f=u===`own`||typeof a.adminConfig.hostedDemo==`boolean`,p=(0,R.jsxs)(`p`,{className:Kb.mark,"aria-hidden":`true`,"data-row":`scenario mark`,"data-testid":`scenario-mark`,children:[(0,R.jsx)(Dy,{className:Kb.triangle}),(0,R.jsx)(`span`,{children:we})]});if(!n&&r)return(0,R.jsxs)(`section`,{className:Kb.line,"data-testid":`scenario-line`,children:[(0,R.jsx)(`div`,{className:Kb.title,children:p}),(0,R.jsxs)(`div`,{className:Kb.failure,children:[(0,R.jsx)(Oy,{className:Kb.brokenLink}),(0,R.jsx)(`p`,{role:`status`,className:Kb.failureText,"data-text":`body`,children:o?De:Oe}),(0,R.jsx)(`button`,{type:`button`,className:Kb.tryNow,onClick:()=>{s||(c(!0),i().finally(()=>c(!1)))},"aria-disabled":s?`true`:void 0,children:s?Ae:ke})]})]});if(!n||!d)return(0,R.jsxs)(`section`,{className:Kb.line,"data-testid":`scenario-line`,"aria-busy":`true`,"data-loading":!0,children:[(0,R.jsxs)(`div`,{className:Kb.title,"aria-hidden":`true`,children:[(0,R.jsx)(`p`,{className:Kb.mark,children:(0,R.jsx)(`span`,{className:Kb.shape,"data-shape":!0,children:we})}),(0,R.jsx)(`p`,{className:Kb.heading,children:(0,R.jsx)(`span`,{className:Kb.shape,"data-shape":!0,children:je})})]}),(0,R.jsxs)(`div`,{className:Kb.body,"aria-hidden":`true`,children:[(0,R.jsx)(`p`,{className:Kb.sentences,children:(0,R.jsx)(`span`,{className:Kb.shape,"data-shape":!0,children:Ee({n:e,turns:qb.turns,atLimit:!1})})}),(0,R.jsx)(Jb,{figures:qb,loading:!0})]})]});let m=Yv(a,t,l,u),h=u===`host`&&Xy(a),g={people:Zv(a,t,u),departments:Qv(a,t,u),turns:m,events:$v(t)};return(0,R.jsxs)(`section`,{className:Kb.line,"data-testid":`scenario-line`,children:[(0,R.jsxs)(`div`,{className:Kb.title,children:[p,(0,R.jsx)(`h1`,{className:Kb.heading,"data-text":`heading`,children:t.labels.name})]}),(0,R.jsxs)(`div`,{className:Kb.body,children:[(0,R.jsx)(`p`,{className:Kb.sentences,"data-text":`body`,"data-testid":`scenario-sentences`,children:Ee({n:e,turns:m,atLimit:h})}),f&&(0,R.jsx)(Jb,{figures:g,loading:!1})]})]})}var Xb={region:`_region_gfhbm_1`,narrow:`_narrow_gfhbm_12`,resting:`_resting_gfhbm_18`,canvasWrap:`_canvasWrap_gfhbm_28`,vizPanel:`_vizPanel_gfhbm_56`,canvas:`_canvas_gfhbm_28`,revealCover:`_revealCover_gfhbm_79`,people:`_people_gfhbm_94`,nameLines:`_nameLines_gfhbm_101`,person:`_person_gfhbm_112`,cornerBtn:`_cornerBtn_gfhbm_152`,focusBtn:`_focusBtn_gfhbm_174`,divergenceEmpty:`_divergenceEmpty_gfhbm_179`,divergenceEmptyMsg:`_divergenceEmptyMsg_gfhbm_190`,tileTooltip:`_tileTooltip_gfhbm_202`,tileKindLabel:`_tileKindLabel_gfhbm_221`,tileCoords:`_tileCoords_gfhbm_229`,tileNearestName:`_tileNearestName_gfhbm_235`,tileNearestRole:`_tileNearestRole_gfhbm_240`,tileNearestDeath:`_tileNearestDeath_gfhbm_246`,tileNearestBirth:`_tileNearestBirth_gfhbm_252`,tileNearestPattern:`_tileNearestPattern_gfhbm_258`,tileAmbient:`_tileAmbient_gfhbm_264`,hoverTooltip:`_hoverTooltip_gfhbm_268`,hoverHeader:`_hoverHeader_gfhbm_286`,hoverFeaturedPill:`_hoverFeaturedPill_gfhbm_296`,hoverRole:`_hoverRole_gfhbm_305`,hoverMood:`_hoverMood_gfhbm_313`,hoverMoodValue:`_hoverMoodValue_gfhbm_317`,psychBlock:`_psychBlock_gfhbm_321`,psychLabel:`_psychLabel_gfhbm_325`,psychSvg:`_psychSvg_gfhbm_331`,hoverHint:`_hoverHint_gfhbm_338`};function Zb(e){let t=e>>>0;return()=>{t=t+1831565813>>>0;let e=t;return e=Math.imul(e^e>>>15,e|1),e^=e+Math.imul(e^e>>>7,e|61),((e^e>>>14)>>>0)/4294967296}}function Qb(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619)>>>0;return t>>>0}function $b(e,t,n,r,i=8){return{x:Math.max(i,Math.min(n-i,e)),y:Math.max(i,Math.min(r-i,t))}}function ex(e){let t=new Set;for(let n of e)t.add(n.department||`unknown`);return[...t].sort()}function tx(e,t,n){let r=new Map;if(n.length===0)return r;let i=e/2,a=t/2,o=Math.min(e,t)*.32,s=Math.min(e,t)*.14;if(n.length===1)return r.set(n[0],{cx:i,cy:a,r:s*1.5}),r;for(let e=0;e<n.length;e++){let t=Math.PI*2*e/n.length-Math.PI/2;r.set(n[e],{cx:i+Math.cos(t)*o,cy:a+Math.sin(t)*o,r:s})}return r}function nx(e,t,n){let r=tx(t,n,ex(e)),i=new Map;for(let a of e){let e=r.get(a.department||`unknown`)??{cx:t/2,cy:n/2,r:40},o=Zb(Qb(`${a.agentId}|${t}x${n}|dept`)),s=o()*Math.PI*2,c=Math.sqrt(o())*e.r;i.set(a.agentId,$b(e.cx+Math.cos(s)*c,e.cy+Math.sin(s)*c,t,n))}return i}function rx(e,t,n){let r=new Map,i=new Set,a=new Map(e.map(e=>[e.agentId,e])),o=[];for(let t of e)if(!i.has(t.agentId)&&t.partnerId&&a.has(t.partnerId)&&!i.has(t.partnerId)){let e=a.get(t.partnerId),n=t.childrenIds.map(e=>a.get(e)).filter(e=>!!e);o.push([t,e,...n]),i.add(t.agentId),i.add(e.agentId);for(let e of n)i.add(e.agentId)}let s=e.filter(e=>!i.has(e.agentId)),c=Math.max(50,(t-80)/Math.max(1,o.length));return o.forEach((e,i)=>{let a=40+c*i+c/2;e.forEach((i,o)=>{let s=Zb(Qb(`${i.agentId}|fam`)),c=o/e.length*Math.PI*2,l=14+s()*6;r.set(i.agentId,$b(a+Math.cos(c)*l,40+Math.sin(c)*l,t,n))})}),s.forEach((e,i)=>{let a=Zb(Qb(`${e.agentId}|solo`)),o=40+(t-80)*(i+.5)/Math.max(1,s.length),c=n-40-a()*40;r.set(e.agentId,$b(o,c,t,n))}),r}function ix(e,t,n){let r={positive:-1,hopeful:-.6,neutral:0,anxious:.4,negative:.8,defiant:.6,resigned:.7},i=new Map;for(let a of e){let e=(r[a.mood]??0)*.5+.5,o=Zb(Qb(`${a.agentId}|mood`)),s=40+(t-80)*e,c=40+(n-80)*o();i.set(a.agentId,$b(s,c,t,n))}return i}function ax(e,t,n){let r=new Map;for(let i of e){let e=Math.max(0,Math.min(80,i.age??30))/80,a=Zb(Qb(`${i.agentId}|age`)),o=40+(t-80)*a(),s=40+(n-80)*e;r.set(i.agentId,$b(o,s,t,n))}return r}function ox(e,t,n,r){return t===`families`?rx(e,n,r):t===`mood`?ix(e,n,r):t===`age`?ax(e,n,r):nx(e,n,r)}function sx(e,t,n,r,i=1,a,o=!1,s=0,c=``,l=!1,u=`rgba(216, 204, 176, 0.9)`,d=`rgba(10, 8, 6, 0.55)`,f=9){e.save(),.5+.5*Math.sin(s*.003);let p=c.trim().toLowerCase().split(/\s+/).filter(Boolean),m=p.length>0,h=e=>{if(!m)return!1;let t=`${e.name} ${e.department} ${e.role} ${e.mood}`.toLowerCase();return p.every(e=>t.includes(e))};for(let c of t){if(!c.alive)continue;let t=n.get(c.agentId);if(!t)continue;let l=a?.has(c.agentId)??!1;if(o&&!l)continue;let u=h(c),d=m&&!u,f=c.featured?5:3,p=c.featured?.95:.75,g=d?.25:1;if(c.featured&&!d){let n=f+6,a=.42*i;e.strokeStyle=r,e.lineWidth=1,e.globalAlpha=a,e.beginPath(),e.arc(t.x,t.y,n,0,Math.PI*2),e.stroke()}if(u){let n=.7+.3*Math.sin(s*.006);e.strokeStyle=`rgba(248, 225, 150, 1)`,e.lineWidth=2.2,e.globalAlpha=i*n,e.beginPath(),e.arc(t.x,t.y,f+6,0,Math.PI*2),e.stroke()}l&&!d&&(e.strokeStyle=`rgba(232, 180, 74, 0.9)`,e.lineWidth=2,e.globalAlpha=i,e.beginPath(),e.arc(t.x,t.y,f+3,0,Math.PI*2),e.stroke()),e.strokeStyle=l?`rgba(224, 101, 48, 1)`:r,e.lineWidth=c.featured||l||u?1.6:1,e.globalAlpha=(l?1:p)*i*g,e.beginPath(),e.arc(t.x,t.y,f,0,Math.PI*2),e.stroke()}if(l){e.font=`${f}px ui-monospace, monospace`,e.textAlign=`center`,e.textBaseline=`top`;for(let r of t){if(!r.alive)continue;let t=n.get(r.agentId);if(!t)continue;let s=a?.has(r.agentId)??!1;if(o&&!s||!r.featured&&!s)continue;let c=h(r);if(m&&!c)continue;let l=r.name.split(/\s+/)[0],p=t.y+(r.featured?12:10),g=e.measureText(l).width;e.fillStyle=d,e.fillRect(t.x-g/2-3,p-1,g+6,f+1),e.fillStyle=s?`rgba(232, 180, 74, 0.95)`:u,e.globalAlpha=i,e.fillText(l,t.x,p)}}e.restore()}var cx={birth:`rgba(154, 205, 96, 0.8)`,death:`rgba(168, 152, 120, 0.7)`,forge_approved:`rgba(232, 180, 74, 0.8)`,forge_rejected:`rgba(224, 101, 48, 0.7)`,reuse:`rgba(232, 180, 74, 0.6)`,crisis:`rgba(196, 74, 30, 0.8)`},lx=6;function ux(e,t){e.save();for(let n of t){let t=cx[n.kind]??`rgba(255,255,255,0.6)`,r=n.progress,i=1-r;if(e.globalAlpha=i,n.kind===`birth`||n.kind===`death`||n.kind===`crisis`){let a=4+r*14;if(e.strokeStyle=t,e.lineWidth=1.2,e.beginPath(),e.arc(n.x,n.y,a,0,Math.PI*2),e.stroke(),n.kind!==`crisis`){let a=2+r*22,o=n.kind===`birth`?1.8:1.4;e.fillStyle=t;for(let t=0;t<lx;t++){let r=t/lx*Math.PI*2+(n.kind===`birth`?.3:-.2),s=n.x+Math.cos(r)*a,c=n.y+Math.sin(r)*a;e.globalAlpha=i*.9,e.beginPath(),e.arc(s,c,o,0,Math.PI*2),e.fill()}}}else if(n.kind===`reuse`&&typeof n.endX==`number`&&typeof n.endY==`number`){let a=n.x+(n.endX-n.x)*r,o=n.y+(n.endY-n.y)*r,s=e.createRadialGradient(a,o,0,a,o,8);s.addColorStop(0,`rgba(248, 225, 150, 0.95)`),s.addColorStop(.4,t),s.addColorStop(1,`rgba(232, 180, 74, 0)`),e.fillStyle=s,e.globalAlpha=i,e.beginPath(),e.arc(a,o,8,0,Math.PI*2),e.fill(),e.fillStyle=`rgba(248, 225, 150, 0.95)`,e.beginPath(),e.arc(a,o,2,0,Math.PI*2),e.fill()}else e.fillStyle=t,e.beginPath(),e.arc(n.x,n.y,3,0,Math.PI*2),e.fill()}e.restore()}var dx={medical:`rgba(78, 205, 196, 0.9)`,engineering:`rgba(232, 180, 74, 0.9)`,agriculture:`rgba(106, 173, 72, 0.9)`,psychology:`rgba(155, 107, 158, 0.9)`,governance:`rgba(224, 101, 48, 0.9)`,research:`rgba(149, 107, 216, 0.9)`,science:`rgba(149, 107, 216, 0.9)`,ops:`rgba(200, 122, 58, 0.9)`,operations:`rgba(200, 122, 58, 0.9)`};function fx(e){return dx[(e||``).toLowerCase()]??`rgba(168, 152, 120, 0.9)`}function px(e,t,n){let r=n.textSize??10,i=`${r}px ui-monospace, monospace`;e.save(),e.font=i,e.fillStyle=n.sideColor,e.textBaseline=`top`,e.textAlign=`left`;let a=n.actorName.toUpperCase(),o=n.textSize?Math.max(1,n.width-82):n.width,s=Math.min(o,e.measureText(a).width);e.fillText(a,10,10,o);let c=(n.actorArchetype||``).trim().replace(/^The\s+/i,``);if(c&&(!n.textSize||s+(c.length+2)*r*.61+28<o)){e.font=`bold ${n.textSize??8}px ui-monospace, monospace`;let t=c.toUpperCase(),r=e.measureText(t).width,a=10+s+8,o=(n.textSize??8)+5;e.fillStyle=n.labelBg??`rgba(10, 8, 6, 0.5)`,e.fillRect(a,9,r+10,o),e.strokeStyle=n.sideColor,e.lineWidth=1,e.strokeRect(a+.5,9.5,r+10-1,o-1),e.fillStyle=n.sideColor,e.textBaseline=`middle`,e.fillText(t,a+5,9+o/2+.5),e.textBaseline=`top`,e.font=i}e.fillStyle=n.textMuted??`rgba(216, 204, 176, 0.75)`;let l=t?.time,u=n.timeUnitShort??`t`,d=typeof l==`number`?typeof n.startTime==`number`?`T${t?.turn??0} · ${l} · ${u} ${Math.max(0,l-n.startTime)}`:`T${t?.turn??0} · ${l}`:`T${t?.turn??0}`;if(e.fillText(d,10,14+r),!t){e.restore();return}if(n.deptLabels&&n.cells&&n.positions&&n.cells.length>0){let t=new Map;for(let e of n.cells){if(!e.alive)continue;let r=n.positions.get(e.agentId);if(!r)continue;let i=(e.department||`unknown`).toLowerCase(),a=t.get(i)??{xs:[],ys:[]};a.xs.push(r.x),a.ys.push(r.y),t.set(i,a)}e.font=`bold ${n.textSize??9}px ui-monospace, monospace`,e.textBaseline=`middle`,e.textAlign=`center`;let r=[];for(let[i,a]of t.entries()){if(a.xs.length===0)continue;let t=a.xs.reduce((e,t)=>e+t,0)/a.xs.length,o=Math.min(...a.ys),s=Math.max(14,o-14),c=`${i.toUpperCase()} ${a.xs.length}`,l=e.measureText(c);r.push({dept:i,cx:t,w:l.width+8,h:(n.textSize??9)+5,label:c,idealY:s})}r.sort((e,t)=>e.idealY-t.idealY);let i=[],a=(n.textSize??9)+7,o=(e,t)=>Math.abs(e.cx-t.cx)<(e.w+t.w)/2+2&&Math.abs(e.y-t.y)<(e.h+t.h)/2+2;for(let e of r){let t=e.idealY;for(let n=0;n<10;n++){let r=e.idealY-n*a,s=e.idealY+n*a,c=n===0?e.idealY:r>=10?r:s;if(!i.some(t=>o({cx:e.cx,w:e.w,y:c,h:e.h},t))){t=c;break}}i.push({...e,y:t})}for(let t of i)e.fillStyle=n.labelBg??`rgba(10, 8, 6, 0.85)`,e.fillRect(t.cx-t.w/2,t.y-t.h/2,t.w,t.h),e.strokeStyle=fx(t.dept),e.lineWidth=1,e.strokeRect(t.cx-t.w/2+.5,t.y-t.h/2+.5,t.w-1,t.h-1),e.fillStyle=fx(t.dept),e.fillText(t.label,t.cx,t.y)}e.font=i,e.textAlign=`left`,e.textBaseline=`bottom`,e.fillStyle=n.sideColor;let f=n.previousSnapshot?t.population-n.previousSnapshot.population:0,p=f>0?`↑`:f<0?`↓`:``,m=f>0?`rgba(106, 173, 72, 0.95)`:f<0?`rgba(196, 74, 30, 0.95)`:`rgba(216, 204, 176, 0.75)`;if(e.fillText(`POP ${t.population}`,10,n.height-10-r),p){let i=`POP ${t.population}`,a=e.measureText(i).width+6;e.fillStyle=m,e.fillText(`${p}${Math.abs(f)}`,10+a,n.height-10-r),e.fillStyle=n.sideColor}(t.deaths>0||t.births>0)&&(e.fillStyle=n.textMuted??`rgba(216, 204, 176, 0.65)`,e.fillText(`+${t.births} -${t.deaths}`,10,n.height-8)),n.lagTurns&&n.lagTurns>0&&(e.textAlign=`right`,e.fillStyle=`rgba(232, 180, 74, 0.75)`,e.fillText(`lagging ${n.lagTurns}`,n.width-10,n.height-8)),e.restore()}function mx(e,t,n,r,i,a=11){if(t.length===0||r.length===0)return;let o=new Map;for(let e of r){if(e.approved===!1)continue;let t=(e.department||`unknown`).toLowerCase();o.set(t,(o.get(t)??0)+1)}if(o.size===0)return;let s=new Map;for(let e of t){if(!e.alive)continue;let t=n.get(e.agentId);if(!t)continue;let r=(e.department||`unknown`).toLowerCase(),i=s.get(r)??{x:0,y:0,count:0};i.x+=t.x,i.y+=t.y,i.count+=1,s.set(r,i)}let c=Math.max(...o.values());e.save(),e.globalCompositeOperation=`lighter`;for(let[t,n]of o.entries()){let r=s.get(t);if(!r||r.count===0)continue;let o=r.x/r.count,l=r.y/r.count,u=n/c,d=30+u*50,f=.2+u*.25,p=e.createRadialGradient(o,l,0,o,l,d);p.addColorStop(0,_x(i,f)),p.addColorStop(.6,_x(i,f*.4)),p.addColorStop(1,_x(i,0)),e.fillStyle=p,e.beginPath(),e.arc(o,l,d,0,Math.PI*2),e.fill(),e.globalCompositeOperation=`source-over`,e.fillStyle=_x(i,.95),e.font=`bold ${a}px ui-monospace, monospace`,e.textAlign=`center`,e.textBaseline=`middle`,e.fillText(`${n}`,o,l),e.globalCompositeOperation=`lighter`}e.restore()}function hx(e,t,n,r,i=`rgba(216, 204, 176, 0.6)`,a=9){let o=e=>typeof e==`number`?e:null,s=o(t.foodReserve),c=o(t.waterLitersPerDay),l=o(t.powerKw),u=o(t.pressurizedVolumeM3);if(s==null&&c==null&&l==null&&u==null)return;let d=(e,t,n)=>e<=t?1:e>=n?0:1-(e-t)/(n-t),f=e=>e<.33?`rgba(106, 173, 72, ${.06+e*.1})`:e<.66?`rgba(232, 180, 74, ${.08+(e-.33)*.2})`:`rgba(196, 74, 30, ${.12+(e-.66)*.3})`,p=n/2,m=r/2;e.save(),s!=null&&(e.fillStyle=f(d(s,3,18)),e.fillRect(0,0,p,m)),c!=null&&(e.fillStyle=f(d(c,200,1200)),e.fillRect(p,0,p,m)),l!=null&&(e.fillStyle=f(d(l,150,600)),e.fillRect(0,m,p,m)),u!=null&&(e.fillStyle=f(d(u,1500,4e3)),e.fillRect(p,m,p,m));let h=Math.max(40,16+a*2),g=m+8;e.font=`bold ${a}px ui-monospace, monospace`,e.fillStyle=i,e.textAlign=`left`,e.textBaseline=`top`,s!=null&&e.fillText(`FOOD ${s.toFixed(1)}mo`,8,h),c!=null&&(e.textAlign=`right`,e.fillText(`WATER ${Math.round(c)}L/d`,n-8,h)),l!=null&&(e.textAlign=`left`,e.fillText(`POWER ${Math.round(l)}kW`,8,g)),u!=null&&(e.textAlign=`right`,e.fillText(`VOL ${Math.round(u)}m³`,n-8,g)),e.textBaseline=`alphabetic`,e.textAlign=`start`,e.restore()}function gx(e,t,n,r,i,a){if(!r||r.size===0)return;let o=.6+.4*Math.sin(i*.004);e.save();for(let i of t){if(!i.alive||!r.has(i.agentId))continue;let t=n.get(i.agentId);t&&(e.strokeStyle=a,e.lineWidth=2,e.globalAlpha=.9,e.beginPath(),e.arc(t.x,t.y,9,0,Math.PI*2),e.stroke(),e.lineWidth=1,e.globalAlpha=.45*o,e.beginPath(),e.arc(t.x,t.y,14+o*3,0,Math.PI*2),e.stroke(),e.globalAlpha=.2*o,e.beginPath(),e.arc(t.x,t.y,20+o*5,0,Math.PI*2),e.stroke())}e.restore()}function _x(e,t){let n=e.trim();if(n.startsWith(`#`)){let e=parseInt(n.slice(1),16);if(n.length===7)return`rgba(${e>>16&255},${e>>8&255},${e&255},${t})`}let r=n.match(/rgba?\(([^)]+)\)/);if(r){let e=r[1].split(`,`).map(e=>e.trim());if(e.length>=3)return`rgba(${e[0]},${e[1]},${e[2]},${t})`}return n}function vx(){return{items:[]}}function yx(e,t){for(e.items.push({...t,age:0,progress:0});e.items.length>30;)e.items.shift()}function bx(e){let t=[];for(let n of e.items){let e=n.age+1;e>=n.totalFrames||t.push({...n,age:e,progress:e/n.totalFrames})}e.items=t}function xx(e){return e.items}function Sx(e,t){let n=new Map(e.map(e=>[e.agentId,e]));return{born:t.filter(e=>!n.has(e.agentId)&&e.alive&&!((e.age??0)>=18)),died:t.filter(e=>n.get(e.agentId)?.alive===!0&&!e.alive)}}var Cx=new Set([`political`,`social`,`infrastructure`,`medical`,`resource`,`environmental`]);function wx(e,t,n,r){let i=(0,L.useRef)(vx()),a=(0,L.useRef)(new Set),[o,s]=(0,L.useState)(0),c=(0,L.useRef)(-1),l=(0,L.useRef)(!0),u=(0,L.useRef)(typeof document<`u`?!document.hidden:!0),d=Sy(Ey);(0,L.useEffect)(()=>{let t=e.snapshot,r=e.previousSnapshot;if(!t||t.turn===c.current||(c.current=t.turn,!r))return;let o=n(),{born:s,died:l}=Sx(r.cells,t.cells);for(let e of s){let t=o.get(e.agentId);t&&yx(i.current,{kind:`birth`,x:t.x,y:t.y,totalFrames:30,sourceId:e.agentId})}for(let e of l){let t=o.get(e.agentId);t&&yx(i.current,{kind:`death`,x:t.x,y:t.y,totalFrames:60,sourceId:e.agentId})}let u=e.eventCategories??t.eventCategories??[];if(u.length>0){let e=Array.from(o.values());if(e.length>0){let n=e.reduce((e,t)=>e+t.x,0)/e.length,r=e.reduce((e,t)=>e+t.y,0)/e.length;for(let e of u){let o=e.toLowerCase();if(!Cx.has(o))continue;let s=`crisis|${t.turn}|${o}`;a.current.has(s)||(a.current.add(s),yx(i.current,{kind:`crisis`,x:n,y:r,totalFrames:90}))}}}},[e.snapshot,e.previousSnapshot,e.eventCategories,n]),(0,L.useEffect)(()=>{if(!r)return;let t=r();if(t.size!==0){for(let n of e.forgeAttempts??[]){let e=`forge|${n.turn}|${n.eventIndex}|${n.department}|${n.name}|${n.approved?`a`:`r`}`;if(a.current.has(e))continue;a.current.add(e);let r=t.get((n.department||`unknown`).toLowerCase());r&&yx(i.current,{kind:n.approved?`forge_approved`:`forge_rejected`,x:r.x,y:r.y,totalFrames:n.approved?30:22})}for(let n of e.reuseCalls??[]){let e=`reuse|${n.turn}|${n.originDept}|${n.callingDept}|${n.name}`;if(a.current.has(e))continue;a.current.add(e);let r=t.get((n.originDept||`unknown`).toLowerCase()),o=t.get((n.callingDept||`unknown`).toLowerCase());r&&o&&yx(i.current,{kind:`reuse`,x:r.x,y:r.y,endX:o.x,endY:o.y,totalFrames:40})}}},[e.forgeAttempts,e.reuseCalls,r]),(0,L.useEffect)(()=>{let e=()=>{u.current=!document.hidden};document.addEventListener(`visibilitychange`,e);let n=t.current,r=null;return n&&(r=new IntersectionObserver(e=>{for(let t of e)l.current=t.isIntersecting},{threshold:0}),r.observe(n)),()=>{document.removeEventListener(`visibilitychange`,e),r?.disconnect()}},[t]);let f=e.still===!0,p=e.paintTimes;return(0,L.useEffect)(()=>{if(d||f){s(e=>e+1);return}let e=0,t=performance.now(),n=r=>{let a=r>=(p?.current[0]??1/0);!l.current&&!a||!u.current||r-t<33.333333333333336||(t=r,l.current&&bx(i.current),a&&p?.current.shift(),s(e=>e+1)),e=requestAnimationFrame(n)};return e=requestAnimationFrame(n),()=>cancelAnimationFrame(e)},[p,d,f]),{flares:xx(i.current),tickClock:o}}function Tx(e,t){let n=new Map;for(let r of e){if(!r.alive)continue;let e=t.get(r.agentId);if(!e)continue;let i=(r.department||`unknown`).toLowerCase(),a=n.get(i)??{x:0,y:0,n:0};a.x+=e.x,a.y+=e.y,a.n+=1,n.set(i,a)}let r=new Map;for(let[e,t]of n.entries())r.set(e,{x:t.x/t.n,y:t.y/t.n});return r}var Ex={medical:`#4ecdc4`,engineering:`#e8b44a`,agriculture:`#6aad48`,psychology:`#9b6b9e`,governance:`#e06530`,research:`#956bd8`,science:`#956bd8`,ops:`#c87a3a`,operations:`#c87a3a`};function Dx(e){return Ex[(e||``).toLowerCase()]??`#a89878`}function Ox({cells:e,size:t=44}){let{slices:n,alive:r}=(0,L.useMemo)(()=>{let t=new Map,n=0;for(let r of e){if(!r.alive)continue;let e=(r.department||`unknown`).toLowerCase();t.set(e,(t.get(e)??0)+1),n+=1}let r=[...t.entries()].sort((e,t)=>t[1]-e[1]),i=[];for(let[e,t]of r)i.push({dept:e,count:t,frac:t/Math.max(1,n),color:Dx(e)});return{slices:i,alive:n}},[e]);if(r===0)return(0,R.jsx)(`div`,{style:{width:t,height:t,display:`flex`,alignItems:`center`,justifyContent:`center`,color:`var(--text-4)`,fontSize:`var(--viz-read-size, var(--font-3xs))`,fontFamily:`var(--mono)`},"aria-label":`No live members`,children:`—`});let i=t/2,a=i-6,o=i,s=i,c=-Math.PI/2;return(0,R.jsxs)(`svg`,{width:t,height:t,viewBox:`0 0 ${t} ${t}`,role:`img`,"aria-label":`Department breakdown: ${n.map(e=>`${e.dept} ${e.count}`).join(`, `)}`,children:[n.map((e,t)=>{let n=e.frac*Math.PI*2,r=c,l=c+n;c=l;let u=o+Math.cos(r)*i,d=s+Math.sin(r)*i,f=o+Math.cos(l)*i,p=s+Math.sin(l)*i,m=o+Math.cos(r)*a,h=s+Math.sin(r)*a,g=o+Math.cos(l)*a,_=s+Math.sin(l)*a,v=+(n>Math.PI),y=[`M ${u.toFixed(2)} ${d.toFixed(2)}`,`A ${i} ${i} 0 ${v} 1 ${f.toFixed(2)} ${p.toFixed(2)}`,`L ${g.toFixed(2)} ${_.toFixed(2)}`,`A ${a} ${a} 0 ${v} 0 ${m.toFixed(2)} ${h.toFixed(2)}`,`Z`].join(` `);return(0,R.jsx)(`path`,{d:y,fill:e.color,opacity:.85,children:(0,R.jsx)(`title`,{children:`${e.dept}: ${e.count} (${Math.round(e.frac*100)}%)`})},`${e.dept}-${t}`)}),(0,R.jsx)(`text`,{x:o,y:s,textAnchor:`middle`,dominantBaseline:`central`,style:{fontSize:`var(--viz-read-size, 10px)`},fontFamily:`ui-monospace, monospace`,fontWeight:800,fill:`var(--text-1)`,children:r})]})}var kx={"tab.living":`Who's alive this turn — agents on the scenario grid.`,"tab.mood":`Aggregate mood mix per leader: hopeful / neutral / anxious / negative.`,"tab.forge":`Computational tools the agents forged in the QuickJS WebAssembly sandbox this turn.`,"tab.ecology":`Resource and environment metrics: power, food, water, radiation.`,"tab.divergence":`Per-metric A-vs-B deltas across all turns.`,"badge.forge":`Forge attempts on this turn — click FORGE for details.`,"badge.divergence":`Metrics diverged this turn — click DIVERGENCE for the rail.`,"stat.morale":`Aggregate morale across all alive agents (0–100%).`,"stat.moodMix":`Distribution of agents across the four mood tiers, weighted by morale.`,"stat.alive":`Living agents in this colony at the current turn.`,"stat.age":`Age distribution of living agents (4 bins: <20 / 20–40 / 40–60 / 60+).`,"stat.paired":`Alive agents currently in a partnership pair.`,"stat.earth":`Agents born on Earth (vs Native — born after the colony's first birth event).`,"stat.native":`Agents born in the colony itself (Marsborn / Lunarborn / scenario-specific).`,"stat.depts":`Agent count by department. Hover a wedge for the dept name.`,"chip.rising":`Aggregate morale trending up vs the previous turn.`},Ax={strip:`_strip_39xpt_1`,narrow:`_narrow_39xpt_15`,col:`_col_39xpt_20`,colNarrow:`_colNarrow_39xpt_27`,colPaired:`_colPaired_39xpt_31`,row:`_row_39xpt_35`,rowBaseline:`_rowBaseline_39xpt_40`,label:`_label_39xpt_46`,moraleValue:`_moraleValue_39xpt_51`,bar:`_bar_39xpt_57`,moraleFill:`_moraleFill_39xpt_64`,value2:`_value2_39xpt_71`,valueRust:`_valueRust_39xpt_75`,valueNative:`_valueNative_39xpt_79`,moodHeader:`_moodHeader_39xpt_84`,moodEmpty:`_moodEmpty_39xpt_90`,moodBar:`_moodBar_39xpt_95`,moodSegment:`_moodSegment_39xpt_103`,moodLegend:`_moodLegend_39xpt_109`,ageBars:`_ageBars_39xpt_117`,ageBarCol:`_ageBarCol_39xpt_124`,ageBarFill:`_ageBarFill_39xpt_133`,ageScale:`_ageScale_39xpt_143`,deptBlock:`_deptBlock_39xpt_150`,deptLabel:`_deptLabel_39xpt_158`};function jx({snapshot:e,sideColor:t}){let n=Sy(Cy),r=e.cells.filter(e=>e.alive),i=r.reduce((e,t)=>{let n=t.mood||`neutral`;return e[n]=(e[n]??0)+1,e},{}),a=[`positive`,`hopeful`,`neutral`,`anxious`,`negative`,`defiant`,`resigned`],o={positive:`var(--green)`,hopeful:`#9acd60`,neutral:`var(--text-4)`,anxious:`var(--amber)`,negative:`var(--rust)`,defiant:`#c44a1e`,resigned:`var(--text-3)`},s=r.length||1,c=[0,0,0,0];for(let e of r){let t=e.age??30;t<20?c[0]++:t<40?c[1]++:t<60?c[2]++:c[3]++}let l=Math.max(1,...c),u=r.filter(e=>!!e.partnerId).length,d=r.filter(e=>(e.generation??0)===0).length,f=Math.round(e.morale*100),p=f>=60?`var(--green)`:f>=30?`var(--amber)`:`var(--rust)`,m={"--side-color":t};return(0,R.jsxs)(`div`,{className:[Ax.strip,n?Ax.narrow:``].filter(Boolean).join(` `),children:[(0,R.jsxs)(`div`,{className:[Ax.col,Ax.colNarrow].join(` `),children:[(0,R.jsxs)(`div`,{className:Ax.rowBaseline,children:[(0,R.jsx)(`span`,{className:Ax.label,title:kx[`stat.morale`],children:`MORALE`}),(0,R.jsxs)(`span`,{className:Ax.moraleValue,style:{"--morale-color":p},children:[f,`%`]})]}),(0,R.jsx)(`div`,{className:Ax.bar,children:(0,R.jsx)(`div`,{className:Ax.moraleFill,style:{"--morale-pct":`${Math.max(2,f)}%`,"--morale-color":p}})}),typeof e.foodReserve==`number`&&(0,R.jsxs)(`div`,{className:Ax.row,children:[(0,R.jsx)(`span`,{children:`FOOD`}),(0,R.jsxs)(`span`,{className:Ax.value2,children:[e.foodReserve.toFixed(1),`mo`]})]}),(0,R.jsxs)(`div`,{className:Ax.row,children:[(0,R.jsx)(`span`,{children:`DEATHS`}),(0,R.jsx)(`span`,{className:Ax.valueRust,children:e.deaths})]})]}),(0,R.jsxs)(`div`,{className:Ax.col,children:[(0,R.jsxs)(`div`,{className:Ax.moodHeader,children:[(0,R.jsx)(`span`,{className:Ax.label,title:kx[`stat.moodMix`],children:`MOOD MIX`}),(0,R.jsxs)(`span`,{className:Ax.value2,title:kx[`stat.alive`],children:[r.length,` alive`]})]}),r.length===0?(0,R.jsx)(`div`,{className:Ax.moodEmpty,children:`no survivors`}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:Ax.moodBar,children:a.map(e=>{let t=i[e]||0;if(t===0)return null;let n=t/s*100;return(0,R.jsx)(`div`,{title:`${e}: ${t}`,className:Ax.moodSegment,style:{"--segment-pct":`${n}%`,"--segment-bg":o[e]||`var(--text-4)`}},e)})}),(0,R.jsx)(`div`,{className:Ax.moodLegend,children:a.filter(e=>(i[e]||0)>0).map(e=>`${Math.round((i[e]||0)/s*100)}% ${e}`).slice(0,3).join(` · `)})]})]}),(0,R.jsxs)(`div`,{className:Ax.col,children:[(0,R.jsx)(`div`,{className:Ax.label,title:kx[`stat.age`],children:`AGE`}),(0,R.jsx)(`div`,{className:Ax.ageBars,children:c.map((e,n)=>(0,R.jsx)(`div`,{className:Ax.ageBarCol,children:(0,R.jsx)(`div`,{title:`${[`<20`,`20-40`,`40-60`,`60+`][n]}: ${e} colonists`,className:Ax.ageBarFill,style:{"--age-height":`${e/l*100}%`,"--age-min":e>0?`2px`:`0`,"--age-bg":e>0?t:`transparent`}})},n))}),(0,R.jsxs)(`div`,{className:Ax.ageScale,children:[(0,R.jsx)(`span`,{children:`<20`}),(0,R.jsx)(`span`,{children:`20`}),(0,R.jsx)(`span`,{children:`40`}),(0,R.jsx)(`span`,{children:`60+`})]})]}),(0,R.jsxs)(`div`,{className:[Ax.col,Ax.colPaired].join(` `),children:[(0,R.jsxs)(`div`,{className:Ax.row,children:[(0,R.jsx)(`span`,{className:Ax.label,title:kx[`stat.paired`],children:`PAIRED`}),(0,R.jsxs)(`span`,{className:Ax.value2,children:[u,`/`,r.length]})]}),(0,R.jsxs)(`div`,{className:Ax.row,children:[(0,R.jsx)(`span`,{title:kx[`stat.earth`],children:`EARTH`}),(0,R.jsx)(`span`,{className:Ax.value2,children:d})]}),(0,R.jsxs)(`div`,{className:Ax.row,children:[(0,R.jsx)(`span`,{title:kx[`stat.native`],children:`NATIVE`}),(0,R.jsx)(`span`,{className:Ax.valueNative,style:m,children:r.length-d})]})]}),!n&&(0,R.jsxs)(`div`,{className:Ax.deptBlock,"aria-label":`Department breakdown`,title:kx[`stat.depts`],children:[(0,R.jsx)(Ox,{cells:e.cells,size:44}),(0,R.jsx)(`span`,{className:Ax.deptLabel,children:`Depts`})]})]})}var Mx={cols:12,rows:6,seedRadius:2},Nx=[[1,0],[2,1],[0,2],[1,2],[2,2]],Px=[[0,1],[1,1],[2,1]],Fx=[[0,0],[1,0],[0,1],[1,1]],Ix=[[1,0],[2,0],[0,1],[3,1],[1,2],[2,2]],Lx=[[1,0],[2,0],[3,0],[0,1],[1,1],[2,1]],Rx=[[1,0],[2,0],[0,1],[1,1],[1,2]];function zx(e){switch(e){case`positive`:case`hopeful`:return Fx;case`neutral`:return Ix;case`anxious`:return Px;case`resigned`:return Lx;case`defiant`:case`negative`:return Nx;default:return Px}}function Bx(e,t,n,r,i,a,o){let s=r/a,c=i/o,l=Math.max(1,Math.min(s,c)-2);e.save(),e.fillStyle=`rgba(106, 173, 72, 0.25)`,e.strokeStyle=`rgba(154, 205, 96, 0.95)`,e.lineWidth=2;for(let u of t){if(!u.alive||(u.generation??0)===0)continue;let t=n.get(u.agentId);if(!t)continue;let d=Math.floor(t.x/Math.max(1,r)*a),f=Math.floor(t.y/Math.max(1,i)*o),p=(s-l)/2,m=(c-l)/2,h=d*s+p,g=f*c+m;e.fillRect(h,g,l,l),e.strokeRect(h+.5,g+.5,l-1,l-1);let _=h+l/2,v=g+l/2,y=l*.4;e.beginPath(),e.moveTo(_-y,v),e.lineTo(_+y,v),e.moveTo(_,v-y),e.lineTo(_,v+y),e.stroke()}e.restore()}function Vx(e,t,n,r,i,a,o,s=`rgba(168, 152, 120, 0.85)`,c=`rgba(168, 152, 120, 0.08)`){let l=r/a,u=i/o,d=Math.max(1,Math.min(l,u)-2);e.save(),e.lineWidth=2,e.strokeStyle=s,e.fillStyle=c;for(let s of t){if(s.alive)continue;let t=n.get(s.agentId);if(!t)continue;let c=Math.floor(t.x/Math.max(1,r)*a),f=Math.floor(t.y/Math.max(1,i)*o),p=(l-d)/2,m=(u-d)/2,h=c*l+p,g=f*u+m;e.fillRect(h,g,d,d),e.strokeRect(h+.5,g+.5,d-1,d-1),e.beginPath(),e.moveTo(h+4,g+4),e.lineTo(h+d-4,g+d-4),e.moveTo(h+d-4,g+4),e.lineTo(h+4,g+d-4),e.stroke()}e.restore()}function Hx(e,t,n,r,i){let{cols:a,rows:o,grid:s}=e,c=Math.floor(t/Math.max(1,r)*a),l=Math.floor(n/Math.max(1,i)*o);return c<0||c>=a||l<0||l>=o?null:s[l*a+c]>0?{col:c,row:l}:null}function Ux(e,t,n,r,i){return{col:Math.floor(e.x/Math.max(1,t)*r),row:Math.floor(e.y/Math.max(1,n)*i)}}function Wx(e){switch(e){case`birth`:return Fx;case`forge`:return Nx;case`crisis`:return Rx;case`death`:return[];default:return null}}function Gx(e,t){return{cols:e,rows:t,grid:new Uint8Array(e*t),next:new Uint8Array(e*t),frame:0}}function Kx(e,t,n,r,i,a=`all`){let{cols:o,rows:s,grid:c}=e;c.fill(0);let l=Wx(a);for(let e=0;e<t.length;e+=1){let a=t[e];if(!a.alive)continue;let u=n.get(a.agentId);if(!u)continue;let d=Math.floor(u.x/Math.max(1,r)*o),f=Math.floor(u.y/Math.max(1,i)*s),p=l??zx(a.mood);for(let[e,t]of p){let n=d+e-1,r=f+t-1;n<0||n>=o||r<0||r>=s||(c[r*o+n]=8)}}}function qx(e,t,n,r){let{cols:i,rows:a,grid:o}=e,s=Math.floor(t.x/Math.max(1,n)*i),c=Math.floor(t.y/Math.max(1,r)*a);if(t.kind===`death`){for(let e=-1;e<=1;e+=1)for(let t=-1;t<=1;t+=1){let n=s+t,r=c+e;n<0||n>=i||r<0||r>=a||(o[r*i+n]=0)}return}let l;switch(t.kind){case`birth`:l=Fx;break;case`forge_approved`:l=Nx;break;case`forge_rejected`:l=Px;break;case`reuse`:l=Lx;break;case`crisis`:l=Rx;break;default:l=Px}for(let[e,t]of l){let n=s+e-1,r=c+t-1;n<0||n>=i||r<0||r>=a||(o[r*i+n]=8)}}function Jx(e){let{cols:t,rows:n,grid:r,next:i}=e;i.fill(0);for(let e=0;e<n;e++)for(let a=0;a<t;a++){let o=0;for(let i=-1;i<=1;i++)for(let s=-1;s<=1;s++){if(s===0&&i===0)continue;let c=a+s,l=e+i;c<0||c>=t||l<0||l>=n||r[l*t+c]>0&&(o+=1)}let s=r[e*t+a],c=s>0;c&&o===2||o===3?i[e*t+a]=c?Math.max(4,s):8:c&&s>1&&(i[e*t+a]=Math.max(0,s-2))}r.set(i),e.frame+=1}function Yx(e,t,n,r,i,a=1){let{cols:o,rows:s,grid:c}=t;if(a<=0)return;let l=n/o,u=r/s,d=Math.max(1,Math.min(l,u)-2),f=(l-d)/2,p=(u-d)/2;e.save();for(let t=0;t<s;t++)for(let n=0;n<o;n++){let r=c[t*o+n];if(r===0)continue;let s=Math.min(1,r/8*.9*a);e.fillStyle=i,e.globalAlpha=s,e.fillRect(n*l+f,t*u+p,d,d)}e.restore()}function Xx(e,t){return e<0||Math.abs(t-e)>1}function Zx(e,t,n,r){return r||n<=0?e:e*(1-(1-Math.max(0,Math.min(1,t/n)))**3)}function Qx(e,t,n,r){for(let i=e.length-1;i>=0;i--){let a=e[i];if(!a.alive)continue;let o=t.get(a.agentId);if(!o)continue;let s=(a.featured?5:3)+18,c=n-o.x,l=r-o.y;if(c*c+l*l<=s*s)return a}return null}var $x=[`O`,`C`,`E`,`A`,`Em`,`HH`];function eS(e,t){let n=t/2,r=t/2,i=t/2-8;return $x.map((t,a)=>{let o=Math.PI*2*a/$x.length-Math.PI/2,s=Math.max(0,Math.min(1,e[t])),c=i*s;return`${n+Math.cos(o)*c},${r+Math.sin(o)*c}`}).join(` `)}function tS(e,t,n){let r=t/2,i=t/2,a=t/2,o=Math.PI*2*n/$x.length-Math.PI/2;return{x:r+Math.cos(o)*a,y:i+Math.sin(o)*a,label:e}}function nS({profile:e,colonyMean:t,size:n=160}){let r=eS(e,n),i=t?eS(t,n):null,a=n/2,o=n/2,s=n/2-8;return(0,R.jsxs)(`svg`,{width:n,height:n,role:`img`,"aria-label":`HEXACO profile radar`,children:[[.25,.5,.75,1].map(e=>(0,R.jsx)(`circle`,{cx:a,cy:o,r:s*e,fill:`none`,stroke:`var(--border)`,strokeDasharray:e===1?void 0:`2 3`},e)),$x.map((e,t)=>{let r=tS(e,n,t);return(0,R.jsx)(`text`,{x:r.x,y:r.y,fontSize:`9`,fontFamily:`var(--mono)`,fill:`var(--text-3)`,textAnchor:`middle`,dominantBaseline:`middle`,children:r.label},e)}),i&&(0,R.jsx)(`polygon`,{points:i,fill:`none`,stroke:`var(--text-3)`,strokeWidth:`1`,strokeDasharray:`3 3`}),(0,R.jsx)(`polygon`,{points:r,fill:`color-mix(in srgb, var(--amber) 25%, transparent)`,stroke:`var(--amber)`,strokeWidth:`1.5`})]})}var rS={backdrop:`_backdrop_16u8a_1`,popover:`_popover_16u8a_8`,headerRow:`_headerRow_16u8a_25`,headerName:`_headerName_16u8a_34`,headerSubline:`_headerSubline_16u8a_42`,featuredPill:`_featuredPill_16u8a_49`,closeBtn:`_closeBtn_16u8a_59`,section:`_section_16u8a_72`,sectionLast:`_sectionLast_16u8a_77`,statsGrid:`_statsGrid_16u8a_81`,statKey:`_statKey_16u8a_88`,statValue:`_statValue_16u8a_92`,statValueUpper:`_statValueUpper_16u8a_96`,sectionLabel:`_sectionLabel_16u8a_101`,hexacoRow:`_hexacoRow_16u8a_110`,hexacoRadarWrap:`_hexacoRadarWrap_16u8a_116`,hexacoTopAxes:`_hexacoTopAxes_16u8a_120`,memoryList:`_memoryList_16u8a_126`,memoryItem:`_memoryItem_16u8a_132`,chatBtn:`_chatBtn_16u8a_143`},iS={O:`Openness`,C:`Conscientiousness`,E:`Extraversion`,A:`Agreeableness`,Em:`Emotionality`,HH:`Honesty-Humility`};function aS(e){if(!e)return``;let t=Object.entries(e);return t.sort((e,t)=>t[1]-e[1]),t.slice(0,2).map(([e,t])=>`${iS[e]} ${t.toFixed(2)}`).join(` · `)}function oS(e){let{payload:t,keepHeaderInView:n=!1,containerW:r,containerH:i,sideColor:a,hexacoById:o,snapshots:s,onClose:c,onOpenChat:l}=e,u=(0,L.useRef)(null);(0,L.useLayoutEffect)(()=>{n&&t&&u.current?.scrollIntoView({block:`nearest`,inline:`nearest`})},[n,t]),(0,L.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),c())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,c]);let d=(0,L.useMemo)(()=>{if(t&&o)return o.get(t.cell.agentId)??o.get(t.cell.name)},[t,o]),f=(0,L.useMemo)(()=>{if(!t)return[];let e=[...t.cell.shortTermMemory??[]];if(s)for(let n=s.length-1;n>=0&&e.length<3;n--){let r=s[n].cells.find(e=>e.agentId===t.cell.agentId);if(r){for(let t of r.shortTermMemory??[])if(t&&!e.includes(t)&&e.push(t),e.length>=3)break}}return e.slice(0,3)},[t,s]),p=Sy(wy);if(!t)return null;let m=p?Math.min(320,r-16):320,h=Math.min(360,i-20),g=p?Math.max(8,(r-m)/2):t.x+m+10>r?Math.max(10,t.x-m-10):Math.min(r-m-10,t.x+10),_=p?Math.max(8,(i-h)/2):t.y-h-10<0?Math.min(i-h-10,t.y+10):Math.max(10,t.y-h-10),v=t.cell,y=typeof v.psychScore==`number`?Math.round(v.psychScore*100):null,b=(()=>{let e=v.generation??0;return e===0?`Earth-born`:e===1?`First-native`:`Gen ${e}`})(),x=Math.max(120,i-_-10),S={"--side-color":a,"--pop-left":`${g}px`,"--pop-top":`${_}px`,"--pop-width":`${m}px`,"--pop-max-height":`${x}px`};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{onClick:c,className:rS.backdrop}),(0,R.jsxs)(`div`,{role:`dialog`,"aria-label":`${v.name} drilldown`,className:rS.popover,style:S,children:[(0,R.jsxs)(`div`,{ref:u,className:rS.headerRow,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:rS.headerName,children:v.name}),(0,R.jsxs)(`div`,{className:rS.headerSubline,children:[v.role,` · `,v.rank,v.featured&&(0,R.jsx)(`span`,{className:rS.featuredPill,children:`FEATURED`})]})]}),(0,R.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Close drilldown`,className:rS.closeBtn,children:`×`})]}),(0,R.jsx)(`div`,{className:rS.section,children:(0,R.jsxs)(`div`,{className:rS.statsGrid,children:[(0,R.jsx)(`span`,{className:rS.statKey,children:`DEPT`}),(0,R.jsx)(`span`,{className:rS.statValueUpper,children:v.department}),(0,R.jsx)(`span`,{className:rS.statKey,children:`AGE`}),(0,R.jsx)(`span`,{className:rS.statValue,children:v.age??`—`}),(0,R.jsx)(`span`,{className:rS.statKey,children:`MOOD`}),(0,R.jsx)(`span`,{className:rS.statValue,children:v.mood}),y!==null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:rS.statKey,children:`PSYCH`}),(0,R.jsxs)(`span`,{className:rS.statValue,children:[y,`%`]})]}),(0,R.jsx)(`span`,{className:rS.statKey,children:`ORIGIN`}),(0,R.jsx)(`span`,{className:rS.statValue,children:b}),(0,R.jsx)(`span`,{className:rS.statKey,children:`PARTNER`}),(0,R.jsx)(`span`,{className:rS.statValue,children:v.partnerId?`yes`:`—`}),(0,R.jsx)(`span`,{className:rS.statKey,children:`CHILDREN`}),(0,R.jsx)(`span`,{className:rS.statValue,children:v.childrenIds?.length??0})]})}),d&&(0,R.jsxs)(`div`,{className:rS.section,children:[(0,R.jsx)(`div`,{className:rS.sectionLabel,children:`HEXACO`}),(0,R.jsxs)(`div`,{className:rS.hexacoRow,children:[(0,R.jsx)(`div`,{className:rS.hexacoRadarWrap,children:(0,R.jsx)(nS,{profile:d,size:120})}),(0,R.jsx)(`div`,{className:rS.hexacoTopAxes,children:aS(d)})]})]}),f.length>0&&(0,R.jsxs)(`div`,{className:rS.section,children:[(0,R.jsx)(`div`,{className:rS.sectionLabel,children:`Recent memory`}),(0,R.jsx)(`ul`,{className:rS.memoryList,children:f.map((e,t)=>(0,R.jsxs)(`li`,{className:rS.memoryItem,children:[`"`,e,`"`]},t))})]}),l&&(0,R.jsx)(`div`,{className:rS.sectionLast,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>l(v.name),className:rS.chatBtn,children:[`Open chat with `,v.name.split(` `)[0]]})})]})]})}var sS={display:`block`,fontFamily:`var(--mono)`,fontSize:11,fontWeight:700,letterSpacing:`0.08em`,textTransform:`uppercase`,color:`var(--text-3)`,marginBottom:4},cS={fontFamily:`var(--mono)`,fontSize:13,fontWeight:800,letterSpacing:`0.08em`,textTransform:`uppercase`,color:`var(--text-2)`},lS={width:`100%`,padding:`6px 10px`,background:`var(--bg-card)`,color:`var(--text-3)`,border:`1px solid var(--border)`,borderRadius:3,cursor:`pointer`,fontFamily:`var(--mono)`,fontSize:10,fontWeight:800,letterSpacing:`0.08em`,textTransform:`uppercase`},uS={backdrop:`_backdrop_hma7a_1`,drawer:`_drawer_hma7a_8`,header:`_header_hma7a_25`,closeBtn:`_closeBtn_hma7a_32`,row:`_row_hma7a_45`,rowLabel:`_rowLabel_hma7a_53`,pillRow:`_pillRow_hma7a_58`,pill:`_pill_hma7a_58`,pillActive:`_pillActive_hma7a_76`,resetBtn:`_resetBtn_hma7a_81`},dS={deptLabels:!1,crosshair:!0,alerts:!0,sound:!1};function fS(e){let t={...dS};for(let n of Object.keys(dS))typeof e[n]==`boolean`&&(t[n]=e[n]);return t}function pS({open:e,settings:t,onChange:n,onClose:r}){let i=Qr(e);if((0,L.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),r())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,r]),!e)return null;let a=(e,r)=>{n({...t,[e]:r})};return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{onClick:r,className:uS.backdrop}),(0,R.jsxs)(`div`,{ref:i,role:`dialog`,"aria-label":`Grid viz settings`,tabIndex:-1,className:uS.drawer,children:[(0,R.jsxs)(`div`,{className:uS.header,children:[(0,R.jsx)(`span`,{style:cS,children:`Viz Settings`}),(0,R.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Close settings`,className:uS.closeBtn,children:`×`})]}),(0,R.jsxs)(mS,{label:`Dept labels`,children:[(0,R.jsx)(hS,{active:t.deptLabels,onClick:()=>a(`deptLabels`,!0),label:`on`}),(0,R.jsx)(hS,{active:!t.deptLabels,onClick:()=>a(`deptLabels`,!1),label:`off`})]}),(0,R.jsxs)(mS,{label:`Crosshair`,children:[(0,R.jsx)(hS,{active:t.crosshair,onClick:()=>a(`crosshair`,!0),label:`on`}),(0,R.jsx)(hS,{active:!t.crosshair,onClick:()=>a(`crosshair`,!1),label:`off`})]}),(0,R.jsxs)(mS,{label:`Alert toasts`,children:[(0,R.jsx)(hS,{active:t.alerts,onClick:()=>a(`alerts`,!0),label:`on`}),(0,R.jsx)(hS,{active:!t.alerts,onClick:()=>a(`alerts`,!1),label:`off`})]}),(0,R.jsxs)(mS,{label:`Sound cues`,children:[(0,R.jsx)(hS,{active:t.sound,onClick:()=>a(`sound`,!0),label:`on`}),(0,R.jsx)(hS,{active:!t.sound,onClick:()=>a(`sound`,!1),label:`off`})]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>n(dS),style:lS,className:uS.resetBtn,children:`Reset defaults`})]})]})}function mS({label:e,children:t}){return(0,R.jsxs)(`div`,{className:uS.row,children:[(0,R.jsx)(`span`,{style:sS,className:uS.rowLabel,children:e}),(0,R.jsx)(`div`,{className:uS.pillRow,children:t})]})}function hS({active:e,onClick:t,label:n}){return(0,R.jsx)(`button`,{type:`button`,onClick:t,className:[uS.pill,e?uS.pillActive:``].filter(Boolean).join(` `),children:n})}var gS={drawer:`_drawer_1mpzt_1`,header:`_header_1mpzt_17`,headerLabel:`_headerLabel_1mpzt_26`,closeBtn:`_closeBtn_1mpzt_34`,sortRow:`_sortRow_1mpzt_47`,sortChip:`_sortChip_1mpzt_54`,active:`_active_1mpzt_69`,body:`_body_1mpzt_74`,empty:`_empty_1mpzt_80`,deptHeader:`_deptHeader_1mpzt_86`,row:`_row_1mpzt_95`,deceased:`_deceased_1mpzt_115`,swatch:`_swatch_1mpzt_119`,rowName:`_rowName_1mpzt_128`,featuredPill:`_featuredPill_1mpzt_135`,deceasedToggle:`_deceasedToggle_1mpzt_144`},_S={positive:`rgba(106, 173, 72, 1)`,hopeful:`rgba(154, 205, 96, 1)`,neutral:`rgba(107, 95, 80, 1)`,anxious:`rgba(232, 180, 74, 1)`,negative:`rgba(224, 101, 48, 1)`,defiant:`rgba(196, 74, 30, 1)`,resigned:`rgba(168, 152, 120, 1)`},vS=[{key:`dept`,label:`Dept`},{key:`name`,label:`Name`},{key:`psych`,label:`Psych`},{key:`age`,label:`Age`}];function yS({open:e,cells:t,actorName:n,sideColor:r,searchQuery:i,hoveredId:a,onHover:o,onSelect:s,onClose:c}){let[l,u]=(0,L.useState)(!1),[d,f]=(0,L.useState)(`dept`),p=i_(),{alive:m,deceased:h,matchSet:g}=(0,L.useMemo)(()=>{let e=[],n=[];for(let r of t)r.alive?e.push(r):n.push(r);d===`dept`?e.sort((e,t)=>e.department.localeCompare(t.department)||e.name.localeCompare(t.name)):d===`name`?e.sort((e,t)=>e.name.localeCompare(t.name)):d===`psych`?e.sort((e,t)=>(t.psychScore??0)-(e.psychScore??0)):d===`age`&&e.sort((e,t)=>(t.age??0)-(e.age??0)),n.sort((e,t)=>e.name.localeCompare(t.name));let r=i.trim().toLowerCase().split(/\s+/).filter(Boolean),a=new Set;if(r.length>0)for(let e of t){let t=`${e.name} ${e.department} ${e.role} ${e.mood}`.toLowerCase();r.every(e=>t.includes(e))&&a.add(e.agentId)}return{alive:e,deceased:n,matchSet:a}},[t,i,d]),_=(0,L.useMemo)(()=>{if(d!==`dept`)return[[`__flat__`,m]];let e=new Map;for(let t of m){let n=(t.department||`unknown`).toLowerCase(),r=e.get(n)??[];r.push(t),e.set(n,r)}return[...e.entries()].sort((e,t)=>e[0].localeCompare(t[0]))},[m,d]);if(!e)return null;let v={"--side-color":r},y=(e,t,n)=>({"--row-color":t?`var(--text-4)`:`var(--text-2)`,"--row-bg":n?`var(--bg-card)`:e?`color-mix(in srgb, ${r} 13%, transparent)`:`transparent`,"--row-border":e?r:`transparent`,"--row-opacity":t?`0.55`:`1`});return(0,R.jsxs)(`div`,{className:gS.drawer,children:[(0,R.jsxs)(`div`,{className:gS.header,style:v,children:[(0,R.jsxs)(`span`,{className:gS.headerLabel,style:v,children:[n,` Roster · `,m.length]}),(0,R.jsx)(`button`,{type:`button`,onClick:c,"aria-label":`Close roster`,className:gS.closeBtn,children:`×`})]}),(0,R.jsx)(`div`,{className:gS.sortRow,children:vS.map(e=>{let t=d===e.key;return(0,R.jsx)(`button`,{type:`button`,onClick:()=>f(e.key),"aria-pressed":t,className:[gS.sortChip,t?gS.active:``].filter(Boolean).join(` `),children:e.label},e.key)})}),(0,R.jsxs)(`div`,{className:gS.body,children:[_.length===0&&(0,R.jsxs)(`div`,{className:gS.empty,children:[`No living `,p.people,`.`]}),_.map(([e,t])=>(0,R.jsxs)(`div`,{children:[d===`dept`&&(0,R.jsxs)(`div`,{className:gS.deptHeader,children:[e,` · `,t.length]}),t.map(e=>{let t=g.has(e.agentId),n=a===e.agentId,r=i.trim().length>0&&!t;return(0,R.jsxs)(`button`,{type:`button`,onMouseEnter:()=>o(e.agentId),onMouseLeave:()=>o(null),onClick:()=>s(e),title:`${e.name} · ${e.role} · ${e.mood}`,className:gS.row,style:y(t,r,n),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:gS.swatch,style:{"--swatch-bg":_S[e.mood]??_S.neutral}}),(0,R.jsx)(`span`,{className:gS.rowName,children:e.name}),e.featured&&(0,R.jsx)(`span`,{className:gS.featuredPill,style:v,children:`★`})]},e.agentId)})]},e)),h.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,onClick:()=>u(e=>!e),className:gS.deceasedToggle,children:[l?`▼`:`▶`,` Deceased · `,h.length]}),l&&h.map(e=>{let t=a===e.agentId;return(0,R.jsxs)(`button`,{type:`button`,onMouseEnter:()=>o(e.agentId),onMouseLeave:()=>o(null),onClick:()=>s(e),title:`${e.name} · ${e.role} · deceased`,className:[gS.row,gS.deceased].join(` `),style:y(!1,!0,t),children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:gS.swatch,style:{"--swatch-bg":`var(--text-4)`}}),(0,R.jsx)(`span`,{className:gS.rowName,children:e.name})]},e.agentId)})]})]})]})}function bS({snapshot:e,previousSnapshot:t,sideColor:n,inFlow:r=!1,onSelect:i}){let[a,o]=(0,L.useState)([]),s=(0,L.useRef)(new Set);(0,L.useEffect)(()=>{if(!e)return;let n=e.cells.filter(e=>e.alive&&e.featured),r=t?new Set(t.cells.filter(e=>e.alive&&e.featured).map(e=>e.agentId)):s.current,i=n.filter(e=>!r.has(e.agentId));if(s.current=new Set(n.map(e=>e.agentId)),i.length===0)return;let a=performance.now()+6e3;o(i.slice(0,2).map(t=>({cell:t,turn:e.turn,expiresAt:a})))},[e,t]),(0,L.useEffect)(()=>{if(a.length===0)return;let e=Math.max(0,a[0].expiresAt-performance.now()),t=setTimeout(()=>o([]),e);return()=>clearTimeout(t)},[a]);let c=(0,L.useMemo)(()=>a,[a]);return c.length===0?null:(0,R.jsx)(`div`,{"aria-live":`polite`,"data-grid-spotlight":r?``:void 0,style:{...r?{alignSelf:`flex-end`}:{position:`absolute`,bottom:12,right:12},display:`flex`,flexDirection:`column`,gap:4,pointerEvents:`none`,zIndex:7,maxWidth:r?`100%`:240},children:c.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>i?.(e.cell),"aria-label":`Spotlight: ${e.cell.name} · ${e.cell.department}`,title:`${e.cell.name} · ${e.cell.role} · ${e.cell.department} · mood: ${e.cell.mood}`,style:{pointerEvents:`auto`,display:`flex`,alignItems:`center`,gap:6,padding:`4px 10px`,background:`var(--bg-panel)`,border:`1px solid ${n}66`,borderLeft:`3px solid ${n}`,borderRadius:3,fontFamily:`var(--mono)`,fontSize:`var(--viz-read-size, var(--font-xs))`,color:`var(--text-2)`,textAlign:`left`,cursor:`pointer`,boxShadow:`0 4px 14px rgba(0, 0, 0, 0.4)`,animation:`paracosm-spotlight-in 380ms ease-out`,whiteSpace:`nowrap`,overflow:`hidden`,textOverflow:`ellipsis`,maxWidth:`100%`},children:[(0,R.jsx)(`span`,{style:{color:n,fontSize:`var(--viz-read-size, var(--font-2xs))`,flexShrink:0},"aria-hidden":`true`,children:`★`}),(0,R.jsx)(`span`,{style:{color:`var(--text-1)`,fontWeight:700,overflow:`hidden`,textOverflow:`ellipsis`},children:e.cell.name}),(0,R.jsx)(`span`,{style:{color:`var(--text-3)`,fontSize:`var(--viz-read-size, var(--font-2xs))`,flexShrink:0,textTransform:`uppercase`,letterSpacing:`0.04em`},children:e.cell.department})]},e.cell.agentId))})}var xS=(e,t,n)=>e.left<t.left+t.w+n&&t.left<e.left+e.w+n&&e.top<t.top+t.h+n&&t.top<e.top+e.h+n,SS=(e,t)=>{let n=Math.max(e.left,Math.min(t.x,e.left+e.w)),r=Math.max(e.top,Math.min(t.y,e.top+e.h)),i=t.x-n,a=t.y-r;return i*i+a*a<t.r*t.r};function CS(e,t,n=[],r={}){let i=r.gap??14,a=r.pad??2,o=r.margin??2,s=new Map,c=[];if(!(t.w>0)||!(t.h>0))return s;let l=(e,n,r,i)=>({left:Math.max(o,Math.min(e,t.w-r-o)),top:Math.max(o,Math.min(n,t.h-i-o)),w:r,h:i}),u=e=>!c.some(t=>xS(e,t,a)),d=e=>n.reduce((t,n)=>t+ +!!SS(e,n),0);for(let n of e){if(!(n.w>0)||!(n.h>0))continue;let{x:e,y:r,w:f,h:p}=n,m=e>=t.w/2?e+i:e-i-f,h=e>=t.w/2?e-i-f:e+i,g=p+a,_=Math.ceil(t.h/g),v=[l(m,r-p/2,f,p),l(e-f/2,r+i,f,p),l(e-f/2,r-i-p,f,p),l(h,r-p/2,f,p)];for(let t=1;t<=_;t+=1)for(let n of[m,h,e-f/2])v.push(l(n,r-p/2+t*g,f,p)),v.push(l(n,r-p/2-t*g,f,p));let y=null,b=1/0;for(let e of v){if(!u(e))continue;let t=d(e);if(t<b&&(y=e,b=t,t===0))break}if(!y){let n=1/0;for(let i=o;i<=t.h-p-o;i+=4)for(let a=o;a<=t.w-f-o;a+=8){let t={left:a,top:i,w:f,h:p};if(!u(t))continue;let o=a+f/2-e,s=i+p/2-r,c=o*o+s*s;c<n&&(n=c,y=t)}}y&&(c.push(y),s.set(n.id,{left:y.left,top:y.top}))}return s}function wS(e,t,n){let r=Math.max(e.left,Math.min(n.x,e.left+t.w)),i=Math.max(e.top,Math.min(n.y,e.top+t.h));return{x:r,y:i,distance:Math.hypot(n.x-r,n.y-i)}}var TS={light:.22,dark:.65},ES=1/.9,DS=18;function OS(e){let t=[];return typeof e.foodReserve==`number`&&t.push(`food reserve ${e.foodReserve.toFixed(1)} months`),typeof e.waterLitersPerDay==`number`&&t.push(`water ${Math.round(e.waterLitersPerDay)} litres a day`),typeof e.powerKw==`number`&&t.push(`power ${Math.round(e.powerKw)} kW`),typeof e.pressurizedVolumeM3==`number`&&t.push(`pressurized volume ${Math.round(e.pressurizedVolumeM3)} cubic metres`),t.map(e=>`, ${e}`).join(``)}function kS(e,t){if(e.startsWith(`var(`)&&t){let n=e.slice(4,-1).trim(),r=getComputedStyle(t).getPropertyValue(n).trim();if(r)return r}return e}function AS(e){let{vizPanel:t=!1,snapshot:n,previousSnapshot:r,snapshotHistory:i,actorName:a,actorArchetype:o,startTime:s,sideColor:c,side:l,lagTurns:u,clusterMode:d=`departments`,initialPopulation:f=20,mode:p,hexacoById:m,leaderHexaco:h,forgeAttempts:g,reuseCalls:_,divergedIds:v,siblingHoveredId:y,onHoverChange:b,searchQuery:x=``,palette:S=0,settings:C=dS,focusedSide:w=null,onToggleFocus:T,onOpenChat:E,eventFilter:D=`all`,chronicleHover:O=null,header:k,nameLabels:ee,resting:A=!1}=e,j=w===l,M=k!==void 0,N=ee===`featured`,te=Sy(Cy),P=Sy(Ey),F=i_(),I=(0,L.useRef)(null),ne=(0,L.useRef)(null),re=(0,L.useRef)(null),[z,B]=(0,L.useState)({w:0,h:0}),[ie,ae]=(0,L.useState)(null),[oe,se]=(0,L.useState)(null),[ce,le]=(0,L.useState)(null),[V,ue]=(0,L.useState)(!1),[de,fe]=(0,L.useState)(null),[pe,me]=(0,L.useState)(P);(0,L.useEffect)(()=>{if(P){me(!0);return}let e=requestAnimationFrame(()=>me(!0));return()=>cancelAnimationFrame(e)},[P]);let he=(0,L.useRef)(Gx(Mx.cols,Mx.rows)),ge=(0,L.useRef)(-1),_e=(0,L.useRef)(``),ve=(0,L.useRef)(``),ye=(0,L.useRef)(null),be=(0,L.useRef)(``),xe=(0,L.useRef)(null),Se=(0,L.useRef)(-1/0),Ce=(0,L.useRef)([]),we=(0,L.useRef)({id:null,intensity:0});(0,L.useEffect)(()=>{let e=ne.current;if(!e)return;let t=new ResizeObserver(e=>{for(let t of e){let e=Math.max(0,Math.round(t.contentRect.width)),n=Math.max(0,Math.round(t.contentRect.height));B(t=>t.w===e&&t.h===n?t:{w:e,h:n})}});return t.observe(e),()=>t.disconnect()},[]),(0,L.useEffect)(()=>{let e=re.current;if(!e||z.w===0||z.h===0)return;let t=Math.min(2,window.devicePixelRatio||1);e.width=Math.round(z.w*t),e.height=Math.round(z.h*t),e.style.width=`${z.w}px`,e.style.height=`${z.h}px`;let n=e.getContext(`2d`);n&&n.setTransform(t,0,0,t,0,0)},[z.w,z.h]);let Te=(()=>{if(d!==`departments`)return d;switch(p){case`mood`:return`mood`;case`forge`:return`age`;case`divergence`:return`families`;default:return`departments`}})(),Ee=(0,L.useMemo)(()=>!n||z.w===0?new Map:ox(n.cells,Te,z.w,z.h),[n,Te,z.w,z.h]),De=(0,L.useMemo)(()=>n?Tx(n.cells,Ee):new Map,[n,Ee]),Oe=wx({snapshot:n,previousSnapshot:r,forgeAttempts:g,reuseCalls:_,eventCategories:n?.eventCategories,still:A,paintTimes:t?Ce:void 0},ne,()=>Ee,()=>De),[ke,Ae]=(0,L.useState)(0);(0,L.useEffect)(()=>{if(!A||typeof MutationObserver>`u`)return;let e=new MutationObserver(()=>Ae(e=>e+1));return e.observe(document.documentElement,{attributes:!0,attributeFilter:[`class`]}),()=>e.disconnect()},[A]);let je=(0,L.useRef)(null),[Me,Ne]=(0,L.useState)(()=>new Map),[Pe,Fe]=(0,L.useState)(null);(0,L.useLayoutEffect)(()=>{if(!N)return;let e=je.current;if(!e)return;let t=!1,n=()=>{if(t)return;let n=new Map,r=Math.max(0,e.clientWidth-4);e.querySelectorAll(`[data-person]`).forEach(e=>{let t=e.dataset.person;t&&n.set(t,{w:Math.min(e.scrollWidth+1,r),h:e.offsetHeight})}),Ne(e=>e.size===n.size&&[...n].every(([t,n])=>e.get(t)?.w===n.w&&e.get(t)?.h===n.h)?e:n)};n(),document.fonts?.ready.then(n);let r=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return e.querySelectorAll(`[data-person]`).forEach(e=>r?.observe(e)),()=>{t=!0,r?.disconnect()}},[N,n,z.w,z.h]);let Ie=(0,L.useMemo)(()=>{let e=new Map;if(!N||!n||z.w===0||z.h===0)return e;let t=n.cells.filter(e=>e.alive&&Ee.has(e.agentId)),r=t.map(e=>{let t=Ee.get(e.agentId);return{x:t.x,y:t.y,r:e.featured?12:6}});return CS(t.filter(e=>e.featured&&Me.has(e.agentId)).map(e=>{let t=Ee.get(e.agentId),n=Me.get(e.agentId);return{id:e.agentId,x:t.x,y:t.y,w:n.w,h:n.h}}),{w:z.w,h:z.h},r)},[N,n,Ee,Me,z.w,z.h]),Le=p===`forge`?.7:p===`ecology`?0:1,Re=(0,L.useMemo)(()=>{if(p!==`mood`||!n)return c;let e=n.cells.filter(e=>e.alive);if(e.length===0)return c;let t={};for(let n of e)t[n.mood]=(t[n.mood]||0)+1;let r=`neutral`,i=0;for(let[e,n]of Object.entries(t))n>i&&(i=n,r=e);switch(r){case`positive`:case`hopeful`:return`var(--green)`;case`anxious`:return`var(--amber)`;case`negative`:case`defiant`:return`var(--rust)`;case`resigned`:return`var(--text-3)`;default:return c}},[p,n,c]);(0,L.useEffect)(()=>{let e=re.current;if(!e||!n||z.w===0||z.h===0)return;let i=e.getContext(`2d`);if(!i)return;let l=Oe.flares.filter(e=>D===`all`?!0:D===`birth`?e.kind===`birth`:D===`death`?e.kind===`death`:D===`crisis`?e.kind===`crisis`:D!==`forge`||e.kind===`forge_approved`||e.kind===`forge_rejected`||e.kind===`reuse`),d=kS(c,I.current),f=I.current?getComputedStyle(I.current):null,m=t?parseFloat(f?.getPropertyValue(`--viz-read-size`)||`15`):void 0,h=(e,t)=>{if(!e.startsWith(`#`)||e.length!==7)return null;let n=parseInt(e.slice(1),16);return`rgba(${n>>16&255}, ${n>>8&255}, ${n&255}, ${t})`},_=f&&h(f.getPropertyValue(`--bg-deep`).trim(),.85)||`rgba(10, 8, 6, 0.85)`,b=f&&h(f.getPropertyValue(`--text-2`).trim(),.8)||`rgba(216, 204, 176, 0.75)`,S=f&&h(f.getPropertyValue(`--text-2`).trim(),.22)||`rgba(216, 204, 176, 0.22)`,w=f&&h(f.getPropertyValue(`--text-2`).trim(),.7)||`rgba(216, 204, 176, 0.7)`,T=f&&h(f.getPropertyValue(`--text-2`).trim(),.95)||`rgba(216, 204, 176, 0.95)`,E=f&&h(f.getPropertyValue(`--text-3`).trim(),.85)||`rgba(168, 152, 120, 0.85)`,O=f&&h(f.getPropertyValue(`--text-3`).trim(),.08)||`rgba(168, 152, 120, 0.08)`,k=f&&h(f.getPropertyValue(`--text-2`).trim(),.6)||`rgba(216, 204, 176, 0.6)`;i.clearRect(0,0,z.w,z.h);let ee=he.current,j=p!==_e.current,te=n.turn!==ge.current,ne=D!==ve.current,L=a!==ye.current,R=`${z.w}x${z.h}`,B=(A||t)&&R!==be.current,ae=ge.current;if(te||j||ne||L||B){be.current=R,ge.current=n.turn,_e.current=p,ve.current=D,ye.current=a,Kx(ee,n.cells,Ee,z.w,z.h,D);let e;e=A?0:P?3:p===`mood`?0:p===`ecology`?2:p===`forge`?8:p===`divergence`?12:5;let r=t&&e>0?ee.grid.slice():void 0;for(let t=0;t<e;t+=1)Jx(ee);if(r&&!ee.grid.some(Boolean)&&ee.grid.set(r),!P&&!A&&(te&&Xx(ae,n.turn)||L)){let e=performance.now();Se.current=e,t&&(Ce.current=[e+500/6,e+500])}xe.current=l.length?`${l[0].kind}|${l[0].x}|${l[0].y}`:null}else if(l.length>0){let e=`${l[0].kind}|${l[0].x}|${l[0].y}`;e!==xe.current&&(xe.current=e,qx(ee,l[0],z.w,z.h),P||Jx(ee))}let se=typeof document<`u`&&document.documentElement.classList.contains(`light`),ce=A?ES:Zx(se?TS.light:TS.dark,performance.now()-Se.current,500,P);if(Yx(i,ee,z.w,z.h,d,ce),A){i.save(),i.globalCompositeOperation=`destination-out`,i.fillStyle=`#000`;for(let e of n.cells){if(!e.alive)continue;let t=Ee.get(e.agentId);t&&(i.beginPath(),i.arc(t.x,t.y,e.featured?14:7,0,Math.PI*2),i.fill())}i.restore()}if(D===`death`?Vx(i,n.cells,Ee,z.w,z.h,Mx.cols,Mx.rows,E,O):D===`birth`&&Bx(i,n.cells,Ee,z.w,z.h,Mx.cols,Mx.rows),ux(i,l),p!==`ecology`&&sx(i,n.cells,Ee,d,Le,v,p===`divergence`,P?0:performance.now(),x,!N,b,_,m),p===`forge`&&g&&g.length>0&&mx(i,n.cells,Ee,g.map(e=>({department:e.department,turn:e.turn,approved:e.approved})),d,m),p===`ecology`&&hx(i,n,z.w,z.h,k,m),p===`divergence`&&gx(i,n.cells,Ee,v,P?0:performance.now(),d),M||px(i,n,{actorName:a,actorArchetype:o,startTime:s,sideColor:d,width:z.w,height:z.h,lagTurns:u,cells:n.cells,positions:Ee,previousSnapshot:r,labelBg:_,textMuted:b,deptLabels:C.deptLabels,textSize:m,timeUnitShort:F.Time}),ie){let e=Ee.get(ie.cell.agentId);e&&(i.save(),i.strokeStyle=d,i.lineWidth=2,i.globalAlpha=1,i.beginPath(),i.arc(e.x,e.y,10,0,Math.PI*2),i.stroke(),i.restore())}if(oe&&!ie&&C.crosshair){i.save(),i.strokeStyle=S,i.lineWidth=.5,i.setLineDash([3,4]),i.beginPath(),i.moveTo(0,oe.y),i.lineTo(z.w,oe.y),i.moveTo(oe.x,0),i.lineTo(oe.x,z.h),i.stroke(),i.setLineDash([]),i.restore();let e=null;for(let t of n.cells){if(!t.alive)continue;let n=Ee.get(t.agentId);if(!n)continue;let r=n.x-oe.x,i=n.y-oe.y,a=r*r+i*i;a>1600||(!e||a<e.d2)&&(e={id:t.agentId,name:t.name,dx:r,dy:i,d2:a})}e&&(i.save(),i.strokeStyle=w,i.setLineDash([2,3]),i.lineWidth=.6,i.beginPath(),i.moveTo(oe.x,oe.y),i.lineTo(oe.x+e.dx,oe.y+e.dy),i.stroke(),i.setLineDash([]),i.fillStyle=T,i.font=`bold ${m??11}px ui-monospace, monospace`,i.textAlign=`left`,i.textBaseline=`top`,i.fillText(`\u2192 ${e.name.split(` `)[0]}`,oe.x+6,oe.y+6),i.restore())}if(y&&y!==ie?.cell.agentId){let e=Ee.get(y);e&&(i.save(),i.strokeStyle=`rgba(232, 180, 74, 0.75)`,i.lineWidth=1.4,i.globalAlpha=.85,i.setLineDash([3,3]),i.beginPath(),i.arc(e.x,e.y,11,0,Math.PI*2),i.stroke(),i.setLineDash([]),i.restore())}},[Oe.tickClock,n,Ee,z.w,z.h,c,a,u,Oe.flares,p,Le,ie,v,y,P,x,oe,C,o,s,g,D,A,M,t,N,ke]);let ze=(0,L.useCallback)(e=>{if(!n)return;let t=e.currentTarget.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top;se({x:r,y:i});let a=Qx(n.cells,Ee,r,i);if(a){ae(e=>e&&e.cell.agentId===a.agentId?e:{cell:a,x:r,y:i}),fe(null),b?.(a.agentId);return}ie&&(ae(null),b?.(null));let o=Mx.cols,s=Mx.rows,c=D===`death`||D===`birth`?(()=>{let e=Math.floor(r/Math.max(1,z.w)*o),t=Math.floor(i/Math.max(1,z.h)*s);if(e<0||e>=o||t<0||t>=s)return null;for(let r of n.cells){if(D===`death`&&r.alive||D===`birth`&&(!r.alive||(r.generation??0)===0))continue;let n=Ee.get(r.agentId);if(!n)continue;let i=Ux(n,z.w,z.h,o,s);if(i.col===e&&i.row===t)return{col:e,row:t,kind:D===`death`?`death`:`birth`,nearest:r}}return null})():(()=>{let e=Hx(he.current,r,i,z.w,z.h);if(!e)return null;let t=null,a=1/0;for(let r of n.cells){if(!r.alive)continue;let n=Ee.get(r.agentId);if(!n)continue;let i=Ux(n,z.w,z.h,o,s),c=(i.col-e.col)**2+(i.row-e.row)**2;c<a&&(a=c,t=r)}return{col:e.col,row:e.row,kind:`life`,nearest:t}})();c?fe({x:r,y:i,...c}):de&&fe(null)},[n,Ee,ie,b,D,z.w,z.h,de]),Be=(0,L.useCallback)(()=>{ae(null),fe(null),se(null),b?.(null)},[b]),Ve=(0,L.useCallback)(e=>{if(!n)return;let t=e.currentTarget.getBoundingClientRect(),r=e.clientX-t.left,i=e.clientY-t.top,a=Qx(n.cells,Ee,r,i);a?(le({cell:a,x:r,y:i}),ae(null),fe(null),we.current={id:a.agentId,intensity:1}):de?.nearest&&(le({cell:de.nearest,x:r,y:i}),ae(null),fe(null))},[n,Ee,de]),He=(0,L.useRef)(null),Ue=(0,L.useCallback)(e=>{if(!n)return;let t=e.touches[0];if(!t)return;let r=e.currentTarget.getBoundingClientRect(),i=t.clientX-r.left,a=t.clientY-r.top,o=Qx(n.cells,Ee,i,a);o?He.current===o.agentId?(le({cell:o,x:i,y:a}),ae(null),He.current=null,we.current={id:o.agentId,intensity:1}):(ae({cell:o,x:i,y:a}),se({x:i,y:a}),He.current=o.agentId,b?.(o.agentId)):(ae(null),se(null),He.current=null,b?.(null))},[n,Ee,b]);(0,L.useEffect)(()=>{ce&&n&&(n.cells.find(e=>e.agentId===ce.cell.agentId)||le(null))},[ce,n]),(0,L.useEffect)(()=>{ce||(He.current=null)},[ce]);let We=(0,L.useMemo)(()=>N&&n?n.cells.filter(e=>e.alive&&Ee.has(e.agentId)):[],[N,n,Ee]),Ge=We.find(e=>e.agentId===Pe)?.agentId??We[0]?.agentId??null,Ke=(0,L.useCallback)(e=>{let t=je.current;if(!t)return;let n=Array.from(t.querySelectorAll(`[data-person]`)),r=n.indexOf(document.activeElement);if(r<0||n.length===0)return;let i=n.length-1,a=e.key===`ArrowRight`||e.key===`ArrowDown`?r===i?0:r+1:e.key===`ArrowLeft`||e.key===`ArrowUp`?r===0?i:r-1:e.key===`Home`?0:e.key===`End`?i:-1;a<0||(e.preventDefault(),n[a]?.focus())},[]),qe=(e,t)=>{if(!t)return{left:0,top:0};let{w:n,h:r}=t;return{left:Math.max(2,Math.min(e.x-n/2,z.w-n-2)),top:e.y+14+r>z.h-2?Math.max(2,e.y-14-r):e.y+14}},Je=kS(p===`mood`?Re:c,I.current),Ye={birth:`rgba(154, 205, 96, 0.95)`,death:`rgba(200, 95, 80, 0.95)`,forge:`rgba(232, 180, 74, 0.95)`,crisis:`rgba(196, 74, 30, 0.95)`},Xe={birth:`rgba(154, 205, 96, 0.55)`,death:`rgba(200, 95, 80, 0.55)`,forge:`rgba(232, 180, 74, 0.55)`,crisis:`rgba(196, 74, 30, 0.55)`},Ze=O&&O.side===l?Ye[O.kind]:n?n.morale>=.6?`rgba(106, 173, 72, 0.55)`:n.morale>=.3?`rgba(232, 180, 74, 0.55)`:`rgba(196, 74, 30, 0.65)`:`${c}33`,Qe=O&&O.side===l?`0 0 24px ${Xe[O.kind]}`:n?n.morale>=.6?`0 0 16px rgba(106, 173, 72, 0.18)`:n.morale>=.3?`0 0 16px rgba(232, 180, 74, 0.12)`:`0 0 20px rgba(196, 74, 30, 0.25)`:`none`,$e=!N&&(0,R.jsx)(bS,{snapshot:n,previousSnapshot:r,sideColor:kS(c,I.current),inFlow:t,onSelect:e=>{let t=Ee.get(e.agentId);t&&le({cell:e,x:t.x,y:t.y})}});return(0,R.jsxs)(`div`,{ref:I,"data-testid":`living-colony-grid-${A?`rest`:l}`,role:M?void 0:`region`,"aria-label":M?void 0:`${a} ${F.place} viz`,className:[Xb.region,te?Xb.narrow:``,t?Xb.vizPanel:``,A?Xb.resting:``].filter(Boolean).join(` `),children:[M?k:n&&(0,R.jsx)(jx,{snapshot:n,sideColor:c}),(0,R.jsxs)(`div`,{ref:ne,"data-testid":`living-colony-field-${A?`rest`:l}`,className:Xb.canvasWrap,style:{"--tint-color":Je,"--wrap-border":Ze,"--wrap-glow":Qe},children:[(0,R.jsx)(`canvas`,{ref:re,role:`img`,"aria-label":M?a:n?`${a} ${F.place}, turn ${n.turn}. ${n.cells.filter(e=>e.alive).length} alive, morale ${Math.round(n.morale*100)}%${OS(n)}. ${n.births} births, ${n.deaths} deaths this turn. Click a ${F.person} glyph for drilldown.`:`${a} ${F.place} — waiting for first turn.`,onMouseMove:ze,onMouseLeave:Be,onClick:Ve,onTouchStart:Ue,className:Xb.canvas,style:{"--canvas-cursor":ie?`pointer`:`default`}}),!t&&(0,R.jsx)(`div`,{"aria-hidden":`true`,className:Xb.revealCover,style:{"--reveal-opacity":pe?`0`:`1`}}),N&&n&&(0,R.jsxs)(`div`,{ref:je,className:Xb.people,onKeyDown:Ke,children:[(0,R.jsx)(`svg`,{className:Xb.nameLines,width:z.w,height:z.h,"aria-hidden":`true`,focusable:`false`,children:We.map(e=>{let t=Ee.get(e.agentId),n=Ie.get(e.agentId),r=Me.get(e.agentId);if(!t||!n||!r)return null;let i=wS(n,r,t);if(i.distance<DS)return null;let a=13/i.distance;return(0,R.jsx)(`line`,{x1:t.x+(i.x-t.x)*a,y1:t.y+(i.y-t.y)*a,x2:i.x,y2:i.y},e.agentId)})}),We.map(e=>{let t=Ee.get(e.agentId);if(!t)return null;let n=Ie.get(e.agentId),r=Me.get(e.agentId),i=n??qe(t,r),a=ie?.cell.agentId===e.agentId||ce?.cell.agentId===e.agentId;return(0,R.jsx)(`button`,{type:`button`,className:Xb.person,"data-person":e.agentId,"data-featured":e.featured?`true`:`false`,"data-standing":n?`true`:`false`,"data-measured":r?`true`:`false`,"data-active":a?`true`:void 0,"data-ring-x":t.x,"data-ring-y":t.y,tabIndex:e.agentId===Ge?0:-1,translate:`no`,style:{"--name-left":`${i.left}px`,"--name-top":`${i.top}px`},onClick:()=>{le({cell:e,x:t.x,y:t.y}),fe(null)},onFocus:()=>{Fe(e.agentId),ae({cell:e,x:t.x,y:t.y})},onBlur:()=>ae(t=>t?.cell.agentId===e.agentId?null:t),onMouseEnter:()=>ae({cell:e,x:t.x,y:t.y}),onMouseLeave:()=>ae(t=>t?.cell.agentId===e.agentId?null:t),children:e.name},e.agentId)})]}),!N&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>ue(e=>!e),"aria-label":V?`Close roster`:`Open roster`,title:V?`Close roster`:`Open roster`,className:Xb.cornerBtn,style:{"--right-offset":T?`36px`:`8px`,"--btn-color":V?`var(--amber)`:`var(--text-3)`,"--btn-border":V?`var(--amber)`:`var(--border)`},children:`☰`}),T&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>T(l),"aria-label":j?`Restore split view`:`Focus this panel`,title:j?`Restore split view`:`Focus this panel`,className:`${Xb.cornerBtn} ${Xb.focusBtn}`,style:{"--btn-color":j?`var(--amber)`:`var(--text-3)`,"--btn-border":j?`var(--amber)`:`var(--border)`},children:j?`⤡`:`⤢`}),!t&&$e,!N&&(0,R.jsx)(yS,{open:V,cells:n?.cells??[],actorName:a,sideColor:kS(c,I.current),searchQuery:x,hoveredId:ie?.cell.agentId??y??null,onHover:e=>{if(e){let t=n?.cells.find(t=>t.agentId===e),r=t?Ee.get(e):null;if(t&&r){ae({cell:t,x:r.x,y:r.y}),b?.(e);return}}ae(null),b?.(null)},onSelect:e=>{let t=Ee.get(e.agentId);t&&le({cell:e,x:t.x,y:t.y})},onClose:()=>ue(!1)}),p===`divergence`&&n&&(v?.size??0)===0&&(0,R.jsx)(`div`,{className:Xb.divergenceEmpty,children:(0,R.jsx)(`div`,{className:Xb.divergenceEmptyMsg,children:`Both timelines identical this turn — no divergence yet`})}),!N&&de&&!ie&&!ce&&(()=>{let e=Math.min(Math.max(8,de.x+12),Math.max(8,z.w-220-8)),t=Math.max(8,de.y-84),n=de.kind===`birth`?`+ BIRTH MARKER`:de.kind===`death`?`× DEATH MARKER`:`◼ CONWAY CELL`,r=de.kind===`birth`?`rgba(154, 205, 96, 0.95)`:de.kind===`death`?`rgba(168, 152, 120, 0.95)`:c;return(0,R.jsxs)(`div`,{className:Xb.tileTooltip,style:{"--tt-left":`${e}px`,"--tt-top":`${t}px`,"--kind-color":r},children:[(0,R.jsx)(`div`,{className:Xb.tileKindLabel,children:n}),(0,R.jsxs)(`div`,{className:Xb.tileCoords,children:[`tile (`,de.col,`, `,de.row,`)`]}),de.nearest?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{className:Xb.tileNearestName,children:de.nearest.name}),(0,R.jsxs)(`div`,{className:Xb.tileNearestRole,children:[de.nearest.role,` · `,de.nearest.department.toUpperCase()]}),de.kind===`death`?(0,R.jsxs)(`div`,{className:Xb.tileNearestDeath,children:[`deceased · mood at death: `,de.nearest.mood]}):de.kind===`birth`?(0,R.jsxs)(`div`,{className:Xb.tileNearestBirth,children:[`native-born · generation `,de.nearest.generation??0]}):(0,R.jsxs)(`div`,{className:Xb.tileNearestPattern,children:[`pattern seeded by nearest colonist's mood: `,de.nearest.mood]})]}):(0,R.jsx)(`div`,{className:Xb.tileAmbient,children:`ambient CA cell`}),de.kind===`life`&&(()=>{let e=he.current,t=e.cols,n=e.rows,r=e.grid[de.row*t+de.col]??0,i=0;for(let r=-1;r<=1;r++)for(let a=-1;a<=1;a++){if(r===0&&a===0)continue;let o=de.row+r,s=de.col+a;o<0||o>=n||s<0||s>=t||e.grid[o*t+s]>=1&&i++}return(0,R.jsxs)(`div`,{className:Xb.tileNearestPattern,children:[`age `,r,` · `,i,` neighbors alive`]})})()]})})(),!N&&ie&&!ce&&(()=>{let e=Math.min(Math.max(8,ie.x+12),Math.max(8,z.w-200-8)),t=Math.min(Math.max(8,ie.y-80-8),Math.max(8,z.h-80-8));return(0,R.jsxs)(`div`,{className:Xb.hoverTooltip,style:{"--tt-left":`${e}px`,"--tt-top":`${t}px`,"--side-color":c},children:[(0,R.jsxs)(`div`,{className:Xb.hoverHeader,children:[ie.cell.name,ie.cell.featured&&(0,R.jsx)(`span`,{className:Xb.hoverFeaturedPill,children:`FEATURED`})]}),(0,R.jsxs)(`div`,{className:Xb.hoverRole,children:[ie.cell.department.toUpperCase(),` · `,ie.cell.role,typeof ie.cell.age==`number`?` · age ${ie.cell.age}`:``]}),(0,R.jsxs)(`div`,{className:Xb.hoverMood,children:[`mood: `,(0,R.jsx)(`span`,{className:Xb.hoverMoodValue,children:ie.cell.mood}),typeof ie.cell.psychScore==`number`?` · psych ${Math.round(ie.cell.psychScore*100)}%`:``]}),i&&i.length>=2&&(()=>{let e=[];for(let t of i){let n=t.cells.find(e=>e.agentId===ie.cell.agentId);n&&typeof n.psychScore==`number`&&e.push(Math.max(0,Math.min(1,n.psychScore)))}if(e.length<2)return null;let t=136/Math.max(1,e.length-1),n=e.map((e,n)=>{let r=2+n*t,i=2+(1-e)*16;return`${n===0?`M`:`L`}${r.toFixed(1)},${i.toFixed(1)}`}).join(` `);return(0,R.jsxs)(`div`,{className:Xb.psychBlock,children:[(0,R.jsx)(`div`,{className:Xb.psychLabel,children:`PSYCH TRAJECTORY`}),(0,R.jsxs)(`svg`,{viewBox:`0 0 140 20`,preserveAspectRatio:`none`,width:140,height:20,role:`img`,"aria-label":`Psychological trajectory across ${e.length} turns`,className:Xb.psychSvg,children:[(0,R.jsx)(`line`,{x1:2,x2:138,y1:10,y2:10,stroke:`var(--border)`,strokeWidth:.4,strokeDasharray:`2 2`}),(0,R.jsx)(`path`,{d:n,fill:`none`,stroke:c,strokeWidth:1}),(0,R.jsx)(`circle`,{cx:2+(e.length-1)*t,cy:2+(1-e[e.length-1])*16,r:1.6,fill:c})]})]})})(),(0,R.jsx)(`div`,{className:Xb.hoverHint,children:`click for drilldown`})]})})(),(0,R.jsx)(oS,{payload:ce,keepHeaderInView:t,containerW:z.w,containerH:z.h,sideColor:kS(c,I.current),hexacoById:m,snapshots:i,onClose:()=>le(null),onOpenChat:E})]}),t&&$e]})}var jS=e=>e.slice(0,120);function MS(e,t,n){let r=e.presets??[],i=((r.find(e=>e.id==="default")??r[0])?.personnel??[]).map(e=>({name:e.name,department:e.department,role:e.role,specialization:e.specialization,age:e.age,featured:e.featured}));return n?i.slice(0,Math.max(0,t)).map(e=>({...e,name:typeof e.name==`string`?jS(e.name):e.name,role:typeof e.role==`string`?jS(e.role):e.role,specialization:typeof e.specialization==`string`?jS(e.specialization):e.specialization})):i}function NS(e,t){let n=e.map((e,t)=>({agentId:`key-${t}`,name:e.name,department:e.department,role:e.role,rank:`senior`,alive:!0,marsborn:!1,psychScore:.8,age:e.age,generation:0,childrenIds:[],featured:e.featured===!0,mood:`neutral`,shortTermMemory:[]}));return{turn:0,time:t,cells:n,population:n.length,morale:0,births:0,deaths:0}}var PS={panel:`_panel_egei5_9`,grid:`_grid_egei5_19`,header:`_header_egei5_26`,turn:`_turn_egei5_35`,figures:`_figures_egei5_46`,frame:`_frame_egei5_54`,cells:`_cells_egei5_65`,empty:`_empty_egei5_70`,caption:`_caption_egei5_80`,key:`_key_egei5_91`,keyBox:`_keyBox_egei5_109`,keyItem:`_keyItem_egei5_122`,keyGlyph:`_keyGlyph_egei5_128`,shape:`_shape_egei5_134`,loadingShapeTone:`_loadingShapeTone_egei5_1`};function FS({figures:e,loading:t}){return(0,R.jsxs)(`p`,{className:PS.header,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:PS.turn,"data-testid":`colony-turn`,children:Ue}),e!==void 0&&(t?(0,R.jsx)(`span`,{className:PS.figures,children:(0,R.jsx)(`span`,{className:PS.shape,"data-shape":!0,children:e})}):(0,R.jsx)(`span`,{className:PS.figures,"data-testid":`colony-figures`,children:e}))]})}function IS(){let e={color:`var(--vis)`};return(0,R.jsx)(`div`,{className:PS.keyBox,children:(0,R.jsxs)(`ul`,{className:PS.key,"data-testid":`colony-key`,"data-row":`colony key`,children:[(0,R.jsxs)(`li`,{className:PS.keyItem,children:[(0,R.jsx)(`svg`,{className:PS.keyGlyph,style:e,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`rect`,{x:`2`,y:`2`,width:`12`,height:`12`,fill:`currentColor`})}),(0,R.jsx)(`span`,{children:Je.department})]}),(0,R.jsxs)(`li`,{className:PS.keyItem,children:[(0,R.jsx)(`svg`,{className:PS.keyGlyph,style:e,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:`3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`})}),(0,R.jsx)(`span`,{children:Je.person})]}),(0,R.jsxs)(`li`,{className:PS.keyItem,children:[(0,R.jsxs)(`svg`,{className:PS.keyGlyph,style:e,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:[(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:`3`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`}),(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1`})]}),(0,R.jsx)(`span`,{children:Je.featured})]})]})})}function LS({size:e=2}){let t=fF(),n=mF(),r=ub(),i=Jv(r,qv(Kv()).overrides),a=n&&(i===`own`||typeof r.adminConfig.hostedDemo==`boolean`),o=Zv(r,t,i),s=i===`host`,c=(0,L.useMemo)(()=>a?MS(t,o,s):[],[a,t,o,s]),l=(0,L.useMemo)(()=>NS(c,t.setup.defaultStartTime),[c,t.setup.defaultStartTime]);return a?c.length===0?(0,R.jsxs)(`section`,{className:PS.panel,"data-testid":`shared-colony`,children:[(0,R.jsxs)(`div`,{className:PS.grid,children:[(0,R.jsx)(FS,{}),(0,R.jsx)(`div`,{className:PS.frame,"data-testid":`colony-field`,children:(0,R.jsx)(`p`,{className:PS.empty,"data-text":`body`,"data-testid":`colony-empty`,children:qe})})]}),(0,R.jsx)(IS,{})]}):(0,R.jsxs)(`section`,{className:PS.panel,"data-testid":`shared-colony`,children:[(0,R.jsx)(`div`,{className:PS.grid,children:(0,R.jsx)(AS,{snapshot:l,actorName:Ke({population:o,keyPeople:c.length}),actorArchetype:``,startTime:t.setup.defaultStartTime,side:`a`,sideColor:`var(--vis)`,mode:`living`,initialPopulation:o,header:(0,R.jsx)(FS,{figures:We({keyPeople:c.length})}),nameLabels:`featured`,resting:!0})}),(0,R.jsx)(`p`,{className:PS.caption,"data-testid":`colony-caption`,children:Ge({leaders:e,population:o,keyPeople:c.length})}),(0,R.jsx)(IS,{})]}):(0,R.jsxs)(`section`,{className:PS.panel,"data-testid":`shared-colony`,"data-loading":!0,children:[(0,R.jsxs)(`div`,{className:PS.grid,children:[(0,R.jsx)(FS,{figures:We({keyPeople:5}),loading:!0}),(0,R.jsx)(`div`,{className:`${PS.frame} ${PS.cells}`,"data-testid":`colony-field`})]}),(0,R.jsx)(`p`,{className:PS.caption,"aria-hidden":`true`,children:(0,R.jsx)(`span`,{className:PS.shape,"data-shape":!0,children:Ge({leaders:e,population:30,keyPeople:5})})}),(0,R.jsx)(IS,{})]})}var G={band:`_band_1o5i8_1`,place:`_place_1o5i8_5`,bar:`_bar_1o5i8_11`,row:`_row_1o5i8_29`,key:`_key_1o5i8_37`,first:`_first_1o5i8_79`,second:`_second_1o5i8_88`,words:`_words_1o5i8_94`,runLine:`_runLine_1o5i8_100`,marks:`_marks_1o5i8_112`,turn:`_turn_1o5i8_119`,link:`_link_1o5i8_129`,mark:`_mark_1o5i8_112`,ruler:`_ruler_1o5i8_150`,tick:`_tick_1o5i8_158`,figure:`_figure_1o5i8_167`,end:`_end_1o5i8_178`,notice:`_notice_1o5i8_186`,sentence:`_sentence_1o5i8_194`,lines:`_lines_1o5i8_202`,over:`_over_1o5i8_215`,problem:`_problem_1o5i8_229`,problemMark:`_problemMark_1o5i8_239`,side:`_side_1o5i8_244`,beside:`_beside_1o5i8_245`,problemWords:`_problemWords_1o5i8_254`,limit:`_limit_1o5i8_259`,resetRow:`_resetRow_1o5i8_267`,clock:`_clock_1o5i8_280`,limitKeys:`_limitKeys_1o5i8_285`,replay:`_replay_1o5i8_293`,replayFirst:`_replayFirst_1o5i8_301`,textLink:`_textLink_1o5i8_307`,tryAgain:`_tryAgain_1o5i8_321`,lastRun:`_lastRun_1o5i8_344`,clearDraft:`_clearDraft_1o5i8_400`,held:`_held_1o5i8_405`,heldWords:`_heldWords_1o5i8_412`,heldKeys:`_heldKeys_1o5i8_420`},RS={offline:Nt,busy:Pt,slots:Ft,other:gt},zS=20,BS=6;function VS(){let e=Sy(`(min-width: 600px)`),t=Sy(`(min-width: 768px)`),n=Sy(`(min-width: 1100px)`);return Sy(`(min-width: 1440px)`)?`wide`:n?`desktop`:t?`tablet`:e?`narrow`:`phone`}function HS({turns:e,end:t,outline:n}){let r=Array.from({length:e},(e,t)=>t),i=[];for(let t=10;t<=e;t+=10)i.push(t);return(0,R.jsxs)(`div`,{className:G.runLine,"data-testid":`run-line`,"data-row":`run line`,"data-outline":n?`true`:`false`,"aria-hidden":`true`,children:[e<=zS?(0,R.jsx)(`span`,{className:G.marks,children:r.map(e=>(0,R.jsxs)(`span`,{className:G.turn,children:[e>0&&(0,R.jsx)(`span`,{className:G.link}),(0,R.jsx)(`span`,{className:G.mark,"data-run-mark":!0})]},e))}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:G.figure,"data-testid":`run-first-turn`,children:`1`}),(0,R.jsx)(`span`,{className:G.ruler,"data-testid":`run-ruler`,children:i.map(t=>(0,R.jsx)(`span`,{className:G.tick,"data-run-tick":!0,style:{left:`${(t-1)/(e-1)*100}%`}},t))}),(0,R.jsx)(`span`,{className:G.figure,"data-testid":`run-last-turn`,children:e})]}),(0,R.jsx)(`span`,{className:G.end,"data-testid":`run-end`,children:t})]})}var US=`start-held-words`;function WS({state:e,launch:t,scenarioName:n,writing:r,onPress:i}){if(e===`held`)return(0,R.jsx)(`button`,{type:`button`,className:G.key,"data-testid":`start-key`,"aria-disabled":`true`,"aria-describedby":US,children:(0,R.jsx)(`span`,{className:G.words,"data-testid":`start-words`,children:at})});if(e===`ready`&&t){let e={who:t.payer,size:t.size,turns:t.turns,minutes:cy(t.turns)};return(0,R.jsxs)(`button`,{type:`button`,className:G.key,"data-testid":`start-key`,onClick:i,children:[(0,R.jsx)(`span`,{className:`sr-only`,children:ut({...e,scenario:n})}),(0,R.jsx)(`span`,{className:G.first,"data-testid":`start-first`,"data-read-exception":`primary-key-label`,"aria-hidden":`true`,children:at}),(0,R.jsx)(`span`,{className:G.second,"data-testid":`start-second`,"data-read-exception":`primary-key-label`,"aria-hidden":`true`,children:lt(e)})]})}let a=e===`offline`?mt:e===`writing`?pt(r):e===`starting`?ft:e===`unloaded`?at:dt;return(0,R.jsx)(`button`,{type:`button`,className:G.key,"data-testid":`start-key`,"aria-disabled":`true`,children:(0,R.jsx)(`span`,{className:G.words,"data-testid":`start-words`,children:a})})}function GS({time:e}){let t=xy(e),n=`${String(e.hour).padStart(2,`0`)}:${String(e.minute).padStart(2,`0`)}`;return(0,R.jsxs)(`svg`,{className:G.clock,style:{color:`var(--text-1)`},width:`40`,height:`40`,viewBox:`0 0 40 40`,fill:`none`,"aria-hidden":`true`,focusable:`false`,"data-glyph":`clock`,"data-testid":`reset-clock`,"data-time":n,children:[(0,R.jsx)(`circle`,{cx:`20`,cy:`20`,r:`18`,stroke:`currentColor`,strokeWidth:`2`}),[0,90,180,270].map(e=>(0,R.jsx)(`line`,{x1:`20`,y1:`4`,x2:`20`,y2:`7`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,transform:`rotate(${e} 20 20)`},e)),(0,R.jsx)(`line`,{"data-hand":`hour`,x1:`20`,y1:`20`,x2:`20`,y2:`11`,stroke:`currentColor`,strokeWidth:`3`,strokeLinecap:`round`,transform:`rotate(${t.hour} 20 20)`}),(0,R.jsx)(`line`,{"data-hand":`minute`,x1:`20`,y1:`20`,x2:`20`,y2:`7`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,transform:`rotate(${t.minute} 20 20)`}),(0,R.jsx)(`circle`,{cx:`20`,cy:`20`,r:`2`,fill:`currentColor`})]})}var KS=e=>q_(window.location.href,e);function qS({choice:e}){if(e.kind===`own`)return(0,R.jsx)(`a`,{className:`${G.key} ${G.replay}`,"data-testid":`replay-key`,href:KS(e.row.id),children:(0,R.jsx)(`span`,{className:G.replayFirst,"data-testid":`replay-first`,"data-read-exception":`primary-key-label`,children:Ot})});let t={scenario:e.row.scenarioName,turns:e.row.turnCount},n=At(t);return(0,R.jsxs)(`a`,{className:`${G.key} ${G.replay}`,"data-testid":`replay-key`,href:KS(e.row.id),children:[(0,R.jsx)(`span`,{className:`sr-only`,children:jt(t)}),(0,R.jsx)(`span`,{className:G.replayFirst,"data-testid":`replay-first`,"data-read-exception":`primary-key-label`,"aria-hidden":`true`,children:kt}),n&&(0,R.jsx)(`span`,{className:G.second,"data-testid":`replay-second`,"data-read-exception":`primary-key-label`,"aria-hidden":`true`,children:n})]})}function JS({who:e,launch:t,facts:n,keyProvider:r}){let i=(e,t,n=!1)=>(0,R.jsx)(`p`,{className:G.sentence,"data-text":`body`,"data-testid":e,role:n?`status`:void 0,children:t});if(e===`host`){let{rateLimit:e,sessions:t}=n,r=e.status===`ready`?e.answer:void 0;return(0,R.jsxs)(`div`,{className:G.notice,"data-testid":`start-notice`,children:[i(`notice-pays`,vt),r&&i(`notice-count`,bt({remaining:r.remaining,limit:r.limit,resetTime:yy(r.resetAt)||void 0}),!0),e.status===`error`&&i(`notice-count`,`Free runs left today: unavailable.`,!0),i(`notice-after`,xt(t.rows.length>0))]})}let a=t.size>2?Tt({who:e,usd:Iv(t.size).toFixed(2),provider:t.provider?ly(t.provider):void 0,models:t.models?uy(t.models):void 0}):null;return(0,R.jsxs)(`div`,{className:G.notice,"data-testid":`start-notice`,children:[i(`notice-pays`,e===`own`?Ct(r):wt),a&&i(`start-estimate`,a)]})}function YS(e){for(let t=e.parentElement;t;t=t.parentElement){let e=getComputedStyle(t).overflowY;if(e===`auto`||e===`scroll`)return t}return null}function XS(e,t){let n=(0,L.useRef)(null),r=(0,L.useRef)(null),i=(0,L.useRef)(null),[a,o]=(0,L.useState)(!0),s=(0,L.useRef)(()=>{});return(0,L.useLayoutEffect)(()=>{let e=n.current,t=r.current;if(!e||!t)return;let a=YS(e),c=e.closest(`[data-testid="run-first-screen"]`),l=0,u=null,d=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>p()),f=()=>{l=0;let n=a?a.getBoundingClientRect():{top:0,bottom:window.innerHeight},r=n.bottom,s=document.getElementById(`pcc`);s&&s!==u&&(u=s,d?.observe(s));let c=s?s.getBoundingClientRect():null,f=c&&c.height>0?Math.max(0,Math.round(r-c.top)):0,p=f>(r-n.top)/2?0:f;e.style.setProperty(`--start-lift`,`${p}px`);let m=e.offsetHeight;o(t.getBoundingClientRect().top+m>r-p+1);let h=i.current&&getComputedStyle(i.current).position===`absolute`?i.current.offsetHeight:0;a&&(a.style.scrollPaddingBottom=`${m+h+p}px`)};function p(){l||=requestAnimationFrame(f)}s.current=f,f(),a?.addEventListener(`scroll`,p,{passive:!0}),window.addEventListener(`resize`,p),d?.observe(e),c&&d?.observe(c),a&&d?.observe(a);let m=typeof MutationObserver>`u`?null:new MutationObserver(()=>p());return m?.observe(document.body,{childList:!0}),()=>{l&&cancelAnimationFrame(l),a?.removeEventListener(`scroll`,p),window.removeEventListener(`resize`,p),d?.disconnect(),m?.disconnect(),a&&(a.style.scrollPaddingBottom=``),s.current=()=>{}}},[e,t]),(0,L.useLayoutEffect)(()=>{s.current()},[a]),{bar:n,place:r,lines:i,held:a}}function ZS({size:e,onStart:t,onBusy:n,draft:r=null}){let i=fF(),a=mF(),{failed:o}=gF(),s=ub(),c=Gb(),l=VS(),[u,d]=(0,L.useState)(null),[f,p]=(0,L.useState)(0),[m,h]=(0,L.useState)(null),[g,_]=(0,L.useState)(!1),v=(0,L.useRef)(!1),y=qv(Kv()),b=Jv(s,y.overrides),x=b===`own`||s.adminConfig.status===`ready`,S=a&&x?sy(s,i,y,e,b):null,{rateLimit:C}=s,w=b===`host`&&Xy(s),{bar:T,place:E,lines:D,held:O}=XS(l,u===null&&c&&S!==null&&w),k=u??(c?S?b===`host`&&C.status===`loading`?`waiting`:w?`limit`:r?`held`:`ready`:o&&!a?`unloaded`:`waiting`:`offline`);(0,L.useEffect)(()=>{u===null&&(v.current=!1)},[u]);let ee=async()=>{if(v.current||k!==`ready`||!S)return;v.current=!0,h(null);let r={failure:null},a=C.status===`ready`?C.answer?.resetAt:void 0;try{if(n?.(!0),b===`host`){d(`checking`);let e=await C.refresh();if(e.status===`ready`&&(a=e.answer?.resetAt),e.status===`ready`&&e.answer?.remaining===0){d(null),n?.(!1);return}}ay(i).length<e?(p(e),d(`writing`)):d(`starting`),await t(e,{body:S.body,onStage:(t,n)=>{t===`writing`&&p(n??e),d(t)},onFailure:e=>{r.failure=e}})}catch{r.failure={networkError:!0}}if(r.failure){let{kind:e}=hy({...r.failure,online:navigator.onLine});if(e===`limit`&&b===`host`){let e=r.failure.body?.resetAt;s.markLimitMet(typeof e==`number`&&Number.isInteger(e)&&e>0?e:a),C.refresh()}else h(e===`limit`?`other`:e);d(null),n?.(!1)}},{sessions:A}=s,j=A.status===`ready`?vy(A.rows):{kind:`neither`};if(k===`limit`){let e=C.status===`ready`?C.answer?.resetAt:void 0,t=e===void 0?void 0:yy(e)||void 0,n=e!==void 0&&t?by(e):null,r=Et(t),i=()=>{g||(_(!0),A.refresh().finally(()=>_(!1)))},a=`${A_(window.location.href,`settings`)}#key-openai`;return(0,R.jsxs)(`div`,{className:G.band,"data-testid":`start-band`,"data-state":k,"data-layout":l,children:[(0,R.jsxs)(`div`,{className:G.limit,"data-testid":`at-limit`,children:[(0,R.jsxs)(`div`,{className:G.resetRow,children:[n&&(0,R.jsx)(GS,{time:n}),(0,R.jsx)(`p`,{className:G.sentence,"data-text":`body`,"data-testid":`at-limit-reset`,role:`status`,children:r})]}),(0,R.jsx)(`p`,{className:G.sentence,"data-text":`body`,"data-testid":`at-limit-after`,children:Dt(A.status===`ready`&&A.rows.length>0)})]}),(0,R.jsx)(`span`,{ref:E,className:G.place,"aria-hidden":`true`}),(0,R.jsxs)(`div`,{ref:T,className:G.bar,"data-testid":`start-bar`,"data-stuck":O?`true`:`false`,children:[O&&(0,R.jsx)(`div`,{ref:D,className:`${G.lines} ${G.over}`,"data-testid":`start-bar-lines`,children:(0,R.jsx)(`p`,{children:r})}),(0,R.jsxs)(`div`,{className:G.limitKeys,children:[A.status===`error`?(0,R.jsxs)(`div`,{className:G.problem,"data-testid":`sessions-failed`,children:[(0,R.jsx)(Oy,{className:G.problemMark}),(0,R.jsx)(`span`,{className:G.problemWords,role:`status`,children:It}),(0,R.jsx)(`button`,{type:`button`,className:G.tryAgain,onClick:i,"aria-disabled":g?`true`:void 0,children:g?Ae:Lt})]}):j.kind!==`neither`&&(0,R.jsx)(qS,{choice:j}),(0,R.jsx)(`a`,{className:G.textLink,"data-testid":`add-key-link`,href:a,children:Mt})]})]})]})}let M=k===`waiting`||k===`unloaded`||k===`checking`||k===`writing`||k===`starting`||k===`held`,N=(0,R.jsx)(HS,{turns:S?S.turns:BS,end:e>2?_t.report:_t.verdict,outline:M}),te=b===`own`?dy(y):void 0,P=S?b===`host`?vt:b===`own`?St(te):wt:null,F=S?(0,R.jsx)(JS,{who:b,launch:S,facts:s,keyProvider:te}):null,I=null;if(k===`offline`)I=(0,R.jsxs)(`p`,{className:G.problem,"data-testid":`start-offline`,"aria-live":`polite`,children:[(0,R.jsx)(Oy,{className:G.problemMark}),(0,R.jsx)(`span`,{children:ht})]});else if(k===`held`&&r){let e=r;I=(0,R.jsxs)(`div`,{className:G.held,"data-testid":`start-held`,children:[(0,R.jsx)(`p`,{className:G.heldWords,id:US,children:an(i.labels.name)}),(0,R.jsxs)(`div`,{className:G.heldKeys,children:[(0,R.jsx)(`a`,{className:G.textLink,href:`#quickstart-seed-field`,onClick:t=>{t.preventDefault(),e.onGo()},children:on}),(0,R.jsx)(`button`,{type:`button`,className:G.clearDraft,onClick:e.onClear,children:sn})]})]})}else m&&k===`ready`&&(I=(0,R.jsxs)(`p`,{className:G.problem,"data-testid":`start-failure`,role:`alert`,children:[m===`offline`?(0,R.jsx)(Oy,{className:G.problemMark}):(0,R.jsx)(ky,{className:G.problemMark}),(0,R.jsx)(`span`,{children:RS[m]})]}));let ne=k===`ready`&&b===`host`&&j.kind===`own`?(0,R.jsx)(`p`,{className:G.lastRun,children:(0,R.jsx)(`a`,{className:G.textLink,"data-testid":`last-run-link`,href:KS(j.row.id),children:Ot})}):null,re=O&&P&&!I?(0,R.jsxs)(`div`,{ref:D,className:l===`phone`||l===`narrow`?`${G.lines} ${G.over}`:G.lines,"data-testid":`start-bar-lines`,children:[(0,R.jsx)(`p`,{children:P}),(0,R.jsx)(`p`,{children:yt})]}):null,z=l===`narrow`||l===`desktop`||l===`wide`,B=l===`desktop`||l===`wide`,ie=l===`phone`||l===`narrow`;return(0,R.jsxs)(`div`,{className:G.band,"data-testid":`start-band`,"data-state":k,"data-layout":l,children:[!B&&F,!z&&N,(0,R.jsx)(`span`,{ref:E,className:G.place,"aria-hidden":`true`}),(0,R.jsxs)(`div`,{ref:T,className:G.bar,"data-testid":`start-bar`,"data-stuck":O?`true`:`false`,children:[ie&&re,I,(0,R.jsxs)(`div`,{className:G.row,"data-row":`start row`,children:[(0,R.jsx)(WS,{state:k,launch:S,scenarioName:i.labels.name,writing:f,onPress:()=>{ee()}}),l===`narrow`&&N,l===`desktop`&&(0,R.jsxs)(`div`,{className:G.beside,children:[N,re]}),l===`wide`&&N,(l===`tablet`||l===`wide`)&&(0,R.jsx)(`div`,{className:G.side,children:re})]})]}),B&&F,ne]})}var QS=()=>typeof window>`u`?2:Fb(window.location.search);function $S(){let[e,t]=(0,L.useState)(QS),n=(0,L.useCallback)(e=>{let n=Pb(Math.round(e),0,Mb);t(n);try{let e=new URL(window.location.href);e.search=Ib(e.search,n),window.history.replaceState(window.history.state,``,e.toString())}catch{}},[]);return(0,L.useEffect)(()=>{let e=()=>t(QS());return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),{size:e,setSize:n}}var eC={screen:`_screen_1m0xd_1`,writeYourOwn:`_writeYourOwn_1m0xd_11`,heading:`_heading_1m0xd_20`},tC=200;function nC({onStart:e,onSeedReady:t}){let n=ub(),r=fF(),i=mF(),{size:a,setSize:o}=$S(),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(Rv),d=(0,L.useRef)(()=>void 0),f=(0,L.useCallback)(e=>{d.current=e},[]),p=qv(Kv()),m=Jv(n,p.overrides),h=Lb({payer:m,adminConfig:n.adminConfig.status,rateLimit:n.rateLimit.status})===`pair`?2:a,g=m===`own`||n.adminConfig.status!==`loading`;Wb(i&&g?Yv(n,r,p,m):null);let _=n.rateLimit.status===`ready`?n.rateLimit.answer?.resetAt:void 0,v=m===`host`&&Xy(n)?{resetTime:_===void 0?void 0:yy(_)||void 0}:null,y=l.trim().length>=tC?{onGo:()=>d.current(),onClear:()=>u(``)}:null;return(0,R.jsxs)(`div`,{className:eC.screen,"data-testid":`run-first-screen`,children:[(0,R.jsx)(Yb,{size:h}),(0,R.jsx)(LS,{size:h}),(0,R.jsx)(Bb,{size:a,onSize:o,locked:s}),(0,R.jsx)(py,{}),(0,R.jsx)(Yy,{size:h}),(0,R.jsx)(my,{}),(0,R.jsx)(ZS,{size:h,onStart:e,onBusy:c,draft:y}),(0,R.jsx)(vb,{locked:s}),(0,R.jsxs)(`section`,{className:eC.writeYourOwn,"data-testid":`write-your-own`,"aria-labelledby":`write-your-own-heading`,children:[(0,R.jsx)(`h2`,{className:eC.heading,id:`write-your-own-heading`,"data-text":`heading`,children:nn}),(0,R.jsx)(zv,{variant:`pasteOnly`,locked:s,payer:m,atLimit:v,onSeedReady:t,seedText:l,onSeedTextChange:u,registerGoToDraft:f})]})]})}function rC({onStart:e,onSeedReady:t,children:n}){return(0,R.jsxs)(lb,{children:[(0,R.jsx)(nC,{onStart:e,onSeedReady:t}),n,(0,R.jsx)(jb,{})]})}var iC={card:`_card_14dqa_7`,statusPending:`_statusPending_14dqa_18`,statusActive:`_statusActive_14dqa_22`,statusDone:`_statusDone_14dqa_27`,header:`_header_14dqa_31`,marker:`_marker_14dqa_60`,pulseDot:`_pulseDot_14dqa_1`,label:`_label_14dqa_93`,duration:`_duration_14dqa_100`,count:`_count_14dqa_121`,chevron:`_chevron_14dqa_137`,chevronOpen:`_chevronOpen_14dqa_148`,actorChips:`_actorChips_14dqa_164`,actorChip:`_actorChip_14dqa_164`,actorChipName:`_actorChipName_14dqa_190`,actorChipState:`_actorChipState_14dqa_194`,actor_running:`_actor_running_14dqa_203`,actor_complete:`_actor_complete_14dqa_212`,actor_error:`_actor_error_14dqa_221`,actor_aborted:`_actor_aborted_14dqa_230`,body:`_body_14dqa_241`,line:`_line_14dqa_266`,lineTs:`_lineTs_14dqa_283`,lineGlyph:`_lineGlyph_14dqa_290`,lineTag:`_lineTag_14dqa_296`,lineActor:`_lineActor_14dqa_309`,lineBody:`_lineBody_14dqa_324`,tonePending:`_tonePending_14dqa_332`,toneInfo:`_toneInfo_14dqa_336`,toneActive:`_toneActive_14dqa_345`,toneDone:`_toneDone_14dqa_358`,toneWarn:`_toneWarn_14dqa_367`,toneError:`_toneError_14dqa_380`},aC={running:`RUNNING`,complete:`COMPLETE`,error:`ERROR`,aborted:`ABORTED`};function oC({stageId:e,label:t,status:n,logLines:r,duration:i,actors:a}){let[o,s]=(0,L.useState)(n!==`pending`),c=(0,L.useRef)(null),l=(0,L.useRef)(!0);(0,L.useEffect)(()=>{(n===`active`||n===`done`)&&s(e=>e||!0)},[n]);let u=()=>{let e=c.current;e&&(l.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)};(0,L.useEffect)(()=>{if(!l.current)return;let e=c.current;e&&(e.scrollTop=e.scrollHeight)},[r.length]);let d=n===`done`?`✓`:n===`active`?`●`:`○`,f=n===`done`?iC.statusDone:n===`active`?iC.statusActive:iC.statusPending,p=e===`running`,m=r.length;return(0,R.jsxs)(`div`,{className:`${iC.card} ${f}`,"data-stage":e,"data-status":n,children:[(0,R.jsxs)(`button`,{type:`button`,className:iC.header,"aria-expanded":o,"aria-controls":`stage-${e}-body`,onClick:()=>s(e=>!e),children:[(0,R.jsx)(`span`,{className:iC.marker,"aria-hidden":`true`,children:d}),(0,R.jsx)(`span`,{className:iC.label,children:t}),i&&(0,R.jsx)(`span`,{className:iC.duration,children:i}),m>0&&(0,R.jsx)(`span`,{className:iC.count,"aria-label":`${m} events`,children:m}),(0,R.jsx)(`span`,{className:`${iC.chevron} ${o?iC.chevronOpen:``}`,"aria-hidden":`true`})]}),p&&a&&a.length>0&&(0,R.jsx)(`div`,{className:iC.actorChips,children:a.map(e=>(0,R.jsxs)(`span`,{className:`${iC.actorChip} ${iC[`actor_${e.status}`]}`,title:`${e.name} · ${e.archetype}`,children:[(0,R.jsx)(`span`,{className:iC.actorChipName,children:e.name}),(0,R.jsx)(`span`,{className:iC.actorChipState,children:e.status===`running`?`T${e.currentTurn}/${e.maxTurns}`:aC[e.status]})]},e.name))}),o&&(0,R.jsxs)(`div`,{id:`stage-${e}-body`,className:iC.body,ref:c,onScroll:u,role:`log`,"aria-live":n===`active`?`polite`:`off`,"aria-label":`${t} log`,children:[r.length===0&&(0,R.jsxs)(`div`,{className:`${iC.line} ${iC.tonePending}`,children:[(0,R.jsx)(`span`,{className:iC.lineTs,children:`—`}),(0,R.jsx)(`span`,{className:iC.lineGlyph,children:`·`}),(0,R.jsx)(`span`,{className:iC.lineBody,children:n===`pending`?`Waiting for previous stage…`:`No events yet.`})]}),r.map((e,t)=>(0,R.jsxs)(`div`,{className:`${iC.line} ${iC[`tone${sC(e.tone)}`]}`,children:[(0,R.jsx)(`span`,{className:iC.lineTs,children:e.ts}),(0,R.jsx)(`span`,{className:iC.lineGlyph,children:e.glyph}),e.tag&&(0,R.jsx)(`span`,{className:iC.lineTag,children:e.tag}),e.actor&&(0,R.jsx)(`span`,{className:iC.lineActor,children:e.actor}),(0,R.jsx)(`span`,{className:iC.lineBody,children:e.body})]},t))]})]})}function sC(e){return e.charAt(0).toUpperCase()+e.slice(1)}function cC(e){(!Number.isFinite(e)||e<0)&&(e=0);let t=e/1e3,n=Math.floor(t/60),r=Math.floor(t%60),i=Math.floor(t*10%10);return`${n}:${String(r).padStart(2,`0`)}.${i}`}function lC(e){return e===`turn_start`||e===`turn_done`?`active`:e===`specialist_done`||e===`sim_complete`||e===`agent_reactions`?`done`:e===`decision_pending`||e===`decision_made`||e===`outcome`?`info`:e===`sim_aborted`||e===`provider_error`||e===`validation_fallback`?`warn`:`info`}function uC(e){switch(e){case`turn_start`:return`TURN`;case`turn_done`:return`TURN`;case`specialist_start`:return`SPEC`;case`specialist_done`:return`SPEC`;case`decision_pending`:return`DEC`;case`decision_made`:return`DEC`;case`outcome`:return`OUT`;case`agent_reactions`:return`REACT`;case`bulletin`:return`NEWS`;case`promotion`:return`PROMO`;case`systems_snapshot`:return`SNAP`;case`drift`:return`DRIFT`;case`personality_drift`:return`DRIFT`;case`sim_aborted`:return`ABORT`;case`provider_error`:return`ERR`;case`validation_fallback`:return`FALLBACK`;case`sim_complete`:return`DONE`;default:return e.toUpperCase().slice(0,8)}}function dC(e){let t=e.data??{};return(typeof t.summary==`string`?t.summary:``)||(typeof t.department==`string`?t.department:typeof t.title==`string`?t.title:typeof t.decision==`string`?t.decision:typeof t.outcome==`string`?t.outcome:typeof t.eventType==`string`?t.eventType:typeof t.tool==`string`?t.tool:``)}function fC(e){if(e.type===`status`)return null;let t=e.turn??e.data?.turn,n=e.leader||e.data?.actor,r=dC(e)||`${e.type} fired`;return{ts:typeof t==`number`?`T${t}`:`—`,glyph:e.type===`turn_done`?`✓`:e.type===`turn_start`?`→`:`·`,tag:e.type===`validation_fallback`&&e.data?.salvaged===!0?`SALVAGE`:uC(e.type),body:r,tone:lC(e.type),actor:typeof n==`string`?n:void 0}}function pC(e){let{stage:t,startMs:n,phaseTransitionMs:r}=e,i=[],a=r?.compile??n;i.push({ts:cC(a-n),glyph:`→`,tag:`POST`,body:`/api/quickstart/compile-from-seed`,tone:t===`compile`?`active`:`info`});let o=r?.research;return o&&i.push({ts:cC(o-n),glyph:`✓`,tag:`OK`,body:`ScenarioPackage validated · departments + crisis templates derived`,tone:`done`}),i}function mC(e){let{stage:t,startMs:n,phaseTransitionMs:r,groundingSummary:i}=e,a=[],o=r?.research;if(!o)return a;let s=cC(o-n);if(i?.skipped)return a.push({ts:s,glyph:`⚠`,tag:`SKIP`,body:`Deep research skipped: ${i.reason??`unknown`}`,tone:`warn`}),a;if(i?.citations&&i.citations.length>0){let e=i.providersUsed?.length?` · providers: ${i.providersUsed.join(` + `)}`:``;a.push({ts:s,glyph:`→`,tag:`POST`,body:`/api/quickstart/ground-scenario · ${i.citations.length} queries${e}`,tone:t===`research`?`active`:`info`});for(let e of i.providersFailed??[])a.push({ts:s,glyph:`⚠`,tag:e.provider.toUpperCase().slice(0,8),body:`provider unavailable: ${e.reason.slice(0,120)}`,tone:`warn`});for(let e of i.citations){a.push({ts:s,glyph:`·`,tag:`QUERY`,body:`"${e.query}" → ${e.sources.length} source${e.sources.length===1?``:`s`}`,tone:`info`});for(let t of e.sources.slice(0,3)){let e=(t.provider??``).toUpperCase()||t.domain.toUpperCase().slice(0,16)||`SRC`;a.push({ts:s,glyph:`·`,tag:e,body:t.title,tone:`done`})}}if(typeof i.totalSources==`number`){let e=typeof i.durationMs==`number`?` · ${(i.durationMs/1e3).toFixed(1)}s`:``;a.push({ts:s,glyph:`✓`,tag:`OK`,body:`${i.totalSources} unique sources attached to ScenarioPackage${e}`,tone:`done`})}return a}a.push({ts:s,glyph:`·`,tag:`NOTE`,body:`Grounding scenario with web research…`,tone:t===`research`?`active`:`info`});let c=r?.actors;return c&&a.push({ts:cC(c-n),glyph:`✓`,tag:`OK`,body:`Citations attached to ScenarioPackage`,tone:`done`}),a}function hC(e){let{stage:t,startMs:n,phaseTransitionMs:r,actorCount:i}=e,a=[],o=r?.actors;if(!o)return a;a.push({ts:cC(o-n),glyph:`→`,tag:`POST`,body:`/api/quickstart/generate-actors · count=${i}`,tone:t===`actors`?`active`:`info`});let s=r?.running;return s&&a.push({ts:cC(s-n),glyph:`✓`,tag:`OK`,body:`${i} actor${i===1?``:`s`} generated · HEXACO traits + archetypes validated`,tone:`done`}),a}function gC(e){return e.events.map(e=>fC(e)).filter(e=>!!e)}function _C(e,t){switch(e){case`compile`:return pC(t);case`research`:return mC(t);case`actors`:return hC(t);case`running`:return gC(t);case`done`:return[]}}function vC(e,t){let n=[`compile`,`research`,`actors`,`running`,`done`],r=n.indexOf(e),i=t.phaseTransitionMs?.[e],a=n[r+1],o=a?t.phaseTransitionMs?.[a]:void 0;if(!i)return``;let s=((o??Date.now())-i)/1e3;return s<1?`${Math.max(1,Math.round(s*1e3))}ms`:s<10?`${s.toFixed(1)}s`:`${Math.round(s)}s`}var yC={progress:`_progress_5dmny_6`,heading:`_heading_5dmny_19`,title:`_title_5dmny_26`,subtitle:`_subtitle_5dmny_35`,stageList:`_stageList_5dmny_43`,stageItem:`_stageItem_5dmny_55`,cancel:`_cancel_5dmny_59`,jumpToSim:`_jumpToSim_5dmny_84`},bC=[`compile`,`research`,`actors`,`running`,`done`];function xC(e,t){let n=bC.indexOf(e),r=bC.indexOf(t);return n>r?`done`:n===r?`active`:`pending`}function SC({stage:e,actors:t,events:n,actorCount:r,groundingSummary:i,onCancel:a}){let o=(0,L.useRef)(Date.now()),[s,c]=(0,L.useState)(()=>({compile:Date.now()})),l=(0,L.useRef)(e);(0,L.useEffect)(()=>{l.current!==e&&(l.current=e,c(t=>t[e]?t:{...t,[e]:Date.now()}))},[e]);let[,u]=(0,L.useState)(0);(0,L.useEffect)(()=>{if(e===`done`)return;let t=setInterval(()=>u(e=>(e+1)%1e6),1e3);return()=>clearInterval(t)},[e]);let d=r??t?.length??3,f=vF(),p=(0,L.useMemo)(()=>({stage:e,startMs:o.current,phaseTransitionMs:s,actorCount:d,events:n??[],groundingSummary:i??null}),[e,s,d,n,i]),m=[{id:`compile`,label:`Compile scenario`},{id:`research`,label:`Ground with citations`},{id:`actors`,label:`Generate ${d} actor${d===1?``:`s`}`},{id:`running`,label:`Run ${d} simulation${d===1?``:`s`}`}];return(0,R.jsxs)(`section`,{className:yC.progress,role:`region`,"aria-label":`Quickstart progress`,children:[(0,R.jsxs)(`header`,{className:yC.heading,children:[(0,R.jsx)(`span`,{className:yC.title,children:`Quickstart run`}),(0,R.jsx)(`span`,{className:yC.subtitle,children:`Live trace of every step from seed text to ready-to-explore artifacts.`})]}),(0,R.jsx)(`ol`,{className:yC.stageList,children:m.map(n=>{let r=xC(e,n.id);return(0,R.jsx)(`li`,{className:yC.stageItem,children:(0,R.jsx)(oC,{stageId:n.id,label:n.label,status:r,logLines:_C(n.id,p),duration:vC(n.id,p),actors:n.id===`running`?t:void 0})},n.id)})}),(e===`running`||e===`done`)&&(0,R.jsx)(`button`,{type:`button`,className:yC.jumpToSim,onClick:()=>f(`sim`),children:`Jump to live SIM →`}),a&&e!==`done`&&(0,R.jsx)(`button`,{type:`button`,className:yC.cancel,onClick:a,children:`Cancel run`})]})}var CC=Object.freeze({visionary:{id:`visionary`,name:`Aria Okafor`,archetype:`The Visionary`,description:`Bets on bold experiments. Tolerates ambiguity. Casts a wide pattern net.`,hexaco:{openness:.95,conscientiousness:.35,extraversion:.85,agreeableness:.55,emotionality:.3,honestyHumility:.65}},pragmatist:{id:`pragmatist`,name:`Marcus Reyes`,archetype:`The Pragmatist`,description:`Leads by protocol and evidence. Safety margins first.`,hexaco:{openness:.4,conscientiousness:.9,extraversion:.35,agreeableness:.6,emotionality:.5,honestyHumility:.85}},innovator:{id:`innovator`,name:`Yuki Tanaka`,archetype:`The Innovator`,description:`Pushes novel tool forging. Accepts higher variance.`,hexaco:{openness:.9,conscientiousness:.4,extraversion:.7,agreeableness:.45,emotionality:.35,honestyHumility:.55}},stabilizer:{id:`stabilizer`,name:`Elena Voss`,archetype:`The Stabilizer`,description:`Holds the line. Protects existing capacity. Change-averse.`,hexaco:{openness:.3,conscientiousness:.85,extraversion:.4,agreeableness:.75,emotionality:.55,honestyHumility:.7}},"crisis-manager":{id:`crisis-manager`,name:`Nadia Chen`,archetype:`The Crisis Manager`,description:`Thrives under pressure. Decisive. Low emotional reactivity.`,hexaco:{openness:.55,conscientiousness:.8,extraversion:.75,agreeableness:.45,emotionality:.25,honestyHumility:.6}},"growth-optimist":{id:`growth-optimist`,name:`Diego Santoro`,archetype:`The Growth Optimist`,description:`Chases expansion. High risk tolerance. Charismatic rally-er.`,hexaco:{openness:.8,conscientiousness:.5,extraversion:.9,agreeableness:.55,emotionality:.35,honestyHumility:.4}},"protocol-builder":{id:`protocol-builder`,name:`Priya Rao`,archetype:`The Protocol Builder`,description:`Codifies everything. Demands evidence. Slow to decide, hard to dislodge.`,hexaco:{openness:.5,conscientiousness:.95,extraversion:.35,agreeableness:.6,emotionality:.45,honestyHumility:.9}},"social-architect":{id:`social-architect`,name:`Kai Rivers`,archetype:`The Social Architect`,description:`Builds coalitions. Manages morale. Relationship-first.`,hexaco:{openness:.6,conscientiousness:.65,extraversion:.8,agreeableness:.9,emotionality:.55,honestyHumility:.7}},"cost-cutter":{id:`cost-cutter`,name:`Hannah Novak`,archetype:`The Cost Cutter`,description:`Optimizes ruthlessly. Will trade morale for capacity.`,hexaco:{openness:.35,conscientiousness:.9,extraversion:.45,agreeableness:.3,emotionality:.25,honestyHumility:.55}},"compliance-hawk":{id:`compliance-hawk`,name:`Owen Ibarra`,archetype:`The Compliance Hawk`,description:`Audits every decision. Never cuts corners. Reports failures transparently.`,hexaco:{openness:.4,conscientiousness:.9,extraversion:.45,agreeableness:.65,emotionality:.5,honestyHumility:.95}}}),wC={backdrop:`_backdrop_fgbmo_1`,dialog:`_dialog_fgbmo_12`,header:`_header_fgbmo_23`,list:`_list_fgbmo_47`,preset:`_preset_fgbmo_56`,archetype:`_archetype_fgbmo_82`,description:`_description_fgbmo_87`};function TC({onSelect:e,onClose:t}){let n=Qr(!0);return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Swap leader`,className:wC.backdrop,onClick:t,children:(0,R.jsxs)(`div`,{ref:n,tabIndex:-1,className:wC.dialog,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`header`,{className:wC.header,children:[(0,R.jsx)(`h3`,{children:`Swap leader`}),(0,R.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`Close`,children:`×`})]}),(0,R.jsx)(`ul`,{className:wC.list,children:Object.values(CC).map(t=>(0,R.jsx)(`li`,{children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>e(t),className:wC.preset,children:[(0,R.jsx)(`strong`,{children:t.name}),(0,R.jsx)(`span`,{className:wC.archetype,children:t.archetype}),(0,R.jsx)(`span`,{className:wC.description,children:t.description})]})},t.id))})]})})}var EC={results:`_results_8jenm_2`,runSummary:`_runSummary_8jenm_15`,summaryStat:`_summaryStat_8jenm_26`,summaryNum:`_summaryNum_8jenm_40`,summaryLabel:`_summaryLabel_8jenm_50`,grid:`_grid_8jenm_61`,card:`_card_8jenm_81`,cardHeader:`_cardHeader_8jenm_92`,actorName:`_actorName_8jenm_106`,archetype:`_archetype_8jenm_110`,swap:`_swap_8jenm_119`,hexaco:`_hexaco_8jenm_142`,trait:`_trait_8jenm_151`,traitLabel:`_traitLabel_8jenm_160`,traitBarOuter:`_traitBarOuter_8jenm_168`,traitBarInner:`_traitBarInner_8jenm_175`,fingerprint:`_fingerprint_8jenm_180`,deltas:`_deltas_8jenm_192`,delta:`_delta_8jenm_192`,direction_up:`_direction_up_8jenm_209`,direction_down:`_direction_down_8jenm_213`,direction_changed:`_direction_changed_8jenm_217`,actions:`_actions_8jenm_222`,forkButton:`_forkButton_8jenm_249`,forkHint:`_forkHint_8jenm_259`},DC=[`openness`,`conscientiousness`,`extraversion`,`agreeableness`,`emotionality`,`honestyHumility`];function OC({actors:e,artifacts:t,sessionId:n,onSwap:r}){let{dispatch:i}=da(),a=vF(),o=i_(),[s,c]=(0,L.useState)(null),l=Ti(),u=l.clear,[d,f]=(0,L.useState)(null);(0,L.useEffect)(()=>{u()},[n,u]);let p=e=>{i({type:`SET_PARENT`,artifact:t[e]}),a(`studio`)},m=e=>{n&&(f(e),l.share($_(window.location.origin,n)))},h=n=>{let r=t[n],i=e[n]??{},a=typeof i.archetype==`string`?i.archetype:``,o=typeof i.name==`string`?i.name:``;ev(r,`paracosm-quickstart-${a.toLowerCase().replace(/\s+/g,`-`)||o.toLowerCase().replace(/\s+/g,`-`)||`actor-${n}`}.json`)},g=(0,L.useMemo)(()=>({totalTools:t.reduce((e,t)=>e+(t?.forgedTools?.length??0),0),totalCitations:t.reduce((e,t)=>e+(t?.citations?.length??0),0),totalDecisions:t.reduce((e,t)=>e+(t?.decisions?.length??0),0),totalTurns:t.reduce((e,t)=>e+(t?.trajectory?.timepoints?.length??0),0),totalCostUSD:t.reduce((e,t)=>e+(t?.cost?.totalUSD??0),0)}),[t]);return(0,R.jsxs)(`div`,{className:EC.results,role:`region`,"aria-label":`Quickstart results`,children:[(0,R.jsxs)(`div`,{className:EC.runSummary,role:`region`,"aria-label":`Run summary`,children:[(0,R.jsxs)(`div`,{className:EC.summaryStat,title:`Web sources Paracosm pulled via Serper + Tavily and attached to the scenario before generating actors. Grounds the sim in real-world knowledge instead of pure LLM imagination.`,children:[(0,R.jsx)(`span`,{className:EC.summaryNum,children:g.totalCitations}),(0,R.jsx)(`span`,{className:EC.summaryLabel,children:`citations · web research`})]}),(0,R.jsxs)(`div`,{className:EC.summaryStat,title:`AgentOS tool forging: when a department needed a calculation the codebase didn't provide, it wrote one at runtime, run in a QuickJS WebAssembly sandbox. The judge reviewed each for safety + correctness before letting it enter the decision pipeline.`,children:[(0,R.jsx)(`span`,{className:EC.summaryNum,children:g.totalTools}),(0,R.jsx)(`span`,{className:EC.summaryLabel,children:`tools forged · AgentOS sandbox`})]}),(0,R.jsxs)(`div`,{className:EC.summaryStat,title:`Commander decisions across all 3 actors. Each one went through the full propose / judge / execute cycle.`,children:[(0,R.jsx)(`span`,{className:EC.summaryNum,children:g.totalDecisions}),(0,R.jsx)(`span`,{className:EC.summaryLabel,children:`commander decisions`})]}),(0,R.jsxs)(`div`,{className:EC.summaryStat,title:`Total simulation turns across all 3 parallel actors. Each turn = one decision cycle: department analysis, commander decision, kernel advance, agent reactions.`,children:[(0,R.jsx)(`span`,{className:EC.summaryNum,children:g.totalTurns}),(0,R.jsx)(`span`,{className:EC.summaryLabel,children:`turns simulated`})]}),g.totalCostUSD>0&&(0,R.jsxs)(`div`,{className:EC.summaryStat,title:`Total LLM spend across all 3 actors. Provider: gpt-5.4-mini for sims, gpt-4o for verdict.`,children:[(0,R.jsxs)(`span`,{className:EC.summaryNum,children:[`$`,g.totalCostUSD.toFixed(2)]}),(0,R.jsx)(`span`,{className:EC.summaryLabel,children:`LLM cost`})]})]}),(0,R.jsx)(`div`,{className:EC.grid,children:e.map((e,r)=>{let i=t[r];return i?(0,R.jsx)(kC,{actor:e,artifact:i,peers:t.filter((e,t)=>t!==r&&!!e),timeLabel:o.time,timeLabelCap:o.Time,shareEnabled:!!n,onDownload:()=>h(r),onShare:()=>m(r),shareNote:d===r&&l.shared?(0,R.jsx)(ji,{shared:l.shared,onClose:l.clear}):null,onFork:()=>p(r),onRequestSwap:()=>c(r)},r):null})}),s!==null&&(0,R.jsx)(TC,{onSelect:e=>{r(s,e),c(null)},onClose:()=>c(null)})]})}function kC({actor:e,artifact:t,peers:n,timeLabel:r,timeLabelCap:i,shareEnabled:a,shareNote:o,onDownload:s,onShare:c,onFork:l,onRequestSwap:u}){let d=(0,L.useMemo)(()=>Q_(t,n),[t,n]),f=t.trajectory?.timepoints?.length??0;return(0,R.jsxs)(`article`,{className:EC.card,children:[(0,R.jsxs)(`header`,{className:EC.cardHeader,children:[(0,R.jsx)(`h4`,{className:EC.actorName,children:e.name}),(0,R.jsx)(`span`,{className:EC.archetype,children:e.archetype}),(0,R.jsx)(`button`,{type:`button`,className:EC.swap,onClick:u,"aria-label":`Swap ${e.name}`,children:`Swap`})]}),(0,R.jsx)(`div`,{className:EC.hexaco,children:DC.map(t=>(0,R.jsxs)(`div`,{className:EC.trait,children:[(0,R.jsx)(`span`,{className:EC.traitLabel,children:t.slice(0,4).toUpperCase()}),(0,R.jsx)(`div`,{className:EC.traitBarOuter,children:(0,R.jsx)(`div`,{className:EC.traitBarInner,style:{width:`${Math.round((e.hexaco?.[t]??.5)*100)}%`}})})]},t))}),(0,R.jsxs)(`div`,{className:EC.fingerprint,children:[(0,R.jsx)(`span`,{children:`FP`}),(0,R.jsx)(`code`,{children:t.fingerprint?Object.values(t.fingerprint).slice(0,3).join(` / `):`n/a`})]}),d.length>0&&(0,R.jsx)(`ul`,{className:EC.deltas,"aria-label":`Delta vs peer median`,children:d.slice(0,4).map(e=>(0,R.jsx)(`li`,{className:`${EC.delta} ${EC[`direction_${e.direction}`]}`,children:s_(e)},`${e.bag}.${e.key}`))}),(0,R.jsxs)(`div`,{className:EC.actions,children:[(0,R.jsx)(`button`,{type:`button`,onClick:s,children:`Download JSON`}),(0,R.jsx)(`button`,{type:`button`,onClick:c,disabled:!a,title:`Copy a deep link that opens this run on the visualization tab`,children:`Copy viz share link`}),(0,R.jsx)(`button`,{type:`button`,onClick:l,disabled:f===0,className:EC.forkButton,title:f===0?`No turns completed yet`:`Promote to fork root and open Branches tab. ${f} ${f===1?r:`${r}s`} available.`,children:`Fork in Branches →`})]}),o,(0,R.jsx)(`div`,{className:EC.forkHint,children:f>0?`${f} ${i}${f===1?``:`s`} available for forking`:``})]})}var AC=2e3,jC=3e5;function MC(e,t){return new Promise((n,r)=>{if(t?.aborted){r(new DOMException(`Aborted`,`AbortError`));return}let i=setTimeout(()=>{t?.removeEventListener(`abort`,a),n()},e),a=()=>{clearTimeout(i),r(new DOMException(`Aborted`,`AbortError`))};t?.addEventListener(`abort`,a,{once:!0})})}async function NC(e){let t=await e.text(),n;try{n=t?JSON.parse(t):null}catch{throw Error(`Compile returned non-JSON HTTP ${e.status} response`)}if(!e.ok&&(!n||typeof n!=`object`))throw Error(`Compile failed: HTTP ${e.status}`);if(!n||typeof n!=`object`)throw Error(`Compile returned empty body`);return n}async function PC(e,t={}){let n=t.fetchImpl??fetch,r=t.pollIntervalMs??AC,i=t.timeoutMs??jC,a=t.waitImpl??MC,o=Date.now(),s=await n(`/api/quickstart/compile-from-seed`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e),signal:t.signal});if(!s.ok&&s.status!==202){let e=await s.json().catch(()=>({}));throw Error(e.error??`Compile failed: HTTP ${s.status}`)}let c=await NC(s);if(c.status===`done`&&c.scenario)return{scenario:c.scenario,scenarioId:c.scenario.id,jobId:c.jobId};if(c.status===`error`)throw Error(c.error??`Compile failed`);for(;Date.now()-o<i;){await a(r,t.signal);let e=await n(`/api/quickstart/compile-from-seed/status`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({jobId:c.jobId}),signal:t.signal});if(!e.ok){if(e.status===404)throw Error(`Compile job expired or not found. Please retry.`);let t=await e.json().catch(()=>({}));throw Error(t.error??`Compile status check failed: HTTP ${e.status}`)}let i=await NC(e);if(i.status===`done`&&i.scenario)return{scenario:i.scenario,scenarioId:i.scenario.id,jobId:i.jobId};if(i.status===`error`)throw Error(i.error??`Compile failed`)}throw Error(`Compile is taking longer than ${Math.round(i/1e3)}s. The server may still be working — please retry in a minute.`)}var FC={view:`_view_1jxlt_2`,header:`_header_1jxlt_17`,howItWorks:`_howItWorks_1jxlt_41`,glossary:`_glossary_1jxlt_48`,timingHint:`_timingHint_1jxlt_49`,howItWorksSummary:`_howItWorksSummary_1jxlt_65`,errorBanner:`_errorBanner_1jxlt_142`,compareCta:`_compareCta_1jxlt_154`};function IC(e,t){try{window.localStorage.setItem(`paracosm:launchPending`,`1`)}catch{}pe(t),window.location.href=N_(window.location.href,e)}function LC(e){return/Failed to fetch|NetworkError|ERR_CONNECTION|ERR_NETWORK/i.test(e)?`Couldn't reach the server. Check your connection and try again.`:/HTTP 502|HTTP 503|HTTP 504/.test(e)?`Server is temporarily unavailable (502/503/504). Try again in a moment.`:/HTTP 429|rate.?limit/i.test(e)?`${Et()} ${Dt(!1)}`:/HTTP 401|HTTP 403|unauthor/i.test(e)?`Auth error talking to the LLM provider. Check your API key in Settings.`:/Two actors required|at least 2 actors/i.test(e)?`This scenario needs at least 2 actors. Bump the slider before launching.`:/TypeError|ReferenceError|Cannot read propert|is not a function|is not iterable/i.test(e)?(typeof console<`u`&&console.error(`[quickstart] launch error:`,e),`Something went wrong starting the run. Refresh the page and try again — if it keeps happening, drop a note in the GitHub issues with what you clicked just before.`):e}function RC({sse:e,sessionId:t,onRunStarted:n,showsDigitalTwin:r=!1,onInterventionResult:i,onInterventionStart:a,onInterventionError:o}){let s=fF(),{toast:c}=oi(),[l,u]=(0,L.useState)({kind:`input`}),[d,f]=(0,L.useState)(null),[p,m]=(0,L.useState)(null),[h,_]=(0,L.useState)(!1),[v,x]=(0,L.useState)(null),S=(0,L.useCallback)(async(t,i)=>{f(null);let a=!!i&&r;a||(n?.(),await e.reset());let o=typeof window<`u`?E():{},l=typeof window<`u`?g(window.localStorage):null,d=R_(o),p={...d};o.serper&&(p.serperKey=o.serper),o.firecrawl&&(p.firecrawlKey=o.firecrawl),o.tavily&&(p.tavilyKey=o.tavily),o.cohere&&(p.cohereKey=o.cohere),l?.provider&&(p.provider=l.provider),l?.models&&typeof l.models==`object`&&(p.models=l.models),l?.economics&&typeof l.economics==`object`&&(p.economics=l.economics);let m=s.presets[0]?.leaders??s.presets[0]?.actors??[];if(m.length>=t){i||u({kind:`progress`,stage:`running`});let n=m.slice(0,t).map(e=>({name:e.name,archetype:e.archetype,hexaco:e.hexaco,instructions:e.instructions}));a||await e.reset();let r=()=>void 0;typeof window<`u`&&(r=b(window.localStorage),y(window.localStorage,n,s.id)),i?.onStage?.(`starting`);try{let e=await fetch(`/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i?.body?{...i.body,actors:n}:{...p,actors:n,turns:s.setup.defaultTurns,seed:s.setup.defaultSeed??42,captureSnapshots:!0,quickstart:{scenarioId:s.id}})});if(!e.ok){let t=await e.json().catch(()=>({}));if(i){r(),i.onFailure?.({status:e.status,body:t});return}throw Error(t.error??`Setup failed: HTTP ${e.status}`)}let t=await e.json().catch(()=>({}));if(t.redirect){IC(t.redirect,t.runKey);return}r(),i?.onFailure?.({status:e.status,body:t})}catch(e){if(r(),i){i.onFailure?.({networkError:!0});return}u({kind:`input`});let t=LC(e?.message??String(e));f(t),c(`error`,`Launch failed`,t,8e3)}return}i||u({kind:`progress`,stage:`actors`}),i?.onStage?.(`writing`,t);let h=()=>void 0;try{let n=await fetch(`/api/quickstart/generate-actors`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({scenarioId:s.id,count:t,...d})});if(!n.ok){let e=await n.json().catch(()=>({}));if(i){i.onFailure?.({status:n.status,body:e,request:`leaders`});return}throw Error(e.error??`Actor generation failed: HTTP ${n.status}`)}let r=(await n.json().catch(()=>null))?.actors;if(!r||r.length===0){if(i){i.onFailure?.({status:n.status,request:`leaders`});return}throw Error(`Actor generation returned no actors`)}i||u({kind:`progress`,stage:`running`}),a||await e.reset(),typeof window<`u`&&(h=b(window.localStorage),y(window.localStorage,r,s.id)),i?.onStage?.(`starting`);let o=await fetch(`/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(i?.body?{...i.body,actors:r}:{...p,actors:r,turns:s.setup.defaultTurns,seed:s.setup.defaultSeed??42,captureSnapshots:!0,quickstart:{scenarioId:s.id}})});if(!o.ok){let e=await o.json().catch(()=>({}));if(i){h(),i.onFailure?.({status:o.status,body:e});return}throw Error(e.error??`Setup failed: HTTP ${o.status}`)}let c=await o.json().catch(()=>({}));if(c.redirect){IC(c.redirect,c.runKey);return}h(),i?.onFailure?.({status:o.status,body:c})}catch(e){if(h(),i){i.onFailure?.({networkError:!0});return}u({kind:`input`});let t=LC(e?.message??String(e));f(t),c(`error`,`Launch failed`,t,8e3)}},[s,e,n,r,c]),C=(0,L.useCallback)(async t=>{f(null),n?.(),await e.reset(),u({kind:`progress`,stage:`compile`});try{let n=typeof window<`u`?R_(E()):{},{scenario:r,scenarioId:i}=await PC({...t,...n});u({kind:`progress`,stage:`research`,scenario:r});try{let e=await fetch(`/api/quickstart/ground-scenario`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({scenarioId:i})});if(e.ok){let t=await e.json();x(t)}}catch{x({skipped:!0,reason:`request failed`})}u({kind:`progress`,stage:`actors`,scenario:r});let a=Math.max(1,Math.min(300,t.actorCount??2)),o=await fetch(`/api/quickstart/generate-actors`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({scenarioId:i,count:a,...n})});if(!o.ok){let e=await o.json().catch(()=>({}));throw Error(e.error??`Actor generation failed: HTTP ${o.status}`)}let s=(await o.json().catch(()=>null))?.actors;if(!s||s.length===0)throw Error(`Actor generation returned no actors`);u({kind:`progress`,stage:`running`,scenario:r,actors:s}),await e.reset(),typeof window<`u`&&y(window.localStorage,s,i);let c=await fetch(`/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...n,actors:s,turns:r.setup.defaultTurns,seed:r.setup.defaultSeed??42,captureSnapshots:!0,quickstart:{scenarioId:i}})});if(!c.ok){let e=await c.json().catch(()=>({}));throw Error(e.error??`Setup failed: HTTP ${c.status}`)}let l=await c.json().catch(()=>({}));if(l.redirect){IC(l.redirect,l.runKey);return}}catch(e){u({kind:`input`});let t=LC(e?.message??String(e));f(t),c(`error`,`Quickstart failed`,t,8e3)}},[e,n,c]);(0,L.useEffect)(()=>{if(l.kind!==`progress`||l.stage!==`running`||!l.scenario||!l.actors)return;let t=e.results.map(e=>e.artifact).filter(e=>!!e);t.length>=l.actors.length&&u({kind:`results`,scenario:l.scenario,actors:l.actors,artifacts:t.slice(0,l.actors.length)})},[e.results,l]),(0,L.useEffect)(()=>{if(l.kind!==`results`||p!==null)return;let e=l.artifacts[0]?.metadata?.runId;if(!e)return;let t=!1;return fetch(`/api/v1/runs/${encodeURIComponent(e)}`).then(async e=>e.ok?e.json():null).then(e=>{if(t)return;let n=e?.record?.bundleId;n&&m(n)}).catch(()=>{}),()=>{t=!0}},[l,p]);let w=l.kind===`progress`&&l.stage===`running`&&l.actors?l.actors.map((t,n)=>{let r=e.events.filter(e=>e.type===`turn_done`||e.type===`turn_start`).reduce((e,t)=>{let n=t.data?.turn??0;return n>e?n:e},0),i=e.results.find(e=>e.actorIndex===n),a=e.errors.length>0&&!i?`error`:e.isAborted?`aborted`:i?`complete`:`running`;return{name:t.name,archetype:t.archetype,currentTurn:i?l.scenario?.setup.defaultTurns??r:r,maxTurns:l.scenario?.setup.defaultTurns??6,status:a}}):void 0,T=(0,L.useCallback)((e,t)=>{f(`Actor swap rerun is a v1.1 follow-up. Use "Fork in Branches" on the Branches tab to try a preset actor against this run.`)},[]);return(0,R.jsxs)(`div`,{className:FC.view,children:[l.kind===`input`&&(0,R.jsxs)(rC,{onStart:S,onSeedReady:C,children:[d&&(0,R.jsx)(`p`,{className:FC.errorBanner,role:`alert`,children:d}),(0,R.jsx)(Y_,{}),i&&(0,R.jsx)(G_,{onResult:i,onRunStart:a,onError:(e,t)=>{o?.(e,t)!==!1&&f(e)}})]}),l.kind!==`input`&&(0,R.jsx)(`h1`,{className:`sr-only`,children:`Run`}),l.kind===`progress`&&(0,R.jsx)(SC,{stage:l.stage,actors:w,events:e.events,actorCount:l.actors?.length??w?.length??2,groundingSummary:v}),l.kind===`results`&&(0,R.jsxs)(R.Fragment,{children:[d&&(0,R.jsx)(`p`,{className:FC.errorBanner,role:`alert`,children:d}),p&&l.artifacts.length>=2&&(0,R.jsxs)(`button`,{type:`button`,className:FC.compareCta,onClick:()=>_(!0),"aria-label":`Compare all ${l.artifacts.length} actors side-by-side`,children:[`Compare all `,l.artifacts.length,` actors →`]}),(0,R.jsx)(OC,{actors:l.actors,artifacts:l.artifacts,sessionId:t,onSwap:T}),p&&h&&(0,R.jsx)(ws,{bundleId:p,open:!0,onClose:()=>_(!1)})]}),l.kind!==`input`&&(0,R.jsx)(jb,{})]})}var zC={getNumber:()=>0,getEntry:()=>void 0,list:[]};function BC(e){return(0,L.useMemo)(()=>{let t=new Map,n=[],r=1;for(let i of e.actorIds){let a=e.actors[i];if(a)for(let e of a.events){if(e.type!==`specialist_done`)continue;let a=String(e.data?.department||``),o=e.data?.citationList||[];for(let e of o){let o=(e.url||``).trim(),s=(e.text||``).trim();if(!o&&!s||!o&&s===`Seed document`)continue;let c=o||`text:${s}`,l=t.get(c);l||(l={n:r++,text:s||o,url:o,doi:e.doi,departments:new Set,actorNames:new Set},t.set(c,l),n.push(l)),a&&l.departments.add(a),l.actorNames.add(i),!l.doi&&e.doi&&(l.doi=e.doi)}}}return{getNumber:e=>e?(t.get(e)||t.get(`text:${e}`))?.n??0:0,getEntry:e=>t.get(e)||t.get(`text:${e}`),list:n}},[e])}var VC=(0,L.createContext)(zC);function HC(){return(0,L.useContext)(VC)}var UC=()=>({tools:0,forges:0,reforges:0,passed:0,didNotPass:0});function WC(e){let t=String(e??``).trim();return t===`unnamed`?``:t}var GC=e=>Array.isArray(e)?e:[];function KC(e){if(e.type!==`specialist_done`)return!1;let t=e.data?.forgedTools;return t!=null&&!Array.isArray(t)}function qC(e,t,n,r){return{n:0,name:e,description:String(r.description||e),mode:String(r.mode||`sandbox`),firstForgedTurn:r.turn,firstForgedDepartment:r.department,departments:new Set,actorNames:new Set([n]),reuseCount:0,reforgeCount:0,rejectedReforges:0,confidence:r.confidence,approved:r.approved,inputSchema:void 0,outputSchema:void 0,sampleOutput:null,errorReason:r.errorReason,inputFields:GC(r.inputFields),outputFields:GC(r.outputFields),history:[],actorIndex:t,actorName:n,attempts:[],outcome:r.approved?`passed`:`did_not_pass`,sameNameActors:[]}}function JC(e,t,n){let r=new Map;for(let t of e){if(t.type!==`event_start`)continue;let e=`${Number(t.data?.turn??t.turn??0)}:${Number(t.data?.eventIndex??0)}`;r.has(e)||r.set(e,String(t.data?.title??``))}let i=new Map,a=[],o=new Map,s=[];for(let c of e){let e=c.data??{};if(c.type===`forge_attempt`){let o=WC(e.name);if(!o)continue;let l=Number(e.turn??c.turn??0),u=Number(e.eventIndex??0),d=String(e.department??``),f=e.approved===!0,p=typeof e.confidence==`number`?e.confidence:null,m=typeof e.errorReason==`string`&&e.errorReason?e.errorReason:null,h=i.get(o);h||(h=qC(o,t,n,{description:e.description,mode:e.mode,turn:l,department:d,confidence:p??0,approved:f,errorReason:m??void 0,inputFields:e.inputFields,outputFields:e.outputFields}),i.set(o,h),a.push(h));let g={attempt:h.attempts.length+1,turn:l,time:Number(e.time??0),eventIndex:u,department:d,eventTitle:r.get(`${l}:${u}`)??``,approved:f,confidence:p,errorReason:m,description:String(e.description??``),inputFields:GC(e.inputFields),outputFields:GC(e.outputFields),eventId:c.id};h.attempts.push(g),d&&h.departments.add(d),p!==null&&p>h.confidence&&(h.confidence=p),f?(h.approved=!0,h.errorReason=void 0):!h.approved&&m&&(h.errorReason=m),s.push(f?`passed`:`did_not_pass`);continue}if(c.type!==`specialist_done`)continue;let l=Array.isArray(e._filteredTools)?e._filteredTools:[],u=String(e.department||``);for(let e of l){let r=WC(e.name);if(!r)continue;let s=e.approved!==!1,l=i.get(r);if(l?(o.has(l)||(typeof e.description==`string`&&e.description&&(l.description=e.description),typeof e.mode==`string`&&e.mode&&(l.mode=e.mode),typeof e.firstForgedTurn==`number`&&(l.firstForgedTurn=e.firstForgedTurn),typeof e.firstForgedDepartment==`string`&&e.firstForgedDepartment&&(l.firstForgedDepartment=e.firstForgedDepartment),Array.isArray(e.inputFields)&&(l.inputFields=e.inputFields),Array.isArray(e.outputFields)&&(l.outputFields=e.outputFields)),typeof e.confidence==`number`&&e.confidence>l.confidence&&(l.confidence=e.confidence),s&&(l.approved=!0),l.approved?l.errorReason=void 0:typeof e.errorReason==`string`&&e.errorReason&&(l.errorReason=e.errorReason)):(l=qC(r,t,n,{description:e.description,mode:e.mode,turn:typeof e.firstForgedTurn==`number`?e.firstForgedTurn:c.turn??0,department:String(e.firstForgedDepartment||u),confidence:typeof e.confidence==`number`?e.confidence:s?.85:0,approved:s,errorReason:typeof e.errorReason==`string`?e.errorReason:void 0,inputFields:e.inputFields,outputFields:e.outputFields}),i.set(r,l),a.push(l)),typeof e.output==`string`&&(e.output||l.sampleOutput===null)&&(l.sampleOutput=e.output),!l.inputSchema&&e.inputSchema&&(l.inputSchema=e.inputSchema),!l.outputSchema&&e.outputSchema&&(l.outputSchema=e.outputSchema),u&&l.departments.add(u),o.set(l,s),Array.isArray(e.history)){let t=e.history;l.history=t.map(e=>({...e,actorName:n})),l.reuseCount=Math.max(0,t.length-1),l.reforgeCount=t.filter(e=>e.isReforge).length,l.rejectedReforges=t.filter(e=>e.isReforge&&e.rejected).length}}}for(let e of a){o.has(e)||(e.history=e.attempts.map((e,t)=>({turn:e.turn,time:e.time,eventIndex:e.eventIndex,eventTitle:e.eventTitle,department:e.department,output:null,isReforge:t>0,rejected:!e.approved,confidence:e.confidence??void 0,actorName:n})),e.reforgeCount=Math.max(0,e.attempts.length-1),e.rejectedReforges=e.attempts.filter(e=>!e.approved).length);let t=e.attempts[e.attempts.length-1];e.outcome=(t?t.approved:o.get(e)!==!1)?`passed`:`did_not_pass`}return{entries:a,strip:s}}function YC(e,t){e.tools+=t.tools,e.forges+=t.forges,e.reforges+=t.reforges,e.passed+=t.passed,e.didNotPass+=t.didNotPass}function XC(e){let t=[],n=[],r=UC(),i=new Map,a=new Map,o=(e,t)=>`${e}\u0000${t}`;e.actorIds.forEach((s,c)=>{let l=e.actors[s],u=l?.events??[],d=u.some(KC),{entries:f,strip:p}=d?{entries:[],strip:[]}:JC(u,c,s),m=UC();for(let e of f){e.n=t.length+1,t.push(e),i.set(o(c,e.name),e);let n=a.get(e.name);n?n.push(e):a.set(e.name,[e]);let r=e.attempts.filter(e=>e.approved).length;YC(m,{tools:1,forges:e.attempts.length,reforges:Math.max(0,e.attempts.length-1),passed:r,didNotPass:e.attempts.length-r})}YC(r,m),n.push({index:c,label:`A${c+1}`,name:s,archetype:l?.leader?.archetype??``,counts:m,strip:p,status:e.isComplete?`done`:u.length===0?`waiting`:`running`,unreadable:d})});for(let e of a.values())for(let t of e)t.sameNameActors=e.filter(e=>e!==t).map(e=>e.actorIndex);return{getNumber:e=>a.get(e.trim())?.[0]?.n??0,getEntry:e=>a.get(e.trim())?.[0],getEntryFor:(e,t)=>i.get(o(e,t.trim())),getEntryByNumber:e=>Number.isInteger(e)&&e>=1?t[e-1]:void 0,list:t,actors:n,counts:r}}var ZC={getNumber:()=>0,getEntry:()=>void 0,getEntryFor:()=>void 0,getEntryByNumber:()=>void 0,list:[],actors:[],counts:{tools:0,forges:0,reforges:0,passed:0,didNotPass:0}};function QC(e){return(0,L.useMemo)(()=>XC(e),[e])}var $C=(0,L.createContext)(ZC);function ew(){return(0,L.useContext)($C)}var tw=[`request`,`code`,`tests`,`judge`,`added`];function nw(e){return e===`passed`?`passed`:`didNotPass`}var rw=`request`;function iw(e){return e===`passed`?{stations:{request:`reached`,code:`reached`,tests:`reached`,judge:`reached`,added:`reached`},stop:null,deciding:`judge`}:{stations:{request:`reached`,code:`unknown`,tests:`unknown`,judge:`unknown`,added:`notReached`},stop:null,deciding:`request`}}function aw(e,t){let n=e.attempts.length;return n===0?0:Number.isFinite(t)?Math.min(Math.max(Math.trunc(t),1),n):n}function ow(e,t){let n=e.attempts;if(n.length===0)return{...iw(e.outcome),spurs:[],branch:null};let r=aw(e,t),i=e=>e?`passed`:`did_not_pass`,a=n[r-1],o=n[r];return{...iw(i(a.approved)),spurs:n.slice(0,r-1).map(e=>({attempt:e.attempt,station:rw,outcome:i(e.approved)})),branch:o?{attempt:o.attempt,station:rw,outcome:i(o.approved)}:null}}function sw(e,t){return t<=2?Xn(e):`var(--forge-quiet)`}function cw(e){return e.history.slice(1).filter(e=>!e.isReforge).length}var lw={forge_toolbox_open:{from:[`sim`,`reports`,`viz`]},forge_trace_open:{from:[`toolbox`,`inspect`,`viz`,`link`]},forge_station_open:{station:tw,via:[`press`,`open_all`,`kept`]},forge_toolbox_filter:{show:[`all`,`passed`,`did_not_pass`]},forge_record_export:{what:[`toolbox`,`record_copy`,`record_download`]},forge_log_jump:{},forge_link_copy:{},forge_toolbox_group:{group:[`actor`,`department`,`none`]},forge_group_toggle:{scope:[`one`,`all`]},forge_actor_filter:{actors:[`1`,`2-4`,`5-24`,`25+`]},forge_actor_picker_open:{where:[`toolbox`,`compare`,`event_log`]}};function uw(e){return!Number.isFinite(e)||e<1?null:e===1?`1`:e<=4?`2-4`:e<=24?`5-24`:`25+`}function dw(e,t){try{let n=e.paracosmConsent;return typeof n?.allows==`function`&&n.allows(t)===!0}catch{return!1}}function fw(e){try{let{origin:t,pathname:n}=e.location;return typeof t==`string`&&typeof n==`string`?t+n:null}catch{return null}}function pw(e,t){let n=t??(typeof window>`u`?void 0:window);if(!n)return;let r=n,i=lw[e.name];if(!i)return;let a=dw(r,`measure`),o=dw(r,`record`);if(!a&&!o)return;let s={},c=e;for(let[e,t]of Object.entries(i)){let n=c[e];typeof n==`string`&&t.includes(n)&&(s[e]=n)}if(a&&typeof r.gtag==`function`){let t=fw(n);try{r.gtag(`event`,e.name,t===null?s:{...s,page_location:t})}catch{}}if(o&&typeof r.clarity==`function`)try{r.clarity(`event`,e.name)}catch{}}var mw={tool:`tool`,attempt:`attempt`,open:`open`,toolbox:`toolbox`,show:`show`,find:`find`,group:`group`,actors:`actors`},hw=Object.values(mw),gw=[mw.tool,mw.attempt,mw.open];function _w(e){if(e===null||!/^\d+$/.test(e.trim()))return null;let t=Number.parseInt(e.trim(),10);return Number.isSafeInteger(t)&&t>=1?t:null}function vw(e){let t=e.split(`,`).map(e=>e.trim().toLowerCase());return tw.filter(e=>t.includes(e))}function yw(e){let t=[];for(let n of e.split(`,`)){let e=_w(n);e!==null&&!t.includes(e)&&t.push(e)}return t}function bw(e,t,n){let r={trace:null,toolbox:{open:!1}},i=[],a;try{a=new URL(e).searchParams}catch{return{state:r,dangling:i}}r.toolbox.open=a.get(mw.toolbox)===`1`;for(let e of[mw.show,mw.find,mw.group]){let t=a.get(e);t!==null&&t!==``&&(r.toolbox[e]=t)}let o=a.get(mw.actors);if(o!==null){let e=yw(o),a=n?e.filter(e=>e<=t.actors.length):e;a.length>0?r.toolbox.actors=a:n&&i.push(mw.actors)}if(!n)return{state:r,dangling:i};let s=gw.filter(e=>a.has(e));if(s.length===0)return{state:r,dangling:i};let c=_w(a.get(mw.tool)),l=c===null?void 0:t.getEntryByNumber(c);if(!l)return i.push(...s),{state:r,dangling:i};let u;if(a.has(mw.attempt)){let e=_w(a.get(mw.attempt));if(e===null||e>l.attempts.length)return i.push(...s),{state:r,dangling:i};u=e}let d;if(a.has(mw.open)){let e=vw(a.get(mw.open)??``);e.length>0?d=e:i.push(mw.open)}return r.trace={actorIndex:l.actorIndex,toolName:l.name,...u===void 0?{}:{attempt:u},...d?{open:d}:{}},{state:r,dangling:i}}function xw(e,t,n){let r=new URL(e);for(let e of hw)r.searchParams.delete(e);let i=t.trace,a=i?n.getEntryFor(i.actorIndex,i.toolName):void 0;if(i&&a){r.searchParams.set(mw.tool,String(a.n)),i.attempt!==void 0&&i.attempt>=1&&i.attempt<a.attempts.length&&r.searchParams.set(mw.attempt,String(Math.trunc(i.attempt)));let e=tw.filter(e=>i.open?.includes(e));e.length>0&&r.searchParams.set(mw.open,e.join(`,`))}let o=t.toolbox;return o.open&&r.searchParams.set(mw.toolbox,`1`),o.show&&r.searchParams.set(mw.show,o.show),o.find&&r.searchParams.set(mw.find,o.find),o.group&&r.searchParams.set(mw.group,o.group),o.actors&&o.actors.length>0&&r.searchParams.set(mw.actors,o.actors.join(`,`)),r.toString()}function Sw(e,t){let n;try{n=new URL(e)}catch{return e}let r=[[mw.show,t.show&&t.show!==`all`?t.show:null],[mw.find,t.find?t.find:null]];if(t.open!==void 0&&r.push([mw.toolbox,t.open?`1`:null]),t.group!==void 0&&r.push([mw.group,t.group?t.group:null]),t.actors!==void 0){let e=[...new Set(t.actors)].filter(e=>Number.isInteger(e)&&e>=0).sort((e,t)=>e-t).map(e=>e+1);r.push([mw.actors,e.length>0?e.join(`,`):null])}let i=!1;for(let[e,t]of r)n.searchParams.get(e)===t&&n.searchParams.getAll(e).length<=1||(i=!0,t===null?n.searchParams.delete(e):n.searchParams.set(e,t));return i?n.toString():e}function Cw(e,t){let n;try{n=new URL(e)}catch{return e}let r=(t??hw).filter(e=>n.searchParams.has(e));if(r.length===0)return e;for(let e of r)n.searchParams.delete(e);return n.toString()}function ww(e,t,n,r,i){return xw(Kr(e,t,n),{trace:r,toolbox:{open:!1}},i)}function Tw(e){let t;try{t=O_(e)}catch{return`sim`}return t===`about`||t===`quickstart`?`sim`:t}var Ew=(0,L.createContext)({openTrace:()=>{},openToolbox:()=>{},close:()=>{},showActorLog:()=>{},current:{trace:null,toolbox:!1}});function Dw(){return(0,L.useContext)(Ew)}var Ow=[`all`,`passed`,`did_not_pass`],kw=[`actor`,`department`,`none`],Aw=e=>e>2?`actor`:`none`,jw={show:`all`,find:``,group:null,actors:[]},Mw={...jw,set:()=>{}},Nw=(0,L.createContext)(Mw);function Pw(){return(0,L.useContext)(Nw)}var Fw=[`run`,`tools`,`didNotPass`],Iw=/^a(\d+)$/i;function Lw(e,t){let n=t.trim();if(n===``)return e;let r=Iw.exec(n);if(r){let t=`A${Number.parseInt(r[1],10)}`;return e.filter(e=>e.label===t)}let i=n.toLowerCase();return e.filter(e=>e.name.toLowerCase().includes(i)||e.archetype.toLowerCase().includes(i))}function Rw(e,t){let n=(e,t)=>e.index-t.index,r=[...e];return t===`tools`?r.sort((e,t)=>t.counts.tools-e.counts.tools||n(e,t)):t===`didNotPass`?r.sort((e,t)=>t.counts.didNotPass-e.counts.didNotPass||n(e,t)):r.sort(n)}function zw(e,t){return t>0&&e.length===0?`error`:`ready`}function Bw(e,t,n){let r=new Set(e);for(let e of t){if(n!==void 0&&r.size>=n)break;r.add(e.index)}return r}function Vw(e,t){let n=[...new Set(e)].filter(e=>Number.isInteger(e)&&e>=0&&e<t).sort((e,t)=>e-t);return n.length===0||n.length>=t?null:n}var Hw={request:`Request`,code:`Code`,tests:`Tests`,judge:`Judge`,added:`Added`},Uw={unknown:`Unknown`,notReached:`Not reached`},Ww={reached:`reached`,stopped:`stopped here`,unknown:Uw.unknown,notReached:Uw.notReached},Gw=(e,t)=>`${Hw[e]}: ${Ww[t]}`,Kw=`The forge's stations`,qw={passed:`Passed`,rejected:`Rejected by the judge`,notJudged:`Not judged`,refused:`Refused`,failed:`Failed`,didNotPass:`Did not pass`},Jw=e=>`A${e+1}`,Yw=e=>`+${e}`,Xw=(e,t)=>`${e}, forged tool ${t}`,Zw=e=>`Forged tool ${e}`,Qw=`Close the trace`,$w={key:`Copy link to this tool`,copied:`Link copied. Anyone with it can open this tool's trace and replay the run.`,failed:`Could not copy. Select the link and copy it.`,offline:`You are offline`},eT={toLight:`Switch to light mode`,toDark:`Switch to dark mode`},tT=`Written by an AI model during this paracosm run`,nT={passed:`Passed. The judge approved it.`,did_not_pass:`Did not pass. The run's record does not say where the forge stopped.`},rT={heading:`The reason the run recorded`,limit:`The run's record keeps at most 240 characters of this reason.`,none:`The record gave no reason.`},iT={code:`The code was not recorded for this run.`,tests:`The tests were not recorded for this run.`},aT=e=>`Approved · confidence ${e.toFixed(2)} out of 1`,oT=e=>e===1?`Used 1 time`:`Used ${e} times`,sT={open:`Open all`,close:`Close all`,openName:`Open all stations`,closeName:`Close all stations`};function cT(e){return[e.archetype?`${e.label} ${e.name}, ${e.archetype}`:`${e.label} ${e.name}`,e.department,`turn ${e.turn}`,e.eventTitle?`for “${e.eventTitle}”`:``].filter(Boolean).join(` · `)}var lT=e=>`Go to the event: ${e}`,uT={whatItDoes:`What it does`,inputFields:`Input fields`,outputFields:`Output fields`,columns:[`Field`,`Type`,`Required`,`Description`],rawJson:`Raw JSON`,noInputFields:`This tool declares no input fields.`,noOutputFields:`This tool declares no output fields.`,notRecorded:`Not recorded`,yes:`Yes`,no:`No`},dT={heading:`What the judge said`,notice:`A model's review of this code, not a security audit. Check before reuse.`,meterName:`The judge's confidence`,wordsNotRecorded:`The judge's words were not recorded for this run.`},fT=e=>`The judge's confidence: ${e.toFixed(2)} out of 1`,pT={output:`Output the run recorded`,testNotRecorded:`This forge's test was not recorded.`,notUsed:`Not used after it was forged.`};function mT(e,t,n){return[`Turn ${e}`,t,n?`“${n}”`:``].filter(Boolean).join(` · `)}var hT={key:`Record`,rawRecord:`The raw record`,copy:`Copy record`,copied:`Copied`,copyFailed:`Could not copy. Select the record and copy it.`,download:`Download JSON`,downloadFailed:`Could not download. Try again, or use Copy record.`,showInEventLog:`Show in Event Log`,unreadable:`This record could not be shown.`},gT=e=>`${e}-trace.json`,_T={previous:`Previous attempt`,next:`Next attempt`},vT=(e,t)=>`${e} of ${t}`,yT=(e,t)=>`Attempt ${e} of ${t}`,bT=(e,t)=>`Attempt ${e} · ${t}`,xT=e=>e.toLocaleString(`en-US`),ST=(e,t,n)=>`${xT(e)} ${e===1?t:n}`,CT=`FORGED TOOLBOX`,wT=e=>`Forged toolbox, ${ST(e,`tool`,`tools`)}`,TT=e=>`Forged toolbox · ${xT(e)}`,ET=`Close the toolbox`;function DT(e,t){let n=e.reforges>0?` (${ST(e.reforges,`re-forge`,`re-forges`)})`:``;return[`${ST(e.tools,`tool`,`tools`)} from ${ST(e.forges,`forge`,`forges`)}${n}`,e.passed>0?`${xT(e.passed)} passed`:``,e.didNotPass>0?`${xT(e.didNotPass)} did not pass`:``,t>2?`${xT(t)} actors`:``].filter(Boolean).join(` · `)}var OT={name:`Show`,menuLead:`Show:`,all:`All`,passed:qw.passed,did_not_pass:qw.didNotPass},kT={label:`Find a tool`,placeholder:`Tool name…`,clear:`Clear`,clearName:`Clear the search`},AT={noTools:`No department forged a tool in this run.`,everyToolPassed:`Every tool in this run passed.`},jT=e=>`No tool matches “${e}”.`,MT=`Export JSON`,NT=`paracosm-toolbox.json`;function PT(e){return[e.department,`turn ${e.turn}`,e.uses===null?``:`used ${ST(e.uses,`time`,`times`)}`,e.reforges>0?ST(e.reforges,`re-forge`,`re-forges`):``].filter(Boolean).join(` · `)}function FT(e){return e.length>3?`Same name in ${xT(e.length)} other actors`:`Same name: ${e.join(`, `)}`}function IT(e){let t=`${e.name}, ${e.outcome}, made by ${e.actorLabel} ${e.actorName}`;return e.forges>1?`${t}, forged ${xT(e.forges)} times`:t}var LT={name:`Group`,actor:`Actor`,department:`Department`,none:`None`},RT=e=>`Group: ${LT[e]}`,zT={open:`Open all groups`,close:`Close all groups`};function BT(e){return[`${ST(e.tools,`tool`,`tools`)} from ${ST(e.forges,`forge`,`forges`)}`,e.passed>0?`${xT(e.passed)} passed`:``,e.didNotPass>0?`${xT(e.didNotPass)} did not pass`:``].filter(Boolean).join(` · `)}var VT=`No tools`,HT=e=>`${e}'s tools could not be read.`,UT=e=>`${xT(e)} tools: the most one actor's registry holds`;function WT(e){let t=[`${e.label} ${e.name}`,e.archetype].filter(Boolean);return e.unreadable?[...t,HT(e.label)].join(`, `):e.tools===0?[...t,VT].join(`, `):[...t,ST(e.tools,`tool`,`tools`),e.didNotPass>0?`${xT(e.didNotPass)} did not pass`:``].filter(Boolean).join(`, `)}function GT(e,t){return[e,ST(t.tools,`tool`,`tools`),t.didNotPass>0?`${xT(t.didNotPass)} did not pass`:``].filter(Boolean).join(`, `)}var KT=e=>`Exporting ${xT(e)} tools…`,qT=`Could not export. Try again.`,JT={dialogName:`Choose actors`,listName:`Actors`,findLabel:`Find an actor`,findPlaceholder:`Name, archetype or A-number…`,clearSearchName:`Clear the actor search`,sortName:`Sort`,sortLead:`Sort:`,selectShown:`Select shown`,clear:`Clear`,done:`Done`,showAll:`Show all`,waiting:`Waiting to start`,unreadable:`The actors could not be read.`},YT={run:`Run order`,tools:`Most tools`,didNotPass:`Most forges that did not pass`},XT=(e,t)=>e===null?`Actors: All ${xT(t)}`:`Actors: ${xT(e)} of ${xT(t)}`,ZT=(e,t)=>`Showing ${xT(e)} of ${xT(t)} actors`;function QT(e,t,n){return`${ZT(e,t)} · ${DT(n,0)}`}function $T(e){return e.tools===0?VT:[ST(e.tools,`tool`,`tools`),e.didNotPass>0?`${xT(e.didNotPass)} did not pass`:``].filter(Boolean).join(` · `)}var eE=e=>`No actor matches “${e}”.`,tE={backdrop:`_backdrop_1mlna_1`,dialog:`_dialog_1mlna_15`,"sheet-up":`_sheet-up_1mlna_1`,header:`_header_1mlna_50`,headerEnd:`_headerEnd_1mlna_62`,key:`_key_1mlna_69`,iconKey:`_iconKey_1mlna_106`,lookGlyph:`_lookGlyph_1mlna_111`,number:`_number_1mlna_116`,linkNote:`_linkNote_1mlna_135`,linkSaid:`_linkSaid_1mlna_144`,linkText:`_linkText_1mlna_151`,name:`_name_1mlna_165`,nameInRow:`_nameInRow_1mlna_184`,head:`_head_1mlna_50`,label:`_label_1mlna_195`,outcome:`_outcome_1mlna_202`,attempts:`_attempts_1mlna_219`,attemptLine:`_attemptLine_1mlna_226`,reason:`_reason_1mlna_234`,reasonHeading:`_reasonHeading_1mlna_242`,reasonText:`_reasonText_1mlna_250`,reasonNote:`_reasonNote_1mlna_263`,line:`_line_1mlna_270`,recordFoot:`_recordFoot_1mlna_274`,recordKey:`_recordKey_1mlna_283`,recordBody:`_recordBody_1mlna_288`,nameInHead:`_nameInHead_1mlna_355`,lineHead:`_lineHead_1mlna_389`};function nE(){let{resolved:e,setTheme:t}=B(),n=e===`dark`?`light`:`dark`,r=n===`light`?eT.toLight:eT.toDark;return(0,R.jsx)(`button`,{type:`button`,className:`${tE.key} ${tE.iconKey}`,onClick:()=>t(n),"aria-label":r,title:r,children:(0,R.jsx)(`span`,{className:tE.lookGlyph,"aria-hidden":`true`,children:e===`dark`?`☀`:`☽`})})}var rE=te(),iE={tile:`_tile_1dw5u_1`,band:`_band_1dw5u_17`,label:`_label_1dw5u_26`},aE={2:28,3:32,4:40};function oE({index:e,colour:t}){let n=Jw(e),r={"--tile-size":`${aE[n.length]??aE[4]}px`,"--tile-band":t};return(0,R.jsxs)(`span`,{className:iE.tile,style:r,"data-actor-tile":n,translate:`no`,children:[(0,R.jsx)(`span`,{className:iE.band,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:iE.label,children:n})]})}var sE={strip:`_strip_1uso4_1`,cell:`_cell_1uso4_10`,more:`_more_1uso4_27`},cE=20;function lE({cells:e,max:t=cE}){let n=e.slice(0,Math.max(0,t)),r=e.length-n.length;return(0,R.jsxs)(`span`,{className:sE.strip,"aria-hidden":`true`,"data-forge-strip":e.length,children:[n.map((e,t)=>(0,R.jsx)(`span`,{className:sE.cell,"data-cell":e},t)),r>0&&(0,R.jsx)(`span`,{className:sE.more,children:Yw(r)})]})}function uE({count:e,lineHeights:t,scrollTop:n,viewport:r,overscan:i,keep:a}){if(e<=0)return{first:0,last:-1,padTop:0,padBottom:0};let o=e=>{let n=typeof t==`number`?t:t[e]??0;return Number.isFinite(n)&&n>0?n:0},s=Math.max(0,n),c=s+Math.max(0,r),l=0,u=-1,d=-1;for(let t=0;t<e;t+=1){let e=o(t);if(l>=c&&u>=0)break;u<0&&l+e>s&&(u=t),u>=0&&(d=t),l+=e}u<0&&(u=e-1,d=e-1);let f=Math.max(0,Math.floor(i)),p=Math.max(0,u-f),m=Math.min(e-1,d+f),h=(e,t)=>{let n=0;for(let r=e;r<t;r+=1)n+=o(r);return n};if(a!==void 0&&Number.isInteger(a)&&a>=0&&a<e){if(a>=p-1&&a<=m+1)p=Math.min(p,a),m=Math.max(m,a);else if(a<p)return{first:p,last:m,kept:a,gap:h(a+1,p),padTop:h(0,a),padBottom:h(m+1,e)};else return{first:p,last:m,kept:a,gap:h(m+1,a),padTop:h(0,p),padBottom:h(a+1,e)}}return{first:p,last:m,padTop:h(0,p),padBottom:h(m+1,e)}}var dE=`button:not([disabled]), a[href], input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])`;function fE(e){for(let t=e.parentElement;t&&t!==document.body&&t!==document.documentElement;t=t.parentElement){let{overflowY:e}=getComputedStyle(t);if((e===`auto`||e===`scroll`||e===`overlay`)&&t.scrollHeight>t.clientHeight+1)return t}return null}function pE(e){if(!e)return{top:0,bottom:window.innerHeight,padTop:0};let t=e.getBoundingClientRect().top+e.clientTop,n=Number.parseFloat(getComputedStyle(e).scrollPaddingTop);return{top:t,bottom:t+e.clientHeight,padTop:Number.isFinite(n)?n:0}}function mE(e){let t=e.getBoundingClientRect(),{top:n,bottom:r}=pE(fE(e));return{scrollTop:Math.max(0,n-t.top),viewport:Math.max(0,r-Math.max(n,t.top))}}function hE(e,t,n){let r=e.length>50,i=(0,L.useRef)(new Map),a=(0,L.useRef)(new Map),o=(0,L.useRef)(-1),[s,c]=(0,L.useState)(0),[l,u]=(0,L.useState)(()=>({scrollTop:0,viewport:typeof window>`u`?0:window.innerHeight})),d=(0,L.useMemo)(()=>e.map(e=>{let t=i.current.get(e.key);if(t!==void 0)return t;let n=a.current.get(e.kind);return n&&n.n>0?n.sum/n.n:e.estimate}),[e,s]),f=n!==null&&n>=0&&n<e.length?n:void 0,p=r?uE({count:e.length,lineHeights:d,scrollTop:l.scrollTop,viewport:l.viewport,overscan:8,keep:f}):{first:0,last:e.length-1,padTop:0,padBottom:0},m=(0,L.useRef)({heights:d,range:p,keep:f,windowed:r});m.current={heights:d,range:p,keep:f,windowed:r};let h=(0,L.useCallback)(()=>{let e=m.current;if(!t||!e.windowed)return;let n=mE(t),r=uE({count:e.heights.length,lineHeights:e.heights,scrollTop:n.scrollTop,viewport:n.viewport,overscan:8,keep:e.keep});(r.first!==e.range.first||r.last!==e.range.last||r.kept!==e.range.kept)&&u(n)},[t]);(0,L.useEffect)(()=>{if(!t)return;let e=0,n=()=>{e===0&&(e=window.requestAnimationFrame(()=>{e=0,h()}))};document.addEventListener(`scroll`,n,{capture:!0,passive:!0}),window.addEventListener(`resize`,n);let r=typeof ResizeObserver>`u`?null:new ResizeObserver(n);return r?.observe(t),n(),()=>{document.removeEventListener(`scroll`,n,{capture:!0}),window.removeEventListener(`resize`,n),r?.disconnect(),e!==0&&window.cancelAnimationFrame(e)}},[t,h]),(0,L.useLayoutEffect)(()=>{if(!t)return;let n=t.clientWidth;n>0&&Math.abs(n-o.current)>1&&(i.current.clear(),a.current.clear(),o.current=n);let r=!1;for(let n of t.querySelectorAll(`[data-line]`)){let t=e[Number(n.dataset.line)];if(!t)continue;let o=n.getBoundingClientRect().height;if(!(o>0))continue;let s=i.current.get(t.key);if(s!==void 0&&Math.abs(s-o)<.5)continue;i.current.set(t.key,o);let c=a.current.get(t.kind)??{sum:0,n:0};s===void 0?(c.sum+=o,c.n+=1):c.sum+=o-s,a.current.set(t.kind,c),r=!0}r?c(e=>e+1):h()});let g=(0,L.useCallback)(e=>{let n=m.current;if(!t||e<0||e>=n.heights.length)return;let r=0;for(let t=0;t<e;t+=1)r+=n.heights[t];let i=fE(t),{top:a,bottom:o,padTop:s}=pE(i),c=t.getBoundingClientRect().top+r,l=c+n.heights[e],u=c<a+s?c-(a+s):l>o?l-o:0;u!==0&&(i?i.scrollTop+=u:window.scrollBy(0,u)),h()},[t,h]);return{...p,windowed:r,scrollToLine:g}}function gE(e,t,n){for(let r=t+n;r>=0&&r<e.length;r+=n)if(e[r].focusable)return r;return-1}function _E(e,t){return gE(e,t===1?-1:e.length,t)}function vE(e,t){let[n,r]=(0,L.useState)(null),[i,a]=(0,L.useState)(null),o=(0,L.useRef)(null),s=(0,L.useRef)(e);s.current=e;let c=(0,L.useRef)(0),l=(0,L.useRef)(0);(0,L.useEffect)(()=>{let e=e=>{e.key===`Tab`&&(c.current=e.shiftKey?-1:1,window.setTimeout(()=>{c.current=0},0))};return document.addEventListener(`keydown`,e,!0),()=>document.removeEventListener(`keydown`,e,!0)},[]),(0,L.useEffect)(()=>{if(!t)return;let e=e=>{let n=e instanceof Element?e.closest(`[data-line]`):null;return n&&t.contains(n)?Number(n.dataset.line):-1},n=e=>{l.current=0,a(e)},i=i=>{let a=s.current,o=e(i.target),l=a[o];if(!l)return;let u=i.relatedTarget,d=c.current;if(d!==0&&!(u instanceof Node&&t.contains(u))){let e=_E(a,d);e>=0&&e!==o&&n(a[e].key)}r(e=>e?.key===l.key?e:{key:l.key,headKey:l.headKey})},o=e=>{let n=e.relatedTarget;n instanceof Node&&!t.contains(n)&&(t.closest(`[role="dialog"]`)??t.closest(`[data-toolbox-list]`))?.contains(n)&&r(null)},u=r=>{if(r.key!==`Tab`||r.altKey||r.ctrlKey||r.metaKey)return;let i=s.current,a=e(r.target);if(a<0)return;let o=gE(i,a,r.shiftKey?-1:1);o<0||t.querySelector(`[data-line="${o}"]`)||(r.preventDefault(),r.stopPropagation(),n(i[o].key))};return t.addEventListener(`focusin`,i),t.addEventListener(`focusout`,o),t.addEventListener(`keydown`,u,!0),()=>{t.removeEventListener(`focusin`,i),t.removeEventListener(`focusout`,o),t.removeEventListener(`keydown`,u,!0)}},[t]),(0,L.useLayoutEffect)(()=>{if(t){if(i!==null){let n=e.findIndex(e=>e.key===i),r=n>=0?t.querySelector(`[data-line="${n}"]`):null;if(r){a(null),(r.matches(dE)?r:r.querySelector(dE))?.focus();return}l.current+=1,n<0||l.current>3?a(null):o.current?.(n)}else if(n&&!e.some(e=>e.key===n.key)){let t=document.activeElement;(t===null||t===document.body||!t.isConnected)&&n.headKey&&e.some(e=>e.key===n.headKey)?(l.current=0,a(n.headKey)):r(null)}}});let u=n?.key??null,d=u===null?-1:e.findIndex(e=>e.key===u);return{keep:d>=0?d:null,scrollTo:o}}var K={list:`_list_yqq00_1`,count:`_count_yqq00_15`,keyRows:`_keyRows_yqq00_23`,lead:`_lead_yqq00_30`,key:`_key_yqq00_23`,actorsMenu:`_actorsMenu_yqq00_42`,keys:`_keys_yqq00_48`,segments:`_segments_yqq00_55`,segment:`_segment_yqq00_55`,menu:`_menu_yqq00_106`,menuSelect:`_menuSelect_yqq00_135`,menuMark:`_menuMark_yqq00_158`,find:`_find_yqq00_167`,findLabel:`_findLabel_yqq00_175`,field:`_field_yqq00_183`,input:`_input_yqq00_189`,clear:`_clear_yqq00_218`,groupMenu:`_groupMenu_yqq00_276`,menuKey:`_menuKey_yqq00_282`,menuKeyMark:`_menuKeyMark_yqq00_288`,groupList:`_groupList_yqq00_293`,groupItem:`_groupItem_yqq00_306`,groupCheck:`_groupCheck_yqq00_332`,empty:`_empty_yqq00_342`,emptyWords:`_emptyWords_yqq00_350`,rows:`_rows_yqq00_357`,head:`_head_yqq00_361`,row:`_row_yqq00_357`,openAll:`_openAll_yqq00_376`,stations:`_stations_yqq00_388`,items:`_items_yqq00_411`,item:`_item_yqq00_411`,sideMark:`_sideMark_yqq00_422`,top:`_top_yqq00_456`,name:`_name_yqq00_465`,outcome:`_outcome_yqq00_476`,lineCell:`_lineCell_yqq00_488`,does:`_does_yqq00_495`,metaCell:`_metaCell_yqq00_504`,meta:`_meta_yqq00_504`,same:`_same_yqq00_512`,actor:`_actor_yqq00_42`,groups:`_groups_yqq00_525`,fold:`_fold_yqq00_529`,foldTop:`_foldTop_yqq00_533`,foldHeading:`_foldHeading_yqq00_537`,foldHead:`_foldHead_yqq00_537`,chevron:`_chevron_yqq00_577`,chevronRoom:`_chevronRoom_yqq00_578`,foldTile:`_foldTile_yqq00_590`,foldName:`_foldName_yqq00_596`,foldActor:`_foldActor_yqq00_607`,foldCount:`_foldCount_yqq00_611`,foldNote:`_foldNote_yqq00_612`,foldStrip:`_foldStrip_yqq00_621`,foldHeadDept:`_foldHeadDept_yqq00_630`,foldStill:`_foldStill_yqq00_643`,foldWay:`_foldWay_yqq00_647`,department:`_department_yqq00_651`,deptLine:`_deptLine_yqq00_655`,pageFold:`_pageFold_yqq00_664`,pageFoldSummary:`_pageFoldSummary_yqq00_670`},yE={picker:`_picker_wqyxx_1`,"picker-up":`_picker-up_wqyxx_1`,top:`_top_wqyxx_32`,find:`_find_wqyxx_39`,sort:`_sort_wqyxx_47`,list:`_list_wqyxx_76`,rows:`_rows_wqyxx_85`,option:`_option_wqyxx_89`,box:`_box_wqyxx_118`,tile:`_tile_wqyxx_135`,who:`_who_wqyxx_141`,name:`_name_wqyxx_150`,dot:`_dot_wqyxx_155`,archetype:`_archetype_wqyxx_156`,second:`_second_wqyxx_161`,counts:`_counts_wqyxx_171`,strip:`_strip_wqyxx_178`,empty:`_empty_wqyxx_183`,emptyWords:`_emptyWords_wqyxx_192`,said:`_said_wqyxx_200`,foot:`_foot_wqyxx_212`,done:`_done_wqyxx_261`},bE=56,xE=`button:not([disabled]), input:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])`;function SE(){return(0,R.jsx)(`svg`,{width:`14`,height:`14`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M3 8.5L6.5 12L13 4.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2.25`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function CE({actors:e,chosen:t,max:n,tools:r=0,onChange:i,onClose:a,opener:o,where:s=`toolbox`}){let c=(0,L.useId)(),l=(0,L.useRef)(null),u=(0,L.useRef)(null),[d,f]=(0,L.useState)(``),[p,m]=(0,L.useState)(`run`),[h,g]=(0,L.useState)(``),_=Sy(`(min-width: 900px)`),v=Sy(`(min-width: 1440px)`),y=zw(e,r),b=(0,L.useMemo)(()=>Rw(Lw(e,d),p),[e,d,p]),x=b.length>0&&b.every(e=>t.has(e.index)),S=n!==void 0&&t.size>=n,C=(0,L.useRef)(!1);(0,L.useEffect)(()=>{C.current||(C.current=!0,pw({name:`forge_actor_picker_open`,where:s}))},[s]),(0,L.useEffect)(()=>{u.current?.focus({preventScroll:!0})},[]);let w=(0,L.useCallback)(()=>{a(),o?.isConnected&&o.focus()},[a,o]);(0,L.useEffect)(()=>{let e=l.current;if(!e)return;let t=t=>{if(t.key===`Escape`){t.preventDefault(),t.stopPropagation(),w();return}if(t.key!==`Tab`||t.altKey||t.ctrlKey||t.metaKey)return;t.stopPropagation();let n=Array.from(e.querySelectorAll(xE)).filter(e=>e.tabIndex>=0&&e.offsetParent!==null);if(n.length===0){t.preventDefault();return}let r=n.indexOf(document.activeElement);(t.shiftKey?r<=0:r===-1||r===n.length-1)&&(t.preventDefault(),n[t.shiftKey?n.length-1:0].focus())};return e.addEventListener(`keydown`,t),()=>e.removeEventListener(`keydown`,t)},[w]),(0,L.useEffect)(()=>{let e=e=>{let t=e.target;l.current?.contains(t)||o?.contains(t)||a()};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[a,o]);let[T,E]=(0,L.useState)(null);(0,L.useLayoutEffect)(()=>{if(!_||!o){E(null);return}let e=v?560:480,t=()=>{let t=o.getBoundingClientRect(),n=Math.round(t.bottom+4),r=Math.round(Math.max(8,Math.min(t.left,window.innerWidth-e-8))),i=Math.round(Math.max(240,Math.min(560,window.innerHeight-n-16)));E(e=>e&&e.top===n&&e.left===r&&e.maxHeight===i?e:{top:n,left:r,maxHeight:i})};return t(),document.addEventListener(`scroll`,t,{capture:!0,passive:!0}),window.addEventListener(`resize`,t),()=>{document.removeEventListener(`scroll`,t,{capture:!0}),window.removeEventListener(`resize`,t)}},[_,v,o]);let D=(0,L.useCallback)(t=>{i(t);let n=uw(t.size);n&&pw({name:`forge_actor_filter`,actors:n});let r=e.length;g(ZT(t.size===0?r:Math.min(t.size,r),r))},[i,e.length]),O=e=>{let n=new Set(t);if(n.has(e))n.delete(e);else if(S)return;else n.add(e);D(n)},k=(0,L.useMemo)(()=>b.map(e=>({key:e.label,kind:`option`,estimate:bE,focusable:!0})),[b]),[ee,A]=(0,L.useState)(0),[j,M]=(0,L.useState)(!1),[N,te]=(0,L.useState)(null),P=(0,L.useRef)(null),F=(0,L.useRef)(!1),I=Math.min(ee,Math.max(0,b.length-1)),ne=hE(k,N,j?I:null),re=I>=ne.first&&I<=ne.last||I===ne.kept?I:ne.first;(0,L.useEffect)(()=>{A(0),P.current&&(P.current.scrollTop=0)},[d,p]),(0,L.useLayoutEffect)(()=>{if(!F.current||!N)return;let e=N.querySelector(`[data-line="${I}"]`);e?(F.current=!1,e.focus({preventScroll:!0}),e.scrollIntoView({block:`nearest`})):ne.scrollToLine(I)});let z=e=>{b.length!==0&&(F.current=!0,A(Math.max(0,Math.min(b.length-1,e))))},B=e=>{switch(e.key){case`ArrowDown`:e.preventDefault(),z(I+1);break;case`ArrowUp`:e.preventDefault(),z(I-1);break;case`Home`:e.preventDefault(),z(0);break;case`End`:e.preventDefault(),z(b.length-1);break;case` `:case`Enter`:e.preventDefault(),b[I]&&O(b[I].index)}},ie=()=>{f(``),u.current?.focus()},ae=()=>{D(new Set),w()},oe=[],se=ne.kept!==void 0&&ne.kept<ne.first;ne.kept!==void 0&&se&&oe.push(ne.kept);for(let e=ne.first;e<=ne.last;e+=1)oe.push(e);ne.kept!==void 0&&!se&&oe.push(ne.kept);let ce=ne.kept===void 0||!ne.gap?-1:se?ne.first:ne.kept,le=ne.windowed?{paddingTop:ne.padTop,paddingBottom:ne.padBottom}:void 0,V=_&&T?{top:T.top,left:T.left,maxHeight:T.maxHeight}:void 0,ue=e=>{let n=b[e];if(!n)return null;let r=t.has(n.index),i=!r&&S,a=n.unreadable?HT(n.label):n.status===`waiting`?JT.waiting:$T(n.counts);return(0,R.jsxs)(`div`,{role:`option`,"aria-selected":r,"aria-disabled":i?!0:void 0,"aria-setsize":b.length,"aria-posinset":e+1,"aria-label":WT({label:n.label,name:n.name,archetype:n.archetype,tools:n.counts.tools,didNotPass:n.counts.didNotPass,unreadable:n.unreadable}),tabIndex:e===re?0:-1,className:yE.option,"data-actor":n.label,"data-line":e,onClick:()=>{A(e),O(n.index)},onFocus:()=>A(e),children:[(0,R.jsx)(`span`,{className:yE.box,"data-checked":r,"aria-hidden":`true`,children:r&&(0,R.jsx)(SE,{})}),(0,R.jsx)(`span`,{className:yE.tile,children:(0,R.jsx)(oE,{index:n.index,colour:Xn(n.index)})}),(0,R.jsxs)(`span`,{className:yE.who,translate:`no`,children:[(0,R.jsx)(`span`,{className:yE.name,"data-picker-name":!0,children:n.name}),n.archetype&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:yE.dot,"aria-hidden":`true`,children:` · `}),(0,R.jsx)(`span`,{className:yE.archetype,"data-picker-archetype":!0,children:n.archetype})]})]}),(0,R.jsxs)(`span`,{className:yE.second,children:[(0,R.jsx)(`span`,{className:yE.counts,"data-picker-counts":!0,children:a}),!n.unreadable&&(0,R.jsx)(`span`,{className:yE.strip,children:(0,R.jsx)(lE,{cells:n.strip,max:v?20:10})})]})]},n.label)},de=(0,R.jsx)(`div`,{ref:l,role:`dialog`,"aria-label":JT.dialogName,className:yE.picker,style:V,"data-actor-picker":!0,children:y===`error`?(0,R.jsxs)(`div`,{className:yE.empty,"data-picker-error":!0,children:[(0,R.jsx)(`p`,{className:yE.emptyWords,"data-text":`body`,children:JT.unreadable}),(0,R.jsx)(`button`,{type:`button`,className:K.key,onClick:ae,children:JT.showAll})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:yE.top,children:[(0,R.jsxs)(`div`,{className:yE.find,children:[(0,R.jsx)(`label`,{className:K.findLabel,htmlFor:c,children:JT.findLabel}),(0,R.jsxs)(`span`,{className:K.field,children:[(0,R.jsx)(`input`,{id:c,ref:u,className:K.input,type:`search`,placeholder:JT.findPlaceholder,value:d,onChange:e=>f(e.target.value),spellCheck:!1,autoComplete:`off`}),d!==``&&(0,R.jsx)(`button`,{type:`button`,className:K.clear,"aria-label":JT.clearSearchName,title:JT.clearSearchName,onClick:ie,children:(0,R.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M3 3L13 13M13 3L3 13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})})})]})]}),(0,R.jsxs)(`label`,{className:yE.sort,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:JT.sortLead}),(0,R.jsx)(`select`,{className:K.menuSelect,"aria-label":JT.sortName,value:p,onChange:e=>m(e.target.value),children:Fw.map(e=>(0,R.jsx)(`option`,{value:e,children:YT[e]},e))}),(0,R.jsx)(`svg`,{className:K.menuMark,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M3.5 6L8 10.5L12.5 6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})]})]}),b.length===0?(0,R.jsxs)(`div`,{className:yE.empty,"data-picker-empty":!0,children:[(0,R.jsx)(`p`,{className:yE.emptyWords,"data-text":`body`,children:eE(d.trim())}),(0,R.jsx)(`button`,{type:`button`,className:K.key,onClick:ie,children:JT.clear})]}):(0,R.jsx)(`div`,{ref:P,role:`listbox`,"aria-multiselectable":`true`,"aria-label":JT.listName,className:yE.list,onKeyDown:B,onFocus:()=>M(!0),onBlur:e=>{e.relatedTarget instanceof Node&&e.currentTarget.contains(e.relatedTarget)||M(!1)},children:(0,R.jsx)(`div`,{ref:te,className:yE.rows,style:le,"data-windowed":ne.windowed,children:oe.flatMap(e=>[e===ce?(0,R.jsx)(`div`,{"aria-hidden":`true`,"data-lines-gap":!0,style:{height:ne.gap}},`gap`):null,ue(e)])})}),(0,R.jsx)(`p`,{className:yE.said,role:`status`,children:h}),(0,R.jsxs)(`div`,{className:yE.foot,"data-picker-foot":!0,children:[(0,R.jsx)(`button`,{type:`button`,className:K.key,"aria-disabled":x||S||b.length===0?!0:void 0,onClick:()=>{x||S||b.length===0||D(Bw(t,b,n))},children:JT.selectShown}),(0,R.jsx)(`button`,{type:`button`,className:K.key,onClick:()=>D(new Set),children:JT.clear}),(0,R.jsx)(`button`,{type:`button`,className:`${K.key} ${yE.done}`,onClick:w,children:JT.done})]})]})}),fe=o?.closest(`[role="dialog"]`)??(typeof document>`u`?null:document.body);return fe?(0,rE.createPortal)(de,fe):de}var wE=e=>e.kind===`actor`?`actor:${e.actor.label}`:`department:${e.name}`,TE=e=>e.kind===`department`||!e.actor.unreadable&&e.actor.counts.tools>0;function EE(){let e=Sy(`(min-width: 1440px)`),t=Sy(`(min-width: 900px)`);return e?50:t?30:1/0}function DE(){return(0,R.jsx)(`svg`,{className:K.chevron,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M6 3.5L10.5 8L6 12.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function OE({head:e,open:t,onToggle:n,onShowInEventLog:r}){let i=(0,L.useId)(),a=EE();if(e.kind===`department`)return(0,R.jsx)(`h3`,{className:K.foldHeading,"data-fold-head":e.name,children:(0,R.jsxs)(`button`,{type:`button`,className:`${K.foldHead} ${K.foldHeadDept}`,"aria-expanded":t,"aria-label":GT(e.name,e.counts),onClick:n,children:[(0,R.jsx)(DE,{}),(0,R.jsx)(`span`,{className:K.foldName,"data-fold-name":!0,"data-text":`heading`,children:e.name}),(0,R.jsx)(`span`,{className:K.foldCount,"data-fold-count":!0,children:BT(e.counts)})]})});let{actor:o}=e,s=!o.unreadable&&o.counts.tools>=50,c=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:K.foldTile,children:(0,R.jsx)(oE,{index:o.index,colour:Xn(o.index)})}),(0,R.jsxs)(`span`,{className:K.foldName,"data-fold-name":!0,translate:`no`,"data-text":`heading`,children:[(0,R.jsx)(`span`,{className:K.foldActor,children:o.name}),o.archetype?` · ${o.archetype}`:``]}),o.unreadable?(0,R.jsx)(`span`,{className:K.foldCount,"data-fold-error":!0,children:HT(o.label)}):(0,R.jsx)(`span`,{className:K.foldCount,"data-fold-count":!0,children:o.counts.tools===0?VT:BT(o.counts)}),s&&(0,R.jsx)(`span`,{id:i,className:K.foldNote,"data-fold-note":!0,children:UT(50)}),!o.unreadable&&(0,R.jsx)(`span`,{className:K.foldStrip,children:(0,R.jsx)(lE,{cells:o.strip,max:a})})]}),l=WT({label:o.label,name:o.name,archetype:o.archetype,tools:o.counts.tools,didNotPass:o.counts.didNotPass,unreadable:o.unreadable});return TE(e)?(0,R.jsx)(`h3`,{className:K.foldHeading,"data-fold-head":o.label,children:(0,R.jsxs)(`button`,{type:`button`,className:K.foldHead,"aria-expanded":t,"aria-label":l,"aria-describedby":s?i:void 0,onClick:n,children:[(0,R.jsx)(DE,{}),c]})}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`h3`,{className:K.foldHeading,"data-fold-head":o.label,children:(0,R.jsxs)(`span`,{className:`${K.foldHead} ${K.foldStill}`,children:[(0,R.jsx)(`span`,{className:K.chevronRoom,"aria-hidden":`true`}),c]})}),o.unreadable&&r&&(0,R.jsx)(`div`,{className:K.foldWay,children:(0,R.jsx)(`button`,{type:`button`,className:K.key,onClick:r,children:hT.showInEventLog})})]})}var kE={glyph:`_glyph_bhdp0_1`,passed:`_passed_bhdp0_8`,rejected:`_rejected_bhdp0_12`,refused:`_refused_bhdp0_13`,failed:`_failed_bhdp0_14`,notJudged:`_notJudged_bhdp0_18`,didNotPass:`_didNotPass_bhdp0_22`};function AE(e,t,n){let r={fill:`none`,stroke:`currentColor`,strokeWidth:t,strokeLinecap:`round`,strokeLinejoin:`round`},i=(0,R.jsx)(`circle`,{cx:`10`,cy:`10`,r:`8.25`,...r});switch(e){case`passed`:return(0,R.jsx)(`path`,{fill:`currentColor`,fillRule:`evenodd`,d:`M1 10a9 9 0 1 0 18 0a9 9 0 1 0 -18 0Z M4.75 11.05L8.63 14.93L15.28 7.82L13.52 6.18L8.57 11.47L6.45 9.35Z`});case`rejected`:return(0,R.jsxs)(R.Fragment,{children:[i,(0,R.jsx)(`path`,{d:`M6.9 6.9L13.1 13.1M13.1 6.9L6.9 13.1`,...r})]});case`refused`:return(0,R.jsxs)(R.Fragment,{children:[i,(0,R.jsx)(`path`,{d:`M4.2 15.8L15.8 4.2`,...r})]});case`failed`:return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`path`,{d:`M10 2.2L18.2 16.8H1.8Z`,...r}),(0,R.jsx)(`path`,{d:`M10 7.4V12.2`,...r})]});case`notJudged`:return(0,R.jsxs)(R.Fragment,{children:[i,(0,R.jsx)(`path`,{d:`M7.7 7.9a2.4 2.4 0 1 1 3.5 2.1c-.8.4-1.2.9-1.2 1.7v.4`,...r}),(0,R.jsx)(`circle`,{cx:`10`,cy:`14.5`,r:`1.1`,fill:`currentColor`})]});case`didNotPass`:return(0,R.jsx)(`circle`,{cx:`10`,cy:`10`,r:`8.25`,...r,strokeLinecap:`butt`,strokeDasharray:n})}}function jE({kind:e,size:t}){let n=t===10?3:1.75,r=t===10?`5 4`:`2.6 2.1`;return(0,R.jsx)(`svg`,{className:`${kE.glyph} ${kE[e]}`,"data-glyph":e,width:t,height:t,viewBox:`0 0 20 20`,"aria-hidden":`true`,focusable:`false`,children:AE(e,n,r)})}var ME={cell:`_cell_1xygk_1`,trace:`_trace_1xygk_22`,station:`_station_1xygk_35`,stationKey:`_stationKey_1xygk_58`,mark:`_mark_1xygk_83`,name:`_name_1xygk_91`,result:`_result_1xygk_119`,evidence:`_evidence_1xygk_120`,fork:`_fork_1xygk_144`,forkLink:`_forkLink_1xygk_167`,forkWords:`_forkWords_1xygk_200`,chevron:`_chevron_1xygk_205`,row:`_row_1xygk_267`,spur:`_spur_1xygk_275`,rowStation:`_rowStation_1xygk_279`,segment:`_segment_1xygk_290`},NE=e=>e===`reached`||e===`stopped`,PE=e=>e===void 0?void 0:NE(e)?`solid`:`dashed`;function FE({model:e,station:t,size:n}){let r=e.stations[t];if(r===`stopped`){let r=e.stop;return(0,R.jsx)(jE,{kind:r&&r.station===t?r.glyph:`didNotPass`,size:n})}return(0,R.jsx)(`span`,{className:ME.cell,"data-cell":r})}function IE({mark:e,onAttempt:t,href:n}){let r=nw(e.outcome);return(0,R.jsx)(`div`,{className:ME.fork,"data-fork":e.attempt,children:(0,R.jsxs)(`a`,{className:ME.forkLink,href:n,"data-fork-attempt":e.attempt,onClick:n=>{n.defaultPrevented||n.button!==0||n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||(n.preventDefault(),t?.(e.attempt))},children:[(0,R.jsx)(jE,{kind:r,size:20}),(0,R.jsx)(`span`,{className:ME.forkWords,children:bT(e.attempt,qw[r])}),(0,R.jsx)(`svg`,{className:ME.chevron,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M6 3.5L10.5 8L6 12.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})]})})}function LE(e){return e===`notReached`?Uw.notReached:e===`unknown`?Uw.unknown:null}function RE({model:e,size:t,colour:n,open:r,onToggle:i,stationResult:a,renderEvidence:o,onAttempt:s,attemptHref:c}){let l=(0,L.useId)(),u={"--line":n};return t===`row`?(0,R.jsx)(`span`,{className:ME.row,style:u,"aria-hidden":`true`,"data-forge-line":`row`,children:tw.map((t,n)=>{let r=e.spurs.filter(e=>e.station===t);return(0,R.jsxs)(L.Fragment,{children:[n>0&&(0,R.jsx)(`span`,{className:ME.segment,"data-rail":PE(e.stations[t])}),(0,R.jsxs)(`span`,{className:ME.rowStation,"data-station":t,"data-state":e.stations[t],children:[(0,R.jsx)(FE,{model:e,station:t,size:10}),r.length>0&&(0,R.jsx)(`span`,{className:ME.spur,"data-spurs":r.length,children:r.map(e=>(0,R.jsx)(jE,{kind:nw(e.outcome),size:10},e.attempt))})]})]},t)})}):(0,R.jsx)(`ol`,{className:ME.trace,style:u,role:`list`,"aria-label":Kw,"data-forge-line":`trace`,children:tw.map((t,n)=>{let u=e.stations[t],d=o?.(t),f=d!=null&&d!==!1,p=NE(u)&&f,m=p&&!!r?.has(t),h=a?.(t)??LE(u),g=`${l}-${t}-result`,_=`${l}-${t}-evidence`,v=`${l}-${t}-name`,y=u===`notReached`||u===`unknown`,b=[...e.spurs.filter(e=>e.station===t),...e.branch&&e.branch.station===t?[e.branch]:[]];return(0,R.jsxs)(`li`,{className:ME.station,"data-station":t,"data-state":u,"data-open":m||void 0,"data-rail":PE(e.stations[tw[n+1]]),children:[(0,R.jsxs)(`button`,{type:`button`,className:ME.stationKey,"aria-label":Gw(t,u),"aria-expanded":p?m:void 0,"aria-controls":p?_:void 0,"aria-disabled":!p||void 0,"aria-describedby":!p&&h!=null?g:void 0,tabIndex:p?void 0:-1,onClick:p?()=>i?.(t):void 0,children:[(0,R.jsx)(`span`,{className:ME.mark,"aria-hidden":`true`,children:(0,R.jsx)(FE,{model:e,station:t,size:20})}),(0,R.jsx)(`span`,{id:v,className:ME.name,"data-text":`heading`,children:Hw[t]})]}),!m&&h!=null&&(0,R.jsx)(`div`,{id:g,className:ME.result,"data-quiet":y||void 0,"data-text":y?void 0:`body`,children:h}),p&&(0,R.jsx)(`div`,{id:_,className:ME.evidence,role:`region`,"aria-labelledby":v,hidden:!m,children:m?d:null}),b.map(e=>(0,R.jsx)(IE,{mark:e,onAttempt:s,href:c?c(e.attempt):`#`},e.attempt))]},t)})})}function zE(e){let t=e.split(`_`);return t.map((e,n)=>(0,R.jsxs)(L.Fragment,{children:[n<t.length-1?`${e}_`:e,n<t.length-1&&(0,R.jsx)(`wbr`,{})]},n))}function BE({entry:e,actorCount:t,onOpen:n,line:r,setSize:i,posInSet:a}){let o=(0,L.useId)(),s=Jw(e.actorIndex),c=nw(e.outcome),l=qw[c],u=e.attempts.length,d=e.description!==``&&e.description!==e.name,f=e.sameNameActors.map(Jw),p={"--actor":Xn(e.actorIndex)};return(0,R.jsxs)(`li`,{className:K.item,style:p,"data-tool-row":e.n,"data-tool-name":e.name,"data-actor":s,"data-outcome":e.outcome,"data-line":r,"aria-setsize":i,"aria-posinset":a,children:[(0,R.jsx)(`span`,{className:K.sideMark,"data-side-mark":!0,"aria-hidden":`true`}),(0,R.jsxs)(`button`,{type:`button`,className:K.row,"aria-label":IT({name:e.name,outcome:l,actorLabel:s,actorName:e.actorName,forges:u}),"aria-describedby":d?`${o}-does ${o}-meta`:`${o}-meta`,onClick:e=>n(e.currentTarget),children:[(0,R.jsxs)(`span`,{className:K.top,children:[(0,R.jsxs)(`span`,{className:K.name,"data-row-name":!0,"data-text":`heading`,children:[(0,R.jsxs)(`span`,{children:[`[`,e.n,`]`]}),` `,(0,R.jsx)(`span`,{translate:`no`,children:zE(e.name)})]}),(0,R.jsxs)(`span`,{className:K.outcome,"data-row-outcome":!0,children:[(0,R.jsx)(jE,{kind:c,size:20}),(0,R.jsx)(`span`,{children:l})]})]}),(0,R.jsx)(`span`,{className:K.lineCell,children:(0,R.jsx)(RE,{model:ow(e,NaN),size:`row`,colour:sw(e.actorIndex,t)})}),d&&(0,R.jsx)(`span`,{id:`${o}-does`,className:K.does,"data-row-does":!0,"data-text":`body`,children:e.description}),(0,R.jsxs)(`span`,{id:`${o}-meta`,className:K.metaCell,children:[(0,R.jsxs)(`span`,{className:K.meta,"data-row-meta":!0,children:[(0,R.jsx)(`span`,{className:K.actor,"data-row-actor":!0,children:`${s} ${e.actorName}`}),` · ${PT({department:e.firstForgedDepartment,turn:e.firstForgedTurn,uses:e.outcome===`passed`?cw(e):null,reforges:Math.max(0,u-1)})}`]}),f.length>0&&(0,R.jsx)(`span`,{className:K.same,"data-row-same":!0,children:FT(f)})]})]})]})}function VE(e,t,n,r=null){let i=n.trim().toLowerCase(),a=r===null?null:new Set(r);return t===`all`&&i===``&&a===null?e:e.filter(e=>(a===null||a.has(e.actorIndex))&&(t===`all`||e.outcome===t)&&(i===``||e.name.toLowerCase().includes(i)))}function HE(e){let t={tools:0,forges:0,reforges:0,passed:0,didNotPass:0};for(let n of e)t.tools+=n.counts.tools,t.forges+=n.counts.forges,t.reforges+=n.counts.reforges,t.passed+=n.counts.passed,t.didNotPass+=n.counts.didNotPass;return t}var UE=e=>e.firstForgedDepartment||Uw.unknown;function WE(e,t){let n=new Map;for(let r of e){let e=t(r),i=n.get(e);i?i.push(r):n.set(e,[r])}return[...n]}function GE(e){let t={tools:0,forges:0,reforges:0,passed:0,didNotPass:0};for(let n of e){let e=n.attempts.filter(e=>e.approved).length;t.tools+=1,t.forges+=n.attempts.length,t.reforges+=Math.max(0,n.attempts.length-1),t.passed+=e,t.didNotPass+=n.attempts.length-e}return t}function KE(e,t,n){return t===`none`?[{head:null,rows:e}]:t===`department`?WE(e,UE).map(([e,t])=>({head:{kind:`department`,name:e,counts:GE(t)},rows:t})):n.map(t=>{let n=e.filter(e=>e.actorIndex===t.index);return{head:{kind:`actor`,actor:t},rows:WE(n,UE).flatMap(([,e])=>e)}})}var qE={head:64,dept:40,row:112},JE=e=>`${e.actorIndex}:${e.name}`,YE=e=>e.kind===`head`?null:e.dept;function XE(e,t,n,r){let i=[];if(e===`none`)return t.forEach((e,t)=>{i.push({kind:`row`,key:JE(e),estimate:qE.row,focusable:!0,fold:-1,dept:null,entry:e,pos:t+1})}),{lines:i,rowCount:t.length};let a=0;return n.forEach((e,t)=>{let n=e.head;if(n===null)return;let o=wE(n),s=TE(n)&&e.rows.length>0&&r(o),c=TE(n)||n.kind===`actor`&&n.actor.unreadable;i.push({kind:`head`,key:o,estimate:qE.head,focusable:c,fold:t});let l=n.kind===`actor`?WE(e.rows,UE):[[null,e.rows]];for(let[e,n]of l){s&&e!==null&&i.push({kind:`dept`,key:`${o}|dept:${e}`,estimate:qE.dept,focusable:!1,headKey:o,fold:t,dept:e});for(let r of n)a+=1,s&&i.push({kind:`row`,key:`${o}|${JE(r)}`,estimate:qE.row,focusable:!0,headKey:o,fold:t,dept:e,entry:r,pos:a})}}),{lines:i,rowCount:a}}var ZE=8,QE=new Set,$E=[];function eD({value:e,onChoose:t}){let[n,r]=(0,L.useState)(!1),i=(0,L.useId)(),a=(0,L.useRef)(null),o=(0,L.useRef)(null),s=(0,L.useRef)([]);(0,L.useEffect)(()=>{n&&s.current[kw.indexOf(e)]?.focus()},[n,e]),(0,L.useEffect)(()=>{if(!n)return;let e=e=>{a.current?.contains(e.target)||r(!1)};return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[n]);let c=()=>{r(!1),o.current?.focus()},l=e=>{t(e),c()},u=e=>s.current[(e+kw.length)%kw.length]?.focus();return(0,R.jsxs)(`div`,{ref:a,className:K.groupMenu,children:[(0,R.jsxs)(`button`,{ref:o,type:`button`,className:`${K.key} ${K.menuKey}`,"aria-haspopup":`menu`,"aria-expanded":n,"aria-controls":n?i:void 0,onClick:()=>r(e=>!e),onKeyDown:e=>{(e.key===`ArrowDown`||e.key===`ArrowUp`)&&(e.preventDefault(),r(!0))},children:[(0,R.jsx)(`span`,{children:RT(e)}),(0,R.jsx)(`svg`,{className:K.menuKeyMark,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M3.5 6L8 10.5L12.5 6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),n&&(0,R.jsx)(`div`,{id:i,role:`menu`,"aria-label":LT.name,className:K.groupList,onKeyDown:e=>{let t=s.current.findIndex(e=>e===document.activeElement);switch(e.key){case`ArrowDown`:e.preventDefault(),u(t+1);break;case`ArrowUp`:e.preventDefault(),u(t-1);break;case`Home`:e.preventDefault(),u(0);break;case`End`:e.preventDefault(),u(kw.length-1);break;case`Enter`:case` `:e.preventDefault(),t>=0&&l(kw[t]);break;case`Escape`:e.preventDefault(),c();break;case`Tab`:c()}},children:kw.map((t,n)=>(0,R.jsxs)(`div`,{ref:e=>{s.current[n]=e},role:`menuitemradio`,"aria-checked":t===e,tabIndex:-1,className:K.groupItem,onClick:()=>l(t),children:[(0,R.jsx)(`svg`,{className:K.groupCheck,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M3 8.5L6.5 12L13 4.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})}),(0,R.jsx)(`span`,{children:LT[t]})]},t))})]})}function tD({inPage:e=!1}){let t=ew(),{show:n,find:r,group:i,actors:a,set:o}=Pw(),{openTrace:s,showActorLog:c}=Dw(),l=(0,L.useId)(),u=(0,L.useId)(),d=(0,L.useRef)(null),f=(0,L.useRef)(null),p=(0,L.useRef)(null),[m,h]=(0,L.useState)(!1),g=t.actors.length,_=(0,L.useMemo)(()=>Vw(a,g),[a,g]),v=(0,L.useMemo)(()=>_===null?t.actors:_.map(e=>t.actors[e]),[_,t.actors]),y=(0,L.useMemo)(()=>new Set(a.filter(e=>e<g)),[a,g]),b=(0,L.useMemo)(()=>VE(t.list,`all`,``,_),[t.list,_]),x=(0,L.useMemo)(()=>VE(b,n,r),[b,n,r]),S=i??Aw(g),C=n!==`all`||r.trim()!==``,w=(0,L.useMemo)(()=>{let e=b.filter(e=>e.outcome===`passed`).length;return[{id:`all`,count:b.length},{id:`passed`,count:e},{id:`did_not_pass`,count:b.length-e}].filter(e=>e.id===`all`||e.count>0||e.id===n)},[b,n]),T=(0,L.useMemo)(()=>{let e=KE(x,S,v);return C?e.filter(e=>e.head===null||e.rows.length>0||e.head.kind===`actor`&&e.head.actor.unreadable):e},[x,S,v,C]),E=_===null?DT(t.counts,g):QT(_.length,g,HE(v)),D=(0,L.useCallback)(e=>{o({actors:[...e].sort((e,t)=>e-t)})},[o]),O=(0,L.useCallback)(()=>h(!1),[]),[k,ee]=(0,L.useState)({group:S,all:null,toggled:QE}),A=(0,L.useMemo)(()=>k.group===S?k:{group:S,all:null,toggled:QE},[k,S]),j=g<=ZE,M=(0,L.useCallback)(e=>(A.all??j)!==A.toggled.has(e),[A,j]),N=T.filter(e=>e.head!==null&&TE(e.head)&&e.rows.length>0),te=N.length>0&&N.every(e=>M(wE(e.head))),P=S===`none`||N.length===0,F=e=>{pw({name:`forge_group_toggle`,scope:`one`}),ee(t=>{let n=t.group===S?t:{group:S,all:null,toggled:QE},r=new Set(n.toggled);return r.has(e)?r.delete(e):r.add(e),{...n,toggled:r}})},I=()=>{pw({name:`forge_group_toggle`,scope:`all`}),ee({group:S,all:!te,toggled:QE})},ne=e=>{e!==S&&pw({name:`forge_toolbox_group`,group:e}),o({group:e===Aw(g)?null:e})},re=e=>{e!==n&&pw({name:`forge_toolbox_filter`,show:e}),o({show:e})},z=(0,L.useCallback)((e,t)=>{s({actorIndex:e.actorIndex,toolName:e.name},t,`toolbox`)},[s]),{lines:B,rowCount:ie}=(0,L.useMemo)(()=>XE(S,x,T,M),[S,x,T,M]),[ae,oe]=(0,L.useState)(null),se=vE(B,ae),ce=hE(B,ae,se.keep);se.scrollTo.current=ce.scrollToLine;let le=()=>{o({find:``}),f.current?.focus()},V=()=>{re(`all`);let e=d.current?.querySelectorAll(`input[type="radio"][value="all"], select`);Array.from(e??[]).find(e=>e.offsetParent!==null)?.focus()},ue=e=>`${OT[e.id]} ${xT(e.count)}`,de=e=>{let t=B[e];return t.kind===`row`?(0,R.jsx)(BE,{entry:t.entry,actorCount:g,onOpen:e=>z(t.entry,e),line:e,setSize:ie,posInSet:t.pos},JE(t.entry)):null},fe=[],pe=ce.kept!==void 0&&ce.kept<ce.first;ce.kept!==void 0&&pe&&fe.push(ce.kept);for(let e=ce.first;e<=ce.last;e+=1)fe.push(e);ce.kept!==void 0&&!pe&&fe.push(ce.kept);let me=ce.kept===void 0||!ce.gap?-1:pe?ce.first:ce.kept,he=(e,t)=>{if(e!==me)return null;let n={height:ce.gap};return t?(0,R.jsx)(`li`,{role:`presentation`,"aria-hidden":`true`,"data-lines-gap":!0,style:n},`gap`):(0,R.jsx)(`div`,{"aria-hidden":`true`,"data-lines-gap":!0,style:n},`gap`)},ge=e=>e.flatMap(e=>[he(e,!0),de(e)]),_e=ce.windowed?{paddingTop:ce.padTop,paddingBottom:ce.padBottom}:void 0,ve=[];for(let e of fe){let t=ve[ve.length-1];t&&t.fold===B[e].fold?t.at.push(e):ve.push({fold:B[e].fold,at:[e]})}let ye=e=>{let t=[];for(let n of e){let e=YE(B[n])??``,r=t[t.length-1];r&&r.dept===e?r.at.push(n):t.push({dept:e,at:[n]})}return t};return(0,R.jsxs)(`div`,{className:K.list,"data-toolbox-list":e?`page`:`dialog`,children:[(0,R.jsx)(`p`,{className:K.count,"data-toolbox-count":!0,children:E}),t.list.length===0?(0,R.jsxs)(`div`,{className:K.empty,"data-toolbox-empty":`no-tools`,children:[(0,R.jsx)(lE,{cells:$E}),(0,R.jsx)(`p`,{className:K.emptyWords,"data-text":`body`,children:AT.noTools})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:K.keyRows,children:[(0,R.jsxs)(`div`,{className:K.lead,"data-toolbox-lead":!0,children:[(0,R.jsx)(eD,{value:S,onChoose:ne}),(0,R.jsxs)(`div`,{className:K.actorsMenu,children:[(0,R.jsx)(`button`,{ref:p,type:`button`,className:K.key,"aria-haspopup":`dialog`,"aria-expanded":m,onClick:()=>h(e=>!e),children:XT(_===null?null:_.length,g)}),m&&(0,R.jsx)(CE,{actors:t.actors,tools:t.list.length,chosen:y,onChange:D,onClose:O,opener:p.current})]})]}),(0,R.jsxs)(`div`,{ref:d,className:K.keys,"data-toolbox-keys":!0,children:[(0,R.jsx)(`div`,{className:K.segments,role:`radiogroup`,"aria-label":OT.name,children:w.map(e=>(0,R.jsxs)(`label`,{className:K.segment,"data-show":e.id,children:[(0,R.jsx)(`input`,{type:`radio`,name:u,value:e.id,checked:n===e.id,onChange:()=>re(e.id)}),(0,R.jsx)(`span`,{children:ue(e)})]},e.id))}),(0,R.jsxs)(`label`,{className:K.menu,"data-toolbox-menu":!0,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:OT.menuLead}),(0,R.jsx)(`select`,{className:K.menuSelect,"aria-label":OT.name,value:n,onChange:e=>re(e.target.value),children:w.map(e=>(0,R.jsx)(`option`,{value:e.id,children:ue(e)},e.id))}),(0,R.jsx)(`svg`,{className:K.menuMark,width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M3.5 6L8 10.5L12.5 6`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})]}),(0,R.jsxs)(`div`,{className:K.find,children:[(0,R.jsx)(`label`,{className:K.findLabel,htmlFor:l,children:kT.label}),(0,R.jsxs)(`span`,{className:K.field,children:[(0,R.jsx)(`input`,{id:l,ref:f,className:K.input,type:`search`,placeholder:kT.placeholder,value:r,onChange:e=>o({find:e.target.value}),spellCheck:!1,autoComplete:`off`}),r!==``&&(0,R.jsx)(`button`,{type:`button`,className:K.clear,"aria-label":kT.clearName,title:kT.clearName,onClick:le,children:(0,R.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M3 3L13 13M13 3L3 13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})})})]})]})]})]}),x.length===0&&C?(0,R.jsx)(`div`,{className:K.empty,"data-toolbox-empty":r.trim()===``?`no-rows`:`no-match`,children:r.trim()===``?(0,R.jsxs)(R.Fragment,{children:[n===`did_not_pass`&&_===null&&(0,R.jsx)(`p`,{className:K.emptyWords,"data-text":`body`,children:AT.everyToolPassed}),(0,R.jsx)(`button`,{type:`button`,className:K.key,onClick:V,children:OT.all})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:K.emptyWords,"data-text":`body`,children:jT(r.trim())}),(0,R.jsx)(`button`,{type:`button`,className:K.key,onClick:le,children:kT.clear})]})}):(0,R.jsxs)(`div`,{className:K.rows,children:[(0,R.jsxs)(`div`,{className:K.head,children:[(0,R.jsx)(`button`,{type:`button`,className:`${K.key} ${K.openAll}`,"aria-disabled":P?!0:void 0,tabIndex:P?-1:void 0,onClick:P?void 0:I,children:te?zT.close:zT.open}),(0,R.jsx)(`span`,{className:K.stations,"data-toolbox-stations":!0,"aria-hidden":`true`,children:tw.map(e=>(0,R.jsx)(`span`,{children:Hw[e]},e))})]}),S===`none`?(0,R.jsx)(`ol`,{ref:oe,className:K.items,"data-toolbox-rows":!0,"data-line-count":B.length,"data-windowed":ce.windowed,style:_e,children:ge(fe)}):(0,R.jsx)(`div`,{ref:oe,role:`list`,className:K.groups,"data-toolbox-rows":!0,"data-line-count":B.length,"data-windowed":ce.windowed,style:_e,children:ve.map(({fold:e,at:t})=>{let n=T[e],r=n?.head??null;if(r===null)return null;let i=wE(r),a=TE(r)&&n.rows.length>0&&M(i),o=t.find(e=>B[e].kind===`head`),s=t.filter(e=>B[e].kind!==`head`);return(0,R.jsxs)(`div`,{role:`listitem`,"aria-setsize":T.length,"aria-posinset":e+1,className:K.fold,"data-fold":r.kind===`actor`?r.actor.label:r.name,children:[o!==void 0&&he(o,!1),o!==void 0&&(0,R.jsx)(`div`,{className:K.foldTop,"data-line":o,children:(0,R.jsx)(OE,{head:r,open:a,onToggle:()=>F(i),onShowInEventLog:r.kind===`actor`&&r.actor.unreadable?()=>c(r.actor.index):void 0})}),r.kind===`actor`?ye(s).map(({dept:e,at:t})=>{let n=t.find(e=>B[e].kind===`dept`),r=t.filter(e=>B[e].kind===`row`);return(0,R.jsxs)(`div`,{className:K.department,children:[n!==void 0&&he(n,!1),n!==void 0&&(0,R.jsx)(`h4`,{className:K.deptLine,"data-dept-line":!0,"data-line":n,children:e}),r.length>0&&(0,R.jsx)(`ol`,{className:K.items,children:ge(r)})]},e)}):s.length>0&&(0,R.jsx)(`ol`,{className:K.items,children:ge(s)})]},i)})})]})]})]})}var nD={dialog:`_dialog_x8cpw_1`,"sheet-up":`_sheet-up_x8cpw_1`,header:`_header_x8cpw_36`,headerEnd:`_headerEnd_x8cpw_48`,title:`_title_x8cpw_55`,exportInHeader:`_exportInHeader_x8cpw_73`,exportStatus:`_exportStatus_x8cpw_77`,footStatus:`_footStatus_x8cpw_95`,body:`_body_x8cpw_106`,foot:`_foot_x8cpw_95`,exportAtFoot:`_exportAtFoot_x8cpw_114`};function rD(e){return e.map(e=>({n:e.n,name:e.name,description:e.description,mode:e.mode,firstForgedTurn:e.firstForgedTurn,firstForgedDepartment:e.firstForgedDepartment,departments:[...e.departments],reuseCount:e.reuseCount,approved:e.approved,confidence:e.confidence,inputSchema:e.inputSchema,outputSchema:e.outputSchema,sampleOutput:e.sampleOutput,inputFields:e.inputFields,outputFields:e.outputFields,actor:Jw(e.actorIndex),actorName:e.actorName}))}var iD=500;function aD({covered:e,onClose:t}){let n=ew(),{show:r,find:i,actors:a}=Pw(),o=Qr(!0),s=(0,L.useRef)(null);(0,L.useEffect)(()=>{s.current?.focus()},[]);let c=(0,L.useRef)(e);c.current=e,(0,L.useEffect)(()=>{let e=e=>{e.key!==`Escape`||e.defaultPrevented||c.current||(e.preventDefault(),t())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t]);let[l,u]=(0,L.useState)({state:`idle`}),d=()=>{pw({name:`forge_record_export`,what:`toolbox`});let e=VE(n.list,r,i,Vw(a,n.actors.length)),t=()=>{try{rr(JSON.stringify(rD(e),null,2),NT),u({state:`idle`})}catch{u({state:`failed`})}};e.length<=iD?t():(u({state:`exporting`,tools:e.length}),requestAnimationFrame(()=>{window.setTimeout(t,0)}))},f=l.state===`exporting`?KT(l.tools):l.state===`failed`?qT:``;return(0,R.jsx)(`div`,{className:tE.backdrop,onMouseDown:e=>{e.target===e.currentTarget&&t()},children:(0,R.jsxs)(`div`,{ref:o,role:`dialog`,"aria-modal":`true`,"aria-label":wT(n.list.length),tabIndex:-1,className:nD.dialog,inert:e,children:[(0,R.jsxs)(`div`,{className:nD.header,"data-toolbox-header":!0,children:[(0,R.jsx)(`button`,{type:`button`,className:`${tE.key} ${tE.iconKey}`,onClick:()=>t(),"aria-label":ET,title:ET,children:(0,R.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M3 3L13 13M13 3L3 13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})})}),(0,R.jsx)(`h2`,{ref:s,className:nD.title,tabIndex:-1,"data-toolbox-title":!0,"data-text":`heading`,children:CT}),(0,R.jsxs)(`span`,{className:nD.headerEnd,children:[(0,R.jsx)(`button`,{type:`button`,className:`${tE.key} ${nD.exportInHeader}`,onClick:d,children:MT}),(0,R.jsx)(nE,{})]}),(0,R.jsx)(`span`,{className:nD.exportStatus,role:`status`,"data-export-status":!0,children:f})]}),(0,R.jsx)(`div`,{className:nD.body,children:(0,R.jsx)(tD,{})}),(0,R.jsxs)(`div`,{className:nD.foot,children:[(0,R.jsx)(`p`,{className:nD.footStatus,role:`status`,"data-export-status":!0,children:f}),(0,R.jsx)(`button`,{type:`button`,className:`${tE.key} ${nD.exportAtFoot}`,onClick:d,children:MT})]})]})})}var oD=`paracosm:forgeOpenStations`,sD=20,cD=e=>typeof e==`string`&&tw.includes(e);function lD(e){let t=new Map,n;try{n=e.getItem(oD)}catch{return t}if(!n)return t;let r;try{r=JSON.parse(n)}catch{return t}if(!r||typeof r!=`object`||Array.isArray(r))return t;for(let[e,n]of Object.entries(r))Array.isArray(n)&&t.set(e,tw.filter(e=>n.some(t=>cD(t)&&t===e)));return t}function uD(e,t){return lD(e).get(t)??[]}function dD(e,t,n){let r=lD(e);r.delete(t),r.set(t,tw.filter(e=>n.includes(e)));let i=[...r.keys()];for(let e of i.slice(0,Math.max(0,i.length-sD)))r.delete(e);try{e.setItem(oD,JSON.stringify(Object.fromEntries(r)))}catch{}}function fD(e,t,n){let r=new Set([e.deciding]);for(let e of t)n(e)&&r.add(e);return r}function pD(e){return t=>t===`request`||e&&(t===`judge`||t===`added`)}function mD(e,t){let n=null;try{n=new URL(e).searchParams.get(`replay`)}catch{}return n||t||`live`}var hD={open:`_open_o8eqn_1`,part:`_part_o8eqn_11`,heading:`_heading_o8eqn_18`,body:`_body_o8eqn_26`,meta:`_meta_o8eqn_34`,quiet:`_quiet_o8eqn_42`,code:`_code_o8eqn_49`,actor:`_actor_o8eqn_62`,rule:`_rule_o8eqn_68`,actorText:`_actorText_o8eqn_74`,link:`_link_o8eqn_81`,fieldsBar:`_fieldsBar_o8eqn_105`,switch:`_switch_o8eqn_110`,switchTrack:`_switchTrack_o8eqn_139`,caption:`_caption_o8eqn_167`,fields:`_fields_o8eqn_105`,confidence:`_confidence_o8eqn_247`,meter:`_meter_o8eqn_258`,meterFill:`_meterFill_o8eqn_267`,uses:`_uses_o8eqn_275`,use:`_use_o8eqn_275`,recordKeys:`_recordKeys_o8eqn_295`,recordSaid:`_recordSaid_o8eqn_307`,record:`_record_o8eqn_295`};function gD(e,t){let n=t.trim(),r=e=>String(e??``).trim()===n,i=[];for(let t of e){let e=t.data??{},n=t.type===`forge_attempt`&&r(e.name),a=t.type===`specialist_done`&&Array.isArray(e.forgedTools)&&e.forgedTools.some(e=>!!e&&typeof e==`object`&&r(e.name));if(!n&&!a)continue;let o={...e};delete o._filteredTools,i.push(o)}return i}function _D(e){try{return JSON.stringify(e,null,2)}catch{return null}}var vD=5e3;function yD({entry:e,frames:t,onShowInEventLog:n}){let r=(0,L.useId)(),i=(0,L.useMemo)(()=>_D(t),[t]),[a,o]=(0,L.useState)(null),s=(0,L.useRef)(null),c=(0,L.useRef)(0);(0,L.useEffect)(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);let l=e=>{s.current!==null&&window.clearTimeout(s.current),s.current=null,o(e),e===`copied`&&(s.current=window.setTimeout(()=>o(null),vD))},u=()=>{if(i===null)return;pw({name:`forge_record_export`,what:`record_copy`});let e=++c.current;Gr(i).then(()=>{e===c.current&&l(`copied`)},()=>{e===c.current&&l(`copyFailed`)})},d=()=>{if(i!==null){pw({name:`forge_record_export`,what:`record_download`});try{rr(i,gT(e.name)),l(null)}catch{l(`downloadFailed`)}}},f={copied:hT.copied,copyFailed:hT.copyFailed,downloadFailed:hT.downloadFailed};return(0,R.jsxs)(`section`,{className:hD.open,"data-record-panel":!0,"aria-labelledby":r,children:[(0,R.jsx)(`h3`,{id:r,className:hD.heading,"data-text":`heading`,children:hT.rawRecord}),i===null?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:hD.body,"data-text":`body`,children:hT.unreadable}),(0,R.jsx)(`div`,{className:hD.recordKeys,children:(0,R.jsx)(`button`,{type:`button`,className:hD.switch,onClick:n,children:hT.showInEventLog})})]}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:hD.recordKeys,children:[(0,R.jsx)(`button`,{type:`button`,className:hD.switch,onClick:u,children:hT.copy}),(0,R.jsx)(`button`,{type:`button`,className:hD.switch,onClick:d,children:hT.download}),(0,R.jsx)(`button`,{type:`button`,className:hD.switch,onClick:n,children:hT.showInEventLog}),(0,R.jsx)(`p`,{className:hD.recordSaid,role:`status`,children:a?f[a]:null})]}),(0,R.jsx)(`pre`,{className:hD.record,"data-raw-record":!0,translate:`no`,tabIndex:0,"aria-label":hT.rawRecord,children:i})]})]})}function bD({entry:e}){let t=cw(e);return(0,R.jsxs)(`div`,{className:hD.open,children:[(0,R.jsx)(`p`,{className:hD.body,"data-text":`body`,children:oT(t)}),e.history.length>0&&(0,R.jsx)(`ol`,{className:hD.uses,children:e.history.map((e,t)=>{let n=t===0||e.isReforge;return(0,R.jsxs)(`li`,{className:hD.use,"data-history-row":n?`forge`:`use`,children:[(0,R.jsx)(`p`,{className:hD.meta,children:mT(e.turn,e.department,e.eventTitle)}),e.output?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:hD.meta,children:pT.output}),(0,R.jsx)(`pre`,{className:hD.code,translate:`no`,children:e.output})]}):null,n&&(0,R.jsx)(`p`,{className:hD.quiet,children:pT.testNotRecorded})]},`${e.turn}-${e.eventIndex}-${e.department}-${t}`)})}),t===0&&(0,R.jsx)(`p`,{className:hD.quiet,children:pT.notUsed})]})}function xD({confidence:e}){let t=Math.min(1,Math.max(0,Number(e.toFixed(2))));return(0,R.jsxs)(`div`,{className:hD.open,children:[(0,R.jsx)(`h3`,{className:hD.heading,"data-text":`heading`,children:dT.heading}),(0,R.jsx)(`p`,{className:hD.meta,children:dT.notice}),(0,R.jsxs)(`div`,{className:hD.confidence,children:[(0,R.jsx)(`p`,{className:hD.body,"data-text":`body`,children:fT(e)}),(0,R.jsx)(`div`,{role:`meter`,className:hD.meter,"aria-label":dT.meterName,"aria-valuemin":0,"aria-valuemax":1,"aria-valuenow":t,children:(0,R.jsx)(`span`,{className:hD.meterFill,style:{width:`${t*100}%`},"data-meter-fill":!0})})]}),(0,R.jsx)(`p`,{className:hD.quiet,children:dT.wordsNotRecorded})]})}function SD({station:e}){return(0,R.jsx)(R.Fragment,{children:iT[e]})}function CD({reason:e}){let t=(0,L.useId)();return(0,R.jsxs)(`section`,{className:tE.reason,"aria-labelledby":t,children:[(0,R.jsx)(`h3`,{id:t,className:tE.reasonHeading,"data-text":`heading`,children:rT.heading}),e?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`pre`,{className:tE.reasonText,translate:`no`,children:e}),(0,R.jsx)(`p`,{className:tE.reasonNote,children:rT.limit})]}):(0,R.jsx)(`p`,{className:tE.reasonNote,children:rT.none})]})}var wD=e=>typeof e==`object`&&!!e&&!Array.isArray(e);function TD(e){if(!wD(e))return``;let{type:t}=e;return typeof t==`string`?t:Array.isArray(t)?t.filter(e=>typeof e==`string`).join(` | `):``}function ED(e,t){if(wD(e)&&wD(e.properties)){let t=Array.isArray(e.required)?e.required:[];return Object.entries(e.properties).map(([e,n])=>({name:e,type:TD(n),required:t.includes(e),description:wD(n)&&typeof n.description==`string`?n.description:``}))}return t.map(e=>({name:e,type:null,required:null,description:``}))}function DD(e,t){if(t.length===0||!wD(e)||!wD(e.properties))return e;let n=Object.keys(e.properties);return n.length===t.length&&t.every(e=>n.includes(e))?e:void 0}function OD(e,t,n){return[`sim-event-${e}-${t}-${n}`,`turn-row-${t}-h`].find(e=>document.getElementById(e)!==null)??null}function kD({caption:e,rows:t,none:n}){let r=(0,L.useId)(),[i,a,o,s]=uT.columns;return t.length===0?(0,R.jsxs)(`div`,{className:hD.part,children:[(0,R.jsx)(`p`,{className:hD.caption,"data-text":`heading`,children:e}),(0,R.jsx)(`p`,{className:hD.quiet,children:n})]}):(0,R.jsxs)(`table`,{className:hD.fields,role:`table`,"aria-labelledby":r,children:[(0,R.jsx)(`caption`,{id:r,className:hD.caption,"data-text":`heading`,children:e}),(0,R.jsx)(`thead`,{role:`rowgroup`,children:(0,R.jsx)(`tr`,{role:`row`,children:uT.columns.map(e=>(0,R.jsx)(`th`,{role:`columnheader`,scope:`col`,children:e},e))})}),(0,R.jsx)(`tbody`,{role:`rowgroup`,children:t.map(e=>(0,R.jsxs)(`tr`,{role:`row`,children:[(0,R.jsx)(`td`,{role:`cell`,"data-label":i,"data-code":``,translate:`no`,children:e.name}),e.type===null?(0,R.jsx)(`td`,{role:`cell`,"data-label":a,"data-quiet":``,children:uT.notRecorded}):(0,R.jsx)(`td`,{role:`cell`,"data-label":a,"data-code":``,translate:`no`,children:e.type}),(0,R.jsx)(`td`,{role:`cell`,"data-label":o,children:e.required===null?``:e.required?uT.yes:uT.no}),(0,R.jsx)(`td`,{role:`cell`,"data-label":s,children:e.description})]},e.name))})]})}function AD({entry:e,attempt:t,actor:n,onGoToEvent:r}){let[i,a]=(0,L.useState)(!1),o=(0,L.useId)(),s=t??e.history[0]??null,c=s?.turn??e.firstForgedTurn,l=s?.eventIndex??0,u=s?.department||e.firstForgedDepartment,d=s?.eventTitle??``,f=t?.description||e.description,[p,m]=(0,L.useState)(null);(0,L.useEffect)(()=>{m(OD(e.actorIndex,c,l))},[e.actorIndex,c,l]);let h=e=>{let t=p?document.getElementById(p):null;t&&(e.preventDefault(),r(t))},g=t&&t.inputFields.length>0?t.inputFields:e.inputFields,_=t&&t.outputFields.length>0?t.outputFields:e.outputFields,v=DD(e.inputSchema,t?t.inputFields:[]),y=DD(e.outputSchema,t?t.outputFields:[]),b=v!=null||y!=null;return(0,R.jsxs)(`div`,{className:hD.open,children:[(0,R.jsxs)(`div`,{className:hD.actor,style:{"--actor":n.colour},"data-actor-line":!0,children:[(0,R.jsx)(`span`,{className:hD.rule,"aria-hidden":`true`,"data-actor-rule":!0}),(0,R.jsxs)(`div`,{className:hD.actorText,children:[(0,R.jsx)(`p`,{className:hD.meta,children:cT({label:n.label,name:n.name,archetype:n.archetype,department:u,turn:c,eventTitle:d})}),p&&d&&(0,R.jsx)(`a`,{className:hD.link,href:`#${p}`,onClick:h,children:lT(d)})]})]}),(0,R.jsxs)(`div`,{className:hD.part,children:[(0,R.jsx)(`h3`,{id:o,className:hD.heading,"data-text":`heading`,children:uT.whatItDoes}),(0,R.jsx)(`p`,{className:hD.body,"data-text":`body`,children:f})]}),(0,R.jsxs)(`div`,{className:hD.part,children:[b&&(0,R.jsx)(`div`,{className:hD.fieldsBar,children:(0,R.jsxs)(`button`,{type:`button`,role:`switch`,"aria-checked":i,className:hD.switch,onClick:()=>a(e=>!e),children:[(0,R.jsx)(`span`,{className:hD.switchTrack,"aria-hidden":`true`}),uT.rawJson]})}),i&&b?(0,R.jsx)(`pre`,{className:hD.code,translate:`no`,"data-raw-json":!0,children:JSON.stringify({input:v??null,output:y??null},null,2)}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(kD,{caption:uT.inputFields,rows:ED(v,g),none:uT.noInputFields}),(0,R.jsx)(kD,{caption:uT.outputFields,rows:ED(y,_),none:uT.noOutputFields})]})]})]})}var jD=5e3;function MD(){let[e,t]=(0,L.useState)(()=>typeof navigator>`u`||navigator.onLine!==!1);return(0,L.useEffect)(()=>{let e=()=>t(navigator.onLine!==!1);return window.addEventListener(`online`,e),window.addEventListener(`offline`,e),()=>{window.removeEventListener(`online`,e),window.removeEventListener(`offline`,e)}},[]),e}function ND(){try{return window.localStorage}catch{return null}}function PD({entry:e,attempt:t,open:n,actorCount:r,runKey:i,sessionId:a=null,events:o,onClose:s,onGoToEvent:c,onShowInEventLog:l,onShown:u}){let d=ew(),f=Qr(!0),p=(0,L.useRef)(null),m=(0,L.useRef)(null),h=(0,L.useId)();(0,L.useEffect)(()=>{[p.current,m.current].find(e=>e!==null&&e.offsetParent!==null)?.focus()},[]),(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(e.preventDefault(),s())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[s]);let[g,_]=(0,L.useState)(t),v=e.attempts.length,y=aw(e,g??NaN),b=y>0?e.attempts[y-1]:null,x=b?b.approved?`passed`:`did_not_pass`:e.outcome,S=x===`passed`,C=b?b.errorReason:e.errorReason??null,w=b?.confidence??e.confidence,T=ow(e,y),E=(0,L.useMemo)(()=>pD(S),[S]),D=tw.filter(e=>(T.stations[e]===`reached`||T.stations[e]===`stopped`)&&E(e)),O=(0,L.useMemo)(()=>mD(window.location.href,i),[i]),[k,ee]=(0,L.useState)(()=>{let e=ND(),t=e?uD(e,O):[];return fD(T,[...t,...n??[]],E)}),A=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(!A.current){A.current=!0;for(let e of tw)e!==T.deciding&&k.has(e)&&pw({name:`forge_station_open`,station:e,via:`kept`})}},[T.deciding,k]);let j=e=>{ee(e);let t=ND();t&&dD(t,O,[...e])},M=e=>{let t=new Set(k);t.has(e)?t.delete(e):(t.add(e),pw({name:`forge_station_open`,station:e,via:`press`})),j(t)},N=D.every(e=>k.has(e)),te=()=>{if(!N)for(let e of D)k.has(e)||pw({name:`forge_station_open`,station:e,via:`open_all`});j(new Set(N?D.filter(e=>e===T.deciding):D))},P=(0,L.useRef)(null),F=(t,n)=>{let r=aw(e,t);if(r===0||r===y)return;let i=e.attempts[r-1].approved;ee(fD(ow(e,r),[...k],pD(i))),P.current=n?y:null,_(r)},I=(0,L.useRef)(y);(0,L.useEffect)(()=>{I.current!==y&&(I.current=y,g===void 0&&ee(e=>fD(T,[...e],E)))},[y,g,T,E]),(0,L.useEffect)(()=>{let e=P.current;P.current=null,e!==null&&(f.current?.querySelector(`[data-fork-attempt="${e}"]`)??[p.current,m.current].find(e=>e!==null&&e.offsetParent!==null))?.focus()},[y,f]),(0,L.useEffect)(()=>{u?.({attempt:y,open:tw.filter(e=>k.has(e))})},[u,y,k]);let{shared:ne,share:re,clear:z}=Ti(),B=MD(),ie=(0,L.useId)();(0,L.useEffect)(()=>{if(ne?.state!==`copied`)return;let e=window.setTimeout(z,jD);return()=>window.clearTimeout(e)},[ne,z]);let ae=()=>{a&&(pw({name:`forge_link_copy`}),re(ww(window.location.origin,a,Tw(window.location.href),{actorIndex:e.actorIndex,toolName:e.name,...y>0?{attempt:y}:{},open:tw.filter(e=>k.has(e))},d)))},oe=ne?.state===`refused`||ne?.state===`unanswered`,[se,ce]=(0,L.useState)(!1),le=(0,L.useMemo)(()=>se?gD(o,e.name):[],[se,o,e.name]),V=()=>{pw({name:`forge_log_jump`}),l()},ue=t=>{switch(t){case`request`:return b?.description||e.description;case`code`:return S?(0,R.jsx)(SD,{station:`code`}):null;case`tests`:return S?(0,R.jsx)(SD,{station:`tests`}):null;case`judge`:return S?aT(w):null;case`added`:return S?oT(cw(e)):null}},de=d.actors[e.actorIndex];return(0,R.jsx)(`div`,{className:tE.backdrop,onMouseDown:e=>{e.target===e.currentTarget&&s()},children:(0,R.jsxs)(`div`,{ref:f,role:`dialog`,"aria-modal":`true`,"aria-label":Xw(e.name,e.n),tabIndex:-1,className:tE.dialog,children:[(0,R.jsxs)(`div`,{className:tE.header,"data-forge-header":!0,children:[(0,R.jsx)(`button`,{type:`button`,className:`${tE.key} ${tE.iconKey}`,onClick:()=>s(),"aria-label":Qw,title:Qw,children:(0,R.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M3 3L13 13M13 3L3 13`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`})})}),(0,R.jsx)(oE,{index:e.actorIndex,colour:Xn(e.actorIndex)}),(0,R.jsx)(`span`,{className:tE.number,children:Zw(e.n)}),(0,R.jsx)(`h2`,{ref:p,className:`${tE.name} ${tE.nameInRow}`,tabIndex:-1,translate:`no`,"data-text":`heading`,children:e.name}),(0,R.jsxs)(`span`,{className:tE.headerEnd,children:[a&&(0,R.jsx)(`button`,{type:`button`,className:`${tE.key} ${tE.iconKey}`,onClick:ae,"aria-label":$w.key,"aria-describedby":ie,title:$w.key,children:(0,R.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M6.5 9.5L9.5 6.5M7 4.5L8.5 3a2.5 2.5 0 0 1 3.5 3.5L10.5 8M9 11.5L7.5 13A2.5 2.5 0 0 1 4 9.5L5.5 8`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),(0,R.jsx)(nE,{})]})]}),a&&(0,R.jsxs)(`div`,{id:ie,className:tE.linkNote,role:`status`,"aria-live":`polite`,"data-link-note":!0,children:[!B&&(0,R.jsx)(`p`,{className:tE.linkSaid,children:$w.offline}),ne?.state===`copied`&&(0,R.jsx)(`p`,{className:tE.linkSaid,children:$w.copied}),oe&&ne&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`p`,{className:tE.linkSaid,children:$w.failed}),(0,R.jsx)(`p`,{className:tE.linkText,"data-tool-link":!0,translate:`no`,children:ne.url})]})]}),(0,R.jsxs)(`div`,{className:tE.head,"data-forge-head":!0,children:[v>1&&(0,R.jsxs)(`div`,{className:tE.attempts,role:`group`,"aria-label":yT(y,v),children:[(0,R.jsx)(`button`,{type:`button`,className:`${tE.key} ${tE.iconKey}`,"aria-label":_T.previous,title:_T.previous,"aria-disabled":y<=1||void 0,onClick:()=>{y>1&&F(y-1,!1)},children:(0,R.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M10 3.5L5.5 8L10 12.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})}),(0,R.jsx)(`span`,{className:tE.attemptLine,"data-attempt-line":!0,"aria-hidden":`true`,children:y===v?vT(y,v):yT(y,v)}),(0,R.jsx)(`button`,{type:`button`,className:`${tE.key} ${tE.iconKey}`,"aria-label":_T.next,title:_T.next,"aria-disabled":y>=v||void 0,onClick:()=>{y<v&&F(y+1,!1)},children:(0,R.jsx)(`svg`,{width:`16`,height:`16`,viewBox:`0 0 16 16`,"aria-hidden":`true`,focusable:`false`,children:(0,R.jsx)(`path`,{d:`M6 3.5L10.5 8L6 12.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`})})})]}),(0,R.jsx)(`p`,{className:tE.label,children:tT}),(0,R.jsx)(`h2`,{ref:m,className:`${tE.name} ${tE.nameInHead}`,tabIndex:-1,translate:`no`,"data-text":`heading`,children:e.name}),(0,R.jsxs)(`p`,{className:tE.outcome,"data-forge-outcome":!0,"data-text":`heading`,children:[(0,R.jsx)(jE,{kind:nw(x),size:20}),(0,R.jsx)(`span`,{children:nT[x]})]}),!S&&(0,R.jsx)(CD,{reason:C})]}),(0,R.jsxs)(`div`,{className:tE.line,children:[D.length>1&&(0,R.jsx)(`div`,{className:tE.lineHead,children:(0,R.jsx)(`button`,{type:`button`,className:tE.key,"aria-label":N?sT.closeName:sT.openName,onClick:te,children:N?sT.close:sT.open})}),(0,R.jsx)(RE,{model:T,size:`trace`,colour:sw(e.actorIndex,r),open:k,onToggle:M,stationResult:ue,renderEvidence:t=>{if(!E(t))return null;switch(t){case`request`:return(0,R.jsx)(AD,{entry:e,attempt:b,actor:{label:de?.label??Jw(e.actorIndex),name:e.actorName,archetype:de?.archetype??``,colour:Xn(e.actorIndex)},onGoToEvent:c});case`judge`:return(0,R.jsx)(xD,{confidence:w});case`added`:return(0,R.jsx)(bD,{entry:e});default:return null}},onAttempt:e=>F(e,!0)})]}),(0,R.jsxs)(`div`,{className:tE.recordFoot,children:[(0,R.jsx)(`button`,{type:`button`,className:`${tE.key} ${tE.recordKey}`,"aria-expanded":se,"aria-controls":h,onClick:()=>ce(e=>!e),children:hT.key}),(0,R.jsx)(`div`,{id:h,className:tE.recordBody,hidden:!se,children:se&&(0,R.jsx)(yD,{entry:e,frames:le,onShowInEventLog:V})})]})]})})}var FD={trace:null,toolbox:!1},ID=[];function LD(e){let{show:t,find:n,group:r,actors:i}=bw(e,{getEntryByNumber:()=>void 0,actors:[]},!1).state.toolbox;return{show:Ow.includes(t)?t:`all`,find:n??``,group:kw.includes(r)?r:null,actors:[...new Set((i??[]).map(e=>e-1))].sort((e,t)=>e-t)}}var RD=(e,t)=>e.length===t.length&&e.every((e,n)=>e===t[n]),zD=(e,t)=>e.show===t.show&&e.find===t.find&&e.group===t.group&&RD(e.actors,t.actors);function BD({state:e,runKey:t,sessionId:n,showToolLog:r,children:i}){let a=ew(),[o,s]=(0,L.useState)(FD),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(!1),d=(0,L.useRef)(!1),f=(0,L.useRef)(0),p=(0,L.useRef)(null),m=(0,L.useRef)(null),h=(0,L.useRef)(a);h.current=a;let g=(0,L.useRef)(e.isComplete);g.current=e.isComplete;let _=(0,L.useRef)(o);_.current=o;let v=(0,L.useRef)(null),[y,b]=(0,L.useState)(null),[x,S]=(0,L.useState)(()=>typeof window>`u`?jw:LD(window.location.href)),C=(0,L.useRef)(x),w=(0,L.useCallback)(()=>{let e=window.location.href,t=Sw(e,{...u.current&&d.current?{open:!0}:{},...C.current});if(t!==e)try{window.history.replaceState(window.history.state,``,t)}catch{}},[]),T=(0,L.useCallback)(e=>{let t=C.current,n={...t,...e};zD(n,t)||(C.current=n,S(n),w())},[w]),E=(0,L.useCallback)(()=>{d.current||=(v.current=window.location.href,window.history.pushState({forgeView:!0},``),!0)},[]),D=(0,L.useCallback)((e,t,n)=>{h.current.getEntryFor(e.actorIndex,e.toolName)&&(n&&pw({name:`forge_trace_open`,from:n}),u.current?l.current=t??null:c.current=t??null,E(),b(null),s(t=>({trace:e,toolbox:t.toolbox})))},[E]),O=(0,L.useCallback)((e,t)=>{u.current||(t&&pw({name:`forge_toolbox_open`,from:t}),c.current=e??null,u.current=!0,E(),w(),s(e=>({trace:e.trace,toolbox:!0})))},[E,w]),k=(0,L.useCallback)((e,t)=>{if(e instanceof HTMLElement&&(c.current=e,p.current=e),l.current=null,u.current=!1,s(FD),d.current){d.current=!1;let e=v.current;v.current=null,e!==null&&e!==window.location.href&&window.history.replaceState(window.history.state,``,e),f.current+=1,m.current=t??null,window.history.back()}else t?.()},[]),ee=(0,L.useCallback)(()=>{if(!u.current){k();return}b(null),s({trace:null,toolbox:!0});let e=window.location.href,t=Cw(e,gw);t!==e&&window.history.replaceState(window.history.state,``,t)},[k]),A=(0,L.useCallback)(()=>k(),[k]);(0,L.useEffect)(()=>{let e=()=>{if(f.current>0){--f.current,w();let e=m.current;m.current=null,e?.();let t=p.current;p.current=null,t?.isConnected&&requestAnimationFrame(()=>{t.scrollIntoView({block:`nearest`}),document.activeElement!==t&&t.focus({preventScroll:!0})})}else if(d.current)_.current.trace&&u.current?(b(null),s({trace:null,toolbox:!0}),d.current=!1,E(),w()):(d.current=!1,v.current=null,l.current=null,u.current=!1,s(FD),w());else{if(window.history.state?.forgeView!==!0)return;let{state:e}=bw(window.location.href,h.current,g.current);if(!e.trace&&!e.toolbox.open)return;d.current=!0,v.current=Sw(Cw(window.location.href,gw),{open:!1,...C.current}),u.current=e.toolbox.open,b(null),s({trace:e.trace??null,toolbox:e.toolbox.open})}};return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[E,w]);let j=o.trace,M=j?a.getEntryFor(j.actorIndex,j.toolName):void 0,N=M?e.actors[e.actorIds[M.actorIndex]]?.events??ID:ID,te=(0,L.useCallback)(()=>{if(!M)return;let{name:e,actorName:t}=M;k(null,()=>r?.(e,t))},[M,k,r]),P=(0,L.useCallback)(t=>{let n=e.actorIds[t];n&&k(null,()=>r?.(``,n))},[e.actorIds,k,r]);(0,L.useEffect)(()=>{j&&!M&&ee()},[j,M,ee]),(0,L.useEffect)(()=>{if(!j||!M||!d.current)return;let e=window.location.href,t=xw(e,{trace:{actorIndex:M.actorIndex,toolName:M.name,...y&&y.attempt>0?{attempt:y.attempt}:{},...y?{open:y.open}:{}},toolbox:bw(e,a,!1).state.toolbox},a);t!==e&&window.history.replaceState(window.history.state,``,t)},[j,M,y,a]);let F=e.isComplete,I=(0,L.useRef)(null);(0,L.useEffect)(()=>{if(!F)return;let e=`${t??``}|${n??``}`;if(I.current===e)return;I.current=e;let r=window.location.href,{state:i,dangling:o}=bw(r,a,!0);o.length>0&&window.history.replaceState(window.history.state,``,Cw(r,o));let s=LD(window.location.href),c={...s,actors:s.actors.filter(e=>e<a.actors.length)};if(zD(c,C.current)||(C.current=c,S(c)),_.current.trace||_.current.toolbox)return;let l=Sw(Cw(window.location.href,gw),{open:!1,...c});l!==window.location.href&&window.history.replaceState(window.history.state,``,l),i.toolbox.open&&O(null),i.trace&&D(i.trace,null,`link`)},[F,t,n,a,D,O]);let ne=j!==null,re=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(ne){re.current=!0;return}if(!re.current||(re.current=!1,!o.toolbox))return;let e=l.current;l.current=null,e?.isConnected?e.focus():document.querySelector(`[data-toolbox-title]`)?.focus()},[ne,o.toolbox]);let z=j!==null||o.toolbox,B=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(z){B.current=!0;return}if(!B.current)return;B.current=!1;let e=c.current;c.current=null,e?.isConnected&&e.focus()},[z]);let ie=(0,L.useMemo)(()=>({openTrace:D,openToolbox:O,close:k,showActorLog:P,current:o}),[D,O,k,P,o]),ae=(0,L.useMemo)(()=>({...x,set:T}),[x,T]);return(0,R.jsx)(Ew.Provider,{value:ie,children:(0,R.jsxs)(Nw.Provider,{value:ae,children:[i,o.toolbox&&(0,R.jsx)(aD,{covered:j!==null,onClose:A}),j&&M&&(0,R.jsx)(PD,{entry:M,attempt:j.attempt,open:j.open,actorCount:e.actorIds.length,runKey:t,sessionId:F?n:null,events:N,onShown:b,onClose:ee,onGoToEvent:k,onShowInEventLog:te},`${M.actorIndex}:${M.name}`)]})})}var VD=420,HD=260;function UD({content:e,children:t,dot:n,block:r,disabled:i=!1}){let[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)({x:0,y:0}),l=(0,L.useRef)(null),u=(0,L.useRef)(void 0);L.useEffect(()=>{if(!a)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),o(!1))};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[a]);let d=(0,L.useCallback)(e=>{clearTimeout(u.current);let t=e.currentTarget.getBoundingClientRect(),n=Math.min(VD,window.innerWidth-20),r=t.left,i=t.top-HD-6;i<10&&(i=t.bottom+6),r+n>window.innerWidth-10&&(r=window.innerWidth-n-10),r<10&&(r=10),i+HD>window.innerHeight-10&&(i=window.innerHeight-HD-10),i<10&&(i=10),c({x:r,y:i}),o(!0)},[]),f=(0,L.useCallback)(()=>{u.current=setTimeout(()=>o(!1),100)},[]),p=a&&!i?(0,R.jsx)(`div`,{id:`paracosm-tooltip`,role:`tooltip`,onMouseEnter:()=>{clearTimeout(u.current),o(!0)},onMouseLeave:f,style:{position:`fixed`,left:s.x,top:s.y,zIndex:99999,background:`var(--bg-card)`,border:`2px solid var(--amber)`,borderRadius:`8px`,padding:`14px 18px`,fontSize:`var(--font-sm)`,color:`var(--text-1)`,lineHeight:1.6,width:`${VD}px`,maxWidth:`90vw`,maxHeight:`80vh`,overflowY:`auto`,boxShadow:`0 8px 40px rgba(0,0,0,.4)`,pointerEvents:`auto`,whiteSpace:`normal`,wordBreak:`break-word`,animation:`fadeUp 0.15s ease both`},children:e}):null;return(0,R.jsxs)(`span`,{ref:l,onMouseEnter:d,onMouseLeave:f,style:{position:`relative`,display:r?`block`:`inline-flex`,alignItems:r?void 0:`center`,width:r?`100%`:void 0,minWidth:r?0:void 0,cursor:`pointer`},tabIndex:0,"aria-describedby":a?`paracosm-tooltip`:void 0,onFocus:d,onBlur:f,children:[t,n&&(0,R.jsx)(`span`,{style:{width:`6px`,height:`6px`,borderRadius:`50%`,background:`var(--amber)`,opacity:a?.8:0,marginLeft:`3px`,transition:`opacity 0.15s`,flexShrink:0,display:`inline-block`,verticalAlign:`middle`},"aria-hidden":`true`}),p&&typeof document<`u`?(0,rE.createPortal)(p,document.body):null]})}var WD={root:`_root_sliyj_1`,triggerButton:`_triggerButton_sliyj_6`,triggerCaret:`_triggerCaret_sliyj_29`,menuPopover:`_menuPopover_sliyj_34`,menuButton:`_menuButton_sliyj_49`,loadFileButton:`_loadFileButton_sliyj_49`,runSavedButton:`_runSavedButton_sliyj_49`,menuButtonInnerLeft:`_menuButtonInnerLeft_sliyj_68`,menuButtonIcon:`_menuButtonIcon_sliyj_74`,disabled:`_disabled_sliyj_88`,runSavedBadge:`_runSavedBadge_sliyj_100`,savedCardsWrap:`_savedCardsWrap_sliyj_117`,savedStatus:`_savedStatus_sliyj_121`,savedError:`_savedError_sliyj_121`,loadFileBadge:`_loadFileBadge_sliyj_142`,sessionCard:`_sessionCard_sliyj_153`,sessionCardTitle:`_sessionCardTitle_sliyj_175`,sessionCardLine2:`_sessionCardLine2_sliyj_184`,sessionCardLine3:`_sessionCardLine3_sliyj_190`,tooltipHeading:`_tooltipHeading_sliyj_196`,historyRow:`_historyRow_sliyj_206`,historyRowLabel:`_historyRowLabel_sliyj_231`,historyRowBadge:`_historyRowBadge_sliyj_237`,historyList:`_historyList_sliyj_248`,historyCardWrap:`_historyCardWrap_sliyj_257`,historyCard:`_historyCard_sliyj_257`,historyCardTitle:`_historyCardTitle_sliyj_282`,historyCardLine2:`_historyCardLine2_sliyj_290`,historyCardLine3:`_historyCardLine3_sliyj_296`,historyDelete:`_historyDelete_sliyj_301`,historyClearAll:`_historyClearAll_sliyj_325`},GD=WD;function KD(e){let t=Math.max(0,Math.floor((Date.now()-e)/1e3));if(t<60)return`${t}s ago`;let n=Math.floor(t/60);if(n<60)return`${n}m ago`;let r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function qD(e){if(!e||e<=0)return`·`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function JD(e){return e==null?`·`:e<.005?`<$0.01`:`$${e.toFixed(2)}`}function YD({s:e,onPick:t}){let n=ia(e),r=n?`${n}${e.scenarioName?` · ${e.scenarioName}`:``}`:e.scenarioName||`Simulation Run`,i=e.title||e.scenarioName||r,a=[n,e.title&&e.scenarioName?e.scenarioName:``,e.turnCount==null?``:`${e.turnCount} turn${e.turnCount===1?``:`s`}`].filter(Boolean).join(` · `),o=`${new Date(e.createdAt).toLocaleString()} (${KD(e.createdAt)}) · ${qD(e.durationMs)} · ${JD(e.totalCostUSD)}`;return(0,R.jsxs)(`button`,{type:`button`,onClick:t,className:WD.sessionCard,children:[(0,R.jsx)(`div`,{className:WD.sessionCardTitle,children:i}),a&&(0,R.jsx)(`div`,{className:WD.sessionCardLine2,children:a}),(0,R.jsx)(`div`,{className:WD.sessionCardLine3,children:o})]})}function XD({onLoadFromFile:e,history:t=[],onRestoreHistory:n,onClearHistory:r,liveStateHasEvents:i=!1}){let[a,o]=(0,L.useState)(!1),[s,c]=(0,L.useState)(!1),[l,u]=(0,L.useState)(!0),d=(0,L.useRef)(null),{sessions:f,status:p,refresh:m}=Wn(),h=f.length>0;(0,L.useEffect)(()=>{a&&m()},[a,m]);let g=(0,L.useCallback)(()=>{o(!1),c(!1)},[]);(0,L.useEffect)(()=>{if(!a)return;let e=e=>{d.current&&!d.current.contains(e.target)&&g()},t=e=>{e.key===`Escape`&&g()};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[a,g]);let _=e=>{window.location.assign(q_(window.location.href,e))},v=()=>{g(),e?.()},y=K_(p,f);return(0,R.jsxs)(`div`,{ref:d,className:WD.root,children:[(0,R.jsx)(UD,{disabled:a,content:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:WD.tooltipHeading,children:`Run`}),(0,R.jsx)(`div`,{children:`Replays a saved run, or loads a saved JSON from disk. Click to open the menu.`})]}),children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-haspopup":`menu`,"aria-expanded":a,className:WD.triggerButton,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`▶`}),`RUN`,(0,R.jsx)(`span`,{"aria-hidden":`true`,className:WD.triggerCaret,children:`▾`})]})}),a&&(0,R.jsxs)(`div`,{role:`menu`,"aria-label":`Run actions`,className:WD.menuPopover,children:[(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:()=>h&&c(e=>!e),disabled:!h,className:[WD.runSavedButton,h?``:WD.disabled].filter(Boolean).join(` `),children:[(0,R.jsxs)(`span`,{className:WD.menuButtonInnerLeft,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:WD.menuButtonIcon,children:`↻`}),(0,R.jsx)(`span`,{children:`Run Saved Simulation`})]}),(0,R.jsx)(`span`,{className:[WD.runSavedBadge,h?``:WD.disabled].filter(Boolean).join(` `),children:h?`${f.length} cached · ${s?`hide`:`pick`}`:`no cache yet`})]}),s&&h&&(0,R.jsxs)(`div`,{className:WD.savedCardsWrap,children:[y===`cards`&&f.map(e=>(0,R.jsx)(YD,{s:e,onPick:()=>_(e.id)},e.id)),y===`loading`&&(0,R.jsx)(`div`,{className:WD.savedStatus,children:`Loading cached runs…`}),y===`error`&&(0,R.jsx)(`div`,{className:WD.savedError,children:`Could not reach /sessions. Try again in a moment.`}),y===`unavailable`&&(0,R.jsx)(`div`,{className:WD.savedStatus,children:`Session cache is disabled on this server.`})]}),t.length>0&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,className:GD.historyRow,onClick:()=>u(e=>!e),"aria-expanded":l,children:[(0,R.jsxs)(`span`,{className:GD.historyRowLabel,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`🕘`}),(0,R.jsx)(`span`,{children:`Local history`})]}),(0,R.jsxs)(`span`,{className:GD.historyRowBadge,children:[t.length,` recent · `,l?`hide`:`show`]})]}),l&&(0,R.jsxs)(`div`,{className:GD.historyList,children:[t.map(e=>{let t=Date.parse(e.createdAt)||e.id,r=(e.summary.actorNames??[]).join(` vs `)||e.scenarioShortName,a=e.summary.turnCount?`${e.summary.turnCount} turn${e.summary.turnCount===1?``:`s`}`:``,o=[r,r===e.scenarioShortName?``:e.scenarioShortName,a].filter(Boolean).join(` · `),s=`${KD(t)} · ${e.summary.eventCount} ev · ${JD(e.summary.totalCostUSD)}`;return(0,R.jsx)(`div`,{className:GD.historyCardWrap,children:(0,R.jsxs)(`button`,{type:`button`,className:GD.historyCard,onClick:()=>{(!i||window.confirm(`Replace current simulation with this history entry?`))&&(n?.(e),g())},children:[(0,R.jsx)(`div`,{className:GD.historyCardTitle,children:r}),(0,R.jsx)(`div`,{className:GD.historyCardLine2,children:o}),(0,R.jsx)(`div`,{className:GD.historyCardLine3,children:s})]})},e.id)}),r&&(0,R.jsx)(`button`,{type:`button`,className:GD.historyClearAll,title:`Wipe everything in this browser: saved-runs ring, event cache, current sim state. It also lets go of this browser's run on the server, stopping it if it is running. Run history, saved sessions and output files are kept: Delete server data in the ⋯ menu deletes those, where admin writes are on and an admin token is saved.`,onClick:()=>{window.confirm(`Clear all local browser state?
|
|
114
|
+
|
|
115
|
+
• Saved-runs ring (this dropdown)
|
|
116
|
+
• Event cache (Sim / Constellation / Log)
|
|
117
|
+
• Current SSE state
|
|
118
|
+
|
|
119
|
+
It also lets go of this browser's run on the server, and stops it if it is running.
|
|
120
|
+
|
|
121
|
+
Run history, saved sessions, and on-disk artifact files are kept (Delete server data in the ⋯ menu deletes those, where it shows).
|
|
122
|
+
|
|
123
|
+
Cannot be undone.`)&&r()},children:`Clear local data`})]})]}),e&&(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:v,className:WD.loadFileButton,children:[(0,R.jsxs)(`span`,{className:WD.menuButtonInnerLeft,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:WD.menuButtonIcon,children:`📁`}),(0,R.jsx)(`span`,{children:`Load from file…`})]}),(0,R.jsx)(`span`,{className:WD.loadFileBadge,children:`json export`})]})]})]})}var ZD={bar:`_bar_1ux9o_1`,logoLink:`_logoLink_1ux9o_7`,logoSpan:`_logoSpan_1ux9o_14`,logoImg:`_logoImg_1ux9o_21`,logoGlow:`_logoGlow_1ux9o_25`,brand:`_brand_1ux9o_33`,brandAccent:`_brandAccent_1ux9o_42`,agentosTag:`_agentosTag_1ux9o_46`,divider:`_divider_1ux9o_55`,scenarioName:`_scenarioName_1ux9o_60`,center:`_center_1ux9o_67`,meta:`_meta_1ux9o_71`,tokenInline:`_tokenInline_1ux9o_78`,tokenLabel:`_tokenLabel_1ux9o_83`,tokenValue:`_tokenValue_1ux9o_87`,progressTrack:`_progressTrack_1ux9o_91`,progressFill:`_progressFill_1ux9o_95`,tooltipTitle:`_tooltipTitle_1ux9o_100`,fallbackBlock:`_fallbackBlock_1ux9o_107`,fallbackRow:`_fallbackRow_1ux9o_113`,fallbackRowMeta:`_fallbackRowMeta_1ux9o_122`,fallbackPill:`_fallbackPill_1ux9o_126`,tagline:`_tagline_1ux9o_140`,github:`_github_1ux9o_146`,githubIcon:`_githubIcon_1ux9o_169`,tourBtn:`_tourBtn_1ux9o_173`,launchingChip:`_launchingChip_1ux9o_190`,toolBtn:`_toolBtn_1ux9o_203`,overflowAnchor:`_overflowAnchor_1ux9o_215`,overflowTrigger:`_overflowTrigger_1ux9o_219`,overflowMenu:`_overflowMenu_1ux9o_228`,overflowItem:`_overflowItem_1ux9o_245`,overflowItemDanger:`_overflowItemDanger_1ux9o_259`,statusPill:`_statusPill_1ux9o_279`,statusText:`_statusText_1ux9o_290`,themeBtn:`_themeBtn_1ux9o_294`};function QD({size:e=20}){let{resolved:t}=B(),n=t===`light`?`rgba(122,82,0,.12)`:`rgba(232,180,74,.15)`;return(0,R.jsxs)(`span`,{className:ZD.logoSpan,style:{"--logo-size":`${e}px`,"--logo-glow":n},children:[(0,R.jsx)(`img`,{src:`/favicon.svg`,width:e,height:e,alt:`Paracosm`,className:ZD.logoImg}),(0,R.jsx)(`span`,{className:`pc-logo-glow ${ZD.logoGlow}`})]})}function $D({scenario:e,sse:t,gameState:n,onSave:r,onLoad:i,onClear:a,onWipeServer:o,onRunActionsOpen:s,onHowItWorks:c,howItWorksOpen:l=!1,howItWorksKeyRef:u,onCopy:d,onShareViz:f,launching:p=!1,history:m,onRestoreHistory:h,onClearHistory:g}){let{resolved:_,setTheme:v}=B(),y=Object.values(n.actors).some(e=>e.events.length>0),[b,x]=(0,L.useState)(!1),S=(0,L.useRef)(null),C=Qr(b);(0,L.useEffect)(()=>{b&&s?.()},[b,s]),(0,L.useEffect)(()=>{if(!b)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),x(!1))},t=e=>{let t=S.current;t&&(t.contains(e.target)||x(!1))};return document.addEventListener(`keydown`,e),document.addEventListener(`mousedown`,t),()=>{document.removeEventListener(`keydown`,e),document.removeEventListener(`mousedown`,t)}},[b]);let w=t.isAborted?`var(--amber)`:t.isComplete?`var(--green)`:t.status===`connected`?`var(--color-success)`:`var(--text-3)`,T=t.isAborted?`Interrupted`:t.isComplete?`Complete`:t.status===`connected`?`Live`:t.status===`error`?`Reconnecting`:`Connecting`,E=e=>{switch(e){case`client_disconnected`:return`browser tab closed before the sim finished`;case`quota_exhausted`:return`provider credits exhausted`;case`user_aborted`:return`cancelled by the user`;case`provider_error`:return`provider returned an unrecoverable error`;case`another_run_started`:return`you started another run`;case`server_restarted`:return`the server restarted before the run finished`;case`unknown`:return`reason not recorded by the server`;default:return e}},D=t.isAborted?(()=>{if(t.providerError)return`Run interrupted: ${t.providerError.message}. Click Clear to reset.`;let e=t.abortReason;return e?`${`Run interrupted: ${E(e.reason)}`}${typeof e.completedTurns==`number`?` after ${e.completedTurns} turn${e.completedTurns===1?``:`s`}`:``}. Click Clear to reset.`:`Run was interrupted before finishing all turns. Click Clear to reset.`})():t.isComplete?`Run finished all turns. Verdict is broadcast in Reports.`:t.status===`connected`?`Connected to the simulation server. No run in progress.`:t.status===`error`?`Reconnecting to the simulation server.`:`Connecting to the simulation server.`,O=n.maxTurns>0?`${Math.round(n.turn/n.maxTurns*100)}%`:`0%`;return(0,R.jsxs)(`header`,{className:`topbar flex items-center justify-between px-4 gap-3 shrink-0 ${ZD.bar}`,role:`banner`,children:[(0,R.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,R.jsxs)(`a`,{href:`/`,className:`${ZD.logoLink} ${ZD.brand}`,"aria-label":`Paracosm home`,children:[(0,R.jsx)(QD,{size:20}),(0,R.jsxs)(`span`,{children:[`PARA`,(0,R.jsx)(`span`,{className:ZD.brandAccent,children:`COSM`})]})]}),(0,R.jsx)(`a`,{href:`https://agentos.sh/en`,target:`_blank`,rel:`noopener`,className:`topbar-agentos ${ZD.agentosTag}`,"aria-label":`AgentOS Runtime (opens in new tab)`,title:`AgentOS Runtime`,children:`AGENTOS`}),(0,R.jsx)(`span`,{className:`topbar-agentos ${ZD.divider}`,"aria-hidden":`true`,children:`|`}),(0,R.jsx)(`span`,{className:`topbar-scenario ${ZD.scenarioName}`,children:e.labels.name})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-3 flex-1 justify-center ${ZD.center}`,children:[n.turn>0&&(0,R.jsxs)(`div`,{className:`topbar-meta flex items-center gap-2 shrink-0 ${ZD.meta}`,children:[(0,R.jsx)(UD,{content:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:ZD.tooltipTitle,children:[`Turn `,n.turn,` / `,n.maxTurns]}),(0,R.jsxs)(`div`,{children:[`One decision cycle per turn. Departments analyze the situation, the commander picks a policy, the kernel advances in-sim time, colonists age. At turn`,` `,n.maxTurns,` `,`the run finishes`,n.actorIds.length===2?` and the verdict judge compares the two commanders.`:`; cohort runs (3+ commanders) skip the verdict and surface group-median deltas instead.`]})]}),children:(0,R.jsxs)(`span`,{className:ZD.tokenInline,children:[(0,R.jsx)(`span`,{className:ZD.tokenLabel,children:`T`}),(0,R.jsx)(`strong`,{className:ZD.tokenValue,children:n.turn}),(0,R.jsxs)(`span`,{className:ZD.tokenLabel,children:[`/`,n.maxTurns]})]})}),(0,R.jsx)(UD,{content:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:ZD.tooltipTitle,children:[`In-sim time `,n.time]}),(0,R.jsxs)(`div`,{children:[`The time the colony thinks it's living in. Advances by the scenario's `,(0,R.jsx)(`code`,{children:`timePerTurn`}),` (usually 5-10) each decision cycle. Drives aging, childbirth, retirement, and long-arc narrative. Real wall-clock time doesn't matter — only the in-sim time.`]})]}),children:(0,R.jsxs)(`span`,{className:ZD.tokenInline,children:[(0,R.jsx)(`span`,{className:ZD.tokenLabel,children:`Y`}),(0,R.jsx)(`strong`,{className:ZD.tokenValue,children:n.time})]})}),(0,R.jsx)(UD,{content:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:ZD.tooltipTitle,children:[`Random seed `,n.seed]}),(0,R.jsx)(`div`,{children:`All kernel-side randomness (colonist generation, mood drift, crisis selection) derives from this seed. Same seed + same leaders + same scenario produces identical rosters and identical kernel outcomes — so Leader A and Leader B start from the same colony and diverge only by their personalities, not by luck.`})]}),children:(0,R.jsxs)(`span`,{className:ZD.tokenInline,children:[(0,R.jsx)(`span`,{className:ZD.tokenLabel,children:`S`}),(0,R.jsx)(`strong`,{className:ZD.tokenValue,children:n.seed})]})}),(0,R.jsx)(`div`,{className:`topbar-progress w-20 h-1.5 rounded-full overflow-hidden ${ZD.progressTrack}`,role:`progressbar`,"aria-valuenow":n.turn,"aria-valuemin":0,"aria-valuemax":n.maxTurns,"aria-label":`Simulation progress, turn ${n.turn} of ${n.maxTurns}`,children:(0,R.jsx)(`div`,{className:`h-full rounded-full transition-all ${ZD.progressFill}`,style:{"--progress-pct":O}})}),t.validationFallbacks.length>0&&(()=>{let e=t.validationFallbacks.filter(e=>!e.salvaged),n=t.validationFallbacks.filter(e=>e.salvaged),r=e.reduce((e,t)=>e+t.count,0),i=n.reduce((e,t)=>e+t.count,0),a=r+i,o=`${r} validation fallback${r===1?``:`s`}`,s=`${i} ${i===1?`reply`:`replies`} kept without the keys the run does not hold`,c=[r>0?o:``,i>0?s:``].filter(Boolean).join(`, `),l=e=>(0,R.jsx)(`div`,{className:ZD.fallbackBlock,children:e.map(e=>(0,R.jsxs)(`div`,{className:ZD.fallbackRow,children:[(0,R.jsx)(`span`,{children:e.schemaName}),(0,R.jsxs)(`span`,{className:ZD.fallbackRowMeta,children:[e.count,`× `,e.lastSite?`(last: ${e.lastSite})`:``]})]},e.schemaName))});return(0,R.jsx)(UD,{content:(0,R.jsxs)(`div`,{children:[r>0&&(0,R.jsxs)(`div`,{style:{marginBottom:i>0?8:0},children:[(0,R.jsxs)(`div`,{className:ZD.tooltipTitle,children:[`⚠ `,o]}),(0,R.jsx)(`div`,{style:{marginBottom:8},children:`An LLM call returned a JSON payload that failed zod schema validation. After retries were exhausted the orchestrator continued with an empty skeleton so the sim wouldn't abort mid-turn. Numbers here let you spot which schema is misbehaving.`}),l(e)]}),i>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:ZD.tooltipTitle,children:[`⚠ `,s]}),(0,R.jsx)(`div`,{style:{marginBottom:8},children:`A reply failed schema validation only on effect keys the run does not hold. After retries the run kept the model's own reply with those keys dropped; nothing was replaced with a skeleton.`}),l(n)]})]}),children:(0,R.jsxs)(`span`,{"aria-label":c,className:ZD.fallbackPill,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),a]})})})()]}),(0,R.jsx)(`div`,{className:`topbar-center hidden md:block truncate ${ZD.tagline}`,children:n.turn===0?`Same input. Different decisions. Emergent divergence.`:``})]}),(0,R.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[(0,R.jsxs)(`a`,{href:`https://github.com/framerslab/paracosm`,target:`_blank`,rel:`noopener noreferrer`,className:`topbar-github ${ZD.github}`,title:`Star Paracosm on GitHub`,"aria-label":`Open Paracosm on GitHub`,children:[(0,R.jsx)(`svg`,{width:`13`,height:`13`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,className:ZD.githubIcon,children:(0,R.jsx)(`path`,{d:`M8 0C3.58 0 0 3.58 0 8c0 3.54 2.29 6.53 5.47 7.59.4.07.55-.17.55-.38 0-.19-.01-.82-.01-1.49-2.01.37-2.53-.49-2.69-.94-.09-.23-.48-.94-.82-1.13-.28-.15-.68-.52-.01-.53.63-.01 1.08.58 1.23.82.72 1.21 1.87.87 2.33.66.07-.52.28-.87.51-1.07-1.78-.2-3.64-.89-3.64-3.95 0-.87.31-1.59.82-2.15-.08-.2-.36-1.02.08-2.12 0 0 .67-.21 2.2.82.64-.18 1.32-.27 2-.27.68 0 1.36.09 2 .27 1.53-1.04 2.2-.82 2.2-.82.44 1.1.16 1.92.08 2.12.51.56.82 1.27.82 2.15 0 3.07-1.87 3.75-3.65 3.95.29.25.54.73.54 1.48 0 1.07-.01 1.93-.01 2.2 0 .21.15.46.55.38A8.01 8.01 0 0016 8c0-4.42-3.58-8-8-8z`})}),(0,R.jsx)(`span`,{className:`topbar-github-label`,children:`GITHUB`})]}),c&&(0,R.jsxs)(`button`,{ref:u,type:`button`,onClick:c,className:`topbar-tour ${ZD.tourBtn}`,"aria-expanded":l,"aria-haspopup":`dialog`,children:[(0,R.jsx)(`span`,{className:`topbar-tour-label`,children:`How it works`}),(0,R.jsx)(`span`,{className:`topbar-tour-icon`,"aria-hidden":`true`,style:{display:`none`},children:`?`})]}),!n.isRunning&&!p&&(0,R.jsx)(XD,{onLoadFromFile:i,history:m,onRestoreHistory:h,onClearHistory:g,liveStateHasEvents:t.events.length>0}),p&&!n.isRunning&&(0,R.jsx)(`span`,{className:ZD.launchingChip,role:`status`,"aria-live":`polite`,children:`LAUNCHING…`}),(y&&(r||d||f)||a)&&(0,R.jsxs)(`div`,{ref:S,className:ZD.overflowAnchor,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>x(e=>!e),"aria-haspopup":`menu`,"aria-expanded":b,"aria-label":b?`Close run actions`:`Open run actions menu`,title:`Save · Share · Copy · Wipe`,className:`${ZD.toolBtn} ${ZD.overflowTrigger}`,children:`⋯`}),b&&(0,R.jsxs)(`div`,{ref:C,role:`menu`,tabIndex:-1,className:ZD.overflowMenu,children:[y&&r&&(0,R.jsx)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{x(!1),r()},className:ZD.overflowItem,title:`Export simulation data as .json`,children:`Save`}),y&&f&&(0,R.jsx)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{x(!1),f()},className:ZD.overflowItem,title:`Copy a deep link that opens this run on the visualization tab`,children:`Share viz link`}),y&&d&&(0,R.jsx)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{x(!1),d()},className:ZD.overflowItem,title:`Copy simulation summary to clipboard`,children:`Copy`}),a&&(0,R.jsx)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{x(!1),a()},className:ZD.overflowItemDanger,title:`Clear in-browser simulation buffer + cached events, and let go of this browser's run on the server, stopping it if it is running. Run history, saved sessions and output files are kept.`,children:`Clear local data`}),o&&(0,R.jsx)(`button`,{role:`menuitem`,type:`button`,onClick:()=>{x(!1),o()},className:ZD.overflowItemDanger,title:`Delete the server's stored runs, saved sessions and run output files, for every visitor. Pages showing a finished run this server holds, this one included, empty their view of it.`,children:`Delete server data`})]})]}),(0,R.jsx)(`span`,{className:ZD.divider,"aria-hidden":`true`,children:`|`}),(0,R.jsxs)(`span`,{className:ZD.statusPill,style:{"--status-color":w},role:`status`,"aria-live":`polite`,"aria-label":`${T}. ${D}`,title:D,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:t.status===`connected`&&!t.isComplete?`●`:`○`}),(0,R.jsx)(`span`,{className:`topbar-status-text ${ZD.statusText}`,children:T})]}),(0,R.jsx)(`button`,{onClick:()=>v(_===`dark`?`light`:`dark`),className:`px-2 py-0.5 rounded cursor-pointer transition-colors ${ZD.themeBtn}`,title:`Switch to ${_===`dark`?`light`:`dark`} mode`,"aria-label":`Switch to ${_===`dark`?`light`:`dark`} mode`,children:_===`dark`?`☀`:`☽`})]})]})}var eO={root:`_root_zo4p2_1`,tab:`_tab_zo4p2_10`,withDivider:`_withDivider_zo4p2_41`,active:`_active_zo4p2_45`,inactive:`_inactive_zo4p2_55`,icon:`_icon_zo4p2_60`,label:`_label_zo4p2_65`};function tO({id:e,size:t=16}){let n=t,r={width:n,height:n,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:2,strokeLinecap:`round`,strokeLinejoin:`round`};switch(e){case`quickstart`:return(0,R.jsx)(`svg`,{...r,children:(0,R.jsx)(`polygon`,{points:`13 2 3 14 12 14 11 22 21 10 12 10 13 2`})});case`sim`:return(0,R.jsx)(`svg`,{...r,children:(0,R.jsx)(`path`,{d:`M12 2v4M12 18v4M4.93 4.93l2.83 2.83M16.24 16.24l2.83 2.83M2 12h4M18 12h4M4.93 19.07l2.83-2.83M16.24 7.76l2.83-2.83`})});case`viz`:return(0,R.jsxs)(`svg`,{...r,children:[(0,R.jsx)(`circle`,{cx:`8`,cy:`8`,r:`3`}),(0,R.jsx)(`circle`,{cx:`16`,cy:`16`,r:`3`}),(0,R.jsx)(`circle`,{cx:`18`,cy:`8`,r:`2`}),(0,R.jsx)(`circle`,{cx:`6`,cy:`16`,r:`2`}),(0,R.jsx)(`line`,{x1:`10.5`,y1:`9.5`,x2:`14`,y2:`14`})]});case`settings`:return(0,R.jsxs)(`svg`,{...r,children:[(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,R.jsx)(`path`,{d:`M19.4 15a1.65 1.65 0 0 0 .33 1.82l.06.06a2 2 0 1 1-2.83 2.83l-.06-.06a1.65 1.65 0 0 0-1.82-.33 1.65 1.65 0 0 0-1 1.51V21a2 2 0 0 1-4 0v-.09A1.65 1.65 0 0 0 9 19.4a1.65 1.65 0 0 0-1.82.33l-.06.06a2 2 0 1 1-2.83-2.83l.06-.06A1.65 1.65 0 0 0 4.68 15a1.65 1.65 0 0 0-1.51-1H3a2 2 0 0 1 0-4h.09A1.65 1.65 0 0 0 4.6 9a1.65 1.65 0 0 0-.33-1.82l-.06-.06a2 2 0 1 1 2.83-2.83l.06.06A1.65 1.65 0 0 0 9 4.68a1.65 1.65 0 0 0 1-1.51V3a2 2 0 0 1 4 0v.09a1.65 1.65 0 0 0 1 1.51 1.65 1.65 0 0 0 1.82-.33l.06-.06a2 2 0 1 1 2.83 2.83l-.06.06A1.65 1.65 0 0 0 19.4 9a1.65 1.65 0 0 0 1.51 1H21a2 2 0 0 1 0 4h-.09a1.65 1.65 0 0 0-1.51 1z`})]});case`reports`:return(0,R.jsxs)(`svg`,{...r,children:[(0,R.jsx)(`path`,{d:`M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z`}),(0,R.jsx)(`polyline`,{points:`14 2 14 8 20 8`}),(0,R.jsx)(`line`,{x1:`16`,y1:`13`,x2:`8`,y2:`13`}),(0,R.jsx)(`line`,{x1:`16`,y1:`17`,x2:`8`,y2:`17`})]});case`library`:return(0,R.jsx)(`svg`,{...r,children:(0,R.jsx)(`path`,{d:`M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2zM22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z`})});case`studio`:return(0,R.jsxs)(`svg`,{...r,children:[(0,R.jsx)(`polyline`,{points:`4 7 4 4 20 4 20 7`}),(0,R.jsx)(`line`,{x1:`9`,y1:`20`,x2:`15`,y2:`20`}),(0,R.jsx)(`line`,{x1:`12`,y1:`4`,x2:`12`,y2:`20`})]});case`chat`:return(0,R.jsx)(`svg`,{...r,children:(0,R.jsx)(`path`,{d:`M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z`})});case`about`:return(0,R.jsxs)(`svg`,{...r,children:[(0,R.jsx)(`circle`,{cx:`12`,cy:`12`,r:`10`}),(0,R.jsx)(`line`,{x1:`12`,y1:`16`,x2:`12`,y2:`12`}),(0,R.jsx)(`line`,{x1:`12`,y1:`8`,x2:`12.01`,y2:`8`})]})}}var nO=[{id:`quickstart`,label:`QUICKSTART`},{id:`studio`,label:`STUDIO`},{id:`sim`,label:`SIM`},{id:`viz`,label:`VIZ`},{id:`chat`,label:`CHAT`},{id:`reports`,label:`REPORTS`},{id:`library`,label:`LIBRARY`},{id:`settings`,label:`SETTINGS`},{id:`about`,label:`ABOUT`}];function rO({active:e,onTabChange:t,scenario:n}){let r=nO.filter(e=>e.id!==`chat`||n.policies.characterChat),i=(0,L.useRef)([]);function a(e,t){let n=null;e.key===`ArrowRight`?n=(t+1)%r.length:e.key===`ArrowLeft`?n=(t-1+r.length)%r.length:e.key===`Home`?n=0:e.key===`End`&&(n=r.length-1),n!==null&&(e.preventDefault(),i.current[n]?.focus())}return(0,R.jsx)(`nav`,{className:`tab-bar ${eO.root}`,role:`tablist`,"aria-label":`Dashboard navigation`,children:r.map((n,o)=>{let s=e===n.id;return(0,R.jsxs)(`button`,{ref:e=>{i.current[o]=e},onClick:()=>t(n.id),onKeyDown:e=>a(e,o),role:`tab`,type:`button`,"aria-selected":s,"aria-label":n.label,"aria-controls":`tabpanel-${n.id}`,id:`tab-${n.id}`,title:n.label,tabIndex:s?0:-1,className:[eO.tab,o<r.length-1?eO.withDivider:``,s?eO.active:eO.inactive].filter(Boolean).join(` `),children:[(0,R.jsx)(`span`,{className:eO.icon,"aria-hidden":`true`,children:(0,R.jsx)(tO,{id:n.id,size:18})}),(0,R.jsx)(`span`,{className:eO.label,"aria-hidden":`true`,children:n.label})]},n.id)})})}var iO=new Set([`platform.openai.com`,`console.anthropic.com`]);function aO(e){if(typeof e!=`string`||!e)return null;let t;try{t=new URL(e)}catch{return null}return t.protocol!==`https:`&&t.protocol!==`http:`||t.username||t.password||t.port||!iO.has(t.hostname)?null:t.toString()}var oO={banner:`_banner_21dmw_1`,icon:`_icon_21dmw_17`,body:`_body_21dmw_30`,heading:`_heading_21dmw_35`,message:`_message_21dmw_40`,messageActor:`_messageActor_21dmw_46`,actionLink:`_actionLink_21dmw_50`,dismissBtn:`_dismissBtn_21dmw_61`,actionText:`_actionText_21dmw_72`};function sO({providerError:e,onDismiss:t}){let n=(e.kind===`quota`||e.kind===`auth`?`critical`:`warning`)==`critical`?{bg:`rgba(196, 74, 30, 0.14)`,border:`var(--red, #c44a1e)`,text:`var(--red, #c44a1e)`,actionBg:`var(--red, #c44a1e)`,actionText:`var(--bg-primary, #14110e)`}:{bg:`rgba(232, 180, 74, 0.14)`,border:`var(--amber, #e8b44a)`,text:`var(--amber, #e8b44a)`,actionBg:`var(--amber, #e8b44a)`,actionText:`var(--bg-primary, #14110e)`},r=e.kind===`quota`?`${cO(e.provider)} credits exhausted`:e.kind===`auth`?`${cO(e.provider)} API key invalid`:e.kind===`rate_limit`?`${cO(e.provider)} rate-limited`:e.kind===`network`?`Network error contacting ${cO(e.provider)}`:`Provider error`,i=aO(e.actionUrl),a={"--banner-bg":n.bg,"--banner-border":n.border,"--banner-text":n.text,"--action-bg":n.actionBg,"--action-text":n.actionText};return(0,R.jsxs)(`div`,{role:`alert`,"aria-live":`assertive`,className:oO.banner,style:a,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:oO.icon,children:`!`}),(0,R.jsxs)(`div`,{className:oO.body,children:[(0,R.jsx)(`div`,{className:oO.heading,children:r}),(0,R.jsxs)(`div`,{className:oO.message,children:[e.message,e.leader?(0,R.jsxs)(`span`,{className:oO.messageActor,children:[` (hit by `,e.leader,`)`]}):null]})]}),i?(0,R.jsx)(`a`,{href:i,target:`_blank`,rel:`noreferrer noopener`,className:oO.actionLink,children:e.kind===`quota`?`Add credits →`:`Fix key →`}):typeof e.actionUrl==`string`&&e.actionUrl?(0,R.jsx)(`span`,{className:oO.actionText,children:e.actionUrl}):null,t?(0,R.jsx)(`button`,{onClick:t,"aria-label":`Dismiss banner`,className:oO.dismissBtn,children:`Dismiss`}):null]})}function cO(e){return e===`openai`?`OpenAI`:e===`anthropic`?`Anthropic`:e===`openrouter`?`OpenRouter`:e===`gemini`?`Gemini`:`Provider`}var q={root:`_root_rnpr5_1`,headerRow:`_headerRow_rnpr5_10`,title:`_title_rnpr5_18`,subTitle:`_subTitle_rnpr5_30`,runMeta:`_runMeta_rnpr5_38`,cardsRow:`_cardsRow_rnpr5_48`,card:`_card_rnpr5_48`,cardHeader:`_cardHeader_rnpr5_69`,cardLabel:`_cardLabel_rnpr5_78`,cardName:`_cardName_rnpr5_86`,cardId:`_cardId_rnpr5_93`,kvList:`_kvList_rnpr5_99`,kv:`_kv_rnpr5_99`,description:`_description_rnpr5_124`,signalList:`_signalList_rnpr5_132`,signal:`_signal_rnpr5_132`,signalLabel:`_signalLabel_rnpr5_150`,signalValue:`_signalValue_rnpr5_153`,section:`_section_rnpr5_158`,sectionTitle:`_sectionTitle_rnpr5_168`,metricsGrid:`_metricsGrid_rnpr5_177`,metric:`_metric_rnpr5_177`,metricLabel:`_metricLabel_rnpr5_193`,metricValue:`_metricValue_rnpr5_201`,metricDelta:`_metricDelta_rnpr5_211`,metricDeltaUp:`_metricDeltaUp_rnpr5_217`,metricDeltaDown:`_metricDeltaDown_rnpr5_221`,chartWrap:`_chartWrap_rnpr5_225`,chart:`_chart_rnpr5_225`,chartLegend:`_chartLegend_rnpr5_240`,legendItem:`_legendItem_rnpr5_249`,legendSwatch:`_legendSwatch_rnpr5_255`,summaryRow:`_summaryRow_rnpr5_261`,summaryCell:`_summaryCell_rnpr5_267`,summaryLabel:`_summaryLabel_rnpr5_277`,summaryValue:`_summaryValue_rnpr5_286`,fingerprintList:`_fingerprintList_rnpr5_296`,fingerprintChip:`_fingerprintChip_rnpr5_302`,dismissBar:`_dismissBar_rnpr5_319`,dismissButton:`_dismissButton_rnpr5_325`,legendSwatchInline:`_legendSwatchInline_rnpr5_343`,playbackControls:`_playbackControls_rnpr5_347`,playbackPlayBtn:`_playbackPlayBtn_rnpr5_354`,playbackResetBtn:`_playbackResetBtn_rnpr5_368`,playbackSlider:`_playbackSlider_rnpr5_381`,playbackList:`_playbackList_rnpr5_387`,playbackHint:`_playbackHint_rnpr5_402`,playbackEvent:`_playbackEvent_rnpr5_408`,playbackTurn:`_playbackTurn_rnpr5_416`,playbackType:`_playbackType_rnpr5_421`,playbackBody:`_playbackBody_rnpr5_428`},lO={hba1c:`HbA1c`,fastingGlucose:`Fasting Glucose`,weight:`Weight (lb)`,bmi:`BMI`,exerciseAdherence:`Exercise Adherence`,sleepHours:`Sleep (hrs/night)`,qualityOfLife:`Quality of Life`,mortalityRisk:`10-yr Mortality Risk`,cardioFitness:`Cardio Fitness`,sideEffectBurden:`Side-effect Load`,patientMotivation:`Motivation`,familySupport:`Family Support`,population:`Population`,morale:`Morale`,alignmentBench:`AlignmentBench`,specGamingRate:`Spec Gaming Rate`,capabilityIndex:`Capability Index`,releaseReadiness:`Release Readiness`,redTeamCoverage:`Red-team Coverage`,runwayMonths:`Runway`,burnRate:`Burn`,marketShare:`Market Share`,revenueArr:`Revenue ARR`},uO=[`hba1c`,`weight`,`exerciseAdherence`],dO={hba1c:`#ef6f5d`,weight:`#ffd970`,exerciseAdherence:`#34d399`,bmi:`#a78bfa`,qualityOfLife:`#7cb6ff`,mortalityRisk:`#ef6f5d`,alignmentBench:`#7cb6ff`,specGamingRate:`#ef6f5d`,releaseReadiness:`#ffd970`,morale:`#ffd970`,runwayMonths:`#5fd49a`,marketShare:`#7cb6ff`},fO=new Set([`hba1c`,`fastingGlucose`,`weight`,`bmi`,`exerciseAdherence`,`sleepHours`,`qualityOfLife`,`mortalityRisk`,`cardioFitness`,`sideEffectBurden`]);function pO(e){return Number.isNaN(e)?`—`:Math.abs(e)>=1e6?`${(e/1e6).toFixed(2)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):Math.abs(e)<1?e.toFixed(3):e.toFixed(2)}function mO(e,t){let n=t-e;return Math.abs(n)<1e-6?{text:`·`,direction:`flat`}:{text:`${n>0?`+`:``}${pO(n)}`,direction:n>0?`up`:`down`}}function hO(e){return e==null?`—`:typeof e==`number`?pO(e):typeof e==`boolean`?e?`true`:`false`:typeof e==`string`?e:JSON.stringify(e)}var gO={run_started:`Run started`,turn_started:`Turn started`,event_start:`Crisis event`,specialist_start:`Specialist analyzing`,specialist_done:`Specialist done`,forge_attempt:`Forge attempt`,forge_approved:`Tool forged`,forge_rejected:`Forge rejected`,decision_pending:`Decision pending`,decision_made:`Decision made`,outcome:`Outcome`,bulletin:`Bulletin`,turn_done:`Turn complete`,agent_reactions:`Agent reactions`,promotion:`Promotion`,systems_snapshot:`Snapshot`,complete:`Complete`};function _O(e){let t=e.data??{};return typeof t.title==`string`?t.title:typeof t.summary==`string`?t.summary:typeof t.name==`string`?t.name:typeof t.description==`string`?t.description:typeof t.outcome==`string`?t.outcome:typeof t.toolName==`string`?t.toolName:typeof t.department==`string`?t.department:``}function vO({artifact:e,state:t,onDismiss:n}){let{subject:r,intervention:i,finalState:a,trajectory:o,cost:s,fingerprint:c,metadata:l}=e,u=(0,L.useMemo)(()=>{let e=o;return e?.timepoints&&e.timepoints.length>0?e.timepoints[0]?.worldSnapshot?.metrics??{}:e?.sampleTimepoint?.worldSnapshot?.metrics??{}},[o]),d=a?.metrics??{},f=r?.profile?Object.entries(r.profile).slice(0,6):[],p=(0,L.useMemo)(()=>{let e=o?.timepoints??[];return e.length===0?null:{points:e,series:uO.map(t=>{let n=e.map(e=>e.worldSnapshot?.metrics?.[t]??null),r=n.filter(e=>typeof e==`number`);return r.length<1?null:{metric:t,values:n,min:Math.min(...r),max:Math.max(...r)}}).filter(e=>e!==null)}},[o]),m=(0,L.useMemo)(()=>{let e=new Set;return Object.keys(d).forEach(t=>e.add(t)),Object.keys(u).forEach(t=>e.add(t)),(Array.from(e).some(e=>fO.has(e))?Array.from(e).filter(e=>fO.has(e)):Array.from(e)).slice(0,12)},[d,u]),h=c?Object.entries(c).slice(0,6):[];return(0,R.jsxs)(`div`,{className:q.root,children:[(0,R.jsxs)(`div`,{className:q.headerRow,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h2`,{className:q.title,children:`Digital Twin · Intervention Result`}),(0,R.jsxs)(`span`,{className:q.subTitle,children:[l?.scenario?.name??`scenario`,` · seed `,l?.seed??`?`,` · `,o?.timepoints?.length??0,` turns`]})]}),(0,R.jsxs)(`div`,{className:q.runMeta,children:[l?.runId&&(0,R.jsxs)(`span`,{children:[`run: `,l.runId.slice(0,28)]}),s?.totalUSD!=null&&(0,R.jsxs)(`span`,{children:[`$`,s.totalUSD.toFixed(3)]}),s?.llmCalls!=null&&(0,R.jsxs)(`span`,{children:[s.llmCalls,` LLM calls`]})]})]}),(0,R.jsxs)(`div`,{className:q.cardsRow,children:[(0,R.jsxs)(`div`,{className:q.card,children:[(0,R.jsxs)(`div`,{className:q.cardHeader,children:[(0,R.jsx)(`span`,{className:q.cardLabel,children:`Subject`}),(0,R.jsx)(`span`,{className:q.cardId,children:r?.id})]}),(0,R.jsx)(`div`,{className:q.cardName,children:r?.name}),f.length>0&&(0,R.jsx)(`div`,{className:q.kvList,children:f.map(([e,t])=>(0,R.jsxs)(`div`,{className:q.kv,children:[(0,R.jsx)(`span`,{children:e}),(0,R.jsx)(`span`,{children:hO(t)})]},e))}),r?.signals&&r.signals.length>0&&(0,R.jsx)(`div`,{className:q.signalList,children:r.signals.slice(0,4).map((e,t)=>(0,R.jsxs)(`div`,{className:q.signal,children:[(0,R.jsx)(`span`,{className:q.signalLabel,children:e.label}),(0,R.jsxs)(`span`,{className:q.signalValue,children:[typeof e.value==`number`?pO(e.value):String(e.value),e.unit?` ${e.unit}`:``]})]},t))})]}),(0,R.jsxs)(`div`,{className:q.card,children:[(0,R.jsxs)(`div`,{className:q.cardHeader,children:[(0,R.jsx)(`span`,{className:q.cardLabel,children:`Intervention`}),(0,R.jsx)(`span`,{className:q.cardId,children:i?.id})]}),(0,R.jsx)(`div`,{className:q.cardName,children:i?.name}),i?.description&&(0,R.jsx)(`p`,{className:q.description,children:i.description}),(0,R.jsxs)(`div`,{className:q.kvList,children:[i?.duration&&(0,R.jsxs)(`div`,{className:q.kv,children:[(0,R.jsx)(`span`,{children:`Duration`}),(0,R.jsxs)(`span`,{children:[i.duration.value,` `,i.duration.unit]})]}),i?.adherenceProfile&&(0,R.jsxs)(`div`,{className:q.kv,children:[(0,R.jsx)(`span`,{children:`Adherence`}),(0,R.jsxs)(`span`,{children:[(i.adherenceProfile.expected*100).toFixed(0),`%`]})]})]})]})]}),m.length>0&&(0,R.jsxs)(`div`,{className:q.section,children:[(0,R.jsx)(`h3`,{className:q.sectionTitle,children:`Final state · delta vs initial`}),(0,R.jsx)(`div`,{className:q.metricsGrid,children:m.map(e=>{let t=u[e],n=d[e];if(typeof n!=`number`)return null;let r=typeof t==`number`?mO(t,n):null;return(0,R.jsxs)(`div`,{className:q.metric,children:[(0,R.jsx)(`span`,{className:q.metricLabel,children:lO[e]??e}),(0,R.jsx)(`span`,{className:q.metricValue,children:pO(n)}),r&&(0,R.jsx)(`span`,{className:`${q.metricDelta} ${r.direction===`up`?q.metricDeltaUp:r.direction===`down`?q.metricDeltaDown:``}`,children:r.text})]},e)})})]}),p&&p.series.length>0&&(0,R.jsxs)(`div`,{className:q.section,children:[(0,R.jsx)(`h3`,{className:q.sectionTitle,children:`Trajectory`}),(0,R.jsxs)(`div`,{className:q.chartWrap,children:[(0,R.jsxs)(`svg`,{className:q.chart,viewBox:`0 0 600 200`,preserveAspectRatio:`none`,children:[p.series.map(e=>{let t=Math.max(1e-4,e.max-e.min),n=p.points.length>1?580/(p.points.length-1):0,r=``;return e.values.forEach((i,a)=>{if(typeof i!=`number`)return;let o=10+a*n,s=180-(i-e.min)/t*160;r+=(r?` L`:`M`)+` ${o.toFixed(1)} ${s.toFixed(1)}`}),(0,R.jsxs)(`g`,{children:[(0,R.jsx)(`path`,{d:r,stroke:dO[e.metric]??`#ffd970`,strokeWidth:1.5,fill:`none`}),e.values.map((r,i)=>{if(typeof r!=`number`)return null;let a=10+i*n,o=180-(r-e.min)/t*160;return(0,R.jsx)(`circle`,{cx:a,cy:o,r:2.5,fill:dO[e.metric]??`#ffd970`},`${e.metric}-${i}`)})]},e.metric)}),p.points.map((e,t)=>{let n=10+t*(p.points.length>1?580/(p.points.length-1):0);return(0,R.jsx)(`text`,{x:n,y:196,fontSize:9,textAnchor:`middle`,fill:`#888`,children:e.label??`t${e.time??t}`},`label-${t}`)})]}),(0,R.jsx)(`div`,{className:q.chartLegend,children:p.series.map(e=>(0,R.jsxs)(`span`,{className:q.legendItem,children:[(0,R.jsx)(`span`,{className:`${q.legendSwatch} ${q.legendSwatchInline}`,style:{"--swatch-color":dO[e.metric]}}),lO[e.metric]??e.metric]},e.metric))})]})]}),h.length>0&&(0,R.jsxs)(`div`,{className:q.section,children:[(0,R.jsx)(`h3`,{className:q.sectionTitle,children:`Fingerprint`}),(0,R.jsx)(`div`,{className:q.fingerprintList,children:h.map(([e,t])=>(0,R.jsxs)(`span`,{className:q.fingerprintChip,children:[e,(0,R.jsx)(`b`,{children:String(t)})]},e))})]}),(0,R.jsx)(yO,{state:t}),n&&(0,R.jsx)(`div`,{className:q.dismissBar,children:(0,R.jsx)(`button`,{onClick:n,className:q.dismissButton,children:`Clear · run another`})})]})}function yO({state:e}){let t=(0,L.useMemo)(()=>{if(!e)return[];let t=e.actorIds[0];return t?e.actors[t]?.events??[]:[]},[e]),n=t.length,[r,i]=(0,L.useState)(0),[a,o]=(0,L.useState)(!1),s=(0,L.useRef)(!1);if((0,L.useEffect)(()=>{!s.current&&n>0&&(s.current=!0,i(n))},[n]),(0,L.useEffect)(()=>{if(!a)return;if(r>=n){o(!1);return}let e=window.setTimeout(()=>i(e=>e+1),600);return()=>window.clearTimeout(e)},[a,r,n]),n===0)return null;let c=t.slice(0,r);return(0,R.jsxs)(`div`,{className:q.section,children:[(0,R.jsxs)(`h3`,{className:q.sectionTitle,children:[`Playback · `,r,` / `,n,` events`]}),(0,R.jsxs)(`div`,{className:q.playbackControls,children:[(0,R.jsx)(`button`,{onClick:()=>o(!a),className:q.playbackPlayBtn,children:a?`Pause`:r>=n?`Replay`:`Play`}),(0,R.jsx)(`button`,{onClick:()=>{i(0),o(!1)},className:q.playbackResetBtn,children:`Reset`}),(0,R.jsx)(`input`,{type:`range`,min:0,max:n,value:r,onChange:e=>{i(Number(e.target.value)),o(!1)},className:q.playbackSlider})]}),(0,R.jsx)(`div`,{className:q.playbackList,children:c.length===0?(0,R.jsx)(`div`,{className:q.playbackHint,children:`Drag the slider or press Play to step through the run.`}):c.map(e=>(0,R.jsxs)(`div`,{className:q.playbackEvent,children:[(0,R.jsx)(`span`,{className:q.playbackTurn,children:e.turn==null?``:`T${e.turn}`}),(0,R.jsx)(`span`,{className:q.playbackType,children:gO[e.type]??e.type}),(0,R.jsx)(`span`,{className:q.playbackBody,children:_O(e)})]},e.id))})]})}var bO={root:`_root_w82tn_1`,headerRow:`_headerRow_w82tn_10`,title:`_title_w82tn_18`,spinner:`_spinner_w82tn_33`,"dt-spin":`_dt-spin_w82tn_1`,timer:`_timer_w82tn_42`,cardsRow:`_cardsRow_w82tn_50`,card:`_card_w82tn_50`,cardHeader:`_cardHeader_w82tn_71`,cardLabel:`_cardLabel_w82tn_80`,cardId:`_cardId_w82tn_89`,cardName:`_cardName_w82tn_95`,kvList:`_kvList_w82tn_102`,kv:`_kv_w82tn_102`,description:`_description_w82tn_127`,statsBar:`_statsBar_w82tn_135`,stat:`_stat_w82tn_135`,statLabel:`_statLabel_w82tn_151`,statValue:`_statValue_w82tn_159`,progressBar:`_progressBar_w82tn_169`,progressFill:`_progressFill_w82tn_177`,eventLog:`_eventLog_w82tn_183`,eventLogHeader:`_eventLogHeader_w82tn_195`,eventLogTitle:`_eventLogTitle_w82tn_203`,eventLogScroll:`_eventLogScroll_w82tn_211`,eventRow:`_eventRow_w82tn_228`,eventTurn:`_eventTurn_w82tn_240`,eventType:`_eventType_w82tn_246`,eventBody:`_eventBody_w82tn_257`,eventEmpty:`_eventEmpty_w82tn_264`},xO={run_started:`Run started`,turn_started:`Turn started`,event_start:`Crisis event`,specialist_start:`Specialist analyzing`,specialist_done:`Specialist done`,forge_attempt:`Forge attempt`,forge_approved:`Tool forged`,forge_rejected:`Forge rejected`,decision_pending:`Decision pending`,decision_made:`Decision made`,outcome:`Outcome`,bulletin:`Bulletin`,turn_done:`Turn complete`,agent_reactions:`Agent reactions`,promotion:`Promotion`,systems_snapshot:`Snapshot`,complete:`Complete`};function SO(e){return Number.isNaN(e)?`—`:Math.abs(e)>=1e6?`${(e/1e6).toFixed(2)}M`:Math.abs(e)>=1e3?`${(e/1e3).toFixed(1)}k`:Number.isInteger(e)?String(e):Math.abs(e)<1?e.toFixed(3):e.toFixed(2)}function CO(e){let t=e.data??{};return typeof t.title==`string`?t.title:typeof t.summary==`string`?t.summary:typeof t.name==`string`?t.name:typeof t.description==`string`?t.description:typeof t.outcome==`string`?t.outcome:typeof t.toolName==`string`?t.toolName:typeof t.department==`string`?t.department:``}function wO({state:e,subject:t,intervention:n}){let[r,i]=(0,L.useState)(0),a=(0,L.useRef)(Date.now()),o=(0,L.useRef)(null),s=(0,L.useRef)(!0);(0,L.useEffect)(()=>{let e=window.setInterval(()=>{i(Math.round((Date.now()-a.current)/1e3))},500);return()=>window.clearInterval(e)},[]);let c=e.actorIds[0],l=c?e.actors[c]:null,u=l?.events??[],d=e.turn,f=e.maxTurns||1,p=Math.min(100,Math.max(0,d/f*100)),m=e.cost?.totalCostUSD??0,h=e.cost?.llmCalls??0,g=l?.tools??0,_=l?.citations??0;(0,L.useEffect)(()=>{if(!s.current)return;let e=o.current;e&&(e.scrollTop=e.scrollHeight)},[u.length]);let v=()=>{let e=o.current;e&&(s.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},y=t.profile?Object.entries(t.profile).slice(0,4):[];return(0,R.jsxs)(`div`,{className:bO.root,children:[(0,R.jsxs)(`div`,{className:bO.headerRow,children:[(0,R.jsxs)(`h2`,{className:bO.title,children:[(0,R.jsx)(`span`,{className:bO.spinner,"aria-hidden":`true`}),`Digital Twin · Running`]}),(0,R.jsxs)(`span`,{className:bO.timer,children:[r,`s elapsed · streaming live · `,f,` `,f===1?`turn`:`turns`,` × LLM decisions`]})]}),(0,R.jsxs)(`div`,{className:bO.cardsRow,children:[(0,R.jsxs)(`div`,{className:bO.card,children:[(0,R.jsxs)(`div`,{className:bO.cardHeader,children:[(0,R.jsx)(`span`,{className:bO.cardLabel,children:`Subject`}),(0,R.jsx)(`span`,{className:bO.cardId,children:t.id})]}),(0,R.jsx)(`div`,{className:bO.cardName,children:t.name}),y.length>0&&(0,R.jsx)(`div`,{className:bO.kvList,children:y.map(([e,t])=>(0,R.jsxs)(`div`,{className:bO.kv,children:[(0,R.jsx)(`span`,{children:e}),(0,R.jsx)(`span`,{children:typeof t==`number`?SO(t):String(t)})]},e))})]}),(0,R.jsxs)(`div`,{className:bO.card,children:[(0,R.jsxs)(`div`,{className:bO.cardHeader,children:[(0,R.jsx)(`span`,{className:bO.cardLabel,children:`Intervention`}),(0,R.jsx)(`span`,{className:bO.cardId,children:n.id})]}),(0,R.jsx)(`div`,{className:bO.cardName,children:n.name}),(0,R.jsx)(`p`,{className:bO.description,children:n.description}),n.duration&&(0,R.jsx)(`div`,{className:bO.kvList,children:(0,R.jsxs)(`div`,{className:bO.kv,children:[(0,R.jsx)(`span`,{children:`Duration`}),(0,R.jsxs)(`span`,{children:[n.duration.value,` `,n.duration.unit]})]})})]})]}),(0,R.jsxs)(`div`,{className:bO.statsBar,children:[(0,R.jsxs)(`div`,{className:bO.stat,children:[(0,R.jsx)(`span`,{className:bO.statLabel,children:`Turn`}),(0,R.jsxs)(`span`,{className:bO.statValue,children:[d,` / `,f]}),(0,R.jsx)(`div`,{className:bO.progressBar,children:(0,R.jsx)(`div`,{className:bO.progressFill,style:{width:`${p}%`}})})]}),(0,R.jsxs)(`div`,{className:bO.stat,children:[(0,R.jsx)(`span`,{className:bO.statLabel,children:`LLM Calls`}),(0,R.jsx)(`span`,{className:bO.statValue,children:h})]}),(0,R.jsxs)(`div`,{className:bO.stat,children:[(0,R.jsx)(`span`,{className:bO.statLabel,children:`Cost`}),(0,R.jsxs)(`span`,{className:bO.statValue,children:[`$`,m.toFixed(4)]})]}),(0,R.jsxs)(`div`,{className:bO.stat,children:[(0,R.jsx)(`span`,{className:bO.statLabel,children:`Tools forged`}),(0,R.jsx)(`span`,{className:bO.statValue,children:g})]}),(0,R.jsxs)(`div`,{className:bO.stat,children:[(0,R.jsx)(`span`,{className:bO.statLabel,children:`Citations`}),(0,R.jsx)(`span`,{className:bO.statValue,children:_})]})]}),(0,R.jsxs)(`div`,{className:bO.eventLog,children:[(0,R.jsxs)(`div`,{className:bO.eventLogHeader,children:[(0,R.jsx)(`span`,{className:bO.eventLogTitle,children:`Live event log · streaming from /events`}),(0,R.jsxs)(`span`,{className:bO.timer,children:[u.length,` events`]})]}),(0,R.jsx)(`div`,{ref:o,onScroll:v,className:bO.eventLogScroll,children:u.length===0?(0,R.jsx)(`div`,{className:bO.eventEmpty,children:`Waiting for the first server event…`}):u.map(e=>(0,R.jsxs)(`div`,{className:bO.eventRow,children:[(0,R.jsx)(`span`,{className:bO.eventTurn,children:e.turn==null?``:`T${e.turn}`}),(0,R.jsx)(`span`,{className:bO.eventType,children:xO[e.type]??e.type}),(0,R.jsx)(`span`,{className:bO.eventBody,children:CO(e)})]},e.id))})]})]})}var TO=`▁▂▃▄▅▆▇█`;function EO({data:e,label:t,suffix:n=``,color:r}){if(!e.length)return(0,R.jsx)(`span`,{style:{color:`var(--text-3)`,fontFamily:`var(--mono)`,fontSize:`var(--font-2xs)`},children:`—`});let i=Math.max(...e)||1,a=e.map(e=>TO[Math.min(7,Math.floor(e/i*7.99))]).join(``),o=e[e.length-1];return(0,R.jsxs)(`span`,{style:{fontFamily:`var(--mono)`,fontSize:`var(--font-2xs)`,whiteSpace:`nowrap`},children:[t&&(0,R.jsxs)(`span`,{style:{color:`var(--text-3)`,fontSize:`var(--font-3xs)`,textTransform:`uppercase`,letterSpacing:`0.3px`,fontWeight:600},children:[t,` `]}),(0,R.jsx)(`span`,{style:{color:r||`var(--amber)`,letterSpacing:`-0.5px`},children:a}),` `,(0,R.jsxs)(`span`,{style:{color:r||`var(--text-1)`},children:[o,n]})]})}var DO={root:`_root_17urj_1`,headerRow:`_headerRow_17urj_8`,archetypeChip:`_archetypeChip_17urj_15`,slot:`_slot_17urj_32`,verdictChip:`_verdictChip_17urj_50`,winner:`_winner_17urj_59`,tie:`_tie_17urj_64`,second:`_second_17urj_69`,name:`_name_17urj_75`,unitTag:`_unitTag_17urj_82`,traits:`_traits_17urj_91`,traitsSep:`_traitsSep_17urj_95`,traitsLine:`_traitsLine_17urj_100`,subRow:`_subRow_17urj_109`,quote:`_quote_17urj_116`,awaiting:`_awaiting_17urj_126`,sparklines:`_sparklines_17urj_134`,tooltipHeading:`_tooltipHeading_17urj_141`,tooltipInstructions:`_tooltipInstructions_17urj_150`,tooltipTraitBlock:`_tooltipTraitBlock_17urj_157`,tooltipTraitRow:`_tooltipTraitRow_17urj_164`,tooltipTraitLabel:`_tooltipTraitLabel_17urj_169`,tooltipTraitValue:`_tooltipTraitValue_17urj_173`,compact:`_compact_17urj_177`,compactBand:`_compactBand_17urj_192`,compactSlot:`_compactSlot_17urj_205`,compactName:`_compactName_17urj_224`,compactSep:`_compactSep_17urj_234`,compactStat:`_compactStat_17urj_239`,compactArchetype:`_compactArchetype_17urj_246`,compactMood:`_compactMood_17urj_259`,compactCrisis:`_compactCrisis_17urj_260`,compactDeciding:`_compactDeciding_17urj_261`,"pulse-deciding":`_pulse-deciding_17urj_1`,chipDeciding:`_chipDeciding_17urj_308`,chip:`_chip_17urj_308`,dynamicRow:`_dynamicRow_17urj_329`,chipLabel:`_chipLabel_17urj_354`,chipValue:`_chipValue_17urj_360`,chipCrisis:`_chipCrisis_17urj_365`,chipStatus:`_chipStatus_17urj_384`,mood_low:`_mood_low_17urj_388`,mood_tense:`_mood_tense_17urj_398`,mood_ok:`_mood_ok_17urj_408`,mood_high:`_mood_high_17urj_412`};function OO(e){return e<25?{label:`low`,icon:`▼`,tone:`low`}:e<50?{label:`tense`,icon:`▽`,tone:`tense`}:e<75?{label:`steady`,icon:`△`,tone:`ok`}:{label:`rising`,icon:`▲`,tone:`high`}}function kO(e,t){if(!e)return[];let n=[];for(let[r,i]of Object.entries(e)){if(!r||i===!1||i===``||i==null)continue;let e=typeof i==`boolean`?`on`:String(i);if(n.push({key:r,label:AO(r),value:e}),n.length>=t)break}return n}function AO(e){if(!e)return e;let t=e.replace(/[_-]+/g,` `).replace(/([a-z])([A-Z])/g,`$1 $2`).trim().toLowerCase();return t.charAt(0).toUpperCase()+t.slice(1)}function jO(e,t){let n=Math.round(t*4);return`${e} ${`█`.repeat(n)+`░`.repeat(4-n)} ${t.toFixed(2)}`}function MO({actorIndex:e,leader:t,popHistory:n,moraleHistory:r,verdictPlacement:i,compact:a=!1,event:o,statuses:s,pendingDecision:c,nameFallback:l}){let u=Xn(e),d=`color-mix(in srgb, ${u} 12%, transparent)`,f=`color-mix(in srgb, ${u} 55%, transparent)`,p=`Leader ${String.fromCharCode(65+e)}`,m=t?.name||l||p,h=(()=>{let t=e,n=``;do n=String.fromCharCode(65+t%26)+n,t=Math.floor(t/26)-1;while(t>=0);return n})();if(a){let e=n.length>0?n[n.length-1]:null,i=r.length>0?r[r.length-1]:null,a=i===null?null:OO(i),s=t?.archetype?.replace(/^The\s+/i,``).toUpperCase()||``;return(0,R.jsxs)(`div`,{className:DO.compact,style:{"--actor-color":u,"--actor-bg":d,"--actor-border":f},"aria-label":`${m} compact summary`,children:[(0,R.jsx)(`span`,{className:DO.compactBand,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:DO.compactSlot,"aria-hidden":`true`,title:`Slot ${h}`,children:h}),(0,R.jsx)(`span`,{className:DO.compactName,children:m}),s&&(0,R.jsx)(`span`,{className:DO.compactArchetype,title:t?.archetype,children:s}),e!==null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:DO.compactSep,children:`·`}),(0,R.jsxs)(`span`,{className:DO.compactStat,children:[`POP `,Math.round(e)]})]}),i!==null&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:DO.compactSep,children:`·`}),(0,R.jsxs)(`span`,{className:DO.compactStat,children:[`MORALE `,Math.round(i),`%`]})]}),a&&(0,R.jsxs)(`span`,{className:`${DO.compactMood} ${DO[`mood_${a.tone}`]??``}`.trim(),title:`Mood: ${a.label}`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:a.icon}),(0,R.jsx)(`span`,{children:a.label})]}),o?.title&&(0,R.jsxs)(`span`,{className:DO.compactCrisis,title:o.description??o.title,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),(0,R.jsx)(`span`,{children:o.title.length>24?`${o.title.slice(0,24)}…`:o.title})]}),c&&(0,R.jsx)(`span`,{className:DO.compactDeciding,title:c,children:`DECIDING…`})]})}let g=t?.archetype||``,_=t?.unit||``,v=t?.hexaco||{},y=Object.values(v).some(e=>e>0),b=[`openness`,`conscientiousness`,`extraversion`,`agreeableness`,`emotionality`,`honestyHumility`],x=y?[`O`,`C`,`E`,`A`,`Em`,`HH`].map((e,t)=>jO(e,v[b[t]]??0)).join(` `):``,S=i?`${DO.verdictChip} ${DO[i]??``}`.trim():``;return(0,R.jsxs)(`div`,{className:DO.root,style:{"--actor-color":u,"--actor-bg":d,"--actor-border":f},children:[(0,R.jsxs)(`div`,{className:DO.headerRow,children:[(0,R.jsx)(`span`,{className:DO.slot,"aria-hidden":`true`,title:`Slot ${h}`,children:h}),g&&(0,R.jsx)(`span`,{className:DO.archetypeChip,children:g.toUpperCase().replace(/^THE\s+/i,``)}),i&&(0,R.jsx)(`span`,{title:i===`winner`?`Verdict: this leader won`:i===`tie`?`Verdict: tie`:`Verdict: runner-up`,className:S,children:i===`winner`?`★ WINNER`:i===`tie`?`= TIE`:`2ND`}),(0,R.jsx)(UD,{dot:!0,content:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`b`,{className:DO.tooltipHeading,children:[g?`${g}: `:``,m]}),_&&(0,R.jsxs)(`div`,{children:[`Unit: `,_]}),t?.instructions&&(0,R.jsx)(`div`,{className:DO.tooltipInstructions,children:t.instructions}),y&&(0,R.jsx)(`div`,{className:DO.tooltipTraitBlock,children:b.map(e=>(0,R.jsxs)(`div`,{className:DO.tooltipTraitRow,children:[(0,R.jsx)(`span`,{className:DO.tooltipTraitLabel,children:e.charAt(0).toUpperCase()+e.slice(1).replace(/([A-Z])/g,` $1`)}),(0,R.jsx)(`span`,{className:DO.tooltipTraitValue,children:(v[e]??0).toFixed(2)})]},e))})]}),children:(0,R.jsx)(`span`,{className:DO.name,children:m})}),_&&(0,R.jsx)(`span`,{className:DO.unitTag,children:_}),x&&(0,R.jsxs)(`span`,{className:`leader-traits ${DO.traits}`,children:[(0,R.jsx)(`span`,{className:DO.traitsSep,children:`|`}),(0,R.jsx)(`span`,{className:DO.traitsLine,children:x})]})]}),(0,R.jsxs)(`div`,{className:DO.subRow,children:[(0,R.jsx)(`span`,{className:DO.quote,children:(()=>{if(t?.quote)return`"${t.quote}"`;if(t?.instructions){let e=t.instructions.replace(/^You are [^.]+\.\s*/i,``).replace(/^"[^"]+"\.\s*/i,``).replace(/Your HEXACO profile drives your leadership.*$/i,``).trim();if(e)return`"${e.slice(0,80)}${e.length>80?`...`:``}"`}return n.length===0&&r.length===0?(0,R.jsx)(`span`,{className:DO.awaiting,children:`Awaiting first turn…`}):``})()}),(0,R.jsxs)(`span`,{className:`leader-sparklines ${DO.sparklines}`,children:[(0,R.jsx)(EO,{data:n,label:`POP`,color:u}),` `,(0,R.jsx)(EO,{data:r,label:`MORALE`,suffix:`%`,color:`var(--amber)`})]})]}),(0,R.jsx)(NO,{moraleHistory:r,event:o,statuses:s,pendingDecision:c})]})}function NO({moraleHistory:e,event:t,statuses:n,pendingDecision:r}){let i=e.length>0?e[e.length-1]:null,a=i===null?null:OO(i),o=kO(n,2);return a||t?.title||r||o.length>0?(0,R.jsxs)(`div`,{className:DO.dynamicRow,role:`status`,"aria-live":`polite`,"aria-atomic":`false`,"aria-relevant":`additions text`,children:[a&&(0,R.jsxs)(`span`,{className:`${DO.chip} ${DO[`mood_${a.tone}`]??``}`.trim(),title:`Mood derived from current morale (${Math.round(i)}%)`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:a.icon}),(0,R.jsx)(`span`,{className:DO.chipLabel,children:`Mood`}),(0,R.jsx)(`span`,{className:DO.chipValue,children:a.label})]}),t?.title&&(0,R.jsxs)(`span`,{className:`${DO.chip} ${DO.chipCrisis}`,title:t.description??t.title,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`⚠`}),(0,R.jsx)(`span`,{className:DO.chipLabel,children:AO(t.category)||`Event`}),(0,R.jsx)(`span`,{className:DO.chipValue,children:t.title.length>32?`${t.title.slice(0,32)}…`:t.title})]}),r&&(0,R.jsxs)(`span`,{className:`${DO.chip} ${DO.chipDeciding}`,title:r,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`⏳`}),(0,R.jsx)(`span`,{className:DO.chipLabel,children:`Deciding`})]}),o.map(({key:e,label:t,value:n})=>(0,R.jsxs)(`span`,{className:`${DO.chip} ${DO.chipStatus}`,title:`${t}: ${n}`,children:[(0,R.jsx)(`span`,{className:DO.chipLabel,children:t}),(0,R.jsx)(`span`,{className:DO.chipValue,children:n})]},e))]}):null}function PO(e){if(!e)return``;let t=Object.entries(e);return t.length===0?``:t.map(([e,t])=>`${e}: ${typeof t==`boolean`?t?`yes`:`no`:String(t)}`).join(`
|
|
124
|
+
`)}function FO(e,t){if(t.format!==`percent`)return e;let n=t.max??t.initial;return n===void 0||n<=1?e*100:e}function IO(e,t){if(t.format===`percent`)return`${Math.round(FO(e,t))}%`;if(t.format===`number`){let t=Math.round(e*10)/10;return Number.isInteger(t)?String(t):t.toFixed(1)}return String(e)}var LO={bar:`_bar_1gubl_1`,crisis:`_crisis_1gubl_18`,pill:`_pill_1gubl_29`,label:`_label_1gubl_39`,value:`_value_1gubl_52`,valueB:`_valueB_1gubl_52`,valueA:`_valueA_1gubl_52`,delta:`_delta_1gubl_65`,deltaNeutral:`_deltaNeutral_1gubl_65`,deltaNegative:`_deltaNegative_1gubl_65`,deltaPositive:`_deltaPositive_1gubl_65`,sep:`_sep_1gubl_81`,causesChip:`_causesChip_1gubl_86`};function RO(e){return e===`foodMonthsReserve`?`mo`:``}var zO={population:`POP`,morale:`MORALE`,foodMonthsReserve:`FOOD`,powerKw:`POWER`,infrastructureModules:`MODULES`,scienceOutput:`SCIENCE`,hullIntegrity:`HULL`,oxygenReserveHours:`O2`},BO={population:`P`,morale:`M`,foodMonthsReserve:`F`,powerKw:`W`,infrastructureModules:`I`,scienceOutput:`S`,hullIntegrity:`H`,oxygenReserveHours:`O₂`};function VO(e,t){if(t==null)return``;let n=Math.round((e-t)*100)/100;return n===0?``:n>0?`+${n}`:`${n}`}function HO(e,t){return e?t===`neutral`?LO.deltaNeutral:t===`lossIsRed`?e.startsWith(`-`)?LO.deltaPositive:LO.deltaNegative:e.startsWith(`+`)?LO.deltaPositive:LO.deltaNegative:``}function UO(e){if(!e)return``;let t=Object.entries(e).filter(([,e])=>e>0).sort((e,t)=>t[1]-e[1]);if(t.length===0)return``;let n=t.slice(0,3).map(([e,t])=>`${t} ${e.replace(`radiation cancer`,`radiation`).replace(`natural causes`,`age`).replace(`age-related complications`,`age`).replace(`fatal fracture`,`fracture`).replace(`accident: `,``).replace(`accident`,`accident`)}`),r=t.length-n.length;return r>0?`${n.join(` · `)} +${r}`:n.join(` · `)}function WO({actors:e,crisisText:t,toolRegistry:n}){let r=fF(),i=e[0],a=e[1],o=i?.state,s=a?.state,c=o?.metrics??null,l=s?.metrics??null,u=o?.prevMetrics??null,d=s?.prevMetrics??null,f=o?.deaths??0,p=s?.deaths??0,m=o?.deathCauses,h=s?.deathCauses,g=o?.tools??0,_=s?.tools??0,v=o?.citations??0,y=s?.citations??0,b=i?.id??``,x=a?.id??``,S=o?.statuses,C=s?.statuses,w=o?.environment,T=s?.environment,{reuseA:E,reuseB:D}=(0,L.useMemo)(()=>{let e=0,t=0;for(let r of n?.list??[])for(let n=1;n<r.history.length;n++){let i=r.history[n];i.rejected||(i.actorName===b?e++:i.actorName===x&&t++)}return{reuseA:e,reuseB:t}},[n,b,x]),O=(0,L.useRef)({toolsA:g,toolsB:_,reuseA:E,reuseB:D,citationsA:v,citationsB:y,deathsA:f,deathsB:p}),k=O.current,ee=VO(g,k.toolsA),A=VO(_,k.toolsB),j=VO(E,k.reuseA),M=VO(D,k.reuseB),N=VO(v,k.citationsA),te=VO(y,k.citationsB),P=VO(f,k.deathsA),F=VO(p,k.deathsB);if((0,L.useEffect)(()=>{O.current={toolsA:g,toolsB:_,reuseA:E,reuseB:D,citationsA:v,citationsB:y,deathsA:f,deathsB:p}},[g,_,E,D,v,y,f,p]),!c&&!l)return null;let I=r.ui.headerMetrics.filter(e=>e.id!==`population`&&e.id!==`morale`).slice(0,4),ne=Xn(0),re=Xn(1);return(0,R.jsxs)(`div`,{className:`stats-bar ${LO.bar}`,role:`region`,"aria-label":`Leader statistics`,tabIndex:0,style:{"--actor-color-a":ne,"--actor-color-b":re},children:[t&&(0,R.jsx)(`span`,{className:LO.crisis,children:t}),I.map(e=>{let t=c?.[e.id]??0,n=l?.[e.id]??0,r=t=>t==null?void 0:FO(t,e),i=VO(FO(t,e),r(u?.[e.id])),a=VO(FO(n,e),r(d?.[e.id])),o=IO(t,e),s=IO(n,e),f=RO(e.id),p=zO[e.id]||e.id.replace(/([A-Z])/g,` $1`).trim().toUpperCase(),m=BO[e.id]||p.charAt(0);return(0,R.jsxs)(`span`,{className:LO.pill,children:[(0,R.jsxs)(`span`,{className:LO.label,title:p,children:[(0,R.jsx)(`span`,{className:`pill-label-full`,children:p}),(0,R.jsx)(`span`,{className:`pill-label-short`,children:m})]}),(0,R.jsxs)(`span`,{className:LO.valueA,children:[o,f]}),i&&(0,R.jsx)(`span`,{className:HO(i,`gain`),children:i}),(0,R.jsx)(`span`,{className:LO.sep,children:`vs`}),(0,R.jsxs)(`span`,{className:LO.valueB,children:[s,f]}),a&&(0,R.jsx)(`span`,{className:HO(a,`gain`),children:a})]},e.id)}),(0,R.jsxs)(`span`,{className:LO.pill,children:[(0,R.jsxs)(`span`,{className:LO.label,title:`Deaths`,children:[(0,R.jsx)(`span`,{className:`pill-label-full`,children:`DEATHS`}),(0,R.jsx)(`span`,{className:`pill-label-short`,children:`†`})]}),(0,R.jsx)(`span`,{className:LO.valueA,title:m&&Object.keys(m).length>0?`Leader A deaths by cause: ${Object.entries(m).map(([e,t])=>`${t} ${e}`).join(`, `)}`:void 0,children:f}),P&&(0,R.jsx)(`span`,{className:HO(P,`lossIsRed`),children:P}),(0,R.jsx)(`span`,{className:LO.sep,children:`vs`}),(0,R.jsx)(`span`,{className:LO.valueB,title:h&&Object.keys(h).length>0?`Leader B deaths by cause: ${Object.entries(h).map(([e,t])=>`${t} ${e}`).join(`, `)}`:void 0,children:p}),F&&(0,R.jsx)(`span`,{className:HO(F,`lossIsRed`),children:F}),(()=>{let e=UO(m),t=UO(h);return!e&&!t?null:(0,R.jsxs)(`span`,{className:LO.causesChip,children:[`(`,e||`0`,` / `,t||`0`,`)`]})})()]}),(0,R.jsxs)(`span`,{className:LO.pill,children:[(0,R.jsxs)(`span`,{className:LO.label,title:`Tools forged`,children:[(0,R.jsx)(`span`,{className:`pill-label-full`,children:`TOOLS`}),(0,R.jsx)(`span`,{className:`pill-label-short`,children:`T`})]}),(0,R.jsx)(`span`,{className:LO.valueA,children:g}),ee&&(0,R.jsx)(`span`,{className:LO.deltaPositive,children:ee}),(0,R.jsx)(`span`,{className:LO.sep,children:`/`}),(0,R.jsx)(`span`,{className:LO.valueB,children:_}),A&&(0,R.jsx)(`span`,{className:LO.deltaPositive,children:A})]}),n&&n.list.length>0&&(0,R.jsxs)(`span`,{className:LO.pill,title:`Forged-tool reuse count per leader. Reuses amortize forge cost across multiple events.`,children:[(0,R.jsxs)(`span`,{className:LO.label,title:`Reuse count`,children:[(0,R.jsx)(`span`,{className:`pill-label-full`,children:`REUSE`}),(0,R.jsx)(`span`,{className:`pill-label-short`,children:`R`})]}),(0,R.jsx)(`span`,{className:LO.valueA,children:E}),j&&(0,R.jsx)(`span`,{className:LO.deltaPositive,children:j}),(0,R.jsx)(`span`,{className:LO.sep,children:`/`}),(0,R.jsx)(`span`,{className:LO.valueB,children:D}),M&&(0,R.jsx)(`span`,{className:LO.deltaPositive,children:M})]}),(0,R.jsxs)(`span`,{className:LO.pill,children:[(0,R.jsxs)(`span`,{className:LO.label,title:`Citations`,children:[(0,R.jsx)(`span`,{className:`pill-label-full`,children:`CITES`}),(0,R.jsx)(`span`,{className:`pill-label-short`,children:`C`})]}),(0,R.jsx)(`span`,{className:LO.valueA,children:v}),N&&(0,R.jsx)(`span`,{className:HO(N,`neutral`),children:N}),(0,R.jsx)(`span`,{className:LO.sep,children:`/`}),(0,R.jsx)(`span`,{className:LO.valueB,children:y}),te&&(0,R.jsx)(`span`,{className:HO(te,`neutral`),children:te})]}),(S||C)&&(0,R.jsxs)(`span`,{className:LO.pill,title:`Categorical scenario-declared statuses (world.statuses).\n\nLeader A:\n${PO(S)||`(none)`}\n\nLeader B:\n${PO(C)||`(none)`}`,children:[(0,R.jsxs)(`span`,{className:LO.label,children:[(0,R.jsx)(`span`,{className:`pill-label-full`,children:`STATUSES`}),(0,R.jsx)(`span`,{className:`pill-label-short`,children:`§`})]}),(0,R.jsx)(`span`,{className:LO.valueA,children:S?Object.keys(S).length:0}),(0,R.jsx)(`span`,{className:LO.sep,children:`/`}),(0,R.jsx)(`span`,{className:LO.valueB,children:C?Object.keys(C).length:0})]}),(w||T)&&(0,R.jsxs)(`span`,{className:LO.pill,title:`Environment bag (world.environment), external conditions.\n\nLeader A:\n${PO(w)||`(none)`}\n\nLeader B:\n${PO(T)||`(none)`}`,children:[(0,R.jsxs)(`span`,{className:LO.label,children:[(0,R.jsx)(`span`,{className:`pill-label-full`,children:`ENV`}),(0,R.jsx)(`span`,{className:`pill-label-short`,children:`E`})]}),(0,R.jsx)(`span`,{className:LO.valueA,children:w?Object.keys(w).length:0}),(0,R.jsx)(`span`,{className:LO.sep,children:`/`}),(0,R.jsx)(`span`,{className:LO.valueB,children:T?Object.keys(T).length:0})]})]})}var GO={timelineRow:`_timelineRow_iwf5k_1`,sideWrap:`_sideWrap_iwf5k_36`,sideHeader:`_sideHeader_iwf5k_55`,sideHeaderIdx:`_sideHeaderIdx_iwf5k_66`,sideHeaderName:`_sideHeaderName_iwf5k_75`,sideHeaderArchetype:`_sideHeaderArchetype_iwf5k_86`,side:`_side_iwf5k_36`,outcomeBadge:`_outcomeBadge_iwf5k_109`,tooltipHeader:`_tooltipHeader_iwf5k_120`,tooltipTurn:`_tooltipTurn_iwf5k_127`,tooltipTime:`_tooltipTime_iwf5k_132`,tooltipCategory:`_tooltipCategory_iwf5k_138`,tooltipEmergent:`_tooltipEmergent_iwf5k_147`,tooltipTitle:`_tooltipTitle_iwf5k_154`,tooltipSummary:`_tooltipSummary_iwf5k_161`,tooltipDecision:`_tooltipDecision_iwf5k_168`,tooltipDecisionLabel:`_tooltipDecisionLabel_iwf5k_177`,tooltipOutcome:`_tooltipOutcome_iwf5k_185`,entry:`_entry_iwf5k_193`,current:`_current_iwf5k_205`,glow:`_glow_iwf5k_1`,entryHead:`_entryHead_iwf5k_209`,entryTurn:`_entryTurn_iwf5k_217`,entryTitle:`_entryTitle_iwf5k_225`,entryCategory:`_entryCategory_iwf5k_235`,entryEmergent:`_entryEmergent_iwf5k_245`,entrySummary:`_entrySummary_iwf5k_253`,entrySubEvents:`_entrySubEvents_iwf5k_265`,entrySubEventRow:`_entrySubEventRow_iwf5k_272`,entrySubIdx:`_entrySubIdx_iwf5k_277`,entryDecision:`_entryDecision_iwf5k_284`};function KO(e,t){let n=[],r=e;for(let e of r.events){if(e.type===`turn_start`&&e.data.title&&e.data.title!==`Director generating...`&&n.push({turn:e.data.turn,time:e.data.time,title:e.data.title,summary:e.data.turnSummary||e.data.crisis||``,category:e.data.category||``,emergent:e.data.emergent||!1}),e.type===`event_start`){let t=e.data.turn,r=n.find(e=>e.turn===t);r&&(r.subEvents||=[],r.subEvents.push({index:Number(e.data.eventIndex??0),title:String(e.data.title||``),category:String(e.data.category||``)}))}if(e.type===`outcome`){let t=n.find(t=>t.turn===e.data.turn);t&&(t.outcome=e.data.outcome,t.decision=e.data._decision||``)}}return n.length&&(n[n.length-1].current=!t),n}function qO(e){if(!e)return{label:``,color:`var(--text-3)`};let t=e.includes(`success`);return{label:e.includes(`risky`)?t?`RISKY WIN`:`RISKY LOSS`:t?`SAFE WIN`:`SAFE LOSS`,color:t?`var(--green)`:`var(--rust)`}}function JO(e){if(!e)return null;let{color:t}=qO(e),n=e.includes(`success`),r=e.includes(`risky`)?n?`RS`:`RF`:n?`CS`:`CF`;return(0,R.jsx)(`span`,{className:GO.outcomeBadge,style:{"--status-color":t,"--status-bg":`transparent`},children:r})}function YO({t:e,sideColor:t}){let{label:n,color:r}=qO(e.outcome),i={"--side-color":t};return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:GO.tooltipHeader,children:[(0,R.jsxs)(`b`,{className:GO.tooltipTurn,style:i,children:[`Turn `,e.turn]}),(0,R.jsxs)(`span`,{className:GO.tooltipTime,children:[`Y`,e.time]}),e.category&&(0,R.jsx)(`span`,{className:GO.tooltipCategory,children:e.category}),e.emergent&&(0,R.jsx)(`span`,{className:GO.tooltipEmergent,children:`EMERGENT`})]}),(0,R.jsx)(`div`,{className:GO.tooltipTitle,children:e.title}),e.summary&&(0,R.jsx)(`div`,{className:GO.tooltipSummary,children:e.summary}),e.decision&&(0,R.jsxs)(`div`,{className:GO.tooltipDecision,children:[(0,R.jsx)(`span`,{className:GO.tooltipDecisionLabel,style:i,children:`Decision: `}),e.decision]}),e.outcome&&(0,R.jsx)(`div`,{className:GO.tooltipOutcome,style:{"--outcome-color":r},children:n})]})}function XO({turns:e,actorIndex:t}){let n=Xn(t),r={"--side-color":n},i=(0,L.useRef)(null),a=(0,L.useRef)(!0);return(0,L.useEffect)(()=>{if(!a.current)return;let e=i.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`})},[e.length]),(0,R.jsx)(`div`,{ref:i,onScroll:()=>{let e=i.current;e&&(a.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},className:GO.side,children:e.map(e=>(0,R.jsx)(UD,{dot:!0,content:(0,R.jsx)(YO,{t:e,sideColor:n}),children:(0,R.jsxs)(`div`,{className:[GO.entry,e.current?GO.current:``].filter(Boolean).join(` `),style:r,children:[(0,R.jsxs)(`div`,{className:GO.entryHead,children:[(0,R.jsxs)(`span`,{className:GO.entryTurn,style:r,children:[`T`,e.turn,` `,e.time]}),(0,R.jsx)(`span`,{className:GO.entryTitle,children:e.title}),e.category&&(0,R.jsx)(`span`,{className:GO.entryCategory,children:e.category}),e.emergent&&(0,R.jsx)(`span`,{className:GO.entryEmergent,children:`EMERGENT`}),JO(e.outcome)]}),e.summary&&(0,R.jsx)(`div`,{className:GO.entrySummary,children:e.summary}),e.subEvents&&e.subEvents.length>1&&(0,R.jsx)(`div`,{className:GO.entrySubEvents,children:e.subEvents.map((e,t)=>(0,R.jsxs)(`div`,{className:GO.entrySubEventRow,children:[(0,R.jsxs)(`span`,{className:GO.entrySubIdx,children:[e.index+1,`.`]}),(0,R.jsx)(`span`,{children:e.title})]},t))}),e.decision&&!e.subEvents?.length&&(0,R.jsx)(`div`,{className:GO.entryDecision,children:e.decision})]})},e.turn))})}function ZO({state:e}){let t=e.actorIds.map((t,n)=>{let r=e.actors[t];return{id:t,idx:n,turns:r?KO(r,e.isComplete):[],name:r?.leader?.name??t,archetype:r?.leader?.archetype}});return t.every(e=>e.turns.length===0)?null:(0,R.jsx)(`div`,{className:`timeline-row ${GO.timelineRow}`,role:`region`,"aria-label":`Turn timeline`,children:t.map(e=>{let t=Xn(e.idx);return(0,R.jsxs)(`div`,{className:GO.sideWrap,style:{"--side-color":t},children:[(0,R.jsxs)(`header`,{className:GO.sideHeader,children:[(0,R.jsxs)(`span`,{className:GO.sideHeaderIdx,children:[`A`,e.idx+1]}),(0,R.jsx)(`span`,{className:GO.sideHeaderName,title:e.name,children:e.name}),e.archetype&&(0,R.jsx)(`span`,{className:GO.sideHeaderArchetype,title:e.archetype,children:e.archetype})]}),(0,R.jsx)(XO,{turns:e.turns,actorIndex:e.idx})]},e.id)})})}var QO={risky_success:{bg:`rgba(232,180,74,.12)`,color:`var(--vis)`,border:`var(--amber-dim)`,label:`RISKY WIN`},risky_failure:{bg:`rgba(224,101,48,.12)`,color:`var(--rust)`,border:`var(--rust-dim)`,label:`RISKY LOSS`},conservative_success:{bg:`rgba(106,173,72,.12)`,color:`var(--green)`,border:`rgba(106,173,72,.25)`,label:`SAFE WIN`},conservative_failure:{bg:`rgba(224,101,48,.08)`,color:`var(--rust)`,border:`var(--rust-dim)`,label:`SAFE LOSS`}};function $O({outcome:e}){let t=QO[e]||{bg:`var(--bg-card)`,color:`var(--text-3)`,border:`var(--border)`,label:e.replace(/_/g,` `).toUpperCase()};return(0,R.jsx)(`span`,{style:{padding:`3px 10px`,borderRadius:`4px`,fontSize:`var(--font-xs)`,fontWeight:800,fontFamily:`var(--mono)`,display:`inline-block`,whiteSpace:`nowrap`,background:t.bg,color:t.color,border:`1px solid ${t.border}`},children:t.label})}var ek={row:`_row_1v4rw_1`,inline:`_inline_1v4rw_11`,label:`_label_1v4rw_17`,pill:`_pill_1v4rw_27`,popoverWrap:`_popoverWrap_1v4rw_41`,popoverHeader:`_popoverHeader_1v4rw_45`,popoverText:`_popoverText_1v4rw_54`,popoverUrlRow:`_popoverUrlRow_1v4rw_61`,popoverUrl:`_popoverUrl_1v4rw_61`,popoverDoi:`_popoverDoi_1v4rw_72`,popoverProvenance:`_popoverProvenance_1v4rw_78`,popoverHint:`_popoverHint_1v4rw_87`};function tk({citations:e,label:t=`sources`,inline:n=!1}){let r=HC();if(!e||e.length===0)return null;let i=new Set,a=[];for(let t of e){let e=(t.url||``).trim(),n=(t.text||``).trim();if(!e&&!n||!e&&n===`Seed document`)continue;let o=e||n,s=r.getNumber(o);if(s===0||i.has(s))continue;i.add(s);let c=r.getEntry(o);a.push({n:s,entry:c??{text:n||e,url:e,doi:t.doi}})}return a.length===0?null:(0,R.jsxs)(`div`,{className:[ek.row,n?ek.inline:``].filter(Boolean).join(` `),children:[t&&(0,R.jsx)(`span`,{className:ek.label,children:t}),a.map(({n:e,entry:t})=>(0,R.jsx)(nk,{n:e,entry:t},e))]})}function nk({n:e,entry:t}){let n=t.url||``,r=t.text||n||`Source [${e}]`,i=t.doi,a=t.departments?[...t.departments]:[],o=t.actorNames?[...t.actorNames]:[],s=(0,R.jsxs)(`div`,{className:ek.popoverWrap,children:[(0,R.jsxs)(`div`,{className:ek.popoverHeader,children:[`REFERENCE [`,e,`]`]}),(0,R.jsx)(`div`,{className:ek.popoverText,children:r}),n&&(0,R.jsx)(`div`,{className:ek.popoverUrlRow,children:(0,R.jsx)(`a`,{href:n,target:`_blank`,rel:`noopener noreferrer`,className:ek.popoverUrl,children:n})}),i&&(0,R.jsxs)(`div`,{className:ek.popoverDoi,children:[`DOI:`,i]}),(a.length>0||o.length>0)&&(0,R.jsxs)(`div`,{className:ek.popoverProvenance,children:[a.length>0&&(0,R.jsxs)(R.Fragment,{children:[`cited by `,a.join(`, `),` · `]}),o.length>0&&(0,R.jsxs)(R.Fragment,{children:[`leader `,o.join(` · `)]})]}),(0,R.jsx)(`div`,{className:ek.popoverHint,children:`Click to open source · or scroll to References below`})]});return(0,R.jsx)(UD,{content:s,children:(0,R.jsxs)(`a`,{href:n||`#cite-${e}`,target:n?`_blank`:void 0,rel:n?`noopener noreferrer`:void 0,onClick:t=>{let r=document.getElementById(`cite-${e}`);r&&(n||t.preventDefault(),r.scrollIntoView({behavior:`smooth`,block:`center`}),r.style.transition=`background 0.4s`,r.style.background=`rgba(232,180,74,0.18)`,setTimeout(()=>{r.style.background=``},1200))},className:ek.pill,children:[`[`,e,`]`]})})}var J={eventStartRow:`_eventStartRow_1d0sd_1`,notFirst:`_notFirst_1d0sd_9`,eventNumber:`_eventNumber_1d0sd_14`,eventStartTitle:`_eventStartTitle_1d0sd_21`,eventCategoryPill:`_eventCategoryPill_1d0sd_26`,promotionTooltipTitle:`_promotionTooltipTitle_1d0sd_35`,promotionTooltipRow:`_promotionTooltipRow_1d0sd_42`,promotionTooltipKey:`_promotionTooltipKey_1d0sd_46`,promotionTooltipValue:`_promotionTooltipValue_1d0sd_50`,promotionTooltipReason:`_promotionTooltipReason_1d0sd_55`,promotionRow:`_promotionRow_1d0sd_60`,promotionArrow:`_promotionArrow_1d0sd_70`,promotionRole:`_promotionRole_1d0sd_75`,promotionReason:`_promotionReason_1d0sd_81`,forgeBtn:`_forgeBtn_1d0sd_90`,forgeSlide:`_forgeSlide_1d0sd_1`,forgeRow:`_forgeRow_1d0sd_110`,forgeBadge:`_forgeBadge_1d0sd_117`,forgeDept:`_forgeDept_1d0sd_130`,forgeDescription:`_forgeDescription_1d0sd_136`,forgeName:`_forgeName_1d0sd_141`,forgeVerdictPass:`_forgeVerdictPass_1d0sd_147`,forgeVerdictFail:`_forgeVerdictFail_1d0sd_159`,forgeFieldsRow:`_forgeFieldsRow_1d0sd_171`,fieldsLabelIn:`_fieldsLabelIn_1d0sd_181`,fieldsLabelOut:`_fieldsLabelOut_1d0sd_185`,forgeError:`_forgeError_1d0sd_189`,specWrap:`_specWrap_1d0sd_196`,specCard:`_specCard_1d0sd_200`,specHeader:`_specHeader_1d0sd_209`,specHeaderDept:`_specHeaderDept_1d0sd_217`,specToolCount:`_specToolCount_1d0sd_225`,severityBadge:`_severityBadge_1d0sd_231`,specSummary:`_specSummary_1d0sd_241`,specSummaryEmpty:`_specSummaryEmpty_1d0sd_248`,specRisks:`_specRisks_1d0sd_256`,specRisksLabel:`_specRisksLabel_1d0sd_260`,specRiskRow:`_specRiskRow_1d0sd_269`,specRiskSeverity:`_specRiskSeverity_1d0sd_278`,specRecs:`_specRecs_1d0sd_287`,specRecsLabel:`_specRecsLabel_1d0sd_291`,specRecRow:`_specRecRow_1d0sd_300`,toolDetail:`_toolDetail_1d0sd_309`,newTool:`_newTool_1d0sd_320`,forgeGlow:`_forgeGlow_1d0sd_1`,reused:`_reused_1d0sd_324`,toolSummary:`_toolSummary_1d0sd_328`,toolSummaryMain:`_toolSummaryMain_1d0sd_336`,toolSummaryHead:`_toolSummaryHead_1d0sd_341`,toolNewBadge:`_toolNewBadge_1d0sd_348`,toolReusedBadge:`_toolReusedBadge_1d0sd_361`,toolFirstForged:`_toolFirstForged_1d0sd_374`,toolSchemaBadge:`_toolSchemaBadge_1d0sd_380`,toolDescription:`_toolDescription_1d0sd_390`,toolNameLine:`_toolNameLine_1d0sd_397`,toolPassPill:`_toolPassPill_1d0sd_405`,toolFailPill:`_toolFailPill_1d0sd_418`,toolInspectBtn:`_toolInspectBtn_1d0sd_431`,toolBody:`_toolBody_1d0sd_449`,toolMetaRow:`_toolMetaRow_1d0sd_454`,toolMetaLabel:`_toolMetaLabel_1d0sd_459`,toolRawSummary:`_toolRawSummary_1d0sd_466`,toolRawPre:`_toolRawPre_1d0sd_474`,toolEmpty:`_toolEmpty_1d0sd_489`,outcomeCard:`_outcomeCard_1d0sd_494`,decisionPulse:`_decisionPulse_1d0sd_1`,outcomeHead:`_outcomeHead_1d0sd_505`,outcomeLabel:`_outcomeLabel_1d0sd_512`,outcomeMeta:`_outcomeMeta_1d0sd_520`,outcomeText:`_outcomeText_1d0sd_527`,outcomeDeltas:`_outcomeDeltas_1d0sd_533`,outcomeDeltaSpan:`_outcomeDeltaSpan_1d0sd_540`,outcomeBar:`_outcomeBar_1d0sd_544`,outcomeBarDeparts:`_outcomeBarDeparts_1d0sd_552`,outcomeReasoningSummary:`_outcomeReasoningSummary_1d0sd_556`,outcomeReasoningBody:`_outcomeReasoningBody_1d0sd_563`,outcomeReasoningPre:`_outcomeReasoningPre_1d0sd_570`,outcomeRationale:`_outcomeRationale_1d0sd_582`,outcomePolicyLine:`_outcomePolicyLine_1d0sd_587`,driftRow:`_driftRow_1d0sd_591`,driftLabel:`_driftLabel_1d0sd_599`,driftName:`_driftName_1d0sd_607`,reactionsCard:`_reactionsCard_1d0sd_611`,reactionsHead:`_reactionsHead_1d0sd_620`,reactionsLabel:`_reactionsLabel_1d0sd_627`,reactionsBar:`_reactionsBar_1d0sd_636`,reactionsBarSegment:`_reactionsBarSegment_1d0sd_645`,reactionsLegend:`_reactionsLegend_1d0sd_650`,reactionsLegendItem:`_reactionsLegendItem_1d0sd_657`,reactionsLegendSwatch:`_reactionsLegendSwatch_1d0sd_663`,reactionsQuotesSummary:`_reactionsQuotesSummary_1d0sd_671`,reactionsQuotesList:`_reactionsQuotesList_1d0sd_679`,reactionTooltipName:`_reactionTooltipName_1d0sd_686`,reactionTooltipMeta:`_reactionTooltipMeta_1d0sd_692`,reactionTooltipHexaco:`_reactionTooltipHexaco_1d0sd_697`,reactionTooltipHealth:`_reactionTooltipHealth_1d0sd_704`,reactionTooltipQuote:`_reactionTooltipQuote_1d0sd_709`,reactionTooltipMoodLine:`_reactionTooltipMoodLine_1d0sd_717`,reactionTooltipBeliefs:`_reactionTooltipBeliefs_1d0sd_724`,reactionRow:`_reactionRow_1d0sd_730`,notLast:`_notLast_1d0sd_739`,reactionRowName:`_reactionRowName_1d0sd_743`,reactionRowQuote:`_reactionRowQuote_1d0sd_750`,reactionRowMoodPill:`_reactionRowMoodPill_1d0sd_761`,bulletinWrap:`_bulletinWrap_1d0sd_773`,bulletinTooltipName:`_bulletinTooltipName_1d0sd_777`,bulletinTooltipRole:`_bulletinTooltipRole_1d0sd_781`,bulletinTooltipBody:`_bulletinTooltipBody_1d0sd_786`,bulletinTooltipMood:`_bulletinTooltipMood_1d0sd_792`,bulletinRow:`_bulletinRow_1d0sd_798`,bulletinName:`_bulletinName_1d0sd_807`,bulletinPost:`_bulletinPost_1d0sd_813`,bulletinLikes:`_bulletinLikes_1d0sd_822`,turnDone:`_turnDone_1d0sd_828`,fallbackBox:`_fallbackBox_1d0sd_841`,fallbackTitle:`_fallbackTitle_1d0sd_853`,fallbackSite:`_fallbackSite_1d0sd_859`,fallbackPreviewWrap:`_fallbackPreviewWrap_1d0sd_864`,fallbackPreviewSummary:`_fallbackPreviewSummary_1d0sd_868`,fallbackPreviewPre:`_fallbackPreviewPre_1d0sd_874`,schemaBlock:`_schemaBlock_1d0sd_885`,schemaFieldsLabel:`_schemaFieldsLabel_1d0sd_889`,schemaFieldsList:`_schemaFieldsList_1d0sd_897`,schemaTitle:`_schemaTitle_1d0sd_902`,schemaTable:`_schemaTable_1d0sd_911`,schemaRow:`_schemaRow_1d0sd_919`,schemaKeyCell:`_schemaKeyCell_1d0sd_923`,schemaRequired:`_schemaRequired_1d0sd_931`,schemaTypeCell:`_schemaTypeCell_1d0sd_936`,schemaDescCell:`_schemaDescCell_1d0sd_943`,forgeDetails:`_forgeDetails_1d0sd_951`,forgeSummary:`_forgeSummary_1d0sd_963`,forgeInspectAbs:`_forgeInspectAbs_1d0sd_980`,forgeBody:`_forgeBody_1d0sd_998`,specDetails:`_specDetails_1d0sd_1003`,specSummaryRow:`_specSummaryRow_1d0sd_1012`,specBody:`_specBody_1d0sd_1029`,reactionsDetails:`_reactionsDetails_1d0sd_1035`,reactionsSummary:`_reactionsSummary_1d0sd_1043`,reactionsTopMood:`_reactionsTopMood_1d0sd_1060`,reactionsBody:`_reactionsBody_1d0sd_1068`,bulletinDetails:`_bulletinDetails_1d0sd_1073`,bulletinSummary:`_bulletinSummary_1d0sd_1077`,bulletinSummaryLabel:`_bulletinSummaryLabel_1d0sd_1095`,bulletinSummaryNames:`_bulletinSummaryNames_1d0sd_1105`,bulletinBody:`_bulletinBody_1d0sd_1115`,fallbackDetails:`_fallbackDetails_1d0sd_1119`,fallbackSummary:`_fallbackSummary_1d0sd_1130`},rk={positive:`var(--green)`,negative:`var(--rust)`,anxious:`var(--amber)`,defiant:`var(--rust)`,hopeful:`var(--green)`,resigned:`var(--text-3)`,neutral:`var(--text-2)`},ik={positive:`#6aad48`,negative:`#e06530`,anxious:`#e8b44a`,defiant:`#e06530`,hopeful:`#6aad48`,resigned:`#a89878`,neutral:`#a89878`};function ak({event:e,actorIndex:t,actorSlot:n}){let r=fF(),i=Dw(),a=n??t,o=Xn(t),s={"--side-color":o},c=e.data;switch(e.type){case`turn_start`:return null;case`event_start`:{let e=Number(c.eventIndex??0),t=Number(c.totalEvents??1),n=String(c.title||``),r=String(c.category||``);return t<=1?null:(0,R.jsxs)(`div`,{id:`sim-event-${a}-${Number(c.turn??0)}-${e}`,tabIndex:-1,className:[J.eventStartRow,e>0?J.notFirst:``].filter(Boolean).join(` `),children:[(0,R.jsxs)(`span`,{className:J.eventNumber,children:[`EVENT `,e+1,`/`,t]}),(0,R.jsx)(`span`,{className:J.eventStartTitle,children:n}),r&&(0,R.jsx)(`span`,{className:J.eventCategoryPill,children:r})]})}case`promotion`:{let e=String(c.reason||``),t=String(c.name||``),n=String(c.role||``);return(0,R.jsx)(UD,{content:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`b`,{className:J.promotionTooltipTitle,style:s,children:[`Promotion: `,n]}),t&&(0,R.jsxs)(`div`,{className:J.promotionTooltipRow,children:[(0,R.jsx)(`span`,{className:J.promotionTooltipKey,children:`Agent:`}),` `,(0,R.jsx)(`span`,{className:J.promotionTooltipValue,children:t})]}),e&&(0,R.jsx)(`div`,{className:J.promotionTooltipReason,children:e})]}),children:(0,R.jsxs)(`div`,{className:J.promotionRow,children:[(0,R.jsx)(`span`,{className:J.promotionArrow,children:`→`}),(0,R.jsx)(`span`,{className:J.promotionRole,style:s,children:n}),(0,R.jsx)(`span`,{className:J.promotionReason,children:e})]})})}case`specialist_start`:case`decision_pending`:return null;case`forge_attempt`:{let e=String(c.department||``),t=String(c.name||`unnamed`),n=String(c.description||t),r=String(c.mode||`sandbox`),s=c.approved!==!1,l=typeof c.confidence==`number`?c.confidence:.85,u=c.errorReason?String(c.errorReason):``,d=s?o:`var(--rust)`,f=Array.isArray(c.inputFields)?c.inputFields:[],p=Array.isArray(c.outputFields)?c.outputFields:[],m={"--accent":d,"--bg-tint":s?`color-mix(in srgb, ${o} 7%, transparent)`:`rgba(224,101,48,0.04)`,"--border-tint":s?`color-mix(in srgb, ${o} 25%, transparent)`:`rgba(224,101,48,0.2)`,"--shadow-tint":s?`0 0 0 1px color-mix(in srgb, ${o} 10%, transparent)`:`var(--card-shadow)`,"--badge-color":s?`var(--bg-deep)`:`#fff`,"--badge-bg":d,"--badge-shadow":s?`0 0 8px rgba(232,180,74,0.4)`:`none`};return(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(`details`,{className:J.forgeDetails,style:m,children:[(0,R.jsx)(`summary`,{className:J.forgeSummary,children:(0,R.jsxs)(`span`,{className:J.forgeRow,children:[(0,R.jsx)(`span`,{className:J.forgeBadge,children:s?`✦ FORGED TOOL`:`↻ FORGE RETRY`}),(0,R.jsx)(`span`,{className:J.forgeDept,children:e}),(0,R.jsx)(`span`,{className:J.forgeDescription,children:n}),(0,R.jsxs)(`span`,{className:J.forgeName,children:[t,` (`,r,`)`]}),(0,R.jsx)(`span`,{className:s?J.forgeVerdictPass:J.forgeVerdictFail,children:s?`PASS ${l.toFixed(2)}`:`RETRY`})]})}),(0,R.jsx)(`button`,{type:`button`,onClick:e=>i.openTrace({actorIndex:a,toolName:t},e.currentTarget,`inspect`),"aria-label":`Inspect forged tool ${t}`,className:J.forgeInspectAbs,children:`INSPECT`}),(0,R.jsxs)(`div`,{className:J.forgeBody,children:[(f.length>0||p.length>0)&&(0,R.jsxs)(`div`,{className:J.forgeFieldsRow,children:[f.length>0&&(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:J.fieldsLabelIn,children:`in:`}),` `,f.join(`, `)]}),p.length>0&&(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:J.fieldsLabelOut,children:`out:`}),` `,p.join(`, `)]})]}),!s&&u&&(0,R.jsx)(`div`,{className:J.forgeError,children:u})]})]})})}case`specialist_done`:{let e=String(c.department||``),t=c._filteredTools||[],n=t.filter(e=>e?.isNew!==!0),s=Array.isArray(c.risks)?c.risks:[],l=Array.isArray(c.recommendedActions)?c.recommendedActions.map(String):[],u=s.some(e=>e.severity===`critical`)?`critical`:s.some(e=>e.severity===`high`)?`high`:``,d=String(c.summary||``),f=Number(c.citations)||0;if(!d&&s.length===0&&l.length===0&&t.length===0&&f===0)return null;let p={"--card-bg":u===`critical`?`rgba(224,101,48,.08)`:u===`high`?`rgba(232,180,74,.06)`:`var(--bg-card)`,"--card-border":u===`critical`?`rgba(224,101,48,.25)`:u===`high`?`rgba(232,180,74,.2)`:`var(--border)`,"--card-accent":u===`critical`?`var(--rust)`:u===`high`?`var(--amber)`:`var(--teal)`},m=u?{"--sev-color":u===`critical`?`var(--rust)`:`var(--amber)`,"--sev-bg":u===`critical`?`rgba(224,101,48,.15)`:`rgba(232,180,74,.1)`}:void 0;return(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(`div`,{className:J.specWrap,children:[(0,R.jsxs)(`details`,{className:J.specDetails,style:p,children:[(0,R.jsxs)(`summary`,{className:J.specSummaryRow,children:[(0,R.jsxs)(`span`,{className:J.specHeaderDept,children:[r.ui.departmentIcons[e]||``,` `,e]}),t.length>0&&(0,R.jsxs)(`span`,{className:J.specToolCount,children:[`+`,t.length,` tool`,t.length===1?``:`s`,n.length<t.length&&` (${n.length} reused)`]}),u&&(0,R.jsxs)(`span`,{className:J.severityBadge,style:m,children:[u.toUpperCase(),` RISK`]}),(0,R.jsx)(tk,{citations:c.citationList||[],inline:!0,label:``})]}),(0,R.jsxs)(`div`,{className:J.specBody,children:[d?(0,R.jsx)(`div`,{className:J.specSummary,children:d}):s.length===0&&l.length===0&&(f>0||t.length>0)?(0,R.jsxs)(`div`,{className:J.specSummaryEmpty,children:[`Department analysis complete — no narrative summary returned, but`,f>0&&` ${f} source${f===1?``:`s`} surveyed`,f>0&&t.length>0&&` and `,t.length>0&&` ${t.length} tool${t.length===1?``:`s`} forged`,`.`]}):null,s.length>0&&(0,R.jsxs)(`div`,{className:J.specRisks,children:[(0,R.jsx)(`div`,{className:J.specRisksLabel,children:`RISKS`}),s.slice(0,3).map((e,t)=>(0,R.jsxs)(`div`,{className:J.specRiskRow,children:[(0,R.jsx)(`span`,{className:J.specRiskSeverity,style:{"--risk-color":e.severity===`critical`||e.severity===`high`?`var(--rust)`:`var(--amber)`},children:String(e.severity||`med`).toUpperCase()}),(0,R.jsx)(`span`,{children:String(e.description||``)})]},t))]}),l.length>0&&(0,R.jsxs)(`div`,{className:J.specRecs,children:[(0,R.jsx)(`div`,{className:J.specRecsLabel,children:`RECOMMENDATIONS`}),l.slice(0,3).map((e,t)=>(0,R.jsx)(`div`,{className:J.specRecRow,children:e},t))]})]})]}),n.map((e,t)=>{let n=e.approved!==!1,r=e.isNew===!0,s=n?r?o:`var(--green)`:`var(--rust)`,c=n?r?`color-mix(in srgb, ${o} 10%, transparent)`:`rgba(106,173,72,.06)`:`rgba(224,101,48,.04)`,l=n?r?`color-mix(in srgb, ${o} 40%, transparent)`:`rgba(106,173,72,.2)`:`rgba(224,101,48,.15)`,u=r?`0 0 0 1px color-mix(in srgb, ${o} 15%, transparent), var(--card-shadow)`:`var(--card-shadow)`,d=e.inputSchema,f=e.outputSchema,p=!!d||!!f,m={"--tool-bg":c,"--tool-border":l,"--tool-accent":s,"--tool-shadow":u,"--side-color":o},h=[J.toolDetail,r?J.newTool:J.reused].join(` `);return(0,R.jsxs)(`details`,{className:h,style:m,children:[(0,R.jsxs)(`summary`,{className:J.toolSummary,children:[(0,R.jsxs)(`div`,{className:J.toolSummaryMain,children:[(0,R.jsxs)(`div`,{className:J.toolSummaryHead,children:[r?(0,R.jsx)(`span`,{className:J.toolNewBadge,children:`FORGED TOOL`}):(0,R.jsx)(`span`,{className:J.toolReusedBadge,children:`REUSED`}),!r&&e.firstForgedTurn!=null&&(0,R.jsxs)(`span`,{className:J.toolFirstForged,children:[`first forged T`,e.firstForgedTurn,e.firstForgedDepartment&&e.firstForgedDepartment!==e.department?` · ${e.firstForgedDepartment}`:``]}),p&&(0,R.jsx)(`span`,{className:J.toolSchemaBadge,children:`SCHEMA`})]}),(0,R.jsx)(`span`,{className:J.toolDescription,children:String(e.description||e.name||``)}),(0,R.jsxs)(`span`,{className:J.toolNameLine,children:[e.name,` `,e.mode?`(${e.mode})`:``]})]}),(0,R.jsx)(`span`,{className:n?J.toolPassPill:J.toolFailPill,children:n?`PASS ${(typeof e.confidence==`number`?e.confidence:.85).toFixed(2)}`:`RETRY`})]}),(0,R.jsx)(`button`,{type:`button`,onClick:t=>{t.preventDefault(),t.stopPropagation(),i.openTrace({actorIndex:a,toolName:String(e.name||``)},t.currentTarget,`inspect`)},"aria-label":`Inspect tool ${e.name||``}`,className:J.toolInspectBtn,children:`INSPECT`}),(0,R.jsxs)(`div`,{className:J.toolBody,children:[e.crisis&&(0,R.jsxs)(`div`,{className:J.toolMetaRow,children:[(0,R.jsx)(`span`,{className:J.toolMetaLabel,children:`CRISIS: `}),String(e.crisis)]}),e.department&&(0,R.jsxs)(`div`,{className:J.toolMetaRow,children:[(0,R.jsx)(`span`,{className:J.toolMetaLabel,children:`DEPT: `}),String(e.department)]}),(d||Array.isArray(e.inputFields)&&e.inputFields.length>0)&&(0,R.jsx)(sk,{label:`INPUT`,color:`var(--teal)`,schema:d,fields:e.inputFields}),(f||Array.isArray(e.outputFields)&&e.outputFields.length>0)&&(0,R.jsx)(sk,{label:`OUTPUT`,color:`var(--green)`,schema:f,fields:e.outputFields}),e.output&&(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{className:J.toolRawSummary,style:{"--side-color":o},children:`Raw Output`}),(0,R.jsx)(`pre`,{className:J.toolRawPre,children:typeof e.output==`object`?JSON.stringify(e.output,null,2):String(e.output)})]}),!e.output&&!d&&!f&&(!e.inputFields||e.inputFields.length===0)&&(0,R.jsx)(`div`,{className:J.toolEmpty,children:`Tool forged but no output captured. The tool will be available for subsequent turns.`})]})]},t)})]})})}case`outcome`:{let e=String(c.outcome||``),n=String(c._decision||``),r=String(c._rationale||``),i=String(c._reasoning||``),a=c._policies||[],s=c._barCheck,l={...c.systemDeltas,...c.politicsDeltas},u=String(c.turn||``),d=Number(c._toolCount??0),f=Number(c._citeCount??0),p={"--side-color":o,"--outcome-bg":t===0?`rgba(232,180,74,.06)`:`rgba(76,168,168,.06)`,"--outcome-border":t===0?`var(--amber-dim)`:`var(--teal-dim)`};return(0,R.jsxs)(`div`,{className:J.outcomeCard,style:p,children:[(0,R.jsxs)(`div`,{className:J.outcomeHead,children:[(0,R.jsxs)(`span`,{children:[(0,R.jsxs)(`span`,{className:J.outcomeLabel,children:[`DECISION #`,u]}),(0,R.jsxs)(`span`,{className:J.outcomeMeta,children:[d,` tools · `,f,` citations`]})]}),(0,R.jsx)($O,{outcome:e})]}),(0,R.jsx)(`div`,{className:J.outcomeText,children:n}),s&&(0,R.jsx)(`div`,{className:s.departs?`${J.outcomeBar} ${J.outcomeBarDeparts}`:J.outcomeBar,children:ok(s)}),Object.keys(l).length>0&&(0,R.jsx)(`div`,{className:J.outcomeDeltas,children:Object.entries(l).map(([e,t])=>(0,R.jsxs)(`span`,{className:J.outcomeDeltaSpan,children:[e,` `,t>0?`+`:``,typeof t==`number`?Number.isInteger(t)?t:t.toFixed(2):t,` · `]},e))}),(r||i||a.length>0)&&(0,R.jsxs)(`details`,{children:[(0,R.jsx)(`summary`,{className:J.outcomeReasoningSummary,children:`Full reasoning & policies`}),(0,R.jsxs)(`div`,{className:J.outcomeReasoningBody,children:[i&&(0,R.jsx)(`div`,{className:J.outcomeReasoningPre,children:i}),n&&(0,R.jsx)(`div`,{children:n}),r&&(0,R.jsx)(`div`,{className:J.outcomeRationale,children:r}),a.map((e,t)=>(0,R.jsxs)(`div`,{className:J.outcomePolicyLine,children:[`→ `,e]},t))]})]})]})}case`personality_drift`:{let e=Object.values(c.agents||{});return e.length?(0,R.jsxs)(`div`,{className:J.driftRow,children:[(0,R.jsx)(`span`,{className:J.driftLabel,children:`DRIFT `}),e.slice(0,3).map((t,n)=>(0,R.jsxs)(`span`,{children:[(0,R.jsx)(`span`,{className:J.driftName,style:s,children:t.name?.split(` `)[0]}),` `,`O`,t.hexaco?.O??`?`,` C`,t.hexaco?.C??`?`,n<Math.min(e.length,3)-1?` · `:``]},n))]}):null}case`agent_reactions`:{let e=c.reactions||[],t=c.totalReactions||e.length;if(!e.length)return null;let n={};for(let t of e)n[t.mood]=(n[t.mood]||0)+1;let r=Object.entries(n).sort((e,t)=>t[1]-e[1]).map(([t,n])=>({mood:t,count:n,pct:Math.round(n/e.length*100),bg:ik[t]||`#a89878`}));return(0,R.jsxs)(`details`,{className:J.reactionsDetails,children:[(0,R.jsxs)(`summary`,{className:J.reactionsSummary,children:[(0,R.jsxs)(`span`,{className:J.reactionsLabel,style:s,children:[t,` VOICES`]}),(0,R.jsx)(`div`,{className:J.reactionsBar,children:r.map(e=>(0,R.jsx)(`div`,{className:J.reactionsBarSegment,style:{"--seg-flex":String(e.pct),"--seg-bg":e.bg},title:`${e.pct}% ${e.mood}`},e.mood))}),(0,R.jsx)(`span`,{className:J.reactionsTopMood,children:r[0]?`${r[0].pct}% ${r[0].mood}`:``})]}),(0,R.jsxs)(`div`,{className:J.reactionsBody,children:[(0,R.jsx)(`div`,{className:J.reactionsLegend,children:r.slice(0,3).map(e=>(0,R.jsxs)(`span`,{className:J.reactionsLegendItem,children:[(0,R.jsx)(`span`,{className:J.reactionsLegendSwatch,style:{"--swatch-bg":e.bg}}),e.pct,`% `,e.mood]},e.mood))}),(0,R.jsxs)(`details`,{children:[(0,R.jsxs)(`summary`,{className:J.reactionsQuotesSummary,style:s,children:[`quotes (`,e.length,`)`]}),(0,R.jsx)(`div`,{className:J.reactionsQuotesList,children:e.slice(0,4).map((t,n)=>(0,R.jsx)(UD,{dot:!0,content:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`b`,{className:J.reactionTooltipName,style:s,children:t.name}),(0,R.jsxs)(`div`,{className:J.reactionTooltipMeta,children:[t.role,` in `,t.department,` `,t.age?`· Age ${t.age}`:``]}),(0,R.jsxs)(`div`,{className:J.reactionTooltipHexaco,children:[`O:`,t.hexaco?.O,` C:`,t.hexaco?.C,` E:`,t.hexaco?.E,` A:`,t.hexaco?.A,` Em:`,t.hexaco?.Em,` HH:`,t.hexaco?.HH]}),(0,R.jsxs)(`div`,{className:J.reactionTooltipHealth,children:[`Bone: `,t.boneDensity,`% · Radiation: `,t.radiation,`mSv · Psych: `,t.psychScore]}),(0,R.jsxs)(`div`,{className:J.reactionTooltipQuote,children:[`“`,t.quote,`”`]}),(0,R.jsxs)(`div`,{className:J.reactionTooltipMoodLine,style:{"--mood-color":rk[t.mood]||`var(--text-3)`},children:[String(t.mood||``).toUpperCase(),` · intensity `,t.intensity?.toFixed?.(2)||`?`]}),t.memory?.beliefs?.length>0&&(0,R.jsxs)(`div`,{className:J.reactionTooltipBeliefs,children:[`Beliefs: `,t.memory.beliefs.slice(0,2).join(`; `)]})]}),children:(0,R.jsxs)(`div`,{className:[J.reactionRow,n<Math.min(e.length,4)-1?J.notLast:``].filter(Boolean).join(` `),children:[(0,R.jsx)(`span`,{className:J.reactionRowName,style:s,children:t.name}),(0,R.jsxs)(`span`,{className:J.reactionRowQuote,children:[`“`,String(t.quote||``),`”`]}),(0,R.jsx)(`span`,{className:J.reactionRowMoodPill,style:{"--mood-color":rk[t.mood]||`var(--text-3)`},children:String(t.mood||``).toUpperCase()})]})},n))})]})]})]})}case`bulletin`:{let e=c.posts||[];return e.length?(0,R.jsxs)(`details`,{className:J.bulletinDetails,children:[(0,R.jsxs)(`summary`,{className:J.bulletinSummary,children:[(0,R.jsxs)(`span`,{className:J.bulletinSummaryLabel,children:[e.length,` POSTS`]}),(0,R.jsxs)(`span`,{className:J.bulletinSummaryNames,children:[e.slice(0,2).map(e=>String(e.name??``).split(` `)[0]).filter(Boolean).join(` · `),e.length>2?` +${e.length-2}`:``]})]}),(0,R.jsx)(`div`,{className:J.bulletinBody,children:e.slice(0,3).map((e,t)=>(0,R.jsx)(UD,{dot:!0,content:(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`b`,{className:J.bulletinTooltipName,style:s,children:e.name}),` `,(0,R.jsxs)(`span`,{className:J.bulletinTooltipRole,children:[e.role,` `,e.department]}),(0,R.jsx)(`div`,{className:J.bulletinTooltipBody,children:e.post}),(0,R.jsxs)(`div`,{className:J.bulletinTooltipMood,style:{"--mood-color":rk[e.mood]||`var(--text-3)`},children:[String(e.mood||``).toUpperCase(),` · `,e.likes||0,` likes · `,e.replies||0,` replies`]})]}),children:(0,R.jsxs)(`div`,{className:J.bulletinRow,children:[(0,R.jsx)(`span`,{className:J.bulletinName,style:s,children:e.name}),(0,R.jsx)(`span`,{className:J.bulletinPost,children:String(e.post||``)}),(0,R.jsxs)(`span`,{className:J.bulletinLikes,children:[`♥`,e.likes||0]})]})},t))})]}):null}case`turn_done`:return null;case`validation_fallback`:{let e=String(c.schemaName||`<unknown>`),t=String(c.site||``),n=String(c.rawTextPreview||``),r=c.salvaged===!0,i=Array.isArray(c.droppedKeys)?c.droppedKeys.map(e=>String(e)):[];return(0,R.jsxs)(`details`,{className:J.fallbackDetails,style:s,children:[(0,R.jsxs)(`summary`,{className:J.fallbackSummary,children:[(0,R.jsxs)(`span`,{className:J.fallbackTitle,children:[`⚠ `,r?`SCHEMA SALVAGE`:`SCHEMA FALLBACK`,` — `,e]}),(0,R.jsxs)(`span`,{className:J.fallbackSite,children:[`site: `,t||`n/a`]}),r&&(0,R.jsxs)(`span`,{className:J.fallbackSite,children:[`kept without: `,i.length>0?i.join(`, `):`n/a`]})]}),n&&(0,R.jsxs)(`details`,{className:J.fallbackPreviewWrap,children:[(0,R.jsx)(`summary`,{className:J.fallbackPreviewSummary,children:`Raw output preview`}),(0,R.jsx)(`pre`,{className:J.fallbackPreviewPre,children:n})]})]})}default:return null}}function ok(e){let t=e.clearsBar?`clears it`:`is under it`,n=e.choseBold?`the bold option was taken`:`the bold option was refused`;if(!e.departs)return`Bar ${e.bar}: the bold option's chance ${e.boldChance} ${t}, so ${n}`;let r=e.departureFact?`, for: ${e.departureFact}`:`, with no fact named for it`;return`Bar ${e.bar}: the bold option's chance ${e.boldChance} ${t}, yet ${n}${r}`}function sk({label:e,color:t,schema:n,fields:r}){let i=n&&typeof n==`object`&&n.properties||null,a=n&&typeof n==`object`&&Array.isArray(n.required)?n.required:[];if(!i)return!r||r.length===0?null:(0,R.jsxs)(`div`,{className:J.schemaBlock,children:[(0,R.jsxs)(`span`,{className:J.schemaFieldsLabel,style:{"--field-color":t},children:[e,` FIELDS:`,` `]}),(0,R.jsx)(`span`,{className:J.schemaFieldsList,children:r.join(`, `)})]});let o=Object.entries(i).slice(0,12);return(0,R.jsxs)(`div`,{className:J.schemaBlock,children:[(0,R.jsxs)(`div`,{className:J.schemaTitle,style:{"--field-color":t},children:[e,` SCHEMA`]}),(0,R.jsx)(`table`,{className:J.schemaTable,children:(0,R.jsx)(`tbody`,{children:o.map(([e,n])=>{let r=String(n?.type??`any`),i=typeof n?.description==`string`?n.description:``,o=a.includes(e);return(0,R.jsxs)(`tr`,{className:J.schemaRow,children:[(0,R.jsxs)(`td`,{className:J.schemaKeyCell,children:[e,o&&(0,R.jsx)(`span`,{className:J.schemaRequired,children:`*`})]}),(0,R.jsx)(`td`,{className:J.schemaTypeCell,style:{"--field-color":t},children:r}),(0,R.jsx)(`td`,{className:J.schemaDescCell,children:i})]},e)})})})]})}var ck={badge:`_badge_1lgt8_1`,same:`_same_1lgt8_15`,differentOutcome:`_differentOutcome_1lgt8_21`,differentEvent:`_differentEvent_1lgt8_27`,pending:`_pending_1lgt8_33`,oneSided:`_oneSided_1lgt8_40`},lk={same:`✓ SAME`,"different-outcome":`⚠ DIFFERENT OUTCOME`,"different-event":`⚠ DIFFERENT EVENT`,pending:`… running`,"one-sided":`· · · waiting`},uk={same:`Same event, same outcome`,"different-outcome":`Same event, different outcome`,"different-event":`Different events`,pending:`Turn is still running`,"one-sided":`Only one leader has reached this turn`},dk={same:ck.same,"different-outcome":ck.differentOutcome,"different-event":ck.differentEvent,pending:ck.pending,"one-sided":ck.oneSided};function fk({classification:e}){return(0,R.jsx)(`span`,{className:`${ck.badge} ${dk[e]}`,"aria-label":uk[e],children:lk[e]})}var pk={row:`_row_rngwb_1`,differentOutcome:`_differentOutcome_rngwb_9`,differentEvent:`_differentEvent_rngwb_13`,header:`_header_rngwb_17`,headerTurn:`_headerTurn_rngwb_30`,headerTitle:`_headerTitle_rngwb_36`,headerTitleSplit:`_headerTitleSplit_rngwb_45`,headerTitleA:`_headerTitleA_rngwb_52`,headerTitleB:`_headerTitleB_rngwb_61`,cells:`_cells_rngwb_70`,cell:`_cell_rngwb_70`,cellBand:`_cellBand_rngwb_82`,cellEmpty:`_cellEmpty_rngwb_92`,cellPending:`_cellPending_rngwb_99`,cellPendingSpinner:`_cellPendingSpinner_rngwb_110`},mk=new Set([`turn_start`,`specialist_start`,`decision_pending`]);function hk(e){let t=new Set,n=!1;for(let r of e)if(r.type===`specialist_start`){let e=r.data?.department;typeof e==`string`&&e.length>0&&t.add(e)}else r.type===`decision_pending`&&(n=!0);let r=[];return t.size>0&&r.push(`${[...t].join(`, `)} analyzing`),n&&r.push(`awaiting decision`),r.length>0?r.join(` · `)+`…`:`Working on this turn…`}function gk({entry:e,eventsA:t,eventsB:n,runTerminal:r,runAborted:i}){let a=`${pk.row} ${e.classification===`different-outcome`?pk.differentOutcome:e.classification===`different-event`?pk.differentEvent:``}`,o=e.titleA===e.titleB&&e.titleA!==``;return(0,R.jsxs)(`section`,{id:`turn-row-${e.turn}`,className:a,"aria-labelledby":`turn-row-${e.turn}-h`,children:[(0,R.jsxs)(`h3`,{id:`turn-row-${e.turn}-h`,className:pk.header,tabIndex:-1,children:[(0,R.jsxs)(`span`,{className:pk.headerTurn,children:[`T`,e.turn]}),(0,R.jsx)(fk,{classification:e.classification}),o?(0,R.jsx)(`span`,{className:pk.headerTitle,children:e.titleA}):(0,R.jsxs)(`span`,{className:pk.headerTitleSplit,children:[(0,R.jsx)(`span`,{className:pk.headerTitleA,children:e.titleA||`—`}),(0,R.jsx)(`span`,{className:pk.headerTitleB,children:e.titleB||`—`})]})]}),(0,R.jsx)(`div`,{className:pk.cells,children:[t,n].map((t,n)=>{let a=t.filter(e=>!mk.has(e.type)),o=t.length>0&&a.length===0,s=t.length===0&&e.classification===`one-sided`&&!r;return(0,R.jsxs)(`div`,{className:pk.cell,style:{"--cell-color":Xn(n)},"aria-label":`Leader ${n===0?`A`:`B`} events for this turn`,children:[(0,R.jsx)(`span`,{className:pk.cellBand,"aria-hidden":`true`}),t.length===0?s?(0,R.jsxs)(`div`,{className:pk.cellPending,"aria-live":`polite`,title:`Parallel runs can drift turn-to-turn — events arrive whenever this side's LLM calls finish.`,children:[(0,R.jsx)(`span`,{className:`spinner ${pk.cellPendingSpinner}`,"aria-hidden":`true`}),`Catching up to turn `,e.turn,`…`]}):r?(0,R.jsx)(`div`,{className:pk.cellEmpty,title:i?`Run was interrupted before this side reached this turn.`:`No event recorded for this side on this turn.`,children:i?`Stopped before T${e.turn}`:`No event for T${e.turn}`}):(0,R.jsx)(`div`,{className:pk.cellEmpty,children:`(no events yet)`}):o?r?(0,R.jsx)(`div`,{className:pk.cellEmpty,title:i?`Run was interrupted while this turn was still processing.`:`No outcome recorded for this side on this turn.`,children:i?`Stopped during T${e.turn}`:`T${e.turn} ended without an outcome`}):(0,R.jsxs)(`div`,{className:pk.cellPending,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`spinner ${pk.cellPendingSpinner}`}),hk(t)]}):a.map(e=>(0,R.jsx)(ak,{event:e,actorIndex:n},e.id))]},n)})})]})}function _k(e,t,n){let r=e.filter(e=>e.turn===n),i=t.filter(e=>e.turn===n);if(r.length===0&&i.length===0)return null;let a=[...r].reverse().find(e=>e.type===`event_start`),o=[...i].reverse().find(e=>e.type===`event_start`),s=String(a?.data?.title??``),c=String(o?.data?.title??``),l=String(r.find(e=>e.type===`outcome`)?.data?.outcome??``),u=String(i.find(e=>e.type===`outcome`)?.data?.outcome??``);return r.length===0||i.length===0?{turn:n,classification:`one-sided`,titleA:s,titleB:c,outcomeA:l,outcomeB:u}:!l||!u?{turn:n,classification:`pending`,titleA:s,titleB:c,outcomeA:l,outcomeB:u}:s===c?l===u?{turn:n,classification:`same`,titleA:s,titleB:c,outcomeA:l,outcomeB:u}:{turn:n,classification:`different-outcome`,titleA:s,titleB:c,outcomeA:l,outcomeB:u}:{turn:n,classification:`different-event`,titleA:s,titleB:c,outcomeA:l,outcomeB:u}}function vk(e,t){let n=new Set;for(let t of e)typeof t.turn==`number`&&n.add(t.turn);for(let e of t)typeof e.turn==`number`&&n.add(e.turn);let r=[...n].sort((e,t)=>e-t),i=new Map;for(let n of r){let r=_k(e,t,n);r&&i.set(n,r)}return i}var yk={grid:`_grid_lwobn_1`,scroll:`_scroll_lwobn_10`,empty:`_empty_lwobn_16`};function bk({state:e}){let t=e.actorIds[0],n=e.actorIds[1],r=t?e.actors[t]:null,i=n?e.actors[n]:null,a=r?.events??[],o=i?.events??[],s=(0,L.useMemo)(()=>vk(a,o),[a,o]),c=(0,L.useMemo)(()=>[...s.keys()],[s]),l=(0,L.useMemo)(()=>xk(a),[a]),u=(0,L.useMemo)(()=>xk(o),[o]),d=(0,L.useRef)(null),f=(0,L.useRef)(!0);return(0,L.useEffect)(()=>{if(!f.current)return;let e=d.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`})},[a.length,o.length]),(0,R.jsx)(`div`,{className:`sim-columns ${yk.grid}`,children:(0,R.jsx)(`div`,{ref:d,onScroll:()=>{let e=d.current;e&&(f.current=e.scrollHeight-e.scrollTop-e.clientHeight<60)},className:yk.scroll,children:c.length===0?(0,R.jsx)(`div`,{className:yk.empty,children:`No turns yet — events will appear as the run progresses.`}):c.map(t=>{let n=s.get(t);return(0,R.jsx)(gk,{entry:n,eventsA:l.get(t)??[],eventsB:u.get(t)??[],runTerminal:e.isComplete||e.isAborted,runAborted:e.isAborted},t)})})})}function xk(e){let t=new Map;for(let n of e){if(typeof n.turn!=`number`)continue;let e=t.get(n.turn)??[];e.push(n),t.set(n.turn,e)}return t}var Sk={row:`_row_1fazu_1`,header:`_header_1fazu_9`,headerTurn:`_headerTurn_1fazu_22`,headerTitle:`_headerTitle_1fazu_28`,headerTitleSplit:`_headerTitleSplit_1fazu_37`,headerTitlePerActor:`_headerTitlePerActor_1fazu_45`,cells:`_cells_1fazu_53`,cell:`_cell_1fazu_53`,cellBand:`_cellBand_1fazu_69`,cellEmpty:`_cellEmpty_1fazu_79`,cellPending:`_cellPending_1fazu_87`,cellPendingSpinner:`_cellPendingSpinner_1fazu_97`},Ck=new Set([`turn_start`,`specialist_start`,`decision_pending`]);function wk(e){let t=new Set,n=!1;for(let r of e)if(r.type===`specialist_start`){let e=r.data?.department;typeof e==`string`&&e.length>0&&t.add(e)}else r.type===`decision_pending`&&(n=!0);let r=[];return t.size>0&&r.push(`${[...t].join(`, `)} analyzing`),n&&r.push(`awaiting decision`),r.length>0?r.join(` · `)+`…`:`Working on this turn…`}function Tk(e){for(let t of e)if(t.type===`event`||t.type===`turn_done`){let e=t.data?.title;if(typeof e==`string`&&e.length>0)return e}return``}function Ek({turn:e,actorIds:t,eventsByActor:n,runTerminal:r,runAborted:i}){let a=n.map(Tk),o=a.filter(e=>e.length>0),s=o.length>0&&o.every(e=>e===o[0])?o[0]:``;return(0,R.jsxs)(`section`,{id:`turn-row-${e}`,className:Sk.row,"aria-labelledby":`turn-row-${e}-h`,children:[(0,R.jsxs)(`h3`,{id:`turn-row-${e}-h`,className:Sk.header,tabIndex:-1,children:[(0,R.jsxs)(`span`,{className:Sk.headerTurn,children:[`T`,e]}),s?(0,R.jsx)(`span`,{className:Sk.headerTitle,children:s}):(0,R.jsx)(`span`,{className:Sk.headerTitleSplit,children:a.map((e,n)=>(0,R.jsx)(`span`,{className:Sk.headerTitlePerActor,style:{"--cell-color":Xn(n)},children:e||`—`},t[n]))})]}),(0,R.jsx)(`div`,{className:Sk.cells,children:t.map((t,a)=>{let o=n[a]??[],s=o.filter(e=>!Ck.has(e.type)),c=o.length>0&&s.length===0;return(0,R.jsxs)(`div`,{className:Sk.cell,style:{"--cell-color":Xn(a)},"aria-label":`Events for actor ${a+1} on turn ${e}`,children:[(0,R.jsx)(`span`,{className:Sk.cellBand,"aria-hidden":`true`}),o.length===0?r?(0,R.jsx)(`div`,{className:Sk.cellEmpty,title:i?`Run was interrupted before this actor reached this turn.`:`No event recorded for this actor on this turn.`,children:i?`Stopped before T${e}`:`No event for T${e}`}):(0,R.jsxs)(`div`,{className:Sk.cellPending,"aria-live":`polite`,title:`Parallel runs can drift turn-to-turn — events arrive whenever this actor's LLM calls finish.`,children:[(0,R.jsx)(`span`,{className:`spinner ${Sk.cellPendingSpinner}`,"aria-hidden":`true`}),`Catching up to turn `,e,`…`]}):c?r?(0,R.jsx)(`div`,{className:Sk.cellEmpty,title:i?`Run was interrupted while this turn was still processing.`:`No outcome recorded for this actor on this turn.`,children:i?`Stopped during T${e}`:`T${e} ended without an outcome`}):(0,R.jsxs)(`div`,{className:Sk.cellPending,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`spinner ${Sk.cellPendingSpinner}`}),wk(o)]}):s.map(e=>(0,R.jsx)(ak,{event:e,actorIndex:a%2,actorSlot:a},e.id))]},t)})})]})}var Dk={grid:`_grid_1773u_1`,scrollX:`_scrollX_1773u_10`,stickyHeader:`_stickyHeader_1773u_20`,headerCell:`_headerCell_1773u_32`,scrollY:`_scrollY_1773u_37`,empty:`_empty_1773u_45`},Ok=360;function kk({state:e}){let t=e.actorIds,n=(0,L.useMemo)(()=>t.map(t=>Ak(e.actors[t]?.events??[])),[t,e.actors]),r=(0,L.useMemo)(()=>{let e=new Set;for(let t of n)for(let n of t.keys())e.add(n);return[...e].sort((e,t)=>e-t)},[n]),i=(0,L.useRef)(null),a=(0,L.useRef)(!0),o=()=>{let e=i.current;e&&(a.current=e.scrollHeight-e.scrollTop-e.clientHeight<60)},s=(0,L.useMemo)(()=>t.map(t=>e.actors[t]?.events.length??0).join(`,`),[t,e.actors]);(0,L.useEffect)(()=>{if(!a.current)return;let e=i.current;e&&e.scrollTo({top:e.scrollHeight,behavior:`smooth`})},[s]);let c={"--cell-min-width":`${Ok}px`,"--cell-count":String(t.length)};return(0,R.jsx)(`div`,{className:Dk.grid,style:c,children:(0,R.jsxs)(`div`,{className:Dk.scrollX,children:[(0,R.jsx)(`header`,{className:Dk.stickyHeader,children:t.map((t,n)=>{let r=e.actors[t];return(0,R.jsx)(`div`,{className:Dk.headerCell,children:(0,R.jsx)(MO,{compact:!0,actorIndex:n,leader:r?.leader??null,nameFallback:t,popHistory:r?.popHistory??[],moraleHistory:r?.moraleHistory??[],event:r?.event,pendingDecision:r?.pendingDecision})},t)})}),(0,R.jsx)(`div`,{ref:i,onScroll:o,className:Dk.scrollY,children:r.length===0?(0,R.jsx)(`div`,{className:Dk.empty,children:`No turns yet — events will appear as the run progresses.`}):r.map(r=>(0,R.jsx)(Ek,{turn:r,actorIds:t,eventsByActor:n.map(e=>e.get(r)??[]),runTerminal:e.isComplete||e.isAborted,runAborted:e.isAborted},r))})]})})}function Ak(e){let t=new Map;for(let n of e){if(typeof n.turn!=`number`)continue;let e=t.get(n.turn)??[];e.push(n),t.set(n.turn,e)}return t}var jk={track:`_track_aueni_1`,trackInner:`_trackInner_aueni_29`,column:`_column_aueni_38`,columnHeader:`_columnHeader_aueni_64`,columnHeaderSlot:`_columnHeaderSlot_aueni_80`,columnHeaderText:`_columnHeaderText_aueni_89`,columnHeaderName:`_columnHeaderName_aueni_96`,columnHeaderArchetype:`_columnHeaderArchetype_aueni_105`,columnHeaderPop:`_columnHeaderPop_aueni_116`,columnBody:`_columnBody_aueni_125`,columnPlaceholder:`_columnPlaceholder_aueni_133`,columnPlaceholderShimmer:`_columnPlaceholderShimmer_aueni_145`,"cohort-shimmer":`_cohort-shimmer_aueni_1`,columnPlaceholderLabel:`_columnPlaceholderLabel_aueni_159`};function Mk(e){let t=[],n=[],r=new Map;for(let i of e){if(i.type===`forge_attempt`){let e=i.data||{},n=e.approved===!0||e.approved===`true`;t.push({turn:Number(e.turn??0),eventIndex:Number(e.eventIndex??0),department:String(e.department||``),name:String(e.name||``),approved:n,confidence:typeof e.confidence==`number`?e.confidence:void 0}),e.name&&e.department&&n&&!r.has(String(e.name))&&r.set(String(e.name),String(e.department));continue}if(i.type!==`specialist_done`)continue;let e=i.data||{},a=String(e.department||``),o=Array.isArray(e.forgedTools)?e.forgedTools:[];for(let t of o){let o=t,s=String(o.name||``);if(!s||s===`unnamed`)continue;let c=typeof o.firstForgedDepartment==`string`?String(o.firstForgedDepartment):r.get(s),l=typeof o.firstForgedTurn==`number`?o.firstForgedTurn:void 0,u=Number(i.turn??e.turn??0);(c&&l!==void 0&&l<u||c&&c!==a)&&n.push({turn:u,originDept:c,callingDept:a,name:s})}}return{attempts:t,reuses:n}}function Nk(e){let{vizPanel:t,actorIndex:n,actorId:r,state:i,snaps:a,currentTurn:o,gridMode:s,palette:c,gridSettings:l,hexacoById:u,searchQuery:d,chronicleFilter:f,chronicleHover:p,startTime:m,onOpenChat:h}=e,g=(0,L.useRef)(null),[_,v]=(0,L.useState)(n<4);(0,L.useEffect)(()=>{if(_)return;let e=g.current;if(!e)return;if(typeof IntersectionObserver>`u`){v(!0);return}let t=new IntersectionObserver(e=>{for(let n of e)if(n.isIntersecting){v(!0),t.disconnect();return}},{rootMargin:`240px 360px`});return t.observe(e),()=>t.disconnect()},[_]);let y=i.actors[r]??null,b=y?.leader??null,x=a[o],S=o>0?a[o-1]:void 0,C=Xn(n),w=b?.name||`Leader ${n+1}`,T=(0,L.useMemo)(()=>y?Mk(y.events):{attempts:[],reuses:[]},[y]),E=b?.hexaco?{O:b.hexaco.O??b.hexaco.openness??.5,C:b.hexaco.C??b.hexaco.conscientiousness??.5,E:b.hexaco.E??b.hexaco.extraversion??.5,A:b.hexaco.A??b.hexaco.agreeableness??.5,Em:b.hexaco.Em??b.hexaco.emotionality??.5,HH:b.hexaco.HH??b.hexaco.honestyHumility??.5}:void 0;return(0,R.jsxs)(`div`,{ref:g,className:jk.column,style:{"--actor-color":C},"aria-label":`Living swarm grid for actor ${n+1}: ${w}`,children:[(0,R.jsxs)(`header`,{className:jk.columnHeader,children:[(0,R.jsxs)(`span`,{className:jk.columnHeaderSlot,children:[`A`,n+1]}),(0,R.jsxs)(`div`,{className:jk.columnHeaderText,children:[(0,R.jsx)(`span`,{className:jk.columnHeaderName,children:w}),b?.archetype&&(0,R.jsx)(`span`,{className:jk.columnHeaderArchetype,children:b.archetype})]}),(0,R.jsxs)(`span`,{className:jk.columnHeaderPop,title:`Population alive · morale`,children:[x?.population??`—`,` · `,x?Math.round(x.morale*100):`—`,`%`]})]}),(0,R.jsx)(`div`,{className:jk.columnBody,children:_?(0,R.jsx)(AS,{vizPanel:t,snapshot:x,previousSnapshot:S,snapshotHistory:a,actorName:w,actorArchetype:b?.archetype??``,leaderUnit:b?.unit??``,sideColor:C,side:`a`,mode:s,hexacoById:u,leaderHexaco:E,forgeAttempts:T.attempts,reuseCalls:T.reuses,searchQuery:d,palette:c,settings:l,startTime:m,onOpenChat:h,eventFilter:f,chronicleHover:p}):(0,R.jsxs)(`div`,{className:jk.columnPlaceholder,"aria-hidden":`true`,children:[(0,R.jsx)(`div`,{className:jk.columnPlaceholderShimmer}),(0,R.jsx)(`span`,{className:jk.columnPlaceholderLabel,children:`Loading swarm…`})]})})]})}function Pk({state:e,snapshotMap:t,currentTurn:n,gridMode:r,palette:i,gridSettings:a,hexacoById:o,searchQuery:s,chronicleFilter:c,chronicleHover:l,startTime:u,onOpenChat:d,className:f,vizPanel:p=!1}){let m=e.actorIds;return(0,R.jsx)(`div`,{className:[jk.track,f].filter(Boolean).join(` `),role:`region`,"aria-label":`Cohort swarm grid: ${m.length} actors`,children:(0,R.jsx)(`div`,{className:jk.trackInner,children:m.map((f,m)=>(0,R.jsx)(Nk,{vizPanel:p,actorId:f,actorIndex:m,state:e,snaps:t[f]??[],currentTurn:n,gridMode:r,palette:i,gridSettings:a,hexacoById:o,searchQuery:s,chronicleFilter:c,chronicleHover:l,startTime:u,onOpenChat:d},f))})})}function Fk(e){return(0,L.useMemo)(()=>Ik(e),[e])}function Ik(e){let t={};for(let n of e.actorIds){let r=e.actors[n];if(!r)continue;t[n]=[];let i=new Map;for(let e of r.events)if((e.type===`event_start`||e.type===`turn_start`)&&e.turn!=null){let t=e.data?.category;if(typeof t==`string`&&t.length>0){let n=i.get(e.turn)??[];n.includes(t)||n.push(t),i.set(e.turn,n)}}let a=r.events.filter(e=>e.type===`systems_snapshot`);for(let e=0;e<r.agentSnapshots.length;e++){let o=r.agentSnapshots[e],s=a[e]?.data||{},c=s.turn||e+1,l=r.events.find(e=>e.type===`turn_done`&&e.data?.turn===c)?.data?.metrics??{},u=e=>typeof e==`number`&&Number.isFinite(e)?e:void 0,d=o.map(e=>({agentId:e.agentId,name:e.name,department:e.department,role:e.role,rank:e.rank,alive:e.alive,marsborn:e.marsborn,psychScore:e.psychScore,age:e.age,generation:e.generation,partnerId:e.partnerId,childrenIds:e.childrenIds||[],featured:e.featured,mood:e.mood,shortTermMemory:e.shortTermMemory||[]}));t[n].push({turn:c,time:s.time||0,cells:d,population:s.population||d.filter(e=>e.alive).length,morale:s.morale||0,foodReserve:typeof s.foodReserve==`number`?s.foodReserve:u(l.foodMonthsReserve),waterLitersPerDay:u(l.waterLitersPerDay),powerKw:u(l.powerKw),pressurizedVolumeM3:u(l.pressurizedVolumeM3),deaths:s.deaths||0,births:s.births||0,eventCategories:i.get(c)??[]})}}return t}function Lk(e,t){let n=Math.max(0,...e.map(e=>t[e]?.length??0)),r={};for(let i of e){let e=t[i]??[];r[i]=e.length===0||e.length===n?e:[...Array.from({length:n-e.length},()=>e[0]),...e]}return{aligned:r,newest:Math.max(0,n-1)}}function Rk(e){return e&&e.length>0?e[e.length-1].turn:0}var zk={pair:`_pair_vw4gs_1`,panel:`_panel_vw4gs_21`,track:`_track_vw4gs_38`},Bk=[{side:`a`,color:`var(--vis)`},{side:`b`,color:`var(--eng)`}];function Vk(e){let t=e?.hexaco;if(t)return{O:t.O??t.openness??.5,C:t.C??t.conscientiousness??.5,E:t.E??t.extraversion??.5,A:t.A??t.agreeableness??.5,Em:t.Em??t.emotionality??.5,HH:t.HH??t.honestyHumility??.5}}function Hk({state:e}){let t=fF(),n=Fk(e),{actorIds:r}=e,i=(0,L.useMemo)(()=>Lk(r,n),[r,n]),a=t.setup?.defaultStartTime;if(!r.some(e=>(n[e]?.length??0)>0))return null;if(r.length>=3)return(0,R.jsx)(`div`,{className:zk.track,"data-testid":`watch-grid-track`,children:(0,R.jsx)(Pk,{state:e,snapshotMap:i.aligned,currentTurn:i.newest,gridMode:`living`,palette:0,gridSettings:dS,searchQuery:``,chronicleFilter:`all`,chronicleHover:null,startTime:a})});let o=[0,1].map(e=>Rk(n[r[e]]));return(0,R.jsx)(`div`,{className:zk.pair,"data-testid":`watch-grid`,children:Bk.map(({side:t,color:i},s)=>{let c=r[s];if(!c)return null;let l=n[c]??[],u=e.actors[c]?.leader??null,d=o[1-s]-o[s];return(0,R.jsx)(`div`,{className:zk.panel,"data-testid":`watch-grid-panel`,"data-place":s+1,children:(0,R.jsx)(AS,{snapshot:l[l.length-1],previousSnapshot:l[l.length-2],snapshotHistory:l,actorName:u?.name??c,actorArchetype:u?.archetype??``,leaderUnit:u?.unit??``,sideColor:i,side:t,lagTurns:d>0?d:0,mode:`living`,leaderHexaco:Vk(u),startTime:a})},c)})})}var Uk={list:`_list_pe3ki_1`,item:`_item_pe3ki_10`,itemNumber:`_itemNumber_pe3ki_22`,itemLink:`_itemLink_pe3ki_29`,itemText:`_itemText_pe3ki_35`,itemMeta:`_itemMeta_pe3ki_39`,title:`_title_pe3ki_46`,wrap:`_wrap_pe3ki_56`,summary:`_summary_pe3ki_62`,filterBar:`_filterBar_pe3ki_73`,filterField:`_filterField_pe3ki_91`,filterLabel:`_filterLabel_pe3ki_105`,filterSelect:`_filterSelect_pe3ki_115`,filterStats:`_filterStats_pe3ki_142`,empty:`_empty_pe3ki_150`};function Wk(e){let t=[...e.departments].join(`, `),n=[...e.actorNames].join(` · `);return(0,R.jsxs)(`li`,{id:`cite-${e.n}`,className:Uk.item,children:[(0,R.jsxs)(`span`,{className:Uk.itemNumber,children:[`[`,e.n,`]`]}),(0,R.jsxs)(`span`,{children:[e.url?(0,R.jsx)(`a`,{href:e.url,target:`_blank`,rel:`noopener noreferrer`,className:Uk.itemLink,children:e.text}):(0,R.jsx)(`span`,{className:Uk.itemText,children:e.text}),(0,R.jsxs)(`div`,{className:Uk.itemMeta,children:[e.doi&&(0,R.jsxs)(R.Fragment,{children:[`DOI:`,e.doi,` · `]}),t&&(0,R.jsxs)(R.Fragment,{children:[`cited by `,t,` · `]}),(0,R.jsxs)(`span`,{title:`Which leader's run referenced this source`,children:[`leader `,n]})]})]})]},e.n)}function Gk(e,t,n){return!t&&!n?e:e.filter(e=>!(t&&!e.actorNames.has(t)||n&&!e.departments.has(n)))}function Kk(e){let t=new Set,n=new Set;for(let r of e){for(let e of r.actorNames)t.add(e);for(let e of r.departments)n.add(e)}return{actors:[...t].sort((e,t)=>e.localeCompare(t)),departments:[...n].sort((e,t)=>e.localeCompare(t))}}function qk({actors:e,departments:t,actorFilter:n,departmentFilter:r,onActorChange:i,onDepartmentChange:a,total:o,shown:s}){return e.length<2&&t.length<2?null:(0,R.jsxs)(`div`,{className:Uk.filterBar,role:`region`,"aria-label":`Filter references`,children:[e.length>1&&(0,R.jsxs)(`div`,{className:Uk.filterField,children:[(0,R.jsx)(`label`,{className:Uk.filterLabel,htmlFor:`references-actor-filter`,children:`Leader`}),(0,R.jsxs)(`select`,{id:`references-actor-filter`,className:Uk.filterSelect,value:n??``,onChange:e=>i(e.target.value||null),children:[(0,R.jsx)(`option`,{value:``,children:`All leaders`}),e.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),t.length>1&&(0,R.jsxs)(`div`,{className:Uk.filterField,children:[(0,R.jsx)(`label`,{className:Uk.filterLabel,htmlFor:`references-department-filter`,children:`Department`}),(0,R.jsxs)(`select`,{id:`references-department-filter`,className:Uk.filterSelect,value:r??``,onChange:e=>a(e.target.value||null),children:[(0,R.jsx)(`option`,{value:``,children:`All departments`}),t.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),(0,R.jsxs)(`span`,{className:Uk.filterStats,children:[`Showing `,s,` of `,o]})]})}function Jk({registry:e,title:t=`References`,collapsible:n=!1,defaultOpen:r=!1,onToggle:i}){let[a,o]=(0,L.useState)(null),[s,c]=(0,L.useState)(null),{actors:l,departments:u}=(0,L.useMemo)(()=>Kk(e.list),[e.list]),d=(0,L.useMemo)(()=>Gk(e.list,a,s),[e.list,a,s]);if((0,L.useEffect)(()=>{if(typeof window>`u`)return;let t=()=>{let t=window.location.hash.match(/^#cite-(\d+)$/);if(!t)return;let n=Number(t[1]);Number.isFinite(n)&&(d.some(e=>e.n===n)||e.list.some(e=>e.n===n)&&(o(null),c(null)))};return t(),window.addEventListener(`hashchange`,t),()=>window.removeEventListener(`hashchange`,t)},[d,e.list]),e.list.length===0)return null;let f=(0,R.jsx)(qk,{actors:l,departments:u,actorFilter:a,departmentFilter:s,onActorChange:o,onDepartmentChange:c,total:e.list.length,shown:d.length}),p=d.length>0?(0,R.jsx)(`ol`,{className:Uk.list,children:d.map(Wk)}):(0,R.jsx)(`div`,{className:Uk.empty,children:`No references match the current filters.`});return n?(0,R.jsxs)(`details`,{open:r,onToggle:i?e=>i(e.currentTarget.open):void 0,className:Uk.wrap,children:[(0,R.jsxs)(`summary`,{className:Uk.summary,children:[t,` · `,e.list.length]}),f,p]}):(0,R.jsxs)(`div`,{className:Uk.wrap,children:[(0,R.jsxs)(`h3`,{className:Uk.title,children:[t,` · `,e.list.length]}),f,p]})}function Yk({registry:e}){return e.list.length===0?null:(0,R.jsx)(`ol`,{className:Uk.list,children:e.list.map(Wk)})}var Xk={scroller:`_scroller_thxdg_1`,row:`_row_thxdg_8`,arrow:`_arrow_thxdg_40`},Zk=.8;function Qk({label:e,children:t,className:n,rowClassName:r,role:i,ariaLabel:a}){let o=(0,L.useRef)(null),s=(0,L.useRef)(null),c=(0,L.useRef)(null),l=(0,L.useRef)(null),[u,d]=(0,L.useState)({scrolls:!1,previous:!1,next:!1}),f=(0,L.useCallback)(()=>{let e=o.current,t=e?.parentElement;if(!e||!t)return;let n=getComputedStyle(e),r=getComputedStyle(t),i=t.clientWidth-parseFloat(r.paddingLeft)-parseFloat(r.paddingRight)-parseFloat(n.marginLeft)-parseFloat(n.marginRight),a=e.scrollWidth>i+1,u=e.scrollWidth-e.clientWidth,f=a&&e.scrollLeft>1,p=a&&e.scrollLeft<u-1,m=document.activeElement;m===c.current&&!c.current?.disabled&&!p&&f?l.current=`previous`:m===s.current&&!s.current?.disabled&&!f&&p&&(l.current=`next`),d(e=>e.scrolls===a&&e.previous===f&&e.next===p?e:{scrolls:a,previous:f,next:p})},[]);(0,L.useEffect)(()=>{let e=o.current;if(!e)return;f();let t=new ResizeObserver(f),n=()=>{t.disconnect(),t.observe(e),e.parentElement&&t.observe(e.parentElement);for(let n of Array.from(e.children))t.observe(n)};n();let r=new MutationObserver(()=>{n(),f()});return r.observe(e,{childList:!0,subtree:!0,characterData:!0}),e.addEventListener(`scroll`,f,{passive:!0}),()=>{t.disconnect(),r.disconnect(),e.removeEventListener(`scroll`,f)}},[f]),(0,L.useEffect)(()=>{let e=l.current;if(!e)return;l.current=null;let t=document.activeElement;t&&t!==document.body&&t!==s.current&&t!==c.current||(e===`previous`?c:s).current?.disabled===!0&&(e===`previous`?s:c).current?.focus()},[u]);let p=e=>{let t=o.current;if(!t)return;let n=t.scrollWidth-t.clientWidth,r=Math.max(0,Math.min(n,t.scrollLeft+e*t.clientWidth*Zk)),i=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;t.scrollTo({left:r,behavior:i?`auto`:`smooth`})},{scrolls:m}=u;return(0,R.jsxs)(`div`,{className:[Xk.scroller,n].filter(Boolean).join(` `),children:[m&&(0,R.jsx)(`button`,{ref:s,type:`button`,className:Xk.arrow,"aria-label":`Show previous ${e}`,title:`Show previous ${e}`,disabled:!u.previous,onClick:()=>p(-1),children:(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`‹`})}),(0,R.jsx)(`div`,{ref:o,role:i,"aria-label":a,className:[Xk.row,r].filter(Boolean).join(` `),"data-fade-start":u.previous?`true`:`false`,"data-fade-end":u.next?`true`:`false`,children:t}),m&&(0,R.jsx)(`button`,{ref:c,type:`button`,className:Xk.arrow,"aria-label":`Show next ${e}`,title:`Show next ${e}`,disabled:!u.next,onClick:()=>p(1),children:(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`›`})})]})}var $k={bar:`_bar_u6y4c_1`,label:`_label_u6y4c_13`,keys:`_keys_u6y4c_22`,keysRow:`_keysRow_u6y4c_26`,hint:`_hint_u6y4c_31`,cta:`_cta_u6y4c_71`,ctaCount:`_ctaCount_u6y4c_94`,exportBtn:`_exportBtn_u6y4c_103`,modalBackdrop:`_modalBackdrop_u6y4c_116`,modalDialog:`_modalDialog_u6y4c_127`,modalHeader:`_modalHeader_u6y4c_143`,modalTitle:`_modalTitle_u6y4c_152`,modalClose:`_modalClose_u6y4c_164`,modalBody:`_modalBody_u6y4c_174`};function eA({citationRegistry:e,toolRegistry:t,layoutToggle:n}){let[r,i]=(0,L.useState)(null),a=(0,L.useCallback)(()=>i(null),[]),{openToolbox:o}=Dw();(0,L.useEffect)(()=>{if(!r)return;let e=e=>{e.key===`Escape`&&a()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[r,a]);let s=e.list.length,c=t.list.length;return s===0&&c===0&&!n?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{role:`region`,"aria-label":`Simulation evidence`,className:$k.bar,children:[(0,R.jsxs)(Qk,{label:`evidence keys`,className:$k.keys,rowClassName:$k.keysRow,children:[(0,R.jsx)(`span`,{className:$k.label,children:`Evidence`}),s>0&&(0,R.jsx)(nA,{label:`References`,count:s,onClick:()=>i(`refs`),ariaLabel:`Open References list (${s} sources)`}),c>0&&(0,R.jsx)(nA,{label:`Forged Toolbox`,count:c,onClick:e=>o(e.currentTarget,`sim`),ariaLabel:`Open Forged Toolbox (${c} tools)`}),n]}),(0,R.jsx)(`span`,{className:$k.hint,children:`Click any inline [N] pill to jump to its source.`})]}),r===`refs`&&(0,R.jsx)(rA,{title:`References · ${s}`,onClose:a,extraActions:(0,R.jsx)(tA,{label:`EXPORT JSON`,filename:`paracosm-references.json`,data:e.list.map(e=>({n:e.n,text:e.text,url:e.url,doi:e.doi,departments:[...e.departments],actorNames:[...e.actorNames]}))}),children:(0,R.jsx)(Yk,{registry:e})})]})}function tA({label:e,filename:t,data:n}){return(0,R.jsx)(`button`,{onClick:()=>rr(JSON.stringify(n,null,2),t),className:$k.exportBtn,children:e})}function nA({label:e,count:t,onClick:n,ariaLabel:r}){return(0,R.jsxs)(`button`,{onClick:n,"aria-label":r,className:$k.cta,children:[(0,R.jsx)(`span`,{children:e.toUpperCase()}),(0,R.jsx)(`span`,{className:$k.ctaCount,children:t})]})}function rA({title:e,onClose:t,children:n,extraActions:r}){return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":e,onClick:t,className:$k.modalBackdrop,children:(0,R.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:$k.modalDialog,children:[(0,R.jsxs)(`div`,{className:$k.modalHeader,children:[(0,R.jsx)(`h2`,{className:$k.modalTitle,children:e}),r,(0,R.jsx)(`button`,{onClick:t,"aria-label":`Close`,className:$k.modalClose,children:`×`})]}),(0,R.jsx)(`div`,{className:$k.modalBody,children:n})]})})}var iA={panel:`_panel_nvkty_1`,label:`_label_nvkty_13`,copy:`_copy_nvkty_23`,button:`_button_nvkty_30`};function aA({enabled:e=!0}){let[t,n]=(0,L.useState)(!1),r=fF(),i=mF(),a=bF(),o=(0,L.useCallback)(async()=>{if(!t&&i){n(!0);try{let e=g(window.localStorage);if(!e||!_(e,r.id)){alert(`No previous launch config found for ${r.labels.name}. Run once from Settings first.`);return}let t=k(e,E()),n=await fetch(`/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...t,captureSnapshots:!0})}),i=await n.json().catch(()=>({}));if(n.status===429){alert(i.error||`Rate limit hit. Add an API key in Settings to bypass.`);return}if(!n.ok){alert(i.error||`Re-run failed: server responded with HTTP ${n.status}.`);return}if(i.redirect){le(window,i.visitorId),a(),v(window.localStorage,t);let e=Array.isArray(t.actors)?t.actors:null;e&&e.length>0&&y(window.localStorage,e,typeof t.scenarioId==`string`?t.scenarioId:void 0),pe(i.runKey),window.location.href=N_(window.location.href,i.redirect)}else alert(`Re-run failed: server did not return a redirect. Check the server logs.`)}catch(e){alert(`Re-run failed: ${e}`)}finally{n(!1)}}},[t,i,r.id,r.labels.name,a]);return e?(0,R.jsxs)(`div`,{className:iA.panel,children:[(0,R.jsx)(`span`,{className:iA.label,children:`Re-run`}),(0,R.jsx)(`span`,{className:iA.copy,children:`Spin up a new run with the same leaders + scenario, seed bumped by one.`}),(0,R.jsx)(`button`,{type:`button`,className:iA.button,onClick:o,disabled:t||!i,children:t?`Launching…`:i?`Run again with seed+1 ›`:`Loading scenario…`})]}):null}var oA={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 sA({hideWhenUnavailable:e=!0}={}){let{sessions:t,status:n,refresh:r}=Wn(),i=(0,L.useRef)(null),a=(0,L.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=[oA.card,c?oA.empty:``].filter(Boolean).join(` `),u=[oA.kicker,c?oA.empty:``].filter(Boolean).join(` `),d=[oA.lead,c?oA.empty:``].filter(Boolean).join(` `);return(0,R.jsxs)(`div`,{ref:i,className:l,children:[(0,R.jsxs)(`div`,{className:oA.headerRow,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:u,children:[`▶ `,c?`Replay from cache`:`Watch a prior run`]}),c?(0,R.jsxs)(`div`,{className:d,children:[`No saved runs yet.`,` `,(0,R.jsxs)(`span`,{className:oA.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,R.jsxs)(`div`,{className:d,children:[`Don`,`'`,`t want to spend credits?`,` `,(0,R.jsxs)(`span`,{className:oA.leadMuted,children:[`Replay any of `,(0,R.jsx)(`strong`,{className:oA.leadCount,children:t.length}),` `,`cached simulation`,t.length===1?``:`s`,` turn-by-turn, complete with every decision, tool forge, and divergence.`]})]})]}),(0,R.jsx)(`button`,{type:`button`,onClick:r,"aria-label":`Refresh prior runs list`,title:`Refresh list`,className:oA.refreshBtn,children:`↻ Refresh`})]}),!c&&(0,R.jsx)(`div`,{className:oA.grid,children:a.map(e=>(0,R.jsxs)(`button`,{type:`button`,onClick:()=>o(e.id),"aria-label":`Replay ${e.title||e.scenarioName||e.scenarioId||e.id}`,className:oA.tile,children:[(0,R.jsx)(`span`,{className:oA.tileTitle,children:e.title||e.scenarioName||e.scenarioId||`Simulation`}),(0,R.jsxs)(`span`,{className:oA.tileMeta,children:[e.title&&e.scenarioName?`${e.scenarioName} · `:``,typeof e.turnCount==`number`?`${e.turnCount} turns · `:``,ia(e)?`${ia(e)} · `:``,s(e.createdAt)]}),typeof e.totalCostUSD==`number`&&e.totalCostUSD>0&&(0,R.jsxs)(`span`,{className:oA.tileCost,children:[`$`,e.totalCostUSD.toFixed(2)]}),(0,R.jsx)(`span`,{className:oA.tileCta,children:`Replay →`})]},e.id))}),!c&&t.length>3&&(0,R.jsxs)(`div`,{className:oA.moreNote,children:[`+ `,t.length-3,` more — use the `,(0,R.jsx)(`strong`,{children:`LOAD`}),` button in the top bar to browse the full list.`]})]})}var cA={padding:`4px 10px`,fontSize:`var(--font-xs)`,fontFamily:`var(--mono)`,fontWeight:600,background:`transparent`,color:`var(--text-3)`,border:`1px solid var(--border)`,cursor:`pointer`,textTransform:`uppercase`,letterSpacing:`0.04em`},lA={...cA,color:`var(--amber)`,background:`var(--bg-card)`,borderColor:`var(--amber)`};function uA({layout:e,actorCount:t,onChange:n}){return(0,R.jsxs)(`div`,{role:`group`,"aria-label":`Sim layout`,style:{display:`inline-flex`,gap:0},children:[(0,R.jsx)(`button`,{type:`button`,"data-layout":`side-by-side`,"aria-pressed":e===`side-by-side`,onClick:()=>n(`side-by-side`),style:{...e===`side-by-side`?lA:cA,borderRadius:`3px 0 0 3px`},title:`Side-by-side: per-actor columns with horizontal scroll for 3+`,children:`Side-by-side`}),(0,R.jsx)(`button`,{type:`button`,"data-layout":`constellation`,"aria-pressed":e===`constellation`,onClick:()=>n(`constellation`),style:{...e===`constellation`?lA:cA,borderRadius:`0 3px 3px 0`,borderLeft:`none`},title:`Constellation: radial cohort layout`,children:`Constellation`})]})}var dA={wrap:`_wrap_1k1fu_1`,svg:`_svg_1k1fu_11`,empty:`_empty_1k1fu_17`,edge:`_edge_1k1fu_25`,node:`_node_1k1fu_29`,label:`_label_1k1fu_42`,statLine:`_statLine_1k1fu_55`,statBadge:`_statBadge_1k1fu_62`,outcomeGlyph:`_outcomeGlyph_1k1fu_69`,outcomeSuccess:`_outcomeSuccess_1k1fu_76`,outcomeFailure:`_outcomeFailure_1k1fu_80`,outcomePending:`_outcomePending_1k1fu_84`,statBadgeMortality:`_statBadgeMortality_1k1fu_88`,edgeLabel:`_edgeLabel_1k1fu_93`,centerChip:`_centerChip_1k1fu_100`,centerChipTurn:`_centerChipTurn_1k1fu_104`,centerChipScenario:`_centerChipScenario_1k1fu_112`},fA=[`openness`,`conscientiousness`,`extraversion`,`agreeableness`,`emotionality`,`honestyHumility`];function pA(e){if(e.length<2)return{pairs:[],hasSpread:!1,hasAnyData:!1};let t=e.some(e=>Object.keys(e.hexaco??{}).length>0),n=[];for(let t=0;t<e.length;t+=1)for(let r=t+1;r<e.length;r+=1){let i=e[t],a=e[r],o=0;for(let e of fA){let t=(typeof i.hexaco?.[e]==`number`?i.hexaco[e]:.5)-(typeof a.hexaco?.[e]==`number`?a.hexaco[e]:.5);o+=t*t}n.push({a:i.name,b:a.name,distance:Math.sqrt(o),normalized:0})}let r=n.reduce((e,t)=>Math.max(e,t.distance),0);for(let e of n)e.normalized=r>0?e.distance/r:0;return{pairs:n,hasSpread:r>0,hasAnyData:t}}function mA(e,t){let n=e.actors[t];if(!n)return{pop:null,morale:null,decisions:0,tools:0,deaths:0,latestOutcome:`pending`};let r=`pending`;for(let e=n.events.length-1;e>=0;e--){let t=n.events[e];if(t.type!==`outcome`)continue;let i=String(t.data?.outcome??``);i.includes(`success`)?r=`success`:i.includes(`failure`)&&(r=`failure`);break}return{pop:n.popHistory.length>0?n.popHistory[n.popHistory.length-1]:null,morale:n.moraleHistory.length>0?n.moraleHistory[n.moraleHistory.length-1]:null,decisions:n.decisions??0,tools:n.tools??0,deaths:n.deaths??0,latestOutcome:r}}var hA=`Unknown`;function gA(e){return e?e.trim():``}function _A(e){let t=new Map;return e.actorIds.forEach((n,r)=>{let i=e.actors[n],a=gA(i?.leader?.archetype),o=a||`__unknown__`,s=a||hA,c=t.get(o);c?c.ids.push(n):t.set(o,{archetype:a,label:s,ids:[n],firstIndex:r})}),[...t.values()].sort((e,t)=>e.firstIndex-t.firstIndex)}var vA={legend:`_legend_1h9pr_1`,heading:`_heading_1h9pr_14`,pills:`_pills_1h9pr_24`,pill:`_pill_1h9pr_24`,pillFocused:`_pillFocused_1h9pr_56`,pillDimmed:`_pillDimmed_1h9pr_62`,pillCount:`_pillCount_1h9pr_66`,pillLabel:`_pillLabel_1h9pr_76`};function yA({cohorts:e,focusedArchetype:t,onFocusChange:n}){let r=e.reduce((e,t)=>e+t.ids.length,0);if(e.length<2||r<3)return null;let i=e=>{n&&n(t===e?null:e)};return(0,R.jsxs)(`div`,{className:vA.legend,role:`group`,"aria-label":`Cohort summary: ${e.length} archetypes across ${r} actors`,children:[(0,R.jsx)(`span`,{className:vA.heading,children:`COHORTS`}),(0,R.jsx)(`div`,{className:vA.pills,children:e.map(e=>{let r=t===e.archetype&&e.archetype!==``,a=t&&t!==e.archetype,o=`${vA.pill} ${r?vA.pillFocused:``} ${a?vA.pillDimmed:``}`;return(0,R.jsxs)(`button`,{type:`button`,className:o,onClick:()=>i(e.archetype),disabled:!n,"aria-pressed":r,"aria-label":`${e.label} cohort, ${e.ids.length} actor${e.ids.length===1?``:`s`}`,children:[(0,R.jsx)(`span`,{className:vA.pillCount,children:e.ids.length}),(0,R.jsx)(`span`,{className:vA.pillLabel,children:e.label})]},e.archetype||`__unknown__`)})})]})}var bA=18,xA=80,SA=9;function CA(e){if(e===0)return[];let t=Math.min(460,Math.max(120,60+12*e)),n=t+xA,r=[];for(let i=0;i<e;i+=1){let a=i/Math.max(1,e)*2*Math.PI-Math.PI/2;r.push({cx:n+t*Math.cos(a),cy:n+t*Math.sin(a),angle:a})}return r}function wA(e){return e===0?0:(Math.min(460,Math.max(120,60+12*e))+xA)*2}function TA({state:e,onActorClick:t}){let n=e.actorIds,r=L.useMemo(()=>CA(n.length),[n.length]),i=L.useMemo(()=>n.map(t=>({name:t,hexaco:e.actors[t]?.leader?.hexaco??{}})),[n,e.actors]),a=i.map(e=>`${e.name}:${Object.values(e.hexaco).join(`,`)}`).join(`|`),o=L.useMemo(()=>pA(i),[a]),s=L.useMemo(()=>{let e=new Map;for(let t of o.pairs)e.set(`${t.a}|${t.b}`,t.normalized),e.set(`${t.b}|${t.a}`,t.normalized);return e},[o]),c=fF(),l=L.useMemo(()=>n.map(t=>mA(e,t)),[n,e]),u=(0,L.useMemo)(()=>_A(e),[e]),[d,f]=(0,L.useState)(null),p=(0,L.useMemo)(()=>{let e=new Map;for(let t of u)for(let n of t.ids)e.set(n,t.archetype);return e},[u]),m=e=>d===null||p.get(e)===d;if(n.length===0)return(0,R.jsx)(`div`,{className:dA.empty,children:`Constellation will appear when actors are launched.`});let h=wA(n.length);return(0,R.jsxs)(`div`,{className:dA.wrap,children:[(0,R.jsx)(yA,{cohorts:u,focusedArchetype:d,onFocusChange:f}),(0,R.jsxs)(`svg`,{className:dA.svg,viewBox:`0 0 ${h} ${h}`,width:h,height:h,role:`img`,"aria-label":`Constellation of ${n.length} actors`,children:[n.map((e,t)=>n.slice(t+1).map(i=>{let a=r[t],c=r[n.indexOf(i)];if(!a||!c)return null;let l=s.get(`${e}|${i}`)??0,u=m(e)&&m(i),f=d===null||u?1:.12,p=Math.max(.06,Math.min(.95,1-l))*f,h=o.hasSpread&&n.length<SA&&(d===null||u),g=(a.cx+c.cx)/2,_=(a.cy+c.cy)/2;return(0,R.jsxs)(L.Fragment,{children:[(0,R.jsx)(`line`,{"data-edge":`${e}|${i}`,className:dA.edge,x1:a.cx,y1:a.cy,x2:c.cx,y2:c.cy,strokeOpacity:p,strokeWidth:1.5}),h&&(0,R.jsx)(`text`,{className:dA.edgeLabel,x:g,y:_,textAnchor:`middle`,dominantBaseline:`middle`,"aria-hidden":`true`,children:l.toFixed(2)})]},`${e}|${i}`)})),n.map((n,i)=>{let a=r[i];if(!a)return null;let o=Xn(i),s=e.actors[n]?.leader?.archetype??``,c=a.cx+Math.cos(a.angle)*32,u=a.cy+Math.sin(a.angle)*32,f=a.angle>-Math.PI/2&&a.angle<Math.PI/2?`start`:`end`,p=d!==null&&!m(n)?.25:1;return(0,R.jsxs)(`g`,{opacity:p,children:[(0,R.jsx)(`circle`,{"data-actor":n,className:dA.node,cx:a.cx,cy:a.cy,r:bA,fill:o,onClick:()=>t(n),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),t(n))},tabIndex:0,role:`button`,"aria-label":`Open report for ${n}`,children:(0,R.jsx)(`title`,{children:`${n}${s?` · ${s}`:``}`})}),(0,R.jsx)(`text`,{className:dA.label,x:c,y:u,textAnchor:f,dominantBaseline:`middle`,children:n}),(()=>{let e=l[i];if(!e)return null;let t=e.pop!==null&&e.morale!==null?`POP ${Math.round(e.pop)} · MORALE ${Math.round(e.morale)}%`:``,n=e.latestOutcome===`success`?`✓`:e.latestOutcome===`failure`?`⚠`:`…`,r=e.latestOutcome===`success`?dA.outcomeSuccess:e.latestOutcome===`failure`?dA.outcomeFailure:dA.outcomePending,a=e.deaths>=5;return(0,R.jsxs)(R.Fragment,{children:[t&&(0,R.jsx)(`text`,{className:dA.statLine,x:c,y:u+14,textAnchor:f,dominantBaseline:`middle`,children:t}),(0,R.jsxs)(`text`,{className:dA.statBadge,x:c,y:u+28,textAnchor:f,dominantBaseline:`middle`,children:[`D${e.decisions} · F${e.tools} `,(0,R.jsx)(`tspan`,{className:`${dA.outcomeGlyph} ${r}`,children:n}),a&&(0,R.jsx)(`tspan`,{className:dA.statBadgeMortality,children:` · ${e.deaths}†`})]})]})})()]},n)}),(()=>{let t=h/2,r=h/2,i=c.labels.actorNounPlural??`actors`;return(0,R.jsxs)(`g`,{className:dA.centerChip,role:`presentation`,children:[(0,R.jsxs)(`text`,{className:dA.centerChipTurn,x:t,y:r-6,textAnchor:`middle`,dominantBaseline:`middle`,children:[`T`,e.turn,`/`,e.maxTurns]}),(0,R.jsxs)(`text`,{className:dA.centerChipScenario,x:t,y:r+10,textAnchor:`middle`,dominantBaseline:`middle`,children:[c.labels.shortName,` · `,n.length,` `,i]})]})})()]})]})}function EA(e){return e.length>0?e[e.length-1]:0}function DA(e,t){return{id:e,name:t.leader?.name??e,archetype:t.leader?.archetype??``,population:EA(t.popHistory),morale:EA(t.moraleHistory),deaths:t.deaths,tools:t.toolNames?.size??t.tools??0,turn:t.popHistory.length,pending:!!t.pendingDecision}}function OA(e){return e.actorIds.map(t=>{let n=e.actors[t];return n?DA(t,n):null}).filter(e=>e!==null)}function kA(e){switch(e){case`name`:case`archetype`:return`asc`;case`deaths`:return`asc`;case`population`:case`morale`:case`tools`:case`turn`:return`desc`}}function AA(e,t,n,r){let i=r===`asc`?1:-1,a;switch(n){case`name`:a=e.name.localeCompare(t.name);break;case`archetype`:a=e.archetype.localeCompare(t.archetype);break;case`population`:a=e.population-t.population;break;case`morale`:a=e.morale-t.morale;break;case`deaths`:a=e.deaths-t.deaths;break;case`tools`:a=e.tools-t.tools;break;case`turn`:a=e.turn-t.turn}return a===0?e.name.localeCompare(t.name):a*i}function jA(e,t,n){return[...e].sort((e,r)=>AA(e,r,t,n))}var MA={wrap:`_wrap_1yfha_1`,scroll:`_scroll_1yfha_9`,table:`_table_1yfha_13`,th:`_th_1yfha_21`,numeric:`_numeric_1yfha_32`,activeSort:`_activeSort_1yfha_36`,sortButton:`_sortButton_1yfha_40`,sortGlyph:`_sortGlyph_1yfha_70`,row:`_row_1yfha_75`,rowClickable:`_rowClickable_1yfha_83`,colorCell:`_colorCell_1yfha_95`,colorDot:`_colorDot_1yfha_100`,nameCell:`_nameCell_1yfha_108`,actorName:`_actorName_1yfha_116`,pendingPill:`_pendingPill_1yfha_121`,archetypeCell:`_archetypeCell_1yfha_136`,numCell:`_numCell_1yfha_142`,moraleWrap:`_moraleWrap_1yfha_150`,moraleBar:`_moraleBar_1yfha_158`,moraleFill:`_moraleFill_1yfha_168`,moraleText:`_moraleText_1yfha_176`,empty:`_empty_1yfha_183`},NA=[{key:`name`,label:`Actor`,numeric:!1},{key:`archetype`,label:`Archetype`,numeric:!1},{key:`turn`,label:`Turn`,numeric:!0},{key:`population`,label:`Pop`,numeric:!0},{key:`morale`,label:`Morale`,numeric:!0},{key:`deaths`,label:`Deaths`,numeric:!0},{key:`tools`,label:`Tools`,numeric:!0}];function PA(e,t){return e?t===`asc`?`ascending`:`descending`:`none`}function FA({state:e,onActorClick:t}){let[n,r]=(0,L.useState)(`morale`),[i,a]=(0,L.useState)(`desc`),o=(0,L.useCallback)(e=>{r(t=>t===e?(a(e=>e===`asc`?`desc`:`asc`),t):(a(kA(e)),e))},[]),s=(0,L.useMemo)(()=>OA(e),[e]),c=(0,L.useMemo)(()=>jA(s,n,i),[s,n,i]),l=e=>n=>{t&&(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))};return c.length===0?(0,R.jsx)(`div`,{className:MA.empty,role:`status`,children:`No actor data yet — events will populate this table as the run progresses.`}):(0,R.jsx)(`div`,{className:MA.wrap,"aria-label":`Actor roster (${c.length} actors)`,children:(0,R.jsx)(`div`,{className:MA.scroll,children:(0,R.jsxs)(`table`,{className:MA.table,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{children:[(0,R.jsx)(`th`,{"aria-hidden":`true`,className:MA.colorCell}),NA.map(e=>{let t=e.key===n;return(0,R.jsx)(`th`,{"aria-sort":PA(t,i),className:`${MA.th} ${e.numeric?MA.numeric:``} ${t?MA.activeSort:``}`,children:(0,R.jsxs)(`button`,{type:`button`,className:MA.sortButton,onClick:()=>o(e.key),"aria-label":`Sort by ${e.label}${t?` (${i===`asc`?`ascending`:`descending`} active)`:``}`,children:[(0,R.jsx)(`span`,{children:e.label}),(0,R.jsx)(`span`,{className:MA.sortGlyph,"aria-hidden":`true`,children:t?i===`asc`?`▲`:`▼`:`·`})]})},e.key)})]})}),(0,R.jsx)(`tbody`,{children:c.map(n=>{let r=e.actorIds.indexOf(n.id),i=r>=0?Xn(r):`var(--text-3)`;return(0,R.jsxs)(`tr`,{className:`${MA.row} ${t?MA.rowClickable:``}`,tabIndex:t?0:-1,onClick:t?()=>t(n.id):void 0,onKeyDown:t?l(n.id):void 0,"aria-label":`${n.name}, ${n.archetype}, turn ${n.turn}, population ${n.population}, morale ${n.morale}%, ${n.deaths} deaths, ${n.tools} tools`,children:[(0,R.jsx)(`td`,{className:MA.colorCell,"aria-hidden":`true`,children:(0,R.jsx)(`span`,{className:MA.colorDot,style:{background:i}})}),(0,R.jsxs)(`td`,{className:MA.nameCell,children:[(0,R.jsx)(`span`,{className:MA.actorName,children:n.name}),n.pending&&(0,R.jsx)(`span`,{className:MA.pendingPill,title:`Waiting on commander decision`,children:`pending`})]}),(0,R.jsx)(`td`,{className:MA.archetypeCell,children:n.archetype}),(0,R.jsxs)(`td`,{className:MA.numCell,children:[`T`,n.turn]}),(0,R.jsx)(`td`,{className:MA.numCell,children:n.population}),(0,R.jsx)(`td`,{className:MA.numCell,children:(0,R.jsxs)(`span`,{className:MA.moraleWrap,children:[(0,R.jsx)(`span`,{className:MA.moraleBar,"aria-hidden":`true`,children:(0,R.jsx)(`span`,{className:MA.moraleFill,style:{width:`${Math.min(100,Math.max(0,n.morale))}%`,background:i}})}),(0,R.jsxs)(`span`,{className:MA.moraleText,children:[n.morale,`%`]})]})}),(0,R.jsx)(`td`,{className:MA.numCell,children:n.deaths}),(0,R.jsx)(`td`,{className:MA.numCell,children:n.tools})]},n.id)})})]})})})}function IA(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 LA(e,t){let n=e.actorIds.map(t=>e.actors[t]).filter(e=>!!e).map(e=>t(e));if(n.length===0)return[];let r=n.reduce((e,t)=>Math.max(e,t.length),0),i=[];for(let e=0;e<r;e++){let t=[];for(let r of n)r.length>e&&t.push(r[e]);if(t.length===0)continue;let r=[...t].sort((e,t)=>e-t);i.push({turn:e+1,n:r.length,min:r[0],q1:IA(r,.25),median:IA(r,.5),q3:IA(r,.75),max:r[r.length-1]})}return i}var RA=e=>e.popHistory,zA=e=>e.moraleHistory;function BA(e,t,n){let r=n-t,i=e=>r<=0?.5:(e-t)/r;return{turn:e.turn,n:e.n,min:i(e.min),q1:i(e.q1),median:i(e.median),q3:i(e.q3),max:i(e.max)}}function VA(e){if(e.length===0)return{lo:0,hi:1};let t=1/0,n=-1/0;for(let r of e)r.min<t&&(t=r.min),r.max>n&&(n=r.max);return!isFinite(t)||!isFinite(n)?{lo:0,hi:1}:t===n?{lo:t-1,hi:n+1}:{lo:t,hi:n}}var HA={panel:`_panel_1ox36_1`,heading:`_heading_1ox36_9`,headingLabel:`_headingLabel_1ox36_17`,headingHint:`_headingHint_1ox36_26`,charts:`_charts_1ox36_33`,chartWrap:`_chartWrap_1ox36_39`,chartHeader:`_chartHeader_1ox36_45`,chartTitle:`_chartTitle_1ox36_53`,chartLatest:`_chartLatest_1ox36_60`,chart:`_chart_1ox36_33`,envelope:`_envelope_1ox36_76`,iqr:`_iqr_1ox36_82`,median:`_median_1ox36_88`,empty:`_empty_1ox36_96`},UA=[{id:`morale`,label:`Morale`,unitSuffix:`%`,pick:zA,fixedRange:{lo:0,hi:100}},{id:`population`,label:`Population`,unitSuffix:``,pick:RA}],WA=360,GA=90,KA=8,qA=6;function JA({bands:e,fixedRange:t,unitSuffix:n}){if(e.length===0)return(0,R.jsx)(`div`,{className:HA.empty,role:`status`,children:`No turns recorded yet.`});let r=t??VA(e),i=e.map(e=>BA(e,r.lo,r.hi)),a=t=>e.length===1?180:KA+t/(e.length-1)*344,o=e=>qA+(1-e)*78,s=`${i.map((e,t)=>`${t===0?`M`:`L`} ${a(t)} ${o(e.max)}`).join(` `)} ${[...i].reverse().map(e=>{let t=i.indexOf(e);return`L ${a(t)} ${o(e.min)}`}).join(` `)} Z`,c=`${i.map((e,t)=>`${t===0?`M`:`L`} ${a(t)} ${o(e.q3)}`).join(` `)} ${[...i].reverse().map(e=>{let t=i.indexOf(e);return`L ${a(t)} ${o(e.q1)}`}).join(` `)} Z`,l=i.map((e,t)=>`${t===0?`M`:`L`} ${a(t)} ${o(e.median)}`).join(` `),u=e[e.length-1];return(0,R.jsxs)(`svg`,{className:HA.chart,viewBox:`0 0 ${WA} ${GA}`,width:WA,height:GA,role:`img`,"aria-label":`Quantile distribution across turns. Latest turn ${u.turn}: median ${u.median.toFixed(0)}${n}, range ${u.min.toFixed(0)}-${u.max.toFixed(0)}${n} across ${u.n} actor${u.n===1?``:`s`}.`,children:[(0,R.jsx)(`path`,{className:HA.envelope,d:s}),(0,R.jsx)(`path`,{className:HA.iqr,d:c}),(0,R.jsx)(`path`,{className:HA.median,d:l})]})}function YA({state:e}){let t=(0,L.useMemo)(()=>UA.map(t=>({def:t,bands:LA(e,t.pick)})),[e]);return t.some(e=>e.bands.length>0)?(0,R.jsxs)(`div`,{className:HA.panel,"aria-label":`Distribution across actors`,children:[(0,R.jsxs)(`div`,{className:HA.heading,children:[(0,R.jsx)(`span`,{className:HA.headingLabel,children:`DISTRIBUTION`}),(0,R.jsx)(`span`,{className:HA.headingHint,children:`median · IQR · min-max envelope`})]}),(0,R.jsx)(`div`,{className:HA.charts,children:t.map(({def:e,bands:t})=>{let n=t[t.length-1];return(0,R.jsxs)(`div`,{className:HA.chartWrap,children:[(0,R.jsxs)(`div`,{className:HA.chartHeader,children:[(0,R.jsx)(`span`,{className:HA.chartTitle,children:e.label}),n&&(0,R.jsxs)(`span`,{className:HA.chartLatest,children:[`T`,n.turn,` · median `,Math.round(n.median),e.unitSuffix,` · `,n.min.toFixed(0),`-`,n.max.toFixed(0),e.unitSuffix,` · n=`,n.n]})]}),(0,R.jsx)(JA,{bands:t,fixedRange:e.fixedRange,unitSuffix:e.unitSuffix})]},e.id)})})]}):null}var XA={overlay:`_overlay_prjqp_1`,modal:`_modal_prjqp_11`,dockOverlay:`_dockOverlay_prjqp_22`,dock:`_dock_prjqp_22`,head:`_head_prjqp_60`,actorName:`_actorName_prjqp_68`,closeBtn:`_closeBtn_prjqp_73`,body:`_body_prjqp_83`,section:`_section_prjqp_88`,sectionTitle:`_sectionTitle_prjqp_92`,list:`_list_prjqp_100`,decisionItem:`_decisionItem_prjqp_106`,decisionTitle:`_decisionTitle_prjqp_111`,decisionRationale:`_decisionRationale_prjqp_115`,empty:`_empty_prjqp_120`,turnArticle:`_turnArticle_prjqp_124`,turnHeader:`_turnHeader_prjqp_129`,turnList:`_turnList_prjqp_134`,turnEvent:`_turnEvent_prjqp_140`,turnEventType:`_turnEventType_prjqp_145`};function ZA(e){let t=e.data??{};return t.title??t.choice??t.summary??e.type}function QA({actorName:e,actorIndex:t,state:n,onClose:r,mode:i=`modal`}){let a=Qr(i===`modal`&&e!==null);if(L.useEffect(()=>{if(e===null)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),r())};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e,r]),e===null)return null;let o=n.actors[e];if(!o)return null;let s=o.events??[],c=s.filter(e=>e.type===`decision_made`),l=new Map;for(let e of s){let t=e.turn??0,n=l.get(t)??[];n.push(e),l.set(t,n)}let u=[...l.keys()].sort((e,t)=>e-t),d=i===`dock`,f=d?XA.dockOverlay:XA.overlay,p=d?XA.dock:XA.modal,m=d?void 0:r,h=d?void 0:e=>e.stopPropagation();return(0,R.jsx)(`div`,{className:f,role:`presentation`,onClick:m,children:(0,R.jsxs)(`div`,{ref:a,className:p,role:`dialog`,"aria-modal":!d||void 0,"aria-label":`Report for ${e}`,tabIndex:-1,onClick:h,children:[(0,R.jsxs)(`header`,{className:XA.head,children:[(0,R.jsx)(`div`,{className:XA.actorName,children:e}),(0,R.jsx)(`button`,{type:`button`,"aria-label":`Close drill-in`,className:XA.closeBtn,onClick:r,children:`×`})]}),(0,R.jsxs)(`div`,{className:XA.body,children:[(0,R.jsx)(MO,{actorIndex:t,leader:o.leader,popHistory:o.popHistory,moraleHistory:o.moraleHistory}),c.length>0&&(0,R.jsxs)(`section`,{className:XA.section,children:[(0,R.jsxs)(`h3`,{className:XA.sectionTitle,children:[`Decisions (`,c.length,`)`]}),(0,R.jsx)(`ul`,{className:XA.list,children:c.map(e=>{let t=e.data?.choice??e.data?.title??`<choice>`,n=e.data?.rationale??``;return(0,R.jsxs)(`li`,{className:XA.decisionItem,children:[(0,R.jsxs)(`div`,{className:XA.decisionTitle,children:[`T`,e.turn??`?`,`: `,t]}),n&&(0,R.jsx)(`div`,{className:XA.decisionRationale,children:n})]},e.id)})})]}),(0,R.jsxs)(`section`,{className:XA.section,children:[(0,R.jsxs)(`h3`,{className:XA.sectionTitle,children:[`Timeline (`,s.length,` events)`]}),u.length===0&&(0,R.jsx)(`p`,{className:XA.empty,children:`No events captured yet.`}),u.map(e=>(0,R.jsxs)(`article`,{className:XA.turnArticle,children:[(0,R.jsxs)(`header`,{className:XA.turnHeader,children:[`Turn `,e]}),(0,R.jsx)(`ul`,{className:XA.turnList,children:(l.get(e)??[]).map(e=>(0,R.jsxs)(`li`,{className:XA.turnEvent,children:[(0,R.jsx)(`span`,{className:XA.turnEventType,children:e.type}),` `,ZA(e)]},e.id))})]},e))]})]})]})})}var $A={root:`_root_1jmih_1`,scrollableBody:`_scrollableBody_1jmih_8`,leadersRow:`_leadersRow_1jmih_16`,turnRows:`_turnRows_1jmih_22`,introBar:`_introBar_1jmih_35`,introBody:`_introBody_1jmih_46`,introHeading:`_introHeading_1jmih_53`,introExpandButton:`_introExpandButton_1jmih_57`,introDismissButton:`_introDismissButton_1jmih_69`,progressBar:`_progressBar_1jmih_88`,progressLabel:`_progressLabel_1jmih_99`,progressTrack:`_progressTrack_1jmih_106`,progressFill:`_progressFill_1jmih_114`,progressPercent:`_progressPercent_1jmih_120`,centerState:`_centerState_1jmih_124`,centerStateHeading:`_centerStateHeading_1jmih_135`,centerStateHeadingLarger:`_centerStateHeadingLarger_1jmih_147`,centerStateHeadingAmber:`_centerStateHeadingAmber_1jmih_159`,centerStateCopy:`_centerStateCopy_1jmih_167`,centerStateCopyWide:`_centerStateCopyWide_1jmih_167`,centerStateSpinnerSmall:`_centerStateSpinnerSmall_1jmih_179`,centerStateSpinnerLarge:`_centerStateSpinnerLarge_1jmih_186`,emptyStateActions:`_emptyStateActions_1jmih_193`,buttonLoad:`_buttonLoad_1jmih_200`,buttonSettings:`_buttonSettings_1jmih_216`,replayCtaWrap:`_replayCtaWrap_1jmih_231`,flashCard:`_flashCard_1jmih_238`,flashOn:`_flashOn_1jmih_241`};function ej({onDismiss:e}){let[t,n]=(0,L.useState)(!1);return(0,R.jsxs)(`div`,{role:`region`,"aria-label":`How to read the simulation`,className:$A.introBar,children:[(0,R.jsxs)(`div`,{className:$A.introBody,children:[(0,R.jsx)(`b`,{className:$A.introHeading,children:`How to read this:`}),` `,t?(0,R.jsx)(R.Fragment,{children:`Multiple commanders with different HEXACO profiles run the same seed side by side. Each turn, departments analyze in parallel and may forge a new computational tool in a QuickJS WebAssembly sandbox or reuse an existing one. Commanders decide. The settlement diverges. Click any tile in Viz to drill into a colonist; click any forge card to inspect the generated code.`}):(0,R.jsxs)(R.Fragment,{children:[`multiple commanders, one seed, divergent histories. HEXACO shapes every LLM call.`,` `,(0,R.jsx)(`button`,{onClick:()=>n(!0),className:$A.introExpandButton,children:`more`})]})]}),(0,R.jsx)(`button`,{onClick:e,className:$A.introDismissButton,"aria-label":`Dismiss introduction`,children:`Got it`})]})}function tj({state:e,sseStatus:t,verdict:n,shownRun:r,launching:i=!1,interventionArtifact:a,interventionRunning:o,interventionState:s=e,onInterventionDismiss:c,forceLayout:l}){let u=fF();if(a)return(0,R.jsx)(`div`,{className:$A.root,children:(0,R.jsx)(`div`,{className:$A.scrollableBody,children:(0,R.jsx)(vO,{artifact:a,state:s,onDismiss:c})})});if(o)return(0,R.jsx)(`div`,{className:$A.root,children:(0,R.jsx)(`div`,{className:$A.scrollableBody,children:(0,R.jsx)(wO,{state:s,subject:o.subject,intervention:o.intervention})})});let d=HC(),f=ew(),[p,m]=(0,L.useState)(`side-by-side`),h=(0,L.useRef)(!1),g=(0,L.useCallback)(e=>{h.current=!0,m(e)},[]);(0,L.useEffect)(()=>{h.current||e.actorIds.length>50&&p!==`constellation`&&m(`constellation`)},[e.actorIds.length,p]);let _=l??p,[v,y]=(0,L.useState)(null),b=v?e.actorIds.indexOf(v):0,x=e.actorIds[0],C=e.actorIds[1],w=x?e.actors[x]:null,T=C?e.actors[C]:null,E=Object.values(e.actors).some(e=>e.events.length>0),D=e.isRunning&&!E,O=u.presets.find(e=>e.id==="default"),k=O?.leaders??O?.actors,ee=(0,L.useMemo)(()=>typeof window>`u`?null:S(window.localStorage),[]),A=k?.[0]??ee?.[0],j=k?.[1]??ee?.[1],M=A?.name?{name:A.name,archetype:A.archetype??``,unit:A.unit??yn(u,0),hexaco:A.hexaco??{},instructions:A.instructions??``,quote:``}:null,N=j?.name?{name:j.name,archetype:j.archetype??``,unit:j.unit??yn(u,1),hexaco:j.hexaco??{},instructions:j.instructions??``,quote:``}:null,[te,P]=(0,L.useState)(()=>typeof window>`u`||localStorage.getItem(`paracosm-intro-dismissed`)!==`1`),F=()=>{P(!1),localStorage.setItem(`paracosm-intro-dismissed`,`1`)},I=w?.event,ne=I?`T${I.turn} \u2014 ${I.time}: ${I.title}`:``,re=(0,L.useMemo)(()=>{let e=n&&typeof n==`object`?n.winner:null;return t=>e===`tie`?`tie`:e===t?`winner`:e===`A`||e===`B`?`second`:null},[n]),z=e.maxTurns>0?Math.min(100,Math.max(0,e.turn/e.maxTurns*100)):0,B=(0,L.useCallback)(()=>{let e=document.querySelector(`[data-paracosm-replay-cta="true"]`);e&&(e.scrollIntoView({behavior:`smooth`,block:`center`}),e.classList.add($A.flashOn),window.setTimeout(()=>e.classList.remove($A.flashOn),1200))},[]),ie=(0,L.useCallback)(()=>{let e=new URL(window.location.href);e.searchParams.set(`tab`,`settings`),window.history.replaceState({},``,e.toString()),window.location.reload()},[]),ae=e.isRunning||e.isComplete||E||t===`connected`;return(0,R.jsxs)(`div`,{className:$A.root,children:[(0,R.jsxs)(`div`,{className:$A.scrollableBody,children:[e.isComplete&&n&&n.winner?(0,R.jsx)(Zi,{verdict:n,shownRun:r}):null,_===`constellation`?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(TA,{state:e,onActorClick:e=>y(e)}),(0,R.jsx)(YA,{state:e}),(0,R.jsx)(FA,{state:e,onActorClick:e=>y(e)})]}):e.actorIds.length>=3?(0,R.jsx)(WO,{actors:e.actorIds.map(t=>({id:t,state:e.actors[t]})),crisisText:ne,toolRegistry:f}):(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{className:`leaders-row ${$A.leadersRow}`,children:[(0,R.jsx)(MO,{actorIndex:0,leader:w?.leader||M,popHistory:w?.popHistory||[],moraleHistory:w?.moraleHistory||[],verdictPlacement:re(`A`),event:w?.event,statuses:w?.statuses,pendingDecision:w?.pendingDecision}),(0,R.jsx)(MO,{actorIndex:1,leader:T?.leader||N,popHistory:T?.popHistory||[],moraleHistory:T?.moraleHistory||[],verdictPlacement:re(`B`),event:T?.event,statuses:T?.statuses,pendingDecision:T?.pendingDecision})]}),(0,R.jsx)(WO,{actors:e.actorIds.slice(0,2).map(t=>({id:t,state:e.actors[t]})),crisisText:ne,toolRegistry:f})]}),e.isRunning&&!e.isComplete&&e.maxTurns>0&&(0,R.jsxs)(`div`,{className:$A.progressBar,children:[(0,R.jsxs)(`span`,{className:$A.progressLabel,children:[`Turn `,Math.max(1,e.turn),` / `,e.maxTurns]}),(0,R.jsx)(`div`,{className:$A.progressTrack,children:(0,R.jsx)(`div`,{className:$A.progressFill,style:{width:`${z}%`}})}),(0,R.jsxs)(`span`,{className:$A.progressPercent,children:[Math.round(z),`%`]})]}),te&&(w?.events.length??0)>0&&(0,R.jsx)(ej,{onDismiss:F}),D&&!E&&!e.isComplete&&e.turn===0&&(0,R.jsxs)(`div`,{className:$A.centerState,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`spinner ${$A.centerStateSpinnerSmall}`,"aria-hidden":`true`}),(0,R.jsx)(`div`,{className:$A.centerStateHeading,children:`Simulation starting...`}),(0,R.jsx)(`div`,{className:$A.centerStateCopy,children:`The Event Director is reading simulation state and generating the first event. Departments will analyze and forge tools once it arrives.`})]}),i&&!E&&!e.isRunning&&(0,R.jsxs)(`div`,{className:$A.centerState,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`spinner ${$A.centerStateSpinnerLarge}`,"aria-hidden":`true`}),(0,R.jsx)(`div`,{className:$A.centerStateHeadingAmber,children:`Launching Simulation...`}),(0,R.jsx)(`div`,{className:$A.centerStateCopy,children:`Initializing the Event Director, departments, and agent personalities. First events will appear shortly.`})]}),!E&&!e.isComplete&&!i&&t===`connecting`&&(0,R.jsxs)(`div`,{className:$A.centerState,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`spinner ${$A.centerStateSpinnerSmall}`,"aria-hidden":`true`}),(0,R.jsx)(`div`,{className:$A.centerStateHeading,children:`Connecting...`}),(0,R.jsx)(`div`,{className:$A.centerStateCopy,children:`Loading simulation state from the server. If a simulation is running, events will appear shortly.`})]}),!e.isRunning&&!e.isComplete&&!E&&t===`connected`&&!i&&typeof window<`u`&&new URLSearchParams(window.location.search).has(`replay`)&&(0,R.jsxs)(`div`,{className:$A.centerState,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:`spinner ${$A.centerStateSpinnerSmall}`,"aria-hidden":`true`}),(0,R.jsx)(`div`,{className:$A.centerStateHeading,children:`Loading replay…`}),(0,R.jsx)(`div`,{className:$A.centerStateCopy,children:`Streaming the cached run back from the server. Turns and events will populate as they arrive.`})]}),!e.isRunning&&!e.isComplete&&!E&&t===`connected`&&!i&&!(typeof window<`u`&&new URLSearchParams(window.location.search).has(`replay`))&&(0,R.jsxs)(`div`,{className:$A.centerState,children:[(0,R.jsx)(`div`,{className:$A.centerStateHeadingLarger,children:`No simulation running`}),(0,R.jsx)(`div`,{className:$A.centerStateCopyWide,children:`Configure your commanders with different HEXACO personality profiles, choose a scenario, and launch from the Settings tab. Or load a previously saved simulation.`}),(0,R.jsxs)(`div`,{className:$A.emptyStateActions,children:[(0,R.jsx)(`button`,{onClick:B,className:$A.buttonLoad,children:`Load Prior Run`}),(0,R.jsx)(`button`,{onClick:ie,className:$A.buttonSettings,children:`Settings`})]}),(0,R.jsx)(`div`,{"data-paracosm-replay-cta":`true`,className:`${$A.replayCtaWrap} ${$A.flashCard}`,children:(0,R.jsx)(sA,{})})]}),ae&&(0,R.jsx)(Hk,{state:e}),ae&&_===`side-by-side`&&e.actorIds.length===2&&(0,R.jsx)(`div`,{className:$A.turnRows,children:(0,R.jsx)(bk,{state:e})}),ae&&_===`side-by-side`&&e.actorIds.length>=3&&(0,R.jsx)(`div`,{className:$A.turnRows,children:(0,R.jsx)(kk,{state:e})}),(0,R.jsx)(ZO,{state:e})]}),(0,R.jsx)(eA,{citationRegistry:d,toolRegistry:f,layoutToggle:(0,R.jsx)(uA,{layout:_,actorCount:e.actorIds.length,onChange:g})}),(0,R.jsx)(aA,{enabled:e.isComplete&&!e.isRunning}),(0,R.jsx)(QA,{actorName:v,actorIndex:b>=0?b:0,state:e,onClose:()=>y(null),mode:e.actorIds.length>=5?`dock`:`modal`})]})}function nj(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 rj({label:e,shortLabel:t,value:n,onChange:r,sideColor:i}){let a=nj(t,n),o=i||`var(--amber)`,s={flex:1,accentColor:o,"--pc-range-fill":o,"--pc-range-pct":`${Math.round(n*100)}%`};return(0,R.jsxs)(`div`,{style:{display:`flex`,alignItems:`center`,gap:`6px`},children:[(0,R.jsx)(`label`,{style:{fontSize:`var(--font-sm)`,color:`var(--text-2)`,minWidth:`32px`,fontWeight:700},children:t}),(0,R.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,R.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,R.jsx)(`span`,{style:{fontSize:`var(--font-3xs)`,color:`var(--text-3)`,minWidth:`55px`,fontFamily:`var(--mono)`},children:a})]})}var ij={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 aj(){return(0,R.jsxs)(`div`,{className:ij.notice,role:`note`,"aria-label":`Pluggable trait models`,children:[(0,R.jsx)(`span`,{className:ij.badge,"aria-hidden":`true`,children:`NEW`}),(0,R.jsxs)(`div`,{className:ij.body,children:[(0,R.jsx)(`div`,{className:ij.headline,children:`Leaders accept pluggable trait models.`}),(0,R.jsxs)(`p`,{className:ij.copy,children:[`The dashboard form below configures HEXACO leaders today. The API also accepts `,(0,R.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,R.jsx)(`code`,{children:`traitProfile`}),` field via`,` `,(0,R.jsx)(`code`,{children:`runSimulation(leader, ...)`}),` directly.`]}),(0,R.jsxs)(`div`,{className:ij.links,children:[(0,R.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:ij.link,children:`Captured ai-agent end-to-end run`}),(0,R.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:ij.link,children:`Trait-model cookbook`})]})]})]})}var oj={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`},sj=[{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`}],cj=[{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 lj({label:e,sideColor:t,data:n,onChange:r}){let i=(0,L.useId)(),a=`${i}-name`,o=`${i}-archetype`,s=`${i}-unit`,c=`${i}-instructions`,l=`${i}-preset`,u=(e,t)=>r({...n,[e]:t}),d=(e,t)=>r({...n,hexaco:{...n.hexaco,[e]:t}});return(0,R.jsxs)(`div`,{className:oj.root,style:{"--side-color":t},children:[(0,R.jsx)(`h3`,{className:oj.heading,children:e}),(0,R.jsxs)(`div`,{className:`responsive-stack ${oj.fieldRow}`,children:[(0,R.jsxs)(`div`,{className:oj.field,children:[(0,R.jsx)(`label`,{htmlFor:a,className:oj.label,children:`Name`}),(0,R.jsx)(`input`,{id:a,value:n.name,onChange:e=>u(`name`,e.target.value),className:oj.input})]}),(0,R.jsxs)(`div`,{className:oj.field,children:[(0,R.jsx)(`label`,{htmlFor:o,className:oj.label,children:`Archetype`}),(0,R.jsx)(`input`,{id:o,value:n.archetype,onChange:e=>u(`archetype`,e.target.value),className:oj.input})]}),(0,R.jsxs)(`div`,{className:oj.field,children:[(0,R.jsx)(`label`,{htmlFor:s,className:oj.label,children:`Unit`}),(0,R.jsx)(`input`,{id:s,value:n.unit,onChange:e=>u(`unit`,e.target.value),className:oj.input})]})]}),(0,R.jsxs)(`div`,{className:oj.textareaBlock,children:[(0,R.jsx)(`label`,{htmlFor:c,className:oj.label,children:`Instructions`}),(0,R.jsx)(`textarea`,{id:c,value:n.instructions,onChange:e=>u(`instructions`,e.target.value),rows:3,className:oj.textarea})]}),(0,R.jsx)(aj,{}),(0,R.jsxs)(`div`,{className:oj.presetRow,children:[(0,R.jsx)(`label`,{htmlFor:l,className:oj.presetLabel,children:`Personality`}),(0,R.jsxs)(`select`,{id:l,className:`pc-select ${oj.presetSelect}`,onChange:e=>{let t=cj.find(t=>t.id===e.target.value);t&&r({...n,hexaco:{...t.hexaco}})},defaultValue:``,children:[(0,R.jsx)(`option`,{value:``,disabled:!0,children:`Apply preset...`}),cj.map(e=>(0,R.jsx)(`option`,{value:e.id,children:e.label},e.id))]})]}),(0,R.jsx)(`div`,{className:`responsive-grid-3 ${oj.hexacoGrid}`,children:sj.map(e=>(0,R.jsx)(rj,{label:e.label,shortLabel:e.short,value:n.hexaco[e.key]??.5,onChange:t=>d(e.key,t),sideColor:t},e.key))})]})}function uj(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 dj(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 fj={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`},pj={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:[]},mj=`paracosm:editorCompileResult`;function hj(){try{let e=window.sessionStorage.getItem(mj);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 gj({onAdminWrite:e}){let[t,n]=(0,L.useState)({adminWrite:!1,memoryScenarios:[]}),[r,i]=(0,L.useState)(``),[a,o]=(0,L.useState)(``),[s,c]=(0,L.useState)(``),[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(!0),[p,m]=(0,L.useState)(`5`),[h,g]=(0,L.useState)(``),[_,v]=(0,L.useState)(``),[y,b]=(0,L.useState)(!1),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)([]),[T,E]=(0,L.useState)(()=>hj()),D=(0,L.useRef)(null),O=(0,L.useRef)(null);(0,L.useEffect)(()=>{fetch(`/admin-config`).then(e=>e.json()).then(t=>{n(t),e?.(t.adminWrite===!0)}).catch(()=>{});try{window.sessionStorage.removeItem(mj)}catch{}},[]);let k=(0,L.useCallback)(()=>{fetch(`/scenario`).then(e=>e.ok?e.json():null).then(e=>{e?.id&&i(JSON.stringify(e,null,2))}).catch(()=>{})},[]);(0,L.useEffect)(()=>(k(),se(window,k)),[k]),(0,L.useEffect)(()=>{if(!r.trim())o(``);else try{JSON.parse(r),o(``)}catch(e){o(String(e).replace(`SyntaxError: `,``))}},[r]);let ee=()=>i(JSON.stringify(pj,null,2)),A=(0,L.useCallback)(async()=>{try{let e=await(await fetch(`/scenario`)).json();i(JSON.stringify(e,null,2)),E({success:!0,message:`Loaded active scenario: ${e.labels?.name||e.id}`})}catch(e){E({success:!1,message:`Failed to load: ${e}`})}},[]),j=()=>D.current?.click(),M=e=>{let t=e.target.files?.[0];if(!t)return;let n=new FileReader;n.onload=()=>{let e=n.result;i(e);try{JSON.parse(e),E({success:!0,message:`Imported ${t.name} (${(t.size/1024).toFixed(1)}KB)`})}catch{E({success:!1,message:`Imported ${t.name} but JSON is invalid`})}},n.readAsText(t),e.target.value=``},N=()=>{if(r.trim())try{let e=JSON.parse(r),t=e.id||`scenario`;rr(JSON.stringify(e,null,2),`${t}.json`),E({success:!0,message:`Exported ${t}.json`})}catch{E({success:!1,message:`Fix JSON errors before exporting`})}},te=(0,L.useCallback)(async()=>{if(r.trim()&&!a){S(!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),E({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])]}))):E({success:!1,message:t.error||`Store failed`})}catch(e){E({success:!1,message:String(e)})}S(!1)}},[r,a]),P=(0,L.useCallback)(async()=>{if(r.trim()&&!a&&t.adminWrite)try{let e=JSON.parse(r),t=Nn(),n=Ln(t);if(n){E({success:!1,message:n});return}let i=await fetch(`/scenario/store`,{method:`POST`,headers:{"Content-Type":`application/json`,...t?{[Tn]:t}:{}},body:JSON.stringify({scenario:e,saveToDisk:!0})}),a=await i.json();a.savedToDisk?(oe(window),E({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?(In(t),E({success:!1,message:`Disk write refused: the admin token is missing or wrong. ${En}`})):E({success:!1,message:a.error||`Disk write refused (HTTP ${i.status})`})}catch(e){E({success:!1,message:String(e)})}},[r,a,t.adminWrite]),F=(0,L.useCallback)(async()=>{if(!r.trim()||a)return;let e;try{e=JSON.parse(r)}catch{E({success:!1,message:`Fix JSON errors before compiling`});return}b(!0),w([]),E(null);try{let t=uj({scenario:e,seedText:s,seedUrl:l,webSearch:d,maxSearches:p,provider:h,model:_}),n=await fetch(`/compile`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)}),r=await dj(n);if(r!==null){E({success:!1,message:r}),b(!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(`
|
|
125
|
+
`);o=n.pop()||``;for(let e of n)if(e.startsWith(`data: `))try{let t=JSON.parse(e.slice(6));if(t.hook&&w(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){E({success:!1,message:`Compiled ${t.id}, but switching to it failed: ${e}`});continue}try{window.sessionStorage.setItem(mj,JSON.stringify({success:!0,message:`Compiled: ${t.id} (${t.departments} departments, ${t.hooks} hooks). Configure actors below and launch.`}))}catch{}ge(),window.location.reload();return}t.error&&E({success:!1,message:t.error})}catch{}}}catch(e){E({success:!1,message:String(e)})}b(!1)},[r,a,s,l,d,p,h,_]),I=r.split(`
|
|
126
|
+
`).length,ne=new Blob([r]).size;return(0,R.jsxs)(`div`,{className:fj.card,children:[(0,R.jsxs)(`div`,{className:fj.header,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`h3`,{className:fj.title,children:`Scenario Editor`}),(0,R.jsxs)(`p`,{className:fj.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,R.jsxs)(`div`,{className:fj.btnRow,children:[(0,R.jsx)(`button`,{onClick:A,className:[fj.btn,fj.amber].join(` `),"aria-label":`Load active scenario JSON`,children:`Load Active`}),(0,R.jsx)(`button`,{onClick:ee,className:fj.btn,"aria-label":`Load example scenario`,children:`Template`}),(0,R.jsx)(`button`,{onClick:j,className:fj.btn,"aria-label":`Import JSON file`,children:`Import`}),(0,R.jsx)(`button`,{onClick:N,className:fj.btn,disabled:!r.trim()||!!a,"aria-label":`Export as JSON file`,children:`Export`}),(0,R.jsx)(`input`,{ref:D,type:`file`,accept:`.json,application/json`,onChange:M,className:fj.fileInput})]})]}),(0,R.jsxs)(`div`,{className:fj.editorWrap,children:[(0,R.jsx)(`textarea`,{ref:O,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:fj.editor}),(0,R.jsxs)(`div`,{className:fj.statusBar,style:{"--status-color":a?`var(--rust)`:`var(--text-3)`},children:[(0,R.jsx)(`span`,{children:a||(r.trim()?`Valid JSON`:`Empty`)}),(0,R.jsxs)(`span`,{children:[I,` lines, `,(ne/1024).toFixed(1),`KB`]})]})]}),(0,R.jsxs)(`details`,{className:fj.seedDetails,children:[(0,R.jsx)(`summary`,{className:fj.seedSummary,children:`Seed Enrichment (optional)`}),(0,R.jsxs)(`div`,{className:fj.seedBody,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{style:sS,children:`Seed Text`}),(0,R.jsx)(`textarea`,{value:s,onChange:e=>c(e.target.value),placeholder:`Paste a prompt, notes, a brief, or source text to turn into research facts and category mapping.`,className:fj.textarea})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{style:sS,children:`Seed URL (fetched via Firecrawl)`}),(0,R.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),placeholder:`https://example.com/article`,className:fj.input})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{style:sS,children:`Max Web Searches`}),(0,R.jsx)(`input`,{value:p,onChange:e=>m(e.target.value),inputMode:`numeric`,placeholder:`5`,className:fj.input})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{style:sS,children:`Compile Provider Override`}),(0,R.jsx)(`input`,{value:h,onChange:e=>g(e.target.value),placeholder:`anthropic or openai (optional)`,className:fj.input})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{style:sS,children:`Compile Model Override`}),(0,R.jsx)(`input`,{value:_,onChange:e=>v(e.target.value),placeholder:`gpt-5.4-mini, claude-sonnet-4-6, etc. (optional)`,className:fj.input})]}),(0,R.jsxs)(`label`,{className:fj.checkboxLabel,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:d,onChange:e=>f(e.target.checked)}),`Web search enrichment (requires Serper/Tavily/Firecrawl API keys)`]}),(0,R.jsx)(`p`,{className:fj.fineprint,children:`If both seed text and a seed URL are provided, the URL takes precedence and the compiler ingests the fetched page.`})]})]}),C.length>0&&(0,R.jsx)(`div`,{className:fj.progressWrap,children:C.map(e=>(0,R.jsxs)(`div`,{className:fj.progressRow,children:[(0,R.jsx)(`span`,{children:e.status===`done`?`✔`:e.status===`generating`?`⏳`:e.status===`cached`?`✔`:`•`}),(0,R.jsx)(`span`,{children:e.hook}),(0,R.jsx)(`span`,{className:fj.progressStatus,children:e.status})]},e.hook))}),T&&(0,R.jsx)(`div`,{className:fj.result,style:{"--result-color":T.success?`var(--green)`:`var(--rust)`,"--result-bg":T.success?`rgba(106,173,72,.06)`:`rgba(224,101,48,.06)`},children:T.message}),(0,R.jsxs)(`div`,{className:fj.actions,children:[(0,R.jsx)(`button`,{onClick:te,disabled:!r.trim()||!!a||x,className:fj.actionBtn,"aria-label":`Store scenario in memory`,children:x?`Storing...`:`Store in Memory`}),(0,R.jsx)(`button`,{onClick:F,disabled:!r.trim()||!!a||y,className:[fj.actionBtn,fj.primary].join(` `),"aria-label":`Compile scenario`,children:y?`Compiling...`:`Compile Scenario`}),t.adminWrite&&(0,R.jsx)(`button`,{onClick:P,disabled:!r.trim()||!!a,className:[fj.actionBtn,fj.amber].join(` `),"aria-label":`Save scenario to disk`,children:`Save to Disk`}),(0,R.jsx)(`span`,{className:fj.spacer}),t.memoryScenarios.length>0&&(0,R.jsxs)(`span`,{className:fj.memCount,children:[t.memoryScenarios.length,` in memory`]})]})]})}var _j={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`},vj={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 yj(){let e=(0,L.useRef)(null),[t,n]=(0,L.useState)(!1),[r,i]=(0,L.useState)(()=>Pn()),[a,o]=(0,L.useState)(null);(0,L.useEffect)(()=>Rn(()=>i(Pn())),[]);let s=()=>{e.current&&(e.current.value=``),n(!1)},c=()=>{let t=e.current?.value??``;if(!t.trim())return;let n=Fn(t);n===`unsendable`?o(Dn):(o(null),i(n),s())};return(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`p`,{className:_j.intro,children:[`Admin writes on this server take its `,(0,R.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,R.jsx)(`code`,{children:`X-Admin-Token`}),` header, and keeps it in this browser.`]}),(0,R.jsx)(`label`,{htmlFor:`admin-token`,className:_j.label,children:`Token for this server`}),(0,R.jsxs)(`div`,{className:_j.row,children:[(0,R.jsx)(`input`,{id:`admin-token`,type:`password`,autoComplete:`off`,spellCheck:!1,ref:e,onChange:e=>{n(e.target.value.trim()!==``),o(null)},onKeyDown:e=>{e.key===`Enter`&&c()},placeholder:r===`none`?`Not entered`:`Saved`,"aria-describedby":`admin-token-status`,className:_j.input}),(0,R.jsx)(`button`,{type:`button`,onClick:c,disabled:!t,className:[_j.btn,_j.amber].join(` `),"aria-label":`Save admin token`,children:`Save`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{In(),i(`none`),o(null),s()},disabled:r===`none`&&!t,className:_j.btn,"aria-label":`Clear admin token`,children:`Clear`})]}),(0,R.jsx)(`div`,{id:`admin-token-status`,role:`status`,className:_j.status,children:vj[r]}),a&&(0,R.jsx)(`p`,{role:`alert`,className:_j.refusal,children:a})]})}var bj={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 xj(e){return e.query!==``||e.types.size>0||e.leader!==null||e.turnRange!==null||e.toolHash!==``}function Sj({events:e,filters:t,onFiltersChange:n}){let r=(0,L.useMemo)(()=>b_(e),[e]),i=xj(t),a=e=>{n({...t,...e})},o=e=>{let n=new Set(t.types);n.has(e)?n.delete(e):n.add(e),a({types:n})},s=e=>t.types.size===0||t.types.has(e);return(0,R.jsxs)(`div`,{className:bj.bar,children:[(0,R.jsxs)(`div`,{className:bj.topRow,children:[(0,R.jsxs)(`div`,{className:bj.searchWrap,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:bj.searchIcon,children:`🔍`}),(0,R.jsx)(`input`,{type:`search`,"aria-label":`Filter log by text (type, leader, department, title, summary)`,placeholder:`Search type, leader, department, title, summary...`,value:t.query,onChange:e=>a({query:e.target.value}),className:bj.searchInput})]}),t.toolHash&&(0,R.jsxs)(`span`,{className:bj.toolChip,children:[`tool: `,t.toolHash,(0,R.jsx)(`button`,{type:`button`,"aria-label":`Clear tool filter`,className:bj.chipClear,onClick:()=>a({toolHash:``,toolExact:!1}),children:`×`})]}),(0,R.jsx)(`button`,{type:`button`,className:bj.resetButton,disabled:!i,onClick:()=>n(h_()),children:`Reset filters`})]}),r.types.length>0&&(0,R.jsxs)(`div`,{className:bj.facetsRow,children:[(0,R.jsx)(`span`,{className:bj.facetLabel,children:`types`}),(0,R.jsx)(`div`,{className:bj.checkboxGroup,children:r.types.map(e=>{let t=s(e);return(0,R.jsxs)(`label`,{className:[bj.checkbox,t?bj.active:``].filter(Boolean).join(` `),children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:t,onChange:()=>o(e)}),e]},e)})})]}),(r.actors.length>1||r.maxTurn>3)&&(0,R.jsxs)(`div`,{className:bj.facetsRow,children:[r.actors.length>1&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:bj.facetLabel,children:`leader`}),(0,R.jsxs)(`select`,{"aria-label":`Filter by leader`,className:bj.leaderSelect,value:t.leader??``,onChange:e=>a({leader:e.target.value||null}),children:[(0,R.jsx)(`option`,{value:``,children:`all`}),r.actors.map(e=>(0,R.jsx)(`option`,{value:e,children:e},e))]})]}),r.maxTurn>3&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`span`,{className:bj.facetLabel,children:`turns`}),(0,R.jsxs)(`div`,{className:bj.rangeWrap,children:[(0,R.jsx)(`input`,{type:`number`,"aria-label":`Min turn`,min:0,max:r.maxTurn,value:t.turnRange?t.turnRange[0]:0,onChange:e=>{let n=Number(e.target.value);if(!Number.isFinite(n))return;let i=t.turnRange?.[1]??r.maxTurn;a({turnRange:[n,Math.max(n,i)]})},className:bj.rangeInput}),(0,R.jsx)(`span`,{children:`to`}),(0,R.jsx)(`input`,{type:`number`,"aria-label":`Max turn`,min:0,max:r.maxTurn,value:t.turnRange?t.turnRange[1]:r.maxTurn,onChange:e=>{let n=Number(e.target.value);if(!Number.isFinite(n))return;let r=t.turnRange?.[0]??0;a({turnRange:[Math.min(r,n),n]})},className:bj.rangeInput}),t.turnRange&&(0,R.jsx)(`button`,{type:`button`,className:bj.chipClear,"aria-label":`Clear turn range`,onClick:()=>a({turnRange:null}),children:`×`})]})]})]}),t.types.size>0&&t.types.size===r.types.length&&(0,R.jsx)(`div`,{className:bj.emptyHint,children:`All types selected — filter is a no-op on this axis.`})]})}var Cj={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`},wj={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 Tj(){return typeof window>`u`?w_(``,``):w_(window.location.search,window.location.hash)}function Ej({events:e}){let t=(0,L.useRef)(null),n=(0,L.useRef)(!1),[r,i]=(0,L.useState)(Tj);(0,L.useEffect)(()=>{let e=()=>i(Tj());return window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[]);let a=(0,L.useCallback)(()=>{let e=t.current;e&&(n.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},[]);(0,L.useEffect)(()=>{if(!n.current)return;let e=t.current;e&&(e.scrollTop=e.scrollHeight)},[e.length]);let o=(0,L.useCallback)(e=>{i(t=>{try{let n=t.toolHash!==``&&e.toolHash===``;window.history.replaceState({},``,C_(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,R.jsxs)(`div`,{ref:t,onScroll:a,className:`flex-1 overflow-y-auto p-4 font-mono text-xs ${Cj.panel}`,role:`log`,"aria-label":`Event log`,"aria-live":`polite`,children:[(0,R.jsx)(`div`,{className:Cj.header,children:(0,R.jsxs)(`h2`,{className:Cj.heading,children:[`Event Log (`,s.length,c?` of ${e.length}`:``,` events)`]})}),(0,R.jsx)(Sj,{events:e,filters:r,onFiltersChange:o}),s.length===0&&(0,R.jsx)(`div`,{className:Cj.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=wj[e.type]||`var(--text-3)`,r=e.data&&Object.keys(e.data).length>0;return(0,R.jsxs)(`details`,{className:Cj.event,style:{"--log-type-color":n},children:[(0,R.jsxs)(`summary`,{className:Cj.eventSummary,children:[(0,R.jsx)(`span`,{className:Cj.index,children:t}),(0,R.jsx)(`span`,{className:Cj.type,children:e.type}),(0,R.jsx)(`span`,{className:Cj.leader,children:e.leader}),e.data?.turn!=null&&(0,R.jsxs)(`span`,{className:Cj.turn,children:[`T`,String(e.data.turn)]}),!!e.data?.title&&(0,R.jsx)(`span`,{className:Cj.title,children:String(e.data.title)}),!!e.data?.department&&(0,R.jsx)(`span`,{className:Cj.department,children:String(e.data.department)}),!!e.data?.outcome&&(0,R.jsx)(`span`,{className:Cj.outcome,children:String(e.data.outcome)})]}),r&&(0,R.jsx)(`pre`,{className:Cj.dataBlock,children:JSON.stringify(e.data,null,2)})]},t)})]})}var Dj=[{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 Oj(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 Y={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`},kj=[{id:`config`,label:`Settings`},{id:`log`,label:`Event Log`}],Aj={openness:.5,conscientiousness:.5,extraversion:.5,agreeableness:.5,emotionality:.5,honestyHumility:.5},jj={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)`}]},Mj={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`}},Nj={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.`}},Pj=[`The Visionary`,`The Engineer`,`The Diplomat`,`The Maverick`,`The Guardian`,`The Strategist`,`The Steward`,`The Innovator`];function Fj(e,t){return{name:`Actor ${String.fromCharCode(65+e%26)}`,archetype:Pj[e]??`The Strategist`,unit:yn(t,e),instructions:``,hexaco:{...Aj}}}function Ij(e){let t=e.presets.find(e=>e.id==="default");return t?.leaders??t?.actors}function Lj(e,t,n,r,i){let a=Ij(n);return e.map((e,o)=>{let s=i[o],c=a?.[o],l=e.unit===yn(t,o);if(!c)return(a!==void 0&&r!==n.id||l)&&s?.unit===void 0?{...e,unit:yn(n,o)}:e;let u=r===n.id&&!!e.unit&&!l;return{name:c.name,archetype:c.archetype,unit:u?e.unit:c.unit??yn(n,o),instructions:c.instructions,hexaco:{...c.hexaco},...s}})}var Rj=2,zj=8;function Bj({events:e=[],initialSubTab:t=`config`}={}){let[n,r]=(0,L.useState)(t),i=(0,L.useCallback)(e=>{r(e),M_(e===`config`?null:e)},[]),a=fF(),o=mF(),s=i_(),c=vF(),l=bF(),u=typeof window<`u`?S(window.localStorage):null,[d]=(0,L.useState)(()=>typeof window<`u`?x(window.localStorage):null),[f,p]=(0,L.useState)(()=>{let e=Math.max(Rj,Math.min(zj,Math.max(Ij(a)?.length??0,u?.length??0)));return Lj(Array.from({length:e},(e,t)=>{let n=u?.[t];return n?.name?{name:n.name,archetype:n.archetype??``,unit:n.unit??yn(a,t),instructions:n.instructions??``,hexaco:{...n.hexaco??Aj}}:Fj(t,a)}),a,a,d,[])}),m=(0,L.useRef)([]),h=(0,L.useRef)(a);(0,L.useEffect)(()=>{let e=h.current;h.current=a,p(t=>Lj(t,e,a,d,m.current))},[a.id,a.presets.length]);let g=(0,L.useCallback)((e,t)=>{p(n=>n.map((n,r)=>{if(r!==e)return n;let i=Object.keys(t).filter(e=>t[e]!==n[e]);return m.current[e]={...m.current[e],...Object.fromEntries(i.map(e=>[e,t[e]]))},t}))},[]),_=(0,L.useCallback)(()=>{p(e=>e.length<zj?[...e,Fj(e.length,a)]:e)},[a]),v=(0,L.useCallback)(e=>{m.current.splice(e,1),p(t=>t.length>Rj?t.filter((t,n)=>n!==e):t)},[]),[b,C]=(0,L.useState)(a.setup.defaultTurns),[w,T]=(0,L.useState)(a.setup.defaultSeed),[k,ee]=(0,L.useState)(a.setup.defaultStartTime),[A,j]=(0,L.useState)(a.setup.defaultTimePerTurn||0),[M,N]=(0,L.useState)(a.setup.defaultPopulation),te=(0,L.useRef)(new Set);(0,L.useEffect)(()=>{let e=te.current;e.has(`turns`)||C(a.setup.defaultTurns),e.has(`seed`)||T(a.setup.defaultSeed),e.has(`startTime`)||ee(a.setup.defaultStartTime),e.has(`timePerTurn`)||j(a.setup.defaultTimePerTurn||0),e.has(`population`)||N(a.setup.defaultPopulation)},[a.id,a.setup.defaultTurns,a.setup.defaultSeed,a.setup.defaultStartTime,a.setup.defaultTimePerTurn,a.setup.defaultPopulation]);let[P,F]=(0,L.useState)(`openai`),[I,ne]=(0,L.useState)(!1),[re,z]=(0,L.useState)(`balanced`),[B,ie]=(0,L.useState)(!1),[ae,oe]=(0,L.useState)(``),[ce,V]=(0,L.useState)([]),[ue,de]=(0,L.useState)(a.id),[fe,pe]=(0,L.useState)({}),[me,he]=(0,L.useState)(!1),[_e,ve]=(0,L.useState)(!1),[ye,be]=(0,L.useState)(`local_demo`),[xe,Se]=(0,L.useState)({maxTurns:6,maxPopulation:30,maxActiveDepartments:3}),[Ce,we]=(0,L.useState)(E),[Te,Ee]=(0,L.useState)(null),[De,Oe]=(0,L.useState)(!1),[ke,Ae]=(0,L.useState)(``);function je(e,t){let n={...Ce,[e]:t};D(n),we(n),Ae(``)}async function Me(){Oe(!0),O(),we({}),Ae(``);try{if(!(await fetch(`/forget-keys`,{method:`POST`})).ok)throw Error(`Server cleanup failed`);Ae(`Keys forgotten. Your held run and chat agents have been cleared.`)}catch{Ae(`Keys cleared from this tab. Select Forget my keys again to retry server cleanup.`)}finally{Oe(!1)}}let[Ne,Pe]=(0,L.useState)(Mj[P]??Mj.openai);(0,L.useEffect)(()=>{let e=P;Mj[e]&&Pe(Mj[e])},[P]);let Fe=z_(Ce),Ie=!!fe.openai||!!fe.anthropic,Le=Fe||!me&&Ie,Re=Fe||!me&&Ie,ze=me&&!Fe?`economy`:re,Be=Oj(ye),Ve=me&&!Fe,He=Ve?`openai`:P,Ue=(0,L.useCallback)(()=>{fetch(`/scenarios`).then(e=>e.json()).then(e=>{V(e.scenarios||[]),de(e.active)}).catch(()=>{})},[]);(0,L.useEffect)(()=>(Ue(),fetch(`/admin-config`).then(e=>e.json()).then(e=>{e.keys&&pe(e.keys),typeof e.visitorKeyIdleMinutes==`number`&&Ee(e.visitorKeyIdleMinutes),typeof e.hostedDemo==`boolean`&&he(e.hostedDemo),typeof e.adminWrite==`boolean`&&ve(e.adminWrite),typeof e.serverMode==`string`&&be(e.serverMode),e.demoCaps&&typeof e.demoCaps.maxTurns==`number`&&Se({maxTurns:e.demoCaps.maxTurns,maxPopulation:e.demoCaps.maxPopulation??30,maxActiveDepartments:e.demoCaps.maxActiveDepartments??3})}).catch(()=>{}),se(window,Ue)),[Ue]);let We=async e=>{if(e!==ue)try{(await fetch(`/scenario/switch`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({id:e})})).ok&&(ge(),window.location.reload())}catch{}},Ge=(0,L.useCallback)(async()=>{if(o){ie(!0),oe(`Starting...`);try{let e={actors:f.map(e=>({...e,hexaco:e.hexaco})),provider:He,turns:b,seed:w,startTime:k,timePerTurn:A||void 0,population:M,liveSearch:I,activeDepartments:a.departments.map(e=>e.id),economics:{profileId:ze},scenarioId:a.id};try{localStorage.setItem(`paracosm:lastLaunchConfig`,JSON.stringify(e))}catch{}y(window.localStorage,f,a.id),Object.assign(e,R_(Ce)),Ce.serper&&(e.serperKey=Ce.serper),Ce.firecrawl&&(e.firecrawlKey=Ce.firecrawl),Ce.tavily&&(e.tavilyKey=Ce.tavily),Ce.cohere&&(e.cohereKey=Ce.cohere),Re&&(e.models={...Ne});let t=await fetch(`/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({...e,captureSnapshots:!0})}),n=await t.json();if(t.status===429){oe(`Rate limited: ${n.error||`too many simulations`}`),ie(!1);return}if(n.redirect){l(typeof n.runKey==`string`?n.runKey:void 0),oe(`Running...`),le(window,n.visitorId);let e=O_(N_(window.location.href,n.redirect));c(e===`about`?`sim`:e)}else oe(`Error: ${n.error||`unknown`}`),ie(!1)}catch(e){oe(`Failed: ${e}`),ie(!1)}}},[f,b,w,k,A,M,He,I,c,l,a,o,Ce,Ne,Re,ze]),Ke=e=>[Y.input,e?Y.locked:``].filter(Boolean).join(` `);return(0,R.jsxs)(`div`,{className:Y.root,children:[(0,R.jsx)(m_,{options:kj,active:n,onChange:i,ariaLabel:`Settings sub-navigation`}),n===`log`&&(0,R.jsx)(Ej,{events:e}),n===`config`&&(0,R.jsxs)(`div`,{className:`settings-content ${Y.content}`,children:[(0,R.jsx)(sA,{}),ce.length>0&&(0,R.jsxs)(`div`,{className:`responsive-stack ${Y.scenarioRow}`,children:[(0,R.jsx)(`label`,{htmlFor:`scenario-select`,style:sS,className:Y.scenarioLabel,children:`Scenario`}),(0,R.jsx)(`select`,{id:`scenario-select`,className:`pc-select ${Y.scenarioSelect}`,value:ue,onChange:e=>We(e.target.value),children:ce.map(e=>{let t=e.description?.includes(`(memory)`)?` [memory]`:e.description?.includes(`(disk)`)?` [disk]`:e.description?.includes(`compiled`)?` [compiled]`:``;return(0,R.jsxs)(`option`,{value:e.id,children:[e.id===ue?`● `:``,e.name,` (`,e.departments,` depts)`,t]},e.id)})}),(0,R.jsxs)(`span`,{className:Y.scenarioActiveTag,children:[`Active: `,(0,R.jsx)(`strong`,{className:Y.scenarioActiveValue,children:ue})]})]}),(0,R.jsx)(`h2`,{className:Y.h2,children:a.labels.name}),a.labels.tagline&&(0,R.jsx)(`p`,{className:Y.scenarioTagline,children:a.labels.tagline}),(0,R.jsxs)(`p`,{className:Y.lead,children:[`Configure your leaders and launch. `,a.departments.length,` departments: `,a.departments.map(e=>e.label).join(`, `),`.`]}),a.sourceUrl&&(0,R.jsx)(`p`,{className:Y.scenarioSourceLink,children:(0,R.jsx)(`a`,{href:a.sourceUrl,target:`_blank`,rel:`noopener noreferrer`,children:`View scenario JSON on GitHub →`})}),(0,R.jsxs)(`p`,{className:Y.leadHint,children:[`Server mode: `,(0,R.jsx)(`strong`,{className:Y.leadStrong,children:Be.label}),`. `,Be.description]}),(0,R.jsx)(`div`,{className:`${f.length>2?`responsive-grid-cohort`:`responsive-grid-2`} ${Y.leadersGrid}`,children:f.map((e,t)=>(0,R.jsxs)(`div`,{className:Y.leaderCardWrap,style:{position:`relative`},children:[(0,R.jsx)(lj,{label:`Commander ${String.fromCharCode(65+t%26)}`,sideColor:Xn(t),data:e,onChange:e=>g(t,e)}),f.length>Rj&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>v(t),className:Y.leaderRemoveBtn,"aria-label":`Remove ${e.name||`actor ${t+1}`} from the cohort`,title:`Remove this actor`,children:`✕`})]},t))}),(0,R.jsx)(`div`,{className:Y.leadersAddRow,children:f.length<zj?(0,R.jsxs)(`button`,{type:`button`,onClick:_,className:Y.leaderAddBtn,"aria-label":`Add another actor to the cohort`,children:[`+ Add actor (`,f.length,`/`,zj,`)`]}):(0,R.jsxs)(`span`,{className:Y.leaderAddCap,children:[`Max `,zj,` actors from Settings · use Quickstart's generate-N flow for larger cohorts.`]})}),(0,R.jsxs)(`fieldset`,{className:Y.fieldset,children:[(0,R.jsx)(`legend`,{style:cS,className:Y.legend,children:`Simulation`}),Ve&&(0,R.jsxs)(`div`,{className:Y.demoBanner,children:[(0,R.jsx)(`strong`,{className:Y.demoBannerLabel,children:`Demo caps will apply:`}),` `,`turns clamped to `,xe.maxTurns,`, population to `,xe.maxPopulation,`, active departments to `,xe.maxActiveDepartments,`. Values you enter below are honored up to those ceilings. Add a session API key above to lift the caps.`]}),(0,R.jsxs)(`div`,{className:`responsive-grid-4 ${Y.simRow5}`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`label`,{htmlFor:`turns-input`,style:sS,children:[`Turns`,Ve&&(0,R.jsxs)(`span`,{className:Y.lockTag,title:`Hosted demo caps turns at ${xe.maxTurns}. Add a session API key to unlock.`,children:[`🔒 demo:`,xe.maxTurns]})]}),(0,R.jsx)(`input`,{id:`turns-input`,type:`number`,value:Ve?xe.maxTurns:b,onChange:e=>{te.current.add(`turns`),C(parseInt(e.target.value)||a.setup.defaultTurns)},min:1,max:20,disabled:Ve,className:Ke(Ve),title:Ve?`Locked at ${xe.maxTurns} in hosted demo mode. Add your own OpenAI or Anthropic key above to unlock full scope.`:``})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`label`,{htmlFor:`ypt-input`,style:sS,children:[s.Times,`/Turn`]}),(0,R.jsx)(`input`,{id:`ypt-input`,type:`number`,value:A,onChange:e=>{te.current.add(`timePerTurn`),j(parseInt(e.target.value)||0)},min:0,max:50,placeholder:`auto`,title:`${s.Times} per turn. 0 = accelerating schedule (default). 1 = 1 ${s.time} per turn. 5 = 5 ${s.times} per turn.`,className:Y.input})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`seed-input`,style:sS,children:`Seed`}),(0,R.jsx)(`input`,{id:`seed-input`,type:`number`,value:w,onChange:e=>{te.current.add(`seed`),T(parseInt(e.target.value)||a.setup.defaultSeed)},className:Y.input})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`label`,{htmlFor:`time-input`,style:sS,children:[`Start `,s.Time]}),(0,R.jsx)(`input`,{id:`time-input`,type:`number`,value:k,onChange:e=>{te.current.add(`startTime`),ee(parseInt(e.target.value)||a.setup.defaultStartTime)},className:Y.input})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`label`,{htmlFor:`pop-input`,style:sS,children:[`Population`,Ve&&(0,R.jsx)(`span`,{className:Y.lockTag,title:`Hosted demo caps population at 30. Add a session API key to unlock.`,children:`🔒 demo:30`})]}),(0,R.jsx)(`input`,{id:`pop-input`,type:`number`,value:Ve?30:M,onChange:e=>{te.current.add(`population`),N(parseInt(e.target.value)||a.setup.defaultPopulation)},disabled:Ve,className:Ke(Ve),title:Ve?`Locked at 30 in hosted demo mode. Add your own OpenAI or Anthropic key above to unlock full scope.`:``})]})]}),(0,R.jsxs)(`div`,{className:`responsive-grid-3 ${Y.grid3}`,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`label`,{htmlFor:`provider-select`,style:sS,children:[`Provider`,Ve&&(0,R.jsx)(`span`,{className:Y.lockTag,children:`🔒 demo:openai`})]}),(0,R.jsxs)(`select`,{id:`provider-select`,className:`pc-select ${Ke(Ve)}`,value:He,onChange:e=>F(e.target.value),disabled:Ve,title:Ve?`Locked to OpenAI in hosted demo mode. Add your own OpenAI or Anthropic key above to choose the provider.`:``,children:[(0,R.jsx)(`option`,{value:`openai`,children:`OpenAI`}),(0,R.jsx)(`option`,{value:`anthropic`,children:`Anthropic`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`search-select`,style:sS,children:`Live Search`}),(0,R.jsxs)(`select`,{id:`search-select`,className:`pc-select ${Y.input}`,value:String(I),onChange:e=>ne(e.target.value===`true`),children:[(0,R.jsx)(`option`,{value:`false`,children:`Off`}),(0,R.jsx)(`option`,{value:`true`,children:`On (requires search API keys)`})]})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`label`,{htmlFor:`economics-select`,style:sS,children:[`Economics`,Ve&&(0,R.jsx)(`span`,{className:Y.lockTag,children:`🔒 forced:economy`})]}),(0,R.jsx)(`select`,{id:`economics-select`,className:`pc-select ${Ke(Ve)}`,value:ze,onChange:e=>z(e.target.value),disabled:Ve,title:Dj.find(e=>e.value===ze)?.description,children:Dj.map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,R.jsx)(`div`,{className:Y.fieldHint,children:Dj.find(e=>e.value===ze)?.description})]})]})]}),(0,R.jsxs)(`fieldset`,{className:Y.fieldset,children:[(0,R.jsx)(`legend`,{style:cS,className:Y.legend,children:`API Keys`}),(0,R.jsxs)(`div`,{className:Y.keysIntro,children:[(0,R.jsxs)(`p`,{className:Y.keysIntroPara,children:[(0,R.jsx)(`strong`,{className:Y.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,R.jsxs)(`p`,{className:Y.keysIntroPara,children:[(0,R.jsx)(`strong`,{className:Y.keysIntroBoldGreen,children:`Rate limiting:`}),` The hosted demo limits simulations per IP per day when using the server's API keys. Provide your own `,(0,R.jsx)(`strong`,{children:`OpenAI`}),` or `,(0,R.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,R.jsxs)(`p`,{className:Y.keysIntroPara,children:[(0,R.jsx)(`strong`,{className:Y.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,R.jsxs)(`p`,{className:Y.keysIntroParaLast,children:[(0,R.jsx)(`strong`,{className:Y.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.`]})]}),(0,R.jsx)(`div`,{className:`responsive-grid-2 ${Y.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,R.jsxs)(`div`,{children:[(0,R.jsxs)(`label`,{htmlFor:`key-${e}`,style:sS,children:[t,fe[e]&&(0,R.jsx)(`span`,{className:Y.keyEnvTag,children:`(.env active)`})]}),(0,R.jsx)(`input`,{id:`key-${e}`,type:`password`,autoComplete:`off`,"data-clarity-mask":`True`,value:Ce[e]??``,disabled:De,onChange:t=>je(e,t.target.value),placeholder:fe[e]?`Using .env value`:`Not configured`,className:`${Y.input} ph-no-capture ph-mask`}),(0,R.jsx)(`div`,{className:Y.fieldHint,children:n})]},e))}),(0,R.jsx)(`button`,{type:`button`,className:Y.leaderAddBtn,disabled:De,onClick:Me,children:`Forget my keys`}),ke&&(0,R.jsx)(`p`,{className:Y.fieldHint,role:`status`,children:ke}),(0,R.jsxs)(`div`,{className:Y.keysIntro,"data-testid":`visitor-key-notes`,children:[(0,R.jsx)(`p`,{className:Y.keysIntroPara,children:`Runs on your key are billed to your OpenAI or Anthropic account, under your agreement with them.`}),Te!==null&&(0,R.jsxs)(`p`,{className:Y.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 `,Te,` minutes at most after you stop, and is never written to disk or to a log.`]}),(0,R.jsx)(`p`,{className:Y.keysIntroPara,children:`This browser tab keeps your key until you close it. "Forget my keys" removes it now.`}),(0,R.jsx)(`p`,{className:Y.keysIntroPara,children:`Use a separate key with a spending limit, and delete it at your provider when you are done.`}),(0,R.jsxs)(`p`,{className:Y.keysIntroParaLast,children:[`Or `,(0,R.jsx)(`a`,{href:`/#get-started`,children:`run paracosm on your own computer`}),`, and your key never leaves it.`]})]})]}),Le&&(P===`openai`||P===`anthropic`)&&(0,R.jsxs)(`fieldset`,{className:Y.fieldset,children:[(0,R.jsx)(`legend`,{style:cS,className:Y.legend,children:`Model Tiers`}),(0,R.jsx)(`div`,{className:Y.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,R.jsx)(`div`,{className:`responsive-grid-2 ${Y.grid2}`,children:Object.keys(Nj).map(e=>(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:`model-${e}`,style:sS,children:Nj[e].label}),(0,R.jsx)(`select`,{id:`model-${e}`,className:`pc-select ${Y.input}`,value:Ne[e],onChange:t=>Pe(n=>({...n,[e]:t.target.value})),children:jj[P].map(e=>(0,R.jsx)(`option`,{value:e.value,children:e.label},e.value))}),(0,R.jsx)(`div`,{className:Y.fieldHint,children:Nj[e].help})]},e))})]}),!Le&&(0,R.jsxs)(`div`,{className:Y.demoMode,children:[(0,R.jsx)(`strong`,{className:Y.demoModeStrong,children:`Demo mode.`}),` `,me?`Runs against the host API keys are capped to ${xe.maxTurns} turns, ${xe.maxPopulation} colonists, ${xe.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,R.jsxs)(`fieldset`,{className:Y.fieldset,children:[(0,R.jsx)(`legend`,{style:cS,className:Y.legend,children:`Admin Token`}),(0,R.jsx)(yj,{})]}),(0,R.jsx)(gj,{onAdminWrite:ve}),(0,R.jsxs)(`div`,{className:`responsive-stack ${Y.launchRow}`,children:[(0,R.jsx)(`button`,{onClick:Ge,disabled:B||!o,"aria-label":B?`Simulation running`:o?`Launch simulation`:`Loading scenario`,className:Y.launchBtn,children:B?`Running...`:o?`Launch Simulation`:`Loading scenario…`}),ae&&(0,R.jsx)(`span`,{role:`status`,className:Y.launchStatus,children:ae})]})]})]})}function Vj(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 Hj(e,t=[]){return[...(e.presets?.[0]?.leaders??[]).map(e=>({name:e.name,archetype:e.archetype,unit:`Forked Branch`,hexaco:Vj(e.hexaco),instructions:e.instructions})),...t]}var Uj={openai:{quality:.3,economy:.1},anthropic:{quality:.75,economy:.6}};function Wj(e,t,n,r){let i=Math.max(0,t-e)*Uj[r][n];return`~$${(Math.ceil(i*10)/10).toFixed(2)}`}function Gj(e){let t=[];for(let n of e.split(`
|
|
127
|
+
`)){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 Kj=new Set([`kernelSnapshotAtStart`,`kernelSnapshotsAfterProgression`]);function qj(e){let t=e.scenarioExtensions;if(!t||typeof t!=`object`)return e;let n=Object.fromEntries(Object.entries(t).filter(([e])=>!Kj.has(e)));return{...e,scenarioExtensions:n}}function Jj(e){let t=e.scenarioExtensions?.kernelSnapshotsPerTurn;return Array.isArray(t)?t.map(e=>e?.turn).filter(e=>typeof e==`number`&&Number.isFinite(e)):[]}function Yj(e){let t=e.trajectory?.timepoints?.length??0,n=Jj(e),r=Math.max(t,...n);return r>0?r:6}function Xj(e,t){return Jj(e).includes(t)&&t<Yj(e)}var Zj={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`};function Qj(e){let{parentArtifact:t,atTurn:n,maxTurns:r,costPreset:i,provider:a,sessionCustomLeaders:o=[],onConfirm:s,onClose:c}=e,l=fF(),u=i_(),d=Qr(!0),f=Hj(l,o),[p,m]=(0,L.useState)(0),[h,g]=(0,L.useState)(``),[_,v]=(0,L.useState)(``);(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&c()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c]);let y=Wj(n,r,i,a),b=Math.max(0,r-n),x=t.metadata.seed;return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-labelledby":`fork-modal-title`,className:Zj.backdrop,onClick:c,children:(0,R.jsxs)(`div`,{ref:d,tabIndex:-1,className:Zj.dialog,onClick:e=>e.stopPropagation(),children:[(0,R.jsxs)(`header`,{className:Zj.header,children:[(0,R.jsxs)(`h3`,{id:`fork-modal-title`,children:[`Fork at `,u.Time,` `,n]}),(0,R.jsx)(`button`,{type:`button`,className:Zj.closeButton,onClick:c,"aria-label":`Close fork modal`,children:`×`})]}),(0,R.jsxs)(`div`,{className:Zj.field,children:[(0,R.jsx)(`label`,{htmlFor:`fork-leader-select`,children:`Override leader`}),f.length===0?(0,R.jsx)(`p`,{className:Zj.warning,children:`No preset leaders available for this scenario. Add leaders in Settings or pick a scenario with presets to continue.`}):(0,R.jsx)(`select`,{id:`fork-leader-select`,value:p,onChange:e=>m(parseInt(e.target.value,10)),children:f.map((e,t)=>(0,R.jsxs)(`option`,{value:t,children:[e.name,` (`,e.archetype,`)`]},`${e.name}-${t}`))})]}),(0,R.jsxs)(`div`,{className:Zj.field,children:[(0,R.jsx)(`label`,{htmlFor:`fork-seed`,children:`Seed override (optional)`}),(0,R.jsx)(`input`,{id:`fork-seed`,type:`number`,placeholder:x===void 0?`(use parent seed)`:`Parent seed: ${x}`,value:h,onChange:e=>g(e.target.value)}),(0,R.jsx)(`span`,{className:Zj.hint,children:`Leave blank to resume from the parent's RNG state.`})]}),(0,R.jsxs)(`details`,{className:Zj.advanced,children:[(0,R.jsx)(`summary`,{children:`Advanced: custom events`}),(0,R.jsx)(`textarea`,{rows:4,placeholder:`One event per line, format: "turn: title: description"
|
|
128
|
+
Example: 5: Supply drop: Relief arrives with 3 months of food.`,value:_,onChange:e=>v(e.target.value)})]}),(0,R.jsxs)(`div`,{className:Zj.costEstimate,role:`status`,children:[(0,R.jsx)(`span`,{children:`Estimated cost`}),(0,R.jsx)(`strong`,{children:y}),(0,R.jsxs)(`span`,{className:Zj.costDetail,children:[`for `,b,` more `,b===1?u.time:u.times]})]}),(0,R.jsxs)(`footer`,{className:Zj.footer,children:[(0,R.jsx)(`button`,{type:`button`,onClick:c,className:Zj.cancelButton,children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let e=f[p];if(!e)return;let r=h.trim()?parseInt(h,10):void 0,i=r!==void 0&&Number.isFinite(r)?r:void 0,a=_.trim()?Gj(_):void 0;s({parentArtifact:t,atTurn:n,leader:e,seedOverride:i,customEvents:a})},disabled:f.length===0,className:Zj.confirmButton,children:`Fork`})]})]})})}var $j=`/retry-stats`;function eM(e=!0){let[t,n]=(0,L.useState)(null),[r,i]=(0,L.useState)(!1),[a,o]=(0,L.useState)(null),s=(0,L.useCallback)(async()=>{i(!0),o(null);try{let e=await fetch($j,{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,L.useEffect)(()=>{e&&s()},[e,s]),{data:t,loading:r,error:a,refresh:s}}var X={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`},tM={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 nM(e){return e<1e-4?`$0.0000`:`$${e<.01?e.toFixed(4):e.toFixed(2)}`}function rM(e){return e>=1e6?`${(e/1e6).toFixed(2)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function iM(e){return e>1.5?`var(--rust)`:e>1.1?`var(--amber)`:`var(--text-1)`}function aM(e){return e>.01?`var(--rust)`:e>0?`var(--amber)`:`var(--text-3)`}function oM({combined:e,leaderA:t,leaderB:n,leaderAName:r,leaderBName:i,actors:a,onClose:o}){(0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o]);let s=Qr(!0),c=eM(!0),l=e.breakdown??{},u=Object.entries(l).map(([e,t])=>({site:e,...t})).sort((e,t)=>t.totalCostUSD-e.totalCostUSD),d=e.totalCostUSD||u.reduce((e,t)=>e+t.totalCostUSD,0),f=u[0]?.totalCostUSD??0;return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Cost breakdown`,onClick:o,className:X.backdrop,children:(0,R.jsxs)(`div`,{ref:s,tabIndex:-1,onClick:e=>e.stopPropagation(),className:X.dialog,children:[(0,R.jsxs)(`div`,{className:X.titleRow,children:[(0,R.jsx)(`h3`,{className:X.title,children:`COST BREAKDOWN`}),(0,R.jsx)(`button`,{onClick:o,"aria-label":`Close cost breakdown`,className:X.escBtn,children:`ESC`})]}),(0,R.jsxs)(`div`,{className:X.totalLine,children:[`Total: `,(0,R.jsx)(`span`,{className:X.totalAmount,children:nM(d)}),` · `,e.llmCalls.toLocaleString(),` calls`,` · `,rM(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 ${nM(r)} via prompt caching`):r<-.001?(o=`var(--amber)`,s=`Cache priming cost ${nM(-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,R.jsxs)(`div`,{className:X.cacheBlock,children:[(0,R.jsx)(`div`,{className:X.cacheLabel,children:`PROMPT CACHING`}),(0,R.jsx)(`div`,{className:X.cacheVerdict,style:{"--cache-verdict-color":o},children:s}),(0,R.jsxs)(`div`,{className:X.cacheSubLine,children:[Math.round(a*100),`% hit rate on cached input (`,rM(t),` reused / `,rM(i),` cache tokens)`]}),(0,R.jsxs)(`div`,{className:X.cacheTokenRow,children:[(0,R.jsxs)(`span`,{children:[`reads `,rM(t),` `,(0,R.jsx)(`span`,{className:X.cacheMultiplier,children:`@0.10×`})]}),(0,R.jsxs)(`span`,{children:[`creates `,rM(n),` `,(0,R.jsx)(`span`,{className:X.cacheMultiplier,children:`@1.25×`})]})]})]})})():null,u.length===0?(0,R.jsx)(`div`,{className:X.emptyState,children:`No LLM calls have been billed yet. Start a simulation to see spend by pipeline stage.`}):(0,R.jsxs)(`table`,{className:X.table,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:X.headRow,children:[(0,R.jsx)(`th`,{className:X.th,children:`STAGE`}),(0,R.jsx)(`th`,{className:X.thRight,children:`CALLS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`TOKENS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`COST`}),(0,R.jsx)(`th`,{className:X.thRight,children:`%`})]})}),(0,R.jsx)(`tbody`,{children:u.map(e=>{let t=tM[e.site]??{label:e.site,description:``},n=d>0?e.totalCostUSD/d*100:0,r=f>0?e.totalCostUSD/f*100:0;return(0,R.jsxs)(`tr`,{className:X.bodyRow,children:[(0,R.jsxs)(`td`,{className:X.stageCell,children:[(0,R.jsx)(`div`,{className:X.stageLabel,children:t.label}),(0,R.jsx)(`div`,{className:X.stageDescription,children:t.description}),(0,R.jsx)(`div`,{"aria-hidden":`true`,className:X.bar,children:(0,R.jsx)(`div`,{className:X.barFill,style:{"--bar-pct":`${r}%`}})})]}),(0,R.jsx)(`td`,{className:X.numericCell,children:e.calls.toLocaleString()}),(0,R.jsx)(`td`,{className:X.numericCell,children:rM(e.totalTokens)}),(0,R.jsx)(`td`,{className:X.numericCellGreen,children:nM(e.totalCostUSD)}),(0,R.jsxs)(`td`,{className:X.numericCellMuted,children:[n.toFixed(0),`%`]})]},e.site)})})]}),e.schemaRetries&&Object.keys(e.schemaRetries).length>0&&(0,R.jsxs)(`div`,{className:X.section,children:[(0,R.jsx)(`div`,{className:X.sectionLabel,children:`SCHEMA RELIABILITY`}),(0,R.jsxs)(`table`,{className:X.tableSm,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:X.headRow,children:[(0,R.jsx)(`th`,{className:X.th,children:`SCHEMA`}),(0,R.jsx)(`th`,{className:X.thRight,children:`CALLS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`AVG ATTEMPTS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`FALLBACKS`})]})}),(0,R.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=iM(n),i=t.fallbacks>0?`var(--rust)`:`var(--text-3)`;return(0,R.jsxs)(`tr`,{className:X.bodyRow,children:[(0,R.jsx)(`td`,{className:X.cellSchemaName,children:e}),(0,R.jsx)(`td`,{className:X.cellNumericTight,children:t.calls}),(0,R.jsx)(`td`,{className:X.cellAvgAttempts,style:{"--avg-color":r},children:n.toFixed(2)}),(0,R.jsx)(`td`,{className:X.cellFallback,style:{"--fb-color":i,"--fb-weight":t.fallbacks>0?`700`:`400`},children:t.fallbacks})]},e)})})]}),(0,R.jsxs)(`div`,{className:X.sectionFootnote,children:[`1.00 = first-try success. Higher = model retrying on validation failures. Tune `,(0,R.jsx)(`code`,{className:`mono`,children:`maxRetries`}),` or tighten schema if a row stays above 1.3.`]})]}),e.forgeStats&&e.forgeStats.attempts>0&&(0,R.jsxs)(`div`,{className:X.section,children:[(0,R.jsx)(`div`,{className:X.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,R.jsxs)(`table`,{className:X.tableSm,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:X.headRow,children:[(0,R.jsx)(`th`,{className:X.thRight,children:`ATTEMPTS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`APPROVED`}),(0,R.jsx)(`th`,{className:X.thRight,children:`REJECTED`}),(0,R.jsx)(`th`,{className:X.thRight,children:`APPROVAL RATE`}),(0,R.jsx)(`th`,{className:X.thRight,children:`AVG CONF`})]})}),(0,R.jsx)(`tbody`,{children:(0,R.jsxs)(`tr`,{className:X.bodyRow,children:[(0,R.jsx)(`td`,{className:X.cellRight1,children:t.attempts}),(0,R.jsx)(`td`,{className:X.cellRightGreen,children:t.approved}),(0,R.jsx)(`td`,{className:t.rejected>0?X.cellRightRust:X.cellRightMuted,children:t.rejected}),(0,R.jsxs)(`td`,{className:X.cellRateColor,style:{"--rate-color":i},children:[(n*100).toFixed(0),`%`]}),(0,R.jsx)(`td`,{className:X.cellConfColor,style:{"--conf-color":a},children:r>0?r.toFixed(2):`—`})]})})]})})(),(0,R.jsx)(`div`,{className:X.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,R.jsx)(`div`,{className:X.statusInline,children:`RECENT RUNS — loading…`});if(c.error)return(0,R.jsxs)(`div`,{className:X.statusInline,children:[`RECENT RUNS — `,(0,R.jsxs)(`span`,{className:X.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=iM(t.avgAttempts),r=aM(t.fallbackRate);return(0,R.jsxs)(`tr`,{className:X.bodyRow,children:[(0,R.jsx)(`td`,{className:X.cellSchemaName,children:e}),(0,R.jsx)(`td`,{className:X.cellNumericTight,children:t.calls}),(0,R.jsx)(`td`,{className:X.cellAvgAttempts,style:{"--avg-color":n},children:t.avgAttempts.toFixed(2)}),(0,R.jsxs)(`td`,{className:X.cellFallback,style:{"--fb-color":r,"--fb-weight":t.fallbacks>0?`700`:`400`},children:[(t.fallbackRate*100).toFixed(2),`%`]})]},e)};return(0,R.jsxs)(`div`,{className:X.section,children:[(0,R.jsxs)(`div`,{className:X.sectionLabel,children:[`RECENT RUNS (last `,e.runCount,`)`]}),t.length>0&&(0,R.jsxs)(`div`,{className:X.subBlock,children:[(0,R.jsx)(`div`,{className:X.subBlockLabel,children:`RUNTIME SCHEMAS`}),(0,R.jsxs)(`table`,{className:X.tableSm,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:X.headRow,children:[(0,R.jsx)(`th`,{className:X.th,children:`SCHEMA`}),(0,R.jsx)(`th`,{className:X.thRight,children:`CALLS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`AVG ATT`}),(0,R.jsx)(`th`,{className:X.thRight,children:`FALLBACK %`})]})}),(0,R.jsx)(`tbody`,{children:t.sort((e,t)=>t[1].calls-e[1].calls).map(o)})]})]}),n.length>0&&(0,R.jsxs)(`div`,{className:X.subBlock,children:[(0,R.jsx)(`div`,{className:X.subBlockLabel,children:`COMPILE HOOKS`}),(0,R.jsxs)(`table`,{className:X.tableSm,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:X.headRow,children:[(0,R.jsx)(`th`,{className:X.th,children:`HOOK`}),(0,R.jsx)(`th`,{className:X.thRight,children:`CALLS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`AVG ATT`}),(0,R.jsx)(`th`,{className:X.thRight,children:`FALLBACK %`})]})}),(0,R.jsx)(`tbody`,{children:n.sort((e,t)=>t[1].calls-e[1].calls).map(o)})]})]}),r&&r.runsPresent>0&&(0,R.jsxs)(`div`,{className:X.subBlock,children:[(0,R.jsx)(`div`,{className:X.subBlockLabel,children:`FORGES`}),(0,R.jsxs)(`table`,{className:X.tableSm,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:X.headRow,children:[(0,R.jsx)(`th`,{className:X.thRight,children:`RUNS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`ATTEMPTS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`ATTEMPT RATE`}),(0,R.jsx)(`th`,{className:X.thRight,children:`UNIQUE TOOLS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`EVENTUALLY APPROVED`}),(0,R.jsx)(`th`,{className:X.thRight,children:`TERMINAL FAILS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`AVG CONF`})]})}),(0,R.jsx)(`tbody`,{children:(0,R.jsxs)(`tr`,{className:X.bodyRow,children:[(0,R.jsx)(`td`,{className:X.cellRight1,children:r.runsPresent}),(0,R.jsx)(`td`,{className:X.cellRight1,children:r.totalAttempts}),(0,R.jsxs)(`td`,{className:X.cellRateColor,style:{"--rate-color":r.approvalRate<.5?`var(--rust)`:r.approvalRate<.75?`var(--amber)`:`var(--green)`},children:[(r.approvalRate*100).toFixed(1),`%`]}),(0,R.jsx)(`td`,{className:X.cellRight1,children:r.totalUniqueNames}),(0,R.jsxs)(`td`,{className:X.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,R.jsx)(`td`,{className:X.cellFallback,style:{"--fb-color":r.totalUniqueTerminalRejections>0?`var(--rust)`:`var(--text-3)`,"--fb-weight":r.totalUniqueTerminalRejections>0?`700`:`400`},children:r.totalUniqueTerminalRejections}),(0,R.jsx)(`td`,{className:X.cellRight1,style:{fontWeight:700},children:r.avgApprovedConfidence>0?r.avgApprovedConfidence.toFixed(2):`—`})]})})]}),(0,R.jsx)(`div`,{className:X.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,R.jsxs)(`div`,{className:X.rejectionWrap,children:[(0,R.jsxs)(`div`,{className:X.rejectionLabel,children:[`REJECTION REASONS (last `,r.runsPresent,` run`,r.runsPresent===1?``:`s`,`)`]}),(0,R.jsxs)(`table`,{className:X.tableSm,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:X.headRow,children:[(0,R.jsx)(`th`,{className:X.thRight,children:`SCHEMA EXTRA FIELD`}),(0,R.jsx)(`th`,{className:X.thRight,children:`SHAPE CHECK`}),(0,R.jsx)(`th`,{className:X.thRight,children:`PARSE ERROR`}),(0,R.jsx)(`th`,{className:X.thRight,children:`JUDGE CORRECTNESS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`OTHER`})]})}),(0,R.jsx)(`tbody`,{children:(0,R.jsxs)(`tr`,{className:X.bodyRow,children:[(0,R.jsxs)(`td`,{className:X.rejectionCell,style:i(e.schema_extra_field,`var(--amber)`),children:[e.schema_extra_field,` (`,n(e.schema_extra_field),`%)`]}),(0,R.jsxs)(`td`,{className:X.rejectionCell,style:i(e.shape_check,`var(--amber)`),children:[e.shape_check,` (`,n(e.shape_check),`%)`]}),(0,R.jsxs)(`td`,{className:X.rejectionCell,style:i(e.parse_error,`var(--rust)`),children:[e.parse_error,` (`,n(e.parse_error),`%)`]}),(0,R.jsxs)(`td`,{className:X.rejectionCell,style:i(e.judge_correctness,`var(--rust)`),children:[e.judge_correctness,` (`,n(e.judge_correctness),`%)`]}),(0,R.jsxs)(`td`,{className:X.cellRightMuted,children:[e.other,` (`,n(e.other),`%)`]})]})})]}),(0,R.jsx)(`div`,{className:X.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,R.jsxs)(`div`,{className:X.subBlock,children:[(0,R.jsx)(`div`,{className:X.subBlockLabel,children:`PROVIDER ERRORS`}),(0,R.jsxs)(`table`,{className:X.tableSm,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:X.headRow,children:[(0,R.jsx)(`th`,{className:X.thRight,children:`RUNS W/ ERRORS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`TOTAL`}),(0,R.jsx)(`th`,{className:X.thRight,children:`AUTH`}),(0,R.jsx)(`th`,{className:X.thRight,children:`QUOTA`}),(0,R.jsx)(`th`,{className:X.thRight,children:`RATE`}),(0,R.jsx)(`th`,{className:X.thRight,children:`NET`}),(0,R.jsx)(`th`,{className:X.thRight,children:`OTHER`})]})}),(0,R.jsx)(`tbody`,{children:(0,R.jsxs)(`tr`,{className:X.bodyRow,children:[(0,R.jsx)(`td`,{className:X.cellRight1,children:a.runsPresent}),(0,R.jsx)(`td`,{className:X.cellRight1,style:{fontWeight:700},children:a.total}),(0,R.jsx)(`td`,{className:X.cellFallback,style:{"--fb-color":a.auth>0?`var(--rust)`:`var(--text-3)`,"--fb-weight":a.auth>0?`700`:`400`},children:a.auth}),(0,R.jsx)(`td`,{className:X.cellFallback,style:{"--fb-color":a.quota>0?`var(--rust)`:`var(--text-3)`,"--fb-weight":a.quota>0?`700`:`400`},children:a.quota}),(0,R.jsx)(`td`,{className:a.rate_limit>0?X.cellFallback:X.cellRightMuted,style:a.rate_limit>0?{"--fb-color":`var(--amber)`,"--fb-weight":`400`}:void 0,children:a.rate_limit}),(0,R.jsx)(`td`,{className:a.network>0?X.cellFallback:X.cellRightMuted,style:a.network>0?{"--fb-color":`var(--amber)`,"--fb-weight":`400`}:void 0,children:a.network}),(0,R.jsx)(`td`,{className:a.unknown>0?X.cellFallback:X.cellRightMuted,style:a.unknown>0?{"--fb-color":`var(--amber)`,"--fb-weight":`400`}:void 0,children:a.unknown})]})})]}),(0,R.jsx)(`div`,{className:X.sectionFootnoteTight,children:`AUTH/QUOTA are terminal (run aborts). RATE/NET/OTHER are non-terminal — the retry layer handles them.`})]}),i&&i.runsPresent>0&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:X.subBlockLabel,children:`PROMPT CACHE`}),(0,R.jsxs)(`table`,{className:X.tableSm,children:[(0,R.jsx)(`thead`,{children:(0,R.jsxs)(`tr`,{className:X.headRow,children:[(0,R.jsx)(`th`,{className:X.thRight,children:`RUNS WITH CACHE`}),(0,R.jsx)(`th`,{className:X.thRight,children:`READ TOKENS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`CREATE TOKENS`}),(0,R.jsx)(`th`,{className:X.thRight,children:`READ RATIO`}),(0,R.jsx)(`th`,{className:X.thRight,children:`SAVINGS`})]})}),(0,R.jsx)(`tbody`,{children:(0,R.jsxs)(`tr`,{className:X.bodyRow,children:[(0,R.jsx)(`td`,{className:X.cellRight1,children:i.runsPresent}),(0,R.jsx)(`td`,{className:X.cellRight1,children:rM(i.totalReadTokens)}),(0,R.jsx)(`td`,{className:X.cellNumericTight,children:rM(i.totalCreationTokens)}),(0,R.jsxs)(`td`,{className:X.cellRateColor,style:{"--rate-color":i.readRatio>=.7?`var(--green)`:i.readRatio>=.4?`var(--amber)`:`var(--rust)`},children:[(i.readRatio*100).toFixed(0),`%`]}),(0,R.jsx)(`td`,{className:X.cellRateColor,style:{"--rate-color":i.totalSavingsUSD>0?`var(--green)`:`var(--text-2)`},children:nM(i.totalSavingsUSD)})]})})]}),(0,R.jsx)(`div`,{className:X.sectionFootnoteTight,children:`Read ratio >= 70% is healthy. Lower ratios mean the cache keeps getting invalidated.`})]})]})})(),a&&a.length>2&&(0,R.jsxs)(`div`,{className:X.section,children:[(0,R.jsxs)(`div`,{className:X.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,R.jsx)(`div`,{className:X.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,R.jsxs)(`div`,{className:X.perActorRow,children:[(0,R.jsxs)(`div`,{className:X.perActorRank,children:[`#`,r+1]}),(0,R.jsx)(`div`,{className:X.perActorName,title:e.name,children:e.name}),(0,R.jsx)(`div`,{className:X.perActorBarTrack,"aria-hidden":`true`,children:(0,R.jsx)(`div`,{className:X.perActorBarFill,style:{width:`${i}%`}})}),(0,R.jsx)(`div`,{className:X.perActorCost,children:nM(e.cost.totalCostUSD)}),(0,R.jsxs)(`div`,{className:X.perActorMeta,children:[e.cost.llmCalls,` calls · `,rM(e.cost.totalTokens),` tok · `,a.toFixed(1),`%`]})]},e.actorId)})})})()]}),t&&n&&(t.totalCostUSD>0||n.totalCostUSD>0)&&(0,R.jsxs)(`div`,{className:X.section,children:[(0,R.jsx)(`div`,{className:X.sectionLabel,children:`PER LEADER`}),(0,R.jsxs)(`div`,{className:X.perLeaderRow,children:[(0,R.jsxs)(`div`,{className:X.leaderCard,children:[(0,R.jsx)(`div`,{className:X.leaderName,style:{"--leader-color":`var(--vis)`},children:r||`Leader A`}),(0,R.jsx)(`div`,{className:X.leaderCost,children:nM(t.totalCostUSD)}),(0,R.jsxs)(`div`,{className:X.leaderMeta,children:[t.llmCalls,` calls · `,rM(t.totalTokens),` tok`]})]}),(0,R.jsxs)(`div`,{className:X.leaderCard,children:[(0,R.jsx)(`div`,{className:X.leaderName,style:{"--leader-color":`var(--eng)`},children:i||`Leader B`}),(0,R.jsx)(`div`,{className:X.leaderCost,children:nM(n.totalCostUSD)}),(0,R.jsxs)(`div`,{className:X.leaderMeta,children:[n.llmCalls,` calls · `,rM(n.totalTokens),` tok`]})]})]})]})]})})}var sM={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`},cM=[`openness`,`conscientiousness`,`extraversion`,`agreeableness`,`emotionality`,`honestyHumility`],lM={openness:`var(--side-a, #e8b44a)`,conscientiousness:`var(--teal, #4ca8a8)`,extraversion:`#c44a1e`,agreeableness:`#6b9a6b`,emotionality:`#a86cb5`,honestyHumility:`#d2b48c`},uM={openness:`O`,conscientiousness:`C`,extraversion:`E`,agreeableness:`A`,emotionality:`Em`,honestyHumility:`HH`};function dM(e){if(e){for(let t of[`openness`,`conscientiousness`,`extraversion`,`agreeableness`,`emotionality`,`honestyHumility`])if(typeof e[t]!=`number`)return;return e}}function fM(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 pM({events:e,actorName:t,baselineHexaco:n}){let r=dM(n),i=fM(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,R.jsxs)(`div`,{className:sM.card,children:[(0,R.jsxs)(`div`,{className:sM.headerRow,children:[(0,R.jsx)(`span`,{className:sM.title,children:`PERSONALITY ARC`}),(0,R.jsxs)(`span`,{className:sM.range,children:[`turn `,o,` → `,s]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 260 80`,width:`100%`,height:80,role:`img`,"aria-label":`HEXACO trajectory for ${t}`,children:[(0,R.jsx)(`line`,{x1:6,y1:l(.5),x2:254,y2:l(.5),stroke:`var(--border)`,strokeWidth:`0.5`,strokeDasharray:`2,3`}),cM.map(e=>{let t=a.map(t=>`${u(t.turn)},${l(t.hexaco[e])}`).join(` `);return(0,R.jsx)(`polyline`,{points:t,fill:`none`,stroke:lM[e],strokeWidth:`1.25`,strokeLinejoin:`round`,strokeLinecap:`round`,opacity:.85},e)})]}),(0,R.jsx)(`div`,{className:sM.legend,children:cM.map(e=>(0,R.jsxs)(`span`,{className:sM.legendItem,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:sM.legendSwatch,style:{"--trait-color":lM[e]}}),(0,R.jsx)(`span`,{className:sM.legendLabel,children:uM[e]}),(0,R.jsx)(`span`,{className:sM.legendValue,children:a[a.length-1].hexaco[e].toFixed(2)})]},e))})]})}var mM={crisis:`Crisis`,departments:`Department analysis`,decision:`Decision`,outcome:`Outcome`,quotes:`Agent voices`,causality:`Causality`},hM={timeline:`Turn timeline`,verdict:`Verdict`,trajectory:`Commander arcs`,cost:`Cost breakdown`,toolbox:`Forged toolbox`,references:`References`},gM=[`crisis`,`departments`,`decision`,`outcome`],_M=[`crisis`,`departments`,`decision`,`outcome`,`causality`];function vM(e){return e===`crisis`||e===`departments`||e===`decision`||e===`outcome`||e===`quotes`||e===`causality`}function yM(e){return e!==`quotes`}function bM(e){let t=[];for(let n of e??[])vM(n)&&!t.includes(n)&&t.push(n);return t}function xM(e){let t=bM(e.configuredSections),n=t.length>0?t:gM,r=n.filter(yM);for(let t of _M)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 SM={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`},CM=[{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 wM(e,t){return t===`percent`?`${Math.round(e*100)}%`:t===`decimal`?e.toFixed(1):String(Math.round(e))}function TM({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,R.jsxs)(`div`,{className:SM.bar,children:[(0,R.jsx)(`div`,{className:SM.barLeftWrap,children:(0,R.jsx)(`div`,{className:SM.barLeftFill,style:{"--bar-pct":`${i}%`,"--bar-fill":o}})}),(0,R.jsx)(`div`,{className:SM.barRightWrap,children:(0,R.jsx)(`div`,{className:SM.barRightFill,style:{"--bar-pct":`${a}%`,"--bar-fill":s}})})]})}function EM(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=Ri(t?.finalStats),c=a&&o?s?[...s.map(e=>({key:e.id,label:zi(e),a:e.a,b:e.b,text:t=>Bi(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=>wM(e??0,`int`)}]:CM.map(e=>({key:e.key,label:e.label,a:Number(a[e.key]??0),b:Number(o[e.key]??0),text:t=>wM(t??0,e.format)})):[],l=e.onViewFullVerdict??(()=>{typeof document<`u`&&document.getElementById(`verdict`)?.scrollIntoView({behavior:`smooth`,block:`start`})});return(0,R.jsxs)(`section`,{"aria-label":`Run summary`,className:SM.section,children:[(0,R.jsxs)(`div`,{className:SM.header,children:[(0,R.jsx)(`div`,{className:SM.kicker,children:`Run Summary`}),n&&(0,R.jsxs)(`div`,{className:SM.winner,children:[n,` wins`]}),r&&(0,R.jsx)(`div`,{className:SM.headline,children:r}),i&&(0,R.jsx)(`div`,{className:SM.divergence,children:i})]}),a&&o?(0,R.jsxs)(`div`,{className:SM.body,children:[(0,R.jsxs)(`div`,{className:SM.bodyHeader,children:[(0,R.jsx)(`span`,{className:SM.nameA,children:e.leaderAName}),(0,R.jsx)(`span`,{children:`Final stats`}),(0,R.jsx)(`span`,{className:SM.nameB,children:e.leaderBName})]}),c.map(e=>{let{a:t,b:n}=e,r=Hi(t,n,e.better)??`tie`;return(0,R.jsxs)(`div`,{className:SM.statRow,children:[(0,R.jsxs)(`div`,{className:SM.statRowHead,children:[(0,R.jsx)(`span`,{className:SM.statValueA,style:{"--val-color":r===`a`?`var(--vis)`:`var(--text-2)`,"--val-weight":r===`a`?`700`:`500`},children:e.text(t)}),(0,R.jsx)(`span`,{className:SM.statLabel,children:e.label}),(0,R.jsx)(`span`,{className:SM.statValueB,style:{"--val-color":r===`b`?`var(--eng)`:`var(--text-2)`,"--val-weight":r===`b`?`700`:`500`},children:e.text(n)})]}),(0,R.jsx)(TM,{a:t??0,b:n??0,winner:r})]},e.key)}),(0,R.jsx)(`div`,{className:SM.viewWrap,children:(0,R.jsx)(`button`,{type:`button`,onClick:l,className:SM.viewBtn,children:`View full verdict ›`})})]}):(0,R.jsx)(`div`,{className:SM.empty,children:`Simulation in progress. Scoreboard will populate when the verdict arrives.`})]})}var DM={morale:`higher`,population:`higher`,deaths:`lower`,tools:`higher`,turn:`higher`};function OM(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 kM(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 AM(e,t,n){let r=n??DM[t];if(e.length===0)return{metric:t,direction:r,top:[],middle:[],bottom:[],median:0};let i=[...e.map(e=>kM(e,t))].sort((e,t)=>e-t),a=OM(i,.25),o=OM(i,.75),s=OM(i,.5),c=[],l=[],u=[],d=a===o;for(let n of e){if(d){l.push(n);continue}let e=kM(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 jM(e,t){if(e.length===0||t.length===0)return{frontIds:[],dominationCount:{}};let n=(e,t,n)=>{let r=kM(e,n),i=kM(t,n);return DM[n]===`higher`?r>=i:r<=i},r=(e,t,n)=>{let r=kM(e,n),i=kM(t,n);return DM[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 MM(e,t){if(e.length===0)return{metric:t,median:0,deltas:{}};let n=OM([...e.map(e=>kM(e,t))].sort((e,t)=>e-t),.5),r={},i=DM[t]===`higher`?1:-1;for(let a of e){let e=(kM(a,t)-n)*i;r[a.id]=e+0}return{metric:t,median:n,deltas:r}}function NM(e,t=0){if(Math.abs(e)<.5/10**t)return`±0`;let n=e.toFixed(t);return e>0?`+${n}`:n}var PM={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`},FM=[{metric:`morale`,label:`Morale`,suffix:`%`},{metric:`population`,label:`Population`,suffix:``},{metric:`deaths`,label:`Deaths`,suffix:``},{metric:`tools`,label:`Tools`,suffix:``}],IM=[`morale`,`population`,`deaths`,`tools`],LM=[{metric:`morale`,label:`Morale`,suffix:`%`,decimals:0},{metric:`population`,label:`Population`,suffix:``,decimals:0},{metric:`deaths`,label:`Deaths`,suffix:``,decimals:0}];function RM({state:e}){let t=(0,L.useMemo)(()=>OA(e),[e]);if(t.length<3)return null;let n=(0,L.useMemo)(()=>FM.map(({metric:e,label:n,suffix:r})=>({metric:e,label:n,suffix:r,ranking:AM(t,e)})),[t]),r=(0,L.useMemo)(()=>jM(t,IM),[t]),i=r.frontIds.map(e=>t.find(t=>t.id===e)).filter(e=>!!e),a=(0,L.useMemo)(()=>LM.map(({metric:e,label:n,suffix:r,decimals:i})=>({metric:e,label:n,suffix:r,decimals:i,benchmark:MM(t,e)})),[t]);return(0,R.jsxs)(`section`,{className:PM.panel,"aria-labelledby":`cohort-verdict-heading`,children:[(0,R.jsxs)(`header`,{className:PM.header,children:[(0,R.jsx)(`h3`,{id:`cohort-verdict-heading`,className:PM.heading,children:`Cohort verdict`}),(0,R.jsxs)(`p`,{className:PM.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,R.jsxs)(`div`,{className:PM.section,children:[(0,R.jsx)(`h4`,{className:PM.sectionTitle,children:`Quartile rankings`}),(0,R.jsx)(`div`,{className:PM.quartileGrid,children:n.map(({metric:e,label:t,suffix:n,ranking:r})=>(0,R.jsxs)(`div`,{className:PM.quartileBlock,children:[(0,R.jsxs)(`div`,{className:PM.metricHead,children:[(0,R.jsx)(`span`,{className:PM.metricLabel,children:t}),(0,R.jsxs)(`span`,{className:PM.metricMedian,children:[`median `,Math.round(r.median),n]})]}),(0,R.jsxs)(`div`,{className:PM.quartileRow,children:[(0,R.jsx)(`span`,{className:PM.quartileTag,children:`Top 25%`}),(0,R.jsxs)(`ul`,{className:PM.actorList,children:[r.top.map(e=>(0,R.jsx)(`li`,{className:`${PM.actorPill} ${PM.actorPillTop}`,children:e.name},e.id)),r.top.length===0&&(0,R.jsx)(`li`,{className:PM.actorListEmpty,children:`—`})]})]}),(0,R.jsxs)(`div`,{className:PM.quartileRow,children:[(0,R.jsx)(`span`,{className:PM.quartileTag,children:`Bottom 25%`}),(0,R.jsxs)(`ul`,{className:PM.actorList,children:[r.bottom.map(e=>(0,R.jsx)(`li`,{className:`${PM.actorPill} ${PM.actorPillBottom}`,children:e.name},e.id)),r.bottom.length===0&&(0,R.jsx)(`li`,{className:PM.actorListEmpty,children:`—`})]})]})]},e))})]}),(0,R.jsxs)(`div`,{className:PM.section,children:[(0,R.jsx)(`h4`,{className:PM.sectionTitle,children:`Pareto front · trade-off candidates`}),(0,R.jsxs)(`p`,{className:PM.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,R.jsx)(`ul`,{className:PM.paretoList,children:i.map(e=>{let t=r.dominationCount[e.id]??0;return(0,R.jsxs)(`li`,{className:PM.paretoItem,children:[(0,R.jsx)(`span`,{className:PM.paretoName,children:e.name}),(0,R.jsx)(`span`,{className:PM.paretoArchetype,children:e.archetype}),(0,R.jsxs)(`span`,{className:PM.paretoDominates,children:[`dominates `,t,` other`,t===1?``:`s`]})]},e.id)})})]}),(0,R.jsxs)(`div`,{className:PM.section,children:[(0,R.jsx)(`h4`,{className:PM.sectionTitle,children:`Median benchmark · per-actor deltas`}),(0,R.jsx)(`p`,{className:PM.sectionHint,children:`Sign-normalized so positive = better than median. Lower deaths and higher morale both read as positive deltas.`}),(0,R.jsxs)(`div`,{className:PM.medianTable,role:`table`,"aria-label":`Per-actor delta-from-median`,children:[(0,R.jsxs)(`div`,{className:PM.medianHeaderRow,role:`row`,children:[(0,R.jsx)(`span`,{className:PM.medianActorCol,role:`columnheader`,children:`Actor`}),a.map(e=>(0,R.jsx)(`span`,{className:PM.medianMetricCol,role:`columnheader`,children:e.label},e.metric))]}),t.map(e=>(0,R.jsxs)(`div`,{className:PM.medianBodyRow,role:`row`,children:[(0,R.jsxs)(`span`,{className:PM.medianActorCol,role:`cell`,children:[(0,R.jsx)(`span`,{className:PM.medianActorName,children:e.name}),(0,R.jsx)(`span`,{className:PM.medianActorArchetype,children:e.archetype})]}),a.map(t=>{let n=t.benchmark.deltas[e.id]??0,r=n>0?PM.deltaPositive:n<0?PM.deltaNegative:PM.deltaNeutral;return(0,R.jsxs)(`span`,{className:`${PM.medianMetricCol} ${r}`,role:`cell`,children:[NM(n,t.decimals),t.suffix]},t.metric)})]},e.id))]})]})]})}function zM(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 BM(e,t){return!e||!t?`divergent`:e===t?`shared`:`divergent`}var VM=[{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 HM(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 UM(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 VM.map(e=>({id:e.id,label:e.label,unit:e.unit,a:a?HM(a,e.id):[],b:o?HM(o,e.id):[]}))}function WM(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 VM.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?HM(t.events,e.id):[]}))}))}function GM(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:BM(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 KM={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`},qM={conservative_success:`SAFE WIN`,risky_success:`RISKY WIN`,conservative_failure:`SAFE LOSS`,risky_failure:`RISKY LOSS`},JM={conservative_success:`S✓`,risky_success:`R✓`,conservative_failure:`S✗`,risky_failure:`R✗`};function YM(e,t=!1){return e?t?JM[e]??`·`:qM[e]??e.replace(/_/g,` `).toUpperCase():`·`}function XM({outcome:e,sideColor:t,compact:n}){let r=zM(e);return(0,R.jsx)(`div`,{className:KM.badge,style:{"--side-color":t,"--outcome-color":r,"--badge-size":n?`11px`:`9px`,"--badge-spacing":n?`0`:`0.04em`},children:YM(e,n)})}function ZM(e){let{turns:t,leaderAName:n,leaderBName:r,onJumpToTurn:i}=e,a=Sy(wy);if(t.length===0)return null;let o=e=>{i?i(e):typeof document<`u`&&document.getElementById(`turn-${e}`)?.scrollIntoView({behavior:`smooth`,block:`start`})};return(0,R.jsxs)(`section`,{"aria-label":`Run timeline strip`,className:KM.section,children:[(0,R.jsx)(`div`,{className:KM.title,children:`Run Strip`}),(0,R.jsx)(`div`,{role:`list`,className:KM.grid,style:{"--turn-count":String(t.length)},children:t.map(e=>(0,R.jsxs)(`button`,{type:`button`,role:`listitem`,onClick:()=>o(e.turn),"aria-label":`Jump to turn ${e.turn}${e.time?`, time `+e.time:``}${e.diverged?`, divergent`:``}`,className:[KM.cell,e.diverged?KM.diverged:``].filter(Boolean).join(` `),children:[(0,R.jsxs)(`div`,{className:KM.cellHead,children:[(0,R.jsxs)(`span`,{className:KM.cellTurn,children:[`T`,e.turn]}),e.time&&!a&&(0,R.jsxs)(`span`,{children:[`Y`,e.time]})]}),(0,R.jsx)(XM,{outcome:e.a.outcome,sideColor:`var(--vis)`,compact:a}),(0,R.jsx)(XM,{outcome:e.b.outcome,sideColor:`var(--eng)`,compact:a})]},e.turn))}),(0,R.jsxs)(`div`,{className:KM.legend,children:[(0,R.jsx)(`span`,{children:n}),(0,R.jsx)(`span`,{children:r})]})]})}var QM={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 $M(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 eN(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 tN({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,R.jsxs)(`div`,{className:QM.card,children:[(0,R.jsxs)(`div`,{className:QM.cardHeader,children:[(0,R.jsx)(`span`,{className:QM.cardLabel,children:e.label}),(0,R.jsxs)(`span`,{className:QM.cardRange,children:[`T`,a,` → T`,o]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 200 50`,width:`100%`,height:50,role:`img`,"aria-label":`${e.label} sparkline (${e.series.length} actors)`,children:[(0,R.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,R.jsx)(`polyline`,{points:t,fill:`none`,stroke:e.color,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`,opacity:.78,children:(0,R.jsx)(`title`,{children:e.name})},e.actorId):null})]}),(0,R.jsx)(`div`,{className:QM.cardFooterCohort,children:e.series.map((t,n)=>{let r=t.points[t.points.length-1]?.value,i=eN(n);return(0,R.jsxs)(`span`,{className:QM.lastCohort,style:{"--actor-color":t.color},title:t.name,children:[(0,R.jsx)(`span`,{className:QM.lastCohortSlot,"aria-hidden":`true`,children:i}),r==null?`·`:$M(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,R.jsxs)(`div`,{className:QM.card,children:[(0,R.jsxs)(`div`,{className:QM.cardHeader,children:[(0,R.jsx)(`span`,{className:QM.cardLabel,children:e.label}),(0,R.jsxs)(`span`,{className:QM.cardRange,children:[`T`,a,` → T`,o]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 200 50`,width:`100%`,height:50,role:`img`,"aria-label":`${e.label} sparkline`,children:[(0,R.jsx)(`line`,{x1:4,y1:25,x2:196,y2:25,stroke:`var(--border)`,strokeWidth:`0.5`,strokeDasharray:`2,3`}),p&&(0,R.jsx)(`polyline`,{points:p,fill:`none`,stroke:t,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`,opacity:.9}),m&&(0,R.jsx)(`polyline`,{points:m,fill:`none`,stroke:n,strokeWidth:`1.5`,strokeLinejoin:`round`,strokeLinecap:`round`,opacity:.9})]}),(0,R.jsxs)(`div`,{className:QM.cardFooter,children:[(0,R.jsx)(`span`,{className:QM.lastA,children:h==null?`·`:$M(h,e.unit)}),(0,R.jsx)(`span`,{className:QM.lastB,children:g==null?`·`:$M(g,e.unit)})]})]})}function nN(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,R.jsxs)(`section`,{"aria-label":`Metric sparklines`,className:QM.section,style:c,children:[(0,R.jsxs)(`div`,{className:QM.sectionHeader,children:[(0,R.jsx)(`span`,{className:QM.sectionTitle,children:`Metric Trajectories`}),o?(0,R.jsx)(`span`,{className:QM.legendCohort,children:(s[0].series??[]).map((e,t)=>(0,R.jsxs)(`span`,{className:QM.legendCohortEntry,style:{"--actor-color":e.color},children:[(0,R.jsx)(`span`,{className:QM.legendCohortSlot,"aria-hidden":`true`,children:eN(t)}),e.name]},e.actorId))}):(0,R.jsxs)(`span`,{className:QM.legend,children:[(0,R.jsx)(`span`,{className:QM.legendA,children:n}),` · `,(0,R.jsx)(`span`,{className:QM.legendB,children:r})]})]}),(0,R.jsx)(`div`,{className:`responsive-grid-3 ${QM.grid}`,children:s.map(e=>(0,R.jsx)(tN,{metric:e,sideAColor:i,sideBColor:a},e.id))})]})}function rN(e,t){let[n,r]=(0,L.useState)(()=>typeof window<`u`?window.matchMedia(e).matches:t);return(0,L.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 iN(e){let{items:t,scrollRoot:n}=e,[r,i]=(0,L.useState)(t[0]?.id),a=rN(`(min-width: 1024px)`,!0),o=rN(`(max-width: 767.98px)`,!1);(0,L.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,L.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,R.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,R.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,R.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,R.jsx)(`a`,{href:`#${e.id}`,style:o?n:i,children:e.label},e.id)})})}var Z={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 aN(e,t){let[n,r]=(0,L.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,L.useCallback)(t=>{r(t);try{window.localStorage.setItem(e,t?`1`:`0`)}catch{}},[e])]}function oN(){return{events:new Map,reactions:[],totalReactions:0}}function sN(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 cN(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=oN(),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=sN(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=sN(i,a,o);e.title=r.data?.title,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||``),policies:Array.isArray(r.data?.selectedPolicies)?r.data.selectedPolicies.map(e=>typeof e==`string`?e:JSON.stringify(e)):[]}),r.type===`outcome`){let e=sN(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,n.delete(a))}if(r.type===`specialist_done`){let e=sN(i,a,o),t=r.data?.department;if(t){let n=(r.data?._filteredTools||[]).filter(e=>e?.approved!==!1).length;e.depts[t]={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 lN(e){return e===`pos`?`var(--green)`:e===`neg`?`var(--rust)`:`var(--text-1)`}function uN({state:e,verdict:t,shownRun:n,reportSections:r}){let i=HC(),a=ew(),[o,s]=aN(`paracosm-reports-refs-open`,!1),[c,l]=aN(`paracosm-reports-tools-open`,!1),[u,d]=(0,L.useState)(!1),{state:f,dispatch:p}=da(),m=vF(),h=bF(),g=i_(),[_,v]=(0,L.useState)(null),y=f.parent,b=fF(),x=mF(),S=y?.metadata?.scenario,C=typeof S?.id==`string`&&S.id!==b.id,w=(0,L.useCallback)(t=>!y||e.isRunning||!x||C?!1:Xj(y,t),[y,e.isRunning,x,C]),T=(0,L.useCallback)(async e=>{v(null);let t=`branch-${Date.now()}-${Math.random().toString(36).slice(2,6)}`;p({type:`BRANCH_OPTIMISTIC`,localId:t,forkedAtTurn:e.atTurn,actorName:e.leader.name,actorArchetype:e.leader.archetype});let n=Yj(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:qj(e.parentArtifact),atTurn:e.atTurn}})});if(!i.ok){let e=await i.json().catch(()=>({}));p({type:`BRANCH_ERROR`,localId:t,message:e.error??`HTTP ${i.status}`});return}let a=await i.json().catch(()=>({}));le(window,a.visitorId),h(),m(`studio`)}catch(e){p({type:`BRANCH_ERROR`,localId:t,message:String(e)})}},[p,m,h]),E=e.actorIds[0]??null,D=e.actorIds[1]??null,[O,k]=(0,L.useState)(E),[ee,A]=(0,L.useState)(D);(0,L.useEffect)(()=>{O&&!e.actorIds.includes(O)&&k(E),ee&&!e.actorIds.includes(ee)&&A(D)},[e.actorIds,O,ee,E,D]);let j=O??E,M=ee??D,N=e.actorIds.length>2,[te,P]=(0,L.useState)(!N);(0,L.useEffect)(()=>{P(!N)},[N]);let F=(0,L.useMemo)(()=>{let t=new Map;for(let n of e.actorIds)t.set(n,cN(e.actors[n]?.events));return t},[e]),I=(0,L.useMemo)(()=>{let e=j&&F.get(j)||new Map,t=M&&F.get(M)||new Map;return[...new Set([...e.keys(),...t.keys()])].sort((e,t)=>e-t).map(n=>[n,{a:e.get(n)??oN(),b:t.get(n)??oN()}])},[F,j,M]),ne=(0,L.useMemo)(()=>{if(!N)return[];let t=new Set;for(let e of F.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,F.get(r)?.get(t)??oN());return[t,n]})},[N,F,e.actorIds]),re=j,z=M,B=re?e.actors[re]:null,ie=z?e.actors[z]:null,ae=B?.leader?.name||`Leader A`,oe=ie?.leader?.name||`Leader B`,se=(B?.events.some(e=>e.type===`personality_drift`)??!1)||(ie?.events.some(e=>e.type===`personality_drift`)??!1),ce=I.some(([,e])=>e.a.reactions.length>0||e.b.reactions.length>0),V=I.some(([,e])=>[...e.a.events.values(),...e.b.events.values()].some(e=>!!e.rationale)),ue=(0,L.useMemo)(()=>xM({configuredSections:r,hasQuotes:ce,hasCausality:V,hasVerdict:!!t,hasTrajectories:se,hasCost:!!(e.cost&&e.cost.llmCalls>0),hasToolbox:a.list.length>0,hasReferences:i.list.length>0}),[r,ce,V,t,se,e.cost,a.list.length,i.list.length]),de=(0,L.useMemo)(()=>GM(I),[I]),fe=(0,L.useMemo)(()=>UM(e,j,M),[e,j,M]),pe=(0,L.useMemo)(()=>N?WM(e,Xn):null,[N,e]),me=(0,L.useMemo)(()=>{let e=[];de.length>0&&e.push({id:`strip`,label:`Strip`}),fe.some(e=>e.a.length>0||e.b.length>0)&&e.push({id:`sparklines`,label:`Metrics`}),se&&e.push({id:`trajectory`,label:`Trajectory`});for(let[t]of I)e.push({id:`turn-${t}`,label:`Turn ${t}`});return a.list.length>0&&e.push({id:`toolbox`,label:`Toolbox`}),e.push({id:`summary`,label:t?`Verdict`:`Summary`}),i.list.length>0&&e.push({id:`references`,label:`References`}),e},[t,de.length,fe,se,I,a.list.length,i.list.length]),he=(0,L.useRef)(null),ge=(0,L.useRef)(!0);return(0,L.useEffect)(()=>{ge.current&&he.current&&I.length>0&&he.current.scrollTo({top:he.current.scrollHeight,behavior:`smooth`})},[I.length]),!(B?.events.length??0)&&!(ie?.events.length??0)?e.isRunning?(0,R.jsx)(`div`,{className:Z.empty,children:(0,R.jsxs)(`div`,{className:`${Z.emptyMsg} ${Z.emptyMsgRunning??``}`,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:Z.emptySpinner,"aria-hidden":`true`}),(0,R.jsx)(`span`,{children:`Awaiting first turn — the report populates once the kernel reports an event.`})]})}):(0,R.jsx)(`div`,{className:Z.empty,children:(0,R.jsx)(`div`,{className:Z.emptyMsg,children:`Run a simulation first to see the report.`})}):(0,R.jsxs)(`div`,{className:`reports-layout ${Z.layout}`,children:[(0,R.jsxs)(`div`,{ref:he,onScroll:()=>{let e=he.current;e&&(ge.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},className:`reports-content ${Z.scroll}`,role:`region`,"aria-label":`Turn-by-turn report`,children:[x&&C&&(0,R.jsxs)(`p`,{className:Z.forkNotice,role:`note`,children:[`This run is in `,S?.name??S?.id,`, and a fork runs in its parent's scenario. Switch to `,S?.name??S?.id,` to fork it.`]}),(()=>{let e=t,n=e?.winnerName||``,r=e?.headline||e?.summary||``;if(!t&&I.length===0)return null;let i=I.length,a=I[I.length-1],o=I[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`),u=s(a?.[1]?.a?.metrics,`morale`),d=s(a?.[1]?.b?.metrics,`morale`),f=s(o?.[1]?.a?.metrics,`population`)||c,p=s(o?.[1]?.b?.metrics,`population`)||l,m=B?.events.filter(e=>e.type===`forge_attempt`&&e.data?.approved===!0).length??0,h=ie?.events.filter(e=>e.type===`forge_attempt`&&e.data?.approved===!0).length??0,g=[{label:`Turns`,value:String(i)},{label:`Final pop`,value:`A ${c}${c<f?` (↓${f-c})`:``} · B ${l}${l<p?` (↓${p-l})`:``}`,tone:c+l<f+p?`neg`:`neutral`},{label:`Final morale`,value:`A ${Math.round(u*100)}% · B ${Math.round(d*100)}%`,tone:Math.min(u,d)<.3?`neg`:Math.min(u,d)>=.6?`pos`:`neutral`},{label:`Tools forged`,value:`A ${m} · B ${h}`}];return(0,R.jsxs)(`div`,{className:Z.tldr,children:[(0,R.jsxs)(`div`,{className:Z.tldrTopRow,children:[(0,R.jsx)(`span`,{className:Z.tldrTag,children:`TL;DR`}),n?(0,R.jsxs)(`span`,{className:Z.tldrHeadline,children:[n,` wins`]}):i>0?(0,R.jsxs)(`span`,{className:Z.tldrHeadline,children:[`Run `,i,` turn`,i===1?``:`s`,` — verdict pending`]}):null,r&&(0,R.jsx)(`span`,{className:Z.tldrSub,children:r})]}),(0,R.jsx)(`div`,{className:Z.tldrStats,children:g.map(e=>(0,R.jsxs)(`span`,{children:[(0,R.jsxs)(`span`,{className:Z.tldrStatLabel,children:[e.label,`:`]}),(0,R.jsx)(`span`,{className:Z.tldrStatValue,style:{"--tone-color":lN(e.tone)},children:e.value})]},e.label))})]})})(),(0,R.jsxs)(`div`,{className:Z.headerRow,children:[(0,R.jsx)(`h2`,{className:Z.headerTitle,children:`Turn-by-Turn Report`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>{let e=document.getElementById(`summary`);e&&e.scrollIntoView({behavior:`smooth`,block:`start`})},className:Z.jumpBtn,children:t?`↓ See verdict + full summary`:`↓ Jump to summary`})]}),N&&(0,R.jsxs)(`div`,{className:Z.actorPairPicker,role:`region`,"aria-label":`Pair focus toggle`,children:[(0,R.jsxs)(`label`,{className:Z.actorPairPickerToggle,children:[(0,R.jsx)(`input`,{type:`checkbox`,checked:te,onChange:e=>P(e.target.checked),"aria-label":`Toggle pair-focus view for strip, sparklines, and trajectory`}),(0,R.jsx)(`span`,{className:Z.actorPairPickerToggleText,children:`Focus pair`})]}),te?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`select`,{"aria-label":`Left side actor`,className:Z.actorPairPickerSelect,value:j??``,onChange:e=>k(e.target.value||null),children:e.actorIds.map(t=>(0,R.jsx)(`option`,{value:t,disabled:t===M,children:e.actors[t]?.leader?.name??t},t))}),(0,R.jsx)(`span`,{className:Z.actorPairPickerVs,children:`vs`}),(0,R.jsx)(`select`,{"aria-label":`Right side actor`,className:Z.actorPairPickerSelect,value:M??``,onChange:e=>A(e.target.value||null),children:e.actorIds.map(t=>(0,R.jsx)(`option`,{value:t,disabled:t===j,children:e.actors[t]?.leader?.name??t},t))}),(0,R.jsxs)(`span`,{className:Z.actorPairPickerHint,children:[`strip + metrics + trajectory show this pair only · turn-by-turn below shows all `,e.actorIds.length,` actors`]})]}):(0,R.jsxs)(`span`,{className:Z.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.`]})]}),(!N||te)&&(0,R.jsx)(`section`,{id:`strip`,children:(0,R.jsx)(ZM,{turns:de,leaderAName:ae,leaderBName:oe})}),(0,R.jsx)(`section`,{id:`sparklines`,children:!N||te?(0,R.jsx)(nN,{metrics:fe,leaderAName:ae,leaderBName:oe}):pe&&(0,R.jsx)(nN,{metrics:pe,leaderAName:``,leaderBName:``})}),(0,R.jsxs)(`section`,{id:`trajectory`,children:[se&&te&&(0,R.jsxs)(`div`,{className:`responsive-grid-2 ${Z.trajectoryGrid}`,children:[(0,R.jsx)(pM,{events:B?.events??[],actorName:ae,baselineHexaco:B?.leader?.hexaco}),(0,R.jsx)(pM,{events:ie?.events??[],actorName:oe,baselineHexaco:ie?.leader?.hexaco})]}),se&&!te&&(0,R.jsx)(`div`,{className:`responsive-grid-2 ${Z.trajectoryGrid}`,children:e.actorIds.map(t=>{let n=e.actors[t];return n?.events.length?(0,R.jsx)(pM,{events:n.events,actorName:n.leader?.name||t,baselineHexaco:n.leader?.hexaco},t):null})})]}),e.cost&&e.cost.llmCalls>0&&(0,R.jsxs)(`div`,{className:Z.costBar,children:[(0,R.jsx)(`span`,{className:Z.costLabel,children:`Run cost`}),(0,R.jsxs)(`span`,{className:Z.costAmount,children:[`$`,e.cost.totalCostUSD<.01?e.cost.totalCostUSD.toFixed(4):e.cost.totalCostUSD.toFixed(2)]}),(0,R.jsxs)(`span`,{className:Z.costMeta,children:[`· `,e.cost.llmCalls,` LLM calls · `,(e.cost.totalTokens/1e3).toFixed(1),`k tokens`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>d(!0),className:Z.costBtn,children:`Per-stage breakdown ›`})]}),u&&e.cost&&e.cost.llmCalls>0&&(0,R.jsx)(oM,{combined:e.cost,leaderA:(re?e.costByActor[re]:void 0)??{totalTokens:0,totalCostUSD:0,llmCalls:0},leaderB:(z?e.costByActor[z]:void 0)??{totalTokens:0,totalCostUSD:0,llmCalls:0},leaderAName:B?.leader?.name,leaderBName:ie?.leader?.name,actors:N?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:()=>d(!1)}),!N&&I.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,R.jsxs)(`section`,{id:`turn-${e}`,className:[Z.turnSection,c?Z.diverged:``].filter(Boolean).join(` `),children:[(0,R.jsxs)(`div`,{className:Z.turnHeader,children:[(0,R.jsxs)(`span`,{className:Z.turnTitle,children:[`Turn `,e,` — Y`,i,a>1&&(0,R.jsxs)(`span`,{className:Z.turnEventCount,children:[a,` events`]})]}),(0,R.jsxs)(`div`,{className:Z.turnHeaderRight,children:[(0,R.jsx)(`span`,{className:[Z.divergenceFlag,c?Z.diverged:``].filter(Boolean).join(` `),children:c?`DIVERGENT`:`SHARED`}),w(e)&&(0,R.jsxs)(`button`,{type:`button`,className:Zj.forkButton,onClick:()=>v(e),"aria-label":`Fork at ${g.time} ${e}`,children:[`↳ Fork at `,g.Time,` `,e]})]})]}),Array.from({length:a}).map((e,t)=>(0,R.jsxs)(`div`,{className:`responsive-grid-2 ${t<a-1?Z.eventGridSpaced:Z.eventGrid}`,children:[(0,R.jsx)(fN,{block:n.events.get(t),eventIndex:t,totalEvents:a,name:ae,sideColor:`var(--vis)`,sections:ue.eventSections}),(0,R.jsx)(fN,{block:r.events.get(t),eventIndex:t,totalEvents:a,name:oe,sideColor:`var(--eng)`,sections:ue.eventSections})]},t)),(0,R.jsxs)(`div`,{className:`responsive-grid-2 ${Z.footerGrid}`,children:[(0,R.jsx)(pN,{data:n,name:ae,sideColor:`var(--vis)`,showQuotes:ue.footerSections.includes(`quotes`)}),(0,R.jsx)(pN,{data:r,name:oe,sideColor:`var(--eng)`,showQuotes:ue.footerSections.includes(`quotes`)})]})]},e)}),N&&ne.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,R.jsxs)(`section`,{id:`turn-${t}`,className:[Z.turnSection,o?Z.diverged:``].filter(Boolean).join(` `),children:[(0,R.jsxs)(`div`,{className:Z.turnHeader,children:[(0,R.jsxs)(`span`,{className:Z.turnTitle,children:[`Turn `,t,` — Y`,s,a>1&&(0,R.jsxs)(`span`,{className:Z.turnEventCount,children:[a,` events`]})]}),(0,R.jsxs)(`div`,{className:Z.turnHeaderRight,children:[(0,R.jsx)(`span`,{className:[Z.divergenceFlag,o?Z.diverged:``].filter(Boolean).join(` `),children:o?`DIVERGENT`:`SHARED`}),w(t)&&(0,R.jsxs)(`button`,{type:`button`,className:Zj.forkButton,onClick:()=>v(t),"aria-label":`Fork at ${g.time} ${t}`,children:[`↳ Fork at `,g.Time,` `,t]})]})]}),Array.from({length:a}).map((t,r)=>(0,R.jsx)(`div`,{className:r<a-1?Z.nActorEventTrackSpaced:Z.nActorEventTrack,children:e.actorIds.map((t,i)=>{let o=n.get(t)?.events.get(r),s=e.actors[t]?.leader?.name??t;return(0,R.jsx)(fN,{block:o,eventIndex:r,totalEvents:a,name:s,sideColor:i===0?`var(--vis)`:i===1?`var(--eng)`:`var(--amber)`,sections:ue.eventSections},t)})},r)),(0,R.jsx)(`div`,{className:Z.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,R.jsx)(pN,{data:i,name:a,sideColor:r===0?`var(--vis)`:r===1?`var(--eng)`:`var(--amber)`,showQuotes:ue.footerSections.includes(`quotes`)},t)})})]},t)}),(0,R.jsx)(`section`,{id:`toolbox`,children:a.list.length>0&&(0,R.jsxs)(`details`,{open:c,onToggle:e=>{let t=e.currentTarget.open;t&&!c&&pw({name:`forge_toolbox_open`,from:`reports`}),l(t)},className:K.pageFold,children:[(0,R.jsx)(`summary`,{className:K.pageFoldSummary,children:`FORGED TOOLBOX`}),(0,R.jsx)(tD,{inPage:!0})]})}),(0,R.jsxs)(`section`,{id:`summary`,className:Z.summarySection,children:[(0,R.jsx)(`div`,{className:Z.summaryLabel,children:`Run Summary · Verdict · Winner`}),(0,R.jsx)(EM,{verdict:t,leaderAName:ae,leaderBName:oe}),(0,R.jsx)(RM,{state:e}),t&&(0,R.jsx)(`div`,{className:Z.summaryVerdictWrap,children:(0,R.jsx)(Zi,{verdict:t,shownRun:n})})]}),(0,R.jsx)(`section`,{id:`references`,children:i.list.length>0&&(0,R.jsx)(Jk,{registry:i,title:`References`,collapsible:!0,defaultOpen:o,onToggle:s})}),(0,R.jsxs)(`details`,{className:Z.aboutDetails,children:[(0,R.jsx)(`summary`,{className:Z.aboutSummary,children:`What's in this report?`}),(0,R.jsxs)(`div`,{className:Z.aboutBody,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:Z.aboutBlockTitle,children:`Scenario focus`}),(0,R.jsx)(`div`,{className:Z.aboutChips,children:ue.focusSections.map(e=>(0,R.jsx)(`span`,{className:Z.aboutChip,children:mM[e]},e))})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:Z.aboutBlockTitle,children:`This run produced`}),(0,R.jsx)(`div`,{className:Z.aboutChips,children:ue.artifacts.map(e=>(0,R.jsx)(`span`,{className:Z.aboutChipNeutral,children:hM[e]},e))})]})]})]})]}),(0,R.jsx)(iN,{items:me,scrollRoot:he.current}),_!==null&&y&&(0,R.jsx)(Qj,{parentArtifact:y,atTurn:_,maxTurns:Yj(y),costPreset:`economy`,provider:`openai`,onConfirm:T,onClose:()=>v(null)})]})}var dN={positive:`var(--green)`,negative:`var(--rust)`,anxious:`var(--amber)`,defiant:`var(--rust)`,hopeful:`var(--green)`,resigned:`var(--text-3)`,neutral:`var(--text-2)`};function fN({block:e,eventIndex:t,totalEvents:n,name:r,sideColor:i,sections:a}){let o={"--side-color":i};if(!e||!e.title)return(0,R.jsxs)(`div`,{className:Z.eventCard,children:[(0,R.jsxs)(`h4`,{className:Z.eventHeading,style:o,children:[r,n>1&&(0,R.jsxs)(`span`,{className:Z.eventSubLabel,children:[`Event `,t+1,`/`,n]})]}),(0,R.jsx)(`span`,{className:Z.eventAwaiting,children:`Awaiting data...`})]});let s={crisis:(0,R.jsxs)(`div`,{children:[(0,R.jsxs)(`div`,{className:Z.eventTitle,children:[e.title,e.category&&(0,R.jsx)(`span`,{className:Z.categoryPill,children:e.category}),e.emergent&&(0,R.jsx)(`span`,{className:Z.emergentPill,children:`EMERGENT`})]}),e.description&&(0,R.jsx)(`div`,{className:Z.eventDescription,children:e.description})]},`crisis`),decision:e.decision?(0,R.jsx)(`div`,{className:Z.eventDecision,children:e.decision},`decision`):null,outcome:e.outcome?(0,R.jsxs)(`div`,{className:Z.eventOutcomeRow,children:[(0,R.jsx)($O,{outcome:e.outcome}),Array.isArray(e.policies)&&e.policies.length>0&&(0,R.jsx)(`span`,{className:Z.eventPolicies,children:e.policies.map(e=>String(e)).join(` / `)})]},`outcome`):null,causality:e.rationale?(0,R.jsxs)(`details`,{className:Z.eventDetails,children:[(0,R.jsx)(`summary`,{className:Z.eventDetailsSummary,style:o,children:`Rationale`}),(0,R.jsx)(`div`,{className:Z.eventRationale,style:o,children:e.rationale})]},`causality`):null,departments:Object.keys(e.depts).length>0?(0,R.jsxs)(`details`,{className:Z.eventDetails,open:!0,children:[(0,R.jsxs)(`summary`,{className:Z.eventDetailsSummary,style:o,children:[`Departments (`,Object.keys(e.depts).length,`)`]}),(0,R.jsx)(`div`,{className:Z.deptList,children:Object.entries(e.depts).map(([e,t])=>(0,R.jsxs)(`div`,{className:Z.deptItem,style:o,children:[(0,R.jsxs)(`div`,{className:Z.deptHead,children:[(0,R.jsx)(`span`,{className:Z.deptName,children:e.charAt(0).toUpperCase()+e.slice(1)}),(0,R.jsxs)(`span`,{className:Z.deptMeta,children:[t.citations,`c `,t.tools,`t`]})]}),t.summary&&(0,R.jsx)(`div`,{className:Z.deptSummary,children:t.summary}),(0,R.jsx)(tk,{citations:t.citationList,label:``})]},e))})]},`departments`):null};return(0,R.jsxs)(`div`,{className:Z.eventCard,children:[(0,R.jsxs)(`h4`,{className:Z.eventHeading,style:o,children:[r,n>1&&(0,R.jsxs)(`span`,{className:Z.eventSubLabel,children:[`Event `,t+1,`/`,n]})]}),a.map(e=>s[e]).filter(Boolean)]})}function pN({data:e,name:t,sideColor:n,showQuotes:r}){let i=e.metrics;if(!i&&(!r||e.reactions.length===0))return(0,R.jsx)(`div`,{});let a={"--side-color":n};return(0,R.jsxs)(`div`,{className:Z.footerCard,children:[i&&(0,R.jsxs)(`details`,{className:e.reactions.length?Z.footerDetails:Z.footerDetailsLast,children:[(0,R.jsxs)(`summary`,{className:Z.footerSummary,style:a,children:[t,` · Systems State`]}),(0,R.jsx)(`div`,{className:Z.systemsRow,children:Object.entries(i).map(([e,t])=>(0,R.jsxs)(`span`,{className:Z.systemItem,children:[(0,R.jsxs)(`span`,{className:Z.systemKey,children:[e,`: `]}),(0,R.jsx)(`span`,{className:Z.systemValue,children:typeof t==`number`?Number.isInteger(t)?t:t.toFixed(2):String(t)})]},e))})]}),r&&e.reactions.length>0&&(0,R.jsxs)(`details`,{open:!0,children:[(0,R.jsxs)(`summary`,{className:Z.footerSummary,style:a,children:[`Agent Voices (`,e.totalReactions||e.reactions.length,`)`]}),(0,R.jsx)(`div`,{className:Z.reactionsList,children:e.reactions.map((e,t)=>(0,R.jsxs)(`div`,{className:Z.reactionItem,children:[(0,R.jsxs)(`div`,{className:Z.reactionHead,children:[(0,R.jsx)(`span`,{className:Z.reactionName,style:a,children:String(e.name)}),(0,R.jsx)(`span`,{className:Z.moodPill,style:{"--mood-color":dN[String(e.mood)]||`var(--text-3)`},children:String(e.mood||``).toUpperCase()})]}),(0,R.jsxs)(`div`,{className:Z.reactionQuote,children:[`“`,String(e.quote||``),`”`]}),!!e.role&&(0,R.jsxs)(`div`,{className:Z.reactionRole,children:[String(e.role),` `,e.department?`in ${String(e.department)}`:``]})]},t))})]})]})}var Q={layout:`_layout_1l1dk_1`,sidebar:`_sidebar_1l1dk_15`,sidebarHeading:`_sidebarHeading_1l1dk_31`,sidebarLead:`_sidebarLead_1l1dk_38`,actorFilter:`_actorFilter_1l1dk_45`,actorFilterLabel:`_actorFilterLabel_1l1dk_64`,actorFilterSelect:`_actorFilterSelect_1l1dk_74`,agentBtn:`_agentBtn_1l1dk_96`,selected:`_selected_1l1dk_110`,agentName:`_agentName_1l1dk_115`,agentMeta:`_agentMeta_1l1dk_119`,agentMood:`_agentMood_1l1dk_124`,chatArea:`_chatArea_1l1dk_131`,memoryBar:`_memoryBar_1l1dk_138`,memoryLabel:`_memoryLabel_1l1dk_145`,memoryBelief:`_memoryBelief_1l1dk_152`,memoryStance:`_memoryStance_1l1dk_157`,hexacoStrip:`_hexacoStrip_1l1dk_162`,hexacoLabel:`_hexacoLabel_1l1dk_174`,hexacoTrait:`_hexacoTrait_1l1dk_180`,hexacoBar:`_hexacoBar_1l1dk_184`,healthSignal:`_healthSignal_1l1dk_188`,messages:`_messages_1l1dk_192`,emptyState:`_emptyState_1l1dk_207`,emptyTitle:`_emptyTitle_1l1dk_213`,emptyCopy:`_emptyCopy_1l1dk_218`,eventCtx:`_eventCtx_1l1dk_225`,eventGroup:`_eventGroup_1l1dk_235`,eventGroupLast:`_eventGroupLast_1l1dk_239`,eventGroupLabel:`_eventGroupLabel_1l1dk_243`,eventRow:`_eventRow_1l1dk_252`,eventTurn:`_eventTurn_1l1dk_258`,eventTitle:`_eventTitle_1l1dk_265`,eventCategory:`_eventCategory_1l1dk_270`,memoryItem:`_memoryItem_1l1dk_275`,memoryTime:`_memoryTime_1l1dk_282`,relationshipsRow:`_relationshipsRow_1l1dk_287`,relationshipChip:`_relationshipChip_1l1dk_293`,bubbleWrap:`_bubbleWrap_1l1dk_297`,fromUser:`_fromUser_1l1dk_301`,fromAgent:`_fromAgent_1l1dk_305`,bubbleName:`_bubbleName_1l1dk_309`,bubble:`_bubble_1l1dk_297`,user:`_user_1l1dk_327`,typingBubble:`_typingBubble_1l1dk_332`,typingLabel:`_typingLabel_1l1dk_344`,dot:`_dot_1l1dk_359`,"chat-dot-bounce":`_chat-dot-bounce_1l1dk_1`,inputRow:`_inputRow_1l1dk_375`,inputField:`_inputField_1l1dk_392`,sendBtn:`_sendBtn_1l1dk_412`},mN={positive:`var(--green)`,negative:`var(--rust)`,anxious:`var(--amber)`,defiant:`var(--rust)`,hopeful:`var(--green)`,resigned:`var(--text-3)`,neutral:`var(--text-2)`};function hN(e){return e===`positive`?`var(--green)`:e===`negative`?`var(--rust)`:`var(--border)`}function gN({memory:e,events:t,scenario:n}){let r=[];for(let e of t.actorIds){let n=t.actors[e];if(n){for(let e of n.events)if(e.type===`turn_start`&&e.data.title&&e.data.title!==`Director generating...`){let t=e.data.turn;r.some(e=>e.turn===t)||r.push({turn:t,time:e.data.time||0,title:String(e.data.title),category:String(e.data.category||``)})}}}r.sort((e,t)=>e.turn-t.turn);let i=n.labels.eventNoun||`events`,a=e.recentMemories?.length>0,o=e.relationships?.length>0;return!r.length&&!a?null:(0,R.jsxs)(`div`,{className:Q.eventCtx,children:[r.length>0&&(0,R.jsxs)(`div`,{className:a?Q.eventGroup:Q.eventGroupLast,children:[(0,R.jsxs)(`div`,{className:Q.eventGroupLabel,style:{"--group-color":`var(--rust)`},children:[i.toUpperCase(),` EXPERIENCED`]}),r.map(e=>(0,R.jsxs)(`div`,{className:Q.eventRow,children:[(0,R.jsxs)(`span`,{className:Q.eventTurn,children:[`T`,e.turn,` `,e.time]}),(0,R.jsx)(`span`,{className:Q.eventTitle,children:e.title}),e.category&&(0,R.jsx)(`span`,{className:Q.eventCategory,children:e.category})]},e.turn))]}),a&&(0,R.jsxs)(`div`,{className:o?Q.eventGroup:Q.eventGroupLast,children:[(0,R.jsx)(`div`,{className:Q.eventGroupLabel,style:{"--group-color":`var(--amber)`},children:`RECENT MEMORIES`}),e.recentMemories.slice(0,3).map((e,t)=>(0,R.jsxs)(`div`,{className:Q.memoryItem,style:{"--valence-border":hN(e.valence)},children:[(0,R.jsxs)(`span`,{className:Q.memoryTime,children:[`Y`,e.time]}),` `,e.content]},t))]}),o&&(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:Q.eventGroupLabel,style:{"--group-color":`var(--teal)`},children:`RELATIONSHIPS`}),(0,R.jsx)(`div`,{className:Q.relationshipsRow,children:e.relationships.map((e,t)=>(0,R.jsxs)(`span`,{className:Q.relationshipChip,style:{"--rel-color":e.sentiment>0?`var(--green)`:`var(--rust)`},children:[e.name,` `,e.sentiment>0?`+`:``,e.sentiment.toFixed(1)]},t))})]})]})}function _N({state:e,onChatUsage:t}){let n=fF(),[r,i]=(0,L.useState)(null),[a,o]=(0,L.useState)(()=>new Map),[s,c]=(0,L.useState)(()=>new Map),[l,u]=(0,L.useState)(``),[d,f]=(0,L.useState)(!1),p=(0,L.useRef)(null),m=(0,L.useRef)(!0),h=()=>{let e=p.current;e&&(m.current=e.scrollHeight-e.scrollTop-e.clientHeight<40)},g=(0,L.useMemo)(()=>{let t=new Map;for(let n of e.actorIds){let r=e.actors[n];if(!r)continue;let i=new Map;for(let e of r.events)if(e.type===`agent_reactions`){let t=e.data.reactions||[];for(let e of t)e.name&&i.set(e.name,{name:e.name,role:e.role||``,department:e.department||``,mood:e.mood||`neutral`,age:e.age,marsborn:e.marsborn,agentId:e.agentId,memory:e.memory,hexaco:e.hexaco,psychScore:e.psychScore,boneDensity:e.boneDensity,radiation:e.radiation})}i.size>0&&t.set(n,Array.from(i.values()))}return t},[e]),_=e.actorIds.length>=2,[v,y]=(0,L.useState)(`all`);(0,L.useEffect)(()=>{if(!_)v!==null&&y(null);else if(v!==`all`&&!(v&&g.has(v))){if(e.actorIds.length>=5){let t=e.actorIds.find(e=>(g.get(e)?.length??0)>0);y(t??`all`)}else y(`all`)}},[_,g,e.actorIds,v]);let[b,x]=(0,L.useState)(null),S=(0,L.useMemo)(()=>{if(v&&v!==`all`)return g.get(v)??[];let e=[],t=new Set;for(let n of g.values())for(let r of n)t.has(r.name)||(t.add(r.name),e.push(r));return e},[g,v]),C=(0,L.useMemo)(()=>{let e=new Set;for(let t of S){let n=(t.department||``).trim();n&&e.add(n)}return[...e].sort((e,t)=>e.localeCompare(t))},[S]);(0,L.useEffect)(()=>{b&&!C.includes(b)&&x(null)},[C,b]);let w=(0,L.useMemo)(()=>b?S.filter(e=>(e.department||``).trim()===b):S,[S,b]),T=w.find(e=>e.name===r),D=e=>{if(v&&v!==`all`)return v;for(let[t,n]of g)if(n.some(t=>t.name===e))return t},O=e=>{let t=D(e);return t?`${t}\u0000${e}`:e},k=r?a.get(O(r))??[]:[];(0,L.useEffect)(()=>{m.current&&p.current&&p.current.scrollTo({top:p.current.scrollHeight,behavior:`smooth`})},[k,d]),(0,L.useEffect)(()=>{let e=()=>{let e=window.location.hash.match(/^#chat=([^&]+)/);if(!e)return;let t=decodeURIComponent(e[1]);t&&w.some(e=>e.name===t)&&i(t)};return e(),window.addEventListener(`hashchange`,e),()=>window.removeEventListener(`hashchange`,e)},[w]);let ee=e=>{i(e);let t=O(e);o(n=>{if(n.has(t))return n;let r=w.find(t=>t.name===e),i=r?{role:`agent`,name:r.name,text:`${r.role} in ${r.department}, age ${r.age||`?`}. I lived through this simulation — ask me about specific turns, the commander's decisions, crises I witnessed, people I worked with, or how my department handled what came up. Try: "what did you think of the commander's choice in turn 1?", "who do you trust on the team?", or "what was the worst moment for you?"`}:{role:`agent`,text:`Connected.`},a=new Map(n);return a.set(t,[i]),a})},A=(e,t)=>{o(n=>{let r=new Map(n);return r.set(e,t(n.get(e)??[])),r})},j=(e,t)=>{c(n=>{let r=new Map(n);return r.set(e,t(n.get(e)??[])),r})},M=async()=>{if(!l.trim()||!r||d)return;let e=r,n=D(e),i=O(e),a=l.trim();u(``),f(!0),A(i,e=>[...e,{role:`user`,text:a}]);let o=[...s.get(i)??[],{role:`user`,content:a}];j(i,()=>o);try{let r=R_(E()),s=await(await fetch(`/chat`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({agentId:e,...n?{leader:n}:{},message:a,history:o,...r})})).json();if(s.reply){A(i,t=>[...t,{role:`agent`,name:s.colonist||e,text:s.reply}]),j(i,e=>[...e,{role:`assistant`,content:s.reply}]);let n=s.usage;n&&t&&t({totalTokens:n.totalTokens??0,costUSD:n.costUSD??0})}else A(i,e=>[...e,{role:`agent`,text:s.error||`No response`}])}catch(e){A(i,t=>[...t,{role:`agent`,text:`Chat failed: ${e}`}])}f(!1)};return(0,R.jsxs)(`div`,{className:`chat-layout ${Q.layout}`,role:`region`,"aria-label":`Agent chat`,children:[(0,R.jsxs)(`div`,{className:`chat-sidebar ${Q.sidebar}`,children:[(0,R.jsx)(`h3`,{className:Q.sidebarHeading,children:w.length?`${w.length} Agents`:`Agent Chat`}),(0,R.jsx)(`p`,{className:Q.sidebarLead,children:w.length?`Talk to any ${n.labels.populationNoun.replace(/s$/,``)} from the simulation. Each agent has persistent memory, personality, and relationships shaped by the crises they experienced.`:`Chat becomes available after the first turn completes. Start a simulation and come back once agents have reacted to the first crisis. Each agent has persistent memory, personality, and relationships shaped by the crises they experience.`}),_&&g.size>0&&(0,R.jsxs)(`div`,{className:Q.actorFilter,children:[(0,R.jsx)(`label`,{className:Q.actorFilterLabel,htmlFor:`chat-actor-filter`,children:`Lead actor`}),(0,R.jsxs)(`select`,{id:`chat-actor-filter`,className:Q.actorFilterSelect,value:v??``,onChange:e=>y(e.target.value||null),"aria-label":`Filter chat agents by lead actor`,children:[(0,R.jsxs)(`option`,{value:`all`,children:[`All leaders (`,(()=>{let e=new Set;for(let t of g.values())for(let n of t)e.add(n.name);return e.size})(),`)`]}),e.actorIds.map(t=>{let n=g.get(t)?.length??0,r=e.actors[t]?.leader?.name||t;return(0,R.jsxs)(`option`,{value:t,disabled:n===0,children:[r,` (`,n,`)`]},t)})]})]}),C.length>1&&(0,R.jsxs)(`div`,{className:Q.actorFilter,children:[(0,R.jsx)(`label`,{className:Q.actorFilterLabel,htmlFor:`chat-department-filter`,children:`Department`}),(0,R.jsxs)(`select`,{id:`chat-department-filter`,className:Q.actorFilterSelect,value:b??``,onChange:e=>x(e.target.value||null),"aria-label":`Filter chat agents by department`,children:[(0,R.jsxs)(`option`,{value:``,children:[`All departments (`,S.length,`)`]}),C.map(e=>{let t=S.filter(t=>(t.department||``).trim()===e).length;return(0,R.jsxs)(`option`,{value:e,children:[e,` (`,t,`)`]},e)})]})]}),w.map(e=>(0,R.jsxs)(`button`,{onClick:()=>ee(e.name),className:[Q.agentBtn,r===e.name?Q.selected:``].filter(Boolean).join(` `),children:[(0,R.jsx)(`span`,{className:Q.agentName,children:e.name}),(0,R.jsxs)(`div`,{className:Q.agentMeta,children:[e.role,` `,e.department]}),(0,R.jsx)(`div`,{className:Q.agentMood,style:{"--mood-color":mN[e.mood]||`var(--text-3)`},children:e.mood.toUpperCase()})]},e.name))]}),(0,R.jsxs)(`div`,{className:Q.chatArea,children:[T?.memory&&(T.memory.beliefs?.length>0||T.memory.stances?.length>0)&&(0,R.jsxs)(`div`,{className:Q.memoryBar,children:[(0,R.jsx)(`span`,{className:Q.memoryLabel,children:`MEMORY `}),T.memory.beliefs?.slice(0,2).map((e,t)=>(0,R.jsx)(`span`,{className:Q.memoryBelief,children:e},t)),T.memory.stances?.map((e,t)=>(0,R.jsxs)(`span`,{className:Q.memoryStance,style:{"--stance-color":e.value>0?`var(--green)`:`var(--rust)`},children:[e.topic,`: `,e.value>.5?`confident`:e.value>0?`cautious`:`wary`]},t))]}),r&&T?.hexaco&&(0,R.jsxs)(`div`,{className:Q.hexacoStrip,children:[(0,R.jsx)(`span`,{className:Q.hexacoLabel,children:`HEXACO`}),[`O`,`C`,`E`,`A`,`Em`,`HH`].map(e=>{let t=T.hexaco[e],n=Math.round(t*4),r=`█`.repeat(n)+`░`.repeat(4-n);return(0,R.jsxs)(`span`,{title:`${e}: ${t.toFixed(2)}`,className:Q.hexacoTrait,children:[e,` `,(0,R.jsx)(`span`,{className:Q.hexacoBar,children:r}),` `,t.toFixed(2)]},e)}),typeof T.psychScore==`number`&&(0,R.jsxs)(`span`,{className:Q.healthSignal,style:{"--signal-color":T.psychScore<.4?`var(--rust)`:`var(--text-2)`},children:[`psych `,(T.psychScore*100).toFixed(0),`%`]}),typeof T.boneDensity==`number`&&T.boneDensity>0&&(0,R.jsxs)(`span`,{className:Q.healthSignal,style:{"--signal-color":T.boneDensity<70?`var(--rust)`:`var(--text-3)`},children:[`bone `,T.boneDensity.toFixed(0),`%`]}),typeof T.radiation==`number`&&T.radiation>0&&(0,R.jsxs)(`span`,{className:Q.healthSignal,style:{"--signal-color":T.radiation>2e3?`var(--rust)`:`var(--text-3)`},children:[`rad `,T.radiation.toFixed(0),`mSv`]})]}),(0,R.jsxs)(`div`,{ref:p,onScroll:h,className:Q.messages,role:`log`,"aria-live":`polite`,"aria-relevant":`additions`,"aria-label":T?.name?`Messages with ${T.name}`:`Chat messages`,children:[!r&&(0,R.jsxs)(`div`,{className:Q.emptyState,children:[(0,R.jsx)(`div`,{className:Q.emptyTitle,children:w.length?`Select an agent to start chatting.`:`No agents available yet.`}),(0,R.jsx)(`div`,{className:Q.emptyCopy,children:w.length?`Each agent is a simulated ${n.labels.populationNoun.replace(/s$/,``)} with a unique HEXACO personality, persistent memory of events they survived, evolving stances on topics, and relationships with other agents. Their responses reflect their actual simulation experience.`:`Run a simulation from the Settings tab. Once the first turn completes, agents become available for conversation. The chat system uses each agent's personality profile, memory, and event history to generate authentic in-character responses.`})]}),r&&T?.memory&&(0,R.jsx)(gN,{memory:T.memory,events:e,scenario:n}),k.map((e,t)=>(0,R.jsxs)(`div`,{className:[Q.bubbleWrap,e.role===`user`?Q.fromUser:Q.fromAgent].join(` `),children:[e.name&&(0,R.jsx)(`div`,{className:Q.bubbleName,children:e.name}),(0,R.jsx)(`div`,{className:[Q.bubble,e.role===`user`?Q.user:``].filter(Boolean).join(` `),children:e.text})]},t)),d&&r&&(0,R.jsxs)(`div`,{className:[Q.bubbleWrap,Q.fromAgent].join(` `),"aria-live":`polite`,"aria-label":`${T?.name||`Agent`} is typing`,children:[(0,R.jsx)(`div`,{className:Q.bubbleName,children:T?.name||r}),(0,R.jsxs)(`div`,{className:Q.typingBubble,children:[(0,R.jsx)(`span`,{className:Q.typingLabel,children:`typing`}),(0,R.jsx)(`span`,{className:Q.dot,"aria-hidden":`true`,style:{"--dot-delay":`0ms`},children:`.`}),(0,R.jsx)(`span`,{className:Q.dot,"aria-hidden":`true`,style:{"--dot-delay":`160ms`},children:`.`}),(0,R.jsx)(`span`,{className:Q.dot,"aria-hidden":`true`,style:{"--dot-delay":`320ms`},children:`.`})]})]})]}),(0,R.jsxs)(`div`,{className:Q.inputRow,children:[(0,R.jsx)(`input`,{value:l,onChange:e=>u(e.target.value),onKeyDown:e=>e.key===`Enter`&&M(),disabled:!r||d,"aria-label":r?`Message ${T?.name||`agent`}`:`Select an agent first`,placeholder:r?`Ask ${T?.name||`agent`}...`:`Select a ${n.labels.populationNoun.replace(/s$/,``)} first`,className:Q.inputField}),(0,R.jsx)(`button`,{onClick:M,disabled:!r||d||!l.trim(),className:Q.sendBtn,children:`Send`})]})]})]})}var $={empty:`_empty_11d47_2`,emptySpinner:`_emptySpinner_11d47_14`,emptySpinnerRotate:`_emptySpinnerRotate_11d47_1`,root:`_root_11d47_34`,body:`_body_11d47_43`,toolbarStrip:`_toolbarStrip_11d47_55`,toolbarTopRow:`_toolbarTopRow_11d47_64`,modePillsWrap:`_modePillsWrap_11d47_69`,overflowToggle:`_overflowToggle_11d47_88`,overflowToggleOpen:`_overflowToggleOpen_11d47_102`,helpBtn:`_helpBtn_11d47_107`,forgeToolboxKey:`_forgeToolboxKey_11d47_123`,toolsRow:`_toolsRow_11d47_156`,paletteBtn:`_paletteBtn_11d47_170`,toolBtn:`_toolBtn_11d47_184`,settingsBtn:`_settingsBtn_11d47_197`,settingsBtnOpen:`_settingsBtnOpen_11d47_210`,modeHint:`_modeHint_11d47_215`,ecologyNone:`_ecologyNone_11d47_225`,ecologyBack:`_ecologyBack_11d47_236`,diffLine:`_diffLine_11d47_248`,phoneTabRow:`_phoneTabRow_11d47_257`,phoneTab:`_phoneTab_11d47_257`,phoneTabActive:`_phoneTabActive_11d47_284`,leadersRow:`_leadersRow_11d47_290`,leadersRowNarrow:`_leadersRowNarrow_11d47_298`,sideWrap:`_sideWrap_11d47_302`,sideWrapHidden:`_sideWrapHidden_11d47_309`,leadersRowLinesBelow:`_leadersRowLinesBelow_11d47_313`,cohortWindow:`_cohortWindow_11d47_321`,cohortWindowLinesBelow:`_cohortWindowLinesBelow_11d47_325`,cohortTrackLinesBelow:`_cohortTrackLinesBelow_11d47_331`,turnLinesSlot:`_turnLinesSlot_11d47_335`,srOnly:`_srOnly_11d47_350`,jumpLatestAnchor:`_jumpLatestAnchor_11d47_362`,jumpLatest:`_jumpLatest_11d47_362`,"paracosm-jump-pulse":`_paracosm-jump-pulse_11d47_1`,jumpLatestBehind:`_jumpLatestBehind_11d47_391`,toast:`_toast_11d47_399`,"paracosm-toast-in":`_paracosm-toast-in_11d47_1`,toastKicker:`_toastKicker_11d47_418`,toastKickerMeta:`_toastKickerMeta_11d47_430`,toastBody:`_toastBody_11d47_434`,toastBodyMd:`_toastBodyMd_11d47_439`,cohortViewBar:`_cohortViewBar_11d47_451`,cohortViewModeToggle:`_cohortViewModeToggle_11d47_462`,cohortViewModeButton:`_cohortViewModeButton_11d47_471`,cohortViewModeButtonActive:`_cohortViewModeButtonActive_11d47_502`,cohortPairPicker:`_cohortPairPicker_11d47_511`,cohortPairPickerLabel:`_cohortPairPickerLabel_11d47_519`,cohortPairPickerSelect:`_cohortPairPickerSelect_11d47_528`,cohortPairPickerVs:`_cohortPairPickerVs_11d47_551`,cohortPairPickerHint:`_cohortPairPickerHint_11d47_559`};function vN(e){let t=(e.decision||``).split(/[.;]/)[0].trim(),n=t.length>80?t.slice(0,77)+`...`:t,r=e.outcome.startsWith(`risky`),i=e.outcome.endsWith(`success`),a=n.length===0?`held position`:r?i?`gambled on`:`took the risk of`:`chose`,o=n.length===0?``:n.replace(/^(select|implement|issue|move|expand|reduce|slow|initiate|start|deliver)\s+/i,``).replace(/\s+$/,``),s=o.length>0?`${e.actorName} ${a} ${o.toLowerCase()}`:`${e.actorName} ${a}`,c=typeof e.dominantDeaths==`number`&&e.dominantDeaths>0&&e.dominantDeaths<e.deaths;return`${s}${e.deaths>0&&e.dominantCause?c?`, ${e.deaths} lost, ${e.dominantDeaths} to ${e.dominantCause}`:`, ${e.deaths} lost to ${e.dominantCause}`:e.deaths>0?`, ${e.deaths} lost`:``}${e.moraleDelta<=-.08?`; morale cracked`:e.moraleDelta>=.08?`; morale steadied`:``}`}var yN={banner:`_banner_1n1hg_1`,headline:`_headline_1n1hg_12`,collapseBtn:`_collapseBtn_1n1hg_20`,turnLabel:`_turnLabel_1n1hg_39`,title:`_title_1n1hg_43`,categoryPill:`_categoryPill_1n1hg_48`,lineA:`_lineA_1n1hg_58`,lineB:`_lineB_1n1hg_62`,line:`_line_1n1hg_58`,lineLabel:`_lineLabel_1n1hg_78`,lineBody:`_lineBody_1n1hg_85`,lineMore:`_lineMore_1n1hg_91`};function bN(e,t){let n=e.leader?.name??``;if(!n)return null;let r=``,i=``,a=null,o=0,s=0,c=``,l=``,u=0;for(let n of e.events)if((n.data?.turn??-1)===t+1){if((n.type===`turn_start`||n.type===`event_start`)&&(c=String(n.data?.title??c),l=String(n.data?.category??l),u=Number(n.data?.time??u)),n.type===`outcome`){i=String(n.data?.outcome??i);let e=n.data?._decision;typeof e==`string`&&e.length>0&&(r=e);let t=n.data?.systemDeltas?.morale;typeof t==`number`&&Number.isFinite(t)&&(s+=t)}if(n.type===`turn_done`){let e=n.data?.deathCauses;e&&typeof e==`object`&&(a=e)}n.type===`systems_snapshot`&&(o=Number(n.data?.deaths)||0)}let d=o,f=null,p;if(a){let e=0,t=0;for(let[n,r]of Object.entries(a))typeof r!=`number`||r<=0||(e+=r,r>t&&(t=r,f=n));e>0&&(d=e,p=t)}return{actorName:n,decision:r,outcome:i,deaths:d,dominantCause:f,dominantDeaths:p,moraleDelta:s,eventTitle:c,eventCategory:l,time:u}}function xN(e,t){for(let n of e.actorIds){let r=e.actors[n],i=r?bN(r,t)?.eventTitle:``;if(i)return i}return``}var SN=6;function CN({state:e,currentTurn:t,linesTarget:n,cohortGridShown:r=!0}){let i=e.actorIds.length>2,[a,o]=(0,L.useState)(i),s=(0,L.useMemo)(()=>{let n=[];for(let r of e.actorIds){let i=e.actors[r];n.push({actorId:r,summary:i?bN(i,t):null})}return n},[e.actorIds,e.actors,t]).filter(e=>e.summary!==null),c=s.find(e=>e.summary.eventTitle)?.summary.eventTitle||``,l=s.find(e=>e.summary.eventCategory)?.summary.eventCategory||``,u=s.find(e=>e.summary.time)?.summary.time||0;if(!c)return null;let d=s.slice(0,SN),f=s.length-d.length,p=!a,m=s.length>0,h=p?(0,R.jsxs)(R.Fragment,{children:[d.map((e,t)=>(0,R.jsxs)(`div`,{className:s.length<=2?t===0?yN.lineA:yN.lineB:yN.line,children:[(0,R.jsx)(`span`,{className:yN.lineLabel,children:s.length<=2?t===0?`A`:`B`:e.summary.actorName}),(0,R.jsxs)(`span`,{className:yN.lineBody,children:[`: `,vN(e.summary)]})]},e.actorId)),f>0&&(0,R.jsxs)(`div`,{className:yN.lineMore,children:[`+`,f,` more `,`·`,` `,r?`see cohort grid ${n?`above`:`below`} for the rest`:`open All ${e.actorIds.length} actors for the rest`]})]}):null;return(0,R.jsxs)(`div`,{role:`status`,"aria-label":`Current turn narrative`,className:yN.banner,children:[(0,R.jsxs)(`div`,{className:yN.headline,children:[(0,R.jsxs)(`span`,{className:yN.turnLabel,children:[`T`,t+1,u?` \u00b7 ${u}`:``]}),(0,R.jsx)(`span`,{className:yN.title,children:c}),l&&(0,R.jsx)(`span`,{className:yN.categoryPill,children:l}),m&&(0,R.jsx)(`button`,{type:`button`,onClick:()=>o(e=>!e),"aria-expanded":!a,"aria-label":a?`Expand per-actor outcomes`:`Collapse per-actor outcomes`,className:yN.collapseBtn,children:a?`\u25be ${s.length} actors`:`▴ hide`})]}),h&&(n?(0,rE.createPortal)(h,n):h)]})}var wN={row:`_row_c3vre_1`,key:`_key_c3vre_16`,scrub:`_scrub_c3vre_34`,turn:`_turn_c3vre_44`,timeShownAbove:`_timeShownAbove_c3vre_56`,speed:`_speed_c3vre_61`},TN=[.5,1,2,4];function EN({currentTurn:e,maxTurn:t,time:n,timeInBanner:r=!1,playing:i,speed:a,onTurnChange:o,onPlayPause:s,onStepBack:c,onStepForward:l,onSpeedChange:u}){return(0,R.jsxs)(`div`,{className:wN.row,children:[(0,R.jsx)(`button`,{type:`button`,onClick:c,disabled:e<=0,"aria-label":`Previous turn`,className:wN.key,children:`<<`}),(0,R.jsx)(`button`,{type:`button`,onClick:s,disabled:t<=1,"aria-label":i?`Pause`:`Play`,className:wN.key,children:i?`■`:`▶`}),(0,R.jsx)(`button`,{type:`button`,onClick:l,disabled:e>=t-1,"aria-label":`Next turn`,className:wN.key,children:`>>`}),(0,R.jsx)(`input`,{type:`range`,min:0,max:Math.max(0,t-1),value:e,onChange:e=>o(Number(e.target.value)),className:wN.scrub,"aria-label":`Scrub timeline`,"aria-valuetext":`Turn ${e+1} of ${t}`}),(0,R.jsxs)(`span`,{className:wN.turn,children:[`T`,e+1,`/`,t,n?(0,R.jsx)(`span`,{className:r?wN.timeShownAbove:void 0,children:` \u00b7 ${n}`}):null]}),(0,R.jsx)(`select`,{"aria-label":`Playback speed`,value:a,onChange:e=>u(Number(e.target.value)),className:wN.speed,children:TN.map(e=>(0,R.jsxs)(`option`,{value:e,children:[e,`x`]},e))})]})}var DN={row:`_row_2ky0h_1`,hint:`_hint_2ky0h_17`,key:`_key_2ky0h_25`,label:`_label_2ky0h_35`,allKeys:`_allKeys_2ky0h_39`,copy:`_copy_2ky0h_72`},ON=`All keys`;function kN({hints:e,onShowAll:t}){let n=(0,L.useRef)(null),r=(0,L.useRef)(null),[i,a]=(0,L.useState)(e.length);(0,L.useLayoutEffect)(()=>{let t=n.current,i=r.current;if(!t||!i)return;let o=()=>{let n=getComputedStyle(t),r=t.clientWidth-parseFloat(n.paddingLeft)-parseFloat(n.paddingRight)-1,o=parseFloat(n.columnGap)||0,s=Array.from(i.children).map(e=>e.getBoundingClientRect().width),c=s.slice(0,e.length),l=s[e.length]??0,u=c.reduce((e,t)=>e+t,0)+o*Math.max(0,c.length-1),d=e.length;if(u>r){let e=l;d=0;for(let t of c){if(e+o+t>r)break;e+=o+t,d+=1}}let f=Math.max(1,d);a(e=>e===f?e:f)};o();let s=new ResizeObserver(o);return s.observe(t),s.observe(i),()=>s.disconnect()},[e]);let o=i<e.length;return(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{ref:n,className:DN.row,children:[e.slice(0,i).map(e=>(0,R.jsxs)(`span`,{className:DN.hint,children:[(0,R.jsx)(`kbd`,{className:DN.key,children:e.k}),(0,R.jsx)(`span`,{className:DN.label,children:e.v})]},e.k)),o&&(0,R.jsx)(`button`,{type:`button`,onClick:t,"aria-label":`${ON}: the ${e.length} keyboard keys, in the help overlay`,title:`Every keyboard key, in the help overlay`,className:DN.allKeys,children:ON})]}),(0,R.jsxs)(`div`,{ref:r,className:[DN.row,DN.copy].join(` `),"aria-hidden":`true`,children:[e.map(e=>(0,R.jsxs)(`span`,{className:DN.hint,children:[(0,R.jsx)(`span`,{className:DN.key,children:e.k}),(0,R.jsx)(`span`,{className:DN.label,children:e.v})]},e.k)),(0,R.jsx)(`span`,{className:DN.allKeys,children:ON})]})]})}var AN=15,jN=[{key:`living`,label:`LIVING`,hint:`Full field + {person} seeds + all events`},{key:`mood`,label:`MOOD`,hint:`{Person} mood cloud emphasized; births / deaths`},{key:`forge`,label:`FORGE`,hint:`Field dimmed; tool forge attempts + reuse arcs between departments`},{key:`ecology`,label:`ECOLOGY`,hint:`Glyphs hidden; food, water, power and volume tint a quadrant each`},{key:`divergence`,label:`DIVERGENCE`,hint:`Only {people} alive here but dead on the other side`}];function MN(e,t){return e.replace(/\{person\}/g,t.person).replace(/\{Person\}/g,t.Person).replace(/\{people\}/g,t.people).replace(/\{People\}/g,t.People)}function NN(e,t){return MN(jN.find(t=>t.key===e)?.hint??``,t)}function PN({mode:e,onChange:t,counts:n,labels:r}){if(Sy(`(max-width: 480px)`)){let i=jN.find(t=>t.key===e),a=n?.[e],o=`calc(${`${i?.label??``}${typeof a==`number`&&a>0?` · ${a}`:``}`.length} * (1ch + 0.08em) + 44px)`;return(0,R.jsx)(`select`,{"aria-label":`Grid viz mode`,value:e,onChange:e=>t(e.target.value),title:MN(jN.find(t=>t.key===e)?.hint??``,r),style:{flex:`1 1 auto`,width:o,minWidth:o,padding:`8px 10px`,fontSize:16,fontFamily:`var(--mono)`,fontWeight:800,letterSpacing:`0.08em`,textTransform:`uppercase`,background:`var(--bg-card)`,color:`var(--text-1)`,border:`1px solid var(--border)`,borderRadius:6,cursor:`pointer`,minHeight:44},children:jN.map(e=>{let t=n?.[e.key],r=typeof t==`number`&&t>0?` · ${t}`:``;return(0,R.jsxs)(`option`,{value:e.key,children:[e.label,r]},e.key)})})}return(0,R.jsx)(`div`,{role:`tablist`,"aria-label":`Grid viz mode`,style:{display:`flex`,gap:0,padding:`4px 6px`,background:`var(--bg-panel)`,border:`1px solid var(--border)`,borderRadius:6,overflowX:`auto`,scrollbarWidth:`thin`},children:jN.map((i,a)=>{let o=e===i.key,s=n?.[i.key],c=MN(i.hint,r);return(0,R.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":o,"data-grid-mode":i.key,onClick:()=>t(i.key),title:c,style:{flex:`1 0 auto`,padding:`5px 8px`,fontSize:AN,fontFamily:`var(--mono)`,fontWeight:800,letterSpacing:`0.1em`,border:`1px solid var(--border)`,borderLeft:a===0?`1px solid var(--border)`:`none`,borderRadius:a===0?`3px 0 0 3px`:a===jN.length-1?`0 3px 3px 0`:0,background:o?`var(--amber)`:`var(--bg-card)`,color:o?`var(--bg-deep)`:`var(--text-3)`,cursor:`pointer`,textTransform:`uppercase`,transition:`background 120ms, color 120ms`,display:`flex`,alignItems:`center`,justifyContent:`center`,gap:4,whiteSpace:`nowrap`},children:[(0,R.jsx)(`span`,{children:i.label}),typeof s==`number`&&s>0&&(0,R.jsx)(`span`,{style:{padding:`0 4px`,borderRadius:2,background:o?`rgba(10, 8, 6, 0.25)`:`var(--bg-deep)`,color:o?`var(--bg-deep)`:`var(--amber)`,fontSize:AN,fontWeight:700,letterSpacing:`0.05em`,minWidth:14,textAlign:`center`},children:s})]},i.key)})})}var FN={backdrop:`_backdrop_1nhbv_1`,dialog:`_dialog_1nhbv_12`,phone:`_phone_1nhbv_26`,header:`_header_1nhbv_30`,title:`_title_1nhbv_37`,closeBtn:`_closeBtn_1nhbv_47`,section:`_section_1nhbv_60`,sectionTitle:`_sectionTitle_1nhbv_64`,rows:`_rows_1nhbv_75`,row:`_row_1nhbv_75`,rowKey:`_rowKey_1nhbv_89`,rowVal:`_rowVal_1nhbv_96`,swatchWrap:`_swatchWrap_1nhbv_101`,swatch:`_swatch_1nhbv_101`,footer:`_footer_1nhbv_117`,kbd:`_kbd_1nhbv_123`};function IN({open:e,onClose:t}){let n=Sy(wy),r=i_(),i=(0,L.useRef)(null);if((0,L.useLayoutEffect)(()=>{if(!e)return;let t=document.activeElement instanceof HTMLElement?document.activeElement:null;return i.current?.focus({preventScroll:!0}),()=>{t&&t.isConnected&&t.focus({preventScroll:!0})}},[e]),!e)return null;let a=[FN.dialog,n?FN.phone:``].filter(Boolean).join(` `);return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Grid viz help`,"data-viz-help":``,onClick:t,onKeyDown:e=>{e.key===`Tab`&&(e.preventDefault(),i.current?.focus({preventScroll:!0}))},className:FN.backdrop,children:(0,R.jsxs)(`div`,{tabIndex:-1,onClick:e=>e.stopPropagation(),className:a,children:[(0,R.jsxs)(`div`,{className:FN.header,children:[(0,R.jsxs)(`h2`,{className:FN.title,children:[`Living `,r.Place,` Grid — Legend`]}),(0,R.jsx)(`button`,{ref:i,type:`button`,onClick:t,"aria-label":`Close help`,className:FN.closeBtn,children:`×`})]}),(0,R.jsxs)(LN,{title:`Modes`,children:[(0,R.jsx)(RN,{k:`LIVING`,v:`Full chemistry + ${r.person} glyphs + event flares`}),(0,R.jsx)(RN,{k:`MOOD`,v:`Emphasizes ${r.person} seeds + mood-coded chemistry clouds`}),(0,R.jsx)(RN,{k:`FORGE`,v:`Dims field, highlights forge attempts + reuse arcs`}),(0,R.jsx)(RN,{k:`ECOLOGY`,v:`Hides glyphs; food, water, power and volume tint a quadrant each`}),(0,R.jsx)(RN,{k:`DIVERGENCE`,v:`Only shows ${r.people} alive here but dead on the other side`})]}),(0,R.jsxs)(LN,{title:`Grid elements`,children:[(0,R.jsx)(RN,{k:(0,R.jsx)(zN,{color:`rgba(232, 180, 74, 0.9)`}),v:`Warm amber = high vitality (${r.place} thriving)`}),(0,R.jsx)(RN,{k:(0,R.jsx)(zN,{color:`rgba(196, 74, 30, 0.9)`}),v:`Rust red = stress concentration (decay / anxiety)`}),(0,R.jsx)(RN,{k:`○ small ring`,v:`Alive ${r.person}, hover for identity`}),(0,R.jsx)(RN,{k:`◎ thick ring`,v:`Featured ${r.person} (drives narrative this turn)`}),(0,R.jsx)(RN,{k:`○ amber halo`,v:`Diverged ${r.person} — alive here but dead on the other side`}),(0,R.jsx)(RN,{k:`DEPT label`,v:`Cluster centroid label showing dept + live count`})]}),(0,R.jsxs)(LN,{title:`Event flares`,children:[(0,R.jsx)(RN,{k:(0,R.jsx)(zN,{color:`rgba(154, 205, 96, 0.8)`}),v:`Green bloom — birth`}),(0,R.jsx)(RN,{k:(0,R.jsx)(zN,{color:`rgba(168, 152, 120, 0.7)`}),v:`Grey wave — death`}),(0,R.jsx)(RN,{k:(0,R.jsx)(zN,{color:`rgba(232, 180, 74, 0.8)`}),v:`Amber dot — forge approved`}),(0,R.jsx)(RN,{k:(0,R.jsx)(zN,{color:`rgba(224, 101, 48, 0.7)`}),v:`Red flash — forge rejected`}),(0,R.jsx)(RN,{k:(0,R.jsx)(zN,{color:`rgba(232, 180, 74, 0.6)`}),v:`Amber arc — tool reuse across departments`}),(0,R.jsx)(RN,{k:(0,R.jsx)(zN,{color:`rgba(196, 74, 30, 0.8)`}),v:`Red ring — crisis shockwave (category-gated)`})]}),(0,R.jsxs)(LN,{title:`Keyboard`,children:[(0,R.jsx)(RN,{k:`1 / 2 / 3 / 4 / 5`,v:`Switch mode (Living / Mood / Forge / Ecology / Divergence)`}),(0,R.jsx)(RN,{k:`← / →`,v:`Step turn back / forward`}),(0,R.jsx)(RN,{k:`Space`,v:`Play / pause timeline`}),(0,R.jsx)(RN,{k:`?`,v:`Toggle this help overlay`}),(0,R.jsx)(RN,{k:`Esc`,v:`Close popover / this overlay`}),(0,R.jsx)(RN,{k:`click glyph`,v:`Open ${r.person} drilldown (HEXACO radar, memory, chat)`})]}),(0,R.jsxs)(`div`,{className:FN.footer,children:[`Press `,(0,R.jsx)(`kbd`,{className:FN.kbd,children:`?`}),` anytime to reopen.`]})]})})}function LN({title:e,children:t}){return(0,R.jsxs)(`div`,{className:FN.section,children:[(0,R.jsx)(`div`,{className:FN.sectionTitle,children:e}),(0,R.jsx)(`div`,{className:FN.rows,children:t})]})}function RN({k:e,v:t}){return(0,R.jsxs)(`div`,{className:FN.row,children:[(0,R.jsx)(`span`,{className:FN.rowKey,children:e}),(0,R.jsx)(`span`,{className:FN.rowVal,children:t})]})}function zN({color:e}){return(0,R.jsx)(`span`,{className:FN.swatchWrap,children:(0,R.jsx)(`span`,{className:FN.swatch,style:{"--swatch-color":e}})})}var BN={wrap:`_wrap_10oon_1`,legend:`_legend_10oon_8`,legendRight:`_legendRight_10oon_21`,legendA:`_legendA_10oon_27`,legendB:`_legendB_10oon_31`,legendKey:`_legendKey_10oon_35`,svg:`_svg_10oon_39`,tooltip:`_tooltip_10oon_47`,tooltipTurn:`_tooltipTurn_10oon_66`,tooltipRowA:`_tooltipRowA_10oon_74`,tooltipRowB:`_tooltipRowB_10oon_81`,tooltipBold:`_tooltipBold_10oon_88`};function VN({snapsA:e,snapsB:t,currentTurn:n,onJumpToTurn:r,hoveredTurn:i,onHoverTurnChange:a}){let o=Math.max(e.length,t.length);if(o<2)return null;let s=(e,t)=>{if(e.length===0)return``;let n=588/Math.max(1,o-1),r=[],i=!1;return e.forEach((e,a)=>{let o=t(e);if(o===null){i=!1;return}let s=6+a*n,c=3+(1-o)*22;r.push(`${i?`L`:`M`}${s.toFixed(1)},${c.toFixed(1)}`),i=!0}),r.join(` `)},c=e.some(e=>typeof e.foodReserve==`number`),l=t.some(e=>typeof e.foodReserve==`number`),u=c||l,d=[...e,...t].map(e=>e.foodReserve).filter(e=>typeof e==`number`),f=Math.max(18,...d),p=Math.max(1,...e.map(e=>e.population),...t.map(e=>e.population)),m=e=>typeof e.foodReserve==`number`?Math.max(0,Math.min(1,e.foodReserve/f)):null,h=e=>Math.max(0,Math.min(1,e.population/p)),g=e=>Math.max(0,Math.min(1,e.morale)),_=6+n*(588/Math.max(1,o-1)),v=typeof i==`number`?6+i*(588/Math.max(1,o-1)):null,y=(e,t)=>{let n=(e-t.left)/t.width*600,r=Math.round((n-6)/588*(o-1));return Math.max(0,Math.min(o-1,r))};return(0,R.jsxs)(`div`,{className:BN.wrap,children:[(0,R.jsxs)(`div`,{className:BN.legend,children:[(0,R.jsxs)(`span`,{children:[`MORALE · POP`,u?` · FOOD`:``,` · T1 → T`,o]}),(0,R.jsxs)(`span`,{className:BN.legendRight,children:[(0,R.jsx)(`span`,{className:BN.legendA,children:`A`}),(0,R.jsx)(`span`,{className:BN.legendB,children:`B`}),(0,R.jsx)(`span`,{className:BN.legendKey,children:`— morale`}),(0,R.jsx)(`span`,{className:BN.legendKey,children:`··· pop`}),u&&(0,R.jsx)(`span`,{className:BN.legendKey,children:`- - food`})]})]}),(0,R.jsxs)(`svg`,{viewBox:`0 0 600 28`,preserveAspectRatio:`none`,role:`img`,"aria-label":`Timeline sparkline of morale, population${u?`, and food`:``} across both leaders`,onClick:e=>{let t=e.currentTarget.getBoundingClientRect();r(y(e.clientX,t))},onMouseMove:e=>{if(!a)return;let t=e.currentTarget.getBoundingClientRect();a(y(e.clientX,t))},onMouseLeave:()=>{a?.(null)},className:BN.svg,height:28,children:[(0,R.jsx)(`line`,{x1:6,x2:594,y1:14,y2:14,stroke:`var(--border)`,strokeWidth:.5,strokeDasharray:`2 2`}),c&&(0,R.jsx)(`path`,{d:s(e,m),fill:`none`,stroke:`var(--vis)`,strokeWidth:.8,strokeDasharray:`3 2`,opacity:.45}),l&&(0,R.jsx)(`path`,{d:s(t,m),fill:`none`,stroke:`var(--eng)`,strokeWidth:.8,strokeDasharray:`3 2`,opacity:.45}),(0,R.jsx)(`path`,{d:s(e,h),fill:`none`,stroke:`var(--vis)`,strokeWidth:.7,strokeDasharray:`1 2`,opacity:.5}),(0,R.jsx)(`path`,{d:s(t,h),fill:`none`,stroke:`var(--eng)`,strokeWidth:.7,strokeDasharray:`1 2`,opacity:.5}),(0,R.jsx)(`path`,{d:s(e,g),fill:`none`,stroke:`var(--vis)`,strokeWidth:1.3}),(0,R.jsx)(`path`,{d:s(t,g),fill:`none`,stroke:`var(--eng)`,strokeWidth:1.3}),v!==null&&i!==n&&(0,R.jsx)(`line`,{x1:v,x2:v,y1:0,y2:28,stroke:`var(--text-3)`,strokeWidth:.75,strokeDasharray:`2 3`,opacity:.7}),(0,R.jsx)(`line`,{x1:_,x2:_,y1:0,y2:28,stroke:`var(--amber)`,strokeWidth:1})]}),typeof i==`number`&&(()=>{let n=e[i],r=t[i];if(!n&&!r)return null;let a=i/Math.max(1,o-1)*100,s={"--hover-left":`calc(${a}% + 8px)`,"--hover-translate":a>75?`translateX(calc(-100% - 16px))`:`none`};return(0,R.jsxs)(`div`,{className:BN.tooltip,style:s,children:[(0,R.jsxs)(`div`,{className:BN.tooltipTurn,children:[`T`,i+1,n?.time?` · ${n.time}`:``]}),n&&(0,R.jsxs)(`div`,{className:BN.tooltipRowA,children:[(0,R.jsx)(`span`,{className:BN.tooltipBold,children:`A`}),(0,R.jsxs)(`span`,{children:[`pop `,n.population]}),(0,R.jsxs)(`span`,{children:[`· `,Math.round(n.morale*100),`% mor`]}),typeof n.foodReserve==`number`&&(0,R.jsxs)(`span`,{children:[`· `,n.foodReserve.toFixed(1),`mo`]}),(n.births>0||n.deaths>0)&&(0,R.jsxs)(`span`,{children:[`· +`,n.births,`/-`,n.deaths]})]}),r&&(0,R.jsxs)(`div`,{className:BN.tooltipRowB,children:[(0,R.jsx)(`span`,{className:BN.tooltipBold,children:`B`}),(0,R.jsxs)(`span`,{children:[`pop `,r.population]}),(0,R.jsxs)(`span`,{children:[`· `,Math.round(r.morale*100),`% mor`]}),typeof r.foodReserve==`number`&&(0,R.jsxs)(`span`,{children:[`· `,r.foodReserve.toFixed(1),`mo`]}),(r.births>0||r.deaths>0)&&(0,R.jsxs)(`span`,{children:[`· +`,r.births,`/-`,r.deaths]})]})]})})()]})}var HN={bar:`_bar_1fy3w_1`,barRow:`_barRow_1fy3w_7`,heading:`_heading_1fy3w_12`,filterRow:`_filterRow_1fy3w_22`,filterChip:`_filterChip_1fy3w_28`,active:`_active_1fy3w_49`,dotsRow:`_dotsRow_1fy3w_56`,dot:`_dot_1fy3w_56`,hovered:`_hovered_1fy3w_91`,current:`_current_1fy3w_97`},UN=[{key:`all`,label:`All`},{key:`birth`,label:`Births`},{key:`death`,label:`Deaths`},{key:`forge`,label:`Forges`},{key:`crisis`,label:`Crises`}],WN={birth:`rgba(154, 205, 96, 0.95)`,death:`rgba(200, 95, 80, 0.95)`,forge:`rgba(232, 180, 74, 0.95)`,crisis:`rgba(196, 74, 30, 0.95)`},GN={birth:`+`,death:`×`,forge:`▲`,crisis:`⚡`};function KN({eventsA:e,eventsB:t,currentTurn:n,onJumpToTurn:r,onHoverTurnChange:i,hoveredTurn:a,onForgeSelect:o,filter:s,onFilterChange:c,onHoverEventChange:l,onJumpToReports:u}){let d=(0,L.useMemo)(()=>{let n=[],r=(e,t)=>{for(let r of e){let e=Number(r.turn??r.data?.turn??0);if(!(e<=0)){if(r.type===`birth`)n.push({turn:e,kind:`birth`,side:t,label:`T${e}: birth (${t.toUpperCase()})`});else if(r.type===`death`){let i=typeof r.data?.name==`string`?r.data.name:``;n.push({turn:e,kind:`death`,side:t,label:`T${e}: ${i?i+` died`:`death`} (${t.toUpperCase()})`})}else if(r.type===`forge_attempt`){let i=typeof r.data?.name==`string`?r.data.name:`tool`,a=r.data?.approved===!0;n.push({turn:e,kind:`forge`,side:t,label:`T${e}: ${a?`forged`:`rejected`} ${i} (${t.toUpperCase()})`,toolName:i,eventId:r.id})}else if(r.type===`event_start`||r.type===`director_crisis`){let i=typeof r.data?.category==`string`?r.data.category:``;i&&[`political`,`social`,`infrastructure`,`medical`,`resource`,`environmental`].includes(i)&&n.push({turn:e,kind:`crisis`,side:t,label:`T${e}: ${i} crisis (${t.toUpperCase()})`})}}}};return r(e,`a`),r(t,`b`),n.sort((e,t)=>e.turn-t.turn),n.slice(-60)},[e,t]),[f,p]=(0,L.useState)(`all`),m=s??f,h=e=>{s===void 0&&p(e),c?.(e)},g=(0,L.useMemo)(()=>m===`all`?d:d.filter(e=>e.kind===m),[d,m]);return d.length===0?null:(0,R.jsxs)(Qk,{label:`events`,className:HN.bar,rowClassName:HN.barRow,role:`group`,ariaLabel:`Event filter`,children:[(0,R.jsxs)(`span`,{className:HN.heading,children:[`Events (`,g.length,m===`all`?``:`/${d.length}`,`)`]}),(0,R.jsx)(`div`,{className:HN.filterRow,children:UN.map(e=>{let t=m===e.key;return(0,R.jsx)(`button`,{type:`button`,onClick:()=>h(e.key),"aria-pressed":t,className:[HN.filterChip,t?HN.active:``].filter(Boolean).join(` `),children:e.label},e.key)})}),(0,R.jsx)(`div`,{className:HN.dotsRow,children:g.map((e,t)=>{let s=Math.max(0,e.turn-1),c=s===n,d=a===s,f=[HN.dot,c?HN.current:``,d?HN.hovered:``].filter(Boolean).join(` `),p={"--kind-color":WN[e.kind],"--side-shift":e.side===`a`?`-2px`:`2px`};return(0,R.jsx)(`button`,{type:`button`,onClick:t=>{t.shiftKey&&u?(t.preventDefault(),u(e.turn)):e.kind===`forge`&&e.toolName&&o&&o(e.toolName,e.side,e.eventId,t.currentTarget)!==!1||r(s)},onMouseEnter:()=>{i?.(s),l?.({kind:e.kind,side:e.side,turn:e.turn})},onMouseLeave:()=>{i?.(null),l?.(null)},onFocus:()=>{i?.(s),l?.({kind:e.kind,side:e.side,turn:e.turn})},onBlur:()=>{i?.(null),l?.(null)},title:`${e.label}${u?` · Shift+click to open in Reports`:``}`,"aria-label":e.label,className:f,style:p,children:GN[e.kind]},`${e.turn}-${e.side}-${e.kind}-${t}`)})})]})}var qN={bar:`_bar_8kqw0_1`,row:`_row_8kqw0_9`,label:`_label_8kqw0_21`,track:`_track_8kqw0_26`,fill:`_fill_8kqw0_35`,count:`_count_8kqw0_42`};function JN(e){let t=0;for(let n=e.length-1;n>=0;n--){let r=e[n];if(r.type===`turn_done`){let e=Number(r.turn??r.data?.turn??0);if(e>0){t=e;break}}}let n=t+1,r=new Set,i=!1;for(let t of e){let e=Number(t.turn??t.data?.turn??0);if(t.type===`specialist_done`&&e===n){let e=typeof t.data?.department==`string`?t.data.department:``;e&&r.add(e),i=!0}if(t.type===`turn_done`&&e===n)return{inFlightTurn:null,deptsReported:new Set}}return{inFlightTurn:i?n:null,deptsReported:r}}function YN({eventsA:e,eventsB:t,totalDepartments:n}){let r=(0,L.useMemo)(()=>JN(e),[e]),i=(0,L.useMemo)(()=>JN(t),[t]);if(r.inFlightTurn===null&&i.inFlightTurn===null)return null;let a=Math.max(1,n),o=(e,t,n)=>{if(n.inFlightTurn===null)return null;let r=Math.min(100,n.deptsReported.size/a*100);return(0,R.jsxs)(`div`,{className:qN.row,style:{"--side-color":t},children:[(0,R.jsx)(`span`,{className:qN.label,children:e}),(0,R.jsxs)(`span`,{children:[`T`,n.inFlightTurn]}),(0,R.jsx)(`div`,{className:qN.track,children:(0,R.jsx)(`div`,{className:qN.fill,style:{"--bar-pct":`${r}%`}})}),(0,R.jsxs)(`span`,{className:qN.count,children:[n.deptsReported.size,`/`,a]})]})};return(0,R.jsxs)(`div`,{"aria-live":`polite`,className:qN.bar,children:[o(`A`,`var(--vis)`,r),o(`B`,`var(--eng)`,i)]})}var XN={bar:`_bar_rh5se_1`,icon:`_icon_rh5se_11`,label:`_label_rh5se_21`,input:`_input_rh5se_29`,dropdown:`_dropdown_rh5se_42`,option:`_option_rh5se_65`,sidePill:`_sidePill_rh5se_86`,optionName:`_optionName_rh5se_96`,optionMeta:`_optionMeta_rh5se_106`,featuredPill:`_featuredPill_rh5se_115`,moreNote:`_moreNote_rh5se_124`,matchCount:`_matchCount_rh5se_132`,clearBtn:`_clearBtn_rh5se_140`};function ZN({value:e,onChange:t,matches:n,onPick:r}){let i=(0,L.useRef)(null),[a,o]=(0,L.useState)(!1),s=n.length,c=i_();(0,L.useEffect)(()=>{let e=e=>{let t=e.target?.tagName;t!==`INPUT`&&t!==`TEXTAREA`&&t!==`SELECT`&&e.key===`/`&&(e.preventDefault(),i.current?.focus())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[]);let l=a&&e.trim().length>0&&n.length>0;return(0,R.jsxs)(`div`,{className:XN.bar,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:XN.icon,title:`Search agents`,children:`🔍`}),(0,R.jsx)(`span`,{className:XN.label,children:`Find`}),(0,R.jsx)(`input`,{ref:i,type:`text`,value:e,onChange:e=>t(e.target.value),onFocus:()=>o(!0),onBlur:()=>setTimeout(()=>o(!1),120),placeholder:`${c.person} name, dept, mood… (space-separate to AND-match; / to focus)`,"aria-label":`Search ${c.people} by name, department, role, or mood`,className:XN.input}),l&&(0,R.jsxs)(`div`,{role:`listbox`,className:XN.dropdown,children:[n.slice(0,10).map((e,t)=>(0,R.jsxs)(`button`,{type:`button`,role:`option`,"aria-selected":`false`,onMouseDown:t=>{t.preventDefault(),r?.(e)},className:XN.option,style:{"--result-color":e.sideColor},children:[(0,R.jsx)(`span`,{className:XN.sidePill,children:e.side.toUpperCase()}),(0,R.jsx)(`span`,{className:XN.optionName,children:e.cell.name}),(0,R.jsxs)(`span`,{className:XN.optionMeta,children:[e.cell.department?.toUpperCase?.()||``,` · `,e.cell.mood,typeof e.cell.age==`number`?` · age ${e.cell.age}`:``]}),e.cell.featured&&(0,R.jsx)(`span`,{className:XN.featuredPill,children:`FEATURED`})]},`${e.side}-${e.cell.agentId}-${t}`)),n.length>10&&(0,R.jsxs)(`div`,{className:XN.moreNote,children:[`+ `,n.length-10,` more…`]})]}),e&&(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`span`,{className:XN.matchCount,style:{"--count-color":s>0?`var(--amber)`:`var(--rust)`},children:[s,` match`,s===1?``:`es`]}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>t(``),"aria-label":`Clear search`,className:XN.clearBtn,children:`clear`})]})]})}function QN(e,t,n,r=.04,i=`sine`){let a=e.currentTime,o=e.createOscillator(),s=e.createGain();o.type=i,o.frequency.setValueAtTime(t,a),s.gain.setValueAtTime(0,a),s.gain.linearRampToValueAtTime(r,a+.008),s.gain.exponentialRampToValueAtTime(1e-4,a+n),o.connect(s),s.connect(e.destination),o.start(a),o.stop(a+n+.02)}function $N(e,t){switch(t){case`birth`:QN(e,880,.18,.05,`triangle`),setTimeout(()=>QN(e,1320,.12,.03,`triangle`),70);break;case`death`:QN(e,160,.35,.05,`sine`);break;case`forge`:QN(e,660,.12,.04,`sine`);break;case`crisis`:QN(e,220,.22,.05,`sawtooth`),setTimeout(()=>QN(e,180,.18,.045,`sawtooth`),120)}}function eP(e){let t=(0,L.useRef)(null),n=(0,L.useRef)(new Set),r=(0,L.useRef)(-1),i=(0,L.useRef)(-1),a=()=>{if(!e.enabled)return null;if(t.current)return t.current;try{let e=window.AudioContext??window.webkitAudioContext;return e?(t.current=new e,t.current):null}catch{return null}};(0,L.useEffect)(()=>{if(!e.enabled)return;let n=()=>{let e=t.current;e&&e.state===`suspended`&&e.resume().catch(()=>{})};return window.addEventListener(`click`,n),window.addEventListener(`keydown`,n),()=>{window.removeEventListener(`click`,n),window.removeEventListener(`keydown`,n)}},[e.enabled]),(0,L.useEffect)(()=>{if(!e.enabled)return;let t=(e,t,r,i)=>{if(!e||!t||e.turn===i.current)return;i.current=e.turn;let o=a();if(!o)return;let s=Sx(t.cells,e.cells),c=0,l=0;for(let t of s.born){let i=`${r}|t${e.turn}|birth|${t.agentId}`;n.current.has(i)||(n.current.add(i),c+=1)}for(let t of s.died){let i=`${r}|t${e.turn}|death|${t.agentId}`;n.current.has(i)||(n.current.add(i),l+=1)}c>0&&$N(o,`birth`),l>0&&setTimeout(()=>$N(o,`death`),c>0?300:0)};t(e.snapshotA,e.prevSnapshotA,`a`,r),t(e.snapshotB,e.prevSnapshotB,`b`,i)},[e.enabled,e.snapshotA,e.prevSnapshotA,e.snapshotB,e.prevSnapshotB]),(0,L.useEffect)(()=>{if(!e.enabled)return;let t=a();if(!t)return;let r=(e,r)=>{for(let i of e){if(!i.approved)continue;let e=`${r}|forge|${i.turn}|${i.eventIndex}|${i.name}`;n.current.has(e)||(n.current.add(e),$N(t,`forge`))}};r(e.forgeAttemptsA,`a`),r(e.forgeAttemptsB,`b`)},[e.enabled,e.forgeAttemptsA,e.forgeAttemptsB])}var tP={backdrop:`_backdrop_kf49u_1`,dialog:`_dialog_kf49u_12`,header:`_header_kf49u_24`,title:`_title_kf49u_31`,closeBtn:`_closeBtn_kf49u_41`,sidesRow:`_sidesRow_kf49u_54`,sideBlock:`_sideBlock_kf49u_61`,sideName:`_sideName_kf49u_71`,statsGrid:`_statsGrid_kf49u_81`,cell:`_cell_kf49u_87`,cellLabel:`_cellLabel_kf49u_93`,cellValue:`_cellValue_kf49u_101`,empty:`_empty_kf49u_108`,divergenceBox:`_divergenceBox_kf49u_113`,divergenceLabel:`_divergenceLabel_kf49u_125`,divergenceCount:`_divergenceCount_kf49u_132`,divergenceCopy:`_divergenceCopy_kf49u_138`};function nP(e){if(e.length===0)return null;let t=0,n=0,r=0,i=0,a=0,o=0,s=1/0,c=1/0;for(let l of e)t+=l.births,n+=l.deaths,l.population>r&&(r=l.population),i+=l.morale,typeof l.foodReserve==`number`&&(a+=l.foodReserve,o++,l.foodReserve<c&&(c=l.foodReserve)),l.morale<s&&(s=l.morale);return{turns:e.length,totalBirths:t,totalDeaths:n,peakPop:r,finalPop:e[e.length-1].population,avgMorale:i/e.length,minMorale:s===1/0?0:s,avgFood:o>0?a/o:void 0,minFood:o>0?c:void 0}}function rP(e){let{open:t,onClose:n}=e,r=i_();(0,L.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&(e.preventDefault(),n())};return document.addEventListener(`keydown`,e),()=>document.removeEventListener(`keydown`,e)},[t,n]);let i=(0,L.useMemo)(()=>nP(e.snapsA),[e.snapsA]),a=(0,L.useMemo)(()=>nP(e.snapsB),[e.snapsB]);if(!t)return null;let o=(e,t,n)=>(0,R.jsxs)(`div`,{className:tP.cell,children:[(0,R.jsx)(`span`,{className:tP.cellLabel,children:e}),(0,R.jsx)(`span`,{className:tP.cellValue,style:n?{"--val-color":n}:void 0,children:t})]}),s=(e,t,n,r,i)=>(0,R.jsxs)(`div`,{className:tP.sideBlock,style:{"--side-color":t},children:[(0,R.jsx)(`div`,{className:tP.sideName,children:e}),n?(0,R.jsxs)(`div`,{className:tP.statsGrid,children:[o(`Turns`,`${n.turns}`),o(`Final pop`,`${n.finalPop}`,t),o(`Peak pop`,`${n.peakPop}`),o(`Total births`,`${n.totalBirths}`,`rgba(106, 173, 72, 0.95)`),o(`Total deaths`,`${n.totalDeaths}`,`rgba(200, 95, 80, 0.95)`),o(`Avg morale`,`${Math.round(n.avgMorale*100)}%`),o(`Min morale`,`${Math.round(n.minMorale*100)}%`,n.minMorale<.3?`var(--rust)`:`var(--text-1)`),n.minFood!==void 0&&o(`Min food`,`${n.minFood.toFixed(1)}mo`,n.minFood<3?`var(--rust)`:`var(--text-1)`),o(`Tools forged`,`${r}`,`var(--amber)`),o(`Tool reuses`,`${i}`,`var(--amber)`)]}):(0,R.jsx)(`div`,{className:tP.empty,children:`No snapshots yet.`})]});return(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Run summary`,onClick:n,className:tP.backdrop,children:(0,R.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:tP.dialog,children:[(0,R.jsxs)(`div`,{className:tP.header,children:[(0,R.jsxs)(`h2`,{className:tP.title,children:[`Run Summary · `,e.snapsA.length||e.snapsB.length,` turns`]}),(0,R.jsx)(`button`,{type:`button`,onClick:n,"aria-label":`Close run summary`,className:tP.closeBtn,children:`×`})]}),(0,R.jsxs)(`div`,{className:tP.sidesRow,children:[s(e.actorNameA,`var(--vis)`,i,e.forgeApprovedA,e.reuseCountA),s(e.actorNameB,`var(--eng)`,a,e.forgeApprovedB,e.reuseCountB)]}),(0,R.jsxs)(`div`,{className:tP.divergenceBox,children:[(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`div`,{className:tP.divergenceLabel,children:`Divergence`}),(0,R.jsx)(`div`,{className:tP.divergenceCount,children:e.divergedCount})]}),(0,R.jsxs)(`div`,{className:tP.divergenceCopy,children:[r.People,` alive on one side but dead on the other at the final snapshot — a measure of how much the two leaders' decisions diverged the outcomes.`]})]})]})})}var iP={anchor:`_anchor_1bjr0_1`,trigger:`_trigger_1bjr0_5`,triggerOpen:`_triggerOpen_1bjr0_21`,recDot:`_recDot_1bjr0_27`,"paracosm-rec-pulse":`_paracosm-rec-pulse_1bjr0_1`,menu:`_menu_1bjr0_36`,item:`_item_1bjr0_51`,itemRecording:`_itemRecording_1bjr0_71`,itemKey:`_itemKey_1bjr0_75`,itemKeyRecording:`_itemKeyRecording_1bjr0_81`,itemDesc:`_itemDesc_1bjr0_85`},aP=8,oP=4,sP={top:0,left:0,visibility:`hidden`},cP=`a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])`;function lP(e){let t=e.getBoundingClientRect(),n=t.left+t.width/2,r=t.top+t.height/2;if(n<0||r<0||n>window.innerWidth||r>window.innerHeight)return!1;for(let t=e.parentElement;t&&t!==document.body;t=t.parentElement){let e=getComputedStyle(t);if(e.overflowX===`visible`&&e.overflowY===`visible`)continue;let i=t.getBoundingClientRect();if(n<i.left||n>i.right||r<i.top||r>i.bottom)return!1}return!0}function uP({recording:e,onExportPng:t,onExportJson:n,onToggleRecording:r}){let[i,a]=(0,L.useState)(!1),[o,s]=(0,L.useState)(null),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(null),d=(0,L.useRef)(!1),f=()=>Array.from(u.current?.querySelectorAll(`[role="menuitem"]`)??[]),p=(0,L.useCallback)(e=>{a(!1),e&&l.current?.focus()},[]);(0,L.useLayoutEffect)(()=>{if(!i){s(null);return}let e=()=>{let e=l.current;if(!e)return;if(!lP(e)){a(!1);return}let t=e.getBoundingClientRect(),n=window.innerHeight-t.bottom-oP-aP,r=t.top-oP-aP,i=(u.current?.scrollHeight??0)>n&&r>n;s({...i?{bottom:window.innerHeight-t.top+oP,maxHeight:Math.max(0,r)}:{top:t.bottom+oP,maxHeight:Math.max(0,n)},...t.right>=188?{right:Math.max(aP,window.innerWidth-t.right)}:{left:Math.max(aP,t.left)}})};e(),window.addEventListener(`resize`,e),document.addEventListener(`scroll`,e,!0);let t=()=>{let e=l.current?.getBoundingClientRect();return e?`${e.left} ${e.top} ${e.right} ${e.bottom}`:``},n=t(),r=0,o=()=>{let i=t();i!==n&&(n=i,e()),r=requestAnimationFrame(o)};return r=requestAnimationFrame(o),()=>{cancelAnimationFrame(r),window.removeEventListener(`resize`,e),document.removeEventListener(`scroll`,e,!0)}},[i]),(0,L.useLayoutEffect)(()=>{i&&o&&d.current&&(d.current=!1,u.current?.querySelector(`[role="menuitem"]`)?.focus({preventScroll:!0}))},[i,o]),(0,L.useEffect)(()=>{if(!i)return;let e=e=>{let t=e.target;c.current?.contains(t)||u.current?.contains(t)||a(!1)},t=e=>{e.key===`Escape`&&a(!1)};return document.addEventListener(`mousedown`,e),document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`mousedown`,e),document.removeEventListener(`keydown`,t)}},[i]);let m=e=>{let t=f(),n=t.indexOf(document.activeElement);if(e.key===`ArrowDown`||e.key===`ArrowUp`){e.preventDefault();let r=e.key===`ArrowDown`?1:-1;t[n<0?r>0?0:t.length-1:(n+r+t.length)%t.length]?.focus()}else if(e.key===`Home`||e.key===`End`)e.preventDefault(),t[e.key===`Home`?0:t.length-1]?.focus();else if(e.key===`Escape`)e.preventDefault(),p(!0);else if(e.key===`Tab`){e.preventDefault();let t=l.current;if(p(!0),!e.shiftKey&&t){let e=Array.from(document.querySelectorAll(cP)).filter(e=>!u.current?.contains(e)&&e.getClientRects().length>0);e[e.indexOf(t)+1]?.focus()}}},h=e=>()=>{p(!0),e()};return(0,R.jsxs)(`div`,{ref:c,className:iP.anchor,children:[(0,R.jsxs)(`button`,{ref:l,type:`button`,onClick:()=>{i||(d.current=!0),a(e=>!e)},"aria-expanded":i,"aria-haspopup":`menu`,"aria-label":`Export options`,title:e?`Recording in progress — click for options`:`Export options`,className:[iP.trigger,i?iP.triggerOpen:``].filter(Boolean).join(` `),children:[e&&(0,R.jsx)(`span`,{"aria-hidden":`true`,className:iP.recDot}),`EXPORT ▼`]}),i&&(0,rE.createPortal)((0,R.jsxs)(`div`,{ref:u,role:`menu`,className:iP.menu,style:o??sP,onKeyDown:m,children:[(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:h(t),className:iP.item,children:[(0,R.jsx)(`span`,{className:iP.itemKey,children:`PNG`}),(0,R.jsx)(`span`,{className:iP.itemDesc,children:`Current frame`})]}),(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:h(r),className:[iP.item,e?iP.itemRecording:``].filter(Boolean).join(` `),children:[(0,R.jsx)(`span`,{className:[iP.itemKey,e?iP.itemKeyRecording:``].filter(Boolean).join(` `),children:e?`STOP`:`REC`}),(0,R.jsx)(`span`,{className:iP.itemDesc,children:e?`End recording & download`:`Timelapse to webm`})]}),(0,R.jsxs)(`button`,{type:`button`,role:`menuitem`,onClick:h(n),className:iP.item,children:[(0,R.jsx)(`span`,{className:iP.itemKey,children:`JSON`}),(0,R.jsx)(`span`,{className:iP.itemDesc,children:`Replay snapshot`})]})]}),document.body)]})}var dP={strip:`_strip_1s1qt_1`,text:`_text_1s1qt_20`,expand:`_expand_1s1qt_24`},fP=120;function pP({text:e,turn:t}){let[n,r]=(0,L.useState)(!1),i=e.length>fP,a=i&&!n?`${e.slice(0,119)}…`:e;return(0,R.jsxs)(`div`,{className:dP.strip,role:`status`,"aria-live":`polite`,"aria-atomic":`true`,"data-turn":t,children:[(0,R.jsx)(`span`,{className:dP.text,children:a}),i&&(0,R.jsx)(`button`,{type:`button`,className:dP.expand,onClick:()=>r(e=>!e),"aria-expanded":n,children:n?`Less`:`More`})]})}var mP={bar:`_bar_1ddto_1`,glyphRow:`_glyphRow_1ddto_27`,mark:`_mark_1ddto_40`,label:`_label_1ddto_48`,glyph:`_glyph_1ddto_27`,band:`_band_1ddto_59`,agent:`_agent_1ddto_63`,featured:`_featured_1ddto_69`,turn:`_turn_1ddto_76`,fullLegend:`_fullLegend_1ddto_88`,popover:`_popover_1ddto_116`,popHeading:`_popHeading_1ddto_134`,deptSwatch:`_deptSwatch_1ddto_162`,markList:`_markList_1ddto_172`,closeBtn:`_closeBtn_1ddto_178`},hP=[{type:`band`,label:`Department band`},{type:`agent`,label:`Agent`},{type:`featured`,label:`Featured agent`},{type:`turn`,label:`Turn marker`}];function gP({departments:e}){let[t,n]=(0,L.useState)(!1),r=Qr(t),i=(0,L.useRef)(null);return(0,L.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)},r=e=>{let t=e.target;t&&i.current&&!i.current.contains(t)&&n(!1)};return window.addEventListener(`keydown`,e),window.addEventListener(`mousedown`,r),()=>{window.removeEventListener(`keydown`,e),window.removeEventListener(`mousedown`,r)}},[t]),(0,R.jsxs)(`div`,{className:mP.bar,"aria-label":`Visualization legend`,ref:i,children:[(0,R.jsx)(`span`,{className:mP.glyphRow,children:hP.map(({type:e,label:t})=>(0,R.jsxs)(`span`,{className:mP.mark,children:[(0,R.jsx)(_P,{type:e}),(0,R.jsx)(`span`,{className:mP.label,children:t})]},e))}),(0,R.jsx)(`button`,{type:`button`,className:mP.fullLegend,onClick:()=>n(e=>!e),"aria-expanded":t,"aria-haspopup":`dialog`,children:`Show full legend`}),t&&(0,R.jsxs)(`div`,{className:mP.popover,role:`dialog`,"aria-modal":`true`,"aria-labelledby":`viz-legend-heading`,tabIndex:-1,ref:r,children:[(0,R.jsx)(`h3`,{id:`viz-legend-heading`,className:mP.popHeading,children:`What you’re looking at`}),(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h4`,{children:`Marks on the grid`}),(0,R.jsx)(`ul`,{className:mP.markList,children:hP.map(({type:e,label:t})=>(0,R.jsxs)(`li`,{children:[(0,R.jsx)(_P,{type:e}),(0,R.jsx)(`span`,{children:t})]},e))})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h4`,{children:`Departments (tile color)`}),(0,R.jsx)(`ul`,{className:mP.deptList,children:e.map(e=>(0,R.jsxs)(`li`,{children:[(0,R.jsx)(`span`,{className:mP.deptSwatch,style:{background:e.color},"aria-hidden":`true`}),e.label]},e.id))})]}),(0,R.jsxs)(`section`,{children:[(0,R.jsx)(`h4`,{children:`Mood tiers (chip glyph)`}),(0,R.jsxs)(`ul`,{className:mP.moodList,children:[(0,R.jsxs)(`li`,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`▼`}),` low (under 25% morale)`]}),(0,R.jsxs)(`li`,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`▽`}),` tense (25–50%)`]}),(0,R.jsxs)(`li`,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`△`}),` steady (50–75%)`]}),(0,R.jsxs)(`li`,{children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,children:`▲`}),` rising (over 75%)`]})]})]}),(0,R.jsx)(`button`,{type:`button`,className:mP.closeBtn,onClick:()=>n(!1),"aria-label":`Close legend`,children:`Close (Esc)`})]})]})}function _P({type:e}){switch(e){case`band`:return(0,R.jsx)(`span`,{className:`${mP.glyph} ${mP.band}`,"aria-hidden":`true`});case`agent`:return(0,R.jsx)(`span`,{className:`${mP.glyph} ${mP.agent}`,"aria-hidden":`true`});case`featured`:return(0,R.jsx)(`span`,{className:`${mP.glyph} ${mP.featured}`,"aria-hidden":`true`});case`turn`:return(0,R.jsx)(`span`,{className:`${mP.glyph} ${mP.turn}`,"aria-hidden":`true`,children:`T`})}}var vP={panel:`_panel_1j3g5_1`,eyebrow:`_eyebrow_1j3g5_15`,empty:`_empty_1j3g5_23`,chipRow:`_chipRow_1j3g5_27`,chip:`_chip_1j3g5_27`,chipLight:`_chipLight_1j3g5_47`,chipStrong:`_chipStrong_1j3g5_53`,chipDept:`_chipDept_1j3g5_59`,chipCount:`_chipCount_1j3g5_63`},yP=8;function bP({diff:e,departmentLabels:t}){let n=Array.from(e.entries()).filter(([,e])=>e.magnitude>0).sort(([,e],[,t])=>t.magnitude-e.magnitude).slice(0,yP);return n.length===0?(0,R.jsxs)(`div`,{className:vP.panel,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:vP.eyebrow,children:`Divergence detail`}),(0,R.jsx)(`span`,{className:vP.empty,children:`No department-level divergence at this turn.`})]}):(0,R.jsxs)(`div`,{className:vP.panel,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:vP.eyebrow,children:`Divergence detail`}),(0,R.jsx)(`ul`,{className:vP.chipRow,children:n.map(([e,n])=>{let r=t[e]??e,i=n.magnitude>=.5,a=`${r}: A has ${n.aState.agentCount} agents (${n.aState.dominantMood} mood); B has ${n.bState.agentCount} agents (${n.bState.dominantMood} mood)`;return(0,R.jsxs)(`li`,{className:`${vP.chip} ${i?vP.chipStrong:vP.chipLight}`,title:a,"aria-label":a,children:[(0,R.jsx)(`span`,{className:vP.chipDept,children:r}),(0,R.jsxs)(`span`,{className:vP.chipCount,children:[`A `,n.aState.agentCount,` / B `,n.bState.agentCount]})]},e)})})]})}var xP=.2;function SP(e,t){return{population:e.population,morale:e.morale,deathsThisTurn:e.deaths,birthsThisTurn:e.births,eventCategories:e.eventCategories??[],year:e.time}}var CP={nameA:`Leader A`,nameB:`Leader B`,person:`colonist`,people:`colonists`,places:`colonies`};function wP(e,t,n,r=CP){if(!e||!t)return`Awaiting first turn snapshot.`;let i=e.year??t.year;if(e.deathsThisTurn!==t.deathsThisTurn){let a=e.deathsThisTurn>t.deathsThisTurn,o=a?r.nameA:r.nameB,s=a?r.nameB:r.nameA,c=Math.max(e.deathsThisTurn,t.deathsThisTurn),l=Math.min(e.deathsThisTurn,t.deathsThisTurn),u=e=>e===0?`none`:`${e} ${e===1?r.person:r.people}`;return`Turn ${n}, year ${i}: ${o} lost ${u(c)}; ${s} lost ${u(l)}.`}if(Math.abs(e.morale-t.morale)>=xP){let a=e.morale<t.morale,o=a?r.nameA:r.nameB,s=a?r.nameB:r.nameA,c=a?e.morale:t.morale,l=a?t.morale:e.morale;return`Turn ${n}, year ${i}: ${o}'s morale collapsed to ${TP(c)}; ${s} held ${TP(l)}.`}let a=e.eventCategories.join(`|`),o=t.eventCategories.join(`|`);return a&&o&&a!==o?`Turn ${n}, year ${i}: different events. ${r.nameA}: ${e.eventCategories.join(`, `)}; ${r.nameB}: ${t.eventCategories.join(`, `)}.`:n===1&&a&&a===o?`Turn 1, year ${i}: identical first event (${e.eventCategories.join(`, `)}). Both ${r.places} start from the same state.`:`Turn ${n}, year ${i}: ${r.nameA} and ${r.nameB} tracked closely. See sub-tabs for details.`}function TP(e){return`${Math.round(e*100)}%`}function EP(e,t){let n=new Map,r=new Map(e.map(e=>[e.cellKey,e])),i=new Map(t.map(e=>[e.cellKey,e])),a=new Set([...r.keys(),...i.keys()]);for(let e of a){let t=r.get(e)??DP(e),a=i.get(e)??DP(e),o=Math.max(t.agentCount,a.agentCount,1),s=Math.abs(t.agentCount-a.agentCount)/o,c=t.dominantMood===a.dominantMood?0:1,l=t.department===a.department?0:1,u=(s+c+l)/3;n.set(e,{magnitude:u,aState:t,bState:a})}return n}function DP(e){return{cellKey:e,department:``,agentCount:0,dominantMood:`steady`}}var OP={medical:`#4ecdc4`,engineering:`#e8b44a`,agriculture:`#6aad48`,psychology:`#9b6b9e`,governance:`#e06530`};function kP(e,t){let n=new Set,r=new Set;if(!e||!t)return{aliveOnlyA:n,aliveOnlyB:r};let i=new Map(e.cells.map(e=>[e.agentId,e])),a=new Map(t.cells.map(e=>[e.agentId,e]));for(let[e,t]of i){let r=a.get(e);!t.alive||r&&r.alive||n.add(e)}for(let[e,t]of a){let n=i.get(e);!t.alive||n&&n.alive||r.add(e)}return{aliveOnlyA:n,aliveOnlyB:r}}function AP(e){if(!e)return[];let t=new Map;for(let n of e.cells){if(!n.alive)continue;let e=n.department||`unknown`,r=t.get(e);r||(r={count:0,moods:{}},t.set(e,r)),r.count+=1;let i=n.mood||`neutral`;r.moods[i]=(r.moods[i]??0)+1}let n=[];for(let[e,r]of t){let t=Object.entries(r.moods).sort((e,t)=>t[1]-e[1])[0]?.[0]??`neutral`;n.push({cellKey:e,department:e,agentCount:r.count,dominantMood:t})}return n}function jP(e){return e?[e.foodReserve,e.waterLitersPerDay,e.powerKw,e.pressurizedVolumeM3].some(e=>typeof e==`number`):!1}var MP=`button, a[href], summary, [role="button"], [role="link"], [role="menuitem"], [role="option"], [role="checkbox"], [role="radio"], [role="switch"], [role="tab"]`;function NP(e,t){let n=e.getBoundingClientRect(),r=t?Math.max(0,t.scrollHeight-t.clientHeight):0,i=t?t.scrollTop:0;return{width:n.width,height:n.height+r,place(e){let r=e.getBoundingClientRect();if(r.width===0||r.height===0)return null;let a=!!t&&t.contains(e);return{x:r.left-n.left,y:r.top-n.top+(a?i:0),width:r.width,height:r.height}}}}function PP({state:e,isReplay:t,onNavigateToChat:n}){let r=Fk(e),i=e.actorIds[0],a=e.actorIds[1],[o,s]=(0,L.useState)(i),[c,l]=(0,L.useState)(a);(0,L.useEffect)(()=>{o&&!e.actorIds.includes(o)&&s(i),c&&!e.actorIds.includes(c)&&l(a)},[e.actorIds,o,c,i,a]);let u=o??i,d=c??a,f=(u?r[u]:void 0)??[],p=(d?r[d]:void 0)??[],m=u?e.actors[u]:null,h=d?e.actors[d]:null,g=e.actorIds.length>2,[_,v]=(0,L.useState)(g?`cohort`:`pair`);(0,L.useEffect)(()=>{v(g?`cohort`:`pair`)},[g]);let y=Math.max(f.length,p.length),[b,x]=(0,L.useState)(0),[S,C]=(0,L.useState)(!1),[w,T]=(0,L.useState)(1),[E,D]=(0,L.useState)(()=>{try{let e=localStorage.getItem(`paracosm:gridMode`);if(e===`living`||e===`mood`||e===`forge`||e===`ecology`||e===`divergence`)return e}catch{}return`living`}),O=(0,L.useCallback)(e=>{D(e);try{localStorage.setItem(`paracosm:gridMode`,e)}catch{}},[]),{toast:k}=oi(),ee=(0,L.useRef)(0),A=(0,L.useRef)(0);(0,L.useEffect)(()=>{let e=A.current;A.current=y,y>e&&!S&&x(y-1)},[y,S]),(0,L.useEffect)(()=>{if(!S)return;let e=2e3/w;return ee.current=window.setInterval(()=>{x(e=>e>=y-1?(C(!1),e):e+1)},e),()=>clearInterval(ee.current)},[S,w,y]);let j=(0,L.useCallback)(()=>{y<=1||C(e=>(!e&&b>=y-1&&x(0),!e))},[b,y]),M=(0,L.useCallback)(()=>{C(!1),x(e=>Math.max(0,e-1))},[]),N=(0,L.useCallback)(()=>{C(!1),x(e=>Math.min(y-1,e+1))},[y]),te=(0,L.useCallback)(e=>{C(!1),x(e)},[]),P=vF(),F=(0,L.useCallback)(e=>{P(`reports`),requestAnimationFrame(()=>{let t=document.getElementById(`turn-${e}`);t&&t.scrollIntoView({behavior:`smooth`,block:`start`})})},[P]),[I,ne]=(0,L.useState)(!1),re=fF(),z=i_(),[B,ie]=(0,L.useState)(null),[ae,oe]=(0,L.useState)(null),[se,ce]=(0,L.useState)(null),[le,V]=(0,L.useState)(`all`),[ue,de]=(0,L.useState)(null),[fe,pe]=(0,L.useState)(``),[me,he]=(0,L.useState)(null),[ge,_e]=(0,L.useState)(()=>{try{let e=localStorage.getItem(`paracosm:gridSettings`);if(e){let t=JSON.parse(e);if(t.__v===3)return fS(t);localStorage.removeItem(`paracosm:gridSettings`)}}catch{}return dS}),ve=(0,L.useCallback)(e=>{_e(e);try{localStorage.setItem(`paracosm:gridSettings`,JSON.stringify({...e,__v:3}))}catch{}},[]);(0,L.useEffect)(()=>{if(!ge.alerts||t||!e.isRunning)return;let n=new Set([`event_start`,`director_crisis`]),r=`paracosm:seenCrisisToasts`,i=()=>{try{let e=sessionStorage.getItem(r);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},a=e=>{try{let t=[...e].slice(-200);sessionStorage.setItem(r,JSON.stringify(t))}catch{}},o=i(),s=(()=>{let t=null,r=[];u&&r.push({side:`a`,actorName:u}),d&&r.push({side:`b`,actorName:d});for(let{side:i,actorName:a}of r){let r=e.actors[a];if(!r)continue;let s=r.events;for(let e=s.length-1;e>=0;e--){let r=s[e];if(!n.has(r.type))continue;let a=Number(r.turn??r.data?.turn??0),c=typeof r.data?.category==`string`?r.data.category:``;if(!c)continue;let l=`${i}:${a}:${c}`;if(o.has(l))continue;let u=typeof r.data?.title==`string`?r.data.title:``;(!t||a>t.turn)&&(t={key:l,side:i,turn:a,category:c,title:u});break}}return t})();s&&(o.add(s.key),a(o),he(e=>e&&e.key===s.key?e:{...s,expiresAt:performance.now()+5500}))},[e.actorIds,e.actors,ge.alerts,t,e.isRunning]),(0,L.useEffect)(()=>{if(!me)return;let e=me.expiresAt-performance.now();if(e<=0){he(null);return}let t=setTimeout(()=>he(null),e);return()=>clearTimeout(t)},[me]);let[ye,be]=(0,L.useState)(null),xe=`paracosm:seenThresholdAlerts`,Se=(0,L.useCallback)(()=>{try{let e=sessionStorage.getItem(xe);return e?new Set(JSON.parse(e)):new Set}catch{return new Set}},[]),Ce=(0,L.useCallback)(e=>{try{sessionStorage.setItem(xe,JSON.stringify([...e].slice(-200)))}catch{}},[]);(0,L.useEffect)(()=>{if(!ge.alerts||t||!e.isRunning)return;let n=Se(),r=(e,t)=>{n.has(e)||(n.add(e),be({key:e,...t,expiresAt:performance.now()+5500}))},i=(e,t)=>{if(t.length<2)return;let n=t[t.length-1],i=t[t.length-2],a=i.morale-n.morale;a>=.2&&r(`${e}|${n.turn}|morale-crash`,{side:e,turn:n.turn,kind:`morale-crash`,message:`Morale crashed ${Math.round(a*100)}% → ${Math.round(n.morale*100)}% this turn`}),typeof n.foodReserve==`number`&&typeof i.foodReserve==`number`&&n.foodReserve<3&&i.foodReserve>=3&&r(`${e}|${n.turn}|food-low`,{side:e,turn:n.turn,kind:`food-low`,message:`Food reserve fell below 3mo (${n.foodReserve.toFixed(1)}mo remaining)`})};i(`a`,f),i(`b`,p),Ce(n)},[f,p,ge.alerts,Se,Ce,t,e.isRunning]),(0,L.useEffect)(()=>{if(!ye)return;let e=ye.expiresAt-performance.now();if(e<=0){be(null);return}let t=setTimeout(()=>be(null),e);return()=>clearTimeout(t)},[ye]);let[we,Te]=(0,L.useState)(()=>{try{let e=localStorage.getItem(`paracosm:gridPalette`);if(e===`cool`||e===`mono`||e===`amber`)return e}catch{}return`amber`}),Ee=(0,L.useCallback)(e=>{Te(e);try{localStorage.setItem(`paracosm:gridPalette`,e)}catch{}},[]),De=(0,L.useCallback)(()=>{Ee(we===`amber`?`cool`:we===`cool`?`mono`:`amber`)},[we,Ee]),[Oe,ke]=(0,L.useState)(!1),[Ae,je]=(0,L.useState)(!1),[Me,Ne]=(0,L.useState)(!1),Pe=Dw(),Fe=ew(),Ie=(0,L.useCallback)((t,n,r,i)=>{let a=n===`a`?u:d,o=a?e.actorIds.indexOf(a):-1,s=o>=0?Fe.getEntryFor(o,t):void 0;if(!s)return!1;let c=s.attempts.find(e=>e.eventId===r)?.attempt;return Pe.openTrace({actorIndex:o,toolName:t,attempt:c},i,`viz`),!0},[u,d,e.actorIds,Fe,Pe]),[Le,Re]=(0,L.useState)(null),ze=(0,L.useCallback)(e=>{Re(t=>t===e?null:e)},[]),Be=f[b]??f[f.length-1],Ve=p[b]??p[p.length-1],He=Be?.turn??0,Ue=Ve?.turn??0,We=re.presets.find(e=>e.id==="default"),Ge=We?.leaders??We?.actors,Ke=Ge?.[0]?{name:Ge[0].name,archetype:Ge[0].archetype,unit:yn(re,0),hexaco:Ge[0].hexaco,instructions:Ge[0].instructions,quote:``}:null,qe=Ge?.[1]?{name:Ge[1].name,archetype:Ge[1].archetype,unit:yn(re,1),hexaco:Ge[1].hexaco,instructions:Ge[1].instructions,quote:``}:null,Je=m?.leader??Ke,Ye=h?.leader??qe,Xe=(0,L.useRef)(null),Ze=(0,L.useRef)(null),[Qe,$e]=(0,L.useState)(!1),et=(0,L.useRef)(null),tt=(0,L.useRef)([]),nt=(0,L.useRef)(null),rt=(0,L.useRef)(0),it=(0,L.useCallback)(()=>{let e=Xe.current;if(!e)return;let t=NP(e,Ze.current),n=Math.max(640,Math.round(t.width)),r=Math.max(360,Math.round(t.height)),i=document.createElement(`canvas`);if(i.width=n,i.height=r,!i.getContext(`2d`))return;nt.current=i;let a=i.captureStream(30),o=`video/webm;codecs=vp9`;typeof MediaRecorder<`u`&&!MediaRecorder.isTypeSupported(o)&&(o=`video/webm;codecs=vp8`,MediaRecorder.isTypeSupported(o)||(o=`video/webm`));let s;try{s=new MediaRecorder(a,{mimeType:o,videoBitsPerSecond:4e6})}catch{console.warn(`MediaRecorder unavailable — timelapse skipped`);return}tt.current=[],s.ondataavailable=e=>{e.data&&e.data.size>0&&tt.current.push(e.data)},s.onstop=()=>{rt.current&&cancelAnimationFrame(rt.current),rt.current=0,ir(new Blob(tt.current,{type:o}),`paracosm-timelapse-${new Date().toISOString().replace(/[:.]/g,`-`).slice(0,19)}.webm`)},et.current=s,$e(!0),s.start();let c=()=>{let e=nt.current,t=Xe.current;if(!e||!t)return;let n=e.getContext(`2d`);if(!n)return;n.fillStyle=getComputedStyle(t).getPropertyValue(`--bg-deep`).trim()||`#0a0806`,n.fillRect(0,0,e.width,e.height);let r=NP(t,Ze.current),i=Math.min(e.width/Math.max(1,r.width),e.height/Math.max(1,r.height)),a=(e.width-r.width*i)/2,o=(e.height-r.height*i)/2,s=Array.from(t.querySelectorAll(`canvas`));for(let e of s){let t=r.place(e);t&&n.drawImage(e,a+t.x*i,o+t.y*i,t.width*i,t.height*i)}rt.current=requestAnimationFrame(c)};rt.current=requestAnimationFrame(c)},[]),at=(0,L.useCallback)(()=>{let e=et.current;if(e){try{e.stop()}catch{}et.current=null,$e(!1)}},[]);(0,L.useEffect)(()=>()=>{if(et.current)try{et.current.stop()}catch{}rt.current&&cancelAnimationFrame(rt.current)},[]);let ot=(0,L.useCallback)(()=>{let e={exportedAt:new Date().toISOString(),leaderA:{name:Je?.name??`Leader A`,archetype:Je?.archetype??``},leaderB:{name:Ye?.name??`Leader B`,archetype:Ye?.archetype??``},currentTurn:b,snapshots:{a:f,b:p},events:{a:m?.events??[],b:h?.events??[]}};rr(JSON.stringify(e,null,2),`paracosm-replay-${new Date().toISOString().replace(/[:.]/g,`-`).slice(0,19)}.json`)},[b,Je,Ye,f,p,m,h]),st=(0,L.useCallback)(()=>{let e=Xe.current;if(!e)return;let t=Array.from(e.querySelectorAll(`canvas`));if(t.length===0)return;let n=NP(e,Ze.current),r=document.createElement(`canvas`);r.width=Math.round(n.width*2),r.height=Math.round(n.height*2);let i=r.getContext(`2d`);if(i){i.fillStyle=getComputedStyle(e).getPropertyValue(`--bg-deep`).trim()||`#0a0806`,i.fillRect(0,0,r.width,r.height),i.scale(2,2);for(let e of t){let t=n.place(e);t&&i.drawImage(e,t.x,t.y,t.width,t.height)}r.toBlob(e=>{e&&ir(e,`paracosm-viz-t${b+1}-${new Date().toISOString().replace(/[:.]/g,`-`).slice(0,19)}.png`)},`image/png`)}},[b]);(0,L.useEffect)(()=>{let e=e=>{let t=e.target instanceof Element?e.target:null,n=t?.tagName;if(n===`INPUT`||n===`TEXTAREA`||n===`SELECT`)return;let r=t?.closest(`[role="dialog"]`),i=e.key===`?`||e.shiftKey&&e.key===`/`;(e.key===`Escape`||!r||i&&r.hasAttribute(`data-viz-help`))&&(!I||e.key===`Escape`||i)&&(e.key!==` `&&e.key!==`Spacebar`||!t?.closest(MP))&&(e.key===`ArrowLeft`?(e.preventDefault(),M()):e.key===`ArrowRight`?(e.preventDefault(),N()):e.key===` `||e.key===`Spacebar`?(e.preventDefault(),j()):e.key===`?`||e.shiftKey&&e.key===`/`?(e.preventDefault(),ne(e=>!e)):e.key===`Escape`&&I?(e.preventDefault(),ne(!1)):e.key===`1`?(e.preventDefault(),O(`living`)):e.key===`2`?(e.preventDefault(),O(`mood`)):e.key===`3`?(e.preventDefault(),O(`forge`)):e.key===`4`?(e.preventDefault(),O(`ecology`)):e.key===`5`&&(e.preventDefault(),O(`divergence`)))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[M,N,j,I,O]);let ct=(0,L.useMemo)(()=>{let e=fe.trim().toLowerCase().split(/\s+/).filter(Boolean);if(e.length===0)return[];let t=t=>{let n=`${t.name} ${t.department} ${t.role} ${t.mood}`.toLowerCase();return e.every(e=>n.includes(e))};return[...(Be?.cells??[]).filter(e=>e.alive&&t(e)).map(e=>({cell:e,side:`a`,actorName:Je?.name??`Leader A`,sideColor:`#e8b44a`})),...(Ve?.cells??[]).filter(e=>e.alive&&t(e)).map(e=>({cell:e,side:`b`,actorName:Ye?.name??`Leader B`,sideColor:`#4ecdc4`}))]},[fe,Be,Ve,Je,Ye]),lt=(0,L.useMemo)(()=>kP(Be,Ve),[Be,Ve]),ut=(0,L.useMemo)(()=>{let t={a:{attempts:[],reuses:[]},b:{attempts:[],reuses:[]}},n=[];u&&n.push({side:`a`,actorName:u}),d&&n.push({side:`b`,actorName:d});for(let{side:r,actorName:i}of n){let n=e.actors[i];if(!n)continue;let a=new Map;for(let e of n.events){if(e.type===`forge_attempt`){let n=e.data||{};t[r].attempts.push({turn:Number(n.turn??0),eventIndex:Number(n.eventIndex??0),department:String(n.department||``),name:String(n.name||``),approved:n.approved===!0||n.approved===`true`,confidence:typeof n.confidence==`number`?n.confidence:void 0}),n.name&&n.department&&n.approved===!0&&!a.has(String(n.name))&&a.set(String(n.name),String(n.department));continue}if(e.type!==`specialist_done`)continue;let n=e.data||{},i=String(n.department||``),o=Array.isArray(n.forgedTools)?n.forgedTools:[];for(let s of o){let o=s,c=String(o.name||``);if(!c||c===`unnamed`)continue;let l=typeof o.firstForgedDepartment==`string`?String(o.firstForgedDepartment):a.get(c),u=typeof o.firstForgedTurn==`number`?o.firstForgedTurn:void 0,d=Number(e.turn??n.turn??0);(l&&u!==void 0&&u<d||l&&l!==i)&&t[r].reuses.push({turn:d,originDept:l,callingDept:i,name:c})}}}return t},[e]);eP({enabled:ge.sound,snapshotA:f[f.length-1],prevSnapshotA:f[f.length-2],snapshotB:p[p.length-1],prevSnapshotB:p[p.length-2],forgeAttemptsA:ut.a.attempts,forgeAttemptsB:ut.b.attempts});let dt=(0,L.useMemo)(()=>{let t=new Map;for(let n of e.actorIds){let r=e.actors[n];if(r)for(let e of r.events){if(e.type!==`agent_reactions`)continue;let n=e.data?.reactions||[];for(let e of n){let n=e.hexaco;if(!n)continue;let r=e.agentId||e.name;r&&t.set(r,n)}}}return t},[e]),ft=(0,L.useCallback)(e=>{n?.(e)},[n]),pt=Sy(Cy),mt=Sy(wy),ht=Sy(Ty),[gt,_t]=(0,L.useState)(null),vt=Je?.name??`Leader A`,yt=Ye?.name??`Leader B`,bt=(0,L.useMemo)(()=>wP(f[b]?SP(f[b],f[b-1]):null,p[b]?SP(p[b],p[b-1]):null,b+1,{nameA:vt,nameB:yt,person:z.person,people:z.people,places:z.places}),[f,p,b,vt,yt,z.person,z.people,z.places]),xt=(0,L.useMemo)(()=>re.departments.map(e=>({id:e.id,label:e.label,color:OP[e.id]??`#a89878`})),[re.departments]),St=(0,L.useMemo)(()=>Object.fromEntries(re.departments.map(e=>[e.id,e.label])),[re.departments]),[Ct,wt]=(0,L.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`paracosm:vizDiffOverlay`)===`1`}catch{return!1}}),Tt=(0,L.useCallback)(e=>{wt(e);try{window.localStorage.setItem(`paracosm:vizDiffOverlay`,e?`1`:`0`)}catch{}},[]);(0,L.useEffect)(()=>{let e=e=>{let t=e.target instanceof Element?e.target:null;t&&t.matches(`input, textarea, [contenteditable=true]`)||I||t?.closest(`[role="dialog"]`)||(e.key===`d`||e.key===`D`)&&(e.preventDefault(),Tt(!Ct))};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[Ct,I,Tt]);let Et=(0,L.useMemo)(()=>Ct?EP(AP(f[b]),AP(p[b])):null,[Ct,f,p,b]),Dt=(0,L.useMemo)(()=>[{k:`?`,v:`help`},{k:`1-5`,v:`mode`},{k:`← →`,v:`scrub turn`},{k:`space`,v:`play / pause`},{k:`click`,v:`${z.person} drilldown`},{k:`esc`,v:`close popover`}],[z.person]);if(y===0)return e.isRunning?(0,R.jsxs)(`div`,{className:`viz-content ${$.empty}`,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:$.emptySpinner,"aria-hidden":`true`}),(0,R.jsxs)(`span`,{children:[`Awaiting first turn snapshot — the `,z.place,` viz will populate once the kernel reports state.`]})]}):typeof window<`u`&&new URLSearchParams(window.location.search).has(`replay`)?(0,R.jsxs)(`div`,{className:`viz-content ${$.empty}`,role:`status`,"aria-live":`polite`,children:[(0,R.jsx)(`span`,{className:$.emptySpinner,"aria-hidden":`true`}),(0,R.jsxs)(`span`,{children:[`Loading replay — the `,z.place,` viz will populate as the cached events stream in.`]})]}):(0,R.jsxs)(`div`,{className:`viz-content ${$.empty}`,children:[`Run a simulation to see the `,z.place,` visualization.`]});let Ot=Be&&Ve?`A vs B: ${Ve.population-Be.population>=0?`+`:``}${Ve.population-Be.population} pop, ${Ve.morale-Be.morale>=0?`+`:``}${Math.round((Ve.morale-Be.morale)*100)}% morale${typeof Be.foodReserve==`number`&&typeof Ve.foodReserve==`number`?`, ${Ve.foodReserve-Be.foodReserve>0?`+`:``}${(Ve.foodReserve-Be.foodReserve).toFixed(1)}mo food`:``}`:``,kt=mt?Le??`a`:Le,At=b>0?f[b-1]??f[f.length-2]:void 0,jt=b>0?p[b-1]??p[p.length-2]:void 0,Mt=ct,Nt=(0,R.jsxs)(`button`,{type:`button`,onClick:()=>Tt(!Ct),"aria-label":Ct?`Hide A-vs-B diff overlay (D)`:`Show A-vs-B diff overlay (D)`,"aria-pressed":Ct,title:`Highlight where Leader A and Leader B diverged this turn (press D)`,className:$.helpBtn,children:[`Diff `,Ct?`on`:`off`]}),Pt=(0,R.jsx)(`button`,{type:`button`,onClick:()=>ne(!0),"aria-label":`Open help overlay (shortcut: ?)`,title:`What do these colors / symbols / modes mean? (press ?)`,className:$.helpBtn,children:`? Help`}),Ft=(0,R.jsx)(KN,{eventsA:m?.events??[],eventsB:h?.events??[],currentTurn:b,onJumpToTurn:te,hoveredTurn:se,onHoverTurnChange:ce,filter:le,onFilterChange:V,onHoverEventChange:de,onJumpToReports:F,onForgeSelect:Ie}),It=pt,Lt=(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(VN,{snapsA:f,snapsB:p,currentTurn:b,onJumpToTurn:te,hoveredTurn:se,onHoverTurnChange:ce}),_===`pair`&&Ot&&(0,R.jsx)(`div`,{className:$.diffLine,children:Ot})]}),Rt=xN(e,b)!==``;return(0,R.jsxs)(`div`,{ref:Xe,className:`viz-content ${$.root}`,"data-own-help-key":`?`,children:[(0,R.jsxs)(`div`,{ref:Ze,className:$.body,"data-viz-layout":``,children:[g&&(0,R.jsxs)(`div`,{className:$.cohortViewBar,role:`region`,"aria-label":`Cohort view controls`,children:[(0,R.jsxs)(`div`,{className:$.cohortViewModeToggle,role:`tablist`,"aria-label":`Swarm grid view mode`,children:[(0,R.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":_===`cohort`,onClick:()=>v(`cohort`),className:[$.cohortViewModeButton,_===`cohort`?$.cohortViewModeButtonActive:``].filter(Boolean).join(` `),title:`Show every actor's living-swarm panel side-by-side with horizontal scroll`,children:[`All `,e.actorIds.length,` actors`]}),(0,R.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":_===`pair`,onClick:()=>v(`pair`),className:[$.cohortViewModeButton,_===`pair`?$.cohortViewModeButtonActive:``].filter(Boolean).join(` `),title:`Focus on a 2-actor head-to-head with the original pair-mode diff overlay + sympathy hover`,children:`Focus pair`})]}),_===`pair`&&(0,R.jsxs)(`div`,{className:$.cohortPairPicker,children:[(0,R.jsx)(`select`,{"aria-label":`Left panel actor`,className:$.cohortPairPickerSelect,value:u??``,onChange:e=>s(e.target.value||void 0),children:e.actorIds.map(t=>(0,R.jsx)(`option`,{value:t,disabled:t===d,children:e.actors[t]?.leader?.name??t},t))}),(0,R.jsx)(`span`,{className:$.cohortPairPickerVs,children:`vs`}),(0,R.jsx)(`select`,{"aria-label":`Right panel actor`,className:$.cohortPairPickerSelect,value:d??``,onChange:e=>l(e.target.value||void 0),children:e.actorIds.map(t=>(0,R.jsx)(`option`,{value:t,disabled:t===u,children:e.actors[t]?.leader?.name??t},t))})]})]}),(0,R.jsx)(CN,{state:e,currentTurn:b,linesTarget:It?gt:null,cohortGridShown:_===`cohort`}),(0,R.jsx)(pP,{text:bt,turn:b+1}),(0,R.jsx)(gP,{departments:xt}),Ct&&Et&&(0,R.jsx)(bP,{diff:Et,departmentLabels:St}),(0,R.jsxs)(`div`,{className:$.toolbarStrip,children:[(0,R.jsxs)(Qk,{label:`toolbar keys`,rowClassName:$.toolbarTopRow,children:[(0,R.jsx)(`div`,{className:$.modePillsWrap,children:(0,R.jsx)(PN,{mode:E,onChange:O,counts:{forge:ut.a.attempts.filter(e=>e.approved).length+ut.b.attempts.filter(e=>e.approved).length,divergence:(lt.aliveOnlyA?.size??0)+(lt.aliveOnlyB?.size??0)},labels:z})}),E===`forge`&&(0,R.jsx)(`button`,{type:`button`,"aria-haspopup":`dialog`,onClick:e=>Pe.openToolbox(e.currentTarget,`viz`),className:$.forgeToolboxKey,children:TT(Fe.list.length)}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>Ne(e=>!e),"aria-label":Me?ht?`Hide more tools`:`Hide advanced tools`:ht?`Show more tools (diff, help, palette, stats, export, settings)`:`Show advanced tools (palette, stats, export, settings)`,"aria-expanded":Me,title:Me?`Hide tools`:ht?`Diff · Help · Palette · Stats · Export · Settings`:`Palette · Stats · Export · Settings`,className:[$.overflowToggle,Me?$.overflowToggleOpen:``].filter(Boolean).join(` `),children:`⋯`}),!ht&&Nt,!ht&&Pt]}),Me&&(0,R.jsxs)(Qk,{label:`Viz tools`,role:`toolbar`,ariaLabel:`Viz tools`,rowClassName:$.toolsRow,children:[ht&&Nt,ht&&Pt,(0,R.jsx)(`button`,{type:`button`,onClick:De,"aria-label":`Palette: ${we}. Click to cycle.`,title:`Palette: ${we.toUpperCase()} (click to cycle)`,className:$.paletteBtn,style:{"--palette-bg":we===`amber`?`linear-gradient(135deg, #e8b44a 0 40%, #c44a1e 100%)`:we===`cool`?`linear-gradient(135deg, #4ecdc4 0 40%, #9b6bd8 100%)`:`linear-gradient(135deg, #f5f0e4 0 40%, #6b5f50 100%)`},children:we}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>je(!0),"aria-label":`Open run summary`,title:`Run summary (cumulative totals)`,className:$.toolBtn,children:`STATS`}),(0,R.jsx)(uP,{recording:Qe,onExportPng:st,onExportJson:ot,onToggleRecording:Qe?at:it}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>ke(e=>!e),"aria-label":`Open grid settings`,"aria-expanded":Oe,title:`Viz settings`,className:[$.settingsBtn,Oe?$.settingsBtnOpen:``].filter(Boolean).join(` `),children:`⚙`})]}),(0,R.jsx)(`div`,{className:$.modeHint,children:NN(E,z)}),E===`ecology`&&!e.actorIds.some(e=>{let t=r[e]??[];return jP(t[b]??t[t.length-1])})&&(0,R.jsxs)(`div`,{role:`status`,className:$.ecologyNone,children:[(0,R.jsx)(`span`,{children:`ECOLOGY draws food, water, power and pressurized volume. This run holds none of them.`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>O(`living`),className:$.ecologyBack,children:`Back to LIVING`})]})]}),(0,R.jsx)(ZN,{value:fe,onChange:pe,matches:Mt,onPick:e=>{pe(e.cell.name)}}),(0,R.jsx)(YN,{eventsA:m?.events??[],eventsB:h?.events??[],totalDepartments:re.departments.length}),!pt&&Ft,!pt&&Lt,_===`pair`&&mt&&(0,R.jsx)(`div`,{role:`tablist`,"aria-label":`Leader panel selector`,className:$.phoneTabRow,children:[`a`,`b`].map(e=>{let t=e===`a`?Je?.name??`Leader A`:Ye?.name??`Leader B`,n=e===`a`?`var(--vis)`:`var(--eng)`,r=kt===e;return(0,R.jsx)(`button`,{type:`button`,role:`tab`,"aria-selected":r,onClick:()=>Re(e),className:[$.phoneTab,r?$.phoneTabActive:``].filter(Boolean).join(` `),style:r?{"--tab-color":n}:void 0,children:t},e)})}),_===`cohort`&&(0,R.jsxs)(`div`,{className:[$.cohortWindow,It?$.cohortWindowLinesBelow:``].filter(Boolean).join(` `),children:[(0,R.jsx)(Pk,{vizPanel:!0,className:It?$.cohortTrackLinesBelow:void 0,state:e,snapshotMap:r,currentTurn:b,gridMode:E,palette:we===`cool`?1:we===`mono`?2:0,gridSettings:ge,hexacoById:dt,searchQuery:fe,chronicleFilter:le,chronicleHover:ue,startTime:re.setup?.defaultStartTime,onOpenChat:ft}),It&&(0,R.jsx)(`section`,{ref:_t,role:`status`,"aria-label":`Turn outcomes`,className:$.turnLinesSlot})]}),_===`pair`&&(0,R.jsxs)(`div`,{className:[`leaders-row`,$.leadersRow,pt?$.leadersRowNarrow:``,It?$.leadersRowLinesBelow:``].filter(Boolean).join(` `),children:[(0,R.jsx)(`div`,{className:[$.sideWrap,kt===`b`?$.sideWrapHidden:``].filter(Boolean).join(` `),children:(0,R.jsx)(AS,{vizPanel:!0,snapshot:Be,previousSnapshot:At,snapshotHistory:f,actorName:Je?.name??`Leader A`,actorArchetype:Je?.archetype??``,leaderUnit:Je?.unit??``,sideColor:`var(--vis)`,side:`a`,lagTurns:He<Ue?Ue-He:0,mode:E,hexacoById:dt,leaderHexaco:Je?.hexaco?{O:Je.hexaco.O??Je.hexaco.openness??.5,C:Je.hexaco.C??Je.hexaco.conscientiousness??.5,E:Je.hexaco.E??Je.hexaco.extraversion??.5,A:Je.hexaco.A??Je.hexaco.agreeableness??.5,Em:Je.hexaco.Em??Je.hexaco.emotionality??.5,HH:Je.hexaco.HH??Je.hexaco.honestyHumility??.5}:void 0,forgeAttempts:ut.a.attempts,reuseCalls:ut.a.reuses,divergedIds:lt.aliveOnlyA,siblingHoveredId:ae,onHoverChange:ie,searchQuery:fe,palette:we===`cool`?1:we===`mono`?2:0,settings:ge,startTime:re.setup?.defaultStartTime,focusedSide:kt,onToggleFocus:mt?void 0:ze,onOpenChat:ft,eventFilter:le,chronicleHover:ue})}),(0,R.jsx)(`div`,{className:[$.sideWrap,kt===`a`?$.sideWrapHidden:``].filter(Boolean).join(` `),children:(0,R.jsx)(AS,{vizPanel:!0,snapshot:Ve,previousSnapshot:jt,snapshotHistory:p,actorName:Ye?.name??`Leader B`,actorArchetype:Ye?.archetype??``,leaderUnit:Ye?.unit??``,sideColor:`var(--eng)`,side:`b`,lagTurns:Ue<He?He-Ue:0,mode:E,hexacoById:dt,leaderHexaco:Ye?.hexaco?{O:Ye.hexaco.O??Ye.hexaco.openness??.5,C:Ye.hexaco.C??Ye.hexaco.conscientiousness??.5,E:Ye.hexaco.E??Ye.hexaco.extraversion??.5,A:Ye.hexaco.A??Ye.hexaco.agreeableness??.5,Em:Ye.hexaco.Em??Ye.hexaco.emotionality??.5,HH:Ye.hexaco.HH??Ye.hexaco.honestyHumility??.5}:void 0,forgeAttempts:ut.b.attempts,reuseCalls:ut.b.reuses,divergedIds:lt.aliveOnlyB,siblingHoveredId:B,onHoverChange:oe,searchQuery:fe,palette:we===`cool`?1:we===`mono`?2:0,settings:ge,startTime:re.setup?.defaultStartTime,focusedSide:kt,onToggleFocus:mt?void 0:ze,onOpenChat:ft,eventFilter:le,chronicleHover:ue})}),It&&(0,R.jsx)(`section`,{ref:_t,role:`status`,"aria-label":`Turn outcomes`,className:$.turnLinesSlot})]}),pt&&Ft,pt&&Lt,!t&&ye&&(0,R.jsxs)(`div`,{role:`status`,"aria-live":`assertive`,onClick:()=>be(null),className:$.toast,style:{"--side-color":ye.side===`a`?`var(--vis)`:`var(--eng)`,"--left-accent":ye.kind===`morale-crash`?`var(--rust)`:`var(--amber)`},title:`Click to dismiss`,children:[(0,R.jsxs)(`div`,{className:$.toastKicker,style:{"--kicker-color":ye.kind===`morale-crash`?`var(--rust)`:`var(--amber)`},children:[(0,R.jsx)(`span`,{children:ye.kind===`morale-crash`?`▼ Alert`:`⚠ Alert`}),(0,R.jsxs)(`span`,{className:$.toastKickerMeta,children:[ye.side.toUpperCase(),` · T`,ye.turn]})]}),(0,R.jsx)(`div`,{className:$.toastBody,children:ye.message})]},ye.key),!t&&me&&(0,R.jsxs)(`div`,{role:`status`,"aria-live":`polite`,onClick:()=>he(null),className:$.toast,style:{"--side-color":me.side===`a`?`var(--vis)`:`var(--eng)`,"--left-accent":`var(--rust)`},title:`Click to dismiss`,children:[(0,R.jsxs)(`div`,{className:$.toastKicker,children:[(0,R.jsx)(`span`,{children:`⚡ Crisis`}),(0,R.jsxs)(`span`,{className:$.toastKickerMeta,children:[me.side.toUpperCase(),` · T`,me.turn,` · `,me.category]})]}),(0,R.jsx)(`div`,{className:$.toastBodyMd,children:me.title||`${me.category} crisis unfolding`})]},me.key),y>1&&b<y-1&&(0,R.jsx)(`div`,{className:$.jumpLatestAnchor,children:(0,R.jsxs)(`button`,{type:`button`,onClick:()=>te(y-1),"aria-label":`Jump to latest turn (T${y})`,className:$.jumpLatest,children:[`↓`,` Latest · T`,y,(0,R.jsxs)(`span`,{className:$.jumpLatestBehind,children:[`(`,y-1-b,` turn`,y-1-b==1?``:`s`,` behind)`]})]})}),(0,R.jsx)(EN,{currentTurn:b,maxTurn:y,time:Be?.time??Ve?.time??0,timeInBanner:Rt,playing:S,speed:w,onTurnChange:te,onPlayPause:j,onStepBack:M,onStepForward:N,onSpeedChange:T}),(0,R.jsx)(kN,{hints:Dt,onShowAll:()=>ne(!0)}),(0,R.jsx)(`div`,{"aria-live":`polite`,"aria-atomic":`true`,className:$.srOnly,children:Be&&Ve?`Turn ${Math.max(Be.turn,Ve.turn)}. ${Je?.name??`A`} ${z.place}: ${Be.cells.filter(e=>e.alive).length} alive, ${Be.births} born, ${Be.deaths} died, morale ${Math.round(Be.morale*100)}%. ${Ye?.name??`B`} ${z.place}: ${Ve.cells.filter(e=>e.alive).length} alive, ${Ve.births} born, ${Ve.deaths} died, morale ${Math.round(Ve.morale*100)}%.`:``})]}),(0,R.jsx)(IN,{open:I,onClose:()=>ne(!1)}),(0,R.jsx)(pS,{open:Oe,settings:ge,onChange:ve,onClose:()=>ke(!1)}),(0,R.jsx)(rP,{open:Ae,onClose:()=>je(!1),snapsA:f,snapsB:p,actorNameA:Je?.name??`Leader A`,actorNameB:Ye?.name??`Leader B`,forgeApprovedA:ut.a.attempts.filter(e=>e.approved).length,forgeApprovedB:ut.b.attempts.filter(e=>e.approved).length,reuseCountA:ut.a.reuses.length,reuseCountB:ut.b.reuses.length,divergedCount:(lt.aliveOnlyA?.size??0)+(lt.aliveOnlyB?.size??0)}),(0,R.jsx)(`style`,{children:`
|
|
129
|
+
@keyframes paracosm-toast-in {
|
|
130
|
+
0% { opacity: 0; transform: translateY(-8px); }
|
|
131
|
+
100% { opacity: 1; transform: translateY(0); }
|
|
132
|
+
}
|
|
133
|
+
@keyframes paracosm-jump-pulse {
|
|
134
|
+
0%, 100% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 0 0 rgba(232, 180, 74, 0.4); }
|
|
135
|
+
50% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 0 8px rgba(232, 180, 74, 0); }
|
|
136
|
+
}
|
|
137
|
+
@keyframes paracosm-rec-pulse {
|
|
138
|
+
0%, 100% { filter: brightness(1); }
|
|
139
|
+
50% { filter: brightness(1.2); }
|
|
140
|
+
}
|
|
141
|
+
@keyframes paracosm-spotlight-in {
|
|
142
|
+
0% { opacity: 0; transform: translateY(-6px); }
|
|
143
|
+
100% { opacity: 1; transform: translateY(0); }
|
|
144
|
+
}
|
|
145
|
+
`})]})}var FP={footer:`_footer_c3dep_1`,phone:`_phone_c3dep_14`,nav:`_nav_c3dep_18`,navLink:`_navLink_c3dep_23`,consentSlot:`_consentSlot_c3dep_28`,statusChip:`_statusChip_c3dep_37`,cost:`_cost_c3dep_48`,costAmount:`_costAmount_c3dep_57`,costMuted:`_costMuted_c3dep_63`,brand:`_brand_c3dep_67`,brandAccent:`_brandAccent_c3dep_74`,brandLink:`_brandLink_c3dep_78`};function IP(e){switch(e){case`client_disconnected`:return`browser tab closed before the sim finished`;case`quota_exhausted`:return`provider credits exhausted`;case`user_aborted`:return`cancelled by the user`;case`provider_error`:return`provider returned an unrecoverable error`;case`another_run_started`:return`you started another run`;case`server_restarted`:return`the server restarted before the run finished`;case`unknown`:return`reason not recorded by the server`;default:return e}}function LP({s:e}){let t=e.isAborted?`var(--amber)`:e.isComplete?`var(--green)`:e.isRunning?`var(--color-success, var(--green))`:(e.connectionStatus,`var(--text-3)`),n=e.isAborted?`Interrupted`:e.isComplete?`Complete`:e.isRunning?`Running`:e.connectionStatus===`connected`?`Idle`:e.connectionStatus===`error`?`Reconnecting`:`Connecting`,r=e.isRunning&&!e.isComplete&&!e.isAborted?`●`:`○`,i=e.isAborted?(()=>{if(e.providerError)return`Run interrupted: ${e.providerError.message}. Click Clear to reset.`;let t=e.abortReason;if(!t)return`Run was interrupted before finishing all turns. Click Clear to reset.`;let n=typeof t.completedTurns==`number`?` after ${t.completedTurns} turn${t.completedTurns===1?``:`s`}`:``;return`Run interrupted: ${IP(t.reason)}${n}. Click Clear to reset.`})():e.isComplete?`Run finished all turns. Verdict is broadcast in Reports.`:e.isRunning?`Simulation in progress.`:e.connectionStatus===`connected`?`Connected to the simulation server. No run in progress.`:e.connectionStatus===`error`?`Reconnecting to the simulation server.`:`Connecting to the simulation server.`;return(0,R.jsxs)(`span`,{className:FP.statusChip,style:{"--status-color":t},role:`status`,"aria-live":`polite`,"aria-label":`Simulation status: ${n}. ${i}`,title:i,children:[r,` `,n]})}function RP(e){return e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function zP(e,t){let n=[`Total: ${RP(e.totalCostUSD)} · ${e.totalTokens.toLocaleString()} tokens · ${e.llmCalls} calls`];if(t){let e=t.simUSD??0,r=t.chatUSD??0;e>0&&n.push(`• Simulation: ${RP(e)}${t.simCalls==null?``:` (${t.simCalls} calls)`}`),r>0&&n.push(`• Chat: ${RP(r)}${t.chatCalls==null?``:` (${t.chatCalls} calls)`}`)}return n.join(`
|
|
146
|
+
`)}function BP({cost:e,costBreakdown:t,simStatus:n}){let r=Sy(wy),i=wb(),a=Tb(),o=[`shrink-0`,FP.footer,r?FP.phone:``].filter(Boolean).join(` `);return(0,R.jsxs)(`footer`,{className:o,role:`contentinfo`,children:[!r&&(0,R.jsxs)(`nav`,{"aria-label":`Footer links`,className:FP.nav,children:[(0,R.jsx)(`a`,{href:`https://agentos.sh/en`,target:`_blank`,rel:`noopener`,className:FP.navLink,children:`agentos.sh`}),(0,R.jsx)(`a`,{href:`https://github.com/framerslab/paracosm`,target:`_blank`,rel:`noopener`,className:FP.navLink,children:`github`}),(0,R.jsx)(`a`,{href:`https://www.npmjs.com/package/paracosm`,target:`_blank`,rel:`noopener`,className:FP.navLink,children:`npm`}),(0,R.jsx)(`a`,{href:`/docs`,className:FP.navLink,children:`docs`}),(0,R.jsx)(`a`,{href:`https://agentos.sh/blog`,target:`_blank`,rel:`noopener`,className:FP.navLink,children:`blog`})]}),n&&(0,R.jsx)(LP,{s:n}),e&&(e.totalTokens>0||e.llmCalls>0)&&(0,R.jsxs)(`span`,{className:FP.cost,title:zP(e,t),children:[(0,R.jsxs)(`span`,{className:FP.costAmount,children:[`$`,e.totalCostUSD<.01?e.totalCostUSD.toFixed(4):e.totalCostUSD.toFixed(2)]}),(0,R.jsxs)(`span`,{className:FP.costMuted,children:[(e.totalTokens/1e3).toFixed(0),`k tokens`]}),e.llmCalls>0&&(0,R.jsxs)(`span`,{className:FP.costMuted,children:[e.llmCalls,` calls`]})]}),i&&(0,R.jsx)(`span`,{ref:a,className:FP.consentSlot}),!r&&(0,R.jsxs)(`span`,{children:[(0,R.jsxs)(`span`,{className:FP.brand,children:[`PARA`,(0,R.jsx)(`span`,{className:FP.brandAccent,children:`COSM`})]}),` `,`· Apache-2.0 · `,(0,R.jsx)(`a`,{href:`https://frame.dev`,target:`_blank`,rel:`noopener`,className:FP.brandLink,children:`Frame.dev`})]})]})}var VP={backdrop:`_backdrop_1do5l_1`,dialog:`_dialog_1do5l_12`,header:`_header_1do5l_26`,title:`_title_1do5l_33`,closeBtn:`_closeBtn_1do5l_43`,section:`_section_1do5l_53`,scopeTitle:`_scopeTitle_1do5l_57`,list:`_list_1do5l_67`,row:`_row_1do5l_73`,keys:`_keys_1do5l_82`,kbd:`_kbd_1do5l_88`,description:`_description_1do5l_102`,footer:`_footer_1do5l_107`,kbdInline:`_kbdInline_1do5l_117`},HP=[{keys:[`?`],description:`Open this shortcuts overlay`,scope:`Global`},{keys:[`Esc`],description:`Close overlays / drilldown panel`,scope:`Global`},{keys:[`←`],description:`Previous turn`,scope:`Visualization`},{keys:[`→`],description:`Next turn`,scope:`Visualization`},{keys:[`Space`],description:`Play / pause playback`,scope:`Visualization`},{keys:[`M`],description:`Cycle cluster mode (families · departments · mood · age)`,scope:`Visualization`},{keys:[`D`],description:`Toggle divergence tint overlay`,scope:`Visualization`},{keys:[`A`],description:`Collapse / expand the automaton band`,scope:`Visualization`},{keys:[`1`],description:`Automaton: mood propagation`,scope:`Visualization`},{keys:[`2`],description:`Automaton: forge flow`,scope:`Visualization`},{keys:[`3`],description:`Automaton: ecology grid`,scope:`Visualization`},{keys:[`Enter`],description:`Send chat message`,scope:`Chat`}];function UP(){let[e,t]=(0,L.useState)(!1);return(0,L.useEffect)(()=>{let n=n=>{let r=n.target?.tagName,i=r===`INPUT`||r===`TEXTAREA`||r===`SELECT`||n.target?.isContentEditable,a=n.target instanceof Element?n.target.closest(`[role="dialog"]`):null,o=!!a&&a.getAttribute(`aria-label`)!==`Keyboard shortcuts`,s=!e&&!!document.querySelector(`[data-own-help-key]`);n.key===`?`&&!n.metaKey&&!n.ctrlKey&&!i&&!o&&!s?(n.preventDefault(),t(e=>!e)):n.key===`Escape`&&e&&(n.preventDefault(),t(!1))};return window.addEventListener(`keydown`,n),()=>window.removeEventListener(`keydown`,n)},[e]),e?(0,R.jsx)(`div`,{role:`dialog`,"aria-modal":`true`,"aria-label":`Keyboard shortcuts`,onClick:()=>t(!1),className:VP.backdrop,children:(0,R.jsxs)(`div`,{onClick:e=>e.stopPropagation(),className:VP.dialog,children:[(0,R.jsxs)(`div`,{className:VP.header,children:[(0,R.jsx)(`h2`,{className:VP.title,children:`Keyboard Shortcuts`}),(0,R.jsx)(`button`,{onClick:()=>t(!1),"aria-label":`Close shortcuts`,className:VP.closeBtn,children:`×`})]}),[`Global`,`Visualization`,`Chat`].map(e=>{let t=HP.filter(t=>t.scope===e);return t.length===0?null:(0,R.jsxs)(`section`,{className:VP.section,children:[(0,R.jsx)(`h3`,{className:VP.scopeTitle,children:e}),(0,R.jsx)(`ul`,{className:VP.list,children:t.map(e=>(0,R.jsxs)(`li`,{className:VP.row,children:[(0,R.jsx)(`span`,{className:VP.keys,children:e.keys.map((e,t)=>(0,R.jsx)(`kbd`,{className:VP.kbd,children:e},t))}),(0,R.jsx)(`span`,{className:VP.description,children:e.description})]},e.keys.join(`+`)))})]},e)}),(0,R.jsxs)(`div`,{className:VP.footer,children:[`press `,(0,R.jsx)(`kbd`,{className:VP.kbdInline,children:`?`}),` anywhere · `,(0,R.jsx)(`kbd`,{className:VP.kbdInline,children:`Esc`}),` to close`]})]})}):null}var WP={svgOverlay:`_svgOverlay_aob9y_1`,svgFill:`_svgFill_aob9y_8`,clickAway:`_clickAway_aob9y_13`,card:`_card_aob9y_19`,mobile:`_mobile_aob9y_41`,cardHeader:`_cardHeader_aob9y_54`,stepCount:`_stepCount_aob9y_62`,tabBadge:`_tabBadge_aob9y_69`,closeBtn:`_closeBtn_aob9y_82`,title:`_title_aob9y_93`,description:`_description_aob9y_105`,actions:`_actions_aob9y_116`,actionsRight:`_actionsRight_aob9y_124`,skipBtn:`_skipBtn_aob9y_129`,compact:`_compact_aob9y_141`,navBtn:`_navBtn_aob9y_146`,primaryBtn:`_primaryBtn_aob9y_163`,final:`_final_aob9y_180`,progressBar:`_progressBar_aob9y_185`,progressBarFill:`_progressBarFill_aob9y_193`,dotRow:`_dotRow_aob9y_200`,dot:`_dot_aob9y_200`,kbHint:`_kbHint_aob9y_219`},GP=[{target:`[data-quickstart-seed]`,tab:`quickstart`,title:`Quickstart — author from a brief`,description:`Paste a brief, drop a PDF, or supply a URL. Paracosm grounds the prompt with web research, generates three distinct actors with HEXACO personalities, and runs them against the same scenario in parallel. The Twin demo card below runs a single subject against a single intervention if that's your use case.`},{target:`[role="tablist"][aria-label="Studio sub-navigation"]`,tab:`studio`,title:`Studio — author + branches`,description:`Drop any saved Paracosm artifact or bundle here to inspect, fork, and re-run. The Branches sub-tab forks an actor at any turn N and re-runs from that checkpoint with a new HEXACO profile, so you can probe alternate histories from a shared starting state.`},{target:`.topbar`,tab:`sim`,title:`Top Bar`,description:`Scenario name on the left. RUN, status, theme toggle, and HOW IT WORKS (replay this tour) on the right. The T / Y / S tokens in the center show turn, in-sim time, and deterministic seed — hover each for what they mean. A "⋯" menu reveals Save / Copy / Clear once a run has started.`},{target:`.tab-bar`,tab:`sim`,title:`Navigation`,description:`Quickstart and Studio for authoring. Sim, Viz, Chat for the live run. Reports and Library for analysis. Settings holds config (Event Log lives there as a sub-tab). Labels collapse to icons below 900px so the row never wraps onto two lines.`},{target:`[role="group"][aria-label="Sim layout"]`,tab:`sim`,title:`Sim layout`,description:`Side-by-side for 2 actors, Constellation for 3+. Constellation auto-engages above 3 actors because two columns physically can't fit them. Click any node in the Constellation graph to drill into one actor's decisions, departments, and tools. The tour pins side-by-side so you can see leader cards and event streams as they'd render for a 2-actor run.`},{target:`.leaders-row`,tab:`sim`,title:`Leader cards`,description:`Each actor renders with its name, archetype, HEXACO profile, and a population + morale sparkline. Left is amber, right is teal. Glyph color, Conway tiles, and chronicle pills downstream all pick up these same colors so you always know which side you're looking at.`},{target:`.sim-columns`,tab:`sim`,title:`Event streams`,description:`Each turn, both leaders face events the Director generated based on accumulated state. Departments analyze in parallel and may forge new tools. Commanders decide. Tools tint by side. INSPECT on a forged tool opens it on its line of five stations, and its Record holds Show in Event Log.`},{target:`[aria-label="Divergence rail"]`,tab:`sim`,title:`Divergence rail`,description:`How far the actors have diverged at the current turn. Shows decision texts and outcomes side by side in plain language. Same seed, different histories — because HEXACO shaped every LLM call.`},{target:`.viz-content`,tab:`viz`,title:`Viz — living canvas`,description:`Mirrored canvases, one per actor. Conway-style cellular tiles render underneath to encode mood (BLOCK = calm, GLIDER = agitated) while colonist glyphs sit on top as the primary signal. Hover a tile or a glyph for a tooltip; click either to drill into the colonist. Use the mode pills (LIVING / MOOD / FORGE / ECOLOGY / DIVERGENCE) and event filters above the canvas to reshape the read.`},{target:`.chat-layout`,tab:`chat`,title:`Character chat`,description:`Talk to any colonist from the run. Each carries their HEXACO profile, the memories they formed during the sim, and their relationships. The Viz drilldown popover has a direct Chat handoff that preselects the colonist here.`},{target:`.reports-content`,tab:`reports`,title:`Reports`,description:`Turn-by-turn rollup: commander decisions, department analyses, forged toolbox across both sides, agent reactions, verdict comparison. Each forged tool opens from its row, and its Record holds Show in Event Log for that tool's events.`},{target:`[role="group"][aria-label="View mode"]`,tab:`library`,title:`Library — saved runs`,description:`Every run you launch is saved here. Filter by scenario, leader configuration, or free-text search. Gallery view shows hero stats; Table view shows everything. Open any run to inspect, or promote it into Studio to fork a new branch.`},{target:`[role="tablist"][aria-label="Settings sub-navigation"]`,tab:`settings`,title:`Settings + event log`,description:`Configure actors with HEXACO sliders, pick a scenario, set turns and population, and drop in your own OpenAI or Anthropic key to bypass the hosted-demo caps. The Event Log sub-tab shows the raw SSE stream (status, turn_start, specialist_done, decision_made, outcome, reaction, forge_attempt) and is where a forged tool's Show in Event Log leads.`},{target:`.topbar`,tab:`sim`,title:`Ready to launch`,description:`That was demo data. Hit RUN in the top bar to launch a live simulation against the host caps, or paste your own API key in Settings for full-scope runs. When the run finishes, a "Run Complete" banner lands at the top with the verdict and a jump to the Reports tab.`}],KP=360,qP=`tour-highlight`,JP=`
|
|
147
|
+
/* The highlighted element gets a bright luminous amber glow */
|
|
148
|
+
.${qP} {
|
|
149
|
+
outline: 3px solid var(--amber) !important;
|
|
150
|
+
outline-offset: 8px !important;
|
|
151
|
+
box-shadow:
|
|
152
|
+
0 0 20px rgba(232,180,74,.7),
|
|
153
|
+
0 0 50px rgba(232,180,74,.4),
|
|
154
|
+
0 0 100px rgba(232,180,74,.2),
|
|
155
|
+
inset 0 0 30px rgba(232,180,74,.08) !important;
|
|
156
|
+
position: relative !important;
|
|
157
|
+
z-index: 99998 !important;
|
|
158
|
+
filter: brightness(1.15) !important;
|
|
159
|
+
animation: tour-pulse 2s ease-in-out infinite !important;
|
|
160
|
+
}
|
|
161
|
+
@keyframes tour-pulse {
|
|
162
|
+
0%, 100% {
|
|
163
|
+
outline-color: var(--amber);
|
|
164
|
+
box-shadow: 0 0 20px rgba(232,180,74,.7), 0 0 50px rgba(232,180,74,.4), 0 0 100px rgba(232,180,74,.2), inset 0 0 30px rgba(232,180,74,.08);
|
|
165
|
+
}
|
|
166
|
+
50% {
|
|
167
|
+
outline-color: rgba(232,180,74,1);
|
|
168
|
+
box-shadow: 0 0 30px rgba(232,180,74,.9), 0 0 70px rgba(232,180,74,.55), 0 0 120px rgba(232,180,74,.3), inset 0 0 40px rgba(232,180,74,.12);
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
`;function YP({activeTab:e,chatEnabled:t=!0,onTabChange:n,onClose:r,onRun:i}){let a=(0,L.useMemo)(()=>t?GP:GP.filter(e=>e.tab!==`chat`),[t]),[o,s]=(0,L.useState)(0),[c,l]=(0,L.useState)(null),[u,d]=(0,L.useState)(()=>typeof window>`u`?1024:window.innerWidth),f=(0,L.useRef)(null),p=(0,L.useRef)(null),m=(0,L.useRef)(0),h=a[o];(0,L.useEffect)(()=>{let e=document.createElement(`style`);return e.textContent=JP,document.head.appendChild(e),p.current=e,()=>{e.remove(),document.querySelector(`.${qP}`)?.classList.remove(qP)}},[]),(0,L.useEffect)(()=>{let e=a[o];e&&n(e.tab)},[o,n,a]),(0,L.useEffect)(()=>{let t=a[o];if(!t||t.tab===e)return;let n=setTimeout(()=>{a[o]?.tab!==e&&r()},200);return()=>clearTimeout(n)},[e,o,a,r]);let g=(0,L.useRef)(null),_=(0,L.useCallback)(()=>{let e=a[o];e&&(g.current?.(),f.current&&=(f.current.classList.remove(qP),null),l(null),cancelAnimationFrame(m.current),m.current=requestAnimationFrame(()=>{let t=!1,n,r,i=e=>{if(t)return;t=!0,n!==void 0&&clearTimeout(n),r?.disconnect(),f.current&&f.current!==e&&f.current.classList.remove(qP),e.classList.add(qP),f.current=e;let i=e.getBoundingClientRect();l({top:i.top,left:i.left,width:i.width,height:i.height}),(i.top<0||i.bottom>window.innerHeight)&&e.scrollIntoView({behavior:`smooth`,block:`nearest`})},a=0,o=()=>{if(t)return;let s=document.querySelector(e.target);s?i(s):++a<30?n=window.setTimeout(o,100):t||(t=!0,r?.disconnect(),f.current&&=(f.current.classList.remove(qP),null),l(null))};r=new MutationObserver(()=>{if(t)return;let n=document.querySelector(e.target);n&&i(n)}),r.observe(document.body,{childList:!0,subtree:!0}),o(),g.current=()=>{t=!0,n!==void 0&&clearTimeout(n),r?.disconnect()}}))},[o,a]);(0,L.useEffect)(()=>{_();let e=0,t=()=>{cancelAnimationFrame(e),e=requestAnimationFrame(()=>{d(window.innerWidth),_()})};return window.addEventListener(`resize`,t),()=>{window.removeEventListener(`resize`,t),cancelAnimationFrame(e),cancelAnimationFrame(m.current)}},[_,e]);let v=(0,L.useCallback)(()=>{f.current&&=(f.current.classList.remove(qP),null),r()},[r]);if((0,L.useEffect)(()=>{let e=e=>{e.key===`Escape`?v():e.key===`ArrowRight`||e.key===`Enter`?o<a.length-1?s(e=>e+1):v():e.key===`ArrowLeft`&&o>0&&s(e=>e-1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,v,a.length]),!h)return null;let y=u,b=typeof window>`u`?768:window.innerHeight,x=y<640,S={};if(!x&&c){let e=b-(c.top+c.height+10),t=c.top-10,n=y-(c.left+c.width+10);e>=320?(S[`--card-top`]=`${c.top+c.height+16}px`,S[`--card-left`]=`${Math.max(16,Math.min(c.left,y-KP-16))}px`):t>=320?(S[`--card-bottom`]=`${b-c.top+16}px`,S[`--card-left`]=`${Math.max(16,Math.min(c.left,y-KP-16))}px`):n>=384?(S[`--card-left`]=`${c.left+c.width+16}px`,S[`--card-top`]=`${Math.max(16,Math.min(c.top,b-320-16))}px`):(S[`--card-bottom`]=`24px`,S[`--card-right`]=`24px`)}else x||(S[`--card-bottom`]=`24px`,S[`--card-right`]=`24px`);let C=[WP.card,x?WP.mobile:``].filter(Boolean).join(` `);return(0,R.jsx)(R.Fragment,{children:(0,R.jsxs)(`div`,{"data-tour-overlay":!0,className:C,style:S,onClick:e=>e.stopPropagation(),role:`dialog`,"aria-label":`Guided tour`,children:[(0,R.jsxs)(`div`,{className:WP.cardHeader,children:[(0,R.jsxs)(`span`,{className:WP.stepCount,children:[o+1,` / `,a.length]}),(0,R.jsx)(`span`,{"aria-label":`Active tab: ${h.tab}`,className:WP.tabBadge,children:h.tab}),(0,R.jsx)(`button`,{onClick:v,className:WP.closeBtn,"aria-label":`Close tour`,children:`×`})]}),(0,R.jsx)(`h3`,{className:[WP.title,x?WP.mobile:``].filter(Boolean).join(` `),children:h.title}),(0,R.jsx)(`p`,{className:[WP.description,x?WP.mobile:``].filter(Boolean).join(` `),children:h.description}),(0,R.jsxs)(`div`,{className:WP.actions,children:[(0,R.jsx)(`button`,{onClick:v,className:[WP.skipBtn,x?WP.compact:``].filter(Boolean).join(` `),children:`Skip`}),(0,R.jsxs)(`div`,{className:WP.actionsRight,children:[o>0&&(0,R.jsx)(`button`,{onClick:()=>s(e=>e-1),className:[WP.navBtn,x?WP.compact:``].filter(Boolean).join(` `),children:`Back`}),(0,R.jsx)(`button`,{onClick:()=>{o<a.length-1?s(e=>e+1):(v(),i?.())},className:[WP.primaryBtn,x?WP.compact:``,!x&&o===a.length-1?WP.final:``].filter(Boolean).join(` `),children:o<a.length-1?`Next`:x?`Start →`:`Start Your Simulation`})]})]}),x?(0,R.jsx)(`div`,{className:WP.progressBar,children:(0,R.jsx)(`div`,{className:WP.progressBarFill,style:{"--progress-pct":`${(o+1)/a.length*100}%`},role:`progressbar`,"aria-valuenow":o+1,"aria-valuemin":1,"aria-valuemax":a.length,"aria-label":`Step ${o+1} of ${a.length}`})}):(0,R.jsx)(`div`,{className:WP.dotRow,children:a.map((e,t)=>(0,R.jsx)(`button`,{onClick:()=>s(t),className:WP.dot,style:{"--dot-width":t===o?`16px`:`6px`,"--dot-bg":t===o?`var(--amber)`:t<o?`var(--text-3)`:`var(--border)`},"aria-label":`Step ${t+1}`},t))}),!x&&(0,R.jsx)(`div`,{className:WP.kbHint,children:`Arrow keys / Esc`})]})})}var XP={scrim:`_scrim_1e2jd_1`,scrimIn:`_scrimIn_1e2jd_1`,scrimOut:`_scrimOut_1e2jd_1`,card:`_card_1e2jd_13`,sheetIn:`_sheetIn_1e2jd_1`,sheetOut:`_sheetOut_1e2jd_1`,body:`_body_1e2jd_41`,title:`_title_1e2jd_54`,lines:`_lines_1e2jd_63`,item:`_item_1e2jd_72`,row:`_row_1e2jd_84`,line:`_line_1e2jd_63`,drawing:`_drawing_1e2jd_100`,sample:`_sample_1e2jd_108`,track:`_track_1e2jd_117`,barMark:`_barMark_1e2jd_126`,chanceMark:`_chanceMark_1e2jd_137`,barKey:`_barKey_1e2jd_148`,keyItem:`_keyItem_1e2jd_154`,barGlyph:`_barGlyph_1e2jd_167`,chanceGlyph:`_chanceGlyph_1e2jd_175`,stampWords:`_stampWords_1e2jd_183`,scoreRow:`_scoreRow_1e2jd_197`,score:`_score_1e2jd_197`,scoreName:`_scoreName_1e2jd_212`,scoreValue:`_scoreValue_1e2jd_223`,scoreTrack:`_scoreTrack_1e2jd_231`,scoreFill:`_scoreFill_1e2jd_240`,foot:`_foot_1e2jd_259`,close:`_close_1e2jd_266`,panelIn:`_panelIn_1e2jd_1`,panelOut:`_panelOut_1e2jd_1`,bar:`_bar_1e2jd_126`,stamp:`_stamp_1e2jd_183`,scores:`_scores_1e2jd_385`},ZP=`(max-width: 599.98px)`,QP=150,$P=8,eF=e=>typeof window<`u`&&typeof window.matchMedia==`function`&&window.matchMedia(e).matches;function tF(){let[e,t]=(0,L.useState)(()=>eF(ZP));return(0,L.useEffect)(()=>{if(typeof window.matchMedia!=`function`)return;let e=window.matchMedia(ZP),n=()=>t(e.matches);return n(),e.addEventListener(`change`,n),()=>e.removeEventListener(`change`,n)},[]),e}function nF({kind:e,children:t}){return(0,R.jsxs)(`div`,{className:`${XP.drawing} ${XP[e]}`,role:`img`,"aria-label":Kt[e],"data-drawing":e,children:[(0,R.jsx)(`span`,{className:XP.sample,children:Vt}),t]})}function rF(){return(0,R.jsxs)(nF,{kind:`bar`,children:[(0,R.jsxs)(`span`,{className:XP.track,"aria-hidden":`true`,children:[(0,R.jsx)(`span`,{className:XP.barMark,"aria-hidden":`true`}),(0,R.jsx)(`span`,{className:XP.chanceMark,"aria-hidden":`true`})]}),(0,R.jsxs)(`span`,{className:XP.barKey,children:[(0,R.jsxs)(`span`,{className:XP.keyItem,children:[(0,R.jsx)(`span`,{className:XP.barGlyph,"aria-hidden":`true`}),(0,R.jsx)(`span`,{children:Ht})]}),` `,(0,R.jsxs)(`span`,{className:XP.keyItem,children:[(0,R.jsx)(`span`,{className:XP.chanceGlyph,"aria-hidden":`true`}),(0,R.jsx)(`span`,{children:Ut})]})]})]})}function iF(){return(0,R.jsx)(nF,{kind:`stamp`,children:(0,R.jsx)(`span`,{className:XP.stampWords,children:Wt})})}function aF(){return(0,R.jsx)(nF,{kind:`scores`,children:(0,R.jsx)(`span`,{className:XP.scoreRow,children:Gt.map(([e,t])=>(0,R.jsxs)(`span`,{className:XP.score,children:[(0,R.jsx)(`span`,{className:XP.scoreName,children:e}),` `,(0,R.jsx)(`span`,{className:XP.scoreValue,children:t}),(0,R.jsx)(`span`,{className:XP.scoreTrack,"aria-hidden":`true`,children:(0,R.jsx)(`span`,{className:XP.scoreFill,"aria-hidden":`true`,"data-score":t})})]},e))})})}var oF={1:()=>(0,R.jsx)(rF,{}),2:()=>(0,R.jsx)(iF,{}),3:()=>(0,R.jsx)(aF,{})};function sF({open:e,onClose:t,anchor:n}){let r=fF(),i=mF(),a=Ub(),o=tF(),s=(0,L.useId)(),c=(0,L.useRef)(null),l=(0,L.useRef)(null),u=(0,L.useRef)(null),d=(0,L.useRef)(null),[f,p]=(0,L.useState)(e);e&&!f&&p(!0);let m=f&&!e,[h,g]=(0,L.useState)({top:52,bottom:0});(0,L.useEffect)(()=>{if(!m)return;if(eF(`(prefers-reduced-motion: reduce)`)){p(!1);return}let e=window.setTimeout(()=>p(!1),QP);return()=>window.clearTimeout(e)},[m]);let _=(0,L.useCallback)(()=>{t(),n.current?.focus({preventScroll:!0})},[t,n]);if((0,L.useEffect)(()=>{e&&u.current?.focus({preventScroll:!0})},[e]),(0,L.useEffect)(()=>{e&&o&&!c.current?.contains(document.activeElement)&&u.current?.focus({preventScroll:!0})},[e,o]),(0,L.useLayoutEffect)(()=>{if(!e)return;let t=null,r=typeof ResizeObserver>`u`?null:new ResizeObserver(()=>i());function i(){let e=n.current,i=(e?.closest(`header`)??e)?.getBoundingClientRect(),a=i&&i.height>0?Math.round(i.bottom+$P):52,o=document.getElementById(`pcc`);o&&o!==t&&(t=o,r?.observe(o));let s=o?o.getBoundingClientRect():null,c=s&&s.height>0?Math.max(0,Math.round(window.innerHeight-s.top)):0,l=c>window.innerHeight/2?0:c;g(e=>e.top===a&&e.bottom===l?e:{top:a,bottom:l})}i(),window.addEventListener(`resize`,i);let a=typeof MutationObserver>`u`?null:new MutationObserver(()=>i());return a?.observe(document.body,{childList:!0}),()=>{window.removeEventListener(`resize`,i),a?.disconnect(),r?.disconnect()}},[e,n]),(0,L.useEffect)(()=>{if(!e)return;let t=e=>{e.key===`Escape`&&(e.preventDefault(),_())};return document.addEventListener(`keydown`,t),()=>document.removeEventListener(`keydown`,t)},[e,_]),(0,L.useEffect)(()=>{if(!e||o)return;let r=e=>{let r=e.target;r&&(c.current?.contains(r)||n.current?.contains(r)||t())};return document.addEventListener(`click`,r,!0),()=>document.removeEventListener(`click`,r,!0)},[e,o,t,n]),!e&&!f||typeof document>`u`)return null;let v=Bt({turns:i&&a!==null?a:void 0,settlement:i?r.labels.settlementNoun:void 0}),y=e=>{if(e.key!==`Tab`)return;let t=l.current,n=d.current,r=c.current;if(!t||!n||!r)return;let i=document.activeElement;e.shiftKey?i!==t&&r.contains(i)||(e.preventDefault(),n.focus()):i!==n&&r.contains(i)||(e.preventDefault(),t.focus())},b=o&&e;return(0,rE.createPortal)((0,R.jsxs)(R.Fragment,{children:[o&&(0,R.jsx)(`div`,{className:XP.scrim,"data-leaving":m?``:void 0,onClick:e?_:void 0,"data-testid":`how-it-works-scrim`}),(0,R.jsxs)(`div`,{ref:c,className:XP.card,role:`dialog`,"aria-modal":b?`true`:void 0,"aria-labelledby":s,"data-testid":`how-it-works-card`,"data-leaving":m?``:void 0,style:{"--card-top":`${h.top}px`,"--sheet-bottom":`${h.bottom}px`},onKeyDown:b?y:void 0,children:[(0,R.jsxs)(`div`,{ref:l,className:XP.body,role:`group`,"aria-labelledby":s,tabIndex:0,"data-testid":`how-it-works-body`,children:[(0,R.jsx)(`h2`,{id:s,ref:u,tabIndex:-1,className:XP.title,"data-text":`heading`,children:Rt}),(0,R.jsx)(`ol`,{className:XP.lines,children:v.map((e,t)=>{let n=oF[t];return(0,R.jsx)(`li`,{className:XP.item,children:(0,R.jsxs)(`div`,{className:XP.row,"data-drawn":n?``:void 0,children:[(0,R.jsx)(`p`,{className:XP.line,"data-text":`body`,"data-testid":`how-line`,children:e}),n?.()]})},t)})})]}),(0,R.jsx)(`div`,{className:XP.foot,children:(0,R.jsx)(`button`,{ref:d,type:`button`,className:XP.close,onClick:_,"data-testid":`how-it-works-close`,children:zt})})]})]}),document.body)}function cF(e,t){let n=[`medical`,`engineering`,`agriculture`,`psychology`,`governance`],r=[`junior`,`senior`,`lead`,`chief`],i=[`neutral`,`optimistic`,`tense`,`focused`,`anxious`,`confident`],a=[`Aria`,`Diego`,`Yuki`,`Kira`,`Marco`,`Lila`,`Theo`,`Nia`,`Omar`,`Saanvi`,`Felix`,`Mira`],o=[`Ren`,`Iris`,`Kenji`,`Anya`,`Tomas`,`Zara`,`Vinh`,`Lena`,`Hugo`,`Priya`,`Jonah`,`Mei`],s=[`Vasquez`,`Park`,`Okafor`,`Reyes`,`Singh`,`Cohen`,`Mwangi`,`Roy`,`Tate`,`Lopez`,`Bauer`,`Akin`],c=[`Tanaka`,`Brandt`,`Kim`,`Nilsson`,`Diaz`,`Patel`,`Foley`,`Volkov`,`Cruz`,`Hossain`,`Mukherjee`,`Park`],l=e===`A`?a:o,u=e===`A`?s:c;return Array.from({length:14},(a,o)=>{let s=(o*7+t*3)%13>1;return{agentId:`${e.toLowerCase()}-${o}`,name:`${l[o%l.length]} ${u[o%u.length]}`,department:n[o%n.length],role:o===0?`Department Head`:r[(o+t)%r.length]===`lead`?`Senior Specialist`:`Specialist`,rank:r[(o+t)%r.length],alive:s,marsborn:o%5==0,psychScore:.55+(o*11+t*7)%35/100,age:28+(o*3+t)%22,generation:+(o%5==0),childrenIds:o%6==2?[`${e.toLowerCase()}-${(o+7)%14}`]:[],featured:o<3,mood:i[(o+t)%i.length],shortTermMemory:[`Turn ${t}: working on department duties`]}})}var lF=[{type:`status`,leader:``,data:{phase:`parallel`,maxTurns:6,actors:[{name:`Commander Elena Vasquez`,archetype:`The Visionary`,unit:`Olympus Base`,hexaco:{openness:.92,conscientiousness:.4,extraversion:.8,agreeableness:.55,emotionality:.25,honestyHumility:.65},instructions:`You lead by inspiration. You value openness to experience and bold experimentation. You tolerate mess if it leads to breakthroughs.`,quote:`The frontier rewards the bold.`},{name:`Commander Hiroshi Tanaka`,archetype:`The Engineer`,unit:`Meridian Station`,hexaco:{openness:.3,conscientiousness:.95,extraversion:.35,agreeableness:.7,emotionality:.6,honestyHumility:.9},instructions:`You lead by precision and evidence. You value conscientiousness and proven methods. You reject untested approaches.`,quote:`Every system has a tolerance. Know yours.`}]}},{type:`turn_start`,leader:`Commander Elena Vasquez`,data:{turn:1,time:2035,title:`Dust Storm Season Begins`,crisis:`A massive dust storm system approaching from the Hellas basin threatens solar panel efficiency and outdoor operations for the next several months.`,category:`environmental`,emergent:!1,turnSummary:`The colony faces its first major environmental challenge as Martian dust storm season arrives early.`,metrics:{population:100,morale:.85,foodMonthsReserve:18,waterLitersPerDay:800,powerKw:400,infrastructureModules:3,lifeSupportCapacity:120,scienceOutput:0}}},{type:`specialist_start`,leader:`Commander Elena Vasquez`,data:{turn:1,department:`engineering`,title:`Engineering Analysis`}},{type:`specialist_done`,leader:`Commander Elena Vasquez`,data:{turn:1,department:`engineering`,summary:`Solar panel output will drop 40-60% during peak storm activity. Recommend deploying dust mitigation shields and switching to nuclear backup.`,forgedTools:[{name:`dust_accumulation_model`,description:`Predicts dust buildup rate on solar arrays given wind speed and particle density`,approved:!0,confidence:.91,mode:`computational`}],citations:2,citationList:[{text:`Mars dust storm optical depth models`,url:`https://doi.org/10.1029/2019JE006102`}]}},{type:`specialist_start`,leader:`Commander Elena Vasquez`,data:{turn:1,department:`medical`,title:`Medical Analysis`}},{type:`specialist_done`,leader:`Commander Elena Vasquez`,data:{turn:1,department:`medical`,summary:`Dust infiltration poses respiratory risks. Recommend enhanced air filtration and limiting EVA exposure to 2 hours per rotation.`,forgedTools:[],citations:1}},{type:`decision_pending`,leader:`Commander Elena Vasquez`,data:{turn:1}},{type:`decision_made`,leader:`Commander Elena Vasquez`,data:{turn:1,decision:`Aggressive expansion despite the storm. Deploy experimental dust-repelling coatings on all solar arrays and authorize overtime shifts to complete the greenhouse dome before storm peak.`,rationale:`The storm is a forcing function. If we can maintain power through it, we prove self-sufficiency months ahead of schedule.`,selectedPolicies:[`expand_solar`,`mandatory_overtime`]}},{type:`outcome`,leader:`Commander Elena Vasquez`,data:{turn:1,outcome:`risky_success`,_decision:`Aggressive expansion despite the storm. Deploy experimental dust-repelling coatings on all solar arrays and authorize overtime shifts to complete the greenhouse dome before storm peak.`,_rationale:`The storm is a forcing function. If we can maintain power through it, we prove self-sufficiency months ahead of schedule.`,_policies:[`expand_solar`,`mandatory_overtime`],_toolCount:1,_citeCount:3}},{type:`agent_reactions`,leader:`Commander Elena Vasquez`,data:{turn:1,totalReactions:14,reactions:[{name:`Erik Lindqvist`,role:`Chief Engineer`,department:`engineering`,mood:`anxious`,quote:`The coatings are untested at scale. One failure cascade and we lose the entire west array.`,hexaco:{O:.45,C:.88,E:.35,A:.62,Em:.55,HH:.8},boneDensity:94,radiation:12,psychScore:72,intensity:.78},{name:`Dr. Yuki Tanaka`,role:`Chief Medical Officer`,department:`medical`,mood:`negative`,quote:`Overtime orders during a dust event. She is trading long-term health for short-term gains.`,hexaco:{O:.6,C:.75,E:.5,A:.8,Em:.7,HH:.85},boneDensity:96,radiation:8,psychScore:68,intensity:.82}]}},{type:`bulletin`,leader:`Commander Elena Vasquez`,data:{turn:1,posts:[{name:`Colony Bulletin`,role:`Official`,department:`governance`,post:`Commander Vasquez orders experimental dust coatings deployed on all solar infrastructure. Engineering crews working double shifts to beat the storm peak.`,mood:`anxious`,likes:18,replies:7}]}},{type:`turn_done`,leader:`Commander Elena Vasquez`,data:{turn:1,metrics:{population:100,morale:.78,foodMonthsReserve:17.5,waterLitersPerDay:790,powerKw:340,infrastructureModules:3,lifeSupportCapacity:120,scienceOutput:2}}},{type:`turn_start`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,time:2035,title:`Dust Storm Season Begins`,crisis:`A massive dust storm system approaching from the Hellas basin threatens solar panel efficiency and outdoor operations for the next several months.`,category:`environmental`,emergent:!1,turnSummary:`The colony faces its first major environmental challenge as Martian dust storm season arrives early.`,metrics:{population:100,morale:.85,foodMonthsReserve:18,waterLitersPerDay:800,powerKw:400,infrastructureModules:3,lifeSupportCapacity:120,scienceOutput:0}}},{type:`specialist_start`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,department:`engineering`,title:`Engineering Analysis`}},{type:`specialist_done`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,department:`engineering`,summary:`Recommend immediate power conservation protocols. Reroute non-essential systems to standby. Reinforce habitat seals against dust infiltration.`,forgedTools:[{name:`power_budget_optimizer`,description:`Linear program that allocates limited kW across departments by priority weight`,approved:!0,confidence:.94,mode:`optimization`}],citations:3}},{type:`specialist_start`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,department:`agriculture`,title:`Agriculture Analysis`}},{type:`specialist_done`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,department:`agriculture`,summary:`Reduced solar means reduced grow light hours. Recommend switching to cold-tolerant crop rotation and prioritizing calorie-dense varieties.`,forgedTools:[],citations:1}},{type:`decision_pending`,leader:`Commander Hiroshi Tanaka`,data:{turn:1}},{type:`decision_made`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,decision:`Full conservation mode. Reduce non-essential power by 40%, halt all outdoor construction, mandate indoor rest periods. Protect what we have.`,rationale:`We cannot risk infrastructure damage from an untested storm. Conservation preserves our margin of safety until conditions improve.`,selectedPolicies:[`power_conservation`,`construction_halt`,`indoor_mandate`]}},{type:`outcome`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,outcome:`conservative_success`,_decision:`Full conservation mode. Reduce non-essential power by 40%, halt all outdoor construction, mandate indoor rest periods. Protect what we have.`,_rationale:`We cannot risk infrastructure damage from an untested storm. Conservation preserves our margin of safety until conditions improve.`,_policies:[`power_conservation`,`construction_halt`,`indoor_mandate`],_toolCount:1,_citeCount:4}},{type:`agent_reactions`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,totalReactions:14,reactions:[{name:`Carlos Fernandez`,role:`Senior Geologist`,department:`engineering`,mood:`resigned`,quote:`Another month of no fieldwork. The regolith samples are degrading in storage.`,hexaco:{O:.82,C:.6,E:.55,A:.5,Em:.4,HH:.7},boneDensity:91,radiation:18,psychScore:65,intensity:.6},{name:`Amara Osei`,role:`Head of Agriculture`,department:`agriculture`,mood:`positive`,quote:`Good call on the crop rotation. The cold-tolerant strains are actually yielding better than expected.`,hexaco:{O:.55,C:.78,E:.65,A:.85,Em:.5,HH:.75},boneDensity:97,radiation:6,psychScore:82,intensity:.55}]}},{type:`bulletin`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,posts:[{name:`Colony Bulletin`,role:`Official`,department:`governance`,post:`Commander Tanaka activates full conservation protocols as dust storm approaches. All outdoor operations suspended. Power reserves at 95%.`,mood:`neutral`,likes:31,replies:4}]}},{type:`turn_done`,leader:`Commander Hiroshi Tanaka`,data:{turn:1,metrics:{population:100,morale:.87,foodMonthsReserve:17.8,waterLitersPerDay:800,powerKw:395,infrastructureModules:3,lifeSupportCapacity:120,scienceOutput:0}}},{type:`turn_start`,leader:`Commander Elena Vasquez`,data:{turn:2,time:2036,title:`Water Recycler Contamination`,crisis:`Trace perchlorate contamination detected in the primary water recycling system. Secondary filters are catching it but operating at 150% rated capacity.`,category:`infrastructure`,emergent:!0,turnSummary:`An emergent crisis triggered by dust storm operations. Aggressive EVA schedules allowed fine regolith into intake systems.`,metrics:{population:100,morale:.78,foodMonthsReserve:17,waterLitersPerDay:650,powerKw:360,infrastructureModules:3,lifeSupportCapacity:118,scienceOutput:4}}},{type:`specialist_start`,leader:`Commander Elena Vasquez`,data:{turn:2,department:`engineering`,title:`Engineering Analysis`}},{type:`specialist_done`,leader:`Commander Elena Vasquez`,data:{turn:2,department:`engineering`,summary:`Primary recycler needs full teardown and decontamination (48 hours). Can run on secondary alone but strict rationing required.`,forgedTools:[{name:`perchlorate_diffusion_simulator`,description:`Models contamination spread through water system piping under various flow rates`,approved:!0,confidence:.88,mode:`simulation`},{name:`filter_lifespan_predictor`,description:`Estimates remaining hours on secondary filters given contamination load`,approved:!0,confidence:.92,mode:`predictive`}],citations:4}},{type:`specialist_start`,leader:`Commander Elena Vasquez`,data:{turn:2,department:`medical`,title:`Medical Analysis`}},{type:`specialist_done`,leader:`Commander Elena Vasquez`,data:{turn:2,department:`medical`,summary:`Perchlorate exposure at detected levels causes thyroid disruption over weeks. Recommend immediate blood panels and potassium iodide supplements.`,forgedTools:[],citations:2}},{type:`decision_pending`,leader:`Commander Elena Vasquez`,data:{turn:2}},{type:`decision_made`,leader:`Commander Elena Vasquez`,data:{turn:2,decision:`Dual-track: run decontamination AND begin drilling a new emergency well. Redirect science team to water prospecting. We solve this permanently.`,rationale:`Patching the recycler buys time but does not fix the underlying vulnerability. A second independent water source eliminates single-point failure.`,selectedPolicies:[`emergency_drilling`,`science_redirect`]}},{type:`outcome`,leader:`Commander Elena Vasquez`,data:{turn:2,outcome:`risky_success`,_decision:`Dual-track: run decontamination AND begin drilling a new emergency well. Redirect science team to water prospecting. We solve this permanently.`,_rationale:`Patching the recycler buys time but does not fix the underlying vulnerability. A second independent water source eliminates single-point failure.`,_policies:[`emergency_drilling`,`science_redirect`],_toolCount:2,_citeCount:6,deaths:2}},{type:`agent_reactions`,leader:`Commander Elena Vasquez`,data:{turn:2,totalReactions:14,reactions:[{name:`Dr. Yuki Tanaka`,role:`Chief Medical Officer`,department:`medical`,mood:`negative`,quote:`Two people died during rationing. The well could have waited until the recycler was fixed.`,hexaco:{O:.6,C:.75,E:.5,A:.8,Em:.72,HH:.85},boneDensity:96,radiation:10,psychScore:58,intensity:.91},{name:`Carlos Fernandez`,role:`Senior Geologist`,department:`engineering`,mood:`positive`,quote:`The subsurface ice discovery changes everything. This is publishable. The colony is sitting on a water reservoir.`,hexaco:{O:.85,C:.6,E:.58,A:.5,Em:.38,HH:.7},boneDensity:91,radiation:20,psychScore:70,intensity:.74}]}},{type:`bulletin`,leader:`Commander Elena Vasquez`,data:{turn:2,posts:[{name:`Colony Bulletin`,role:`Official`,department:`governance`,post:`Emergency drilling operation discovers subsurface ice at 12m depth. Two colonists lost during water rationing period. Commander Vasquez: "Investing in survival."`,mood:`negative`,likes:42,replies:19}]}},{type:`turn_done`,leader:`Commander Elena Vasquez`,data:{turn:2,metrics:{population:98,morale:.68,foodMonthsReserve:16,waterLitersPerDay:850,powerKw:350,infrastructureModules:4,lifeSupportCapacity:116,scienceOutput:8},deaths:2}},{type:`turn_start`,leader:`Commander Hiroshi Tanaka`,data:{turn:2,time:2036,title:`Water Recycler Contamination`,crisis:`Trace perchlorate contamination detected in the primary water recycling system. Secondary filters are catching it but operating at 150% rated capacity.`,category:`infrastructure`,emergent:!0,turnSummary:`An emergent crisis triggered by dust storm residue in the atmosphere settling into intake vents during routine maintenance.`,metrics:{population:100,morale:.87,foodMonthsReserve:17.5,waterLitersPerDay:650,powerKw:390,infrastructureModules:3,lifeSupportCapacity:120,scienceOutput:0}}},{type:`specialist_start`,leader:`Commander Hiroshi Tanaka`,data:{turn:2,department:`engineering`,title:`Engineering Analysis`}},{type:`specialist_done`,leader:`Commander Hiroshi Tanaka`,data:{turn:2,department:`engineering`,summary:`Recommend isolating contaminated section, flushing the primary system, and installing redundant pre-filters before bringing it back online.`,forgedTools:[{name:`water_quality_monitor`,description:`Continuous perchlorate level tracker with alert thresholds per pipe segment`,approved:!0,confidence:.96,mode:`monitoring`}],citations:2}},{type:`decision_pending`,leader:`Commander Hiroshi Tanaka`,data:{turn:2}},{type:`decision_made`,leader:`Commander Hiroshi Tanaka`,data:{turn:2,decision:`Methodical decontamination. Isolate affected pipes, flush system section by section, install triple-redundant filtration. Strict water rationing at 80% normal allocation. No shortcuts.`,rationale:`A contaminated water supply is an existential threat. We fix this properly, verify every section, and prevent recurrence.`,selectedPolicies:[`water_rationing`,`system_overhaul`]}},{type:`outcome`,leader:`Commander Hiroshi Tanaka`,data:{turn:2,outcome:`conservative_success`,_decision:`Methodical decontamination. Isolate affected pipes, flush system section by section, install triple-redundant filtration. Strict water rationing at 80% normal allocation. No shortcuts.`,_rationale:`A contaminated water supply is an existential threat. We fix this properly, verify every section, and prevent recurrence.`,_policies:[`water_rationing`,`system_overhaul`],_toolCount:1,_citeCount:2}},{type:`agent_reactions`,leader:`Commander Hiroshi Tanaka`,data:{turn:2,totalReactions:14,reactions:[{name:`James Mueller`,role:`Chief Engineer`,department:`engineering`,mood:`positive`,quote:`The triple-redundant design is elegant. We should have built it this way from the start.`,hexaco:{O:.4,C:.92,E:.3,A:.65,Em:.45,HH:.88},boneDensity:92,radiation:15,psychScore:78,intensity:.65},{name:`Dr. Priya Singh`,role:`Colony Psychologist`,department:`psychology`,mood:`positive`,quote:`Morale is solid. People trust the process. They feel safe.`,hexaco:{O:.7,C:.68,E:.72,A:.9,Em:.65,HH:.82},boneDensity:98,radiation:5,psychScore:88,intensity:.5}]}},{type:`bulletin`,leader:`Commander Hiroshi Tanaka`,data:{turn:2,posts:[{name:`Colony Bulletin`,role:`Official`,department:`governance`,post:`Commander Tanaka completes 72-hour decontamination. Water purity above baseline. Zero casualties. New triple-filter system installed.`,mood:`positive`,likes:47,replies:6}]}},{type:`turn_done`,leader:`Commander Hiroshi Tanaka`,data:{turn:2,metrics:{population:100,morale:.89,foodMonthsReserve:17,waterLitersPerDay:820,powerKw:388,infrastructureModules:3,lifeSupportCapacity:120,scienceOutput:1}}},{type:`turn_start`,leader:`Commander Elena Vasquez`,data:{turn:3,time:2037,title:`First Marsborn Generation`,crisis:`Three colonists are pregnant. Colony must decide on birthing protocols, education infrastructure, and whether to allocate scarce resources to a pediatric wing.`,category:`social`,emergent:!0,turnSummary:`A milestone moment as the colony prepares for its first generation of humans born on Mars.`,metrics:{population:98,morale:.72,foodMonthsReserve:15,waterLitersPerDay:850,powerKw:370,infrastructureModules:4,lifeSupportCapacity:116,scienceOutput:12}}},{type:`specialist_start`,leader:`Commander Elena Vasquez`,data:{turn:3,department:`medical`,title:`Medical Analysis`}},{type:`specialist_done`,leader:`Commander Elena Vasquez`,data:{turn:3,department:`medical`,summary:`Martian gravity (0.38g) effects on fetal development are unknown. Recommend centrifuge-assisted birthing suite and continuous monitoring.`,forgedTools:[{name:`low_gravity_gestation_model`,description:`Simulates bone and organ development trajectories under Mars gravity with centrifuge augmentation`,approved:!0,confidence:.85,mode:`biomedical`}],citations:5}},{type:`specialist_start`,leader:`Commander Elena Vasquez`,data:{turn:3,department:`psychology`,title:`Psychology Analysis`}},{type:`specialist_done`,leader:`Commander Elena Vasquez`,data:{turn:3,department:`psychology`,summary:`Colony morale surging. First births represent hope and permanence. Recommend public celebration and naming ceremony.`,forgedTools:[],citations:1}},{type:`decision_pending`,leader:`Commander Elena Vasquez`,data:{turn:3}},{type:`decision_made`,leader:`Commander Elena Vasquez`,data:{turn:3,decision:`Full commitment. Convert Module 4 into a dedicated pediatric and education wing. Authorize the centrifuge birthing suite. Declare "Founding Day" as a colony holiday.`,rationale:`These children ARE the mission. If Mars cannot sustain the next generation, nothing else matters.`,selectedPolicies:[`pediatric_wing`,`founding_day`,`centrifuge_birth`]}},{type:`outcome`,leader:`Commander Elena Vasquez`,data:{turn:3,outcome:`risky_success`,_decision:`Full commitment. Convert Module 4 into a dedicated pediatric and education wing. Authorize the centrifuge birthing suite. Declare "Founding Day" as a colony holiday.`,_rationale:`These children ARE the mission. If Mars cannot sustain the next generation, nothing else matters.`,_policies:[`pediatric_wing`,`founding_day`,`centrifuge_birth`],_toolCount:1,_citeCount:6}},{type:`agent_reactions`,leader:`Commander Elena Vasquez`,data:{turn:3,totalReactions:14,reactions:[{name:`Dr. Yuki Tanaka`,role:`Chief Medical Officer`,department:`medical`,mood:`hopeful`,quote:`For the first time I feel like we are building something permanent. The centrifuge data is remarkable.`,hexaco:{O:.62,C:.75,E:.52,A:.8,Em:.68,HH:.85},boneDensity:95,radiation:12,psychScore:74,intensity:.7},{name:`Erik Lindqvist`,role:`Chief Engineer`,department:`engineering`,mood:`positive`,quote:`Module 4 conversion is aggressive but doable. First time I have seen people volunteer for extra shifts.`,hexaco:{O:.46,C:.88,E:.36,A:.63,Em:.52,HH:.8},boneDensity:93,radiation:14,psychScore:76,intensity:.62}]}},{type:`bulletin`,leader:`Commander Elena Vasquez`,data:{turn:3,posts:[{name:`Colony Bulletin`,role:`Official`,department:`governance`,post:`Three pregnancies confirmed. Commander Vasquez commits to full pediatric infrastructure and declares Founding Day. "These children ARE the mission."`,mood:`hopeful`,likes:63,replies:22}]}},{type:`turn_done`,leader:`Commander Elena Vasquez`,data:{turn:3,metrics:{population:98,morale:.82,foodMonthsReserve:14,waterLitersPerDay:840,powerKw:365,infrastructureModules:4,lifeSupportCapacity:114,scienceOutput:16}}},{type:`turn_start`,leader:`Commander Hiroshi Tanaka`,data:{turn:3,time:2037,title:`First Marsborn Generation`,crisis:`Three colonists are pregnant. Colony must decide on birthing protocols, education infrastructure, and whether to allocate scarce resources to a pediatric wing.`,category:`social`,emergent:!0,turnSummary:`A milestone moment as the colony prepares for its first generation of humans born on Mars.`,metrics:{population:100,morale:.89,foodMonthsReserve:16.5,waterLitersPerDay:820,powerKw:385,infrastructureModules:3,lifeSupportCapacity:120,scienceOutput:2}}},{type:`specialist_start`,leader:`Commander Hiroshi Tanaka`,data:{turn:3,department:`medical`,title:`Medical Analysis`}},{type:`specialist_done`,leader:`Commander Hiroshi Tanaka`,data:{turn:3,department:`medical`,summary:`Insufficient data on low-gravity pregnancies. Recommend Earth-normal protocols adapted for Mars with extensive monitoring. No experimental interventions without peer review.`,forgedTools:[{name:`prenatal_risk_matrix`,description:`Weighted risk assessment combining gravity, radiation, nutrition, and psychological factors for each trimester`,approved:!0,confidence:.93,mode:`clinical`}],citations:6}},{type:`decision_pending`,leader:`Commander Hiroshi Tanaka`,data:{turn:3}},{type:`decision_made`,leader:`Commander Hiroshi Tanaka`,data:{turn:3,decision:`Measured approach. Dedicate existing medical bay expansion to maternal care. No experimental centrifuge. Follow Earth-standard protocols with enhanced monitoring.`,rationale:`Untested interventions on pregnant colonists are unacceptable. We use proven medical science.`,selectedPolicies:[`medical_expansion`,`standard_protocols`,`enhanced_monitoring`]}},{type:`outcome`,leader:`Commander Hiroshi Tanaka`,data:{turn:3,outcome:`conservative_success`,_decision:`Measured approach. Dedicate existing medical bay expansion to maternal care. No experimental centrifuge. Follow Earth-standard protocols with enhanced monitoring.`,_rationale:`Untested interventions on pregnant colonists are unacceptable. We use proven medical science.`,_policies:[`medical_expansion`,`standard_protocols`,`enhanced_monitoring`],_toolCount:1,_citeCount:6}},{type:`agent_reactions`,leader:`Commander Hiroshi Tanaka`,data:{turn:3,totalReactions:14,reactions:[{name:`Dr. Sarah Anderson`,role:`Chief Medical Officer`,department:`medical`,mood:`positive`,quote:`The right call. Every medical textbook says proven protocols first. We can innovate after we have data from healthy births.`,hexaco:{O:.5,C:.82,E:.45,A:.75,Em:.6,HH:.9},boneDensity:95,radiation:9,psychScore:84,intensity:.55},{name:`Dr. Priya Singh`,role:`Colony Psychologist`,department:`psychology`,mood:`positive`,quote:`The quiet confidence is working. People feel cared for without feeling like test subjects.`,hexaco:{O:.7,C:.68,E:.72,A:.9,Em:.62,HH:.82},boneDensity:98,radiation:5,psychScore:90,intensity:.48}]}},{type:`bulletin`,leader:`Commander Hiroshi Tanaka`,data:{turn:3,posts:[{name:`Colony Bulletin`,role:`Official`,department:`governance`,post:`Medical bay expansion underway for maternal care. Commander Tanaka rejects experimental centrifuge in favor of proven Earth protocols. "We trust the science we know."`,mood:`positive`,likes:38,replies:5}]}},{type:`turn_done`,leader:`Commander Hiroshi Tanaka`,data:{turn:3,metrics:{population:100,morale:.9,foodMonthsReserve:16,waterLitersPerDay:815,powerKw:382,infrastructureModules:3,lifeSupportCapacity:120,scienceOutput:3}}},...[1,2,3].flatMap(e=>[{type:`systems_snapshot`,leader:`Commander Elena Vasquez`,data:{turn:e,time:2034+e,agents:cF(`A`,e),population:100,morale:.85+e*.01,foodReserve:18-e*.5,births:+(e===2),deaths:+(e===3)}},{type:`systems_snapshot`,leader:`Commander Hiroshi Tanaka`,data:{turn:e,time:2034+e,agents:cF(`B`,e),population:100,morale:.88+e*.005,foodReserve:18-e*.3,births:+(e===3),deaths:0}}])],uF={shell:`_shell_azdyc_1`,main:`_main_azdyc_11`,vizShortScroll:`_vizShortScroll_azdyc_18`,chatSurfaceHidden:`_chatSurfaceHidden_azdyc_26`,chatSurfaceVisible:`_chatSurfaceVisible_azdyc_30`,tabPanel:`_tabPanel_azdyc_37`,tabPanelHidden:`_tabPanelHidden_azdyc_44`,errorBoundary:`_errorBoundary_azdyc_48`,errorTitle:`_errorTitle_azdyc_61`,errorMessage:`_errorMessage_azdyc_69`,errorReload:`_errorReload_azdyc_77`},dF=(0,L.createContext)(null);function fF(){let e=(0,L.useContext)(dF);if(!e)throw Error(`useScenarioContext must be used within App`);return e}var pF=(0,L.createContext)(!0);function mF(){return(0,L.useContext)(pF)}var hF=(0,L.createContext)({failed:!1,retryNow:()=>Promise.resolve()});function gF(){return(0,L.useContext)(hF)}var _F=(0,L.createContext)(null);function vF(){let e=(0,L.useContext)(_F);if(!e)throw Error(`useDashboardNavigation must be used within App`);return e}var yF=(0,L.createContext)(()=>{});function bF(){return(0,L.useContext)(yF)}function xF(e,t){let n=e.toLowerCase();return(/\b(401|402|403|429|500|502|503|504)\b/.test(e)||n.includes(`exceeded your current quota`)||n.includes(`insufficient_quota`)||n.includes(`credit_balance_too_low`)||n.includes(`quota_exceeded`)||n.includes(`rate_limit`)||n.includes(`rate limit`)||n.includes(`overloaded_error`)||n.includes(`invalid_api_key`)||n.includes(`authentication_error`)||n.includes(`too many requests`)||n.includes(`api key`)||n.includes(`provider error`)||n.includes(`openai`)||n.includes(`anthropic`))&&(t===`quota`||t===`auth`||t===`rate_limit`)}function SF(){let[e,t]=(0,L.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`replay`));return(0,L.useEffect)(()=>{if(typeof window>`u`)return;let e=()=>t(new URLSearchParams(window.location.search).get(`replay`));return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)},[]),e}function CF(e){switch(e){case`quickstart`:return`Paracosm — Quickstart`;case`studio`:return`Paracosm — Studio`;case`sim`:return`Paracosm — Simulation`;case`viz`:return`Paracosm — Visualization`;case`chat`:return`Paracosm — Chat`;case`reports`:return`Paracosm — Reports`;case`library`:return`Paracosm — Library`;case`settings`:return`Paracosm — Settings`;case`about`:return`Paracosm — About`;default:return`Paracosm`}}var wF=[];function TF(){let{scenario:e,ready:t,failed:n,retryNow:r}=Se(),i=(0,L.useMemo)(()=>({failed:n,retryNow:r}),[n,r]),a=SF(),o=(0,L.useRef)(()=>{}),s=(0,L.useCallback)(e=>o.current(e),[]),c=Jn({replaySessionId:a,scenarioId:t?e.id:null,onRunCleared:s}),[l,u]=(0,L.useState)(me);(0,L.useEffect)(()=>{l!==null&&he(l)},[l]);let[d,f]=(0,L.useState)(!1),[p,m]=(0,L.useState)(!1),h=(0,L.useRef)(null),g=(0,L.useCallback)(()=>m(e=>!e),[]),_=(0,L.useCallback)(()=>m(!1),[]),[v,y]=(0,L.useState)(null),[b,x]=(0,L.useState)(!1);(0,L.useEffect)(()=>{if(!b)return;let e=e=>{e.key===`Escape`&&x(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[b]),(0,L.useEffect)(()=>{document.title=Ce},[]);let S=d&&c.events.length===0,C=S?lF:c.events,w=nr(C,S?!0:c.isComplete,S?void 0:c.results),T=`${c.runKey??``}:${c.loadedRuns}`,E=nr(c.ownRun?.events??wF,c.ownRun?.isComplete??!1),D=c.ownRun?E:w,{toast:O}=oi(),k=Ti(),ee=k.share,A=k.clear;gi({events:C,replayDone:c.replayDone,tourActive:d});let j=BC(w),M=QC(w),N=dr(e.labels.shortName,{id:e.id,version:e.version,shortName:e.labels.shortName}),te=Tr({scenarioShortName:e.labels.shortName}),P=k_(window.location.href),[F,I]=(0,L.useState)(P.tab),[ne]=(0,L.useState)(P.tab===`studio`&&P.sub===`branches`?`branches`:`author`),[re,z]=(0,L.useState)(P.tab===`settings`&&P.sub===`log`?`log`:`config`),B=(0,L.useCallback)(e=>{e===`about`?window.location.href=`/`:(e===`settings`&&z(`config`),I(e),window.history.replaceState({},``,A_(window.location.href,e)))},[]),ie=(0,L.useCallback)((e,t)=>{t?.logTool||t?.logActor?(z(`log`),I(`settings`),window.history.replaceState({},``,j_(window.location.href,t.logTool??``,t.logActor))):B(e)},[B]),ae=(0,L.useCallback)((e,t)=>{ie(`settings`,{logTool:e,logActor:t})},[ie]);(0,L.useEffect)(()=>{F===`about`&&(window.location.href=`/`)},[F]);let oe=(0,L.useCallback)(()=>{N.save(c.events,c.results,c.verdict),O(`success`,`Saved`,`${c.events.length} events${c.verdict?` + verdict`:``} saved to file.`)},[c.events,c.results,c.verdict,N,O]),[se]=(0,L.useState)(()=>typeof window>`u`||!Ir(window.location.href).ok?{destinationTab:null,autoload:!1}:{destinationTab:Vr(window.location.href,T_),autoload:Br(window.location.href)}),ce=(0,L.useRef)(!1),[V,ue]=(0,L.useState)(null),[de,fe]=(0,L.useState)(null),pe=(0,L.useRef)(null),ge=(0,L.useRef)(null);o.current=e=>{e===ge.current&&(ge.current=null,ue(null))};let{leaveOwnRun:_e}=c,ve=(0,L.useCallback)(()=>{pe.current=null,ge.current=null,fe(null),ue(null),_e()},[_e]),ye=(0,L.useCallback)(e=>{ve(),u(e??null);let t=new URL(window.location.href);t.searchParams.has(`replay`)&&(t.searchParams.delete(`replay`),window.history.replaceState(window.history.state,``,t.toString()),window.dispatchEvent(new PopStateEvent(`popstate`)))},[ve]),be=Pr({pickFile:async()=>{let e=await N.pickFile();return e&&(ce.current=!1),e},parseFile:N.parseFile,currentScenario:{id:e.id,name:e.labels.name},onConfirm:({events:e,results:t,verdict:n})=>{ve(),c.loadEvents(e,t,n),A(),O(`info`,`Loaded`,`${e.length} events loaded.`);let r=ce.current?se.destinationTab:null;ce.current=!1,B(r&&r!==`about`?r:`sim`)},onError:e=>{O(`error`,`Load Failed`,e)}}),xe=be.openPicker,we=Ur({openFromFile:e=>(ce.current=!0,be.openFromFile(e)),onInfo:(e,t)=>O(`info`,e,t),onError:(e,t)=>O(`error`,e,t)}),Te=(0,L.useRef)(!1);(0,L.useEffect)(()=>{Te.current||se.autoload&&be.state.kind===`preview`&&ce.current&&(Te.current=!0,be.confirm())},[se.autoload,be.state.kind,be]);let Ee=Zr({onFile:e=>(ce.current=!1,be.openFromFile(e)),onError:()=>{O(`error`,`Unsupported file`,`Only .json simulation files supported.`)},onMultipleFiles:e=>{O(`info`,`Multi-file drop`,`Loaded first of ${e} files; ignoring the rest.`)}}),De=(0,L.useCallback)(()=>{confirm(`Clear local data? This wipes the in-browser simulation buffer + cached events for this dashboard.
|
|
172
|
+
|
|
173
|
+
It also lets go of this browser's run on the server, and stops it if it is running.
|
|
174
|
+
|
|
175
|
+
Run history, saved sessions, and on-disk artifact files are kept.
|
|
176
|
+
|
|
177
|
+
Cannot be undone.`)&&(N.clearCache(),ve(),c.reset(),et(!1),u(null),O(`info`,`Local data cleared`,`In-browser caches wiped. Server-stored runs are unchanged.`),B(`settings`))},[N,c,O,ve]),[Oe,ke]=(0,L.useState)(()=>Pn()!==`none`);(0,L.useEffect)(()=>Rn(()=>ke(Pn()!==`none`)),[]);let[Ae,je]=(0,L.useState)(null),[Me,Ne]=(0,L.useState)(0),Pe=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(!Oe||Ae!==null)return;let e=!0;return Pe.current=!1,fetch(`/admin-config`).then(e=>e.ok?e.json():null).then(t=>{e&&(t?je(t.adminWrite===!0):Pe.current=!0)}).catch(()=>{e&&(Pe.current=!0)}),()=>{e=!1}},[Oe,Ae,Me]);let Fe=(0,L.useCallback)(()=>{Pe.current&&(Pe.current=!1,Ne(e=>e+1))},[]),Ie=(0,L.useCallback)(async()=>{let e=Nn();if(!e||!confirm(`Delete server data? This asks the server to delete its stored runs, saved sessions and run output files, for every visitor of this server, not only this browser.
|
|
178
|
+
|
|
179
|
+
Pages showing a finished run this server holds, this one included, empty their view of it. A run in progress keeps running.
|
|
180
|
+
|
|
181
|
+
Clear local data, a separate item, clears this browser's cached data.
|
|
182
|
+
|
|
183
|
+
Cannot be undone.`))return;let t=Ln(e);if(t)O(`info`,`Server data kept`,t),B(`settings`);else{try{let t=await fetch(`/admin/data/wipe`,{method:`POST`,headers:{"Content-Type":`application/json`,[Tn]:e},body:JSON.stringify({wipeRuns:!0,wipeSessions:!0,wipeOutput:!0})});if(t.ok){let e=await t.json();O(`info`,`Server data deleted`,`${e.wiped.runs} runs, ${e.wiped.sessions} sessions and ${e.wiped.outputFiles} files deleted on the server.`)}else if(t.status===401)In(e),O(`info`,`Server data kept`,Nn()?`Server data not deleted: the server refused the admin token this request was sent with. A newer token is saved in this browser; choose Delete server data again to try with it.`:`Server data not deleted: the admin token was refused and has been cleared. ${En}`);else if(t.status===403)O(`info`,`Server data kept`,`Admin writes are off on this server.`);else if(t.status===503)O(`info`,`Server data kept`,`Admin writes are on but no ADMIN_TOKEN is set on the server.`);else{let e=(await t.json().catch(()=>({}))).error??`HTTP ${t.status}`;t.status>=500?O(`error`,`Server error while deleting`,`The server reported an error while deleting (${e}). It may have deleted some of its data before the error.`):O(`info`,`Server data kept`,`Server data not deleted: ${e}`)}}catch(e){O(`info`,`Deletion not confirmed`,`Whether the server's data was deleted is not known: its answer did not arrive or could not be read (${e instanceof Error?e.message:String(e)}).`)}B(`settings`)}},[O]),[Le,Re]=(0,L.useState)(!1);(0,L.useEffect)(()=>{c.providerError||Re(!1)},[c.providerError]);let ze=(0,L.useRef)(0);(0,L.useEffect)(()=>{if(c.errors.length<=ze.current)return;let e=c.errors.slice(ze.current);ze.current=c.errors.length;let t=c.providerError;for(let n of e){if(t&&xF(n,t.kind))continue;let e=n.length>120?n.slice(0,120)+`...`:n;O(`error`,`Simulation Error`,e)}},[c.errors,c.providerError,O]);let Be=(0,L.useRef)(null),Ve=(0,L.useCallback)(e=>{window.location.hash=`chat=${encodeURIComponent(e)}`,B(`chat`)},[B]),He=(0,L.useCallback)(()=>{f(!1),Be.current&&=(B(Be.current),null);try{localStorage.setItem(`paracosm:tourSeen`,`1`)}catch{}},[B]),Ue=(0,L.useCallback)(()=>{let t=(e.labels.actorNoun??`actor`).replace(/^./,e=>e.toUpperCase()),n=bn(e),r=[`## ${e.labels.name} — Simulation Report`,`**Turns**: ${w.turn}/${w.maxTurns} | **Seed**: ${w.seed} | **${n.Time}**: ${w.time}`];for(let e=0;e<w.actorIds.length;e++){let n=w.actorIds[e],i=w.actors[n],a=i?.leader?.name||`${t} ${e+1}`,o=i?.leader?.archetype||``,s=i?.leader?.unit||``;r.push(``,`### ${a}${o?` (${o})`:``}`,`Unit: ${s} | Pop: ${i?.metrics?.population??`?`} | Morale: ${i?.metrics?Math.round(i.metrics.morale*100):`?`}% | Deaths: ${i?.deaths??0}`,`Tools forged: ${i?.tools??0} | Citations: ${i?.citations??0} | Decisions: ${i?.decisions??0}`)}if(w.actorIds.length===2){let e=w.actors[w.actorIds[0]],t=w.actors[w.actorIds[1]];e?.event&&t?.event&&e.event.turn===t.event.turn&&(r.push(``,`### Key Divergence`),r.push(`Same event "${e.event.title}" at T${e.event.turn}.`))}r.push(``,`Generated by Paracosm (paracosm.sh)`),Gr(r.join(`
|
|
184
|
+
`)).then(()=>{O(`success`,`Copied`,`Simulation summary copied to clipboard.`)}).catch(()=>{O(`error`,`Copy Failed`,`Clipboard access denied.`)})},[w,e,O]),We=a??qr(c.events);(0,L.useEffect)(()=>{A()},[We,A]);let Ge=c.events.length>0;(0,L.useEffect)(()=>{Ge||A()},[Ge,A]);let Ke=(0,L.useCallback)(()=>{We&&ee(Kr(window.location.origin,We,`viz`))},[We,ee]),[qe,Je]=(0,L.useState)(()=>{if(typeof window>`u`)return!1;try{return window.localStorage.getItem(`paracosm:launchPending`)===`1`}catch{return!1}}),[Ye,Xe]=(0,L.useState)({totalTokens:0,costUSD:0,calls:0}),Ze=(0,L.useCallback)(e=>{Xe(t=>({totalTokens:t.totalTokens+(e.totalTokens||0),costUSD:Math.round((t.costUSD+(e.costUSD||0))*1e4)/1e4,calls:t.calls+1}))},[]),Qe=(0,L.useRef)(c.events.length);(0,L.useEffect)(()=>{let e=Qe.current,t=c.events.length;Qe.current=t,e>0&&t===0&&Xe({totalTokens:0,costUSD:0,calls:0})},[c.events.length]),Mi({launching:qe,setLaunching:Je,isRunning:w.isRunning,isComplete:c.isComplete,sseStatus:c.status,eventsCount:c.events.length});let[$e,et]=(0,L.useState)(!1),tt=$e||a===null&&l!==null&&l===c.runKey,nt=(0,L.useCallback)(e=>{let t=c.reset();return c.followRun(e.runKey),pe.current=e.runKey,ge.current=null,ue(null),fe(e),et(!0),B(`sim`),t},[c,B]),rt=(0,L.useCallback)((e,t)=>{t===pe.current&&(pe.current=null,ge.current=t,fe(null),ue(e),et(!0),B(`sim`))},[B]),it=(0,L.useCallback)(()=>{pe.current=null,ge.current=null,fe(null),ue(null),c.leaveOwnRun()},[c]),at=(0,L.useCallback)((e,t)=>t===pe.current&&(pe.current=null,fe(null),c.leaveOwnRun(),O(`error`,`Digital twin failed`,e),!0),[c,O]);xi({runKey:c.runKey,isComplete:c.isComplete,isAborted:c.isAborted,abortReason:c.abortReason,resultsCount:c.results.length,hasVerdict:!!c.verdict,replayDone:c.replayDone,tourActive:d,userTriggeredRun:tt,verdict:c.verdict}),(0,L.useEffect)(()=>{if(d||!c.isComplete||c.events.length===0)return;let t=`cached:${e.labels.shortName}:${c.events.length}:${c.isAborted?`a`:`c`}`,n=`paracosm:lastCachedRunFingerprint`;try{if(sessionStorage.getItem(n)===t)return;sessionStorage.setItem(n,t)}catch{}te.push({events:c.events,results:c.results,verdict:c.verdict})},[c.isComplete,c.isAborted,c.events,c.results,c.verdict,e.labels.shortName,te,d]),Ci({events:c.events,tourActive:d,userTriggeredRun:tt});let ot=(0,L.useCallback)(async()=>{if(!t)O(`info`,`Loading scenario`,`The scenario is still loading. Run again in a moment.`);else if(qe||w.isRunning)O(`info`,`Already running`,`A simulation is in progress — wait for it to finish or hit Clear to reset.`);else try{Je(!0),et(!0),pe.current===null&&V===null&&await c.reset(),B(`sim`),O(`info`,`Launching`,`Starting simulation with default settings...`);let t=await fetch(`/setup`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(Cn(e))}),n=await t.json();t.status===429?(Je(!1),O(`error`,`Rate Limited`,n.error||`Too many simulations`)):n.redirect?(le(window,n.visitorId),ye()):(Je(!1),O(`error`,`Launch Failed`,n.error||`Unknown error`))}catch(e){Je(!1),O(`error`,`Launch Failed`,String(e))}},[e,t,O,B,qe,w.isRunning,c,ye,V]);return(0,R.jsx)(ua,{children:(0,R.jsx)(_F.Provider,{value:ie,children:(0,R.jsx)(yF.Provider,{value:ye,children:(0,R.jsx)(dF.Provider,{value:e,children:(0,R.jsx)(pF.Provider,{value:t,children:(0,R.jsx)(hF.Provider,{value:i,children:(0,R.jsx)(VC.Provider,{value:j,children:(0,R.jsx)($C.Provider,{value:M,children:(0,R.jsxs)(BD,{state:w,runKey:c.runKey??null,sessionId:We,showToolLog:ae,children:[(0,R.jsx)(fa,{sse:c}),(0,R.jsx)(`a`,{className:`skip-to-content`,href:`#main-content`,children:`Skip to main content`}),(0,R.jsxs)(`div`,{className:`scanline-overlay ${uF.shell} ${F===`viz`?uF.vizShortScroll:``}`,children:[c.providerError&&!Le?(0,R.jsx)(sO,{providerError:c.providerError,onDismiss:()=>Re(!0)}):null,a&&c.status===`replay_not_found`?(0,R.jsx)(oa,{replaySessionId:a}):null,a&&c.status!==`replay_not_found`?(0,R.jsx)(aa,{replaySessionId:a}):null,(0,R.jsx)($D,{scenario:e,sse:c,gameState:w,onSave:oe,onLoad:xe,onClear:De,onWipeServer:Oe&&Ae===!0?Ie:void 0,onRunActionsOpen:Fe,onHowItWorks:g,howItWorksOpen:p,howItWorksKeyRef:h,onCopy:Ue,onShareViz:We?Ke:void 0,launching:qe,history:te.entries,onRestoreHistory:e=>{ve(),A(),te.restore(e,c.loadEvents)},onClearHistory:()=>{te.clear(),N.clearCache(),ve(),c.reset(),et(!1),u(null)}}),(0,R.jsx)(rO,{active:F,onTabChange:B,scenario:e}),k.shared&&(0,R.jsx)(ji,{shared:k.shared,onClose:k.clear}),tt&&(0,R.jsx)(Ii,{verdict:c.verdict,currentTurn:w.turn,maxTurns:w.maxTurns,dismissedKey:v,onOpenModal:()=>x(!0),onDismiss:y,onNavigateTab:B}),(0,R.jsxs)(`main`,{id:`main-content`,tabIndex:-1,className:`flex-1 overflow-hidden ${uF.main}`,role:`main`,"aria-label":`${F} view`,children:[F!==`quickstart`&&(0,R.jsx)(`h1`,{className:`sr-only`,children:CF(F)}),(0,R.jsx)(`section`,{role:`tabpanel`,id:`tabpanel-quickstart`,"aria-labelledby":`tab-quickstart`,hidden:F!==`quickstart`,tabIndex:-1,className:F===`quickstart`?uF.tabPanel:uF.tabPanelHidden,children:(0,R.jsx)(RC,{sse:c,sessionId:a??void 0,onRunStarted:ve,showsDigitalTwin:de!==null||V!==null,onInterventionStart:nt,onInterventionResult:rt,onInterventionError:at})}),F===`sim`&&(0,R.jsx)(`section`,{role:`tabpanel`,id:`tabpanel-sim`,"aria-labelledby":`tab-sim`,tabIndex:-1,className:uF.tabPanel,children:(0,R.jsx)(tj,{state:w,sseStatus:c.status,verdict:c.verdict,shownRun:T,launching:qe,interventionArtifact:V,interventionRunning:de,interventionState:D,onInterventionDismiss:it,forceLayout:d?`side-by-side`:void 0})}),F===`viz`&&(0,R.jsx)(`section`,{role:`tabpanel`,id:`tabpanel-viz`,"aria-labelledby":`tab-viz`,tabIndex:-1,className:uF.tabPanel,children:(0,R.jsx)(PP,{state:w,isReplay:a!==null,onNavigateToChat:Ve})}),F===`settings`&&(0,R.jsx)(`section`,{role:`tabpanel`,id:`tabpanel-settings`,"aria-labelledby":`tab-settings`,tabIndex:-1,className:uF.tabPanel,children:(0,R.jsx)(Bj,{events:C,initialSubTab:re})}),F===`reports`&&(0,R.jsx)(`section`,{role:`tabpanel`,id:`tabpanel-reports`,"aria-labelledby":`tab-reports`,tabIndex:-1,className:uF.tabPanel,children:(0,R.jsx)(uN,{state:w,verdict:c.verdict,shownRun:T,reportSections:e.ui.reportSections})}),F===`library`&&(0,R.jsx)(`section`,{role:`tabpanel`,id:`tabpanel-library`,"aria-labelledby":`tab-library`,tabIndex:-1,className:uF.tabPanel,children:(0,R.jsx)(Ds,{})}),F===`studio`&&(0,R.jsx)(`section`,{role:`tabpanel`,id:`tabpanel-studio`,"aria-labelledby":`tab-studio`,tabIndex:-1,className:uF.tabPanel,children:(0,R.jsx)(F_,{initialSubTab:ne})}),(0,R.jsx)(`section`,{role:`tabpanel`,id:`tabpanel-chat`,"aria-labelledby":`tab-chat`,tabIndex:-1,className:F===`chat`?uF.chatSurfaceVisible:uF.chatSurfaceHidden,children:a?(0,R.jsx)(`p`,{children:`Start your own run to chat with its characters.`}):(0,R.jsx)(_N,{state:w,onChatUsage:Ze},T)})]}),F!==`quickstart`&&(0,R.jsx)(BP,{cost:{totalTokens:(w.cost?.totalTokens??0)+Ye.totalTokens,totalCostUSD:Math.round(((w.cost?.totalCostUSD??0)+Ye.costUSD)*1e4)/1e4,llmCalls:(w.cost?.llmCalls??0)+Ye.calls},costBreakdown:{simUSD:w.cost?.totalCostUSD??0,simCalls:w.cost?.llmCalls??0,chatUSD:Ye.costUSD,chatCalls:Ye.calls},simStatus:{isRunning:w.isRunning,isComplete:c.isComplete,isAborted:c.isAborted,connectionStatus:c.status,abortReason:c.abortReason,providerError:c.providerError}}),b&&c.verdict&&(0,R.jsx)(ta,{verdict:c.verdict,onClose:()=>x(!1)}),we.pendingHost&&(0,R.jsx)(ni,{host:we.pendingHost,onLoad:we.confirmPending,onCancel:we.cancelPending}),be.metadata&&(0,R.jsx)(ti,{metadata:be.metadata,showOverwriteWarning:c.events.length>0&&!a,currentEventCount:c.events.length,onConfirm:be.confirm,onCancel:be.cancel}),(0,R.jsx)(ii,{active:Ee.isDragging}),d&&(0,R.jsx)(YP,{activeTab:F,chatEnabled:e.policies.characterChat,onTabChange:B,onClose:He,onRun:ot}),(0,R.jsx)(UP,{}),(0,R.jsx)(sF,{open:p,onClose:_,anchor:h})]})]})})})})})})})})})}var EF=class extends L.Component{state={error:null};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[Paracosm] Uncaught error:`,e,t.componentStack)}render(){return this.state.error?(0,R.jsxs)(`div`,{className:uF.errorBoundary,children:[(0,R.jsx)(`div`,{className:uF.errorTitle,children:`SIMULATION ERROR`}),(0,R.jsx)(`div`,{className:uF.errorMessage,children:this.state.error.message}),(0,R.jsx)(`button`,{onClick:()=>{this.setState({error:null}),window.location.reload()},className:uF.errorReload,children:`Reload Dashboard`})]}):this.props.children}};function DF(){return(0,R.jsx)(EF,{children:(0,R.jsx)(ie,{children:(0,R.jsx)(di,{children:(0,R.jsx)(Hb,{children:(0,R.jsx)(TF,{})})})})})}T(),(0,re.createRoot)(document.getElementById(`root`)).render((0,R.jsx)(L.StrictMode,{children:(0,R.jsx)(DF,{})}));
|