sessiongraph 1.0.15 → 1.0.17

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.
Files changed (41) hide show
  1. package/PRIVACY.md +15 -61
  2. package/README.md +36 -56
  3. package/bin/sessiongraph.mjs +14 -8
  4. package/dist/assets/{index-Kotmn42s.js → index-BcuycrLl.js} +1 -1
  5. package/dist/assets/{index-BLM-0yG6.js → index-CxNvtrVy.js} +1 -1
  6. package/dist/assets/{index-D4P4hbvc.js → index-DHztibvv.js} +1 -1
  7. package/dist/assets/index-Dm6VCxBu.js +186 -0
  8. package/dist/assets/index-ZvQzUBK1.css +1 -0
  9. package/dist/assets/katagami-sans-DMv8PCo8.woff2 +0 -0
  10. package/dist/assets/licenses/hugeicons.txt +21 -0
  11. package/dist/assets/licenses/katagami.txt +93 -0
  12. package/dist/assets/public-viewer-B3t-LR4T.js +24 -0
  13. package/dist/assets/public-viewer-CyDoUT6s.css +1 -0
  14. package/dist/assets/scene-CnihjOu5.js +248 -0
  15. package/dist/assets/share-BWJVjZdG.js +7 -0
  16. package/dist/assets/{three-D_1Qt16u.js → three-DDiuFd7k.js} +21 -21
  17. package/dist/assets/{worker-C10U_apJ.js → worker-B9mWJfQ6.js} +1 -1
  18. package/dist/index.html +2 -2
  19. package/dist-server/cli.mjs +48514 -15784
  20. package/dist-server/install-cli.mjs +204 -0
  21. package/dist-server/server.mjs +1196 -424
  22. package/docs/cli.md +293 -190
  23. package/docs/guide.md +15 -8
  24. package/docs/import-coverage.md +73 -5
  25. package/docs/performance.md +164 -0
  26. package/docs/releases.md +6 -0
  27. package/package.json +18 -10
  28. package/dist/assets/external-links-BmBkCsrt.js +0 -1
  29. package/dist/assets/geist-cyrillic-ext-wght-normal-DjL33-gN.woff2 +0 -0
  30. package/dist/assets/geist-cyrillic-wght-normal-BEAKL7Jp.woff2 +0 -0
  31. package/dist/assets/geist-latin-ext-wght-normal-DC-KSUi6.woff2 +0 -0
  32. package/dist/assets/geist-latin-wght-normal-BgDaEnEv.woff2 +0 -0
  33. package/dist/assets/geist-vietnamese-wght-normal-6IgcOCM7.woff2 +0 -0
  34. package/dist/assets/index-B1kyvo41.js +0 -175
  35. package/dist/assets/index-Du0_nVjH.css +0 -1
  36. package/dist/assets/publishing-CEvQPkO1.css +0 -1
  37. package/dist/assets/publishing-D9CqkbeB.js +0 -23
  38. package/dist/assets/scene-CTHyYtma.js +0 -139
  39. package/dist/assets/share-Cw1E-ED9.js +0 -7
  40. package/docs/importer-comparison.md +0 -48
  41. package/docs/session-artifacts-audit.md +0 -176
@@ -0,0 +1,248 @@
1
+ import{R as De,W as Ae,H as Ce,T as Ee,M as ve,C as V,S as xe,a as k,G as X,P as he,I as ge,b as F,D,c as L,A as H,d as Z,e as j,B as E,F as I,f as re,g as U,V as v,h as O,i as ne,j as Fe,k as Ge,l as Ue,O as Oe,E as ze,U as Xe,m as Le,n as He,o as _e,p as Ve,q as Ne,r as se,s as $e,t as We,u as ue,v as je,w as qe,x as ae,y as de,z as Ye,L as Ze,J as we,K as Me,N as Ke}from"./three-DDiuFd7k.js";import{K as te,L as P,D as Re,M as le,N as B,a as Qe,O as Je,Q as oe,T as et,U as tt,W as it}from"./index-Dm6VCxBu.js";class st extends De{target=new Ae(1,1,{type:Ce});copy=new Ee(this.target.texture);setSamples(e){this.target.samples!==e&&(this.target.samples=e,this.target.dispose())}setSize(e,t){this.target.setSize(e,t)}render(e,t,s,o,i){if(!this.target.samples){super.render(e,t,s,o,i);return}super.render(e,t,this.target,o,i),this.copy.render(e,t,s,o,i)}dispose(){this.copy.dispose(),this.target.dispose()}}const ot=new Intl.DateTimeFormat("en",{month:"short"}),rt=new Intl.DateTimeFormat("en",{month:"short",year:"numeric"});function nt(u){if(u.calendarTime===!1||!(u.end>u.start))return[];const e=new Date(u.start),t=new Date(u.end);if(!Number.isFinite(+e)||!Number.isFinite(+t))return[];const s=h=>h.getFullYear()*12+h.getMonth(),o=s(e),i=s(t),r=Math.ceil((i-o+1)/24),a=[1,2,3,6,12].find(h=>h>=r)??Math.ceil(r/12)*12,n=o===i||e.getFullYear()!==t.getFullYear()?rt:ot,l=[];for(let h=Math.ceil(o/a)*a;h<=i;h+=a){const c=new Date(0);c.setFullYear(Math.floor(h/12),h%12,1),c.setHours(0,0,0,0),+c>=u.start&&+c<=u.end&&l.push({x:te(+c,u),label:n.format(c)})}return!l.length&&o===i&&l.push({x:te(u.start,u),label:n.format(e)}),l}const Te=`
2
+ attribute float nodeIndex;
3
+ uniform float uSelected;
4
+ uniform float uHovered;
5
+ uniform float uFocus;
6
+ attribute float familyDepth;
7
+ uniform float uFamilyTime;
8
+ varying float vNodeEmphasis;
9
+ float nodeEmphasis() {
10
+ if (abs(nodeIndex - uSelected) < .5) return 1.12;
11
+ if (abs(nodeIndex - uHovered) < .5) return 1.2;
12
+ float family = step(-.5, familyDepth) * smoothstep(familyDepth*.12, familyDepth*.12+.35, uFamilyTime);
13
+ return mix(mix(1.0, .12, uFocus), mix(1.0, .85, uFocus), family);
14
+ }
15
+ `;function Y(u){const e=new V(u.color),t=e.getHSL({h:0,s:0,l:0},xe),s=u.session.id;return e.setHSL(t.h+(P(`${s}:hue`)-.5)*.09,k.clamp(t.s+P(`${s}:saturation`)*.12,.4,.72),.63+P(`${s}:lightness`)*.11,xe)}function at(u){const e=new ve;return e.onBeforeCompile=t=>{Object.assign(t.uniforms,u),t.vertexShader=`${Te}
16
+ varying vec3 vSphereNormal; varying vec3 vSphereView;
17
+ ${t.vertexShader}`.replace("#include <project_vertex>",`
18
+ #include <project_vertex>
19
+ // Instances only translate/uniformly scale, so view-space normals retain
20
+ // the original sphere's lighting and depth cues.
21
+ vSphereNormal = mat3(viewMatrix) * normal;
22
+ vSphereView = -mvPosition.xyz;
23
+ vNodeEmphasis = nodeEmphasis();
24
+ `),t.fragmentShader=`varying vec3 vSphereNormal; varying vec3 vSphereView; varying float vNodeEmphasis;
25
+ ${t.fragmentShader}`.replace("#include <color_fragment>",`
26
+ #include <color_fragment>
27
+ vec3 n = normalize(vSphereNormal);
28
+ float facing = max(dot(n, normalize(vSphereView)), 0.0);
29
+ float light = .8 + .4 * max(dot(n, normalize(vec3(-.5, .65, 1.0))), 0.0);
30
+ // Luminous colored centers bloom; a soft rim still separates overlaps.
31
+ float rim = mix(.35, 1.0, smoothstep(0.0, .28, facing));
32
+ diffuseColor.rgb = mix(diffuseColor.rgb, vec3(1.0), .07 * facing);
33
+ diffuseColor.rgb *= 1.4 * light * rim * vNodeEmphasis;
34
+ `)},e}const Ie=32,ee=4,ie=2*Math.PI/Ie,ye=.02,be=.18;function Be(u,e){const t=Math.max(0,e-u.startPosition[0]),s=Math.min(1,t/ee),o=ye+u.radius*be;return{angle:t*ie+P(u.session.id)*2*Math.PI,amplitude:o*s*s*(3-2*s),derivative:t<ee?o*6*s*(1-s)/ee:0}}function G(u,e){const{angle:t,amplitude:s}=Be(u,e);return[e,u.position[1]+Math.cos(t)*s,u.position[2]+Math.sin(t)*s]}function ke(u,e){const{angle:t,amplitude:s,derivative:o}=Be(u,e);return[1,Math.cos(t)*o-Math.sin(t)*s*ie,Math.sin(t)*o+Math.cos(t)*s*ie]}const Pe=`
35
+ uniform float uHeadX; uniform float uGraphReveal; uniform float uContextFocus;
36
+ uniform float uTrailTime; uniform float uTrailFlow; uniform float uTrailSpeed;
37
+ uniform float uTrailOpacity; uniform float uNodeScale; uniform float uPixelScale;
38
+ attribute vec3 origin; attribute float endX; attribute float radius; attribute float seed; attribute float reveal;
39
+ varying vec3 vColor; varying float vAlpha;
40
+ vec3 cometPoint(float t, float head) {
41
+ float distance = (head - origin.x) * t;
42
+ float phase = distance * ${ie.toFixed(10)} + seed * ${String(2*Math.PI)};
43
+ float curl = (${ye} + radius * ${be}) * smoothstep(0., ${ee.toFixed(1)}, distance);
44
+ return vec3(origin.x + distance, origin.y + cos(phase) * curl, origin.z + sin(phase) * curl);
45
+ }
46
+ `;function lt(u,e,t,s=!1){const o=u.filter(a=>a.position[0]>a.startPosition[0]),i=new X;i.userData.kind="lifetime";const r=[];for(const a of[16,64,256,512]){const n=o.filter(l=>{const h=(l.position[0]-l.startPosition[0])/Ie*32;return(h<=16?16:h<=64?64:h<=256?256:512)===a});if(n.length){const l=ht(n,e,t,s,a);r.push(l),i.add(l.group)}}return{group:i,update(a){for(const n of r)n.update(a)}}}function ht(u,e,t,s,o){const i=new X,r=u.map(x=>t.get(x.session.id)),a={...e,uIntensity:{value:s?1:.48}},n=[],l=[],h=[],c=[],d=[];for(const x of u)n.push(...x.startPosition),l.push(x.position[0]),h.push(x.radius),c.push(P(x.session.id)),d.push(...Y(x).toArray());const p=new he(1,2,o,1),y=new ge;y.index=p.index,y.attributes=p.attributes,y.instanceCount=u.length,y.setAttribute("origin",new F(new Float32Array(n),3)),y.setAttribute("endX",new F(new Float32Array(l),1)),y.setAttribute("radius",new F(new Float32Array(h),1)),y.setAttribute("seed",new F(new Float32Array(c),1)),y.setAttribute("color",new F(new Float32Array(d),3));const M=new F(new Float32Array(u.length),1).setUsage(D);y.setAttribute("reveal",M);const g=new L({uniforms:a,vertexColors:!0,transparent:!0,depthWrite:!1,side:Z,blending:H,vertexShader:`${Pe}
47
+ varying float vAcross; varying float vAlong;
48
+ void main() {
49
+ float head = clamp(uHeadX, origin.x, endX), span = head - origin.x;
50
+ float t = uv.x; vAlong = t; vAcross = position.y;
51
+ vColor = color; vAlpha = step(.0001, span) * smoothstep(.45,1.,reveal) * uGraphReveal * mix(1.0, .12, uContextFocus);
52
+ vec3 point = cometPoint(t, head);
53
+ vec4 mv = modelViewMatrix * vec4(point, 1.0);
54
+ vec3 tangent = cometPoint(min(1., t + .001), head) - cometPoint(max(0., t - .001), head);
55
+ vec2 axis = (modelViewMatrix * vec4(tangent,0.)).xy;
56
+ vec2 normal = length(axis) > .001 ? normalize(vec2(-axis.y, axis.x)) : vec2(0.,1.);
57
+ float taper = pow(max(0., t), 1.25);
58
+ float width = (.012 + radius * uNodeScale * .55 * taper) * smoothstep(0., .06, t);
59
+ mv.xy += normal * position.y * width;
60
+ gl_Position = projectionMatrix * mv;
61
+ }`,fragmentShader:`uniform float uTrailOpacity; uniform float uIntensity;
62
+ varying vec3 vColor; varying float vAlpha; varying float vAcross; varying float vAlong;
63
+ void main() {
64
+ float core = exp(-abs(vAcross) * 7.0), halo = pow(max(0., 1.-abs(vAcross)), 2.);
65
+ // Interpolation can put the first ribbon pixels just below zero.
66
+ // Fractional pow of that value poisons the HDR buffer and every bloom mip.
67
+ float along = clamp(vAlong, 0., 1.);
68
+ float tail = smoothstep(0., .04, along) * (.18 + .82 * pow(along, .7));
69
+ float alpha = (core * .8 + halo * .28) * tail * vAlpha * uTrailOpacity * uIntensity;
70
+ gl_FragColor = vec4(vColor * (1.1 + core * .35), alpha);
71
+ }`}),b=new j(y,g);b.frustumCulled=!1,i.add(b);const m=new E,R=[],f=[],w=[],S=[],A=[],C=[],K=[0];for(let x=0;x<u.length;x++){const N=Math.min(24,Math.max(8,Math.ceil((l[x]-n[x*3])/3)));for(let T=0;T<N;T++)R.push((T+.5)/N,P(`${c[x]}:${T}`),0),f.push(...n.slice(x*3,x*3+3)),w.push(l[x]),S.push(h[x]),A.push(c[x]),C.push(...d.slice(x*3,x*3+3));K.push(R.length/3)}for(const[x,N,T]of[["position",R,3],["origin",f,3],["endX",w,1],["radius",S,1],["seed",A,1],["color",C,3]])m.setAttribute(x,new I(N,T));const Q=new re(new Float32Array(R.length/3),1).setUsage(D);m.setAttribute("reveal",Q);const _=new U(m,new L({uniforms:a,vertexColors:!0,transparent:!0,depthWrite:!1,blending:H,vertexShader:`${Pe}
72
+ void main() {
73
+ float head = clamp(uHeadX, origin.x, endX), span = head - origin.x;
74
+ float clock = uTrailTime * uTrailFlow * uTrailSpeed;
75
+ float t = fract(position.x - clock * .12 + seed);
76
+ float wake = min(span, 24. + radius * 16.);
77
+ float age = 1. - t;
78
+ float angle = age * 10. + seed * 6.28318 + clock * .5;
79
+ float spread = sin(age * 3.14159) * radius * uNodeScale * (.25 + position.y * .65);
80
+ vec3 point = cometPoint(1. - wake * age / max(.001, span), head);
81
+ point.y += cos(angle) * spread; point.z += sin(angle) * spread;
82
+ vec4 mv = modelViewMatrix * vec4(point, 1.);
83
+ gl_Position = projectionMatrix * mv;
84
+ gl_PointSize = clamp((.045 + radius * .15 * pow(t, .8)) * uPixelScale / max(.1, -mv.z), 1., 7.);
85
+ vColor = color;
86
+ vAlpha = step(.001, span) * smoothstep(.45,1.,reveal) * smoothstep(0., .12, span) * pow(t, 1.4) * (.3 + .7 * position.y) * uGraphReveal * mix(1., .1, uContextFocus);
87
+ }`,fragmentShader:`uniform float uTrailOpacity; uniform float uIntensity; varying vec3 vColor; varying float vAlpha;
88
+ void main() { float d = length(gl_PointCoord - .5) * 2.; if (d > 1.) discard;
89
+ gl_FragColor = vec4(vColor * 1.7, pow(1.-d, 1.6) * vAlpha * uTrailOpacity * uIntensity); }`}));return _.name="comet-particles",_.frustumCulled=!1,i.add(_),{group:i,update(x){let N=!1;for(let T=0;T<u.length;T++){const ce=x[r[T]];M.getX(T)!==ce&&(N=!0,M.setX(T,ce),Q.array.fill(ce,K[T],K[T+1]))}N&&(M.needsUpdate=!0,Q.needsUpdate=!0)}}}class ct{constructor(e,t,s=!1){this.links=e,this.group.userData.kind="relationship";const o=new he(1,2,48,1),i=new ge;i.index=o.index,i.attributes=o.attributes,i.instanceCount=e.length;for(const[a,n]of[["a","v0"],["b","v1"],["c","v2"],["d","v3"]])i.setAttribute(a,new F(Float32Array.from(e.flatMap(l=>l.curve[n].toArray())),3));i.setAttribute("color",new F(Float32Array.from(e.flatMap(a=>a.color.toArray())),3)),this.progress=new F(new Float32Array(e.length),1).setUsage(D),i.setAttribute("reveal",this.progress);const r=new j(i,new L({uniforms:{...t,uIntensity:{value:s?1.15:.65}},vertexColors:!0,transparent:!0,depthWrite:!1,side:Z,blending:H,vertexShader:`attribute vec3 a,b,c,d; attribute float reveal; uniform float uPixelScale,uPixelRatio;
90
+ varying vec3 vColor; varying float vAcross,vAlong,vReveal;
91
+ vec3 curve(float t) { float s=1.-t; return s*s*s*a+3.*s*s*t*b+3.*s*t*t*c+t*t*t*d; }
92
+ void main() {
93
+ float t=uv.x*reveal; vec3 p=curve(t);
94
+ vec2 axis=(modelViewMatrix*vec4(curve(min(1.,t+.001))-curve(max(0.,t-.001)),0.)).xy;
95
+ vec2 normal=length(axis)>.0001?normalize(vec2(-axis.y,axis.x)):vec2(0.,1.);
96
+ vec4 mv=modelViewMatrix*vec4(p,1.);
97
+ mv.xy+=normal*position.y*max(.015,-mv.z/uPixelScale*5.5*uPixelRatio);
98
+ gl_Position=projectionMatrix*mv; vColor=color; vAcross=position.y; vAlong=uv.x; vReveal=reveal;
99
+ }`,fragmentShader:`uniform float uIntensity,uContextFocus; varying vec3 vColor; varying float vAcross,vAlong,vReveal;
100
+ void main() {
101
+ if(vReveal<=0.) discard;
102
+ float core=exp(-vAcross*vAcross*100.), aura=exp(-vAcross*vAcross*4.)*(1.-smoothstep(.65,1.,abs(vAcross)));
103
+ float distance=(1.-clamp(vAlong,0.,1.))*16.;
104
+ float tip=exp(-distance*distance)*max(0.,sin(vReveal*3.14159));
105
+ vec3 tint=mix(vColor,vec3(1.),tip*.18);
106
+ float alpha=(core*.8+aura*.24+tip*aura*.7)*smoothstep(0.,.04,vReveal)*uIntensity*mix(1.,.16,uContextFocus);
107
+ gl_FragColor=vec4(tint*(1.2+tip),alpha);
108
+ }`}));r.frustumCulled=!1,this.group.add(r)}links;group=new X;progress;update(e,t=1/0){this.links.forEach((s,o)=>this.progress.setX(o,e[s.child]*(Number.isFinite(t)?k.smoothstep(t-(s.delay||0),0,.4):1))),this.progress.needsUpdate=!0}samples(){return Array.from(this.progress.array).slice(0,32)}}function ut(u,e,t,s){const o=new he(2,2),i=new ge;i.index=o.index,i.attributes=o.attributes,i.instanceCount=u.length;const r=new F(e,3).setUsage(D),a=new F(t,1).setUsage(D);i.setAttribute("center",r),i.setAttribute("reveal",a),i.setAttribute("color",new F(Float32Array.from(u.flatMap(l=>Y(l).toArray())),3)),i.setAttribute("radius",new F(Float32Array.from(u.map(l=>l.radius)),1)),i.setAttribute("nodeIndex",new F(Float32Array.from(u.map((l,h)=>h)),1));const n=new j(i,new L({uniforms:s,vertexColors:!0,transparent:!0,depthWrite:!1,depthTest:!1,side:Z,blending:H,vertexShader:`attribute vec3 center; attribute float reveal,radius; uniform float uPixelScale,uPixelRatio,uNodeScale;
109
+ varying vec3 vColor; varying vec2 vPoint; varying float vAlpha;
110
+ void main(){
111
+ vColor=color; vPoint=position.xy; vAlpha=max(0.,sin(reveal*3.14159));
112
+ if(reveal<=0. || reveal>=1.) { gl_Position=vec4(2.,2.,2.,1.); return; }
113
+ vec4 mv=modelViewMatrix*vec4(center,1.);
114
+ float size=max(radius*uNodeScale*1.8,-mv.z/uPixelScale*4.*uPixelRatio);
115
+ mv.xy+=position.xy*size;
116
+ gl_Position=projectionMatrix*mv;
117
+ }`,fragmentShader:`varying vec3 vColor; varying vec2 vPoint; varying float vAlpha; uniform float uFocus;
118
+ void main(){
119
+ float d=length(vPoint); if(d>=1.) discard;
120
+ float core=exp(-d*d*22.);
121
+ float sparkle=exp(-abs(vPoint.x*vPoint.y)*90.)*pow(max(0.,1.-d),2.);
122
+ gl_FragColor=vec4(mix(vColor,vec3(1.),.65),(core*.18+sparkle*.16)*vAlpha*mix(1.,.16,uFocus));
123
+ }`}));return n.frustumCulled=!1,{mesh:n,update(){r.needsUpdate=!0,a.needsUpdate=!0}}}const me={performance:{dust:160,trails:32,bursts:8,sparks:12},balanced:{dust:560,trails:96,bursts:24,sparks:20},high:{dust:1100,trails:160,bursts:40,sparks:28}};function pe(u,e){const t=Math.min(u.length,Math.max(0,Math.floor(e)));return Array.from({length:t},(s,o)=>u[Math.floor(o*u.length/t)])}function dt(u,e,t=256){const s=new Set(u.nodes.map(n=>n.session.id)),o=new Map;if(!s.has(e)||t<1)return{depths:o,edges:[]};const i=new Map;for(const n of u.edges)if(!(!s.has(n.from)||!s.has(n.to)))for(const[l,h]of[[n.from,n.to],[n.to,n.from]]){const c=i.get(l)||[];c.push(h),i.set(l,c)}const r=[e];o.set(e,0);for(let n=0;n<r.length;n++){const l=r[n];for(const h of i.get(l)||[])o.has(h)||o.size>=t||(o.set(h,o.get(l)+1),r.push(h))}const a=u.edges.filter(n=>o.has(n.from)&&o.has(n.to)).slice(0,t*2).map(n=>({edge:n,depth:Math.min(o.get(n.from),o.get(n.to))}));return{depths:o,edges:a}}function mt(u,e,t,s){if(![u,e,t,s].every(Number.isFinite)||s<=0||u===e)return 0;const o=(e-u)/s/Math.max(1/120,t);return Math.max(-1,Math.min(1,o*.65))}function pt(u,e,t,s=6){if(!Number.isFinite(e)||!Number.isFinite(t)||t<=e)return[];const o=n=>{let l=0,h=u.length;for(;l<h;){const c=l+h>>>1;u[c]<=n?l=c+1:h=c}return l},i=o(e),r=o(t),a=Math.min(r-i,Math.max(0,Math.floor(s)));return Array.from({length:a},(n,l)=>u[i+Math.floor(l*(r-i)/a)])}const fe=Math.PI*2,ft=`
124
+ varying vec3 vColor; varying float vAlpha;
125
+ void main() {
126
+ float d = length(gl_PointCoord - .5) * 2.;
127
+ if (d > 1. || vAlpha < .001) discard;
128
+ gl_FragColor = vec4(vColor, (exp(-d*d*5.) + .25*exp(-d*d*35.)) * (1.-smoothstep(.7,1.,d)) * vAlpha);
129
+ }`,$=(u,e,t=ft)=>new L({uniforms:u,vertexShader:e,fragmentShader:t,transparent:!0,depthWrite:!1,blending:H}),z=(u,e)=>new I(u,e);class vt{group=new X;graph={nodes:[],edges:[],lanes:[],start:0,end:0};preferences={...Re};selected;indices=new Map;kinds=new Map;dust;energy;energyIndices=[];energyReveal;windBand;orbit;sparkGeometry;burstCursor=0;packets=[];messageXs=[];packetGeometry;time=0;wind=0;lastScrub=-1/0;pointerActive=!1;pointerAt=-1/0;visibleBirthsUntil=0;uniforms={uTime:{value:0},uPixelScale:{value:1e3},uPixelRatio:{value:1},uHeadX:{value:150},uViewport:{value:new O(1e3,600)},uPointer:{value:new O(3,3)},uPointerVelocity:{value:new O},uPointerStrength:{value:0},uHover:{value:new v},uHoverStrength:{value:0},uWind:{value:0},uWindX:{value:0},uTimeAxis:{value:new O(1,0)},uFlow:{value:0},uSpeed:{value:.5},uOpacity:{value:1},uSelectedIndex:{value:-1},uSelectedOnly:{value:0},uFocus:{value:0},uOrbitCenter:{value:new v},uOrbitRadius:{value:1},uOrbitColor:{value:new V},uOrbitBorn:{value:0}};configure(e){const t=e.quality!==this.preferences.quality;if(this.preferences={...e},t&&this.graph.nodes.length){const s=this.messageXs;this.setGraph(this.graph),this.messageXs=s}this.uniforms.uSpeed.value=e.trailSpeed/100,this.uniforms.uOpacity.value=e.trailOpacity/100,this.uniforms.uSelectedOnly.value=+(e.trails==="selected"),e.messageDots||(this.packets=[])}setGraph(e){if(this.disposeLayers(),this.graph=e,this.indices=new Map(e.nodes.map((h,c)=>[h.session.id,c])),this.kinds=new Map(e.edges.map(h=>[h.to,h.kind==="fork"?1:2])),this.burstCursor=0,this.visibleBirthsUntil=0,this.wind=0,this.lastScrub=-1/0,this.packets=[],this.messageXs=[],this.energyIndices=[],this.energyReveal=void 0,!e.nodes.length){this.select();return}const t=me[this.preferences.quality],s=new ne;for(const h of e.nodes)s.expandByPoint(new v(...h.position)),s.expandByPoint(new v(...h.startPosition));s.expandByVector(new v(18,18,24));const o=s.getSize(new v),i=s.getCenter(new v),r=[],a=[],n=[];for(let h=0;h<t.dust;h++){const c=e.nodes[Math.floor(P(`dust-lane${h}`)*(e.nodes.length-1))];r.push(s.min.x+P(`dust-x${h}`)*o.x,h%4?c.position[1]+(P(`dust-y${h}`)-.5)*34:s.min.y+P(`dust-y${h}`)*o.y,c.position[2]+(P(`dust-z${h}`)-.5)*65),a.push(P(`dust-seed${h}`)),n.push(...new V(c.color).toArray())}const l=new E;l.setAttribute("position",z(r,3)),l.setAttribute("seed",z(a,1)),l.setAttribute("tint",z(n,3)),this.dust=new U(l,$(this.uniforms,`
130
+ attribute float seed; attribute vec3 tint;
131
+ uniform float uTime,uPixelRatio,uPointerStrength,uHoverStrength,uWind,uWindX;
132
+ uniform vec2 uViewport,uPointer,uPointerVelocity,uTimeAxis; uniform vec3 uHover;
133
+ varying vec3 vColor; varying float vAlpha,vStretch; varying vec2 vAxis;
134
+ void main() {
135
+ vec3 p=position+vec3(sin(uTime*.14+seed*31.)*1.4,cos(uTime*.19+seed*19.)*1.6,sin(uTime*.12+seed*23.)*1.8);
136
+ float gust=exp(-abs(p.x-uWindX)/22.)*abs(uWind);
137
+ p.x+=uWind*gust*14.;
138
+ vec4 mv=modelViewMatrix*vec4(p,1.); vec4 clip=projectionMatrix*mv;
139
+ vec2 screen=clip.xy/max(.001,clip.w);
140
+ vec2 delta=(screen-uPointer)*uViewport*.5;
141
+ float influence=exp(-dot(delta,delta)/9000.)*uPointerStrength;
142
+ vec2 tangent=vec2(-delta.y,delta.x)/max(1.,length(delta));
143
+ clip.xy+=(tangent*influence*10.+uPointerVelocity*influence*26.)*2./uViewport*clip.w;
144
+ vec4 hover=projectionMatrix*modelViewMatrix*vec4(uHover,1.);
145
+ vec2 target=hover.xy/max(.001,hover.w);
146
+ vec2 hd=(screen-target)*uViewport*.5;
147
+ float attraction=exp(-dot(hd,hd)/7000.)*uHoverStrength;
148
+ float angle=uTime*(.5+seed*.5)+seed*62.;
149
+ vec2 orbit=target+vec2(cos(angle),sin(angle))*(17.+seed*22.)*2./uViewport;
150
+ clip.xy=mix(clip.xy,orbit*clip.w,attraction*.72);
151
+ gl_Position=clip;
152
+ vStretch=1.+gust*5.+influence*min(3.,length(uPointerVelocity)*2.);
153
+ vAxis=gust>.01?uTimeAxis:(length(uPointerVelocity)>.001?normalize(uPointerVelocity):vec2(1.,0.));
154
+ gl_PointSize=(1.3+seed*1.7)*uPixelRatio*vStretch;
155
+ vColor=mix(tint,vec3(.75,.91,1.),.4);
156
+ vAlpha=(.14+seed*.22)*(.72+.28*sin(uTime*.7+seed*62.))+gust*.2+attraction*.2;
157
+ }`,`
158
+ varying vec3 vColor; varying float vAlpha,vStretch; varying vec2 vAxis;
159
+ void main() {
160
+ vec2 p=(gl_PointCoord-.5)*2.;
161
+ vec2 q=vec2(dot(p,vAxis),dot(p,vec2(-vAxis.y,vAxis.x))*vStretch);
162
+ float d=length(q); if(d>1.) discard;
163
+ gl_FragColor=vec4(vColor,exp(-d*d*4.)*(1.-smoothstep(.65,1.,d))*vAlpha);
164
+ }`)),this.dust.name="interactive-stardust",this.dust.frustumCulled=!1,this.group.add(this.dust),this.windBand=new j(new he(1,1),$({...this.uniforms,uBandCenter:{value:i},uBandHeight:{value:o.y}},`
165
+ uniform float uWindX,uBandHeight; uniform vec3 uBandCenter; varying vec2 vUv;
166
+ void main(){vUv=uv;gl_Position=projectionMatrix*modelViewMatrix*vec4(uWindX+position.x*8.,uBandCenter.y+position.y*uBandHeight,uBandCenter.z,1.);}
167
+ `,`
168
+ uniform float uWind; varying vec2 vUv;
169
+ void main(){float a=exp(-abs(vUv.x-.5)*15.)*pow(max(0.,sin(vUv.y*3.14159)),.6)*abs(uWind)*.16;
170
+ gl_FragColor=vec4(.55,.86,1.,a);}
171
+ `)),this.windBand.name="scrub-time-wind",this.windBand.material.side=Z,this.windBand.frustumCulled=!1,this.group.add(this.windBand),this.createEnergy(t.trails),this.createBursts(t.bursts,t.sparks),this.createPackets(),this.createOrbit(),this.select(this.selected&&e.nodes.find(h=>h.session.id===this.selected.session.id))}createEnergy(e){const t=pe(this.graph.nodes.filter(c=>c.position[0]>c.startPosition[0]),e),s=[],o=[],i=[],r=[],a=[],n=[],l=[];for(const c of t)for(let d=0;d<6;d++)s.push(...c.startPosition),o.push(c.position[0]),i.push(c.radius),r.push(P(c.session.id)),a.push(...Y(c).toArray()),n.push(d,0,0),l.push(this.indices.get(c.session.id));const h=new E;for(const[c,d,p]of[["position",n,3],["origin",s,3],["endX",o,1],["radius",i,1],["seed",r,1],["tint",a,3],["nodeIndex",l,1]])h.setAttribute(c,z(d,p));this.energyIndices=l,this.energyReveal=z(new Float32Array(l.length),1),h.setAttribute("reveal",this.energyReveal),this.energy=new U(h,$(this.uniforms,`
172
+ attribute vec3 origin,tint; attribute float endX,radius,seed,reveal,nodeIndex;
173
+ uniform float uTime,uHeadX,uPixelScale,uFlow,uSpeed,uOpacity,uSelectedIndex,uSelectedOnly,uFocus;
174
+ varying vec3 vColor; varying float vAlpha;
175
+ void main(){
176
+ float head=clamp(uHeadX,origin.x,endX),span=max(0.,head-origin.x);
177
+ float t=fract(uTime*(.12+uSpeed*.23)+seed)-position.x*.014;
178
+ float distance=max(0.,t)*span;
179
+ float angle=distance*${ie}+seed*${fe};
180
+ float curl=(${ye}+radius*${be})*smoothstep(0.,${ee.toFixed(1)},distance);
181
+ vec3 p=vec3(origin.x+distance,origin.y+cos(angle)*curl,origin.z+sin(angle)*curl);
182
+ vec4 mv=modelViewMatrix*vec4(p,1.);gl_Position=projectionMatrix*mv;
183
+ float selected=1.-step(.5,abs(nodeIndex-uSelectedIndex));
184
+ float allowed=mix(1.,selected,uSelectedOnly)*mix(1.,mix(.1,1.,selected),uFocus);
185
+ gl_PointSize=clamp((.1+radius*.12)*uPixelScale/max(.1,-mv.z),1.5,5.5)*(1.-position.x*.09);
186
+ vColor=mix(tint,vec3(1.),.42)*(1.35-position.x*.09);
187
+ vAlpha=step(.01,span)*step(0.,t)*smoothstep(0.,.08,t)*smoothstep(0.,.05,1.-t)*exp(-position.x*.55)*reveal*uFlow*uOpacity*allowed;
188
+ }`)),this.energy.name="trail-energy-packets",this.energy.frustumCulled=!1,this.group.add(this.energy)}createBursts(e,t){const s=new E;for(const[i,r]of[["position",3],["origin",3],["tint",3],["born",1],["kind",1]]){const a=new Float32Array(e*t*r);i==="born"&&a.fill(-1e3),s.setAttribute(i,z(a,r).setUsage(D))}for(let i=0;i<e*t;i++){const r=P(`birth-angle${i}`)*fe,a=P(`birth-depth${i}`)*2-1;s.getAttribute("position").setXYZ(i,Math.cos(r)*Math.sqrt(1-a*a),Math.sin(r)*Math.sqrt(1-a*a),a)}this.sparkGeometry=s;const o=new U(s,$(this.uniforms,`
189
+ attribute vec3 origin,tint;attribute float born,kind;
190
+ uniform float uTime,uPixelScale,uHeadX;varying vec3 vColor;varying float vAlpha;
191
+ void main(){
192
+ float age=uTime-born;vec3 direction=position;
193
+ if(age<0. || age>1.2 || origin.x>uHeadX){vAlpha=0.;vColor=tint;gl_PointSize=1.;gl_Position=vec4(2.,2.,2.,1.);return;}
194
+ if(kind>.5 && kind<1.5)direction=vec3(abs(position.x)*.8+.35,sign(position.y)*(.6+abs(position.y)),position.z*.35);
195
+ float distance=(1.-exp(-max(0.,age)*3.))*(2.2+kind*1.7);
196
+ vec3 p=origin+direction*distance;p.y-=max(0.,age)*max(0.,age)*.5;
197
+ vec4 mv=modelViewMatrix*vec4(p,1.);gl_Position=projectionMatrix*mv;
198
+ gl_PointSize=clamp(.15*uPixelScale/max(.1,-mv.z),1.5,5.);
199
+ vColor=mix(tint,vec3(1.),.38)*1.35;
200
+ vAlpha=step(0.,age)*pow(max(0.,1.-age/1.2),2.)*.8;
201
+ }`));o.name="fork-bloom-sparks",o.frustumCulled=!1,this.group.add(o)}births(e,t){if(!this.sparkGeometry||!e.length)return;const s=this.sparkGeometry,o=me[this.preferences.quality],i=pe(e.filter(a=>this.kinds.has(a.session.id)),Math.ceil(o.bursts/2)),r=[...i,...pe(e.filter(a=>!this.kinds.has(a.session.id)),o.bursts-i.length)];for(const a of r){const n=this.burstCursor++%o.bursts,l=this.kinds.get(a.session.id)||0,h=Y(a).lerp(new V(l===1?"#ffc891":"#c3b0ff"),l?.35:0),c=G(a,Math.max(a.startPosition[0],Math.min(this.uniforms.uHeadX.value,a.position[0]))),d=n*o.sparks;for(let p=d;p<d+o.sparks;p++)s.getAttribute("origin").setXYZ(p,...c),s.getAttribute("tint").setXYZ(p,h.r,h.g,h.b),s.getAttribute("born").setX(p,t),s.getAttribute("kind").setX(p,l)}for(const a of["origin","tint","born","kind"])s.getAttribute(a).needsUpdate=!0;this.visibleBirthsUntil=t+1.2}createPackets(){this.packetGeometry=new E,this.packetGeometry.setAttribute("position",z(new Float32Array(192),3).setUsage(D)),this.packetGeometry.setAttribute("alpha",z(new Float32Array(64),1).setUsage(D)),this.packetGeometry.setDrawRange(0,0);const e=new U(this.packetGeometry,$(this.uniforms,`
202
+ attribute float alpha;uniform float uPixelScale;uniform vec3 uOrbitColor;varying vec3 vColor;varying float vAlpha;
203
+ void main(){vec4 mv=modelViewMatrix*vec4(position,1.);gl_Position=projectionMatrix*mv;
204
+ gl_PointSize=clamp(.2*uPixelScale/max(.1,-mv.z),2.,7.);vColor=mix(uOrbitColor,vec3(1.),.6)*1.6;vAlpha=alpha;}
205
+ `));e.name="recorded-message-packets",e.frustumCulled=!1,this.group.add(e)}createOrbit(){this.orbit=new X,this.orbit.name="selection-solar-system";const e=`
206
+ uniform float uTime,uPixelScale,uPixelRatio,uOrbitRadius,uOrbitBorn;
207
+ uniform vec3 uOrbitCenter,uOrbitColor;
208
+ varying vec3 vColor;varying float vAlpha;
209
+ vec2 orbit(float angle,float ring){
210
+ vec2 p=vec2(cos(angle),sin(angle)*mix(.5,.7,ring))*(1.+ring*.26);
211
+ float tilt=mix(.45,-.65,ring)+uTime*.06;
212
+ return mat2(cos(tilt),sin(tilt),-sin(tilt),cos(tilt))*p;
213
+ }
214
+ float orbitSize(vec4 mv){return max(uOrbitRadius,-mv.z/uPixelScale*uPixelRatio*14.);}
215
+ `;for(let i=0;i<2;i++){const r=new j(new Fe(.985,1,96),$(this.uniforms,`${e}
216
+ void main(){
217
+ vec4 mv=modelViewMatrix*vec4(uOrbitCenter,1.);
218
+ float angle=atan(position.y,position.x);
219
+ mv.xy+=orbit(angle,${i.toFixed(1)})*length(position.xy)*orbitSize(mv);
220
+ gl_Position=projectionMatrix*mv;
221
+ vColor=uOrbitColor;vAlpha=.24*smoothstep(0.,.4,uTime-uOrbitBorn);
222
+ }`,"varying vec3 vColor;varying float vAlpha;void main(){gl_FragColor=vec4(vColor,vAlpha);}"));r.material.side=Z,r.frustumCulled=!1,this.orbit.add(r)}const t=new E,s=[];for(let i=0;i<6;i++)for(let r=0;r<5;r++)s.push(i/3*fe,i%2,r);t.setAttribute("position",z(s,3));const o=new U(t,$(this.uniforms,`${e}
223
+ void main(){
224
+ float angle=position.x+uTime*mix(.8,-.6,position.y)-position.z*.07*mix(1.,-1.,position.y);
225
+ vec4 mv=modelViewMatrix*vec4(uOrbitCenter,1.);
226
+ mv.xy+=orbit(angle,position.y)*orbitSize(mv);gl_Position=projectionMatrix*mv;
227
+ gl_PointSize=(3.5-position.z*.45)*uPixelRatio;
228
+ vColor=mix(uOrbitColor,vec3(1.),.5);vAlpha=exp(-position.z*.6)*smoothstep(0.,.4,uTime-uOrbitBorn);
229
+ }`));o.frustumCulled=!1,this.orbit.add(o),this.group.add(this.orbit)}select(e){this.selected=e,this.messageXs=[],this.packets=[],this.uniforms.uSelectedIndex.value=e?this.indices.get(e.session.id)??-1:-1,this.uniforms.uOrbitBorn.value=this.time,e&&this.uniforms.uOrbitColor.value.copy(Y(e))}events(e){this.messageXs=this.selected?e.filter(t=>le(t)&&t.time!==null&&t.timeSource!=="unknown").map(t=>te(t.time,this.graph)).filter(t=>t>=this.selected.startPosition[0]&&t<=this.selected.position[0]).sort((t,s)=>t-s):[]}seek(e,t,s,o){if(this.uniforms.uHeadX.value=t,o&&(this.wind=mt(e,t,Number.isFinite(this.lastScrub)?this.time-this.lastScrub:1/30,Math.max(1,B(1,this.graph)-B(0,this.graph))),this.lastScrub=this.time,this.uniforms.uWindX.value=t),t<e&&(this.packets=[]),s&&this.preferences.messageDots&&this.selected){for(const i of pt(this.messageXs,e,t))this.packets.push({x:i,born:this.time});this.packets=this.packets.slice(-8)}}pointer(e,t,s,o){const i=new O(e/s*2-1,1-t/o*2),r=i.clone().sub(this.uniforms.uPointer.value).multiplyScalar(12);this.pointerActive||r.set(0,0),r.clampLength(0,1.5),this.uniforms.uPointerVelocity.value.copy(r),this.uniforms.uPointer.value.copy(i),this.pointerActive=!0,this.pointerAt=this.time}leave(){this.pointerActive=!1}update(e,t,s,o,i){this.time=e,this.group.visible=i.motion&&!i.suspended&&this.graph.nodes.length>0,this.uniforms.uTime.value=e,this.uniforms.uPixelScale.value=i.pixelScale,this.uniforms.uPixelRatio.value=i.pixelRatio,this.uniforms.uViewport.value.set(i.width,i.height),this.uniforms.uPointerStrength.value=k.damp(this.uniforms.uPointerStrength.value,Number(this.pointerActive),7,t),e-this.pointerAt>.03&&this.uniforms.uPointerVelocity.value.multiplyScalar(Math.exp(-t*6)),this.uniforms.uHoverStrength.value=k.damp(this.uniforms.uHoverStrength.value,+!!i.hoverCenter,8,t),i.hoverCenter&&this.uniforms.uHover.value.fromArray(i.hoverCenter),this.wind*=Math.exp(-t*4.5),this.uniforms.uWind.value=this.wind;const r=s.matrixWorldInverse.elements;this.uniforms.uTimeAxis.value.set(r[0],r[1]),this.uniforms.uTimeAxis.value.lengthSq()<1e-4?this.uniforms.uTimeAxis.value.set(1,0):this.uniforms.uTimeAxis.value.normalize();const a=i.playing||this.preferences.trailFlow;if(this.uniforms.uFlow.value=Number(a),this.uniforms.uFocus.value=Number(this.preferences.focusDimming&&!!this.selected&&!i.playing),this.dust&&(this.dust.visible=this.preferences.stars),this.windBand&&(this.windBand.visible=Math.abs(this.wind)>.005),this.energy&&(this.energy.visible=this.preferences.trails!=="off"&&a),this.energyReveal){let l=!1;this.energyIndices.forEach((h,c)=>{const d=o[h]||0;this.energyReveal.getX(c)!==d&&(this.energyReveal.setX(c,d),l=!0)}),l&&(this.energyReveal.needsUpdate=!0)}this.orbit&&(this.orbit.visible=!!i.selectedCenter),i.selectedCenter&&this.selected&&(this.uniforms.uOrbitCenter.value.fromArray(i.selectedCenter),this.uniforms.uOrbitRadius.value=this.selected.radius*this.preferences.nodeScale/100*2.7),this.packets=this.packets.filter(l=>e-l.born<1.15);let n=0;if(this.packetGeometry&&this.selected&&this.preferences.messageDots&&i.selectedCenter)for(const l of this.packets)for(let h=0;h<8;h++){const c=e-l.born-h*.018,d=Math.max(0,Math.min(1,c/.75)),p=Math.min(this.uniforms.uHeadX.value,this.selected.position[0]),y=Math.max(this.selected.startPosition[0],Math.min(p,l.x+(p-l.x)*d));this.packetGeometry.getAttribute("position").setXYZ(n,...G(this.selected,y)),this.packetGeometry.getAttribute("alpha").setX(n++,c<0?0:Math.exp(-h*.35)*Math.max(0,1-c/1.15))}return this.packetGeometry&&(this.packetGeometry.setDrawRange(0,n),this.packetGeometry.getAttribute("position").needsUpdate=!0,this.packetGeometry.getAttribute("alpha").needsUpdate=!0),this.group.visible&&(this.preferences.stars||a&&this.preferences.trails!=="off"||!!i.selectedCenter||Math.abs(this.wind)>.005||e<this.visibleBirthsUntil||this.packets.length>0)}reset(){this.packets=[],this.wind=0,this.lastScrub=-1/0,this.visibleBirthsUntil=0,this.leave();const e=this.sparkGeometry?.getAttribute("born");e&&(e.array.fill(-1e3),e.needsUpdate=!0)}dispose(){this.disposeLayers(),this.energyIndices=[],this.packets=[],this.messageXs=[]}diagnostics(){return{enabled:this.group.visible,dust:this.dust?.geometry.getAttribute("position").count||0,energyParticles:this.energyIndices.length,burstSlots:me[this.preferences.quality].bursts,messagePackets:this.packets.length,wind:this.wind,orbit:!!this.orbit?.visible}}disposeLayers(){this.group.traverse(e=>{const t=e;t.geometry?.dispose(),t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(s=>s.dispose())}),this.group.clear(),this.dust=void 0,this.energy=void 0,this.windBand=void 0,this.orbit=void 0,this.sparkGeometry=void 0,this.packetGeometry=void 0}}function gt(u,e,t=72){const s=u.right-u.left,o=u.bottom-u.top,i={left:Math.min(16,s/4),right:s-Math.min(16,s/4),top:Math.min(t,o/4),bottom:o-Math.min(24,o/4)};let r=[i];for(const h of e){const c={left:h.left-u.left-20,right:h.right-u.left+20,top:h.top-u.top-20,bottom:h.bottom-u.top+20};r=r.flatMap(d=>c.right<=d.left||c.left>=d.right||c.bottom<=d.top||c.top>=d.bottom?[d]:[{...d,right:Math.min(d.right,c.left)},{...d,left:Math.max(d.left,c.right)},{...d,bottom:Math.min(d.bottom,c.top)},{...d,top:Math.max(d.top,c.bottom)}].filter(p=>p.right>p.left&&p.bottom>p.top))}const a=h=>(h.right-h.left)*(h.bottom-h.top),n=r.filter(h=>h.right-h.left>=120&&h.bottom-h.top>=100),l=(n.length?n:r).sort((h,c)=>a(c)-a(h))[0]??i;return{x:(l.left+l.right)/2,y:(l.top+l.bottom)/2,width:l.right-l.left,height:l.bottom-l.top}}class Se{constructor(e=48){this.cellSize=e}cellSize;cells=new Map;clear(){this.cells.clear()}add(e,t,s,o,i,r){if(![t,s,o].every(Number.isFinite)||t+o<0||s+o<0||t-o>i||s-o>r)return;const a=Math.floor(Math.max(0,t-o)/this.cellSize),n=Math.floor(Math.min(i,t+o)/this.cellSize),l=Math.floor(Math.max(0,s-o)/this.cellSize),h=Math.floor(Math.min(r,s+o)/this.cellSize);for(let c=l;c<=h;c++)for(let d=a;d<=n;d++){const p=`${d}:${c}`,y=this.cells.get(p);y?y.push(e):this.cells.set(p,[e])}}at(e,t){return this.cells.get(`${Math.floor(e/this.cellSize)}:${Math.floor(t/this.cellSize)}`)||[]}}function yt(u){return Qe(u.kind==="commit"?"git-commit":u.role==="user"?"user":"bot")}const q=-105,J=70;function W(u){u.traverse(e=>{const t=e;e instanceof ae&&e.dispose(),t.geometry?.dispose(),t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(o=>o.dispose())}),u.clear()}class wt{constructor(e,t,s={}){this.container=e,this.options=s,this.onSelect=t.onSelect,this.onHover=t.onHover,this.onEvent=t.onEvent,this.onEventHover=t.onEventHover,this.renderer=new Ge({antialias:!1,alpha:!0,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(Math.max(devicePixelRatio,1.5),2)),this.renderer.localClippingEnabled=!0,this.renderer.setClearColor(new V().setRGB(.001,.0017,.0024),1),this.renderer.toneMapping=Ue,this.renderer.toneMappingExposure=1.05,this.renderer.domElement.setAttribute("aria-label","Interactive 3D session timeline. Drag to orbit, scroll to zoom. Sessions are also available in the list."),this.renderer.domElement.tabIndex=0,e.append(this.renderer.domElement),this.labelLayer=document.createElement("div"),this.labelLayer.className="scene-labels",this.labelLayer.dataset.motion=String(this.motion),e.append(this.labelLayer),this.controls=new Oe(this.camera,this.renderer.domElement),this.controls.enableDamping=!0,this.controls.dampingFactor=.065,this.controls.rotateSpeed=.5,this.controls.zoomSpeed=.8,this.controls.addEventListener("change",()=>{this.cameraDirty=!0}),this.controls.addEventListener("start",()=>{this.targetPosition=void 0,this.targetLook=void 0,this.focusedSession=null,this.playing&&t.onPlaybackInterrupt()}),this.camera.position.set(20,70,320),this.scene.add(this.graphGroup,this.selectionGroup,this.filesGroup,this.particles.group);const o=Math.min(2,this.renderer.capabilities.maxSamples),i=new Ae(1,1,{type:Ce,depthBuffer:o===0});this.composer=new ze(this.renderer,i),this.scenePass=new st(this.scene,this.camera),this.scenePass.setSamples(o),this.composer.addPass(this.scenePass),this.bloom=new Xe(new O(1,1),.23,.4,.9);for(const a of[this.bloom.renderTargetBright,...this.bloom.renderTargetsHorizontal,...this.bloom.renderTargetsVertical])a.depthBuffer=!1;this.composer.addPass(this.bloom),this.smaa=new Le,this.composer.addPass(this.smaa),this.composer.addPass(new He);const r=this.smaa;for(const a of[r._areaTexture??r.areaTexture,r._searchTexture??r.searchTexture])a?.image?.addEventListener("load",()=>{this.dirty=!0},{once:!0});this.addStars(),this.resizeObserver=new ResizeObserver(()=>this.resize()),this.resizeObserver.observe(e),this.renderer.domElement.addEventListener("pointermove",this.pointerMove),this.renderer.domElement.addEventListener("pointerdown",this.pointerStart),this.renderer.domElement.addEventListener("pointerup",this.pointerEnd),this.renderer.domElement.addEventListener("pointercancel",()=>{this.pointerID=null}),this.renderer.domElement.addEventListener("pointerleave",this.pointerLeave),this.renderer.domElement.addEventListener("webglcontextlost",this.contextLost),this.resize(),s.manual||this.animate()}container;options;renderer;scene=new _e;camera=new Ve(45,1,.1,2500);controls;composer;scenePass;bloom;smaa;dirty=!0;cameraDirty=!0;cameraSettlesAt=0;graphGroup=new X;selectionGroup=new X;filesGroup=new X;labels=[];labelLayer;graph={nodes:[],edges:[],lanes:[],start:0,end:0};nodeMesh;nodeByID=new Map;nodeIndices=new Map;focusUniforms={uSelected:{value:-1},uHovered:{value:-1},uFocus:{value:0},uFamilyTime:{value:0}};familyDepth;familyGlowDepth;selectionBorn=0;particles=new vt;raycaster=new Ne;nodeGrid=new Se;markerGrid=new Se;pickingDirty=!0;pickingView=new se;pickingProjection=new se;pickMesh;pickMatrix=new se;pickHits=[];width=1;height=1;pointer=new O;pointerDown=new O;pointerID=null;pointerDragged=!1;selected=null;hovered=null;cutoff=1;clipPlane=new $e(new v(-1,0,0),151);motion=!matchMedia("(prefers-reduced-motion: reduce)").matches;suspended=!1;frame=0;resizeObserver;targetPosition;targetLook;playing=!1;playbackPath;playbackRadii=[];playbackSphere=new We;playbackFocus=new v;playbackOffset=new v;playbackOutro=null;playbackOrbit;playbackYawSpeed=0;glowMaterial;glowPositions;time=0;previousFrame=performance.now();nodeReveal=new Float32Array;nodeBorn=new Float64Array;arrivals;comets;selectedComets;links;selectedLinks;headDirection=new v;revealAttribute;revealsActive=!1;graphBorn=0;fileMesh;eventMarkers=[];selectedEvent=null;focusedEvent;focusedSession=null;eventIcons=[];iconPoint=new v;markerUniforms={uPixelRatio:{value:1},uSelected:{value:-1},uHovered:{value:-1}};fileOffsets=[];fileOrigin=new v;fileBorn=0;fileUniforms={uTime:{value:0},uBorn:{value:0},uMotion:{value:1},uOrigin:{value:new v}};lineUniforms={uCutoff:{value:160},uReveal:{value:1}};preferences={...Re};trailUniforms={uTrailTime:{value:0},uTrailFlow:{value:0},uTrailSpeed:{value:.5},uTrailOpacity:{value:1}};cometUniforms={uHeadX:{value:150},uPixelScale:{value:1e3},uNodeScale:{value:1}};stars;transform=new ue;onSelect;onHover;onEvent;onEventHover;contextLost=e=>{e.preventDefault(),this.container.dispatchEvent(new CustomEvent("scene-error",{detail:"The graphics context was lost. Reload to restore the 3D view; the session list is still available."}))};addStars(){const e=[];for(let s=0;s<280;s++)e.push((P(`sx${s}`)-.5)*1100,(P(`sy${s}`)-.5)*700,-120-P(`sz${s}`)*500);const t=new E;t.setAttribute("position",new I(e,3)),this.stars=new U(t,new je({color:"#7b9fa9",size:.4,transparent:!0,opacity:.18,sizeAttenuation:!0})),this.scene.add(this.stars)}applyPreferences(e){const t=this.preferences;this.preferences={...e},this.particles.configure(e);const s=Je(e,matchMedia("(prefers-reduced-motion: reduce)").matches);if(s!==this.motion&&this.setMotion(s),e.quality!==t.quality){const i=e.quality==="performance"?0:Math.min(e.quality==="high"?4:2,this.renderer.capabilities.maxSamples);this.scenePass.setSamples(i);for(const r of[this.composer.renderTarget1,this.composer.renderTarget2])r.depthBuffer=i===0,r.dispose();this.smaa.enabled=e.quality!=="performance",this.resize()}this.bloom.strength=e.bloom/100,this.bloom.enabled=e.quality!=="performance"&&e.bloom>0,this.stars&&(this.stars.visible=e.stars),this.labelLayer.hidden=!e.labels,this.trailUniforms.uTrailOpacity.value=e.trailOpacity/42,this.trailUniforms.uTrailSpeed.value=e.trailSpeed/100,this.cometUniforms.uNodeScale.value=e.nodeScale/100;for(const i of[this.graphGroup,this.selectionGroup])for(const r of i.children)r.userData.kind==="lifetime"&&(r.visible=e.trails==="all"||e.trails==="selected"&&i===this.selectionGroup),r.userData.kind==="relationship"&&(r.visible=e.relationships);const o=this.selectionGroup.getObjectByName("event-markers");o&&(o.visible=e.messageDots),this.nodeMesh&&t.nodeScale!==e.nodeScale&&(this.nodeMesh.boundingSphere=null,this.revealsActive=!0),t.messageDots!==e.messageDots&&(this.revealsActive=!0),this.dirty=!0}setGraph(e,t=!1,s=!1){const o=s?new Map(this.graph.nodes.map((f,w)=>[f.session.id,this.nodeBorn[w]])):void 0;if(this.pickingDirty=!0,this.dirty=!0,W(this.graphGroup),W(this.selectionGroup),W(this.filesGroup),this.eventMarkers=[],this.eventIcons=[],this.fileMesh=void 0,this.fileOffsets=[],this.labels=[],this.labelLayer.replaceChildren(),this.graph=e,this.particles.setGraph(e),(!s||!this.playing)&&(this.playbackPath=void 0,this.playbackRadii=[]),this.nodeByID=new Map(e.nodes.map(f=>[f.session.id,f])),this.nodeIndices=new Map(e.nodes.map((f,w)=>[f.session.id,w])),this.focusUniforms.uSelected.value=this.selected?this.nodeIndices.get(this.selected)??-1:-1,this.focusUniforms.uHovered.value=-1,this.hovered=null,this.nodeMesh=void 0,this.pickMesh=void 0,this.glowMaterial=void 0,this.glowPositions=void 0,this.arrivals=void 0,this.links=void 0,this.selectedLinks=void 0,this.comets=void 0,this.selectedComets=void 0,this.graphBorn=s?this.time-1:this.time,this.nodeBorn=Float64Array.from(e.nodes,f=>o?.get(f.session.id)??NaN),this.nodeReveal=new Float32Array(e.nodes.length),this.revealsActive=this.motion&&e.nodes.length>0,this.familyDepth=void 0,this.familyGlowDepth=void 0,!e.nodes.length)return;const i=new qe(1,32,20),r=Float32Array.from(e.nodes,(f,w)=>w);i.setAttribute("nodeIndex",new F(r,1));const a=new Float32Array(e.nodes.length).fill(-1);this.familyDepth=new F(a,1).setUsage(D),i.setAttribute("familyDepth",this.familyDepth);const n=new ae(i,at(this.focusUniforms),e.nodes.length);n.instanceMatrix.setUsage(D),n.frustumCulled=!1;const l=new ue,h=[],c=[],d=[];e.nodes.forEach((f,w)=>{l.position.fromArray(f.position),l.scale.setScalar(f.radius*this.preferences.nodeScale/100),l.updateMatrix(),n.setMatrixAt(w,l.matrix);const S=Y(f);n.setColorAt(w,S),h.push(...f.position),c.push(...S.toArray()),d.push(f.radius*11)}),n.instanceMatrix.needsUpdate=!0,n.computeBoundingSphere(),this.nodeMesh=n,this.pickMesh=new j(i,n.material),this.graphGroup.add(n);const p=new E;this.glowPositions=new I(h,3).setUsage(D),p.setAttribute("position",this.glowPositions),p.setAttribute("color",new I(c,3)),p.setAttribute("size",new I(d,1)),p.setAttribute("nodeIndex",new re(r,1)),this.familyGlowDepth=new re(a,1).setUsage(D),p.setAttribute("familyDepth",this.familyGlowDepth),this.revealAttribute=new re(this.nodeReveal,1).setUsage(D),p.setAttribute("reveal",this.revealAttribute),this.glowMaterial=new L({uniforms:{...this.focusUniforms,uCutoff:{value:151},uScale:{value:this.container.clientHeight*this.renderer.getPixelRatio()*.9},uGlowSize:{value:1},uGlowIntensity:{value:1}},vertexShader:`${Te}
230
+ attribute float size; attribute float reveal; varying vec3 vColor; varying float vVisible; uniform float uScale; uniform float uCutoff; uniform float uGlowSize;
231
+ void main() { vColor = color; vVisible = reveal; vNodeEmphasis = nodeEmphasis(); vec4 mv = modelViewMatrix * vec4(position, 1.0);
232
+ gl_PointSize = clamp(size * uGlowSize * uScale / max(.1,-mv.z), 2.0, 100.0); gl_Position = projectionMatrix * mv; }`,fragmentShader:`varying vec3 vColor; varying float vVisible; varying float vNodeEmphasis; uniform float uGlowIntensity;
233
+ void main() { float d = length(gl_PointCoord - .5) * 2.0; if (d > 1.0) discard;
234
+ float a = pow(max(0., 1.0 - d), 3.1) * .34 * uGlowIntensity * vVisible * vNodeEmphasis; gl_FragColor = vec4(vColor * 1.15, a); }`,vertexColors:!0,transparent:!0,depthWrite:!1,blending:H});const y=new U(p,this.glowMaterial);y.frustumCulled=!1,this.graphGroup.add(y),this.arrivals=ut(e.nodes,this.glowPositions.array,this.nodeReveal,{...this.focusUniforms,...this.cometUniforms,uPixelRatio:this.markerUniforms.uPixelRatio}),this.graphGroup.add(this.arrivals.mesh),this.comets=this.addComets(e.nodes,this.graphGroup),e.lanes.forEach((f,w)=>{const S=Math.min(...f.nodes.map(A=>A.startPosition[0]));w<12&&this.addLabel(f.label,new v(S-4,f.y+8,f.z),f.color)}),this.links=this.addForks(e.edges,this.graphGroup);const M=[],g=[],b=nt(e),m=new V("#314149"),R=b.length>1?b.map(f=>f.x):Array.from({length:9},(f,w)=>B(w/8,e));for(const f of R)this.appendSegments([new v(f,q,-J),new v(f,q,J)],m,M,g);for(const{x:f,label:w}of b)b.length===1&&f!==R[0]&&this.appendSegments([new v(f,q,-J),new v(f,q,J)],m,M,g),this.addLabel(w,new v(f,q,J),"#9ab9b3",!1,!0);this.addLines(M,g,.23),this.setCutoff(this.cutoff),this.selected&&this.select(this.selected),t&&this.reset()}appendSegments(e,t,s,o){for(let i=1;i<e.length;i++)s.push(...e[i-1].toArray(),...e[i].toArray()),o.push(t.r,t.g,t.b,t.r,t.g,t.b)}addComets(e,t){const s=t===this.selectionGroup,o=lt(e,{...this.trailUniforms,...this.cometUniforms,uGraphReveal:this.lineUniforms.uReveal,uContextFocus:s?{value:0}:this.focusUniforms.uFocus},this.nodeIndices,s);return o.group.visible=this.preferences.trails==="all"||s&&this.preferences.trails==="selected",o.update(this.nodeReveal),t.add(o.group),o}drawnRadius(e){const t=this.nodeReveal[this.nodeIndices.get(e.session.id)]??1;return e.radius*this.preferences.nodeScale/100*t}orbCenter(e){const t=B(this.cutoff,this.graph),s=oe(e,t)[0],o=G(e,s),i=this.camera.matrixWorldInverse.elements,r=-(i[2]*o[0]+i[6]*o[1]+i[10]*o[2]+i[14]),a=Math.max(.001,r)*2*Math.tan(k.degToRad(this.camera.fov/2))/(this.height*this.camera.zoom),n=this.selected===e.session.id&&this.preferences.messageDots?Math.max(.06,a*8):.02,l=ke(e,s),h=i[0]*l[0]+i[4]*l[1]+i[8]*l[2],c=i[1]*l[0]+i[5]*l[1]+i[9]*l[2],d=this.headDirection.set(h,c,0);d.lengthSq()<1e-4&&d.set(1,0,0),d.normalize().applyQuaternion(this.camera.quaternion);const p=et(e,t,this.drawnRadius(e),n,d.toArray());return p[1]+=o[1]-e.position[1],p[2]+=o[2]-e.position[2],p}buildPlaybackPath(){if(this.playbackPath=void 0,this.playbackRadii=[],!this.graph.nodes.length)return;const e=this.graph.nodes.flatMap(i=>[new v(...i.position),new v(...i.startPosition)]),t=new ne().setFromPoints(e).getBoundingSphere(new de),s=[],o=Math.max(1,B(1,this.graph)-B(0,this.graph));for(let i=0;i<=100;i++){const r=i/100,a=B(r,this.graph),n=new v,l=new ne;let h=0;for(const y of this.graph.nodes){if(y.startPosition[0]>a)continue;const M=new v(...G(y,oe(y,a)[0])),g=(M.x-a)*300/o,b=Math.exp(-(((g+6)/24)**2));n.addScaledVector(M,b),h+=b,g>=-38&&g<=12&&l.expandByPoint(M)}h>0?n.divideScalar(h):n.copy(t.center);const c=l.isEmpty()?new de(n,0):l.getBoundingSphere(new de),d=Math.max(50,c.radius+c.center.distanceTo(n)),p=k.smoothstep(r,.86,1);n.lerp(t.center,p),s.push(n),this.playbackRadii.push(k.lerp(d,t.radius+20,p))}this.playbackPath=new Ye(s)}setPlaying(e){this.playing!==e&&(this.playing=e,this.playbackOutro=null,this.playbackOrbit=void 0,this.playbackYawSpeed=0,e||(this.playbackPath=void 0,this.playbackRadii=[],this.camera.clearViewOffset()),e&&(this.focusedSession=null,this.camera.clearViewOffset()),e&&this.cutoff===0&&(this.nodeBorn.fill(NaN),this.nodeReveal.fill(0),this.revealsActive=!0),e&&this.motion&&(this.playbackPath||this.buildPlaybackPath(),this.targetPosition=void 0,this.targetLook=void 0,this.playbackSphere.setFromVector3(this.camera.position.clone().sub(this.controls.target)),this.framePlayback()),this.dirty=!0)}setPlaybackOutro(e){const t=e===null?null:k.clamp(e,0,1);t!==this.playbackOutro&&(t!==null&&this.playbackOutro===null&&(this.playbackSphere.setFromVector3(this.camera.position.clone().sub(this.controls.target)),this.playbackOrbit={theta:this.playbackSphere.theta,phi:this.playbackSphere.phi,radius:this.playbackSphere.radius,focus:this.controls.target.clone(),incomingTurnsPerSecond:this.playbackYawSpeed/(2*Math.PI)}),t===null&&(this.playbackOrbit=void 0),this.playbackOutro=t,this.dirty=!0)}animatePlaybackCamera(e){if(!this.playing||!this.motion||!this.playbackPath)return!1;const t=k.degToRad(this.camera.fov)/2,s=Math.min(t,Math.atan(Math.tan(t)*this.camera.aspect));if(this.playbackOutro!==null&&this.playbackOrbit){const p=this.playbackOrbit,y=this.playbackOutro;return this.playbackSphere.theta=p.theta+tt(y,p.incomingTurnsPerSecond)*Math.PI*2,this.playbackSphere.phi=p.phi,this.playbackSphere.radius=p.radius,this.controls.target.copy(p.focus),this.playbackFocus.copy(this.controls.target),this.camera.position.copy(this.controls.target).add(this.playbackOffset.setFromSpherical(this.playbackSphere)),!0}this.playbackPath.getPoint(this.cutoff,this.playbackFocus);const o=this.cutoff*(this.playbackRadii.length-1),i=Math.floor(o),r=Math.min(i+1,this.playbackRadii.length-1),a=k.lerp(this.playbackRadii[i],this.playbackRadii[r],o-i),n=k.clamp(a/Math.sin(s)*.84,110,1100),l=-.3+this.cutoff*Math.PI,h=.16+Math.sin(this.cutoff*Math.PI)*.12,d=Math.atan2(Math.sin(l-this.playbackSphere.theta),Math.cos(l-this.playbackSphere.theta))*-Math.expm1(-3*e);return this.playbackSphere.theta+=d,e>0&&(this.playbackYawSpeed=d/e),this.playbackSphere.phi=k.damp(this.playbackSphere.phi,Math.PI/2-h,1.5,e),this.playbackSphere.radius=k.damp(this.playbackSphere.radius,n,1.25,e),this.controls.target.lerp(this.playbackFocus,1-Math.exp(-2.1*e)),this.camera.position.copy(this.controls.target).add(this.playbackOffset.setFromSpherical(this.playbackSphere)),!0}addLines(e,t,s,o=this.graphGroup,i="grid",r){if(!e.length)return;const a=new E;a.setAttribute("position",new I(e,3)),a.setAttribute("color",new I(t,3)),r&&a.setAttribute("timelineTime",new I(r,1));const n=new Ze({vertexColors:!0,transparent:!0,opacity:s,depthWrite:!1,blending:H,clippingPlanes:i==="grid"?[this.clipPlane]:[]});o!==this.filesGroup&&(n.onBeforeCompile=h=>{h.uniforms.uTimelineCutoff=this.lineUniforms.uCutoff,h.uniforms.uGraphReveal=this.lineUniforms.uReveal,h.uniforms.uContextFocus=o===this.graphGroup?this.focusUniforms.uFocus:{value:0},h.vertexShader=`${r?"attribute float timelineTime;":""} varying float vTimelineX;
235
+ ${h.vertexShader}`.replace("#include <begin_vertex>",`#include <begin_vertex>
236
+ vTimelineX = ${r?"timelineTime":"position.x"};`),h.fragmentShader=`varying float vTimelineX; uniform float uTimelineCutoff; uniform float uGraphReveal; uniform float uContextFocus;
237
+ ${h.fragmentShader}`.replace("#include <color_fragment>",`#include <color_fragment>
238
+ diffuseColor.a *= ${r?"step(vTimelineX, uTimelineCutoff)":"smoothstep(0.0, .6, uTimelineCutoff - vTimelineX)"} * uGraphReveal * mix(1.0, .16, uContextFocus);`)}),n.customProgramCacheKey=()=>i;const l=new we(a,n);l.userData.kind=i,l.visible=i!=="relationship"||this.preferences.relationships,o.add(l)}edgeCurve(e,t){const s=new v(...e),o=new v(...t),i=Math.max(Math.abs(t[0]-e[0])*.55,Math.min(14,s.distanceTo(o)*.45),2);return new Me(s,new v(e[0]+i,e[1],e[2]),new v(t[0]-i,t[1],t[2]),o)}branchCurve(e,t,s){const[o,i]=it(e,t),r=G(e,o[0]),a=G(t,i[0]);if(s==="child"){const n=new v(...r),l=new v(...a);return new Me(n,n.clone().lerp(l,1/3),n.clone().lerp(l,2/3),l)}return this.edgeCurve(r,a)}addForks(e,t,s){if(!e.length)return;const o=t===this.selectionGroup,i=new ct(e.map((r,a)=>{const n=this.nodeByID.get(r.from),l=this.nodeByID.get(r.to);return{curve:this.branchCurve(n,l,r.kind),child:this.nodeIndices.get(r.to),delay:(s?.[a]||0)*.12,color:new V(r.kind==="fork"?"#edbc8d":"#bda6ef")}}),{uPixelScale:this.cometUniforms.uPixelScale,uPixelRatio:this.markerUniforms.uPixelRatio,uContextFocus:o?{value:0}:this.focusUniforms.uFocus},o);return i.group.visible=this.preferences.relationships,i.update(this.nodeReveal,o&&this.motion?0:1/0),t.add(i.group),i}addLabel(e,t,s,o=!1,i=!1){const r=document.createElement("div");r.className=o?"scene-label selected-label":i?"scene-label month-label":"scene-label",r.textContent=e,r.style.setProperty("--label-color",s),this.labelLayer.append(r);const a={element:r,point:t,priority:o,month:i};o?this.labels.unshift(a):this.labels.push(a)}select(e){this.pickingDirty=!0,this.revealsActive=!0,this.dirty=!0,this.selected!==e&&(this.selectedEvent=null,this.focusedEvent=void 0),this.selected=e,this.selectionBorn=this.time,this.focusUniforms.uFamilyTime.value=this.preferences.relationships?this.motion?0:1e6:-1e6,this.familyDepth&&(this.familyDepth.array.fill(-1),this.familyDepth.needsUpdate=!0),this.familyGlowDepth&&(this.familyGlowDepth.needsUpdate=!0),this.focusUniforms.uSelected.value=e?this.nodeIndices.get(e)??-1:-1,W(this.selectionGroup),this.selectedLinks=void 0,this.selectedComets=void 0,W(this.filesGroup),this.eventMarkers=[],this.clearEventIcons(),this.fileMesh=void 0,this.fileOffsets=[],this.labels=this.labels.filter(i=>(i.priority&&i.element.remove(),!i.priority));const t=e?this.nodeByID.get(e):void 0;if(this.particles.select(t),!t)return;const s=dt(this.graph,t.session.id);for(const[i,r]of s.depths)this.familyDepth?.setX(this.nodeIndices.get(i),r);const o=new j(new Fe(t.radius*1.45,t.radius*1.55,96),new ve({color:"#e1fff4",side:Z,transparent:!0,opacity:.65,depthTest:!1}));o.position.fromArray(this.orbCenter(t)),o.name="selection-ring",this.selectionGroup.add(o),this.selectedComets=this.addComets([t],this.selectionGroup),this.selectedLinks=this.addForks(s.edges.map(i=>i.edge),this.selectionGroup,s.edges.map(i=>i.depth)),this.addLabel(t.session.title.slice(0,52),new v(...t.position).add(new v(0,6,0)),"#e6f3ef",!0),this.setCutoff(this.cutoff)}setEvents(e,t=!1){this.particles.events(e),this.pickingDirty=!0;const s=this.selectionGroup.getObjectByName("event-markers");s&&(W(s),s.removeFromParent()),this.eventMarkers=[],this.clearEventIcons(),this.dirty=!0;const o=this.selected?this.nodeByID.get(this.selected):void 0;if(!o)return;const i=[],r=e.filter(g=>le(g)||g.kind==="commit");this.focusedEvent&&le(this.focusedEvent)&&!r.some(g=>g.id===this.focusedEvent.id)&&r.push(this.focusedEvent);for(const g of r){if(g.time===null)continue;const b=te(g.time,this.graph);if(!Number.isFinite(b)||b<o.startPosition[0]||b>o.position[0])continue;const m=new v(...G(o,b));this.eventMarkers.push({item:g,position:m}),i.push(...m.toArray())}if(!i.length)return;const a=new E;a.setAttribute("position",new I(i,3)),a.setAttribute("markerIndex",new I(this.eventMarkers.map((g,b)=>b),1)),a.setAttribute("isCommit",new I(this.eventMarkers.map(g=>+(g.item.kind==="commit")),1)),this.markerUniforms.uPixelRatio.value=this.renderer.getPixelRatio(),this.markerUniforms.uHovered.value=-1,this.selectEvent(this.selectedEvent);const n={uCutoff:this.lineUniforms.uCutoff,uTint:{value:new V(o.color)},...this.markerUniforms},l=`uniform float uPixelRatio; uniform float uPointScale; uniform float uSelected; uniform float uHovered; attribute float markerIndex; attribute float isCommit; varying float vCommit; varying float vTimeX; varying float vActive;
239
+ void main() { vCommit = isCommit; vTimeX = position.x; vActive = float(abs(markerIndex-uSelected)<.1 || abs(markerIndex-uHovered)<.1); gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0); gl_PointSize = mix(7.5,12.0,max(vActive,vCommit*.5)) * uPixelRatio * uPointScale; }`,h=new L({uniforms:{...n,uPointScale:{value:1}},transparent:!0,depthWrite:!1,depthTest:!1,vertexShader:l,fragmentShader:`uniform float uCutoff; uniform vec3 uTint; varying float vTimeX; varying float vActive; varying float vCommit;
240
+ void main() { float d = length(gl_PointCoord - .5) * 2.0; if (d > 1.0 || vTimeX > uCutoff) discard;
241
+ gl_FragColor = vec4(mix(mix(vec3(1.0), uTint, .08), vec3(1.0,.66,.2),vCommit) * (1.5 + vActive * .3), 1.0 - smoothstep(.55, 1.0, d)); }`}),c=new X;c.name="event-markers",c.visible=this.preferences.messageDots;const d=new U(a.clone(),new L({uniforms:{...n,uPointScale:{value:3}},transparent:!0,depthWrite:!1,depthTest:!1,blending:H,vertexShader:l,fragmentShader:`uniform float uCutoff; uniform vec3 uTint; varying float vTimeX; varying float vActive;
242
+ void main() { float d = length(gl_PointCoord - .5) * 2.0; if (d > 1.0 || vTimeX > uCutoff) discard;
243
+ float alpha = exp(-d*d*5.0) * (1.0-smoothstep(.6,1.0,d)) * mix(.2,.32,vActive);
244
+ gl_FragColor = vec4(mix(vec3(1.0), uTint, .65), alpha); }`}));d.renderOrder=9;const p=new U(a,h);p.renderOrder=10,c.add(d,p),this.selectionGroup.add(c);const y=this.eventMarkers.length-1,M=new Set;for(let g=y;g>=Math.max(0,y-31);g--)M.add(g);for(let g=0;g<32&&y>31;g++)M.add(Math.floor(g*(y-32)/31));for(const g of this.eventMarkers.map((b,m)=>({...b,index:m})).filter(b=>b.item.kind==="commit").slice(-32))M.add(g.index);for(const g of[...M].sort((b,m)=>m-b)){const b=document.createElement("div");b.className="event-marker-icon",b.setAttribute("aria-hidden","true"),b.style.color=this.eventMarkers[g].item.kind==="commit"?"#ffd580":"#ffffff",b.append(yt(this.eventMarkers[g].item)),this.labelLayer.append(b),this.eventIcons.push({element:b,marker:g,visible:!1,transform:""})}t&&this.focusedSession===this.selected&&this.selected&&this.focus(this.selected)}clearEventIcons(){for(const e of this.eventIcons)e.element.remove();this.eventIcons=[]}selectEvent(e){this.selectedEvent=e,e||(this.focusedEvent=void 0),this.markerUniforms.uSelected.value=this.eventMarkers.findIndex(t=>t.item.id===e),this.dirty=!0}focusEvent(e){this.focusedSession=null;const t=this.selected?this.nodeByID.get(this.selected):void 0;if(!t||e.time===null||!le(e)&&e.kind!=="commit")return;const s=te(e.time,this.graph);!Number.isFinite(s)||s<t.startPosition[0]||s>t.position[0]||(this.focusedEvent={...e,preview:"preview"in e?e.preview:(e.text||e.input||e.output||"").slice(0,180)},this.eventMarkers.some(o=>o.item.id===e.id)||this.setEvents(this.eventMarkers.map(o=>o.item)),this.selectEvent(e.id),this.focusPoint(new v(...G(t,s)),8))}setFiles(e){this.dirty=!0,W(this.filesGroup),this.fileMesh=void 0,this.fileOffsets=[];const t=this.selected?this.nodeByID.get(this.selected):void 0;if(!t)return;const s=[],o=[],i=e.slice(0,80);if(!i.length)return;const r=new Ke(.55),a=new ve({color:"#edc899"}),n=new ae(r,a,i.length);n.instanceMatrix.setUsage(D),n.frustumCulled=!1,this.fileMesh=n,this.fileBorn=this.time,this.fileOrigin.fromArray(t.position),this.fileUniforms.uOrigin.value.copy(this.fileOrigin),this.fileUniforms.uBorn.value=this.fileBorn;const l=new ue;if(i.forEach((h,c)=>{const d=c*2.399963,p=9+Math.sqrt(c)*2.5,y=[t.position[0]+Math.cos(d)*p,t.position[1]+Math.sin(d)*p,t.position[2]+6+P(h.path)*8];this.fileOffsets.push(new v(...y).sub(this.fileOrigin)),l.position.fromArray(y),l.scale.setScalar(this.motion?0:1),l.updateMatrix(),n.setMatrixAt(c,l.matrix);const M=this.edgeCurve(t.position,y).getPoints(24);for(let g=1;g<M.length;g++)s.push(...M[g-1].toArray(),...M[g].toArray()),o.push(c*.018,c*.018)}),n.instanceMatrix.needsUpdate=!0,this.filesGroup.add(n),s.length){const h=new E;h.setAttribute("position",new I(s,3)),h.setAttribute("delay",new I(o,1));const c=new L({uniforms:this.fileUniforms,transparent:!0,depthWrite:!1,blending:H,vertexShader:`attribute float delay; uniform vec3 uOrigin; uniform float uTime; uniform float uBorn; uniform float uMotion; varying float vAlpha;
245
+ void main() { float t = uMotion > .5 ? clamp((uTime-uBorn-delay)/.85,0.0,1.0) : 1.0; float p = 1.0-pow(1.0-t,3.0);
246
+ vec3 offset = (position-uOrigin)*p; float a = uMotion > .5 ? sin(uTime*.22)*.035 : 0.0;
247
+ offset.xy = mat2(cos(a),sin(a),-sin(a),cos(a))*offset.xy;
248
+ vAlpha = smoothstep(0.0,.3,t)*.34; gl_Position = projectionMatrix*modelViewMatrix*vec4(uOrigin+offset,1.0); }`,fragmentShader:"varying float vAlpha; void main(){gl_FragColor=vec4(.78,.57,.32,vAlpha);}"});this.filesGroup.add(new we(h,c))}}focus(e){const t=this.nodeByID.get(e);if(!t)return;this.selected!==e&&this.select(e),this.focusedSession=e;const s=t.radius*this.preferences.nodeScale/100,o=Math.max(8,s*this.height/(2*Math.tan(Math.PI/8)*24)),i=oe(t,B(this.cutoff,this.graph))[0],r=new v(...G(t,i)),a=this.focusDirection(),n=new v(...ke(t,i));n.projectOnPlane(a),n.lengthSq()<1e-4&&n.set(1,0,0).applyQuaternion(this.camera.quaternion),n.normalize();const l=this.preferences.messageDots?Math.max(.06,o*2*Math.tan(Math.PI/8)/this.height*8):.02;r.addScaledVector(n,s+l),this.focusPoint(r,o)}focusPoint(e,t){this.frameFocus();const s=this.focusDirection();this.targetLook=e,this.targetPosition=e.clone().addScaledVector(s,t),this.dirty=!0}focusDirection(){const e=this.camera.position.clone().sub(this.controls.target);return e.lengthSq()>1e-6?e.normalize():this.camera.getWorldDirection(e).negate()}focusArea(){const e=(this.options.panels??[]).filter(t=>!t.hidden&&t.getClientRects().length&&getComputedStyle(t).visibility!=="hidden").map(t=>t.getBoundingClientRect());return gt(this.container.getBoundingClientRect(),e,this.options.focusTop??(this.width>=760?92:72))}frameFocus(){const e=this.container.clientWidth,t=this.container.clientHeight,{x:s,y:o}=this.focusArea(),i=e/2-s,r=t/2-o,a=this.camera.view;a?.enabled&&a.fullWidth===e&&a.fullHeight===t&&a.offsetX===i&&a.offsetY===r||(this.camera.setViewOffset(e,t,i,r,e,t),this.dirty=!0)}framePlayback(){this.camera.setViewOffset(this.width,this.height,0,Math.min(70,this.height*.08),this.width,this.height)}reset(){if(this.focusedSession=null,this.camera.clearViewOffset(),!this.graph.nodes.length)return;const e=new ne().setFromPoints(this.graph.nodes.flatMap(n=>[new v(...n.startPosition),new v(...n.position)]));this.preferences.labels&&this.labels.some(n=>n.month)&&(e.min.y=Math.min(e.min.y,q-12));const t=e.getSize(new v),s=e.getCenter(new v),o=2*Math.tan(k.degToRad(22.5)),i=(t.y+30)/o,r=(t.x+50)/(o*this.camera.aspect),a=Math.max(i,r,100)+t.z/2+20;this.targetLook=s,this.targetPosition=s.clone().add(new v(18,45,a))}setMotion(e){this.motion=e,e||this.particles.reset(),e&&this.playing&&!this.playbackPath&&this.buildPlaybackPath(),e&&this.playing&&this.playbackSphere.setFromVector3(this.camera.position.clone().sub(this.controls.target)),this.labelLayer.dataset.motion=String(e),this.revealsActive=this.graph.nodes.length>0,this.dirty=!0}setSuspended(e){this.suspended=e,this.previousFrame=performance.now(),this.dirty=!0}diagnostics(){return{camera:this.camera.position.toArray(),target:this.controls.target.toArray(),cameraZoom:this.camera.zoom,zoomRestricted:this.controls.minDistance>0||Number.isFinite(this.controls.maxDistance),cameraMoving:!!(this.targetPosition||this.targetLook),timeFrame:this.graph.timeFrame,timeRange:[this.graph.start,this.graph.end],cutoffX:this.clipPlane.constant,nodes:this.graph.nodes.length,edges:this.graph.edges.length,lanes:this.graph.lanes.map(e=>({key:e.key,label:e.label,kind:e.kind,color:e.color,sessions:e.nodes.length,sources:[...new Set(e.nodes.map(t=>t.session.source||"opencode"))]})),xRange:[Math.min(...this.graph.nodes.map(e=>e.position[0])),Math.max(...this.graph.nodes.map(e=>e.position[0]))],yRange:[Math.min(...this.graph.nodes.map(e=>e.position[1])),Math.max(...this.graph.nodes.map(e=>e.position[1]))],calls:this.renderer.info.render.calls,geometries:this.renderer.info.memory.geometries,msaaSamples:this.composer.renderTarget1.samples,smaa:this.smaa.enabled,pixelRatio:this.renderer.getPixelRatio(),bloomSize:[this.bloom.renderTargetBright.width,this.bloom.renderTargetBright.height],forkReveals:this.links?.samples()||[],cutoff:this.cutoff,selectedVisible:this.selectionGroup.visible,selectedNode:this.selected,selectedPosition:this.selected&&this.nodeByID.has(this.selected)?this.orbCenter(this.nodeByID.get(this.selected)):void 0,selectedEndpoint:this.selected&&this.nodeByID.has(this.selected)?(()=>{const e=this.nodeByID.get(this.selected);return G(e,oe(e,B(this.cutoff,this.graph))[0])})():void 0,selectedRadius:this.selected&&this.nodeByID.has(this.selected)?this.drawnRadius(this.nodeByID.get(this.selected)):void 0,headSamples:this.graph.nodes.slice(0,32).map((e,t)=>{const s=new se;this.nodeMesh?.getMatrixAt(t,s);const o=new v(...this.orbCenter(e));return o.project(this.camera),{id:e.session.id,start:e.startPosition[0],end:e.position[0],x:s.elements[12],glowX:this.glowPositions?.getX(t),reveal:this.nodeReveal[t],screen:[(o.x+1)/2*this.width,(1-o.y)/2*this.height]}}),focusDimming:this.focusUniforms.uFocus.value,nodeSegments:this.nodeMesh?.geometry.parameters.widthSegments,eventMarkers:this.eventMarkers.length,eventIcons:this.eventIcons.filter(e=>e.visible).length,focusArea:this.focusArea(),selectedScreen:this.selected&&this.nodeByID.has(this.selected)?(()=>{const e=new v(...this.orbCenter(this.nodeByID.get(this.selected)));return e.project(this.camera),[(e.x+1)/2*this.width,(1-e.y)/2*this.height]})():void 0,selectedEvent:this.selectedEvent,selectedEventPosition:this.eventMarkers.find(e=>e.item.id===this.selectedEvent)?.position.toArray(),markerSamples:this.eventMarkers.slice(-30).map(({item:e,position:t})=>{const s=t.clone();return s.project(this.camera),{id:e.id,kind:e.kind,time:e.time,position:t.toArray(),x:(s.x+1)/2*this.container.clientWidth,y:(1-s.y)/2*this.container.clientHeight}}),sessionTrails:this.graph.nodes.filter(e=>e.position[0]>e.startPosition[0]).length,renderedFrames:this.renderer.info.render.frame,revealingNodes:this.revealsActive,revealedNodes:this.nodeReveal.filter(e=>e>.95).length,fileSatellites:this.fileOffsets.length,fileRevealProgress:this.motion?Math.min(1,(this.time-this.fileBorn)/(.85+this.fileOffsets.length*.018)):1,motion:this.motion,suspended:this.suspended,particles:this.particles.diagnostics(),playbackFollowing:this.playing&&this.motion&&!!this.playbackPath,playbackOutro:this.playbackOutro,playbackOrbitAngle:this.playbackOrbit?this.playbackSphere.theta-this.playbackOrbit.theta:0,playbackFocus:this.playbackFocus.toArray(),preferences:{...this.preferences}}}setCutoff(e,t=!1){this.dirty=!0;const s=B(this.cutoff,this.graph);if(this.cutoff=k.clamp(e,0,1),this.particles.seek(s,B(this.cutoff,this.graph),this.playing&&this.motion,t&&this.motion),!this.nodeMesh)return;const o=B(this.cutoff,this.graph)+.001;this.cometUniforms.uHeadX.value=B(this.cutoff,this.graph),this.clipPlane.constant=o,this.lineUniforms.uCutoff.value=this.cutoff>=1?o+10:o,this.revealsActive=!0;const i=this.selected?this.nodeByID.get(this.selected):void 0;i&&i.position[0]<=o&&!this.filesGroup.visible&&(this.fileBorn=this.time,this.fileUniforms.uBorn.value=this.fileBorn),this.selectionGroup.visible=!i||i.startPosition[0]<=o,this.filesGroup.visible=!i||i.position[0]<=o;const r=this.selectionGroup.getObjectByName("selection-ring");r&&i&&(r.position.fromArray(this.orbCenter(i)),r.visible=i.startPosition[0]<=o),this.glowMaterial&&(this.glowMaterial.uniforms.uCutoff.value=o)}animateNodes(){if(!this.nodeMesh||!this.revealsActive)return;this.pickingDirty=!0;let e=!1;const t=[],s=B(this.cutoff,this.graph);for(let o=0;o<this.graph.nodes.length;o++){const i=this.graph.nodes[o],r=i.startPosition[0]<=s;r?Number.isFinite(this.nodeBorn[o])||(this.nodeBorn[o]=this.time,this.motion&&t.push(i)):this.nodeBorn[o]=NaN;const a=r?this.motion?k.smoothstep(this.time-this.nodeBorn[o],0,.45):1:0;r&&a<1&&(e=!0),this.nodeReveal[o]=a;const n=this.orbCenter(i);this.transform.position.fromArray(n),this.glowPositions?.setXYZ(o,...n),this.transform.scale.setScalar(this.drawnRadius(i)),this.transform.updateMatrix(),this.nodeMesh.setMatrixAt(o,this.transform.matrix)}this.nodeMesh.instanceMatrix.needsUpdate=!0,this.revealAttribute&&(this.revealAttribute.needsUpdate=!0),this.glowPositions&&(this.glowPositions.needsUpdate=!0),this.arrivals&&(this.arrivals.mesh.visible=this.motion&&e,this.arrivals.update()),this.links?.update(this.nodeReveal),this.comets?.update(this.nodeReveal),this.selectedComets?.update(this.nodeReveal),this.particles.births(t,this.time),this.revealsActive=e}animateFiles(){if(this.fileUniforms.uTime.value=this.time,this.fileUniforms.uMotion.value=Number(this.motion),!this.fileMesh)return;const e=this.motion?Math.sin(this.time*.22)*.035:0,t=Math.cos(e),s=Math.sin(e);this.fileOffsets.forEach((o,i)=>{const a=1-(1-(this.motion?k.clamp((this.time-this.fileBorn-i*.018)/.85,0,1):1))**3;this.transform.position.set((o.x*t-o.y*s)*a,(o.x*s+o.y*t)*a,o.z*a).add(this.fileOrigin),this.transform.scale.setScalar(a),this.transform.rotation.set(this.motion?this.time*.18+i:0,this.motion?this.time*.24+i:0,Math.PI/4),this.transform.updateMatrix(),this.fileMesh.setMatrixAt(i,this.transform.matrix)}),this.fileMesh.instanceMatrix.needsUpdate=!0,this.transform.rotation.set(0,0,0)}updatePicking(){if(!this.pickingDirty&&this.pickingView.equals(this.camera.matrixWorldInverse)&&this.pickingProjection.equals(this.camera.projectionMatrix))return;this.pickingView.copy(this.camera.matrixWorldInverse),this.pickingProjection.copy(this.camera.projectionMatrix),this.nodeGrid.clear(),this.markerGrid.clear();const e=new v,t=new v;this.graph.nodes.forEach((s,o)=>{if(!this.nodeMesh||(e.fromArray(this.nodeMesh.instanceMatrix.array,o*16+12).applyMatrix4(this.nodeMesh.matrixWorld),t.copy(e).applyMatrix4(this.camera.matrixWorldInverse),e.project(this.camera),e.z<-1||e.z>1))return;const i=this.drawnRadius(s),r=-t.z,a=Math.max(.001,r-i),n=this.width/2*Math.abs(this.camera.projectionMatrix.elements[0])*i*(1+Math.abs(t.x)/r)/a,l=this.height/2*Math.abs(this.camera.projectionMatrix.elements[5])*i*(1+Math.abs(t.y)/r)/a,h=(e.x+1)/2*this.width,c=(1-e.y)/2*this.height;this.nodeGrid.add({index:o,x:h,y:c},h,c,Math.max(12,n,l),this.width,this.height)}),this.eventMarkers.forEach(({position:s},o)=>{if(e.copy(s),e.project(this.camera),e.z<-1||e.z>1)return;const i=(e.x+1)/2*this.width,r=(1-e.y)/2*this.height;this.markerGrid.add({index:o,x:i,y:r},i,r,22,this.width,this.height)}),this.pickingDirty=!1}pick(e){if(!this.nodeMesh||!this.pickMesh)return null;this.updatePicking();const t=this.renderer.domElement.getBoundingClientRect(),s=e.clientX-t.left,o=e.clientY-t.top;this.pointer.set(s/this.width*2-1,-o/this.height*2+1),this.raycaster.setFromCamera(this.pointer,this.camera);let i=null,r=1/0,a=null,n=e.pointerType==="touch"?12:6;for(const l of this.nodeGrid.at(s,o)){const h=this.graph.nodes[l.index];if(h.startPosition[0]>this.clipPlane.constant||this.nodeReveal[l.index]<.05)continue;this.nodeMesh.getMatrixAt(l.index,this.pickMatrix),this.pickMesh.matrixWorld.multiplyMatrices(this.nodeMesh.matrixWorld,this.pickMatrix),this.pickHits.length=0,this.pickMesh.raycast(this.raycaster,this.pickHits);for(const d of this.pickHits)d.distance<r&&(r=d.distance,i=h);const c=Math.hypot(l.x-s,l.y-o);c<n&&(a=h,n=c)}return i||a}pointerStart=e=>{this.pointerID=e.isPrimary&&e.button===0?e.pointerId:null,this.pointerDragged=!1,this.pointerDown.set(e.clientX,e.clientY),this.onHover(null,0,0)};pickEvent(e){if(!this.preferences.messageDots||!this.selectionGroup.visible)return null;this.updatePicking();const t=this.renderer.domElement.getBoundingClientRect(),s=e.clientX-t.left,o=e.clientY-t.top;let i=1/0,r=-1,a=0;for(const n of this.markerGrid.at(s,o)){if(this.eventMarkers[n.index].position.x>this.lineUniforms.uCutoff.value)continue;const l=Math.hypot(n.x-s,n.y-o);l>(e.pointerType==="touch"?22:10)||(a++,l<i&&(i=l,r=n.index))}return r>=0?{index:r,item:this.eventMarkers[r].item,count:a}:null}pointerEnd=e=>{const t=e.button===0&&this.pointerID===e.pointerId&&!this.pointerDragged;if(this.pointerID=null,!t||this.pointerDown.distanceTo(new O(e.clientX,e.clientY))>5)return;const s=this.pickEvent(e);if(s){this.selectEvent(s.item.id),this.onEvent(s.item.id),this.focusEvent(s.item);return}const o=this.pick(e);this.onSelect(o?.session.id||null)};pointerMove=e=>{if(this.pointerID===e.pointerId&&this.pointerDown.distanceTo(new O(e.clientX,e.clientY))>5&&(this.pointerDragged=!0),e.buttons){this.particles.leave();return}const t=this.renderer.domElement.getBoundingClientRect();this.particles.pointer(e.clientX-t.left,e.clientY-t.top,this.width,this.height),this.motion&&this.preferences.stars&&(this.dirty=!0);const s=this.pickEvent(e);this.markerUniforms.uHovered.value!==(s?.index??-1)&&(this.markerUniforms.uHovered.value=s?.index??-1,this.dirty=!0);const o=s?null:this.pick(e),i=o?.session.id||null;i!==this.hovered&&(this.hovered=i,this.focusUniforms.uHovered.value=i?this.nodeIndices.get(i)??-1:-1,this.dirty=!0),this.renderer.domElement.style.cursor=o||s?"pointer":"grab";const r=this.container.getBoundingClientRect();s?this.onEventHover(s.item,s.count,e.clientX-r.left,e.clientY-r.top):this.onHover(o,e.clientX-r.left,e.clientY-r.top)};pointerLeave=()=>{this.particles.leave(),this.hovered=null,this.focusUniforms.uHovered.value=-1,this.markerUniforms.uHovered.value=-1,this.dirty=!0,this.onHover(null,0,0)};resize(){this.dirty=!0,this.pickingDirty=!0,this.revealsActive=!0;const e=this.container.clientWidth,t=this.container.clientHeight;if(!e||!t)return;this.width=e,this.height=t;const s=this.preferences.quality,o=this.options.manual||s==="performance"?1:s==="high"?Math.min(Math.max(devicePixelRatio,2),2.5):Math.min(Math.max(devicePixelRatio,1.5),2),r=Math.min(o,Math.sqrt((s==="high"?5e6:3e6)/(e*t)),this.renderer.capabilities.maxTextureSize/Math.max(e,t));this.renderer.getPixelRatio()!==r&&(this.renderer.setPixelRatio(r),this.composer.setPixelRatio(r)),this.camera.aspect=e/t,this.playing&&this.motion?this.framePlayback():this.camera.view?.enabled&&this.frameFocus(),this.camera.updateProjectionMatrix(),this.renderer.setSize(e,t),this.composer.setSize(e,t);const a=Math.min(r,s==="high"?1.5:1);this.bloom.setSize(Math.max(32,e*a),Math.max(32,t*a)),this.markerUniforms.uPixelRatio.value=this.renderer.getPixelRatio(),this.cometUniforms.uPixelScale.value=t*this.renderer.getPixelRatio()/(2*Math.tan(k.degToRad(this.camera.fov/2))),this.glowMaterial&&(this.glowMaterial.uniforms.uScale.value=t*this.renderer.getPixelRatio()*.9)}animate=()=>{this.frame=requestAnimationFrame(this.animate);const e=performance.now(),t=this.suspended?0:Math.min(.05,(e-this.previousFrame)/1e3);this.previousFrame=e,!(document.hidden||this.suspended&&!this.dirty)&&this.renderFrame(t)};renderFrame(e){this.time+=e;const s=this.animatePlaybackCamera(e)||!!this.targetPosition;if(this.targetPosition&&this.targetLook){const m=this.motion&&!this.suspended?1-Math.exp(-4.7*e):1;this.camera.position.lerp(this.targetPosition,m),this.controls.target.lerp(this.targetLook,m),this.camera.position.distanceTo(this.targetPosition)<.05&&(this.targetPosition=void 0,this.targetLook=void 0)}this.controls.update();const o=this.cameraDirty;(o||s)&&(this.cameraSettlesAt=this.time+.15);const i=!this.options.manual&&this.preferences.quality==="balanced"&&!this.playing&&this.time<this.cameraSettlesAt,r=this.preferences.quality!=="performance"&&!i;this.smaa.enabled!==r&&(this.smaa.enabled=r,this.dirty=!0);const a=this.preferences.quality!=="performance"&&this.preferences.bloom>0&&!i;this.bloom.enabled!==a&&(this.bloom.enabled=a,this.dirty=!0),!this.playing&&this.camera.view?.enabled&&(this.focusedSession||this.focusedEvent)&&this.frameFocus(),this.camera.updateMatrixWorld();const n=this.selected?this.nodeByID.get(this.selected):void 0,l=!this.playing&&this.preferences.focusDimming&&n&&n.startPosition[0]<=this.clipPlane.constant?1:0,h=Math.abs(this.focusUniforms.uFocus.value-l)>.001;this.focusUniforms.uFocus.value=h&&this.motion&&!this.suspended?k.damp(this.focusUniforms.uFocus.value,l,10,e):l,this.focusUniforms.uFamilyTime.value=this.preferences.relationships?this.motion?this.time-this.selectionBorn:1e6:-1e6;const c=this.motion&&(this.playing||this.preferences.trailFlow)&&this.preferences.trails!=="off";this.trailUniforms.uTrailTime.value=this.time,this.trailUniforms.uTrailFlow.value=Number(c);const d=this.hovered?this.nodeByID.get(this.hovered):void 0,p=this.particles.update(this.time,this.suspended?0:e,this.camera,this.nodeReveal,{motion:this.motion,suspended:this.suspended,playing:this.playing,pixelScale:this.cometUniforms.uPixelScale.value,pixelRatio:this.renderer.getPixelRatio(),width:this.width,height:this.height,selectedCenter:n&&this.selectionGroup.visible?this.orbCenter(n):void 0,hoverCenter:d?this.orbCenter(d):void 0});if(!this.dirty&&!o&&!s&&!h&&!this.revealsActive&&!c&&!p&&!(this.motion&&this.selected&&this.selectionGroup.visible))return;if((o||s)&&(this.revealsActive=!0),this.animateNodes(),this.selectedLinks?.update(this.nodeReveal,this.motion?this.time-this.selectionBorn:1/0),n){const m=this.orbCenter(n);this.fileOrigin.fromArray(m),this.fileUniforms.uOrigin.value.copy(this.fileOrigin);for(const R of this.labels)R.priority&&R.point.set(m[0],m[1]+6,m[2])}this.animateFiles(),this.lineUniforms.uReveal.value=this.motion?k.smoothstep(this.time-this.graphBorn,0,.9):1;const y=this.selectionGroup.getObjectByName("selection-ring");y&&(n&&y.position.fromArray(this.orbCenter(n)),y.quaternion.copy(this.camera.quaternion),y.scale.setScalar(this.preferences.nodeScale/100*(this.motion?1+Math.sin(this.time*2)*.07:1)));const M=this.width,g=this.height,b=[];for(const m of this.labels){const f=m.point.clone().project(this.camera),w=m.priority?Math.min(260,M-24):m.month?m.element.textContent.length>3?62:32:this.options.manual?235:155,S=(f.x*.5+.5)*M,A=m.priority?k.clamp(S-w/2,12,M-w-12):m.month?S-w/2:S,C=(-f.y*.5+.5)*g+(m.priority?-24:m.month?4:0),K=b.some(x=>A<x.x+x.width+8&&A+w+8>x.x&&Math.abs(C-x.y)<26),Q=m.priority&&n?n.startPosition[0]<=this.clipPlane.constant:m.point.x<=this.clipPlane.constant,_=(M>600||m.priority||m.month)&&!K&&(!m.month||A>=12)&&A+w<=M-12&&Q&&f.z<1&&f.z>-1&&Math.abs(f.x)<.95&&Math.abs(f.y)<.9;if(m.visible!==_&&(m.element.classList.toggle("visible",_),m.visible=_),_){m.x=A,m.y=C;const x=`translate(${A}px, ${C}px)${m.month?` translateX(${w/2}px) translateX(-50%)`:""}`;m.transform!==x&&(m.element.style.transform=x,m.transform=x),b.push({x:A,y:C,width:w})}}for(const m of this.eventIcons){const R=this.eventMarkers[m.marker],f=this.iconPoint.copy(R.position);f.project(this.camera);const w=(f.x+1)/2*M-6,S=(1-f.y)/2*g-25,A=this.preferences.messageDots&&this.selectionGroup.visible&&R.position.x<=this.clipPlane.constant&&f.z>-1&&f.z<1&&w>12&&w<M-24&&S>12&&S<g-30&&!b.some(C=>w<C.x+C.width+12&&w+24>C.x&&Math.abs(S-C.y)<24);if(A!==m.visible&&(m.element.classList.toggle("visible",A),m.visible=A),A){const C=`translate(${Math.round(w)}px, ${Math.round(S)}px)`;C!==m.transform&&(m.element.style.transform=C,m.transform=C),b.push({x:w,y:S,width:12})}}this.composer.render(),this.cameraDirty=!1,this.dirty=!1}prepareCapture(){this.setPlaying(!1),this.time=0,this.graphBorn=0,this.particles.reset(),this.bloom.strength=Math.min(this.bloom.strength,.08),this.bloom.radius=0,this.bloom.threshold=1.2,this.trailUniforms.uTrailOpacity.value=Math.min(this.trailUniforms.uTrailOpacity.value,.5),this.glowMaterial&&(this.glowMaterial.uniforms.uGlowSize.value=.7,this.glowMaterial.uniforms.uGlowIntensity.value=.45),this.reset(),this.targetPosition&&this.targetLook&&(this.camera.position.copy(this.targetPosition),this.controls.target.copy(this.targetLook)),this.targetPosition=void 0,this.targetLook=void 0,this.controls.enableDamping=!1,this.controls.update(),this.setCutoff(0),this.setPlaying(!0)}captureFrame(e,t,s,o=null){if(this.setCutoff(e),this.setPlaybackOutro(o),this.renderFrame(t),s.drawImage(this.renderer.domElement,0,0,this.width,this.height),!!this.preferences.labels){s.save(),s.font='11px "IBM Plex Mono", monospace',s.textBaseline="top";for(const i of this.labels)if(i.visible&&!i.priority){s.fillStyle=i.element.style.getPropertyValue("--label-color"),s.globalAlpha=.8;const r=i.element.textContent||"",a=(i.x||0)+(i.month?((r.length>3?62:32)-s.measureText(r).width)/2:8);s.fillText(r,a,(i.y||0)+5)}s.restore()}}dispose(){cancelAnimationFrame(this.frame),this.resizeObserver.disconnect(),this.controls.dispose(),this.particles.dispose(),this.scene.traverse(e=>{const t=e;e instanceof ae&&e.dispose(),t.geometry?.dispose(),t.material&&(Array.isArray(t.material)?t.material:[t.material]).forEach(s=>s.dispose())});for(const e of this.composer.passes)e.dispose();this.composer.dispose(),this.renderer.dispose(),this.renderer.domElement.removeEventListener("webglcontextlost",this.contextLost),this.renderer.forceContextLoss(),this.renderer.domElement.remove(),this.labelLayer.remove()}}export{wt as TimelineScene};
@@ -0,0 +1,7 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/index-BcuycrLl.js","assets/index-Dm6VCxBu.js","assets/index-ZvQzUBK1.css","assets/index-DHztibvv.js"])))=>i.map(i=>d[i]);
2
+ import{p as z,i as j,_ as H,s as K,a as V,o as J,b as Q,c as Y,t as Z,d as ee,S as L,e as te,f as ae,g as se,h as oe}from"./index-Dm6VCxBu.js";import{TimelineScene as re}from"./scene-CnihjOu5.js";import"./three-DDiuFd7k.js";const ne="#b0e9d6",ie="#dbe7e3",O=128,le=10,de="M102 24 86 40H36a14 14 0 0 0 0 28h40a14 14 0 0 1 0 28H22",ce=[[102,24],[36,40],[22,96]],ue=10;let U;function he(e,l,a,n,i=ne){U??=new Path2D(de),e.save(),e.translate(l,a),e.scale(n/O,n/O),e.strokeStyle=e.fillStyle=i,e.lineWidth=le,e.lineCap=e.lineJoin="round",e.stroke(U);for(const[y,h]of ce)e.beginPath(),e.arc(y,h,ue,0,Math.PI*2),e.fill();e.restore()}function pe(e){const l=z(e.lanes.length),a=new Map(e.lanes.flatMap(s=>s.nodes.map(t=>[t.session.id,s.key]))),n=new Map;for(const s of e.nodes.map(t=>t.session).sort((t,r)=>t.created-r.created||t.id.localeCompare(r.id))){const t=a.get(s.id);t!==void 0&&!n.has(t)&&n.set(t,n.size)}const i=new Map(e.nodes.map((s,t)=>[s.session.id,`session-${t}`])),y=new Map(e.lanes.flatMap((s,t)=>s.nodes.map(r=>[r.session.id,`project-${t}`]))),h=e.nodes.map(s=>{const t=s.session,r={id:i.get(t.id),title:"Session",projectID:y.get(t.id),directory:"",created:t.created,updated:t.created,activity:t.activity&&{firstMessageAt:t.activity.firstMessageAt,lastMessageAt:t.activity.lastMessageAt,userMessages:t.activity.userMessages,untimedUserMessages:t.activity.untimedUserMessages},archived:!1,model:"",provider:"",agent:"",cost:null,source:t.source==="continue"?"continue":t.source==="opencode"||!t.source?"opencode":"unknown",tokens:t.tokens};return t.parentID&&i.has(t.parentID)&&(r.parentID=i.get(t.parentID)),t.forkID&&i.has(t.forkID)&&(r.forkID=i.get(t.forkID)),{session:r,position:[...s.position],startPosition:[...s.startPosition],color:s.color,radius:s.radius}}),d=new Map(h.map(s=>[s.session.id,s]));return{start:e.start,end:e.end,timeFrame:e.timeFrame&&{...e.timeFrame},nodes:h,edges:e.edges.map(s=>({from:i.get(s.from),to:i.get(s.to),kind:s.kind})),lanes:e.lanes.map((s,t)=>({key:`project-${t}`,label:l[n.get(s.key)],color:s.color,kind:"directory",y:s.y,z:s.z,nodes:s.nodes.map(r=>d.get(i.get(r.session.id)))}))}}const $={mp4:{label:"MP4",description:"MP4 video",mime:"video/mp4",filename:"sessiongraph-playback.mp4"}},T=`My coding sessions, visualized with SessionGraph.
3
+ https://github.com/arvindell/sessiongraph`,ye=`https://x.com/intent/tweet?text=${encodeURIComponent(T)}`,G=e=>e instanceof Error&&e.name==="AbortError";async function me(e,l,a){const{label:n,description:i,mime:y,filename:h}=$[a];try{if(j()){const[{save:d},{writeFile:s}]=await Promise.all([H(()=>import("./index-BcuycrLl.js"),__vite__mapDeps([0,1,2])),H(()=>import("./index-DHztibvv.js"),__vite__mapDeps([3,1,2]))]),t=await d({title:`Save SessionGraph ${n}`,defaultPath:h,filters:[{name:i,extensions:[a]}]});if(!t)return"cancelled";await s(t,new Uint8Array(await e.arrayBuffer()))}else{const d=window.showSaveFilePicker;if(d){const t=await(await d.call(window,{suggestedName:h,types:[{description:i,accept:{[y]:[`.${a}`]}}]})).createWritable();try{await t.write(e),await t.close()}catch(r){throw await t.abort().catch(()=>{}),r}}else{const s=document.createElement("a");return s.href=l,s.download=h,document.body.append(s),s.click(),s.remove(),"downloaded"}}return"saved"}catch(d){if(G(d))return"cancelled";throw d}}const g=960,P=600,q='"Katagami Sans", sans-serif',fe=e=>Intl.NumberFormat("en",{notation:"compact",maximumFractionDigits:1}).format(e);function ve(e,l,a,n,i,y){const s=P-122,t=Math.max(1,...n);e.save(),he(e,24,14,28),e.fillStyle=ie,e.font=`600 14px ${q}`,e.textAlign="left",e.textBaseline="middle",e.fillText("SessionGraph",58,28),e.restore();for(let u=0;u<n.length;u++){const m=Math.max(2,n[u]/t*22);e.fillStyle=u/n.length<=a?"#91bfae":"#253d39",e.fillRect(260+u/n.length*440,s-m,440/n.length-2,m)}e.fillStyle="#d6f4e8",e.fillRect(260+440*a,s-27,1,31);const r=l.start+(l.end-l.start)*a,k=i.at(r,a===1).tokens;e.textAlign="center",e.fillStyle="#a0baae",e.font='12px "IBM Plex Mono", monospace',e.fillText(oe(r,l.end-l.start),g/2,s+23),e.fillStyle="#e7f5ee",e.font=`36px ${q}`,e.fillText(y(r,a===1).toLocaleString("en"),g/2-105,s+66),e.fillText(i.recorded?fe(k):"—",g/2+105,s+66),e.font=`12px ${q}`,e.fillStyle="#92b0a3",e.fillText("Sessions",g/2-105,s+87),e.fillText("Burnt tokens",g/2+105,s+87),e.textAlign="left"}async function be(e,l,a,n){a.throwIfAborted();const{label:i,mime:y}=$.mp4,h=Q(e.nodes.map(p=>p.session)),d=Y(e.nodes.map(p=>p.session)),s=Z(e.nodes.map(p=>ee(p.session)),e.start,e.end),t=document.createElement("div");t.className="share-render-host",t.setAttribute("aria-hidden","true"),t.style.cssText=`position:fixed;left:-12000px;top:0;width:${g}px;height:${P}px;pointer-events:none;visibility:hidden`,document.body.append(t);const r=document.createElement("canvas");r.width=g,r.height=P;const k=r.getContext("2d",{willReadFrequently:!0});let u,m;try{if(!k)throw new Error("Canvas export is unavailable.");u=new re(t,{onSelect(){},onHover(){},onPlaybackInterrupt(){},onEvent(){},onEventHover(){}},{manual:!0}),u.applyPreferences({...l,quality:"balanced",motion:"on",labels:!0,focusDimming:!1,trails:l.trails==="selected"?"all":l.trails}),u.setGraph(e,!0),u.prepareCapture(),await document.fonts.ready,a.throwIfAborted(),m=new Worker(new URL("/assets/mp4-worker-Dc_1QUwS.js",import.meta.url),{type:"module"});const p=(v,A=[])=>new Promise((b,w)=>{a.throwIfAborted();const f=()=>{clearTimeout(M),a.removeEventListener("abort",C),m.onmessage=null,m.onerror=null},C=()=>{f(),w(a.reason)},M=setTimeout(()=>{f(),w(new Error(`${i} encoding timed out. Please try again.`))},6e4);a.addEventListener("abort",C,{once:!0}),m.onmessage=E=>{f(),E.data.error?w(new Error(E.data.error)):b(E.data)},m.onerror=()=>{f(),w(new Error(`Could not start the ${i} encoder.`))},m.postMessage(v,A)});await p({init:!0,width:g,height:P});for(let v=0;v<L;v++){a.throwIfAborted();const A=te(v);u.captureFrame(A,1/ae,k,se(v)),ve(k,e,A,s,h,d);const b=k.getImageData(0,0,g,P).data.buffer;await p({rgba:b,width:g,height:P},[b]),n((v+1)/L)}const I=await p({finish:!0});return new Blob([I.bytes],{type:y})}finally{m?.terminate(),u?.dispose(),t.remove()}}function ke(e,l){const a=document.createElement("dialog");a.className="share-dialog",a.setAttribute("aria-labelledby","share-title"),a.innerHTML=`<p>Create a private MP4 video. Project and session names are hidden, and nothing is uploaded.</p>
4
+ <div class="share-preview"><video aria-label="SessionGraph playback with hidden project and session names" muted loop playsinline controls hidden></video><div class="share-progress"><progress max="100" value="0" aria-label="Creating video"></progress><span role="status">Creating video… 0%</span></div></div>
5
+ <p class="share-notice" role="status" hidden></p>
6
+ <div class="share-actions"><button class="text-button share-close">Cancel</button><button class="secondary-button share-retry" hidden>Try again</button><a class="secondary-button share-x" target="_blank" rel="noopener noreferrer" hidden>Share in X</a><button class="secondary-button share-system" aria-label="Open share tray" aria-controls="playback-share-tray" aria-expanded="false" hidden>Share…</button><button class="primary-button share-save" hidden>Save MP4</button></div>
7
+ <section id="playback-share-tray" class="share-tray" aria-label="Share options" hidden><p>Save the video to attach it in any app.</p><textarea class="share-caption" aria-label="Share caption" readonly rows="3"></textarea><div><button class="secondary-button share-copy">Copy caption</button><a class="secondary-button share-x" target="_blank" rel="noopener noreferrer">Share in X</a><button class="secondary-button share-tray-save">Save MP4</button></div></section>`,a.prepend(K(a,"video",()=>l())),document.body.append(a);const n=a.querySelector("video"),i=a.querySelector("progress"),y=a.querySelector('[role="status"]'),h=a.querySelector(".share-progress"),d=a.querySelector(".share-close"),s=a.querySelector(".share-save"),t=a.querySelector(".share-retry"),r=a.querySelector(".share-system"),k=a.querySelector(".share-actions .share-x"),u=a.querySelector(".share-tray"),m=a.querySelector(".share-notice"),p=a.querySelector(".share-tray-save"),I=a.querySelector(".share-copy"),v=a.querySelector(".share-caption");v.value=T,r.prepend(V("share-2"));let A,b,w,f,C,M,E=Promise.resolve();const S=o=>{m.textContent=o,m.hidden=!o},R=o=>{u.hidden=!o,r.setAttribute("aria-expanded",String(o)),o&&I.focus()},x=()=>{A?.abort(),A=void 0,n.pause(),n.removeAttribute("src"),n.load(),f&&URL.revokeObjectURL(f),f=void 0,b=void 0,w=void 0,R(!1),S(""),a.setAttribute("aria-busy","false")};for(const o of a.querySelectorAll(".share-x"))o.href=ye,o.title="Open an X draft, then attach your saved animation",o.onclick=c=>{S("Attach your saved MP4 in X to include the video."),j()&&(c.preventDefault(),J(o.href).catch(()=>S("Could not open your browser. Copy the caption and attach your saved video manually.")))};d.onclick=()=>a.close(),a.addEventListener("cancel",o=>{u.hidden||(o.preventDefault(),R(!1),r.focus())}),a.addEventListener("close",()=>{a.open||(x(),C=void 0,M=void 0,e())});function B(){x();const o=new AbortController;A=o;const{label:c,mime:D,filename:X}=$.mp4;s.textContent=p.textContent=`Save ${c}`,n.hidden=!0,h.hidden=!1,s.hidden=!0,r.hidden=!0,k.hidden=!0,t.hidden=!0,d.textContent="Cancel",i.hidden=!1,i.value=0,i.setAttribute("aria-label",`Creating ${c}`),y.textContent=`Creating ${c}… 0%`,a.setAttribute("aria-busy","true"),E=E.then(async()=>{if(!o.signal.aborted)try{const _=await be(C,M,o.signal,W=>{if(o.signal.aborted)return;const F=Math.round(W*100);i.value=F,y.textContent=`Creating ${c}… ${F}%`});if(o.signal.aborted)return;b=_,w=new File([_],X,{type:D}),f=URL.createObjectURL(_),n.src=f,n.hidden=!1,n.play().catch(()=>{}),h.hidden=!0,s.hidden=!1,r.hidden=!1,k.hidden=!1,d.textContent="Done"}catch(_){if(o.signal.aborted)return;i.hidden=!0,y.textContent=_ instanceof Error?_.message:`Could not create the ${c}.`,t.hidden=!1,d.textContent="Close"}finally{A===o&&a.setAttribute("aria-busy","false")}})}t.onclick=B;const N=async()=>{if(!b||!f||s.disabled)return;const o=b,{label:c}=$.mp4;s.disabled=!0,p.disabled=!0,S(`Choose where to save your ${c}…`);try{const D=await me(o,f,"mp4");b===o&&S(D==="saved"?`${c} saved.`:D==="downloaded"?`${c} download started. Check your downloads.`:`Save cancelled. Your ${c} is still ready.`)}catch{b===o&&S(`Could not save the ${c}. Try choosing another location.`)}finally{s.disabled=!1,p.disabled=!1}};return s.onclick=N,p.onclick=N,r.onclick=async()=>{if(!w||r.disabled)return;const o=w,c={files:[o],title:"SessionGraph",text:T};if(!navigator.share||!navigator.canShare?.({files:[o]})){R(u.hidden);return}r.disabled=!0,S("");try{await navigator.share(c)}catch(D){w===o&&!G(D)&&(R(!0),S("Could not open system sharing. Save the animation or choose an option below."))}finally{r.disabled=!1}},I.onclick=async()=>{try{await navigator.clipboard.writeText(T),S("Caption copied. Attach your saved animation with it.")}catch{v.focus(),v.select(),S("Copy the selected caption, then attach your saved animation.")}},{open(o,c){a.open||(C=pe(o),M={...c},a.showModal(),e(),B())},dispose(){x(),C=void 0,M=void 0,a.close(),a.remove()}}}export{ke as createPlaybackShare};