voice-ring 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.d.ts +78 -5
- package/dist/index.es.js +982 -801
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
A voice-reactive ring of light for AI voice interfaces: a few rings lean off the view axis and bundle into a glassy ribbon, a spectrum runs around it, and the voice bends every ring together. It takes the colour of the voice's emotion and leans toward whoever is speaking.
|
|
4
4
|
|
|
5
|
-
Voice ring is the
|
|
5
|
+
Voice ring is the two aura types of the voice orbs, as a library of their own: `ring`, the default, and `mono`, two loops of grey tube that a voice opens into a turning globe, an emotion colouring the tube. Choose with `type="mono"` in React and `VoiceRing(.mono, …)` in SwiftUI.
|
|
6
6
|
|
|
7
7
|
## SwiftUI
|
|
8
8
|
|
|
@@ -29,7 +29,7 @@ struct VoiceScreen: View {
|
|
|
29
29
|
Two models plug in:
|
|
30
30
|
|
|
31
31
|
- **Emotion** (`VoiceRingEmotion`, Pro): emotion2vec+ reads the tone of the voice, GoEmotions its words; pass `mood: emotion.mood`.
|
|
32
|
-
- **Direction** ([Voice
|
|
32
|
+
- **Direction** ([Voice position](https://libraries.dev/voice-position.html), free account): add `VoicePosition.mfxl` to the app target and the ring leans toward the voice from the iPhone's stereo mics, no calibration.
|
|
33
33
|
|
|
34
34
|
Docs: https://libraries.dev/voice-ring.html
|
|
35
35
|
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const zn=require("react/jsx-runtime"),$=require("react");let Dt=null;function $n(){if(typeof window>"u")return null;const t=window;return t.AudioContext??t.webkitAudioContext??null}function me(){return $n()!=null}function xn(){const t=$n();return t?(Dt||(Dt=new t),Dt.state==="suspended"&&Dt.resume().catch(()=>{}),Dt):null}const hn=new WeakMap;function Wn(t){const n=xn();if(!n||t.getAudioTracks().length===0)return null;let s=hn.get(t);s||(s={node:n.createMediaStreamSource(t),refs:0},hn.set(t,s)),s.refs+=1;const e=n.createAnalyser();e.fftSize=1024,e.smoothingTimeConstant=.5,s.node.connect(e);let o=!1;return{analyser:e,release:()=>{if(!o){o=!0;try{s.node.disconnect(e)}catch{}if(s.refs-=1,s.refs<=0){try{s.node.disconnect()}catch{}hn.delete(t)}}}}}const Gt={positive:{r:92,g:224,b:150},negative:{r:255,g:104,b:104},calm:{r:104,g:162,b:255}},Vn={green:Gt.positive,red:Gt.negative,blue:Gt.calm},Me=.7,ge=1.1,be=.6;class ve{constructor(){this.glow={r:0,g:0,b:0,amount:0,t:0,size:0}}step(n,s,e,o,r){const c=this.glow,l=a=>r?1:1-Math.exp(-n/a),i=s?1:0;if(c.amount+=(i-c.amount)*l(i>c.amount?Me:ge),s){const a=c.amount<.03?1:l(be);c.r+=(s.r-c.r)*a,c.g+=(s.g-c.g)*a,c.b+=(s.b-c.b)*a}return c.t=e,c.size=o,c}}const Xn=(t,n)=>{var s;return((s=t.light)==null?void 0:s.r)??n*.28};function xe(t,n,s){const o=(Xn(t,n)*.7)**2,r=.9*Math.min(1,Math.max(0,s.amount)),c=(l,i)=>{const a=s.x-l,p=s.y-i,h=r*Math.exp(-(a*a+p*p)/o);return[l+a*h,i+p*h]};return{...t,strokes:t.strokes.map(l=>{const i=l.pts.slice();for(let a=0;a<i.length;a+=2)[i[a],i[a+1]]=c(i[a],i[a+1]);return{...l,pts:i}}),dots:t.dots.map(l=>{const[i,a]=c(l.x,l.y);return{...l,x:i,y:a}})}}const ye=(t,n)=>Math.min(1,Math.max(0,(.8*n-t)/(.6*n))),xt={move:2,pull:.7,deform:.1,squash:.5,lens:.67,stretch:1,split:1,blur:1,bounce:1};function Se(t,n){const s=Math.abs(t.move)+Math.abs(t.pull)+2*Math.abs(t.deform);return s===0?0:Math.ceil(n*.36*s)+2}class we{constructor(){this.x=0,this.v=0,this.landed=!1}step(n,s){const r=Math.max(1,Math.ceil(s*240)),c=s/r;for(let i=0;i<r;i++)this.v+=(15*15*(n-this.x)-2*.3*15*this.v)*c,this.x+=this.v*c;const l=this.x-n;return n<=0?this.landed=!1:l>=0&&(this.landed=!0),l<0&&!this.landed?0:l}}function Ee(t,n,s,e,o=[1/0,1/0],r=0){if(Math.abs(n)<.002||e.move===0&&e.pull===0&&e.deform===0)return t;const c=s/2,l=s*.36,i=n<0?-1:1,a=Math.abs(n),p=(b,w)=>{const y=(b-c)/l,I=(w-c)/l,R=Math.max(0,Math.min(1,(y*i+1)/2)),B=Math.max(0,y*i);return n*l*(e.move+e.pull*R*R+e.deform*B*B*Math.exp(-I*I*1.5))},h=Math.max(0,Math.min(2,e.lens??1)),f=l*.9,m=i>0?o[1]:o[0],d=Number.isFinite(m)?Math.min(f*.45,l*.3*h*Math.max(0,e.stretch??1)):0;let M=1,v=1/0,_=1;if(Number.isFinite(m)){v=i>0?s+m:-m;const b=(w,y,I)=>{_=Math.max(_,I);const R=p(w,y)*i;R>1e-9&&(M=Math.min(M,Math.max(0,((v-w)*i-I-d)/R)))};for(const w of t.dots)b(w.x,w.y,w.r);for(const w of t.strokes)for(let y=0;y<w.pts.length;y+=2)b(w.pts[y],w.pts[y+1],1)}const u=M<1?Math.min(1,(1-M)/.35):0,g=u>0?r*(e.bounce??1):0,x=Math.min(1.4,u+Math.max(0,g)),O=l*.12*Math.max(0,-g),E=v-i*_,q=E-i*d,S=l*.55*x*(e.squash??0);let C=1/0,A=-1/0,D=!0;const U=(b,w)=>{const y=Math.max(0,Math.min(1,((b-c)/l*i+1)/2)),I=1-.15*e.deform*a*M*y;let R=b+p(b,w)*M+i*(S*.5-O),B=c+(w-c)*I;if(S>0){const k=(R-(q-i*S))*i;if(k>0){const F=k/S,T=S*(F/Math.sqrt(1+F*F));R=q-i*S+i*T,B=c+(B-c)*(1+.18*x*(e.squash??0)*(T/S))}}return D&&(q-R)*i<Math.max(S,f*.3)&&(C=Math.min(C,B),A=Math.max(A,B)),[R,B]};for(const b of t.dots)[b.x,b.y]=U(b.x,b.y);for(const b of t.strokes)for(let w=0;w<b.pts.length;w+=2){const[y,I]=U(b.pts[w],b.pts[w+1]);b.pts[w]=y,b.pts[w+1]=I}if(u>0&&A>C){const b=h*x;t.contact={side:i,x:E,y0:C,y1:A,depth:S,press:u,lens:b>.02?{zone:f,gap:d*Math.min(1,x),flare:.22*b*Math.max(0,e.stretch??1),split:f*.1*b*Math.max(0,e.split??1),blur:f*.075*b*Math.max(0,e.blur??1),cy:c}:void 0}}if(D=!1,t.light){const b=t.light;[b.cx,b.cy]=U(b.cx,b.cy);for(const w of b.spec)[w.x,w.y]=U(w.x,w.y)}return t}const bt=Math.PI*2;function kt(t,n,s){return t+(n-t)*s}function Z(t){return t<0?0:t>1?1:t}function yn(t,n,s){const e=Z((s-t)/(n-t));return e*e*(3-2*e)}const jt=t=>t<1e-6?1:Math.sin(t)/t,Te=Math.hypot(2.1,1.3),Re=Math.hypot(1.9,1.7),Ae=Math.hypot(4.3-2.9,-3.7,-3.1),Pe=Math.hypot(4.3+2.9,3.7,-3.1);function Sn(t,n,s,e=1){const o=1/Math.max(.05,e),r=.9*s,c=-.7*s+1.3,l=2.1*s,i=-1.6*s,a=t*(.55*Math.sin(r)*jt(Te*o)+.45*Math.sin(c)*jt(Re*o))+n*.5*(Math.cos(l-i)*jt(Ae*o)-Math.cos(l+i)*jt(Pe*o));return(p,h,f)=>(p*=o,h*=o,f*=o,t*(.55*Math.sin(2.1*p+1.3*h+r)+.45*Math.sin(1.7*f-1.9*h+c))+n*Math.sin(4.3*p-3.1*f+l)*Math.sin(3.7*h+2.9*p+i)-a)}function Tt(t,n){const s=Math.sin(t*12.9898+n*78.233)*43758.5453;return s-Math.floor(s)}function Et(t,n,s){const e=Math.sin(t*127.1+n*311.7+s*74.7)*43758.5453;return e-Math.floor(e)}function Ut(t,n,s){const e=Math.floor(t),o=Math.floor(n),r=Math.floor(s);let c=t-e,l=n-o,i=s-r;c=c*c*(3-2*c),l=l*l*(3-2*l),i=i*i*(3-2*i);const a=kt(Et(e,o,r),Et(e+1,o,r),c),p=kt(Et(e,o+1,r),Et(e+1,o+1,r),c),h=kt(Et(e,o,r+1),Et(e+1,o,r+1),c),f=kt(Et(e,o+1,r+1),Et(e+1,o+1,r+1),c);return kt(kt(a,p,l),kt(h,f,l),i)}function wn(t,n){const s=Math.PI*(3-Math.sqrt(5)),e=1-2*(t+.5)/n,o=Math.sqrt(1-e*e),r=t*s;return[o*Math.cos(r),e,o*Math.sin(r)]}function Qt(t,n,s,e,o){const r=Math.sin(n),c=Math.cos(n),l=Math.sin(t),i=Math.cos(t);return(a,p,h)=>{const f=a*i+h*l,m=-a*l+h*i,d=p*c-m*r,M=p*r+m*c;return[s+f*o,e-d*o,M]}}function zt(t,n=.6){return(t/200)**n}function Nt(t,n,s=.3){const e=[];for(const o of t)(o.a??1)<.02||(o.r=Math.max(s,o.r),e.push(o));return e.sort((o,r)=>o.z-r.z),{dots:e,strokes:n}}const Ht=32;function _e(t,n=0,s=0,e=1){const o=t.r/255,r=t.g/255,c=t.b/255,l=Math.max(o,r,c),i=Math.min(o,r,c);let a=(l+i)/2,p=l===i?0:(l-i)/(1-Math.abs(2*a-1)),h=0;if(l!==i){const M=l-i;h=l===o?(r-c)/M%6:l===r?(c-o)/M+2:(o-r)/M+4,h*=60}h=((h+n)%360+360)%360,p=Math.min(1,p*(1+s)),a=.5+(a-.5)*(1-.6*s),a=Math.max(0,Math.min(1,a*e));const f=M=>(M+h/30)%12,m=p*Math.min(a,1-a),d=M=>a-m*Math.max(-1,Math.min(f(M)-3,9-f(M),1));return[Math.round(d(0)*255),Math.round(d(8)*255),Math.round(d(4)*255)]}function Ce(t){const n=Math.max(0,Math.min(1,t.saturation)),s=Math.max(0,Math.min(1,t.neutral)),e=t.start??.1,o=Math.max(.05,t.width??.6),r=[];for(let h=0;h<Ht;h++){const f=h/(Ht-1),m=Math.max(0,Math.min(1,(f-e)/o)),d=m*m*(3-2*m);r.push(n*(1-s*(1-d)))}const c=t.angle*Math.PI/180,l=Math.cos(c),i=Math.sin(c),a=t.size/2,p=t.size*.8;return{rgb:_e(t.accent,t.hue,Math.max(0,Math.min(1,t.vivid??0)),t.brightness),mix:r,saturation:n,at:(h,f)=>{const m=((h-a)*l+(f-a)*i)/p+.5;return Math.max(0,Math.min(Ht-1,Math.round(m*(Ht-1))))}}}const ke=[120,232,214],Fe=[64,72,255];function On(t,n,s){t/=255,n/=255,s/=255;const e=Math.max(t,n,s),o=Math.min(t,n,s),r=(e+o)/2;if(e===o)return[0,0,r];const c=e-o,l=r>.5?c/(2-e-o):c/(e+o);return[(e===t?(n-s)/c+(n<s?6:0):e===n?(s-t)/c+2:(t-n)/c+4)/6,l,r]}function Ie(t,n,s){const e=c=>(c+t*12)%12,o=n*Math.min(s,1-s),r=c=>s-o*Math.max(-1,Math.min(e(c)-3,9-e(c),1));return[r(0)*255,r(8)*255,r(4)*255]}const un=t=>(t/=255)<=.04045?t/12.92:((t+.055)/1.055)**2.4,Ne=t=>255*(t<=.0031308?12.92*t:1.055*Math.max(0,t)**(1/2.4)-.055);function vn(t,n,s){const[e,o,r]=[un(t),un(n),un(s)],c=Math.cbrt(.4122214708*e+.5363325363*o+.0514459929*r),l=Math.cbrt(.2119034982*e+.6806995451*o+.1073969566*r),i=Math.cbrt(.0883024619*e+.2817188376*o+.6299787005*r);return[.2104542553*c+.793617785*l-.0040720468*i,1.9779984951*c-2.428592205*l+.4505937099*i,.0259040371*c+.7827717662*l-.808675766*i]}function Kn(t,n,s){const e=(t+.3963377774*n+.2158037573*s)**3,o=(t-.1055613458*n-.0638541728*s)**3,r=(t-.0894841775*n-1.291485548*s)**3,c=l=>Math.max(0,Math.min(255,Ne(l)));return[c(4.0767416621*e-3.3077115913*o+.2309699292*r),c(-1.2684380046*e+2.6097574011*o-.3413193965*r),c(-.0041960863*e-.7034186147*o+1.707614701*r)]}function Oe(t,n,s,e){const o=e&&e.amount>.005?e:void 0;return t.map(([r,c,l,i])=>{if(s&&(c+=(s.r-c)*.85,l+=(s.g-l)*.85,i+=(s.b-i)*.85),o){const[,p,h]=On(c,l,i),[f]=On(o.r,o.g,o.b),m=Ie((f+.1*Math.sin(2*Math.PI*r)+1)%1,p,h),d=vn(c,l,i),M=vn(m[0],m[1],m[2]),v=o.amount;[c,l,i]=Kn(d[0]+(M[0]-d[0])*v,d[1]+(M[1]-d[1])*v,d[2]+(M[2]-d[2])*v)}const a=n?1:.82;return[r,c*a,l*a,i*a]})}const Yn=(t,n,s)=>`rgb(${Math.round(t)},${Math.round(n)},${Math.round(s)})`;function Be(t,n=36){const s=t.filter(([a])=>a<1),e=s.length;if(e<3)return t;const o=s.map(([,a,p,h])=>vn(a,p,h)),r=a=>(a%e+e)%e,c=a=>s[r(a)][0]+Math.floor(a/e),l=a=>{const p=c(a+1)-c(a-1);return o[r(a+1)].map((h,f)=>(h-o[r(a-1)][f])/p)},i=[];for(let a=0;a<=n;a++){const p=a/n;let h=-1;for(;h<e-1&&c(h+1)<=p;)h++;const f=c(h+1)-c(h),m=(p-c(h))/f,d=m*m,M=d*m,v=o[r(h)],_=o[r(h+1)],u=l(h),g=l(h+1),x=[0,1,2].map(S=>(2*M-3*d+1)*v[S]+(M-2*d+m)*f*u[S]+(-2*M+3*d)*_[S]+(M-d)*f*g[S]),[O,E,q]=Kn(x[0],x[1],x[2]);i.push([p,O,E,q])}return i}const Le=1.5,jn=typeof CanvasRenderingContext2D=="function"&&"filter"in CanvasRenderingContext2D.prototype,Bn=new WeakMap;function fn(t,n){return(typeof OffscreenCanvas=="function"?new OffscreenCanvas(t,n):Object.assign(document.createElement("canvas"),{width:t,height:n})).getContext("2d")}function qe(t){const{width:n,height:s}=t.canvas;let e=Bn.get(t);return(!e||e.full.canvas.width!==n||e.full.canvas.height!==s)&&(e={full:fn(n,s)},jn||(e.half=fn(Math.ceil(n/2),Math.ceil(s/2)),e.quarter=fn(Math.ceil(n/4),Math.ceil(s/4))),Bn.set(t,e)),e.full.setTransform(1,0,0,1,0,0),e.full.clearRect(0,0,n,s),e.full.setTransform(t.getTransform()),e}function dn(t,n){t.globalCompositeOperation="copy",t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",t.drawImage(n.canvas,0,0,t.canvas.width,t.canvas.height)}function De(t,n,s){const e=t.getTransform();t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation=s,t.globalAlpha=1,t.imageSmoothingEnabled=!0,t.imageSmoothingQuality="high",jn?(t.filter=`blur(${Le*Math.hypot(e.a,e.b)}px)`,t.drawImage(n.full.canvas,0,0)):n.half&&n.quarter&&(dn(n.half,n.full),dn(n.quarter,n.half),dn(n.half,n.quarter),t.drawImage(n.half.canvas,0,0,n.half.canvas.width*2,n.half.canvas.height*2)),t.restore()}function Ln(t,n,s){const e=typeof t.createConicGradient=="function"?t.createConicGradient(n.angle,n.cx,n.cy):t.createLinearGradient(n.cx-n.r,n.cy-n.r,n.cx+n.r,n.cy+n.r);for(const[o,r,c,l]of s)e.addColorStop(Z(o),Yn(r,c,l));return e}function Ge(t,n,s,e,o,r){const c=Be(Oe(s.stops,e,o,r)),l=Ln(t,s,c),i=n.strokes.map(u=>{const g=new Path2D,x=u.pts.length>>1;let O=0;for(let E=0;E<x;E++)E===0?g.moveTo(u.pts[0],u.pts[1]):g.lineTo(u.pts[2*E],u.pts[2*E+1]),O+=u.a[E];return u.closed&&g.closePath(),{p:g,a:x?O/x:1,w:u.w}}),a=Math.max(1,i.length),p=s.intensity,h=e?"lighter":"source-over",f=(u,g,x=t)=>{for(const O of i)x.lineWidth=u(O.w),x.globalAlpha=Z(g(O.a)),x.stroke(O.p)},m=(u,g)=>{u.lineCap="round",u.lineJoin="round",u.globalCompositeOperation=h,u.strokeStyle=g},d=qe(t),M=d.full;m(M,Ln(M,s,c));const v=s.halo*p*(e?1:.2)/a;for(const[u,g]of[[.7,.045],[.42,.075],[.24,.11],[.12,.16]])f(()=>s.r*u,()=>g*v,M);const _=p*(e?1:.6);for(const[u,g]of[[16,.05],[8,.11],[4,.2]])f(x=>x*u,x=>g*_*x,M);if(De(t,d,h),t.save(),m(t,l),e&&s.fringe>0){for(const[u,g,x]of[[1+s.fringe,ke,.16],[1-s.fringe,Fe,.22]])t.save(),t.translate(s.cx,s.cy),t.scale(u,u),t.translate(-s.cx,-s.cy),t.strokeStyle=Yn(g[0],g[1],g[2]),f(O=>O*1.4/u,O=>x*p*O),t.restore();t.strokeStyle=l}if(f(u=>u,u=>.7*u*(.75+.25*p)),e)for(const u of s.spec){const g=t.createRadialGradient(u.x,u.y,0,u.x,u.y,u.r);g.addColorStop(0,"rgba(255,255,255,1)"),g.addColorStop(.35,"rgba(255,255,255,0.45)"),g.addColorStop(1,"rgba(255,255,255,0)"),t.strokeStyle=g,f(x=>x*2.2,x=>u.a*x)}t.restore()}const Ue=`
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const jn=require("react/jsx-runtime"),$=require("react");let Kt=null;function Kn(){if(typeof window>"u")return null;const n=window;return n.AudioContext??n.webkitAudioContext??null}function Ss(){return Kn()!=null}function Rn(){const n=Kn();return n?(Kt||(Kt=new n),Kt.state==="suspended"&&Kt.resume().catch(()=>{}),Kt):null}const mn=new WeakMap;function Hn(n){const s=Rn();if(!s||n.getAudioTracks().length===0)return null;let e=mn.get(n);e||(e={node:s.createMediaStreamSource(n),refs:0},mn.set(n,e)),e.refs+=1;const t=s.createAnalyser();t.fftSize=1024,t.smoothingTimeConstant=.5,e.node.connect(t);let o=!1;return{analyser:t,release:()=>{if(!o){o=!0;try{e.node.disconnect(t)}catch{}if(e.refs-=1,e.refs<=0){try{e.node.disconnect()}catch{}mn.delete(n)}}}}}const Ft={positive:{r:92,g:224,b:150},negative:{r:255,g:104,b:104},calm:{r:104,g:162,b:255}},Zn={green:Ft.positive,red:Ft.negative,blue:Ft.calm},ws=.7,Es=1.1,Ts=.6;class Rs{constructor(){this.glow={r:0,g:0,b:0,amount:0,t:0,size:0}}step(s,e,t,o,r){const c=this.glow,l=a=>r?1:1-Math.exp(-s/a),i=e?1:0;if(c.amount+=(i-c.amount)*l(i>c.amount?ws:Es),e){const a=c.amount<.03?1:l(Ts);c.r+=(e.r-c.r)*a,c.g+=(e.g-c.g)*a,c.b+=(e.b-c.b)*a}return c.t=t,c.size=o,c}}const Jn=(n,s)=>{var e;return((e=n.light)==null?void 0:e.r)??s*.28};function As(n,s,e){const o=(Jn(n,s)*.7)**2,r=.9*Math.min(1,Math.max(0,e.amount)),c=(l,i)=>{const a=e.x-l,f=e.y-i,h=r*Math.exp(-(a*a+f*f)/o);return[l+a*h,i+f*h]};return{...n,strokes:n.strokes.map(l=>{const i=l.pts.slice();for(let a=0;a<i.length;a+=2)[i[a],i[a+1]]=c(i[a],i[a+1]);return{...l,pts:i}}),dots:n.dots.map(l=>{const[i,a]=c(l.x,l.y);return{...l,x:i,y:a}})}}const Ps=(n,s)=>Math.min(1,Math.max(0,(.8*s-n)/(.6*s))),Pt={move:2,pull:.7,deform:.1,squash:.5,lens:.67,stretch:1,split:1,blur:1,bounce:1};function Cs(n,s){const e=Math.abs(n.move)+Math.abs(n.pull)+2*Math.abs(n.deform);return e===0?0:Math.ceil(s*.36*e)+2}class _s{constructor(){this.x=0,this.v=0,this.landed=!1}step(s,e){const r=Math.max(1,Math.ceil(e*240)),c=e/r;for(let i=0;i<r;i++)this.v+=(15*15*(s-this.x)-2*.3*15*this.v)*c,this.x+=this.v*c;const l=this.x-s;return s<=0?this.landed=!1:l>=0&&(this.landed=!0),l<0&&!this.landed?0:l}}function Bs(n,s,e,t,o=[1/0,1/0],r=0){if(Math.abs(s)<.002||t.move===0&&t.pull===0&&t.deform===0)return n;const c=e/2,l=e*.36,i=s<0?-1:1,a=Math.abs(s),f=(S,T)=>{const F=(S-c)/l,P=(T-c)/l,w=Math.max(0,Math.min(1,(F*i+1)/2)),I=Math.max(0,F*i);return s*l*(t.move+t.pull*w*w+t.deform*I*I*Math.exp(-P*P*1.5))},h=Math.max(0,Math.min(2,t.lens??1)),u=l*.9,p=i>0?o[1]:o[0],d=Number.isFinite(p)?Math.min(u*.45,l*.3*h*Math.max(0,t.stretch??1)):0;let g=1,M=1/0,y=1;if(Number.isFinite(p)){M=i>0?e+p:-p;const S=(T,F,P)=>{y=Math.max(y,P);const w=f(T,F)*i;w>1e-9&&(g=Math.min(g,Math.max(0,((M-T)*i-P-d)/w)))};for(const T of n.dots)S(T.x,T.y,T.r);for(const T of n.strokes)for(let F=0;F<T.pts.length;F+=2)S(T.pts[F],T.pts[F+1],1)}const m=g<1?Math.min(1,(1-g)/.35):0,R=m>0?r*(t.bounce??1):0,b=Math.min(1.4,m+Math.max(0,R)),A=l*.12*Math.max(0,-R),v=M-i*y,E=v-i*d,x=l*.55*b*(t.squash??0);let N=1/0,_=-1/0,k=!0;const B=(S,T)=>{const F=Math.max(0,Math.min(1,((S-c)/l*i+1)/2)),P=1-.15*t.deform*a*g*F;let w=S+f(S,T)*g+i*(x*.5-A),I=c+(T-c)*P;if(x>0){const z=(w-(E-i*x))*i;if(z>0){const L=z/x,C=x*(L/Math.sqrt(1+L*L));w=E-i*x+i*C,I=c+(I-c)*(1+.18*b*(t.squash??0)*(C/x))}}return k&&(E-w)*i<Math.max(x,u*.3)&&(N=Math.min(N,I),_=Math.max(_,I)),[w,I]};for(const S of n.dots)[S.x,S.y]=B(S.x,S.y);for(const S of n.strokes)for(let T=0;T<S.pts.length;T+=2){const[F,P]=B(S.pts[T],S.pts[T+1]);S.pts[T]=F,S.pts[T+1]=P}if(m>0&&_>N){const S=h*b;n.contact={side:i,x:v,y0:N,y1:_,depth:x,press:m,lens:S>.02?{zone:u,gap:d*Math.min(1,b),flare:.22*S*Math.max(0,t.stretch??1),split:u*.1*S*Math.max(0,t.split??1),blur:u*.075*S*Math.max(0,t.blur??1),cy:c}:void 0}}if(k=!1,n.light){const S=n.light;[S.cx,S.cy]=B(S.cx,S.cy);for(const T of S.spec)[T.x,T.y]=B(T.x,T.y)}return n}const gt=Math.PI*2;function Lt(n,s,e){return n+(s-n)*e}function W(n){return n<0?0:n>1?1:n}function Zt(n,s,e){const t=W((e-n)/(s-n));return t*t*(3-2*t)}const nn=n=>n<1e-6?1:Math.sin(n)/n,Is=Math.hypot(2.1,1.3),Fs=Math.hypot(1.9,1.7),Ns=Math.hypot(4.3-2.9,-3.7,-3.1),Os=Math.hypot(4.3+2.9,3.7,-3.1);function An(n,s,e,t=1){const o=1/Math.max(.05,t),r=.9*e,c=-.7*e+1.3,l=2.1*e,i=-1.6*e,a=n*(.55*Math.sin(r)*nn(Is*o)+.45*Math.sin(c)*nn(Fs*o))+s*.5*(Math.cos(l-i)*nn(Ns*o)-Math.cos(l+i)*nn(Os*o));return(f,h,u)=>(f*=o,h*=o,u*=o,n*(.55*Math.sin(2.1*f+1.3*h+r)+.45*Math.sin(1.7*u-1.9*h+c))+s*Math.sin(4.3*f-3.1*u+l)*Math.sin(3.7*h+2.9*f+i)-a)}function Nt(n,s){const e=Math.sin(n*12.9898+s*78.233)*43758.5453;return e-Math.floor(e)}function It(n,s,e){const t=Math.sin(n*127.1+s*311.7+e*74.7)*43758.5453;return t-Math.floor(t)}function Ht(n,s,e){const t=Math.floor(n),o=Math.floor(s),r=Math.floor(e);let c=n-t,l=s-o,i=e-r;c=c*c*(3-2*c),l=l*l*(3-2*l),i=i*i*(3-2*i);const a=Lt(It(t,o,r),It(t+1,o,r),c),f=Lt(It(t,o+1,r),It(t+1,o+1,r),c),h=Lt(It(t,o,r+1),It(t+1,o,r+1),c),u=Lt(It(t,o+1,r+1),It(t+1,o+1,r+1),c);return Lt(Lt(a,f,l),Lt(h,u,l),i)}function Pn(n,s){const e=Math.PI*(3-Math.sqrt(5)),t=1-2*(n+.5)/s,o=Math.sqrt(1-t*t),r=n*e;return[o*Math.cos(r),t,o*Math.sin(r)]}function cn(n,s,e,t,o){const r=Math.sin(s),c=Math.cos(s),l=Math.sin(n),i=Math.cos(n);return(a,f,h)=>{const u=a*i+h*l,p=-a*l+h*i,d=f*c-p*r,g=f*r+p*c;return[e+u*o,t-d*o,g]}}function $t(n,s=.6){return(n/200)**s}function Wt(n,s,e=.3){const t=[];for(const o of n)(o.a??1)<.02||(o.r=Math.max(e,o.r),t.push(o));return t.sort((o,r)=>o.z-r.z),{dots:t,strokes:s}}const sn=32;function ks(n,s=0,e=0,t=1){const o=n.r/255,r=n.g/255,c=n.b/255,l=Math.max(o,r,c),i=Math.min(o,r,c);let a=(l+i)/2,f=l===i?0:(l-i)/(1-Math.abs(2*a-1)),h=0;if(l!==i){const g=l-i;h=l===o?(r-c)/g%6:l===r?(c-o)/g+2:(o-r)/g+4,h*=60}h=((h+s)%360+360)%360,f=Math.min(1,f*(1+e)),a=.5+(a-.5)*(1-.6*e),a=Math.max(0,Math.min(1,a*t));const u=g=>(g+h/30)%12,p=f*Math.min(a,1-a),d=g=>a-p*Math.max(-1,Math.min(u(g)-3,9-u(g),1));return[Math.round(d(0)*255),Math.round(d(8)*255),Math.round(d(4)*255)]}function zs(n){const s=Math.max(0,Math.min(1,n.saturation)),e=Math.max(0,Math.min(1,n.neutral)),t=n.start??.1,o=Math.max(.05,n.width??.6),r=[];for(let h=0;h<sn;h++){const u=h/(sn-1),p=Math.max(0,Math.min(1,(u-t)/o)),d=p*p*(3-2*p);r.push(s*(1-e*(1-d)))}const c=n.angle*Math.PI/180,l=Math.cos(c),i=Math.sin(c),a=n.size/2,f=n.size*.8;return{rgb:ks(n.accent,n.hue,Math.max(0,Math.min(1,n.vivid??0)),n.brightness),mix:r,saturation:s,at:(h,u)=>{const p=((h-a)*l+(u-a)*i)/f+.5;return Math.max(0,Math.min(sn-1,Math.round(p*(sn-1))))}}}const Ls=[120,232,214],qs=[64,72,255];function qn(n,s,e){n/=255,s/=255,e/=255;const t=Math.max(n,s,e),o=Math.min(n,s,e),r=(t+o)/2;if(t===o)return[0,0,r];const c=t-o,l=r>.5?c/(2-t-o):c/(t+o);return[(t===n?(s-e)/c+(s<e?6:0):t===s?(e-n)/c+2:(n-s)/c+4)/6,l,r]}function Gs(n,s,e){const t=c=>(c+n*12)%12,o=s*Math.min(e,1-e),r=c=>e-o*Math.max(-1,Math.min(t(c)-3,9-t(c),1));return[r(0)*255,r(8)*255,r(4)*255]}const Mn=n=>(n/=255)<=.04045?n/12.92:((n+.055)/1.055)**2.4,Ds=n=>255*(n<=.0031308?12.92*n:1.055*Math.max(0,n)**(1/2.4)-.055);function an(n,s,e){const[t,o,r]=[Mn(n),Mn(s),Mn(e)],c=Math.cbrt(.4122214708*t+.5363325363*o+.0514459929*r),l=Math.cbrt(.2119034982*t+.6806995451*o+.1073969566*r),i=Math.cbrt(.0883024619*t+.2817188376*o+.6299787005*r);return[.2104542553*c+.793617785*l-.0040720468*i,1.9779984951*c-2.428592205*l+.4505937099*i,.0259040371*c+.7827717662*l-.808675766*i]}function Cn(n,s,e){const t=(n+.3963377774*s+.2158037573*e)**3,o=(n-.1055613458*s-.0638541728*e)**3,r=(n-.0894841775*s-1.291485548*e)**3,c=l=>Math.max(0,Math.min(255,Ds(l)));return[c(4.0767416621*t-3.3077115913*o+.2309699292*r),c(-1.2684380046*t+2.6097574011*o-.3413193965*r),c(-.0041960863*t-.7034186147*o+1.707614701*r)]}const Us=146/360,$s=[81,136],Gn=.1;function Ws(n,s=$s){const e=(s[0]+s[1])/720,t=(s[1]-s[0])/720,o=Math.abs((n-Us+1.5)%1-.5),r=Math.max(0,1-o/(40/360));return[n+(e-n)*r,Gn+(t-Gn)*r]}function Vs(n,s,e,t,o){const r=t&&t.amount>.005?t:void 0;return n.map(([c,l,i,a])=>{if(e&&(l+=(e.r-l)*.85,i+=(e.g-i)*.85,a+=(e.b-a)*.85),r){const[,h,u]=qn(l,i,a),[p,d]=Ws(qn(r.r,r.g,r.b)[0],o),g=Gs((p+d*Math.sin(2*Math.PI*c)+1)%1,h,u),M=an(l,i,a),y=an(g[0],g[1],g[2]),m=r.amount;[l,i,a]=Cn(M[0]+(y[0]-M[0])*m,M[1]+(y[1]-M[1])*m,M[2]+(y[2]-M[2])*m)}const f=s?1:.82;return[c,l*f,i*f,a*f]})}function Xs(n,s){if(!s.hue&&s.chroma===1&&!s.warmth&&s.contrast===1)return n;const e=n.map(([,c,l,i])=>an(c,l,i)),t=e.reduce((c,[l])=>c+l,0)/e.length,o=Math.cos(s.hue*Math.PI/180),r=Math.sin(s.hue*Math.PI/180);return n.map(([c],l)=>{const[i,a,f]=e[l],h=Math.max(0,Math.min(1,t+(i-t)*s.contrast)),u=(a*o-f*r)*s.chroma+.02*s.warmth,p=(a*r+f*o)*s.chroma+.07*s.warmth;return[c,...Cn(h,u,p)]})}function Ys(n,s){if(s<=1)return n;const e=[];for(let t=0;t<s;t++)for(const[o,r,c,l]of n)e.push([(o+t)/s,r,c,l]);return e}const gn={hue:0,chroma:1,warmth:0,contrast:1,cycles:1,glowSize:1,bloom:1,bloomSize:1,soft:1.5,core:1},Qn=(n,s,e)=>`rgb(${Math.round(n)},${Math.round(s)},${Math.round(e)})`;function js(n,s=36){const e=n.filter(([a])=>a<1),t=e.length;if(t<3)return n;const o=e.map(([,a,f,h])=>an(a,f,h)),r=a=>(a%t+t)%t,c=a=>e[r(a)][0]+Math.floor(a/t),l=a=>{const f=c(a+1)-c(a-1);return o[r(a+1)].map((h,u)=>(h-o[r(a-1)][u])/f)},i=[];for(let a=0;a<=s;a++){const f=a/s;let h=-1;for(;h<t-1&&c(h+1)<=f;)h++;const u=c(h+1)-c(h),p=(f-c(h))/u,d=p*p,g=d*p,M=o[r(h)],y=o[r(h+1)],m=l(h),R=l(h+1),b=[0,1,2].map(x=>(2*g-3*d+1)*M[x]+(g-2*d+p)*u*m[x]+(-2*g+3*d)*y[x]+(g-d)*u*R[x]),[A,v,E]=Cn(b[0],b[1],b[2]);i.push([f,A,v,E])}return i}const ts=typeof CanvasRenderingContext2D=="function"&&"filter"in CanvasRenderingContext2D.prototype,Dn=new WeakMap;function bn(n,s){return(typeof OffscreenCanvas=="function"?new OffscreenCanvas(n,s):Object.assign(document.createElement("canvas"),{width:n,height:s})).getContext("2d")}function Ks(n){const{width:s,height:e}=n.canvas;let t=Dn.get(n);return(!t||t.full.canvas.width!==s||t.full.canvas.height!==e)&&(t={full:bn(s,e)},ts||(t.half=bn(Math.ceil(s/2),Math.ceil(e/2)),t.quarter=bn(Math.ceil(s/4),Math.ceil(e/4))),Dn.set(n,t)),t.full.setTransform(1,0,0,1,0,0),t.full.clearRect(0,0,s,e),t.full.setTransform(n.getTransform()),t}function vn(n,s){n.globalCompositeOperation="copy",n.imageSmoothingEnabled=!0,n.imageSmoothingQuality="high",n.drawImage(s.canvas,0,0,n.canvas.width,n.canvas.height)}function Hs(n,s,e,t){const o=n.getTransform();n.save(),n.setTransform(1,0,0,1,0,0),n.globalCompositeOperation=e,n.globalAlpha=1,n.imageSmoothingEnabled=!0,n.imageSmoothingQuality="high",ts||t<=0?(t>0&&(n.filter=`blur(${t*Math.hypot(o.a,o.b)}px)`),n.drawImage(s.full.canvas,0,0)):s.half&&s.quarter&&(vn(s.half,s.full),vn(s.quarter,s.half),vn(s.half,s.quarter),n.drawImage(s.half.canvas,0,0,s.half.canvas.width*2,s.half.canvas.height*2)),n.restore()}function Un(n,s,e){const t=typeof n.createConicGradient=="function"?n.createConicGradient(s.angle,s.cx,s.cy):n.createLinearGradient(s.cx-s.r,s.cy-s.r,s.cx+s.r,s.cy+s.r);for(const[o,r,c,l]of e)t.addColorStop(W(o),Qn(r,c,l));return t}function Zs(n,s,e,t,o,r){var R;const c={...gn};for(const b of Object.keys(gn))c[b]=((R=e.look)==null?void 0:R[b])??gn[b];const l=Ys(js(Vs(Xs(e.stops,c),t,o,r,e.green)),Math.round(c.cycles)),i=Un(n,e,l),a=s.strokes.map(b=>{const A=new Path2D,v=b.pts.length>>1;let E=0;for(let x=0;x<v;x++)x===0?A.moveTo(b.pts[0],b.pts[1]):A.lineTo(b.pts[2*x],b.pts[2*x+1]),E+=b.a[x];return b.closed&&A.closePath(),{p:A,a:v?E/v:1,w:b.w}}),f=Math.max(1,a.length),h=e.intensity,u=t?"lighter":"source-over",p=(b,A,v=n)=>{for(const E of a)v.lineWidth=b(E.w),v.globalAlpha=W(A(E.a)),v.stroke(E.p)},d=(b,A)=>{b.lineCap="round",b.lineJoin="round",b.globalCompositeOperation=u,b.strokeStyle=A},g=Ks(n),M=g.full;d(M,Un(M,e,l));const y=e.halo*h*(t?1:.2)/f;for(const[b,A]of[[.7,.045],[.42,.075],[.24,.11],[.12,.16]])p(()=>e.r*b*c.glowSize,()=>A*y,M);const m=h*(t?1:.6)*c.bloom;for(const[b,A]of[[16,.05],[8,.11],[4,.2]])p(v=>v*b*c.bloomSize,v=>A*m*v,M);if(Hs(n,g,u,c.soft),n.save(),d(n,i),t&&e.fringe>0){for(const[b,A,v]of[[1+e.fringe,Ls,.16],[1-e.fringe,qs,.22]])n.save(),n.translate(e.cx,e.cy),n.scale(b,b),n.translate(-e.cx,-e.cy),n.strokeStyle=Qn(A[0],A[1],A[2]),p(E=>E*1.4/b,E=>v*h*E),n.restore();n.strokeStyle=i}if(p(b=>b,b=>.7*b*(.75+.25*h)*c.core),t)for(const b of e.spec){const A=n.createRadialGradient(b.x,b.y,0,b.x,b.y,b.r);A.addColorStop(0,"rgba(255,255,255,1)"),A.addColorStop(.35,"rgba(255,255,255,0.45)"),A.addColorStop(1,"rgba(255,255,255,0)"),n.strokeStyle=A,p(v=>v*2.2,v=>b.a*v)}n.restore()}const $n=6;function Js(n,s){const e=[[Ft.positive,n.positiveBrightness??1],[Ft.negative,n.negativeBrightness??1],[Ft.calm,n.calmBrightness??1]];let t=0,o=0;for(const[r,c]of e){const l=Math.exp(-((s.r-r.r)**2+(s.g-r.g)**2+(s.b-r.b)**2)/6e3);t+=l*c,o+=l}return o>1e-6?t/o:1}function yn(n,s,e,t,o,r=1){const c=s?255*(.16+.84*n):255*(.1+.6*(1-n));let l=c,i=c,a=c;if(t){const h=u=>s?u*c/255:u+(255-u)*(c/255)*.7;l+=(h(t.r)-l)*.85,i+=(h(t.g)-i)*.85,a+=(h(t.b)-a)*.85}if(o){const h=(e.colorBrightness??1)*Js(e,o),u=g=>s?Math.min(255,g*(.3+.9*n)*h+90*n**4):Math.min(255,g*(.45+.55*(1-n))*h),p=o.amount*r;l+=(u(o.r)-l)*p,i+=(u(o.g)-i)*p,a+=(u(o.b)-a)*p;const d=e.saturation??1;if(d!==1){const g=(l+i+a)/3;l=g+(l-g)*d,i=g+(i-g)*d,a=g+(a-g)*d}}const f=h=>Math.round(Math.max(0,Math.min(255,h)));return`rgb(${f(l)},${f(i)},${f(a)})`}function Qs(n,s,e,t,o,r){var g;const c=(M,y)=>W(.5+(M.a[y]-.5)*e.contrast),l=[];for(const M of s){const y=M.pts.length>>1,m=M.closed?y:y-1;for(let R=0;R<m;R+=$n){const b=Math.min(m,R+$n);let A=0;for(let E=R;E<=b;E++)A+=((g=M.z)==null?void 0:g[E%y])??0;const v=M.closed?R-1:Math.max(0,R-1);l.push({s:M,from:v,to:b,z:A/(b-R+1)})}}l.sort((M,y)=>M.z-y.z);const i=r&&r.amount>.005?r:void 0;let a=0,f=0,h=0;if(i){for(const M of s)for(let y=0;y<M.pts.length;y+=2)a+=M.pts[y],f+=M.pts[y+1],h++;a/=h||1,f/=h||1}const u=((e.gradientAngle??0)+(e.gradientSpin??20)*((r==null?void 0:r.t)??0))*Math.PI/180,p=W(e.gradient??1),d=(M,y)=>{if(!i)return 1;const m=(Math.sin(Math.atan2(M.pts[2*y+1]-f,M.pts[2*y]-a)+u)+1)/2;return 1-p*(1-Zt(0,1,m))};n.save(),n.lineCap="butt",n.lineJoin="round";for(const{s:M,from:y,to:m,z:R}of l){const b=M.pts.length>>1,A=w=>(w%b+b)%b,v=new Path2D;for(let w=y;w<=m;w++){const I=A(w);w===y?v.moveTo(M.pts[2*I],M.pts[2*I+1]):v.lineTo(M.pts[2*I],M.pts[2*I+1])}const E=A(y),x=A(m),N=e.depth??.15,_=M.w*(1-N+N*R);n.globalCompositeOperation="destination-out",n.strokeStyle="#000",n.lineWidth=_*1.35,n.stroke(v),n.globalCompositeOperation="source-over";const k=M.pts[2*E],B=M.pts[2*E+1],S=M.pts[2*x],T=M.pts[2*x+1];if(Math.hypot(S-k,T-B)>.5){const w=n.createLinearGradient(k,B,S,T);w.addColorStop(0,yn(c(M,E),t,e,o,i,d(M,E))),w.addColorStop(1,yn(c(M,x),t,e,o,i,d(M,x))),n.strokeStyle=w}else n.strokeStyle=yn(c(M,E),t,e,o,i,d(M,E));n.lineWidth=_,n.stroke(v);let F=0;for(let w=y;w<=m;w++)F+=c(M,A(w));F/=m-y+1;const P=W(e.shine*(t?.6:.45)*F*F);P>.01&&(n.save(),n.translate(-.17*_,-.19*_),n.strokeStyle=`rgba(255,255,255,${P.toFixed(3)})`,n.lineWidth=_*.32,n.stroke(v),n.restore())}n.restore()}const te=`
|
|
2
2
|
attribute vec2 aPos;
|
|
3
3
|
varying vec2 vUv;
|
|
4
4
|
void main() {
|
|
5
5
|
vUv = vec2(aPos.x + 1.0, 1.0 - aPos.y) * 0.5;
|
|
6
6
|
gl_Position = vec4(aPos, 0.0, 1.0);
|
|
7
|
-
}`,
|
|
7
|
+
}`,ne=`
|
|
8
8
|
precision highp float;
|
|
9
9
|
uniform sampler2D uTex;
|
|
10
10
|
uniform vec2 uSize;
|
|
@@ -38,4 +38,4 @@ void main() {
|
|
|
38
38
|
a += max(cg.a, max(cr.a, cb.a));
|
|
39
39
|
}
|
|
40
40
|
gl_FragColor = vec4(rgb, a) / float(TAPS);
|
|
41
|
-
}`;let Zt;function $e(){if(typeof document>"u")return null;const t=document.createElement("canvas"),n=t.getContext("webgl",{premultipliedAlpha:!0,antialias:!1,depth:!1});if(!n)return null;const s=(i,a)=>{const p=n.createShader(i);return n.shaderSource(p,a),n.compileShader(p),p},e=n.createProgram();if(n.attachShader(e,s(n.VERTEX_SHADER,Ue)),n.attachShader(e,s(n.FRAGMENT_SHADER,ze)),n.linkProgram(e),!n.getProgramParameter(e,n.LINK_STATUS))return null;n.useProgram(e);const o=n.createBuffer();n.bindBuffer(n.ARRAY_BUFFER,o),n.bufferData(n.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),n.STATIC_DRAW);const r=n.getAttribLocation(e,"aPos");n.enableVertexAttribArray(r),n.vertexAttribPointer(r,2,n.FLOAT,!1,0,0);const c=n.createTexture();n.bindTexture(n.TEXTURE_2D,c),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_S,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_WRAP_T,n.CLAMP_TO_EDGE),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MIN_FILTER,n.LINEAR),n.texParameteri(n.TEXTURE_2D,n.TEXTURE_MAG_FILTER,n.LINEAR),n.pixelStorei(n.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);const l={};for(const i of["uSize","uWall","uSide","uZone","uGap","uFlare","uSplit","uBlur","uCy"])l[i]=n.getUniformLocation(e,i);return{gl:n,canvas:t,source:document.createElement("canvas"),tex:c,u:l}}function We(t,n,s,e){if(Zt===void 0&&(Zt=$e()),!Zt)return!1;const{gl:o,canvas:r,source:c,tex:l,u:i}=Zt,a=t.getTransform(),p=Math.hypot(a.a,a.b)||1,h=t.canvas.width,f=t.canvas.height,m=a.a*s+a.e,d=e.zone*p,M=e.blur*p,v=Math.max(0,Math.floor(n>0?m-d-2*M-4:0)),u=Math.min(h,Math.ceil(n>0?h:m+d+2*M+4))-v;if(u<2||f<2)return!1;(c.width!==u||c.height!==f)&&(c.width=u,c.height=f);const g=c.getContext("2d");return g.clearRect(0,0,u,f),g.drawImage(t.canvas,v,0,u,f,0,0,u,f),(r.width!==u||r.height!==f)&&(r.width=u,r.height=f),o.viewport(0,0,u,f),o.bindTexture(o.TEXTURE_2D,l),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,c),o.uniform2f(i.uSize,u,f),o.uniform1f(i.uWall,m-v),o.uniform1f(i.uSide,n),o.uniform1f(i.uZone,d),o.uniform1f(i.uGap,e.gap*p),o.uniform1f(i.uFlare,e.flare),o.uniform1f(i.uSplit,e.split*p),o.uniform1f(i.uBlur,M),o.uniform1f(i.uCy,a.d*e.cy+a.f),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLE_STRIP,0,4),t.save(),t.setTransform(1,0,0,1,0,0),t.globalCompositeOperation="copy",t.beginPath(),t.rect(v,0,u,f),t.clip(),t.drawImage(r,v,0),t.restore(),!0}function Hn(t,n,s,e){const o=2.2/e.size,r=Ut(t*o+e.t*.11,n*o-e.t*.08,e.t*.07),c=yn(.3,.75,r);return e.amount*(.2+.75*c)*Z(1.3-s)}function Zn(t,n,s,e,o,r=0,c,l=0){const i=Math.round(n*1e3)/1e3,a=d=>s?d*(1-t):d+(255-d)*t,p=(s?1-t:t)*255;let h=e?a(e.r):p,f=e?a(e.g):p,m=e?a(e.b):p;return c&&l>0&&(h+=(a(c[0])-h)*l,f+=(a(c[1])-f)*l,m+=(a(c[2])-m)*l),o&&r>0&&(h+=(a(o.r)-h)*r,f+=(a(o.g)-f)*r,m+=(a(o.b)-m)*r),`rgba(${Math.round(h)},${Math.round(f)},${Math.round(m)},${i})`}const qn=24,Dn=8;function Ve(t,n,s,e,o,r){const c=o&&o.amount>.005?o:void 0,l=r&&r.saturation>0?r:void 0,i=new Map;for(const a of n){const p=a.pts.length>>1,h=a.closed?p:p-1;let f="",m;for(let d=0;d<h;d++){const M=d+1===p?0:d+1,v=Math.round(Z((a.a[d]+a.a[M])/2)*qn);if(v===0){f="";continue}const _=c?Math.round(Hn((a.pts[2*d]+a.pts[2*M])/2,(a.pts[2*d+1]+a.pts[2*M+1])/2,a.white,c)*Dn):0,u=l?l.at((a.pts[2*d]+a.pts[2*M])/2,(a.pts[2*d+1]+a.pts[2*M+1])/2):0,g=`${v}|${a.white}|${Math.round(a.w*20)}|${_}|${u}`;if(g!==f){let x=i.get(g);x||(x={path:new Path2D,white:a.white,w:a.w,a:v/qn,gw:_/Dn,ci:u},i.set(g,x)),m=x,f=g,x.path.moveTo(a.pts[2*d],a.pts[2*d+1])}m.path.lineTo(a.pts[2*M],a.pts[2*M+1])}}t.lineCap="round",t.lineJoin="round";for(const a of i.values())t.strokeStyle=Zn(Z(a.white),a.a,s,e,c,a.gw,l==null?void 0:l.rgb,l==null?void 0:l.mix[a.ci]),t.lineWidth=a.w,t.stroke(a.path)}function Xe(t,n,s,e,o,r,c=!1){const l=o&&o.amount>.005?o:void 0,i=r&&r.saturation>0?r:void 0;for(const a of n){const p=Z(a.white),h=l?Hn(a.x,a.y,p,l):0,f=i?i.at(a.x,a.y):0;if(t.fillStyle=Zn(p,Z(a.a??1),s,e,l,h,i==null?void 0:i.rgb,i==null?void 0:i.mix[f]),c){t.fillRect(a.x-a.r,a.y-a.r,2*a.r,2*a.r);continue}t.beginPath(),t.arc(a.x,a.y,a.r,0,bt),t.fill()}}function Ke(t,n,s,e,o,r){var l;const c=r&&r.saturation>0&&!n.light?Ce(r):void 0;n.light?Ge(t,n,n.light,s,e,o):n.strokes.length&&Ve(t,n.strokes,s,e,o,c),Xe(t,n.dots,s,e,o,c,n.square),(l=n.contact)!=null&&l.lens&&We(t,n.contact.side,n.contact.x,n.contact.lens)}const Ye=[[0,255,150,90],[.12,255,110,120],[.24,255,80,170],[.4,190,80,255],[.58,90,92,255],[.74,60,132,255],[.84,170,90,255],[.93,240,104,165],[1,255,150,90]],je=(t,n,s,e)=>{const o=t/2,r=s.level,[c,l]=s.softBands,i=s.bands[2],a=s.drive,p=s.processing,h=.5*r+.5*s.soft,f=o*(e.radius??.56)*(1+(e.zoom??.17)*s.soft)*(1-.06*p),m=e.deform??1.45,d=.02+(.14*c+.06*r)*m,M=.01+(.07*l+.03*i)*m,v=Sn(d,M,a,e.deformRadius??1.75),_=Math.max(.6,(e.lineW??1.85)*zt(t,.5)),u=Math.max(1,Math.round(e.rings??6)),g=Math.max(24,Math.round(e.segs??140)),x=e.lean??.91,O=e.ringGap??.02,E=[];let q=0,S=0;for(let y=0;y<u;y++){const I=.16*(.5+Tt(y,2.1))*(y%2?1:-1),R=Math.max(.02,x*(.2+.8*Tt(y,3.1))+.03*Math.sin(n*.27+y*1.3)+.08*Math.sin(a*.35+y*1.7)),B=Tt(y,7.7)*bt+n*.05*(y%2?1:-1)+a*I,k=Math.sin(R)*Math.cos(B),F=Math.sin(R)*Math.sin(B),T=Math.cos(R),P=Math.hypot(k,T),N=T/P,G=-k/P,z=F*G,V=T*N-k*G,X=-F*N,tt=f*(1+O*(y-(u-1)/2)),J=Math.sin(R),K=[],ct=[],st=[];for(let Y=0;Y<g;Y++){const ot=Y/g*bt,W=Math.cos(ot),ut=Math.sin(ot),ft=N*W+z*ut,nt=V*ut,dt=G*W+X*ut,pt=v(ft,nt,dt);K.push(ft,nt),ct.push(pt),q+=pt,S++,st.push(.62+.38*Z((dt/J+1)/2))}E.push({dirs:K,f:ct,a:st,rk:tt})}const C=S?q/S:0;let A=0,D=0;for(const{dirs:y,f:I}of E)for(let R=0;R<I.length;R++){const B=y[2*R],k=y[2*R+1],F=Math.hypot(B,k)||1;A+=(I[R]-C)*(B/F),D+=(I[R]-C)*(k/F)}A=S?2*A/S:0,D=S?2*D/S:0;const U=E.map(({dirs:y,f:I,a:R,rk:B})=>{const k=[];for(let F=0;F<I.length;F++){const T=y[2*F],P=y[2*F+1],N=Math.hypot(T,P)||1,G=B*(1+I[F]-C-A*(T/N)-D*(P/N));k.push(o+T*G,o-P*G)}return{pts:k,a:R,white:0,w:_,closed:!0}}),b=2.3+.25*Math.sin(n*.21)+2*s.spin,w={cx:o,cy:o,r:f,stops:Ye,angle:-Math.PI/2-.35+.5*Math.sin(n*.07)+.4*Math.sin(a*.2)+s.spin,intensity:.62+.55*h+.5*p,halo:(e.halo??.5)*(1+.6*p),spec:[{x:o+Math.cos(b)*f,y:o+Math.sin(b)*f,r:f*(.5+.25*p),a:.5+.35*h+.4*p}],fringe:.016+.012*h};return{...Nt([],U),light:w}},Jn=-.45,Qn=.55,te=.7,He=Math.hypot(Jn,Qn,te),Ze=(t,n,s,e)=>{const o=t/2,r=s.level,[c,l,i]=s.bands,a=s.drive,p=s.processing,h=o*(e.radius??.72),f=h*(1+(e.zoom??.3)*r)*(1-.06*p),m=e.rMul??1,d=Math.max(4,Math.round(e.cells??17)),M=2*h/d,v=M/2-Math.max(.5,M*(e.gap??.24)/2),_=Math.ceil(f*1.25/M),u=(e.turn??.12)*n+.1*a+.5*s.spin,g=Math.sin(u),x=Math.cos(u),O=Math.sin(.35),E=Math.cos(.35),q=e.shade??.7,S=e.texture??.35,C=e.fade??1.3,A=e.strength??1.38,D=e.deform??1.7,U=.012+(.09*c+.03*r)*D,b=(.035*l+.025*i)*D,w=k=>U*(.55*Math.sin(2*k+.9*a)+.45*Math.sin(3*k-.7*a+1.3))+b*Math.sin(7*k+2.3*a)*Math.sin(5*k-1.7*a),y=.95*Math.sin(n*1.3),I=s.spectrum,R=I.length,B=[];for(let k=-_;k<=_;k++)for(let F=-_;F<=_;F++){const T=o+F*M,P=o+k*M,N=(T-o)/f,G=-(P-o)/f,z=w(Math.atan2(G,N)),V=Math.hypot(N,G)/(1+z);if(V>=1)continue;const X=1/(1+z),tt=N*X,J=G*X,K=Math.sqrt(Math.max(0,1-tt*tt-J*J)),ct=Z((tt*Jn+J*Qn+K*te)/He),st=1-q+q*ct,Y=J*E+K*O,ot=-J*O+K*E,W=tt*x-ot*g,ut=tt*g+ot*x,ft=.65*Ut(W*2.2+a*.15,Y*2.2,ut*2.2-a*.1)+.35*Ut(W*4.6-a*.2,Y*4.6+7.3,ut*4.6),nt=1-S+S*yn(.32,.68,ft),dt=R?I[Math.min(R-1,Math.floor(V*R))]:r,pt=.35*r+.85*dt,Rt=Math.exp(-((J-y)**2)/.01)*p,$t=1-.4*C*(1-K),rt=(.35+.75*st*nt+.3*pt+.2*Rt)*$t*m,At=.22+.62*st*nt+.22*pt+.3*Rt;B.push({x:T,y:P,z:K*f,r:v*Math.min(1,rt),white:Z(1-At*A),a:Z((1-.75*C*(1-Math.sqrt(K)))*A)})}return{...Nt(B,[],e.rMin??.4),square:!0}},Je=(t,n,s,e)=>{const o=t/2,r=t/2,c=.5*s.level+.5*s.soft,l=(1+(e.swell??.49)*c)*(1-.14*s.processing),i=t/2*(e.radius??.56),a=e.persp??.25,p=Qt(n*.12+s.drive*.03,.3,0,0,1),h=zt(t,e.rsPow??.9)*(e.rMul??1),f=[],m=e.orbitN??12,d=e.particles??6;for(let M=0;M<m;M++){const v=Tt(M,1.7),_=Tt(M,5.2),u=Tt(M,8.9),g=i*(.45+.52*v),x=v*bt,O=Math.acos(2*_-1),E=Math.sin(O)*Math.cos(x),q=Math.cos(O),S=Math.sin(O)*Math.sin(x);let C=-q,A=E;const D=Math.max(1e-6,Math.sqrt(C*C+A*A));C/=D,A/=D;const U=-S*A,b=S*C,w=E*A-q*C,y=(.25+.55*u)*(u>.5?1:-1);for(let I=0;I<d;I++){const R=s.drive*y+I/d*bt+_*6,B=Math.cos(R),k=Math.sin(R),[F,T,P]=p((C*B+U*k)*g,(A*B+b*k)*g,w*k*g),N=Z((P/i+1)/2),G=l/(1-a*P/i);f.push({x:o+F*G,y:r+T*G,z:P,r:((e.partR??.47)+(e.partRDepth??.65)*N)*h*G,white:.32-.24*N})}}return Nt(f,[],e.rMin)},Qe=(t,n,s,e)=>{const o=t/2,r=t/2,c=s.soft,[l,i]=s.softBands,a=t/2*(e.radius??.66)*(1+(e.zoom??.21)*s.level),p=s.drive,h=e.deform??1,f=e.wave??1,m=.015+(.1*l+.05*s.level)*h,d=.04*i*h,M=Sn(m,d,p),v=.55+.05*Math.sin(n*.37),_=Math.cos(v),u=Math.sin(v);let g=0;for(let T=0;T<48;T++){const P=T/48*bt;g+=M(Math.cos(P),Math.sin(P)*_,Math.sin(P)*u)}g/=48;const x=(T,P,N)=>1+M(T,P,N)-g,E=Qt(0,.3,o,r,1),q=zt(t,e.rsPow??.6)*(e.rMul??1),S=s.drive,C=[],A=e.ghostN??60;for(let T=0;T<A;T++){const P=wn(T,A),N=a*x(P[0],P[1],P[2]),[G,z,V]=E(P[0]*N,P[1]*N,P[2]*N),X=(V/a+1)/2;C.push({x:G,y:z,z:V,r:.65*q,white:.78,a:.1+.22*X})}const D=-u,U=_,b=Math.max(1,Math.round(e.lanes??10)),w=Math.max(8,Math.round(e.segs??56)),y=s.processing,I=(e.laneGap??.062)*(1+.25*c)*(1-.4*y),R=S*1.6,B=.15*(.55+.9*l*f)*(1-.6*y),k=.06*(.5+1.2*i*f),F=.05+.05*c;for(let T=0;T<b;T++){const P=(T-(b-1)/2)*I,N=Math.abs(T-(b-1)/2)/Math.max(1,(b-1)/2);for(let G=0;G<w;G++){const z=G/w*bt,V=B*Math.sin(z*3-S*.95+T*.18)+k*Math.sin(z*5+S*.6)+F*Math.sin(z*2+n*.31+Math.sin(n*.17)*1.5),X=P+V,tt=Math.cos(z),J=Math.sin(z),K=tt,ct=J*_+D*X,st=J*u+U*X,Y=Math.sqrt(K*K+ct*ct+st*st),ot=a*x(K/Y,ct/Y,st/Y)/Y,[W,ut,ft]=E(K*ot,ct*ot,st*ot),nt=(ft/a+1)/2,dt=Math.max(0,V)*c,pt=Math.atan2(Math.sin(z-R),Math.cos(z-R)),Rt=Math.exp(-(pt*pt)/.18)*y;C.push({x:W,y:ut,z:ft,r:((e.rBase??.49)+(e.rDepth??.78)*nt)*(1-.25*N)*(1+1.2*dt+.5*Rt)*q,white:.52-.44*nt+.18*N-.3*Rt,a:.4+.6*nt})}}return Nt(C,[],e.rMin)},ts=(t,n,s,e)=>{const o=t/2,r=s.level,[c,l]=s.softBands,i=s.bands[2],a=s.drive,p=o*(e.radius??.6)*(1+(e.zoom??.06)*s.soft)*(1-.08*s.processing),h=Qt((e.yaw??.42)+.08*Math.sin(n*.23),e.tilt??.32,o,o,1),f=Math.max(.4,(e.lineW??.6)*zt(t,.5)),m=E=>.06+.94*Z((E/p+1)/2)**2,d=e.deform??1,M=.02+(.14*c+.06*r)*d,v=.01+(.07*l+.03*i)*d,_=Sn(M,v,a),u=[],g=Math.max(24,Math.round(e.segs??96)),x=Math.max(0,Math.round(e.limbs??2));for(let E=0;E<x;E++){const q=.1+.05*Math.sin(n*.31+E*2.1),S=n*.17*(E%2?1:-1)+E*2.4,C=Math.sin(q)*Math.cos(S),A=Math.sin(q)*Math.sin(S),D=Math.cos(q),U=Math.hypot(C,D),b=D/U,w=-C/U,y=A*w,I=D*b-C*w,R=-A*b,B=[],k=[];for(let F=0;F<g;F++){const T=F/g*bt,P=b*Math.cos(T)+y*Math.sin(T),N=I*Math.sin(T),G=w*Math.cos(T)+R*Math.sin(T),z=p*(1+.006*E+_(P,N,G));B.push(o+P*z,o-N*z),k.push(.55+.35*Z((G/Math.sin(q)+1)/2))}u.push({pts:B,a:k,white:0,w:f,closed:!0})}const O=Math.max(2,Math.round(e.circles??8));for(let E=0;E<O;E++){const[q,S,C]=wn(E,O),A=a*.16*(.5+Tt(E,2.1))*(E%2?1:-1)+Tt(E,6.6)*bt,D=S*Math.cos(A)-C*Math.sin(A),U=S*Math.sin(A)+C*Math.cos(A),b=Math.max(1e-6,Math.hypot(U,q)),w=U/b,y=-q/b,I=D*y,R=U*w-q*y,B=-D*w,k=[],F=[];for(let T=0;T<g;T++){const P=T/g*bt,N=w*Math.cos(P)+I*Math.sin(P),G=R*Math.sin(P),z=y*Math.cos(P)+B*Math.sin(P),V=p*(1+_(N,G,z)),[X,tt,J]=h(N*V,G*V,z*V);k.push(X,tt),F.push(m(J))}u.push({pts:k,a:F,white:0,w:f,closed:!0})}return Nt([],u,e.rMin)},ns=(t,n,s,e)=>{const o=t/2,r=s.level,[c,l,i]=s.bands,a=s.drive,p=s.processing,h=o*(e.radius??.6)*(1+(e.zoom??.1)*r)*(1-.08*p),f=.95*Math.sin(n*1.3),m=Qt(n*.14,.32,o,o,1),d=zt(t,e.rsPow??.6)*(e.rMul??1),M=Math.max(40,Math.round(e.dotN??900)),v=e.cloudFreq??2.3,_=e.deform??1,u=.018+(.12*c+.04*r)*_,g=(.045*l+.03*i)*_,x=[],O=[];let E=0;for(let S=0;S<M;S++){const C=wn(S,M),[A,D,U]=C,b=.55*Math.sin(2.1*A+1.3*D+.9*a)+.45*Math.sin(1.7*U-1.9*D-.7*a+1.3),w=Math.sin(5.3*A-4.1*U+2.3*a)*Math.sin(4.7*D+3.1*A-1.7*a),y=u*b+g*w;x.push(C),O.push(y),E+=y/M}const q=[];for(let S=0;S<M;S++){const[C,A,D]=x[S],U=O[S]-E,b=h*(1+U),[w,y,I]=m(C*b,A*b,D*b),R=Z((I/h+1)/2),B=.65*Ut(C*v+a*.21,A*v-a*.15,D*v+a*.1)+.35*Ut(C*v*2.1-a*.29,A*v*2.1+7.3,D*v*2.1+a*.24),k=yn(.34,.68,B),F=Math.exp(-((A-f)**2)/.012)*p,T=Math.max(0,U)/.16;q.push({x:w,y,z:I,r:((e.rBase??.27)+(e.rDepth??.84)*R)*(.22+.95*k+.6*F)*(1+.5*T)*d,white:.62-.52*R-.16*k-.3*F,a:.3+.7*R})}return Nt(q,[],e.rMin??.25)},es=["orbit","sash","signal","swell","pixel","aura"],ss={orbit:Je,sash:Qe,signal:ts,swell:ns,pixel:Ze,aura:je},et={orbit:{speed:1.05,driveGain:.12,opts:{orbitN:12,particles:6},counts:{}},sash:{speed:1.5,driveGain:.8,gain:1.1,opts:{lanes:10,segs:56,ghostN:60},counts:{segs:.45,ghostN:.8}},signal:{speed:1.6,driveGain:2,opts:{circles:8,segs:96},counts:{circles:.5,segs:.5}},swell:{speed:1.4,driveGain:2.4,opts:{dotN:900},counts:{dotN:1}},pixel:{speed:1.2,driveGain:1.6,attack:.16,dotSize:.55,opts:{cells:17},counts:{cells:.5}},aura:{speed:1.6,driveGain:2,voiceSpeed:.9,lean:{move:.21,pull:.36,deform:.28,squash:0,bounce:.92,lens:.49,stretch:1.04,split:1.01,blur:1.24},opts:{rings:6,segs:140},counts:{segs:.5}}};function ne(t,n,s=1,e=1){const o=t in et?t:"orbit",r=et[o],c=Math.min(1.4,Math.max(.2,n/200))*Math.max(.1,s),l={...r.opts};for(const[i,a]of Object.entries(r.counts)){const p=l[i];p!=null&&(l[i]=Math.max(1,Math.round(p*c**a)))}return e!==1&&(l.rMul=Math.max(.1,e)),{frame:ss[o],speed:r.speed,driveGain:r.driveGain,gain:r.gain??1,opts:l}}function os(t){let n=t;for(;n;){const s=n.getAttribute("data-theme");if(s==="dark")return!0;if(s==="light")return!1;if(n.classList.contains("dark"))return!0;if(n.classList.contains("light"))return!1;n=n.parentElement}return null}function as(){return typeof matchMedia>"u"||matchMedia("(prefers-color-scheme: dark)").matches}function cs(t,n){const[s,e]=$.useState(!0);return $.useEffect(()=>{if(t==="dark"){e(!0);return}if(t==="light"){e(!1);return}const o=()=>{const i=os(n.current);e(i??as())};o();const r=typeof matchMedia<"u"?matchMedia("(prefers-color-scheme: dark)"):null,c=()=>o();r==null||r.addEventListener("change",c);let l=null;return typeof MutationObserver<"u"&&n.current&&(l=new MutationObserver(o),l.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"],subtree:!0})),()=>{r==null||r.removeEventListener("change",c),l==null||l.disconnect()}},[t,n]),s}function rs(){const[t,n]=$.useState(!1);return $.useEffect(()=>{if(typeof matchMedia>"u")return;const s=matchMedia("(prefers-reduced-motion: reduce)");n(s.matches);const e=o=>n(o.matches);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)},[]),t}const gt=16,is=2.1,ls=.3,hs=2.5,us=1.6,fs=5,Gn=2.2,Un=[[80,300],[300,2e3],[2e3,6e3]],pn=90,ds=7e3,mn=Math.PI*2,Mn=.35,gn=.9;function ee(t){return t<0?0:t>1?1:t}function bn(t,n){if(t<=n)return 0;const s=(t-n)/Math.max(.001,1-n);return ee((1-Math.exp(-3*s))/(1-Math.exp(-3)))}function Ft(t,n,s,e,o){const r=n>t?e:o;return t+(n-t)*(1-Math.exp(-s/Math.max(.001,r)))}class se{constructor(){this.clock=0,this.t=0,this.drive=0,this.level=0,this.bands=[0,0,0],this.spectrum=new Float32Array(gt),this.floor=new Float32Array(gt+3).fill(1),this.heard=0,this.proc=0,this.spin=0,this.pan=0,this.panVel=0,this.raw={level:0,bands:[0,0,0],spectrum:new Float32Array(gt)},this.timeBuf=null,this.freqBuf=null,this.out={level:0,bands:[0,0,0],soft:0,softBands:[0,0,0],spectrum:this.spectrum,drive:0,processing:0,spin:0,pan:0}}readAnalyser(n,s,e){(!this.timeBuf||this.timeBuf.length!==n.fftSize)&&(this.timeBuf=new Float32Array(n.fftSize)),(!this.freqBuf||this.freqBuf.length!==n.frequencyBinCount)&&(this.freqBuf=new Uint8Array(n.frequencyBinCount));const o=this.timeBuf,r=this.freqBuf;n.getFloatTimeDomainData(o);let c=0;for(let h=0;h<o.length;h++)c+=o[h]*o[h];this.raw.level=Math.sqrt(c/o.length)*fs*s,n.getByteFrequencyData(r);const l=n.context.sampleRate/n.fftSize,i=(h,f)=>{const m=Math.max(0,Math.floor(h/l)),d=Math.max(m,Math.min(r.length-1,Math.ceil(f/l)));let M=0;for(let v=m;v<=d;v++)M+=r[v];return M/(d-m+1)/255},a=(h,f)=>{const m=this.floor[h];return this.floor[h]=f<m?f:m+(f-m)*(1-Math.exp(-e/8)),Math.max(0,f-this.floor[h])/Math.max(.05,1-this.floor[h])};for(let h=0;h<3;h++)this.raw.bands[h]=a(h,i(Un[h][0],Un[h][1]))*Gn*s;const p=ds/pn;for(let h=0;h<gt;h++){const f=pn*p**(h/gt),m=pn*p**((h+1)/gt);this.raw.spectrum[h]=a(3+h,i(f,m))*Gn*s}}readLevel(n,s){const e=ee(n)*s,o=this.clock;this.raw.level=e,this.raw.bands[0]=e,this.raw.bands[1]=e*(.72+.28*Math.sin(o*2.3)),this.raw.bands[2]=e*(.6+.4*Math.sin(o*3.7+2));const r=.28+.1*Math.sin(o*2.3)+.05*Math.sin(o*5.1),c=.64+.1*Math.sin(o*1.7+1);for(let l=0;l<gt;l++){const i=l/(gt-1),a=Math.exp(-((i-r)**2)/.012)+.6*Math.exp(-((i-c)**2)/.008);this.raw.spectrum[l]=e*(.25+.75*a)*(1-.4*i)}}readSilence(){this.raw.level=0,this.raw.bands.fill(0),this.raw.spectrum.fill(0)}step(n,s,e){const{threshold:o,attack:r,release:c,rate:l}=s,i=this.proc=Ft(this.proc,s.processing?1:0,n,.35,.5),a=s.calm+(1-s.calm)*Math.min(1,Math.max(this.heard*2.5,i));e||(this.clock+=n,this.t+=n*l*a*(1+.5*i));const p=bn(this.raw.level,o);this.level=Ft(this.level,p,n,r,c),this.heard=Ft(this.heard,this.level,n,Mn,gn);for(let u=0;u<3;u++)this.bands[u]=Ft(this.bands[u],bn(this.raw.bands[u],o*.6),n,r,c*1.15);for(let u=0;u<gt;u++)this.spectrum[u]=Ft(this.spectrum[u],bn(this.raw.spectrum[u],o*.6),n,r,c);const h=this.clock,f=e?.5:.5+.5*Math.sin(mn*h/6),m=s.idle*f*(1-i),d=this.out;d.level=this.level+(1-this.level)*m;for(let u=0;u<3;u++)d.bands[u]=this.bands[u]+(1-this.bands[u])*m*.6;d.soft=Ft(d.soft,d.level,n,Mn,gn);for(let u=0;u<3;u++)d.softBands[u]=Ft(d.softBands[u],d.bands[u],n,Mn,gn);if(e||(this.drive+=n*l*(a+s.driveGain*this.level+1.3*i)),d.drive=this.drive,d.processing=i,!e){const u=Math.ceil(this.spin/mn-1e-6)*mn,g=Math.min(ls,(u-this.spin)*.6);this.spin+=n*(is*l*i+g*(1-i))}d.spin=this.spin;const M=Math.max(-1,Math.min(1,s.direction||0)),v=this.heard>.06&&!s.processing?M:0,_=Math.abs(v)>Math.abs(this.pan)?hs:us;return this.panVel+=(_*_*(v-this.pan)-2*_*this.panVel)*n,this.pan+=this.panVel*n,d.pan=this.pan,d}}function ps(t){if(!t)return;const n=t.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(n){let e=n[1];e.length===3&&(e=e.replace(/./g,r=>r+r));const o=parseInt(e,16);return{r:o>>16&255,g:o>>8&255,b:o&255}}const s=t.trim().match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);if(s)return{r:Number(s[1]),g:Number(s[2]),b:Number(s[3])}}const ms={idle:"Waiting",listening:"Listening",speaking:"Speaking",processing:"Thinking"},Ms=.55,gs=1e3/62;function oe({type:t="orbit",state:n="listening",size:s=160,stream:e,analyser:o,level:r,sensitivity:c=.85,threshold:l=.04,attack:i,release:a=.32,idle:p=.1,calm:h=.4,voiceSpeed:f,emotion:m=null,emotionColors:d,saturation:M=2,accent:v=null,gradientAngle:_=99,gradientSpin:u=12,neutral:g=1,colorBrightness:x=1.02,colorHue:O=0,gradientStart:E=.1,gradientWidth:q=.6,direction:S,directionMove:C,directionPull:A,directionDeform:D,directionSquash:U,directionLens:b,directionStretch:w,directionSplit:y,directionBlur:I,directionBounce:R,directionMargin:B,directionBounds:k,hoverBend:F=!1,theme:T="auto",speed:P=1,paused:N=!1,color:G,dots:z=1,dotSize:V,opts:X,frame:tt,onLevel:J,style:K,"aria-label":ct,...st}){const Y=$.useRef(null),ot=cs(T,Y),W=rs(),ut=X?JSON.stringify(X):"",ft=!!(e||o||r!=null||n==="processing"),nt=$.useRef(null);nt.current||(nt.current=new se);const dt=$.useRef(null);dt.current||(dt.current=new ve);const pt=m?(d==null?void 0:d[m])??Gt[m]:null,Rt={saturation:Math.min(1,M),vivid:Math.max(0,Math.min(1,M-1)),brightness:x,hue:O,start:E,width:q,accent:v?Vn[v]:null,angle:_,spin:u,neutral:g,size:s},$t=V??et[t in et?t:"orbit"].dotSize??1,rt=et[t in et?t:"orbit"].lean??{},At=B??et[t in et?t:"orbit"].margin??32,Wt={state:n,level:r,analyser:o,sensitivity:c,threshold:l,attack:i??et[t in et?t:"orbit"].attack??.06,release:a,idle:p,calm:h,voiceSpeed:f??et[t in et?t:"orbit"].voiceSpeed??1,onLevel:J,emotionTint:pt,colors:Rt,direction:S,bounds:k,bend:F===!0?Ms:typeof F=="number"?Math.max(0,Math.min(1,F)):0,lean:{move:C??rt.move??xt.move,pull:A??rt.pull??xt.pull,deform:D??rt.deform??xt.deform,squash:U??rt.squash??xt.squash,lens:b??rt.lens??xt.lens,stretch:w??rt.stretch??xt.stretch,split:y??rt.split??xt.split,blur:I??rt.blur??xt.blur,bounce:R??rt.bounce??xt.bounce}},yt=$.useRef(Wt);yt.current=Wt;const It=S==null?0:Se(Wt.lean,s),[En,ae]=$.useState([1/0,1/0]),tn=Math.min(It,En[0]),nn=Math.min(It,En[1]),it=It?tn+At:0,Pt=It?nn+At:0,Vt=$.useRef({x:0,y:0,over:!1}),Tn=Wt.bend>0&&!W;$.useEffect(()=>{const j=Y.current;if(!Tn||!j||typeof matchMedia!="function"||!matchMedia("(hover: hover) and (pointer: fine)").matches)return;const St=lt=>{if(lt.pointerType==="touch")return;const Ot=j.getBoundingClientRect(),Xt=(s+it+Pt)/(Ot.width||1);Vt.current={x:(lt.clientX-Ot.left)*Xt-it,y:(lt.clientY-Ot.top)*Xt,over:!0}},_t=()=>{Vt.current.over=!1};return window.addEventListener("pointermove",St,{passive:!0}),document.documentElement.addEventListener("pointerleave",_t),()=>{window.removeEventListener("pointermove",St),document.documentElement.removeEventListener("pointerleave",_t),Vt.current.over=!1}},[Tn,s,it,Pt]);const en=$.useRef(null);return $.useEffect(()=>{if(!e)return;const j=Wn(e);return en.current=(j==null?void 0:j.analyser)??null,()=>{en.current=null,j==null||j.release()}},[e]),$.useEffect(()=>{const j=Y.current;if(!j)return;const St=Math.min(2,typeof devicePixelRatio<"u"&&devicePixelRatio||1);j.width=Math.round((s+it+Pt)*St),j.height=Math.round(s*St);const _t=j.getContext("2d");if(!_t)return;const lt=ne(t,s,z,$t),Ot=X?{...lt.opts,...X}:lt.opts,Xt=tt??lt.frame,ce=ps(G),wt=nt.current,re=dt.current,ie=new we;let Rn=0,Bt=0,sn=s/2,on=s/2;const le=(Q,H,L)=>{var Fn;_t.setTransform(St,0,0,St,it*St,0),_t.clearRect(-it,0,s+it+Pt,s);const Lt=N||W?0:ie.step(Rn,L);let ht=Ee(Xt(s,wt.t,Q,Ot),Q.pan,s,yt.current.lean,[tn,nn],Lt);Rn=((Fn=ht.contact)==null?void 0:Fn.press)??0;const vt=yt.current.bend;if(vt>0){const qt=Vt.current,In=Xn(ht,s),de=yt.current.state==="idle"||yt.current.state==="processing",pe=qt.over&&de&&!N&&!W?ye(Math.hypot(qt.x-s/2,qt.y-s/2)-In,In):0;Bt+=(pe-Bt)*(1-Math.exp(-L/.14));const Nn=Bt<.01?1:1-Math.exp(-L/.05);sn+=(qt.x-sn)*Nn,on+=(qt.y-on)*Nn,Bt>.002&&(ht=xe(ht,s,{x:sn,y:on,amount:Bt*vt}))}const mt=yt.current.colors,Mt=H.amount,at=mt.accent,ue=at?{r:at.r+(H.r-at.r)*Mt,g:at.g+(H.g-at.g)*Mt,b:at.b+(H.b-at.b)*Mt}:{r:H.r,g:H.g,b:H.b},fe={...mt,accent:ue,saturation:mt.saturation*(at?1:Mt),angle:mt.angle+mt.spin*wt.clock};Ke(_t,ht,ot,ce,ht.light?H:void 0,fe)};let An=-1/0;const he=Q=>{var mt,Mt;if(!It||Q-An<500)return;An=Q;const H=j.getBoundingClientRect().left+it,L=(Mt=(mt=yt.current.bounds)==null?void 0:mt.current)==null?void 0:Mt.getBoundingClientRect(),Lt=L?L.left:0,ht=L?L.right:document.documentElement.clientWidth,vt=[Math.max(0,Math.floor(H-Lt-At)),Math.max(0,Math.floor(ht-H-s-At))];ae(at=>Math.abs(at[0]-vt[0])>1||Math.abs(at[1]-vt[1])>1?vt:at)};let Kt=0;const Pn=Q=>{var Mt;he(Q);const H=Kt?Math.min(.05,(Q-Kt)/1e3):1/60;Kt=Q;const L=yt.current,Lt=L.state==="listening"||L.state==="speaking",ht=en.current??L.analyser??null;Lt?ht?wt.readAnalyser(ht,L.sensitivity*lt.gain,H):L.level!=null?wt.readLevel(typeof L.level=="function"?L.level():L.level,L.sensitivity*lt.gain):wt.readSilence():wt.readSilence();const vt=wt.step(H,{sensitivity:L.sensitivity,threshold:L.threshold,attack:L.attack,release:L.release,idle:L.idle,driveGain:lt.driveGain*L.voiceSpeed,calm:L.calm,rate:lt.speed*P,processing:L.state==="processing",direction:typeof L.direction=="function"?L.direction():L.direction??0},W);(Mt=L.onLevel)==null||Mt.call(L,vt.level);const mt=re.step(H,L.emotionTint,wt.clock,s,N||W);le(vt,mt,H)};if(Pn(performance.now()),N||W&&!ft)return;let an=0,Yt=!1,_n=0;const Cn=Q=>{Yt&&(an=requestAnimationFrame(Cn),!(Q-_n<gs)&&(_n=Q,Pn(Q)))},cn=()=>{Yt||(Yt=!0,Kt=0,an=requestAnimationFrame(Cn))},rn=()=>{Yt=!1,cancelAnimationFrame(an)};let ln=!0;const Ct=typeof IntersectionObserver<"u"?new IntersectionObserver(([Q])=>{ln=Q.isIntersecting,ln&&document.visibilityState!=="hidden"?cn():rn()}):null;Ct==null||Ct.observe(j);const kn=()=>{document.visibilityState==="hidden"?rn():ln&&cn()};return document.addEventListener("visibilitychange",kn),Ct||cn(),()=>{rn(),Ct==null||Ct.disconnect(),document.removeEventListener("visibilitychange",kn)}},[t,s,It,tn,nn,it,Pt,At,ot,P,N,W,ft,G,z,$t,ut,tt,N||W?m:null,N||W?`${M}|${v}|${_}|${u}|${g}|${x}|${O}|${E}|${q}`:null]),zn.jsx("canvas",{ref:Y,role:"img","aria-label":ct??ms[n],style:{width:s+it+Pt,height:s,display:"block",marginLeft:-it,marginRight:-Pt,...K},...st})}const bs={echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1};function Jt(){return typeof navigator<"u"&&typeof navigator.mediaDevices<"u"&&typeof navigator.mediaDevices.getUserMedia=="function"}function vs(t={}){const{constraints:n,autoStart:s=!1}=t,[e,o]=$.useState(null),[r,c]=$.useState(()=>Jt()?"idle":"unsupported"),[l,i]=$.useState(null),a=$.useRef(null),p=$.useRef(n);p.current=n;const h=$.useCallback(()=>{const m=a.current;a.current=null,m&&m.getTracks().forEach(d=>d.stop()),o(null),c(Jt()?"idle":"unsupported")},[]),f=$.useCallback(async()=>{if(!Jt())return c("unsupported"),null;if(a.current)return a.current;xn(),c("requesting"),i(null);try{const m=await navigator.mediaDevices.getUserMedia({audio:{...bs,...p.current??{}}});a.current=m,o(m),c("live");const d=()=>{a.current===m&&(a.current=null,o(null),c("idle"))};return m.getAudioTracks().forEach(M=>M.addEventListener("ended",d)),m}catch(m){const d=m instanceof Error?m:new Error(String(m));return i(d),c(d.name==="NotAllowedError"||d.name==="SecurityError"?"denied":"error"),null}},[]);return $.useEffect(()=>{s&&f()},[s]),$.useEffect(()=>()=>{const m=a.current;a.current=null,m&&m.getTracks().forEach(d=>d.stop())},[]),{stream:e,state:r,error:l,supported:Jt(),start:f,stop:h}}function xs(t){return zn.jsx(oe,{...t,type:"aura"})}exports.ACCENT_COLORS=Vn;exports.EMOTION_COLORS=Gt;exports.PRESETS=et;exports.SPECTRUM_N=gt;exports.VOICE_ORB_TYPES=es;exports.VoiceFollower=se;exports.VoiceOrb=oe;exports.VoiceRing=xs;exports.acquireAnalyser=Wn;exports.getAudioContext=xn;exports.isAudioSupported=me;exports.resolvePreset=ne;exports.useMicrophone=vs;
|
|
41
|
+
}`;let en;function se(){if(typeof document>"u")return null;const n=document.createElement("canvas"),s=n.getContext("webgl",{premultipliedAlpha:!0,antialias:!1,depth:!1});if(!s)return null;const e=(i,a)=>{const f=s.createShader(i);return s.shaderSource(f,a),s.compileShader(f),f},t=s.createProgram();if(s.attachShader(t,e(s.VERTEX_SHADER,te)),s.attachShader(t,e(s.FRAGMENT_SHADER,ne)),s.linkProgram(t),!s.getProgramParameter(t,s.LINK_STATUS))return null;s.useProgram(t);const o=s.createBuffer();s.bindBuffer(s.ARRAY_BUFFER,o),s.bufferData(s.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,1,1]),s.STATIC_DRAW);const r=s.getAttribLocation(t,"aPos");s.enableVertexAttribArray(r),s.vertexAttribPointer(r,2,s.FLOAT,!1,0,0);const c=s.createTexture();s.bindTexture(s.TEXTURE_2D,c),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_S,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_WRAP_T,s.CLAMP_TO_EDGE),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MIN_FILTER,s.LINEAR),s.texParameteri(s.TEXTURE_2D,s.TEXTURE_MAG_FILTER,s.LINEAR),s.pixelStorei(s.UNPACK_PREMULTIPLY_ALPHA_WEBGL,!0);const l={};for(const i of["uSize","uWall","uSide","uZone","uGap","uFlare","uSplit","uBlur","uCy"])l[i]=s.getUniformLocation(t,i);return{gl:s,canvas:n,source:document.createElement("canvas"),tex:c,u:l}}function ee(n,s,e,t){if(en===void 0&&(en=se()),!en)return!1;const{gl:o,canvas:r,source:c,tex:l,u:i}=en,a=n.getTransform(),f=Math.hypot(a.a,a.b)||1,h=n.canvas.width,u=n.canvas.height,p=a.a*e+a.e,d=t.zone*f,g=t.blur*f,M=Math.max(0,Math.floor(s>0?p-d-2*g-4:0)),m=Math.min(h,Math.ceil(s>0?h:p+d+2*g+4))-M;if(m<2||u<2)return!1;(c.width!==m||c.height!==u)&&(c.width=m,c.height=u);const R=c.getContext("2d");return R.clearRect(0,0,m,u),R.drawImage(n.canvas,M,0,m,u,0,0,m,u),(r.width!==m||r.height!==u)&&(r.width=m,r.height=u),o.viewport(0,0,m,u),o.bindTexture(o.TEXTURE_2D,l),o.texImage2D(o.TEXTURE_2D,0,o.RGBA,o.RGBA,o.UNSIGNED_BYTE,c),o.uniform2f(i.uSize,m,u),o.uniform1f(i.uWall,p-M),o.uniform1f(i.uSide,s),o.uniform1f(i.uZone,d),o.uniform1f(i.uGap,t.gap*f),o.uniform1f(i.uFlare,t.flare),o.uniform1f(i.uSplit,t.split*f),o.uniform1f(i.uBlur,g),o.uniform1f(i.uCy,a.d*t.cy+a.f),o.clearColor(0,0,0,0),o.clear(o.COLOR_BUFFER_BIT),o.drawArrays(o.TRIANGLE_STRIP,0,4),n.save(),n.setTransform(1,0,0,1,0,0),n.globalCompositeOperation="copy",n.beginPath(),n.rect(M,0,m,u),n.clip(),n.drawImage(r,M,0),n.restore(),!0}function ns(n,s,e,t){const o=2.2/t.size,r=Ht(n*o+t.t*.11,s*o-t.t*.08,t.t*.07),c=Zt(.3,.75,r);return t.amount*(.2+.75*c)*W(1.3-e)}function ss(n,s,e,t,o,r=0,c,l=0){const i=Math.round(s*1e3)/1e3,a=d=>e?d*(1-n):d+(255-d)*n,f=(e?1-n:n)*255;let h=t?a(t.r):f,u=t?a(t.g):f,p=t?a(t.b):f;return c&&l>0&&(h+=(a(c[0])-h)*l,u+=(a(c[1])-u)*l,p+=(a(c[2])-p)*l),o&&r>0&&(h+=(a(o.r)-h)*r,u+=(a(o.g)-u)*r,p+=(a(o.b)-p)*r),`rgba(${Math.round(h)},${Math.round(u)},${Math.round(p)},${i})`}const Wn=24,Vn=8;function oe(n,s,e,t,o,r){const c=o&&o.amount>.005?o:void 0,l=r&&r.saturation>0?r:void 0,i=new Map;for(const a of s){const f=a.pts.length>>1,h=a.closed?f:f-1;let u="",p;for(let d=0;d<h;d++){const g=d+1===f?0:d+1,M=Math.round(W((a.a[d]+a.a[g])/2)*Wn);if(M===0){u="";continue}const y=c?Math.round(ns((a.pts[2*d]+a.pts[2*g])/2,(a.pts[2*d+1]+a.pts[2*g+1])/2,a.white,c)*Vn):0,m=l?l.at((a.pts[2*d]+a.pts[2*g])/2,(a.pts[2*d+1]+a.pts[2*g+1])/2):0,R=`${M}|${a.white}|${Math.round(a.w*20)}|${y}|${m}`;if(R!==u){let b=i.get(R);b||(b={path:new Path2D,white:a.white,w:a.w,a:M/Wn,gw:y/Vn,ci:m},i.set(R,b)),p=b,u=R,b.path.moveTo(a.pts[2*d],a.pts[2*d+1])}p.path.lineTo(a.pts[2*g],a.pts[2*g+1])}}n.lineCap="round",n.lineJoin="round";for(const a of i.values())n.strokeStyle=ss(W(a.white),a.a,e,t,c,a.gw,l==null?void 0:l.rgb,l==null?void 0:l.mix[a.ci]),n.lineWidth=a.w,n.stroke(a.path)}function ae(n,s,e,t,o,r,c=!1){const l=o&&o.amount>.005?o:void 0,i=r&&r.saturation>0?r:void 0;for(const a of s){const f=W(a.white),h=l?ns(a.x,a.y,f,l):0,u=i?i.at(a.x,a.y):0;if(n.fillStyle=ss(f,W(a.a??1),e,t,l,h,i==null?void 0:i.rgb,i==null?void 0:i.mix[u]),c){n.fillRect(a.x-a.r,a.y-a.r,2*a.r,2*a.r);continue}n.beginPath(),n.arc(a.x,a.y,a.r,0,gt),n.fill()}}function ce(n,s,e,t,o,r){var l;const c=r&&r.saturation>0&&!s.light?zs(r):void 0;s.light?Zs(n,s,s.light,e,t,o):s.tube?Qs(n,s.strokes,s.tube,e,t,o):s.strokes.length&&oe(n,s.strokes,e,t,o,c),ae(n,s.dots,e,t,o,c,s.square),(l=s.contact)!=null&&l.lens&&ee(n,s.contact.side,s.contact.x,s.contact.lens)}const re=[[0,255,150,90],[.12,255,110,120],[.24,255,80,170],[.4,190,80,255],[.58,90,92,255],[.74,60,132,255],[.84,170,90,255],[.93,240,104,165],[1,255,150,90]],ie=(n,s,e,t)=>{const o=n/2,r=e.level,[c,l]=e.softBands,i=e.bands[2],a=e.drive,f=e.processing,h=.5*r+.5*e.soft,u=o*(t.radius??.56)*(1+(t.zoom??.17)*e.soft)*(1-.06*f),p=t.deform??1.45,d=.02+(.14*c+.06*r)*p,g=.01+(.07*l+.03*i)*p,M=An(d,g,a,t.deformRadius??1.75),y=Math.max(.6,(t.lineW??1.85)*$t(n,.5)),m=Math.max(1,Math.round(t.rings??6)),R=Math.max(24,Math.round(t.segs??140)),b=t.lean??.91,A=t.ringGap??.02,v=[];let E=0,x=0;for(let P=0;P<m;P++){const w=.16*(.5+Nt(P,2.1))*(P%2?1:-1),I=Math.max(.02,b*(.2+.8*Nt(P,3.1))+.03*Math.sin(s*.27+P*1.3)+.08*Math.sin(a*.35+P*1.7)),z=Nt(P,7.7)*gt+s*.05*(P%2?1:-1)+a*w,L=Math.sin(I)*Math.cos(z),C=Math.sin(I)*Math.sin(z),O=Math.cos(I),q=Math.hypot(L,O),D=O/q,U=-L/q,Y=C*U,j=O*D-L*U,Q=-C*D,K=u*(1+A*(P-(m-1)/2)),H=Math.sin(I),ht=[],it=[],Z=[];for(let ot=0;ot<R;ot++){const X=ot/R*gt,bt=Math.cos(X),ut=Math.sin(X),tt=D*bt+Y*ut,at=j*ut,ct=U*bt+Q*ut,nt=M(tt,at,ct);ht.push(tt,at),it.push(nt),E+=nt,x++,Z.push(.62+.38*W((ct/H+1)/2))}v.push({dirs:ht,f:it,a:Z,rk:K})}const N=x?E/x:0;let _=0,k=0;for(const{dirs:P,f:w}of v)for(let I=0;I<w.length;I++){const z=P[2*I],L=P[2*I+1],C=Math.hypot(z,L)||1;_+=(w[I]-N)*(z/C),k+=(w[I]-N)*(L/C)}_=x?2*_/x:0,k=x?2*k/x:0;const B=v.map(({dirs:P,f:w,a:I,rk:z})=>{const L=[];for(let C=0;C<w.length;C++){const O=P[2*C],q=P[2*C+1],D=Math.hypot(O,q)||1,U=z*(1+w[C]-N-_*(O/D)-k*(q/D));L.push(o+O*U,o-q*U)}return{pts:L,a:I,white:0,w:y,closed:!0}}),S=2.3+.25*Math.sin(s*.21)+2*e.spin,T=t.colorDrift??1,F={cx:o,cy:o,r:u,stops:re,angle:-Math.PI/2-.35+(t.colorTurn??0)*Math.PI/180+T*(.5*Math.sin(s*.07)+.4*Math.sin(a*.2))+e.spin,intensity:(.62+.55*h+.5*f)*(t.brightness??.78),halo:(t.halo??.5)*(1+.6*f),spec:[{x:o+Math.cos(S)*u,y:o+Math.sin(S)*u,r:u*(.5+.25*f)*(t.highlightSize??1),a:(.5+.35*h+.4*f)*(t.highlight??1.4)}],fringe:(.016+.012*h)*(t.fringe??1),green:[t.greenFrom??81,t.greenTo??136],look:{hue:t.hue,chroma:t.chroma,warmth:t.warmth,contrast:t.contrast,cycles:t.colorCycles,glowSize:t.glowSize,bloom:t.bloom??.55,bloomSize:t.bloomSize??1.4,soft:t.softness??3.7,core:t.core}};return{...Wt([],B),light:F}},es=-.45,os=.55,as=.7,le=Math.hypot(es,os,as),he=(n,s,e,t)=>{const o=n/2,r=e.processing,c=e.soft,l=e.softBands[1],i=o*(t.radius??.44)*(1+(t.zoom??.08)*c)*(1-.06*r),a=t.deform??1.85,f=Math.max(1,Math.round(t.rings??2)),h=Math.max(48,Math.round(t.segs??180)),u=Math.max(.5,(t.lineW??1.7)*$t(n,.6)),p=(t.tilt??.22)+(t.open??.75)*c,d=W(t.restBend??.12),g=d+(1-d)*W(c*a),M=(t.twist??1.69)*g,y=(t.wobble??.31)*g,m=e.drive*(t.pace??2.1),R=1/Math.max(.02,t.persp??0),b=1-Zt(.1,.5,c),A=(t.idleSway??.18)*b,v=(t.idleDeform??.05)*b,E=(t.idleDrift??.03)*b,x=o+i*E*Math.sin(.9*s+.6),N=o+i*E*Math.sin(.7*s+2.1),_=[];for(let k=0;k<f;k++){const B=k*2.399,S=p*(1+.25*Math.sin(.17*m+B))+A*Math.sin(1.3*s+1.3*B),T=k*gt/f+.23*m*(k%2?-1:1)+.4*Math.sin(.11*m+B)+e.spin,F=Math.sin(S)*Math.cos(T),P=Math.sin(S)*Math.sin(T),w=Math.cos(S),I=Math.hypot(F,w)||1,z=w/I,L=-F/I,C=P*L,O=w*z-F*L,q=-P*z,D=.2*M*Math.sin(.29*m+1.3+B),U=.37*m+B,Y=.07*M*Math.sin(.23*m+.4+B),j=-.31*m+2.1+B,Q=.07*y*Math.sin(.33*m+.4+B),K=.41*m+B,H=.04*y*Math.sin(.27*m+1+B),ht=-.35*m+.8+B,it=.04*a*l,Z=.5*m+B,ot=v*Math.sin(1.1*s+.7+B),X=.7*s+B,bt=.6*v*Math.sin(1.5*s+1.9+B),ut=-.5*s+B,tt=1-(t.ringGap??.035)*k,at=[],ct=[],nt=[];for(let J=0;J<h;J++){const V=J/h*gt,ft=Math.cos(V),xt=Math.sin(V),Ct=tt*(1+Q*Math.cos(2*V+K)+H*Math.cos(3*V+ht)+it*Math.cos(4*V+Z)+ot*Math.cos(2*V+X)+bt*Math.cos(3*V+ut)),St=tt*(D*Math.sin(2*V+U)+Y*Math.sin(3*V+j));at.push((z*ft+C*xt)*Ct+F*St),ct.push(O*xt*Ct+P*St),nt.push((L*ft+q*xt)*Ct+w*St)}const Ot=[],lt=[],yt=[];for(let J=0;J<h;J++){const V=R/(R-nt[J]);Ot.push(x+at[J]*i*V,N-ct[J]*i*V);const ft=(J+1)%h,xt=(J+h-1)%h,Ct=at[ft]-at[xt],St=ct[ft]-ct[xt],Gt=nt[ft]-nt[xt],dt=Math.hypot(Ct,St,Gt)||1,wt=(Ct*es+St*os+Gt*as)/(dt*le),Dt=Math.sqrt(Math.max(0,1-wt*wt)),Ut=W((nt[J]+1)/2);lt.push(W(.12+.6*Dt*(.55+.45*Ut)+.28*Ut+.08*c)),yt.push(Ut*2-1)}_.push({pts:Ot,a:lt,z:yt,white:0,w:u,closed:!0})}return{dots:[],strokes:_,tube:{shine:t.shine??1,contrast:t.contrast??0,depth:t.depthWidth??0,saturation:t.colorSaturation??2,gradient:t.colorGradient??.69,gradientAngle:t.gradientAngle??0,gradientSpin:t.gradientSpin??0,colorBrightness:t.colorBrightness??.9,positiveBrightness:t.positiveBrightness??.93,negativeBrightness:t.negativeBrightness??1,calmBrightness:t.calmBrightness??1}}},cs=-.45,rs=.55,is=.7,ue=Math.hypot(cs,rs,is),fe=(n,s,e,t)=>{const o=n/2,r=e.level,[c,l,i]=e.bands,a=e.drive,f=e.processing,h=o*(t.radius??.72),u=h*(1+(t.zoom??.3)*r)*(1-.06*f),p=t.rMul??1,d=Math.max(4,Math.round(t.cells??17)),g=2*h/d,M=g/2-Math.max(.5,g*(t.gap??.24)/2),y=Math.ceil(u*1.25/g),m=(t.turn??.12)*s+.1*a+.5*e.spin,R=Math.sin(m),b=Math.cos(m),A=Math.sin(.35),v=Math.cos(.35),E=t.shade??.7,x=t.texture??.35,N=t.fade??1.3,_=t.strength??1.38,k=t.deform??1.7,B=.012+(.09*c+.03*r)*k,S=(.035*l+.025*i)*k,T=z=>B*(.55*Math.sin(2*z+.9*a)+.45*Math.sin(3*z-.7*a+1.3))+S*Math.sin(7*z+2.3*a)*Math.sin(5*z-1.7*a),F=.95*Math.sin(s*1.3),P=e.spectrum,w=P.length,I=[];for(let z=-y;z<=y;z++)for(let L=-y;L<=y;L++){const C=o+L*g,O=o+z*g,q=(C-o)/u,D=-(O-o)/u,U=T(Math.atan2(D,q)),Y=Math.hypot(q,D)/(1+U);if(Y>=1)continue;const j=1/(1+U),Q=q*j,K=D*j,H=Math.sqrt(Math.max(0,1-Q*Q-K*K)),ht=W((Q*cs+K*rs+H*is)/ue),it=1-E+E*ht,Z=K*v+H*A,ot=-K*A+H*v,X=Q*b-ot*R,bt=Q*R+ot*b,ut=.65*Ht(X*2.2+a*.15,Z*2.2,bt*2.2-a*.1)+.35*Ht(X*4.6-a*.2,Z*4.6+7.3,bt*4.6),tt=1-x+x*Zt(.32,.68,ut),at=w?P[Math.min(w-1,Math.floor(Y*w))]:r,ct=.35*r+.85*at,nt=Math.exp(-((K-F)**2)/.01)*f,Ot=1-.4*N*(1-H),lt=(.35+.75*it*tt+.3*ct+.2*nt)*Ot*p,yt=.22+.62*it*tt+.22*ct+.3*nt;I.push({x:C,y:O,z:H*u,r:M*Math.min(1,lt),white:W(1-yt*_),a:W((1-.75*N*(1-Math.sqrt(H)))*_)})}return{...Wt(I,[],t.rMin??.4),square:!0}},de=(n,s,e,t)=>{const o=n/2,r=n/2,c=.5*e.level+.5*e.soft,l=(1+(t.swell??.49)*c)*(1-.14*e.processing),i=n/2*(t.radius??.56),a=t.persp??.25,f=cn(s*.12+e.drive*.03,.3,0,0,1),h=$t(n,t.rsPow??.9)*(t.rMul??1),u=[],p=t.orbitN??12,d=t.particles??6;for(let g=0;g<p;g++){const M=Nt(g,1.7),y=Nt(g,5.2),m=Nt(g,8.9),R=i*(.45+.52*M),b=M*gt,A=Math.acos(2*y-1),v=Math.sin(A)*Math.cos(b),E=Math.cos(A),x=Math.sin(A)*Math.sin(b);let N=-E,_=v;const k=Math.max(1e-6,Math.sqrt(N*N+_*_));N/=k,_/=k;const B=-x*_,S=x*N,T=v*_-E*N,F=(.25+.55*m)*(m>.5?1:-1);for(let P=0;P<d;P++){const w=e.drive*F+P/d*gt+y*6,I=Math.cos(w),z=Math.sin(w),[L,C,O]=f((N*I+B*z)*R,(_*I+S*z)*R,T*z*R),q=W((O/i+1)/2),D=l/(1-a*O/i);u.push({x:o+L*D,y:r+C*D,z:O,r:((t.partR??.47)+(t.partRDepth??.65)*q)*h*D,white:.32-.24*q})}}return Wt(u,[],t.rMin)},pe=(n,s,e,t)=>{const o=n/2,r=n/2,c=e.soft,[l,i]=e.softBands,a=n/2*(t.radius??.66)*(1+(t.zoom??.21)*e.level),f=e.drive,h=t.deform??1,u=t.wave??1,p=.015+(.1*l+.05*e.level)*h,d=.04*i*h,g=An(p,d,f),M=.55+.05*Math.sin(s*.37),y=Math.cos(M),m=Math.sin(M);let R=0;for(let C=0;C<48;C++){const O=C/48*gt;R+=g(Math.cos(O),Math.sin(O)*y,Math.sin(O)*m)}R/=48;const b=(C,O,q)=>1+g(C,O,q)-R,v=cn(0,.3,o,r,1),E=$t(n,t.rsPow??.6)*(t.rMul??1),x=e.drive,N=[],_=t.ghostN??60;for(let C=0;C<_;C++){const O=Pn(C,_),q=a*b(O[0],O[1],O[2]),[D,U,Y]=v(O[0]*q,O[1]*q,O[2]*q),j=(Y/a+1)/2;N.push({x:D,y:U,z:Y,r:.65*E,white:.78,a:.1+.22*j})}const k=-m,B=y,S=Math.max(1,Math.round(t.lanes??10)),T=Math.max(8,Math.round(t.segs??56)),F=e.processing,P=(t.laneGap??.062)*(1+.25*c)*(1-.4*F),w=x*1.6,I=.15*(.55+.9*l*u)*(1-.6*F),z=.06*(.5+1.2*i*u),L=.05+.05*c;for(let C=0;C<S;C++){const O=(C-(S-1)/2)*P,q=Math.abs(C-(S-1)/2)/Math.max(1,(S-1)/2);for(let D=0;D<T;D++){const U=D/T*gt,Y=I*Math.sin(U*3-x*.95+C*.18)+z*Math.sin(U*5+x*.6)+L*Math.sin(U*2+s*.31+Math.sin(s*.17)*1.5),j=O+Y,Q=Math.cos(U),K=Math.sin(U),H=Q,ht=K*y+k*j,it=K*m+B*j,Z=Math.sqrt(H*H+ht*ht+it*it),ot=a*b(H/Z,ht/Z,it/Z)/Z,[X,bt,ut]=v(H*ot,ht*ot,it*ot),tt=(ut/a+1)/2,at=Math.max(0,Y)*c,ct=Math.atan2(Math.sin(U-w),Math.cos(U-w)),nt=Math.exp(-(ct*ct)/.18)*F;N.push({x:X,y:bt,z:ut,r:((t.rBase??.49)+(t.rDepth??.78)*tt)*(1-.25*q)*(1+1.2*at+.5*nt)*E,white:.52-.44*tt+.18*q-.3*nt,a:.4+.6*tt})}}return Wt(N,[],t.rMin)},me=(n,s,e,t)=>{const o=n/2,r=e.level,[c,l]=e.softBands,i=e.bands[2],a=e.drive,f=o*(t.radius??.6)*(1+(t.zoom??.06)*e.soft)*(1-.08*e.processing),h=cn((t.yaw??.42)+.08*Math.sin(s*.23),t.tilt??.32,o,o,1),u=Math.max(.4,(t.lineW??.6)*$t(n,.5)),p=v=>.06+.94*W((v/f+1)/2)**2,d=t.deform??1,g=.02+(.14*c+.06*r)*d,M=.01+(.07*l+.03*i)*d,y=An(g,M,a),m=[],R=Math.max(24,Math.round(t.segs??96)),b=Math.max(0,Math.round(t.limbs??2));for(let v=0;v<b;v++){const E=.1+.05*Math.sin(s*.31+v*2.1),x=s*.17*(v%2?1:-1)+v*2.4,N=Math.sin(E)*Math.cos(x),_=Math.sin(E)*Math.sin(x),k=Math.cos(E),B=Math.hypot(N,k),S=k/B,T=-N/B,F=_*T,P=k*S-N*T,w=-_*S,I=[],z=[];for(let L=0;L<R;L++){const C=L/R*gt,O=S*Math.cos(C)+F*Math.sin(C),q=P*Math.sin(C),D=T*Math.cos(C)+w*Math.sin(C),U=f*(1+.006*v+y(O,q,D));I.push(o+O*U,o-q*U),z.push(.55+.35*W((D/Math.sin(E)+1)/2))}m.push({pts:I,a:z,white:0,w:u,closed:!0})}const A=Math.max(2,Math.round(t.circles??8));for(let v=0;v<A;v++){const[E,x,N]=Pn(v,A),_=a*.16*(.5+Nt(v,2.1))*(v%2?1:-1)+Nt(v,6.6)*gt,k=x*Math.cos(_)-N*Math.sin(_),B=x*Math.sin(_)+N*Math.cos(_),S=Math.max(1e-6,Math.hypot(B,E)),T=B/S,F=-E/S,P=k*F,w=B*T-E*F,I=-k*T,z=[],L=[];for(let C=0;C<R;C++){const O=C/R*gt,q=T*Math.cos(O)+P*Math.sin(O),D=w*Math.sin(O),U=F*Math.cos(O)+I*Math.sin(O),Y=f*(1+y(q,D,U)),[j,Q,K]=h(q*Y,D*Y,U*Y);z.push(j,Q),L.push(p(K))}m.push({pts:z,a:L,white:0,w:u,closed:!0})}return Wt([],m,t.rMin)},Me=(n,s,e,t)=>{const o=n/2,r=e.level,[c,l,i]=e.bands,a=e.drive,f=e.processing,h=o*(t.radius??.6)*(1+(t.zoom??.1)*r)*(1-.08*f),u=.95*Math.sin(s*1.3),p=cn(s*.14,.32,o,o,1),d=$t(n,t.rsPow??.6)*(t.rMul??1),g=Math.max(40,Math.round(t.dotN??900)),M=t.cloudFreq??2.3,y=t.deform??1,m=.018+(.12*c+.04*r)*y,R=(.045*l+.03*i)*y,b=[],A=[];let v=0;for(let x=0;x<g;x++){const N=Pn(x,g),[_,k,B]=N,S=.55*Math.sin(2.1*_+1.3*k+.9*a)+.45*Math.sin(1.7*B-1.9*k-.7*a+1.3),T=Math.sin(5.3*_-4.1*B+2.3*a)*Math.sin(4.7*k+3.1*_-1.7*a),F=m*S+R*T;b.push(N),A.push(F),v+=F/g}const E=[];for(let x=0;x<g;x++){const[N,_,k]=b[x],B=A[x]-v,S=h*(1+B),[T,F,P]=p(N*S,_*S,k*S),w=W((P/h+1)/2),I=.65*Ht(N*M+a*.21,_*M-a*.15,k*M+a*.1)+.35*Ht(N*M*2.1-a*.29,_*M*2.1+7.3,k*M*2.1+a*.24),z=Zt(.34,.68,I),L=Math.exp(-((_-u)**2)/.012)*f,C=Math.max(0,B)/.16;E.push({x:T,y:F,z:P,r:((t.rBase??.27)+(t.rDepth??.84)*w)*(.22+.95*z+.6*L)*(1+.5*C)*d,white:.62-.52*w-.16*z-.3*L,a:.3+.7*w})}return Wt(E,[],t.rMin??.25)},ge=["orbit","sash","signal","swell","pixel","aura-mono","aura"],be={orbit:de,sash:pe,signal:me,swell:Me,pixel:fe,"aura-mono":he,aura:ie},pt={orbit:{speed:1.05,driveGain:.12,opts:{orbitN:12,particles:6},counts:{}},sash:{speed:1.5,driveGain:.8,gain:1.1,opts:{lanes:10,segs:56,ghostN:60},counts:{segs:.45,ghostN:.8}},signal:{speed:1.6,driveGain:2,opts:{circles:8,segs:96},counts:{circles:.5,segs:.5}},swell:{speed:1.4,driveGain:2.4,opts:{dotN:900},counts:{dotN:1}},pixel:{speed:1.2,driveGain:1.6,attack:.16,dotSize:.55,opts:{cells:17},counts:{cells:.5}},"aura-mono":{speed:1.2,driveGain:4,lean:{move:.55,pull:.36,deform:.28,squash:0,bounce:.92,lens:0,stretch:0,split:0,blur:1.24},opts:{segs:180},counts:{segs:.5}},aura:{speed:1.6,driveGain:2,voiceSpeed:.9,lean:{move:.21,pull:.36,deform:.28,squash:0,bounce:.92,lens:.49,stretch:1.04,split:1.01,blur:1.24},opts:{rings:6,segs:140},counts:{segs:.5}}};function ls(n,s,e=1,t=1){const o=n in pt?n:"orbit",r=pt[o],c=Math.min(1.4,Math.max(.2,s/200))*Math.max(.1,e),l={...r.opts};for(const[i,a]of Object.entries(r.counts)){const f=l[i];f!=null&&(l[i]=Math.max(1,Math.round(f*c**a)))}return t!==1&&(l.rMul=Math.max(.1,t)),{frame:be[o],speed:r.speed,driveGain:r.driveGain,gain:r.gain??1,opts:l}}function ve(n){let s=n;for(;s;){const e=s.getAttribute("data-theme");if(e==="dark")return!0;if(e==="light")return!1;if(s.classList.contains("dark"))return!0;if(s.classList.contains("light"))return!1;s=s.parentElement}return null}function ye(){return typeof matchMedia>"u"||matchMedia("(prefers-color-scheme: dark)").matches}function xe(n,s){const[e,t]=$.useState(!0);return $.useEffect(()=>{if(n==="dark"){t(!0);return}if(n==="light"){t(!1);return}const o=()=>{const i=ve(s.current);t(i??ye())};o();const r=typeof matchMedia<"u"?matchMedia("(prefers-color-scheme: dark)"):null,c=()=>o();r==null||r.addEventListener("change",c);let l=null;return typeof MutationObserver<"u"&&s.current&&(l=new MutationObserver(o),l.observe(document.documentElement,{attributes:!0,attributeFilter:["class","data-theme"],subtree:!0})),()=>{r==null||r.removeEventListener("change",c),l==null||l.disconnect()}},[n,s]),e}function Se(){const[n,s]=$.useState(!1);return $.useEffect(()=>{if(typeof matchMedia>"u")return;const e=matchMedia("(prefers-reduced-motion: reduce)");s(e.matches);const t=o=>s(o.matches);return e.addEventListener("change",t),()=>e.removeEventListener("change",t)},[]),n}const Rt=16,we=2.1,Ee=.3,Te=2.5,Re=1.6,Ae=5,Xn=2.2,Yn=[[80,300],[300,2e3],[2e3,6e3]],xn=90,Pe=7e3,Sn=Math.PI*2,wn=.35,En=.9;function hs(n){return n<0?0:n>1?1:n}function Tn(n,s){if(n<=s)return 0;const e=(n-s)/Math.max(.001,1-s);return hs((1-Math.exp(-3*e))/(1-Math.exp(-3)))}function qt(n,s,e,t,o){const r=s>n?t:o;return n+(s-n)*(1-Math.exp(-e/Math.max(.001,r)))}class us{constructor(){this.clock=0,this.t=0,this.drive=0,this.level=0,this.bands=[0,0,0],this.spectrum=new Float32Array(Rt),this.floor=new Float32Array(Rt+3).fill(1),this.heard=0,this.proc=0,this.spin=0,this.pan=0,this.panVel=0,this.raw={level:0,bands:[0,0,0],spectrum:new Float32Array(Rt)},this.timeBuf=null,this.freqBuf=null,this.out={level:0,bands:[0,0,0],soft:0,softBands:[0,0,0],spectrum:this.spectrum,drive:0,processing:0,spin:0,pan:0}}readAnalyser(s,e,t){(!this.timeBuf||this.timeBuf.length!==s.fftSize)&&(this.timeBuf=new Float32Array(s.fftSize)),(!this.freqBuf||this.freqBuf.length!==s.frequencyBinCount)&&(this.freqBuf=new Uint8Array(s.frequencyBinCount));const o=this.timeBuf,r=this.freqBuf;s.getFloatTimeDomainData(o);let c=0;for(let h=0;h<o.length;h++)c+=o[h]*o[h];this.raw.level=Math.sqrt(c/o.length)*Ae*e,s.getByteFrequencyData(r);const l=s.context.sampleRate/s.fftSize,i=(h,u)=>{const p=Math.max(0,Math.floor(h/l)),d=Math.max(p,Math.min(r.length-1,Math.ceil(u/l)));let g=0;for(let M=p;M<=d;M++)g+=r[M];return g/(d-p+1)/255},a=(h,u)=>{const p=this.floor[h];return this.floor[h]=u<p?u:p+(u-p)*(1-Math.exp(-t/8)),Math.max(0,u-this.floor[h])/Math.max(.05,1-this.floor[h])};for(let h=0;h<3;h++)this.raw.bands[h]=a(h,i(Yn[h][0],Yn[h][1]))*Xn*e;const f=Pe/xn;for(let h=0;h<Rt;h++){const u=xn*f**(h/Rt),p=xn*f**((h+1)/Rt);this.raw.spectrum[h]=a(3+h,i(u,p))*Xn*e}}readLevel(s,e){const t=hs(s)*e,o=this.clock;this.raw.level=t,this.raw.bands[0]=t,this.raw.bands[1]=t*(.72+.28*Math.sin(o*2.3)),this.raw.bands[2]=t*(.6+.4*Math.sin(o*3.7+2));const r=.28+.1*Math.sin(o*2.3)+.05*Math.sin(o*5.1),c=.64+.1*Math.sin(o*1.7+1);for(let l=0;l<Rt;l++){const i=l/(Rt-1),a=Math.exp(-((i-r)**2)/.012)+.6*Math.exp(-((i-c)**2)/.008);this.raw.spectrum[l]=t*(.25+.75*a)*(1-.4*i)}}readSilence(){this.raw.level=0,this.raw.bands.fill(0),this.raw.spectrum.fill(0)}step(s,e,t){const{threshold:o,attack:r,release:c,rate:l}=e,i=this.proc=qt(this.proc,e.processing?1:0,s,.35,.5),a=e.calm+(1-e.calm)*Math.min(1,Math.max(this.heard*2.5,i));t||(this.clock+=s,this.t+=s*l*a*(1+.5*i));const f=Tn(this.raw.level,o);this.level=qt(this.level,f,s,r,c),this.heard=qt(this.heard,this.level,s,wn,En);for(let m=0;m<3;m++)this.bands[m]=qt(this.bands[m],Tn(this.raw.bands[m],o*.6),s,r,c*1.15);for(let m=0;m<Rt;m++)this.spectrum[m]=qt(this.spectrum[m],Tn(this.raw.spectrum[m],o*.6),s,r,c);const h=this.clock,u=t?.5:.5+.5*Math.sin(Sn*h/6),p=e.idle*u*(1-i),d=this.out;d.level=this.level+(1-this.level)*p;for(let m=0;m<3;m++)d.bands[m]=this.bands[m]+(1-this.bands[m])*p*.6;d.soft=qt(d.soft,d.level,s,wn,En);for(let m=0;m<3;m++)d.softBands[m]=qt(d.softBands[m],d.bands[m],s,wn,En);if(t||(this.drive+=s*l*(a+e.driveGain*this.level+1.3*i)),d.drive=this.drive,d.processing=i,!t){const m=Math.ceil(this.spin/Sn-1e-6)*Sn,R=Math.min(Ee,(m-this.spin)*.6);this.spin+=s*(we*l*i+R*(1-i))}d.spin=this.spin;const g=Math.max(-1,Math.min(1,e.direction||0)),M=this.heard>.06&&!e.processing?g:0,y=Math.abs(M)>Math.abs(this.pan)?Te:Re;return this.panVel+=(y*y*(M-this.pan)-2*y*this.panVel)*s,this.pan+=this.panVel*s,d.pan=this.pan,d}}function Ce(n){if(!n)return;const s=n.trim().match(/^#([0-9a-f]{3}|[0-9a-f]{6})$/i);if(s){let t=s[1];t.length===3&&(t=t.replace(/./g,r=>r+r));const o=parseInt(t,16);return{r:o>>16&255,g:o>>8&255,b:o&255}}const e=n.trim().match(/^rgba?\(\s*([\d.]+)\s*,\s*([\d.]+)\s*,\s*([\d.]+)/i);if(e)return{r:Number(e[1]),g:Number(e[2]),b:Number(e[3])}}const _e={idle:"Waiting",listening:"Listening",speaking:"Speaking",processing:"Thinking"},Be=.55,Ie=1e3/62;function fs({type:n="orbit",state:s="listening",size:e=160,stream:t,analyser:o,level:r,sensitivity:c=.85,threshold:l=.04,attack:i,release:a=.32,idle:f=.1,calm:h=.4,voiceSpeed:u,emotion:p=null,emotionColors:d,saturation:g=2,accent:M=null,gradientAngle:y=99,gradientSpin:m=12,neutral:R=1,colorBrightness:b=1.02,colorHue:A=0,gradientStart:v=.1,gradientWidth:E=.6,direction:x,directionMove:N,directionPull:_,directionDeform:k,directionSquash:B,directionLens:S,directionStretch:T,directionSplit:F,directionBlur:P,directionBounce:w,directionMargin:I,directionBounds:z,hoverBend:L=!1,theme:C="auto",speed:O=1,paused:q=!1,color:D,dots:U=1,dotSize:Y,opts:j,frame:Q,onLevel:K,style:H,"aria-label":ht,...it}){const Z=$.useRef(null),ot=xe(C,Z),X=Se(),bt=j?JSON.stringify(j):"",ut=!!(t||o||r!=null||s==="processing"),tt=$.useRef(null);tt.current||(tt.current=new us);const at=$.useRef(null);at.current||(at.current=new Rs);const ct=p?(d==null?void 0:d[p])??Ft[p]:null,nt={saturation:Math.min(1,g),vivid:Math.max(0,Math.min(1,g-1)),brightness:b,hue:A,start:v,width:E,accent:M?Zn[M]:null,angle:y,spin:m,neutral:R,size:e},Ot=Y??pt[n in pt?n:"orbit"].dotSize??1,lt=pt[n in pt?n:"orbit"].lean??{},yt=I??pt[n in pt?n:"orbit"].margin??32,J={state:s,level:r,analyser:o,sensitivity:c,threshold:l,attack:i??pt[n in pt?n:"orbit"].attack??.06,release:a,idle:f,calm:h,voiceSpeed:u??pt[n in pt?n:"orbit"].voiceSpeed??1,onLevel:K,emotionTint:ct,colors:nt,direction:x,bounds:z,bend:L===!0?Be:typeof L=="number"?Math.max(0,Math.min(1,L)):0,lean:{move:N??lt.move??Pt.move,pull:_??lt.pull??Pt.pull,deform:k??lt.deform??Pt.deform,squash:B??lt.squash??Pt.squash,lens:S??lt.lens??Pt.lens,stretch:T??lt.stretch??Pt.stretch,split:F??lt.split??Pt.split,blur:P??lt.blur??Pt.blur,bounce:w??lt.bounce??Pt.bounce}},V=$.useRef(J);V.current=J;const ft=x==null?0:Cs(J.lean,e),[xt,Ct]=$.useState([1/0,1/0]),St=Math.min(ft,xt[0]),Gt=Math.min(ft,xt[1]),dt=ft?St+yt:0,wt=ft?Gt+yt:0,Dt=$.useRef({x:0,y:0,over:!1}),Ut=J.bend>0&&!X;$.useEffect(()=>{const st=Z.current;if(!Ut||!st||typeof matchMedia!="function"||!matchMedia("(hover: hover) and (pointer: fine)").matches)return;const _t=vt=>{if(vt.pointerType==="touch")return;const Vt=st.getBoundingClientRect(),Jt=(e+dt+wt)/(Vt.width||1);Dt.current={x:(vt.clientX-Vt.left)*Jt-dt,y:(vt.clientY-Vt.top)*Jt,over:!0}},kt=()=>{Dt.current.over=!1};return window.addEventListener("pointermove",_t,{passive:!0}),document.documentElement.addEventListener("pointerleave",kt),()=>{window.removeEventListener("pointermove",_t),document.documentElement.removeEventListener("pointerleave",kt),Dt.current.over=!1}},[Ut,e,dt,wt]);const rn=$.useRef(null);return $.useEffect(()=>{if(!t)return;const st=Hn(t);return rn.current=(st==null?void 0:st.analyser)??null,()=>{rn.current=null,st==null||st.release()}},[t]),$.useEffect(()=>{const st=Z.current;if(!st)return;const _t=Math.min(2,typeof devicePixelRatio<"u"&&devicePixelRatio||1);st.width=Math.round((e+dt+wt)*_t),st.height=Math.round(e*_t);const kt=st.getContext("2d");if(!kt)return;const vt=ls(n,e,U,Ot),Vt=j?{...vt.opts,...j}:vt.opts,Jt=Q??vt.frame,ds=Ce(D),Bt=tt.current,ps=at.current,ms=new _s;let _n=0,Xt=0,ln=e/2,hn=e/2;const Ms=(rt,et,G)=>{var kn;kt.setTransform(_t,0,0,_t,dt*_t,0),kt.clearRect(-dt,0,e+dt+wt,e);const Yt=q||X?0:ms.step(_n,G);let mt=Bs(Jt(e,Bt.t,rt,Vt),rt.pan,e,V.current.lean,[St,Gt],Yt);_n=((kn=mt.contact)==null?void 0:kn.press)??0;const At=V.current.bend;if(At>0){const jt=Dt.current,zn=Jn(mt,e),ys=V.current.state==="idle"||V.current.state==="processing",xs=jt.over&&ys&&!q&&!X?Ps(Math.hypot(jt.x-e/2,jt.y-e/2)-zn,zn):0;Xt+=(xs-Xt)*(1-Math.exp(-G/.14));const Ln=Xt<.01?1:1-Math.exp(-G/.05);ln+=(jt.x-ln)*Ln,hn+=(jt.y-hn)*Ln,Xt>.002&&(mt=As(mt,e,{x:ln,y:hn,amount:Xt*At}))}const Et=V.current.colors,Tt=et.amount,Mt=Et.accent,bs=Mt?{r:Mt.r+(et.r-Mt.r)*Tt,g:Mt.g+(et.g-Mt.g)*Tt,b:Mt.b+(et.b-Mt.b)*Tt}:{r:et.r,g:et.g,b:et.b},vs={...Et,accent:bs,saturation:Et.saturation*(Mt?1:Tt),angle:Et.angle+Et.spin*Bt.clock};ce(kt,mt,ot,ds,mt.light||mt.tube?et:void 0,vs)};let Bn=-1/0;const gs=rt=>{var Et,Tt;if(!ft||rt-Bn<500)return;Bn=rt;const et=st.getBoundingClientRect().left+dt,G=(Tt=(Et=V.current.bounds)==null?void 0:Et.current)==null?void 0:Tt.getBoundingClientRect(),Yt=G?G.left:0,mt=G?G.right:document.documentElement.clientWidth,At=[Math.max(0,Math.floor(et-Yt-yt)),Math.max(0,Math.floor(mt-et-e-yt))];Ct(Mt=>Math.abs(Mt[0]-At[0])>1||Math.abs(Mt[1]-At[1])>1?At:Mt)};let Qt=0;const In=rt=>{var Tt;gs(rt);const et=Qt?Math.min(.05,(rt-Qt)/1e3):1/60;Qt=rt;const G=V.current,Yt=G.state==="listening"||G.state==="speaking",mt=rn.current??G.analyser??null;Yt?mt?Bt.readAnalyser(mt,G.sensitivity*vt.gain,et):G.level!=null?Bt.readLevel(typeof G.level=="function"?G.level():G.level,G.sensitivity*vt.gain):Bt.readSilence():Bt.readSilence();const At=Bt.step(et,{sensitivity:G.sensitivity,threshold:G.threshold,attack:G.attack,release:G.release,idle:G.idle,driveGain:vt.driveGain*G.voiceSpeed,calm:G.calm,rate:vt.speed*O,processing:G.state==="processing",direction:typeof G.direction=="function"?G.direction():G.direction??0},X);(Tt=G.onLevel)==null||Tt.call(G,At.level);const Et=ps.step(et,G.emotionTint,Bt.clock,e,q||X);Ms(At,Et,et)};if(In(performance.now()),q||X&&!ut)return;let un=0,tn=!1,Fn=0;const Nn=rt=>{tn&&(un=requestAnimationFrame(Nn),!(rt-Fn<Ie)&&(Fn=rt,In(rt)))},fn=()=>{tn||(tn=!0,Qt=0,un=requestAnimationFrame(Nn))},dn=()=>{tn=!1,cancelAnimationFrame(un)};let pn=!0;const zt=typeof IntersectionObserver<"u"?new IntersectionObserver(([rt])=>{pn=rt.isIntersecting,pn&&document.visibilityState!=="hidden"?fn():dn()}):null;zt==null||zt.observe(st);const On=()=>{document.visibilityState==="hidden"?dn():pn&&fn()};return document.addEventListener("visibilitychange",On),zt||fn(),()=>{dn(),zt==null||zt.disconnect(),document.removeEventListener("visibilitychange",On)}},[n,e,ft,St,Gt,dt,wt,yt,ot,O,q,X,ut,D,U,Ot,bt,Q,q||X?p:null,q||X?`${g}|${M}|${y}|${m}|${R}|${b}|${A}|${v}|${E}`:null]),jn.jsx("canvas",{ref:Z,role:"img","aria-label":ht??_e[s],style:{width:e+dt+wt,height:e,display:"block",marginLeft:-dt,marginRight:-wt,...H},...it})}const Fe={echoCancellation:!1,noiseSuppression:!1,autoGainControl:!1};function on(){return typeof navigator<"u"&&typeof navigator.mediaDevices<"u"&&typeof navigator.mediaDevices.getUserMedia=="function"}function Ne(n={}){const{constraints:s,autoStart:e=!1}=n,[t,o]=$.useState(null),[r,c]=$.useState(()=>on()?"idle":"unsupported"),[l,i]=$.useState(null),a=$.useRef(null),f=$.useRef(s);f.current=s;const h=$.useCallback(()=>{const p=a.current;a.current=null,p&&p.getTracks().forEach(d=>d.stop()),o(null),c(on()?"idle":"unsupported")},[]),u=$.useCallback(async()=>{if(!on())return c("unsupported"),null;if(a.current)return a.current;Rn(),c("requesting"),i(null);try{const p=await navigator.mediaDevices.getUserMedia({audio:{...Fe,...f.current??{}}});a.current=p,o(p),c("live");const d=()=>{a.current===p&&(a.current=null,o(null),c("idle"))};return p.getAudioTracks().forEach(g=>g.addEventListener("ended",d)),p}catch(p){const d=p instanceof Error?p:new Error(String(p));return i(d),c(d.name==="NotAllowedError"||d.name==="SecurityError"?"denied":"error"),null}},[]);return $.useEffect(()=>{e&&u()},[e]),$.useEffect(()=>()=>{const p=a.current;a.current=null,p&&p.getTracks().forEach(d=>d.stop())},[]),{stream:t,state:r,error:l,supported:on(),start:u,stop:h}}const Oe={ring:"aura",mono:"aura-mono"};function ke({type:n="ring",...s}){return jn.jsx(fs,{...s,type:Oe[n]})}exports.ACCENT_COLORS=Zn;exports.EMOTION_COLORS=Ft;exports.PRESETS=pt;exports.SPECTRUM_N=Rt;exports.VOICE_ORB_TYPES=ge;exports.VoiceFollower=us;exports.VoiceOrb=fs;exports.VoiceRing=ke;exports.acquireAnalyser=Hn;exports.getAudioContext=Rn;exports.isAudioSupported=Ss;exports.resolvePreset=ls;exports.useMicrophone=Ne;
|
package/dist/index.d.ts
CHANGED
|
@@ -75,6 +75,39 @@ declare interface FrameLight {
|
|
|
75
75
|
}>;
|
|
76
76
|
/** Chromatic fringe offset, as a share of `r`. */
|
|
77
77
|
fringe: number;
|
|
78
|
+
/** Where the positive emotion's colours run round the ring: degrees of
|
|
79
|
+
* hue, from one side to the other. @default [81, 136] (yellow-green → green) */
|
|
80
|
+
green?: [number, number];
|
|
81
|
+
/** How the spectrum is graded and the glow drawn; each part defaults to
|
|
82
|
+
* the untouched look. */
|
|
83
|
+
look?: Partial<LightLook>;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** How a tube frame is lit. */
|
|
87
|
+
declare interface FrameTube {
|
|
88
|
+
/** The strength of the highlight running along the tube. @default 1 */
|
|
89
|
+
shine: number;
|
|
90
|
+
/** Stretches the light between the tube's lit and shadowed parts. @default 1 */
|
|
91
|
+
contrast: number;
|
|
92
|
+
/** How much thinner the far side is: 0 even … 0.5 the far side vanishing. @default 0.15 */
|
|
93
|
+
depth?: number;
|
|
94
|
+
/** An emotion's colour on the tube: 0 grey … 1 full … 2 deeper still. @default 1 */
|
|
95
|
+
saturation?: number;
|
|
96
|
+
/** How far the colour fades into the neutral grey round the orb: 0 the
|
|
97
|
+
* colour all round … 1 grey on the far side. @default 1 */
|
|
98
|
+
gradient?: number;
|
|
99
|
+
/** Where round the orb the colour is fullest, degrees. @default 0 */
|
|
100
|
+
gradientAngle?: number;
|
|
101
|
+
/** How fast the fade turns round the orb, degrees a second. @default 20 */
|
|
102
|
+
gradientSpin?: number;
|
|
103
|
+
/** The coloured tube's lightness: below 1 deeper, above 1 paler. @default 1 */
|
|
104
|
+
colorBrightness?: number;
|
|
105
|
+
/** Each emotion's own brightness on top of `colorBrightness`: positive's
|
|
106
|
+
* green, negative's red, calm's blue. A colour between them takes a
|
|
107
|
+
* blend, by how near it is to each. @default 1 */
|
|
108
|
+
positiveBrightness?: number;
|
|
109
|
+
negativeBrightness?: number;
|
|
110
|
+
calmBrightness?: number;
|
|
78
111
|
}
|
|
79
112
|
|
|
80
113
|
/**
|
|
@@ -118,6 +151,30 @@ declare interface LeanAmounts {
|
|
|
118
151
|
bounce?: number;
|
|
119
152
|
}
|
|
120
153
|
|
|
154
|
+
/** The light's grade and glow, as the painter takes them. */
|
|
155
|
+
declare interface LightLook {
|
|
156
|
+
/** Turns the spectrum's hues, degrees. @default 0 */
|
|
157
|
+
hue: number;
|
|
158
|
+
/** Scales its colourfulness: 0 white light … 2 twice as vivid. @default 1 */
|
|
159
|
+
chroma: number;
|
|
160
|
+
/** Warms (+) or cools (−) it, −1 … 1. @default 0 */
|
|
161
|
+
warmth: number;
|
|
162
|
+
/** Stretches the lightness between its colours. @default 1 */
|
|
163
|
+
contrast: number;
|
|
164
|
+
/** How many times the spectrum runs round the ring. @default 1 */
|
|
165
|
+
cycles: number;
|
|
166
|
+
/** Scales the halo's width. @default 1 */
|
|
167
|
+
glowSize: number;
|
|
168
|
+
/** Scales the bloom hugging the rings. @default 1 */
|
|
169
|
+
bloom: number;
|
|
170
|
+
/** Scales the bloom's width. @default 1 */
|
|
171
|
+
bloomSize: number;
|
|
172
|
+
/** How far the halo and bloom are blurred, CSS px. @default 1.5 */
|
|
173
|
+
soft: number;
|
|
174
|
+
/** Scales the crisp core of the rings. @default 1 */
|
|
175
|
+
core: number;
|
|
176
|
+
}
|
|
177
|
+
|
|
121
178
|
export declare type MicrophoneState = 'idle' | 'requesting' | 'live' | 'denied' | 'unsupported' | 'error';
|
|
122
179
|
|
|
123
180
|
/** Where a leaning orb meets the screen's edge, and how hard it presses. */
|
|
@@ -147,6 +204,9 @@ declare interface OrbFrame {
|
|
|
147
204
|
strokes: Stroke[];
|
|
148
205
|
/** Present on luminous types: paint the strokes as coloured light. */
|
|
149
206
|
light?: FrameLight;
|
|
207
|
+
/** Present on tube types: paint the strokes as lit tubes, each stroke's
|
|
208
|
+
* `a` its light (0 … 1) and `z` its depth. */
|
|
209
|
+
tube?: FrameTube;
|
|
150
210
|
/** Paint the dots as squares, `r` their half side: pixels, not points. */
|
|
151
211
|
square?: boolean;
|
|
152
212
|
/** Set by the lean while the orb presses on the screen's edge. */
|
|
@@ -232,6 +292,9 @@ declare interface Stroke {
|
|
|
232
292
|
/** Width in CSS px. */
|
|
233
293
|
w: number;
|
|
234
294
|
closed?: boolean;
|
|
295
|
+
/** Depth per point, −1 far … 1 near: a tube frame's draw order and
|
|
296
|
+
* thickness where the line passes in front of itself. */
|
|
297
|
+
z?: number[];
|
|
235
298
|
}
|
|
236
299
|
|
|
237
300
|
/**
|
|
@@ -545,19 +608,29 @@ export declare interface VoiceOrbProps extends Omit<CanvasHTMLAttributes<HTMLCan
|
|
|
545
608
|
export declare type VoiceOrbState = 'idle' | 'listening' | 'speaking' | 'processing';
|
|
546
609
|
|
|
547
610
|
/**
|
|
548
|
-
* The
|
|
611
|
+
* The seven orb types:
|
|
549
612
|
* - `orbit` — particles on tilted orbits in perspective; a voice zooms it toward you
|
|
550
613
|
* - `sash` — an undulating band of dotted lanes; a voice deepens the wave
|
|
551
614
|
* - `signal` — a wireframe of great circles; a voice deforms it like a skin
|
|
552
615
|
* - `swell` — a halftone sphere of drifting clouds; a voice bulges its surface
|
|
553
616
|
* - `pixel` — a ball of square pixels, halftone shaded; a voice bulges it and lights it in rings
|
|
617
|
+
* - `aura-mono` — the aura's rings as two loops of grey tube; a voice opens them into a turning globe
|
|
554
618
|
* - `aura` — signal's rings drawn in light: a blooming spectrum; a voice bends and brightens it
|
|
555
619
|
*/
|
|
556
|
-
export declare type VoiceOrbType = 'orbit' | 'sash' | 'signal' | 'swell' | 'pixel' | 'aura';
|
|
620
|
+
export declare type VoiceOrbType = 'orbit' | 'sash' | 'signal' | 'swell' | 'pixel' | 'aura-mono' | 'aura';
|
|
557
621
|
|
|
558
|
-
/** A voice-reactive ring
|
|
559
|
-
export declare function VoiceRing(props: VoiceRingProps): JSX_2.Element;
|
|
622
|
+
/** A voice-reactive ring: VoiceOrb with its type fixed to one of the two aura types. */
|
|
623
|
+
export declare function VoiceRing({ type, ...props }: VoiceRingProps): JSX_2.Element;
|
|
624
|
+
|
|
625
|
+
export declare type VoiceRingProps = Omit<VoiceOrbProps, 'type' | 'frame'> & {
|
|
626
|
+
/**
|
|
627
|
+
* How the ring is drawn: `ring`, a glassy ribbon with a spectrum running
|
|
628
|
+
* round it, or `mono`, two loops of grey tube that a voice opens into a
|
|
629
|
+
* turning globe, an emotion colouring the tube. @default 'ring'
|
|
630
|
+
*/
|
|
631
|
+
type?: VoiceRingType;
|
|
632
|
+
};
|
|
560
633
|
|
|
561
|
-
export declare type
|
|
634
|
+
export declare type VoiceRingType = 'ring' | 'mono';
|
|
562
635
|
|
|
563
636
|
export { }
|