orb-ui 0.6.0 → 0.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/orb-ui.js CHANGED
@@ -472,27 +472,27 @@ function j({ state: e, volume: n, size: i, className: o, style: s, disabled: c =
472
472
  }
473
473
  //#endregion
474
474
  //#region src/themes/cloud/CloudTheme.tsx
475
- var M = typeof window < "u" ? n : t, N = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", P = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_activity;\n\nfloat hash(vec2 p) {\n p = fract(p * vec2(123.34, 456.21));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.52;\n mat2 rotation = mat2(0.80, 0.60, -0.60, 0.80);\n\n for (int octave = 0; octave < 5; octave++) {\n value += amplitude * noise(p);\n p = rotation * p * 1.92 + vec2(9.7, 4.3);\n amplitude *= 0.5;\n }\n\n return value;\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 centered = uv - 0.5;\n float radius = length(centered);\n float edge = 1.0 - smoothstep(0.488, 0.5, radius);\n\n if (edge <= 0.0) discard;\n\n vec2 p = centered * 2.0;\n float t = u_time;\n\n vec2 warp = vec2(\n fbm(p * 1.02 + vec2(t * 0.34, -t * 0.24)),\n fbm(p * 1.08 + vec2(-t * 0.27, t * 0.32) + vec2(6.7, 2.9))\n );\n vec2 curl = vec2(\n sin(p.y * 2.4 + t * 0.68 + warp.y * 3.2),\n cos(p.x * 2.1 - t * 0.61 + warp.x * 3.0)\n );\n vec2 warped =\n p +\n (warp - 0.5) * (1.18 + u_activity * 0.38) +\n curl * (0.035 + u_activity * 0.07);\n float broad = fbm(warped * 0.92 + vec2(t * 0.14, -t * 0.18));\n float folded = fbm(warped * 1.66 + vec2(-t * 0.23, t * 0.19) + 5.2);\n float field = mix(broad, folded, 0.3 + u_activity * 0.14);\n\n float horizon =\n 0.46 +\n 0.08 * sin((uv.x + warp.x * 0.2) * 5.4 + t * 0.42) +\n 0.16 * (broad - 0.5);\n float upper = smoothstep(horizon - 0.12, horizon + 0.08, uv.y);\n float band = exp(-pow((uv.y - horizon) * (5.2 + u_activity * 0.8), 2.0));\n float cloud = smoothstep(0.24, 0.79, field);\n\n vec3 deepPeriwinkle = vec3(0.36, 0.39, 0.985);\n vec3 upperPeriwinkle = vec3(0.48, 0.56, 0.985);\n vec3 lowerLavender = vec3(0.72, 0.78, 0.975);\n vec3 milk = vec3(0.89, 0.92, 0.995);\n\n vec3 color = mix(lowerLavender, upperPeriwinkle, upper);\n float upperDepth = upper * (0.14 + smoothstep(0.42, 0.78, folded) * 0.5);\n color = mix(color, deepPeriwinkle, upperDepth);\n\n float milkAmount = clamp(band * (0.42 + cloud * 0.62), 0.0, 0.88);\n color = mix(color, milk, milkAmount);\n\n float lowerMist = (1.0 - upper) * smoothstep(0.58, 0.9, broad) * 0.18;\n color = mix(color, milk, lowerMist);\n\n float grain = (noise(gl_FragCoord.xy * 0.64) - 0.5) / 255.0;\n color += grain;\n\n gl_FragColor = vec4(color, edge);\n}\n", F = .55, I = .204, L = .2145, R = .063, z = "#5659dc", B = 1.178, V = 180, H = 300, U = 1350, W = 246, G = 420, K = 354, ee = 480;
476
- function q(e, t = 0, n = 1) {
475
+ var M = typeof window < "u" ? n : t, N = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", P = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_activity;\n\nfloat hash(vec2 p) {\n p = fract(p * vec2(123.34, 456.21));\n p += dot(p, p + 45.32);\n return fract(p.x * p.y);\n}\n\nfloat noise(vec2 p) {\n vec2 i = floor(p);\n vec2 f = fract(p);\n vec2 u = f * f * (3.0 - 2.0 * f);\n\n return mix(\n mix(hash(i), hash(i + vec2(1.0, 0.0)), u.x),\n mix(hash(i + vec2(0.0, 1.0)), hash(i + vec2(1.0, 1.0)), u.x),\n u.y\n );\n}\n\nfloat fbm(vec2 p) {\n float value = 0.0;\n float amplitude = 0.52;\n mat2 rotation = mat2(0.80, 0.60, -0.60, 0.80);\n\n for (int octave = 0; octave < 5; octave++) {\n value += amplitude * noise(p);\n p = rotation * p * 1.92 + vec2(9.7, 4.3);\n amplitude *= 0.5;\n }\n\n return value;\n}\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 centered = uv - 0.5;\n float radius = length(centered);\n float edge = 1.0 - smoothstep(0.488, 0.5, radius);\n\n if (edge <= 0.0) discard;\n\n vec2 p = centered * 2.0;\n float t = u_time;\n\n vec2 warp = vec2(\n fbm(p * 1.02 + vec2(t * 0.34, -t * 0.24)),\n fbm(p * 1.08 + vec2(-t * 0.27, t * 0.32) + vec2(6.7, 2.9))\n );\n vec2 curl = vec2(\n sin(p.y * 2.4 + t * 0.68 + warp.y * 3.2),\n cos(p.x * 2.1 - t * 0.61 + warp.x * 3.0)\n );\n vec2 warped =\n p +\n (warp - 0.5) * (1.18 + u_activity * 0.38) +\n curl * (0.035 + u_activity * 0.07);\n float broad = fbm(warped * 0.92 + vec2(t * 0.14, -t * 0.18));\n float folded = fbm(warped * 1.66 + vec2(-t * 0.23, t * 0.19) + 5.2);\n float field = mix(broad, folded, 0.3 + u_activity * 0.14);\n\n float horizon =\n 0.46 +\n 0.08 * sin((uv.x + warp.x * 0.2) * 5.4 + t * 0.42) +\n 0.16 * (broad - 0.5);\n float upper = smoothstep(horizon - 0.12, horizon + 0.08, uv.y);\n float band = exp(-pow((uv.y - horizon) * (5.2 + u_activity * 0.8), 2.0));\n float cloud = smoothstep(0.24, 0.79, field);\n\n vec3 deepPeriwinkle = vec3(0.36, 0.39, 0.985);\n vec3 upperPeriwinkle = vec3(0.48, 0.56, 0.985);\n vec3 lowerLavender = vec3(0.72, 0.78, 0.975);\n vec3 milk = vec3(0.89, 0.92, 0.995);\n\n vec3 color = mix(lowerLavender, upperPeriwinkle, upper);\n float upperDepth = upper * (0.14 + smoothstep(0.42, 0.78, folded) * 0.5);\n color = mix(color, deepPeriwinkle, upperDepth);\n\n float milkAmount = clamp(band * (0.42 + cloud * 0.62), 0.0, 0.88);\n color = mix(color, milk, milkAmount);\n\n float lowerMist = (1.0 - upper) * smoothstep(0.58, 0.9, broad) * 0.18;\n color = mix(color, milk, lowerMist);\n\n float grain = (noise(gl_FragCoord.xy * 0.64) - 0.5) / 255.0;\n color += grain;\n\n gl_FragColor = vec4(color, edge);\n}\n", F = .55, I = .204, L = .2145, R = .063, z = "#5659dc", B = 1.178, V = 180, H = 300, U = 1350, ee = 246, te = 420, ne = 354, re = 480;
476
+ function W(e, t = 0, n = 1) {
477
477
  return Math.min(n, Math.max(t, e));
478
478
  }
479
- function J(e, t, n, r) {
479
+ function G(e, t, n, r) {
480
480
  return e + (t - e) * (1 - Math.exp(-n * r));
481
481
  }
482
- function te(e) {
482
+ function ie(e) {
483
483
  return 1 - (1 - e) ** 3;
484
484
  }
485
- function Y(e, t, n) {
485
+ function K(e, t, n) {
486
486
  return e + (t - e) * n;
487
487
  }
488
- function X(e, t, n) {
489
- let r = q((e - t) / (n - t));
488
+ function q(e, t, n) {
489
+ let r = W((e - t) / (n - t));
490
490
  return r * r * (3 - 2 * r);
491
491
  }
492
- function Z(e) {
492
+ function J(e) {
493
493
  return e === "listening" || e === "speaking" || e === "thinking";
494
494
  }
495
- function Q(e, t, n) {
495
+ function Y(e, t, n) {
496
496
  let r = e.createShader(t);
497
497
  if (r) {
498
498
  if (e.shaderSource(r, n), e.compileShader(r), !e.getShaderParameter(r, e.COMPILE_STATUS)) {
@@ -502,14 +502,14 @@ function Q(e, t, n) {
502
502
  return r;
503
503
  }
504
504
  }
505
- function ne(e, t) {
505
+ function ae(e, t) {
506
506
  let n = e.getContext("webgl", {
507
507
  alpha: !0,
508
508
  antialias: !0,
509
509
  premultipliedAlpha: !0
510
510
  });
511
511
  if (!n) return;
512
- let r = Q(n, n.VERTEX_SHADER, N), i = Q(n, n.FRAGMENT_SHADER, P);
512
+ let r = Y(n, n.VERTEX_SHADER, N), i = Y(n, n.FRAGMENT_SHADER, P);
513
513
  if (!r || !i) {
514
514
  r && n.deleteShader(r), i && n.deleteShader(i);
515
515
  return;
@@ -551,15 +551,15 @@ function ne(e, t) {
551
551
  }
552
552
  };
553
553
  }
554
- function re(e) {
554
+ function oe(e) {
555
555
  if (e <= V) return R;
556
- if (e <= 480) return Y(R, B, te((e - V) / H));
556
+ if (e <= 480) return K(R, B, ie((e - V) / H));
557
557
  let t = e - V - H;
558
558
  if (t >= U) return 1;
559
- let n = q(t / U);
559
+ let n = W(t / U);
560
560
  return 1 + (B - 1) * (1 - n) ** 2;
561
561
  }
562
- function ie({ state: e, volume: n, size: i, className: s, style: c, disabled: l = !1, interactive: u = !1, onClick: d, ...f }) {
562
+ function se({ state: e, volume: n, size: i, className: s, style: c, disabled: l = !1, interactive: u = !1, onClick: d, ...f }) {
563
563
  let p = r(null), m = r(null), h = r(null), g = r(e), _ = r(n), v = r(u), y = r(!1);
564
564
  M(() => {
565
565
  g.current = e, _.current = n, v.current = u;
@@ -576,32 +576,32 @@ function ie({ state: e, volume: n, size: i, className: s, style: c, disabled: l
576
576
  y.current = r.matches;
577
577
  };
578
578
  i(), r.addEventListener("change", i);
579
- let a = ne(e, b);
579
+ let a = ae(e, b);
580
580
  a || (e.style.background = "linear-gradient(180deg, #626afb 2%, #8f9dfb 32%, #dde6fd 52%, #c9d3fb 84%)");
581
- let o = 0, s = performance.now(), c = g.current, l = Z(c) ? s : void 0, u = q(_.current), d = 1, f = +!!Z(c), x = 1, S = +(c === "connecting"), C = 0, w = (r) => {
581
+ let o = 0, s = performance.now(), c = g.current, l = J(c) ? s : void 0, u = W(_.current), d = 1, f = +!!J(c), x = 1, S = +(c === "connecting"), C = 0, w = (r) => {
582
582
  let i = Math.min((r - s) / 1e3, .05);
583
583
  s = r;
584
584
  let p = g.current, m = y.current;
585
- p !== c && (Z(p) && !Z(c) && (l = r), (p === "idle" || p === "error") && (l = void 0), c = p);
586
- let h = q(_.current);
587
- u = m ? 0 : J(u, h, h > u ? 11 : 6, i);
585
+ p !== c && (J(p) && !J(c) && (l = r), (p === "idle" || p === "error") && (l = void 0), c = p);
586
+ let h = W(_.current);
587
+ u = m ? 0 : G(u, h, h > u ? 11 : 6, i);
588
588
  let b = 1;
589
589
  p === "listening" && (b = 1 - u * I), p === "speaking" && (b = 1 + u * L);
590
590
  let T = Math.abs(b - 1) > Math.abs(d - 1) ? 12 : 6;
591
- d = m ? 1 : J(d, b, T, i);
592
- let E = Z(p), D = p === "idle" && v.current, O = E || D ? 1 : 0;
593
- f = m ? O : J(f, O, 14, i);
591
+ d = m ? 1 : G(d, b, T, i);
592
+ let E = J(p), D = p === "idle" && v.current, O = E || D ? 1 : 0;
593
+ f = m ? O : G(f, O, 14, i);
594
594
  let k = E || D ? 1 : .92;
595
- x = m ? k : J(x, k, 12, i);
595
+ x = m ? k : G(x, k, 12, i);
596
596
  let A = d * x;
597
597
  D && (A = R);
598
598
  let j = +!D, M = D ? f : 0;
599
599
  if (E && l !== void 0 && !m) {
600
- let e = r - l, t = re(e), n = q((e - V - H) / U);
601
- A = t * Y(1, d, n), j = X(e, W, G), M = f * (1 - X(e, K, ee)), e >= 1830 && (l = void 0);
600
+ let e = r - l, t = oe(e), n = W((e - V - H) / U);
601
+ A = t * K(1, d, n), j = q(e, ee, te), M = f * (1 - q(e, ne, re)), e >= 1830 && (l = void 0);
602
602
  }
603
603
  let N = +(p === "connecting");
604
- S = m ? N : J(S, N, 18, i), e.style.opacity = String(f * j), e.style.transform = `scale(${A})`, t.style.opacity = String(M), t.style.transform = `scale(${A})`, n.style.opacity = String(S), n.style.transform = `rotate(${m ? 45 : r * .34}deg)`;
604
+ S = m ? N : G(S, N, 18, i), e.style.opacity = String(f * j), e.style.transform = `scale(${A})`, t.style.opacity = String(M), t.style.transform = `scale(${A})`, n.style.opacity = String(S), n.style.transform = `rotate(${m ? 45 : r * .34}deg)`;
605
605
  let P = .24, F = .1;
606
606
  p === "listening" ? (P = .72 + u * .78, F = .28 + u * .32) : p === "speaking" && (P = 1.65 + u * 1.55, F = .66 + u * .34), m || (C += i * P), a?.draw(C, F), o = requestAnimationFrame(w);
607
607
  };
@@ -711,6 +711,225 @@ function ie({ state: e, volume: n, size: i, className: s, style: c, disabled: l
711
711
  });
712
712
  }
713
713
  //#endregion
714
+ //#region src/themes/radial/RadialTheme.tsx
715
+ var ce = typeof window < "u" ? n : t, le = "\nattribute vec2 a_position;\n\nvoid main() {\n gl_Position = vec4(a_position, 0.0, 1.0);\n}\n", ue = "\nprecision highp float;\n\nuniform vec2 u_resolution;\nuniform float u_time;\nuniform float u_rotation;\nuniform float u_listen;\nuniform float u_speak;\n\nvoid main() {\n vec2 uv = gl_FragCoord.xy / u_resolution;\n vec2 p = (uv - 0.5) * 2.0;\n float radius = length(p);\n float edge = 1.0 - smoothstep(0.993, 1.0, radius);\n\n if (edge <= 0.0) discard;\n\n float angle = atan(p.y, p.x);\n float warpStrength = 0.026 + u_speak * 0.105;\n float angularWarp =\n sin(angle * 3.0 - u_time * 0.54 + radius * 2.1) +\n 0.48 * sin(angle * 5.0 + u_time * 0.31 - radius * 3.7) +\n 0.22 * sin(angle * 8.0 - u_time * 0.19 + radius * 5.2);\n float phase =\n angle - 1.78 - u_rotation + angularWarp * warpStrength * (0.2 + radius * 0.8);\n\n // Two opposing dark lobes and two opposing aqua lobes form the main pinwheel.\n float lobeField = cos(phase * 2.0);\n float darkMix = smoothstep(-0.04, 0.38, lobeField);\n\n vec3 deepBlue = vec3(0.004, 0.105, 0.37);\n vec3 cobalt = vec3(0.015, 0.34, 0.76);\n vec3 aqua = vec3(0.24, 0.76, 0.79);\n vec3 paleAqua = vec3(0.77, 0.96, 0.95);\n\n float radialLight = 0.5 + 0.5 * sin(radius * 3.0 - u_time * 0.16);\n vec3 darkColor = mix(cobalt, deepBlue, 0.42 + 0.38 * radius);\n float darkRay = pow(max(lobeField, 0.0), 11.0);\n darkColor = mix(darkColor, aqua, darkRay * (0.18 + radialLight * 0.16));\n\n vec3 lightColor = mix(paleAqua, aqua, 0.5 + 0.2 * sin(radius * 3.4 + phase * 2.0));\n float lightRay = pow(max(-lobeField, 0.0), 5.0);\n lightColor = mix(lightColor, vec3(0.04, 0.42, 0.64), lightRay * 0.28);\n\n vec3 color = mix(lightColor, darkColor, darkMix);\n\n // Soft secondary streaks make each of the four lobes feel layered rather than flat.\n float secondaryRay = 0.5 + 0.5 * sin(phase * 6.0 + radius * 1.8 - u_time * 0.42);\n float rayStrength = (0.055 + u_speak * 0.045) * (0.25 + radius * 0.75);\n color = mix(color, vec3(0.26, 0.76, 0.8), secondaryRay * rayStrength);\n\n // The outer membrane keeps a circular perimeter while independent traveling waves\n // continuously reshape its inner boundary.\n float rimWave =\n 0.063 * sin(angle * 3.0 + u_time * 1.34) +\n 0.036 * sin(angle * 5.0 - u_time * 0.91 + 1.4) +\n 0.021 * sin(angle * 7.0 + u_time * 0.63 - 0.8) +\n 0.012 * sin(angle * 11.0 - u_time * 1.72 + sin(angle * 2.0 + u_time * 0.58));\n rimWave *= 1.0 + u_listen * 0.38;\n float rimInner = 0.82 + rimWave - u_listen * 0.2;\n float rim = smoothstep(rimInner - 0.02, rimInner + 0.015, radius);\n float rimStrength = rim * (0.3 + u_listen * 0.3);\n vec3 membrane = mix(\n vec3(0.47, 0.84, 0.84),\n vec3(0.76, 0.93, 0.92),\n smoothstep(0.78, 1.0, radius)\n );\n color = mix(color, membrane, clamp(rimStrength, 0.0, 0.72));\n\n // Only one transition direction becomes a bright seam, producing two opposing ribbons.\n float seamDirection = max(0.0, -sin(phase * 2.0));\n float seamExponent = mix(30.0, 3.2, smoothstep(0.05, 1.0, radius));\n float seam = pow(seamDirection, seamExponent) * (0.78 + radius * 0.25);\n color = mix(color, vec3(0.985, 0.995, 0.995), clamp(seam, 0.0, 0.96));\n\n // The drawing buffer uses premultiplied alpha. Premultiply the antialiased\n // perimeter so translucent edge pixels cannot become a bright outline.\n gl_FragColor = vec4(color * edge, edge);\n}\n", de = "\n@keyframes orb-radial-spinner {\n to { transform: rotate(360deg); }\n}\n@media (prefers-reduced-motion: reduce) {\n [data-radial-spinner] { animation: none !important; }\n}\n", fe = .66, pe = .2;
716
+ function X(e, t = 0, n = 1) {
717
+ return Math.min(n, Math.max(t, e));
718
+ }
719
+ function Z(e, t, n, r) {
720
+ return e + (t - e) * (1 - Math.exp(-n * r));
721
+ }
722
+ function Q(e, t, n) {
723
+ let r = e.createShader(t);
724
+ if (r) {
725
+ if (e.shaderSource(r, n), e.compileShader(r), !e.getShaderParameter(r, e.COMPILE_STATUS)) {
726
+ e.deleteShader(r);
727
+ return;
728
+ }
729
+ return r;
730
+ }
731
+ }
732
+ function me(e, t) {
733
+ let n = e.getContext("webgl", {
734
+ alpha: !0,
735
+ antialias: !0,
736
+ premultipliedAlpha: !0
737
+ });
738
+ if (!n) return;
739
+ let r = Q(n, n.VERTEX_SHADER, le), i = Q(n, n.FRAGMENT_SHADER, ue);
740
+ if (!r || !i) {
741
+ r && n.deleteShader(r), i && n.deleteShader(i);
742
+ return;
743
+ }
744
+ let a = n.createProgram(), o = n.createBuffer();
745
+ if (!a || !o) {
746
+ a && n.deleteProgram(a), o && n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
747
+ return;
748
+ }
749
+ if (n.attachShader(a, r), n.attachShader(a, i), n.linkProgram(a), !n.getProgramParameter(a, n.LINK_STATUS)) {
750
+ n.deleteProgram(a), n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
751
+ return;
752
+ }
753
+ let s = n.getAttribLocation(a, "a_position"), c = n.getUniformLocation(a, "u_resolution"), l = n.getUniformLocation(a, "u_time"), u = n.getUniformLocation(a, "u_rotation"), d = n.getUniformLocation(a, "u_listen"), f = n.getUniformLocation(a, "u_speak");
754
+ if (s < 0 || !c || !l || !u || !d || !f) {
755
+ n.deleteProgram(a), n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
756
+ return;
757
+ }
758
+ let p = Math.min(window.devicePixelRatio || 1, 2), m = Math.max(1, Math.round(t * p));
759
+ return e.width = m, e.height = m, n.viewport(0, 0, m, m), n.useProgram(a), n.bindBuffer(n.ARRAY_BUFFER, o), n.bufferData(n.ARRAY_BUFFER, new Float32Array([
760
+ -1,
761
+ -1,
762
+ 1,
763
+ -1,
764
+ -1,
765
+ 1,
766
+ -1,
767
+ 1,
768
+ 1,
769
+ -1,
770
+ 1,
771
+ 1
772
+ ]), n.STATIC_DRAW), n.enableVertexAttribArray(s), n.vertexAttribPointer(s, 2, n.FLOAT, !1, 0, 0), n.uniform2f(c, m, m), {
773
+ draw(e, t, r, i) {
774
+ n.uniform1f(l, e), n.uniform1f(u, t), n.uniform1f(d, r), n.uniform1f(f, i), n.drawArrays(n.TRIANGLES, 0, 6);
775
+ },
776
+ destroy() {
777
+ n.deleteProgram(a), n.deleteBuffer(o), n.deleteShader(r), n.deleteShader(i);
778
+ }
779
+ };
780
+ }
781
+ function he(e) {
782
+ return e !== "idle" && e !== "connecting" && e !== "error";
783
+ }
784
+ function ge({ active: e }) {
785
+ return /* @__PURE__ */ a("svg", {
786
+ "aria-hidden": "true",
787
+ fill: "none",
788
+ viewBox: "0 0 24 24",
789
+ style: {
790
+ display: "block",
791
+ width: "50%",
792
+ height: "50%",
793
+ transform: `rotate(${e ? 132 : -8}deg)`,
794
+ transformOrigin: "center",
795
+ transition: "transform 180ms ease"
796
+ },
797
+ children: /* @__PURE__ */ a("path", {
798
+ d: "M6.7 3.8 9.1 7a1.6 1.6 0 0 1-.2 2.1l-1.4 1.3a13.1 13.1 0 0 0 6.1 6.1l1.3-1.4a1.6 1.6 0 0 1 2.1-.2l3.2 2.4a1.6 1.6 0 0 1 .5 1.9l-.7 1.7c-.3.8-1.1 1.3-2 1.2C9.7 21.2 2.8 14.3 1.9 6c-.1-.9.4-1.7 1.2-2l1.7-.7a1.6 1.6 0 0 1 1.9.5Z",
799
+ fill: "currentColor"
800
+ })
801
+ });
802
+ }
803
+ function _e({ state: e, volume: n, size: i, className: s, style: c, disabled: l = !1, interactive: u = !1, onClick: d, ...f }) {
804
+ let p = r(null), m = r(e), h = r(n), g = r(!1);
805
+ ce(() => {
806
+ m.current = e, h.current = n;
807
+ }, [e, n]);
808
+ let _ = i * fe, v = _ * pe;
809
+ t(() => {
810
+ let e = "orb-radial-keyframes";
811
+ if (!document.getElementById(e)) {
812
+ let t = document.createElement("style");
813
+ t.id = e, t.textContent = de, document.head.appendChild(t);
814
+ }
815
+ }, []), t(() => {
816
+ let e = p.current;
817
+ if (!e) return;
818
+ let t = window.matchMedia("(prefers-reduced-motion: reduce)"), n = () => {
819
+ g.current = t.matches;
820
+ };
821
+ n(), t.addEventListener("change", n);
822
+ let r = me(e, _), i = 0, a = performance.now(), o = 0, s = .36, c = .62, l = .15, u = 0, d = 0, f = 0, v = 0, y = +(m.current === "speaking"), b = X(h.current), x = m.current === "listening" ? b : 0, S = m.current === "speaking" ? b : 0, C = (e) => {
823
+ let t = Math.min((e - a) / 1e3, .05);
824
+ a = e;
825
+ let n = m.current, p = g.current, _ = X(h.current);
826
+ b = p ? 0 : Z(b, _, _ > b ? 15 : 7, t);
827
+ let w = n === "listening" ? b : 0, T = n === "speaking" ? b : 0;
828
+ x = p ? 0 : Z(x, w, w > x ? 17 : 7, t), S = p ? 0 : Z(S, T, T > S ? 12 : 5, t);
829
+ let E = .36, D = .62, O = .15;
830
+ if (n === "connecting" ? (E = .42, D = .68, O = .13) : n === "listening" ? (E = .54 + x * .26, D = .78 + x * .18, O = .18 + x * .04) : n === "thinking" ? (E = .46, D = .72, O = .16) : n === "speaking" && (E = 1.05 + S * 1.15), !p) {
831
+ s = Z(s, E, 3.6, t), c = Z(c, D, 3.6, t), l = Z(l, O, 3.6, t), y = Z(y, +(n === "speaking"), n === "speaking" ? 3.8 : 3, t), o += t * s, f += t * c;
832
+ let e = 1.2 + S * 1.35 + Math.sin(o * 1.73) * .34 + Math.sin(o * .61 + .8) * .18;
833
+ v += t * Math.max(.65, e);
834
+ let r = Math.sin(f) * l + Math.sin(f * .47 + 1.1) * .032, i = Math.sin(v * 1.08), a = Math.sin(v * 2.47 + .9), p = Math.sin(v * .43 - .5), m = r + (i * (.13 + S * .17) + a * (.035 + S * .035) + p * .055 - r) * y, h = 4.2 + y * 3, g = h * h, _ = 2 * h;
835
+ d += ((m - u) * g - d * _) * t, u += d * t;
836
+ }
837
+ r?.draw(o, u, x, S), i = requestAnimationFrame(C);
838
+ };
839
+ return i = requestAnimationFrame(C), () => {
840
+ cancelAnimationFrame(i), t.removeEventListener("change", n), r?.destroy();
841
+ };
842
+ }, [_]);
843
+ let y = he(e), b = e === "connecting", x = _ + (u ? v * .5 : 0), S = {
844
+ "--orb-ui-radial-control-surround": "#fff",
845
+ width: i,
846
+ height: i,
847
+ display: "flex",
848
+ alignItems: "center",
849
+ justifyContent: "center",
850
+ position: "relative",
851
+ ...c
852
+ }, C = /* @__PURE__ */ o("span", {
853
+ style: {
854
+ position: "relative",
855
+ display: "block",
856
+ width: _,
857
+ height: x,
858
+ lineHeight: 0
859
+ },
860
+ children: [/* @__PURE__ */ a("canvas", {
861
+ ref: p,
862
+ "aria-hidden": "true",
863
+ "data-radial-surface": "",
864
+ style: {
865
+ position: "absolute",
866
+ left: 0,
867
+ top: 0,
868
+ display: "block",
869
+ width: _,
870
+ height: _,
871
+ borderRadius: "50%",
872
+ background: "conic-gradient(from 12deg, #06358d 0deg, #0b65b5 72deg, #c7f1ef 92deg, #45c2c8 172deg, #06358d 196deg, #0b65b5 254deg, #c7f1ef 278deg, #45c2c8 360deg)"
873
+ }
874
+ }), u ? /* @__PURE__ */ a("button", {
875
+ ...f,
876
+ type: "button",
877
+ "data-radial-control": "",
878
+ disabled: l,
879
+ onClick: l ? void 0 : d,
880
+ style: {
881
+ appearance: "none",
882
+ WebkitAppearance: "none",
883
+ position: "absolute",
884
+ left: "50%",
885
+ top: _ - v * .52,
886
+ width: v,
887
+ height: v,
888
+ display: "flex",
889
+ alignItems: "center",
890
+ justifyContent: "center",
891
+ boxSizing: "border-box",
892
+ padding: 0,
893
+ margin: 0,
894
+ border: 0,
895
+ borderRadius: "50%",
896
+ background: b ? "#9da1aa" : y ? "#ef4146" : "#080808",
897
+ color: "#fff",
898
+ boxShadow: `0 0 0 ${Math.max(3, v * .085)}px var(--orb-ui-radial-control-surround), 0 2px 5px rgba(0, 0, 0, 0.18)`,
899
+ cursor: l ? "not-allowed" : "pointer",
900
+ opacity: l ? .52 : 1,
901
+ transform: "translateX(-50%)",
902
+ transition: "background 160ms ease, opacity 160ms ease, transform 160ms ease",
903
+ font: "inherit"
904
+ },
905
+ children: b ? /* @__PURE__ */ a("span", {
906
+ "aria-hidden": "true",
907
+ "data-radial-spinner": "",
908
+ style: {
909
+ width: "42%",
910
+ height: "42%",
911
+ boxSizing: "border-box",
912
+ border: `${Math.max(1.5, v * .055)}px solid rgba(255, 255, 255, 0.38)`,
913
+ borderTopColor: "#fff",
914
+ borderRightColor: "#fff",
915
+ borderRadius: "50%",
916
+ animation: "orb-radial-spinner 760ms linear infinite"
917
+ }
918
+ }) : /* @__PURE__ */ a(ge, { active: y })
919
+ }) : null]
920
+ });
921
+ return u ? /* @__PURE__ */ a("div", {
922
+ className: s,
923
+ style: S,
924
+ children: C
925
+ }) : /* @__PURE__ */ a("div", {
926
+ ...f,
927
+ className: s,
928
+ style: S,
929
+ children: C
930
+ });
931
+ }
932
+ //#endregion
714
933
  //#region src/components/Orb/Orb.tsx
715
934
  function $({ signal: n, state: r, volume: o, adapter: l, theme: u = "debug", size: f = 200, className: p, style: m, disabled: h = !1, interactive: g = !0, onStart: _, onStop: v, ...y }) {
716
935
  let [b, x] = i({ state: "idle" });
@@ -747,7 +966,11 @@ function $({ signal: n, state: r, volume: o, adapter: l, theme: u = "debug", siz
747
966
  ...N,
748
967
  onClick: A
749
968
  });
750
- case "cloud": return /* @__PURE__ */ a(ie, {
969
+ case "cloud": return /* @__PURE__ */ a(se, {
970
+ ...N,
971
+ onClick: A
972
+ });
973
+ case "radial": return /* @__PURE__ */ a(_e, {
751
974
  ...N,
752
975
  onClick: A
753
976
  });
@@ -2,3 +2,4 @@ export { DebugTheme } from './debug/index.js';
2
2
  export { CircleTheme } from './circle/index.js';
3
3
  export { BarsTheme } from './bars/index.js';
4
4
  export { CloudTheme } from './cloud/index.js';
5
+ export { RadialTheme } from './radial/index.js';
@@ -0,0 +1,13 @@
1
+ import { OrbHtmlAttributes, OrbState, OrbStyle } from '../../components/Orb/Orb.types.js';
2
+ interface RadialThemeProps extends OrbHtmlAttributes {
3
+ state: OrbState;
4
+ volume: number;
5
+ size: number;
6
+ className?: string;
7
+ style?: OrbStyle;
8
+ disabled?: boolean;
9
+ interactive?: boolean;
10
+ onClick?: () => void;
11
+ }
12
+ export declare function RadialTheme({ state, volume, size, className, style, disabled, interactive, onClick, ...controlProps }: RadialThemeProps): import("react/jsx-runtime").JSX.Element;
13
+ export {};
@@ -0,0 +1 @@
1
+ export { RadialTheme } from './RadialTheme.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "orb-ui",
3
- "version": "0.6.0",
3
+ "version": "0.7.0",
4
4
  "description": "React voice agent UI components with audio-reactive adapters for Vapi, ElevenLabs, LiveKit, Pipecat, OpenAI Realtime, Gemini Live, and custom voice AI apps.",
5
5
  "type": "module",
6
6
  "main": "./dist/orb-ui.cjs",
@@ -1,240 +0,0 @@
1
- //#region src/adapters/types.ts
2
- function e(e) {
3
- let t = Math.min(e / .5, 1);
4
- return t **= 1.3, t;
5
- }
6
- //#endregion
7
- //#region src/adapters/livekit/index.ts
8
- var t = 4, n = .03, r = 1.5, i = .6, a = .2, o = .35;
9
- function s(e) {
10
- switch (e) {
11
- case "speaking": return "speaking";
12
- case "thinking": return "thinking";
13
- case "listening":
14
- case "idle": return "listening";
15
- case "connecting":
16
- case "pre-connect-buffering":
17
- case "initializing": return "connecting";
18
- case "disconnected": return "idle";
19
- case "failed": return "error";
20
- default: return "idle";
21
- }
22
- }
23
- function c(e) {
24
- return "RoomClass" in e;
25
- }
26
- function l(e) {
27
- return typeof e == "function" ? e() : e;
28
- }
29
- function u(e) {
30
- if (!e) return {};
31
- let t = {}, n = (e, n) => {
32
- n !== void 0 && (t[e] = n);
33
- };
34
- return n("roomName", l(e.roomName)), n("participantName", l(e.participantName)), n("participantIdentity", l(e.participantIdentity)), n("participantMetadata", l(e.participantMetadata)), n("participantAttributes", typeof e.participantAttributes == "function" ? e.participantAttributes() : e.participantAttributes), n("agentName", l(e.agentName)), n("agentMetadata", l(e.agentMetadata)), n("deployment", l(e.deployment)), t;
35
- }
36
- function d(e) {
37
- if (!e.serverUrl || !e.participantToken) throw Error("[orb-ui/livekit] connection details must include serverUrl and participantToken.");
38
- return e;
39
- }
40
- async function f(e) {
41
- let t = u(e.tokenOptions);
42
- return typeof e.getConnectionDetails == "function" ? d(await e.getConnectionDetails(t)) : e.tokenSource ? d(await e.tokenSource.fetch(t)) : d({
43
- serverUrl: e.serverUrl,
44
- participantToken: e.participantToken
45
- });
46
- }
47
- function p(e) {
48
- for (let [, n] of e.remoteParticipants) if (!n.isLocal && (n.kind === t || n.attributes?.["lk.agent.state"] !== void 0)) return n;
49
- return null;
50
- }
51
- function m(e, t, n) {
52
- let r = e.off;
53
- if (r) {
54
- r.call(e, t, n);
55
- return;
56
- }
57
- e.removeListener?.call(e, t, n);
58
- }
59
- function h(e, t, n) {
60
- e.on.call(e, t, n);
61
- }
62
- function g(l) {
63
- let u = c(l), d = l.createAudioAnalyser, g = { current: u ? null : l.room }, _ = /* @__PURE__ */ new Set(), v = {
64
- state: "idle",
65
- volume: 0,
66
- inputVolume: 0,
67
- outputVolume: 0
68
- }, y = "idle", b = null, x = null, S = null, C = null, w = null, T = null, E = null, D = 0, O = null;
69
- function k(e) {
70
- v = e, _.forEach((t) => t(e));
71
- }
72
- function A(e) {
73
- k({
74
- ...v,
75
- ...e,
76
- state: e.state ?? v.state
77
- });
78
- }
79
- function j(e) {
80
- let t = e < n ? 0 : e, s = t > D ? i : a;
81
- D += (t - D) * s;
82
- let c = Math.min(D * r, 1);
83
- return c / (c + o);
84
- }
85
- function M() {
86
- D = 0, A({
87
- volume: 0,
88
- outputVolume: 0
89
- });
90
- }
91
- function N({ emitZero: e = !0 } = {}) {
92
- w &&= (clearInterval(w), null), C &&= (C.cleanup().catch(() => {}), null), e && A({
93
- volume: 0,
94
- inputVolume: 0
95
- });
96
- }
97
- function P(t) {
98
- if (!(b === t && C)) {
99
- N({ emitZero: !1 }), b = t;
100
- try {
101
- C = d(t);
102
- } catch (e) {
103
- console.warn("[orb-ui/livekit] local createAudioAnalyser failed:", e);
104
- return;
105
- }
106
- w = setInterval(() => {
107
- if (!C || y !== "listening") return;
108
- let t = e(C.calculateVolume());
109
- A({
110
- volume: t,
111
- inputVolume: t,
112
- outputVolume: 0
113
- });
114
- }, 33);
115
- }
116
- }
117
- function F({ emitZero: e = !0 } = {}) {
118
- E &&= (clearInterval(E), null), T &&= (T.cleanup().catch(() => {}), null), D = 0, e && A({
119
- volume: 0,
120
- outputVolume: 0
121
- });
122
- }
123
- function I(e) {
124
- F();
125
- try {
126
- T = d(e);
127
- } catch (e) {
128
- console.warn("[orb-ui/livekit] remote createAudioAnalyser failed:", e);
129
- return;
130
- }
131
- E = setInterval(() => {
132
- if (!T || y !== "speaking") return;
133
- let e = j(T.calculateVolume());
134
- A({
135
- volume: e,
136
- inputVolume: 0,
137
- outputVolume: e
138
- });
139
- }, 33);
140
- }
141
- function L(e) {
142
- y = e, A({
143
- state: e,
144
- volume: 0,
145
- inputVolume: 0,
146
- outputVolume: 0
147
- }), e === "speaking" && x ? I(x) : e !== "speaking" && F({ emitZero: !1 });
148
- }
149
- function R(e) {
150
- S || typeof document > "u" || (S = e.attach(), S.id = "orb-ui-livekit-agent-audio", document.body.appendChild(S));
151
- }
152
- function z() {
153
- S &&= (S.remove(), null);
154
- }
155
- function B(e) {
156
- x = e, R(e), y === "speaking" && I(e);
157
- }
158
- function V(e) {
159
- P(e);
160
- }
161
- function H(e) {
162
- let t = e.getTrackPublication?.("microphone");
163
- t?.track && V(t.track);
164
- }
165
- function U(e) {
166
- let t = s(e);
167
- t !== y && L(t);
168
- }
169
- function W(e) {
170
- let t = e.attributes?.["lk.agent.state"];
171
- t && U(t);
172
- let n = e.getTrackPublication("microphone");
173
- n?.track && B(n.track);
174
- }
175
- function G(e) {
176
- if (O) return;
177
- let n = (e, t) => {
178
- if (t.isLocal) return;
179
- let n = e["lk.agent.state"];
180
- n && U(n);
181
- }, r = (e, n, r) => {
182
- r.isLocal || !(r.kind === t || r.attributes?.["lk.agent.state"] !== void 0) || e.mediaStreamTrack.kind !== "audio" || B(e);
183
- }, i = (e) => {
184
- x === e && (x = null, z(), F());
185
- }, a = (e) => {
186
- e.source !== "microphone" || !e.track || V(e.track);
187
- }, o = (e) => {
188
- e.source === "microphone" && (b = null, N());
189
- }, s = () => {
190
- b = null, x = null, z(), N({ emitZero: !1 }), F({ emitZero: !1 }), L("idle");
191
- };
192
- if (h(e, "participantAttributesChanged", n), h(e, "trackSubscribed", r), h(e, "trackUnsubscribed", i), h(e, "localTrackPublished", a), h(e, "localTrackUnpublished", o), h(e, "disconnected", s), O = () => {
193
- m(e, "participantAttributesChanged", n), m(e, "trackSubscribed", r), m(e, "trackUnsubscribed", i), m(e, "localTrackPublished", a), m(e, "localTrackUnpublished", o), m(e, "disconnected", s);
194
- }, H(e.localParticipant), e.state === "connected") {
195
- let t = p(e);
196
- t ? W(t) : L("connecting");
197
- } else L("idle");
198
- }
199
- function K() {
200
- O?.(), O = null, b = null, x = null, z(), N({ emitZero: !1 }), F({ emitZero: !1 }), A({
201
- volume: 0,
202
- inputVolume: 0,
203
- outputVolume: 0
204
- });
205
- }
206
- let q = (e) => {
207
- _.add(e), e(v);
208
- let t = g.current;
209
- return t && G(t), () => {
210
- _.delete(e), _.size === 0 && K();
211
- };
212
- };
213
- return u ? {
214
- subscribe: q,
215
- async start() {
216
- if (g.current) return;
217
- let e = l, t = new e.RoomClass();
218
- L("connecting");
219
- try {
220
- let n = await f(e);
221
- if (await t.connect(n.serverUrl, n.participantToken, e.connectOptions), g.current = t, G(t), e.enableMicrophone !== !1) {
222
- let e = (await t.localParticipant.setMicrophoneEnabled(!0))?.track ?? t.localParticipant.getTrackPublication?.("microphone")?.track;
223
- e && V(e);
224
- }
225
- } catch (e) {
226
- throw console.error("[orb-ui/livekit] connect failed:", e), g.current === t && K(), t.disconnect(), g.current = null, L("error"), M(), A({ error: e }), e;
227
- }
228
- },
229
- async stop() {
230
- let e = g.current;
231
- if (!e) {
232
- L("idle");
233
- return;
234
- }
235
- K(), e.disconnect(), g.current = null, L("idle");
236
- }
237
- } : { subscribe: q };
238
- }
239
- //#endregion
240
- export { g as t };
@@ -1 +0,0 @@
1
- function e(e){let t=Math.min(e/.5,1);return t**=1.3,t}var t=4,n=.03,r=1.5,i=.6,a=.2,o=.35;function s(e){switch(e){case`speaking`:return`speaking`;case`thinking`:return`thinking`;case`listening`:case`idle`:return`listening`;case`connecting`:case`pre-connect-buffering`:case`initializing`:return`connecting`;case`disconnected`:return`idle`;case`failed`:return`error`;default:return`idle`}}function c(e){return`RoomClass`in e}function l(e){return typeof e==`function`?e():e}function u(e){if(!e)return{};let t={},n=(e,n)=>{n!==void 0&&(t[e]=n)};return n(`roomName`,l(e.roomName)),n(`participantName`,l(e.participantName)),n(`participantIdentity`,l(e.participantIdentity)),n(`participantMetadata`,l(e.participantMetadata)),n(`participantAttributes`,typeof e.participantAttributes==`function`?e.participantAttributes():e.participantAttributes),n(`agentName`,l(e.agentName)),n(`agentMetadata`,l(e.agentMetadata)),n(`deployment`,l(e.deployment)),t}function d(e){if(!e.serverUrl||!e.participantToken)throw Error(`[orb-ui/livekit] connection details must include serverUrl and participantToken.`);return e}async function f(e){let t=u(e.tokenOptions);return typeof e.getConnectionDetails==`function`?d(await e.getConnectionDetails(t)):e.tokenSource?d(await e.tokenSource.fetch(t)):d({serverUrl:e.serverUrl,participantToken:e.participantToken})}function p(e){for(let[,n]of e.remoteParticipants)if(!n.isLocal&&(n.kind===t||n.attributes?.[`lk.agent.state`]!==void 0))return n;return null}function m(e,t,n){let r=e.off;if(r){r.call(e,t,n);return}e.removeListener?.call(e,t,n)}function h(e,t,n){e.on.call(e,t,n)}function g(l){let u=c(l),d=l.createAudioAnalyser,g={current:u?null:l.room},_=new Set,v={state:`idle`,volume:0,inputVolume:0,outputVolume:0},y=`idle`,b=null,x=null,S=null,C=null,w=null,T=null,E=null,D=0,O=null;function k(e){v=e,_.forEach(t=>t(e))}function A(e){k({...v,...e,state:e.state??v.state})}function j(e){let t=e<n?0:e,s=t>D?i:a;D+=(t-D)*s;let c=Math.min(D*r,1);return c/(c+o)}function M(){D=0,A({volume:0,outputVolume:0})}function N({emitZero:e=!0}={}){w&&=(clearInterval(w),null),C&&=(C.cleanup().catch(()=>{}),null),e&&A({volume:0,inputVolume:0})}function P(t){if(!(b===t&&C)){N({emitZero:!1}),b=t;try{C=d(t)}catch(e){console.warn(`[orb-ui/livekit] local createAudioAnalyser failed:`,e);return}w=setInterval(()=>{if(!C||y!==`listening`)return;let t=e(C.calculateVolume());A({volume:t,inputVolume:t,outputVolume:0})},33)}}function F({emitZero:e=!0}={}){E&&=(clearInterval(E),null),T&&=(T.cleanup().catch(()=>{}),null),D=0,e&&A({volume:0,outputVolume:0})}function I(e){F();try{T=d(e)}catch(e){console.warn(`[orb-ui/livekit] remote createAudioAnalyser failed:`,e);return}E=setInterval(()=>{if(!T||y!==`speaking`)return;let e=j(T.calculateVolume());A({volume:e,inputVolume:0,outputVolume:e})},33)}function L(e){y=e,A({state:e,volume:0,inputVolume:0,outputVolume:0}),e===`speaking`&&x?I(x):e!==`speaking`&&F({emitZero:!1})}function R(e){S||typeof document>`u`||(S=e.attach(),S.id=`orb-ui-livekit-agent-audio`,document.body.appendChild(S))}function z(){S&&=(S.remove(),null)}function B(e){x=e,R(e),y===`speaking`&&I(e)}function V(e){P(e)}function H(e){let t=e.getTrackPublication?.(`microphone`);t?.track&&V(t.track)}function U(e){let t=s(e);t!==y&&L(t)}function W(e){let t=e.attributes?.[`lk.agent.state`];t&&U(t);let n=e.getTrackPublication(`microphone`);n?.track&&B(n.track)}function G(e){if(O)return;let n=(e,t)=>{if(t.isLocal)return;let n=e[`lk.agent.state`];n&&U(n)},r=(e,n,r)=>{r.isLocal||!(r.kind===t||r.attributes?.[`lk.agent.state`]!==void 0)||e.mediaStreamTrack.kind!==`audio`||B(e)},i=e=>{x===e&&(x=null,z(),F())},a=e=>{e.source!==`microphone`||!e.track||V(e.track)},o=e=>{e.source===`microphone`&&(b=null,N())},s=()=>{b=null,x=null,z(),N({emitZero:!1}),F({emitZero:!1}),L(`idle`)};if(h(e,`participantAttributesChanged`,n),h(e,`trackSubscribed`,r),h(e,`trackUnsubscribed`,i),h(e,`localTrackPublished`,a),h(e,`localTrackUnpublished`,o),h(e,`disconnected`,s),O=()=>{m(e,`participantAttributesChanged`,n),m(e,`trackSubscribed`,r),m(e,`trackUnsubscribed`,i),m(e,`localTrackPublished`,a),m(e,`localTrackUnpublished`,o),m(e,`disconnected`,s)},H(e.localParticipant),e.state===`connected`){let t=p(e);t?W(t):L(`connecting`)}else L(`idle`)}function K(){O?.(),O=null,b=null,x=null,z(),N({emitZero:!1}),F({emitZero:!1}),A({volume:0,inputVolume:0,outputVolume:0})}let q=e=>{_.add(e),e(v);let t=g.current;return t&&G(t),()=>{_.delete(e),_.size===0&&K()}};return u?{subscribe:q,async start(){if(g.current)return;let e=l,t=new e.RoomClass;L(`connecting`);try{let n=await f(e);if(await t.connect(n.serverUrl,n.participantToken,e.connectOptions),g.current=t,G(t),e.enableMicrophone!==!1){let e=(await t.localParticipant.setMicrophoneEnabled(!0))?.track??t.localParticipant.getTrackPublication?.(`microphone`)?.track;e&&V(e)}}catch(e){throw console.error(`[orb-ui/livekit] connect failed:`,e),g.current===t&&K(),t.disconnect(),g.current=null,L(`error`),M(),A({error:e}),e}},async stop(){let e=g.current;if(!e){L(`idle`);return}K(),e.disconnect(),g.current=null,L(`idle`)}}:{subscribe:q}}Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return g}});