@w0nna_dev/lina-widget 1.1.2 → 1.2.1

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.
@@ -8746,7 +8746,7 @@ function Ky(i) {
8746
8746
  value: i.value
8747
8747
  });
8748
8748
  }
8749
- class fw extends hi.EventEmitter {
8749
+ class gw extends hi.EventEmitter {
8750
8750
  constructor() {
8751
8751
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
8752
8752
  super(), this.onKeyRatcheted = (t, n, s) => {
@@ -17878,7 +17878,7 @@ class h_ extends os {
17878
17878
  });
17879
17879
  }
17880
17880
  }
17881
- class pw extends hi.EventEmitter {
17881
+ class vw extends hi.EventEmitter {
17882
17882
  constructor(e, t) {
17883
17883
  let n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
17884
17884
  super(), this.options = {}, this.checkResults = /* @__PURE__ */ new Map(), this.url = e, this.token = t, this.options = n;
@@ -39693,13 +39693,28 @@ class bu {
39693
39693
  return this.analyser;
39694
39694
  }
39695
39695
  }
39696
- class _u {
39696
+ const JM = "/sounds/pop-connect.mp3", ZM = "/sounds/pop-disconnect.mp3";
39697
+ let _u = class {
39697
39698
  constructor(e = {}) {
39698
- this.audioContext = null, this.config = {
39699
+ this.audioContext = null, this.connectAudio = null, this.disconnectAudio = null, this.config = {
39699
39700
  enabled: !0,
39700
- volume: 0.15,
39701
+ volume: 0.5,
39701
39702
  ...e
39702
- };
39703
+ }, this.preloadAudio();
39704
+ }
39705
+ /**
39706
+ * Preload audio files for instant playback
39707
+ */
39708
+ preloadAudio() {
39709
+ try {
39710
+ this.connectAudio = new Audio(this.config.connectSoundUrl || JM), this.connectAudio.preload = "auto", this.connectAudio.volume = this.config.volume, this.disconnectAudio = new Audio(this.config.disconnectSoundUrl || ZM), this.disconnectAudio.preload = "auto", this.disconnectAudio.volume = this.config.volume, this.connectAudio.addEventListener("error", () => {
39711
+ console.warn("Failed to load connect sound, will use synthesized fallback");
39712
+ }), this.disconnectAudio.addEventListener("error", () => {
39713
+ console.warn("Failed to load disconnect sound, will use synthesized fallback");
39714
+ });
39715
+ } catch (e) {
39716
+ console.warn("Failed to preload audio:", e);
39717
+ }
39703
39718
  }
39704
39719
  /**
39705
39720
  * Initialize audio context (must be called from user interaction)
@@ -39722,7 +39737,18 @@ class _u {
39722
39737
  await this.ensureContext();
39723
39738
  }
39724
39739
  /**
39725
- * Create an oscillator with envelope
39740
+ * Play MP3 audio element
39741
+ */
39742
+ async playAudioElement(e) {
39743
+ if (!e || !this.config.enabled) return !1;
39744
+ try {
39745
+ return e.currentTime = 0, e.volume = this.config.volume, await e.play(), !0;
39746
+ } catch (t) {
39747
+ return console.warn("Failed to play audio:", t), !1;
39748
+ }
39749
+ }
39750
+ /**
39751
+ * Create a synthesized tone (fallback)
39726
39752
  */
39727
39753
  createTone(e, t, n, s, r = "sine") {
39728
39754
  const o = e.createOscillator(), a = e.createGain();
@@ -39731,10 +39757,9 @@ class _u {
39731
39757
  return a.gain.setValueAtTime(0, n), a.gain.linearRampToValueAtTime(this.config.volume, n + c), a.gain.linearRampToValueAtTime(this.config.volume * d, n + c + l), a.gain.setValueAtTime(this.config.volume * d, n + s - u), a.gain.linearRampToValueAtTime(0, n + s), o.connect(a), { oscillator: o, gain: a };
39732
39758
  }
39733
39759
  /**
39734
- * Play pleasant notification sound for call start
39735
- * Two-tone ascending melody like messenger notifications
39760
+ * Synthesized fallback for call start sound
39736
39761
  */
39737
- async playCallStartSound() {
39762
+ async playSynthesizedStartSound() {
39738
39763
  const e = await this.ensureContext();
39739
39764
  if (!e || typeof e.createGain != "function") return;
39740
39765
  const t = e.currentTime, n = e.createGain();
@@ -39754,10 +39779,9 @@ class _u {
39754
39779
  }, 300);
39755
39780
  }
39756
39781
  /**
39757
- * Play gentle descending sound for call end
39758
- * Single soft tone
39782
+ * Synthesized fallback for call end sound
39759
39783
  */
39760
- async playCallEndSound() {
39784
+ async playSynthesizedEndSound() {
39761
39785
  const e = await this.ensureContext();
39762
39786
  if (!e || typeof e.createGain != "function") return;
39763
39787
  const t = e.currentTime, n = e.createGain();
@@ -39770,11 +39794,25 @@ class _u {
39770
39794
  }
39771
39795
  }, 250);
39772
39796
  }
39797
+ /**
39798
+ * Play call start sound (MP3 with synthesized fallback)
39799
+ */
39800
+ async playCallStartSound() {
39801
+ if (!this.config.enabled) return;
39802
+ await this.playAudioElement(this.connectAudio) || await this.playSynthesizedStartSound();
39803
+ }
39804
+ /**
39805
+ * Play call end sound (MP3 with synthesized fallback)
39806
+ */
39807
+ async playCallEndSound() {
39808
+ if (!this.config.enabled) return;
39809
+ await this.playAudioElement(this.disconnectAudio) || await this.playSynthesizedEndSound();
39810
+ }
39773
39811
  /**
39774
39812
  * Update configuration
39775
39813
  */
39776
39814
  setConfig(e) {
39777
- this.config = { ...this.config, ...e };
39815
+ this.config = { ...this.config, ...e }, this.connectAudio && (this.connectAudio.volume = this.config.volume), this.disconnectAudio && (this.disconnectAudio.volume = this.config.volume);
39778
39816
  }
39779
39817
  /**
39780
39818
  * Enable or disable sounds
@@ -39786,7 +39824,7 @@ class _u {
39786
39824
  * Set volume (0.0 - 1.0)
39787
39825
  */
39788
39826
  setVolume(e) {
39789
- this.config.volume = Math.max(0, Math.min(1, e));
39827
+ this.config.volume = Math.max(0, Math.min(1, e)), this.connectAudio && (this.connectAudio.volume = this.config.volume), this.disconnectAudio && (this.disconnectAudio.volume = this.config.volume);
39790
39828
  }
39791
39829
  /**
39792
39830
  * Get current config
@@ -39804,9 +39842,9 @@ class _u {
39804
39842
  * Cleanup
39805
39843
  */
39806
39844
  destroy() {
39807
- this.audioContext && (this.audioContext.close(), this.audioContext = null);
39845
+ this.audioContext && (this.audioContext.close(), this.audioContext = null), this.connectAudio && (this.connectAudio.pause(), this.connectAudio.src = "", this.connectAudio = null), this.disconnectAudio && (this.disconnectAudio.pause(), this.disconnectAudio.src = "", this.disconnectAudio = null);
39808
39846
  }
39809
- }
39847
+ };
39810
39848
  const Si = {
39811
39849
  default: {
39812
39850
  primary: "#6366f1",
@@ -39953,11 +39991,11 @@ const Si = {
39953
39991
  // Light pink
39954
39992
  }
39955
39993
  };
39956
- function mw(i, e = "dark") {
39994
+ function bw(i, e = "dark") {
39957
39995
  const t = e === "dark" ? Si : xi;
39958
39996
  return t[i] || t[Object.keys(t)[0]];
39959
39997
  }
39960
- function gw(i = "dark") {
39998
+ function _w(i = "dark") {
39961
39999
  return Object.keys(i === "dark" ? Si : xi);
39962
40000
  }
39963
40001
  const da = {
@@ -40045,41 +40083,41 @@ const da = {
40045
40083
  idleGlowMultiplier: 1.2
40046
40084
  }
40047
40085
  }
40048
- }, vw = Object.fromEntries(
40086
+ }, Sw = Object.fromEntries(
40049
40087
  Object.entries(da).map(([i, e]) => [i, e.dark])
40050
- ), yw = Object.fromEntries(
40088
+ ), xw = Object.fromEntries(
40051
40089
  Object.entries(da).map(([i, e]) => [i, e.light])
40052
40090
  );
40053
- function JM() {
40091
+ function QM() {
40054
40092
  return typeof window > "u" || window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
40055
40093
  }
40056
40094
  function Jo(i, e = "auto") {
40057
- const t = da[i] || da.default, n = e === "auto" ? JM() : e;
40095
+ const t = da[i] || da.default, n = e === "auto" ? QM() : e;
40058
40096
  return t[n];
40059
40097
  }
40060
- function bw() {
40098
+ function Tw() {
40061
40099
  return Object.keys(da);
40062
40100
  }
40063
- function ZM(i, e, t = "auto") {
40101
+ function ew(i, e, t = "auto") {
40064
40102
  const n = Jo(e, t);
40065
40103
  i.orbColors = n.colors, i.glowIntensity = n.glowIntensity, i.idleGlowMultiplier = n.idleGlowMultiplier;
40066
40104
  }
40067
- function _w(i, e) {
40105
+ function Cw(i, e) {
40068
40106
  if (typeof window > "u")
40069
40107
  return () => {
40070
40108
  };
40071
40109
  const t = window.matchMedia("(prefers-color-scheme: dark)"), n = () => {
40072
40110
  const s = t.matches ? "dark" : "light";
40073
- ZM(i, e, s);
40111
+ ew(i, e, s);
40074
40112
  };
40075
40113
  return n(), t.addEventListener("change", n), () => {
40076
40114
  t.removeEventListener("change", n);
40077
40115
  };
40078
40116
  }
40079
- var QM = Object.defineProperty, ew = Object.getOwnPropertyDescriptor, Mt = (i, e, t, n) => {
40080
- for (var s = n > 1 ? void 0 : n ? ew(e, t) : e, r = i.length - 1, o; r >= 0; r--)
40117
+ var tw = Object.defineProperty, nw = Object.getOwnPropertyDescriptor, Mt = (i, e, t, n) => {
40118
+ for (var s = n > 1 ? void 0 : n ? nw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
40081
40119
  (o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
40082
- return n && s && QM(e, t, s), s;
40120
+ return n && s && tw(e, t, s), s;
40083
40121
  };
40084
40122
  let bt = class extends es {
40085
40123
  constructor() {
@@ -40590,10 +40628,10 @@ Mt([
40590
40628
  bt = Mt([
40591
40629
  Lo("hanc-ai-inline-call")
40592
40630
  ], bt);
40593
- var tw = Object.defineProperty, nw = Object.getOwnPropertyDescriptor, wt = (i, e, t, n) => {
40594
- for (var s = n > 1 ? void 0 : n ? nw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
40631
+ var iw = Object.defineProperty, sw = Object.getOwnPropertyDescriptor, wt = (i, e, t, n) => {
40632
+ for (var s = n > 1 ? void 0 : n ? sw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
40595
40633
  (o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
40596
- return n && s && tw(e, t, s), s;
40634
+ return n && s && iw(e, t, s), s;
40597
40635
  };
40598
40636
  let _t = class extends es {
40599
40637
  constructor() {
@@ -41088,10 +41126,10 @@ wt([
41088
41126
  _t = wt([
41089
41127
  Lo("hanc-ai-floating-call")
41090
41128
  ], _t);
41091
- var iw = Object.defineProperty, sw = Object.getOwnPropertyDescriptor, At = (i, e, t, n) => {
41092
- for (var s = n > 1 ? void 0 : n ? sw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
41129
+ var rw = Object.defineProperty, aw = Object.getOwnPropertyDescriptor, At = (i, e, t, n) => {
41130
+ for (var s = n > 1 ? void 0 : n ? aw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
41093
41131
  (o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
41094
- return n && s && iw(e, t, s), s;
41132
+ return n && s && rw(e, t, s), s;
41095
41133
  };
41096
41134
  let St = class extends es {
41097
41135
  constructor() {
@@ -41508,7 +41546,7 @@ At([
41508
41546
  St = At([
41509
41547
  Lo("hanc-ai-pill-call")
41510
41548
  ], St);
41511
- const rw = {
41549
+ const ow = {
41512
41550
  core: "#ffffff",
41513
41551
  coreGlow: "#a855f7",
41514
41552
  lightning: "#c084fc",
@@ -41567,7 +41605,7 @@ const rw = {
41567
41605
  coreScale: 1
41568
41606
  }
41569
41607
  };
41570
- class aw {
41608
+ class cw {
41571
41609
  constructor(e, t = {}) {
41572
41610
  this.shellSegments = [], this.coreInner = null, this.coreOuter = null, this.coreGlow = null, this.pulseRings = [], this.particles = null, this.particlePositions = null, this.particleVelocities = null, this.animationId = null, this._currentState = "idle", this._currentEmotion = "neutral", this.targetConfig = { ...rl.idle }, this.currentConfig = { ...rl.idle }, this.targetAudioLevel = 0, this.currentAudioLevel = 0, this.audioVelocity = 0, this.targetPulseColor = new Ue("#a855f7"), this.currentPulseColor = new Ue("#a855f7"), this.targetRotation = { x: 0, y: 0 }, this.currentRotation = { x: 0, y: 0 }, this.time = 0, this.animate = () => {
41573
41611
  this.animationId = requestAnimationFrame(this.animate);
@@ -41617,7 +41655,7 @@ class aw {
41617
41655
  shellSegments: t.shellSegments ?? 6,
41618
41656
  colors: t.colors ?? {},
41619
41657
  canvasPadding: t.canvasPadding ?? 2
41620
- }, this.colors = { ...rw, ...t.colors }, this.clock = new vg(), this.initScene(), this.createShell(), this.createCore(), this.createParticles(), window.addEventListener("resize", this.handleResize), e.addEventListener("mousemove", this.handleMouseMove), e.addEventListener("mouseleave", this.handleMouseLeave);
41658
+ }, this.colors = { ...ow, ...t.colors }, this.clock = new vg(), this.initScene(), this.createShell(), this.createCore(), this.createParticles(), window.addEventListener("resize", this.handleResize), e.addEventListener("mousemove", this.handleMouseMove), e.addEventListener("mouseleave", this.handleMouseLeave);
41621
41659
  }
41622
41660
  initScene() {
41623
41661
  this.scene = new pg();
@@ -42173,14 +42211,172 @@ class aw {
42173
42211
  this.pulseRings = [], this.particles && (this.particles.geometry.dispose(), this.particles.material.dispose()), this.renderer.dispose(), this.renderer.domElement.parentNode && this.renderer.domElement.parentNode.removeChild(this.renderer.domElement);
42174
42212
  }
42175
42213
  }
42176
- var ow = Object.defineProperty, cw = Object.getOwnPropertyDescriptor, jt = (i, e, t, n) => {
42177
- for (var s = n > 1 ? void 0 : n ? cw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
42214
+ class lw {
42215
+ constructor(e = {}) {
42216
+ this.audioContext = null, this.config = {
42217
+ enabled: !0,
42218
+ volume: 0.3,
42219
+ ...e
42220
+ };
42221
+ }
42222
+ /**
42223
+ * Initialize audio context (must be called from user interaction)
42224
+ */
42225
+ async ensureContext() {
42226
+ if (!this.config.enabled) return null;
42227
+ if (!this.audioContext)
42228
+ try {
42229
+ this.audioContext = new (window.AudioContext || window.webkitAudioContext)();
42230
+ } catch {
42231
+ return console.warn("Web Audio API not supported"), null;
42232
+ }
42233
+ return this.audioContext.state === "suspended" && await this.audioContext.resume(), this.audioContext;
42234
+ }
42235
+ /**
42236
+ * Create an oscillator with envelope
42237
+ */
42238
+ createTone(e, t, n, s, r = "sine") {
42239
+ const o = e.createOscillator(), a = e.createGain();
42240
+ o.type = r, o.frequency.setValueAtTime(t, n);
42241
+ const c = 0.05, l = 0.1, d = 0.7, u = 0.3;
42242
+ return a.gain.setValueAtTime(0, n), a.gain.linearRampToValueAtTime(this.config.volume, n + c), a.gain.linearRampToValueAtTime(this.config.volume * d, n + c + l), a.gain.setValueAtTime(this.config.volume * d, n + s - u), a.gain.linearRampToValueAtTime(0, n + s), o.connect(a), { oscillator: o, gain: a };
42243
+ }
42244
+ /**
42245
+ * Play ascending melodic sound for call start
42246
+ * C4 → E4 → G4 (C major chord arpeggio)
42247
+ */
42248
+ async playCallStartSound() {
42249
+ const e = await this.ensureContext();
42250
+ if (!e || typeof e.createGain != "function") return;
42251
+ const t = e.currentTime, n = e.createGain();
42252
+ n.gain.setValueAtTime(1, t), n.connect(e.destination);
42253
+ const s = [
42254
+ { freq: 261.63, start: 0, duration: 0.5 },
42255
+ // C4
42256
+ { freq: 329.63, start: 0.15, duration: 0.5 },
42257
+ // E4
42258
+ { freq: 392, start: 0.3, duration: 0.6 },
42259
+ // G4
42260
+ { freq: 523.25, start: 0.5, duration: 0.8 }
42261
+ // C5 (octave up)
42262
+ ], r = [];
42263
+ s.forEach((o) => {
42264
+ const { oscillator: a, gain: c } = this.createTone(
42265
+ e,
42266
+ o.freq,
42267
+ t + o.start,
42268
+ o.duration,
42269
+ "sine"
42270
+ );
42271
+ c.connect(n), a.start(t + o.start), a.stop(t + o.start + o.duration), r.push(a);
42272
+ const { oscillator: l, gain: d } = this.createTone(
42273
+ e,
42274
+ o.freq * 2,
42275
+ // Octave up
42276
+ t + o.start,
42277
+ o.duration,
42278
+ "triangle"
42279
+ );
42280
+ d.gain.setValueAtTime(d.gain.value * 0.3, t), d.connect(n), l.start(t + o.start), l.stop(t + o.start + o.duration), r.push(l);
42281
+ }), setTimeout(() => {
42282
+ r.forEach((o) => {
42283
+ try {
42284
+ o.disconnect();
42285
+ } catch {
42286
+ }
42287
+ });
42288
+ }, 2e3);
42289
+ }
42290
+ /**
42291
+ * Play descending melodic sound for call end
42292
+ * G4 → E4 → C4 (descending C major arpeggio)
42293
+ */
42294
+ async playCallEndSound() {
42295
+ const e = await this.ensureContext();
42296
+ if (!e || typeof e.createGain != "function") return;
42297
+ const t = e.currentTime, n = e.createGain();
42298
+ n.gain.setValueAtTime(1, t), n.connect(e.destination);
42299
+ const s = [
42300
+ { freq: 523.25, start: 0, duration: 0.4 },
42301
+ // C5
42302
+ { freq: 392, start: 0.12, duration: 0.4 },
42303
+ // G4
42304
+ { freq: 329.63, start: 0.24, duration: 0.5 },
42305
+ // E4
42306
+ { freq: 261.63, start: 0.4, duration: 0.7 }
42307
+ // C4
42308
+ ], r = [];
42309
+ s.forEach((o) => {
42310
+ const { oscillator: a, gain: c } = this.createTone(
42311
+ e,
42312
+ o.freq,
42313
+ t + o.start,
42314
+ o.duration,
42315
+ "sine"
42316
+ );
42317
+ c.connect(n), a.start(t + o.start), a.stop(t + o.start + o.duration), r.push(a);
42318
+ const { oscillator: l, gain: d } = this.createTone(
42319
+ e,
42320
+ o.freq * 2,
42321
+ t + o.start,
42322
+ o.duration,
42323
+ "triangle"
42324
+ );
42325
+ d.gain.setValueAtTime(d.gain.value * 0.25, t), d.connect(n), l.start(t + o.start), l.stop(t + o.start + o.duration), r.push(l);
42326
+ }), setTimeout(() => {
42327
+ r.forEach((o) => {
42328
+ try {
42329
+ o.disconnect();
42330
+ } catch {
42331
+ }
42332
+ });
42333
+ }, 1500);
42334
+ }
42335
+ /**
42336
+ * Update configuration
42337
+ */
42338
+ setConfig(e) {
42339
+ this.config = { ...this.config, ...e };
42340
+ }
42341
+ /**
42342
+ * Enable or disable sounds
42343
+ */
42344
+ setEnabled(e) {
42345
+ this.config.enabled = e;
42346
+ }
42347
+ /**
42348
+ * Set volume (0.0 - 1.0)
42349
+ */
42350
+ setVolume(e) {
42351
+ this.config.volume = Math.max(0, Math.min(1, e));
42352
+ }
42353
+ /**
42354
+ * Get current config
42355
+ */
42356
+ getConfig() {
42357
+ return { ...this.config };
42358
+ }
42359
+ /**
42360
+ * Check if sounds are enabled
42361
+ */
42362
+ isEnabled() {
42363
+ return this.config.enabled;
42364
+ }
42365
+ /**
42366
+ * Cleanup
42367
+ */
42368
+ destroy() {
42369
+ this.audioContext && (this.audioContext.close(), this.audioContext = null);
42370
+ }
42371
+ }
42372
+ var dw = Object.defineProperty, uw = Object.getOwnPropertyDescriptor, jt = (i, e, t, n) => {
42373
+ for (var s = n > 1 ? void 0 : n ? uw(e, t) : e, r = i.length - 1, o; r >= 0; r--)
42178
42374
  (o = i[r]) && (s = (n ? o(e, t, s) : o(s)) || s);
42179
- return n && s && ow(e, t, s), s;
42375
+ return n && s && dw(e, t, s), s;
42180
42376
  };
42181
42377
  let Ft = class extends es {
42182
42378
  constructor() {
42183
- super(...arguments), this.orbRenderer = null, this.orbContainerRef = No(), this.audioSimPhase = 0, this.animationId = null, this.callManager = null, this.size = 300, this.headerLogo = "HANC.ai", this.headerTitle = "Lina-Voice AI", this.showBranding = !0, this.version = "v1.1.2", this.agentId = "", this.voiceServiceUrl = "", this.btnStartText = "Start", this.btnEndText = "End", this.colors = {}, this.brandingLogoColor = "rgba(255, 255, 255, 0.9)", this.brandingTitleColor = "rgba(255, 255, 255, 0.6)", this.brandingDividerColor = "rgba(255, 255, 255, 0.3)", this.versionColor = "rgba(255, 255, 255, 0.3)", this.buttonBackground = "linear-gradient(135deg, rgba(139, 92, 246, 0.95) 0%, rgba(124, 58, 237, 0.95) 100%)", this.buttonTextColor = "rgba(255, 255, 255, 0.95)", this.currentState = "idle", this.callStatus = "idle", this.isLoading = !0, this._hasMicPermission = null, this._localAudioContext = null, this._localAudioAnalyser = null, this._localAudioMonitorId = null, this._agentAudioContext = null, this._agentAudioAnalyser = null, this._agentAudioMonitorId = null, this._agentIsSpeaking = !1, this._interruptionTimeout = null, this._lastInterruptionTime = 0, this.handleCallClick = async () => {
42379
+ super(...arguments), this.orbRenderer = null, this.orbContainerRef = No(), this.audioSimPhase = 0, this.animationId = null, this.callManager = null, this.soundManager = new lw({ enabled: !0, volume: 0.4 }), this.size = 300, this.headerLogo = "HANC.ai", this.headerTitle = "Lina-Voice AI", this.showBranding = !0, this.version = "v1.1.2", this.agentId = "", this.voiceServiceUrl = "", this.btnStartText = "Start", this.btnEndText = "End", this.colors = {}, this.brandingLogoColor = "rgba(255, 255, 255, 0.9)", this.brandingTitleColor = "rgba(255, 255, 255, 0.6)", this.brandingDividerColor = "rgba(255, 255, 255, 0.3)", this.versionColor = "rgba(255, 255, 255, 0.3)", this.buttonBackground = "linear-gradient(135deg, rgba(139, 92, 246, 0.95) 0%, rgba(124, 58, 237, 0.95) 100%)", this.buttonTextColor = "rgba(255, 255, 255, 0.95)", this.currentState = "idle", this.callStatus = "idle", this.isLoading = !0, this._hasMicPermission = null, this._localAudioContext = null, this._localAudioAnalyser = null, this._localAudioMonitorId = null, this._agentAudioContext = null, this._agentAudioAnalyser = null, this._agentAudioMonitorId = null, this._agentIsSpeaking = !1, this._interruptionTimeout = null, this._lastInterruptionTime = 0, this.handleCallClick = async () => {
42184
42380
  if (this.callStatus === "mic-denied")
42185
42381
  try {
42186
42382
  (await navigator.mediaDevices.getUserMedia({ audio: !0 })).getTracks().forEach((e) => e.stop()), this._hasMicPermission = !0, this.callStatus = "idle";
@@ -42211,7 +42407,7 @@ let Ft = class extends es {
42211
42407
  }
42212
42408
  initializeOrb() {
42213
42409
  const i = this.orbContainerRef.value;
42214
- i && (this.orbRenderer = new aw(i, {
42410
+ i && (this.orbRenderer = new cw(i, {
42215
42411
  size: 1,
42216
42412
  colors: this.colors
42217
42413
  }), this.orbRenderer.start(), this.startIdleAnimation(), requestAnimationFrame(() => {
@@ -42326,6 +42522,9 @@ let Ft = class extends es {
42326
42522
  case "agent_state":
42327
42523
  (n = i.payload) != null && n.state && (this.setState(i.payload.state), this._agentIsSpeaking = i.payload.state === "speaking");
42328
42524
  break;
42525
+ case "end_call":
42526
+ console.log("[LinaWidget] Agent requested to end call"), this.endCall();
42527
+ break;
42329
42528
  }
42330
42529
  }
42331
42530
  /**
@@ -42346,13 +42545,13 @@ let Ft = class extends es {
42346
42545
  break;
42347
42546
  case "connected":
42348
42547
  case "agent-connected":
42349
- this.callStatus = "active", this.currentState = "speaking", (t = this.orbRenderer) == null || t.setState("speaking"), this.startActiveAnimation();
42548
+ this.callStatus = "active", this.currentState = "speaking", (t = this.orbRenderer) == null || t.setState("speaking"), this.startActiveAnimation(), this.soundManager.playCallStartSound();
42350
42549
  break;
42351
42550
  case "disconnecting":
42352
42551
  this.callStatus = "ending";
42353
42552
  break;
42354
42553
  case "disconnected":
42355
- this.callStatus = "idle", this.currentState = "idle", (n = this.orbRenderer) == null || n.setState("idle"), this.startIdleAnimation();
42554
+ this.callStatus = "idle", this.currentState = "idle", (n = this.orbRenderer) == null || n.setState("idle"), this.startIdleAnimation(), this.soundManager.playCallEndSound();
42356
42555
  break;
42357
42556
  case "error":
42358
42557
  this.callStatus = "error", this.currentState = "idle", (s = this.orbRenderer) == null || s.setState("idle");
@@ -42360,8 +42559,8 @@ let Ft = class extends es {
42360
42559
  }
42361
42560
  }
42362
42561
  cleanup() {
42363
- var i, e;
42364
- this.animationId !== null && (cancelAnimationFrame(this.animationId), this.animationId = null), this.stopLocalAudioMonitoring(), this.stopAgentAudioMonitoring(), this._interruptionTimeout && (clearTimeout(this._interruptionTimeout), this._interruptionTimeout = null), (i = this.callManager) == null || i.hangUp(), (e = this.orbRenderer) == null || e.destroy(), this.orbRenderer = null;
42562
+ var i, e, t;
42563
+ this.animationId !== null && (cancelAnimationFrame(this.animationId), this.animationId = null), this.stopLocalAudioMonitoring(), this.stopAgentAudioMonitoring(), this._interruptionTimeout && (clearTimeout(this._interruptionTimeout), this._interruptionTimeout = null), (i = this.callManager) == null || i.hangUp(), (e = this.orbRenderer) == null || e.destroy(), this.orbRenderer = null, (t = this.soundManager) == null || t.destroy();
42365
42564
  }
42366
42565
  startIdleAnimation() {
42367
42566
  this.animationId !== null && cancelAnimationFrame(this.animationId);
@@ -42433,7 +42632,7 @@ let Ft = class extends es {
42433
42632
  }, 3e3);
42434
42633
  }
42435
42634
  } else
42436
- this.callStatus = "connecting", this.currentState = "listening", (t = this.orbRenderer) == null || t.setState("listening"), await new Promise((s) => setTimeout(s, 1500)), this.callStatus = "active", this.currentState = "speaking", (n = this.orbRenderer) == null || n.setState("speaking"), this.startActiveAnimation(), this.dispatchEvent(new CustomEvent("call-start", {
42635
+ this.callStatus = "connecting", this.currentState = "listening", (t = this.orbRenderer) == null || t.setState("listening"), await new Promise((s) => setTimeout(s, 1500)), this.callStatus = "active", this.currentState = "speaking", (n = this.orbRenderer) == null || n.setState("speaking"), this.startActiveAnimation(), this.soundManager.playCallStartSound(), this.dispatchEvent(new CustomEvent("call-start", {
42437
42636
  detail: { agentId: "demo", timestamp: Date.now() },
42438
42637
  bubbles: !0,
42439
42638
  composed: !0
@@ -42444,7 +42643,7 @@ let Ft = class extends es {
42444
42643
  */
42445
42644
  async endCall() {
42446
42645
  var i;
42447
- this.callStatus = "ending", this.callManager && await this.callManager.hangUp(), this.callStatus = "idle", this.currentState = "idle", (i = this.orbRenderer) == null || i.setState("idle"), this.startIdleAnimation(), this.dispatchEvent(new CustomEvent("call-end", {
42646
+ this.callStatus = "ending", this.callManager ? await this.callManager.hangUp() : (this.soundManager.playCallEndSound(), this.callStatus = "idle", this.currentState = "idle", (i = this.orbRenderer) == null || i.setState("idle"), this.startIdleAnimation()), this.dispatchEvent(new CustomEvent("call-end", {
42448
42647
  detail: { timestamp: Date.now() },
42449
42648
  bubbles: !0,
42450
42649
  composed: !0
@@ -42849,20 +43048,20 @@ Ft = jt([
42849
43048
  export {
42850
43049
  _t as FloatingCall,
42851
43050
  bt as InlineCall,
42852
- aw as LinaOrbRenderer,
43051
+ cw as LinaOrbRenderer,
42853
43052
  Ft as LinaWidget,
42854
43053
  St as PillCall,
42855
43054
  _u as SoundManager,
42856
- ZM as applyTheme,
43055
+ ew as applyTheme,
42857
43056
  Si as darkPresets,
42858
- vw as darkThemes,
42859
- JM as detectSystemTheme,
42860
- mw as getColorPreset,
42861
- gw as getPresetNames,
43057
+ Sw as darkThemes,
43058
+ QM as detectSystemTheme,
43059
+ bw as getColorPreset,
43060
+ _w as getPresetNames,
42862
43061
  Jo as getTheme,
42863
- bw as getThemeNames,
43062
+ Tw as getThemeNames,
42864
43063
  xi as lightPresets,
42865
- yw as lightThemes,
43064
+ xw as lightThemes,
42866
43065
  da as themes,
42867
- _w as watchSystemTheme
43066
+ Cw as watchSystemTheme
42868
43067
  };