hanc-webrtc-widgets 2.1.9 → 2.1.10

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.
@@ -38188,95 +38188,44 @@ class zd {
38188
38188
  return o.gain.setValueAtTime(0, n), o.gain.linearRampToValueAtTime(this.config.volume, n + c), o.gain.linearRampToValueAtTime(this.config.volume * d, n + c + l), o.gain.setValueAtTime(this.config.volume * d, n + s - u), o.gain.linearRampToValueAtTime(0, n + s), a.connect(o), { oscillator: a, gain: o };
38189
38189
  }
38190
38190
  /**
38191
- * Play ascending melodic sound for call start
38192
- * C4 E4 G4 (C major chord arpeggio)
38191
+ * Play pleasant notification sound for call start
38192
+ * Two-tone ascending melody like messenger notifications
38193
38193
  */
38194
38194
  async playCallStartSound() {
38195
38195
  const e = await this.ensureContext();
38196
38196
  if (!e || typeof e.createGain != "function") return;
38197
38197
  const t = e.currentTime, n = e.createGain();
38198
38198
  n.gain.setValueAtTime(1, t), n.connect(e.destination);
38199
- const s = [
38200
- { freq: 261.63, start: 0, duration: 0.5 },
38201
- // C4
38202
- { freq: 329.63, start: 0.15, duration: 0.5 },
38203
- // E4
38204
- { freq: 392, start: 0.3, duration: 0.6 },
38205
- // G4
38206
- { freq: 523.25, start: 0.5, duration: 0.8 }
38207
- // C5 (octave up)
38208
- ], r = [];
38209
- s.forEach((a) => {
38210
- const { oscillator: o, gain: c } = this.createTone(
38211
- e,
38212
- a.freq,
38213
- t + a.start,
38214
- a.duration,
38215
- "sine"
38216
- );
38217
- c.connect(n), o.start(t + a.start), o.stop(t + a.start + a.duration), r.push(o);
38218
- const { oscillator: l, gain: d } = this.createTone(
38219
- e,
38220
- a.freq * 2,
38221
- // Octave up
38222
- t + a.start,
38223
- a.duration,
38224
- "triangle"
38225
- );
38226
- d.gain.setValueAtTime(d.gain.value * 0.3, t), d.connect(n), l.start(t + a.start), l.stop(t + a.start + a.duration), r.push(l);
38227
- }), setTimeout(() => {
38228
- r.forEach((a) => {
38229
- try {
38230
- a.disconnect();
38231
- } catch {
38232
- }
38233
- });
38234
- }, 2e3);
38199
+ const { oscillator: s, gain: r } = this.createTone(e, 880, t, 0.12, "sine");
38200
+ r.connect(n), s.start(t), s.stop(t + 0.12);
38201
+ const { oscillator: a, gain: o } = this.createTone(e, 1046, t + 0.08, 0.15, "sine");
38202
+ o.connect(n), a.start(t + 0.08), a.stop(t + 0.23), setTimeout(() => {
38203
+ try {
38204
+ s.disconnect();
38205
+ } catch {
38206
+ }
38207
+ try {
38208
+ a.disconnect();
38209
+ } catch {
38210
+ }
38211
+ }, 300);
38235
38212
  }
38236
38213
  /**
38237
- * Play descending melodic sound for call end
38238
- * G4 E4 → C4 (descending C major arpeggio)
38214
+ * Play gentle descending sound for call end
38215
+ * Single soft tone
38239
38216
  */
38240
38217
  async playCallEndSound() {
38241
38218
  const e = await this.ensureContext();
38242
38219
  if (!e || typeof e.createGain != "function") return;
38243
38220
  const t = e.currentTime, n = e.createGain();
38244
38221
  n.gain.setValueAtTime(1, t), n.connect(e.destination);
38245
- const s = [
38246
- { freq: 523.25, start: 0, duration: 0.4 },
38247
- // C5
38248
- { freq: 392, start: 0.12, duration: 0.4 },
38249
- // G4
38250
- { freq: 329.63, start: 0.24, duration: 0.5 },
38251
- // E4
38252
- { freq: 261.63, start: 0.4, duration: 0.7 }
38253
- // C4
38254
- ], r = [];
38255
- s.forEach((a) => {
38256
- const { oscillator: o, gain: c } = this.createTone(
38257
- e,
38258
- a.freq,
38259
- t + a.start,
38260
- a.duration,
38261
- "sine"
38262
- );
38263
- c.connect(n), o.start(t + a.start), o.stop(t + a.start + a.duration), r.push(o);
38264
- const { oscillator: l, gain: d } = this.createTone(
38265
- e,
38266
- a.freq * 2,
38267
- t + a.start,
38268
- a.duration,
38269
- "triangle"
38270
- );
38271
- d.gain.setValueAtTime(d.gain.value * 0.25, t), d.connect(n), l.start(t + a.start), l.stop(t + a.start + a.duration), r.push(l);
38272
- }), setTimeout(() => {
38273
- r.forEach((a) => {
38274
- try {
38275
- a.disconnect();
38276
- } catch {
38277
- }
38278
- });
38279
- }, 1500);
38222
+ const { oscillator: s, gain: r } = this.createTone(e, 660, t, 0.2, "sine");
38223
+ r.connect(n), s.start(t), s.stop(t + 0.2), setTimeout(() => {
38224
+ try {
38225
+ s.disconnect();
38226
+ } catch {
38227
+ }
38228
+ }, 250);
38280
38229
  }
38281
38230
  /**
38282
38231
  * Update configuration
@@ -4468,7 +4468,7 @@ void main() {
4468
4468
  // Softer alpha for more diffuse appearance
4469
4469
  gl_FragColor = vec4(glowColor, glow * 0.4);
4470
4470
  }
4471
- `,bs={primary:"#6366f1",secondary:"#8b5cf6",accent:"#06b6d4",glow:"#818cf8",atmosphere:"#c4b5fd",depth:"#312e81",highlight:"#e0e7ff"},NC={size:1,segments:128,colors:bs,morphStrength:1,noiseScale:1.5,noiseSpeed:.3,glowIntensity:.8,idleGlowMultiplier:.4,fresnelPower:2.5,rotationSpeed:.1,audioReactivity:3,audioSmoothing:.9,idleMorphMultiplier:.25,colorContrast:1.5};class Nd{constructor(e,t={}){this.orb=null,this.glowMesh=null,this.orbMaterial=null,this.glowMaterial=null,this.animationId=null,this.isActive=!1,this.targetRotation={x:0,y:0},this.currentRotation={x:0,y:0},this.audioValues={bass:0,mid:0,treble:0,level:0},this.canvasPadding=3,this.animate=()=>{this.animationId=requestAnimationFrame(this.animate);const o=this.clock.getElapsedTime();if(this.clock.getDelta(),this.orbMaterial){this.orbMaterial.uniforms.uTime.value=o,this.orbMaterial.uniforms.uAudioBass.value=this.audioValues.bass,this.orbMaterial.uniforms.uAudioMid.value=this.audioValues.mid,this.orbMaterial.uniforms.uAudioTreble.value=this.audioValues.treble,this.orbMaterial.uniforms.uAudioLevel.value=this.audioValues.level;const c=this.isActive?this.config.morphStrength*1.5:this.config.morphStrength*this.config.idleMorphMultiplier,l=this.orbMaterial.uniforms.uMorphStrength.value;this.orbMaterial.uniforms.uMorphStrength.value+=(c-l)*.05}if(this.glowMaterial){this.glowMaterial.uniforms.uTime.value=o,this.glowMaterial.uniforms.uAudioLevel.value=this.audioValues.level;const c=this.isActive?this.config.glowIntensity*1.5:this.config.glowIntensity*this.config.idleGlowMultiplier,l=this.glowMaterial.uniforms.uGlowIntensity.value;this.glowMaterial.uniforms.uGlowIntensity.value+=(c-l)*.05}this.currentRotation.x+=(this.targetRotation.x-this.currentRotation.x)*.05,this.currentRotation.y+=(this.targetRotation.y-this.currentRotation.y)*.05,this.orb&&(this.orb.rotation.x=this.currentRotation.x+o*this.config.rotationSpeed*.3,this.orb.rotation.y=this.currentRotation.y+o*this.config.rotationSpeed),this.glowMesh&&(this.glowMesh.rotation.x=this.currentRotation.x+o*this.config.rotationSpeed*.3,this.glowMesh.rotation.y=this.currentRotation.y+o*this.config.rotationSpeed),this.renderer.render(this.scene,this.camera)},this.handleResize=()=>{const o=this.container.clientWidth*this.canvasPadding,c=this.container.clientHeight*this.canvasPadding;this.camera.aspect=o/c,this.camera.updateProjectionMatrix(),this.renderer.setSize(o,c)},this.handleMouseMove=o=>{const c=this.container.getBoundingClientRect(),l=(o.clientX-c.left)/c.width*2-1,d=-((o.clientY-c.top)/c.height)*2+1;this.targetRotation.x=d*.3,this.targetRotation.y=l*.3},this.handleMouseLeave=()=>{this.targetRotation.x=0,this.targetRotation.y=0},this.container=e,this.config={...NC,...t},this.clock=new py,this.scene=new sy;const n=e.clientWidth*this.canvasPadding,s=e.clientHeight*this.canvasPadding,r=n/s;this.camera=new Cn(45,r,.1,100),this.camera.position.z=9,this.renderer=new PC({antialias:!0,alpha:!0,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(n,s),this.renderer.setClearColor(0,0);const a=this.renderer.domElement;a.style.position="absolute",a.style.left="50%",a.style.top="50%",a.style.transform="translate(-50%, -50%)",a.style.pointerEvents="none",e.appendChild(a),this.createOrb(),window.addEventListener("resize",this.handleResize),e.addEventListener("mousemove",this.handleMouseMove),e.addEventListener("mouseleave",this.handleMouseLeave)}createOrb(){const e={...bs,...this.config.colors},t=new Ed(this.config.size,this.config.segments/4);this.orbMaterial=new Tn({vertexShader:kC,fragmentShader:IC,uniforms:{uTime:{value:0},uAudioBass:{value:0},uAudioMid:{value:0},uAudioTreble:{value:0},uAudioLevel:{value:0},uMorphStrength:{value:this.config.morphStrength},uNoiseScale:{value:this.config.noiseScale},uNoiseSpeed:{value:this.config.noiseSpeed},uAudioReactivity:{value:this.config.audioReactivity},uColorPrimary:{value:new Ze(e.primary)},uColorSecondary:{value:new Ze(e.secondary)},uColorAccent:{value:new Ze(e.accent)},uColorDepth:{value:new Ze(e.depth||bs.depth)},uColorHighlight:{value:new Ze(e.highlight||bs.highlight)},uFresnelPower:{value:this.config.fresnelPower},uGlowIntensity:{value:this.config.glowIntensity},uColorContrast:{value:this.config.colorContrast}},transparent:!0,side:pi}),this.orb=new Vn(t,this.orbMaterial),this.scene.add(this.orb);const n=new Md(this.config.size,64,64);this.glowMaterial=new Tn({vertexShader:DC,fragmentShader:LC,uniforms:{uTime:{value:0},uAudioLevel:{value:0},uGlowColor:{value:new Ze(e.glow)},uGlowIntensity:{value:this.config.glowIntensity*.6},uPulseSpeed:{value:2}},transparent:!0,side:Zt,blending:Kc,depthWrite:!1}),this.glowMesh=new Vn(n,this.glowMaterial),this.scene.add(this.glowMesh)}updateAudio(e){const t=this.config.audioSmoothing;this.audioValues.bass+=(e.bass-this.audioValues.bass)*t,this.audioValues.mid+=(e.mid-this.audioValues.mid)*t,this.audioValues.treble+=(e.treble-this.audioValues.treble)*t,this.audioValues.level+=(e.level-this.audioValues.level)*t}setSimulatedAudio(e,t,n,s){const r=this.config.audioSmoothing;this.audioValues.bass+=(e-this.audioValues.bass)*r,this.audioValues.mid+=(t-this.audioValues.mid)*r,this.audioValues.treble+=(n-this.audioValues.treble)*r,this.audioValues.level+=(s-this.audioValues.level)*r}setActive(e){this.isActive=e}setColors(e){const t={...bs,...this.config.colors,...e};this.orbMaterial&&(this.orbMaterial.uniforms.uColorPrimary.value.set(t.primary),this.orbMaterial.uniforms.uColorSecondary.value.set(t.secondary),this.orbMaterial.uniforms.uColorAccent.value.set(t.accent),this.orbMaterial.uniforms.uColorDepth.value.set(t.depth||bs.depth),this.orbMaterial.uniforms.uColorHighlight.value.set(t.highlight||bs.highlight)),this.glowMaterial&&this.glowMaterial.uniforms.uGlowColor.value.set(t.glow)}setGlowSettings(e,t){this.config.glowIntensity=e,this.config.idleGlowMultiplier=t}start(){this.animationId===null&&(this.clock.start(),this.animate())}stop(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}getCanvas(){return this.renderer.domElement}destroy(){this.stop(),window.removeEventListener("resize",this.handleResize),this.container.removeEventListener("mousemove",this.handleMouseMove),this.container.removeEventListener("mouseleave",this.handleMouseLeave),this.orb&&(this.orb.geometry.dispose(),this.scene.remove(this.orb)),this.glowMesh&&(this.glowMesh.geometry.dispose(),this.scene.remove(this.glowMesh)),this.orbMaterial&&this.orbMaterial.dispose(),this.glowMaterial&&this.glowMaterial.dispose(),this.renderer.dispose(),this.renderer.domElement.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}class Ud{constructor(e={}){this.audioContext=null,this.analyser=null,this.source=null,this.localSource=null,this.mixer=null,this.frequencyData=new Uint8Array(0),this.waveformData=new Float32Array(0),this.smoothedBass=0,this.smoothedMid=0,this.smoothedTreble=0,this.smoothedLevel=0,this.smoothingFactor=.3,this.options={fftSize:e.fftSize??2048,smoothingTimeConstant:e.smoothingTimeConstant??.8,minDecibels:e.minDecibels??-90,maxDecibels:e.maxDecibels??-10}}async connectStream(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.source&&this.source.disconnect(),this.source=this.audioContext.createMediaStreamSource(e),this.setupMixerAndAnalyser(),this.source.connect(this.mixer)}async connectLocalStream(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.localSource&&this.localSource.disconnect(),this.localSource=this.audioContext.createMediaStreamSource(e),this.setupMixerAndAnalyser(),this.localSource.connect(this.mixer)}setupMixerAndAnalyser(){this.audioContext&&(this.mixer||(this.mixer=this.audioContext.createGain(),this.mixer.gain.value=1),this.analyser||(this.analyser=this.audioContext.createAnalyser()),this.analyser.fftSize=this.options.fftSize,this.analyser.smoothingTimeConstant=this.options.smoothingTimeConstant,this.analyser.minDecibels=this.options.minDecibels,this.analyser.maxDecibels=this.options.maxDecibels,this.mixer.disconnect(),this.mixer.connect(this.analyser),this.frequencyData=new Uint8Array(this.analyser.frequencyBinCount),this.waveformData=new Float32Array(this.analyser.fftSize))}async connectAudioElement(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.source&&this.source.disconnect();const t=this.audioContext.createMediaElementSource(e);this.analyser||(this.analyser=this.audioContext.createAnalyser()),this.analyser.fftSize=this.options.fftSize,this.analyser.smoothingTimeConstant=this.options.smoothingTimeConstant,this.analyser.minDecibels=this.options.minDecibels,this.analyser.maxDecibels=this.options.maxDecibels,t.connect(this.analyser),this.analyser.connect(this.audioContext.destination),this.frequencyData=new Uint8Array(this.analyser.frequencyBinCount),this.waveformData=new Float32Array(this.analyser.fftSize)}getAudioData(){if(!this.analyser)return{bass:0,mid:0,treble:0,level:0,waveform:new Float32Array(0),frequency:new Uint8Array(0)};this.analyser.getByteFrequencyData(this.frequencyData),this.analyser.getFloatTimeDomainData(this.waveformData);const{bass:e,mid:t,treble:n}=this.calculateFrequencyBands(),s=this.calculateOverallLevel();return this.smoothedBass+=(e-this.smoothedBass)*this.smoothingFactor,this.smoothedMid+=(t-this.smoothedMid)*this.smoothingFactor,this.smoothedTreble+=(n-this.smoothedTreble)*this.smoothingFactor,this.smoothedLevel+=(s-this.smoothedLevel)*this.smoothingFactor,{bass:this.smoothedBass,mid:this.smoothedMid,treble:this.smoothedTreble,level:this.smoothedLevel,waveform:this.waveformData,frequency:this.frequencyData}}calculateFrequencyBands(){if(!this.audioContext||this.frequencyData.length===0)return{bass:0,mid:0,treble:0};const e=this.audioContext.sampleRate,t=this.frequencyData.length,n=e/(t*2),s=Math.floor(250/n),r=Math.floor(2e3/n);let a=0,o=0,c=0;for(let h=0;h<t;h++){const p=this.frequencyData[h]/255;h<s?a+=p:h<r?o+=p:c+=p}const l=s>0?a/s:0,d=r-s>0?o/(r-s):0,u=t-r>0?c/(t-r):0;return{bass:Math.pow(l,.8),mid:Math.pow(d,.9),treble:Math.pow(u,1.1)}}calculateOverallLevel(){if(this.frequencyData.length===0)return 0;let e=0;for(let n=0;n<this.frequencyData.length;n++)e+=this.frequencyData[n];const t=e/this.frequencyData.length/255;return Math.pow(t,.8)}getPeakLevel(){if(this.frequencyData.length===0)return 0;let e=0;for(let t=0;t<this.frequencyData.length;t++)this.frequencyData[t]>e&&(e=this.frequencyData[t]);return e/255}isActive(){return this.audioContext!==null&&this.audioContext.state==="running"}disconnect(){this.source&&(this.source.disconnect(),this.source=null),this.localSource&&(this.localSource.disconnect(),this.localSource=null),this.mixer&&(this.mixer.disconnect(),this.mixer=null),this.analyser&&(this.analyser.disconnect(),this.analyser=null),this.audioContext&&(this.audioContext.close(),this.audioContext=null),this.smoothedBass=0,this.smoothedMid=0,this.smoothedTreble=0,this.smoothedLevel=0}getAudioContext(){return this.audioContext}getAnalyser(){return this.analyser}}class mo{constructor(e={}){this.audioContext=null,this.config={enabled:!0,volume:.15,...e}}async ensureContext(){if(!this.config.enabled)return null;if(!this.audioContext)try{this.audioContext=new(window.AudioContext||window.webkitAudioContext)}catch{return console.warn("Web Audio API not supported"),null}return this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.audioContext}async prewarm(){await this.ensureContext()}createTone(e,t,n,s,r="sine"){const a=e.createOscillator(),o=e.createGain();a.type=r,a.frequency.setValueAtTime(t,n);const c=.05,l=.1,d=.7,u=.3;return o.gain.setValueAtTime(0,n),o.gain.linearRampToValueAtTime(this.config.volume,n+c),o.gain.linearRampToValueAtTime(this.config.volume*d,n+c+l),o.gain.setValueAtTime(this.config.volume*d,n+s-u),o.gain.linearRampToValueAtTime(0,n+s),a.connect(o),{oscillator:a,gain:o}}async playCallStartSound(){const e=await this.ensureContext();if(!e||typeof e.createGain!="function")return;const t=e.currentTime,n=e.createGain();n.gain.setValueAtTime(1,t),n.connect(e.destination);const s=[{freq:261.63,start:0,duration:.5},{freq:329.63,start:.15,duration:.5},{freq:392,start:.3,duration:.6},{freq:523.25,start:.5,duration:.8}],r=[];s.forEach(a=>{const{oscillator:o,gain:c}=this.createTone(e,a.freq,t+a.start,a.duration,"sine");c.connect(n),o.start(t+a.start),o.stop(t+a.start+a.duration),r.push(o);const{oscillator:l,gain:d}=this.createTone(e,a.freq*2,t+a.start,a.duration,"triangle");d.gain.setValueAtTime(d.gain.value*.3,t),d.connect(n),l.start(t+a.start),l.stop(t+a.start+a.duration),r.push(l)}),setTimeout(()=>{r.forEach(a=>{try{a.disconnect()}catch{}})},2e3)}async playCallEndSound(){const e=await this.ensureContext();if(!e||typeof e.createGain!="function")return;const t=e.currentTime,n=e.createGain();n.gain.setValueAtTime(1,t),n.connect(e.destination);const s=[{freq:523.25,start:0,duration:.4},{freq:392,start:.12,duration:.4},{freq:329.63,start:.24,duration:.5},{freq:261.63,start:.4,duration:.7}],r=[];s.forEach(a=>{const{oscillator:o,gain:c}=this.createTone(e,a.freq,t+a.start,a.duration,"sine");c.connect(n),o.start(t+a.start),o.stop(t+a.start+a.duration),r.push(o);const{oscillator:l,gain:d}=this.createTone(e,a.freq*2,t+a.start,a.duration,"triangle");d.gain.setValueAtTime(d.gain.value*.25,t),d.connect(n),l.start(t+a.start),l.stop(t+a.start+a.duration),r.push(l)}),setTimeout(()=>{r.forEach(a=>{try{a.disconnect()}catch{}})},1500)}setConfig(e){this.config={...this.config,...e}}setEnabled(e){this.config.enabled=e}setVolume(e){this.config.volume=Math.max(0,Math.min(1,e))}getConfig(){return{...this.config}}isEnabled(){return this.config.enabled}destroy(){this.audioContext&&(this.audioContext.close(),this.audioContext=null)}}const ii={default:{primary:"#6366f1",secondary:"#8b5cf6",accent:"#06b6d4",glow:"#818cf8",atmosphere:"#c4b5fd",depth:"#312e81",highlight:"#e0e7ff"},emerald:{primary:"#10b981",secondary:"#34d399",accent:"#6ee7b7",glow:"#34d399",atmosphere:"#a7f3d0",depth:"#064e3b",highlight:"#d1fae5"},rose:{primary:"#f43f5e",secondary:"#fb7185",accent:"#fda4af",glow:"#fb7185",atmosphere:"#fecdd3",depth:"#881337",highlight:"#ffe4e6"},amber:{primary:"#f59e0b",secondary:"#fbbf24",accent:"#fcd34d",glow:"#fbbf24",atmosphere:"#fde68a",depth:"#78350f",highlight:"#fef3c7"},cyan:{primary:"#06b6d4",secondary:"#22d3ee",accent:"#67e8f9",glow:"#22d3ee",atmosphere:"#a5f3fc",depth:"#164e63",highlight:"#cffafe"},purple:{primary:"#9333ea",secondary:"#a855f7",accent:"#c084fc",glow:"#a855f7",atmosphere:"#d8b4fe",depth:"#581c87",highlight:"#f3e8ff"},blue:{primary:"#2563eb",secondary:"#3b82f6",accent:"#60a5fa",glow:"#3b82f6",atmosphere:"#93c5fd",depth:"#1e3a8a",highlight:"#dbeafe"}},si={indigo:{primary:"#3730a3",secondary:"#4338ca",accent:"#4f46e5",glow:"#3730a3",atmosphere:"#4338ca",depth:"#1e1b4b",highlight:"#a5b4fc"},violet:{primary:"#5b21b6",secondary:"#6d28d9",accent:"#7c3aed",glow:"#5b21b6",atmosphere:"#6d28d9",depth:"#2e1065",highlight:"#c4b5fd"},teal:{primary:"#0f766e",secondary:"#0d9488",accent:"#14b8a6",glow:"#0f766e",atmosphere:"#0d9488",depth:"#042f2e",highlight:"#5eead4"},orange:{primary:"#c2410c",secondary:"#ea580c",accent:"#f97316",glow:"#c2410c",atmosphere:"#ea580c",depth:"#431407",highlight:"#fed7aa"},blue:{primary:"#1d4ed8",secondary:"#2563eb",accent:"#3b82f6",glow:"#1d4ed8",atmosphere:"#2563eb",depth:"#1e3a8a",highlight:"#93c5fd"},pink:{primary:"#be185d",secondary:"#db2777",accent:"#ec4899",glow:"#be185d",atmosphere:"#db2777",depth:"#500724",highlight:"#f9a8d4"}};function UC(i,e="dark"){const t=e==="dark"?ii:si;return t[i]||t[Object.keys(t)[0]]}function OC(i="dark"){return Object.keys(i==="dark"?ii:si)}const cr={default:{dark:{colors:ii.default,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.indigo,glowIntensity:1.8,idleGlowMultiplier:1.2}},emerald:{dark:{colors:ii.emerald,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.teal,glowIntensity:1.8,idleGlowMultiplier:1.2}},rose:{dark:{colors:ii.rose,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.pink,glowIntensity:1.8,idleGlowMultiplier:1.2}},amber:{dark:{colors:ii.amber,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.orange,glowIntensity:1.8,idleGlowMultiplier:1.2}},cyan:{dark:{colors:ii.cyan,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.blue,glowIntensity:1.8,idleGlowMultiplier:1.2}},purple:{dark:{colors:ii.purple,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.violet,glowIntensity:1.8,idleGlowMultiplier:1.2}},blue:{dark:{colors:ii.blue,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.blue,glowIntensity:1.8,idleGlowMultiplier:1.2}}},FC=Object.fromEntries(Object.entries(cr).map(([i,e])=>[i,e.dark])),BC=Object.fromEntries(Object.entries(cr).map(([i,e])=>[i,e.light]));function xm(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Jr(i,e="auto"){const t=cr[i]||cr.default,n=e==="auto"?xm():e;return t[n]}function VC(){return Object.keys(cr)}function Tm(i,e,t="auto"){const n=Jr(e,t);i.orbColors=n.colors,i.glowIntensity=n.glowIntensity,i.idleGlowMultiplier=n.idleGlowMultiplier}function zC(i,e){if(typeof window>"u")return()=>{};const t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{const s=t.matches?"dark":"light";Tm(i,e,s)};return n(),t.addEventListener("change",n),()=>{t.removeEventListener("change",n)}}var GC=Object.defineProperty,HC=Object.getOwnPropertyDescriptor,St=(i,e,t,n)=>{for(var s=n>1?void 0:n?HC(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&GC(e,t,s),s};te.InlineCall=class extends Qi{constructor(){super(...arguments),this.callManager=new Xc,this.orbRenderer=null,this.audioAnalyzer=null,this.soundManager=null,this.orbContainerRef=Ao(),this.animationId=null,this.callStatus="idle",this.microphoneEnabled=!1,this.buttonStartText="Try to call",this.buttonConnectingText="Connecting...",this.size=370,this.containerPadding=45,this.theme="default",this.themeMode="auto",this.orbColors={},this.glowIntensity=.8,this.idleGlowMultiplier=.4,this.morphStrength=1,this.noiseScale=1.5,this.noiseSpeed=.3,this.fresnelPower=2.5,this.rotationSpeed=.1,this.audioReactivity=3,this.audioSmoothing=.9,this.idleMorphMultiplier=.25,this.colorContrast=1.5,this.soundEnabled=!0,this.soundVolume=.15,this.handleAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectStream(s)}catch(s){console.error("Failed to connect audio stream:",s)}},this.handleLocalAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectLocalStream(s)}catch(s){console.error("Failed to connect local audio stream:",s)}},this.handleMicrophoneEnabled=()=>{this.microphoneEnabled=!0},this.handleMicrophoneDisabled=()=>{this.microphoneEnabled=!1},this.handleStatusChange=e=>{var n,s,r,a,o,c,l;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),(s=this.soundManager)==null||s.playCallStartSound(),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(r=this.orbRenderer)==null||r.setActive(!1),(a=this.audioAnalyzer)==null||a.disconnect(),this.startIdleAnimation(),(o=this.soundManager)==null||o.playCallEndSound(),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(c=this.orbRenderer)==null||c.setActive(!1),(l=this.audioAnalyzer)==null||l.disconnect(),setTimeout(()=>{this.callStatus==="error"&&(this.callStatus="idle",this.startIdleAnimation())},3e3);break}},this.toggleCall=async()=>{var e;this.agentId&&((e=this.soundManager)==null||e.prewarm(),this.callStatus==="idle"?(this.callStatus="connecting",await this.callManager.makeCall({agentId:this.agentId})):this.callStatus==="connected"&&this.callManager.hangUp())}}connectedCallback(){if(super.connectedCallback(),this.theme){const e=Jr(this.theme,this.themeMode);Object.keys(this.orbColors).length===0&&(this.orbColors=e.colors),this.glowIntensity===.8&&(this.glowIntensity=e.glowIntensity),this.idleGlowMultiplier===.4&&(this.idleGlowMultiplier=e.idleGlowMultiplier)}this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),this.soundManager=new mo({enabled:this.soundEnabled,volume:this.soundVolume}),this.callManager.addEventListener("status-changed",this.handleStatusChange),this.callManager.addEventListener("audio-track",this.handleAudioTrack),this.callManager.addEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.addEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.addEventListener("microphone-disabled",this.handleMicrophoneDisabled)}disconnectedCallback(){var e;super.disconnectedCallback(),this.callManager.removeEventListener("status-changed",this.handleStatusChange),this.callManager.removeEventListener("audio-track",this.handleAudioTrack),this.callManager.removeEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.removeEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.removeEventListener("microphone-disabled",this.handleMicrophoneDisabled),this.callManager.hangUp(),this.cleanupOrb(),(e=this.soundManager)==null||e.destroy(),this.soundManager=null}firstUpdated(){this.initializeOrb()}updated(e){var t,n;super.updated(e),e.has("agentId")&&(this.callManager.hangUp(),this.callStatus="idle"),e.has("voiceServiceUrl")&&this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),e.has("soundEnabled")&&((t=this.soundManager)==null||t.setEnabled(this.soundEnabled)),e.has("soundVolume")&&((n=this.soundManager)==null||n.setVolume(this.soundVolume))}initializeOrb(){const e=this.orbContainerRef.value;e&&(this.orbRenderer=new Nd(e,{size:1,colors:this.orbColors,glowIntensity:this.glowIntensity,idleGlowMultiplier:this.idleGlowMultiplier,morphStrength:this.morphStrength,noiseScale:this.noiseScale,noiseSpeed:this.noiseSpeed,fresnelPower:this.fresnelPower,rotationSpeed:this.rotationSpeed,audioReactivity:this.audioReactivity,audioSmoothing:this.audioSmoothing,idleMorphMultiplier:this.idleMorphMultiplier,colorContrast:this.colorContrast}),this.audioAnalyzer=new Ud,this.orbRenderer.start(),this.startIdleAnimation())}cleanupOrb(){var e,t;this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),(e=this.audioAnalyzer)==null||e.disconnect(),(t=this.orbRenderer)==null||t.destroy(),this.audioAnalyzer=null,this.orbRenderer=null}startIdleAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{if(this.callStatus!=="idle"||!this.orbRenderer)return;const t=performance.now()/1e3,n=Math.sin(t*.5)*.15+.15,s=Math.sin(t*.7+1)*.12+.12,r=Math.sin(t*.9+2)*.08+.08,a=(n+s+r)/3;this.orbRenderer.setSimulatedAudio(n,s,r,a),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}startRealAudioLoop(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{var n;if(this.callStatus!=="connected"||!this.orbRenderer)return;const t=(n=this.audioAnalyzer)==null?void 0:n.getAudioData();t&&this.orbRenderer.updateAudio(t),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}getButtonIcon(){return this.callStatus==="connecting"?Xt`
4471
+ `,bs={primary:"#6366f1",secondary:"#8b5cf6",accent:"#06b6d4",glow:"#818cf8",atmosphere:"#c4b5fd",depth:"#312e81",highlight:"#e0e7ff"},NC={size:1,segments:128,colors:bs,morphStrength:1,noiseScale:1.5,noiseSpeed:.3,glowIntensity:.8,idleGlowMultiplier:.4,fresnelPower:2.5,rotationSpeed:.1,audioReactivity:3,audioSmoothing:.9,idleMorphMultiplier:.25,colorContrast:1.5};class Nd{constructor(e,t={}){this.orb=null,this.glowMesh=null,this.orbMaterial=null,this.glowMaterial=null,this.animationId=null,this.isActive=!1,this.targetRotation={x:0,y:0},this.currentRotation={x:0,y:0},this.audioValues={bass:0,mid:0,treble:0,level:0},this.canvasPadding=3,this.animate=()=>{this.animationId=requestAnimationFrame(this.animate);const o=this.clock.getElapsedTime();if(this.clock.getDelta(),this.orbMaterial){this.orbMaterial.uniforms.uTime.value=o,this.orbMaterial.uniforms.uAudioBass.value=this.audioValues.bass,this.orbMaterial.uniforms.uAudioMid.value=this.audioValues.mid,this.orbMaterial.uniforms.uAudioTreble.value=this.audioValues.treble,this.orbMaterial.uniforms.uAudioLevel.value=this.audioValues.level;const c=this.isActive?this.config.morphStrength*1.5:this.config.morphStrength*this.config.idleMorphMultiplier,l=this.orbMaterial.uniforms.uMorphStrength.value;this.orbMaterial.uniforms.uMorphStrength.value+=(c-l)*.05}if(this.glowMaterial){this.glowMaterial.uniforms.uTime.value=o,this.glowMaterial.uniforms.uAudioLevel.value=this.audioValues.level;const c=this.isActive?this.config.glowIntensity*1.5:this.config.glowIntensity*this.config.idleGlowMultiplier,l=this.glowMaterial.uniforms.uGlowIntensity.value;this.glowMaterial.uniforms.uGlowIntensity.value+=(c-l)*.05}this.currentRotation.x+=(this.targetRotation.x-this.currentRotation.x)*.05,this.currentRotation.y+=(this.targetRotation.y-this.currentRotation.y)*.05,this.orb&&(this.orb.rotation.x=this.currentRotation.x+o*this.config.rotationSpeed*.3,this.orb.rotation.y=this.currentRotation.y+o*this.config.rotationSpeed),this.glowMesh&&(this.glowMesh.rotation.x=this.currentRotation.x+o*this.config.rotationSpeed*.3,this.glowMesh.rotation.y=this.currentRotation.y+o*this.config.rotationSpeed),this.renderer.render(this.scene,this.camera)},this.handleResize=()=>{const o=this.container.clientWidth*this.canvasPadding,c=this.container.clientHeight*this.canvasPadding;this.camera.aspect=o/c,this.camera.updateProjectionMatrix(),this.renderer.setSize(o,c)},this.handleMouseMove=o=>{const c=this.container.getBoundingClientRect(),l=(o.clientX-c.left)/c.width*2-1,d=-((o.clientY-c.top)/c.height)*2+1;this.targetRotation.x=d*.3,this.targetRotation.y=l*.3},this.handleMouseLeave=()=>{this.targetRotation.x=0,this.targetRotation.y=0},this.container=e,this.config={...NC,...t},this.clock=new py,this.scene=new sy;const n=e.clientWidth*this.canvasPadding,s=e.clientHeight*this.canvasPadding,r=n/s;this.camera=new Cn(45,r,.1,100),this.camera.position.z=9,this.renderer=new PC({antialias:!0,alpha:!0,powerPreference:"high-performance"}),this.renderer.setPixelRatio(Math.min(window.devicePixelRatio,2)),this.renderer.setSize(n,s),this.renderer.setClearColor(0,0);const a=this.renderer.domElement;a.style.position="absolute",a.style.left="50%",a.style.top="50%",a.style.transform="translate(-50%, -50%)",a.style.pointerEvents="none",e.appendChild(a),this.createOrb(),window.addEventListener("resize",this.handleResize),e.addEventListener("mousemove",this.handleMouseMove),e.addEventListener("mouseleave",this.handleMouseLeave)}createOrb(){const e={...bs,...this.config.colors},t=new Ed(this.config.size,this.config.segments/4);this.orbMaterial=new Tn({vertexShader:kC,fragmentShader:IC,uniforms:{uTime:{value:0},uAudioBass:{value:0},uAudioMid:{value:0},uAudioTreble:{value:0},uAudioLevel:{value:0},uMorphStrength:{value:this.config.morphStrength},uNoiseScale:{value:this.config.noiseScale},uNoiseSpeed:{value:this.config.noiseSpeed},uAudioReactivity:{value:this.config.audioReactivity},uColorPrimary:{value:new Ze(e.primary)},uColorSecondary:{value:new Ze(e.secondary)},uColorAccent:{value:new Ze(e.accent)},uColorDepth:{value:new Ze(e.depth||bs.depth)},uColorHighlight:{value:new Ze(e.highlight||bs.highlight)},uFresnelPower:{value:this.config.fresnelPower},uGlowIntensity:{value:this.config.glowIntensity},uColorContrast:{value:this.config.colorContrast}},transparent:!0,side:pi}),this.orb=new Vn(t,this.orbMaterial),this.scene.add(this.orb);const n=new Md(this.config.size,64,64);this.glowMaterial=new Tn({vertexShader:DC,fragmentShader:LC,uniforms:{uTime:{value:0},uAudioLevel:{value:0},uGlowColor:{value:new Ze(e.glow)},uGlowIntensity:{value:this.config.glowIntensity*.6},uPulseSpeed:{value:2}},transparent:!0,side:Zt,blending:Kc,depthWrite:!1}),this.glowMesh=new Vn(n,this.glowMaterial),this.scene.add(this.glowMesh)}updateAudio(e){const t=this.config.audioSmoothing;this.audioValues.bass+=(e.bass-this.audioValues.bass)*t,this.audioValues.mid+=(e.mid-this.audioValues.mid)*t,this.audioValues.treble+=(e.treble-this.audioValues.treble)*t,this.audioValues.level+=(e.level-this.audioValues.level)*t}setSimulatedAudio(e,t,n,s){const r=this.config.audioSmoothing;this.audioValues.bass+=(e-this.audioValues.bass)*r,this.audioValues.mid+=(t-this.audioValues.mid)*r,this.audioValues.treble+=(n-this.audioValues.treble)*r,this.audioValues.level+=(s-this.audioValues.level)*r}setActive(e){this.isActive=e}setColors(e){const t={...bs,...this.config.colors,...e};this.orbMaterial&&(this.orbMaterial.uniforms.uColorPrimary.value.set(t.primary),this.orbMaterial.uniforms.uColorSecondary.value.set(t.secondary),this.orbMaterial.uniforms.uColorAccent.value.set(t.accent),this.orbMaterial.uniforms.uColorDepth.value.set(t.depth||bs.depth),this.orbMaterial.uniforms.uColorHighlight.value.set(t.highlight||bs.highlight)),this.glowMaterial&&this.glowMaterial.uniforms.uGlowColor.value.set(t.glow)}setGlowSettings(e,t){this.config.glowIntensity=e,this.config.idleGlowMultiplier=t}start(){this.animationId===null&&(this.clock.start(),this.animate())}stop(){this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null)}getCanvas(){return this.renderer.domElement}destroy(){this.stop(),window.removeEventListener("resize",this.handleResize),this.container.removeEventListener("mousemove",this.handleMouseMove),this.container.removeEventListener("mouseleave",this.handleMouseLeave),this.orb&&(this.orb.geometry.dispose(),this.scene.remove(this.orb)),this.glowMesh&&(this.glowMesh.geometry.dispose(),this.scene.remove(this.glowMesh)),this.orbMaterial&&this.orbMaterial.dispose(),this.glowMaterial&&this.glowMaterial.dispose(),this.renderer.dispose(),this.renderer.domElement.parentNode&&this.renderer.domElement.parentNode.removeChild(this.renderer.domElement)}}class Ud{constructor(e={}){this.audioContext=null,this.analyser=null,this.source=null,this.localSource=null,this.mixer=null,this.frequencyData=new Uint8Array(0),this.waveformData=new Float32Array(0),this.smoothedBass=0,this.smoothedMid=0,this.smoothedTreble=0,this.smoothedLevel=0,this.smoothingFactor=.3,this.options={fftSize:e.fftSize??2048,smoothingTimeConstant:e.smoothingTimeConstant??.8,minDecibels:e.minDecibels??-90,maxDecibels:e.maxDecibels??-10}}async connectStream(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.source&&this.source.disconnect(),this.source=this.audioContext.createMediaStreamSource(e),this.setupMixerAndAnalyser(),this.source.connect(this.mixer)}async connectLocalStream(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.localSource&&this.localSource.disconnect(),this.localSource=this.audioContext.createMediaStreamSource(e),this.setupMixerAndAnalyser(),this.localSource.connect(this.mixer)}setupMixerAndAnalyser(){this.audioContext&&(this.mixer||(this.mixer=this.audioContext.createGain(),this.mixer.gain.value=1),this.analyser||(this.analyser=this.audioContext.createAnalyser()),this.analyser.fftSize=this.options.fftSize,this.analyser.smoothingTimeConstant=this.options.smoothingTimeConstant,this.analyser.minDecibels=this.options.minDecibels,this.analyser.maxDecibels=this.options.maxDecibels,this.mixer.disconnect(),this.mixer.connect(this.analyser),this.frequencyData=new Uint8Array(this.analyser.frequencyBinCount),this.waveformData=new Float32Array(this.analyser.fftSize))}async connectAudioElement(e){this.audioContext||(this.audioContext=new AudioContext),this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.source&&this.source.disconnect();const t=this.audioContext.createMediaElementSource(e);this.analyser||(this.analyser=this.audioContext.createAnalyser()),this.analyser.fftSize=this.options.fftSize,this.analyser.smoothingTimeConstant=this.options.smoothingTimeConstant,this.analyser.minDecibels=this.options.minDecibels,this.analyser.maxDecibels=this.options.maxDecibels,t.connect(this.analyser),this.analyser.connect(this.audioContext.destination),this.frequencyData=new Uint8Array(this.analyser.frequencyBinCount),this.waveformData=new Float32Array(this.analyser.fftSize)}getAudioData(){if(!this.analyser)return{bass:0,mid:0,treble:0,level:0,waveform:new Float32Array(0),frequency:new Uint8Array(0)};this.analyser.getByteFrequencyData(this.frequencyData),this.analyser.getFloatTimeDomainData(this.waveformData);const{bass:e,mid:t,treble:n}=this.calculateFrequencyBands(),s=this.calculateOverallLevel();return this.smoothedBass+=(e-this.smoothedBass)*this.smoothingFactor,this.smoothedMid+=(t-this.smoothedMid)*this.smoothingFactor,this.smoothedTreble+=(n-this.smoothedTreble)*this.smoothingFactor,this.smoothedLevel+=(s-this.smoothedLevel)*this.smoothingFactor,{bass:this.smoothedBass,mid:this.smoothedMid,treble:this.smoothedTreble,level:this.smoothedLevel,waveform:this.waveformData,frequency:this.frequencyData}}calculateFrequencyBands(){if(!this.audioContext||this.frequencyData.length===0)return{bass:0,mid:0,treble:0};const e=this.audioContext.sampleRate,t=this.frequencyData.length,n=e/(t*2),s=Math.floor(250/n),r=Math.floor(2e3/n);let a=0,o=0,c=0;for(let h=0;h<t;h++){const p=this.frequencyData[h]/255;h<s?a+=p:h<r?o+=p:c+=p}const l=s>0?a/s:0,d=r-s>0?o/(r-s):0,u=t-r>0?c/(t-r):0;return{bass:Math.pow(l,.8),mid:Math.pow(d,.9),treble:Math.pow(u,1.1)}}calculateOverallLevel(){if(this.frequencyData.length===0)return 0;let e=0;for(let n=0;n<this.frequencyData.length;n++)e+=this.frequencyData[n];const t=e/this.frequencyData.length/255;return Math.pow(t,.8)}getPeakLevel(){if(this.frequencyData.length===0)return 0;let e=0;for(let t=0;t<this.frequencyData.length;t++)this.frequencyData[t]>e&&(e=this.frequencyData[t]);return e/255}isActive(){return this.audioContext!==null&&this.audioContext.state==="running"}disconnect(){this.source&&(this.source.disconnect(),this.source=null),this.localSource&&(this.localSource.disconnect(),this.localSource=null),this.mixer&&(this.mixer.disconnect(),this.mixer=null),this.analyser&&(this.analyser.disconnect(),this.analyser=null),this.audioContext&&(this.audioContext.close(),this.audioContext=null),this.smoothedBass=0,this.smoothedMid=0,this.smoothedTreble=0,this.smoothedLevel=0}getAudioContext(){return this.audioContext}getAnalyser(){return this.analyser}}class mo{constructor(e={}){this.audioContext=null,this.config={enabled:!0,volume:.15,...e}}async ensureContext(){if(!this.config.enabled)return null;if(!this.audioContext)try{this.audioContext=new(window.AudioContext||window.webkitAudioContext)}catch{return console.warn("Web Audio API not supported"),null}return this.audioContext.state==="suspended"&&await this.audioContext.resume(),this.audioContext}async prewarm(){await this.ensureContext()}createTone(e,t,n,s,r="sine"){const a=e.createOscillator(),o=e.createGain();a.type=r,a.frequency.setValueAtTime(t,n);const c=.05,l=.1,d=.7,u=.3;return o.gain.setValueAtTime(0,n),o.gain.linearRampToValueAtTime(this.config.volume,n+c),o.gain.linearRampToValueAtTime(this.config.volume*d,n+c+l),o.gain.setValueAtTime(this.config.volume*d,n+s-u),o.gain.linearRampToValueAtTime(0,n+s),a.connect(o),{oscillator:a,gain:o}}async playCallStartSound(){const e=await this.ensureContext();if(!e||typeof e.createGain!="function")return;const t=e.currentTime,n=e.createGain();n.gain.setValueAtTime(1,t),n.connect(e.destination);const{oscillator:s,gain:r}=this.createTone(e,880,t,.12,"sine");r.connect(n),s.start(t),s.stop(t+.12);const{oscillator:a,gain:o}=this.createTone(e,1046,t+.08,.15,"sine");o.connect(n),a.start(t+.08),a.stop(t+.23),setTimeout(()=>{try{s.disconnect()}catch{}try{a.disconnect()}catch{}},300)}async playCallEndSound(){const e=await this.ensureContext();if(!e||typeof e.createGain!="function")return;const t=e.currentTime,n=e.createGain();n.gain.setValueAtTime(1,t),n.connect(e.destination);const{oscillator:s,gain:r}=this.createTone(e,660,t,.2,"sine");r.connect(n),s.start(t),s.stop(t+.2),setTimeout(()=>{try{s.disconnect()}catch{}},250)}setConfig(e){this.config={...this.config,...e}}setEnabled(e){this.config.enabled=e}setVolume(e){this.config.volume=Math.max(0,Math.min(1,e))}getConfig(){return{...this.config}}isEnabled(){return this.config.enabled}destroy(){this.audioContext&&(this.audioContext.close(),this.audioContext=null)}}const ii={default:{primary:"#6366f1",secondary:"#8b5cf6",accent:"#06b6d4",glow:"#818cf8",atmosphere:"#c4b5fd",depth:"#312e81",highlight:"#e0e7ff"},emerald:{primary:"#10b981",secondary:"#34d399",accent:"#6ee7b7",glow:"#34d399",atmosphere:"#a7f3d0",depth:"#064e3b",highlight:"#d1fae5"},rose:{primary:"#f43f5e",secondary:"#fb7185",accent:"#fda4af",glow:"#fb7185",atmosphere:"#fecdd3",depth:"#881337",highlight:"#ffe4e6"},amber:{primary:"#f59e0b",secondary:"#fbbf24",accent:"#fcd34d",glow:"#fbbf24",atmosphere:"#fde68a",depth:"#78350f",highlight:"#fef3c7"},cyan:{primary:"#06b6d4",secondary:"#22d3ee",accent:"#67e8f9",glow:"#22d3ee",atmosphere:"#a5f3fc",depth:"#164e63",highlight:"#cffafe"},purple:{primary:"#9333ea",secondary:"#a855f7",accent:"#c084fc",glow:"#a855f7",atmosphere:"#d8b4fe",depth:"#581c87",highlight:"#f3e8ff"},blue:{primary:"#2563eb",secondary:"#3b82f6",accent:"#60a5fa",glow:"#3b82f6",atmosphere:"#93c5fd",depth:"#1e3a8a",highlight:"#dbeafe"}},si={indigo:{primary:"#3730a3",secondary:"#4338ca",accent:"#4f46e5",glow:"#3730a3",atmosphere:"#4338ca",depth:"#1e1b4b",highlight:"#a5b4fc"},violet:{primary:"#5b21b6",secondary:"#6d28d9",accent:"#7c3aed",glow:"#5b21b6",atmosphere:"#6d28d9",depth:"#2e1065",highlight:"#c4b5fd"},teal:{primary:"#0f766e",secondary:"#0d9488",accent:"#14b8a6",glow:"#0f766e",atmosphere:"#0d9488",depth:"#042f2e",highlight:"#5eead4"},orange:{primary:"#c2410c",secondary:"#ea580c",accent:"#f97316",glow:"#c2410c",atmosphere:"#ea580c",depth:"#431407",highlight:"#fed7aa"},blue:{primary:"#1d4ed8",secondary:"#2563eb",accent:"#3b82f6",glow:"#1d4ed8",atmosphere:"#2563eb",depth:"#1e3a8a",highlight:"#93c5fd"},pink:{primary:"#be185d",secondary:"#db2777",accent:"#ec4899",glow:"#be185d",atmosphere:"#db2777",depth:"#500724",highlight:"#f9a8d4"}};function UC(i,e="dark"){const t=e==="dark"?ii:si;return t[i]||t[Object.keys(t)[0]]}function OC(i="dark"){return Object.keys(i==="dark"?ii:si)}const cr={default:{dark:{colors:ii.default,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.indigo,glowIntensity:1.8,idleGlowMultiplier:1.2}},emerald:{dark:{colors:ii.emerald,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.teal,glowIntensity:1.8,idleGlowMultiplier:1.2}},rose:{dark:{colors:ii.rose,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.pink,glowIntensity:1.8,idleGlowMultiplier:1.2}},amber:{dark:{colors:ii.amber,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.orange,glowIntensity:1.8,idleGlowMultiplier:1.2}},cyan:{dark:{colors:ii.cyan,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.blue,glowIntensity:1.8,idleGlowMultiplier:1.2}},purple:{dark:{colors:ii.purple,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.violet,glowIntensity:1.8,idleGlowMultiplier:1.2}},blue:{dark:{colors:ii.blue,glowIntensity:1.2,idleGlowMultiplier:.6},light:{colors:si.blue,glowIntensity:1.8,idleGlowMultiplier:1.2}}},FC=Object.fromEntries(Object.entries(cr).map(([i,e])=>[i,e.dark])),BC=Object.fromEntries(Object.entries(cr).map(([i,e])=>[i,e.light]));function xm(){return typeof window>"u"||window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function Jr(i,e="auto"){const t=cr[i]||cr.default,n=e==="auto"?xm():e;return t[n]}function VC(){return Object.keys(cr)}function Tm(i,e,t="auto"){const n=Jr(e,t);i.orbColors=n.colors,i.glowIntensity=n.glowIntensity,i.idleGlowMultiplier=n.idleGlowMultiplier}function zC(i,e){if(typeof window>"u")return()=>{};const t=window.matchMedia("(prefers-color-scheme: dark)"),n=()=>{const s=t.matches?"dark":"light";Tm(i,e,s)};return n(),t.addEventListener("change",n),()=>{t.removeEventListener("change",n)}}var GC=Object.defineProperty,HC=Object.getOwnPropertyDescriptor,St=(i,e,t,n)=>{for(var s=n>1?void 0:n?HC(e,t):e,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(n?a(e,t,s):a(s))||s);return n&&s&&GC(e,t,s),s};te.InlineCall=class extends Qi{constructor(){super(...arguments),this.callManager=new Xc,this.orbRenderer=null,this.audioAnalyzer=null,this.soundManager=null,this.orbContainerRef=Ao(),this.animationId=null,this.callStatus="idle",this.microphoneEnabled=!1,this.buttonStartText="Try to call",this.buttonConnectingText="Connecting...",this.size=370,this.containerPadding=45,this.theme="default",this.themeMode="auto",this.orbColors={},this.glowIntensity=.8,this.idleGlowMultiplier=.4,this.morphStrength=1,this.noiseScale=1.5,this.noiseSpeed=.3,this.fresnelPower=2.5,this.rotationSpeed=.1,this.audioReactivity=3,this.audioSmoothing=.9,this.idleMorphMultiplier=.25,this.colorContrast=1.5,this.soundEnabled=!0,this.soundVolume=.15,this.handleAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectStream(s)}catch(s){console.error("Failed to connect audio stream:",s)}},this.handleLocalAudioTrack=async e=>{const n=e.detail;if(!(!n||!this.audioAnalyzer))try{const s=new MediaStream([n]);await this.audioAnalyzer.connectLocalStream(s)}catch(s){console.error("Failed to connect local audio stream:",s)}},this.handleMicrophoneEnabled=()=>{this.microphoneEnabled=!0},this.handleMicrophoneDisabled=()=>{this.microphoneEnabled=!1},this.handleStatusChange=e=>{var n,s,r,a,o,c,l;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),(s=this.soundManager)==null||s.playCallStartSound(),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(r=this.orbRenderer)==null||r.setActive(!1),(a=this.audioAnalyzer)==null||a.disconnect(),this.startIdleAnimation(),(o=this.soundManager)==null||o.playCallEndSound(),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(c=this.orbRenderer)==null||c.setActive(!1),(l=this.audioAnalyzer)==null||l.disconnect(),setTimeout(()=>{this.callStatus==="error"&&(this.callStatus="idle",this.startIdleAnimation())},3e3);break}},this.toggleCall=async()=>{var e;this.agentId&&((e=this.soundManager)==null||e.prewarm(),this.callStatus==="idle"?(this.callStatus="connecting",await this.callManager.makeCall({agentId:this.agentId})):this.callStatus==="connected"&&this.callManager.hangUp())}}connectedCallback(){if(super.connectedCallback(),this.theme){const e=Jr(this.theme,this.themeMode);Object.keys(this.orbColors).length===0&&(this.orbColors=e.colors),this.glowIntensity===.8&&(this.glowIntensity=e.glowIntensity),this.idleGlowMultiplier===.4&&(this.idleGlowMultiplier=e.idleGlowMultiplier)}this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),this.soundManager=new mo({enabled:this.soundEnabled,volume:this.soundVolume}),this.callManager.addEventListener("status-changed",this.handleStatusChange),this.callManager.addEventListener("audio-track",this.handleAudioTrack),this.callManager.addEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.addEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.addEventListener("microphone-disabled",this.handleMicrophoneDisabled)}disconnectedCallback(){var e;super.disconnectedCallback(),this.callManager.removeEventListener("status-changed",this.handleStatusChange),this.callManager.removeEventListener("audio-track",this.handleAudioTrack),this.callManager.removeEventListener("local-audio-track",this.handleLocalAudioTrack),this.callManager.removeEventListener("microphone-enabled",this.handleMicrophoneEnabled),this.callManager.removeEventListener("microphone-disabled",this.handleMicrophoneDisabled),this.callManager.hangUp(),this.cleanupOrb(),(e=this.soundManager)==null||e.destroy(),this.soundManager=null}firstUpdated(){this.initializeOrb()}updated(e){var t,n;super.updated(e),e.has("agentId")&&(this.callManager.hangUp(),this.callStatus="idle"),e.has("voiceServiceUrl")&&this.voiceServiceUrl&&(this.callManager.serviceUrl=this.voiceServiceUrl),e.has("soundEnabled")&&((t=this.soundManager)==null||t.setEnabled(this.soundEnabled)),e.has("soundVolume")&&((n=this.soundManager)==null||n.setVolume(this.soundVolume))}initializeOrb(){const e=this.orbContainerRef.value;e&&(this.orbRenderer=new Nd(e,{size:1,colors:this.orbColors,glowIntensity:this.glowIntensity,idleGlowMultiplier:this.idleGlowMultiplier,morphStrength:this.morphStrength,noiseScale:this.noiseScale,noiseSpeed:this.noiseSpeed,fresnelPower:this.fresnelPower,rotationSpeed:this.rotationSpeed,audioReactivity:this.audioReactivity,audioSmoothing:this.audioSmoothing,idleMorphMultiplier:this.idleMorphMultiplier,colorContrast:this.colorContrast}),this.audioAnalyzer=new Ud,this.orbRenderer.start(),this.startIdleAnimation())}cleanupOrb(){var e,t;this.animationId!==null&&(cancelAnimationFrame(this.animationId),this.animationId=null),(e=this.audioAnalyzer)==null||e.disconnect(),(t=this.orbRenderer)==null||t.destroy(),this.audioAnalyzer=null,this.orbRenderer=null}startIdleAnimation(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{if(this.callStatus!=="idle"||!this.orbRenderer)return;const t=performance.now()/1e3,n=Math.sin(t*.5)*.15+.15,s=Math.sin(t*.7+1)*.12+.12,r=Math.sin(t*.9+2)*.08+.08,a=(n+s+r)/3;this.orbRenderer.setSimulatedAudio(n,s,r,a),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}startRealAudioLoop(){this.animationId!==null&&cancelAnimationFrame(this.animationId);const e=()=>{var n;if(this.callStatus!=="connected"||!this.orbRenderer)return;const t=(n=this.audioAnalyzer)==null?void 0:n.getAudioData();t&&this.orbRenderer.updateAudio(t),this.animationId=requestAnimationFrame(e)};this.animationId=requestAnimationFrame(e)}getButtonIcon(){return this.callStatus==="connecting"?Xt`
4472
4472
  <svg width="16" height="16" viewBox="0 0 16 16" fill="none" class="hanc-spinner">
4473
4473
  <circle
4474
4474
  cx="8"
@@ -24,13 +24,13 @@ export declare class SoundManager {
24
24
  */
25
25
  private createTone;
26
26
  /**
27
- * Play ascending melodic sound for call start
28
- * C4 E4 G4 (C major chord arpeggio)
27
+ * Play pleasant notification sound for call start
28
+ * Two-tone ascending melody like messenger notifications
29
29
  */
30
30
  playCallStartSound(): Promise<void>;
31
31
  /**
32
- * Play descending melodic sound for call end
33
- * G4 E4 → C4 (descending C major arpeggio)
32
+ * Play gentle descending sound for call end
33
+ * Single soft tone
34
34
  */
35
35
  playCallEndSound(): Promise<void>;
36
36
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hanc-webrtc-widgets",
3
- "version": "2.1.9",
3
+ "version": "2.1.10",
4
4
  "type": "module",
5
5
  "main": "dist/hanc-webrtc-widgets.umd.js",
6
6
  "module": "dist/hanc-webrtc-widgets.es.js",