@lofcz/orb-ui 0.11.0 → 0.12.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/dist/orb-ui.cjs CHANGED
@@ -308,4 +308,4 @@ void main() {
308
308
  // perimeter so translucent edge pixels cannot become a bright outline.
309
309
  gl_FragColor = vec4(color * edge, edge);
310
310
  }
311
- `,ye=.72;function Z(e,t=0,n=1){return Math.min(n,Math.max(t,e))}function Q(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}function be(e,t){let n=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!n)return t;let r=parseInt(n[1],16);return[(r>>16&255)/255,(r>>8&255)/255,(r&255)/255]}function xe(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function $([e,t,n],r){return`rgba(${Math.round(e*255)}, ${Math.round(t*255)}, ${Math.round(n*255)}, ${r})`}function Se(e,t){let n=ge[e],r=e=>{let r=be(n[e],[0,0,0]),i=t?.[e];return i?be(i,r):r};return{deep:r(`deep`),shallow:r(`shallow`),foam:r(`foam`),glow:r(`glow`),sky:r(`sky`),horizon:r(`horizon`)}}function Ce(e,t,n){let r=e.createShader(t);if(r){if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){e.deleteShader(r);return}return r}}function we(e,t,n){let r=e.getContext(`webgl`,{alpha:!0,antialias:!0,premultipliedAlpha:!0});if(!r)return;let i=Ce(r,r.VERTEX_SHADER,_e),a=Ce(r,r.FRAGMENT_SHADER,ve);if(!i||!a){i&&r.deleteShader(i),a&&r.deleteShader(a);return}let o=r.createProgram(),s=r.createBuffer();if(!o||!s){o&&r.deleteProgram(o),s&&r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a);return}if(r.attachShader(o,i),r.attachShader(o,a),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS)){r.deleteProgram(o),r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a);return}let c=()=>{r.deleteProgram(o),r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a)},l=r.getAttribLocation(o,`a_position`),u=e=>r.getUniformLocation(o,e),d={resolution:u(`u_resolution`),time:u(`u_time`),level:u(`u_level`),swell:u(`u_swell`),ripple:u(`u_ripple`),glow:u(`u_glow`),tilt:u(`u_tilt`),listen:u(`u_listen`),speak:u(`u_speak`),surge:u(`u_surge`),deep:u(`u_deep`),shallow:u(`u_shallow`),foam:u(`u_foam`),light:u(`u_light`),sky:u(`u_sky`),horizon:u(`u_horizon`)};if(l<0||Object.values(d).some(e=>!e)){c();return}let f=Math.min(window.devicePixelRatio||1,2),p=Math.max(1,Math.round(t*f));return e.width=p,e.height=p,r.viewport(0,0,p,p),r.useProgram(o),r.bindBuffer(r.ARRAY_BUFFER,s),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),r.STATIC_DRAW),r.enableVertexAttribArray(l),r.vertexAttribPointer(l,2,r.FLOAT,!1,0,0),r.uniform2f(d.resolution,p,p),r.uniform3fv(d.deep,n.deep),r.uniform3fv(d.shallow,n.shallow),r.uniform3fv(d.foam,n.foam),r.uniform3fv(d.light,n.glow),r.uniform3fv(d.sky,n.sky),r.uniform3fv(d.horizon,n.horizon),{draw(e){r.uniform1f(d.time,e.time),r.uniform1f(d.level,e.level),r.uniform1f(d.swell,e.swell),r.uniform1f(d.ripple,e.ripple),r.uniform1f(d.glow,e.glow),r.uniform1f(d.tilt,e.tilt),r.uniform1f(d.listen,e.listen),r.uniform1f(d.speak,e.speak),r.uniform1f(d.surge,e.surge),r.drawArrays(r.TRIANGLES,0,6)},destroy:c}}function Te(e,t,n,r){switch(e){case`connecting`:return{swell:.03,speed:.32,glow:.3+.2*Math.sin(r*2.6),tiltAmplitude:.02,levelOffset:0,corona:.3+.1*Math.sin(r*2.6),reach:.24,ringEvery:0,ringStrength:0,ringInward:!1,orbit:0,sweep:1,pulse:.5};case`listening`:return{swell:.045+t*.03,speed:.45+t*.25,glow:.42+t*.5,tiltAmplitude:.03,levelOffset:t*.05,corona:.36+t*.3,reach:.24+t*.1,ringEvery:1.6-t*.5,ringStrength:.3+t*.35,ringInward:!0,orbit:0,sweep:0,pulse:.3};case`thinking`:return{swell:.05,speed:.7,glow:.5+.1*Math.sin(r*1.6),tiltAmplitude:.045,levelOffset:.01,corona:.38+.08*Math.sin(r*1.6),reach:.28,ringEvery:0,ringStrength:0,ringInward:!0,orbit:1,sweep:0,pulse:1};case`speaking`:return{swell:.055+n*.045,speed:.5+n*.25,glow:.55+n*.3,tiltAmplitude:.035,levelOffset:.02+n*.05,corona:.45+n*.3,reach:.24+n*.1,ringEvery:0,ringStrength:.3,ringInward:!1,orbit:0,sweep:0,pulse:.2};case`error`:return{swell:.02,speed:.2,glow:.06,tiltAmplitude:.01,levelOffset:-.04,corona:.08,reach:.15,ringEvery:0,ringStrength:0,ringInward:!1,orbit:0,sweep:0,pulse:0};default:return{swell:.036,speed:.36,glow:.28,tiltAmplitude:.028,levelOffset:0,corona:.3,reach:.22,ringEvery:6,ringStrength:.25,ringInward:!1,orbit:0,sweep:0,pulse:.35}}}var Ee=.1,De=7.5,Oe=3.2,ke=14,Ae=1.7,je=.3,Me=2.2,Ne=3,Pe=9,Fe=3.2,Ie=14,Le=.45,Re=.25,ze=.085;function Be(){return Array.from({length:Ne},(e,t)=>({angle:t/Ne*Math.PI*2,speed:(.55+t%3*.2)*(t%2==0?1:-1),radius:1.12+t%2*.08,size:.016+t%2*.006,wobble:.7+t*.37}))}function Ve(e,t,n,r){let i=e.getContext(`2d`);if(!i)return;let a=Math.min(window.devicePixelRatio||1,2),o=t*Ae;e.width=Math.max(1,Math.round(o*a)),e.height=e.width,i.scale(a,a);let s=o/2,c=t/2,l=r===`dark`?xe(n.shallow,n.glow,.35):n.shallow,u=r===`dark`?xe(n.glow,n.foam,.4):n.deep,d=r===`dark`?n.shallow:n.deep,f=r===`dark`?1:.75,p=(e,t,n)=>{i.beginPath(),i.arc(e,t,n,0,Math.PI*2)};return{draw(e){i.clearRect(0,0,o,o),i.globalCompositeOperation=r===`dark`?`lighter`:`source-over`;let t=c*(1+e.reach+e.pulse*.03+Math.sin(e.breath)*.015),n=Z(e.corona*(r===`dark`?.55:.5)),a=i.createRadialGradient(s,s,c*.9,s,s,t);a.addColorStop(0,$(l,n)),a.addColorStop(.3,$(l,n*.5)),a.addColorStop(.65,$(l,n*.15)),a.addColorStop(1,$(l,0)),i.fillStyle=a,p(s,s,t),i.fill();let m=Z(e.speak+e.listen*.6);if(m>.01){let e=c*(1.02+m*.5),t=i.createRadialGradient(s,s,c*.95,s,s,e);t.addColorStop(0,$(l,.35*m*f)),t.addColorStop(.4,$(u,.1*m*f)),t.addColorStop(1,$(u,0)),i.fillStyle=t,p(s,s,e),i.fill()}let h=Z((.3+e.glow*.35+e.speak*.2+e.listen*.25)*f),g=c*(1.06+e.speak*.04),_=i.createRadialGradient(s,s,c*.97,s,s,g);_.addColorStop(0,$(u,h)),_.addColorStop(1,$(u,0)),i.fillStyle=_,p(s,s,c*1.15),i.fill();for(let t of e.rings){let n=Z((e.time-t.born)/Me),r=1-(1-n)**2.2,a=t.inward?1-r:r,o=c*(1+je*a),d=Z((t.inward?(1-a)**.6*(1-n**4):(1-n)**1.3)*t.strength);if(d<.005)continue;let m=c*(.01+t.strength*.014)*(1-a*.3);i.lineWidth=m*4,i.strokeStyle=$(l,d*.16),p(s,s,o),i.stroke(),i.lineWidth=m,i.strokeStyle=$(u,d*.4*f),p(s,s,o),i.stroke()}if(e.orbit>.01)for(let t of e.orbiters){let n=Math.sin(e.time*t.wobble)*.05,r=c*(t.radius+n),a=.8+e.orbit*.7,o=t.speed>0?1:-1;for(let n=0;n<14;n+=1){let d=n/14*a,m=t.angle-o*d,h=s+Math.cos(m)*r,g=s+Math.sin(m)*r,_=(1-n/14)**2*e.orbit;i.fillStyle=$(n===0?u:l,Z(_*(n===0?1:.7)*f)),p(h,g,c*t.size*(1-n/14*.7)),i.fill()}let d=c*t.size*5,m=s+Math.cos(t.angle)*r,h=s+Math.sin(t.angle)*r,g=i.createRadialGradient(m,h,0,m,h,d);g.addColorStop(0,$(l,.35*e.orbit)),g.addColorStop(1,$(l,0)),i.fillStyle=g,p(m,h,d),i.fill()}if(e.sweep>.01){let t=[{orbitRadius:c*1.12,start:e.time*2,span:Math.PI*.55,width:.025}];for(let{orbitRadius:n,start:r,span:a,width:o}of t){let t=i.createConicGradient(r,s,s);t.addColorStop(0,$(u,0)),t.addColorStop(a/(Math.PI*2),$(u,.7*e.sweep*f)),t.addColorStop(a/(Math.PI*2)+.001,$(u,0)),t.addColorStop(1,$(u,0)),i.lineWidth=c*o,i.strokeStyle=t,i.beginPath(),i.arc(s,s,n,r,r+a),i.stroke(),i.lineWidth=c*.01,i.strokeStyle=$(d,.2*e.sweep*f),p(s,s,n),i.stroke()}}}}}function He({state:n,volume:r,size:i,scheme:a=`light`,palette:o,className:s,style:c,disabled:l=!1,interactive:u=!1,onClick:d,...f}){let p=(0,e.useRef)(null),m=(0,e.useRef)(null),h=(0,e.useRef)(null),g=(0,e.useRef)(n),_=(0,e.useRef)(r),v=(0,e.useRef)(!1);he(()=>{g.current=n,_.current=r},[n,r]);let y=i*ye,b=Se(a,o),x=JSON.stringify(b);(0,e.useEffect)(()=>{let e=p.current,t=m.current,n=h.current;if(!e||!t||!n)return;let r=JSON.parse(x),i=window.matchMedia(`(prefers-reduced-motion: reduce)`),o=()=>{v.current=i.matches};o(),i.addEventListener(`change`,o);let s=we(e,y,r);s||(e.style.background=`linear-gradient(180deg, ${$(r.sky,1)} 0%, ${$(r.horizon,1)} 44%, ${$(r.shallow,1)} 48%, ${$(r.deep,1)} 100%)`);let c=Ve(t,y,r,a),l=0,u=performance.now(),d=0,f=0,b=0,S=0,C=Z(_.current),w=0,T=0,E=.036,D=.36,O=.26,k=.028,A=0,j=.3,M=.24,N=0,P=0,F=.3,I=0,L=0,R=0,z=Re,B=0,V=0,H=!1,U=0,W=[],G=Be(),K=e=>{let t=Math.min((e-u)/1e3,.05);u=e;let r=g.current,i=v.current,a=Z(_.current);C=i?0:Q(C,a,a>C?4:1.5,t);let o=r===`listening`?C:0,p=r===`speaking`?C:0;w=Q(w,o,o>w?4:1.5,t),T=Q(T,p,p>T?4:1.5,t),f+=t;let m=Te(r,w,T,f);E=Q(E,m.swell,2.4,t),D=Q(D,m.speed,2.4,t),O=Q(O,m.glow,3.2,t),k=Q(k,m.tiltAmplitude,1.8,t),A=Q(A,m.levelOffset,3,t),j=Q(j,m.corona,m.corona>j?6:2.5,t),M=Q(M,m.reach,m.reach>M?7:2.5,t),N=Q(N,m.orbit,3,t),P=Q(P,m.sweep,3,t),F=Q(F,m.pulse,2.5,t),R+=((r===`speaking`?C:0)-L)*ke*t,R*=Math.exp(-8*t),L+=R*t;let h=r===`speaking`&&!i;z=Math.max(h?a:0,Re,z-(z-Re)*Le*t);let y=h?Z(a/z):0;if(B=Q(B,y,y>B?Pe:Fe,t),V=Q(V,B,Ie,t),!i){d+=t*D,b+=t*Math.PI*2/De,S+=t*.31,I+=t*Math.PI*2/Oe;for(let e of G)e.angle+=t*e.speed*(.6+N*.9);U+=t;let e=V>.55;for(h?e&&!H&&U>=1&&(U=0,W.push({born:f,strength:m.ringStrength,inward:!1})):m.ringEvery>0&&(r!==`listening`||w>.03)&&U>=m.ringEvery&&(U=0,W.push({born:f,strength:m.ringStrength,inward:m.ringInward})),H=e;W.length>0&&f-W[0].born>Me;)W.shift()}let x=Ee+A+Math.sin(b)*.022,ee=Math.sin(S)*k+Math.sin(S*2.3+.7)*.006,q=i?0:Z(L);s?.draw({time:d,level:x,swell:i?.012:E,ripple:i?0:w,glow:O,tilt:i?0:ee,listen:w,speak:T,surge:q});let J=(.5+.5*Math.sin(I))*F,Y=V**.85*ze,te=1+J*.012+Math.sin(b)*.005+Y+w*.015;n.style.transform=i?`none`:`scale(${te})`,c?.draw({time:f,corona:i?j*.6:j+V*.2,reach:M,glow:O,speak:Math.max(T,V*.8),listen:w,orbit:i?0:N,sweep:i?0:P,pulse:J,breath:b,rings:i?[]:W,orbiters:G}),l=requestAnimationFrame(K)};return l=requestAnimationFrame(K),()=>{cancelAnimationFrame(l),i.removeEventListener(`change`,o),s?.destroy()}},[y,x,a]);let S={width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...c},C=y*Ae,w=(0,t.jsxs)(`span`,{ref:h,style:{position:`relative`,display:`block`,width:y,height:y,borderRadius:`50%`,lineHeight:0,cursor:u?l?`not-allowed`:`pointer`:`default`,transformOrigin:`center`,willChange:`transform`},children:[(0,t.jsx)(`canvas`,{ref:m,"aria-hidden":`true`,"data-ocean-aura":``,style:{position:`absolute`,left:(y-C)/2,top:(y-C)/2,display:`block`,width:C,height:C,pointerEvents:`none`}}),(0,t.jsx)(`canvas`,{ref:p,"aria-hidden":`true`,"data-ocean-surface":``,style:{position:`absolute`,inset:0,display:`block`,width:y,height:y,borderRadius:`50%`,boxShadow:`0 ${y*.06}px ${y*.22}px ${$(b.deep,a===`dark`?.55:.28)}`}})]});return u?(0,t.jsx)(`button`,{...f,type:`button`,className:s,disabled:l,onClick:l?void 0:d,style:{appearance:`none`,WebkitAppearance:`none`,border:0,padding:0,margin:0,background:`transparent`,color:`inherit`,font:`inherit`,cursor:l?`not-allowed`:`pointer`,...S},children:w}):(0,t.jsx)(`div`,{...f,className:s,style:S,children:w})}function Ue({signal:i,state:a,volume:s,adapter:c,theme:l=`debug`,size:u=200,scheme:d,palette:f,className:p,style:m,disabled:h=!1,interactive:g=!0,onStart:_,onStop:v,renderTheme:y,...x}){let[S,C]=(0,e.useState)({state:`idle`});(0,e.useEffect)(()=>{if(C({state:`idle`}),c)return c.subscribe(C)},[c]);let w=i??S,T=n(a,i,S),D=r(s,T,w),O=w.inputVolume??0,k=w.outputVolume??0,A=(0,e.useMemo)(()=>({...w,state:T,inputVolume:O,outputVolume:k}),[w,O,k,T]),j=T!==`idle`&&T!==`error`,M=(0,e.useCallback)(()=>{if(!h)return _?_():c?.start?.()},[c,h,_]),N=(0,e.useCallback)(()=>{if(!h)return v?v():c?.stop?.()},[c,h,v]),P=(0,e.useCallback)(()=>j?N():M(),[j,M,N]),F=j?!!(c?.stop||v):!!(c?.start||_),I=g&&F,L=I&&!h?P:void 0,R=x[`aria-label`]??(I?`${j?`Stop`:`Start`} voice session`:void 0),z={...x,"aria-label":R};if(y){let e={...x,type:`button`,disabled:h||!I,onClick:L,"data-orb-ui-state":T,"aria-label":R};return y({state:T,signal:A,inputVolume:O,outputVolume:k,activity:D,size:u,isActive:j,interactive:I,disabled:h,start:M,stop:N,toggle:P,rootProps:{className:p,style:{width:u,height:u,...m},"data-orb-ui-theme":`custom`,"data-orb-ui-state":T},controlProps:e})}let B={state:T,volume:D,size:u,className:p,style:m,disabled:h,...z},V={...B,interactive:I};switch(l){case`circle`:return(0,t.jsx)(b,{...V,onClick:L});case`bars`:return(0,t.jsx)(E,{...V,onClick:L});case`cloud`:return(0,t.jsx)(ne,{...V,onClick:L});case`radial`:return(0,t.jsx)(me,{...V,onClick:L});case`ocean`:return(0,t.jsx)(He,{...V,scheme:d,palette:f,onClick:L});default:return(0,t.jsx)(o,{...B,disabled:h||!g,onStart:h||!g?void 0:M,onStop:h||!g?void 0:N})}}exports.Orb=Ue,exports.VoiceOrb=Ue;
311
+ `,ye=.72;function Z(e,t=0,n=1){return Math.min(n,Math.max(t,e))}function Q(e,t,n,r){return e+(t-e)*(1-Math.exp(-n*r))}function be(e,t){let n=/^#?([0-9a-f]{6})$/i.exec(e.trim());if(!n)return t;let r=parseInt(n[1],16);return[(r>>16&255)/255,(r>>8&255)/255,(r&255)/255]}function xe(e,t,n){return[e[0]+(t[0]-e[0])*n,e[1]+(t[1]-e[1])*n,e[2]+(t[2]-e[2])*n]}function $([e,t,n],r){return`rgba(${Math.round(e*255)}, ${Math.round(t*255)}, ${Math.round(n*255)}, ${r})`}function Se(e,t){let n=ge[e],r=e=>{let r=be(n[e],[0,0,0]),i=t?.[e];return i?be(i,r):r};return{deep:r(`deep`),shallow:r(`shallow`),foam:r(`foam`),glow:r(`glow`),sky:r(`sky`),horizon:r(`horizon`)}}function Ce(e,t,n){let r=e.createShader(t);if(r){if(e.shaderSource(r,n),e.compileShader(r),!e.getShaderParameter(r,e.COMPILE_STATUS)){e.deleteShader(r);return}return r}}function we(e,t,n){let r=e.getContext(`webgl`,{alpha:!0,antialias:!0,premultipliedAlpha:!0});if(!r)return;let i=Ce(r,r.VERTEX_SHADER,_e),a=Ce(r,r.FRAGMENT_SHADER,ve);if(!i||!a){i&&r.deleteShader(i),a&&r.deleteShader(a);return}let o=r.createProgram(),s=r.createBuffer();if(!o||!s){o&&r.deleteProgram(o),s&&r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a);return}if(r.attachShader(o,i),r.attachShader(o,a),r.linkProgram(o),!r.getProgramParameter(o,r.LINK_STATUS)){r.deleteProgram(o),r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a);return}let c=()=>{r.deleteProgram(o),r.deleteBuffer(s),r.deleteShader(i),r.deleteShader(a)},l=r.getAttribLocation(o,`a_position`),u=e=>r.getUniformLocation(o,e),d={resolution:u(`u_resolution`),time:u(`u_time`),level:u(`u_level`),swell:u(`u_swell`),ripple:u(`u_ripple`),glow:u(`u_glow`),tilt:u(`u_tilt`),listen:u(`u_listen`),speak:u(`u_speak`),surge:u(`u_surge`),deep:u(`u_deep`),shallow:u(`u_shallow`),foam:u(`u_foam`),light:u(`u_light`),sky:u(`u_sky`),horizon:u(`u_horizon`)};if(l<0||Object.values(d).some(e=>!e)){c();return}let f=Math.min(window.devicePixelRatio||1,2),p=Math.max(1,Math.round(t*f));return e.width=p,e.height=p,r.viewport(0,0,p,p),r.useProgram(o),r.bindBuffer(r.ARRAY_BUFFER,s),r.bufferData(r.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),r.STATIC_DRAW),r.enableVertexAttribArray(l),r.vertexAttribPointer(l,2,r.FLOAT,!1,0,0),r.uniform2f(d.resolution,p,p),r.uniform3fv(d.deep,n.deep),r.uniform3fv(d.shallow,n.shallow),r.uniform3fv(d.foam,n.foam),r.uniform3fv(d.light,n.glow),r.uniform3fv(d.sky,n.sky),r.uniform3fv(d.horizon,n.horizon),{draw(e){r.uniform1f(d.time,e.time),r.uniform1f(d.level,e.level),r.uniform1f(d.swell,e.swell),r.uniform1f(d.ripple,e.ripple),r.uniform1f(d.glow,e.glow),r.uniform1f(d.tilt,e.tilt),r.uniform1f(d.listen,e.listen),r.uniform1f(d.speak,e.speak),r.uniform1f(d.surge,e.surge),r.drawArrays(r.TRIANGLES,0,6)},destroy:c}}function Te(e,t,n,r){switch(e){case`connecting`:return{swell:.03,speed:.32,glow:.3+.2*Math.sin(r*2.6),tiltAmplitude:.02,levelOffset:0,corona:.3+.1*Math.sin(r*2.6),reach:.24,ringEvery:0,ringStrength:0,ringInward:!1,orbit:0,sweep:1,pulse:.5};case`listening`:return{swell:.045+t*.03,speed:.45+t*.25,glow:.42+t*.5,tiltAmplitude:.03,levelOffset:t*.05,corona:.36+t*.3,reach:.24+t*.1,ringEvery:1.6-t*.5,ringStrength:.3+t*.35,ringInward:!0,orbit:0,sweep:0,pulse:.3};case`thinking`:return{swell:.05,speed:.7,glow:.5+.1*Math.sin(r*1.6),tiltAmplitude:.045,levelOffset:.01,corona:.38+.08*Math.sin(r*1.6),reach:.28,ringEvery:0,ringStrength:0,ringInward:!0,orbit:1,sweep:0,pulse:1};case`speaking`:return{swell:.055+n*.045,speed:.5+n*.25,glow:.55+n*.3,tiltAmplitude:.035,levelOffset:.02+n*.05,corona:.45+n*.3,reach:.24+n*.1,ringEvery:0,ringStrength:.3,ringInward:!1,orbit:0,sweep:0,pulse:.2};case`error`:return{swell:.02,speed:.2,glow:.06,tiltAmplitude:.01,levelOffset:-.04,corona:.08,reach:.15,ringEvery:0,ringStrength:0,ringInward:!1,orbit:0,sweep:0,pulse:0};default:return{swell:.036,speed:.36,glow:.28,tiltAmplitude:.028,levelOffset:0,corona:.3,reach:.22,ringEvery:6,ringStrength:.25,ringInward:!1,orbit:0,sweep:0,pulse:.35}}}var Ee=.1,De=7.5,Oe=3.2,ke=14,Ae=1.7,je=.3,Me=2.2,Ne=3,Pe=.18,Fe=.3,Ie=.1,Le=.35,Re=.4,ze=[.7,.85,1,1,1.2,1.45],Be=1.4,Ve=2.2,He=11,Ue=8,We=3.5,Ge=.07;function Ke(){return{open:0,target:0,remaining:0,tempo:1,tempoRemaining:0,gestureBegan:!1}}function qe(e){return e[Math.floor(Math.random()*e.length)]}function Je(e,t,n){if(e.gestureBegan=!1,!t)return e.target=0,e.remaining=0,e.tempoRemaining=0,e.open=Q(e.open,0,We,n),!1;if(e.tempoRemaining-=n,e.tempoRemaining<=0&&(e.tempo=qe(ze),e.tempoRemaining=Be+Math.random()*Ve),e.remaining-=n,e.remaining<=0){if(Math.random()<Ie)e.target=.04,e.remaining=Le+Math.random()*Re;else{let t=.22+Math.random()**.7*.78;e.target=Math.abs(t-e.target)<.18?Z(t+(t>.6?-.3:.3)):t,e.remaining=(Pe+Math.random()*Fe)*e.tempo,e.gestureBegan=e.target>.7}}let r=e.target>e.open?He:Ue;return e.open=Q(e.open,e.target,r/e.tempo,n),e.gestureBegan}function Ye(){return Array.from({length:Ne},(e,t)=>({angle:t/Ne*Math.PI*2,speed:(.55+t%3*.2)*(t%2==0?1:-1),radius:1.12+t%2*.08,size:.016+t%2*.006,wobble:.7+t*.37}))}function Xe(e,t,n,r){let i=e.getContext(`2d`);if(!i)return;let a=Math.min(window.devicePixelRatio||1,2),o=t*Ae;e.width=Math.max(1,Math.round(o*a)),e.height=e.width,i.scale(a,a);let s=o/2,c=t/2,l=r===`dark`?xe(n.shallow,n.glow,.35):n.shallow,u=r===`dark`?xe(n.glow,n.foam,.4):n.deep,d=r===`dark`?n.shallow:n.deep,f=r===`dark`?1:.75,p=(e,t,n)=>{i.beginPath(),i.arc(e,t,n,0,Math.PI*2)};return{draw(e){i.clearRect(0,0,o,o),i.globalCompositeOperation=r===`dark`?`lighter`:`source-over`;let t=c*(1+e.reach+e.pulse*.03+Math.sin(e.breath)*.015),n=Z(e.corona*(r===`dark`?.55:.5)),a=i.createRadialGradient(s,s,c*.9,s,s,t);a.addColorStop(0,$(l,n)),a.addColorStop(.3,$(l,n*.5)),a.addColorStop(.65,$(l,n*.15)),a.addColorStop(1,$(l,0)),i.fillStyle=a,p(s,s,t),i.fill();let m=Z(e.speak+e.listen*.6);if(m>.01){let e=c*(1.02+m*.5),t=i.createRadialGradient(s,s,c*.95,s,s,e);t.addColorStop(0,$(l,.35*m*f)),t.addColorStop(.4,$(u,.1*m*f)),t.addColorStop(1,$(u,0)),i.fillStyle=t,p(s,s,e),i.fill()}let h=Z((.3+e.glow*.35+e.speak*.2+e.listen*.25)*f),g=c*(1.06+e.speak*.04),_=i.createRadialGradient(s,s,c*.97,s,s,g);_.addColorStop(0,$(u,h)),_.addColorStop(1,$(u,0)),i.fillStyle=_,p(s,s,c*1.15),i.fill();for(let t of e.rings){let n=Z((e.time-t.born)/Me),r=1-(1-n)**2.2,a=t.inward?1-r:r,o=c*(1+je*a),d=Z((t.inward?(1-a)**.6*(1-n**4):(1-n)**1.3)*t.strength);if(d<.005)continue;let m=c*(.01+t.strength*.014)*(1-a*.3);i.lineWidth=m*4,i.strokeStyle=$(l,d*.16),p(s,s,o),i.stroke(),i.lineWidth=m,i.strokeStyle=$(u,d*.4*f),p(s,s,o),i.stroke()}if(e.orbit>.01)for(let t of e.orbiters){let n=Math.sin(e.time*t.wobble)*.05,r=c*(t.radius+n),a=.8+e.orbit*.7,o=t.speed>0?1:-1;for(let n=0;n<14;n+=1){let d=n/14*a,m=t.angle-o*d,h=s+Math.cos(m)*r,g=s+Math.sin(m)*r,_=(1-n/14)**2*e.orbit;i.fillStyle=$(n===0?u:l,Z(_*(n===0?1:.7)*f)),p(h,g,c*t.size*(1-n/14*.7)),i.fill()}let d=c*t.size*5,m=s+Math.cos(t.angle)*r,h=s+Math.sin(t.angle)*r,g=i.createRadialGradient(m,h,0,m,h,d);g.addColorStop(0,$(l,.35*e.orbit)),g.addColorStop(1,$(l,0)),i.fillStyle=g,p(m,h,d),i.fill()}if(e.sweep>.01){let t=[{orbitRadius:c*1.12,start:e.time*2,span:Math.PI*.55,width:.025}];for(let{orbitRadius:n,start:r,span:a,width:o}of t){let t=i.createConicGradient(r,s,s);t.addColorStop(0,$(u,0)),t.addColorStop(a/(Math.PI*2),$(u,.7*e.sweep*f)),t.addColorStop(a/(Math.PI*2)+.001,$(u,0)),t.addColorStop(1,$(u,0)),i.lineWidth=c*o,i.strokeStyle=t,i.beginPath(),i.arc(s,s,n,r,r+a),i.stroke(),i.lineWidth=c*.01,i.strokeStyle=$(d,.2*e.sweep*f),p(s,s,n),i.stroke()}}}}}function Ze({state:n,volume:r,size:i,scheme:a=`light`,palette:o,className:s,style:c,disabled:l=!1,interactive:u=!1,onClick:d,...f}){let p=(0,e.useRef)(null),m=(0,e.useRef)(null),h=(0,e.useRef)(null),g=(0,e.useRef)(n),_=(0,e.useRef)(r),v=(0,e.useRef)(!1);he(()=>{g.current=n,_.current=r},[n,r]);let y=i*ye,b=Se(a,o),x=JSON.stringify(b);(0,e.useEffect)(()=>{let e=p.current,t=m.current,n=h.current;if(!e||!t||!n)return;let r=JSON.parse(x),i=window.matchMedia(`(prefers-reduced-motion: reduce)`),o=()=>{v.current=i.matches};o(),i.addEventListener(`change`,o);let s=we(e,y,r);s||(e.style.background=`linear-gradient(180deg, ${$(r.sky,1)} 0%, ${$(r.horizon,1)} 44%, ${$(r.shallow,1)} 48%, ${$(r.deep,1)} 100%)`);let c=Xe(t,y,r,a),l=0,u=performance.now(),d=0,f=0,b=0,S=0,C=Z(_.current),w=0,T=0,E=.036,D=.36,O=.26,k=.028,A=0,j=.3,M=.24,N=0,P=0,F=.3,I=0,L=0,R=0,z=Ke(),B=0,V=[],H=Ye(),U=e=>{let t=Math.min((e-u)/1e3,.05);u=e;let r=g.current,i=v.current,a=Z(_.current);C=i?0:Q(C,a,a>C?4:1.5,t);let o=r===`speaking`&&!i,p=Je(z,o,t),m=z.open,h=r===`listening`?C:0,y=o?.45+m*.35:0;w=Q(w,h,h>w?4:1.5,t),T=Q(T,y,y>T?3:1.5,t),f+=t;let x=Te(r,w,T,f);E=Q(E,x.swell,2.4,t),D=Q(D,x.speed,2.4,t),O=Q(O,x.glow,3.2,t),k=Q(k,x.tiltAmplitude,1.8,t),A=Q(A,x.levelOffset,3,t),j=Q(j,x.corona,x.corona>j?6:2.5,t),M=Q(M,x.reach,x.reach>M?7:2.5,t),N=Q(N,x.orbit,3,t),P=Q(P,x.sweep,3,t),F=Q(F,x.pulse,2.5,t);let W=o?.25+m*.5:0;if(R+=(W-L)*ke*t,R*=Math.exp(-8*t),L+=R*t,!i){d+=t*D,b+=t*Math.PI*2/De,S+=t*.31,I+=t*Math.PI*2/Oe;for(let e of H)e.angle+=t*e.speed*(.6+N*.9);for(B+=t,o?p&&B>=1&&(B=0,V.push({born:f,strength:x.ringStrength,inward:!1})):x.ringEvery>0&&(r!==`listening`||w>.03)&&B>=x.ringEvery&&(B=0,V.push({born:f,strength:x.ringStrength,inward:x.ringInward}));V.length>0&&f-V[0].born>Me;)V.shift()}let G=Ee+A+Math.sin(b)*.022,K=Math.sin(S)*k+Math.sin(S*2.3+.7)*.006,ee=i?0:Z(L);s?.draw({time:d,level:G,swell:i?.012:E,ripple:i?0:w,glow:O,tilt:i?0:K,listen:w,speak:T,surge:ee});let q=(.5+.5*Math.sin(I))*F,J=m*Ge,Y=1+q*.012+Math.sin(b)*.005+J+w*.015;n.style.transform=i?`none`:`scale(${Y})`,c?.draw({time:f,corona:i?j*.6:j+m*.2,reach:M,glow:O,speak:Math.max(T,m*.8),listen:w,orbit:i?0:N,sweep:i?0:P,pulse:q,breath:b,rings:i?[]:V,orbiters:H}),l=requestAnimationFrame(U)};return l=requestAnimationFrame(U),()=>{cancelAnimationFrame(l),i.removeEventListener(`change`,o),s?.destroy()}},[y,x,a]);let S={width:i,height:i,display:`flex`,alignItems:`center`,justifyContent:`center`,position:`relative`,...c},C=y*Ae,w=(0,t.jsxs)(`span`,{ref:h,style:{position:`relative`,display:`block`,width:y,height:y,borderRadius:`50%`,lineHeight:0,cursor:u?l?`not-allowed`:`pointer`:`default`,transformOrigin:`center`,willChange:`transform`},children:[(0,t.jsx)(`canvas`,{ref:m,"aria-hidden":`true`,"data-ocean-aura":``,style:{position:`absolute`,left:(y-C)/2,top:(y-C)/2,display:`block`,width:C,height:C,pointerEvents:`none`}}),(0,t.jsx)(`canvas`,{ref:p,"aria-hidden":`true`,"data-ocean-surface":``,style:{position:`absolute`,inset:0,display:`block`,width:y,height:y,borderRadius:`50%`,boxShadow:`0 ${y*.06}px ${y*.22}px ${$(b.deep,a===`dark`?.55:.28)}`}})]});return u?(0,t.jsx)(`button`,{...f,type:`button`,className:s,disabled:l,onClick:l?void 0:d,style:{appearance:`none`,WebkitAppearance:`none`,border:0,padding:0,margin:0,background:`transparent`,color:`inherit`,font:`inherit`,cursor:l?`not-allowed`:`pointer`,...S},children:w}):(0,t.jsx)(`div`,{...f,className:s,style:S,children:w})}function Qe({signal:i,state:a,volume:s,adapter:c,theme:l=`debug`,size:u=200,scheme:d,palette:f,className:p,style:m,disabled:h=!1,interactive:g=!0,onStart:_,onStop:v,renderTheme:y,...x}){let[S,C]=(0,e.useState)({state:`idle`});(0,e.useEffect)(()=>{if(C({state:`idle`}),c)return c.subscribe(C)},[c]);let w=i??S,T=n(a,i,S),D=r(s,T,w),O=w.inputVolume??0,k=w.outputVolume??0,A=(0,e.useMemo)(()=>({...w,state:T,inputVolume:O,outputVolume:k}),[w,O,k,T]),j=T!==`idle`&&T!==`error`,M=(0,e.useCallback)(()=>{if(!h)return _?_():c?.start?.()},[c,h,_]),N=(0,e.useCallback)(()=>{if(!h)return v?v():c?.stop?.()},[c,h,v]),P=(0,e.useCallback)(()=>j?N():M(),[j,M,N]),F=j?!!(c?.stop||v):!!(c?.start||_),I=g&&F,L=I&&!h?P:void 0,R=x[`aria-label`]??(I?`${j?`Stop`:`Start`} voice session`:void 0),z={...x,"aria-label":R};if(y){let e={...x,type:`button`,disabled:h||!I,onClick:L,"data-orb-ui-state":T,"aria-label":R};return y({state:T,signal:A,inputVolume:O,outputVolume:k,activity:D,size:u,isActive:j,interactive:I,disabled:h,start:M,stop:N,toggle:P,rootProps:{className:p,style:{width:u,height:u,...m},"data-orb-ui-theme":`custom`,"data-orb-ui-state":T},controlProps:e})}let B={state:T,volume:D,size:u,className:p,style:m,disabled:h,...z},V={...B,interactive:I};switch(l){case`circle`:return(0,t.jsx)(b,{...V,onClick:L});case`bars`:return(0,t.jsx)(E,{...V,onClick:L});case`cloud`:return(0,t.jsx)(ne,{...V,onClick:L});case`radial`:return(0,t.jsx)(me,{...V,onClick:L});case`ocean`:return(0,t.jsx)(Ze,{...V,scheme:d,palette:f,onClick:L});default:return(0,t.jsx)(o,{...B,disabled:h||!g,onStart:h||!g?void 0:M,onStop:h||!g?void 0:N})}}exports.Orb=Qe,exports.VoiceOrb=Qe;
package/dist/orb-ui.js CHANGED
@@ -472,7 +472,7 @@ function M({ state: e, volume: n, size: r, className: a, style: s, disabled: c =
472
472
  }
473
473
  //#endregion
474
474
  //#region src/themes/cloud/CloudTheme.tsx
475
- var N = typeof window < "u" ? n : t, P = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", F = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_activity;\n\nfloat hash(vec2 p) {\n p = fract(p * vec2(123.34, 456.21));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.52;\n mat2 rotation = mat2(0.80, 0.60, -0.60, 0.80);\n\n for (int octave = 0; octave < 5; octave++) {\n value += amplitude * noise(p);\n p = rotation * p * 1.92 + vec2(9.7, 4.3);\n amplitude *= 0.5;\n }\n\n return value;\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 centered = uv - 0.5;\n float radius = length(centered);\n float edge = 1.0 - smoothstep(0.488, 0.5, radius);\n\n if (edge <= 0.0) discard;\n\n vec2 p = centered * 2.0;\n float t = u_time;\n\n vec2 warp = vec2(\n fbm(p * 1.02 + vec2(t * 0.34, -t * 0.24)),\n fbm(p * 1.08 + vec2(-t * 0.27, t * 0.32) + vec2(6.7, 2.9))\n );\n vec2 curl = vec2(\n sin(p.y * 2.4 + t * 0.68 + warp.y * 3.2),\n cos(p.x * 2.1 - t * 0.61 + warp.x * 3.0)\n );\n vec2 warped =\n p +\n (warp - 0.5) * (1.18 + u_activity * 0.38) +\n curl * (0.035 + u_activity * 0.07);\n float broad = fbm(warped * 0.92 + vec2(t * 0.14, -t * 0.18));\n float folded = fbm(warped * 1.66 + vec2(-t * 0.23, t * 0.19) + 5.2);\n float field = mix(broad, folded, 0.3 + u_activity * 0.14);\n\n float horizon =\n 0.46 +\n 0.08 * sin((uv.x + warp.x * 0.2) * 5.4 + t * 0.42) +\n 0.16 * (broad - 0.5);\n float upper = smoothstep(horizon - 0.12, horizon + 0.08, uv.y);\n float band = exp(-pow((uv.y - horizon) * (5.2 + u_activity * 0.8), 2.0));\n float cloud = smoothstep(0.24, 0.79, field);\n\n vec3 deepPeriwinkle = vec3(0.36, 0.39, 0.985);\n vec3 upperPeriwinkle = vec3(0.48, 0.56, 0.985);\n vec3 lowerLavender = vec3(0.72, 0.78, 0.975);\n vec3 milk = vec3(0.89, 0.92, 0.995);\n\n vec3 color = mix(lowerLavender, upperPeriwinkle, upper);\n float upperDepth = upper * (0.14 + smoothstep(0.42, 0.78, folded) * 0.5);\n color = mix(color, deepPeriwinkle, upperDepth);\n\n float milkAmount = clamp(band * (0.42 + cloud * 0.62), 0.0, 0.88);\n color = mix(color, milk, milkAmount);\n\n float lowerMist = (1.0 - upper) * smoothstep(0.58, 0.9, broad) * 0.18;\n color = mix(color, milk, lowerMist);\n\n float grain = (noise(gl_FragCoord.xy * 0.64) - 0.5) / 255.0;\n color += grain;\n\n gl_FragColor = vec4(color, edge);\n}\n", I = .55, L = .204, R = .2145, z = .063, B = "#5659dc", V = 1.178, H = 180, U = 300, W = 1350, G = 246, K = 420, ee = 354, te = 480;
475
+ var N = typeof window < "u" ? n : t, P = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", F = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_activity;\n\nfloat hash(vec2 p) {\n p = fract(p * vec2(123.34, 456.21));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.52;\n mat2 rotation = mat2(0.80, 0.60, -0.60, 0.80);\n\n for (int octave = 0; octave < 5; octave++) {\n value += amplitude * noise(p);\n p = rotation * p * 1.92 + vec2(9.7, 4.3);\n amplitude *= 0.5;\n }\n\n return value;\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 centered = uv - 0.5;\n float radius = length(centered);\n float edge = 1.0 - smoothstep(0.488, 0.5, radius);\n\n if (edge <= 0.0) discard;\n\n vec2 p = centered * 2.0;\n float t = u_time;\n\n vec2 warp = vec2(\n fbm(p * 1.02 + vec2(t * 0.34, -t * 0.24)),\n fbm(p * 1.08 + vec2(-t * 0.27, t * 0.32) + vec2(6.7, 2.9))\n );\n vec2 curl = vec2(\n sin(p.y * 2.4 + t * 0.68 + warp.y * 3.2),\n cos(p.x * 2.1 - t * 0.61 + warp.x * 3.0)\n );\n vec2 warped =\n p +\n (warp - 0.5) * (1.18 + u_activity * 0.38) +\n curl * (0.035 + u_activity * 0.07);\n float broad = fbm(warped * 0.92 + vec2(t * 0.14, -t * 0.18));\n float folded = fbm(warped * 1.66 + vec2(-t * 0.23, t * 0.19) + 5.2);\n float field = mix(broad, folded, 0.3 + u_activity * 0.14);\n\n float horizon =\n 0.46 +\n 0.08 * sin((uv.x + warp.x * 0.2) * 5.4 + t * 0.42) +\n 0.16 * (broad - 0.5);\n float upper = smoothstep(horizon - 0.12, horizon + 0.08, uv.y);\n float band = exp(-pow((uv.y - horizon) * (5.2 + u_activity * 0.8), 2.0));\n float cloud = smoothstep(0.24, 0.79, field);\n\n vec3 deepPeriwinkle = vec3(0.36, 0.39, 0.985);\n vec3 upperPeriwinkle = vec3(0.48, 0.56, 0.985);\n vec3 lowerLavender = vec3(0.72, 0.78, 0.975);\n vec3 milk = vec3(0.89, 0.92, 0.995);\n\n vec3 color = mix(lowerLavender, upperPeriwinkle, upper);\n float upperDepth = upper * (0.14 + smoothstep(0.42, 0.78, folded) * 0.5);\n color = mix(color, deepPeriwinkle, upperDepth);\n\n float milkAmount = clamp(band * (0.42 + cloud * 0.62), 0.0, 0.88);\n color = mix(color, milk, milkAmount);\n\n float lowerMist = (1.0 - upper) * smoothstep(0.58, 0.9, broad) * 0.18;\n color = mix(color, milk, lowerMist);\n\n float grain = (noise(gl_FragCoord.xy * 0.64) - 0.5) / 255.0;\n color += grain;\n\n gl_FragColor = vec4(color, edge);\n}\n", I = .55, L = .204, R = .2145, z = .063, B = "#5659dc", V = 1.178, H = 180, U = 300, W = 1350, G = 246, ee = 420, te = 354, K = 480;
476
476
  function q(e, t = 0, n = 1) {
477
477
  return Math.min(n, Math.max(t, e));
478
478
  }
@@ -596,7 +596,7 @@ function ce({ state: e, volume: n, size: r, className: a, style: c, disabled: l
596
596
  let j = +!D, M = D ? f : 0;
597
597
  if (E && l !== void 0 && !m) {
598
598
  let e = r - l, t = se(e), n = q((e - H - U) / W);
599
- A = t * re(1, d, n), j = ie(e, G, K), M = f * (1 - ie(e, ee, te)), e >= 1830 && (l = void 0);
599
+ A = t * re(1, d, n), j = ie(e, G, ee), M = f * (1 - ie(e, te, K)), e >= 1830 && (l = void 0);
600
600
  }
601
601
  let N = +(p === "connecting");
602
602
  S = m ? N : J(S, N, 18, i), e.style.opacity = String(f * j), e.style.transform = `scale(${A})`, t.style.opacity = String(M), t.style.transform = `scale(${A})`, n.style.opacity = String(S), n.style.transform = `rotate(${m ? 45 : r * .34}deg)`;
@@ -1161,8 +1161,40 @@ function je(e, t, n, r) {
1161
1161
  };
1162
1162
  }
1163
1163
  }
1164
- var Me = .1, Ne = 7.5, Pe = 3.2, Fe = 14, Ie = 1.7, Le = .3, Re = 2.2, ze = 3, Be = 9, Ve = 3.2, He = 14, Ue = .45, We = .25, Ge = .085;
1165
- function Ke() {
1164
+ var Me = .1, Ne = 7.5, Pe = 3.2, Fe = 14, Ie = 1.7, Le = .3, Re = 2.2, ze = 3, Be = .18, Ve = .3, He = .1, Ue = .35, We = .4, Ge = [
1165
+ .7,
1166
+ .85,
1167
+ 1,
1168
+ 1,
1169
+ 1.2,
1170
+ 1.45
1171
+ ], Ke = 1.4, qe = 2.2, Je = 11, Ye = 8, Xe = 3.5, Ze = .07;
1172
+ function Qe() {
1173
+ return {
1174
+ open: 0,
1175
+ target: 0,
1176
+ remaining: 0,
1177
+ tempo: 1,
1178
+ tempoRemaining: 0,
1179
+ gestureBegan: !1
1180
+ };
1181
+ }
1182
+ function $e(e) {
1183
+ return e[Math.floor(Math.random() * e.length)];
1184
+ }
1185
+ function et(e, t, n) {
1186
+ if (e.gestureBegan = !1, !t) return e.target = 0, e.remaining = 0, e.tempoRemaining = 0, e.open = Q(e.open, 0, Xe, n), !1;
1187
+ if (e.tempoRemaining -= n, e.tempoRemaining <= 0 && (e.tempo = $e(Ge), e.tempoRemaining = Ke + Math.random() * qe), e.remaining -= n, e.remaining <= 0) {
1188
+ if (Math.random() < He) e.target = .04, e.remaining = Ue + Math.random() * We;
1189
+ else {
1190
+ let t = .22 + Math.random() ** .7 * .78;
1191
+ e.target = Math.abs(t - e.target) < .18 ? Z(t + (t > .6 ? -.3 : .3)) : t, e.remaining = (Be + Math.random() * Ve) * e.tempo, e.gestureBegan = e.target > .7;
1192
+ }
1193
+ }
1194
+ let r = e.target > e.open ? Je : Ye;
1195
+ return e.open = Q(e.open, e.target, r / e.tempo, n), e.gestureBegan;
1196
+ }
1197
+ function tt() {
1166
1198
  return Array.from({ length: ze }, (e, t) => ({
1167
1199
  angle: t / ze * Math.PI * 2,
1168
1200
  speed: (.55 + t % 3 * .2) * (t % 2 == 0 ? 1 : -1),
@@ -1171,7 +1203,7 @@ function Ke() {
1171
1203
  wobble: .7 + t * .37
1172
1204
  }));
1173
1205
  }
1174
- function qe(e, t, n, r) {
1206
+ function nt(e, t, n, r) {
1175
1207
  let i = e.getContext("2d");
1176
1208
  if (!i) return;
1177
1209
  let a = Math.min(window.devicePixelRatio || 1, 2), o = t * Ie;
@@ -1219,7 +1251,7 @@ function qe(e, t, n, r) {
1219
1251
  }
1220
1252
  } };
1221
1253
  }
1222
- function Je({ state: e, volume: n, size: r, scheme: a = "light", palette: c, className: l, style: u, disabled: d = !1, interactive: f = !1, onClick: p, ...m }) {
1254
+ function rt({ state: e, volume: n, size: r, scheme: a = "light", palette: c, className: l, style: u, disabled: d = !1, interactive: f = !1, onClick: p, ...m }) {
1223
1255
  let h = i(null), g = i(null), _ = i(null), v = i(e), y = i(n), b = i(!1);
1224
1256
  xe(() => {
1225
1257
  v.current = e, y.current = n;
@@ -1234,37 +1266,33 @@ function Je({ state: e, volume: n, size: r, scheme: a = "light", palette: c, cla
1234
1266
  o(), i.addEventListener("change", o);
1235
1267
  let s = Ae(e, x, r);
1236
1268
  s || (e.style.background = `linear-gradient(180deg, ${$(r.sky, 1)} 0%, ${$(r.horizon, 1)} 44%, ${$(r.shallow, 1)} 48%, ${$(r.deep, 1)} 100%)`);
1237
- let c = qe(t, x, r, a), l = 0, u = performance.now(), d = 0, f = 0, p = 0, m = 0, S = Z(y.current), w = 0, T = 0, E = .036, D = .36, O = .26, k = .028, A = 0, j = .3, M = .24, N = 0, P = 0, F = .3, I = 0, L = 0, R = 0, z = We, B = 0, V = 0, H = !1, U = 0, W = [], G = Ke(), K = (e) => {
1269
+ let c = nt(t, x, r, a), l = 0, u = performance.now(), d = 0, f = 0, p = 0, m = 0, S = Z(y.current), w = 0, T = 0, E = .036, D = .36, O = .26, k = .028, A = 0, j = .3, M = .24, N = 0, P = 0, F = .3, I = 0, L = 0, R = 0, z = Qe(), B = 0, V = [], H = tt(), U = (e) => {
1238
1270
  let t = Math.min((e - u) / 1e3, .05);
1239
1271
  u = e;
1240
1272
  let r = v.current, i = b.current, a = Z(y.current);
1241
1273
  S = i ? 0 : Q(S, a, a > S ? 4 : 1.5, t);
1242
- let o = r === "listening" ? S : 0, h = r === "speaking" ? S : 0;
1243
- w = Q(w, o, o > w ? 4 : 1.5, t), T = Q(T, h, h > T ? 4 : 1.5, t), f += t;
1244
- let g = je(r, w, T, f);
1245
- E = Q(E, g.swell, 2.4, t), D = Q(D, g.speed, 2.4, t), O = Q(O, g.glow, 3.2, t), k = Q(k, g.tiltAmplitude, 1.8, t), A = Q(A, g.levelOffset, 3, t), j = Q(j, g.corona, g.corona > j ? 6 : 2.5, t), M = Q(M, g.reach, g.reach > M ? 7 : 2.5, t), N = Q(N, g.orbit, 3, t), P = Q(P, g.sweep, 3, t), F = Q(F, g.pulse, 2.5, t), R += ((r === "speaking" ? S : 0) - L) * Fe * t, R *= Math.exp(-8 * t), L += R * t;
1246
- let _ = r === "speaking" && !i;
1247
- z = Math.max(_ ? a : 0, We, z - (z - We) * Ue * t);
1248
- let x = _ ? Z(a / z) : 0;
1249
- if (B = Q(B, x, x > B ? Be : Ve, t), V = Q(V, B, He, t), !i) {
1274
+ let o = r === "speaking" && !i, h = et(z, o, t), g = z.open, _ = r === "listening" ? S : 0, x = o ? .45 + g * .35 : 0;
1275
+ w = Q(w, _, _ > w ? 4 : 1.5, t), T = Q(T, x, x > T ? 3 : 1.5, t), f += t;
1276
+ let C = je(r, w, T, f);
1277
+ E = Q(E, C.swell, 2.4, t), D = Q(D, C.speed, 2.4, t), O = Q(O, C.glow, 3.2, t), k = Q(k, C.tiltAmplitude, 1.8, t), A = Q(A, C.levelOffset, 3, t), j = Q(j, C.corona, C.corona > j ? 6 : 2.5, t), M = Q(M, C.reach, C.reach > M ? 7 : 2.5, t), N = Q(N, C.orbit, 3, t), P = Q(P, C.sweep, 3, t), F = Q(F, C.pulse, 2.5, t);
1278
+ let W = o ? .25 + g * .5 : 0;
1279
+ if (R += (W - L) * Fe * t, R *= Math.exp(-8 * t), L += R * t, !i) {
1250
1280
  d += t * D, p += t * Math.PI * 2 / Ne, m += t * .31, I += t * Math.PI * 2 / Pe;
1251
- for (let e of G) e.angle += t * e.speed * (.6 + N * .9);
1252
- U += t;
1253
- let e = V > .55;
1254
- for (_ ? e && !H && U >= 1 && (U = 0, W.push({
1281
+ for (let e of H) e.angle += t * e.speed * (.6 + N * .9);
1282
+ for (B += t, o ? h && B >= 1 && (B = 0, V.push({
1255
1283
  born: f,
1256
- strength: g.ringStrength,
1284
+ strength: C.ringStrength,
1257
1285
  inward: !1
1258
- })) : g.ringEvery > 0 && (r !== "listening" || w > .03) && U >= g.ringEvery && (U = 0, W.push({
1286
+ })) : C.ringEvery > 0 && (r !== "listening" || w > .03) && B >= C.ringEvery && (B = 0, V.push({
1259
1287
  born: f,
1260
- strength: g.ringStrength,
1261
- inward: g.ringInward
1262
- })), H = e; W.length > 0 && f - W[0].born > Re;) W.shift();
1288
+ strength: C.ringStrength,
1289
+ inward: C.ringInward
1290
+ })); V.length > 0 && f - V[0].born > Re;) V.shift();
1263
1291
  }
1264
- let C = Me + A + Math.sin(p) * .022, ee = Math.sin(m) * k + Math.sin(m * 2.3 + .7) * .006, te = i ? 0 : Z(L);
1292
+ let G = Me + A + Math.sin(p) * .022, ee = Math.sin(m) * k + Math.sin(m * 2.3 + .7) * .006, te = i ? 0 : Z(L);
1265
1293
  s?.draw({
1266
1294
  time: d,
1267
- level: C,
1295
+ level: G,
1268
1296
  swell: i ? .012 : E,
1269
1297
  ripple: i ? 0 : w,
1270
1298
  glow: O,
@@ -1273,23 +1301,23 @@ function Je({ state: e, volume: n, size: r, scheme: a = "light", palette: c, cla
1273
1301
  speak: T,
1274
1302
  surge: te
1275
1303
  });
1276
- let q = (.5 + .5 * Math.sin(I)) * F, J = V ** .85 * Ge, ne = 1 + q * .012 + Math.sin(p) * .005 + J + w * .015;
1277
- n.style.transform = i ? "none" : `scale(${ne})`, c?.draw({
1304
+ let K = (.5 + .5 * Math.sin(I)) * F, q = g * Ze, J = 1 + K * .012 + Math.sin(p) * .005 + q + w * .015;
1305
+ n.style.transform = i ? "none" : `scale(${J})`, c?.draw({
1278
1306
  time: f,
1279
- corona: i ? j * .6 : j + V * .2,
1307
+ corona: i ? j * .6 : j + g * .2,
1280
1308
  reach: M,
1281
1309
  glow: O,
1282
- speak: Math.max(T, V * .8),
1310
+ speak: Math.max(T, g * .8),
1283
1311
  listen: w,
1284
1312
  orbit: i ? 0 : N,
1285
1313
  sweep: i ? 0 : P,
1286
- pulse: q,
1314
+ pulse: K,
1287
1315
  breath: p,
1288
- rings: i ? [] : W,
1289
- orbiters: G
1290
- }), l = requestAnimationFrame(K);
1316
+ rings: i ? [] : V,
1317
+ orbiters: H
1318
+ }), l = requestAnimationFrame(U);
1291
1319
  };
1292
- return l = requestAnimationFrame(K), () => {
1320
+ return l = requestAnimationFrame(U), () => {
1293
1321
  cancelAnimationFrame(l), i.removeEventListener("change", o), s?.destroy();
1294
1322
  };
1295
1323
  }, [
@@ -1374,7 +1402,7 @@ function Je({ state: e, volume: n, size: r, scheme: a = "light", palette: c, cla
1374
1402
  }
1375
1403
  //#endregion
1376
1404
  //#region src/components/Orb/Orb.tsx
1377
- function Ye({ signal: n, state: i, volume: s, adapter: u, theme: d = "debug", size: p = 200, scheme: m, palette: h, className: g, style: _, disabled: v = !1, interactive: y = !0, onStart: b, onStop: x, renderTheme: S, ...C }) {
1405
+ function it({ signal: n, state: i, volume: s, adapter: u, theme: d = "debug", size: p = 200, scheme: m, palette: h, className: g, style: _, disabled: v = !1, interactive: y = !0, onStart: b, onStop: x, renderTheme: S, ...C }) {
1378
1406
  let [w, T] = a({ state: "idle" });
1379
1407
  t(() => {
1380
1408
  if (T({ state: "idle" }), u) return u.subscribe(T);
@@ -1473,7 +1501,7 @@ function Ye({ signal: n, state: i, volume: s, adapter: u, theme: d = "debug", si
1473
1501
  ...W,
1474
1502
  onClick: B
1475
1503
  });
1476
- case "ocean": return /* @__PURE__ */ o(Je, {
1504
+ case "ocean": return /* @__PURE__ */ o(rt, {
1477
1505
  ...W,
1478
1506
  scheme: m,
1479
1507
  palette: h,
@@ -1488,4 +1516,4 @@ function Ye({ signal: n, state: i, volume: s, adapter: u, theme: d = "debug", si
1488
1516
  }
1489
1517
  }
1490
1518
  //#endregion
1491
- export { Ye as Orb, Ye as VoiceOrb };
1519
+ export { it as Orb, it as VoiceOrb };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lofcz/orb-ui",
3
- "version": "0.11.0",
3
+ "version": "0.12.0",
4
4
  "description": "React voice agent UI components with audio-reactive adapters for Vapi, ElevenLabs, LiveKit, Pipecat, OpenAI Realtime, Gemini Live, and custom voice AI apps.",
5
5
  "type": "module",
6
6
  "main": "./dist/orb-ui.cjs",