hanc-webrtc-widgets 2.1.11 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hanc-webrtc-widgets.es.js +28 -22
- package/dist/hanc-webrtc-widgets.umd.js +3 -3
- package/dist/src/components/floating-call/floating-call.d.ts +1 -0
- package/dist/src/components/inline-call/inline-call.d.ts +1 -0
- package/dist/src/components/pill-call/pill-call.d.ts +1 -0
- package/package.json +1 -1
|
@@ -38602,11 +38602,7 @@ let gt = class extends ps {
|
|
|
38602
38602
|
};
|
|
38603
38603
|
}
|
|
38604
38604
|
connectedCallback() {
|
|
38605
|
-
|
|
38606
|
-
const i = _o(this.theme, this.themeMode);
|
|
38607
|
-
Object.keys(this.orbColors).length === 0 && (this.orbColors = i.colors), this.glowIntensity === 0.8 && (this.glowIntensity = i.glowIntensity), this.idleGlowMultiplier === 0.4 && (this.idleGlowMultiplier = i.idleGlowMultiplier);
|
|
38608
|
-
}
|
|
38609
|
-
this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), this.soundManager = new zd({
|
|
38605
|
+
super.connectedCallback(), this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), this.soundManager = new zd({
|
|
38610
38606
|
enabled: this.soundEnabled,
|
|
38611
38607
|
volume: this.soundVolume
|
|
38612
38608
|
}), this.callManager.addEventListener(
|
|
@@ -38622,11 +38618,17 @@ let gt = class extends ps {
|
|
|
38622
38618
|
), 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(), (i = this.soundManager) == null || i.destroy(), this.soundManager = null;
|
|
38623
38619
|
}
|
|
38624
38620
|
firstUpdated() {
|
|
38625
|
-
this.initializeOrb();
|
|
38621
|
+
this.applyTheme(), this.initializeOrb();
|
|
38626
38622
|
}
|
|
38627
38623
|
updated(i) {
|
|
38628
38624
|
var e, t;
|
|
38629
|
-
super.updated(i), i.has("agentId") && (this.callManager.hangUp(), this.callStatus = "idle"), i.has("voiceServiceUrl") && this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), i.has("soundEnabled") && ((e = this.soundManager) == null || e.setEnabled(this.soundEnabled)), i.has("soundVolume") && ((t = this.soundManager) == null || t.setVolume(this.soundVolume));
|
|
38625
|
+
super.updated(i), i.has("agentId") && (this.callManager.hangUp(), this.callStatus = "idle"), i.has("voiceServiceUrl") && this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), (i.has("theme") || i.has("themeMode")) && this.applyTheme(), i.has("soundEnabled") && ((e = this.soundManager) == null || e.setEnabled(this.soundEnabled)), i.has("soundVolume") && ((t = this.soundManager) == null || t.setVolume(this.soundVolume));
|
|
38626
|
+
}
|
|
38627
|
+
applyTheme() {
|
|
38628
|
+
if (this.theme) {
|
|
38629
|
+
const i = _o(this.theme, this.themeMode);
|
|
38630
|
+
this.orbColors = i.colors, this.glowIntensity = i.glowIntensity, this.idleGlowMultiplier = i.idleGlowMultiplier, this.orbRenderer && (this.orbRenderer.setColors(this.orbColors), this.orbRenderer.setGlowSettings(this.glowIntensity, this.idleGlowMultiplier));
|
|
38631
|
+
}
|
|
38630
38632
|
}
|
|
38631
38633
|
initializeOrb() {
|
|
38632
38634
|
const i = this.orbContainerRef.value;
|
|
@@ -38999,7 +39001,7 @@ Et([
|
|
|
38999
39001
|
Se({ type: Number, attribute: "container-padding" })
|
|
39000
39002
|
], gt.prototype, "containerPadding", 2);
|
|
39001
39003
|
Et([
|
|
39002
|
-
Se({ type: String, attribute: "theme" })
|
|
39004
|
+
Se({ type: String, attribute: "theme", reflect: !0 })
|
|
39003
39005
|
], gt.prototype, "theme", 2);
|
|
39004
39006
|
Et([
|
|
39005
39007
|
Se({ type: String, attribute: "theme-mode" })
|
|
@@ -39114,11 +39116,7 @@ let vt = class extends ps {
|
|
|
39114
39116
|
};
|
|
39115
39117
|
}
|
|
39116
39118
|
connectedCallback() {
|
|
39117
|
-
|
|
39118
|
-
const i = _o(this.theme, this.themeMode);
|
|
39119
|
-
Object.keys(this.orbColors).length === 0 && (this.orbColors = i.colors), this.glowIntensity === 0.8 && (this.glowIntensity = i.glowIntensity), this.idleGlowMultiplier === 0.4 && (this.idleGlowMultiplier = i.idleGlowMultiplier);
|
|
39120
|
-
}
|
|
39121
|
-
this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), this.soundManager = new zd({
|
|
39119
|
+
super.connectedCallback(), this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), this.soundManager = new zd({
|
|
39122
39120
|
enabled: this.soundEnabled,
|
|
39123
39121
|
volume: this.soundVolume
|
|
39124
39122
|
}), this.callManager.addEventListener(
|
|
@@ -39134,11 +39132,17 @@ let vt = class extends ps {
|
|
|
39134
39132
|
), 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(), (i = this.soundManager) == null || i.destroy(), this.soundManager = null;
|
|
39135
39133
|
}
|
|
39136
39134
|
firstUpdated() {
|
|
39137
|
-
this.initializeOrb();
|
|
39135
|
+
this.applyTheme(), this.initializeOrb();
|
|
39138
39136
|
}
|
|
39139
39137
|
updated(i) {
|
|
39140
39138
|
var e, t;
|
|
39141
|
-
super.updated(i), i.has("agentId") && (this.callManager.hangUp(), this.callStatus = "idle"), i.has("voiceServiceUrl") && this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), i.has("soundEnabled") && ((e = this.soundManager) == null || e.setEnabled(this.soundEnabled)), i.has("soundVolume") && ((t = this.soundManager) == null || t.setVolume(this.soundVolume));
|
|
39139
|
+
super.updated(i), i.has("agentId") && (this.callManager.hangUp(), this.callStatus = "idle"), i.has("voiceServiceUrl") && this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), (i.has("theme") || i.has("themeMode")) && this.applyTheme(), i.has("soundEnabled") && ((e = this.soundManager) == null || e.setEnabled(this.soundEnabled)), i.has("soundVolume") && ((t = this.soundManager) == null || t.setVolume(this.soundVolume));
|
|
39140
|
+
}
|
|
39141
|
+
applyTheme() {
|
|
39142
|
+
if (this.theme) {
|
|
39143
|
+
const i = _o(this.theme, this.themeMode);
|
|
39144
|
+
this.orbColors = i.colors, this.glowIntensity = i.glowIntensity, this.idleGlowMultiplier = i.idleGlowMultiplier, this.orbRenderer && (this.orbRenderer.setColors(this.orbColors), this.orbRenderer.setGlowSettings(this.glowIntensity, this.idleGlowMultiplier));
|
|
39145
|
+
}
|
|
39142
39146
|
}
|
|
39143
39147
|
initializeOrb() {
|
|
39144
39148
|
const i = this.orbContainerRef.value;
|
|
@@ -39610,11 +39614,7 @@ let _t = class extends ps {
|
|
|
39610
39614
|
};
|
|
39611
39615
|
}
|
|
39612
39616
|
connectedCallback() {
|
|
39613
|
-
|
|
39614
|
-
const i = _o(this.theme, this.themeMode);
|
|
39615
|
-
Object.keys(this.orbColors).length === 0 && (this.orbColors = i.colors), this.glowIntensity === 0.8 && (this.glowIntensity = i.glowIntensity), this.idleGlowMultiplier === 0.4 && (this.idleGlowMultiplier = i.idleGlowMultiplier);
|
|
39616
|
-
}
|
|
39617
|
-
this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), this.soundManager = new zd({
|
|
39617
|
+
super.connectedCallback(), this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), this.soundManager = new zd({
|
|
39618
39618
|
enabled: this.soundEnabled,
|
|
39619
39619
|
volume: this.soundVolume
|
|
39620
39620
|
}), this.callManager.addEventListener(
|
|
@@ -39630,11 +39630,17 @@ let _t = class extends ps {
|
|
|
39630
39630
|
), 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(), (i = this.soundManager) == null || i.destroy(), this.soundManager = null;
|
|
39631
39631
|
}
|
|
39632
39632
|
firstUpdated() {
|
|
39633
|
-
this.initializeOrb();
|
|
39633
|
+
this.applyTheme(), this.initializeOrb();
|
|
39634
39634
|
}
|
|
39635
39635
|
updated(i) {
|
|
39636
39636
|
var e, t;
|
|
39637
|
-
super.updated(i), i.has("agentId") && (this.callManager.hangUp(), this.callStatus = "idle"), i.has("voiceServiceUrl") && this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), i.has("soundEnabled") && ((e = this.soundManager) == null || e.setEnabled(this.soundEnabled)), i.has("soundVolume") && ((t = this.soundManager) == null || t.setVolume(this.soundVolume));
|
|
39637
|
+
super.updated(i), i.has("agentId") && (this.callManager.hangUp(), this.callStatus = "idle"), i.has("voiceServiceUrl") && this.voiceServiceUrl && (this.callManager.serviceUrl = this.voiceServiceUrl), (i.has("theme") || i.has("themeMode")) && this.applyTheme(), i.has("soundEnabled") && ((e = this.soundManager) == null || e.setEnabled(this.soundEnabled)), i.has("soundVolume") && ((t = this.soundManager) == null || t.setVolume(this.soundVolume));
|
|
39638
|
+
}
|
|
39639
|
+
applyTheme() {
|
|
39640
|
+
if (this.theme) {
|
|
39641
|
+
const i = _o(this.theme, this.themeMode);
|
|
39642
|
+
this.orbColors = i.colors, this.glowIntensity = i.glowIntensity, this.idleGlowMultiplier = i.idleGlowMultiplier, this.orbRenderer && (this.orbRenderer.setColors(this.orbColors), this.orbRenderer.setGlowSettings(this.glowIntensity, this.idleGlowMultiplier));
|
|
39643
|
+
}
|
|
39638
39644
|
}
|
|
39639
39645
|
initializeOrb() {
|
|
39640
39646
|
const i = this.orbContainerRef.value;
|
|
@@ -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{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;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(a=this.orbRenderer)==null||a.setActive(!1),(o=this.audioAnalyzer)==null||o.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;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(a=this.orbRenderer)==null||a.setActive(!1),(o=this.audioAnalyzer)==null||o.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(){super.connectedCallback(),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.applyTheme(),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("theme")||e.has("themeMode"))&&this.applyTheme(),e.has("soundEnabled")&&((t=this.soundManager)==null||t.setEnabled(this.soundEnabled)),e.has("soundVolume")&&((n=this.soundManager)==null||n.setVolume(this.soundVolume))}applyTheme(){if(this.theme){const e=Jr(this.theme,this.themeMode);this.orbColors=e.colors,this.glowIntensity=e.glowIntensity,this.idleGlowMultiplier=e.idleGlowMultiplier,this.orbRenderer&&(this.orbRenderer.setColors(this.orbColors),this.orbRenderer.setGlowSettings(this.glowIntensity,this.idleGlowMultiplier))}}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"
|
|
@@ -4750,7 +4750,7 @@ void main() {
|
|
|
4750
4750
|
display: inline-block;
|
|
4751
4751
|
contain: layout style;
|
|
4752
4752
|
}
|
|
4753
|
-
`,St([xe({type:String,attribute:"agent-id"})],te.InlineCall.prototype,"agentId",2),St([xe({type:String,attribute:"voice-service-url"})],te.InlineCall.prototype,"voiceServiceUrl",2),St([Es()],te.InlineCall.prototype,"callStatus",2),St([Es()],te.InlineCall.prototype,"microphoneEnabled",2),St([xe({type:String,attribute:"button-start-text"})],te.InlineCall.prototype,"buttonStartText",2),St([xe({type:String,attribute:"button-connecting-text"})],te.InlineCall.prototype,"buttonConnectingText",2),St([xe({type:Number,attribute:"size"})],te.InlineCall.prototype,"size",2),St([xe({type:Number,attribute:"container-padding"})],te.InlineCall.prototype,"containerPadding",2),St([xe({type:String,attribute:"theme"})],te.InlineCall.prototype,"theme",2),St([xe({type:String,attribute:"theme-mode"})],te.InlineCall.prototype,"themeMode",2),St([xe({type:Object,attribute:"orb-colors"})],te.InlineCall.prototype,"orbColors",2),St([xe({type:Number,attribute:"glow-intensity"})],te.InlineCall.prototype,"glowIntensity",2),St([xe({type:Number,attribute:"idle-glow-multiplier"})],te.InlineCall.prototype,"idleGlowMultiplier",2),St([xe({type:Number,attribute:"morph-strength"})],te.InlineCall.prototype,"morphStrength",2),St([xe({type:Number,attribute:"noise-scale"})],te.InlineCall.prototype,"noiseScale",2),St([xe({type:Number,attribute:"noise-speed"})],te.InlineCall.prototype,"noiseSpeed",2),St([xe({type:Number,attribute:"fresnel-power"})],te.InlineCall.prototype,"fresnelPower",2),St([xe({type:Number,attribute:"rotation-speed"})],te.InlineCall.prototype,"rotationSpeed",2),St([xe({type:Number,attribute:"audio-reactivity"})],te.InlineCall.prototype,"audioReactivity",2),St([xe({type:Number,attribute:"audio-smoothing"})],te.InlineCall.prototype,"audioSmoothing",2),St([xe({type:Number,attribute:"idle-morph-multiplier"})],te.InlineCall.prototype,"idleMorphMultiplier",2),St([xe({type:Number,attribute:"color-contrast"})],te.InlineCall.prototype,"colorContrast",2),St([xe({type:Boolean,attribute:"sound-enabled"})],te.InlineCall.prototype,"soundEnabled",2),St([xe({type:Number,attribute:"sound-volume"})],te.InlineCall.prototype,"soundVolume",2),te.InlineCall=St([wo("hanc-ai-inline-call")],te.InlineCall);var WC=Object.defineProperty,qC=Object.getOwnPropertyDescriptor,xt=(i,e,t,n)=>{for(var s=n>1?void 0:n?qC(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&&WC(e,t,s),s};te.FloatingCall=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="Call",this.buttonConnectingText="Connecting...",this.position="bottom-right",this.size=120,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;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(a=this.orbRenderer)==null||a.setActive(!1),(o=this.audioAnalyzer)==null||o.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(){
|
|
4753
|
+
`,St([xe({type:String,attribute:"agent-id"})],te.InlineCall.prototype,"agentId",2),St([xe({type:String,attribute:"voice-service-url"})],te.InlineCall.prototype,"voiceServiceUrl",2),St([Es()],te.InlineCall.prototype,"callStatus",2),St([Es()],te.InlineCall.prototype,"microphoneEnabled",2),St([xe({type:String,attribute:"button-start-text"})],te.InlineCall.prototype,"buttonStartText",2),St([xe({type:String,attribute:"button-connecting-text"})],te.InlineCall.prototype,"buttonConnectingText",2),St([xe({type:Number,attribute:"size"})],te.InlineCall.prototype,"size",2),St([xe({type:Number,attribute:"container-padding"})],te.InlineCall.prototype,"containerPadding",2),St([xe({type:String,attribute:"theme",reflect:!0})],te.InlineCall.prototype,"theme",2),St([xe({type:String,attribute:"theme-mode"})],te.InlineCall.prototype,"themeMode",2),St([xe({type:Object,attribute:"orb-colors"})],te.InlineCall.prototype,"orbColors",2),St([xe({type:Number,attribute:"glow-intensity"})],te.InlineCall.prototype,"glowIntensity",2),St([xe({type:Number,attribute:"idle-glow-multiplier"})],te.InlineCall.prototype,"idleGlowMultiplier",2),St([xe({type:Number,attribute:"morph-strength"})],te.InlineCall.prototype,"morphStrength",2),St([xe({type:Number,attribute:"noise-scale"})],te.InlineCall.prototype,"noiseScale",2),St([xe({type:Number,attribute:"noise-speed"})],te.InlineCall.prototype,"noiseSpeed",2),St([xe({type:Number,attribute:"fresnel-power"})],te.InlineCall.prototype,"fresnelPower",2),St([xe({type:Number,attribute:"rotation-speed"})],te.InlineCall.prototype,"rotationSpeed",2),St([xe({type:Number,attribute:"audio-reactivity"})],te.InlineCall.prototype,"audioReactivity",2),St([xe({type:Number,attribute:"audio-smoothing"})],te.InlineCall.prototype,"audioSmoothing",2),St([xe({type:Number,attribute:"idle-morph-multiplier"})],te.InlineCall.prototype,"idleMorphMultiplier",2),St([xe({type:Number,attribute:"color-contrast"})],te.InlineCall.prototype,"colorContrast",2),St([xe({type:Boolean,attribute:"sound-enabled"})],te.InlineCall.prototype,"soundEnabled",2),St([xe({type:Number,attribute:"sound-volume"})],te.InlineCall.prototype,"soundVolume",2),te.InlineCall=St([wo("hanc-ai-inline-call")],te.InlineCall);var WC=Object.defineProperty,qC=Object.getOwnPropertyDescriptor,xt=(i,e,t,n)=>{for(var s=n>1?void 0:n?qC(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&&WC(e,t,s),s};te.FloatingCall=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="Call",this.buttonConnectingText="Connecting...",this.position="bottom-right",this.size=120,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;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(a=this.orbRenderer)==null||a.setActive(!1),(o=this.audioAnalyzer)==null||o.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(){super.connectedCallback(),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.applyTheme(),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("theme")||e.has("themeMode"))&&this.applyTheme(),e.has("soundEnabled")&&((t=this.soundManager)==null||t.setEnabled(this.soundEnabled)),e.has("soundVolume")&&((n=this.soundManager)==null||n.setVolume(this.soundVolume))}applyTheme(){if(this.theme){const e=Jr(this.theme,this.themeMode);this.orbColors=e.colors,this.glowIntensity=e.glowIntensity,this.idleGlowMultiplier=e.idleGlowMultiplier,this.orbRenderer&&(this.orbRenderer.setColors(this.orbColors),this.orbRenderer.setGlowSettings(this.glowIntensity,this.idleGlowMultiplier))}}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`
|
|
4754
4754
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" class="hanc-spinner">
|
|
4755
4755
|
<circle
|
|
4756
4756
|
cx="8"
|
|
@@ -5017,7 +5017,7 @@ void main() {
|
|
|
5017
5017
|
:host {
|
|
5018
5018
|
display: block;
|
|
5019
5019
|
}
|
|
5020
|
-
`,xt([xe({type:String,attribute:"agent-id"})],te.FloatingCall.prototype,"agentId",2),xt([xe({type:String,attribute:"voice-service-url"})],te.FloatingCall.prototype,"voiceServiceUrl",2),xt([Es()],te.FloatingCall.prototype,"callStatus",2),xt([Es()],te.FloatingCall.prototype,"microphoneEnabled",2),xt([xe({type:String,attribute:"button-start-text"})],te.FloatingCall.prototype,"buttonStartText",2),xt([xe({type:String,attribute:"button-connecting-text"})],te.FloatingCall.prototype,"buttonConnectingText",2),xt([xe({type:String,attribute:"position"})],te.FloatingCall.prototype,"position",2),xt([xe({type:Number,attribute:"size"})],te.FloatingCall.prototype,"size",2),xt([xe({type:String,attribute:"theme"})],te.FloatingCall.prototype,"theme",2),xt([xe({type:String,attribute:"theme-mode"})],te.FloatingCall.prototype,"themeMode",2),xt([xe({type:Object,attribute:"orb-colors"})],te.FloatingCall.prototype,"orbColors",2),xt([xe({type:Number,attribute:"glow-intensity"})],te.FloatingCall.prototype,"glowIntensity",2),xt([xe({type:Number,attribute:"idle-glow-multiplier"})],te.FloatingCall.prototype,"idleGlowMultiplier",2),xt([xe({type:Number,attribute:"morph-strength"})],te.FloatingCall.prototype,"morphStrength",2),xt([xe({type:Number,attribute:"noise-scale"})],te.FloatingCall.prototype,"noiseScale",2),xt([xe({type:Number,attribute:"noise-speed"})],te.FloatingCall.prototype,"noiseSpeed",2),xt([xe({type:Number,attribute:"fresnel-power"})],te.FloatingCall.prototype,"fresnelPower",2),xt([xe({type:Number,attribute:"rotation-speed"})],te.FloatingCall.prototype,"rotationSpeed",2),xt([xe({type:Number,attribute:"audio-reactivity"})],te.FloatingCall.prototype,"audioReactivity",2),xt([xe({type:Number,attribute:"audio-smoothing"})],te.FloatingCall.prototype,"audioSmoothing",2),xt([xe({type:Number,attribute:"idle-morph-multiplier"})],te.FloatingCall.prototype,"idleMorphMultiplier",2),xt([xe({type:Number,attribute:"color-contrast"})],te.FloatingCall.prototype,"colorContrast",2),xt([xe({type:Boolean,attribute:"sound-enabled"})],te.FloatingCall.prototype,"soundEnabled",2),xt([xe({type:Number,attribute:"sound-volume"})],te.FloatingCall.prototype,"soundVolume",2),te.FloatingCall=xt([wo("hanc-ai-floating-call")],te.FloatingCall);var jC=Object.defineProperty,$C=Object.getOwnPropertyDescriptor,Tt=(i,e,t,n)=>{for(var s=n>1?void 0:n?$C(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&&jC(e,t,s),s};te.PillCall=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="Talk to AI Agent",this.buttonConnectingText="Connecting...",this.buttonEndText="End call",this.orbSize=48,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;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(a=this.orbRenderer)==null||a.setActive(!1),(o=this.audioAnalyzer)==null||o.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(){
|
|
5020
|
+
`,xt([xe({type:String,attribute:"agent-id"})],te.FloatingCall.prototype,"agentId",2),xt([xe({type:String,attribute:"voice-service-url"})],te.FloatingCall.prototype,"voiceServiceUrl",2),xt([Es()],te.FloatingCall.prototype,"callStatus",2),xt([Es()],te.FloatingCall.prototype,"microphoneEnabled",2),xt([xe({type:String,attribute:"button-start-text"})],te.FloatingCall.prototype,"buttonStartText",2),xt([xe({type:String,attribute:"button-connecting-text"})],te.FloatingCall.prototype,"buttonConnectingText",2),xt([xe({type:String,attribute:"position"})],te.FloatingCall.prototype,"position",2),xt([xe({type:Number,attribute:"size"})],te.FloatingCall.prototype,"size",2),xt([xe({type:String,attribute:"theme"})],te.FloatingCall.prototype,"theme",2),xt([xe({type:String,attribute:"theme-mode"})],te.FloatingCall.prototype,"themeMode",2),xt([xe({type:Object,attribute:"orb-colors"})],te.FloatingCall.prototype,"orbColors",2),xt([xe({type:Number,attribute:"glow-intensity"})],te.FloatingCall.prototype,"glowIntensity",2),xt([xe({type:Number,attribute:"idle-glow-multiplier"})],te.FloatingCall.prototype,"idleGlowMultiplier",2),xt([xe({type:Number,attribute:"morph-strength"})],te.FloatingCall.prototype,"morphStrength",2),xt([xe({type:Number,attribute:"noise-scale"})],te.FloatingCall.prototype,"noiseScale",2),xt([xe({type:Number,attribute:"noise-speed"})],te.FloatingCall.prototype,"noiseSpeed",2),xt([xe({type:Number,attribute:"fresnel-power"})],te.FloatingCall.prototype,"fresnelPower",2),xt([xe({type:Number,attribute:"rotation-speed"})],te.FloatingCall.prototype,"rotationSpeed",2),xt([xe({type:Number,attribute:"audio-reactivity"})],te.FloatingCall.prototype,"audioReactivity",2),xt([xe({type:Number,attribute:"audio-smoothing"})],te.FloatingCall.prototype,"audioSmoothing",2),xt([xe({type:Number,attribute:"idle-morph-multiplier"})],te.FloatingCall.prototype,"idleMorphMultiplier",2),xt([xe({type:Number,attribute:"color-contrast"})],te.FloatingCall.prototype,"colorContrast",2),xt([xe({type:Boolean,attribute:"sound-enabled"})],te.FloatingCall.prototype,"soundEnabled",2),xt([xe({type:Number,attribute:"sound-volume"})],te.FloatingCall.prototype,"soundVolume",2),te.FloatingCall=xt([wo("hanc-ai-floating-call")],te.FloatingCall);var jC=Object.defineProperty,$C=Object.getOwnPropertyDescriptor,Tt=(i,e,t,n)=>{for(var s=n>1?void 0:n?$C(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&&jC(e,t,s),s};te.PillCall=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="Talk to AI Agent",this.buttonConnectingText="Connecting...",this.buttonEndText="End call",this.orbSize=48,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;switch(e.detail){case"connecting":this.callStatus="connecting";break;case"connected":this.callStatus="connected",(n=this.orbRenderer)==null||n.setActive(!0),this.startRealAudioLoop(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallStartSound()},300),this.dispatchEvent(new Event("call-start",{bubbles:!0,composed:!0}));break;case"disconnected":this.callStatus="idle",(s=this.orbRenderer)==null||s.setActive(!1),(r=this.audioAnalyzer)==null||r.disconnect(),this.startIdleAnimation(),setTimeout(()=>{var c;(c=this.soundManager)==null||c.playCallEndSound()},150),this.dispatchEvent(new Event("call-end",{bubbles:!0,composed:!0}));break;case"error":this.callStatus="error",(a=this.orbRenderer)==null||a.setActive(!1),(o=this.audioAnalyzer)==null||o.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(){super.connectedCallback(),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.applyTheme(),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("theme")||e.has("themeMode"))&&this.applyTheme(),e.has("soundEnabled")&&((t=this.soundManager)==null||t.setEnabled(this.soundEnabled)),e.has("soundVolume")&&((n=this.soundManager)==null||n.setVolume(this.soundVolume))}applyTheme(){if(this.theme){const e=Jr(this.theme,this.themeMode);this.orbColors=e.colors,this.glowIntensity=e.glowIntensity,this.idleGlowMultiplier=e.idleGlowMultiplier,this.orbRenderer&&(this.orbRenderer.setColors(this.orbColors),this.orbRenderer.setGlowSettings(this.glowIntensity,this.idleGlowMultiplier))}}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`
|
|
5021
5021
|
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" class="hanc-spinner">
|
|
5022
5022
|
<circle
|
|
5023
5023
|
cx="8"
|
|
@@ -36,6 +36,7 @@ export declare class FloatingCall extends LitElement {
|
|
|
36
36
|
disconnectedCallback(): void;
|
|
37
37
|
firstUpdated(): void;
|
|
38
38
|
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
39
|
+
private applyTheme;
|
|
39
40
|
private initializeOrb;
|
|
40
41
|
private cleanupOrb;
|
|
41
42
|
private startIdleAnimation;
|
|
@@ -36,6 +36,7 @@ export declare class InlineCall extends LitElement {
|
|
|
36
36
|
disconnectedCallback(): void;
|
|
37
37
|
firstUpdated(): void;
|
|
38
38
|
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
39
|
+
private applyTheme;
|
|
39
40
|
private initializeOrb;
|
|
40
41
|
private cleanupOrb;
|
|
41
42
|
private startIdleAnimation;
|
|
@@ -36,6 +36,7 @@ export declare class PillCall extends LitElement {
|
|
|
36
36
|
disconnectedCallback(): void;
|
|
37
37
|
firstUpdated(): void;
|
|
38
38
|
updated(changedProperties: Map<string | number | symbol, unknown>): void;
|
|
39
|
+
private applyTheme;
|
|
39
40
|
private initializeOrb;
|
|
40
41
|
private cleanupOrb;
|
|
41
42
|
private startIdleAnimation;
|