Files
gnommoplayer/public/glitch/glitch_gallery/assets/index-C370CA0j.js
T
2026-04-11 09:21:22 +02:00

126 lines
79 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import{r as c,u as _t,c as Nt,a as We,_ as dt,D as Ht,V as ve,b as Vt,P as Tt,O as Et,S as Gt,U as Ut,d as Yt,M as Jt,R as qt,e as Xt,f as Zt,B as Qt,C as ut,A as Kt,j as e,Q as en}from"./index-CEeZxcxj.js";const Xe=new ve,ft=new ve,tn=new ve,jt=new Vt;function nn(t,n,o){const r=Xe.setFromMatrixPosition(t.matrixWorld);r.project(n);const s=o.width/2,i=o.height/2;return[r.x*s+s,-(r.y*i)+i]}function on(t,n){const o=Xe.setFromMatrixPosition(t.matrixWorld),r=ft.setFromMatrixPosition(n.matrixWorld),s=o.sub(r),i=n.getWorldDirection(tn);return s.angleTo(i)>Math.PI/2}function rn(t,n,o,r){const s=Xe.setFromMatrixPosition(t.matrixWorld),i=s.clone();i.project(n),jt.set(i.x,i.y),o.setFromCamera(jt,n);const d=o.intersectObjects(r,!0);if(d.length){const l=d[0].distance;return s.distanceTo(o.ray.origin)<l}return!0}function sn(t,n){if(n instanceof Et)return n.zoom;if(n instanceof Tt){const o=Xe.setFromMatrixPosition(t.matrixWorld),r=ft.setFromMatrixPosition(n.matrixWorld),s=n.fov*Math.PI/180,i=o.distanceTo(r);return 1/(2*Math.tan(s/2)*i)}else return 1}function an(t,n,o){if(n instanceof Tt||n instanceof Et){const r=Xe.setFromMatrixPosition(t.matrixWorld),s=ft.setFromMatrixPosition(n.matrixWorld),i=r.distanceTo(s),d=(o[1]-o[0])/(n.far-n.near),l=o[1]-d*n.far;return Math.round(d*i+l)}}const pt=t=>Math.abs(t)<1e-10?0:t;function kt(t,n,o=""){let r="matrix3d(";for(let s=0;s!==16;s++)r+=pt(n[s]*t.elements[s])+(s!==15?",":")");return o+r}const ln=(t=>n=>kt(n,t))([1,-1,1,1,1,-1,1,1,1,-1,1,1,1,-1,1,1]),cn=(t=>(n,o)=>kt(n,t(o),"translate(-50%,-50%)"))(t=>[1/t,1/t,1/t,1,-1/t,-1/t,-1/t,-1,1/t,1/t,1/t,1,1,1,1,1]);function dn(t){return t&&typeof t=="object"&&"current"in t}const Ae=c.forwardRef(({children:t,eps:n=.001,style:o,className:r,prepend:s,center:i,fullscreen:d,portal:l,distanceFactor:a,sprite:u=!1,transform:h=!1,occlude:p,onOcclude:g,castShadow:y,receiveShadow:I,material:S,geometry:L,zIndexRange:F=[16777271,0],calculatePosition:_=nn,as:v="div",wrapperClass:$,pointerEvents:A="auto",...D},W)=>{const{gl:B,camera:C,scene:te,size:j,raycaster:N,events:H,viewport:R}=_t(),[E]=c.useState(()=>document.createElement(v)),x=c.useRef(null),U=c.useRef(null),Se=c.useRef(0),G=c.useRef([0,0]),b=c.useRef(null),z=c.useRef(null),k=l?.current||H.connected||B.domElement.parentNode,w=c.useRef(null),K=c.useRef(!1),V=c.useMemo(()=>p&&p!=="blending"||Array.isArray(p)&&p.length&&dn(p[0]),[p]);c.useLayoutEffect(()=>{const X=B.domElement;p&&p==="blending"?(X.style.zIndex=`${Math.floor(F[0]/2)}`,X.style.position="absolute",X.style.pointerEvents="none"):(X.style.zIndex=null,X.style.position=null,X.style.pointerEvents=null)},[p]),c.useLayoutEffect(()=>{if(U.current){const X=x.current=Nt.createRoot(E);if(te.updateMatrixWorld(),h)E.style.cssText="position:absolute;top:0;left:0;pointer-events:none;overflow:hidden;";else{const O=_(U.current,C,j);E.style.cssText=`position:absolute;top:0;left:0;transform:translate3d(${O[0]}px,${O[1]}px,0);transform-origin:0 0;`}return k&&(s?k.prepend(E):k.appendChild(E)),()=>{k&&k.removeChild(E),X.unmount()}}},[k,h]),c.useLayoutEffect(()=>{$&&(E.className=$)},[$]);const re=c.useMemo(()=>h?{position:"absolute",top:0,left:0,width:j.width,height:j.height,transformStyle:"preserve-3d",pointerEvents:"none"}:{position:"absolute",transform:i?"translate3d(-50%,-50%,0)":"none",...d&&{top:-j.height/2,left:-j.width/2,width:j.width,height:j.height},...o},[o,i,d,j,h]),ge=c.useMemo(()=>({position:"absolute",pointerEvents:A}),[A]);c.useLayoutEffect(()=>{if(K.current=!1,h){var X;(X=x.current)==null||X.render(c.createElement("div",{ref:b,style:re},c.createElement("div",{ref:z,style:ge},c.createElement("div",{ref:W,className:r,style:o,children:t}))))}else{var O;(O=x.current)==null||O.render(c.createElement("div",{ref:W,style:re,className:r,children:t}))}});const he=c.useRef(!0);We(X=>{if(U.current){C.updateMatrixWorld(),U.current.updateWorldMatrix(!0,!1);const O=h?G.current:_(U.current,C,j);if(h||Math.abs(Se.current-C.zoom)>n||Math.abs(G.current[0]-O[0])>n||Math.abs(G.current[1]-O[1])>n){const me=on(U.current,C);let ee=!1;V&&(Array.isArray(p)?ee=p.map(ae=>ae.current):p!=="blending"&&(ee=[te]));const fe=he.current;if(ee){const ae=rn(U.current,C,N,ee);he.current=ae&&!me}else he.current=!me;fe!==he.current&&(g?g(!he.current):E.style.display=he.current?"block":"none");const ce=Math.floor(F[0]/2),Y=p?V?[F[0],ce]:[ce-1,0]:F;if(E.style.zIndex=`${an(U.current,C,Y)}`,h){const[ae,ie]=[j.width/2,j.height/2],Be=C.projectionMatrix.elements[5]*ie,{isOrthographicCamera:Ce,top:Le,left:Te,bottom:Re,right:$e}=C,J=ln(C.matrixWorldInverse),_e=Ce?`scale(${Be})translate(${pt(-($e+Te)/2)}px,${pt((Le+Re)/2)}px)`:`translateZ(${Be}px)`;let be=U.current.matrixWorld;u&&(be=C.matrixWorldInverse.clone().transpose().copyPosition(be).scale(U.current.scale),be.elements[3]=be.elements[7]=be.elements[11]=0,be.elements[15]=1),E.style.width=j.width+"px",E.style.height=j.height+"px",E.style.perspective=Ce?"":`${Be}px`,b.current&&z.current&&(b.current.style.transform=`${_e}${J}translate(${ae}px,${ie}px)`,z.current.style.transform=cn(be,1/((a||10)/400)))}else{const ae=a===void 0?1:sn(U.current,C)*a;E.style.transform=`translate3d(${O[0]}px,${O[1]}px,0) scale(${ae})`}G.current=O,Se.current=C.zoom}}if(!V&&w.current&&!K.current)if(h){if(b.current){const O=b.current.children[0];if(O!=null&&O.clientWidth&&O!=null&&O.clientHeight){const{isOrthographicCamera:me}=C;if(me||L)D.scale&&(Array.isArray(D.scale)?D.scale instanceof ve?w.current.scale.copy(D.scale.clone().divideScalar(1)):w.current.scale.set(1/D.scale[0],1/D.scale[1],1/D.scale[2]):w.current.scale.setScalar(1/D.scale));else{const ee=(a||10)/400,fe=O.clientWidth*ee,ce=O.clientHeight*ee;w.current.scale.set(fe,ce,1)}K.current=!0}}}else{const O=E.children[0];if(O!=null&&O.clientWidth&&O!=null&&O.clientHeight){const me=1/R.factor,ee=O.clientWidth*me,fe=O.clientHeight*me;w.current.scale.set(ee,fe,1),K.current=!0}w.current.lookAt(X.camera.position)}});const q=c.useMemo(()=>({vertexShader:h?void 0:`
/*
This shader is from the THREE's SpriteMaterial.
We need to turn the backing plane into a Sprite
(make it always face the camera) if "transfrom"
is false.
*/
#include <common>
void main() {
vec2 center = vec2(0., 1.);
float rotation = 0.0;
// This is somewhat arbitrary, but it seems to work well
// Need to figure out how to derive this dynamically if it even matters
float size = 0.03;
vec4 mvPosition = modelViewMatrix * vec4( 0.0, 0.0, 0.0, 1.0 );
vec2 scale;
scale.x = length( vec3( modelMatrix[ 0 ].x, modelMatrix[ 0 ].y, modelMatrix[ 0 ].z ) );
scale.y = length( vec3( modelMatrix[ 1 ].x, modelMatrix[ 1 ].y, modelMatrix[ 1 ].z ) );
bool isPerspective = isPerspectiveMatrix( projectionMatrix );
if ( isPerspective ) scale *= - mvPosition.z;
vec2 alignedPosition = ( position.xy - ( center - vec2( 0.5 ) ) ) * scale * size;
vec2 rotatedPosition;
rotatedPosition.x = cos( rotation ) * alignedPosition.x - sin( rotation ) * alignedPosition.y;
rotatedPosition.y = sin( rotation ) * alignedPosition.x + cos( rotation ) * alignedPosition.y;
mvPosition.xy += rotatedPosition;
gl_Position = projectionMatrix * mvPosition;
}
`,fragmentShader:`
void main() {
gl_FragColor = vec4(0.0, 0.0, 0.0, 0.0);
}
`}),[h]);return c.createElement("group",dt({},D,{ref:U}),p&&!V&&c.createElement("mesh",{castShadow:y,receiveShadow:I,ref:w},L||c.createElement("planeGeometry",null),S||c.createElement("shaderMaterial",{side:Ht,vertexShader:q.vertexShader,fragmentShader:q.fragmentShader})))});function un(t,n,o,r){var s;return s=class extends Gt{constructor(i){super({vertexShader:n,fragmentShader:o,...i});for(const d in t)this.uniforms[d]=new Ut(t[d]),Object.defineProperty(this,d,{get(){return this.uniforms[d].value},set(l){this.uniforms[d].value=l}});this.uniforms=Yt.clone(this.uniforms)}},s.key=Jt.generateUUID(),s}const pn=()=>parseInt(qt.replace(/\D+/g,"")),hn=pn(),fn=un({cellSize:.5,sectionSize:1,fadeDistance:100,fadeStrength:1,fadeFrom:1,cellThickness:.5,sectionThickness:1,cellColor:new ut,sectionColor:new ut,infiniteGrid:!1,followCamera:!1,worldCamProjPosition:new ve,worldPlanePosition:new ve},`
varying vec3 localPosition;
varying vec4 worldPosition;
uniform vec3 worldCamProjPosition;
uniform vec3 worldPlanePosition;
uniform float fadeDistance;
uniform bool infiniteGrid;
uniform bool followCamera;
void main() {
localPosition = position.xzy;
if (infiniteGrid) localPosition *= 1.0 + fadeDistance;
worldPosition = modelMatrix * vec4(localPosition, 1.0);
if (followCamera) {
worldPosition.xyz += (worldCamProjPosition - worldPlanePosition);
localPosition = (inverse(modelMatrix) * worldPosition).xyz;
}
gl_Position = projectionMatrix * viewMatrix * worldPosition;
}
`,`
varying vec3 localPosition;
varying vec4 worldPosition;
uniform vec3 worldCamProjPosition;
uniform float cellSize;
uniform float sectionSize;
uniform vec3 cellColor;
uniform vec3 sectionColor;
uniform float fadeDistance;
uniform float fadeStrength;
uniform float fadeFrom;
uniform float cellThickness;
uniform float sectionThickness;
float getGrid(float size, float thickness) {
vec2 r = localPosition.xz / size;
vec2 grid = abs(fract(r - 0.5) - 0.5) / fwidth(r);
float line = min(grid.x, grid.y) + 1.0 - thickness;
return 1.0 - min(line, 1.0);
}
void main() {
float g1 = getGrid(cellSize, cellThickness);
float g2 = getGrid(sectionSize, sectionThickness);
vec3 from = worldCamProjPosition*vec3(fadeFrom);
float dist = distance(from, worldPosition.xyz);
float d = 1.0 - min(dist / fadeDistance, 1.0);
vec3 color = mix(cellColor, sectionColor, min(1.0, sectionThickness * g2));
gl_FragColor = vec4(color, (g1 + g2) * pow(d, fadeStrength));
gl_FragColor.a = mix(0.75 * gl_FragColor.a, gl_FragColor.a, g2);
if (gl_FragColor.a <= 0.0) discard;
#include <tonemapping_fragment>
#include <${hn>=154?"colorspace_fragment":"encodings_fragment"}>
}
`),xn=c.forwardRef(({args:t,cellColor:n="#000000",sectionColor:o="#2080ff",cellSize:r=.5,sectionSize:s=1,followCamera:i=!1,infiniteGrid:d=!1,fadeDistance:l=100,fadeStrength:a=1,fadeFrom:u=1,cellThickness:h=.5,sectionThickness:p=1,side:g=Qt,...y},I)=>{Xt({GridMaterial:fn});const S=c.useRef(null);c.useImperativeHandle(I,()=>S.current,[]);const L=new Zt,F=new ve(0,1,0),_=new ve(0,0,0);We(A=>{L.setFromNormalAndCoplanarPoint(F,_).applyMatrix4(S.current.matrixWorld);const D=S.current.material,W=D.uniforms.worldCamProjPosition,B=D.uniforms.worldPlanePosition;L.projectPoint(A.camera.position,W.value),B.value.set(0,0,0).applyMatrix4(S.current.matrixWorld)});const v={cellSize:r,sectionSize:s,cellColor:n,sectionColor:o,cellThickness:h,sectionThickness:p},$={fadeDistance:l,fadeStrength:a,fadeFrom:u,infiniteGrid:d,followCamera:i};return c.createElement("mesh",dt({ref:S,frustumCulled:!1},y),c.createElement("gridMaterial",dt({transparent:!0,"extensions-derivatives":!0,side:g},v,$)),c.createElement("planeGeometry",{args:t}))});function mn({vector:t,origin:n=[0,0,0],color:o="#facc15"}){const{dir:r,len:s,position:i}=c.useMemo(()=>{const l=new ve(...n),a=new ve(...t),u=l.distanceTo(a);return{dir:a.clone().sub(l).normalize(),len:u,position:l}},[t,n]),d=c.useMemo(()=>new Kt(r,i,s,o,.2*Math.min(s,1)+.1,.1*Math.min(s,1)+.05),[r,s,i,o]);return e.jsx("primitive",{object:d})}function gn(t,n=!1){const o=[];for(let r=0;r<=t;r++)for(let s=0;s<=t-r;s++){const i=t-r-s;if(i>=0)if(!n)o.push([r,s,i]);else{const d=r===0?[1]:[1,-1],l=s===0?[1]:[1,-1],a=i===0?[1]:[1,-1];for(const u of d)for(const h of l)for(const p of a)o.push([r*u,s*h,i*p])}}return o}function bn({vector:t,radius:n,distance:o,color:r}){const{position:s,quaternion:i}=c.useMemo(()=>{const d=new ve(...t).normalize(),l=new ve(0,1,0),a=new en().setFromUnitVectors(l,d);return{position:d.clone().multiplyScalar(o/2),quaternion:a}},[t,o]);return e.jsxs("mesh",{position:s,quaternion:i,children:[e.jsx("cylinderGeometry",{args:[n,n,o,32]}),e.jsx("meshStandardMaterial",{color:r,opacity:.5,transparent:!0})]})}function yn({complexity:t,lightlanes:n=!1,radius:o=.5,distance:r=5,allSectors:s=!1,cumulative:i=!1}){const d=c.useMemo(()=>{const a=[],u=i?1:t,h=t;for(let p=u;p<=h;p++){const g=gn(p,s);for(const y of g)a.push({vec:y,c:p})}return a},[t,s,i]),l=a=>{const u=i?Math.max(t,1):t;return`hsl(${270*(1-(u>1?(a-1)/(u-1):1))}, 100%, 50%)`};return e.jsx("group",{children:d.map((a,u)=>{const h=i?l(a.c):n?"#ff33c5":"#4ade80";return n?e.jsx(bn,{vector:a.vec,radius:o,distance:r,color:h},`cyl-${u}-${a.vec.join(",")}-${a.c}`):e.jsx(mn,{vector:a.vec,color:h},`vec-${u}-${a.vec.join(",")}-${a.c}`)})})}const vn="glitch:play-sound",Sn="glitch:stop-sound",ke={click:"ui.button_click",hover:"ui.button_hover",computeStart:"machine.compute_start",computeStep:"machine.compute_step",computeDone:"machine.compute_done"};function Bt(t,n){typeof window>"u"||window.dispatchEvent(new CustomEvent(t,{detail:n}))}function Ie(t,n,o){try{if(t?.playSound){t.playSound(n,o);return}}catch{}Bt(vn,{id:n,payload:o})}function jn(t,n,o){try{if(t?.stopSound){t.stopSound(n,o);return}}catch{}Bt(Sn,{id:n,payload:o})}const Ue=1e-12;function ct(t=123456789){let n=t>>>0;return function(){n|=0,n=n+1831565813|0;let r=Math.imul(n^n>>>15,1|n);return r=r+Math.imul(r^r>>>7,61|r)^r,((r^r>>>14)>>>0)/4294967296}}function Mn(t,n=Math.random){if(!Number.isFinite(t)||t<=0)return 0;if(t<30){const d=Math.exp(-t);let l=0,a=1;do l++,a*=n();while(a>d);return l-1}const o=Math.max(1e-12,n()),r=n(),s=Math.sqrt(-2*Math.log(o))*Math.cos(2*Math.PI*r),i=t+Math.sqrt(t)*s;return Math.max(0,Math.round(i))}function ot(t){return[t[0]??t.x,t[1]??t.y,t[2]??t.z]}function wn(t,n,o){return Math.sqrt(t*t+n*n+o*o)}function Rt(t){const n=2*Math.PI;let o=t%n;return o<0&&(o+=n),o}function Pn(t){const n=2*t()-1,o=2*Math.PI*t();return{theta:Math.acos(Math.max(-1,Math.min(1,n))),phi:o}}function ht(t){const n=2*Math.PI;let o=t%n;return o<0&&(o+=n),o>Math.PI&&(o=n-o),o}function Mt(t=Math.random){const n=Math.max(1e-12,t()),o=t();return Math.sqrt(-2*Math.log(n))*Math.cos(2*Math.PI*o)}function Fn(t,n,o){const r=Math.sin(n);return[t*r*Math.cos(o),t*Math.cos(n),t*r*Math.sin(o)]}function Cn(t,n=!1,o=!1){const r=[],s=o?1:t,i=t;for(let d=s;d<=i;d++)for(let l=0;l<=d;l++)for(let a=0;a<=d-l;a++){const u=d-l-a;if(!n){r.push([l,a,u]);continue}const h=l===0?[1]:[1,-1],p=a===0?[1]:[1,-1],g=u===0?[1]:[1,-1];for(const y of h)for(const I of p)for(const S of g)r.push([l*y,a*I,u*S])}return r}function wt({D:t,complexity:n,allSectors:o=!1,cumulative:r=!1}){if(!Number.isFinite(t)||t<=0)return[];if(!Number.isInteger(n)||n<1)return[];const s=Cn(n,o,r),i=[];for(let d=0;d<s.length;d++){const[l,a,u]=s[d],h=wn(l,a,u);h<=Ue||i.push([t*l/h,t*a/h,t*u/h])}return i}function Tn(t,n,o){if(!t||t.length===0||!Number.isFinite(o)||o<=0)return 0;const[r,s,i]=ot(n),d=o*o;let l=0;for(let a=0;a<t.length;a++){const[u,h,p]=ot(t[a]),g=u*u+h*h+p*p;if(g<=Ue)continue;let y=(r*u+s*h+i*p)/g;y<0&&(y=0),y>1&&(y=1);const I=y*u,S=y*h,L=y*p,F=r-I,_=s-S,v=i-L;F*F+_*_+v*v<d&&l++}return l}function En(t,n,o,r){if(!t||t.length===0||!Number.isFinite(n)||n<=0||!Number.isFinite(r)||r<=0)return 0;const[s,i,d]=ot(o),a=n*n-.5*r*r;let u=0;for(let h=0;h<t.length;h++){const[p,g,y]=ot(t[h]);s*p+i*g+d*y>a&&u++}return u}function zt({D:t,lane_radius:n}){if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0)return 0;const o=n*n/(4*t*t);return o<=0?0:o>1?1:o}function kn({D:t,lane_radius:n,lane_length:o}){if(!Number.isFinite(t)||t<=0||!Number.isFinite(n)||n<=0||!Number.isFinite(o)||o<=0)return 0;if(o>=t-Ue)return zt({D:t,lane_radius:n});const r=n,s=o,i=t-s;if(r<=i)return 0;if(r>=t+s)return 1;const d=Math.sqrt(Math.max(0,t*t-s*s));let l;return r<d?l=(t*t+s*s-r*r)/(2*t*s):r<t?l=Math.sqrt(Math.max(0,1-r*r/(t*t))):l=-1,Number.isFinite(l)?(l<-1&&(l=-1),l>1&&(l=1),(1-l)/2):0}function Bn({flux:t,D:n,lane_radius:o,dt:r}){if(!Number.isFinite(t)||t<=0||!Number.isFinite(r)||r<=0)return 0;const s=zt({D:n,lane_radius:o});return t*s*r}function Rn({flux:t,D:n,lane_radius:o,lane_length:r,dt:s}){if(!Number.isFinite(t)||t<=0||!Number.isFinite(s)||s<=0)return 0;const i=kn({D:n,lane_radius:o,lane_length:r});return t*i*s}function It({flux:t,D:n,lane_radius:o,dt:r,hitTestModel:s="shell",lane_length:i}){return s==="segment"?Rn({flux:t,D:n,lane_radius:o,lane_length:i,dt:r}):Bn({flux:t,D:n,lane_radius:o,dt:r})}function zn(t){if(!t||typeof t!="object")throw new Error("createSamplingSimulation: config object is required.");const n=t.lane_radius??t.radius,o=t.D,r=t.complexity,s=t.flux,i=t.bin_size??1,d=t.sub_bin_sampling??4,l=t.thetaDrift??t.theta_drift??0,a=t.thetaJitter??t.theta_jitter??0,u=t.phiJitter??t.phi_jitter??0,h=t.laneLength??t.lane_length??t.distance??o,p=t.hitTestModel??t.hit_test_model??"shell",g=t.observationMode??t.observation_mode??"orbit";if(!Number.isFinite(o)||o<=0)throw new Error("createSamplingSimulation: D must be a positive number.");if(!Number.isFinite(n)||n<=0)throw new Error("createSamplingSimulation: lane_radius (or radius) must be a positive number.");if(!Number.isInteger(r)||r<1)throw new Error("createSamplingSimulation: complexity must be an integer >= 1.");if(!Number.isFinite(s)||s<0)throw new Error("createSamplingSimulation: flux must be a finite number >= 0.");if(!Number.isFinite(i)||i<=0)throw new Error("createSamplingSimulation: bin_size must be a positive number.");if(!Number.isInteger(d)||d<1)throw new Error("createSamplingSimulation: sub_bin_sampling must be an integer >= 1.");if(!Number.isFinite(l))throw new Error("createSamplingSimulation: thetaDrift must be finite.");if(!Number.isFinite(a)||a<0)throw new Error("createSamplingSimulation: thetaJitter must be a finite number >= 0.");if(!Number.isFinite(u)||u<0)throw new Error("createSamplingSimulation: phiJitter must be a finite number >= 0.");if(!Number.isFinite(h)||h<=0)throw new Error("createSamplingSimulation: laneLength/lane_length/distance must be a positive number.");if(p!=="shell"&&p!=="segment")throw new Error('createSamplingSimulation: hitTestModel must be "shell" or "segment".');if(g!=="orbit"&&g!=="randomSphere")throw new Error('createSamplingSimulation: observationMode must be "orbit" or "randomSphere".');return{D:o,lane_radius:n,complexity:r,flux:s,bin_size:i,sub_bin_sampling:d,theta:ht(t.theta??Math.PI/2),phi:Rt(t.phi??0),velocity:t.velocity??0,thetaDrift:l,thetaJitter:a,phiJitter:u,lane_length:h,hitTestModel:p,observationMode:g,allSectors:!!t.allSectors,cumulative:!!t.cumulative,usePoisson:t.usePoisson!==!1,seed:Number.isFinite(t.seed)?t.seed:1}}function Lt(t){const n=zn(t),o=wt(n),r=n.hitTestModel==="segment"?wt({...n,D:n.lane_length}):o,s=ct(n.seed),i=ct(n.seed+1),d=ct(n.seed+2),l=n.bin_size/n.sub_bin_sampling,a=It({flux:n.flux,D:n.D,lane_radius:n.lane_radius,dt:l,hitTestModel:n.hitTestModel,lane_length:n.lane_length});let u=0,h=0,p=n.phi,g=n.theta,y=0,I=0,S=0,L=0,F=0,_=0,v=0;function $(B,C){return n.usePoisson?Mn(B,C):B}function A(B=g,C=p){return Fn(n.D,B,C)}function D(){let B,C;if(n.observationMode==="randomSphere"){const R=Pn(d);B=R.theta,C=R.phi}else B=ht(g+(n.thetaJitter>0?n.thetaJitter*Mt(d):0)),C=Rt(p+(n.phiJitter>0?n.phiJitter*Mt(d):0));const te=A(B,C),j=n.hitTestModel==="segment"?Tn(r,te,n.lane_radius):En(o,n.D,te,n.lane_radius);_=j;const N=o.length,H=N>0?j*n.flux*l/N:0;return I+=$(H,s),S+=$(a,i),L+=H,v+=j,F++,{laneCount:j,satPos:te,lambdaLightlaneSubBin:H,phase:C,theta:B}}function W(){const B=F>0?F*l:n.bin_size,C=a*n.sub_bin_sampling,N={time:y,bin_size:B,lightlane:I,isotropic:S,lambdaIsotropic:F>0?a*F:C,overlaps:_,overlapsMean:F>0?v/F:0,subBins:F,phase:p,theta:g,lambdaLightlaneExpected:L};return I=0,S=0,L=0,v=0,F=0,N}return{config:{...n},getLaneCount(){return o.length},getState(){return{elapsed:y,phase:p,theta:g,timeInBin:u,timeInSubBin:h,accumulatedLightlane:I,accumulatedIsotropic:S,expectedLightlaneThisBin:L,processedSubBinsInCurrentBin:F,lastLaneCount:_,laneCount:o.length}},reset(){u=0,h=0,p=n.phi,g=n.theta,y=0,I=0,S=0,L=0,F=0,_=0,v=0},flushPartialBin(){if(F<=0)return null;const B=W();return u=0,h=0,B},simulate(B){if(!Number.isFinite(B)||B<=0)return{bins:[],lastLaneCount:_,subBinEvents:0,elapsed:y};let C=B,te=0;const j=[];for(;C>Ue;){const N=l-h,H=n.bin_size-u,R=Math.min(C,N,H);p+=n.velocity*R,g=ht(g+n.thetaDrift*R),y+=R,h+=R,u+=R,C-=R,h>=l-Ue&&(h=0,D(),te++),u>=n.bin_size-Ue&&(u=0,j.push(W()))}return{bins:j,lastLaneCount:_,subBinEvents:te,elapsed:y}}}}function Pt(t,n){const o=t.n+1,r=n-t.mean,s=t.mean+r/o,i=t.m2+r*(n-s);return{n:o,mean:s,m2:i}}function Ft(){return{n:0,mean:0,m2:0}}function In({complexity:t,samplesPerPoint:n,runsPerPoint:o,binSize:r,subBinSampling:s,props:i,observationMode:d,seed:l}){let a=Ft(),u=Ft(),h=0;for(let S=0;S<o;S++){const L=Lt({D:i.chandraDistance,theta:i.theta,phi:i.phi,observationMode:d,velocity:i.orbitSpeed,thetaDrift:i.thetaDrift,thetaJitter:i.thetaJitter,phiJitter:i.phiJitter,bin_size:r,complexity:t,sub_bin_sampling:s,flux:i.K,lane_radius:i.radius,distance:i.distance,hitTestModel:"segment",allSectors:i.allSectors,cumulative:i.cumulative,usePoisson:i.usePoisson,seed:l+S*7919});S===0&&(h=L.getLaneCount());for(let F=0;F<n;F++){const{bins:_}=L.simulate(r),v=_[0];v&&(a=Pt(a,v.lightlane),u=Pt(u,v.isotropic))}}const p=a.n>1?a.m2/(a.n-1):0,g=u.n>1?u.m2/(u.n-1):0,y=a.mean>0?p/a.mean:0,I=u.mean>0?g/u.mean:0;return{complexity:t,laneCount:h,meanBlue:a.mean,meanYellow:u.mean,fanoBlue:y,fanoYellow:I,fanoExcess:Math.max(0,y-I)}}function Ln(t,n=1){const o=t.filter(p=>p.complexity>=n&&p.complexity>1&&p.fanoExcess>1e-6);if(o.length<3)return null;let r=0,s=0,i=0,d=0;const l=o.length;for(const p of o){const g=Math.log(p.laneCount),y=Math.log(p.fanoExcess);r+=g,s+=y,i+=g*g,d+=g*y}const a=l*i-r*r;if(Math.abs(a)<1e-12)return null;const u=(l*d-r*s)/a,h=(s-u*r)/l;return{A:Math.exp(h),alpha:-u,predictFanoExcessFromLaneCount(p){return Math.exp(h+u*Math.log(Math.max(1,p)))}}}function $n(t,n=1){const o=t.filter(l=>l.complexity>=n&&l.complexity>1&&l.fanoExcess>1e-6);if(o.length<4)return null;const r=Math.min(...o.map(l=>l.fanoExcess)),s=Math.max(0,r*.98);let i=null;const d=80;for(let l=0;l<=d;l++){const a=l/d*s,u=o.map(A=>({x:A.laneCount,y:A.fanoExcess-a})).filter(A=>A.y>1e-9);if(u.length<3)continue;let h=0,p=0,g=0,y=0;const I=u.length;for(const A of u){const D=Math.log(A.x),W=Math.log(A.y);h+=D,p+=W,g+=D*D,y+=D*W}const S=I*g-h*h;if(Math.abs(S)<1e-12)continue;const L=(I*y-h*p)/S,F=(p-L*h)/I,_=Math.exp(F),v=-L;if(!(_>0)||!(v>0))continue;let $=0;for(const A of o){const D=a+_*Math.pow(Math.max(1,A.laneCount),-v),W=Math.log(Math.max(1e-9,A.fanoExcess))-Math.log(Math.max(1e-9,D));$+=W*W}(!i||$<i.score)&&(i={A:_,alpha:v,B:a,score:$})}return i?{A:i.A,alpha:i.alpha,B:i.B,score:i.score,predictFanoExcessFromLaneCount(l){return i.B+i.A*Math.pow(Math.max(1,l),-i.alpha)}}:null}function On(t){const n=t.filter(p=>p.x>0&&p.y>0);if(n.length<3)return null;let o=0,r=0,s=0,i=0;const d=n.length;for(const p of n){const g=Math.log(p.x),y=Math.log(p.y);o+=g,r+=y,s+=g*g,i+=g*y}const l=d*s-o*o;if(Math.abs(l)<1e-12)return null;const a=(d*i-o*r)/l,u=(r-a*o)/d,h=Math.exp(u);return{A:h,beta:a,predict(p){return h*Math.pow(Math.max(1e-9,p),a)},invert(p){return h<=0||Math.abs(a)<1e-12||p<=0?null:Math.pow(p/h,1/a)}}}function Dn(t,n){if(!Number.isFinite(n)||n<=0||t.length===0)return null;const o=[...t].sort((a,u)=>a.complexity-u.complexity),r=[...o].sort((a,u)=>a.laneCount-u.laneCount),s=r[0],i=r[r.length-1];if(n<=s.laneCount)return{complexity:s.complexity,mode:"observed-range"};for(let a=1;a<r.length;a++){const u=r[a-1],h=r[a];if(n<=h.laneCount){const p=Math.max(1e-9,h.laneCount-u.laneCount),g=(n-u.laneCount)/p;return{complexity:u.complexity+g*(h.complexity-u.complexity),mode:"observed-range"}}}const l=On(o.map(a=>({x:a.complexity,y:a.laneCount})))?.invert(n)??null;return l&&Number.isFinite(l)?{complexity:l,mode:"extrapolated"}:{complexity:i.complexity,mode:"observed-max"}}function Ct(t,n,o,r){return t.map((s,i)=>`${i===0?"M":"L"} ${o(s.complexity)} ${r(n(s))}`).join(" ")}function An(t){return t>=10?t.toFixed(0):t>=2?t.toFixed(1):t.toFixed(2)}function Wn(t,n){const r=[.5,.6,.7,.8,.9,1,1.1,1.2,1.4,1.6,1.8,2,2.5,3,4,5,7.5,10].filter(l=>l>=t&&l<=n);if(r.length>=3)return r;const s=5,i=Math.log(t),d=Math.log(n);return Array.from({length:s},(l,a)=>{const u=a/(s-1);return Math.exp(i+(d-i)*u)})}function _n(t){const[n,o]=c.useState(40),[r,s]=c.useState(1e3),[i,d]=c.useState(3),[l,a]=c.useState(1),[u,h]=c.useState(4),[p,g]=c.useState("randomSphere"),[y,I]=c.useState(.05),[S,L]=c.useState(10),[F,_]=c.useState(0),[v,$]=c.useState([]),[A,D]=c.useState(0),[W,B]=c.useState(!1),C=c.useRef(!1),te=c.useRef(-1),j=()=>{Ie(t.host,ke.hover,{page:"fano"})},N=(b,z)=>{Ie(t.host,ke.click,{page:"fano",target:b,...z})};c.useEffect(()=>{let b=!1;return $([]),D(0),B(!0),(async()=>{const z=[];for(let k=1;k<=n;k++){if(b)return;const w=In({complexity:k,samplesPerPoint:r,runsPerPoint:i,binSize:l,subBinSampling:u,props:t,observationMode:p,seed:1e4+k*97+F*100003});z.push(w),$([...z]),D(k/n),await new Promise(K=>setTimeout(K,0))}b||B(!1)})(),()=>{b=!0}},[n,r,i,l,u,p,F,t.radius,t.distance,t.chandraDistance,t.allSectors,t.cumulative,t.theta,t.phi,t.orbitSpeed,t.thetaDrift,t.thetaJitter,t.phiJitter,t.K,t.speedup,t.usePoisson]),c.useEffect(()=>{const b=C.current;if(C.current=W,W&&!b){te.current=-1,Ie(t.host,ke.computeStart,{page:"fano"});return}!W&&b&&(jn(t.host,ke.computeStep,{page:"fano"}),Ie(t.host,ke.computeDone,{page:"fano",points:v.length}))},[W,t.host,v.length]),c.useEffect(()=>{if(!W)return;const b=Math.floor(A*10);b<=te.current||(te.current=b,Ie(t.host,ke.computeStep,{page:"fano",progress:A}))},[A,W,t.host]);const H=c.useMemo(()=>Ln(v,S),[v,S]),R=c.useMemo(()=>$n(v,S),[v,S]),E=c.useMemo(()=>{if(!H||H.alpha<=0||y<=0)return null;if(R&&R.B>=y)return{targetExcess:y,requiredLaneCount:Number.POSITIVE_INFINITY,measuredCrossing:v.find(re=>re.fanoExcess<=y)??null,complexityEstimate:null,blockedByFloor:!0,floorExcess:R.B};const b=R?Math.max(1e-9,y-R.B):y,z=R?R.A:H.A,k=R?R.alpha:H.alpha,w=Math.pow(z/b,1/k);if(!Number.isFinite(w)||w<=0)return null;const K=v.find(re=>re.fanoExcess<=y)??null,V=Dn(v,w);return{targetExcess:y,requiredLaneCount:w,measuredCrossing:K,complexityEstimate:V,blockedByFloor:!1,floorExcess:R?.B??0}},[H,R,v,y]),x=c.useMemo(()=>{const k={top:20,right:20,bottom:42,left:48},w=860-k.left-k.right,K=360-k.top-k.bottom,V=Math.max(2,n),re=[1,...v.map(Y=>Y.fanoBlue),...v.map(Y=>Y.fanoYellow),...v.map(Y=>1+Y.fanoExcess)].filter(Y=>Number.isFinite(Y)&&Y>0),ge=Math.min(...re),he=Math.max(...re),q=Math.max(.001,Math.min(.95,ge*.95)),X=Math.max(1.05,he*1.05),O=Math.log(q),me=Math.log(X),ee=Y=>k.left+(Y-1)/(V-1)*w,fe=Y=>{const ae=Math.min(X,Math.max(q,Y)),ie=Math.log(ae);return k.top+K-(ie-O)/Math.max(1e-9,me-O)*K},ce=Wn(q,X);return{width:860,height:360,margin:k,innerW:w,innerH:K,xToPx:ee,yToPx:fe,yMax:X,yMin:q,yTicks:ce}},[v,n]),U=c.useMemo(()=>v.length>1?Ct(v,b=>b.fanoBlue,x.xToPx,x.yToPx):"",[v,x]),Se=c.useMemo(()=>v.length>1?Ct(v,b=>b.fanoYellow,x.xToPx,x.yToPx):"",[v,x]),G=v.at(-1)??null;return e.jsx(Ae,{fullscreen:!0,style:{pointerEvents:"auto"},children:e.jsxs("div",{style:{width:"100%",height:"100%",display:"flex",flexDirection:"column",background:"radial-gradient(circle at 20% 10%, rgba(30,41,59,0.9), rgba(2,6,23,0.96))",color:"var(--terminal-green-soft)",padding:"16px",paddingBottom:`${16+(t.bottomInset??0)}px`,boxSizing:"border-box",gap:"12px",fontFamily:"var(--font-ui)"},children:[e.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"center",gap:"12px",flexWrap:"wrap"},children:[e.jsxs("div",{children:[e.jsx("div",{style:{fontSize:"14px",fontWeight:400,letterSpacing:"0.12em",textTransform:"uppercase",fontFamily:"var(--font-headline)",color:"var(--terminal-green-soft)"},children:"Fano Sweep"}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--terminal-green)",marginTop:"4px"},children:["Goal: show ","Fano(Blue)"," trending toward 1.0 (or toward Yellow) as complexity increases."]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"},children:[t.onBack&&e.jsx("button",{type:"button",onClick:()=>{N("back-to-simulator"),t.onBack?.()},onPointerEnter:j,style:{border:"1px solid var(--terminal-panel-border)",background:"rgba(7,19,11,0.8)",color:"var(--terminal-green-soft)",padding:"8px 12px",borderRadius:"8px",cursor:"pointer",fontSize:"12px",fontWeight:400,fontFamily:"var(--font-headline)",letterSpacing:"0.08em",textTransform:"uppercase"},children:"Back To Simulator"}),e.jsx("button",{type:"button",onClick:()=>{N("rerun-sweep"),_(b=>b+1)},onPointerEnter:j,style:{border:"1px solid var(--terminal-panel-border)",background:W?"rgba(125, 255, 155, 0.14)":"rgba(7,19,11,0.8)",color:"var(--terminal-green-soft)",padding:"8px 12px",borderRadius:"8px",cursor:"pointer",fontSize:"12px",fontWeight:400,fontFamily:"var(--font-headline)",letterSpacing:"0.08em",textTransform:"uppercase"},children:W?"Rerun (queued)":"Rerun Sweep"})]})]}),e.jsxs("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap"},children:[e.jsx("button",{type:"button",onClick:()=>{N("preset-video-demo"),g("randomSphere"),o(60),s(1200),d(2),a(1),h(4),L(12)},onPointerEnter:j,style:{border:"1px solid var(--terminal-panel-border)",background:"rgba(7,19,11,0.8)",color:"var(--terminal-green-soft)",padding:"6px 10px",borderRadius:8,cursor:"pointer",fontSize:11,fontWeight:400,fontFamily:"var(--font-headline)",letterSpacing:"0.06em"},children:"Preset: Video Demo"}),e.jsx("button",{type:"button",onClick:()=>{N("preset-robust-sweep"),g("randomSphere"),o(200),s(3e3),d(5),a(1),h(16),L(40)},onPointerEnter:j,style:{border:"1px solid rgba(125, 255, 155, 0.32)",background:"rgba(2,6,23,0.8)",color:"var(--terminal-green-soft)",padding:"6px 10px",borderRadius:8,cursor:"pointer",fontSize:11,fontWeight:400,fontFamily:"var(--font-headline)",letterSpacing:"0.06em"},children:"Preset: Robust Sweep"})]}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(140px, 1fr))",gap:"8px"},children:[e.jsxs("label",{style:{fontSize:"11px",color:"var(--terminal-green-soft)",display:"flex",flexDirection:"column",gap:"4px"},children:["Max Complexity",e.jsx("input",{type:"number",min:2,max:200,value:n,onChange:b=>o(Math.max(2,Math.min(200,Number(b.target.value)||2))),onFocus:()=>j(),style:{background:"#07130b",color:"var(--terminal-green-soft)",border:"1px solid var(--terminal-panel-border)",borderRadius:"6px",padding:"6px 8px"}})]}),e.jsxs("label",{style:{fontSize:"11px",color:"var(--terminal-green-soft)",display:"flex",flexDirection:"column",gap:"4px"},children:["Samples / Point",e.jsx("input",{type:"number",min:100,max:2e4,step:100,value:r,onChange:b=>s(Math.max(100,Math.min(2e4,Number(b.target.value)||100))),onFocus:()=>j(),style:{background:"#07130b",color:"var(--terminal-green-soft)",border:"1px solid var(--terminal-panel-border)",borderRadius:"6px",padding:"6px 8px"}})]}),e.jsxs("label",{style:{fontSize:"11px",color:"var(--terminal-green-soft)",display:"flex",flexDirection:"column",gap:"4px"},children:["Runs / Point (Seeds)",e.jsx("input",{type:"number",min:1,max:20,step:1,value:i,onChange:b=>d(Math.max(1,Math.min(20,Number(b.target.value)||1))),onFocus:()=>j(),style:{background:"#07130b",color:"var(--terminal-green-soft)",border:"1px solid var(--terminal-panel-border)",borderRadius:"6px",padding:"6px 8px"}})]}),e.jsxs("label",{style:{fontSize:"11px",color:"var(--terminal-green-soft)",display:"flex",flexDirection:"column",gap:"4px"},children:["Bin Size (s)",e.jsx("input",{type:"number",min:.1,max:20,step:.1,value:l,onChange:b=>a(Math.max(.1,Math.min(20,Number(b.target.value)||.1))),onFocus:()=>j(),style:{background:"#07130b",color:"var(--terminal-green-soft)",border:"1px solid var(--terminal-panel-border)",borderRadius:"6px",padding:"6px 8px"}})]}),e.jsxs("label",{style:{fontSize:"11px",color:"var(--terminal-green-soft)",display:"flex",flexDirection:"column",gap:"4px"},children:["Sub-Bin Sampling",e.jsx("input",{type:"number",min:1,max:256,step:1,value:u,onChange:b=>h(Math.max(1,Math.min(256,Math.round(Number(b.target.value)||1)))),onFocus:()=>j(),style:{background:"#07130b",color:"var(--terminal-green-soft)",border:"1px solid var(--terminal-panel-border)",borderRadius:"6px",padding:"6px 8px"}})]}),e.jsxs("label",{style:{fontSize:"11px",color:"var(--terminal-green-soft)",display:"flex",flexDirection:"column",gap:"4px"},children:["Observation Mode",e.jsxs("select",{value:p,onChange:b=>g(b.target.value),onFocus:()=>j(),style:{background:"#07130b",color:"var(--terminal-green-soft)",border:"1px solid var(--terminal-panel-border)",borderRadius:"6px",padding:"6px 8px"},children:[e.jsx("option",{value:"randomSphere",children:"Random Sphere (recommended)"}),e.jsx("option",{value:"orbit",children:"Orbit (path-biased)"})]})]}),e.jsxs("label",{style:{fontSize:"11px",color:"var(--terminal-green-soft)",display:"flex",flexDirection:"column",gap:"4px"},children:["Target Excess (B-Y)",e.jsx("input",{type:"number",min:.001,max:1,step:.005,value:y,onChange:b=>I(Math.max(.001,Math.min(1,Number(b.target.value)||.05))),onFocus:()=>j(),style:{background:"#07130b",color:"var(--terminal-green-soft)",border:"1px solid var(--terminal-panel-border)",borderRadius:"6px",padding:"6px 8px"}})]}),e.jsxs("label",{style:{fontSize:"11px",color:"var(--terminal-green-soft)",display:"flex",flexDirection:"column",gap:"4px"},children:["Fit Start Complexity",e.jsx("input",{type:"number",min:1,max:n,step:1,value:S,onChange:b=>L(Math.max(1,Math.min(n,Number(b.target.value)||1))),onFocus:()=>j(),style:{background:"#07130b",color:"var(--terminal-green-soft)",border:"1px solid var(--terminal-panel-border)",borderRadius:"6px",padding:"6px 8px"}})]}),e.jsxs("div",{style:{fontSize:"11px",color:"var(--terminal-green-soft)",display:"flex",flexDirection:"column",gap:"6px"},children:["Progress",e.jsx("div",{style:{background:"rgba(7,19,11,0.9)",border:"1px solid var(--terminal-panel-border)",borderRadius:"999px",padding:"3px"},children:e.jsx("div",{style:{height:"8px",width:`${Math.round(A*100)}%`,background:"linear-gradient(90deg, var(--terminal-green-dim), var(--terminal-green-soft))",borderRadius:"999px",transition:"width 0.15s ease"}})}),e.jsx("div",{style:{color:"var(--terminal-green)"},children:W?`Running ${Math.round(A*100)}%`:"Complete"})]})]}),e.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"12px",minHeight:0,flex:1},children:[e.jsx("div",{style:{background:"rgba(7,19,11,0.72)",border:"1px solid var(--terminal-panel-border)",borderRadius:"10px",padding:"10px",width:"100%",minWidth:0,minHeight:"min(58vh, 520px)"},children:e.jsxs("svg",{viewBox:`0 0 ${x.width} ${x.height}`,style:{width:"100%",height:"100%"},children:[e.jsx("rect",{x:0,y:0,width:x.width,height:x.height,fill:"transparent"}),x.yTicks.map((b,z)=>{const k=x.yToPx(b);return e.jsxs("g",{children:[e.jsx("line",{x1:x.margin.left,y1:k,x2:x.margin.left+x.innerW,y2:k,stroke:"rgba(125, 255, 155, 0.12)"}),e.jsx("text",{x:8,y:k+4,fill:"var(--terminal-green)",fontSize:"10",fontFamily:"var(--font-ui)",children:An(b)})]},`ygrid-${z}`)}),e.jsx("line",{x1:x.margin.left,y1:x.yToPx(1),x2:x.margin.left+x.innerW,y2:x.yToPx(1),stroke:"#f97316",strokeDasharray:"4 4",opacity:.8}),e.jsx("text",{x:x.margin.left+6,y:x.yToPx(1)-6,fill:"#fdba74",fontSize:"10",children:"Fano = 1"}),e.jsx("line",{x1:x.margin.left,y1:x.margin.top+x.innerH,x2:x.margin.left+x.innerW,y2:x.margin.top+x.innerH,stroke:"rgba(125, 255, 155, 0.3)"}),e.jsx("line",{x1:x.margin.left,y1:x.margin.top,x2:x.margin.left,y2:x.margin.top+x.innerH,stroke:"rgba(125, 255, 155, 0.3)"}),Array.from({length:Math.min(n,10)},(b,z)=>{const k=1+(n-1)*z/Math.max(1,Math.min(n-1,9)),w=x.xToPx(k);return e.jsxs("g",{children:[e.jsx("line",{x1:w,y1:x.margin.top+x.innerH,x2:w,y2:x.margin.top+x.innerH+4,stroke:"rgba(125, 255, 155, 0.3)"}),e.jsx("text",{x:w,y:x.margin.top+x.innerH+18,fill:"var(--terminal-green)",fontSize:"10",fontFamily:"var(--font-ui)",textAnchor:"middle",children:Math.round(k)})]},`xtick-${z}`)}),Se&&e.jsx("path",{d:Se,fill:"none",stroke:"#fbbf24",strokeWidth:"2",opacity:.95}),U&&e.jsx("path",{d:U,fill:"none",stroke:"#60a5fa",strokeWidth:"2.25",opacity:.95}),H&&v.length>2&&(()=>{const b=v.filter(z=>z.complexity>=S).map((z,k)=>{const w=1+H.predictFanoExcessFromLaneCount(z.laneCount);return`${k===0?"M":"L"} ${x.xToPx(z.complexity)} ${x.yToPx(w)}`}).join(" ");return e.jsx("path",{d:b,fill:"none",stroke:"#93c5fd",strokeDasharray:"5 4",strokeWidth:"1.5",opacity:.8})})(),R&&v.length>2&&(()=>{const b=v.filter(z=>z.complexity>=S).map((z,k)=>{const w=1+R.predictFanoExcessFromLaneCount(z.laneCount);return`${k===0?"M":"L"} ${x.xToPx(z.complexity)} ${x.yToPx(w)}`}).join(" ");return e.jsx("path",{d:b,fill:"none",stroke:"#22d3ee",strokeDasharray:"2 4",strokeWidth:"1.5",opacity:.7})})(),v.map(b=>e.jsxs("g",{children:[e.jsx("circle",{cx:x.xToPx(b.complexity),cy:x.yToPx(b.fanoYellow),r:"2.2",fill:"#fbbf24"}),e.jsx("circle",{cx:x.xToPx(b.complexity),cy:x.yToPx(b.fanoBlue),r:"2.5",fill:"#60a5fa"})]},`dot-${b.complexity}`)),e.jsx("text",{x:x.margin.left+x.innerW/2,y:x.height-8,fill:"var(--terminal-green)",fontSize:"11",fontFamily:"var(--font-ui)",textAnchor:"middle",children:"Complexity"}),e.jsx("text",{x:14,y:x.margin.top+x.innerH/2,fill:"var(--terminal-green)",fontSize:"11",fontFamily:"var(--font-ui)",textAnchor:"middle",transform:`rotate(-90 14 ${x.margin.top+x.innerH/2})`,children:"Fano Factor (Var / Mean, log scale)"})]})}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fit, minmax(220px, 1fr))",gap:"8px",alignItems:"start"},children:[e.jsxs("div",{style:{background:"rgba(7,19,11,0.72)",border:"1px solid var(--terminal-panel-border)",borderRadius:"10px",padding:"10px",fontSize:"11px"},children:[e.jsx("div",{style:{fontWeight:400,marginBottom:"6px",color:"var(--terminal-green-soft)",fontFamily:"var(--font-headline)",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Legend"}),e.jsx("div",{style:{color:"#60a5fa"},children:"Blue: Lightlane Fano"}),e.jsx("div",{style:{color:"#fbbf24"},children:"Yellow: Isotropic Fano"}),e.jsx("div",{style:{color:"#fdba74",marginTop:"4px"},children:"Dashed orange: Fano = 1"}),e.jsx("div",{style:{color:"#93c5fd",marginTop:"4px"},children:"Dashed blue: power-fit extrapolation (blue excess over yellow)"}),e.jsx("div",{style:{color:"#22d3ee",marginTop:"4px"},children:"Dashed cyan: floor-aware fit (B + A×N^-α)"})]}),e.jsxs("div",{style:{background:"rgba(7,19,11,0.72)",border:"1px solid var(--terminal-panel-border)",borderRadius:"10px",padding:"10px",fontSize:"11px"},children:[e.jsx("div",{style:{fontWeight:400,marginBottom:"6px",color:"var(--terminal-green-soft)",fontFamily:"var(--font-headline)",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Latest Point"}),G?e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Complexity: ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:G.complexity})]}),e.jsxs("div",{children:["Lanes: ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:G.laneCount})]}),e.jsxs("div",{children:["Mean Ratio (B/Y): ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:(G.meanBlue/Math.max(1e-9,G.meanYellow)).toFixed(3)})]}),e.jsxs("div",{children:["Fano Blue: ",e.jsx("span",{style:{fontFamily:"monospace",color:"#93c5fd"},children:G.fanoBlue.toFixed(3)})]}),e.jsxs("div",{children:["Fano Yellow: ",e.jsx("span",{style:{fontFamily:"monospace",color:"#fef3c7"},children:G.fanoYellow.toFixed(3)})]}),e.jsxs("div",{children:["Excess (B-Y): ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:G.fanoExcess.toFixed(3)})]}),e.jsxs("div",{style:{color:"var(--terminal-green)",marginTop:"6px"},children:["Aggregated over ",r.toLocaleString()," bins × ",i," seeds"]})]}):e.jsx("div",{style:{color:"var(--terminal-green)"},children:"No points yet."})]}),e.jsxs("div",{style:{background:"rgba(7,19,11,0.72)",border:"1px solid var(--terminal-panel-border)",borderRadius:"10px",padding:"10px",fontSize:"11px"},children:[e.jsx("div",{style:{fontWeight:400,marginBottom:"6px",color:"var(--terminal-green-soft)",fontFamily:"var(--font-headline)",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Power Fit"}),H?e.jsxs(e.Fragment,{children:[e.jsxs("div",{style:{color:"var(--terminal-green-soft)"},children:["Excess ≈ ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:H.A.toExponential(2)})," × N",e.jsxs("sup",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:["-",H.alpha.toFixed(2)]})]}),e.jsxs("div",{style:{color:"var(--terminal-green)",marginTop:"6px"},children:["Fit is on blue excess over yellow using lane count N, starting at complexity ",S,"."]})]}):e.jsx("div",{style:{color:"var(--terminal-green)"},children:"Need more points with nonzero excess."}),R&&e.jsxs("div",{style:{color:"var(--terminal-green)",marginTop:"6px"},children:["Floor fit: excess ≈ ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:R.B.toFixed(3)})," + ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:R.A.toExponential(2)})," × N",e.jsxs("sup",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:["-",R.alpha.toFixed(2)]})]})]}),e.jsxs("div",{style:{background:"rgba(7,19,11,0.72)",border:"1px solid var(--terminal-panel-border)",borderRadius:"10px",padding:"10px",fontSize:"11px"},children:[e.jsx("div",{style:{fontWeight:400,marginBottom:"6px",color:"var(--terminal-green-soft)",fontFamily:"var(--font-headline)",letterSpacing:"0.06em",textTransform:"uppercase"},children:"Indistinguishable Target"}),e.jsxs("div",{style:{color:"var(--terminal-green)",marginBottom:"6px"},children:["Criterion: ",e.jsxs("span",{style:{color:"var(--terminal-green-soft)"},children:["Fano Blue - Fano Yellow ≤ ",y.toFixed(3)]})]}),E?e.jsxs(e.Fragment,{children:[E.blockedByFloor?e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{color:"#ff8f8f"},children:"Floor-aware fit predicts no finite crossing for this threshold."}),e.jsxs("div",{children:["Fitted excess floor:"," ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:E.floorExcess.toFixed(3)})]}),e.jsx("div",{style:{color:"var(--terminal-green)",marginTop:"6px"},children:"Increase `Max Complexity` / `Samples`, or raise fit start to test whether the floor is a transient or a genuine plateau."})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:["Required lane count N (fit):"," ",e.jsx("span",{style:{fontFamily:"monospace",color:"var(--terminal-green-soft)"},children:Math.round(E.requiredLaneCount).toLocaleString()})]}),e.jsxs("div",{children:["Estimated complexity:"," ",e.jsx("span",{style:{fontFamily:"monospace",color:"#93c5fd"},children:E.complexityEstimate?Math.ceil(E.complexityEstimate.complexity).toLocaleString():"n/a"}),E.complexityEstimate&&e.jsxs("span",{style:{color:"var(--terminal-green)"},children:[" ","(",E.complexityEstimate.mode==="observed-range"?"interpolated from current sweep":E.complexityEstimate.mode==="extrapolated"?"extrapolated":"bounded by current sweep",")"]})]})]}),e.jsx("div",{style:{marginTop:"6px",color:"var(--terminal-green)"},children:E.measuredCrossing?`Observed crossing already reached at complexity ${E.measuredCrossing.complexity}.`:"No observed crossing yet in current sweep; estimate uses fit."})]}):e.jsx("div",{style:{color:"var(--terminal-green)"},children:"Need a stable excess fit (nonzero blue excess across multiple points)."})]}),e.jsxs("div",{style:{background:"rgba(7,19,11,0.72)",border:"1px solid var(--terminal-panel-border)",borderRadius:"10px",padding:"10px",fontSize:"11px",color:"var(--terminal-green)"},children:["Use ",e.jsx("span",{style:{color:"var(--terminal-green-soft)"},children:"Random Sphere"})," to isolate discretization convergence from path bias. Orbit mode is still useful to show persistent anisotropy on specific trajectories.",e.jsxs("div",{style:{marginTop:"6px"},children:["For a stronger/cleaner claim in the video: report the threshold estimate together with ",e.jsx("span",{style:{color:"var(--terminal-green-soft)"},children:"bin size"}),", ",e.jsx("span",{style:{color:"var(--terminal-green-soft)"},children:"sub-bin sampling"}),", and ",e.jsx("span",{style:{color:"var(--terminal-green-soft)"},children:"runs/point"}),"."]}),e.jsx("div",{style:{marginTop:"6px"},children:"If the floor-aware fit stays above zero as you increase complexity and samples, frame it as an open question for viewers."})]})]})]})]})})}const Ye=new ut("#dbeafe");function Nn(t,n){const o=new Float32Array(n*3),r=new Float32Array(n*3),s=[],i=t+.01;for(let d=0;d<n;d+=1){const l=Math.random(),a=Math.random(),u=2*Math.PI*l,h=1-2*a,p=Math.sqrt(Math.max(0,1-h*h)),g=d*3;o[g]=i*p*Math.cos(u),o[g+1]=i*p*Math.sin(u),o[g+2]=i*h,r[g]=Ye.r*.15,r[g+1]=Ye.g*.15,r[g+2]=Ye.b*.15,s.push({speed:.8+Math.random()*2.6,phase:Math.random()*Math.PI*2,minBrightness:.03+Math.random()*.06,maxBoost:.35+Math.random()*.85})}return{positions:o,colors:r,sparklePoints:s}}function Hn({radius:t}){const n=c.useRef(null),o=16e3,{positions:r,colors:s,sparklePoints:i}=c.useMemo(()=>Nn(t,o),[t]);return We(({clock:d})=>{const l=n.current;if(!l)return;const a=l.geometry.getAttribute("color");if(!a)return;const u=d.getElapsedTime(),h=a.array;for(let p=0;p<i.length;p+=1){const g=i[p],y=Math.pow(Math.max(0,Math.sin(u*g.speed+g.phase)),24),I=g.minBrightness+y*g.maxBoost,S=p*3;h[S]=Ye.r*I,h[S+1]=Ye.g*I,h[S+2]=Ye.b*I}a.needsUpdate=!0}),e.jsxs("group",{children:[e.jsxs("mesh",{children:[e.jsx("sphereGeometry",{args:[t,64,64]}),e.jsx("meshStandardMaterial",{color:"#60a5fa",emissive:"#1d4ed8",emissiveIntensity:.18,transparent:!0,opacity:.08,roughness:.15,metalness:.05})]}),e.jsxs("mesh",{renderOrder:2,children:[e.jsx("sphereGeometry",{args:[t,48,48]}),e.jsx("meshBasicMaterial",{color:"#93c5fd",wireframe:!0,transparent:!0,opacity:.14,toneMapped:!1})]}),e.jsxs("points",{ref:n,renderOrder:3,children:[e.jsxs("bufferGeometry",{children:[e.jsx("bufferAttribute",{attach:"attributes-position",args:[r,3]}),e.jsx("bufferAttribute",{attach:"attributes-color",args:[s,3]})]}),e.jsx("pointsMaterial",{size:Math.max(.06,t*.018),sizeAttenuation:!0,transparent:!0,opacity:.95,vertexColors:!0,depthWrite:!1,toneMapped:!1})]})]})}function Vn({radius:t,paused:n=!1}){const o=c.useRef(null);return We(r=>{if(!n&&o.current){const s=r.clock.elapsedTime*3,i=.5+(Math.sin(s)+1)/2*1.5;o.current.emissiveIntensity=i}}),e.jsxs("mesh",{position:[0,0,0],children:[e.jsx("sphereGeometry",{args:[t,64,64]}),e.jsx("meshStandardMaterial",{ref:o,color:"#ec4899",emissive:"#db2777",emissiveIntensity:1,toneMapped:!1})]})}function Gn(t){const n=2*Math.PI;let o=t%n;return o<0&&(o+=n),o>Math.PI&&(o=n-o),o}function Un({radius:t,theta:n,phi:o,orbitTime:r,simTime:s,thetaDrift:i=0,paused:d=!1}){const l=c.useRef(null);return We(()=>{if(!d&&l.current){const a=o+r.current,u=Gn(n+(s?.current??0)*i),h=t*Math.sin(u)*Math.cos(a),p=t*Math.cos(u),g=t*Math.sin(u)*Math.sin(a);l.current.position.set(h,p,g),l.current.lookAt(0,0,0)}}),e.jsxs("group",{ref:l,children:[e.jsxs("mesh",{renderOrder:10,children:[e.jsx("sphereGeometry",{args:[.09,16,16]}),e.jsx("meshBasicMaterial",{color:"#22d3ee",toneMapped:!1})]}),e.jsxs("mesh",{renderOrder:9,children:[e.jsx("sphereGeometry",{args:[.16,16,16]}),e.jsx("meshBasicMaterial",{color:"#22d3ee",transparent:!0,opacity:.18,toneMapped:!1})]}),e.jsxs("mesh",{rotation:[Math.PI/2,0,0],children:[e.jsx("cylinderGeometry",{args:[.14,.18,1,16]}),e.jsx("meshStandardMaterial",{color:"#c0c0c0",metalness:.8,roughness:.2})]}),e.jsxs("mesh",{position:[0,0,.3],rotation:[Math.PI/2,0,0],children:[e.jsx("cylinderGeometry",{args:[.18,.18,.16,8]}),e.jsx("meshStandardMaterial",{color:"#d4af37",metalness:.95,roughness:.18})]}),e.jsxs("mesh",{position:[0,0,.6],rotation:[Math.PI/2,0,0],children:[e.jsx("cylinderGeometry",{args:[.22,.22,.2,16]}),e.jsx("meshStandardMaterial",{color:"#ffd700",metalness:1,roughness:.1})]}),e.jsxs("mesh",{position:[0,0,.7],renderOrder:11,children:[e.jsx("sphereGeometry",{args:[.05,12,12]}),e.jsx("meshBasicMaterial",{color:"#f97316",toneMapped:!1})]}),e.jsxs("mesh",{position:[0,0,.35],rotation:[Math.PI/2,0,0],renderOrder:8,children:[e.jsx("cylinderGeometry",{args:[.015,.015,.7,8]}),e.jsx("meshBasicMaterial",{color:"#f97316",transparent:!0,opacity:.7,toneMapped:!1})]}),e.jsxs("group",{position:[0,0,.22],children:[e.jsxs("mesh",{position:[.6,0,0],children:[e.jsx("boxGeometry",{args:[.8,.4,.05]}),e.jsx("meshStandardMaterial",{color:"#1e3a8a",metalness:.5,roughness:.1})]}),e.jsxs("mesh",{position:[-.6,0,0],children:[e.jsx("boxGeometry",{args:[.8,.4,.05]}),e.jsx("meshStandardMaterial",{color:"#1e3a8a",metalness:.5,roughness:.1})]}),e.jsxs("mesh",{position:[.28,0,-.01],children:[e.jsx("boxGeometry",{args:[.18,.05,.04]}),e.jsx("meshStandardMaterial",{color:"#94a3b8",metalness:.7,roughness:.22})]}),e.jsxs("mesh",{position:[-.28,0,-.01],children:[e.jsx("boxGeometry",{args:[.18,.05,.04]}),e.jsx("meshStandardMaterial",{color:"#94a3b8",metalness:.7,roughness:.22})]})]})]})}const xe={solid:"#60a5fa",dark:"#3b82f6",light:"#93c5fd",glow:"rgba(96,165,250,0.5)",panel:"rgba(0,20,40,0.8)"},pe={solid:"#fbbf24",dark:"#f59e0b",light:"#fef3c7",glow:"rgba(251,191,36,0.5)"},tt="var(--font-headline)",ye="var(--font-ui)",Yn="var(--terminal-green)",De="var(--terminal-green-soft)",Fe="var(--terminal-green-muted)";function Jn({bars:t}){const n=window.innerHeight;return e.jsxs(e.Fragment,{children:[t.map(o=>{const r=n-o.startBottom-o.barHeight,s=o.targetLeft-o.startLeft,i=o.targetTop-r;return e.jsx("div",{style:{position:"absolute",left:`${o.startLeft}px`,top:`${r}px`,width:`${o.barWidth}px`,height:`${o.barHeight}px`,background:o.color,borderRadius:"2px 2px 0 0",opacity:.95,animation:"flyToDistribution 1.2s ease-in-out forwards","--delta-x":`${s}px`,"--delta-y":`${i}px`,zIndex:1e3,boxShadow:`0 0 15px ${o.color}`}},o.id)}),e.jsx("style",{children:`
@keyframes flyToDistribution {
0% {
transform: translate(0, 0) scale(1);
opacity: 0.95;
}
40% {
transform: translate(calc(var(--delta-x) * 0.3), calc(var(--delta-y) * 0.5)) scale(0.9);
opacity: 0.9;
}
85% {
transform: translate(calc(var(--delta-x) * 0.95), calc(var(--delta-y) * 0.95)) scale(0.7);
opacity: 0.85;
}
100% {
transform: translate(var(--delta-x), var(--delta-y)) scale(0.6);
opacity: 0;
}
}
.clickable-bar {
transition: all 0.2s ease;
}
.clickable-bar:hover {
transform: scaleY(1.1) scaleX(1.2);
filter: brightness(1.3);
box-shadow: 0 0 10px currentColor;
}
`})]})}function nt(){return{n:0,meanObs:0,m2Obs:0,meanIso:0,m2Iso:0}}function qn(t,n,o){const r=t.n+1,s=n-t.meanObs,i=t.meanObs+s/r,d=t.m2Obs+s*(n-i),l=o-t.meanIso,a=t.meanIso+l/r,u=t.m2Iso+l*(o-a);return{n:r,meanObs:i,m2Obs:d,meanIso:a,m2Iso:u}}function Xn({complexity:t,radius:n,distance:o,theta:r,phi:s,observationMode:i,allSectors:d,cumulative:l,K:a,orbitRadius:u,orbitVelocity:h,thetaDrift:p,thetaJitter:g,phiJitter:y,usePoisson:I,speedup:S,paused:L,sceneView:F,bottomInset:_=0,showNumericDiagnostics:v=!0,compactNumericDiagnostics:$=!1,host:A,centerDistribution:D=!1,hideFlyingBars:W=!1}){const[B,C]=c.useState({current:0,total:0,lastCheck:0,overlaps:0,currentTheory:0,binOverlapsMean:0,currentExpectedLightlane:0}),te=4,j=c.useMemo(()=>Lt({D:u,theta:r,phi:s,observationMode:i,velocity:h,thetaDrift:p,thetaJitter:g,phiJitter:y,distance:o,hitTestModel:"segment",bin_size:1,complexity:t,sub_bin_sampling:te,flux:a,lane_radius:n,allSectors:d,cumulative:l,usePoisson:I}),[u,r,s,i,h,p,g,y,t,a,n,o,d,l,I]),N=60,H=c.useRef(new Array(N).fill(-1)),R=c.useRef(new Array(N).fill(-1)),E=c.useRef(0),[x,U]=c.useState(new Array(N).fill(-1)),[Se,G]=c.useState(new Array(N).fill(-1)),b=It({flux:a,D:u,lane_radius:n,dt:1,hitTestModel:"segment",lane_length:o}),z=Math.sqrt(b),k=15,w=4*z,K=Math.max(0,b-w),V=b+w,re=I,ge=Math.max(0,Math.floor(K)),he=Math.max(ge,Math.ceil(V)),q=re?he-ge+1:k,X=re?1:Math.max(1e-9,(V-K)/k),O=m=>{if(re){const M=Math.round(m);return M<=ge?0:M>=he?q-1:M-ge}return m<K?0:m>=V?q-1:Math.floor((m-K)/X)},me=m=>re?ge+m:K+(m+.5)*X,[ee,fe]=c.useState(new Array(q).fill(0)),[ce,Y]=c.useState(new Array(q).fill(0)),[ae,ie]=c.useState(new Set),[Be,Ce]=c.useState(new Set),[Le,Te]=c.useState([]),Re=c.useRef(0),$e=c.useRef(nt()),[J,_e]=c.useState(nt()),be=c.useRef(L),Ze=c.useRef(0);c.useEffect(()=>{fe(new Array(q).fill(0)),Y(new Array(q).fill(0)),H.current.fill(-1),R.current.fill(-1),E.current=0,U(new Array(N).fill(-1)),G(new Array(N).fill(-1)),ie(new Set),Ce(new Set),Te([]),$e.current=nt(),_e(nt()),C({current:0,total:0,lastCheck:0,overlaps:0,currentTheory:0,binOverlapsMean:0,currentExpectedLightlane:0})},[t,a,n,o,u,r,s,i,h,p,g,y,d,l,I,q]);const Qe=(m,M)=>{if(m.length===0)return;let T=0,le=0,se=0,je=B.binOverlapsMean,Q=B.currentExpectedLightlane,de=$e.current;for(const ue of m){const Me=ue.lightlane,we=ue.isotropic;if(T+=Me,le=Me,se=we,je=ue.overlapsMean,Q=ue.lambdaLightlaneExpected,de=qn(de,Me,we),H.current[E.current]=Me,R.current[E.current]=we,E.current++,E.current>=N){const Ee=Math.max(10,...H.current.filter(oe=>oe>=0),...R.current.filter(oe=>oe>=0));ne([...H.current],[...R.current],Ee),H.current.fill(-1),R.current.fill(-1),E.current=0,ie(new Set),Ce(new Set)}}$e.current=de,C(ue=>({current:le,total:ue.total+T,lastCheck:Date.now(),overlaps:M,currentTheory:se,binOverlapsMean:je,currentExpectedLightlane:Q})),_e(de),U([...H.current]),G([...R.current])},Ne=c.useRef(!1),He=c.useRef(null),Ke=(m,M)=>{m.stopPropagation(),Ne.current=!0,He.current=M,m.target.setPointerCapture(m.pointerId),Ie(A,ke.click,{target:`${M}-periodogram`,action:"pointer-down"})},et=(m,M,T,le)=>{if(!Ne.current||He.current!==M)return;m.stopPropagation();const se=m.currentTarget.getBoundingClientRect(),je=m.clientX-se.left,Q=Math.floor(je/se.width*N);if(Q>=0&&Q<N){const de=T[Q],ue=M==="observed"?ae.has(Q):Be.has(Q);de>=0&&!ue&&Z(Q,de,M,le)}},f=m=>{m.stopPropagation(),Ne.current=!1,He.current=null},P=(m,M,T,le)=>{const se=window.innerWidth,je=m/N*se,Q=se/N,de=Math.max(2,M/le*80),we=T==="observed"?25:110,Ee=O(M),oe=20,Pe=se-2*oe,ze=oe+(Ee+.5)/q*Pe;return{startLeft:je,startBottom:we,barHeight:de,barWidth:Q,targetLeft:ze,targetTop:150,binIndex:Ee}},Z=(m,M,T,le)=>{if(M<0)return;const se=Date.now();se-Ze.current>=45&&(Ze.current=se,Ie(A,ke.computeStep,{target:`${T}-periodogram`,value:M}));const{startLeft:je,startBottom:Q,barHeight:de,barWidth:ue,targetLeft:Me,targetTop:we}=P(m,M,T,le),Ee={id:Re.current++,value:M,startLeft:je,startBottom:Q,barHeight:de,barWidth:ue,targetLeft:Me,targetTop:we,color:T==="observed"?pe.solid:xe.solid,type:T};Te(oe=>[...oe,Ee]),T==="observed"?(ie(oe=>new Set(oe).add(m)),fe(oe=>{const Pe=[...oe],ze=O(M);return Pe[ze]++,Pe})):(Ce(oe=>new Set(oe).add(m)),Y(oe=>{const Pe=[...oe],ze=O(M);return Pe[ze]++,Pe}))},ne=(m,M,T)=>{const le=[],se=[...ee],je=[...ce];m.forEach((Q,de)=>{if(Q>=0){const{startLeft:ue,startBottom:Me,barHeight:we,barWidth:Ee,targetLeft:oe,targetTop:Pe,binIndex:ze}=P(de,Q,"observed",T);le.push({id:Re.current++,value:Q,startLeft:ue,startBottom:Me,barHeight:we,barWidth:Ee,targetLeft:oe,targetTop:Pe,color:pe.solid,type:"observed"}),se[ze]++}}),M.forEach((Q,de)=>{if(Q>=0){const{startLeft:ue,startBottom:Me,barHeight:we,barWidth:Ee,targetLeft:oe,targetTop:Pe,binIndex:ze}=P(de,Q,"theory",T);le.push({id:Re.current++,value:Q,startLeft:ue,startBottom:Me,barHeight:we,barWidth:Ee,targetLeft:oe,targetTop:Pe,color:xe.solid,type:"theory"}),je[ze]++}}),Te(Q=>[...Q,...le]),fe(se),Y(je)};c.useEffect(()=>{if(Le.length>0){const m=setTimeout(()=>{Te([])},1300);return()=>clearTimeout(m)}},[Le.length]);const Ve=c.useRef(0);c.useEffect(()=>{E.current<Ve.current&&(ie(new Set),Ce(new Set)),Ve.current=E.current}),c.useEffect(()=>{const m=be.current;if(be.current=L,!L||m)return;const M=j.flushPartialBin();M&&Qe([M],M.overlaps)},[L,j]),We((m,M)=>{if(L)return;const T=j.simulate(M*S);T.subBinEvents>0&&C(le=>({...le,overlaps:T.lastLaneCount})),Qe(T.bins,T.lastLaneCount)});const $t=x.filter(m=>m>=0),Ot=Se.filter(m=>m>=0),rt=Math.max(10,Math.max(0,...$t)),it=Math.max(10,Math.max(0,...Ot)),xt=Math.max(1,...ee,...ce),mt=J.n>1?J.m2Obs/(J.n-1):0,st=J.n>1?J.m2Iso/(J.n-1):0,Dt=J.meanIso>0?J.meanObs/J.meanIso:0,gt=st>0?mt/st:0,at=J.meanObs>0?mt/J.meanObs:0,Je=J.meanIso>0?st/J.meanIso:0,lt=j.getLaneCount(),bt=lt>0&&a>0?lt*b/a:0,yt=v&&!$,qe=F!=="lightlane",Oe=F!=="poisson",At=Le.filter(m=>m.type==="theory"&&qe||m.type==="observed"&&Oe),Wt=F==="poisson"?"Shot Noise Distribution":F==="lightlane"?"Shot Noise + Lightlane":"Head to Head",Ge={background:"rgba(255,255,255,0.04)",border:"1px solid var(--terminal-panel-border)",borderRadius:"6px",padding:"6px 8px",fontFamily:ye},vt=e.jsxs("div",{style:{marginTop:$?"0":"12px",display:"grid",gridTemplateColumns:$?"1fr":"repeat(3, minmax(0, 1fr))",gap:$?"6px":"8px",fontSize:"10px",color:De,fontFamily:ye},children:[e.jsxs("div",{style:Ge,children:[e.jsx("div",{style:{color:Fe},children:"Samples"}),e.jsx("div",{style:{fontFamily:"monospace"},children:J.n})]}),e.jsxs("div",{style:Ge,children:[e.jsx("div",{style:{color:Fe},children:"Mean Ratio (Lightlane/Poisson)"}),e.jsx("div",{style:{fontFamily:"monospace",color:De},children:J.n>0?Dt.toFixed(3):"n/a"})]}),e.jsxs("div",{style:Ge,children:[e.jsx("div",{style:{color:Fe},children:"Var Ratio (Lightlane/Poisson)"}),e.jsx("div",{style:{fontFamily:"monospace",color:gt>1.1?pe.light:xe.light},children:J.n>1?gt.toFixed(3):"n/a"})]}),e.jsxs("div",{style:Ge,children:[e.jsx("div",{style:{color:Fe},children:"Fano Lightlane"}),e.jsx("div",{style:{fontFamily:"monospace",color:pe.light},children:J.n>1?at.toFixed(3):"n/a"})]}),e.jsxs("div",{style:Ge,children:[e.jsx("div",{style:{color:Fe},children:"Fano Poisson"}),e.jsx("div",{style:{fontFamily:"monospace",color:xe.light},children:J.n>1?Je.toFixed(3):"n/a"})]}),e.jsxs("div",{style:Ge,children:[e.jsx("div",{style:{color:Fe},children:"Fano Ratio (Lightlane/Poisson)"}),e.jsx("div",{style:{fontFamily:"monospace",color:Je>0&&at/Je>1.05?pe.light:De},children:J.n>1&&Je>0?(at/Je).toFixed(3):"n/a"})]})]}),St=e.jsxs("div",{style:{marginTop:$?"6px":"8px",display:$?"grid":"flex",gridTemplateColumns:$?"1fr":void 0,justifyContent:$?void 0:"center",gap:$?"4px":"12px",flexWrap:$?void 0:"wrap",fontSize:"10px",color:Fe,fontFamily:ye},children:[e.jsxs("span",{children:["LC(now): ",B.overlaps]}),e.jsxs("span",{children:["LC(bin avg): ",B.binOverlapsMean.toFixed(2)]}),e.jsxs("span",{children:["LC iso target: ",Number.isFinite(bt)?bt.toFixed(2):"n/a"]}),e.jsxs("span",{children:["E[Lightlane|bin]: ",B.currentExpectedLightlane.toFixed(2)]}),e.jsxs("span",{children:["Lightlane(last): ",typeof B.current=="number"?Number(B.current).toFixed(2):B.current]}),e.jsxs("span",{children:["Lanes: ",lt]}),e.jsxs("span",{children:["Mode: ",i==="randomSphere"?"Random Sphere":"Orbit"]}),e.jsxs("span",{children:["theta drift: ",p.toFixed(3)]}),e.jsxs("span",{children:["theta jitter: ",g.toFixed(3)]}),e.jsxs("span",{children:["phi jitter: ",y.toFixed(3)]})]});return e.jsxs(e.Fragment,{children:[!W&&e.jsx(Ae,{fullscreen:!0,style:{pointerEvents:"none"},children:e.jsx(Jn,{bars:At})}),e.jsxs(Ae,{fullscreen:!0,style:{pointerEvents:"none",display:"flex",flexDirection:"column",justifyContent:D?"center":"flex-start"},children:[e.jsxs("div",{style:{position:"absolute",top:"18px",left:"20px",right:"20px",color:De,fontSize:"12px",fontWeight:400,textAlign:"center",textTransform:"uppercase",letterSpacing:"0.16em",fontFamily:tt},children:[Wt,e.jsxs("span",{style:{fontSize:"10px",fontWeight:"normal",marginLeft:"10px",opacity:.8,fontFamily:ye,color:Yn},children:["(λ = ",b.toFixed(1),", σ = ",z.toFixed(1),")"]})]}),e.jsxs("div",{style:{width:"100%",padding:D?"20px":"60px 20px 20px 20px",background:D?"transparent":"linear-gradient(to bottom, rgba(0,0,0,0.9), transparent)",fontFamily:ye,alignSelf:"center"},children:[e.jsx("div",{style:{position:"absolute",left:"5px",top:D?"130px":"170px",transform:"rotate(-90deg)",transformOrigin:"left top",fontSize:"10px",color:Fe,fontStyle:"italic",whiteSpace:"nowrap",fontFamily:ye},children:"← Frequency (how many)"}),e.jsx("div",{style:{display:"flex",height:"100px",gap:"2px",alignItems:"flex-end",padding:"0 20px"},children:ee.map((m,M)=>{const T=ce[M],le=m/xt*100,se=T/xt*100;return e.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",alignItems:"center",position:"relative",height:"100%",justifyContent:"flex-end"},children:[e.jsxs("div",{style:{width:"100%",display:"flex",justifyContent:"center",gap:"1px",alignItems:"flex-end",height:"100%",position:"relative"},children:[qe&&e.jsx("div",{style:{width:Oe?"45%":"92%",height:`${se}%`,background:`linear-gradient(to top, ${xe.solid}, ${xe.dark})`,borderRadius:"2px 2px 0 0",minHeight:T>0?"2px":"0",transition:"height 0.3s ease",boxShadow:T>0?`0 0 5px ${xe.glow}`:"none",position:"relative"},children:T>0&&e.jsx("div",{style:{position:"absolute",top:"-16px",left:"50%",transform:"translateX(-50%)",fontSize:"9px",fontWeight:"bold",color:xe.solid,textShadow:"0 0 3px rgba(0,0,0,0.8)"},children:T})}),Oe&&e.jsx("div",{style:{width:qe?"45%":"92%",height:`${le}%`,background:`linear-gradient(to top, ${pe.solid}, ${pe.dark})`,borderRadius:"2px 2px 0 0",minHeight:m>0?"2px":"0",transition:"height 0.3s ease",boxShadow:m>0?`0 0 5px ${pe.glow}`:"none",position:"relative"},children:m>0&&e.jsx("div",{style:{position:"absolute",top:"-16px",left:"50%",transform:"translateX(-50%)",fontSize:"9px",fontWeight:"bold",color:pe.solid,textShadow:"0 0 3px rgba(0,0,0,0.8)"},children:m})})]}),e.jsx("div",{style:{position:"absolute",bottom:"-18px",fontSize:"9px",color:Fe,fontWeight:"bold",fontFamily:ye},children:me(M).toFixed(0)})]},M)})}),e.jsx("div",{style:{textAlign:"center",marginTop:"25px",fontSize:"10px",color:Fe,fontStyle:"italic",fontFamily:ye},children:"Photon Count Value →"}),e.jsxs("div",{style:{display:"flex",justifyContent:"center",gap:"20px",marginTop:"25px",fontSize:"10px"},children:[qe&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[e.jsx("div",{style:{width:"12px",height:"12px",background:xe.solid,borderRadius:"2px"}}),e.jsx("span",{style:{color:xe.solid},children:"Theory (Poisson)"})]}),Oe&&e.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"5px"},children:[e.jsx("div",{style:{width:"12px",height:"12px",background:pe.solid,borderRadius:"2px"}}),e.jsx("span",{style:{color:pe.solid},children:"Observed (Lightlanes)"})]})]}),yt&&vt,yt&&St]})]}),v&&$&&e.jsx(Ae,{fullscreen:!0,style:{pointerEvents:"none"},children:e.jsxs("div",{style:{position:"absolute",top:"88px",left:"12px",width:"min(300px, calc(100vw - 24px))",background:"linear-gradient(to bottom, rgba(0,0,0,0.88), rgba(0,0,0,0.55))",border:"1px solid var(--terminal-panel-border)",borderRadius:"10px",padding:"10px",boxShadow:"0 8px 24px rgba(0,0,0,0.35)",fontFamily:ye},children:[e.jsx("div",{style:{color:De,fontSize:"10px",textTransform:"uppercase",letterSpacing:"0.08em",marginBottom:"8px",fontWeight:400,fontFamily:tt},children:"Diagnostics"}),vt,St]})}),e.jsxs(Ae,{fullscreen:!0,style:{pointerEvents:"none",display:"flex",flexDirection:"column",justifyContent:"flex-end",paddingBottom:`${_}px`,boxSizing:"border-box"},children:[qe&&e.jsxs("div",{onPointerDown:m=>Ke(m,"theory"),onPointerMove:m=>et(m,"theory",Se,it),onPointerUp:f,onPointerLeave:f,style:{width:"100%",height:"100px",background:`linear-gradient(to top, ${xe.panel}, transparent)`,display:"flex",alignItems:"flex-end",padding:Oe?"0 20px 5px 20px":"0 20px 20px 20px",gap:"2px",position:"relative",borderBottom:Oe?"1px solid #555":"none",pointerEvents:"auto",touchAction:"none",cursor:"crosshair"},children:[e.jsx("div",{style:{position:"absolute",top:"10px",left:"20px",color:xe.solid,fontSize:"10px",fontWeight:400,pointerEvents:"none",fontFamily:tt,letterSpacing:"0.08em"},children:"THEORY (Poisson) - Swipe or click to count"}),Se.map((m,M)=>{const T=Be.has(M);return e.jsx("div",{className:m>=0&&!T?"clickable-bar":"",style:{flex:1,height:m>=0&&!T?`${m/it*100}%`:"0",background:m===0?"rgba(255,255,255,0.1)":xe.solid,color:xe.solid,minHeight:m>=0&&!T?"1px":"0",transition:"all 0.3s ease",opacity:T?0:.8,borderRadius:"2px 2px 0 0",transform:T?"scale(0)":"scale(1)",pointerEvents:"none"}},M)}),e.jsxs("div",{style:{position:"absolute",bottom:"10px",right:"80px",color:De,fontFamily:ye,fontSize:"10px",pointerEvents:"none"},children:["Max: ",it]})]}),Oe&&e.jsxs("div",{onPointerDown:m=>Ke(m,"observed"),onPointerMove:m=>et(m,"observed",x,rt),onPointerUp:f,onPointerLeave:f,style:{width:"100%",height:"100px",background:"linear-gradient(to top, rgba(0,0,0,0.8), transparent)",display:"flex",alignItems:"flex-end",padding:"0 20px 20px 20px",gap:"2px",position:"relative",pointerEvents:"auto",touchAction:"none",cursor:"crosshair"},children:[e.jsx("div",{style:{position:"absolute",top:"10px",left:"20px",color:pe.solid,fontSize:"10px",fontWeight:400,pointerEvents:"none",fontFamily:tt,letterSpacing:"0.08em"},children:"OBSERVED (Lightlanes) - Swipe or click to count"}),x.map((m,M)=>{const T=ae.has(M);return e.jsx("div",{className:m>=0&&!T?"clickable-bar":"",style:{flex:1,height:m>=0&&!T?`${m/rt*100}%`:"0",background:m===0?"rgba(255,255,255,0.1)":m>0?pe.solid:"transparent",color:pe.solid,minHeight:m>=0&&!T?"2px":"0",transition:"all 0.3s ease",borderTop:m>=0&&!T?`2px solid ${pe.light}`:"none",opacity:T?0:.8,position:"relative",borderRadius:"2px 2px 0 0",transform:T?"scale(0)":"scale(1)",pointerEvents:"none"},children:(M+1)%5===0&&!T&&e.jsx("div",{style:{position:"absolute",bottom:"-20px",left:"50%",transform:"translateX(-50%)",width:"1px",height:"5px",background:"#fff",opacity:.5,pointerEvents:"none"},children:e.jsx("span",{style:{position:"absolute",top:"5px",left:"-50%",fontSize:"10px",color:Fe,fontFamily:ye},children:M+1})})},M)}),e.jsxs("div",{style:{position:"absolute",bottom:"10px",right:"80px",color:De,fontFamily:ye,fontSize:"10px"},children:["Max: ",rt]})]})]})]})}const Zn={complexity:1,radius:2,distance:5,chandraDistance:6,showAxes:!1,lightlanes:!0,allSectors:!0,cumulative:!1,phi:0,theta:Math.PI/2,observationMode:"orbit",orbitSpeed:.2,thetaDrift:0,thetaJitter:0,phiJitter:0,speedup:1,K:1e3,usePoisson:!0,sceneView:"both",hideScenePresentation:!1,hideFlyingBars:!1,hideDataBoxes:!1};function eo(t){const n=t.host,o=t.devUi?.compactNumericDiagnostics??!1,r=t.devUi?.maxComplexity??20,s=t.devUi?.maxSpeedup??240,i=74,d=20,l=t.config?.params||{},{complexity:a,radius:u,distance:h,chandraDistance:p,showAxes:g,lightlanes:y,allSectors:I,cumulative:S,phi:L,theta:F,observationMode:_,orbitSpeed:v,thetaDrift:$,thetaJitter:A,phiJitter:D,speedup:W,K:B,usePoisson:C,sceneView:te,hideScenePresentation:j,hideFlyingBars:N,hideDataBoxes:H}={...Zn,...l},R=!H,E=c.useRef(0),x=c.useRef(0),[U,Se]=c.useState(!1),[G,b]=c.useState("scene"),[z,k]=c.useState(te),[w,K]=c.useState(a),[V,re]=c.useState(W),[ge,he]=c.useState(null),q=c.useRef(null);c.useEffect(()=>{k(te)},[te]),c.useEffect(()=>{K(a)},[a]),c.useEffect(()=>{re(W)},[W]);const X=V>20,O=z!=="lightlane",me=z!=="poisson",ee=G==="scene"&&z!=="poisson",fe=f=>f==="poisson"?"Poisson":f==="lightlane"?"Lightlane":"Both",ce=()=>{Ie(n,ke.hover,{page:G,sceneView:z})},Y=(f,P)=>{Ie(n,ke.click,{page:G,sceneView:z,target:f,...P})},ae=f=>{he(f),q.current&&clearTimeout(q.current),q.current=setTimeout(()=>{he(null),q.current=null},1500)},ie=f=>{const P=Array.from({length:d},(Z,ne)=>ne===0?1:ne===d-1?f:Math.round(1+(f-1)*ne/(d-1)));return Array.from(new Set(P)).sort((Z,ne)=>Z-ne)},Be=(f,P)=>{const Z=ie(P);return Z.find(ne=>f<ne)??Z[Z.length-1]},Ce=(f,P)=>{const Z=ie(P);for(let ne=Z.length-1;ne>=0;ne-=1)if(f>Z[ne])return Z[ne];return Z[0]},Le=(f,P)=>{const Z=ie(P),ne=Z.findIndex(Ve=>f<=Ve);return ne>=0?ne:Z.length-1},Te=Le(w,r),Re=Le(V,s),$e=`${(Te+1)/d*100}%`,J=`${(Re+1)/d*100}%`,_e=ee&&w>ie(r)[0],be=ee&&w<ie(r).at(-1),Ze=V>ie(s)[0],Qe=V<ie(s).at(-1),Ne=f=>{if(!ee)return;const P=f==="up"?Be(w,r):Ce(w,r);P!==w&&(Y("complexity",{direction:f,value:P}),K(P),t.devUi?.onSetParam?.("complexity",P),ae(`Complexity ${P}`))},He=f=>{const P=f==="up"?Be(V,s):Ce(V,s);P!==V&&(Y("turbo",{direction:f,value:P}),re(P),t.devUi?.onSetParam?.("speedup",P),ae(`Turbo ${P}x`))},Ke=()=>{const f=["poisson","lightlane","both"],P=f.indexOf(z),Z=f[(P+1)%f.length];Y("mode",{value:Z}),k(Z),ae(`Mode ${fe(Z)}`)},et=()=>{Y("fano-page",{value:G==="scene"?"fano":"scene"}),b(f=>f==="scene"?"fano":"scene")};return c.useEffect(()=>{const f=P=>{if(P.code!=="Space"||P.repeat)return;const Z=P.target,ne=Z?.tagName;ne==="INPUT"||ne==="TEXTAREA"||Z?.isContentEditable||(P.preventDefault(),Se(Ve=>!Ve))};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[]),c.useEffect(()=>()=>{q.current&&clearTimeout(q.current)},[]),We((f,P)=>{U||G==="fano"||(E.current+=P*v*V,x.current+=P*V)}),c.useEffect(()=>{E.current=0,x.current=0},[w,u,h,p,L,F,_,v,$,A,D,V,B,I,S,C]),e.jsxs(e.Fragment,{children:[e.jsx(Ae,{fullscreen:!0,style:{pointerEvents:"none",zIndex:3e3},children:e.jsx("div",{style:{position:"absolute",top:12,right:12,display:"flex",gap:8,pointerEvents:"auto"},children:e.jsx("button",{type:"button",onClick:()=>{Y("advanced"),t.devUi?.onOpenHarness?.()},onPointerEnter:ce,style:{border:"1px solid var(--terminal-panel-border)",background:"rgba(7,19,11,0.86)",color:"var(--terminal-green-soft)",borderRadius:10,padding:"10px 12px",fontSize:12,fontWeight:400,letterSpacing:"0.08em",fontFamily:"var(--font-headline)",textTransform:"uppercase",cursor:"pointer",boxShadow:"0 8px 24px rgba(0,0,0,0.25)"},children:"Advanced"})})}),e.jsx("ambientLight",{intensity:.4}),e.jsx("directionalLight",{position:[10,10,5],intensity:1,castShadow:!0}),e.jsx("pointLight",{position:[-10,-10,-10],intensity:.5,color:"blue"}),G==="scene"?e.jsxs(e.Fragment,{children:[!j&&O&&e.jsx(Hn,{radius:p}),!j&&me&&e.jsx(yn,{complexity:w,lightlanes:y,radius:u,distance:h,allSectors:I,cumulative:S}),!j&&e.jsx(Vn,{radius:u,paused:U}),e.jsx(Un,{radius:p,theta:F,phi:L,orbitTime:E,simTime:x,thetaDrift:$,paused:U}),e.jsx(Xn,{complexity:w,radius:u,distance:h,theta:F,phi:L,observationMode:_,allSectors:I,cumulative:S,K:B,orbitRadius:p,orbitVelocity:v,thetaDrift:$,thetaJitter:A,phiJitter:D,usePoisson:C,speedup:V,paused:U,sceneView:z,bottomInset:i,showNumericDiagnostics:R,compactNumericDiagnostics:o,host:n,centerDistribution:j,hideFlyingBars:N||X}),U&&e.jsx("group",{position:[0,p+1.5,0],children:e.jsxs("mesh",{children:[e.jsx("sphereGeometry",{args:[.12,16,16]}),e.jsx("meshBasicMaterial",{color:"#ef4444",toneMapped:!1})]})}),g&&e.jsx("axesHelper",{args:[Math.max(5,w)]}),e.jsx(xn,{infiniteGrid:!0,fadeDistance:50,sectionColor:"#333",cellColor:"#111",position:[0,-.01,0]})]}):e.jsx(_n,{radius:u,distance:h,chandraDistance:p,allSectors:I,cumulative:S,theta:F,phi:L,orbitSpeed:v,thetaDrift:$,thetaJitter:A,phiJitter:D,K:B,speedup:V,usePoisson:C,bottomInset:i,onBack:()=>b("scene"),host:n}),e.jsxs(Ae,{fullscreen:!0,style:{pointerEvents:"none",zIndex:3200},children:[ge&&e.jsx("div",{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%) skewX(-12deg)",padding:"16px 28px",color:"var(--terminal-green-soft)",fontFamily:"var(--font-headline)",fontStyle:"italic",fontSize:42,letterSpacing:"0.16em",textTransform:"uppercase",textShadow:"0 0 20px rgba(125,255,155,0.38), 0 0 42px rgba(125,255,155,0.18)"},children:e.jsx("span",{style:{display:"inline-block",transform:"skewX(12deg)"},children:ge})}),e.jsx("div",{style:{position:"absolute",left:10,bottom:i+16,width:26,height:"min(44vh, 320px)",display:"flex",alignItems:"flex-end"},children:e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:14,border:"1px solid rgba(251,191,36,0.35)",background:"linear-gradient(to top, rgba(30,18,0,0.92), rgba(7,19,11,0.15))",boxShadow:"0 0 22px rgba(251,191,36,0.12)",overflow:"hidden",opacity:ee?1:.35,transition:"opacity 0.2s ease"},children:[e.jsx("div",{style:{position:"absolute",inset:"6px",borderRadius:10,border:"1px solid rgba(251,191,36,0.14)"}}),e.jsx("div",{style:{position:"absolute",left:5,right:5,bottom:5,height:$e,borderRadius:9,background:"linear-gradient(to top, rgba(245,158,11,0.96), rgba(253,224,71,0.96))",boxShadow:"0 0 18px rgba(251,191,36,0.5)",transition:"height 0.25s ease"}}),e.jsx("div",{style:{position:"absolute",inset:"8px 7px",display:"grid",gridTemplateRows:`repeat(${d}, 1fr)`,pointerEvents:"none"},children:Array.from({length:d}).map((f,P)=>e.jsx("div",{style:{borderTop:P===0?"none":"1px solid rgba(251,191,36,0.15)"}},`complexity-tick-${P}`))}),e.jsxs("div",{style:{position:"absolute",left:34,bottom:0,color:"#fcd34d",fontFamily:"var(--font-headline)",fontSize:10,letterSpacing:"0.08em",textTransform:"uppercase",writingMode:"vertical-rl",transform:"rotate(180deg)",textShadow:"0 0 12px rgba(251,191,36,0.25)"},children:["Complexity ",Te+1,"/",d]})]})}),e.jsx("div",{style:{position:"absolute",right:10,bottom:i+16,width:26,height:"min(44vh, 320px)",display:"flex",alignItems:"flex-end"},children:e.jsxs("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:14,border:"1px solid rgba(244,114,182,0.35)",background:"linear-gradient(to top, rgba(42,7,23,0.94), rgba(7,19,11,0.15))",boxShadow:"0 0 22px rgba(244,114,182,0.14)",overflow:"hidden"},children:[e.jsx("div",{style:{position:"absolute",inset:"6px",borderRadius:10,border:"1px solid rgba(244,114,182,0.14)"}}),e.jsx("div",{style:{position:"absolute",left:5,right:5,bottom:5,height:J,borderRadius:9,background:"linear-gradient(to top, rgba(236,72,153,0.96), rgba(244,114,182,0.98))",boxShadow:"0 0 18px rgba(244,114,182,0.5)",transition:"height 0.25s ease"}}),e.jsx("div",{style:{position:"absolute",inset:"8px 7px",display:"grid",gridTemplateRows:`repeat(${d}, 1fr)`,pointerEvents:"none"},children:Array.from({length:d}).map((f,P)=>e.jsx("div",{style:{borderTop:P===0?"none":"1px solid rgba(244,114,182,0.15)"}},`turbo-tick-${P}`))}),e.jsxs("div",{style:{position:"absolute",right:34,bottom:0,color:"#f9a8d4",fontFamily:"var(--font-headline)",fontSize:10,letterSpacing:"0.08em",textTransform:"uppercase",writingMode:"vertical-rl",textShadow:"0 0 12px rgba(244,114,182,0.25)"},children:["Turbo ",Re+1,"/",d]})]})}),e.jsx("div",{style:{position:"absolute",left:12,right:12,bottom:10,display:"grid",gridTemplateColumns:"repeat(4, minmax(0, 1fr))",gap:8,pointerEvents:"auto"},children:[{label:"Complexity",kind:"adjust",active:!1,disabled:!ee,accent:"rgba(245,158,11,0.2)",sublabel:`${w}${Te+1}/${d}`,meterColor:"linear-gradient(to top, rgba(245,158,11,0.95), rgba(253,224,71,0.95))",meterSide:"left",meterFill:$e,onDecrease:()=>Ne("down"),onIncrease:()=>Ne("up"),canDecrease:_e,canIncrease:be},{label:"Mode",kind:"action",onClick:Ke,active:!1,accent:"rgba(59,130,246,0.18)",sublabel:fe(z)},{label:"Fano Sweep",kind:"action",onClick:et,active:G==="fano",accent:"rgba(59,130,246,0.22)",sublabel:G==="fano"?"Open":"Scene"},{label:"Turbo",kind:"adjust",active:!1,accent:"rgba(34,197,94,0.2)",sublabel:`${V}x • ${Re+1}/${d}`,meterColor:"linear-gradient(to top, rgba(236,72,153,0.95), rgba(244,114,182,0.95))",meterSide:"right",meterFill:J,onDecrease:()=>He("down"),onIncrease:()=>He("up"),canDecrease:Ze,canIncrease:Qe}].map(f=>f.kind==="adjust"?e.jsxs("div",{style:{minHeight:54,border:"1px solid var(--terminal-panel-border)",background:f.active?f.accent:"rgba(7,19,11,0.86)",color:"var(--terminal-green-soft)",borderRadius:10,padding:"8px 10px",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:6,boxShadow:f.active?"0 0 18px rgba(125,255,155,0.12)":"0 8px 24px rgba(0,0,0,0.25)",position:"relative",overflow:"hidden",opacity:f.disabled?.38:1},children:["meterColor"in f&&e.jsxs(e.Fragment,{children:[e.jsx("div",{style:{position:"absolute",top:6,bottom:6,left:f.meterSide==="left"?6:void 0,right:f.meterSide==="right"?6:void 0,width:6,borderRadius:999,background:"rgba(255,255,255,0.07)",border:"1px solid rgba(255,255,255,0.08)"}}),e.jsx("div",{style:{position:"absolute",bottom:7,left:f.meterSide==="left"?7:void 0,right:f.meterSide==="right"?7:void 0,width:4,height:f.meterFill,borderRadius:999,background:f.meterColor,boxShadow:f.meterSide==="left"?"0 0 10px rgba(251,191,36,0.45)":"0 0 10px rgba(244,114,182,0.45)",transition:"height 0.25s ease"}})]}),e.jsx("span",{style:{fontFamily:"var(--font-headline)",fontSize:11,fontWeight:400,letterSpacing:"0.08em",textTransform:"uppercase",lineHeight:1.1},children:f.label}),e.jsx("span",{style:{fontFamily:"var(--font-ui)",fontSize:10,color:"var(--terminal-green)",letterSpacing:"0.08em",lineHeight:1},children:f.sublabel}),e.jsxs("div",{style:{display:"grid",gridTemplateColumns:"repeat(2, minmax(0, 1fr))",gap:6,width:"100%",marginTop:"auto"},children:[e.jsx("button",{type:"button",onClick:f.onDecrease,onPointerEnter:ce,disabled:f.disabled||!f.canDecrease,style:{border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.04)",color:"var(--terminal-green-soft)",borderRadius:8,minHeight:24,cursor:f.disabled||!f.canDecrease?"not-allowed":"pointer",fontFamily:"var(--font-headline)",fontSize:12,letterSpacing:"0.08em",opacity:f.disabled||!f.canDecrease?.35:1,position:"relative",zIndex:1},children:"-"}),e.jsx("button",{type:"button",onClick:f.onIncrease,onPointerEnter:ce,disabled:f.disabled||!f.canIncrease,style:{border:"1px solid rgba(255,255,255,0.12)",background:"rgba(255,255,255,0.04)",color:"var(--terminal-green-soft)",borderRadius:8,minHeight:24,cursor:f.disabled||!f.canIncrease?"not-allowed":"pointer",fontFamily:"var(--font-headline)",fontSize:12,letterSpacing:"0.08em",opacity:f.disabled||!f.canIncrease?.35:1,position:"relative",zIndex:1},children:"+"})]})]},f.label):e.jsxs("button",{type:"button",onClick:f.onClick,onPointerEnter:ce,disabled:"disabled"in f?f.disabled:!1,style:{minHeight:54,border:"1px solid var(--terminal-panel-border)",background:f.active?f.accent:"rgba(7,19,11,0.86)",color:"var(--terminal-green-soft)",borderRadius:10,padding:"8px 10px",cursor:"disabled"in f&&f.disabled?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:2,boxShadow:f.active?"0 0 18px rgba(125,255,155,0.12)":"0 8px 24px rgba(0,0,0,0.25)",position:"relative",overflow:"hidden",opacity:"disabled"in f&&f.disabled?.38:1},children:[e.jsx("span",{style:{fontFamily:"var(--font-headline)",fontSize:11,fontWeight:400,letterSpacing:"0.08em",textTransform:"uppercase",lineHeight:1.1},children:f.label}),e.jsx("span",{style:{fontFamily:"var(--font-ui)",fontSize:10,color:"var(--terminal-green)",letterSpacing:"0.08em",lineHeight:1},children:f.sublabel})]},f.label))})]}),e.jsx("color",{attach:"background",args:["#050505"]})]})}const to={name:"lightlane",displayName:"Lightlane Challenge",version:"1.1.0",paramSchema:{hideScenePresentation:{type:"boolean",label:"Hide Sphere + Lightlanes",default:!1},hideFlyingBars:{type:"boolean",label:"Hide Flying Bars",default:!1},hideDataBoxes:{type:"boolean",label:"Hide Data Boxes",default:!1},complexity:{type:"range",label:"Complexity",default:5,min:1,max:20,step:1},radius:{type:"range",label:"Distance to star",default:2,min:.1,max:5,step:.1},chandraDistance:{type:"range",label:"Chandra Camera Distance",default:6,min:5,max:30,step:.5},observationMode:{type:"select",label:"Observation Mode",default:"randomSphere",options:[{value:"orbit",label:"Orbit"},{value:"randomSphere",label:"Random Sphere"}]},sceneView:{type:"select",label:"Scene View",default:"both",options:[{value:"both",label:"Both"},{value:"poisson",label:"Poisson"},{value:"lightlane",label:"Lightlane"}]},orbitSpeed:{type:"range",label:"Orbit Speed",default:.2,min:0,max:2,step:.01},thetaDrift:{type:"range",label:"Theta Drift",default:0,min:-1,max:1,step:.01},thetaJitter:{type:"range",label:"Theta Jitter",default:0,min:0,max:.25,step:.005},phiJitter:{type:"range",label:"Phi Jitter",default:0,min:0,max:.5,step:.01},speedup:{type:"range",label:"Speedup",default:1,min:1,max:240,step:1}},defaultParams:{complexity:5,radius:2,orbitSpeed:.2,thetaDrift:0,thetaJitter:0,phiJitter:0,chandraDistance:6,observationMode:"randomSphere",sceneView:"both",speedup:1,distance:5,showAxes:!1,lightlanes:!0,allSectors:!0,cumulative:!1,phi:0,theta:Math.PI/2,K:1e3,usePoisson:!0,hideScenePresentation:!1,hideFlyingBars:!1,hideDataBoxes:!1}};export{eo as default,to as metadata};