@livekit/components-react
Advanced tools
| import * as e from "react"; | ||
| import { useState as B, useRef as z, useEffect as V, useMemo as Ne } from "react"; | ||
| import { u as Le, a as he, b as ze, c as Ve, d as Fe, e as Ze, f as ge, g as He, h as Be, i as je, j as _e, k as Oe, l as ve, m as We, n as qe, o as $e, p as De, q as Ue, r as Ge, s as Ee, t as Qe, v as Xe } from "./hooks-0IvkS6LV.mjs"; | ||
| import { a as I, c as ee } from "./room-Bb6uLxS5.mjs"; | ||
| import { RoomEvent as Ye, Track as S, ConnectionQuality as Q, RemoteTrackPublication as J, RemoteAudioTrack as Je, ConnectionState as X } from "livekit-client"; | ||
| import { ae as te, af as pe, w as Ke, u as et, f as tt, c as at, ag as nt, X as rt, Y as ct, a1 as $, l as j, ah as q, ai as lt, i as _, B as st, aj as we, ak as ae, j as it, al as ot, m as ut, p as ke, am as dt, an as mt, ao as ft, ap as ht, aq as gt, ar as vt, R as Et } from "./contexts-CsO1QZ3r.mjs"; | ||
| const ca = /* @__PURE__ */ e.forwardRef( | ||
| function(n, a) { | ||
| const { buttonProps: c } = Le(n); | ||
| return /* @__PURE__ */ e.createElement("button", { ref: a, ...c }, n.children); | ||
| } | ||
| ), la = /* @__PURE__ */ e.forwardRef( | ||
| function({ room: n, ...a }, c) { | ||
| const r = he(n); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: c, ...a }, r); | ||
| } | ||
| ), sa = /* @__PURE__ */ e.forwardRef( | ||
| function(n, a) { | ||
| const { mergedProps: c } = ze({ props: n }); | ||
| return /* @__PURE__ */ e.createElement("button", { ref: a, ...c }, n.children); | ||
| } | ||
| ), ia = /* @__PURE__ */ e.forwardRef( | ||
| function(n, a) { | ||
| const { buttonProps: c } = Ve(n); | ||
| return /* @__PURE__ */ e.createElement("button", { ref: a, ...c }, n.children); | ||
| } | ||
| ), pt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708L11 10.293V4.5A1.5 1.5 0 0 0 9.5 3H3.707zM0 4.5a1.5 1.5 0 0 1 .943-1.393l9.532 9.533c-.262.224-.603.36-.975.36h-8A1.5 1.5 0 0 1 0 11.5z" }), /* @__PURE__ */ e.createElement("path", { d: "m15.2 3.6-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z" })), wt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M0 4.5A1.5 1.5 0 0 1 1.5 3h8A1.5 1.5 0 0 1 11 4.5v7A1.5 1.5 0 0 1 9.5 13h-8A1.5 1.5 0 0 1 0 11.5zM15.2 3.6l-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z" })), oa = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, viewBox: "0 0 24 24", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "#FFF", | ||
| d: "M4.99 3.99a1 1 0 0 0-.697 1.717L10.586 12l-6.293 6.293a1 1 0 1 0 1.414 1.414L12 13.414l6.293 6.293a1 1 0 1 0 1.414-1.414L13.414 12l6.293-6.293a1 1 0 0 0-.727-1.717 1 1 0 0 0-.687.303L12 10.586 5.707 4.293a1 1 0 0 0-.717-.303z" | ||
| } | ||
| )), ua = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 18, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M0 2.75A2.75 2.75 0 0 1 2.75 0h10.5A2.75 2.75 0 0 1 16 2.75v13.594a.75.75 0 0 1-1.234.572l-3.691-3.12a1.25 1.25 0 0 0-.807-.296H2.75A2.75 2.75 0 0 1 0 10.75v-8ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v8c0 .69.56 1.25 1.25 1.25h7.518c.65 0 1.279.23 1.775.65l2.457 2.077V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M3 4.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), ie = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentcolor", | ||
| fillRule: "evenodd", | ||
| d: "M5.293 2.293a1 1 0 0 1 1.414 0l4.823 4.823a1.25 1.25 0 0 1 0 1.768l-4.823 4.823a1 1 0 0 1-1.414-1.414L9.586 8 5.293 3.707a1 1 0 0 1 0-1.414z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), kt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement("g", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5 }, /* @__PURE__ */ e.createElement("path", { d: "M10 1.75h4.25m0 0V6m0-4.25L9 7M6 14.25H1.75m0 0V10m0 4.25L7 9" }))), da = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentcolor", | ||
| fillRule: "evenodd", | ||
| d: "M8.961.894C8.875-.298 7.125-.298 7.04.894c-.066.912-1.246 1.228-1.76.472-.67-.99-2.186-.115-1.664.96.399.824-.465 1.688-1.288 1.289-1.076-.522-1.95.994-.961 1.665.756.513.44 1.693-.472 1.759-1.192.086-1.192 1.836 0 1.922.912.066 1.228 1.246.472 1.76-.99.67-.115 2.186.96 1.664.824-.399 1.688.465 1.289 1.288-.522 1.076.994 1.95 1.665.961.513-.756 1.693-.44 1.759.472.086 1.192 1.836 1.192 1.922 0 .066-.912 1.246-1.228 1.76-.472.67.99 2.186.115 1.664-.96-.399-.824.465-1.688 1.288-1.289 1.076.522 1.95-.994.961-1.665-.756-.513-.44-1.693.472-1.759 1.192-.086 1.192-1.836 0-1.922-.912-.066-1.228-1.246-.472-1.76.99-.67.115-2.186-.96-1.664-.824.399-1.688-.465-1.289-1.288.522-1.076-.994-1.95-1.665-.961-.513.756-1.693.44-1.759-.472ZM8 13A5 5 0 1 0 8 3a5 5 0 0 0 0 10Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), ma = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M2 2.75A2.75 2.75 0 0 1 4.75 0h6.5A2.75 2.75 0 0 1 14 2.75v10.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-.5a.75.75 0 0 1 1.5 0v.5c0 .69.56 1.25 1.25 1.25h6.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25h-6.5c-.69 0-1.25.56-1.25 1.25v.5a.75.75 0 0 1-1.5 0v-.5Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M8.78 7.47a.75.75 0 0 1 0 1.06l-2.25 2.25a.75.75 0 1 1-1.06-1.06l.97-.97H1.75a.75.75 0 0 1 0-1.5h4.69l-.97-.97a.75.75 0 0 1 1.06-1.06l2.25 2.25Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), Rt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentcolor", | ||
| fillRule: "evenodd", | ||
| d: "M4 6.104V4a4 4 0 1 1 8 0v2.104c1.154.326 2 1.387 2 2.646v4.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-4.5c0-1.259.846-2.32 2-2.646ZM5.5 4a2.5 2.5 0 0 1 5 0v2h-5V4Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), Mt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M12.227 11.52a5.477 5.477 0 0 0 1.246-2.97.5.5 0 0 0-.995-.1 4.478 4.478 0 0 1-.962 2.359l-1.07-1.07C10.794 9.247 11 8.647 11 8V3a3 3 0 0 0-6 0v1.293L1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708zM8 12.5c.683 0 1.33-.152 1.911-.425l.743.743c-.649.359-1.378.59-2.154.66V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .995-.098A4.5 4.5 0 0 0 8 12.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M8.743 10.907 5 7.164V8a3 3 0 0 0 3.743 2.907z" })), yt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fillRule: "evenodd", | ||
| d: "M2.975 8.002a.5.5 0 0 1 .547.449 4.5 4.5 0 0 0 8.956 0 .5.5 0 1 1 .995.098A5.502 5.502 0 0 1 8.5 13.478V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .448-.547z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement("path", { d: "M5 3a3 3 0 1 1 6 0v5a3 3 0 0 1-6 0z" })), bt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentcolor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" })), St = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentcolor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("g", { opacity: 0.25 }, /* @__PURE__ */ e.createElement("path", { d: "M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }))), Ct = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentcolor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("g", { opacity: 0.25 }, /* @__PURE__ */ e.createElement("path", { d: "M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }))), It = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement("g", { opacity: 0.25 }, /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z" }), /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z" }))), Re = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M0 2.75A2.75 2.75 0 0 1 2.75 0h14.5A2.75 2.75 0 0 1 20 2.75v10.5A2.75 2.75 0 0 1 17.25 16H2.75A2.75 2.75 0 0 1 0 13.25V2.75ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h14.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M9.47 4.22a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1-1.06 1.06l-.97-.97v4.69a.75.75 0 0 1-1.5 0V6.56l-.97.97a.75.75 0 0 1-1.06-1.06l2.25-2.25Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), xt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement("g", { fill: "currentColor" }, /* @__PURE__ */ e.createElement("path", { d: "M7.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L10 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L11.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L10 6.94z" }), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fillRule: "evenodd", | ||
| d: "M2.75 0A2.75 2.75 0 0 0 0 2.75v10.5A2.75 2.75 0 0 0 2.75 16h14.5A2.75 2.75 0 0 0 20 13.25V2.75A2.75 2.75 0 0 0 17.25 0zM1.5 2.75c0-.69.56-1.25 1.25-1.25h14.5c.69 0 1.25.56 1.25 1.25v10.5c0 .69-.56 1.25-1.25 1.25H2.75c-.69 0-1.25-.56-1.25-1.25z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ))), oe = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M8 0a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0V.75A.75.75 0 0 1 8 0Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M8 12a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5A.75.75 0 0 1 8 12Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.7 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M12 1.072a.75.75 0 0 1 .274 1.024l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 12 1.072Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M6 11.464a.75.75 0 0 1 .274 1.025l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 6 11.464Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.6 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M14.928 4a.75.75 0 0 1-.274 1.025l-2.165 1.25a.75.75 0 1 1-.75-1.3l2.165-1.25A.75.75 0 0 1 14.928 4Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M4.536 10a.75.75 0 0 1-.275 1.024l-2.165 1.25a.75.75 0 0 1-.75-1.298l2.165-1.25A.75.75 0 0 1 4.536 10Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.5 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M16 8a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 16 8Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M4 8a.75.75 0 0 1-.75.75H.75a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 4 8Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.4 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M14.928 12a.75.75 0 0 1-1.024.274l-2.165-1.25a.75.75 0 0 1 .75-1.299l2.165 1.25A.75.75 0 0 1 14.928 12Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.9 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M4.536 6a.75.75 0 0 1-1.025.275l-2.165-1.25a.75.75 0 1 1 .75-1.3l2.165 1.25A.75.75 0 0 1 4.536 6Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.3 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M12 14.928a.75.75 0 0 1-1.024-.274l-1.25-2.165a.75.75 0 0 1 1.298-.75l1.25 2.165A.75.75 0 0 1 12 14.928Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.8 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M6 4.536a.75.75 0 0 1-1.024-.275l-1.25-2.165a.75.75 0 1 1 1.299-.75l1.25 2.165A.75.75 0 0 1 6 4.536Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.2 | ||
| } | ||
| )), Pt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement("g", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5 }, /* @__PURE__ */ e.createElement("path", { d: "M13.25 7H9m0 0V2.75M9 7l5.25-5.25M2.75 9H7m0 0v4.25M7 9l-5.25 5.25" }))), Tt = /* @__PURE__ */ e.forwardRef( | ||
| function({ trackRef: n, ...a }, c) { | ||
| const r = te(), { mergedProps: s, inFocus: o } = Fe({ | ||
| trackRef: n ?? r, | ||
| props: a | ||
| }); | ||
| return /* @__PURE__ */ e.createElement(pe.Consumer, null, (l) => l !== void 0 && /* @__PURE__ */ e.createElement("button", { ref: c, ...s }, a.children ? a.children : o ? /* @__PURE__ */ e.createElement(Pt, null) : /* @__PURE__ */ e.createElement(kt, null))); | ||
| } | ||
| ), fa = /* @__PURE__ */ e.forwardRef( | ||
| function({ | ||
| kind: n, | ||
| initialSelection: a, | ||
| onActiveDeviceChange: c, | ||
| onDeviceListChange: r, | ||
| onDeviceSelectError: s, | ||
| exactMatch: o, | ||
| track: l, | ||
| requestPermissions: i, | ||
| onError: d, | ||
| ...u | ||
| }, v) { | ||
| const f = Ke(), p = e.useRef("default"), E = e.useCallback( | ||
| (w) => { | ||
| f && f.emit(Ye.MediaDevicesError, w), d == null || d(w); | ||
| }, | ||
| [f, d] | ||
| ), { devices: h, activeDeviceId: m, setActiveMediaDevice: y, className: C } = Ze({ | ||
| kind: n, | ||
| room: f, | ||
| track: l, | ||
| requestPermissions: i, | ||
| onError: E | ||
| }); | ||
| e.useEffect(() => { | ||
| a !== void 0 && y(a); | ||
| }, [y]), e.useEffect(() => { | ||
| typeof r == "function" && r(h); | ||
| }, [r, h]), e.useEffect(() => { | ||
| m !== p.current && (c == null || c(m)), p.current = m; | ||
| }, [m]); | ||
| const A = async (w) => { | ||
| try { | ||
| await y(w, { exact: o ?? !0 }); | ||
| } catch (M) { | ||
| if (M instanceof Error) | ||
| s == null || s(M); | ||
| else | ||
| throw M; | ||
| } | ||
| }, N = e.useMemo( | ||
| () => I(u, { className: C }, { className: "lk-list" }), | ||
| [C, u] | ||
| ), g = !!h.find((w) => w.label.toLowerCase().startsWith("default")); | ||
| function R(w, M, P) { | ||
| return w === M || !g && P === 0 && M === "default"; | ||
| } | ||
| return /* @__PURE__ */ e.createElement("ul", { ref: v, ...N }, h.map((w, M) => /* @__PURE__ */ e.createElement( | ||
| "li", | ||
| { | ||
| key: w.deviceId, | ||
| id: w.deviceId, | ||
| "data-lk-active": R(w.deviceId, m, M), | ||
| "aria-selected": R(w.deviceId, m, M), | ||
| role: "option" | ||
| }, | ||
| /* @__PURE__ */ e.createElement("button", { className: "lk-button", onClick: () => A(w.deviceId) }, w.label) | ||
| ))); | ||
| } | ||
| ), ha = /* @__PURE__ */ e.forwardRef( | ||
| function({ label: n = "Allow Audio", ...a }, c) { | ||
| const r = et(a.room), { mergedProps: s } = ge({ room: r, props: a }); | ||
| return /* @__PURE__ */ e.createElement("button", { ref: c, ...s }, n); | ||
| } | ||
| ), ga = /* @__PURE__ */ e.forwardRef( | ||
| function({ label: n, ...a }, c) { | ||
| const r = tt(), { mergedProps: s, canPlayAudio: o } = ge({ room: r, props: a }), { mergedProps: l, canPlayVideo: i } = He({ room: r, props: s }), { style: d, ...u } = l; | ||
| return d.display = o && i ? "none" : "block", /* @__PURE__ */ e.createElement("button", { ref: c, style: d, ...u }, n ?? `Start ${o ? "Video" : "Audio"}`); | ||
| } | ||
| ); | ||
| function Me(t, n) { | ||
| switch (t) { | ||
| case S.Source.Microphone: | ||
| return n ? /* @__PURE__ */ e.createElement(yt, null) : /* @__PURE__ */ e.createElement(Mt, null); | ||
| case S.Source.Camera: | ||
| return n ? /* @__PURE__ */ e.createElement(wt, null) : /* @__PURE__ */ e.createElement(pt, null); | ||
| case S.Source.ScreenShare: | ||
| return n ? /* @__PURE__ */ e.createElement(xt, null) : /* @__PURE__ */ e.createElement(Re, null); | ||
| default: | ||
| return; | ||
| } | ||
| } | ||
| function At(t) { | ||
| switch (t) { | ||
| case Q.Excellent: | ||
| return /* @__PURE__ */ e.createElement(bt, null); | ||
| case Q.Good: | ||
| return /* @__PURE__ */ e.createElement(St, null); | ||
| case Q.Poor: | ||
| return /* @__PURE__ */ e.createElement(Ct, null); | ||
| default: | ||
| return /* @__PURE__ */ e.createElement(It, null); | ||
| } | ||
| } | ||
| const va = /* @__PURE__ */ e.forwardRef(function({ showIcon: n, ...a }, c) { | ||
| const { buttonProps: r, enabled: s } = Be(a), [o, l] = e.useState(!1); | ||
| return e.useEffect(() => { | ||
| l(!0); | ||
| }, []), o && /* @__PURE__ */ e.createElement("button", { ref: c, ...r }, (n ?? !0) && Me(a.source, s), a.children); | ||
| }), ye = /* @__PURE__ */ e.forwardRef(function(n, a) { | ||
| const { className: c, quality: r } = je(n), s = e.useMemo(() => ({ ...I(n, { className: c }), "data-lk-quality": r }), [r, n, c]); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: a, ...s }, n.children ?? At(r)); | ||
| }), K = /* @__PURE__ */ e.forwardRef( | ||
| function({ participant: n, ...a }, c) { | ||
| const r = at(n), { className: s, infoObserver: o } = e.useMemo(() => nt(r), [r]), { identity: l, name: i } = _e(o, { | ||
| name: r.name, | ||
| identity: r.identity, | ||
| metadata: r.metadata | ||
| }), d = e.useMemo(() => I(a, { className: s, "data-lk-participant-name": i }), [a, s, i]); | ||
| return /* @__PURE__ */ e.createElement("span", { ref: c, ...d }, i !== "" ? i : l, a.children); | ||
| } | ||
| ), be = /* @__PURE__ */ e.forwardRef( | ||
| function({ trackRef: n, show: a = "always", ...c }, r) { | ||
| const { className: s, isMuted: o } = Oe(n), l = a === "always" || a === "muted" && o || a === "unmuted" && !o, i = e.useMemo( | ||
| () => I(c, { | ||
| className: s | ||
| }), | ||
| [s, c] | ||
| ); | ||
| return l ? /* @__PURE__ */ e.createElement("div", { ref: r, ...i, "data-lk-muted": o }, c.children ?? Me(n.source, !o)) : null; | ||
| } | ||
| ), Nt = (t) => /* @__PURE__ */ e.createElement( | ||
| "svg", | ||
| { | ||
| width: 320, | ||
| height: 320, | ||
| viewBox: "0 0 320 320", | ||
| preserveAspectRatio: "xMidYMid meet", | ||
| fill: "none", | ||
| xmlns: "http://www.w3.org/2000/svg", | ||
| ...t | ||
| }, | ||
| /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| d: "M160 180C204.182 180 240 144.183 240 100C240 55.8172 204.182 20 160 20C115.817 20 79.9997 55.8172 79.9997 100C79.9997 144.183 115.817 180 160 180Z", | ||
| fill: "white", | ||
| fillOpacity: 0.25 | ||
| } | ||
| ), | ||
| /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| d: "M97.6542 194.614C103.267 191.818 109.841 192.481 115.519 195.141C129.025 201.466 144.1 205 159.999 205C175.899 205 190.973 201.466 204.48 195.141C210.158 192.481 216.732 191.818 222.345 194.614C262.703 214.719 291.985 253.736 298.591 300.062C300.15 310.997 291.045 320 280 320H39.9997C28.954 320 19.8495 310.997 21.4087 300.062C28.014 253.736 57.2966 214.72 97.6542 194.614Z", | ||
| fill: "white", | ||
| fillOpacity: 0.25 | ||
| } | ||
| ) | ||
| ); | ||
| function Se(t, n = {}) { | ||
| const [a, c] = e.useState(rt(t)), [r, s] = e.useState(a == null ? void 0 : a.isMuted), [o, l] = e.useState(a == null ? void 0 : a.isSubscribed), [i, d] = e.useState(a == null ? void 0 : a.track), [u, v] = e.useState("landscape"), f = e.useRef(), { className: p, trackObserver: E } = e.useMemo(() => ct(t), [ | ||
| t.participant.sid ?? t.participant.identity, | ||
| t.source, | ||
| $(t) && t.publication.trackSid | ||
| ]); | ||
| return e.useEffect(() => { | ||
| const h = E.subscribe((m) => { | ||
| j.debug("update track", m), c(m), s(m == null ? void 0 : m.isMuted), l(m == null ? void 0 : m.isSubscribed), d(m == null ? void 0 : m.track); | ||
| }); | ||
| return () => h == null ? void 0 : h.unsubscribe(); | ||
| }, [E]), e.useEffect(() => { | ||
| var h, m; | ||
| return i && (f.current && i.detach(f.current), (h = n.element) != null && h.current && !(t.participant.isLocal && (i == null ? void 0 : i.kind) === "audio") && i.attach(n.element.current)), f.current = (m = n.element) == null ? void 0 : m.current, () => { | ||
| f.current && (i == null || i.detach(f.current)); | ||
| }; | ||
| }, [i, n.element]), e.useEffect(() => { | ||
| var h, m; | ||
| if (typeof ((h = a == null ? void 0 : a.dimensions) == null ? void 0 : h.width) == "number" && typeof ((m = a == null ? void 0 : a.dimensions) == null ? void 0 : m.height) == "number") { | ||
| const y = a.dimensions.width > a.dimensions.height ? "landscape" : "portrait"; | ||
| v(y); | ||
| } | ||
| }, [a]), { | ||
| publication: a, | ||
| isMuted: r, | ||
| isSubscribed: o, | ||
| track: i, | ||
| elementProps: I(n.props, { | ||
| className: p, | ||
| "data-lk-local-participant": t.participant.isLocal, | ||
| "data-lk-source": a == null ? void 0 : a.source, | ||
| ...(a == null ? void 0 : a.kind) === "video" && { "data-lk-orientation": u } | ||
| }) | ||
| }; | ||
| } | ||
| var Y, ue; | ||
| function Lt() { | ||
| if (ue) return Y; | ||
| ue = 1; | ||
| var t = "Expected a function", n = NaN, a = "[object Symbol]", c = /^\s+|\s+$/g, r = /^[-+]0x[0-9a-f]+$/i, s = /^0b[01]+$/i, o = /^0o[0-7]+$/i, l = parseInt, i = typeof q == "object" && q && q.Object === Object && q, d = typeof self == "object" && self && self.Object === Object && self, u = i || d || Function("return this")(), v = Object.prototype, f = v.toString, p = Math.max, E = Math.min, h = function() { | ||
| return u.Date.now(); | ||
| }; | ||
| function m(g, R, w) { | ||
| var M, P, O, L, b, T, F = 0, re = !1, Z = !1, D = !0; | ||
| if (typeof g != "function") | ||
| throw new TypeError(t); | ||
| R = N(R) || 0, y(w) && (re = !!w.leading, Z = "maxWait" in w, O = Z ? p(N(w.maxWait) || 0, R) : O, D = "trailing" in w ? !!w.trailing : D); | ||
| function U(k) { | ||
| var x = M, H = P; | ||
| return M = P = void 0, F = k, L = g.apply(H, x), L; | ||
| } | ||
| function xe(k) { | ||
| return F = k, b = setTimeout(W, R), re ? U(k) : L; | ||
| } | ||
| function Pe(k) { | ||
| var x = k - T, H = k - F, se = R - x; | ||
| return Z ? E(se, O - H) : se; | ||
| } | ||
| function ce(k) { | ||
| var x = k - T, H = k - F; | ||
| return T === void 0 || x >= R || x < 0 || Z && H >= O; | ||
| } | ||
| function W() { | ||
| var k = h(); | ||
| if (ce(k)) | ||
| return le(k); | ||
| b = setTimeout(W, Pe(k)); | ||
| } | ||
| function le(k) { | ||
| return b = void 0, D && M ? U(k) : (M = P = void 0, L); | ||
| } | ||
| function Te() { | ||
| b !== void 0 && clearTimeout(b), F = 0, M = T = P = b = void 0; | ||
| } | ||
| function Ae() { | ||
| return b === void 0 ? L : le(h()); | ||
| } | ||
| function G() { | ||
| var k = h(), x = ce(k); | ||
| if (M = arguments, P = this, T = k, x) { | ||
| if (b === void 0) | ||
| return xe(T); | ||
| if (Z) | ||
| return b = setTimeout(W, R), U(T); | ||
| } | ||
| return b === void 0 && (b = setTimeout(W, R)), L; | ||
| } | ||
| return G.cancel = Te, G.flush = Ae, G; | ||
| } | ||
| function y(g) { | ||
| var R = typeof g; | ||
| return !!g && (R == "object" || R == "function"); | ||
| } | ||
| function C(g) { | ||
| return !!g && typeof g == "object"; | ||
| } | ||
| function A(g) { | ||
| return typeof g == "symbol" || C(g) && f.call(g) == a; | ||
| } | ||
| function N(g) { | ||
| if (typeof g == "number") | ||
| return g; | ||
| if (A(g)) | ||
| return n; | ||
| if (y(g)) { | ||
| var R = typeof g.valueOf == "function" ? g.valueOf() : g; | ||
| g = y(R) ? R + "" : R; | ||
| } | ||
| if (typeof g != "string") | ||
| return g === 0 ? g : +g; | ||
| g = g.replace(c, ""); | ||
| var w = s.test(g); | ||
| return w || o.test(g) ? l(g.slice(2), w ? 2 : 8) : r.test(g) ? n : +g; | ||
| } | ||
| return Y = m, Y; | ||
| } | ||
| var zt = Lt(); | ||
| const de = /* @__PURE__ */ lt(zt); | ||
| function Vt(t) { | ||
| const n = z(t); | ||
| n.current = t, V( | ||
| () => () => { | ||
| n.current(); | ||
| }, | ||
| [] | ||
| ); | ||
| } | ||
| function Ft(t, n = 500, a) { | ||
| const c = z(); | ||
| Vt(() => { | ||
| c.current && c.current.cancel(); | ||
| }); | ||
| const r = Ne(() => { | ||
| const s = de(t, n, a), o = (...l) => s(...l); | ||
| return o.cancel = () => { | ||
| s.cancel(); | ||
| }, o.isPending = () => !!c.current, o.flush = () => s.flush(), o; | ||
| }, [t, n, a]); | ||
| return V(() => { | ||
| c.current = de(t, n, a); | ||
| }, [t, n, a]), r; | ||
| } | ||
| function Zt(t, n, a) { | ||
| const c = ((d, u) => d === u), r = t instanceof Function ? t() : t, [s, o] = B(r), l = z(r), i = Ft( | ||
| o, | ||
| n, | ||
| a | ||
| ); | ||
| return c(l.current, r) || (i(r), l.current = r), [s, i]; | ||
| } | ||
| function Ht({ | ||
| threshold: t = 0, | ||
| root: n = null, | ||
| rootMargin: a = "0%", | ||
| freezeOnceVisible: c = !1, | ||
| initialIsIntersecting: r = !1, | ||
| onChange: s | ||
| } = {}) { | ||
| var o; | ||
| const [l, i] = B(null), [d, u] = B(() => ({ | ||
| isIntersecting: r, | ||
| entry: void 0 | ||
| })), v = z(); | ||
| v.current = s; | ||
| const f = ((o = d.entry) == null ? void 0 : o.isIntersecting) && c; | ||
| V(() => { | ||
| if (!l || !("IntersectionObserver" in window) || f) | ||
| return; | ||
| const h = new IntersectionObserver( | ||
| (m) => { | ||
| const y = Array.isArray(h.thresholds) ? h.thresholds : [h.thresholds]; | ||
| m.forEach((C) => { | ||
| const A = C.isIntersecting && y.some((N) => C.intersectionRatio >= N); | ||
| u({ isIntersecting: A, entry: C }), v.current && v.current(A, C); | ||
| }); | ||
| }, | ||
| { threshold: t, root: n, rootMargin: a } | ||
| ); | ||
| return h.observe(l), () => { | ||
| h.disconnect(); | ||
| }; | ||
| }, [ | ||
| l, | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| JSON.stringify(t), | ||
| n, | ||
| a, | ||
| f, | ||
| c | ||
| ]); | ||
| const p = z(null); | ||
| V(() => { | ||
| var h; | ||
| !l && ((h = d.entry) != null && h.target) && !c && !f && p.current !== d.entry.target && (p.current = d.entry.target, u({ isIntersecting: r, entry: void 0 })); | ||
| }, [l, d.entry, c, f, r]); | ||
| const E = [ | ||
| i, | ||
| !!d.isIntersecting, | ||
| d.entry | ||
| ]; | ||
| return E.ref = E[0], E.isIntersecting = E[1], E.entry = E[2], E; | ||
| } | ||
| const Bt = /* @__PURE__ */ e.forwardRef( | ||
| function({ | ||
| onTrackClick: n, | ||
| onClick: a, | ||
| onSubscriptionStatusChanged: c, | ||
| trackRef: r, | ||
| manageSubscription: s, | ||
| ...o | ||
| }, l) { | ||
| const i = _(r), d = e.useRef(null); | ||
| e.useImperativeHandle(l, () => d.current); | ||
| const u = Ht({ root: d.current }), [v] = Zt(u, 3e3); | ||
| e.useEffect(() => { | ||
| s && i.publication instanceof J && (v == null ? void 0 : v.isIntersecting) === !1 && (u == null ? void 0 : u.isIntersecting) === !1 && i.publication.setSubscribed(!1); | ||
| }, [v, i, s]), e.useEffect(() => { | ||
| s && i.publication instanceof J && (u == null ? void 0 : u.isIntersecting) === !0 && i.publication.setSubscribed(!0); | ||
| }, [u, i, s]); | ||
| const { | ||
| elementProps: f, | ||
| publication: p, | ||
| isSubscribed: E | ||
| } = Se(i, { | ||
| element: d, | ||
| props: o | ||
| }); | ||
| e.useEffect(() => { | ||
| c == null || c(!!E); | ||
| }, [E, c]); | ||
| const h = (m) => { | ||
| a == null || a(m), n == null || n({ participant: i == null ? void 0 : i.participant, track: p }); | ||
| }; | ||
| return /* @__PURE__ */ e.createElement("video", { ref: d, ...f, muted: !0, onClick: h }); | ||
| } | ||
| ), ne = /* @__PURE__ */ e.forwardRef( | ||
| function({ trackRef: n, onSubscriptionStatusChanged: a, volume: c, ...r }, s) { | ||
| const o = _(n), l = e.useRef(null); | ||
| e.useImperativeHandle(s, () => l.current); | ||
| const { | ||
| elementProps: i, | ||
| isSubscribed: d, | ||
| track: u, | ||
| publication: v | ||
| } = Se(o, { | ||
| element: l, | ||
| props: r | ||
| }); | ||
| return e.useEffect(() => { | ||
| a == null || a(!!d); | ||
| }, [d, a]), e.useEffect(() => { | ||
| u === void 0 || c === void 0 || (u instanceof Je ? u.setVolume(c) : j.warn("Volume can only be set on remote audio tracks.")); | ||
| }, [c, u]), e.useEffect(() => { | ||
| v === void 0 || r.muted === void 0 || (v instanceof J ? v.setEnabled(!r.muted) : j.warn("Can only call setEnabled on remote track publications.")); | ||
| }, [r.muted, v, u]), /* @__PURE__ */ e.createElement("audio", { ref: l, ...i }); | ||
| } | ||
| ); | ||
| function jt(t) { | ||
| const n = !!st(); | ||
| return t.participant && !n ? /* @__PURE__ */ e.createElement(we.Provider, { value: t.participant }, t.children) : /* @__PURE__ */ e.createElement(e.Fragment, null, t.children); | ||
| } | ||
| function _t(t) { | ||
| const n = !!te(); | ||
| return t.trackRef && !n ? /* @__PURE__ */ e.createElement(ae.Provider, { value: t.trackRef }, t.children) : /* @__PURE__ */ e.createElement(e.Fragment, null, t.children); | ||
| } | ||
| const Ot = /* @__PURE__ */ e.forwardRef( | ||
| function({ | ||
| trackRef: n, | ||
| children: a, | ||
| onParticipantClick: c, | ||
| disableSpeakingIndicator: r, | ||
| ...s | ||
| }, o) { | ||
| var p, E; | ||
| const l = _(n), { elementProps: i } = ve({ | ||
| htmlProps: s, | ||
| disableSpeakingIndicator: r, | ||
| onParticipantClick: c, | ||
| trackRef: l | ||
| }), d = We(l.participant), u = it(), v = (p = ot()) == null ? void 0 : p.autoSubscription, f = e.useCallback( | ||
| (h) => { | ||
| l.source && !h && u && u.pin.dispatch && ut(l, u.pin.state) && u.pin.dispatch({ msg: "clear_pin" }); | ||
| }, | ||
| [l, u] | ||
| ); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: o, style: { position: "relative" }, ...i }, /* @__PURE__ */ e.createElement(_t, { trackRef: l }, /* @__PURE__ */ e.createElement(jt, { participant: l.participant }, a ?? /* @__PURE__ */ e.createElement(e.Fragment, null, $(l) && (((E = l.publication) == null ? void 0 : E.kind) === "video" || l.source === S.Source.Camera || l.source === S.Source.ScreenShare) ? /* @__PURE__ */ e.createElement( | ||
| Bt, | ||
| { | ||
| trackRef: l, | ||
| onSubscriptionStatusChanged: f, | ||
| manageSubscription: v | ||
| } | ||
| ) : $(l) && /* @__PURE__ */ e.createElement( | ||
| ne, | ||
| { | ||
| trackRef: l, | ||
| onSubscriptionStatusChanged: f | ||
| } | ||
| ), /* @__PURE__ */ e.createElement("div", { className: "lk-participant-placeholder" }, /* @__PURE__ */ e.createElement(Nt, null)), /* @__PURE__ */ e.createElement("div", { className: "lk-participant-metadata" }, /* @__PURE__ */ e.createElement("div", { className: "lk-participant-metadata-item" }, l.source === S.Source.Camera ? /* @__PURE__ */ e.createElement(e.Fragment, null, d && /* @__PURE__ */ e.createElement(Rt, { style: { marginRight: "0.25rem" } }), /* @__PURE__ */ e.createElement( | ||
| be, | ||
| { | ||
| trackRef: { | ||
| participant: l.participant, | ||
| source: S.Source.Microphone | ||
| }, | ||
| show: "muted" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement(K, null)) : /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(Re, { style: { marginRight: "0.25rem" } }), /* @__PURE__ */ e.createElement(K, null, "'s screen"))), /* @__PURE__ */ e.createElement(ye, { className: "lk-participant-metadata-item" }))), /* @__PURE__ */ e.createElement(Tt, { trackRef: l })))); | ||
| } | ||
| ); | ||
| function Ea(t) { | ||
| const n = I(t, { className: "lk-focus-layout" }); | ||
| return /* @__PURE__ */ e.createElement("div", { ...n }, t.children); | ||
| } | ||
| function pa({ trackRef: t, ...n }) { | ||
| return /* @__PURE__ */ e.createElement(Ot, { trackRef: t, ...n }); | ||
| } | ||
| function Ce({ tracks: t, ...n }) { | ||
| return /* @__PURE__ */ e.createElement(e.Fragment, null, t.map((a) => /* @__PURE__ */ e.createElement( | ||
| ae.Provider, | ||
| { | ||
| value: a, | ||
| key: ke(a) | ||
| }, | ||
| ee(n.children) | ||
| ))); | ||
| } | ||
| function Wt({ | ||
| totalPageCount: t, | ||
| nextPage: n, | ||
| prevPage: a, | ||
| currentPage: c, | ||
| pagesContainer: r | ||
| }) { | ||
| const [s, o] = e.useState(!1); | ||
| return e.useEffect(() => { | ||
| let l; | ||
| return r && (l = dt(r.current, 2e3).subscribe( | ||
| o | ||
| )), () => { | ||
| l && l.unsubscribe(); | ||
| }; | ||
| }, [r]), /* @__PURE__ */ e.createElement("div", { className: "lk-pagination-control", "data-lk-user-interaction": s }, /* @__PURE__ */ e.createElement("button", { className: "lk-button", onClick: a }, /* @__PURE__ */ e.createElement(ie, null)), /* @__PURE__ */ e.createElement("span", { className: "lk-pagination-count" }, `${c} of ${t}`), /* @__PURE__ */ e.createElement("button", { className: "lk-button", onClick: n }, /* @__PURE__ */ e.createElement(ie, null))); | ||
| } | ||
| const qt = /* @__PURE__ */ e.forwardRef( | ||
| function({ totalPageCount: n, currentPage: a }, c) { | ||
| const r = new Array(n).fill("").map((s, o) => o + 1 === a ? /* @__PURE__ */ e.createElement("span", { "data-lk-active": !0, key: o }) : /* @__PURE__ */ e.createElement("span", { key: o })); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: c, className: "lk-pagination-indicator" }, r); | ||
| } | ||
| ); | ||
| function wa({ tracks: t, ...n }) { | ||
| const a = e.createRef(), c = e.useMemo( | ||
| () => I(n, { className: "lk-grid-layout" }), | ||
| [n] | ||
| ), { layout: r } = qe(a, t.length), s = $e(r.maxTiles, t); | ||
| return De(a, { | ||
| onLeftSwipe: s.nextPage, | ||
| onRightSwipe: s.prevPage | ||
| }), /* @__PURE__ */ e.createElement("div", { ref: a, "data-lk-pagination": s.totalPageCount > 1, ...c }, /* @__PURE__ */ e.createElement(Ce, { tracks: s.tracks }, n.children), t.length > r.maxTiles && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement( | ||
| qt, | ||
| { | ||
| totalPageCount: s.totalPageCount, | ||
| currentPage: s.currentPage | ||
| } | ||
| ), /* @__PURE__ */ e.createElement(Wt, { pagesContainer: a, ...s }))); | ||
| } | ||
| const $t = 130, Dt = 140, me = 1, Ie = 16 / 10, Ut = (1 - Ie) * -1; | ||
| function ka({ tracks: t, orientation: n, ...a }) { | ||
| const c = e.useRef(null), [r, s] = e.useState(0), { width: o, height: l } = Ue(c), i = n || (l >= o ? "vertical" : "horizontal"), d = i === "vertical" ? Math.max(o * Ut, $t) : Math.max(l * Ie, Dt), u = mt(), v = Math.max(i === "vertical" ? (l - u) / d : (o - u) / d, me); | ||
| let f = Math.round(v); | ||
| Math.abs(v - r) < 0.5 ? f = Math.round(r) : r !== v && s(v); | ||
| const p = Ge(t, f); | ||
| return e.useLayoutEffect(() => { | ||
| c.current && (c.current.dataset.lkOrientation = i, c.current.style.setProperty("--lk-max-visible-tiles", f.toString())); | ||
| }, [f, i]), /* @__PURE__ */ e.createElement("aside", { key: i, className: "lk-carousel", ref: c, ...a }, /* @__PURE__ */ e.createElement(Ce, { tracks: p }, a.children)); | ||
| } | ||
| function Ra({ | ||
| value: t, | ||
| onPinChange: n, | ||
| onWidgetChange: a, | ||
| children: c | ||
| }) { | ||
| const r = ft(t); | ||
| return e.useEffect(() => { | ||
| j.debug("PinState Updated", { state: r.pin.state }), n && r.pin.state && n(r.pin.state); | ||
| }, [r.pin.state, n]), e.useEffect(() => { | ||
| j.debug("Widget Updated", { widgetState: r.widget.state }), a && r.widget.state && a(r.widget.state); | ||
| }, [a, r.widget.state]), /* @__PURE__ */ e.createElement(pe.Provider, { value: r }, c); | ||
| } | ||
| const Ma = /* @__PURE__ */ e.forwardRef( | ||
| function({ trackRef: n, ...a }, c) { | ||
| const u = _(n), v = Ee(u, { bands: 7, loPass: 300 }); | ||
| return /* @__PURE__ */ e.createElement( | ||
| "svg", | ||
| { | ||
| ref: c, | ||
| width: "100%", | ||
| height: "100%", | ||
| viewBox: "0 0 200 90", | ||
| ...a, | ||
| className: "lk-audio-visualizer" | ||
| }, | ||
| /* @__PURE__ */ e.createElement("rect", { x: "0", y: "0", width: "100%", height: "100%" }), | ||
| /* @__PURE__ */ e.createElement( | ||
| "g", | ||
| { | ||
| style: { | ||
| transform: `translate(${130 / 2}px, 0)` | ||
| } | ||
| }, | ||
| v.map((f, p) => /* @__PURE__ */ e.createElement( | ||
| "rect", | ||
| { | ||
| key: p, | ||
| x: p * 10, | ||
| y: 90 / 2 - f * 50 / 2, | ||
| width: 6, | ||
| height: f * 50 | ||
| } | ||
| )) | ||
| ) | ||
| ); | ||
| } | ||
| ); | ||
| function ya({ participants: t, ...n }) { | ||
| return /* @__PURE__ */ e.createElement(e.Fragment, null, t.map((a) => /* @__PURE__ */ e.createElement(we.Provider, { value: a, key: a.identity }, ee(n.children)))); | ||
| } | ||
| function ba({ room: t, volume: n, muted: a }) { | ||
| const c = Qe( | ||
| [S.Source.Microphone, S.Source.ScreenShareAudio, S.Source.Unknown], | ||
| { | ||
| updateOnlyOn: [], | ||
| onlySubscribed: !0, | ||
| room: t | ||
| } | ||
| ).filter((r) => !r.participant.isLocal && r.publication.kind === S.Kind.Audio); | ||
| return /* @__PURE__ */ e.createElement("div", { style: { display: "none" } }, c.map((r) => /* @__PURE__ */ e.createElement( | ||
| ne, | ||
| { | ||
| key: ke(r), | ||
| trackRef: r, | ||
| volume: n, | ||
| muted: a | ||
| } | ||
| ))); | ||
| } | ||
| const Sa = /* @__PURE__ */ e.forwardRef(function({ childrenPosition: n = "before", children: a, ...c }, r) { | ||
| const { name: s } = Xe(); | ||
| return /* @__PURE__ */ e.createElement("span", { ref: r, ...c }, n === "before" && a, s, n === "after" && a); | ||
| }); | ||
| function Gt(t) { | ||
| const n = e.useMemo(() => I(t, { className: "lk-toast" }), [t]); | ||
| return /* @__PURE__ */ e.createElement("div", { ...n }, t.children); | ||
| } | ||
| const Qt = (t) => { | ||
| const n = []; | ||
| for (let a = 0; a < t; a++) | ||
| n.push([a, t - 1 - a]); | ||
| return n; | ||
| }, fe = (t) => [[Math.floor(t / 2)], [-1]], Xt = (t, n, a) => { | ||
| const [c, r] = B(0), [s, o] = B([[]]); | ||
| V(() => { | ||
| if (t === "thinking") | ||
| o(fe(n)); | ||
| else if (t === "connecting" || t === "initializing") { | ||
| const i = [...Qt(n)]; | ||
| o(i); | ||
| } else o(t === "listening" ? fe(n) : t === void 0 || t === "speaking" ? [new Array(n).fill(0).map((i, d) => d)] : [[]]); | ||
| r(0); | ||
| }, [t, n]); | ||
| const l = z(null); | ||
| return V(() => { | ||
| let i = performance.now(); | ||
| const d = (u) => { | ||
| u - i >= a && (r((f) => f + 1), i = u), l.current = requestAnimationFrame(d); | ||
| }; | ||
| return l.current = requestAnimationFrame(d), () => { | ||
| l.current !== null && cancelAnimationFrame(l.current); | ||
| }; | ||
| }, [a, n, t, s.length]), s[c % s.length]; | ||
| }, Yt = /* @__PURE__ */ new Map([ | ||
| ["connecting", 2e3], | ||
| ["initializing", 2e3], | ||
| ["listening", 500], | ||
| ["thinking", 150] | ||
| ]), Jt = (t, n) => { | ||
| if (t === void 0) | ||
| return 1e3; | ||
| let a = Yt.get(t); | ||
| if (a) | ||
| switch (t) { | ||
| case "connecting": | ||
| a /= n; | ||
| break; | ||
| } | ||
| return a; | ||
| }, Kt = /* @__PURE__ */ e.forwardRef( | ||
| function({ state: n, options: a, barCount: c = 15, trackRef: r, track: s, children: o, ...l }, i) { | ||
| const d = I(l, { className: "lk-audio-visualizer-bar" }); | ||
| let u = te(); | ||
| (r || s) && (u = r || s); | ||
| const v = Ee(u, { | ||
| bands: c, | ||
| loPass: 100, | ||
| hiPass: 200 | ||
| }), f = (a == null ? void 0 : a.minHeight) ?? 20, p = (a == null ? void 0 : a.maxHeight) ?? 100, E = Xt( | ||
| n, | ||
| c, | ||
| Jt(n, c) ?? 100 | ||
| ); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: i, ...d, "data-lk-va-state": n }, v.map( | ||
| (h, m) => o ? ee(o, { | ||
| "data-lk-highlighted": E.includes(m), | ||
| "data-lk-bar-index": m, | ||
| className: "lk-audio-bar", | ||
| style: { height: `${Math.min(p, Math.max(f, h * 100 + 5))}%` } | ||
| }) : /* @__PURE__ */ e.createElement( | ||
| "span", | ||
| { | ||
| key: m, | ||
| "data-lk-highlighted": E.includes(m), | ||
| "data-lk-bar-index": m, | ||
| className: `lk-audio-bar ${E.includes(m) && "lk-highlighted"}`, | ||
| style: { | ||
| // TODO transform animations would be more performant, however the border-radius gets distorted when using scale transforms. a 9-slice approach (or 3 in this case) could work | ||
| // transform: `scale(1, ${Math.min(maxHeight, Math.max(minHeight, volume))}`, | ||
| height: `${Math.min(p, Math.max(f, h * 100 + 5))}%` | ||
| } | ||
| } | ||
| ) | ||
| )); | ||
| } | ||
| ), Ca = /* @__PURE__ */ e.forwardRef( | ||
| function({ | ||
| children: n, | ||
| disableSpeakingIndicator: a, | ||
| onParticipantClick: c, | ||
| trackRef: r, | ||
| ...s | ||
| }, o) { | ||
| const l = _(r), { elementProps: i } = ve({ | ||
| trackRef: l, | ||
| htmlProps: s, | ||
| disableSpeakingIndicator: a, | ||
| onParticipantClick: c | ||
| }); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: o, style: { position: "relative", minHeight: "160px" }, ...i }, /* @__PURE__ */ e.createElement(ae.Provider, { value: l }, n ?? /* @__PURE__ */ e.createElement(e.Fragment, null, $(l) && /* @__PURE__ */ e.createElement(ne, { trackRef: l }), /* @__PURE__ */ e.createElement(Kt, { barCount: 7, options: { minHeight: 8 } }), /* @__PURE__ */ e.createElement("div", { className: "lk-participant-metadata" }, /* @__PURE__ */ e.createElement("div", { className: "lk-participant-metadata-item" }, /* @__PURE__ */ e.createElement(be, { trackRef: l }), /* @__PURE__ */ e.createElement(K, null)), /* @__PURE__ */ e.createElement(ye, { className: "lk-participant-metadata-item" }))))); | ||
| } | ||
| ); | ||
| function Ia(t) { | ||
| const [n, a] = e.useState(void 0), c = he(t.room); | ||
| return e.useEffect(() => { | ||
| switch (c) { | ||
| case X.Reconnecting: | ||
| a( | ||
| /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(oe, { className: "lk-spinner" }), " Reconnecting") | ||
| ); | ||
| break; | ||
| case X.Connecting: | ||
| a( | ||
| /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(oe, { className: "lk-spinner" }), " Connecting") | ||
| ); | ||
| break; | ||
| case X.Disconnected: | ||
| a(/* @__PURE__ */ e.createElement(e.Fragment, null, "Disconnected")); | ||
| break; | ||
| default: | ||
| a(void 0); | ||
| break; | ||
| } | ||
| }, [c]), n ? /* @__PURE__ */ e.createElement(Gt, { className: "lk-toast-connection-state" }, n) : /* @__PURE__ */ e.createElement(e.Fragment, null); | ||
| } | ||
| const xa = /* @__PURE__ */ e.forwardRef( | ||
| function({ entry: n, hideName: a = !1, hideTimestamp: c = !1, messageFormatter: r, ...s }, o) { | ||
| var f, p, E, h; | ||
| const l = e.useMemo(() => r ? r(n.message) : n.message, [n.message, r]), i = !!n.editTimestamp, d = new Date(n.timestamp), u = typeof navigator < "u" ? navigator.language : "en-US", v = ((f = n.from) == null ? void 0 : f.name) ?? ((p = n.from) == null ? void 0 : p.identity); | ||
| return /* @__PURE__ */ e.createElement( | ||
| "li", | ||
| { | ||
| ref: o, | ||
| className: "lk-chat-entry", | ||
| title: d.toLocaleTimeString(u, { timeStyle: "full" }), | ||
| "data-lk-message-origin": (E = n.from) != null && E.isLocal ? "local" : "remote", | ||
| ...s | ||
| }, | ||
| (!c || !a || i) && /* @__PURE__ */ e.createElement("span", { className: "lk-meta-data" }, !a && /* @__PURE__ */ e.createElement("strong", { className: "lk-participant-name" }, v), (!c || i) && /* @__PURE__ */ e.createElement("span", { className: "lk-timestamp" }, i && "edited ", d.toLocaleTimeString(u, { timeStyle: "short" }))), | ||
| /* @__PURE__ */ e.createElement("span", { className: "lk-message-body" }, l), | ||
| /* @__PURE__ */ e.createElement("span", { className: "lk-message-attachements" }, (h = n.attachedFiles) == null ? void 0 : h.map( | ||
| (m) => m.type.startsWith("image/") && /* @__PURE__ */ e.createElement( | ||
| "img", | ||
| { | ||
| style: { maxWidth: "300px", maxHeight: "300px" }, | ||
| key: m.name, | ||
| src: URL.createObjectURL(m), | ||
| alt: m.name | ||
| } | ||
| ) | ||
| )) | ||
| ); | ||
| } | ||
| ); | ||
| function Pa(t) { | ||
| return ht(t, gt()).map((n, a) => { | ||
| if (typeof n == "string") | ||
| return n; | ||
| { | ||
| const c = n.content.toString(), r = n.type === "url" ? /^http(s?):\/\//.test(c) ? c : `https://${c}` : `mailto:${c}`; | ||
| return /* @__PURE__ */ e.createElement("a", { className: "lk-chat-link", key: a, href: r, target: "_blank", rel: "noreferrer" }, c); | ||
| } | ||
| }); | ||
| } | ||
| function Ta(t) { | ||
| return /* @__PURE__ */ e.createElement(vt.Provider, { value: t.session }, /* @__PURE__ */ e.createElement(Et.Provider, { value: t.session.room }, t.children)); | ||
| } | ||
| export { | ||
| Pt as $, | ||
| Ma as A, | ||
| Kt as B, | ||
| sa as C, | ||
| ia as D, | ||
| pt as E, | ||
| Ea as F, | ||
| wa as G, | ||
| wt as H, | ||
| ie as I, | ||
| kt as J, | ||
| Rt as K, | ||
| Ra as L, | ||
| fa as M, | ||
| Mt as N, | ||
| yt as O, | ||
| Ot as P, | ||
| bt as Q, | ||
| ba as R, | ||
| oa as S, | ||
| va as T, | ||
| St as U, | ||
| Bt as V, | ||
| Ct as W, | ||
| It as X, | ||
| Re as Y, | ||
| xt as Z, | ||
| oe as _, | ||
| xa as a, | ||
| Nt as b, | ||
| ua as c, | ||
| da as d, | ||
| ma as e, | ||
| ga as f, | ||
| ka as g, | ||
| pa as h, | ||
| Ia as i, | ||
| Ce as j, | ||
| Ca as k, | ||
| Gt as l, | ||
| Pa as m, | ||
| ca as n, | ||
| la as o, | ||
| Tt as p, | ||
| ha as q, | ||
| ye as r, | ||
| ne as s, | ||
| K as t, | ||
| be as u, | ||
| ya as v, | ||
| Sa as w, | ||
| jt as x, | ||
| _t as y, | ||
| Ta as z | ||
| }; | ||
| //# sourceMappingURL=components-Cc_gXqiR.mjs.map |
Sorry, the diff of this file is too big to display
| import * as s from "react"; | ||
| import { useRef as ue, useMemo as Be, useCallback as ne, useEffect as Ve } from "react"; | ||
| import { u as U, r as qe, a as De, b as je, c as Y, d as We, e as ze, f as ce, g as Ge, h as Je, i as fe, j as $e, k as Qe, m as Ke, G as Ye, n as Xe, o as Ze, p as me, q as et, t as tt, v as Ie, w as pe, x as Ne, y as nt, l as j, z as rt, A as st, B as he, C as ot, D as at, E as it, F as ct, H as ut, I as dt, J as lt, K as ft, M as Te, N as mt, O as pt, P as ht, Q as bt, S as vt, T as gt, U as St, V as yt, W as _e, X as Ct, Y as Mt, Z as Tt, _ as Et, $ as kt, a0 as wt, a1 as Pt, a2 as Lt, a3 as At, a4 as Rt, a5 as Ot, a6 as Dt, a7 as le, a8 as $, a9 as It, aa as Nt, ab as _t, ac as Ft, ad as xt } from "./contexts-CsO1QZ3r.mjs"; | ||
| import { m as Q } from "./room-Bb6uLxS5.mjs"; | ||
| import { ConnectionState as I, LocalTrackPublication as Ut, facingModeFromLocalTrack as Ht, Room as Fe, Track as E, createAudioAnalyser as be, ParticipantKind as ae, Mutex as Bt, ParticipantEvent as ee, RoomEvent as V, decodeTokenPayload as Vt, TokenSourceConfigurable as qt } from "livekit-client"; | ||
| const jt = (e) => { | ||
| const n = s.useRef(e); | ||
| return s.useEffect(() => { | ||
| n.current = e; | ||
| }), n; | ||
| }; | ||
| function Wt(e, n) { | ||
| const t = Gt(), r = jt(n); | ||
| return s.useLayoutEffect(() => { | ||
| let o = !1; | ||
| const i = e.current; | ||
| if (!i) return; | ||
| function a(c, u) { | ||
| o || r.current(c, u); | ||
| } | ||
| return t == null || t.subscribe(i, a), () => { | ||
| o = !0, t == null || t.unsubscribe(i, a); | ||
| }; | ||
| }, [e.current, t, r]), t == null ? void 0 : t.observer; | ||
| } | ||
| function zt() { | ||
| let e = !1, n = []; | ||
| const t = /* @__PURE__ */ new Map(); | ||
| if (typeof window > "u") | ||
| return; | ||
| const r = new ResizeObserver((o, i) => { | ||
| n = n.concat(o), e || window.requestAnimationFrame(() => { | ||
| const a = /* @__PURE__ */ new Set(); | ||
| for (let c = 0; c < n.length; c++) { | ||
| if (a.has(n[c].target)) continue; | ||
| a.add(n[c].target); | ||
| const u = t.get(n[c].target); | ||
| u == null || u.forEach((p) => p(n[c], i)); | ||
| } | ||
| n = [], e = !1; | ||
| }), e = !0; | ||
| }); | ||
| return { | ||
| observer: r, | ||
| subscribe(o, i) { | ||
| r.observe(o); | ||
| const a = t.get(o) ?? []; | ||
| a.push(i), t.set(o, a); | ||
| }, | ||
| unsubscribe(o, i) { | ||
| const a = t.get(o) ?? []; | ||
| if (a.length === 1) { | ||
| r.unobserve(o), t.delete(o); | ||
| return; | ||
| } | ||
| const c = a.indexOf(i); | ||
| c !== -1 && a.splice(c, 1), t.set(o, a); | ||
| } | ||
| }; | ||
| } | ||
| let de; | ||
| const Gt = () => de || (de = zt()), Jt = (e) => { | ||
| const [n, t] = s.useState({ width: 0, height: 0 }); | ||
| s.useLayoutEffect(() => { | ||
| if (e.current) { | ||
| const { width: o, height: i } = e.current.getBoundingClientRect(); | ||
| t({ width: o, height: i }); | ||
| } | ||
| }, [e.current]); | ||
| const r = s.useCallback( | ||
| (o) => t(o.contentRect), | ||
| [] | ||
| ); | ||
| return Wt(e, r), n; | ||
| }; | ||
| function O(e, n, t = !0) { | ||
| const [r, o] = s.useState(n); | ||
| return s.useEffect(() => { | ||
| if (t && o(n), typeof window > "u" || !e) return; | ||
| const i = e.subscribe(o); | ||
| return () => i.unsubscribe(); | ||
| }, [e, t]), r; | ||
| } | ||
| function Dn(e) { | ||
| const n = (i) => typeof window < "u" ? window.matchMedia(i).matches : !1, [t, r] = s.useState(n(e)); | ||
| function o() { | ||
| r(n(e)); | ||
| } | ||
| return s.useEffect(() => { | ||
| const i = window.matchMedia(e); | ||
| return o(), i.addListener ? i.addListener(o) : i.addEventListener("change", o), () => { | ||
| i.removeListener ? i.removeListener(o) : i.removeEventListener("change", o); | ||
| }; | ||
| }, [e]), t; | ||
| } | ||
| function In(e) { | ||
| const n = U(e), t = s.useCallback(async () => { | ||
| await n.startAudio(); | ||
| }, [n]), r = s.useMemo( | ||
| () => qe(n), | ||
| [n] | ||
| ), { canPlayAudio: o } = O(r, { | ||
| canPlayAudio: n.canPlaybackAudio | ||
| }); | ||
| return { canPlayAudio: o, startAudio: t }; | ||
| } | ||
| function Nn(e) { | ||
| const { state: n, dispatch: t } = De().pin; | ||
| return { buttonProps: s.useMemo(() => { | ||
| const { className: o } = je(); | ||
| return Q(e, { | ||
| className: o, | ||
| disabled: !(n != null && n.length), | ||
| onClick: () => { | ||
| t && t({ msg: "clear_pin" }); | ||
| } | ||
| }); | ||
| }, [e, t, n]) }; | ||
| } | ||
| function _n(e = {}) { | ||
| const n = Y(e.participant), { className: t, connectionQualityObserver: r } = s.useMemo( | ||
| () => We(n), | ||
| [n] | ||
| ), o = O(r, n.connectionQuality); | ||
| return { className: t, quality: o }; | ||
| } | ||
| function re(e) { | ||
| const n = U(e), t = s.useMemo(() => ze(n), [n]); | ||
| return O(t, n.state); | ||
| } | ||
| function Fn(e, n) { | ||
| const t = typeof e == "function" ? e : n, r = typeof e == "string" ? e : void 0, o = ce(), { send: i, messageObservable: a, isSendingObservable: c } = s.useMemo( | ||
| () => Ge(o, r, t), | ||
| [o, r, t] | ||
| ), u = O(a, void 0), p = O(c, !1); | ||
| return { | ||
| message: u, | ||
| send: i, | ||
| isSending: p | ||
| }; | ||
| } | ||
| function xn(e) { | ||
| const n = ce(), t = re(n); | ||
| return { buttonProps: s.useMemo(() => { | ||
| const { className: o, disconnect: i } = Je(n); | ||
| return Q(e, { | ||
| className: o, | ||
| onClick: () => i(e.stopTracks ?? !0), | ||
| disabled: t === I.Disconnected | ||
| }); | ||
| }, [n, e, t]) }; | ||
| } | ||
| function $t(e) { | ||
| if (e.publication instanceof Ut) { | ||
| const n = e.publication.track; | ||
| if (n) { | ||
| const { facingMode: t } = Ht(n); | ||
| return t; | ||
| } | ||
| } | ||
| return "undefined"; | ||
| } | ||
| function Un({ trackRef: e, props: n }) { | ||
| const t = fe(e), r = $e(), { className: o } = s.useMemo(() => Qe(), []), i = s.useMemo(() => Ke(t, r == null ? void 0 : r.pin.state), [t, r == null ? void 0 : r.pin.state]); | ||
| return { mergedProps: s.useMemo( | ||
| () => Q(n, { | ||
| className: o, | ||
| onClick: (c) => { | ||
| var u, p, h, l, d; | ||
| (u = n.onClick) == null || u.call(n, c), i ? (h = r == null ? void 0 : (p = r.pin).dispatch) == null || h.call(p, { | ||
| msg: "clear_pin" | ||
| }) : (d = r == null ? void 0 : (l = r.pin).dispatch) == null || d.call(l, { | ||
| msg: "set_pin", | ||
| trackReference: t | ||
| }); | ||
| } | ||
| }), | ||
| [n, o, t, i, r == null ? void 0 : r.pin] | ||
| ), inFocus: i }; | ||
| } | ||
| function Hn(e, n, t = {}) { | ||
| const r = t.gridLayouts ?? Ye, { width: o, height: i } = Jt(e), a = Xe(r, n, o, i); | ||
| return s.useEffect(() => { | ||
| e.current && a && (e.current.style.setProperty("--lk-col-count", a == null ? void 0 : a.columns.toString()), e.current.style.setProperty("--lk-row-count", a == null ? void 0 : a.rows.toString())); | ||
| }, [e, a]), { | ||
| layout: a, | ||
| containerWidth: o, | ||
| containerHeight: i | ||
| }; | ||
| } | ||
| function Ee(e, n = {}) { | ||
| var c, u; | ||
| const t = typeof e == "string" ? n.participant : e.participant, r = Y(t), o = typeof e == "string" ? { participant: r, source: e } : e, [i, a] = s.useState( | ||
| !!((c = o.publication) != null && c.isMuted || (u = r.getTrackPublication(o.source)) != null && u.isMuted) | ||
| ); | ||
| return s.useEffect(() => { | ||
| const p = Ze(o).subscribe(a); | ||
| return () => p.unsubscribe(); | ||
| }, [me(o)]), i; | ||
| } | ||
| function Qt(e) { | ||
| const n = Y(e), t = s.useMemo(() => et(n), [n]); | ||
| return O(t, n.isSpeaking); | ||
| } | ||
| function xe(e = {}) { | ||
| const n = U(e.room), [t, r] = s.useState(n.localParticipant), [o, i] = s.useState( | ||
| t.isMicrophoneEnabled | ||
| ), [a, c] = s.useState(t.isCameraEnabled), [u, p] = s.useState( | ||
| t.isScreenShareEnabled | ||
| ), [h, l] = s.useState( | ||
| t.lastMicrophoneError | ||
| ), [d, v] = s.useState(t.lastCameraError), [M, w] = s.useState( | ||
| void 0 | ||
| ), [A, P] = s.useState(void 0), D = (R) => { | ||
| c(R.isCameraEnabled), i(R.isMicrophoneEnabled), p(R.isScreenShareEnabled), P(R.cameraTrack), w(R.microphoneTrack), l(R.participant.lastMicrophoneError), v(R.participant.lastCameraError), r(R.participant); | ||
| }; | ||
| return s.useEffect(() => { | ||
| const R = tt(n.localParticipant).subscribe(D); | ||
| return () => R.unsubscribe(); | ||
| }, [n]), { | ||
| isMicrophoneEnabled: o, | ||
| isScreenShareEnabled: u, | ||
| isCameraEnabled: a, | ||
| microphoneTrack: M, | ||
| cameraTrack: A, | ||
| lastMicrophoneError: h, | ||
| lastCameraError: d, | ||
| localParticipant: t | ||
| }; | ||
| } | ||
| function Bn() { | ||
| const e = ce(), n = s.useMemo( | ||
| () => Ie(e.localParticipant), | ||
| [e] | ||
| ); | ||
| return O(n, e.localParticipant.permissions); | ||
| } | ||
| function Vn({ | ||
| kind: e, | ||
| room: n, | ||
| track: t, | ||
| requestPermissions: r, | ||
| onError: o | ||
| }) { | ||
| const i = pe(), a = s.useMemo(() => n ?? i ?? new Fe(), [n, i]), c = s.useMemo( | ||
| () => Ne(e, o, r), | ||
| [e, r, o] | ||
| ), u = O(c, []), [p, h] = s.useState( | ||
| (a == null ? void 0 : a.getActiveDevice(e)) ?? "default" | ||
| ), { className: l, activeDeviceObservable: d, setActiveMediaDevice: v } = s.useMemo( | ||
| () => nt(e, a), | ||
| [e, a, t] | ||
| ); | ||
| return s.useEffect(() => { | ||
| const M = d.subscribe((w) => { | ||
| w && (j.info("setCurrentDeviceId", w), h(w)); | ||
| }); | ||
| return () => { | ||
| M == null || M.unsubscribe(); | ||
| }; | ||
| }, [d]), { devices: u, className: l, activeDeviceId: p, setActiveMediaDevice: v }; | ||
| } | ||
| function qn({ | ||
| kind: e, | ||
| onError: n | ||
| }) { | ||
| const t = s.useMemo( | ||
| () => Ne(e, n), | ||
| [e, n] | ||
| ); | ||
| return O(t, []); | ||
| } | ||
| function Kt(e, n, t = {}) { | ||
| const r = s.useRef([]), o = s.useRef(-1), i = n !== o.current, a = typeof t.customSortFunction == "function" ? t.customSortFunction(e) : rt(e); | ||
| let c = [...a]; | ||
| if (i === !1) | ||
| try { | ||
| c = st(r.current, a, n); | ||
| } catch (u) { | ||
| j.error("Error while running updatePages(): ", u); | ||
| } | ||
| return i ? r.current = a : r.current = c, o.current = n, c; | ||
| } | ||
| function jn(e, n) { | ||
| const [t, r] = s.useState(1), o = Math.max(Math.ceil(n.length / e), 1); | ||
| t > o && r(o); | ||
| const i = t * e, a = i - e, c = (l) => { | ||
| r((d) => l === "next" ? d === o ? d : d + 1 : d === 1 ? d : d - 1); | ||
| }, u = (l) => { | ||
| l > o ? r(o) : l < 1 ? r(1) : r(l); | ||
| }, h = Kt(n, e).slice(a, i); | ||
| return { | ||
| totalPageCount: o, | ||
| nextPage: () => c("next"), | ||
| prevPage: () => c("previous"), | ||
| setPage: u, | ||
| firstItemIndex: a, | ||
| lastItemIndex: i, | ||
| tracks: h, | ||
| currentPage: t | ||
| }; | ||
| } | ||
| function Yt(e = {}) { | ||
| let n = he(); | ||
| e.participant && (n = e.participant); | ||
| const t = s.useMemo(() => ot(n), [n]), { identity: r, name: o, metadata: i } = O(t, { | ||
| name: n == null ? void 0 : n.name, | ||
| identity: n == null ? void 0 : n.identity, | ||
| metadata: n == null ? void 0 : n.metadata | ||
| }); | ||
| return { identity: r, name: o, metadata: i }; | ||
| } | ||
| function Wn(e = {}) { | ||
| const n = Y(e.participant), t = s.useMemo(() => Ie(n), [n]); | ||
| return O(t, n.permissions); | ||
| } | ||
| function zn({ | ||
| trackRef: e, | ||
| onParticipantClick: n, | ||
| disableSpeakingIndicator: t, | ||
| htmlProps: r | ||
| }) { | ||
| const o = fe(e), i = s.useMemo(() => { | ||
| const { className: d } = at(); | ||
| return Q(r, { | ||
| className: d, | ||
| onClick: (v) => { | ||
| var M; | ||
| if ((M = r.onClick) == null || M.call(r, v), typeof n == "function") { | ||
| const w = o.publication ?? o.participant.getTrackPublication(o.source); | ||
| n({ participant: o.participant, track: w }); | ||
| } | ||
| } | ||
| }); | ||
| }, [ | ||
| r, | ||
| n, | ||
| o.publication, | ||
| o.source, | ||
| o.participant | ||
| ]), a = o.participant.getTrackPublication(E.Source.Microphone), c = s.useMemo(() => ({ | ||
| participant: o.participant, | ||
| source: E.Source.Microphone, | ||
| publication: a | ||
| }), [a, o.participant]), u = Ee(o), p = Ee(c), h = Qt(o.participant), l = $t(o); | ||
| return { | ||
| elementProps: { | ||
| "data-lk-audio-muted": p, | ||
| "data-lk-video-muted": u, | ||
| "data-lk-speaking": t === !0 ? !1 : h, | ||
| "data-lk-local-participant": o.participant.isLocal, | ||
| "data-lk-source": o.source, | ||
| "data-lk-facing-mode": l, | ||
| ...i | ||
| } | ||
| }; | ||
| } | ||
| function ve(e = {}) { | ||
| const n = U(e.room), [t, r] = s.useState([]); | ||
| return s.useEffect(() => { | ||
| const o = it(n, { | ||
| additionalRoomEvents: e.updateOnlyOn | ||
| }).subscribe(r); | ||
| return () => o.unsubscribe(); | ||
| }, [n, JSON.stringify(e.updateOnlyOn)]), t; | ||
| } | ||
| function Xt(e = {}) { | ||
| const n = ve(e), { localParticipant: t } = xe(e); | ||
| return s.useMemo( | ||
| () => [t, ...n], | ||
| [t, n] | ||
| ); | ||
| } | ||
| function Gn(e) { | ||
| return e = ct(e), s.useMemo(() => (e == null ? void 0 : e.pin.state) !== void 0 && e.pin.state.length >= 1 ? e.pin.state : [], [e.pin.state]); | ||
| } | ||
| function Jn(e, n = {}) { | ||
| const t = ce(), [r] = s.useState(n.updateOnlyOn), o = s.useMemo(() => typeof e == "string" ? ut(t, e, { | ||
| additionalEvents: r | ||
| }) : dt(t, e, { | ||
| additionalEvents: r | ||
| }), [t, JSON.stringify(e), r]), [i, a] = s.useState({ | ||
| p: void 0 | ||
| }); | ||
| return s.useEffect(() => { | ||
| const c = o.subscribe((u) => a({ p: u })); | ||
| return () => c.unsubscribe(); | ||
| }, [o]), i.p; | ||
| } | ||
| function $n(e = {}) { | ||
| const n = U(e.room), t = s.useMemo(() => lt(n), [n]), { name: r, metadata: o } = O(t, { | ||
| name: n.name, | ||
| metadata: n.metadata | ||
| }); | ||
| return { name: r, metadata: o }; | ||
| } | ||
| function Zt(e) { | ||
| const n = U(e == null ? void 0 : e.room), t = s.useMemo(() => ft(n), [n]); | ||
| return O(t, n.activeSpeakers); | ||
| } | ||
| function Qn(e) { | ||
| const [n, t] = s.useState( | ||
| Te(e) | ||
| ), r = Zt(); | ||
| return s.useEffect(() => { | ||
| t(Te(e)); | ||
| }, [r, e]), n; | ||
| } | ||
| function Kn({ room: e, props: n }) { | ||
| const t = U(e), { className: r, roomAudioPlaybackAllowedObservable: o, handleStartAudioPlayback: i } = s.useMemo( | ||
| () => mt(), | ||
| [] | ||
| ), a = s.useMemo( | ||
| () => o(t), | ||
| [t, o] | ||
| ), { canPlayAudio: c } = O(a, { | ||
| canPlayAudio: t.canPlaybackAudio | ||
| }); | ||
| return { mergedProps: s.useMemo( | ||
| () => Q(n, { | ||
| className: r, | ||
| onClick: () => { | ||
| i(t); | ||
| }, | ||
| style: { display: c ? "none" : "block" } | ||
| }), | ||
| [n, r, c, i, t] | ||
| ), canPlayAudio: c }; | ||
| } | ||
| function Yn({ room: e, props: n }) { | ||
| const t = U(e), { className: r, roomVideoPlaybackAllowedObservable: o, handleStartVideoPlayback: i } = s.useMemo( | ||
| () => pt(), | ||
| [] | ||
| ), a = s.useMemo( | ||
| () => o(t), | ||
| [t, o] | ||
| ), { canPlayVideo: c } = O(a, { | ||
| canPlayVideo: t.canPlaybackVideo | ||
| }); | ||
| return { mergedProps: s.useMemo( | ||
| () => Q(n, { | ||
| className: r, | ||
| onClick: () => { | ||
| i(t); | ||
| }, | ||
| style: { display: c ? "none" : "block" } | ||
| }), | ||
| [n, r, c, i, t] | ||
| ), canPlayVideo: c }; | ||
| } | ||
| function Xn(e, n = {}) { | ||
| const t = s.useRef(null), r = s.useRef(null), o = n.minSwipeDistance ?? 50, i = (u) => { | ||
| r.current = null, t.current = u.targetTouches[0].clientX; | ||
| }, a = (u) => { | ||
| r.current = u.targetTouches[0].clientX; | ||
| }, c = s.useCallback(() => { | ||
| if (!t.current || !r.current) | ||
| return; | ||
| const u = t.current - r.current, p = u > o, h = u < -o; | ||
| p && n.onLeftSwipe && n.onLeftSwipe(), h && n.onRightSwipe && n.onRightSwipe(); | ||
| }, [o, n]); | ||
| s.useEffect(() => { | ||
| const u = e.current; | ||
| return u && (u.addEventListener("touchstart", i, { passive: !0 }), u.addEventListener("touchmove", a, { passive: !0 }), u.addEventListener("touchend", c, { passive: !0 })), () => { | ||
| u && (u.removeEventListener("touchstart", i), u.removeEventListener("touchmove", a), u.removeEventListener("touchend", c)); | ||
| }; | ||
| }, [e, c]); | ||
| } | ||
| function Zn({ props: e }) { | ||
| const { dispatch: n, state: t } = De().widget, { className: r } = s.useMemo(() => ht(), []); | ||
| return { mergedProps: s.useMemo(() => Q(e, { | ||
| className: r, | ||
| onClick: () => { | ||
| n && n({ msg: "toggle_chat" }); | ||
| }, | ||
| "aria-pressed": t != null && t.showChat ? "true" : "false", | ||
| "data-lk-unread-msgs": t ? t.unreadMessages < 10 ? t.unreadMessages.toFixed(0) : "9+" : "0" | ||
| }), [e, r, n, t]) }; | ||
| } | ||
| function er(e, n, t = {}) { | ||
| const [r, o] = s.useState(void 0); | ||
| return s.useEffect(() => { | ||
| var a; | ||
| if (e === void 0) | ||
| throw Error("token endpoint needs to be defined"); | ||
| if (((a = t.userInfo) == null ? void 0 : a.identity) === void 0) | ||
| return; | ||
| (async () => { | ||
| j.debug("fetching token"); | ||
| const c = new URLSearchParams({ ...t.userInfo, roomName: n }), u = await fetch(`${e}?${c.toString()}`); | ||
| if (!u.ok) { | ||
| j.error( | ||
| `Could not fetch token. Server responded with status ${u.status}: ${u.statusText}` | ||
| ); | ||
| return; | ||
| } | ||
| const { accessToken: p } = await u.json(); | ||
| o(p); | ||
| })(); | ||
| }, [e, n, JSON.stringify(t)]), r; | ||
| } | ||
| function tr(e) { | ||
| var i, a; | ||
| const n = fe(e), { className: t, mediaMutedObserver: r } = s.useMemo( | ||
| () => bt(n), | ||
| [me(n)] | ||
| ); | ||
| return { isMuted: O( | ||
| r, | ||
| !!((i = n.publication) != null && i.isMuted || (a = n.participant.getTrackPublication(n.source)) != null && a.isMuted) | ||
| ), className: t }; | ||
| } | ||
| function nr({ | ||
| source: e, | ||
| onChange: n, | ||
| initialState: t, | ||
| captureOptions: r, | ||
| publishOptions: o, | ||
| onDeviceError: i, | ||
| room: a, | ||
| ...c | ||
| }) { | ||
| var m; | ||
| const u = pe(), p = s.useMemo(() => a ?? u, [a, u]), h = (m = p == null ? void 0 : p.localParticipant) == null ? void 0 : m.getTrackPublication(e), l = s.useRef(!1), { toggle: d, className: v, pendingObserver: M, enabledObserver: w } = s.useMemo( | ||
| () => p ? vt(e, p, r, o, i) : gt(), | ||
| [p, e, JSON.stringify(r), o] | ||
| ), A = O(M, !1), P = O(w, t ?? !!(h != null && h.isEnabled)); | ||
| s.useEffect(() => { | ||
| n == null || n(P, l.current), l.current = !1; | ||
| }, [P, n]), s.useEffect(() => { | ||
| t !== void 0 && (j.debug("forcing initial toggle state", e, t), d(t)); | ||
| }, []); | ||
| const D = s.useMemo(() => Q(c, { className: v }), [c, v]), R = s.useCallback( | ||
| (f) => { | ||
| var b; | ||
| l.current = !0, d().catch(() => l.current = !1), (b = c.onClick) == null || b.call(c, f); | ||
| }, | ||
| [c, d] | ||
| ); | ||
| return { | ||
| toggle: d, | ||
| enabled: P, | ||
| pending: A, | ||
| track: h, | ||
| buttonProps: { | ||
| ...D, | ||
| "aria-pressed": P, | ||
| "data-lk-source": e, | ||
| "data-lk-enabled": P, | ||
| disabled: A, | ||
| onClick: R | ||
| } | ||
| }; | ||
| } | ||
| function rr(e = [ | ||
| E.Source.Camera, | ||
| E.Source.Microphone, | ||
| E.Source.ScreenShare, | ||
| E.Source.ScreenShareAudio, | ||
| E.Source.Unknown | ||
| ], n = {}) { | ||
| const t = U(n.room), [r, o] = s.useState([]), [i, a] = s.useState([]), c = s.useMemo(() => e.map((p) => St(p) ? p.source : p), [JSON.stringify(e)]); | ||
| return s.useEffect(() => { | ||
| const p = yt(t, c, { | ||
| additionalRoomEvents: n.updateOnlyOn, | ||
| onlySubscribed: n.onlySubscribed | ||
| }).subscribe(({ trackReferences: h, participants: l }) => { | ||
| j.debug("setting track bundles", h, l), o(h), a(l); | ||
| }); | ||
| return () => p.unsubscribe(); | ||
| }, [ | ||
| t, | ||
| JSON.stringify(n.onlySubscribed), | ||
| JSON.stringify(n.updateOnlyOn), | ||
| JSON.stringify(e) | ||
| ]), s.useMemo(() => { | ||
| if (_e(e)) { | ||
| const p = tn(e, i), h = Array.from(r); | ||
| return i.forEach((l) => { | ||
| p.has(l.identity) && (p.get(l.identity) ?? []).forEach((v) => { | ||
| if (r.find( | ||
| ({ participant: w, publication: A }) => l.identity === w.identity && A.source === v | ||
| )) | ||
| return; | ||
| j.debug( | ||
| `Add ${v} placeholder for participant ${l.identity}.` | ||
| ); | ||
| const M = { | ||
| participant: l, | ||
| source: v | ||
| }; | ||
| h.push(M); | ||
| }); | ||
| }), h; | ||
| } else | ||
| return r; | ||
| }, [r, i, e]); | ||
| } | ||
| function en(e, n) { | ||
| const t = new Set(e); | ||
| for (const r of n) | ||
| t.delete(r); | ||
| return t; | ||
| } | ||
| function tn(e, n) { | ||
| const t = /* @__PURE__ */ new Map(); | ||
| if (_e(e)) { | ||
| const r = e.filter((o) => o.withPlaceholder).map((o) => o.source); | ||
| n.forEach((o) => { | ||
| const i = o.getTrackPublications().map((c) => { | ||
| var u; | ||
| return (u = c.track) == null ? void 0 : u.source; | ||
| }).filter((c) => c !== void 0), a = Array.from( | ||
| en(new Set(r), new Set(i)) | ||
| ); | ||
| a.length > 0 && t.set(o.identity, a); | ||
| }); | ||
| } | ||
| return t; | ||
| } | ||
| function nn(e) { | ||
| const [n, t] = s.useState(Ct(e)), { trackObserver: r } = s.useMemo(() => Mt(e), [e.participant.sid ?? e.participant.identity, e.source]); | ||
| return s.useEffect(() => { | ||
| const o = r.subscribe((i) => { | ||
| t(i); | ||
| }); | ||
| return () => o == null ? void 0 : o.unsubscribe(); | ||
| }, [r]), { | ||
| participant: e.participant, | ||
| source: e.source ?? E.Source.Unknown, | ||
| publication: n | ||
| }; | ||
| } | ||
| function sr(e, n) { | ||
| const t = Y(n); | ||
| return nn({ name: e, participant: t }); | ||
| } | ||
| function rn(e) { | ||
| const n = U(e == null ? void 0 : e.room), t = re(n), r = s.useMemo( | ||
| () => t === I.Disconnected, | ||
| [t] | ||
| ), o = s.useMemo( | ||
| () => Tt(n, e), | ||
| [n, e, r] | ||
| ), i = O(o.isSendingObservable, !1), a = O(o.messageObservable, []); | ||
| return { send: o.send, chatMessages: a, isSending: i }; | ||
| } | ||
| function or(e = {}) { | ||
| const [n, t] = s.useState( | ||
| Et(e.defaults, e.preventLoad ?? !1) | ||
| ), r = s.useCallback((u) => { | ||
| t((p) => ({ ...p, audioEnabled: u })); | ||
| }, []), o = s.useCallback((u) => { | ||
| t((p) => ({ ...p, videoEnabled: u })); | ||
| }, []), i = s.useCallback((u) => { | ||
| t((p) => ({ ...p, audioDeviceId: u })); | ||
| }, []), a = s.useCallback((u) => { | ||
| t((p) => ({ ...p, videoDeviceId: u })); | ||
| }, []), c = s.useCallback((u) => { | ||
| t((p) => ({ ...p, username: u })); | ||
| }, []); | ||
| return s.useEffect(() => { | ||
| kt(n, e.preventSave ?? !1); | ||
| }, [n, e.preventSave]), { | ||
| userChoices: n, | ||
| saveAudioInputEnabled: r, | ||
| saveVideoInputEnabled: o, | ||
| saveAudioInputDeviceId: i, | ||
| saveVideoInputDeviceId: a, | ||
| saveUsername: c | ||
| }; | ||
| } | ||
| function ar(e, n = {}) { | ||
| const t = Y(e), r = U(n.room), o = s.useMemo(() => wt(r, t), [r, t]); | ||
| return O( | ||
| o, | ||
| t.isLocal ? t.isE2EEEnabled : !!(t != null && t.isEncrypted) | ||
| ); | ||
| } | ||
| function ir(e, n = { fftSize: 32, smoothingTimeConstant: 0 }) { | ||
| const t = Pt(e) ? e.publication.track : e, [r, o] = s.useState(0); | ||
| return s.useEffect(() => { | ||
| if (!t || !t.mediaStream) | ||
| return; | ||
| const { cleanup: i, analyser: a } = be(t, n), c = a.frequencyBinCount, u = new Uint8Array(c), h = setInterval(() => { | ||
| a.getByteFrequencyData(u); | ||
| let l = 0; | ||
| for (let d = 0; d < u.length; d++) { | ||
| const v = u[d]; | ||
| l += v * v; | ||
| } | ||
| o(Math.sqrt(l / u.length) / 255); | ||
| }, 1e3 / 30); | ||
| return () => { | ||
| i(), clearInterval(h); | ||
| }; | ||
| }, [t, t == null ? void 0 : t.mediaStream, JSON.stringify(n)]), r; | ||
| } | ||
| const sn = (e) => { | ||
| const n = (t) => { | ||
| let i = 1 - Math.max(-100, Math.min(-10, t)) * -1 / 100; | ||
| return i = Math.sqrt(i), i; | ||
| }; | ||
| return e.map((t) => t === -1 / 0 ? 0 : n(t)); | ||
| }, on = { | ||
| bands: 5, | ||
| loPass: 100, | ||
| hiPass: 600, | ||
| updateInterval: 32, | ||
| analyserOptions: { fftSize: 2048 } | ||
| }; | ||
| function cr(e, n = {}) { | ||
| var a; | ||
| const t = e instanceof E ? e : (a = e == null ? void 0 : e.publication) == null ? void 0 : a.track, r = { ...on, ...n }, [o, i] = s.useState( | ||
| new Array(r.bands).fill(0) | ||
| ); | ||
| return s.useEffect(() => { | ||
| if (!t || !(t != null && t.mediaStream)) { | ||
| i((v) => v.slice().fill(0)); | ||
| return; | ||
| } | ||
| const { analyser: c, cleanup: u } = be(t, r.analyserOptions), p = c.frequencyBinCount, h = new Float32Array(p), d = setInterval(() => { | ||
| c.getFloatFrequencyData(h); | ||
| let v = new Float32Array(h.length); | ||
| for (let P = 0; P < h.length; P++) | ||
| v[P] = h[P]; | ||
| v = v.slice(r.loPass, r.hiPass); | ||
| const M = sn(v), w = M.length, A = []; | ||
| for (let P = 0; P < r.bands; P++) { | ||
| const D = Math.floor(P * w / r.bands), R = Math.floor((P + 1) * w / r.bands), m = M.slice(D, R), f = m.length; | ||
| if (f === 0) | ||
| A.push(0); | ||
| else { | ||
| const b = m.reduce((g, y) => g += y, 0); | ||
| A.push(b / f); | ||
| } | ||
| } | ||
| i(A); | ||
| }, r.updateInterval); | ||
| return () => { | ||
| u(), clearInterval(d); | ||
| }; | ||
| }, [t, t == null ? void 0 : t.mediaStream, JSON.stringify(n)]), o; | ||
| } | ||
| const an = { | ||
| barCount: 120, | ||
| volMultiplier: 5, | ||
| updateInterval: 20 | ||
| }; | ||
| function ur(e, n = {}) { | ||
| var h; | ||
| const t = e instanceof E ? e : (h = e == null ? void 0 : e.publication) == null ? void 0 : h.track, r = { ...an, ...n }, o = s.useRef(new Float32Array()), i = s.useRef(performance.now()), a = s.useRef(0), [c, u] = s.useState([]), p = s.useCallback((l) => { | ||
| u( | ||
| Array.from( | ||
| un(l, r.barCount).map((d) => Math.sqrt(d) * r.volMultiplier) | ||
| // wave.slice(0, opts.barCount).map((v) => sigmoid(v * opts.volMultiplier, 0.08, 0.2)), | ||
| ) | ||
| ); | ||
| }, []); | ||
| return s.useEffect(() => { | ||
| if (!t || !(t != null && t.mediaStream)) | ||
| return; | ||
| const { analyser: l, cleanup: d } = be(t, { | ||
| fftSize: ke(r.barCount) | ||
| }), v = ke(r.barCount), M = new Float32Array(v), w = () => { | ||
| if (A = requestAnimationFrame(w), l.getFloatTimeDomainData(M), o.current.map((P, D) => P + M[D]), a.current += 1, performance.now() - i.current >= r.updateInterval) { | ||
| const P = M.map((D) => D / a.current); | ||
| p(P), i.current = performance.now(), a.current = 0; | ||
| } | ||
| }; | ||
| let A = requestAnimationFrame(w); | ||
| return () => { | ||
| d(), cancelAnimationFrame(A); | ||
| }; | ||
| }, [t, t == null ? void 0 : t.mediaStream, JSON.stringify(n), p]), { | ||
| bars: c | ||
| }; | ||
| } | ||
| function ke(e) { | ||
| return e < 32 ? 32 : cn(e); | ||
| } | ||
| function cn(e) { | ||
| let n = 2; | ||
| for (; e >>= 1; ) | ||
| n <<= 1; | ||
| return n; | ||
| } | ||
| function un(e, n) { | ||
| const t = Math.floor(e.length / n), r = new Float32Array(n); | ||
| for (let o = 0; o < n; o++) { | ||
| const i = t * o; | ||
| let a = 0; | ||
| for (let c = 0; c < t; c++) | ||
| a = a + Math.abs(e[i + c]); | ||
| r[o] = a / t; | ||
| } | ||
| return r; | ||
| } | ||
| function ie(e, n = {}) { | ||
| let t, r; | ||
| typeof n == "string" ? t = n : (t = n == null ? void 0 : n.participantIdentity, r = n == null ? void 0 : n.room); | ||
| const o = he(), i = Xt({ room: r, updateOnlyOn: [] }), a = s.useMemo(() => t ? i.find((p) => p.identity === t) : o, [t, i, o]), c = s.useMemo(() => { | ||
| if (a) | ||
| return Lt(a, { sources: e }); | ||
| }, [a, JSON.stringify(e)]); | ||
| return O(c, []); | ||
| } | ||
| function dn(e) { | ||
| var t, r, o; | ||
| const n = s.useMemo( | ||
| () => { | ||
| var i; | ||
| return (i = e == null ? void 0 : e.publication) != null && i.track ? At(e == null ? void 0 : e.publication.track) : void 0; | ||
| }, | ||
| [(t = e == null ? void 0 : e.publication) == null ? void 0 : t.track] | ||
| ); | ||
| return O(n, { | ||
| timestamp: Date.now(), | ||
| rtpTimestamp: (o = (r = e == null ? void 0 : e.publication) == null ? void 0 : r.track) == null ? void 0 : o.rtpTimestamp | ||
| }); | ||
| } | ||
| const ln = { | ||
| bufferSize: 100 | ||
| // maxAge: 2_000, | ||
| }; | ||
| function fn(e, n) { | ||
| const t = { ...ln, ...n }, [r, o] = s.useState([]), i = dn(e), a = (c) => { | ||
| var u; | ||
| (u = t.onTranscription) == null || u.call(t, c), o( | ||
| (p) => Ot( | ||
| p, | ||
| // when first receiving a segment, add the current media timestamp to it | ||
| c.map((h) => Dt(h, i)), | ||
| t.bufferSize | ||
| ) | ||
| ); | ||
| }; | ||
| return s.useEffect(() => { | ||
| if (!(e != null && e.publication)) | ||
| return; | ||
| const c = Rt(e.publication).subscribe((u) => { | ||
| a(...u); | ||
| }); | ||
| return () => { | ||
| c.unsubscribe(); | ||
| }; | ||
| }, [e && me(e), a]), { segments: r }; | ||
| } | ||
| function mn(e = {}) { | ||
| const n = he(), t = e.participant ?? n, r = s.useMemo( | ||
| // weird typescript constraint | ||
| () => t ? le(t) : le(t), | ||
| [t] | ||
| ); | ||
| return O(r, { | ||
| attributes: t == null ? void 0 : t.attributes | ||
| }); | ||
| } | ||
| function dr(e, n = {}) { | ||
| const t = Y(n.participant), [r, o] = s.useState(t.attributes[e]); | ||
| return s.useEffect(() => { | ||
| if (!t) | ||
| return; | ||
| const i = le(t).subscribe((a) => { | ||
| a.changed[e] !== void 0 && o(a.attributes[e]); | ||
| }); | ||
| return () => { | ||
| i.unsubscribe(); | ||
| }; | ||
| }, [t, e]), r; | ||
| } | ||
| const we = $.AgentState; | ||
| function lr() { | ||
| const e = ve(), n = e.find( | ||
| (l) => l.kind === ae.AGENT && !($.PublishOnBehalf in l.attributes) | ||
| ), t = e.find( | ||
| (l) => l.kind === ae.AGENT && l.attributes[$.PublishOnBehalf] === (n == null ? void 0 : n.identity) | ||
| ), r = ie( | ||
| [E.Source.Microphone, E.Source.Camera], | ||
| n == null ? void 0 : n.identity | ||
| ), o = ie( | ||
| [E.Source.Microphone, E.Source.Camera], | ||
| t == null ? void 0 : t.identity | ||
| ), i = r.find((l) => l.source === E.Source.Microphone) ?? o.find((l) => l.source === E.Source.Microphone), a = r.find((l) => l.source === E.Source.Camera) ?? o.find((l) => l.source === E.Source.Camera), { segments: c } = fn(i), u = re(), { attributes: p } = mn({ participant: n }), h = s.useMemo(() => u === I.Disconnected ? "disconnected" : u === I.Connecting || !n || !(p != null && p[we]) ? "connecting" : p[we], [p, n, u]); | ||
| return { | ||
| agent: n, | ||
| state: h, | ||
| audioTrack: i, | ||
| videoTrack: a, | ||
| agentTranscriptions: c, | ||
| agentAttributes: p | ||
| }; | ||
| } | ||
| function fr(e) { | ||
| const n = U(e), t = re(n), r = s.useMemo(() => It(n), [n, t]); | ||
| return O(r, n.isRecording); | ||
| } | ||
| function pn(e, n) { | ||
| const t = U(n == null ? void 0 : n.room), o = re(t) === I.Disconnected, i = s.useMemo(() => Nt(t, e), [t, e]); | ||
| return { textStreams: O(o ? void 0 : i, []) }; | ||
| } | ||
| function hn(e) { | ||
| const { participantIdentities: n, trackSids: t } = e ?? {}, { textStreams: r } = pn(_t.TRANSCRIPTION, { room: e == null ? void 0 : e.room }); | ||
| return s.useMemo( | ||
| () => r.filter( | ||
| (i) => n ? n.includes(i.participantInfo.identity) : !0 | ||
| ).filter( | ||
| (i) => { | ||
| var a; | ||
| return t ? t.includes( | ||
| ((a = i.streamInfo.attributes) == null ? void 0 : a[$.TranscribedTrackId]) ?? "" | ||
| ) : !0; | ||
| } | ||
| ), | ||
| [r, n, t] | ||
| ); | ||
| } | ||
| const Pe = 2, Le = 400, Ae = 3, Re = 1e3; | ||
| function mr(e) { | ||
| const n = ue([]), t = Be(() => new Bt(), []), r = ne(async () => t.lock().then(async (h) => { | ||
| for (; ; ) { | ||
| const l = n.current.pop(); | ||
| if (!l) { | ||
| h(); | ||
| break; | ||
| } | ||
| switch (l.type) { | ||
| case "connect": | ||
| await l.room.connect(...l.args).then(l.resolve).catch(l.reject); | ||
| break; | ||
| case "disconnect": | ||
| await l.room.disconnect(...l.args).then(l.resolve).catch(l.reject); | ||
| break; | ||
| } | ||
| } | ||
| }), []), o = ue([]), i = ne((h) => { | ||
| let l = 0; | ||
| o.current = o.current.filter((d) => { | ||
| const v = h.getTime() - d.getTime() < Re; | ||
| return v && (l += 1), v; | ||
| }), l > Ae && j.warn( | ||
| `useSequentialRoomConnectDisconnect: room changed reference rapidly (over ${Ae}x in ${Re}ms). This is not recommended.` | ||
| ); | ||
| }, []); | ||
| Ve(() => { | ||
| n.current = []; | ||
| const h = /* @__PURE__ */ new Date(); | ||
| o.current.push(h), i(h); | ||
| }, [e, i]); | ||
| const a = ue([]), c = ne((h) => { | ||
| let l = 0; | ||
| a.current = a.current.filter((d) => { | ||
| const v = h.getTime() - d.getTime() < Le; | ||
| return v && (l += 1), v; | ||
| }), l > Pe && j.warn( | ||
| `useSequentialRoomConnectDisconnect: room connect / disconnect occurring in rapid sequence (over ${Pe}x in ${Le}ms). This is not recommended and may be the sign of a bug like a useEffect dependency changing every render.` | ||
| ); | ||
| }, []), u = ne( | ||
| async (...h) => new Promise((l, d) => { | ||
| if (!e) | ||
| throw new Error("Called connect(), but room was unset"); | ||
| const v = /* @__PURE__ */ new Date(); | ||
| c(v), n.current.push({ type: "connect", room: e, args: h, resolve: l, reject: d }), a.current.push(v), r(); | ||
| }), | ||
| [e, c, r] | ||
| ), p = ne( | ||
| async (...h) => new Promise((l, d) => { | ||
| if (!e) | ||
| throw new Error("Called discconnect(), but room was unset"); | ||
| const v = /* @__PURE__ */ new Date(); | ||
| c(v), n.current.push({ type: "disconnect", room: e, args: h, resolve: l, reject: d }), a.current.push(v), r(); | ||
| }), | ||
| [e, c, r] | ||
| ); | ||
| return { | ||
| connect: e ? u : null, | ||
| disconnect: e ? p : null | ||
| }; | ||
| } | ||
| var oe = { exports: {} }, Oe; | ||
| function bn() { | ||
| if (Oe) return oe.exports; | ||
| Oe = 1; | ||
| var e = typeof Reflect == "object" ? Reflect : null, n = e && typeof e.apply == "function" ? e.apply : function(f, b, g) { | ||
| return Function.prototype.apply.call(f, b, g); | ||
| }, t; | ||
| e && typeof e.ownKeys == "function" ? t = e.ownKeys : Object.getOwnPropertySymbols ? t = function(f) { | ||
| return Object.getOwnPropertyNames(f).concat(Object.getOwnPropertySymbols(f)); | ||
| } : t = function(f) { | ||
| return Object.getOwnPropertyNames(f); | ||
| }; | ||
| function r(m) { | ||
| console && console.warn && console.warn(m); | ||
| } | ||
| var o = Number.isNaN || function(f) { | ||
| return f !== f; | ||
| }; | ||
| function i() { | ||
| i.init.call(this); | ||
| } | ||
| oe.exports = i, oe.exports.once = P, i.EventEmitter = i, i.prototype._events = void 0, i.prototype._eventsCount = 0, i.prototype._maxListeners = void 0; | ||
| var a = 10; | ||
| function c(m) { | ||
| if (typeof m != "function") | ||
| throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof m); | ||
| } | ||
| Object.defineProperty(i, "defaultMaxListeners", { | ||
| enumerable: !0, | ||
| get: function() { | ||
| return a; | ||
| }, | ||
| set: function(m) { | ||
| if (typeof m != "number" || m < 0 || o(m)) | ||
| throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + m + "."); | ||
| a = m; | ||
| } | ||
| }), i.init = function() { | ||
| (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0; | ||
| }, i.prototype.setMaxListeners = function(f) { | ||
| if (typeof f != "number" || f < 0 || o(f)) | ||
| throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + f + "."); | ||
| return this._maxListeners = f, this; | ||
| }; | ||
| function u(m) { | ||
| return m._maxListeners === void 0 ? i.defaultMaxListeners : m._maxListeners; | ||
| } | ||
| i.prototype.getMaxListeners = function() { | ||
| return u(this); | ||
| }, i.prototype.emit = function(f) { | ||
| for (var b = [], g = 1; g < arguments.length; g++) b.push(arguments[g]); | ||
| var y = f === "error", T = this._events; | ||
| if (T !== void 0) | ||
| y = y && T.error === void 0; | ||
| else if (!y) | ||
| return !1; | ||
| if (y) { | ||
| var C; | ||
| if (b.length > 0 && (C = b[0]), C instanceof Error) | ||
| throw C; | ||
| var k = new Error("Unhandled error." + (C ? " (" + C.message + ")" : "")); | ||
| throw k.context = C, k; | ||
| } | ||
| var F = T[f]; | ||
| if (F === void 0) | ||
| return !1; | ||
| if (typeof F == "function") | ||
| n(F, this, b); | ||
| else | ||
| for (var B = F.length, H = M(F, B), g = 0; g < B; ++g) | ||
| n(H[g], this, b); | ||
| return !0; | ||
| }; | ||
| function p(m, f, b, g) { | ||
| var y, T, C; | ||
| if (c(b), T = m._events, T === void 0 ? (T = m._events = /* @__PURE__ */ Object.create(null), m._eventsCount = 0) : (T.newListener !== void 0 && (m.emit( | ||
| "newListener", | ||
| f, | ||
| b.listener ? b.listener : b | ||
| ), T = m._events), C = T[f]), C === void 0) | ||
| C = T[f] = b, ++m._eventsCount; | ||
| else if (typeof C == "function" ? C = T[f] = g ? [b, C] : [C, b] : g ? C.unshift(b) : C.push(b), y = u(m), y > 0 && C.length > y && !C.warned) { | ||
| C.warned = !0; | ||
| var k = new Error("Possible EventEmitter memory leak detected. " + C.length + " " + String(f) + " listeners added. Use emitter.setMaxListeners() to increase limit"); | ||
| k.name = "MaxListenersExceededWarning", k.emitter = m, k.type = f, k.count = C.length, r(k); | ||
| } | ||
| return m; | ||
| } | ||
| i.prototype.addListener = function(f, b) { | ||
| return p(this, f, b, !1); | ||
| }, i.prototype.on = i.prototype.addListener, i.prototype.prependListener = function(f, b) { | ||
| return p(this, f, b, !0); | ||
| }; | ||
| function h() { | ||
| if (!this.fired) | ||
| return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments); | ||
| } | ||
| function l(m, f, b) { | ||
| var g = { fired: !1, wrapFn: void 0, target: m, type: f, listener: b }, y = h.bind(g); | ||
| return y.listener = b, g.wrapFn = y, y; | ||
| } | ||
| i.prototype.once = function(f, b) { | ||
| return c(b), this.on(f, l(this, f, b)), this; | ||
| }, i.prototype.prependOnceListener = function(f, b) { | ||
| return c(b), this.prependListener(f, l(this, f, b)), this; | ||
| }, i.prototype.removeListener = function(f, b) { | ||
| var g, y, T, C, k; | ||
| if (c(b), y = this._events, y === void 0) | ||
| return this; | ||
| if (g = y[f], g === void 0) | ||
| return this; | ||
| if (g === b || g.listener === b) | ||
| --this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete y[f], y.removeListener && this.emit("removeListener", f, g.listener || b)); | ||
| else if (typeof g != "function") { | ||
| for (T = -1, C = g.length - 1; C >= 0; C--) | ||
| if (g[C] === b || g[C].listener === b) { | ||
| k = g[C].listener, T = C; | ||
| break; | ||
| } | ||
| if (T < 0) | ||
| return this; | ||
| T === 0 ? g.shift() : w(g, T), g.length === 1 && (y[f] = g[0]), y.removeListener !== void 0 && this.emit("removeListener", f, k || b); | ||
| } | ||
| return this; | ||
| }, i.prototype.off = i.prototype.removeListener, i.prototype.removeAllListeners = function(f) { | ||
| var b, g, y; | ||
| if (g = this._events, g === void 0) | ||
| return this; | ||
| if (g.removeListener === void 0) | ||
| return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : g[f] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete g[f]), this; | ||
| if (arguments.length === 0) { | ||
| var T = Object.keys(g), C; | ||
| for (y = 0; y < T.length; ++y) | ||
| C = T[y], C !== "removeListener" && this.removeAllListeners(C); | ||
| return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this; | ||
| } | ||
| if (b = g[f], typeof b == "function") | ||
| this.removeListener(f, b); | ||
| else if (b !== void 0) | ||
| for (y = b.length - 1; y >= 0; y--) | ||
| this.removeListener(f, b[y]); | ||
| return this; | ||
| }; | ||
| function d(m, f, b) { | ||
| var g = m._events; | ||
| if (g === void 0) | ||
| return []; | ||
| var y = g[f]; | ||
| return y === void 0 ? [] : typeof y == "function" ? b ? [y.listener || y] : [y] : b ? A(y) : M(y, y.length); | ||
| } | ||
| i.prototype.listeners = function(f) { | ||
| return d(this, f, !0); | ||
| }, i.prototype.rawListeners = function(f) { | ||
| return d(this, f, !1); | ||
| }, i.listenerCount = function(m, f) { | ||
| return typeof m.listenerCount == "function" ? m.listenerCount(f) : v.call(m, f); | ||
| }, i.prototype.listenerCount = v; | ||
| function v(m) { | ||
| var f = this._events; | ||
| if (f !== void 0) { | ||
| var b = f[m]; | ||
| if (typeof b == "function") | ||
| return 1; | ||
| if (b !== void 0) | ||
| return b.length; | ||
| } | ||
| return 0; | ||
| } | ||
| i.prototype.eventNames = function() { | ||
| return this._eventsCount > 0 ? t(this._events) : []; | ||
| }; | ||
| function M(m, f) { | ||
| for (var b = new Array(f), g = 0; g < f; ++g) | ||
| b[g] = m[g]; | ||
| return b; | ||
| } | ||
| function w(m, f) { | ||
| for (; f + 1 < m.length; f++) | ||
| m[f] = m[f + 1]; | ||
| m.pop(); | ||
| } | ||
| function A(m) { | ||
| for (var f = new Array(m.length), b = 0; b < f.length; ++b) | ||
| f[b] = m[b].listener || m[b]; | ||
| return f; | ||
| } | ||
| function P(m, f) { | ||
| return new Promise(function(b, g) { | ||
| function y(C) { | ||
| m.removeListener(f, T), g(C); | ||
| } | ||
| function T() { | ||
| typeof m.removeListener == "function" && m.removeListener("error", y), b([].slice.call(arguments)); | ||
| } | ||
| R(m, f, T, { once: !0 }), f !== "error" && D(m, y, { once: !0 }); | ||
| }); | ||
| } | ||
| function D(m, f, b) { | ||
| typeof m.on == "function" && R(m, "error", f, b); | ||
| } | ||
| function R(m, f, b, g) { | ||
| if (typeof m.on == "function") | ||
| g.once ? m.once(f, b) : m.on(f, b); | ||
| else if (typeof m.addEventListener == "function") | ||
| m.addEventListener(f, function y(T) { | ||
| g.once && m.removeEventListener(f, y), b(T); | ||
| }); | ||
| else | ||
| throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof m); | ||
| } | ||
| return oe.exports; | ||
| } | ||
| var ge = bn(); | ||
| const vn = 2e4; | ||
| var gn = /* @__PURE__ */ ((e) => (e.CameraChanged = "cameraChanged", e.MicrophoneChanged = "microphoneChanged", e.StateChanged = "stateChanged", e))(gn || {}); | ||
| const x = (e) => ({ | ||
| isConnected: e === "listening" || e === "thinking" || e === "speaking", | ||
| canListen: e === "pre-connect-buffering" || e === "listening" || e === "thinking" || e === "speaking", | ||
| isFinished: e === "disconnected" || e === "failed", | ||
| isPending: e === "connecting" || e === "initializing" || e === "idle" | ||
| }), Sn = () => { | ||
| const [e, n] = s.useState( | ||
| null | ||
| ), [t, r] = s.useState( | ||
| null | ||
| ), o = s.useRef("connecting"), i = s.useRef(!1), a = (c) => setTimeout(() => { | ||
| if (!i.current) { | ||
| n("Agent did not join the room."); | ||
| return; | ||
| } | ||
| const { isConnected: u } = x(o.current); | ||
| if (!u) { | ||
| n("Agent joined the room but did not complete initializing."); | ||
| return; | ||
| } | ||
| }, c ?? vn); | ||
| return { | ||
| agentTimeoutFailureReason: e, | ||
| startAgentTimeout: s.useCallback( | ||
| (c) => { | ||
| t && clearTimeout(t), n(null), r(a(c)), o.current = "connecting", i.current = !1; | ||
| }, | ||
| [t] | ||
| ), | ||
| clearAgentTimeout: s.useCallback(() => { | ||
| t && clearTimeout(t), n(null), r(null), o.current = "connecting", i.current = !1; | ||
| }, [t]), | ||
| clearAgentTimeoutFailureReason: s.useCallback(() => { | ||
| n(null); | ||
| }, []), | ||
| updateAgentTimeoutState: s.useCallback((c) => { | ||
| o.current = c; | ||
| }, []), | ||
| updateAgentTimeoutParticipantExists: s.useCallback((c) => { | ||
| i.current = c; | ||
| }, []) | ||
| }; | ||
| }; | ||
| function yn(e, n) { | ||
| const t = s.useRef(n); | ||
| s.useEffect(() => { | ||
| t.current = n; | ||
| }, [n]); | ||
| const r = s.useCallback( | ||
| async (a) => { | ||
| const { isConnected: c } = x(t.current); | ||
| if (!c) | ||
| return new Promise((u, p) => { | ||
| const h = (v) => { | ||
| const { isConnected: M } = x(v); | ||
| M && (d(), u()); | ||
| }, l = () => { | ||
| d(), p(new Error("useAgent(/* ... */).waitUntilConnected - signal aborted")); | ||
| }, d = () => { | ||
| e.off("stateChanged", h), a == null || a.removeEventListener("abort", l); | ||
| }; | ||
| e.on("stateChanged", h), a == null || a.addEventListener("abort", l); | ||
| }); | ||
| }, | ||
| [e] | ||
| ), o = s.useCallback( | ||
| async (a) => { | ||
| const { canListen: c } = x(t.current); | ||
| if (!c) | ||
| return new Promise((u, p) => { | ||
| const h = (v) => { | ||
| const { canListen: M } = x(v); | ||
| M && (d(), u()); | ||
| }, l = () => { | ||
| d(), p(new Error("useAgent(/* ... */).waitUntilCouldBeListening - signal aborted")); | ||
| }, d = () => { | ||
| e.off("stateChanged", h), a == null || a.removeEventListener("abort", l); | ||
| }; | ||
| e.on("stateChanged", h), a == null || a.addEventListener("abort", l); | ||
| }); | ||
| }, | ||
| [e] | ||
| ), i = s.useCallback( | ||
| async (a) => { | ||
| const { isFinished: c } = x(t.current); | ||
| if (!c) | ||
| return new Promise((u, p) => { | ||
| const h = (v) => { | ||
| const { isFinished: M } = x(v); | ||
| M && (d(), u()); | ||
| }, l = () => { | ||
| d(), p(new Error("useAgent(/* ... */).waitUntilFinished - signal aborted")); | ||
| }, d = () => { | ||
| e.off("stateChanged", h), a == null || a.removeEventListener("abort", l); | ||
| }; | ||
| e.on("stateChanged", h), a == null || a.addEventListener("abort", l); | ||
| }); | ||
| }, | ||
| [e] | ||
| ); | ||
| return { waitUntilConnected: r, waitUntilCouldBeListening: o, waitUntilFinished: i }; | ||
| } | ||
| function Ue(e) { | ||
| const n = Ft(); | ||
| if (e = e ?? n, !e) | ||
| throw new Error( | ||
| "No session provided, make sure you are inside a Session context or pass the session explicitly" | ||
| ); | ||
| const { | ||
| room: t, | ||
| internal: { | ||
| agentConnectTimeoutMilliseconds: r, | ||
| agentTimeoutFailureReason: o, | ||
| startAgentTimeout: i, | ||
| clearAgentTimeout: a, | ||
| clearAgentTimeoutFailureReason: c, | ||
| updateAgentTimeoutState: u, | ||
| updateAgentTimeoutParticipantExists: p | ||
| } | ||
| } = e, h = s.useMemo(() => new ge.EventEmitter(), []), l = ve({ room: t }), d = s.useMemo(() => l.find( | ||
| (S) => S.kind === ae.AGENT && !($.PublishOnBehalf in S.attributes) | ||
| ) ?? null, [l]), v = s.useMemo(() => d ? l.find( | ||
| (S) => S.kind === ae.AGENT && S.attributes[$.PublishOnBehalf] === d.identity | ||
| ) ?? null : null, [d, l]), [M, w] = s.useState((d == null ? void 0 : d.attributes) ?? {}); | ||
| s.useEffect(() => { | ||
| if (!d) | ||
| return; | ||
| const S = (_) => { | ||
| w(_); | ||
| }; | ||
| return d.on(ee.AttributesChanged, S), () => { | ||
| d.off(ee.AttributesChanged, S); | ||
| }; | ||
| }, [d, h]); | ||
| const A = ie([E.Source.Camera, E.Source.Microphone], { | ||
| room: t, | ||
| participantIdentity: d == null ? void 0 : d.identity | ||
| }), P = ie([E.Source.Camera, E.Source.Microphone], { | ||
| room: t, | ||
| participantIdentity: v == null ? void 0 : v.identity | ||
| }), D = s.useMemo( | ||
| () => A.find((S) => S.source === E.Source.Camera) ?? P.find((S) => S.source === E.Source.Camera), | ||
| [A, P] | ||
| ); | ||
| s.useEffect(() => { | ||
| h.emit("cameraChanged", D); | ||
| }, [h, D]); | ||
| const R = s.useMemo( | ||
| () => A.find((S) => S.source === E.Source.Microphone) ?? P.find((S) => S.source === E.Source.Microphone), | ||
| [A, P] | ||
| ); | ||
| s.useEffect(() => { | ||
| h.emit("microphoneChanged", R); | ||
| }, [h, R]); | ||
| const [m, f] = s.useState(t.state); | ||
| s.useEffect(() => { | ||
| const S = (_) => { | ||
| f(_); | ||
| }; | ||
| return t.on(V.ConnectionStateChanged, S), () => { | ||
| t.off(V.ConnectionStateChanged, S); | ||
| }; | ||
| }, [t]), s.useEffect(() => { | ||
| d && c(); | ||
| }, [d]); | ||
| const [b, g] = s.useState(null); | ||
| s.useEffect(() => { | ||
| if (!d) | ||
| return; | ||
| const S = (_) => { | ||
| _.identity === (d == null ? void 0 : d.identity) && g("Agent left the room unexpectedly."); | ||
| }; | ||
| return t.on(V.ParticipantDisconnected, S), () => { | ||
| t.off(V.ParticipantDisconnected, S); | ||
| }; | ||
| }, [d, t]), s.useEffect(() => { | ||
| m === I.Disconnected && g(null); | ||
| }, [m]); | ||
| const [y, T] = s.useState( | ||
| () => t.localParticipant.getTrackPublication(E.Source.Microphone) ?? null | ||
| ); | ||
| s.useEffect(() => { | ||
| const S = () => { | ||
| T(t.localParticipant.getTrackPublication(E.Source.Microphone) ?? null); | ||
| }, _ = () => { | ||
| T(null); | ||
| }; | ||
| return t.localParticipant.on( | ||
| ee.LocalTrackPublished, | ||
| S | ||
| ), t.localParticipant.on( | ||
| ee.LocalTrackUnpublished, | ||
| _ | ||
| ), () => { | ||
| t.localParticipant.off( | ||
| ee.LocalTrackPublished, | ||
| S | ||
| ), t.localParticipant.off( | ||
| ee.LocalTrackUnpublished, | ||
| _ | ||
| ); | ||
| }; | ||
| }, [t.localParticipant]); | ||
| const C = s.useMemo(() => { | ||
| const S = []; | ||
| return o && S.push(o), b && S.push(b), S; | ||
| }, [o, b]), k = s.useMemo(() => { | ||
| if (C.length > 0) | ||
| return "failed"; | ||
| let S = "disconnected"; | ||
| return m !== I.Disconnected && (S = "connecting"), y && (S = "pre-connect-buffering"), d && M[$.AgentState] && (S = M[$.AgentState]), S; | ||
| }, [ | ||
| C, | ||
| m, | ||
| y, | ||
| d, | ||
| M | ||
| ]); | ||
| s.useEffect(() => { | ||
| h.emit("stateChanged", k), u(k); | ||
| }, [h, k]), s.useEffect(() => { | ||
| p(d !== null); | ||
| }, [d]); | ||
| const F = e.connectionState === "disconnected"; | ||
| s.useEffect(() => { | ||
| if (!F) | ||
| return i(r), () => { | ||
| a(); | ||
| }; | ||
| }, [F, r]); | ||
| const { | ||
| identity: B, | ||
| name: H, | ||
| metadata: K | ||
| } = Yt({ participant: d ?? void 0 }), te = s.useMemo(() => { | ||
| const S = { | ||
| attributes: M, | ||
| internal: { | ||
| agentParticipant: d, | ||
| workerParticipant: v, | ||
| emitter: h | ||
| } | ||
| }; | ||
| switch (k) { | ||
| case "disconnected": | ||
| return { | ||
| ...S, | ||
| identity: void 0, | ||
| name: void 0, | ||
| metadata: void 0, | ||
| state: k, | ||
| ...x(k), | ||
| failureReasons: null, | ||
| // Clear inner values if no longer connected | ||
| cameraTrack: void 0, | ||
| microphoneTrack: void 0 | ||
| }; | ||
| case "connecting": | ||
| return { | ||
| ...S, | ||
| identity: void 0, | ||
| name: void 0, | ||
| metadata: void 0, | ||
| state: k, | ||
| ...x(k), | ||
| failureReasons: null, | ||
| // Clear inner values if no longer connected | ||
| cameraTrack: void 0, | ||
| microphoneTrack: void 0 | ||
| }; | ||
| case "initializing": | ||
| case "idle": | ||
| return { | ||
| ...S, | ||
| identity: B, | ||
| name: H, | ||
| metadata: K, | ||
| state: k, | ||
| ...x(k), | ||
| failureReasons: null, | ||
| cameraTrack: D, | ||
| microphoneTrack: R | ||
| }; | ||
| case "pre-connect-buffering": | ||
| return { | ||
| ...S, | ||
| identity: B, | ||
| name: H, | ||
| metadata: K, | ||
| state: k, | ||
| ...x(k), | ||
| failureReasons: null, | ||
| cameraTrack: D, | ||
| microphoneTrack: R | ||
| }; | ||
| case "listening": | ||
| case "thinking": | ||
| case "speaking": | ||
| return { | ||
| ...S, | ||
| identity: B, | ||
| name: H, | ||
| metadata: K, | ||
| state: k, | ||
| ...x(k), | ||
| failureReasons: null, | ||
| cameraTrack: D, | ||
| microphoneTrack: R | ||
| }; | ||
| case "failed": | ||
| return { | ||
| ...S, | ||
| identity: void 0, | ||
| name: void 0, | ||
| metadata: void 0, | ||
| state: "failed", | ||
| ...x("failed"), | ||
| failureReasons: C, | ||
| // Clear inner values if no longer connected | ||
| cameraTrack: void 0, | ||
| microphoneTrack: void 0 | ||
| }; | ||
| } | ||
| }, [ | ||
| B, | ||
| H, | ||
| K, | ||
| M, | ||
| h, | ||
| d, | ||
| k, | ||
| D, | ||
| R | ||
| ]), { waitUntilConnected: X, waitUntilCouldBeListening: L, waitUntilFinished: N } = yn(h, k), q = s.useCallback( | ||
| (S) => new Promise((_, Z) => { | ||
| const W = (J) => { | ||
| J && (G(), _(J)); | ||
| }, z = () => { | ||
| G(), Z(new Error("useAgent(/* ... */).waitUntilCamera - signal aborted")); | ||
| }, G = () => { | ||
| h.off("cameraChanged", W), S == null || S.removeEventListener("abort", z); | ||
| }; | ||
| h.on("cameraChanged", W), S == null || S.addEventListener("abort", z); | ||
| }), | ||
| [h] | ||
| ), se = s.useCallback( | ||
| (S) => new Promise((_, Z) => { | ||
| const W = (J) => { | ||
| J && (G(), _(J)); | ||
| }, z = () => { | ||
| G(), Z(new Error("useAgent(/* ... */).waitUntilMicrophone - signal aborted")); | ||
| }, G = () => { | ||
| h.off("microphoneChanged", W), S == null || S.removeEventListener("abort", z); | ||
| }; | ||
| h.on("microphoneChanged", W), S == null || S.addEventListener("abort", z); | ||
| }), | ||
| [h] | ||
| ); | ||
| return s.useMemo(() => ({ | ||
| ...te, | ||
| waitUntilConnected: X, | ||
| waitUntilCouldBeListening: L, | ||
| waitUntilFinished: N, | ||
| waitUntilCamera: q, | ||
| waitUntilMicrophone: se | ||
| }), [ | ||
| te, | ||
| X, | ||
| L, | ||
| N, | ||
| q, | ||
| se | ||
| ]); | ||
| } | ||
| var Cn = /* @__PURE__ */ ((e) => (e.ConnectionStateChanged = "connectionStateChanged", e.MediaDevicesError = "mediaDevicesError", e.EncryptionError = "encryptionError", e))(Cn || {}); | ||
| function Mn(e, n) { | ||
| const t = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(n)]); | ||
| for (const r of t) | ||
| switch (r) { | ||
| case "roomName": | ||
| case "participantName": | ||
| case "participantIdentity": | ||
| case "participantMetadata": | ||
| case "participantAttributes": | ||
| case "agentName": | ||
| case "agentMetadata": | ||
| if (e[r] !== n[r]) | ||
| return !1; | ||
| break; | ||
| default: | ||
| const o = r; | ||
| throw new Error(`Options key ${o} not being checked for equality!`); | ||
| } | ||
| return !0; | ||
| } | ||
| function Tn(e, n) { | ||
| const t = s.useRef(n); | ||
| return s.useEffect(() => { | ||
| t.current = n; | ||
| }, [n]), s.useCallback( | ||
| async (o, i) => { | ||
| if (t.current !== o) | ||
| return new Promise((a, c) => { | ||
| const u = (l) => { | ||
| l === o && (h(), a()); | ||
| }, p = () => { | ||
| h(), c( | ||
| new Error( | ||
| `useSession(/* ... */).waitUntilConnectionState(${o}, /* signal */) - signal aborted` | ||
| ) | ||
| ); | ||
| }, h = () => { | ||
| e.off("connectionStateChanged", u), i == null || i.removeEventListener("abort", p); | ||
| }; | ||
| e.on("connectionStateChanged", u), i == null || i.addEventListener("abort", p); | ||
| }); | ||
| }, | ||
| [e] | ||
| ); | ||
| } | ||
| function En(e, n) { | ||
| const t = e instanceof qt, r = s.useRef( | ||
| t ? n : null | ||
| ); | ||
| return s.useEffect(() => { | ||
| if (!t) { | ||
| r.current = null; | ||
| return; | ||
| } | ||
| r.current !== null && Mn(r.current, n) || (r.current = n); | ||
| }, [t, n]), s.useCallback(async () => { | ||
| if (t) { | ||
| if (!r.current) | ||
| throw new Error( | ||
| "AgentSession - memoized token fetch options are not set, but the passed tokenSource was an instance of TokenSourceConfigurable. If you are seeing this please make a new GitHub issue!" | ||
| ); | ||
| return e.fetch(r.current); | ||
| } else | ||
| return e.fetch(); | ||
| }, [t, e]); | ||
| } | ||
| function pr(e, n = {}) { | ||
| const { room: t, agentConnectTimeoutMilliseconds: r, ...o } = n, i = pe(), a = s.useMemo( | ||
| () => i ?? t ?? new Fe(), | ||
| [i, t] | ||
| ), c = s.useMemo( | ||
| () => new ge.EventEmitter(), | ||
| [] | ||
| ), u = s.useCallback( | ||
| (L) => ({ | ||
| isConnected: L === I.Connected || L === I.Reconnecting || L === I.SignalReconnecting | ||
| }), | ||
| [] | ||
| ), [p, h] = s.useState(a.state); | ||
| s.useEffect(() => { | ||
| const L = (N) => { | ||
| h(N); | ||
| }; | ||
| return a.on(V.ConnectionStateChanged, L), () => { | ||
| a.off(V.ConnectionStateChanged, L); | ||
| }; | ||
| }, [a]), s.useEffect(() => { | ||
| const L = async (N) => { | ||
| c.emit("mediaDevicesError", N); | ||
| }; | ||
| return a.on(V.MediaDevicesError, L), () => { | ||
| a.off(V.MediaDevicesError, L); | ||
| }; | ||
| }, [a, c]), s.useEffect(() => { | ||
| const L = async (N) => { | ||
| c.emit("encryptionError", N); | ||
| }; | ||
| return a.on(V.EncryptionError, L), () => { | ||
| a.off(V.EncryptionError, L); | ||
| }; | ||
| }, [a, c]); | ||
| const { localParticipant: l } = xe({ room: a }), d = l.getTrackPublication(E.Source.Camera), v = s.useMemo(() => { | ||
| if (d) | ||
| return { | ||
| source: E.Source.Camera, | ||
| participant: l, | ||
| publication: d | ||
| }; | ||
| }, [l, d]), M = l.getTrackPublication(E.Source.Microphone), w = s.useMemo(() => { | ||
| if (M) | ||
| return { | ||
| source: E.Source.Microphone, | ||
| participant: l, | ||
| publication: M | ||
| }; | ||
| }, [l, M]), A = l.getTrackPublication(E.Source.ScreenShare), P = s.useMemo(() => { | ||
| if (A) | ||
| return { | ||
| source: E.Source.ScreenShare, | ||
| participant: l, | ||
| publication: A | ||
| }; | ||
| }, [l, A]), { | ||
| agentTimeoutFailureReason: D, | ||
| startAgentTimeout: R, | ||
| clearAgentTimeout: m, | ||
| clearAgentTimeoutFailureReason: f, | ||
| updateAgentTimeoutState: b, | ||
| updateAgentTimeoutParticipantExists: g | ||
| } = Sn(), y = s.useMemo( | ||
| () => ({ | ||
| emitter: c, | ||
| tokenSource: e, | ||
| agentConnectTimeoutMilliseconds: r, | ||
| agentTimeoutFailureReason: D, | ||
| startAgentTimeout: R, | ||
| clearAgentTimeout: m, | ||
| clearAgentTimeoutFailureReason: f, | ||
| updateAgentTimeoutState: b, | ||
| updateAgentTimeoutParticipantExists: g | ||
| }), | ||
| [ | ||
| c, | ||
| r, | ||
| e, | ||
| D, | ||
| R, | ||
| m, | ||
| f, | ||
| b, | ||
| g | ||
| ] | ||
| ), T = s.useMemo(() => { | ||
| const L = { | ||
| room: a, | ||
| internal: y | ||
| }; | ||
| switch (p) { | ||
| case I.Connecting: | ||
| return { | ||
| ...L, | ||
| connectionState: I.Connecting, | ||
| ...u(I.Connecting), | ||
| local: { | ||
| cameraTrack: void 0, | ||
| microphoneTrack: void 0, | ||
| screenShareTrack: void 0 | ||
| } | ||
| }; | ||
| case I.Connected: | ||
| case I.Reconnecting: | ||
| case I.SignalReconnecting: | ||
| return { | ||
| ...L, | ||
| connectionState: p, | ||
| ...u(p), | ||
| local: { | ||
| cameraTrack: v, | ||
| microphoneTrack: w, | ||
| screenShareTrack: P | ||
| } | ||
| }; | ||
| case I.Disconnected: | ||
| return { | ||
| ...L, | ||
| connectionState: I.Disconnected, | ||
| ...u(I.Disconnected), | ||
| local: { | ||
| cameraTrack: void 0, | ||
| microphoneTrack: void 0, | ||
| screenShareTrack: void 0 | ||
| } | ||
| }; | ||
| } | ||
| }, [ | ||
| y, | ||
| a, | ||
| p, | ||
| v, | ||
| w, | ||
| u | ||
| ]); | ||
| s.useEffect(() => { | ||
| c.emit("connectionStateChanged", T.connectionState); | ||
| }, [c, T.connectionState]); | ||
| const C = Tn( | ||
| c, | ||
| T.connectionState | ||
| ), k = s.useCallback( | ||
| async (L) => C( | ||
| I.Connected, | ||
| L | ||
| ), | ||
| [C] | ||
| ), F = s.useCallback( | ||
| async (L) => C(I.Disconnected, L), | ||
| [C] | ||
| ), B = Ue( | ||
| s.useMemo( | ||
| () => ({ | ||
| connectionState: T.connectionState, | ||
| room: a, | ||
| internal: y | ||
| }), | ||
| [T, a, y] | ||
| ) | ||
| ), H = En(e, o), K = s.useCallback( | ||
| async (L = {}) => { | ||
| var Z, W, z, G, J, Se; | ||
| const { | ||
| signal: N, | ||
| tracks: q = { microphone: { enabled: !0, publishOptions: { preConnectBuffer: !0 } } }, | ||
| roomConnectOptions: se | ||
| } = L; | ||
| await F(N); | ||
| const S = () => { | ||
| a.disconnect(); | ||
| }; | ||
| N == null || N.addEventListener("abort", S); | ||
| let _ = !1; | ||
| await Promise.all([ | ||
| H().then(({ serverUrl: He, participantToken: ye }) => { | ||
| var Ce, Me; | ||
| return _ = (((Me = (Ce = Vt(ye).roomConfig) == null ? void 0 : Ce.agents) == null ? void 0 : Me.length) ?? 0) > 0, a.connect(He, ye, se); | ||
| }), | ||
| // Start microphone (with preconnect buffer) by default | ||
| (Z = q.microphone) != null && Z.enabled ? a.localParticipant.setMicrophoneEnabled( | ||
| !0, | ||
| void 0, | ||
| ((W = q.microphone) == null ? void 0 : W.publishOptions) ?? {} | ||
| ) : Promise.resolve(), | ||
| (z = q.camera) != null && z.enabled ? a.localParticipant.setCameraEnabled( | ||
| !0, | ||
| void 0, | ||
| ((G = q.camera) == null ? void 0 : G.publishOptions) ?? {} | ||
| ) : Promise.resolve(), | ||
| (J = q.screenShare) != null && J.enabled ? a.localParticipant.setScreenShareEnabled( | ||
| !0, | ||
| void 0, | ||
| ((Se = q.screenShare) == null ? void 0 : Se.publishOptions) ?? {} | ||
| ) : Promise.resolve() | ||
| ]), await k(N), _ && await B.waitUntilConnected(N), N == null || N.removeEventListener("abort", S); | ||
| }, | ||
| [a, F, H, k, B.waitUntilConnected] | ||
| ), te = s.useCallback(async () => { | ||
| await a.disconnect(); | ||
| }, [a]), X = s.useCallback(async () => { | ||
| const L = await H(); | ||
| await a.prepareConnection(L.serverUrl, L.participantToken); | ||
| }, [H, a]); | ||
| return s.useEffect( | ||
| () => { | ||
| X().catch((L) => { | ||
| console.warn("WARNING: Room.prepareConnection failed:", L); | ||
| }); | ||
| }, | ||
| [ | ||
| /* note: no prepareConnection here, this effect should only ever run once! */ | ||
| ] | ||
| ), s.useMemo( | ||
| () => ({ | ||
| ...T, | ||
| waitUntilConnected: k, | ||
| waitUntilDisconnected: F, | ||
| prepareConnection: X, | ||
| start: K, | ||
| end: te | ||
| }), | ||
| [T, k, F, X, K, te] | ||
| ); | ||
| } | ||
| function hr(e, n, t, r) { | ||
| const o = s.useMemo(() => () => { | ||
| }, []), i = s.useCallback(t ?? o, r ?? []), a = r ? i : t, c = s.useMemo(() => e ? "internal" in e ? e.internal.emitter : e : null, [e]); | ||
| s.useEffect(() => { | ||
| if (!(!c || !a)) | ||
| return c.on(n, a), () => { | ||
| c.off(n, a); | ||
| }; | ||
| }, [c, n, a]); | ||
| } | ||
| var kn = /* @__PURE__ */ ((e) => (e.MessageReceived = "messageReceived", e))(kn || {}); | ||
| function br(e) { | ||
| const { room: n } = xt(e), t = s.useMemo( | ||
| () => new ge.EventEmitter(), | ||
| [] | ||
| ), r = Ue(e), o = hn({ room: n }), i = s.useMemo(() => ({ room: n }), [n]), a = rn(i), c = s.useMemo(() => o.map((d) => { | ||
| var v, M, w; | ||
| switch (d.participantInfo.identity) { | ||
| case n.localParticipant.identity: | ||
| return { | ||
| type: "userTranscript", | ||
| message: d.text, | ||
| id: d.streamInfo.id, | ||
| timestamp: d.streamInfo.timestamp, | ||
| from: n.localParticipant | ||
| }; | ||
| case ((v = r.internal.agentParticipant) == null ? void 0 : v.identity): | ||
| case ((M = r.internal.workerParticipant) == null ? void 0 : M.identity): | ||
| return { | ||
| type: "agentTranscript", | ||
| message: d.text, | ||
| id: d.streamInfo.id, | ||
| timestamp: d.streamInfo.timestamp, | ||
| from: ((w = r.internal.agentParticipant) == null ? void 0 : w.identity) === d.participantInfo.identity ? r.internal.agentParticipant : r.internal.workerParticipant | ||
| }; | ||
| default: | ||
| return { | ||
| type: "agentTranscript", | ||
| message: d.text, | ||
| id: d.streamInfo.id, | ||
| timestamp: d.streamInfo.timestamp, | ||
| from: Array.from(n.remoteParticipants.values()).find( | ||
| (A) => A.identity === d.participantInfo.identity | ||
| ) | ||
| }; | ||
| } | ||
| }), [o, n]), u = s.useMemo(() => [...c, ...a.chatMessages], [c, a.chatMessages]), p = s.useRef(/* @__PURE__ */ new Map()), h = s.useMemo(() => { | ||
| const d = /* @__PURE__ */ new Date(); | ||
| for (const v of u) | ||
| p.current.has(v.id) || p.current.set(v.id, d); | ||
| return u.sort((v, M) => { | ||
| const w = p.current.get(v.id), A = p.current.get(M.id); | ||
| return typeof w > "u" || typeof A > "u" ? 0 : w.getTime() - A.getTime(); | ||
| }); | ||
| }, [u]), l = s.useRef(/* @__PURE__ */ new Set()); | ||
| return s.useEffect(() => { | ||
| for (const d of h) | ||
| l.current.has(d.id) || (l.current.add(d.id), t.emit("messageReceived", d)); | ||
| }, [h]), s.useMemo( | ||
| () => ({ | ||
| messages: h, | ||
| send: a.send, | ||
| isSending: a.isSending, | ||
| internal: { emitter: t } | ||
| }), | ||
| [h, a.send, a.isSending] | ||
| ); | ||
| } | ||
| export { | ||
| pn as $, | ||
| Bn as A, | ||
| Gn as B, | ||
| xe as C, | ||
| In as D, | ||
| Fn as E, | ||
| $t as F, | ||
| Ee as G, | ||
| Qt as H, | ||
| Yt as I, | ||
| Wn as J, | ||
| Xt as K, | ||
| Jn as L, | ||
| ve as M, | ||
| Qn as N, | ||
| Zt as O, | ||
| er as P, | ||
| sr as Q, | ||
| gn as R, | ||
| Ue as S, | ||
| ir as T, | ||
| ur as U, | ||
| ie as V, | ||
| fn as W, | ||
| lr as X, | ||
| mn as Y, | ||
| dr as Z, | ||
| fr as _, | ||
| re as a, | ||
| hn as a0, | ||
| mr as a1, | ||
| Cn as a2, | ||
| pr as a3, | ||
| hr as a4, | ||
| kn as a5, | ||
| br as a6, | ||
| Zn as b, | ||
| xn as c, | ||
| Un as d, | ||
| Vn as e, | ||
| Kn as f, | ||
| Yn as g, | ||
| nr as h, | ||
| _n as i, | ||
| O as j, | ||
| tr as k, | ||
| zn as l, | ||
| ar as m, | ||
| Hn as n, | ||
| jn as o, | ||
| Xn as p, | ||
| Jt as q, | ||
| Kt as r, | ||
| cr as s, | ||
| rr as t, | ||
| Nn as u, | ||
| $n as v, | ||
| rn as w, | ||
| or as x, | ||
| qn as y, | ||
| Dn as z | ||
| }; | ||
| //# sourceMappingURL=hooks-0IvkS6LV.mjs.map |
Sorry, the diff of this file is too big to display
| "use strict";const j=require("react"),b=require("./shared-CVy2Ouqp.js"),M=require("./shared-I8hFcrmp.js"),d=require("livekit-client");function we(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=we(j),ee=r.createContext(void 0);function Re(){const e=r.useContext(ee);if(!e)throw Error("tried to access session context outside of SessionProvider component");return e}function te(){return r.useContext(ee)}function pe(e){const t=te(),n=e??t;if(!n)throw new Error("No session provided, make sure you are inside a Session context or pass the session explicitly");return n}function Me(e){const t=b.useEnsureRoom(e),n=r.useCallback(async()=>{await t.startAudio()},[t]),s=r.useMemo(()=>b.roomAudioPlaybackAllowedObservable(t),[t]),{canPlayAudio:f}=M.useObservableState(s,{canPlayAudio:t.canPlaybackAudio});return{canPlayAudio:f,startAudio:n}}function Ae(e){const{state:t,dispatch:n}=M.useLayoutContext().pin;return{buttonProps:r.useMemo(()=>{const{className:f}=b.setupClearPinButton();return M.mergeProps(e,{className:f,disabled:!(t!=null&&t.length),onClick:()=>{n&&n({msg:"clear_pin"})}})},[e,n,t])}}function Le(e,t){const n=typeof e=="function"?e:t,s=typeof e=="string"?e:void 0,f=b.useRoomContext(),{send:c,messageObservable:o,isSendingObservable:p}=r.useMemo(()=>b.setupDataMessageHandler(f,s,n),[f,s,n]),T=M.useObservableState(o,void 0),E=M.useObservableState(p,!1);return{message:T,send:c,isSending:E}}const Oe={connect:!0,audio:!1,video:!1};function xe(e){const{token:t,serverUrl:n,options:s,room:f,connectOptions:c,connect:o,audio:p,video:T,screen:E,onConnected:v,onDisconnected:m,onError:u,onMediaDeviceFailure:k,onEncryptionError:R,simulateParticipants:x,...L}={...Oe,...e};s&&f&&b.log.warn("when using a manually created room, the options object will be ignored. set the desired options directly when creating the room instead.");const[A,I]=r.useState(),D=r.useRef(o);r.useEffect(()=>{I(f??new d.Room(s))},[f,JSON.stringify(s,M.roomOptionsStringifyReplacer)]);const a=r.useMemo(()=>{const{className:i}=b.setupLiveKitRoom();return M.mergeProps(L,{className:i})},[L]);return r.useEffect(()=>{if(!A)return;const i=()=>{const C=A.localParticipant;b.log.debug("trying to publish local tracks"),Promise.all([C.setMicrophoneEnabled(!!p,typeof p!="boolean"?p:void 0),C.setCameraEnabled(!!T,typeof T!="boolean"?T:void 0),C.setScreenShareEnabled(!!E,typeof E!="boolean"?E:void 0)]).catch(P=>{b.log.warn(P),u==null||u(P)})},l=(C,P)=>{const N=d.MediaDeviceFailure.getFailure(C);k==null||k(N,P)},h=C=>{R==null||R(C)},S=C=>{m==null||m(C)},y=()=>{v==null||v()};return A.on(d.RoomEvent.SignalConnected,i).on(d.RoomEvent.MediaDevicesError,l).on(d.RoomEvent.EncryptionError,h).on(d.RoomEvent.Disconnected,S).on(d.RoomEvent.Connected,y),()=>{A.off(d.RoomEvent.SignalConnected,i).off(d.RoomEvent.MediaDevicesError,l).off(d.RoomEvent.EncryptionError,h).off(d.RoomEvent.Disconnected,S).off(d.RoomEvent.Connected,y)}},[A,p,T,E,u,R,k,v,m]),r.useEffect(()=>{if(A){if(x){A.simulateParticipants({participants:{count:x},publish:{audio:!0,useRealTracks:!0}});return}if(o){if(D.current=!0,b.log.debug("connecting"),!t){b.log.debug("no token yet");return}if(!n){b.log.warn("no livekit url provided"),u==null||u(Error("no livekit url provided"));return}A.connect(n,t,c).catch(i=>{b.log.warn(i),D.current===!0&&(u==null||u(i))})}else b.log.debug("disconnecting because connect is false"),D.current=!1,A.disconnect()}},[o,t,JSON.stringify(c),A,u,n,x]),r.useEffect(()=>{if(A)return()=>{b.log.info("disconnecting on onmount"),A.disconnect()}},[A]),{room:A,htmlProps:a}}function he(e={}){let t=M.useMaybeParticipantContext();e.participant&&(t=e.participant);const n=r.useMemo(()=>b.participantInfoObserver(t),[t]),{identity:s,name:f,metadata:c}=M.useObservableState(n,{name:t==null?void 0:t.name,identity:t==null?void 0:t.identity,metadata:t==null?void 0:t.metadata});return{identity:s,name:f,metadata:c}}function De(e={}){const t=M.useEnsureParticipant(e.participant),n=r.useMemo(()=>b.participantPermissionObserver(t),[t]);return M.useObservableState(n,t.permissions)}function Z(e={}){const t=b.useEnsureRoom(e.room),[n,s]=r.useState([]);return r.useEffect(()=>{const f=b.connectedParticipantsObserver(t,{additionalRoomEvents:e.updateOnlyOn}).subscribe(s);return()=>f.unsubscribe()},[t,JSON.stringify(e.updateOnlyOn)]),n}function ve(e={}){const t=Z(e),{localParticipant:n}=b.useLocalParticipant(e);return r.useMemo(()=>[n,...t],[n,t])}function Ne(e,t={}){const n=b.useRoomContext(),[s]=r.useState(t.updateOnlyOn),f=r.useMemo(()=>typeof e=="string"?b.connectedParticipantObserver(n,e,{additionalEvents:s}):b.participantByIdentifierObserver(n,e,{additionalEvents:s}),[n,JSON.stringify(e),s]),[c,o]=r.useState({p:void 0});return r.useEffect(()=>{const p=f.subscribe(T=>o({p:T}));return()=>p.unsubscribe()},[f]),c.p}function _e(e={}){const t=b.useEnsureRoom(e.room),n=r.useMemo(()=>b.roomInfoObserver(t),[t]),{name:s,metadata:f}=M.useObservableState(n,{name:t.name,metadata:t.metadata});return{name:s,metadata:f}}function be(e){const t=b.useEnsureRoom(e==null?void 0:e.room),n=r.useMemo(()=>b.activeSpeakerObserver(t),[t]);return M.useObservableState(n,t.activeSpeakers)}function Ie(e){const[t,n]=r.useState(b.sortParticipants(e)),s=be();return r.useEffect(()=>{n(b.sortParticipants(e))},[s,e]),t}function Fe(e,t,n={}){const[s,f]=r.useState(void 0);return r.useEffect(()=>{var o;if(e===void 0)throw Error("token endpoint needs to be defined");if(((o=n.userInfo)==null?void 0:o.identity)===void 0)return;(async()=>{b.log.debug("fetching token");const p=new URLSearchParams({...n.userInfo,roomName:t}),T=await fetch(`${e}?${p.toString()}`);if(!T.ok){b.log.error(`Could not fetch token. Server responded with status ${T.status}: ${T.statusText}`);return}const{accessToken:E}=await T.json();f(E)})()},[e,t,JSON.stringify(n)]),s}function Ue(e){const[t,n]=r.useState(b.getTrackByIdentifier(e)),{trackObserver:s}=r.useMemo(()=>b.setupMediaTrack(e),[e.participant.sid??e.participant.identity,e.source]);return r.useEffect(()=>{const f=s.subscribe(c=>{n(c)});return()=>f==null?void 0:f.unsubscribe()},[s]),{participant:e.participant,source:e.source??d.Track.Source.Unknown,publication:t}}function je(e,t){const n=M.useEnsureParticipant(t);return Ue({name:e,participant:n})}function Q(e,t={}){let n,s;typeof t=="string"?n=t:(n=t==null?void 0:t.participantIdentity,s=t==null?void 0:t.room);const f=M.useMaybeParticipantContext(),c=ve({room:s,updateOnlyOn:[]}),o=r.useMemo(()=>n?c.find(E=>E.identity===n):f,[n,c,f]),p=r.useMemo(()=>{if(o)return b.participantTracksObservable(o,{sources:e})},[o,JSON.stringify(e)]);return M.useObservableState(p,[])}function He(e){var n,s,f;const t=r.useMemo(()=>{var c;return(c=e==null?void 0:e.publication)!=null&&c.track?b.trackSyncTimeObserver(e==null?void 0:e.publication.track):void 0},[(n=e==null?void 0:e.publication)==null?void 0:n.track]);return M.useObservableState(t,{timestamp:Date.now(),rtpTimestamp:(f=(s=e==null?void 0:e.publication)==null?void 0:s.track)==null?void 0:f.rtpTimestamp})}const Be={bufferSize:100};function ge(e,t){const n={...Be,...t},[s,f]=r.useState([]),c=He(e),o=p=>{var T;(T=n.onTranscription)==null||T.call(n,p),f(E=>b.dedupeSegments(E,p.map(v=>b.addMediaTimestampToTranscription(v,c)),n.bufferSize))};return r.useEffect(()=>{if(!(e!=null&&e.publication))return;const p=b.trackTranscriptionObserver(e.publication).subscribe(T=>{o(...T)});return()=>{p.unsubscribe()}},[e&&b.getTrackReferenceId(e),o]),{segments:s}}function Se(e={}){const t=M.useMaybeParticipantContext(),n=e.participant??t,s=r.useMemo(()=>b.participantAttributesObserver(n),[n]);return M.useObservableState(s,{attributes:n==null?void 0:n.attributes})}function We(e,t={}){const n=M.useEnsureParticipant(t.participant),[s,f]=r.useState(n.attributes[e]);return r.useEffect(()=>{if(!n)return;const c=b.participantAttributesObserver(n).subscribe(o=>{o.changed[e]!==void 0&&f(o.attributes[e])});return()=>{c.unsubscribe()}},[n,e]),s}const ce=b.ParticipantAgentAttributes.AgentState;function qe(){const e=Z(),t=e.find(m=>m.kind===d.ParticipantKind.AGENT&&!(b.ParticipantAgentAttributes.PublishOnBehalf in m.attributes)),n=e.find(m=>m.kind===d.ParticipantKind.AGENT&&m.attributes[b.ParticipantAgentAttributes.PublishOnBehalf]===(t==null?void 0:t.identity)),s=Q([d.Track.Source.Microphone,d.Track.Source.Camera],t==null?void 0:t.identity),f=Q([d.Track.Source.Microphone,d.Track.Source.Camera],n==null?void 0:n.identity),c=s.find(m=>m.source===d.Track.Source.Microphone)??f.find(m=>m.source===d.Track.Source.Microphone),o=s.find(m=>m.source===d.Track.Source.Camera)??f.find(m=>m.source===d.Track.Source.Camera),{segments:p}=ge(c),T=M.useConnectionState(),{attributes:E}=Se({participant:t}),v=r.useMemo(()=>T===d.ConnectionState.Disconnected?"disconnected":T===d.ConnectionState.Connecting||!t||!(E!=null&&E[ce])?"connecting":E[ce],[E,t,T]);return{agent:t,state:v,audioTrack:c,videoTrack:o,agentTranscriptions:p,agentAttributes:E}}function Ge(e){const t=b.useEnsureRoom(e),n=M.useConnectionState(t),s=r.useMemo(()=>b.recordingStatusObservable(t),[t,n]);return M.useObservableState(s,t.isRecording)}function Ce(e,t){const n=b.useEnsureRoom(t==null?void 0:t.room),f=M.useConnectionState(n)===d.ConnectionState.Disconnected,c=r.useMemo(()=>b.setupTextStream(n,e),[n,e]),o=f?void 0:c;return{textStreams:M.useObservableState(o,[])}}function Te(e){const{participantIdentities:t,trackSids:n}=e??{},{textStreams:s}=Ce(b.DataTopic.TRANSCRIPTION,{room:e==null?void 0:e.room});return r.useMemo(()=>s.filter(c=>t?t.includes(c.participantInfo.identity):!0).filter(c=>{var o;return n?n.includes(((o=c.streamInfo.attributes)==null?void 0:o[b.ParticipantAgentAttributes.TranscribedTrackId])??""):!0}),[s,t,n])}const ue=2,de=400,le=3,fe=1e3;function Ke(e){const t=j.useRef([]),n=j.useMemo(()=>new d.Mutex,[]),s=j.useCallback(async()=>n.lock().then(async v=>{for(;;){const m=t.current.pop();if(!m){v();break}switch(m.type){case"connect":await m.room.connect(...m.args).then(m.resolve).catch(m.reject);break;case"disconnect":await m.room.disconnect(...m.args).then(m.resolve).catch(m.reject);break}}}),[]),f=j.useRef([]),c=j.useCallback(v=>{let m=0;f.current=f.current.filter(u=>{const k=v.getTime()-u.getTime()<fe;return k&&(m+=1),k}),m>le&&b.log.warn(`useSequentialRoomConnectDisconnect: room changed reference rapidly (over ${le}x in ${fe}ms). This is not recommended.`)},[]);j.useEffect(()=>{t.current=[];const v=new Date;f.current.push(v),c(v)},[e,c]);const o=j.useRef([]),p=j.useCallback(v=>{let m=0;o.current=o.current.filter(u=>{const k=v.getTime()-u.getTime()<de;return k&&(m+=1),k}),m>ue&&b.log.warn(`useSequentialRoomConnectDisconnect: room connect / disconnect occurring in rapid sequence (over ${ue}x in ${de}ms). This is not recommended and may be the sign of a bug like a useEffect dependency changing every render.`)},[]),T=j.useCallback(async(...v)=>new Promise((m,u)=>{if(!e)throw new Error("Called connect(), but room was unset");const k=new Date;p(k),t.current.push({type:"connect",room:e,args:v,resolve:m,reject:u}),o.current.push(k),s()}),[e,p,s]),E=j.useCallback(async(...v)=>new Promise((m,u)=>{if(!e)throw new Error("Called discconnect(), but room was unset");const k=new Date;p(k),t.current.push({type:"disconnect",room:e,args:v,resolve:m,reject:u}),o.current.push(k),s()}),[e,p,s]);return{connect:e?T:null,disconnect:e?E:null}}var X={exports:{}},me;function $e(){if(me)return X.exports;me=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(i,l,h){return Function.prototype.apply.call(i,l,h)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(i){return Object.getOwnPropertyNames(i).concat(Object.getOwnPropertySymbols(i))}:n=function(i){return Object.getOwnPropertyNames(i)};function s(a){console&&console.warn&&console.warn(a)}var f=Number.isNaN||function(i){return i!==i};function c(){c.init.call(this)}X.exports=c,X.exports.once=A,c.EventEmitter=c,c.prototype._events=void 0,c.prototype._eventsCount=0,c.prototype._maxListeners=void 0;var o=10;function p(a){if(typeof a!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof a)}Object.defineProperty(c,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(a){if(typeof a!="number"||a<0||f(a))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+a+".");o=a}}),c.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},c.prototype.setMaxListeners=function(i){if(typeof i!="number"||i<0||f(i))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+i+".");return this._maxListeners=i,this};function T(a){return a._maxListeners===void 0?c.defaultMaxListeners:a._maxListeners}c.prototype.getMaxListeners=function(){return T(this)},c.prototype.emit=function(i){for(var l=[],h=1;h<arguments.length;h++)l.push(arguments[h]);var S=i==="error",y=this._events;if(y!==void 0)S=S&&y.error===void 0;else if(!S)return!1;if(S){var C;if(l.length>0&&(C=l[0]),C instanceof Error)throw C;var P=new Error("Unhandled error."+(C?" ("+C.message+")":""));throw P.context=C,P}var N=y[i];if(N===void 0)return!1;if(typeof N=="function")t(N,this,l);else for(var H=N.length,U=R(N,H),h=0;h<H;++h)t(U[h],this,l);return!0};function E(a,i,l,h){var S,y,C;if(p(l),y=a._events,y===void 0?(y=a._events=Object.create(null),a._eventsCount=0):(y.newListener!==void 0&&(a.emit("newListener",i,l.listener?l.listener:l),y=a._events),C=y[i]),C===void 0)C=y[i]=l,++a._eventsCount;else if(typeof C=="function"?C=y[i]=h?[l,C]:[C,l]:h?C.unshift(l):C.push(l),S=T(a),S>0&&C.length>S&&!C.warned){C.warned=!0;var P=new Error("Possible EventEmitter memory leak detected. "+C.length+" "+String(i)+" listeners added. Use emitter.setMaxListeners() to increase limit");P.name="MaxListenersExceededWarning",P.emitter=a,P.type=i,P.count=C.length,s(P)}return a}c.prototype.addListener=function(i,l){return E(this,i,l,!1)},c.prototype.on=c.prototype.addListener,c.prototype.prependListener=function(i,l){return E(this,i,l,!0)};function v(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function m(a,i,l){var h={fired:!1,wrapFn:void 0,target:a,type:i,listener:l},S=v.bind(h);return S.listener=l,h.wrapFn=S,S}c.prototype.once=function(i,l){return p(l),this.on(i,m(this,i,l)),this},c.prototype.prependOnceListener=function(i,l){return p(l),this.prependListener(i,m(this,i,l)),this},c.prototype.removeListener=function(i,l){var h,S,y,C,P;if(p(l),S=this._events,S===void 0)return this;if(h=S[i],h===void 0)return this;if(h===l||h.listener===l)--this._eventsCount===0?this._events=Object.create(null):(delete S[i],S.removeListener&&this.emit("removeListener",i,h.listener||l));else if(typeof h!="function"){for(y=-1,C=h.length-1;C>=0;C--)if(h[C]===l||h[C].listener===l){P=h[C].listener,y=C;break}if(y<0)return this;y===0?h.shift():x(h,y),h.length===1&&(S[i]=h[0]),S.removeListener!==void 0&&this.emit("removeListener",i,P||l)}return this},c.prototype.off=c.prototype.removeListener,c.prototype.removeAllListeners=function(i){var l,h,S;if(h=this._events,h===void 0)return this;if(h.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):h[i]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete h[i]),this;if(arguments.length===0){var y=Object.keys(h),C;for(S=0;S<y.length;++S)C=y[S],C!=="removeListener"&&this.removeAllListeners(C);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(l=h[i],typeof l=="function")this.removeListener(i,l);else if(l!==void 0)for(S=l.length-1;S>=0;S--)this.removeListener(i,l[S]);return this};function u(a,i,l){var h=a._events;if(h===void 0)return[];var S=h[i];return S===void 0?[]:typeof S=="function"?l?[S.listener||S]:[S]:l?L(S):R(S,S.length)}c.prototype.listeners=function(i){return u(this,i,!0)},c.prototype.rawListeners=function(i){return u(this,i,!1)},c.listenerCount=function(a,i){return typeof a.listenerCount=="function"?a.listenerCount(i):k.call(a,i)},c.prototype.listenerCount=k;function k(a){var i=this._events;if(i!==void 0){var l=i[a];if(typeof l=="function")return 1;if(l!==void 0)return l.length}return 0}c.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function R(a,i){for(var l=new Array(i),h=0;h<i;++h)l[h]=a[h];return l}function x(a,i){for(;i+1<a.length;i++)a[i]=a[i+1];a.pop()}function L(a){for(var i=new Array(a.length),l=0;l<i.length;++l)i[l]=a[l].listener||a[l];return i}function A(a,i){return new Promise(function(l,h){function S(C){a.removeListener(i,y),h(C)}function y(){typeof a.removeListener=="function"&&a.removeListener("error",S),l([].slice.call(arguments))}D(a,i,y,{once:!0}),i!=="error"&&I(a,S,{once:!0})})}function I(a,i,l){typeof a.on=="function"&&D(a,"error",i,l)}function D(a,i,l,h){if(typeof a.on=="function")h.once?a.once(i,l):a.on(i,l);else if(typeof a.addEventListener=="function")a.addEventListener(i,function S(y){h.once&&a.removeEventListener(i,S),l(y)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof a)}return X.exports}var ne=$e();const ze=2e4;var Ee=(e=>(e.CameraChanged="cameraChanged",e.MicrophoneChanged="microphoneChanged",e.StateChanged="stateChanged",e))(Ee||{});const F=e=>({isConnected:e==="listening"||e==="thinking"||e==="speaking",canListen:e==="pre-connect-buffering"||e==="listening"||e==="thinking"||e==="speaking",isFinished:e==="disconnected"||e==="failed",isPending:e==="connecting"||e==="initializing"||e==="idle"}),Je=()=>{const[e,t]=r.useState(null),[n,s]=r.useState(null),f=r.useRef("connecting"),c=r.useRef(!1),o=p=>setTimeout(()=>{if(!c.current){t("Agent did not join the room.");return}const{isConnected:T}=F(f.current);if(!T){t("Agent joined the room but did not complete initializing.");return}},p??ze);return{agentTimeoutFailureReason:e,startAgentTimeout:r.useCallback(p=>{n&&clearTimeout(n),t(null),s(o(p)),f.current="connecting",c.current=!1},[n]),clearAgentTimeout:r.useCallback(()=>{n&&clearTimeout(n),t(null),s(null),f.current="connecting",c.current=!1},[n]),clearAgentTimeoutFailureReason:r.useCallback(()=>{t(null)},[]),updateAgentTimeoutState:r.useCallback(p=>{f.current=p},[]),updateAgentTimeoutParticipantExists:r.useCallback(p=>{c.current=p},[])}};function Ve(e,t){const n=r.useRef(t);r.useEffect(()=>{n.current=t},[t]);const s=r.useCallback(async o=>{const{isConnected:p}=F(n.current);if(!p)return new Promise((T,E)=>{const v=k=>{const{isConnected:R}=F(k);R&&(u(),T())},m=()=>{u(),E(new Error("useAgent(/* ... */).waitUntilConnected - signal aborted"))},u=()=>{e.off("stateChanged",v),o==null||o.removeEventListener("abort",m)};e.on("stateChanged",v),o==null||o.addEventListener("abort",m)})},[e]),f=r.useCallback(async o=>{const{canListen:p}=F(n.current);if(!p)return new Promise((T,E)=>{const v=k=>{const{canListen:R}=F(k);R&&(u(),T())},m=()=>{u(),E(new Error("useAgent(/* ... */).waitUntilCouldBeListening - signal aborted"))},u=()=>{e.off("stateChanged",v),o==null||o.removeEventListener("abort",m)};e.on("stateChanged",v),o==null||o.addEventListener("abort",m)})},[e]),c=r.useCallback(async o=>{const{isFinished:p}=F(n.current);if(!p)return new Promise((T,E)=>{const v=k=>{const{isFinished:R}=F(k);R&&(u(),T())},m=()=>{u(),E(new Error("useAgent(/* ... */).waitUntilFinished - signal aborted"))},u=()=>{e.off("stateChanged",v),o==null||o.removeEventListener("abort",m)};e.on("stateChanged",v),o==null||o.addEventListener("abort",m)})},[e]);return{waitUntilConnected:s,waitUntilCouldBeListening:f,waitUntilFinished:c}}function re(e){const t=te();if(e=e??t,!e)throw new Error("No session provided, make sure you are inside a Session context or pass the session explicitly");const{room:n,internal:{agentConnectTimeoutMilliseconds:s,agentTimeoutFailureReason:f,startAgentTimeout:c,clearAgentTimeout:o,clearAgentTimeoutFailureReason:p,updateAgentTimeoutState:T,updateAgentTimeoutParticipantExists:E}}=e,v=r.useMemo(()=>new ne.EventEmitter,[]),m=Z({room:n}),u=r.useMemo(()=>m.find(g=>g.kind===d.ParticipantKind.AGENT&&!(b.ParticipantAgentAttributes.PublishOnBehalf in g.attributes))??null,[m]),k=r.useMemo(()=>u?m.find(g=>g.kind===d.ParticipantKind.AGENT&&g.attributes[b.ParticipantAgentAttributes.PublishOnBehalf]===u.identity)??null:null,[u,m]),[R,x]=r.useState((u==null?void 0:u.attributes)??{});r.useEffect(()=>{if(!u)return;const g=_=>{x(_)};return u.on(d.ParticipantEvent.AttributesChanged,g),()=>{u.off(d.ParticipantEvent.AttributesChanged,g)}},[u,v]);const L=Q([d.Track.Source.Camera,d.Track.Source.Microphone],{room:n,participantIdentity:u==null?void 0:u.identity}),A=Q([d.Track.Source.Camera,d.Track.Source.Microphone],{room:n,participantIdentity:k==null?void 0:k.identity}),I=r.useMemo(()=>L.find(g=>g.source===d.Track.Source.Camera)??A.find(g=>g.source===d.Track.Source.Camera),[L,A]);r.useEffect(()=>{v.emit("cameraChanged",I)},[v,I]);const D=r.useMemo(()=>L.find(g=>g.source===d.Track.Source.Microphone)??A.find(g=>g.source===d.Track.Source.Microphone),[L,A]);r.useEffect(()=>{v.emit("microphoneChanged",D)},[v,D]);const[a,i]=r.useState(n.state);r.useEffect(()=>{const g=_=>{i(_)};return n.on(d.RoomEvent.ConnectionStateChanged,g),()=>{n.off(d.RoomEvent.ConnectionStateChanged,g)}},[n]),r.useEffect(()=>{u&&p()},[u]);const[l,h]=r.useState(null);r.useEffect(()=>{if(!u)return;const g=_=>{_.identity===(u==null?void 0:u.identity)&&h("Agent left the room unexpectedly.")};return n.on(d.RoomEvent.ParticipantDisconnected,g),()=>{n.off(d.RoomEvent.ParticipantDisconnected,g)}},[u,n]),r.useEffect(()=>{a===d.ConnectionState.Disconnected&&h(null)},[a]);const[S,y]=r.useState(()=>n.localParticipant.getTrackPublication(d.Track.Source.Microphone)??null);r.useEffect(()=>{const g=()=>{y(n.localParticipant.getTrackPublication(d.Track.Source.Microphone)??null)},_=()=>{y(null)};return n.localParticipant.on(d.ParticipantEvent.LocalTrackPublished,g),n.localParticipant.on(d.ParticipantEvent.LocalTrackUnpublished,_),()=>{n.localParticipant.off(d.ParticipantEvent.LocalTrackPublished,g),n.localParticipant.off(d.ParticipantEvent.LocalTrackUnpublished,_)}},[n.localParticipant]);const C=r.useMemo(()=>{const g=[];return f&&g.push(f),l&&g.push(l),g},[f,l]),P=r.useMemo(()=>{if(C.length>0)return"failed";let g="disconnected";return a!==d.ConnectionState.Disconnected&&(g="connecting"),S&&(g="pre-connect-buffering"),u&&R[b.ParticipantAgentAttributes.AgentState]&&(g=R[b.ParticipantAgentAttributes.AgentState]),g},[C,a,S,u,R]);r.useEffect(()=>{v.emit("stateChanged",P),T(P)},[v,P]),r.useEffect(()=>{E(u!==null)},[u]);const N=e.connectionState==="disconnected";r.useEffect(()=>{if(!N)return c(s),()=>{o()}},[N,s]);const{identity:H,name:U,metadata:$}=he({participant:u??void 0}),V=r.useMemo(()=>{const g={attributes:R,internal:{agentParticipant:u,workerParticipant:k,emitter:v}};switch(P){case"disconnected":return{...g,identity:void 0,name:void 0,metadata:void 0,state:P,...F(P),failureReasons:null,cameraTrack:void 0,microphoneTrack:void 0};case"connecting":return{...g,identity:void 0,name:void 0,metadata:void 0,state:P,...F(P),failureReasons:null,cameraTrack:void 0,microphoneTrack:void 0};case"initializing":case"idle":return{...g,identity:H,name:U,metadata:$,state:P,...F(P),failureReasons:null,cameraTrack:I,microphoneTrack:D};case"pre-connect-buffering":return{...g,identity:H,name:U,metadata:$,state:P,...F(P),failureReasons:null,cameraTrack:I,microphoneTrack:D};case"listening":case"thinking":case"speaking":return{...g,identity:H,name:U,metadata:$,state:P,...F(P),failureReasons:null,cameraTrack:I,microphoneTrack:D};case"failed":return{...g,identity:void 0,name:void 0,metadata:void 0,state:"failed",...F("failed"),failureReasons:C,cameraTrack:void 0,microphoneTrack:void 0}}},[H,U,$,R,v,u,P,I,D]),{waitUntilConnected:z,waitUntilCouldBeListening:w,waitUntilFinished:O}=Ve(v,P),B=r.useCallback(g=>new Promise((_,J)=>{const W=K=>{K&&(G(),_(K))},q=()=>{G(),J(new Error("useAgent(/* ... */).waitUntilCamera - signal aborted"))},G=()=>{v.off("cameraChanged",W),g==null||g.removeEventListener("abort",q)};v.on("cameraChanged",W),g==null||g.addEventListener("abort",q)}),[v]),Y=r.useCallback(g=>new Promise((_,J)=>{const W=K=>{K&&(G(),_(K))},q=()=>{G(),J(new Error("useAgent(/* ... */).waitUntilMicrophone - signal aborted"))},G=()=>{v.off("microphoneChanged",W),g==null||g.removeEventListener("abort",q)};v.on("microphoneChanged",W),g==null||g.addEventListener("abort",q)}),[v]);return r.useMemo(()=>({...V,waitUntilConnected:z,waitUntilCouldBeListening:w,waitUntilFinished:O,waitUntilCamera:B,waitUntilMicrophone:Y}),[V,z,w,O,B,Y])}var ke=(e=>(e.ConnectionStateChanged="connectionStateChanged",e.MediaDevicesError="mediaDevicesError",e.EncryptionError="encryptionError",e))(ke||{});function Qe(e,t){const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const s of n)switch(s){case"roomName":case"participantName":case"participantIdentity":case"participantMetadata":case"participantAttributes":case"agentName":case"agentMetadata":if(e[s]!==t[s])return!1;break;default:const f=s;throw new Error(`Options key ${f} not being checked for equality!`)}return!0}function Ye(e,t){const n=r.useRef(t);return r.useEffect(()=>{n.current=t},[t]),r.useCallback(async(f,c)=>{if(n.current!==f)return new Promise((o,p)=>{const T=m=>{m===f&&(v(),o())},E=()=>{v(),p(new Error(`useSession(/* ... */).waitUntilConnectionState(${f}, /* signal */) - signal aborted`))},v=()=>{e.off("connectionStateChanged",T),c==null||c.removeEventListener("abort",E)};e.on("connectionStateChanged",T),c==null||c.addEventListener("abort",E)})},[e])}function Xe(e,t){const n=e instanceof d.TokenSourceConfigurable,s=r.useRef(n?t:null);return r.useEffect(()=>{if(!n){s.current=null;return}s.current!==null&&Qe(s.current,t)||(s.current=t)},[n,t]),r.useCallback(async()=>{if(n){if(!s.current)throw new Error("AgentSession - memoized token fetch options are not set, but the passed tokenSource was an instance of TokenSourceConfigurable. If you are seeing this please make a new GitHub issue!");return e.fetch(s.current)}else return e.fetch()},[n,e])}function Ze(e,t={}){const{room:n,agentConnectTimeoutMilliseconds:s,...f}=t,c=b.useMaybeRoomContext(),o=r.useMemo(()=>c??n??new d.Room,[c,n]),p=r.useMemo(()=>new ne.EventEmitter,[]),T=r.useCallback(w=>({isConnected:w===d.ConnectionState.Connected||w===d.ConnectionState.Reconnecting||w===d.ConnectionState.SignalReconnecting}),[]),[E,v]=r.useState(o.state);r.useEffect(()=>{const w=O=>{v(O)};return o.on(d.RoomEvent.ConnectionStateChanged,w),()=>{o.off(d.RoomEvent.ConnectionStateChanged,w)}},[o]),r.useEffect(()=>{const w=async O=>{p.emit("mediaDevicesError",O)};return o.on(d.RoomEvent.MediaDevicesError,w),()=>{o.off(d.RoomEvent.MediaDevicesError,w)}},[o,p]),r.useEffect(()=>{const w=async O=>{p.emit("encryptionError",O)};return o.on(d.RoomEvent.EncryptionError,w),()=>{o.off(d.RoomEvent.EncryptionError,w)}},[o,p]);const{localParticipant:m}=b.useLocalParticipant({room:o}),u=m.getTrackPublication(d.Track.Source.Camera),k=r.useMemo(()=>{if(u)return{source:d.Track.Source.Camera,participant:m,publication:u}},[m,u]),R=m.getTrackPublication(d.Track.Source.Microphone),x=r.useMemo(()=>{if(R)return{source:d.Track.Source.Microphone,participant:m,publication:R}},[m,R]),L=m.getTrackPublication(d.Track.Source.ScreenShare),A=r.useMemo(()=>{if(L)return{source:d.Track.Source.ScreenShare,participant:m,publication:L}},[m,L]),{agentTimeoutFailureReason:I,startAgentTimeout:D,clearAgentTimeout:a,clearAgentTimeoutFailureReason:i,updateAgentTimeoutState:l,updateAgentTimeoutParticipantExists:h}=Je(),S=r.useMemo(()=>({emitter:p,tokenSource:e,agentConnectTimeoutMilliseconds:s,agentTimeoutFailureReason:I,startAgentTimeout:D,clearAgentTimeout:a,clearAgentTimeoutFailureReason:i,updateAgentTimeoutState:l,updateAgentTimeoutParticipantExists:h}),[p,s,e,I,D,a,i,l,h]),y=r.useMemo(()=>{const w={room:o,internal:S};switch(E){case d.ConnectionState.Connecting:return{...w,connectionState:d.ConnectionState.Connecting,...T(d.ConnectionState.Connecting),local:{cameraTrack:void 0,microphoneTrack:void 0,screenShareTrack:void 0}};case d.ConnectionState.Connected:case d.ConnectionState.Reconnecting:case d.ConnectionState.SignalReconnecting:return{...w,connectionState:E,...T(E),local:{cameraTrack:k,microphoneTrack:x,screenShareTrack:A}};case d.ConnectionState.Disconnected:return{...w,connectionState:d.ConnectionState.Disconnected,...T(d.ConnectionState.Disconnected),local:{cameraTrack:void 0,microphoneTrack:void 0,screenShareTrack:void 0}}}},[S,o,E,k,x,T]);r.useEffect(()=>{p.emit("connectionStateChanged",y.connectionState)},[p,y.connectionState]);const C=Ye(p,y.connectionState),P=r.useCallback(async w=>C(d.ConnectionState.Connected,w),[C]),N=r.useCallback(async w=>C(d.ConnectionState.Disconnected,w),[C]),H=re(r.useMemo(()=>({connectionState:y.connectionState,room:o,internal:S}),[y,o,S])),U=Xe(e,f),$=r.useCallback(async(w={})=>{var J,W,q,G,K,oe;const{signal:O,tracks:B={microphone:{enabled:!0,publishOptions:{preConnectBuffer:!0}}},roomConnectOptions:Y}=w;await N(O);const g=()=>{o.disconnect()};O==null||O.addEventListener("abort",g);let _=!1;await Promise.all([U().then(({serverUrl:Pe,participantToken:ie})=>{var se,ae;return _=(((ae=(se=d.decodeTokenPayload(ie).roomConfig)==null?void 0:se.agents)==null?void 0:ae.length)??0)>0,o.connect(Pe,ie,Y)}),(J=B.microphone)!=null&&J.enabled?o.localParticipant.setMicrophoneEnabled(!0,void 0,((W=B.microphone)==null?void 0:W.publishOptions)??{}):Promise.resolve(),(q=B.camera)!=null&&q.enabled?o.localParticipant.setCameraEnabled(!0,void 0,((G=B.camera)==null?void 0:G.publishOptions)??{}):Promise.resolve(),(K=B.screenShare)!=null&&K.enabled?o.localParticipant.setScreenShareEnabled(!0,void 0,((oe=B.screenShare)==null?void 0:oe.publishOptions)??{}):Promise.resolve()]),await P(O),_&&await H.waitUntilConnected(O),O==null||O.removeEventListener("abort",g)},[o,N,U,P,H.waitUntilConnected]),V=r.useCallback(async()=>{await o.disconnect()},[o]),z=r.useCallback(async()=>{const w=await U();await o.prepareConnection(w.serverUrl,w.participantToken)},[U,o]);return r.useEffect(()=>{z().catch(w=>{console.warn("WARNING: Room.prepareConnection failed:",w)})},[]),r.useMemo(()=>({...y,waitUntilConnected:P,waitUntilDisconnected:N,prepareConnection:z,start:$,end:V}),[y,P,N,z,$,V])}function et(e,t,n,s){const f=r.useMemo(()=>()=>{},[]),c=r.useCallback(n??f,s??[]),o=s?c:n,p=r.useMemo(()=>e?"internal"in e?e.internal.emitter:e:null,[e]);r.useEffect(()=>{if(!(!p||!o))return p.on(t,o),()=>{p.off(t,o)}},[p,t,o])}var ye=(e=>(e.MessageReceived="messageReceived",e))(ye||{});function tt(e){const{room:t}=pe(e),n=r.useMemo(()=>new ne.EventEmitter,[]),s=re(e),f=Te({room:t}),c=r.useMemo(()=>({room:t}),[t]),o=M.useChat(c),p=r.useMemo(()=>f.map(u=>{var k,R,x;switch(u.participantInfo.identity){case t.localParticipant.identity:return{type:"userTranscript",message:u.text,id:u.streamInfo.id,timestamp:u.streamInfo.timestamp,from:t.localParticipant};case((k=s.internal.agentParticipant)==null?void 0:k.identity):case((R=s.internal.workerParticipant)==null?void 0:R.identity):return{type:"agentTranscript",message:u.text,id:u.streamInfo.id,timestamp:u.streamInfo.timestamp,from:((x=s.internal.agentParticipant)==null?void 0:x.identity)===u.participantInfo.identity?s.internal.agentParticipant:s.internal.workerParticipant};default:return{type:"agentTranscript",message:u.text,id:u.streamInfo.id,timestamp:u.streamInfo.timestamp,from:Array.from(t.remoteParticipants.values()).find(L=>L.identity===u.participantInfo.identity)}}}),[f,t]),T=r.useMemo(()=>[...p,...o.chatMessages],[p,o.chatMessages]),E=r.useRef(new Map),v=r.useMemo(()=>{const u=new Date;for(const k of T)E.current.has(k.id)||E.current.set(k.id,u);return T.sort((k,R)=>{const x=E.current.get(k.id),L=E.current.get(R.id);return typeof x>"u"||typeof L>"u"?0:x.getTime()-L.getTime()})},[T]),m=r.useRef(new Set);return r.useEffect(()=>{for(const u of v)m.current.has(u.id)||(m.current.add(u.id),n.emit("messageReceived",u))},[v]),r.useMemo(()=>({messages:v,send:o.send,isSending:o.isSending,internal:{emitter:n}}),[v,o.send,o.isSending])}exports.AgentEvent=Ee;exports.MessagesEvent=ye;exports.SessionContext=ee;exports.SessionEvent=ke;exports.useAgent=re;exports.useAudioPlayback=Me;exports.useClearPinButton=Ae;exports.useDataChannel=Le;exports.useEnsureSession=pe;exports.useEvents=et;exports.useIsRecording=Ge;exports.useLiveKitRoom=xe;exports.useMaybeSessionContext=te;exports.useParticipantAttribute=We;exports.useParticipantAttributes=Se;exports.useParticipantInfo=he;exports.useParticipantPermissions=De;exports.useParticipantTracks=Q;exports.useParticipants=ve;exports.useRemoteParticipant=Ne;exports.useRemoteParticipants=Z;exports.useRoomInfo=_e;exports.useSequentialRoomConnectDisconnect=Ke;exports.useSession=Ze;exports.useSessionContext=Re;exports.useSessionMessages=tt;exports.useSortedParticipants=Ie;exports.useSpeakingParticipants=be;exports.useTextStream=Ce;exports.useToken=Fe;exports.useTrackByName=je;exports.useTrackTranscription=ge;exports.useTranscriptions=Te;exports.useVoiceAssistant=qe; | ||
| //# sourceMappingURL=shared-BGiZtWPs.js.map |
Sorry, the diff of this file is too big to display
| "use strict";const k=require("livekit-client"),V=require("react"),S=require("./shared-CVy2Ouqp.js"),f=require("./shared-I8hFcrmp.js");function ct(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const e=ct(V);function lt(t){const a=s=>typeof window<"u"?window.matchMedia(s).matches:!1,[n,r]=e.useState(a(t));function c(){r(a(t))}return e.useEffect(()=>{const s=window.matchMedia(t);return c(),s.addListener?s.addListener(c):s.addEventListener("change",c),()=>{s.removeListener?s.removeListener(c):s.removeEventListener("change",c)}},[t]),n}const Ce=e.createContext(void 0);function Me(t){const a=e.useContext(Ce);if(t===!0){if(a)return a;throw Error("tried to access feature context, but none is present")}return a}const le=e.forwardRef(function(a,n){const{mergedProps:r}=f.useChatToggle({props:a});return e.createElement("button",{ref:n,...r},a.children)}),ie=e.forwardRef(function(a,n){const{buttonProps:r}=f.useDisconnectButton(a);return e.createElement("button",{ref:n,...r},a.children)}),Te=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{d:"M1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708L11 10.293V4.5A1.5 1.5 0 0 0 9.5 3H3.707zM0 4.5a1.5 1.5 0 0 1 .943-1.393l9.532 9.533c-.262.224-.603.36-.975.36h-8A1.5 1.5 0 0 1 0 11.5z"}),e.createElement("path",{d:"m15.2 3.6-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z"})),ye=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{d:"M0 4.5A1.5 1.5 0 0 1 1.5 3h8A1.5 1.5 0 0 1 11 4.5v7A1.5 1.5 0 0 1 9.5 13h-8A1.5 1.5 0 0 1 0 11.5zM15.2 3.6l-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z"})),Re=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,viewBox:"0 0 24 24",...t},e.createElement("path",{fill:"#FFF",d:"M4.99 3.99a1 1 0 0 0-.697 1.717L10.586 12l-6.293 6.293a1 1 0 1 0 1.414 1.414L12 13.414l6.293 6.293a1 1 0 1 0 1.414-1.414L13.414 12l6.293-6.293a1 1 0 0 0-.727-1.717 1 1 0 0 0-.687.303L12 10.586 5.707 4.293a1 1 0 0 0-.717-.303z"})),Ie=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:18,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M0 2.75A2.75 2.75 0 0 1 2.75 0h10.5A2.75 2.75 0 0 1 16 2.75v13.594a.75.75 0 0 1-1.234.572l-3.691-3.12a1.25 1.25 0 0 0-.807-.296H2.75A2.75 2.75 0 0 1 0 10.75v-8ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v8c0 .69.56 1.25 1.25 1.25h7.518c.65 0 1.279.23 1.775.65l2.457 2.077V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M3 4.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Z",clipRule:"evenodd"})),re=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentcolor",fillRule:"evenodd",d:"M5.293 2.293a1 1 0 0 1 1.414 0l4.823 4.823a1.25 1.25 0 0 1 0 1.768l-4.823 4.823a1 1 0 0 1-1.414-1.414L9.586 8 5.293 3.707a1 1 0 0 1 0-1.414z",clipRule:"evenodd"})),Pe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5},e.createElement("path",{d:"M10 1.75h4.25m0 0V6m0-4.25L9 7M6 14.25H1.75m0 0V10m0 4.25L7 9"}))),Ae=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentcolor",fillRule:"evenodd",d:"M8.961.894C8.875-.298 7.125-.298 7.04.894c-.066.912-1.246 1.228-1.76.472-.67-.99-2.186-.115-1.664.96.399.824-.465 1.688-1.288 1.289-1.076-.522-1.95.994-.961 1.665.756.513.44 1.693-.472 1.759-1.192.086-1.192 1.836 0 1.922.912.066 1.228 1.246.472 1.76-.99.67-.115 2.186.96 1.664.824-.399 1.688.465 1.289 1.288-.522 1.076.994 1.95 1.665.961.513-.756 1.693-.44 1.759.472.086 1.192 1.836 1.192 1.922 0 .066-.912 1.246-1.228 1.76-.472.67.99 2.186.115 1.664-.96-.399-.824.465-1.688 1.288-1.289 1.076.522 1.95-.994.961-1.665-.756-.513-.44-1.693.472-1.759 1.192-.086 1.192-1.836 0-1.922-.912-.066-1.228-1.246-.472-1.76.99-.67.115-2.186-.96-1.664-.824.399-1.688-.465-1.289-1.288.522-1.076-.994-1.95-1.665-.961-.513.756-1.693.44-1.759-.472ZM8 13A5 5 0 1 0 8 3a5 5 0 0 0 0 10Z",clipRule:"evenodd"})),Ne=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M2 2.75A2.75 2.75 0 0 1 4.75 0h6.5A2.75 2.75 0 0 1 14 2.75v10.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-.5a.75.75 0 0 1 1.5 0v.5c0 .69.56 1.25 1.25 1.25h6.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25h-6.5c-.69 0-1.25.56-1.25 1.25v.5a.75.75 0 0 1-1.5 0v-.5Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8.78 7.47a.75.75 0 0 1 0 1.06l-2.25 2.25a.75.75 0 1 1-1.06-1.06l.97-.97H1.75a.75.75 0 0 1 0-1.5h4.69l-.97-.97a.75.75 0 0 1 1.06-1.06l2.25 2.25Z",clipRule:"evenodd"})),Le=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentcolor",fillRule:"evenodd",d:"M4 6.104V4a4 4 0 1 1 8 0v2.104c1.154.326 2 1.387 2 2.646v4.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-4.5c0-1.259.846-2.32 2-2.646ZM5.5 4a2.5 2.5 0 0 1 5 0v2h-5V4Z",clipRule:"evenodd"})),xe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{d:"M12.227 11.52a5.477 5.477 0 0 0 1.246-2.97.5.5 0 0 0-.995-.1 4.478 4.478 0 0 1-.962 2.359l-1.07-1.07C10.794 9.247 11 8.647 11 8V3a3 3 0 0 0-6 0v1.293L1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708zM8 12.5c.683 0 1.33-.152 1.911-.425l.743.743c-.649.359-1.378.59-2.154.66V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .995-.098A4.5 4.5 0 0 0 8 12.5z"}),e.createElement("path",{d:"M8.743 10.907 5 7.164V8a3 3 0 0 0 3.743 2.907z"})),Ve=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{fillRule:"evenodd",d:"M2.975 8.002a.5.5 0 0 1 .547.449 4.5 4.5 0 0 0 8.956 0 .5.5 0 1 1 .995.098A5.502 5.502 0 0 1 8.5 13.478V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .448-.547z",clipRule:"evenodd"}),e.createElement("path",{d:"M5 3a3 3 0 1 1 6 0v5a3 3 0 0 1-6 0z"})),Fe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentcolor",...t},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"})),De=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentcolor",...t},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("g",{opacity:.25},e.createElement("path",{d:"M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}))),ze=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentcolor",...t},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("g",{opacity:.25},e.createElement("path",{d:"M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}))),Oe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("g",{opacity:.25},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z"}))),oe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:16,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M0 2.75A2.75 2.75 0 0 1 2.75 0h14.5A2.75 2.75 0 0 1 20 2.75v10.5A2.75 2.75 0 0 1 17.25 16H2.75A2.75 2.75 0 0 1 0 13.25V2.75ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h14.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M9.47 4.22a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1-1.06 1.06l-.97-.97v4.69a.75.75 0 0 1-1.5 0V6.56l-.97.97a.75.75 0 0 1-1.06-1.06l2.25-2.25Z",clipRule:"evenodd"})),$e=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:16,fill:"none",...t},e.createElement("g",{fill:"currentColor"},e.createElement("path",{d:"M7.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L10 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L11.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L10 6.94z"}),e.createElement("path",{fillRule:"evenodd",d:"M2.75 0A2.75 2.75 0 0 0 0 2.75v10.5A2.75 2.75 0 0 0 2.75 16h14.5A2.75 2.75 0 0 0 20 13.25V2.75A2.75 2.75 0 0 0 17.25 0zM1.5 2.75c0-.69.56-1.25 1.25-1.25h14.5c.69 0 1.25.56 1.25 1.25v10.5c0 .69-.56 1.25-1.25 1.25H2.75c-.69 0-1.25-.56-1.25-1.25z",clipRule:"evenodd"}))),ce=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8 0a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0V.75A.75.75 0 0 1 8 0Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8 12a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5A.75.75 0 0 1 8 12Z",clipRule:"evenodd",opacity:.7}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 1.072a.75.75 0 0 1 .274 1.024l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 12 1.072Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M6 11.464a.75.75 0 0 1 .274 1.025l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 6 11.464Z",clipRule:"evenodd",opacity:.6}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M14.928 4a.75.75 0 0 1-.274 1.025l-2.165 1.25a.75.75 0 1 1-.75-1.3l2.165-1.25A.75.75 0 0 1 14.928 4Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M4.536 10a.75.75 0 0 1-.275 1.024l-2.165 1.25a.75.75 0 0 1-.75-1.298l2.165-1.25A.75.75 0 0 1 4.536 10Z",clipRule:"evenodd",opacity:.5}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M16 8a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 16 8Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M4 8a.75.75 0 0 1-.75.75H.75a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 4 8Z",clipRule:"evenodd",opacity:.4}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M14.928 12a.75.75 0 0 1-1.024.274l-2.165-1.25a.75.75 0 0 1 .75-1.299l2.165 1.25A.75.75 0 0 1 14.928 12Z",clipRule:"evenodd",opacity:.9}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M4.536 6a.75.75 0 0 1-1.025.275l-2.165-1.25a.75.75 0 1 1 .75-1.3l2.165 1.25A.75.75 0 0 1 4.536 6Z",clipRule:"evenodd",opacity:.3}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 14.928a.75.75 0 0 1-1.024-.274l-1.25-2.165a.75.75 0 0 1 1.298-.75l1.25 2.165A.75.75 0 0 1 12 14.928Z",clipRule:"evenodd",opacity:.8}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M6 4.536a.75.75 0 0 1-1.024-.275l-1.25-2.165a.75.75 0 1 1 1.299-.75l1.25 2.165A.75.75 0 0 1 6 4.536Z",clipRule:"evenodd",opacity:.2})),Ze=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5},e.createElement("path",{d:"M13.25 7H9m0 0V2.75M9 7l5.25-5.25M2.75 9H7m0 0v4.25M7 9l-5.25 5.25"}))),_e=e.forwardRef(function({trackRef:a,...n},r){const c=f.useMaybeTrackRefContext(),{mergedProps:s,inFocus:u}=f.useFocusToggle({trackRef:a??c,props:n});return e.createElement(f.LayoutContext.Consumer,null,l=>l!==void 0&&e.createElement("button",{ref:r,...s},n.children?n.children:u?e.createElement(Ze,null):e.createElement(Pe,null)))}),G=e.forwardRef(function({kind:a,initialSelection:n,onActiveDeviceChange:r,onDeviceListChange:c,onDeviceSelectError:s,exactMatch:u,track:l,requestPermissions:i,onError:v,...o},p){const m=S.useMaybeRoomContext(),w=e.useRef("default"),h=e.useCallback(T=>{m&&m.emit(k.RoomEvent.MediaDevicesError,T),v==null||v(T)},[m,v]),{devices:g,activeDeviceId:d,setActiveMediaDevice:C,className:E}=f.useMediaDeviceSelect({kind:a,room:m,track:l,requestPermissions:i,onError:h});e.useEffect(()=>{n!==void 0&&C(n)},[C]),e.useEffect(()=>{typeof c=="function"&&c(g)},[c,g]),e.useEffect(()=>{d!==w.current&&(r==null||r(d)),w.current=d},[d]);const I=async T=>{try{await C(T,{exact:u??!0})}catch(P){if(P instanceof Error)s==null||s(P);else throw P}},R=e.useMemo(()=>f.mergeProps$1(o,{className:E},{className:"lk-list"}),[E,o]),b=!!g.find(T=>T.label.toLowerCase().startsWith("default"));function M(T,P,z){return T===P||!b&&z===0&&P==="default"}return e.createElement("ul",{ref:p,...R},g.map((T,P)=>e.createElement("li",{key:T.deviceId,id:T.deviceId,"data-lk-active":M(T.deviceId,d,P),"aria-selected":M(T.deviceId,d,P),role:"option"},e.createElement("button",{className:"lk-button",onClick:()=>I(T.deviceId)},T.label))))}),se=e.forwardRef(function({label:a,...n},r){const c=S.useRoomContext(),{mergedProps:s,canPlayAudio:u}=f.useStartAudio({room:c,props:n}),{mergedProps:l,canPlayVideo:i}=f.useStartVideo({room:c,props:s}),{style:v,...o}=l;return v.display=u&&i?"none":"block",e.createElement("button",{ref:r,style:v,...o},a??`Start ${u?"Video":"Audio"}`)});function je(t,a){switch(t){case k.Track.Source.Microphone:return a?e.createElement(Ve,null):e.createElement(xe,null);case k.Track.Source.Camera:return a?e.createElement(ye,null):e.createElement(Te,null);case k.Track.Source.ScreenShare:return a?e.createElement($e,null):e.createElement(oe,null);default:return}}function it(t){switch(t){case k.ConnectionQuality.Excellent:return e.createElement(Fe,null);case k.ConnectionQuality.Good:return e.createElement(De,null);case k.ConnectionQuality.Poor:return e.createElement(ze,null);default:return e.createElement(Oe,null)}}const Z=e.forwardRef(function({showIcon:a,...n},r){const{buttonProps:c,enabled:s}=f.useTrackToggle(n),[u,l]=e.useState(!1);return e.useEffect(()=>{l(!0)},[]),u&&e.createElement("button",{ref:r,...c},(a??!0)&&je(n.source,s),n.children)}),ue=e.forwardRef(function(a,n){const{className:r,quality:c}=f.useConnectionQualityIndicator(a),s=e.useMemo(()=>({...f.mergeProps$1(a,{className:r}),"data-lk-quality":c}),[c,a,r]);return e.createElement("div",{ref:n,...s},a.children??it(c))}),K=e.forwardRef(function({participant:a,...n},r){const c=f.useEnsureParticipant(a),{className:s,infoObserver:u}=e.useMemo(()=>S.setupParticipantName(c),[c]),{identity:l,name:i}=f.useObservableState(u,{name:c.name,identity:c.identity,metadata:c.metadata}),v=e.useMemo(()=>f.mergeProps$1(n,{className:s,"data-lk-participant-name":i}),[n,s,i]);return e.createElement("span",{ref:r,...v},i!==""?i:l,n.children)}),de=e.forwardRef(function({trackRef:a,show:n="always",...r},c){const{className:s,isMuted:u}=f.useTrackMutedIndicator(a),l=n==="always"||n==="muted"&&u||n==="unmuted"&&!u,i=e.useMemo(()=>f.mergeProps$1(r,{className:s}),[s,r]);return l?e.createElement("div",{ref:c,...i,"data-lk-muted":u},r.children??je(a.source,!u)):null}),me=t=>e.createElement("svg",{width:320,height:320,viewBox:"0 0 320 320",preserveAspectRatio:"xMidYMid meet",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{d:"M160 180C204.182 180 240 144.183 240 100C240 55.8172 204.182 20 160 20C115.817 20 79.9997 55.8172 79.9997 100C79.9997 144.183 115.817 180 160 180Z",fill:"white",fillOpacity:.25}),e.createElement("path",{d:"M97.6542 194.614C103.267 191.818 109.841 192.481 115.519 195.141C129.025 201.466 144.1 205 159.999 205C175.899 205 190.973 201.466 204.48 195.141C210.158 192.481 216.732 191.818 222.345 194.614C262.703 214.719 291.985 253.736 298.591 300.062C300.15 310.997 291.045 320 280 320H39.9997C28.954 320 19.8495 310.997 21.4087 300.062C28.014 253.736 57.2966 214.72 97.6542 194.614Z",fill:"white",fillOpacity:.25}));function Be(t,a={}){const[n,r]=e.useState(S.getTrackByIdentifier(t)),[c,s]=e.useState(n==null?void 0:n.isMuted),[u,l]=e.useState(n==null?void 0:n.isSubscribed),[i,v]=e.useState(n==null?void 0:n.track),[o,p]=e.useState("landscape"),m=e.useRef(),{className:w,trackObserver:h}=e.useMemo(()=>S.setupMediaTrack(t),[t.participant.sid??t.participant.identity,t.source,S.isTrackReference(t)&&t.publication.trackSid]);return e.useEffect(()=>{const g=h.subscribe(d=>{S.log.debug("update track",d),r(d),s(d==null?void 0:d.isMuted),l(d==null?void 0:d.isSubscribed),v(d==null?void 0:d.track)});return()=>g==null?void 0:g.unsubscribe()},[h]),e.useEffect(()=>{var g,d;return i&&(m.current&&i.detach(m.current),(g=a.element)!=null&&g.current&&!(t.participant.isLocal&&(i==null?void 0:i.kind)==="audio")&&i.attach(a.element.current)),m.current=(d=a.element)==null?void 0:d.current,()=>{m.current&&(i==null||i.detach(m.current))}},[i,a.element]),e.useEffect(()=>{var g,d;if(typeof((g=n==null?void 0:n.dimensions)==null?void 0:g.width)=="number"&&typeof((d=n==null?void 0:n.dimensions)==null?void 0:d.height)=="number"){const C=n.dimensions.width>n.dimensions.height?"landscape":"portrait";p(C)}},[n]),{publication:n,isMuted:c,isSubscribed:u,track:i,elementProps:f.mergeProps$1(a.props,{className:w,"data-lk-local-participant":t.participant.isLocal,"data-lk-source":n==null?void 0:n.source,...(n==null?void 0:n.kind)==="video"&&{"data-lk-orientation":o}})}}var ae,ke;function ot(){if(ke)return ae;ke=1;var t="Expected a function",a=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt,i=typeof S.commonjsGlobal=="object"&&S.commonjsGlobal&&S.commonjsGlobal.Object===Object&&S.commonjsGlobal,v=typeof self=="object"&&self&&self.Object===Object&&self,o=i||v||Function("return this")(),p=Object.prototype,m=p.toString,w=Math.max,h=Math.min,g=function(){return o.Date.now()};function d(b,M,T){var P,z,y,N,F,O,D=0,_=!1,L=!1,q=!0;if(typeof b!="function")throw new TypeError(t);M=R(M)||0,C(T)&&(_=!!T.leading,L="maxWait"in T,y=L?w(R(T.maxWait)||0,M):y,q="trailing"in T?!!T.trailing:q);function j(x){var $=P,Q=z;return P=z=void 0,D=x,N=b.apply(Q,$),N}function ee(x){return D=x,F=setTimeout(H,M),_?j(x):N}function te(x){var $=x-O,Q=x-D,Ee=M-$;return L?h(Ee,y-Q):Ee}function B(x){var $=x-O,Q=x-D;return O===void 0||$>=M||$<0||L&&Q>=y}function H(){var x=g();if(B(x))return A(x);F=setTimeout(H,te(x))}function A(x){return F=void 0,q&&P?j(x):(P=z=void 0,N)}function W(){F!==void 0&&clearTimeout(F),D=0,P=O=z=F=void 0}function rt(){return F===void 0?N:A(g())}function ne(){var x=g(),$=B(x);if(P=arguments,z=this,O=x,$){if(F===void 0)return ee(O);if(L)return F=setTimeout(H,M),j(O)}return F===void 0&&(F=setTimeout(H,M)),N}return ne.cancel=W,ne.flush=rt,ne}function C(b){var M=typeof b;return!!b&&(M=="object"||M=="function")}function E(b){return!!b&&typeof b=="object"}function I(b){return typeof b=="symbol"||E(b)&&m.call(b)==n}function R(b){if(typeof b=="number")return b;if(I(b))return a;if(C(b)){var M=typeof b.valueOf=="function"?b.valueOf():b;b=C(M)?M+"":M}if(typeof b!="string")return b===0?b:+b;b=b.replace(r,"");var T=s.test(b);return T||u.test(b)?l(b.slice(2),T?2:8):c.test(b)?a:+b}return ae=d,ae}var st=ot();const Se=S.getDefaultExportFromCjs(st);function ut(t){const a=V.useRef(t);a.current=t,V.useEffect(()=>()=>{a.current()},[])}function dt(t,a=500,n){const r=V.useRef();ut(()=>{r.current&&r.current.cancel()});const c=V.useMemo(()=>{const s=Se(t,a,n),u=(...l)=>s(...l);return u.cancel=()=>{s.cancel()},u.isPending=()=>!!r.current,u.flush=()=>s.flush(),u},[t,a,n]);return V.useEffect(()=>{r.current=Se(t,a,n)},[t,a,n]),c}function mt(t,a,n){const r=((v,o)=>v===o),c=t instanceof Function?t():t,[s,u]=V.useState(c),l=V.useRef(c),i=dt(u,a,n);return r(l.current,c)||(i(c),l.current=c),[s,i]}function ft({threshold:t=0,root:a=null,rootMargin:n="0%",freezeOnceVisible:r=!1,initialIsIntersecting:c=!1,onChange:s}={}){var u;const[l,i]=V.useState(null),[v,o]=V.useState(()=>({isIntersecting:c,entry:void 0})),p=V.useRef();p.current=s;const m=((u=v.entry)==null?void 0:u.isIntersecting)&&r;V.useEffect(()=>{if(!l||!("IntersectionObserver"in window)||m)return;const g=new IntersectionObserver(d=>{const C=Array.isArray(g.thresholds)?g.thresholds:[g.thresholds];d.forEach(E=>{const I=E.isIntersecting&&C.some(R=>E.intersectionRatio>=R);o({isIntersecting:I,entry:E}),p.current&&p.current(I,E)})},{threshold:t,root:a,rootMargin:n});return g.observe(l),()=>{g.disconnect()}},[l,JSON.stringify(t),a,n,m,r]);const w=V.useRef(null);V.useEffect(()=>{var g;!l&&((g=v.entry)!=null&&g.target)&&!r&&!m&&w.current!==v.entry.target&&(w.current=v.entry.target,o({isIntersecting:c,entry:void 0}))},[l,v.entry,r,m,c]);const h=[i,!!v.isIntersecting,v.entry];return h.ref=h[0],h.isIntersecting=h[1],h.entry=h[2],h}const He=e.forwardRef(function({onTrackClick:a,onClick:n,onSubscriptionStatusChanged:r,trackRef:c,manageSubscription:s,...u},l){const i=f.useEnsureTrackRef(c),v=e.useRef(null);e.useImperativeHandle(l,()=>v.current);const o=ft({root:v.current}),[p]=mt(o,3e3);e.useEffect(()=>{s&&i.publication instanceof k.RemoteTrackPublication&&(p==null?void 0:p.isIntersecting)===!1&&(o==null?void 0:o.isIntersecting)===!1&&i.publication.setSubscribed(!1)},[p,i,s]),e.useEffect(()=>{s&&i.publication instanceof k.RemoteTrackPublication&&(o==null?void 0:o.isIntersecting)===!0&&i.publication.setSubscribed(!0)},[o,i,s]);const{elementProps:m,publication:w,isSubscribed:h}=Be(i,{element:v,props:u});e.useEffect(()=>{r==null||r(!!h)},[h,r]);const g=d=>{n==null||n(d),a==null||a({participant:i==null?void 0:i.participant,track:w})};return e.createElement("video",{ref:v,...m,muted:!0,onClick:g})}),X=e.forwardRef(function({trackRef:a,onSubscriptionStatusChanged:n,volume:r,...c},s){const u=f.useEnsureTrackRef(a),l=e.useRef(null);e.useImperativeHandle(s,()=>l.current);const{elementProps:i,isSubscribed:v,track:o,publication:p}=Be(u,{element:l,props:c});return e.useEffect(()=>{n==null||n(!!v)},[v,n]),e.useEffect(()=>{o===void 0||r===void 0||(o instanceof k.RemoteAudioTrack?o.setVolume(r):S.log.warn("Volume can only be set on remote audio tracks."))},[r,o]),e.useEffect(()=>{p===void 0||c.muted===void 0||(p instanceof k.RemoteTrackPublication?p.setEnabled(!c.muted):S.log.warn("Can only call setEnabled on remote track publications."))},[c.muted,p,o]),e.createElement("audio",{ref:l,...i})});function Ue(t){const a=!!f.useMaybeParticipantContext();return t.participant&&!a?e.createElement(f.ParticipantContext.Provider,{value:t.participant},t.children):e.createElement(e.Fragment,null,t.children)}function qe(t){const a=!!f.useMaybeTrackRefContext();return t.trackRef&&!a?e.createElement(f.TrackRefContext.Provider,{value:t.trackRef},t.children):e.createElement(e.Fragment,null,t.children)}const J=e.forwardRef(function({trackRef:a,children:n,onParticipantClick:r,disableSpeakingIndicator:c,...s},u){var w,h;const l=f.useEnsureTrackRef(a),{elementProps:i}=f.useParticipantTile({htmlProps:s,disableSpeakingIndicator:c,onParticipantClick:r,trackRef:l}),v=f.useIsEncrypted(l.participant),o=f.useMaybeLayoutContext(),p=(w=Me())==null?void 0:w.autoSubscription,m=e.useCallback(g=>{l.source&&!g&&o&&o.pin.dispatch&&S.isTrackReferencePinned(l,o.pin.state)&&o.pin.dispatch({msg:"clear_pin"})},[l,o]);return e.createElement("div",{ref:u,style:{position:"relative"},...i},e.createElement(qe,{trackRef:l},e.createElement(Ue,{participant:l.participant},n??e.createElement(e.Fragment,null,S.isTrackReference(l)&&(((h=l.publication)==null?void 0:h.kind)==="video"||l.source===k.Track.Source.Camera||l.source===k.Track.Source.ScreenShare)?e.createElement(He,{trackRef:l,onSubscriptionStatusChanged:m,manageSubscription:p}):S.isTrackReference(l)&&e.createElement(X,{trackRef:l,onSubscriptionStatusChanged:m}),e.createElement("div",{className:"lk-participant-placeholder"},e.createElement(me,null)),e.createElement("div",{className:"lk-participant-metadata"},e.createElement("div",{className:"lk-participant-metadata-item"},l.source===k.Track.Source.Camera?e.createElement(e.Fragment,null,v&&e.createElement(Le,{style:{marginRight:"0.25rem"}}),e.createElement(de,{trackRef:{participant:l.participant,source:k.Track.Source.Microphone},show:"muted"}),e.createElement(K,null)):e.createElement(e.Fragment,null,e.createElement(oe,{style:{marginRight:"0.25rem"}}),e.createElement(K,null,"'s screen"))),e.createElement(ue,{className:"lk-participant-metadata-item"}))),e.createElement(_e,{trackRef:l}))))});function We(t){const a=f.mergeProps$1(t,{className:"lk-focus-layout"});return e.createElement("div",{...a},t.children)}function Qe({trackRef:t,...a}){return e.createElement(J,{trackRef:t,...a})}function Y({tracks:t,...a}){return e.createElement(e.Fragment,null,t.map(n=>e.createElement(f.TrackRefContext.Provider,{value:n,key:S.getTrackReferenceId(n)},f.cloneSingleChild(a.children))))}function ht({totalPageCount:t,nextPage:a,prevPage:n,currentPage:r,pagesContainer:c}){const[s,u]=e.useState(!1);return e.useEffect(()=>{let l;return c&&(l=S.createInteractingObservable(c.current,2e3).subscribe(u)),()=>{l&&l.unsubscribe()}},[c]),e.createElement("div",{className:"lk-pagination-control","data-lk-user-interaction":s},e.createElement("button",{className:"lk-button",onClick:n},e.createElement(re,null)),e.createElement("span",{className:"lk-pagination-count"},`${r} of ${t}`),e.createElement("button",{className:"lk-button",onClick:a},e.createElement(re,null)))}const gt=e.forwardRef(function({totalPageCount:a,currentPage:n},r){const c=new Array(a).fill("").map((s,u)=>u+1===n?e.createElement("span",{"data-lk-active":!0,key:u}):e.createElement("span",{key:u}));return e.createElement("div",{ref:r,className:"lk-pagination-indicator"},c)});function Ge({tracks:t,...a}){const n=e.createRef(),r=e.useMemo(()=>f.mergeProps$1(a,{className:"lk-grid-layout"}),[a]),{layout:c}=f.useGridLayout(n,t.length),s=f.usePagination(c.maxTiles,t);return f.useSwipe(n,{onLeftSwipe:s.nextPage,onRightSwipe:s.prevPage}),e.createElement("div",{ref:n,"data-lk-pagination":s.totalPageCount>1,...r},e.createElement(Y,{tracks:s.tracks},a.children),t.length>c.maxTiles&&e.createElement(e.Fragment,null,e.createElement(gt,{totalPageCount:s.totalPageCount,currentPage:s.currentPage}),e.createElement(ht,{pagesContainer:n,...s})))}const vt=130,pt=140,we=1,Ke=16/10,Et=(1-Ke)*-1;function Je({tracks:t,orientation:a,...n}){const r=e.useRef(null),[c,s]=e.useState(0),{width:u,height:l}=f.useSize(r),i=a||(l>=u?"vertical":"horizontal"),v=i==="vertical"?Math.max(u*Et,vt):Math.max(l*Ke,pt),o=S.getScrollBarWidth(),p=Math.max(i==="vertical"?(l-o)/v:(u-o)/v,we);let m=Math.round(p);Math.abs(p-c)<.5?m=Math.round(c):c!==p&&s(p);const w=f.useVisualStableUpdate(t,m);return e.useLayoutEffect(()=>{r.current&&(r.current.dataset.lkOrientation=i,r.current.style.setProperty("--lk-max-visible-tiles",m.toString()))},[m,i]),e.createElement("aside",{key:i,className:"lk-carousel",ref:r,...n},e.createElement(Y,{tracks:w},n.children))}function fe({value:t,onPinChange:a,onWidgetChange:n,children:r}){const c=f.useEnsureCreateLayoutContext(t);return e.useEffect(()=>{S.log.debug("PinState Updated",{state:c.pin.state}),a&&c.pin.state&&a(c.pin.state)},[c.pin.state,a]),e.useEffect(()=>{S.log.debug("Widget Updated",{widgetState:c.widget.state}),n&&c.widget.state&&n(c.widget.state)},[n,c.widget.state]),e.createElement(f.LayoutContext.Provider,{value:c},r)}function Xe({room:t,volume:a,muted:n}){const r=f.useTracks([k.Track.Source.Microphone,k.Track.Source.ScreenShareAudio,k.Track.Source.Unknown],{updateOnlyOn:[],onlySubscribed:!0,room:t}).filter(c=>!c.participant.isLocal&&c.publication.kind===k.Track.Kind.Audio);return e.createElement("div",{style:{display:"none"}},r.map(c=>e.createElement(X,{key:S.getTrackReferenceId(c),trackRef:c,volume:a,muted:n})))}function Ye(t){const a=e.useMemo(()=>f.mergeProps$1(t,{className:"lk-toast"}),[t]);return e.createElement("div",{...a},t.children)}const kt=t=>{const a=[];for(let n=0;n<t;n++)a.push([n,t-1-n]);return a},be=t=>[[Math.floor(t/2)],[-1]],St=(t,a,n)=>{const[r,c]=V.useState(0),[s,u]=V.useState([[]]);V.useEffect(()=>{if(t==="thinking")u(be(a));else if(t==="connecting"||t==="initializing"){const i=[...kt(a)];u(i)}else u(t==="listening"?be(a):t===void 0||t==="speaking"?[new Array(a).fill(0).map((i,v)=>v)]:[[]]);c(0)},[t,a]);const l=V.useRef(null);return V.useEffect(()=>{let i=performance.now();const v=o=>{o-i>=n&&(c(m=>m+1),i=o),l.current=requestAnimationFrame(v)};return l.current=requestAnimationFrame(v),()=>{l.current!==null&&cancelAnimationFrame(l.current)}},[n,a,t,s.length]),s[r%s.length]},wt=new Map([["connecting",2e3],["initializing",2e3],["listening",500],["thinking",150]]),bt=(t,a)=>{if(t===void 0)return 1e3;let n=wt.get(t);if(n)switch(t){case"connecting":n/=a;break}return n},he=e.forwardRef(function({state:a,options:n,barCount:r=15,trackRef:c,track:s,children:u,...l},i){const v=f.mergeProps$1(l,{className:"lk-audio-visualizer-bar"});let o=f.useMaybeTrackRefContext();(c||s)&&(o=c||s);const p=f.useMultibandTrackVolume(o,{bands:r,loPass:100,hiPass:200}),m=(n==null?void 0:n.minHeight)??20,w=(n==null?void 0:n.maxHeight)??100,h=St(a,r,bt(a,r)??100);return e.createElement("div",{ref:i,...v,"data-lk-va-state":a},p.map((g,d)=>u?f.cloneSingleChild(u,{"data-lk-highlighted":h.includes(d),"data-lk-bar-index":d,className:"lk-audio-bar",style:{height:`${Math.min(w,Math.max(m,g*100+5))}%`}}):e.createElement("span",{key:d,"data-lk-highlighted":h.includes(d),"data-lk-bar-index":d,className:`lk-audio-bar ${h.includes(d)&&"lk-highlighted"}`,style:{height:`${Math.min(w,Math.max(m,g*100+5))}%`}})))}),et=e.forwardRef(function({children:a,disableSpeakingIndicator:n,onParticipantClick:r,trackRef:c,...s},u){const l=f.useEnsureTrackRef(c),{elementProps:i}=f.useParticipantTile({trackRef:l,htmlProps:s,disableSpeakingIndicator:n,onParticipantClick:r});return e.createElement("div",{ref:u,style:{position:"relative",minHeight:"160px"},...i},e.createElement(f.TrackRefContext.Provider,{value:l},a??e.createElement(e.Fragment,null,S.isTrackReference(l)&&e.createElement(X,{trackRef:l}),e.createElement(he,{barCount:7,options:{minHeight:8}}),e.createElement("div",{className:"lk-participant-metadata"},e.createElement("div",{className:"lk-participant-metadata-item"},e.createElement(de,{trackRef:l}),e.createElement(K,null)),e.createElement(ue,{className:"lk-participant-metadata-item"})))))});function tt(t){const[a,n]=e.useState(void 0),r=f.useConnectionState(t.room);return e.useEffect(()=>{switch(r){case k.ConnectionState.Reconnecting:n(e.createElement(e.Fragment,null,e.createElement(ce,{className:"lk-spinner"})," Reconnecting"));break;case k.ConnectionState.Connecting:n(e.createElement(e.Fragment,null,e.createElement(ce,{className:"lk-spinner"})," Connecting"));break;case k.ConnectionState.Disconnected:n(e.createElement(e.Fragment,null,"Disconnected"));break;default:n(void 0);break}},[r]),a?e.createElement(Ye,{className:"lk-toast-connection-state"},a):e.createElement(e.Fragment,null)}const nt=e.forwardRef(function({entry:a,hideName:n=!1,hideTimestamp:r=!1,messageFormatter:c,...s},u){var m,w,h,g;const l=e.useMemo(()=>c?c(a.message):a.message,[a.message,c]),i=!!a.editTimestamp,v=new Date(a.timestamp),o=typeof navigator<"u"?navigator.language:"en-US",p=((m=a.from)==null?void 0:m.name)??((w=a.from)==null?void 0:w.identity);return e.createElement("li",{ref:u,className:"lk-chat-entry",title:v.toLocaleTimeString(o,{timeStyle:"full"}),"data-lk-message-origin":(h=a.from)!=null&&h.isLocal?"local":"remote",...s},(!r||!n||i)&&e.createElement("span",{className:"lk-meta-data"},!n&&e.createElement("strong",{className:"lk-participant-name"},p),(!r||i)&&e.createElement("span",{className:"lk-timestamp"},i&&"edited ",v.toLocaleTimeString(o,{timeStyle:"short"}))),e.createElement("span",{className:"lk-message-body"},l),e.createElement("span",{className:"lk-message-attachements"},(g=a.attachedFiles)==null?void 0:g.map(d=>d.type.startsWith("image/")&&e.createElement("img",{style:{maxWidth:"300px",maxHeight:"300px"},key:d.name,src:URL.createObjectURL(d),alt:d.name}))))});function Ct(t){return S.tokenize(t,S.createDefaultGrammar()).map((a,n)=>{if(typeof a=="string")return a;{const r=a.content.toString(),c=a.type==="url"?/^http(s?):\/\//.test(r)?r:`https://${r}`:`mailto:${r}`;return e.createElement("a",{className:"lk-chat-link",key:n,href:c,target:"_blank",rel:"noreferrer"},r)}})}function ge({messageFormatter:t,messageDecoder:a,messageEncoder:n,channelTopic:r,...c}){const s=e.useRef(null),u=e.useRef(null),l=e.useMemo(()=>({messageDecoder:a,messageEncoder:n,channelTopic:r}),[a,n,r]),{chatMessages:i,send:v,isSending:o}=f.useChat(l),p=f.useMaybeLayoutContext(),m=e.useRef(0);async function w(h){h.preventDefault(),u.current&&u.current.value.trim()!==""&&(await v(u.current.value),u.current.value="",u.current.focus())}return e.useEffect(()=>{var h;s&&((h=s.current)==null||h.scrollTo({top:s.current.scrollHeight}))},[s,i]),e.useEffect(()=>{var d,C,E,I,R;if(!p||i.length===0)return;if((d=p.widget.state)!=null&&d.showChat&&i.length>0&&m.current!==((C=i[i.length-1])==null?void 0:C.timestamp)){m.current=(E=i[i.length-1])==null?void 0:E.timestamp;return}const h=i.filter(b=>!m.current||b.timestamp>m.current).length,{widget:g}=p;h>0&&((I=g.state)==null?void 0:I.unreadMessages)!==h&&((R=g.dispatch)==null||R.call(g,{msg:"unread_msg",count:h}))},[i,p==null?void 0:p.widget]),e.createElement("div",{...c,className:"lk-chat"},e.createElement("div",{className:"lk-chat-header"},"Messages",p&&e.createElement(le,{className:"lk-close-button"},e.createElement(Re,null))),e.createElement("ul",{className:"lk-list lk-chat-messages",ref:s},c.children?i.map((h,g)=>f.cloneSingleChild(c.children,{entry:h,key:h.id??g,messageFormatter:t})):i.map((h,g,d)=>{const C=g>=1&&d[g-1].from===h.from,E=g>=1&&h.timestamp-d[g-1].timestamp<6e4;return e.createElement(nt,{key:h.id??g,hideName:C,hideTimestamp:C===!1?!1:E,entry:h,messageFormatter:t})})),e.createElement("form",{className:"lk-chat-form",onSubmit:w},e.createElement("input",{className:"lk-form-control lk-chat-form-input",disabled:o,ref:u,type:"text",placeholder:"Enter a message...",onInput:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),onKeyUp:h=>h.stopPropagation()}),e.createElement("button",{type:"submit",className:"lk-button lk-chat-form-button",disabled:o},"Send")))}function U({kind:t,initialSelection:a,onActiveDeviceChange:n,tracks:r,requestPermissions:c=!1,...s}){const[u,l]=e.useState(!1),[i,v]=e.useState([]),[o,p]=e.useState(!0),[m,w]=e.useState(c),h=(E,I)=>{S.log.debug("handle device change"),l(!1),n==null||n(E,I)},g=e.useRef(null),d=e.useRef(null);e.useLayoutEffect(()=>{u&&w(!0)},[u]),e.useLayoutEffect(()=>{let E;return g.current&&d.current&&(i||o)&&(E=S.computeMenuPosition(g.current,d.current,(I,R)=>{d.current&&Object.assign(d.current.style,{left:`${I}px`,top:`${R}px`})})),p(!1),()=>{E==null||E()}},[g,d,i,o]);const C=e.useCallback(E=>{d.current&&E.target!==g.current&&u&&S.wasClickOutside(d.current,E)&&l(!1)},[u,d,g]);return e.useEffect(()=>(document.addEventListener("click",C),()=>{document.removeEventListener("click",C)}),[C]),e.createElement(e.Fragment,null,e.createElement("button",{className:"lk-button lk-button-menu","aria-pressed":u,...s,onClick:()=>l(!u),ref:g},s.children),!s.disabled&&e.createElement("div",{className:"lk-device-menu",ref:d,style:{visibility:u?"visible":"hidden"}},t?e.createElement(G,{initialSelection:a,onActiveDeviceChange:E=>h(t,E),onDeviceListChange:v,kind:t,track:r==null?void 0:r[t],requestPermissions:m}):e.createElement(e.Fragment,null,e.createElement("div",{className:"lk-device-menu-heading"},"Audio inputs"),e.createElement(G,{kind:"audioinput",onActiveDeviceChange:E=>h("audioinput",E),onDeviceListChange:v,track:r==null?void 0:r.audioinput,requestPermissions:m}),e.createElement("div",{className:"lk-device-menu-heading"},"Video inputs"),e.createElement(G,{kind:"videoinput",onActiveDeviceChange:E=>h("videoinput",E),onDeviceListChange:v,track:r==null?void 0:r.videoinput,requestPermissions:m}))))}function ve(){e.useEffect(()=>{f.warnAboutMissingStyles()},[])}function at(t,a){const[n,r]=e.useState(),c=e.useMemo(()=>new k.Mutex,[]);return e.useEffect(()=>{let s=!1,u=[];return c.lock().then(async l=>{try{(t.audio||t.video)&&(u=await k.createLocalTracks(t),s?u.forEach(i=>i.stop()):r(u))}catch(i){a&&i instanceof Error?a(i):S.log.error(i)}finally{l()}}),()=>{s=!0,u.forEach(l=>{l.stop()})}},[JSON.stringify(t,f.roomOptionsStringifyReplacer),a,c]),n}function Mt(t,a,n){const[r,c]=e.useState(null),[s,u]=e.useState(!1),l=f.useMediaDevices({kind:n}),[i,v]=e.useState(void 0),[o,p]=e.useState(),[m,w]=e.useState(a);e.useEffect(()=>{w(a)},[a]);const h=async(C,E)=>{try{const I=E==="videoinput"?await k.createLocalVideoTrack({deviceId:C,resolution:k.VideoPresets.h720.resolution}):await k.createLocalAudioTrack({deviceId:C}),R=await I.getDeviceId(!1);R&&C!==R&&(d.current=R,w(R)),p(I)}catch(I){I instanceof Error&&c(I)}},g=async(C,E)=>{await C.setDeviceId(E),d.current=E},d=e.useRef(m);return e.useEffect(()=>{t&&!o&&!r&&!s&&(S.log.debug("creating track",n),u(!0),h(m,n).finally(()=>{u(!1)}))},[t,o,r,s]),e.useEffect(()=>{o&&(t?i!=null&&i.deviceId&&d.current!==(i==null?void 0:i.deviceId)?(S.log.debug(`switching ${n} device from`,d.current,i.deviceId),g(o,i.deviceId)):(S.log.debug(`unmuting local ${n} track`),o.unmute()):(S.log.debug(`muting ${n} track`),o.mute().then(()=>S.log.debug(o.mediaStreamTrack))))},[o,i,t,n]),e.useEffect(()=>()=>{o&&(S.log.debug(`stopping local ${n} track`),o.stop(),o.mute())},[]),e.useEffect(()=>{v(l==null?void 0:l.find(C=>C.deviceId===m))},[m,l]),{selectedDevice:i,localTrack:o,deviceError:r}}function Tt({defaults:t={},onValidate:a,onSubmit:n,onError:r,debug:c,joinLabel:s="Join Room",micLabel:u="Microphone",camLabel:l="Camera",userLabel:i="Username",persistUserChoices:v=!0,videoProcessor:o,...p}){const{userChoices:m,saveAudioInputDeviceId:w,saveAudioInputEnabled:h,saveVideoInputDeviceId:g,saveVideoInputEnabled:d,saveUsername:C}=f.usePersistentUserChoices({defaults:t,preventSave:!v,preventLoad:!v}),[E,I]=e.useState(m),[R,b]=e.useState(E.audioEnabled),[M,T]=e.useState(E.videoEnabled),[P,z]=e.useState(E.audioDeviceId),[y,N]=e.useState(E.videoDeviceId),[F,O]=e.useState(E.username);e.useEffect(()=>{h(R)},[R,h]),e.useEffect(()=>{d(M)},[M,d]),e.useEffect(()=>{w(P)},[P,w]),e.useEffect(()=>{g(y)},[y,g]),e.useEffect(()=>{C(F)},[F,C]);const D=at({audio:R?{deviceId:m.audioDeviceId}:!1,video:M?{deviceId:m.videoDeviceId,processor:o}:!1},r),_=e.useRef(null),L=e.useMemo(()=>D==null?void 0:D.filter(A=>A.kind===k.Track.Kind.Video)[0],[D]),q=e.useMemo(()=>{if(L){const{facingMode:A}=k.facingModeFromLocalTrack(L);return A}else return"undefined"},[L]),j=e.useMemo(()=>D==null?void 0:D.filter(A=>A.kind===k.Track.Kind.Audio)[0],[D]);e.useEffect(()=>(_.current&&L&&(L.unmute(),L.attach(_.current)),()=>{L==null||L.detach()}),[L]);const[ee,te]=e.useState(),B=e.useCallback(A=>typeof a=="function"?a(A):A.username!=="",[a]);e.useEffect(()=>{const A={username:F,videoEnabled:M,videoDeviceId:y,audioEnabled:R,audioDeviceId:P};I(A),te(B(A))},[F,M,B,R,P,y]);function H(A){A.preventDefault(),B(E)?typeof n=="function"&&n(E):S.log.warn("Validation failed with: ",E)}return ve(),e.createElement("div",{className:"lk-prejoin",...p},e.createElement("div",{className:"lk-video-container"},L&&e.createElement("video",{ref:_,width:"1280",height:"720","data-lk-facing-mode":q}),(!L||!M)&&e.createElement("div",{className:"lk-camera-off-note"},e.createElement(me,null))),e.createElement("div",{className:"lk-button-group-container"},e.createElement("div",{className:"lk-button-group audio"},e.createElement(Z,{initialState:R,source:k.Track.Source.Microphone,onChange:A=>b(A)},u),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{initialSelection:P,kind:"audioinput",disabled:!j,tracks:{audioinput:j},onActiveDeviceChange:(A,W)=>z(W)}))),e.createElement("div",{className:"lk-button-group video"},e.createElement(Z,{initialState:M,source:k.Track.Source.Camera,onChange:A=>T(A)},l),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{initialSelection:y,kind:"videoinput",disabled:!L,tracks:{videoinput:L},onActiveDeviceChange:(A,W)=>N(W)})))),e.createElement("form",{className:"lk-username-container"},e.createElement("input",{className:"lk-form-control",id:"username",name:"username",type:"text",defaultValue:F,placeholder:i,onChange:A=>O(A.target.value),autoComplete:"off"}),e.createElement("button",{className:"lk-button lk-join-button",type:"submit",onClick:H,disabled:!ee},s)),c&&e.createElement(e.Fragment,null,e.createElement("strong",null,"User Choices:"),e.createElement("ul",{className:"lk-list",style:{overflow:"hidden",maxWidth:"15rem"}},e.createElement("li",null,"Username: ",`${E.username}`),e.createElement("li",null,"Video Enabled: ",`${E.videoEnabled}`),e.createElement("li",null,"Audio Enabled: ",`${E.audioEnabled}`),e.createElement("li",null,"Video Device: ",`${E.videoDeviceId}`),e.createElement("li",null,"Audio Device: ",`${E.audioDeviceId}`))))}function yt({props:t}){const{dispatch:a,state:n}=f.useLayoutContext().widget,r="lk-button lk-settings-toggle";return{mergedProps:e.useMemo(()=>f.mergeProps(t,{className:r,onClick:()=>{a&&a({msg:"toggle_settings"})},"aria-pressed":n!=null&&n.showSettings?"true":"false"}),[t,r,a,n])}}const Rt=e.forwardRef(function(a,n){const{mergedProps:r}=yt({props:a});return e.createElement("button",{ref:n,...r},a.children)}),It=t=>{switch(t){case k.Track.Source.Camera:return 1;case k.Track.Source.Microphone:return 2;case k.Track.Source.ScreenShare:return 3;default:return 0}};function pe({variation:t,controls:a,saveUserChoices:n=!0,onDeviceError:r,...c}){var z;const[s,u]=e.useState(!1),l=f.useMaybeLayoutContext();e.useEffect(()=>{var y,N;((y=l==null?void 0:l.widget.state)==null?void 0:y.showChat)!==void 0&&u((N=l==null?void 0:l.widget.state)==null?void 0:N.showChat)},[(z=l==null?void 0:l.widget.state)==null?void 0:z.showChat]);const v=lt(`(max-width: ${s?1e3:760}px)`)?"minimal":"verbose";t??(t=v);const o={leave:!0,...a},p=f.useLocalParticipantPermissions();if(!p)o.camera=!1,o.chat=!1,o.microphone=!1,o.screenShare=!1;else{const y=N=>p.canPublish&&(p.canPublishSources.length===0||p.canPublishSources.includes(It(N)));o.camera??(o.camera=y(k.Track.Source.Camera)),o.microphone??(o.microphone=y(k.Track.Source.Microphone)),o.screenShare??(o.screenShare=y(k.Track.Source.ScreenShare)),o.chat??(o.chat=p.canPublishData&&(a==null?void 0:a.chat))}const m=e.useMemo(()=>t==="minimal"||t==="verbose",[t]),w=e.useMemo(()=>t==="textOnly"||t==="verbose",[t]),h=S.supportsScreenSharing(),[g,d]=e.useState(!1),C=e.useCallback(y=>{d(y)},[d]),E=f.mergeProps$1({className:"lk-control-bar"},c),{saveAudioInputEnabled:I,saveVideoInputEnabled:R,saveAudioInputDeviceId:b,saveVideoInputDeviceId:M}=f.usePersistentUserChoices({preventSave:!n}),T=e.useCallback((y,N)=>N?I(y):null,[I]),P=e.useCallback((y,N)=>N?R(y):null,[R]);return e.createElement("div",{...E},o.microphone&&e.createElement("div",{className:"lk-button-group"},e.createElement(Z,{source:k.Track.Source.Microphone,showIcon:m,onChange:T,onDeviceError:y=>r==null?void 0:r({source:k.Track.Source.Microphone,error:y})},w&&"Microphone"),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{kind:"audioinput",onActiveDeviceChange:(y,N)=>b(N??"default")}))),o.camera&&e.createElement("div",{className:"lk-button-group"},e.createElement(Z,{source:k.Track.Source.Camera,showIcon:m,onChange:P,onDeviceError:y=>r==null?void 0:r({source:k.Track.Source.Camera,error:y})},w&&"Camera"),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{kind:"videoinput",onActiveDeviceChange:(y,N)=>M(N??"default")}))),o.screenShare&&h&&e.createElement(Z,{source:k.Track.Source.ScreenShare,captureOptions:{audio:!0,selfBrowserSurface:"include"},showIcon:m,onChange:C,onDeviceError:y=>r==null?void 0:r({source:k.Track.Source.ScreenShare,error:y})},w&&(g?"Stop screen share":"Share screen")),o.chat&&e.createElement(le,null,m&&e.createElement(Ie,null),w&&"Chat"),o.settings&&e.createElement(Rt,null,m&&e.createElement(Ae,null),w&&"Settings"),o.leave&&e.createElement(ie,null,m&&e.createElement(Ne,null),w&&"Leave"),e.createElement(se,null))}function Pt({chatMessageFormatter:t,chatMessageDecoder:a,chatMessageEncoder:n,SettingsComponent:r,...c}){var h,g;const[s,u]=e.useState({showChat:!1,unreadMessages:0,showSettings:!1}),l=e.useRef(null),i=f.useTracks([{source:k.Track.Source.Camera,withPlaceholder:!0},{source:k.Track.Source.ScreenShare,withPlaceholder:!1}],{updateOnlyOn:[k.RoomEvent.ActiveSpeakersChanged],onlySubscribed:!1}),v=d=>{S.log.debug("updating widget state",d),u(d)},o=f.useCreateLayoutContext(),p=i.filter(S.isTrackReference).filter(d=>d.publication.source===k.Track.Source.ScreenShare),m=(h=f.usePinnedTracks(o))==null?void 0:h[0],w=i.filter(d=>!S.isEqualTrackRef(d,m));return e.useEffect(()=>{var d,C,E,I,R,b;if(p.some(M=>M.publication.isSubscribed)&&l.current===null?(S.log.debug("Auto set screen share focus:",{newScreenShareTrack:p[0]}),(C=(d=o.pin).dispatch)==null||C.call(d,{msg:"set_pin",trackReference:p[0]}),l.current=p[0]):l.current&&!p.some(M=>{var T,P;return M.publication.trackSid===((P=(T=l.current)==null?void 0:T.publication)==null?void 0:P.trackSid)})&&(S.log.debug("Auto clearing screen share focus."),(I=(E=o.pin).dispatch)==null||I.call(E,{msg:"clear_pin"}),l.current=null),m&&!S.isTrackReference(m)){const M=i.find(T=>T.participant.identity===m.participant.identity&&T.source===m.source);M!==m&&S.isTrackReference(M)&&((b=(R=o.pin).dispatch)==null||b.call(R,{msg:"set_pin",trackReference:M}))}},[p.map(d=>`${d.publication.trackSid}_${d.publication.isSubscribed}`).join(),(g=m==null?void 0:m.publication)==null?void 0:g.trackSid,i]),ve(),e.createElement("div",{className:"lk-video-conference",...c},S.isWeb()&&e.createElement(fe,{value:o,onWidgetChange:v},e.createElement("div",{className:"lk-video-conference-inner"},m?e.createElement("div",{className:"lk-focus-layout-wrapper"},e.createElement(We,null,e.createElement(Je,{tracks:w},e.createElement(J,null)),m&&e.createElement(Qe,{trackRef:m}))):e.createElement("div",{className:"lk-grid-layout-wrapper"},e.createElement(Ge,{tracks:i},e.createElement(J,null))),e.createElement(pe,{controls:{chat:!0,settings:!!r}})),e.createElement(ge,{style:{display:s.showChat?"grid":"none"},messageFormatter:t,messageEncoder:n,messageDecoder:a}),r&&e.createElement("div",{className:"lk-settings-menu-modal",style:{display:s.showSettings?"block":"none"}},e.createElement(r,null))),e.createElement(Xe,null),e.createElement(tt,null))}function At({...t}){const[a,n]=e.useState({showChat:!1,unreadMessages:0}),r=f.useTracks([k.Track.Source.Microphone]);return ve(),e.createElement(fe,{onWidgetChange:n},e.createElement("div",{className:"lk-audio-conference",...t},e.createElement("div",{className:"lk-audio-conference-stage"},e.createElement(Y,{tracks:r},e.createElement(et,null))),e.createElement(pe,{controls:{microphone:!0,screenShare:!1,camera:!1,chat:!0}}),a.showChat&&e.createElement(ge,null)))}function Nt({controls:t,saveUserChoices:a=!0,onDeviceError:n,...r}){const c={leave:!0,microphone:!0,...t},s=f.useLocalParticipantPermissions(),{microphoneTrack:u,localParticipant:l}=S.useLocalParticipant(),i=e.useMemo(()=>({participant:l,source:k.Track.Source.Microphone,publication:u}),[l,u]);s?c.microphone??(c.microphone=s.canPublish):c.microphone=!1;const v=f.mergeProps$1({className:"lk-agent-control-bar"},r),{saveAudioInputEnabled:o,saveAudioInputDeviceId:p}=f.usePersistentUserChoices({preventSave:!a}),m=e.useCallback((w,h)=>{h&&o(w)},[o]);return e.createElement("div",{...v},c.microphone&&e.createElement("div",{className:"lk-button-group"},e.createElement(Z,{source:k.Track.Source.Microphone,showIcon:!0,onChange:m,onDeviceError:w=>n==null?void 0:n({source:k.Track.Source.Microphone,error:w})},e.createElement(he,{trackRef:i,barCount:7,options:{minHeight:5}})),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{kind:"audioinput",onActiveDeviceChange:(w,h)=>p(h??"default")}))),c.leave&&e.createElement(ie,null,"Disconnect"),e.createElement(se,null))}exports.AudioConference=At;exports.AudioTrack=X;exports.BarVisualizer=he;exports.CarouselLayout=Je;exports.Chat=ge;exports.ChatEntry=nt;exports.ChatToggle=le;exports.ConnectionQualityIndicator=ue;exports.ConnectionStateToast=tt;exports.ControlBar=pe;exports.DisconnectButton=ie;exports.FocusLayout=Qe;exports.FocusLayoutContainer=We;exports.FocusToggle=_e;exports.GridLayout=Ge;exports.LKFeatureContext=Ce;exports.LayoutContextProvider=fe;exports.MediaDeviceMenu=U;exports.MediaDeviceSelect=G;exports.ParticipantAudioTile=et;exports.ParticipantContextIfNeeded=Ue;exports.ParticipantName=K;exports.ParticipantTile=J;exports.PreJoin=Tt;exports.RoomAudioRenderer=Xe;exports.StartMediaButton=se;exports.SvgCameraDisabledIcon=Te;exports.SvgCameraIcon=ye;exports.SvgChatCloseIcon=Re;exports.SvgChatIcon=Ie;exports.SvgChevron=re;exports.SvgFocusToggleIcon=Pe;exports.SvgGearIcon=Ae;exports.SvgLeaveIcon=Ne;exports.SvgLockLockedIcon=Le;exports.SvgMicDisabledIcon=xe;exports.SvgMicIcon=Ve;exports.SvgParticipantPlaceholder=me;exports.SvgQualityExcellentIcon=Fe;exports.SvgQualityGoodIcon=De;exports.SvgQualityPoorIcon=ze;exports.SvgQualityUnknownIcon=Oe;exports.SvgScreenShareIcon=oe;exports.SvgScreenShareStopIcon=$e;exports.SvgSpinnerIcon=ce;exports.SvgUnfocusToggleIcon=Ze;exports.Toast=Ye;exports.TrackLoop=Y;exports.TrackMutedIndicator=de;exports.TrackRefContextIfNeeded=qe;exports.TrackToggle=Z;exports.VideoConference=Pt;exports.VideoTrack=He;exports.VoiceAssistantControlBar=Nt;exports.formatChatMessageLinks=Ct;exports.useFeatureContext=Me;exports.usePreviewDevice=Mt;exports.usePreviewTracks=at; | ||
| //# sourceMappingURL=shared-DsGkPi0_.js.map |
Sorry, the diff of this file is too big to display
| "use strict";const l=require("./shared-CVy2Ouqp.js"),K=require("react"),y=require("livekit-client");function Z(e){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const t in e)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(e,t);Object.defineProperty(n,t,s.get?s:{enumerable:!0,get:()=>e[t]})}}return n.default=e,Object.freeze(n)}const o=Z(K),ee=e=>{const n=o.useRef(e);return o.useEffect(()=>{n.current=e}),n};function te(e,n){const t=se(),s=ee(n);return o.useLayoutEffect(()=>{let r=!1;const i=e.current;if(!i)return;function c(a,u){r||s.current(a,u)}return t==null||t.subscribe(i,c),()=>{r=!0,t==null||t.unsubscribe(i,c)}},[e.current,t,s]),t==null?void 0:t.observer}function ne(){let e=!1,n=[];const t=new Map;if(typeof window>"u")return;const s=new ResizeObserver((r,i)=>{n=n.concat(r),e||window.requestAnimationFrame(()=>{const c=new Set;for(let a=0;a<n.length;a++){if(c.has(n[a].target))continue;c.add(n[a].target);const u=t.get(n[a].target);u==null||u.forEach(d=>d(n[a],i))}n=[],e=!1}),e=!0});return{observer:s,subscribe(r,i){s.observe(r);const c=t.get(r)??[];c.push(i),t.set(r,c)},unsubscribe(r,i){const c=t.get(r)??[];if(c.length===1){s.unobserve(r),t.delete(r);return}const a=c.indexOf(i);a!==-1&&c.splice(a,1),t.set(r,c)}}}let D;const se=()=>D||(D=ne()),q=e=>{const[n,t]=o.useState({width:0,height:0});o.useLayoutEffect(()=>{if(e.current){const{width:r,height:i}=e.current.getBoundingClientRect();t({width:r,height:i})}},[e.current]);const s=o.useCallback(r=>t(r.contentRect),[]);return te(e,s),n};function v(e,n,t=!0){const[s,r]=o.useState(n);return o.useEffect(()=>{if(t&&r(n),typeof window>"u"||!e)return;const i=e.subscribe(r);return()=>i.unsubscribe()},[e,t]),s}function U(e,n){if(n.msg==="show_chat")return{...e,showChat:!0,unreadMessages:0};if(n.msg==="hide_chat")return{...e,showChat:!1};if(n.msg==="toggle_chat"){const t={...e,showChat:!e.showChat};return t.showChat===!0&&(t.unreadMessages=0),t}else return n.msg==="unread_msg"?{...e,unreadMessages:n.count}:n.msg==="toggle_settings"?{...e,showSettings:!e.showSettings}:{...e}}function z(e,n){return n.msg==="set_pin"?[n.trackReference]:n.msg==="clear_pin"?[]:{...e}}const I=o.createContext(void 0);function B(){const e=o.useContext(I);if(!e)throw Error("Tried to access LayoutContext context outside a LayoutContextProvider provider.");return e}function W(e){const n=x();if(e??(e=n),!e)throw Error("Tried to access LayoutContext context outside a LayoutContextProvider provider.");return e}function re(){const[e,n]=o.useReducer(z,l.PIN_DEFAULT_STATE),[t,s]=o.useReducer(U,l.WIDGET_DEFAULT_STATE);return{pin:{dispatch:n,state:e},widget:{dispatch:s,state:t}}}function oe(e){const[n,t]=o.useReducer(z,l.PIN_DEFAULT_STATE),[s,r]=o.useReducer(U,l.WIDGET_DEFAULT_STATE);return e??{pin:{dispatch:t,state:n},widget:{dispatch:r,state:s}}}function x(){return o.useContext(I)}const N=o.createContext(void 0);function ce(){const e=o.useContext(N);if(!e)throw Error("tried to access track context outside of track context provider");return e}function F(){return o.useContext(N)}function A(e){const n=F(),t=e??n;if(!t)throw new Error("No TrackRef, make sure you are inside a TrackRefContext or pass the TrackRef explicitly");return t}const O=o.createContext(void 0);function ie(){const e=o.useContext(O);if(!e)throw Error("tried to access participant context outside of participant context provider");return e}function J(){return o.useContext(O)}function P(e){const n=J(),t=F(),s=e??n??(t==null?void 0:t.participant);if(!s)throw new Error("No participant provided, make sure you are inside a participant context or pass the participant explicitly");return s}function j(e){var n,t,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(n=0;n<r;n++)e[n]&&(t=j(e[n]))&&(s&&(s+=" "),s+=t)}else for(t in e)e[t]&&(s&&(s+=" "),s+=t);return s}function G(){for(var e,n,t=0,s="",r=arguments.length;t<r;t++)(e=arguments[t])&&(n=j(e))&&(s&&(s+=" "),s+=n);return s}function ae(...e){return(...n)=>{for(const t of e)if(typeof t=="function")try{t(...n)}catch(s){console.error(s)}}}function k(...e){const n={...e[0]};for(let t=1;t<e.length;t++){const s=e[t];for(const r in s){const i=n[r],c=s[r];typeof i=="function"&&typeof c=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?n[r]=ae(i,c):(r==="className"||r==="UNSAFE_className")&&typeof i=="string"&&typeof c=="string"?n[r]=G(i,c):n[r]=c!==void 0?c:i}}return n}function ue(e={}){const n=P(e.participant),{className:t,connectionQualityObserver:s}=o.useMemo(()=>l.setupConnectionQualityIndicator(n),[n]),r=v(s,n.connectionQuality);return{className:t,quality:r}}function V(e){const n=l.useEnsureRoom(e),t=o.useMemo(()=>l.connectionStateObserver(n),[n]);return v(t,n.state)}function le(e){const n=l.useRoomContext(),t=V(n);return{buttonProps:o.useMemo(()=>{const{className:r,disconnect:i}=l.setupDisconnectButton(n);return k(e,{className:r,onClick:()=>i(e.stopTracks??!0),disabled:t===y.ConnectionState.Disconnected})},[n,e,t])}}function Q(e){if(e.publication instanceof y.LocalTrackPublication){const n=e.publication.track;if(n){const{facingMode:t}=y.facingModeFromLocalTrack(n);return t}}return"undefined"}function de({trackRef:e,props:n}){const t=A(e),s=x(),{className:r}=o.useMemo(()=>l.setupFocusToggle(),[]),i=o.useMemo(()=>l.isTrackReferencePinned(t,s==null?void 0:s.pin.state),[t,s==null?void 0:s.pin.state]);return{mergedProps:o.useMemo(()=>k(n,{className:r,onClick:a=>{var u,d,p,f,m;(u=n.onClick)==null||u.call(n,a),i?(p=s==null?void 0:(d=s.pin).dispatch)==null||p.call(d,{msg:"clear_pin"}):(m=s==null?void 0:(f=s.pin).dispatch)==null||m.call(f,{msg:"set_pin",trackReference:t})}}),[n,r,t,i,s==null?void 0:s.pin]),inFocus:i}}function fe(e,n,t={}){const s=t.gridLayouts??l.GRID_LAYOUTS,{width:r,height:i}=q(e),c=l.selectGridLayout(s,n,r,i);return o.useEffect(()=>{e.current&&c&&(e.current.style.setProperty("--lk-col-count",c==null?void 0:c.columns.toString()),e.current.style.setProperty("--lk-row-count",c==null?void 0:c.rows.toString()))},[e,c]),{layout:c,containerWidth:r,containerHeight:i}}function L(e,n={}){var a,u;const t=typeof e=="string"?n.participant:e.participant,s=P(t),r=typeof e=="string"?{participant:s,source:e}:e,[i,c]=o.useState(!!((a=r.publication)!=null&&a.isMuted||(u=s.getTrackPublication(r.source))!=null&&u.isMuted));return o.useEffect(()=>{const d=l.mutedObserver(r).subscribe(c);return()=>d.unsubscribe()},[l.getTrackReferenceId(r)]),i}function $(e){const n=P(e),t=o.useMemo(()=>l.createIsSpeakingObserver(n),[n]);return v(t,n.isSpeaking)}function pe(e){return e!==void 0}function me(...e){return k(...e.filter(pe))}function ge(e,n,t){return o.Children.map(e,s=>o.isValidElement(s)&&o.Children.only(e)?(s.props.className&&(n??(n={}),n.className=G(s.props.className,n.className),n.style={...s.props.style,...n.style}),o.cloneElement(s,{...n,key:t})):s)}function be(e){var n,t;if(typeof window<"u"&&typeof process<"u"&&(((n=process==null?void 0:process.env)==null?void 0:n.NODE_ENV)==="dev"||((t=process==null?void 0:process.env)==null?void 0:t.NODE_ENV)==="development")){const s=document.querySelector(".lk-room-container");s&&!getComputedStyle(s).getPropertyValue("--lk-has-imported-styles")&&l.log.warn("It looks like you're not using the `@livekit/components-styles package`. To render the UI with the default styling, please import it in your layout or page.")}}function he(e,n){return e==="processor"&&n&&typeof n=="object"&&"name"in n?n.name:e==="e2ee"&&n?"e2ee-enabled":n}function ye(){const e=l.useRoomContext(),n=o.useMemo(()=>l.participantPermissionObserver(e.localParticipant),[e]);return v(n,e.localParticipant.permissions)}function Se({kind:e,room:n,track:t,requestPermissions:s,onError:r}){const i=l.useMaybeRoomContext(),c=o.useMemo(()=>n??i??new y.Room,[n,i]),a=o.useMemo(()=>l.createMediaDeviceObserver(e,r,s),[e,s,r]),u=v(a,[]),[d,p]=o.useState((c==null?void 0:c.getActiveDevice(e))??"default"),{className:f,activeDeviceObservable:m,setActiveMediaDevice:g}=o.useMemo(()=>l.setupDeviceSelector(e,c),[e,c,t]);return o.useEffect(()=>{const h=m.subscribe(S=>{S&&(l.log.info("setCurrentDeviceId",S),p(S))});return()=>{h==null||h.unsubscribe()}},[m]),{devices:u,className:f,activeDeviceId:d,setActiveMediaDevice:g}}function ve({kind:e,onError:n}){const t=o.useMemo(()=>l.createMediaDeviceObserver(e,n),[e,n]);return v(t,[])}function H(e,n,t={}){const s=o.useRef([]),r=o.useRef(-1),i=n!==r.current,c=typeof t.customSortFunction=="function"?t.customSortFunction(e):l.sortTrackReferences(e);let a=[...c];if(i===!1)try{a=l.updatePages(s.current,c,n)}catch(u){l.log.error("Error while running updatePages(): ",u)}return i?s.current=c:s.current=a,r.current=n,a}function Me(e,n){const[t,s]=o.useState(1),r=Math.max(Math.ceil(n.length/e),1);t>r&&s(r);const i=t*e,c=i-e,a=f=>{s(m=>f==="next"?m===r?m:m+1:m===1?m:m-1)},u=f=>{f>r?s(r):f<1?s(1):s(f)},p=H(n,e).slice(c,i);return{totalPageCount:r,nextPage:()=>a("next"),prevPage:()=>a("previous"),setPage:u,firstItemIndex:c,lastItemIndex:i,tracks:p,currentPage:t}}function ke({trackRef:e,onParticipantClick:n,disableSpeakingIndicator:t,htmlProps:s}){const r=A(e),i=o.useMemo(()=>{const{className:m}=l.setupParticipantTile();return k(s,{className:m,onClick:g=>{var h;if((h=s.onClick)==null||h.call(s,g),typeof n=="function"){const S=r.publication??r.participant.getTrackPublication(r.source);n({participant:r.participant,track:S})}}})},[s,n,r.publication,r.source,r.participant]),c=r.participant.getTrackPublication(y.Track.Source.Microphone),a=o.useMemo(()=>({participant:r.participant,source:y.Track.Source.Microphone,publication:c}),[c,r.participant]),u=L(r),d=L(a),p=$(r.participant),f=Q(r);return{elementProps:{"data-lk-audio-muted":d,"data-lk-video-muted":u,"data-lk-speaking":t===!0?!1:p,"data-lk-local-participant":r.participant.isLocal,"data-lk-source":r.source,"data-lk-facing-mode":f,...i}}}function Ce(e){return e=W(e),o.useMemo(()=>(e==null?void 0:e.pin.state)!==void 0&&e.pin.state.length>=1?e.pin.state:[],[e.pin.state])}function Te({room:e,props:n}){const t=l.useEnsureRoom(e),{className:s,roomAudioPlaybackAllowedObservable:r,handleStartAudioPlayback:i}=o.useMemo(()=>l.setupStartAudio(),[]),c=o.useMemo(()=>r(t),[t,r]),{canPlayAudio:a}=v(c,{canPlayAudio:t.canPlaybackAudio});return{mergedProps:o.useMemo(()=>k(n,{className:s,onClick:()=>{i(t)},style:{display:a?"none":"block"}}),[n,s,a,i,t]),canPlayAudio:a}}function Pe({room:e,props:n}){const t=l.useEnsureRoom(e),{className:s,roomVideoPlaybackAllowedObservable:r,handleStartVideoPlayback:i}=o.useMemo(()=>l.setupStartVideo(),[]),c=o.useMemo(()=>r(t),[t,r]),{canPlayVideo:a}=v(c,{canPlayVideo:t.canPlaybackVideo});return{mergedProps:o.useMemo(()=>k(n,{className:s,onClick:()=>{i(t)},style:{display:a?"none":"block"}}),[n,s,a,i,t]),canPlayVideo:a}}function we(e,n={}){const t=o.useRef(null),s=o.useRef(null),r=n.minSwipeDistance??50,i=u=>{s.current=null,t.current=u.targetTouches[0].clientX},c=u=>{s.current=u.targetTouches[0].clientX},a=o.useCallback(()=>{if(!t.current||!s.current)return;const u=t.current-s.current,d=u>r,p=u<-r;d&&n.onLeftSwipe&&n.onLeftSwipe(),p&&n.onRightSwipe&&n.onRightSwipe()},[r,n]);o.useEffect(()=>{const u=e.current;return u&&(u.addEventListener("touchstart",i,{passive:!0}),u.addEventListener("touchmove",c,{passive:!0}),u.addEventListener("touchend",a,{passive:!0})),()=>{u&&(u.removeEventListener("touchstart",i),u.removeEventListener("touchmove",c),u.removeEventListener("touchend",a))}},[e,a])}function Ee({props:e}){const{dispatch:n,state:t}=B().widget,{className:s}=o.useMemo(()=>l.setupChatToggle(),[]);return{mergedProps:o.useMemo(()=>k(e,{className:s,onClick:()=>{n&&n({msg:"toggle_chat"})},"aria-pressed":t!=null&&t.showChat?"true":"false","data-lk-unread-msgs":t?t.unreadMessages<10?t.unreadMessages.toFixed(0):"9+":"0"}),[e,s,n,t])}}function Ae(e){var i,c;const n=A(e),{className:t,mediaMutedObserver:s}=o.useMemo(()=>l.setupTrackMutedIndicator(n),[l.getTrackReferenceId(n)]);return{isMuted:v(s,!!((i=n.publication)!=null&&i.isMuted||(c=n.participant.getTrackPublication(n.source))!=null&&c.isMuted)),className:t}}function Re({source:e,onChange:n,initialState:t,captureOptions:s,publishOptions:r,onDeviceError:i,room:c,...a}){var T;const u=l.useMaybeRoomContext(),d=o.useMemo(()=>c??u,[c,u]),p=(T=d==null?void 0:d.localParticipant)==null?void 0:T.getTrackPublication(e),f=o.useRef(!1),{toggle:m,className:g,pendingObserver:h,enabledObserver:S}=o.useMemo(()=>d?l.setupMediaToggle(e,d,s,r,i):l.setupManualToggle(),[d,e,JSON.stringify(s),r]),M=v(h,!1),b=v(S,t??!!(p!=null&&p.isEnabled));o.useEffect(()=>{n==null||n(b,f.current),f.current=!1},[b,n]),o.useEffect(()=>{t!==void 0&&(l.log.debug("forcing initial toggle state",e,t),m(t))},[]);const C=o.useMemo(()=>k(a,{className:g}),[a,g]),R=o.useCallback(w=>{var E;f.current=!0,m().catch(()=>f.current=!1),(E=a.onClick)==null||E.call(a,w)},[a,m]);return{toggle:m,enabled:b,pending:M,track:p,buttonProps:{...C,"aria-pressed":b,"data-lk-source":e,"data-lk-enabled":b,disabled:M,onClick:R}}}function De(e=[y.Track.Source.Camera,y.Track.Source.Microphone,y.Track.Source.ScreenShare,y.Track.Source.ScreenShareAudio,y.Track.Source.Unknown],n={}){const t=l.useEnsureRoom(n.room),[s,r]=o.useState([]),[i,c]=o.useState([]),a=o.useMemo(()=>e.map(d=>l.isSourceWitOptions(d)?d.source:d),[JSON.stringify(e)]);return o.useEffect(()=>{const d=l.trackReferencesObservable(t,a,{additionalRoomEvents:n.updateOnlyOn,onlySubscribed:n.onlySubscribed}).subscribe(({trackReferences:p,participants:f})=>{l.log.debug("setting track bundles",p,f),r(p),c(f)});return()=>d.unsubscribe()},[t,JSON.stringify(n.onlySubscribed),JSON.stringify(n.updateOnlyOn),JSON.stringify(e)]),o.useMemo(()=>{if(l.isSourcesWithOptions(e)){const d=Ie(e,i),p=Array.from(s);return i.forEach(f=>{d.has(f.identity)&&(d.get(f.identity)??[]).forEach(g=>{if(s.find(({participant:S,publication:M})=>f.identity===S.identity&&M.source===g))return;l.log.debug(`Add ${g} placeholder for participant ${f.identity}.`);const h={participant:f,source:g};p.push(h)})}),p}else return s},[s,i,e])}function Le(e,n){const t=new Set(e);for(const s of n)t.delete(s);return t}function Ie(e,n){const t=new Map;if(l.isSourcesWithOptions(e)){const s=e.filter(r=>r.withPlaceholder).map(r=>r.source);n.forEach(r=>{const i=r.getTrackPublications().map(a=>{var u;return(u=a.track)==null?void 0:u.source}).filter(a=>a!==void 0),c=Array.from(Le(new Set(s),new Set(i)));c.length>0&&t.set(r.identity,c)})}return t}function xe(e){const n=l.useEnsureRoom(e==null?void 0:e.room),t=V(n),s=o.useMemo(()=>t===y.ConnectionState.Disconnected,[t]),r=o.useMemo(()=>l.setupChat(n,e),[n,e,s]),i=v(r.isSendingObservable,!1),c=v(r.messageObservable,[]);return{send:r.send,chatMessages:c,isSending:i}}function Ne(e={}){const[n,t]=o.useState(l.loadUserChoices(e.defaults,e.preventLoad??!1)),s=o.useCallback(u=>{t(d=>({...d,audioEnabled:u}))},[]),r=o.useCallback(u=>{t(d=>({...d,videoEnabled:u}))},[]),i=o.useCallback(u=>{t(d=>({...d,audioDeviceId:u}))},[]),c=o.useCallback(u=>{t(d=>({...d,videoDeviceId:u}))},[]),a=o.useCallback(u=>{t(d=>({...d,username:u}))},[]);return o.useEffect(()=>{l.saveUserChoices(n,e.preventSave??!1)},[n,e.preventSave]),{userChoices:n,saveAudioInputEnabled:s,saveVideoInputEnabled:r,saveAudioInputDeviceId:i,saveVideoInputDeviceId:c,saveUsername:a}}function Fe(e,n={}){const t=P(e),s=l.useEnsureRoom(n.room),r=o.useMemo(()=>l.encryptionStatusObservable(s,t),[s,t]);return v(r,t.isLocal?t.isE2EEEnabled:!!(t!=null&&t.isEncrypted))}function Oe(e,n={fftSize:32,smoothingTimeConstant:0}){const t=l.isTrackReference(e)?e.publication.track:e,[s,r]=o.useState(0);return o.useEffect(()=>{if(!t||!t.mediaStream)return;const{cleanup:i,analyser:c}=y.createAudioAnalyser(t,n),a=c.frequencyBinCount,u=new Uint8Array(a),p=setInterval(()=>{c.getByteFrequencyData(u);let f=0;for(let m=0;m<u.length;m++){const g=u[m];f+=g*g}r(Math.sqrt(f/u.length)/255)},1e3/30);return()=>{i(),clearInterval(p)}},[t,t==null?void 0:t.mediaStream,JSON.stringify(n)]),s}const Ve=e=>{const n=t=>{let i=1-Math.max(-100,Math.min(-10,t))*-1/100;return i=Math.sqrt(i),i};return e.map(t=>t===-1/0?0:n(t))},_e={bands:5,loPass:100,hiPass:600,updateInterval:32,analyserOptions:{fftSize:2048}};function qe(e,n={}){var c;const t=e instanceof y.Track?e:(c=e==null?void 0:e.publication)==null?void 0:c.track,s={..._e,...n},[r,i]=o.useState(new Array(s.bands).fill(0));return o.useEffect(()=>{if(!t||!(t!=null&&t.mediaStream)){i(g=>g.slice().fill(0));return}const{analyser:a,cleanup:u}=y.createAudioAnalyser(t,s.analyserOptions),d=a.frequencyBinCount,p=new Float32Array(d),m=setInterval(()=>{a.getFloatFrequencyData(p);let g=new Float32Array(p.length);for(let b=0;b<p.length;b++)g[b]=p[b];g=g.slice(s.loPass,s.hiPass);const h=Ve(g),S=h.length,M=[];for(let b=0;b<s.bands;b++){const C=Math.floor(b*S/s.bands),R=Math.floor((b+1)*S/s.bands),T=h.slice(C,R),w=T.length;if(w===0)M.push(0);else{const E=T.reduce((X,Y)=>X+=Y,0);M.push(E/w)}}i(M)},s.updateInterval);return()=>{u(),clearInterval(m)}},[t,t==null?void 0:t.mediaStream,JSON.stringify(n)]),r}const Ue={barCount:120,volMultiplier:5,updateInterval:20};function ze(e,n={}){var p;const t=e instanceof y.Track?e:(p=e==null?void 0:e.publication)==null?void 0:p.track,s={...Ue,...n},r=o.useRef(new Float32Array),i=o.useRef(performance.now()),c=o.useRef(0),[a,u]=o.useState([]),d=o.useCallback(f=>{u(Array.from(We(f,s.barCount).map(m=>Math.sqrt(m)*s.volMultiplier)))},[]);return o.useEffect(()=>{if(!t||!(t!=null&&t.mediaStream))return;const{analyser:f,cleanup:m}=y.createAudioAnalyser(t,{fftSize:_(s.barCount)}),g=_(s.barCount),h=new Float32Array(g),S=()=>{if(M=requestAnimationFrame(S),f.getFloatTimeDomainData(h),r.current.map((b,C)=>b+h[C]),c.current+=1,performance.now()-i.current>=s.updateInterval){const b=h.map(C=>C/c.current);d(b),i.current=performance.now(),c.current=0}};let M=requestAnimationFrame(S);return()=>{m(),cancelAnimationFrame(M)}},[t,t==null?void 0:t.mediaStream,JSON.stringify(n),d]),{bars:a}}function _(e){return e<32?32:Be(e)}function Be(e){let n=2;for(;e>>=1;)n<<=1;return n}function We(e,n){const t=Math.floor(e.length/n),s=new Float32Array(n);for(let r=0;r<n;r++){const i=t*r;let c=0;for(let a=0;a<t;a++)c=c+Math.abs(e[i+a]);s[r]=c/t}return s}exports.LayoutContext=I;exports.ParticipantContext=O;exports.TrackRefContext=N;exports.cloneSingleChild=ge;exports.mergeProps=k;exports.mergeProps$1=me;exports.roomOptionsStringifyReplacer=he;exports.useAudioWaveform=ze;exports.useChat=xe;exports.useChatToggle=Ee;exports.useConnectionQualityIndicator=ue;exports.useConnectionState=V;exports.useCreateLayoutContext=re;exports.useDisconnectButton=le;exports.useEnsureCreateLayoutContext=oe;exports.useEnsureLayoutContext=W;exports.useEnsureParticipant=P;exports.useEnsureTrackRef=A;exports.useFacingMode=Q;exports.useFocusToggle=de;exports.useGridLayout=fe;exports.useIsEncrypted=Fe;exports.useIsMuted=L;exports.useIsSpeaking=$;exports.useLayoutContext=B;exports.useLocalParticipantPermissions=ye;exports.useMaybeLayoutContext=x;exports.useMaybeParticipantContext=J;exports.useMaybeTrackRefContext=F;exports.useMediaDeviceSelect=Se;exports.useMediaDevices=ve;exports.useMultibandTrackVolume=qe;exports.useObservableState=v;exports.usePagination=Me;exports.useParticipantContext=ie;exports.useParticipantTile=ke;exports.usePersistentUserChoices=Ne;exports.usePinnedTracks=Ce;exports.useSize=q;exports.useStartAudio=Te;exports.useStartVideo=Pe;exports.useSwipe=we;exports.useTrackMutedIndicator=Ae;exports.useTrackRefContext=ce;exports.useTrackToggle=Re;exports.useTrackVolume=Oe;exports.useTracks=De;exports.useVisualStableUpdate=H;exports.warnAboutMissingStyles=be; | ||
| //# sourceMappingURL=shared-I8hFcrmp.js.map |
Sorry, the diff of this file is too big to display
+1
-1
@@ -1,2 +0,2 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared-D30bmTxp.js"),s=require("./shared-DoNgw2-D.js"),t=require("./shared-CVy2Ouqp.js");exports.AgentEvent=e.AgentEvent;exports.MessagesEvent=e.MessagesEvent;exports.SessionEvent=e.SessionEvent;exports.useAgent=e.useAgent;exports.useAudioPlayback=e.useAudioPlayback;exports.useClearPinButton=e.useClearPinButton;exports.useDataChannel=e.useDataChannel;exports.useEvents=e.useEvents;exports.useIsRecording=e.useIsRecording;exports.useLiveKitRoom=e.useLiveKitRoom;exports.useParticipantAttribute=e.useParticipantAttribute;exports.useParticipantAttributes=e.useParticipantAttributes;exports.useParticipantInfo=e.useParticipantInfo;exports.useParticipantPermissions=e.useParticipantPermissions;exports.useParticipantTracks=e.useParticipantTracks;exports.useParticipants=e.useParticipants;exports.useRemoteParticipant=e.useRemoteParticipant;exports.useRemoteParticipants=e.useRemoteParticipants;exports.useRoomInfo=e.useRoomInfo;exports.useSequentialRoomConnectDisconnect=e.useSequentialRoomConnectDisconnect;exports.useSession=e.useSession;exports.useSessionMessages=e.useSessionMessages;exports.useSortedParticipants=e.useSortedParticipants;exports.useSpeakingParticipants=e.useSpeakingParticipants;exports.useTextStream=e.useTextStream;exports.useToken=e.useToken;exports.useTrackByName=e.useTrackByName;exports.useTrackTranscription=e.useTrackTranscription;exports.useTranscriptions=e.useTranscriptions;exports.useVoiceAssistant=e.useVoiceAssistant;exports.useAudioWaveform=s.useAudioWaveform;exports.useChat=s.useChat;exports.useChatToggle=s.useChatToggle;exports.useConnectionQualityIndicator=s.useConnectionQualityIndicator;exports.useConnectionState=s.useConnectionState;exports.useDisconnectButton=s.useDisconnectButton;exports.useFacingMode=s.useFacingMode;exports.useFocusToggle=s.useFocusToggle;exports.useGridLayout=s.useGridLayout;exports.useIsEncrypted=s.useIsEncrypted;exports.useIsMuted=s.useIsMuted;exports.useIsSpeaking=s.useIsSpeaking;exports.useLocalParticipantPermissions=s.useLocalParticipantPermissions;exports.useMediaDeviceSelect=s.useMediaDeviceSelect;exports.useMediaDevices=s.useMediaDevices;exports.useMultibandTrackVolume=s.useMultibandTrackVolume;exports.usePagination=s.usePagination;exports.useParticipantTile=s.useParticipantTile;exports.usePersistentUserChoices=s.usePersistentUserChoices;exports.usePinnedTracks=s.usePinnedTracks;exports.useStartAudio=s.useStartAudio;exports.useStartVideo=s.useStartVideo;exports.useSwipe=s.useSwipe;exports.useTrackMutedIndicator=s.useTrackMutedIndicator;exports.useTrackToggle=s.useTrackToggle;exports.useTrackVolume=s.useTrackVolume;exports.useTracks=s.useTracks;exports.useVisualStableUpdate=s.useVisualStableUpdate;exports.useLocalParticipant=t.useLocalParticipant; | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared-BGiZtWPs.js"),s=require("./shared-I8hFcrmp.js"),t=require("./shared-CVy2Ouqp.js");exports.AgentEvent=e.AgentEvent;exports.MessagesEvent=e.MessagesEvent;exports.SessionEvent=e.SessionEvent;exports.useAgent=e.useAgent;exports.useAudioPlayback=e.useAudioPlayback;exports.useClearPinButton=e.useClearPinButton;exports.useDataChannel=e.useDataChannel;exports.useEvents=e.useEvents;exports.useIsRecording=e.useIsRecording;exports.useLiveKitRoom=e.useLiveKitRoom;exports.useParticipantAttribute=e.useParticipantAttribute;exports.useParticipantAttributes=e.useParticipantAttributes;exports.useParticipantInfo=e.useParticipantInfo;exports.useParticipantPermissions=e.useParticipantPermissions;exports.useParticipantTracks=e.useParticipantTracks;exports.useParticipants=e.useParticipants;exports.useRemoteParticipant=e.useRemoteParticipant;exports.useRemoteParticipants=e.useRemoteParticipants;exports.useRoomInfo=e.useRoomInfo;exports.useSequentialRoomConnectDisconnect=e.useSequentialRoomConnectDisconnect;exports.useSession=e.useSession;exports.useSessionMessages=e.useSessionMessages;exports.useSortedParticipants=e.useSortedParticipants;exports.useSpeakingParticipants=e.useSpeakingParticipants;exports.useTextStream=e.useTextStream;exports.useToken=e.useToken;exports.useTrackByName=e.useTrackByName;exports.useTrackTranscription=e.useTrackTranscription;exports.useTranscriptions=e.useTranscriptions;exports.useVoiceAssistant=e.useVoiceAssistant;exports.useAudioWaveform=s.useAudioWaveform;exports.useChat=s.useChat;exports.useChatToggle=s.useChatToggle;exports.useConnectionQualityIndicator=s.useConnectionQualityIndicator;exports.useConnectionState=s.useConnectionState;exports.useDisconnectButton=s.useDisconnectButton;exports.useFacingMode=s.useFacingMode;exports.useFocusToggle=s.useFocusToggle;exports.useGridLayout=s.useGridLayout;exports.useIsEncrypted=s.useIsEncrypted;exports.useIsMuted=s.useIsMuted;exports.useIsSpeaking=s.useIsSpeaking;exports.useLocalParticipantPermissions=s.useLocalParticipantPermissions;exports.useMediaDeviceSelect=s.useMediaDeviceSelect;exports.useMediaDevices=s.useMediaDevices;exports.useMultibandTrackVolume=s.useMultibandTrackVolume;exports.usePagination=s.usePagination;exports.useParticipantTile=s.useParticipantTile;exports.usePersistentUserChoices=s.usePersistentUserChoices;exports.usePinnedTracks=s.usePinnedTracks;exports.useStartAudio=s.useStartAudio;exports.useStartVideo=s.useStartVideo;exports.useSwipe=s.useSwipe;exports.useTrackMutedIndicator=s.useTrackMutedIndicator;exports.useTrackToggle=s.useTrackToggle;exports.useTrackVolume=s.useTrackVolume;exports.useTracks=s.useTracks;exports.useVisualStableUpdate=s.useVisualStableUpdate;exports.useLocalParticipant=t.useLocalParticipant; | ||
| //# sourceMappingURL=hooks.js.map |
+1
-1
@@ -1,2 +0,2 @@ | ||
| import { R as e, a5 as t, a2 as i, S as u, D as n, U as o, w as r, b as c, u as p, i as P, a as d, E as l, c as T, a4 as g, F as m, d as S, n as k, m as v, G as A, _ as C, H as I, C as M, A as R, e as b, y as f, s as y, o as D, Z as E, Y as V, I as h, J as L, l as x, V as B, K as F, x as U, B as w, L as G, M as K, v as N, a1 as Q, a3 as W, a6 as q, N as H, O as J, f as O, g as X, p as Y, $ as Z, P as _, Q as $, k as j, h as z, W as ss, T as as, t as es, a0 as ts, r as is, X as us } from "./hooks-yU-srrIO.mjs"; | ||
| import { R as e, a5 as t, a2 as i, S as u, D as n, U as o, w as r, b as c, u as p, i as P, a as d, E as l, c as T, a4 as g, F as m, d as S, n as k, m as v, G as A, _ as C, H as I, C as M, A as R, e as b, y as f, s as y, o as D, Z as E, Y as V, I as h, J as L, l as x, V as B, K as F, x as U, B as w, L as G, M as K, v as N, a1 as Q, a3 as W, a6 as q, N as H, O as J, f as O, g as X, p as Y, $ as Z, P as _, Q as $, k as j, h as z, W as ss, T as as, t as es, a0 as ts, r as is, X as us } from "./hooks-0IvkS6LV.mjs"; | ||
| import { u as os } from "./room-Bb6uLxS5.mjs"; | ||
@@ -3,0 +3,0 @@ export { |
@@ -1,2 +0,2 @@ | ||
| import { RemoteParticipant } from 'livekit-client'; | ||
| import { RemoteParticipant, Participant } from 'livekit-client'; | ||
| import { default as TypedEventEmitter } from 'typed-emitter'; | ||
@@ -38,3 +38,3 @@ import { TrackReference } from '@livekit/components-core'; | ||
| type AgentStateCommon = { | ||
| attributes: Record<string, string>; | ||
| attributes: Participant['attributes']; | ||
| internal: { | ||
@@ -49,2 +49,6 @@ emitter: TypedEventEmitter<AgentCallbacks>; | ||
| failureReasons: null; | ||
| /** The agent's assigned identity, coming from the JWT token. */ | ||
| identity: Participant['identity']; | ||
| name: Participant['name']; | ||
| metadata: Participant['metadata']; | ||
| /** Is the agent connected to the client? */ | ||
@@ -69,2 +73,6 @@ isConnected: true; | ||
| failureReasons: null; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: Participant['identity']; | ||
| name: Participant['name']; | ||
| metadata: Participant['metadata']; | ||
| /** Is the agent connected to the client? */ | ||
@@ -89,2 +97,6 @@ isConnected: false; | ||
| failureReasons: null; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: Participant['identity']; | ||
| name: Participant['name']; | ||
| metadata: Participant['metadata']; | ||
| /** Is the agent connected to the client? */ | ||
@@ -109,2 +121,6 @@ isConnected: false; | ||
| failureReasons: null; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: undefined; | ||
| name: undefined; | ||
| metadata: undefined; | ||
| /** Is the agent connected to the client? */ | ||
@@ -129,2 +145,6 @@ isConnected: false; | ||
| failureReasons: null; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: undefined; | ||
| name: undefined; | ||
| metadata: undefined; | ||
| /** Is the agent connected to the client? */ | ||
@@ -149,2 +169,6 @@ isConnected: false; | ||
| failureReasons: Array<string>; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: undefined; | ||
| name: undefined; | ||
| metadata: undefined; | ||
| /** Is the agent connected to the client? */ | ||
@@ -151,0 +175,0 @@ isConnected: false; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"useAgent.d.ts","sourceRoot":"","sources":["../../src/hooks/useAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EAGlB,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,iBAAiB,MAAM,eAAe,CAAC;AAGnD,OAAO,EAA8B,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAItF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAMhD,6IAA6I;AAC7I,KAAK,cAAc,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtF;;;;;;;;;;;;;;;;KAgBK;AACL,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,YAAY,GACZ,uBAAuB,GACvB,QAAQ,GACR,cAAc,CAAC;AAEnB,YAAY;AACZ,oBAAY,UAAU;IACpB,aAAa,kBAAkB;IAC/B,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;CAC9B;AAED,YAAY;AACZ,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;IAC3E,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/E,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,aAAa,EAAE,UAAU,KAAK,IAAI,CAAC;CAChE,CAAC;AAEF,KAAK,gBAAgB,GAAG;IAEtB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAEnC,QAAQ,EAAE;QACR,OAAO,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;QAE3C,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAAC;QAC3C,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;KAC7C,CAAC;CACH,CAAC;AAEF,KAAK,mBAAmB,GAAG,gBAAgB,GAAG;IAC5C,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;IAC7C,cAAc,EAAE,IAAI,CAAC;IAErB,4CAA4C;IAC5C,WAAW,EAAE,IAAI,CAAC;IAElB;;;;;SAKK;IACL,SAAS,EAAE,IAAI,CAAC;IAEhB,8FAA8F;IAC9F,UAAU,EAAE,KAAK,CAAC;IAElB,8DAA8D;IAC9D,SAAS,EAAE,KAAK,CAAC;IAEjB,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,KAAK,6BAA6B,GAAG,gBAAgB,GAAG;IACtD,KAAK,EAAE,uBAAuB,CAAC;IAC/B,cAAc,EAAE,IAAI,CAAC;IAErB,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,IAAI,CAAC;IAEhB,8FAA8F;IAC9F,UAAU,EAAE,KAAK,CAAC;IAElB,8DAA8D;IAC9D,SAAS,EAAE,KAAK,CAAC;IAEjB,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,KAAK,qBAAqB,GAAG,gBAAgB,GAAG;IAC9C,KAAK,EAAE,cAAc,GAAG,MAAM,CAAC;IAC/B,cAAc,EAAE,IAAI,CAAC;IAErB,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,KAAK,CAAC;IAEjB,8FAA8F;IAC9F,UAAU,EAAE,KAAK,CAAC;IAElB,8DAA8D;IAC9D,SAAS,EAAE,IAAI,CAAC;IAEhB,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,KAAK,oBAAoB,GAAG,gBAAgB,GAAG;IAC7C,KAAK,EAAE,YAAY,CAAC;IACpB,cAAc,EAAE,IAAI,CAAC;IAErB,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,KAAK,CAAC;IAEjB,8FAA8F;IAC9F,UAAU,EAAE,KAAK,CAAC;IAElB,8DAA8D;IAC9D,SAAS,EAAE,IAAI,CAAC;IAEhB,WAAW,EAAE,SAAS,CAAC;IACvB,eAAe,EAAE,SAAS,CAAC;CAC5B,CAAC;AAEF,KAAK,sBAAsB,GAAG,gBAAgB,GAAG;IAC/C,KAAK,EAAE,cAAc,CAAC;IACtB,cAAc,EAAE,IAAI,CAAC;IAErB,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,KAAK,CAAC;IAEjB,8FAA8F;IAC9F,UAAU,EAAE,IAAI,CAAC;IAEjB,8DAA8D;IAC9D,SAAS,EAAE,KAAK,CAAC;IAEjB,WAAW,EAAE,SAAS,CAAC;IACvB,eAAe,EAAE,SAAS,CAAC;CAC5B,CAAC;AAEF,KAAK,gBAAgB,GAAG,gBAAgB,GAAG;IACzC,KAAK,EAAE,QAAQ,CAAC;IAChB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,KAAK,CAAC;IAEjB,8FAA8F;IAC9F,UAAU,EAAE,IAAI,CAAC;IAEjB,8DAA8D;IAC9D,SAAS,EAAE,KAAK,CAAC;IAEjB,WAAW,EAAE,SAAS,CAAC;IACvB,eAAe,EAAE,SAAS,CAAC;CAC5B,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,+FAA+F;IAC/F,kBAAkB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;;;;SAKK;IACL,yBAAyB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnE,mIAAmI;IACnI,iBAAiB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D,kFAAkF;IAClF,eAAe,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAEnE,sFAAsF;IACtF,mBAAmB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CACxE,CAAC;AAEF,KAAK,eAAe,GAChB,oBAAoB,GACpB,sBAAsB,GACtB,mBAAmB,GACnB,6BAA6B,GAC7B,qBAAqB,GACrB,gBAAgB,CAAC;AAErB,YAAY;AACZ,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,YAAY,CAAC;AAqB5D,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,QAAO;IACxC,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,iBAAiB,EAAE,CAAC,+BAA+B,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,8BAA8B,EAAE,MAAM,IAAI,CAAC;IAC3C,uBAAuB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC1D,mCAAmC,EAAE,CAAC,sBAAsB,EAAE,OAAO,KAAK,IAAI,CAAC;CA+DhF,CAAC;AAEF,KAAK,WAAW,GAAG,IAAI,CAAC,gBAAgB,EAAE,iBAAiB,GAAG,MAAM,GAAG,UAAU,CAAC,CAAC;AAmHnF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CA0Z9D"} | ||
| {"version":3,"file":"useAgent.d.ts","sourceRoot":"","sources":["../../src/hooks/useAgent.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,iBAAiB,EAGjB,WAAW,EACZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,KAAK,iBAAiB,MAAM,eAAe,CAAC;AAGnD,OAAO,EAA8B,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAItF,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAOhD,6IAA6I;AAC7I,KAAK,cAAc,GAAG,cAAc,GAAG,MAAM,GAAG,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;AAEtF;;;;;;;;;;;;;;;;KAgBK;AACL,MAAM,MAAM,UAAU,GAClB,cAAc,GACd,YAAY,GACZ,uBAAuB,GACvB,QAAQ,GACR,cAAc,CAAC;AAEnB,YAAY;AACZ,oBAAY,UAAU;IACpB,aAAa,kBAAkB;IAC/B,iBAAiB,sBAAsB;IACvC,YAAY,iBAAiB;CAC9B;AAED,YAAY;AACZ,MAAM,MAAM,cAAc,GAAG;IAC3B,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;IAC3E,CAAC,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC,QAAQ,EAAE,cAAc,GAAG,SAAS,KAAK,IAAI,CAAC;IAC/E,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC,aAAa,EAAE,UAAU,KAAK,IAAI,CAAC;CAChE,CAAC;AAEF,KAAK,gBAAgB,GAAG;IAEtB,UAAU,EAAE,WAAW,CAAC,YAAY,CAAC,CAAC;IAEtC,QAAQ,EAAE;QACR,OAAO,EAAE,iBAAiB,CAAC,cAAc,CAAC,CAAC;QAE3C,gBAAgB,EAAE,iBAAiB,GAAG,IAAI,CAAC;QAC3C,iBAAiB,EAAE,iBAAiB,GAAG,IAAI,CAAC;KAC7C,CAAC;CACH,CAAC;AAEF,KAAK,mBAAmB,GAAG,gBAAgB,GAAG;IAC5C,KAAK,EAAE,WAAW,GAAG,UAAU,GAAG,UAAU,CAAC;IAC7C,cAAc,EAAE,IAAI,CAAC;IAErB,gEAAgE;IAChE,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAClC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAElC,4CAA4C;IAC5C,WAAW,EAAE,IAAI,CAAC;IAElB;;;;;SAKK;IACL,SAAS,EAAE,IAAI,CAAC;IAEhB,8FAA8F;IAC9F,UAAU,EAAE,KAAK,CAAC;IAElB,8DAA8D;IAC9D,SAAS,EAAE,KAAK,CAAC;IAEjB,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,KAAK,6BAA6B,GAAG,gBAAgB,GAAG;IACtD,KAAK,EAAE,uBAAuB,CAAC;IAC/B,cAAc,EAAE,IAAI,CAAC;IAErB,iEAAiE;IACjE,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAClC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAElC,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,IAAI,CAAC;IAEhB,8FAA8F;IAC9F,UAAU,EAAE,KAAK,CAAC;IAElB,8DAA8D;IAC9D,SAAS,EAAE,KAAK,CAAC;IAEjB,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,KAAK,qBAAqB,GAAG,gBAAgB,GAAG;IAC9C,KAAK,EAAE,cAAc,GAAG,MAAM,CAAC;IAC/B,cAAc,EAAE,IAAI,CAAC;IAErB,iEAAiE;IACjE,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAClC,IAAI,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC1B,QAAQ,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;IAElC,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,KAAK,CAAC;IAEjB,8FAA8F;IAC9F,UAAU,EAAE,KAAK,CAAC;IAElB,8DAA8D;IAC9D,SAAS,EAAE,IAAI,CAAC;IAEhB,WAAW,CAAC,EAAE,cAAc,CAAC;IAC7B,eAAe,CAAC,EAAE,cAAc,CAAC;CAClC,CAAC;AAEF,KAAK,oBAAoB,GAAG,gBAAgB,GAAG;IAC7C,KAAK,EAAE,YAAY,CAAC;IACpB,cAAc,EAAE,IAAI,CAAC;IAErB,iEAAiE;IACjE,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IAEpB,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,KAAK,CAAC;IAEjB,8FAA8F;IAC9F,UAAU,EAAE,KAAK,CAAC;IAElB,8DAA8D;IAC9D,SAAS,EAAE,IAAI,CAAC;IAEhB,WAAW,EAAE,SAAS,CAAC;IACvB,eAAe,EAAE,SAAS,CAAC;CAC5B,CAAC;AAEF,KAAK,sBAAsB,GAAG,gBAAgB,GAAG;IAC/C,KAAK,EAAE,cAAc,CAAC;IACtB,cAAc,EAAE,IAAI,CAAC;IAErB,iEAAiE;IACjE,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IAEpB,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,KAAK,CAAC;IAEjB,8FAA8F;IAC9F,UAAU,EAAE,IAAI,CAAC;IAEjB,8DAA8D;IAC9D,SAAS,EAAE,KAAK,CAAC;IAEjB,WAAW,EAAE,SAAS,CAAC;IACvB,eAAe,EAAE,SAAS,CAAC;CAC5B,CAAC;AAEF,KAAK,gBAAgB,GAAG,gBAAgB,GAAG;IACzC,KAAK,EAAE,QAAQ,CAAC;IAChB,cAAc,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAE9B,iEAAiE;IACjE,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,QAAQ,EAAE,SAAS,CAAC;IAEpB,4CAA4C;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB;;;;;SAKK;IACL,SAAS,EAAE,KAAK,CAAC;IAEjB,8FAA8F;IAC9F,UAAU,EAAE,IAAI,CAAC;IAEjB,8DAA8D;IAC9D,SAAS,EAAE,KAAK,CAAC;IAEjB,WAAW,EAAE,SAAS,CAAC;IACvB,eAAe,EAAE,SAAS,CAAC;CAC5B,CAAC;AAEF,KAAK,YAAY,GAAG;IAClB,+FAA+F;IAC/F,kBAAkB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE5D;;;;;SAKK;IACL,yBAAyB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEnE,mIAAmI;IACnI,iBAAiB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3D,kFAAkF;IAClF,eAAe,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;IAEnE,sFAAsF;IACtF,mBAAmB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,cAAc,CAAC,CAAC;CACxE,CAAC;AAEF,KAAK,eAAe,GAChB,oBAAoB,GACpB,sBAAsB,GACtB,mBAAmB,GACnB,6BAA6B,GAC7B,qBAAqB,GACrB,gBAAgB,CAAC;AAErB,YAAY;AACZ,MAAM,MAAM,cAAc,GAAG,eAAe,GAAG,YAAY,CAAC;AAqB5D,mEAAmE;AACnE,eAAO,MAAM,sBAAsB,QAAO;IACxC,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;IACzC,iBAAiB,EAAE,CAAC,+BAA+B,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;IACtE,iBAAiB,EAAE,MAAM,IAAI,CAAC;IAC9B,8BAA8B,EAAE,MAAM,IAAI,CAAC;IAC3C,uBAAuB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;IAC1D,mCAAmC,EAAE,CAAC,sBAAsB,EAAE,OAAO,KAAK,IAAI,CAAC;CA+DhF,CAAC;AAEF,KAAK,WAAW,GAAG,IAAI,CAAC,gBAAgB,EAAE,iBAAiB,GAAG,MAAM,GAAG,UAAU,CAAC,CAAC;AAmHnF;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,OAAO,CAAC,EAAE,WAAW,GAAG,cAAc,CA4b9D"} |
@@ -35,2 +35,10 @@ import { default as TypedEventEmitter } from 'typed-emitter'; | ||
| }; | ||
| camera?: { | ||
| enabled?: boolean; | ||
| publishOptions?: TrackPublishOptions; | ||
| }; | ||
| screenShare?: { | ||
| enabled?: boolean; | ||
| publishOptions?: TrackPublishOptions; | ||
| }; | ||
| }; | ||
@@ -66,4 +74,5 @@ /** Options for Room.connect(.., .., opts) */ | ||
| local: { | ||
| cameraTrack: null; | ||
| microphoneTrack: null; | ||
| cameraTrack: undefined; | ||
| microphoneTrack: undefined; | ||
| screenShareTrack: undefined; | ||
| }; | ||
@@ -75,4 +84,5 @@ }; | ||
| local: { | ||
| cameraTrack: TrackReference | null; | ||
| microphoneTrack: TrackReference | null; | ||
| cameraTrack?: TrackReference; | ||
| microphoneTrack?: TrackReference; | ||
| screenShareTrack?: TrackReference; | ||
| }; | ||
@@ -84,4 +94,5 @@ }; | ||
| local: { | ||
| cameraTrack: null; | ||
| microphoneTrack: null; | ||
| cameraTrack: undefined; | ||
| microphoneTrack: undefined; | ||
| screenShareTrack: undefined; | ||
| }; | ||
@@ -88,0 +99,0 @@ }; |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"useSession.d.ts","sourceRoot":"","sources":["../../src/hooks/useSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,iBAAiB,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,IAAI,EAEJ,eAAe,EACf,mBAAmB,EAEnB,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,UAAU,EAAoC,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,YAAY;AACZ,oBAAY,YAAY;IACtB,sBAAsB,2BAA2B;IACjD;;;;OAIG;IACH,iBAAiB,sBAAsB;IACvC;;;OAGG;IACH,eAAe,oBAAoB;CACpC;AAED,YAAY;AACZ,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,YAAY,CAAC,sBAAsB,CAAC,EAAE,CAAC,uBAAuB,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1F,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACzD,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACxD,CAAC;AAEF,YAAY;AACZ,MAAM,MAAM,qBAAqB,GAAG;IAClC,mGAAmG;IACnG,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,MAAM,CAAC,EAAE;QACP,UAAU,CAAC,EAAE;YACX,OAAO,CAAC,EAAE,OAAO,CAAC;YAClB,cAAc,CAAC,EAAE,mBAAmB,CAAC;SACtC,CAAC;KACH,CAAC;IAEF,6CAA6C;IAC7C,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF,YAAY;AACZ,MAAM,MAAM,yBAAyB,GAAG;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE;QACR,OAAO,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;QAC7C,WAAW,EAAE,uBAAuB,GAAG,gBAAgB,CAAC;QACxD,+BAA+B,CAAC,EAAE,MAAM,CAAC;QAEzC,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;QACzC,iBAAiB,EAAE,CAAC,+BAA+B,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;QACtE,iBAAiB,EAAE,MAAM,IAAI,CAAC;QAC9B,8BAA8B,EAAE,MAAM,IAAI,CAAC;QAC3C,uBAAuB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;QAC1D,mCAAmC,EAAE,CAAC,sBAAsB,EAAE,OAAO,KAAK,IAAI,CAAC;KAChF,CAAC;CACH,CAAC;AAEF,KAAK,sBAAsB,GAAG,kBAAkB,GAAG;IACjD,eAAe,EAAE,eAAe,CAAC,UAAU,CAAC;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB,KAAK,EAAE;QACL,WAAW,EAAE,IAAI,CAAC;QAClB,eAAe,EAAE,IAAI,CAAC;KACvB,CAAC;CACH,CAAC;AAEF,KAAK,qBAAqB,GAAG,kBAAkB,GAAG;IAChD,eAAe,EACX,eAAe,CAAC,SAAS,GACzB,eAAe,CAAC,YAAY,GAC5B,eAAe,CAAC,kBAAkB,CAAC;IACvC,WAAW,EAAE,IAAI,CAAC;IAElB,KAAK,EAAE;QACL,WAAW,EAAE,cAAc,GAAG,IAAI,CAAC;QACnC,eAAe,EAAE,cAAc,GAAG,IAAI,CAAC;KACxC,CAAC;CACH,CAAC;AAEF,KAAK,wBAAwB,GAAG,kBAAkB,GAAG;IACnD,eAAe,EAAE,eAAe,CAAC,YAAY,CAAC;IAC9C,WAAW,EAAE,KAAK,CAAC;IAEnB,KAAK,EAAE;QACL,WAAW,EAAE,IAAI,CAAC;QAClB,eAAe,EAAE,IAAI,CAAC;KACvB,CAAC;CACH,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,8DAA8D;IAC9D,kBAAkB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;IACnD,gEAAgE;IAChE,qBAAqB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;IAEtD,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC,6DAA6D;IAC7D,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D,0CAA0C;IAC1C,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B,CAAC;AAEF,YAAY;AACZ,MAAM,MAAM,gBAAgB,GAAG,CAC3B,sBAAsB,GACtB,qBAAqB,GACrB,wBAAwB,CAC3B,GACC,cAAc,CAAC;AAEjB,KAAK,uBAAuB,GAAG;IAC7B,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;OAGG;IACH,+BAA+B,CAAC,EAAE,MAAM,CAAC;CAC1C,CAAC;AAEF,KAAK,6BAA6B,GAAG,uBAAuB,GAAG,uBAAuB,CAAC;AACvF,KAAK,sBAAsB,GAAG,uBAAuB,CAAC;AAiItD;;;GAGG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,uBAAuB,EACpC,OAAO,CAAC,EAAE,6BAA6B,GACtC,gBAAgB,CAAC;AACpB;;;GAGG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,gBAAgB,CAAC"} | ||
| {"version":3,"file":"useSession.d.ts","sourceRoot":"","sources":["../../src/hooks/useSession.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,iBAAiB,MAAM,eAAe,CAAC;AACnD,OAAO,EACL,IAAI,EAEJ,eAAe,EACf,mBAAmB,EAEnB,uBAAuB,EACvB,gBAAgB,EAChB,uBAAuB,EACvB,kBAAkB,EAEnB,MAAM,gBAAgB,CAAC;AAIxB,OAAO,EAAE,UAAU,EAAoC,MAAM,YAAY,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAG1D,YAAY;AACZ,oBAAY,YAAY;IACtB,sBAAsB,2BAA2B;IACjD;;;;OAIG;IACH,iBAAiB,sBAAsB;IACvC;;;OAGG;IACH,eAAe,oBAAoB;CACpC;AAED,YAAY;AACZ,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,YAAY,CAAC,sBAAsB,CAAC,EAAE,CAAC,uBAAuB,EAAE,eAAe,KAAK,IAAI,CAAC;IAC1F,CAAC,YAAY,CAAC,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACzD,CAAC,YAAY,CAAC,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACxD,CAAC;AAEF,YAAY;AACZ,MAAM,MAAM,qBAAqB,GAAG;IAClC,mGAAmG;IACnG,MAAM,CAAC,EAAE,WAAW,CAAC;IAErB,MAAM,CAAC,EAAE;QACP,UAAU,CAAC,EAAE;YACX,OAAO,CAAC,EAAE,OAAO,CAAC;YAClB,cAAc,CAAC,EAAE,mBAAmB,CAAC;SACtC,CAAC;QACF,MAAM,CAAC,EAAE;YACP,OAAO,CAAC,EAAE,OAAO,CAAC;YAClB,cAAc,CAAC,EAAE,mBAAmB,CAAC;SACtC,CAAC;QACF,WAAW,CAAC,EAAE;YACZ,OAAO,CAAC,EAAE,OAAO,CAAC;YAClB,cAAc,CAAC,EAAE,mBAAmB,CAAC;SACtC,CAAC;KACH,CAAC;IAEF,6CAA6C;IAC7C,kBAAkB,CAAC,EAAE,kBAAkB,CAAC;CACzC,CAAC;AAEF,YAAY;AACZ,MAAM,MAAM,yBAAyB,GAAG;IACtC;;;OAGG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,KAAK,kBAAkB,GAAG;IACxB,IAAI,EAAE,IAAI,CAAC;IACX,QAAQ,EAAE;QACR,OAAO,EAAE,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;QAC7C,WAAW,EAAE,uBAAuB,GAAG,gBAAgB,CAAC;QACxD,+BAA+B,CAAC,EAAE,MAAM,CAAC;QAEzC,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;QACzC,iBAAiB,EAAE,CAAC,+BAA+B,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;QACtE,iBAAiB,EAAE,MAAM,IAAI,CAAC;QAC9B,8BAA8B,EAAE,MAAM,IAAI,CAAC;QAC3C,uBAAuB,EAAE,CAAC,UAAU,EAAE,UAAU,KAAK,IAAI,CAAC;QAC1D,mCAAmC,EAAE,CAAC,sBAAsB,EAAE,OAAO,KAAK,IAAI,CAAC;KAChF,CAAC;CACH,CAAC;AAEF,KAAK,sBAAsB,GAAG,kBAAkB,GAAG;IACjD,eAAe,EAAE,eAAe,CAAC,UAAU,CAAC;IAC5C,WAAW,EAAE,KAAK,CAAC;IAEnB,KAAK,EAAE;QACL,WAAW,EAAE,SAAS,CAAC;QACvB,eAAe,EAAE,SAAS,CAAC;QAC3B,gBAAgB,EAAE,SAAS,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,KAAK,qBAAqB,GAAG,kBAAkB,GAAG;IAChD,eAAe,EACX,eAAe,CAAC,SAAS,GACzB,eAAe,CAAC,YAAY,GAC5B,eAAe,CAAC,kBAAkB,CAAC;IACvC,WAAW,EAAE,IAAI,CAAC;IAElB,KAAK,EAAE;QACL,WAAW,CAAC,EAAE,cAAc,CAAC;QAC7B,eAAe,CAAC,EAAE,cAAc,CAAC;QACjC,gBAAgB,CAAC,EAAE,cAAc,CAAC;KACnC,CAAC;CACH,CAAC;AAEF,KAAK,wBAAwB,GAAG,kBAAkB,GAAG;IACnD,eAAe,EAAE,eAAe,CAAC,YAAY,CAAC;IAC9C,WAAW,EAAE,KAAK,CAAC;IAEnB,KAAK,EAAE;QACL,WAAW,EAAE,SAAS,CAAC;QACvB,eAAe,EAAE,SAAS,CAAC;QAC3B,gBAAgB,EAAE,SAAS,CAAC;KAC7B,CAAC;CACH,CAAC;AAEF,KAAK,cAAc,GAAG;IACpB,8DAA8D;IAC9D,kBAAkB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;IACnD,gEAAgE;IAChE,qBAAqB,EAAE,CAAC,MAAM,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;IAEtD,iBAAiB,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAEvC,6DAA6D;IAC7D,KAAK,EAAE,CAAC,OAAO,CAAC,EAAE,qBAAqB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE1D,0CAA0C;IAC1C,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC1B,CAAC;AAEF,YAAY;AACZ,MAAM,MAAM,gBAAgB,GAAG,CAC3B,sBAAsB,GACtB,qBAAqB,GACrB,wBAAwB,CAC3B,GACC,cAAc,CAAC;AAEjB,KAAK,uBAAuB,GAAG;IAC7B,IAAI,CAAC,EAAE,IAAI,CAAC;IAEZ;;;OAGG;IACH,+BAA+B,CAAC,EAAE,MAAM,CAAC;CAC1C,CAAC;AAEF,KAAK,6BAA6B,GAAG,uBAAuB,GAAG,uBAAuB,CAAC;AACvF,KAAK,sBAAsB,GAAG,uBAAuB,CAAC;AAiItD;;;GAGG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,uBAAuB,EACpC,OAAO,CAAC,EAAE,6BAA6B,GACtC,gBAAgB,CAAC;AACpB;;;GAGG;AACH,wBAAgB,UAAU,CACxB,WAAW,EAAE,gBAAgB,EAC7B,OAAO,CAAC,EAAE,sBAAsB,GAC/B,gBAAgB,CAAC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"useTrackVolume.d.ts","sourceRoot":"","sources":["../../src/hooks/useTrackVolume.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE9F,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,2BAA2B,EACjC,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,qBAAqB,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,cAAc,EAC3E,OAAO,GAAE,oBAAgE,UAmC1E;AAqBD;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAUD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,qBAAqB,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,2BAA2B,EACxF,OAAO,GAAE,2BAAgC,YAmD1C;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAQD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,qBAAqB,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,2BAA2B,EACxF,OAAO,GAAE,oBAAyB;;EA0DnC"} | ||
| {"version":3,"file":"useTrackVolume.d.ts","sourceRoot":"","sources":["../../src/hooks/useTrackVolume.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAE9F,OAAO,EACL,KAAK,cAAc,EAEnB,KAAK,2BAA2B,EACjC,MAAM,0BAA0B,CAAC;AAElC;;;GAGG;AACH,wBAAgB,cAAc,CAC5B,qBAAqB,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,cAAc,EAC3E,OAAO,GAAE,oBAAgE,UAmC1E;AAqBD;;;GAGG;AACH,MAAM,WAAW,2BAA2B;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,eAAe,CAAC;CACnC;AAUD;;;GAGG;AACH,wBAAgB,uBAAuB,CACrC,qBAAqB,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,2BAA2B,EACxF,OAAO,GAAE,2BAAgC,YA0D1C;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAQD;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,qBAAqB,CAAC,EAAE,eAAe,GAAG,gBAAgB,GAAG,2BAA2B,EACxF,OAAO,GAAE,oBAAyB;;EA0DnC"} |
+1
-1
@@ -1,2 +0,2 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./shared-D30bmTxp.js"),t=require("./shared-DoNgw2-D.js"),u=require("./shared-CVy2Ouqp.js"),e=require("./shared-BGEsyR2K.js"),m=require("react");function P(i){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const s in i)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(a,s,r.get?r:{enumerable:!0,get:()=>i[s]})}}return a.default=i,Object.freeze(a)}const n=P(m),v=n.forwardRef(function(a,s){const{buttonProps:r}=o.useClearPinButton(a);return n.createElement("button",{ref:s,...r},a.children)}),T=n.forwardRef(function({room:a,...s},r){const c=t.useConnectionState(a);return n.createElement("div",{ref:r,...s},c)}),p=n.forwardRef(function({label:a="Allow Audio",...s},r){const c=u.useEnsureRoom(s.room),{mergedProps:l}=t.useStartAudio({room:c,props:s});return n.createElement("button",{ref:r,...l},a)}),f=n.forwardRef(function(a,s){const{room:r,htmlProps:c}=o.useLiveKitRoom(a);return n.createElement("div",{ref:s,...c},r&&n.createElement(u.RoomContext.Provider,{value:r},n.createElement(e.LKFeatureContext.Provider,{value:a.featureFlags},a.children)))}),k=n.forwardRef(function({trackRef:a,...s},r){const g=t.useEnsureTrackRef(a),S=t.useMultibandTrackVolume(g,{bands:7,loPass:300});return n.createElement("svg",{ref:r,width:"100%",height:"100%",viewBox:"0 0 200 90",...s,className:"lk-audio-visualizer"},n.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%"}),n.createElement("g",{style:{transform:`translate(${130/2}px, 0)`}},S.map((d,C)=>n.createElement("rect",{key:C,x:C*10,y:90/2-d*50/2,width:6,height:d*50}))))});function y({participants:i,...a}){return n.createElement(n.Fragment,null,i.map(s=>n.createElement(t.ParticipantContext.Provider,{value:s,key:s.identity},t.cloneSingleChild(a.children))))}const I=n.forwardRef(function({childrenPosition:a="before",children:s,...r},c){const{name:l}=o.useRoomInfo();return n.createElement("span",{ref:c,...r},a==="before"&&s,l,a==="after"&&s)});function x(i){return n.createElement(o.SessionContext.Provider,{value:i.session},n.createElement(u.RoomContext.Provider,{value:i.session.room},i.children))}exports.AgentEvent=o.AgentEvent;exports.MessagesEvent=o.MessagesEvent;exports.SessionEvent=o.SessionEvent;exports.useAgent=o.useAgent;exports.useAudioPlayback=o.useAudioPlayback;exports.useClearPinButton=o.useClearPinButton;exports.useDataChannel=o.useDataChannel;exports.useEnsureSession=o.useEnsureSession;exports.useEvents=o.useEvents;exports.useIsRecording=o.useIsRecording;exports.useLiveKitRoom=o.useLiveKitRoom;exports.useMaybeSessionContext=o.useMaybeSessionContext;exports.useParticipantAttribute=o.useParticipantAttribute;exports.useParticipantAttributes=o.useParticipantAttributes;exports.useParticipantInfo=o.useParticipantInfo;exports.useParticipantPermissions=o.useParticipantPermissions;exports.useParticipantTracks=o.useParticipantTracks;exports.useParticipants=o.useParticipants;exports.useRemoteParticipant=o.useRemoteParticipant;exports.useRemoteParticipants=o.useRemoteParticipants;exports.useRoomInfo=o.useRoomInfo;exports.useSequentialRoomConnectDisconnect=o.useSequentialRoomConnectDisconnect;exports.useSession=o.useSession;exports.useSessionContext=o.useSessionContext;exports.useSessionMessages=o.useSessionMessages;exports.useSortedParticipants=o.useSortedParticipants;exports.useSpeakingParticipants=o.useSpeakingParticipants;exports.useTextStream=o.useTextStream;exports.useToken=o.useToken;exports.useTrackByName=o.useTrackByName;exports.useTrackTranscription=o.useTrackTranscription;exports.useTranscriptions=o.useTranscriptions;exports.useVoiceAssistant=o.useVoiceAssistant;exports.LayoutContext=t.LayoutContext;exports.ParticipantContext=t.ParticipantContext;exports.TrackRefContext=t.TrackRefContext;exports.useAudioWaveform=t.useAudioWaveform;exports.useChat=t.useChat;exports.useChatToggle=t.useChatToggle;exports.useConnectionQualityIndicator=t.useConnectionQualityIndicator;exports.useConnectionState=t.useConnectionState;exports.useCreateLayoutContext=t.useCreateLayoutContext;exports.useDisconnectButton=t.useDisconnectButton;exports.useEnsureCreateLayoutContext=t.useEnsureCreateLayoutContext;exports.useEnsureLayoutContext=t.useEnsureLayoutContext;exports.useEnsureParticipant=t.useEnsureParticipant;exports.useEnsureTrackRef=t.useEnsureTrackRef;exports.useFacingMode=t.useFacingMode;exports.useFocusToggle=t.useFocusToggle;exports.useGridLayout=t.useGridLayout;exports.useIsEncrypted=t.useIsEncrypted;exports.useIsMuted=t.useIsMuted;exports.useIsSpeaking=t.useIsSpeaking;exports.useLayoutContext=t.useLayoutContext;exports.useLocalParticipantPermissions=t.useLocalParticipantPermissions;exports.useMaybeLayoutContext=t.useMaybeLayoutContext;exports.useMaybeParticipantContext=t.useMaybeParticipantContext;exports.useMaybeTrackRefContext=t.useMaybeTrackRefContext;exports.useMediaDeviceSelect=t.useMediaDeviceSelect;exports.useMediaDevices=t.useMediaDevices;exports.useMultibandTrackVolume=t.useMultibandTrackVolume;exports.usePagination=t.usePagination;exports.useParticipantContext=t.useParticipantContext;exports.useParticipantTile=t.useParticipantTile;exports.usePersistentUserChoices=t.usePersistentUserChoices;exports.usePinnedTracks=t.usePinnedTracks;exports.useStartAudio=t.useStartAudio;exports.useStartVideo=t.useStartVideo;exports.useSwipe=t.useSwipe;exports.useTrackMutedIndicator=t.useTrackMutedIndicator;exports.useTrackRefContext=t.useTrackRefContext;exports.useTrackToggle=t.useTrackToggle;exports.useTrackVolume=t.useTrackVolume;exports.useTracks=t.useTracks;exports.useVisualStableUpdate=t.useVisualStableUpdate;exports.RoomContext=u.RoomContext;exports.isTrackReference=u.isTrackReference;exports.setLogExtension=u.setLogExtension;exports.setLogLevel=u.setLogLevel;exports.useEnsureRoom=u.useEnsureRoom;exports.useLocalParticipant=u.useLocalParticipant;exports.useMaybeRoomContext=u.useMaybeRoomContext;exports.useRoomContext=u.useRoomContext;exports.AudioConference=e.AudioConference;exports.AudioTrack=e.AudioTrack;exports.BarVisualizer=e.BarVisualizer;exports.CameraDisabledIcon=e.SvgCameraDisabledIcon;exports.CameraIcon=e.SvgCameraIcon;exports.CarouselLayout=e.CarouselLayout;exports.Chat=e.Chat;exports.ChatCloseIcon=e.SvgChatCloseIcon;exports.ChatEntry=e.ChatEntry;exports.ChatIcon=e.SvgChatIcon;exports.ChatToggle=e.ChatToggle;exports.Chevron=e.SvgChevron;exports.ConnectionQualityIndicator=e.ConnectionQualityIndicator;exports.ConnectionStateToast=e.ConnectionStateToast;exports.ControlBar=e.ControlBar;exports.DisconnectButton=e.DisconnectButton;exports.FocusLayout=e.FocusLayout;exports.FocusLayoutContainer=e.FocusLayoutContainer;exports.FocusToggle=e.FocusToggle;exports.FocusToggleIcon=e.SvgFocusToggleIcon;exports.GearIcon=e.SvgGearIcon;exports.GridLayout=e.GridLayout;exports.LKFeatureContext=e.LKFeatureContext;exports.LayoutContextProvider=e.LayoutContextProvider;exports.LeaveIcon=e.SvgLeaveIcon;exports.LockLockedIcon=e.SvgLockLockedIcon;exports.MediaDeviceMenu=e.MediaDeviceMenu;exports.MediaDeviceSelect=e.MediaDeviceSelect;exports.MicDisabledIcon=e.SvgMicDisabledIcon;exports.MicIcon=e.SvgMicIcon;exports.ParticipantAudioTile=e.ParticipantAudioTile;exports.ParticipantContextIfNeeded=e.ParticipantContextIfNeeded;exports.ParticipantName=e.ParticipantName;exports.ParticipantPlaceholder=e.SvgParticipantPlaceholder;exports.ParticipantTile=e.ParticipantTile;exports.PreJoin=e.PreJoin;exports.QualityExcellentIcon=e.SvgQualityExcellentIcon;exports.QualityGoodIcon=e.SvgQualityGoodIcon;exports.QualityPoorIcon=e.SvgQualityPoorIcon;exports.QualityUnknownIcon=e.SvgQualityUnknownIcon;exports.RoomAudioRenderer=e.RoomAudioRenderer;exports.ScreenShareIcon=e.SvgScreenShareIcon;exports.ScreenShareStopIcon=e.SvgScreenShareStopIcon;exports.SpinnerIcon=e.SvgSpinnerIcon;exports.StartMediaButton=e.StartMediaButton;exports.Toast=e.Toast;exports.TrackLoop=e.TrackLoop;exports.TrackMutedIndicator=e.TrackMutedIndicator;exports.TrackRefContextIfNeeded=e.TrackRefContextIfNeeded;exports.TrackToggle=e.TrackToggle;exports.UnfocusToggleIcon=e.SvgUnfocusToggleIcon;exports.VideoConference=e.VideoConference;exports.VideoTrack=e.VideoTrack;exports.VoiceAssistantControlBar=e.VoiceAssistantControlBar;exports.formatChatMessageLinks=e.formatChatMessageLinks;exports.useFeatureContext=e.useFeatureContext;exports.usePreviewDevice=e.usePreviewDevice;exports.usePreviewTracks=e.usePreviewTracks;exports.AudioVisualizer=k;exports.ClearPinButton=v;exports.ConnectionState=T;exports.LiveKitRoom=f;exports.ParticipantLoop=y;exports.RoomName=I;exports.SessionProvider=x;exports.StartAudio=p; | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("./shared-BGiZtWPs.js"),t=require("./shared-I8hFcrmp.js"),u=require("./shared-CVy2Ouqp.js"),e=require("./shared-DsGkPi0_.js"),m=require("react");function P(i){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(i){for(const s in i)if(s!=="default"){const r=Object.getOwnPropertyDescriptor(i,s);Object.defineProperty(a,s,r.get?r:{enumerable:!0,get:()=>i[s]})}}return a.default=i,Object.freeze(a)}const n=P(m),v=n.forwardRef(function(a,s){const{buttonProps:r}=o.useClearPinButton(a);return n.createElement("button",{ref:s,...r},a.children)}),T=n.forwardRef(function({room:a,...s},r){const c=t.useConnectionState(a);return n.createElement("div",{ref:r,...s},c)}),p=n.forwardRef(function({label:a="Allow Audio",...s},r){const c=u.useEnsureRoom(s.room),{mergedProps:l}=t.useStartAudio({room:c,props:s});return n.createElement("button",{ref:r,...l},a)}),f=n.forwardRef(function(a,s){const{room:r,htmlProps:c}=o.useLiveKitRoom(a);return n.createElement("div",{ref:s,...c},r&&n.createElement(u.RoomContext.Provider,{value:r},n.createElement(e.LKFeatureContext.Provider,{value:a.featureFlags},a.children)))}),k=n.forwardRef(function({trackRef:a,...s},r){const g=t.useEnsureTrackRef(a),S=t.useMultibandTrackVolume(g,{bands:7,loPass:300});return n.createElement("svg",{ref:r,width:"100%",height:"100%",viewBox:"0 0 200 90",...s,className:"lk-audio-visualizer"},n.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%"}),n.createElement("g",{style:{transform:`translate(${130/2}px, 0)`}},S.map((d,C)=>n.createElement("rect",{key:C,x:C*10,y:90/2-d*50/2,width:6,height:d*50}))))});function y({participants:i,...a}){return n.createElement(n.Fragment,null,i.map(s=>n.createElement(t.ParticipantContext.Provider,{value:s,key:s.identity},t.cloneSingleChild(a.children))))}const I=n.forwardRef(function({childrenPosition:a="before",children:s,...r},c){const{name:l}=o.useRoomInfo();return n.createElement("span",{ref:c,...r},a==="before"&&s,l,a==="after"&&s)});function x(i){return n.createElement(o.SessionContext.Provider,{value:i.session},n.createElement(u.RoomContext.Provider,{value:i.session.room},i.children))}exports.AgentEvent=o.AgentEvent;exports.MessagesEvent=o.MessagesEvent;exports.SessionEvent=o.SessionEvent;exports.useAgent=o.useAgent;exports.useAudioPlayback=o.useAudioPlayback;exports.useClearPinButton=o.useClearPinButton;exports.useDataChannel=o.useDataChannel;exports.useEnsureSession=o.useEnsureSession;exports.useEvents=o.useEvents;exports.useIsRecording=o.useIsRecording;exports.useLiveKitRoom=o.useLiveKitRoom;exports.useMaybeSessionContext=o.useMaybeSessionContext;exports.useParticipantAttribute=o.useParticipantAttribute;exports.useParticipantAttributes=o.useParticipantAttributes;exports.useParticipantInfo=o.useParticipantInfo;exports.useParticipantPermissions=o.useParticipantPermissions;exports.useParticipantTracks=o.useParticipantTracks;exports.useParticipants=o.useParticipants;exports.useRemoteParticipant=o.useRemoteParticipant;exports.useRemoteParticipants=o.useRemoteParticipants;exports.useRoomInfo=o.useRoomInfo;exports.useSequentialRoomConnectDisconnect=o.useSequentialRoomConnectDisconnect;exports.useSession=o.useSession;exports.useSessionContext=o.useSessionContext;exports.useSessionMessages=o.useSessionMessages;exports.useSortedParticipants=o.useSortedParticipants;exports.useSpeakingParticipants=o.useSpeakingParticipants;exports.useTextStream=o.useTextStream;exports.useToken=o.useToken;exports.useTrackByName=o.useTrackByName;exports.useTrackTranscription=o.useTrackTranscription;exports.useTranscriptions=o.useTranscriptions;exports.useVoiceAssistant=o.useVoiceAssistant;exports.LayoutContext=t.LayoutContext;exports.ParticipantContext=t.ParticipantContext;exports.TrackRefContext=t.TrackRefContext;exports.useAudioWaveform=t.useAudioWaveform;exports.useChat=t.useChat;exports.useChatToggle=t.useChatToggle;exports.useConnectionQualityIndicator=t.useConnectionQualityIndicator;exports.useConnectionState=t.useConnectionState;exports.useCreateLayoutContext=t.useCreateLayoutContext;exports.useDisconnectButton=t.useDisconnectButton;exports.useEnsureCreateLayoutContext=t.useEnsureCreateLayoutContext;exports.useEnsureLayoutContext=t.useEnsureLayoutContext;exports.useEnsureParticipant=t.useEnsureParticipant;exports.useEnsureTrackRef=t.useEnsureTrackRef;exports.useFacingMode=t.useFacingMode;exports.useFocusToggle=t.useFocusToggle;exports.useGridLayout=t.useGridLayout;exports.useIsEncrypted=t.useIsEncrypted;exports.useIsMuted=t.useIsMuted;exports.useIsSpeaking=t.useIsSpeaking;exports.useLayoutContext=t.useLayoutContext;exports.useLocalParticipantPermissions=t.useLocalParticipantPermissions;exports.useMaybeLayoutContext=t.useMaybeLayoutContext;exports.useMaybeParticipantContext=t.useMaybeParticipantContext;exports.useMaybeTrackRefContext=t.useMaybeTrackRefContext;exports.useMediaDeviceSelect=t.useMediaDeviceSelect;exports.useMediaDevices=t.useMediaDevices;exports.useMultibandTrackVolume=t.useMultibandTrackVolume;exports.usePagination=t.usePagination;exports.useParticipantContext=t.useParticipantContext;exports.useParticipantTile=t.useParticipantTile;exports.usePersistentUserChoices=t.usePersistentUserChoices;exports.usePinnedTracks=t.usePinnedTracks;exports.useStartAudio=t.useStartAudio;exports.useStartVideo=t.useStartVideo;exports.useSwipe=t.useSwipe;exports.useTrackMutedIndicator=t.useTrackMutedIndicator;exports.useTrackRefContext=t.useTrackRefContext;exports.useTrackToggle=t.useTrackToggle;exports.useTrackVolume=t.useTrackVolume;exports.useTracks=t.useTracks;exports.useVisualStableUpdate=t.useVisualStableUpdate;exports.RoomContext=u.RoomContext;exports.isTrackReference=u.isTrackReference;exports.setLogExtension=u.setLogExtension;exports.setLogLevel=u.setLogLevel;exports.useEnsureRoom=u.useEnsureRoom;exports.useLocalParticipant=u.useLocalParticipant;exports.useMaybeRoomContext=u.useMaybeRoomContext;exports.useRoomContext=u.useRoomContext;exports.AudioConference=e.AudioConference;exports.AudioTrack=e.AudioTrack;exports.BarVisualizer=e.BarVisualizer;exports.CameraDisabledIcon=e.SvgCameraDisabledIcon;exports.CameraIcon=e.SvgCameraIcon;exports.CarouselLayout=e.CarouselLayout;exports.Chat=e.Chat;exports.ChatCloseIcon=e.SvgChatCloseIcon;exports.ChatEntry=e.ChatEntry;exports.ChatIcon=e.SvgChatIcon;exports.ChatToggle=e.ChatToggle;exports.Chevron=e.SvgChevron;exports.ConnectionQualityIndicator=e.ConnectionQualityIndicator;exports.ConnectionStateToast=e.ConnectionStateToast;exports.ControlBar=e.ControlBar;exports.DisconnectButton=e.DisconnectButton;exports.FocusLayout=e.FocusLayout;exports.FocusLayoutContainer=e.FocusLayoutContainer;exports.FocusToggle=e.FocusToggle;exports.FocusToggleIcon=e.SvgFocusToggleIcon;exports.GearIcon=e.SvgGearIcon;exports.GridLayout=e.GridLayout;exports.LKFeatureContext=e.LKFeatureContext;exports.LayoutContextProvider=e.LayoutContextProvider;exports.LeaveIcon=e.SvgLeaveIcon;exports.LockLockedIcon=e.SvgLockLockedIcon;exports.MediaDeviceMenu=e.MediaDeviceMenu;exports.MediaDeviceSelect=e.MediaDeviceSelect;exports.MicDisabledIcon=e.SvgMicDisabledIcon;exports.MicIcon=e.SvgMicIcon;exports.ParticipantAudioTile=e.ParticipantAudioTile;exports.ParticipantContextIfNeeded=e.ParticipantContextIfNeeded;exports.ParticipantName=e.ParticipantName;exports.ParticipantPlaceholder=e.SvgParticipantPlaceholder;exports.ParticipantTile=e.ParticipantTile;exports.PreJoin=e.PreJoin;exports.QualityExcellentIcon=e.SvgQualityExcellentIcon;exports.QualityGoodIcon=e.SvgQualityGoodIcon;exports.QualityPoorIcon=e.SvgQualityPoorIcon;exports.QualityUnknownIcon=e.SvgQualityUnknownIcon;exports.RoomAudioRenderer=e.RoomAudioRenderer;exports.ScreenShareIcon=e.SvgScreenShareIcon;exports.ScreenShareStopIcon=e.SvgScreenShareStopIcon;exports.SpinnerIcon=e.SvgSpinnerIcon;exports.StartMediaButton=e.StartMediaButton;exports.Toast=e.Toast;exports.TrackLoop=e.TrackLoop;exports.TrackMutedIndicator=e.TrackMutedIndicator;exports.TrackRefContextIfNeeded=e.TrackRefContextIfNeeded;exports.TrackToggle=e.TrackToggle;exports.UnfocusToggleIcon=e.SvgUnfocusToggleIcon;exports.VideoConference=e.VideoConference;exports.VideoTrack=e.VideoTrack;exports.VoiceAssistantControlBar=e.VoiceAssistantControlBar;exports.formatChatMessageLinks=e.formatChatMessageLinks;exports.useFeatureContext=e.useFeatureContext;exports.usePreviewDevice=e.usePreviewDevice;exports.usePreviewTracks=e.usePreviewTracks;exports.AudioVisualizer=k;exports.ClearPinButton=v;exports.ConnectionState=T;exports.LiveKitRoom=f;exports.ParticipantLoop=y;exports.RoomName=I;exports.SessionProvider=x;exports.StartAudio=p; | ||
| //# sourceMappingURL=index.js.map |
+2
-2
@@ -1,6 +0,6 @@ | ||
| import { R as e, a5 as t, a2 as o, S as n, D as i, U as u, w as r, b as c, u as C, i as d, a as l, E as p, c as P, a4 as T, F as k, d as x, n as I, m, G as S, _ as g, H as y, C as L, A as f, e as M, y as R, s as v, o as A, Z as h, Y as E, I as b, J as B, l as D, V, K as F, x as Q, B as w, L as N, M as G, v as U, a1 as K, a3 as z, a6 as j, N as J, O as W, f as q, g as H, p as O, $ as X, P as Y, Q as Z, k as _, h as $, W as aa, T as sa, t as ea, a0 as ta, r as oa, X as na } from "./hooks-yU-srrIO.mjs"; | ||
| import { R as e, a5 as t, a2 as o, S as n, D as i, U as u, w as r, b as c, u as C, i as d, a as l, E as p, c as P, a4 as T, F as k, d as x, n as I, m, G as S, _ as g, H as y, C as L, A as f, e as M, y as R, s as v, o as A, Z as h, Y as E, I as b, J as B, l as D, V, K as F, x as Q, B as w, L as N, M as G, v as U, a1 as K, a3 as z, a6 as j, N as J, O as W, f as q, g as H, p as O, $ as X, P as Y, Q as Z, k as _, h as $, W as aa, T as sa, t as ea, a0 as ta, r as oa, X as na } from "./hooks-0IvkS6LV.mjs"; | ||
| import { L as ua, u as ra } from "./room-Bb6uLxS5.mjs"; | ||
| import { AudioConference as Ca, Chat as da, ControlBar as la, MediaDeviceMenu as pa, PreJoin as Pa, VideoConference as Ta, VoiceAssistantControlBar as ka, usePreviewDevice as xa, usePreviewTracks as Ia } from "./prefabs.mjs"; | ||
| import { L as Sa, af as ga, aj as ya, R as La, ak as fa, a1 as Ma, az as Ra, ay as va, av as Aa, ao as ha, F as Ea, c as ba, u as Ba, ad as Da, i as Va, al as Fa, a as Qa, j as wa, B as Na, w as Ga, ac as Ua, ae as Ka, aA as za, f as ja, aB as Ja, aC as Wa } from "./contexts-CsO1QZ3r.mjs"; | ||
| import { s as Ha, A as Oa, B as Xa, E as Ya, H as Za, g as _a, S as $a, a as as, c as ss, C as es, I as ts, n as os, r as ns, o as is, i as us, D as rs, h as cs, F as Cs, p as ds, J as ls, d as ps, G as Ps, L as Ts, e as ks, K as xs, M as Is, N as ms, O as Ss, k as gs, x as ys, v as Ls, t as fs, b as Ms, P as Rs, Q as vs, U as As, W as hs, X as Es, R as bs, w as Bs, Y as Ds, Z as Vs, z as Fs, _ as Qs, q as ws, f as Ns, l as Gs, j as Us, u as Ks, y as zs, T as js, $ as Js, V as Ws, m as qs } from "./components-DuRBtGp8.mjs"; | ||
| import { s as Ha, A as Oa, B as Xa, E as Ya, H as Za, g as _a, S as $a, a as as, c as ss, C as es, I as ts, n as os, r as ns, o as is, i as us, D as rs, h as cs, F as Cs, p as ds, J as ls, d as ps, G as Ps, L as Ts, e as ks, K as xs, M as Is, N as ms, O as Ss, k as gs, x as ys, v as Ls, t as fs, b as Ms, P as Rs, Q as vs, U as As, W as hs, X as Es, R as bs, w as Bs, Y as Ds, Z as Vs, z as Fs, _ as Qs, q as ws, f as Ns, l as Gs, j as Us, u as Ks, y as zs, T as js, $ as Js, V as Ws, m as qs } from "./components-Cc_gXqiR.mjs"; | ||
| export { | ||
@@ -7,0 +7,0 @@ e as AgentEvent, |
+1
-1
| import * as i from "react"; | ||
| import { LocalAudioTrack as b } from "livekit-client"; | ||
| import { l as f } from "./contexts-CsO1QZ3r.mjs"; | ||
| import { C as h } from "./hooks-yU-srrIO.mjs"; | ||
| import { C as h } from "./hooks-0IvkS6LV.mjs"; | ||
| function K(l = {}) { | ||
@@ -6,0 +6,0 @@ const [o, u] = i.useState(!1), [p, a] = i.useState(!1), [d, n] = i.useState(!1); |
+1
-1
@@ -1,2 +0,2 @@ | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared-BGEsyR2K.js");exports.AudioConference=e.AudioConference;exports.Chat=e.Chat;exports.ControlBar=e.ControlBar;exports.MediaDeviceMenu=e.MediaDeviceMenu;exports.PreJoin=e.PreJoin;exports.VideoConference=e.VideoConference;exports.VoiceAssistantControlBar=e.VoiceAssistantControlBar;exports.usePreviewDevice=e.usePreviewDevice;exports.usePreviewTracks=e.usePreviewTracks; | ||
| "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared-DsGkPi0_.js");exports.AudioConference=e.AudioConference;exports.Chat=e.Chat;exports.ControlBar=e.ControlBar;exports.MediaDeviceMenu=e.MediaDeviceMenu;exports.PreJoin=e.PreJoin;exports.VideoConference=e.VideoConference;exports.VoiceAssistantControlBar=e.VoiceAssistantControlBar;exports.usePreviewDevice=e.usePreviewDevice;exports.usePreviewTracks=e.usePreviewTracks; | ||
| //# sourceMappingURL=prefabs.js.map |
+2
-2
| import * as e from "react"; | ||
| import { c as ie, w as oe, r as ue, m as le, a as G } from "./room-Bb6uLxS5.mjs"; | ||
| import { C as J, S as de, a as me, M as x, b as fe, T as R, c as he, d as pe, D as z, e as ge, f as H, L as Q, G as Ee, P as K, F as Se, g as ve, h as ke, R as be, i as Ce, j as we, k as ye, B as Ie } from "./components-DuRBtGp8.mjs"; | ||
| import { w as Me, x as W, y as Pe, z as Ne, A as X, t as Y, B as Te, C as Le } from "./hooks-yU-srrIO.mjs"; | ||
| import { C as J, S as de, a as me, M as x, b as fe, T as R, c as he, d as pe, D as z, e as ge, f as H, L as Q, G as Ee, P as K, F as Se, g as ve, h as ke, R as be, i as Ce, j as we, k as ye, B as Ie } from "./components-Cc_gXqiR.mjs"; | ||
| import { w as Me, x as W, y as Pe, z as Ne, A as X, t as Y, B as Te, C as Le } from "./hooks-0IvkS6LV.mjs"; | ||
| import { j as Z, as as Ae, at as De, l as N, a as Re, au as Ve, av as Oe, a1 as B, aw as $e, ax as Ue } from "./contexts-CsO1QZ3r.mjs"; | ||
@@ -6,0 +6,0 @@ import { Track as k, facingModeFromLocalTrack as _e, Mutex as Fe, createLocalTracks as xe, createLocalVideoTrack as Be, VideoPresets as We, createLocalAudioTrack as je, RoomEvent as qe } from "livekit-client"; |
+4
-3
| { | ||
| "name": "@livekit/components-react", | ||
| "version": "2.9.17", | ||
| "version": "2.9.18", | ||
| "license": "Apache-2.0", | ||
@@ -50,3 +50,3 @@ "author": "LiveKit", | ||
| "@livekit/krisp-noise-filter": "^0.2.12 || ^0.3.0", | ||
| "livekit-client": "^2.15.14", | ||
| "livekit-client": "^2.16.0", | ||
| "react": ">=18", | ||
@@ -62,3 +62,3 @@ "react-dom": ">=18", | ||
| "devDependencies": { | ||
| "@livekit/protocol": "^1.42.0", | ||
| "@livekit/protocol": "^1.43.4", | ||
| "@microsoft/api-extractor": "^7.35.0", | ||
@@ -75,2 +75,3 @@ "@size-limit/file": "^11.0.2", | ||
| "@vitejs/plugin-react": "^4.3.2", | ||
| "eslint": "^8.56.0", | ||
| "jsdom": "^26.0.0", | ||
@@ -77,0 +78,0 @@ "react": "^18.2.0", |
@@ -115,3 +115,3 @@ import * as React from 'react'; | ||
| ) { | ||
| const elementProps = mergeProps(props, { className: 'lk-audio-bar-visualizer' }); | ||
| const elementProps = mergeProps(props, { className: 'lk-audio-visualizer-bar' }); | ||
| let targetTrack: TrackReferenceOrPlaceholder | LocalAudioTrack | RemoteAudioTrack | undefined = | ||
@@ -118,0 +118,0 @@ useMaybeTrackRefContext(); |
@@ -9,2 +9,3 @@ import { | ||
| Track, | ||
| Participant, | ||
| } from 'livekit-client'; | ||
@@ -20,2 +21,3 @@ import type TypedEventEmitter from 'typed-emitter'; | ||
| import { useMaybeSessionContext } from '../context'; | ||
| import { useParticipantInfo } from './useParticipantInfo'; | ||
@@ -68,3 +70,3 @@ // FIXME: make this 10 seconds once room dispatch booting info is discoverable | ||
| // FIXME: maybe add some sort of schema to this? | ||
| attributes: Record<string, string>; | ||
| attributes: Participant['attributes']; | ||
@@ -83,2 +85,7 @@ internal: { | ||
| /** The agent's assigned identity, coming from the JWT token. */ | ||
| identity: Participant['identity']; | ||
| name: Participant['name']; | ||
| metadata: Participant['metadata']; | ||
| /** Is the agent connected to the client? */ | ||
@@ -109,2 +116,7 @@ isConnected: true; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: Participant['identity']; | ||
| name: Participant['name']; | ||
| metadata: Participant['metadata']; | ||
| /** Is the agent connected to the client? */ | ||
@@ -135,2 +147,7 @@ isConnected: false; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: Participant['identity']; | ||
| name: Participant['name']; | ||
| metadata: Participant['metadata']; | ||
| /** Is the agent connected to the client? */ | ||
@@ -161,2 +178,7 @@ isConnected: false; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: undefined; | ||
| name: undefined; | ||
| metadata: undefined; | ||
| /** Is the agent connected to the client? */ | ||
@@ -187,2 +209,7 @@ isConnected: false; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: undefined; | ||
| name: undefined; | ||
| metadata: undefined; | ||
| /** Is the agent connected to the client? */ | ||
@@ -213,2 +240,7 @@ isConnected: false; | ||
| /** The client's assigned identity, coming from the JWT token. */ | ||
| identity: undefined; | ||
| name: undefined; | ||
| metadata: undefined; | ||
| /** Is the agent connected to the client? */ | ||
@@ -529,4 +561,4 @@ isConnected: false; | ||
| const [agentParticipantAttributes, setAgentParticipantAttributes] = React.useState< | ||
| Record<string, string> | ||
| >({}); | ||
| Participant['attributes'] | ||
| >(agentParticipant?.attributes ?? {}); | ||
| React.useEffect(() => { | ||
@@ -723,2 +755,8 @@ if (!agentParticipant) { | ||
| const { | ||
| identity: agentParticipantIdentity, | ||
| name: agentParticipantName, | ||
| metadata: agentParticipantMetadata, | ||
| } = useParticipantInfo({ participant: agentParticipant ?? undefined }); | ||
| const agentState: AgentStateCases = React.useMemo(() => { | ||
@@ -739,2 +777,5 @@ const common: AgentStateCommon = { | ||
| ...common, | ||
| identity: undefined, | ||
| name: undefined, | ||
| metadata: undefined, | ||
@@ -753,2 +794,5 @@ state, | ||
| ...common, | ||
| identity: undefined, | ||
| name: undefined, | ||
| metadata: undefined, | ||
@@ -768,2 +812,5 @@ state, | ||
| ...common, | ||
| identity: agentParticipantIdentity!, | ||
| name: agentParticipantName, | ||
| metadata: agentParticipantMetadata, | ||
@@ -781,2 +828,5 @@ state, | ||
| ...common, | ||
| identity: agentParticipantIdentity!, | ||
| name: agentParticipantName, | ||
| metadata: agentParticipantMetadata, | ||
@@ -796,2 +846,5 @@ state, | ||
| ...common, | ||
| identity: agentParticipantIdentity!, | ||
| name: agentParticipantName, | ||
| metadata: agentParticipantMetadata, | ||
@@ -809,2 +862,5 @@ state, | ||
| ...common, | ||
| identity: undefined, | ||
| name: undefined, | ||
| metadata: undefined, | ||
@@ -820,3 +876,13 @@ state: 'failed', | ||
| } | ||
| }, [agentParticipantAttributes, emitter, agentParticipant, state, videoTrack, audioTrack]); | ||
| }, [ | ||
| agentParticipantIdentity, | ||
| agentParticipantName, | ||
| agentParticipantMetadata, | ||
| agentParticipantAttributes, | ||
| emitter, | ||
| agentParticipant, | ||
| state, | ||
| videoTrack, | ||
| audioTrack, | ||
| ]); | ||
@@ -823,0 +889,0 @@ const { waitUntilConnected, waitUntilCouldBeListening, waitUntilFinished } = |
+55
-16
@@ -55,2 +55,10 @@ import * as React from 'react'; | ||
| }; | ||
| camera?: { | ||
| enabled?: boolean; | ||
| publishOptions?: TrackPublishOptions; | ||
| }; | ||
| screenShare?: { | ||
| enabled?: boolean; | ||
| publishOptions?: TrackPublishOptions; | ||
| }; | ||
| }; | ||
@@ -92,4 +100,5 @@ | ||
| local: { | ||
| cameraTrack: null; | ||
| microphoneTrack: null; | ||
| cameraTrack: undefined; | ||
| microphoneTrack: undefined; | ||
| screenShareTrack: undefined; | ||
| }; | ||
@@ -106,4 +115,5 @@ }; | ||
| local: { | ||
| cameraTrack: TrackReference | null; | ||
| microphoneTrack: TrackReference | null; | ||
| cameraTrack?: TrackReference; | ||
| microphoneTrack?: TrackReference; | ||
| screenShareTrack?: TrackReference; | ||
| }; | ||
@@ -117,4 +127,5 @@ }; | ||
| local: { | ||
| cameraTrack: null; | ||
| microphoneTrack: null; | ||
| cameraTrack: undefined; | ||
| microphoneTrack: undefined; | ||
| screenShareTrack: undefined; | ||
| }; | ||
@@ -374,4 +385,4 @@ }; | ||
| const localCamera = React.useMemo(() => { | ||
| if (!cameraPublication || cameraPublication.isMuted) { | ||
| return null; | ||
| if (!cameraPublication) { | ||
| return undefined; | ||
| } | ||
@@ -383,7 +394,7 @@ return { | ||
| }; | ||
| }, [localParticipant, cameraPublication, cameraPublication?.isMuted]); | ||
| }, [localParticipant, cameraPublication]); | ||
| const microphonePublication = localParticipant.getTrackPublication(Track.Source.Microphone); | ||
| const localMicrophone = React.useMemo(() => { | ||
| if (!microphonePublication || microphonePublication.isMuted) { | ||
| return null; | ||
| if (!microphonePublication) { | ||
| return undefined; | ||
| } | ||
@@ -395,3 +406,14 @@ return { | ||
| }; | ||
| }, [localParticipant, microphonePublication, microphonePublication?.isMuted]); | ||
| }, [localParticipant, microphonePublication]); | ||
| const screenSharePublication = localParticipant.getTrackPublication(Track.Source.ScreenShare); | ||
| const localScreenShare = React.useMemo(() => { | ||
| if (!screenSharePublication) { | ||
| return undefined; | ||
| } | ||
| return { | ||
| source: Track.Source.ScreenShare, | ||
| participant: localParticipant, | ||
| publication: screenSharePublication, | ||
| }; | ||
| }, [localParticipant, screenSharePublication]); | ||
@@ -451,4 +473,5 @@ const { | ||
| local: { | ||
| cameraTrack: null, | ||
| microphoneTrack: null, | ||
| cameraTrack: undefined, | ||
| microphoneTrack: undefined, | ||
| screenShareTrack: undefined, | ||
| }, | ||
@@ -469,2 +492,3 @@ }; | ||
| microphoneTrack: localMicrophone, | ||
| screenShareTrack: localScreenShare, | ||
| }, | ||
@@ -481,4 +505,5 @@ }; | ||
| local: { | ||
| cameraTrack: null, | ||
| microphoneTrack: null, | ||
| cameraTrack: undefined, | ||
| microphoneTrack: undefined, | ||
| screenShareTrack: undefined, | ||
| }, | ||
@@ -568,2 +593,16 @@ }; | ||
| : Promise.resolve(), | ||
| tracks.camera?.enabled | ||
| ? room.localParticipant.setCameraEnabled( | ||
| true, | ||
| undefined, | ||
| tracks.camera?.publishOptions ?? {}, | ||
| ) | ||
| : Promise.resolve(), | ||
| tracks.screenShare?.enabled | ||
| ? room.localParticipant.setScreenShareEnabled( | ||
| true, | ||
| undefined, | ||
| tracks.screenShare?.publishOptions ?? {}, | ||
| ) | ||
| : Promise.resolve(), | ||
| ]); | ||
@@ -570,0 +609,0 @@ |
@@ -136,12 +136,19 @@ import * as React from 'react'; | ||
| } | ||
| frequencies = frequencies.slice(options.loPass, options.hiPass); | ||
| frequencies = frequencies.slice(opts.loPass, opts.hiPass); | ||
| const normalizedFrequencies = normalizeFrequencies(frequencies); // is this needed ? | ||
| const chunkSize = Math.ceil(normalizedFrequencies.length / opts.bands); // we want logarithmic chunking here | ||
| const totalBins = normalizedFrequencies.length; | ||
| const chunks: Array<number> = []; | ||
| for (let i = 0; i < opts.bands; i++) { | ||
| const summedVolumes = normalizedFrequencies | ||
| .slice(i * chunkSize, (i + 1) * chunkSize) | ||
| .reduce((acc, val) => (acc += val), 0); | ||
| chunks.push(summedVolumes / chunkSize); | ||
| // Use proportional distribution to evenly divide bins across bands | ||
| const startIndex = Math.floor((i * totalBins) / opts.bands); | ||
| const endIndex = Math.floor(((i + 1) * totalBins) / opts.bands); | ||
| const chunk = normalizedFrequencies.slice(startIndex, endIndex); | ||
| const chunkLength = chunk.length; | ||
| if (chunkLength === 0) { | ||
| chunks.push(0); | ||
| } else { | ||
| const summedVolumes = chunk.reduce((acc, val) => (acc += val), 0); | ||
| chunks.push(summedVolumes / chunkLength); | ||
| } | ||
| } | ||
@@ -148,0 +155,0 @@ |
| import * as e from "react"; | ||
| import { useState as B, useRef as z, useEffect as V, useMemo as Ne } from "react"; | ||
| import { u as Le, a as he, b as ze, c as Ve, d as Fe, e as Ze, f as ge, g as He, h as Be, i as je, j as _e, k as Oe, l as ve, m as We, n as qe, o as $e, p as De, q as Ue, r as Ge, s as Ee, t as Qe, v as Xe } from "./hooks-yU-srrIO.mjs"; | ||
| import { a as I, c as ee } from "./room-Bb6uLxS5.mjs"; | ||
| import { RoomEvent as Ye, Track as S, ConnectionQuality as Q, RemoteTrackPublication as J, RemoteAudioTrack as Je, ConnectionState as X } from "livekit-client"; | ||
| import { ae as te, af as pe, w as Ke, u as et, f as tt, c as at, ag as nt, X as rt, Y as ct, a1 as $, l as j, ah as q, ai as lt, i as _, B as st, aj as we, ak as ae, j as it, al as ot, m as ut, p as ke, am as dt, an as mt, ao as ft, ap as ht, aq as gt, ar as vt, R as Et } from "./contexts-CsO1QZ3r.mjs"; | ||
| const ca = /* @__PURE__ */ e.forwardRef( | ||
| function(n, a) { | ||
| const { buttonProps: c } = Le(n); | ||
| return /* @__PURE__ */ e.createElement("button", { ref: a, ...c }, n.children); | ||
| } | ||
| ), la = /* @__PURE__ */ e.forwardRef( | ||
| function({ room: n, ...a }, c) { | ||
| const r = he(n); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: c, ...a }, r); | ||
| } | ||
| ), sa = /* @__PURE__ */ e.forwardRef( | ||
| function(n, a) { | ||
| const { mergedProps: c } = ze({ props: n }); | ||
| return /* @__PURE__ */ e.createElement("button", { ref: a, ...c }, n.children); | ||
| } | ||
| ), ia = /* @__PURE__ */ e.forwardRef( | ||
| function(n, a) { | ||
| const { buttonProps: c } = Ve(n); | ||
| return /* @__PURE__ */ e.createElement("button", { ref: a, ...c }, n.children); | ||
| } | ||
| ), pt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708L11 10.293V4.5A1.5 1.5 0 0 0 9.5 3H3.707zM0 4.5a1.5 1.5 0 0 1 .943-1.393l9.532 9.533c-.262.224-.603.36-.975.36h-8A1.5 1.5 0 0 1 0 11.5z" }), /* @__PURE__ */ e.createElement("path", { d: "m15.2 3.6-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z" })), wt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M0 4.5A1.5 1.5 0 0 1 1.5 3h8A1.5 1.5 0 0 1 11 4.5v7A1.5 1.5 0 0 1 9.5 13h-8A1.5 1.5 0 0 1 0 11.5zM15.2 3.6l-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z" })), oa = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, viewBox: "0 0 24 24", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "#FFF", | ||
| d: "M4.99 3.99a1 1 0 0 0-.697 1.717L10.586 12l-6.293 6.293a1 1 0 1 0 1.414 1.414L12 13.414l6.293 6.293a1 1 0 1 0 1.414-1.414L13.414 12l6.293-6.293a1 1 0 0 0-.727-1.717 1 1 0 0 0-.687.303L12 10.586 5.707 4.293a1 1 0 0 0-.717-.303z" | ||
| } | ||
| )), ua = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 18, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M0 2.75A2.75 2.75 0 0 1 2.75 0h10.5A2.75 2.75 0 0 1 16 2.75v13.594a.75.75 0 0 1-1.234.572l-3.691-3.12a1.25 1.25 0 0 0-.807-.296H2.75A2.75 2.75 0 0 1 0 10.75v-8ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v8c0 .69.56 1.25 1.25 1.25h7.518c.65 0 1.279.23 1.775.65l2.457 2.077V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M3 4.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), ie = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentcolor", | ||
| fillRule: "evenodd", | ||
| d: "M5.293 2.293a1 1 0 0 1 1.414 0l4.823 4.823a1.25 1.25 0 0 1 0 1.768l-4.823 4.823a1 1 0 0 1-1.414-1.414L9.586 8 5.293 3.707a1 1 0 0 1 0-1.414z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), kt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement("g", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5 }, /* @__PURE__ */ e.createElement("path", { d: "M10 1.75h4.25m0 0V6m0-4.25L9 7M6 14.25H1.75m0 0V10m0 4.25L7 9" }))), da = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentcolor", | ||
| fillRule: "evenodd", | ||
| d: "M8.961.894C8.875-.298 7.125-.298 7.04.894c-.066.912-1.246 1.228-1.76.472-.67-.99-2.186-.115-1.664.96.399.824-.465 1.688-1.288 1.289-1.076-.522-1.95.994-.961 1.665.756.513.44 1.693-.472 1.759-1.192.086-1.192 1.836 0 1.922.912.066 1.228 1.246.472 1.76-.99.67-.115 2.186.96 1.664.824-.399 1.688.465 1.289 1.288-.522 1.076.994 1.95 1.665.961.513-.756 1.693-.44 1.759.472.086 1.192 1.836 1.192 1.922 0 .066-.912 1.246-1.228 1.76-.472.67.99 2.186.115 1.664-.96-.399-.824.465-1.688 1.288-1.289 1.076.522 1.95-.994.961-1.665-.756-.513-.44-1.693.472-1.759 1.192-.086 1.192-1.836 0-1.922-.912-.066-1.228-1.246-.472-1.76.99-.67.115-2.186-.96-1.664-.824.399-1.688-.465-1.289-1.288.522-1.076-.994-1.95-1.665-.961-.513.756-1.693.44-1.759-.472ZM8 13A5 5 0 1 0 8 3a5 5 0 0 0 0 10Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), ma = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M2 2.75A2.75 2.75 0 0 1 4.75 0h6.5A2.75 2.75 0 0 1 14 2.75v10.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-.5a.75.75 0 0 1 1.5 0v.5c0 .69.56 1.25 1.25 1.25h6.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25h-6.5c-.69 0-1.25.56-1.25 1.25v.5a.75.75 0 0 1-1.5 0v-.5Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M8.78 7.47a.75.75 0 0 1 0 1.06l-2.25 2.25a.75.75 0 1 1-1.06-1.06l.97-.97H1.75a.75.75 0 0 1 0-1.5h4.69l-.97-.97a.75.75 0 0 1 1.06-1.06l2.25 2.25Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), Rt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentcolor", | ||
| fillRule: "evenodd", | ||
| d: "M4 6.104V4a4 4 0 1 1 8 0v2.104c1.154.326 2 1.387 2 2.646v4.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-4.5c0-1.259.846-2.32 2-2.646ZM5.5 4a2.5 2.5 0 0 1 5 0v2h-5V4Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), Mt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M12.227 11.52a5.477 5.477 0 0 0 1.246-2.97.5.5 0 0 0-.995-.1 4.478 4.478 0 0 1-.962 2.359l-1.07-1.07C10.794 9.247 11 8.647 11 8V3a3 3 0 0 0-6 0v1.293L1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708zM8 12.5c.683 0 1.33-.152 1.911-.425l.743.743c-.649.359-1.378.59-2.154.66V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .995-.098A4.5 4.5 0 0 0 8 12.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M8.743 10.907 5 7.164V8a3 3 0 0 0 3.743 2.907z" })), yt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fillRule: "evenodd", | ||
| d: "M2.975 8.002a.5.5 0 0 1 .547.449 4.5 4.5 0 0 0 8.956 0 .5.5 0 1 1 .995.098A5.502 5.502 0 0 1 8.5 13.478V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .448-.547z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement("path", { d: "M5 3a3 3 0 1 1 6 0v5a3 3 0 0 1-6 0z" })), bt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentcolor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" })), St = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentcolor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("g", { opacity: 0.25 }, /* @__PURE__ */ e.createElement("path", { d: "M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }))), Ct = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentcolor", ...t }, /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("g", { opacity: 0.25 }, /* @__PURE__ */ e.createElement("path", { d: "M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }), /* @__PURE__ */ e.createElement("path", { d: "M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z" }))), It = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "currentColor", ...t }, /* @__PURE__ */ e.createElement("g", { opacity: 0.25 }, /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z" }), /* @__PURE__ */ e.createElement("path", { d: "M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z" }))), Re = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M0 2.75A2.75 2.75 0 0 1 2.75 0h14.5A2.75 2.75 0 0 1 20 2.75v10.5A2.75 2.75 0 0 1 17.25 16H2.75A2.75 2.75 0 0 1 0 13.25V2.75ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h14.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M9.47 4.22a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1-1.06 1.06l-.97-.97v4.69a.75.75 0 0 1-1.5 0V6.56l-.97.97a.75.75 0 0 1-1.06-1.06l2.25-2.25Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| )), xt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 20, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement("g", { fill: "currentColor" }, /* @__PURE__ */ e.createElement("path", { d: "M7.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L10 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L11.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L10 6.94z" }), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fillRule: "evenodd", | ||
| d: "M2.75 0A2.75 2.75 0 0 0 0 2.75v10.5A2.75 2.75 0 0 0 2.75 16h14.5A2.75 2.75 0 0 0 20 13.25V2.75A2.75 2.75 0 0 0 17.25 0zM1.5 2.75c0-.69.56-1.25 1.25-1.25h14.5c.69 0 1.25.56 1.25 1.25v10.5c0 .69-.56 1.25-1.25 1.25H2.75c-.69 0-1.25-.56-1.25-1.25z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ))), oe = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M8 0a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0V.75A.75.75 0 0 1 8 0Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M8 12a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5A.75.75 0 0 1 8 12Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.7 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M12 1.072a.75.75 0 0 1 .274 1.024l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 12 1.072Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M6 11.464a.75.75 0 0 1 .274 1.025l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 6 11.464Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.6 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M14.928 4a.75.75 0 0 1-.274 1.025l-2.165 1.25a.75.75 0 1 1-.75-1.3l2.165-1.25A.75.75 0 0 1 14.928 4Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M4.536 10a.75.75 0 0 1-.275 1.024l-2.165 1.25a.75.75 0 0 1-.75-1.298l2.165-1.25A.75.75 0 0 1 4.536 10Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.5 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M16 8a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 16 8Z", | ||
| clipRule: "evenodd" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M4 8a.75.75 0 0 1-.75.75H.75a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 4 8Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.4 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M14.928 12a.75.75 0 0 1-1.024.274l-2.165-1.25a.75.75 0 0 1 .75-1.299l2.165 1.25A.75.75 0 0 1 14.928 12Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.9 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M4.536 6a.75.75 0 0 1-1.025.275l-2.165-1.25a.75.75 0 1 1 .75-1.3l2.165 1.25A.75.75 0 0 1 4.536 6Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.3 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M12 14.928a.75.75 0 0 1-1.024-.274l-1.25-2.165a.75.75 0 0 1 1.298-.75l1.25 2.165A.75.75 0 0 1 12 14.928Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.8 | ||
| } | ||
| ), /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| fill: "currentColor", | ||
| fillRule: "evenodd", | ||
| d: "M6 4.536a.75.75 0 0 1-1.024-.275l-1.25-2.165a.75.75 0 1 1 1.299-.75l1.25 2.165A.75.75 0 0 1 6 4.536Z", | ||
| clipRule: "evenodd", | ||
| opacity: 0.2 | ||
| } | ||
| )), Pt = (t) => /* @__PURE__ */ e.createElement("svg", { xmlns: "http://www.w3.org/2000/svg", width: 16, height: 16, fill: "none", ...t }, /* @__PURE__ */ e.createElement("g", { stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 1.5 }, /* @__PURE__ */ e.createElement("path", { d: "M13.25 7H9m0 0V2.75M9 7l5.25-5.25M2.75 9H7m0 0v4.25M7 9l-5.25 5.25" }))), Tt = /* @__PURE__ */ e.forwardRef( | ||
| function({ trackRef: n, ...a }, c) { | ||
| const r = te(), { mergedProps: s, inFocus: o } = Fe({ | ||
| trackRef: n ?? r, | ||
| props: a | ||
| }); | ||
| return /* @__PURE__ */ e.createElement(pe.Consumer, null, (l) => l !== void 0 && /* @__PURE__ */ e.createElement("button", { ref: c, ...s }, a.children ? a.children : o ? /* @__PURE__ */ e.createElement(Pt, null) : /* @__PURE__ */ e.createElement(kt, null))); | ||
| } | ||
| ), fa = /* @__PURE__ */ e.forwardRef( | ||
| function({ | ||
| kind: n, | ||
| initialSelection: a, | ||
| onActiveDeviceChange: c, | ||
| onDeviceListChange: r, | ||
| onDeviceSelectError: s, | ||
| exactMatch: o, | ||
| track: l, | ||
| requestPermissions: i, | ||
| onError: d, | ||
| ...u | ||
| }, v) { | ||
| const f = Ke(), p = e.useRef("default"), E = e.useCallback( | ||
| (w) => { | ||
| f && f.emit(Ye.MediaDevicesError, w), d == null || d(w); | ||
| }, | ||
| [f, d] | ||
| ), { devices: h, activeDeviceId: m, setActiveMediaDevice: y, className: C } = Ze({ | ||
| kind: n, | ||
| room: f, | ||
| track: l, | ||
| requestPermissions: i, | ||
| onError: E | ||
| }); | ||
| e.useEffect(() => { | ||
| a !== void 0 && y(a); | ||
| }, [y]), e.useEffect(() => { | ||
| typeof r == "function" && r(h); | ||
| }, [r, h]), e.useEffect(() => { | ||
| m !== p.current && (c == null || c(m)), p.current = m; | ||
| }, [m]); | ||
| const A = async (w) => { | ||
| try { | ||
| await y(w, { exact: o ?? !0 }); | ||
| } catch (M) { | ||
| if (M instanceof Error) | ||
| s == null || s(M); | ||
| else | ||
| throw M; | ||
| } | ||
| }, N = e.useMemo( | ||
| () => I(u, { className: C }, { className: "lk-list" }), | ||
| [C, u] | ||
| ), g = !!h.find((w) => w.label.toLowerCase().startsWith("default")); | ||
| function R(w, M, P) { | ||
| return w === M || !g && P === 0 && M === "default"; | ||
| } | ||
| return /* @__PURE__ */ e.createElement("ul", { ref: v, ...N }, h.map((w, M) => /* @__PURE__ */ e.createElement( | ||
| "li", | ||
| { | ||
| key: w.deviceId, | ||
| id: w.deviceId, | ||
| "data-lk-active": R(w.deviceId, m, M), | ||
| "aria-selected": R(w.deviceId, m, M), | ||
| role: "option" | ||
| }, | ||
| /* @__PURE__ */ e.createElement("button", { className: "lk-button", onClick: () => A(w.deviceId) }, w.label) | ||
| ))); | ||
| } | ||
| ), ha = /* @__PURE__ */ e.forwardRef( | ||
| function({ label: n = "Allow Audio", ...a }, c) { | ||
| const r = et(a.room), { mergedProps: s } = ge({ room: r, props: a }); | ||
| return /* @__PURE__ */ e.createElement("button", { ref: c, ...s }, n); | ||
| } | ||
| ), ga = /* @__PURE__ */ e.forwardRef( | ||
| function({ label: n, ...a }, c) { | ||
| const r = tt(), { mergedProps: s, canPlayAudio: o } = ge({ room: r, props: a }), { mergedProps: l, canPlayVideo: i } = He({ room: r, props: s }), { style: d, ...u } = l; | ||
| return d.display = o && i ? "none" : "block", /* @__PURE__ */ e.createElement("button", { ref: c, style: d, ...u }, n ?? `Start ${o ? "Video" : "Audio"}`); | ||
| } | ||
| ); | ||
| function Me(t, n) { | ||
| switch (t) { | ||
| case S.Source.Microphone: | ||
| return n ? /* @__PURE__ */ e.createElement(yt, null) : /* @__PURE__ */ e.createElement(Mt, null); | ||
| case S.Source.Camera: | ||
| return n ? /* @__PURE__ */ e.createElement(wt, null) : /* @__PURE__ */ e.createElement(pt, null); | ||
| case S.Source.ScreenShare: | ||
| return n ? /* @__PURE__ */ e.createElement(xt, null) : /* @__PURE__ */ e.createElement(Re, null); | ||
| default: | ||
| return; | ||
| } | ||
| } | ||
| function At(t) { | ||
| switch (t) { | ||
| case Q.Excellent: | ||
| return /* @__PURE__ */ e.createElement(bt, null); | ||
| case Q.Good: | ||
| return /* @__PURE__ */ e.createElement(St, null); | ||
| case Q.Poor: | ||
| return /* @__PURE__ */ e.createElement(Ct, null); | ||
| default: | ||
| return /* @__PURE__ */ e.createElement(It, null); | ||
| } | ||
| } | ||
| const va = /* @__PURE__ */ e.forwardRef(function({ showIcon: n, ...a }, c) { | ||
| const { buttonProps: r, enabled: s } = Be(a), [o, l] = e.useState(!1); | ||
| return e.useEffect(() => { | ||
| l(!0); | ||
| }, []), o && /* @__PURE__ */ e.createElement("button", { ref: c, ...r }, (n ?? !0) && Me(a.source, s), a.children); | ||
| }), ye = /* @__PURE__ */ e.forwardRef(function(n, a) { | ||
| const { className: c, quality: r } = je(n), s = e.useMemo(() => ({ ...I(n, { className: c }), "data-lk-quality": r }), [r, n, c]); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: a, ...s }, n.children ?? At(r)); | ||
| }), K = /* @__PURE__ */ e.forwardRef( | ||
| function({ participant: n, ...a }, c) { | ||
| const r = at(n), { className: s, infoObserver: o } = e.useMemo(() => nt(r), [r]), { identity: l, name: i } = _e(o, { | ||
| name: r.name, | ||
| identity: r.identity, | ||
| metadata: r.metadata | ||
| }), d = e.useMemo(() => I(a, { className: s, "data-lk-participant-name": i }), [a, s, i]); | ||
| return /* @__PURE__ */ e.createElement("span", { ref: c, ...d }, i !== "" ? i : l, a.children); | ||
| } | ||
| ), be = /* @__PURE__ */ e.forwardRef( | ||
| function({ trackRef: n, show: a = "always", ...c }, r) { | ||
| const { className: s, isMuted: o } = Oe(n), l = a === "always" || a === "muted" && o || a === "unmuted" && !o, i = e.useMemo( | ||
| () => I(c, { | ||
| className: s | ||
| }), | ||
| [s, c] | ||
| ); | ||
| return l ? /* @__PURE__ */ e.createElement("div", { ref: r, ...i, "data-lk-muted": o }, c.children ?? Me(n.source, !o)) : null; | ||
| } | ||
| ), Nt = (t) => /* @__PURE__ */ e.createElement( | ||
| "svg", | ||
| { | ||
| width: 320, | ||
| height: 320, | ||
| viewBox: "0 0 320 320", | ||
| preserveAspectRatio: "xMidYMid meet", | ||
| fill: "none", | ||
| xmlns: "http://www.w3.org/2000/svg", | ||
| ...t | ||
| }, | ||
| /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| d: "M160 180C204.182 180 240 144.183 240 100C240 55.8172 204.182 20 160 20C115.817 20 79.9997 55.8172 79.9997 100C79.9997 144.183 115.817 180 160 180Z", | ||
| fill: "white", | ||
| fillOpacity: 0.25 | ||
| } | ||
| ), | ||
| /* @__PURE__ */ e.createElement( | ||
| "path", | ||
| { | ||
| d: "M97.6542 194.614C103.267 191.818 109.841 192.481 115.519 195.141C129.025 201.466 144.1 205 159.999 205C175.899 205 190.973 201.466 204.48 195.141C210.158 192.481 216.732 191.818 222.345 194.614C262.703 214.719 291.985 253.736 298.591 300.062C300.15 310.997 291.045 320 280 320H39.9997C28.954 320 19.8495 310.997 21.4087 300.062C28.014 253.736 57.2966 214.72 97.6542 194.614Z", | ||
| fill: "white", | ||
| fillOpacity: 0.25 | ||
| } | ||
| ) | ||
| ); | ||
| function Se(t, n = {}) { | ||
| const [a, c] = e.useState(rt(t)), [r, s] = e.useState(a == null ? void 0 : a.isMuted), [o, l] = e.useState(a == null ? void 0 : a.isSubscribed), [i, d] = e.useState(a == null ? void 0 : a.track), [u, v] = e.useState("landscape"), f = e.useRef(), { className: p, trackObserver: E } = e.useMemo(() => ct(t), [ | ||
| t.participant.sid ?? t.participant.identity, | ||
| t.source, | ||
| $(t) && t.publication.trackSid | ||
| ]); | ||
| return e.useEffect(() => { | ||
| const h = E.subscribe((m) => { | ||
| j.debug("update track", m), c(m), s(m == null ? void 0 : m.isMuted), l(m == null ? void 0 : m.isSubscribed), d(m == null ? void 0 : m.track); | ||
| }); | ||
| return () => h == null ? void 0 : h.unsubscribe(); | ||
| }, [E]), e.useEffect(() => { | ||
| var h, m; | ||
| return i && (f.current && i.detach(f.current), (h = n.element) != null && h.current && !(t.participant.isLocal && (i == null ? void 0 : i.kind) === "audio") && i.attach(n.element.current)), f.current = (m = n.element) == null ? void 0 : m.current, () => { | ||
| f.current && (i == null || i.detach(f.current)); | ||
| }; | ||
| }, [i, n.element]), e.useEffect(() => { | ||
| var h, m; | ||
| if (typeof ((h = a == null ? void 0 : a.dimensions) == null ? void 0 : h.width) == "number" && typeof ((m = a == null ? void 0 : a.dimensions) == null ? void 0 : m.height) == "number") { | ||
| const y = a.dimensions.width > a.dimensions.height ? "landscape" : "portrait"; | ||
| v(y); | ||
| } | ||
| }, [a]), { | ||
| publication: a, | ||
| isMuted: r, | ||
| isSubscribed: o, | ||
| track: i, | ||
| elementProps: I(n.props, { | ||
| className: p, | ||
| "data-lk-local-participant": t.participant.isLocal, | ||
| "data-lk-source": a == null ? void 0 : a.source, | ||
| ...(a == null ? void 0 : a.kind) === "video" && { "data-lk-orientation": u } | ||
| }) | ||
| }; | ||
| } | ||
| var Y, ue; | ||
| function Lt() { | ||
| if (ue) return Y; | ||
| ue = 1; | ||
| var t = "Expected a function", n = NaN, a = "[object Symbol]", c = /^\s+|\s+$/g, r = /^[-+]0x[0-9a-f]+$/i, s = /^0b[01]+$/i, o = /^0o[0-7]+$/i, l = parseInt, i = typeof q == "object" && q && q.Object === Object && q, d = typeof self == "object" && self && self.Object === Object && self, u = i || d || Function("return this")(), v = Object.prototype, f = v.toString, p = Math.max, E = Math.min, h = function() { | ||
| return u.Date.now(); | ||
| }; | ||
| function m(g, R, w) { | ||
| var M, P, O, L, b, T, F = 0, re = !1, Z = !1, D = !0; | ||
| if (typeof g != "function") | ||
| throw new TypeError(t); | ||
| R = N(R) || 0, y(w) && (re = !!w.leading, Z = "maxWait" in w, O = Z ? p(N(w.maxWait) || 0, R) : O, D = "trailing" in w ? !!w.trailing : D); | ||
| function U(k) { | ||
| var x = M, H = P; | ||
| return M = P = void 0, F = k, L = g.apply(H, x), L; | ||
| } | ||
| function xe(k) { | ||
| return F = k, b = setTimeout(W, R), re ? U(k) : L; | ||
| } | ||
| function Pe(k) { | ||
| var x = k - T, H = k - F, se = R - x; | ||
| return Z ? E(se, O - H) : se; | ||
| } | ||
| function ce(k) { | ||
| var x = k - T, H = k - F; | ||
| return T === void 0 || x >= R || x < 0 || Z && H >= O; | ||
| } | ||
| function W() { | ||
| var k = h(); | ||
| if (ce(k)) | ||
| return le(k); | ||
| b = setTimeout(W, Pe(k)); | ||
| } | ||
| function le(k) { | ||
| return b = void 0, D && M ? U(k) : (M = P = void 0, L); | ||
| } | ||
| function Te() { | ||
| b !== void 0 && clearTimeout(b), F = 0, M = T = P = b = void 0; | ||
| } | ||
| function Ae() { | ||
| return b === void 0 ? L : le(h()); | ||
| } | ||
| function G() { | ||
| var k = h(), x = ce(k); | ||
| if (M = arguments, P = this, T = k, x) { | ||
| if (b === void 0) | ||
| return xe(T); | ||
| if (Z) | ||
| return b = setTimeout(W, R), U(T); | ||
| } | ||
| return b === void 0 && (b = setTimeout(W, R)), L; | ||
| } | ||
| return G.cancel = Te, G.flush = Ae, G; | ||
| } | ||
| function y(g) { | ||
| var R = typeof g; | ||
| return !!g && (R == "object" || R == "function"); | ||
| } | ||
| function C(g) { | ||
| return !!g && typeof g == "object"; | ||
| } | ||
| function A(g) { | ||
| return typeof g == "symbol" || C(g) && f.call(g) == a; | ||
| } | ||
| function N(g) { | ||
| if (typeof g == "number") | ||
| return g; | ||
| if (A(g)) | ||
| return n; | ||
| if (y(g)) { | ||
| var R = typeof g.valueOf == "function" ? g.valueOf() : g; | ||
| g = y(R) ? R + "" : R; | ||
| } | ||
| if (typeof g != "string") | ||
| return g === 0 ? g : +g; | ||
| g = g.replace(c, ""); | ||
| var w = s.test(g); | ||
| return w || o.test(g) ? l(g.slice(2), w ? 2 : 8) : r.test(g) ? n : +g; | ||
| } | ||
| return Y = m, Y; | ||
| } | ||
| var zt = Lt(); | ||
| const de = /* @__PURE__ */ lt(zt); | ||
| function Vt(t) { | ||
| const n = z(t); | ||
| n.current = t, V( | ||
| () => () => { | ||
| n.current(); | ||
| }, | ||
| [] | ||
| ); | ||
| } | ||
| function Ft(t, n = 500, a) { | ||
| const c = z(); | ||
| Vt(() => { | ||
| c.current && c.current.cancel(); | ||
| }); | ||
| const r = Ne(() => { | ||
| const s = de(t, n, a), o = (...l) => s(...l); | ||
| return o.cancel = () => { | ||
| s.cancel(); | ||
| }, o.isPending = () => !!c.current, o.flush = () => s.flush(), o; | ||
| }, [t, n, a]); | ||
| return V(() => { | ||
| c.current = de(t, n, a); | ||
| }, [t, n, a]), r; | ||
| } | ||
| function Zt(t, n, a) { | ||
| const c = ((d, u) => d === u), r = t instanceof Function ? t() : t, [s, o] = B(r), l = z(r), i = Ft( | ||
| o, | ||
| n, | ||
| a | ||
| ); | ||
| return c(l.current, r) || (i(r), l.current = r), [s, i]; | ||
| } | ||
| function Ht({ | ||
| threshold: t = 0, | ||
| root: n = null, | ||
| rootMargin: a = "0%", | ||
| freezeOnceVisible: c = !1, | ||
| initialIsIntersecting: r = !1, | ||
| onChange: s | ||
| } = {}) { | ||
| var o; | ||
| const [l, i] = B(null), [d, u] = B(() => ({ | ||
| isIntersecting: r, | ||
| entry: void 0 | ||
| })), v = z(); | ||
| v.current = s; | ||
| const f = ((o = d.entry) == null ? void 0 : o.isIntersecting) && c; | ||
| V(() => { | ||
| if (!l || !("IntersectionObserver" in window) || f) | ||
| return; | ||
| const h = new IntersectionObserver( | ||
| (m) => { | ||
| const y = Array.isArray(h.thresholds) ? h.thresholds : [h.thresholds]; | ||
| m.forEach((C) => { | ||
| const A = C.isIntersecting && y.some((N) => C.intersectionRatio >= N); | ||
| u({ isIntersecting: A, entry: C }), v.current && v.current(A, C); | ||
| }); | ||
| }, | ||
| { threshold: t, root: n, rootMargin: a } | ||
| ); | ||
| return h.observe(l), () => { | ||
| h.disconnect(); | ||
| }; | ||
| }, [ | ||
| l, | ||
| // eslint-disable-next-line react-hooks/exhaustive-deps | ||
| JSON.stringify(t), | ||
| n, | ||
| a, | ||
| f, | ||
| c | ||
| ]); | ||
| const p = z(null); | ||
| V(() => { | ||
| var h; | ||
| !l && ((h = d.entry) != null && h.target) && !c && !f && p.current !== d.entry.target && (p.current = d.entry.target, u({ isIntersecting: r, entry: void 0 })); | ||
| }, [l, d.entry, c, f, r]); | ||
| const E = [ | ||
| i, | ||
| !!d.isIntersecting, | ||
| d.entry | ||
| ]; | ||
| return E.ref = E[0], E.isIntersecting = E[1], E.entry = E[2], E; | ||
| } | ||
| const Bt = /* @__PURE__ */ e.forwardRef( | ||
| function({ | ||
| onTrackClick: n, | ||
| onClick: a, | ||
| onSubscriptionStatusChanged: c, | ||
| trackRef: r, | ||
| manageSubscription: s, | ||
| ...o | ||
| }, l) { | ||
| const i = _(r), d = e.useRef(null); | ||
| e.useImperativeHandle(l, () => d.current); | ||
| const u = Ht({ root: d.current }), [v] = Zt(u, 3e3); | ||
| e.useEffect(() => { | ||
| s && i.publication instanceof J && (v == null ? void 0 : v.isIntersecting) === !1 && (u == null ? void 0 : u.isIntersecting) === !1 && i.publication.setSubscribed(!1); | ||
| }, [v, i, s]), e.useEffect(() => { | ||
| s && i.publication instanceof J && (u == null ? void 0 : u.isIntersecting) === !0 && i.publication.setSubscribed(!0); | ||
| }, [u, i, s]); | ||
| const { | ||
| elementProps: f, | ||
| publication: p, | ||
| isSubscribed: E | ||
| } = Se(i, { | ||
| element: d, | ||
| props: o | ||
| }); | ||
| e.useEffect(() => { | ||
| c == null || c(!!E); | ||
| }, [E, c]); | ||
| const h = (m) => { | ||
| a == null || a(m), n == null || n({ participant: i == null ? void 0 : i.participant, track: p }); | ||
| }; | ||
| return /* @__PURE__ */ e.createElement("video", { ref: d, ...f, muted: !0, onClick: h }); | ||
| } | ||
| ), ne = /* @__PURE__ */ e.forwardRef( | ||
| function({ trackRef: n, onSubscriptionStatusChanged: a, volume: c, ...r }, s) { | ||
| const o = _(n), l = e.useRef(null); | ||
| e.useImperativeHandle(s, () => l.current); | ||
| const { | ||
| elementProps: i, | ||
| isSubscribed: d, | ||
| track: u, | ||
| publication: v | ||
| } = Se(o, { | ||
| element: l, | ||
| props: r | ||
| }); | ||
| return e.useEffect(() => { | ||
| a == null || a(!!d); | ||
| }, [d, a]), e.useEffect(() => { | ||
| u === void 0 || c === void 0 || (u instanceof Je ? u.setVolume(c) : j.warn("Volume can only be set on remote audio tracks.")); | ||
| }, [c, u]), e.useEffect(() => { | ||
| v === void 0 || r.muted === void 0 || (v instanceof J ? v.setEnabled(!r.muted) : j.warn("Can only call setEnabled on remote track publications.")); | ||
| }, [r.muted, v, u]), /* @__PURE__ */ e.createElement("audio", { ref: l, ...i }); | ||
| } | ||
| ); | ||
| function jt(t) { | ||
| const n = !!st(); | ||
| return t.participant && !n ? /* @__PURE__ */ e.createElement(we.Provider, { value: t.participant }, t.children) : /* @__PURE__ */ e.createElement(e.Fragment, null, t.children); | ||
| } | ||
| function _t(t) { | ||
| const n = !!te(); | ||
| return t.trackRef && !n ? /* @__PURE__ */ e.createElement(ae.Provider, { value: t.trackRef }, t.children) : /* @__PURE__ */ e.createElement(e.Fragment, null, t.children); | ||
| } | ||
| const Ot = /* @__PURE__ */ e.forwardRef( | ||
| function({ | ||
| trackRef: n, | ||
| children: a, | ||
| onParticipantClick: c, | ||
| disableSpeakingIndicator: r, | ||
| ...s | ||
| }, o) { | ||
| var p, E; | ||
| const l = _(n), { elementProps: i } = ve({ | ||
| htmlProps: s, | ||
| disableSpeakingIndicator: r, | ||
| onParticipantClick: c, | ||
| trackRef: l | ||
| }), d = We(l.participant), u = it(), v = (p = ot()) == null ? void 0 : p.autoSubscription, f = e.useCallback( | ||
| (h) => { | ||
| l.source && !h && u && u.pin.dispatch && ut(l, u.pin.state) && u.pin.dispatch({ msg: "clear_pin" }); | ||
| }, | ||
| [l, u] | ||
| ); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: o, style: { position: "relative" }, ...i }, /* @__PURE__ */ e.createElement(_t, { trackRef: l }, /* @__PURE__ */ e.createElement(jt, { participant: l.participant }, a ?? /* @__PURE__ */ e.createElement(e.Fragment, null, $(l) && (((E = l.publication) == null ? void 0 : E.kind) === "video" || l.source === S.Source.Camera || l.source === S.Source.ScreenShare) ? /* @__PURE__ */ e.createElement( | ||
| Bt, | ||
| { | ||
| trackRef: l, | ||
| onSubscriptionStatusChanged: f, | ||
| manageSubscription: v | ||
| } | ||
| ) : $(l) && /* @__PURE__ */ e.createElement( | ||
| ne, | ||
| { | ||
| trackRef: l, | ||
| onSubscriptionStatusChanged: f | ||
| } | ||
| ), /* @__PURE__ */ e.createElement("div", { className: "lk-participant-placeholder" }, /* @__PURE__ */ e.createElement(Nt, null)), /* @__PURE__ */ e.createElement("div", { className: "lk-participant-metadata" }, /* @__PURE__ */ e.createElement("div", { className: "lk-participant-metadata-item" }, l.source === S.Source.Camera ? /* @__PURE__ */ e.createElement(e.Fragment, null, d && /* @__PURE__ */ e.createElement(Rt, { style: { marginRight: "0.25rem" } }), /* @__PURE__ */ e.createElement( | ||
| be, | ||
| { | ||
| trackRef: { | ||
| participant: l.participant, | ||
| source: S.Source.Microphone | ||
| }, | ||
| show: "muted" | ||
| } | ||
| ), /* @__PURE__ */ e.createElement(K, null)) : /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(Re, { style: { marginRight: "0.25rem" } }), /* @__PURE__ */ e.createElement(K, null, "'s screen"))), /* @__PURE__ */ e.createElement(ye, { className: "lk-participant-metadata-item" }))), /* @__PURE__ */ e.createElement(Tt, { trackRef: l })))); | ||
| } | ||
| ); | ||
| function Ea(t) { | ||
| const n = I(t, { className: "lk-focus-layout" }); | ||
| return /* @__PURE__ */ e.createElement("div", { ...n }, t.children); | ||
| } | ||
| function pa({ trackRef: t, ...n }) { | ||
| return /* @__PURE__ */ e.createElement(Ot, { trackRef: t, ...n }); | ||
| } | ||
| function Ce({ tracks: t, ...n }) { | ||
| return /* @__PURE__ */ e.createElement(e.Fragment, null, t.map((a) => /* @__PURE__ */ e.createElement( | ||
| ae.Provider, | ||
| { | ||
| value: a, | ||
| key: ke(a) | ||
| }, | ||
| ee(n.children) | ||
| ))); | ||
| } | ||
| function Wt({ | ||
| totalPageCount: t, | ||
| nextPage: n, | ||
| prevPage: a, | ||
| currentPage: c, | ||
| pagesContainer: r | ||
| }) { | ||
| const [s, o] = e.useState(!1); | ||
| return e.useEffect(() => { | ||
| let l; | ||
| return r && (l = dt(r.current, 2e3).subscribe( | ||
| o | ||
| )), () => { | ||
| l && l.unsubscribe(); | ||
| }; | ||
| }, [r]), /* @__PURE__ */ e.createElement("div", { className: "lk-pagination-control", "data-lk-user-interaction": s }, /* @__PURE__ */ e.createElement("button", { className: "lk-button", onClick: a }, /* @__PURE__ */ e.createElement(ie, null)), /* @__PURE__ */ e.createElement("span", { className: "lk-pagination-count" }, `${c} of ${t}`), /* @__PURE__ */ e.createElement("button", { className: "lk-button", onClick: n }, /* @__PURE__ */ e.createElement(ie, null))); | ||
| } | ||
| const qt = /* @__PURE__ */ e.forwardRef( | ||
| function({ totalPageCount: n, currentPage: a }, c) { | ||
| const r = new Array(n).fill("").map((s, o) => o + 1 === a ? /* @__PURE__ */ e.createElement("span", { "data-lk-active": !0, key: o }) : /* @__PURE__ */ e.createElement("span", { key: o })); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: c, className: "lk-pagination-indicator" }, r); | ||
| } | ||
| ); | ||
| function wa({ tracks: t, ...n }) { | ||
| const a = e.createRef(), c = e.useMemo( | ||
| () => I(n, { className: "lk-grid-layout" }), | ||
| [n] | ||
| ), { layout: r } = qe(a, t.length), s = $e(r.maxTiles, t); | ||
| return De(a, { | ||
| onLeftSwipe: s.nextPage, | ||
| onRightSwipe: s.prevPage | ||
| }), /* @__PURE__ */ e.createElement("div", { ref: a, "data-lk-pagination": s.totalPageCount > 1, ...c }, /* @__PURE__ */ e.createElement(Ce, { tracks: s.tracks }, n.children), t.length > r.maxTiles && /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement( | ||
| qt, | ||
| { | ||
| totalPageCount: s.totalPageCount, | ||
| currentPage: s.currentPage | ||
| } | ||
| ), /* @__PURE__ */ e.createElement(Wt, { pagesContainer: a, ...s }))); | ||
| } | ||
| const $t = 130, Dt = 140, me = 1, Ie = 16 / 10, Ut = (1 - Ie) * -1; | ||
| function ka({ tracks: t, orientation: n, ...a }) { | ||
| const c = e.useRef(null), [r, s] = e.useState(0), { width: o, height: l } = Ue(c), i = n || (l >= o ? "vertical" : "horizontal"), d = i === "vertical" ? Math.max(o * Ut, $t) : Math.max(l * Ie, Dt), u = mt(), v = Math.max(i === "vertical" ? (l - u) / d : (o - u) / d, me); | ||
| let f = Math.round(v); | ||
| Math.abs(v - r) < 0.5 ? f = Math.round(r) : r !== v && s(v); | ||
| const p = Ge(t, f); | ||
| return e.useLayoutEffect(() => { | ||
| c.current && (c.current.dataset.lkOrientation = i, c.current.style.setProperty("--lk-max-visible-tiles", f.toString())); | ||
| }, [f, i]), /* @__PURE__ */ e.createElement("aside", { key: i, className: "lk-carousel", ref: c, ...a }, /* @__PURE__ */ e.createElement(Ce, { tracks: p }, a.children)); | ||
| } | ||
| function Ra({ | ||
| value: t, | ||
| onPinChange: n, | ||
| onWidgetChange: a, | ||
| children: c | ||
| }) { | ||
| const r = ft(t); | ||
| return e.useEffect(() => { | ||
| j.debug("PinState Updated", { state: r.pin.state }), n && r.pin.state && n(r.pin.state); | ||
| }, [r.pin.state, n]), e.useEffect(() => { | ||
| j.debug("Widget Updated", { widgetState: r.widget.state }), a && r.widget.state && a(r.widget.state); | ||
| }, [a, r.widget.state]), /* @__PURE__ */ e.createElement(pe.Provider, { value: r }, c); | ||
| } | ||
| const Ma = /* @__PURE__ */ e.forwardRef( | ||
| function({ trackRef: n, ...a }, c) { | ||
| const u = _(n), v = Ee(u, { bands: 7, loPass: 300 }); | ||
| return /* @__PURE__ */ e.createElement( | ||
| "svg", | ||
| { | ||
| ref: c, | ||
| width: "100%", | ||
| height: "100%", | ||
| viewBox: "0 0 200 90", | ||
| ...a, | ||
| className: "lk-audio-visualizer" | ||
| }, | ||
| /* @__PURE__ */ e.createElement("rect", { x: "0", y: "0", width: "100%", height: "100%" }), | ||
| /* @__PURE__ */ e.createElement( | ||
| "g", | ||
| { | ||
| style: { | ||
| transform: `translate(${130 / 2}px, 0)` | ||
| } | ||
| }, | ||
| v.map((f, p) => /* @__PURE__ */ e.createElement( | ||
| "rect", | ||
| { | ||
| key: p, | ||
| x: p * 10, | ||
| y: 90 / 2 - f * 50 / 2, | ||
| width: 6, | ||
| height: f * 50 | ||
| } | ||
| )) | ||
| ) | ||
| ); | ||
| } | ||
| ); | ||
| function ya({ participants: t, ...n }) { | ||
| return /* @__PURE__ */ e.createElement(e.Fragment, null, t.map((a) => /* @__PURE__ */ e.createElement(we.Provider, { value: a, key: a.identity }, ee(n.children)))); | ||
| } | ||
| function ba({ room: t, volume: n, muted: a }) { | ||
| const c = Qe( | ||
| [S.Source.Microphone, S.Source.ScreenShareAudio, S.Source.Unknown], | ||
| { | ||
| updateOnlyOn: [], | ||
| onlySubscribed: !0, | ||
| room: t | ||
| } | ||
| ).filter((r) => !r.participant.isLocal && r.publication.kind === S.Kind.Audio); | ||
| return /* @__PURE__ */ e.createElement("div", { style: { display: "none" } }, c.map((r) => /* @__PURE__ */ e.createElement( | ||
| ne, | ||
| { | ||
| key: ke(r), | ||
| trackRef: r, | ||
| volume: n, | ||
| muted: a | ||
| } | ||
| ))); | ||
| } | ||
| const Sa = /* @__PURE__ */ e.forwardRef(function({ childrenPosition: n = "before", children: a, ...c }, r) { | ||
| const { name: s } = Xe(); | ||
| return /* @__PURE__ */ e.createElement("span", { ref: r, ...c }, n === "before" && a, s, n === "after" && a); | ||
| }); | ||
| function Gt(t) { | ||
| const n = e.useMemo(() => I(t, { className: "lk-toast" }), [t]); | ||
| return /* @__PURE__ */ e.createElement("div", { ...n }, t.children); | ||
| } | ||
| const Qt = (t) => { | ||
| const n = []; | ||
| for (let a = 0; a < t; a++) | ||
| n.push([a, t - 1 - a]); | ||
| return n; | ||
| }, fe = (t) => [[Math.floor(t / 2)], [-1]], Xt = (t, n, a) => { | ||
| const [c, r] = B(0), [s, o] = B([[]]); | ||
| V(() => { | ||
| if (t === "thinking") | ||
| o(fe(n)); | ||
| else if (t === "connecting" || t === "initializing") { | ||
| const i = [...Qt(n)]; | ||
| o(i); | ||
| } else o(t === "listening" ? fe(n) : t === void 0 || t === "speaking" ? [new Array(n).fill(0).map((i, d) => d)] : [[]]); | ||
| r(0); | ||
| }, [t, n]); | ||
| const l = z(null); | ||
| return V(() => { | ||
| let i = performance.now(); | ||
| const d = (u) => { | ||
| u - i >= a && (r((f) => f + 1), i = u), l.current = requestAnimationFrame(d); | ||
| }; | ||
| return l.current = requestAnimationFrame(d), () => { | ||
| l.current !== null && cancelAnimationFrame(l.current); | ||
| }; | ||
| }, [a, n, t, s.length]), s[c % s.length]; | ||
| }, Yt = /* @__PURE__ */ new Map([ | ||
| ["connecting", 2e3], | ||
| ["initializing", 2e3], | ||
| ["listening", 500], | ||
| ["thinking", 150] | ||
| ]), Jt = (t, n) => { | ||
| if (t === void 0) | ||
| return 1e3; | ||
| let a = Yt.get(t); | ||
| if (a) | ||
| switch (t) { | ||
| case "connecting": | ||
| a /= n; | ||
| break; | ||
| } | ||
| return a; | ||
| }, Kt = /* @__PURE__ */ e.forwardRef( | ||
| function({ state: n, options: a, barCount: c = 15, trackRef: r, track: s, children: o, ...l }, i) { | ||
| const d = I(l, { className: "lk-audio-bar-visualizer" }); | ||
| let u = te(); | ||
| (r || s) && (u = r || s); | ||
| const v = Ee(u, { | ||
| bands: c, | ||
| loPass: 100, | ||
| hiPass: 200 | ||
| }), f = (a == null ? void 0 : a.minHeight) ?? 20, p = (a == null ? void 0 : a.maxHeight) ?? 100, E = Xt( | ||
| n, | ||
| c, | ||
| Jt(n, c) ?? 100 | ||
| ); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: i, ...d, "data-lk-va-state": n }, v.map( | ||
| (h, m) => o ? ee(o, { | ||
| "data-lk-highlighted": E.includes(m), | ||
| "data-lk-bar-index": m, | ||
| className: "lk-audio-bar", | ||
| style: { height: `${Math.min(p, Math.max(f, h * 100 + 5))}%` } | ||
| }) : /* @__PURE__ */ e.createElement( | ||
| "span", | ||
| { | ||
| key: m, | ||
| "data-lk-highlighted": E.includes(m), | ||
| "data-lk-bar-index": m, | ||
| className: `lk-audio-bar ${E.includes(m) && "lk-highlighted"}`, | ||
| style: { | ||
| // TODO transform animations would be more performant, however the border-radius gets distorted when using scale transforms. a 9-slice approach (or 3 in this case) could work | ||
| // transform: `scale(1, ${Math.min(maxHeight, Math.max(minHeight, volume))}`, | ||
| height: `${Math.min(p, Math.max(f, h * 100 + 5))}%` | ||
| } | ||
| } | ||
| ) | ||
| )); | ||
| } | ||
| ), Ca = /* @__PURE__ */ e.forwardRef( | ||
| function({ | ||
| children: n, | ||
| disableSpeakingIndicator: a, | ||
| onParticipantClick: c, | ||
| trackRef: r, | ||
| ...s | ||
| }, o) { | ||
| const l = _(r), { elementProps: i } = ve({ | ||
| trackRef: l, | ||
| htmlProps: s, | ||
| disableSpeakingIndicator: a, | ||
| onParticipantClick: c | ||
| }); | ||
| return /* @__PURE__ */ e.createElement("div", { ref: o, style: { position: "relative", minHeight: "160px" }, ...i }, /* @__PURE__ */ e.createElement(ae.Provider, { value: l }, n ?? /* @__PURE__ */ e.createElement(e.Fragment, null, $(l) && /* @__PURE__ */ e.createElement(ne, { trackRef: l }), /* @__PURE__ */ e.createElement(Kt, { barCount: 7, options: { minHeight: 8 } }), /* @__PURE__ */ e.createElement("div", { className: "lk-participant-metadata" }, /* @__PURE__ */ e.createElement("div", { className: "lk-participant-metadata-item" }, /* @__PURE__ */ e.createElement(be, { trackRef: l }), /* @__PURE__ */ e.createElement(K, null)), /* @__PURE__ */ e.createElement(ye, { className: "lk-participant-metadata-item" }))))); | ||
| } | ||
| ); | ||
| function Ia(t) { | ||
| const [n, a] = e.useState(void 0), c = he(t.room); | ||
| return e.useEffect(() => { | ||
| switch (c) { | ||
| case X.Reconnecting: | ||
| a( | ||
| /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(oe, { className: "lk-spinner" }), " Reconnecting") | ||
| ); | ||
| break; | ||
| case X.Connecting: | ||
| a( | ||
| /* @__PURE__ */ e.createElement(e.Fragment, null, /* @__PURE__ */ e.createElement(oe, { className: "lk-spinner" }), " Connecting") | ||
| ); | ||
| break; | ||
| case X.Disconnected: | ||
| a(/* @__PURE__ */ e.createElement(e.Fragment, null, "Disconnected")); | ||
| break; | ||
| default: | ||
| a(void 0); | ||
| break; | ||
| } | ||
| }, [c]), n ? /* @__PURE__ */ e.createElement(Gt, { className: "lk-toast-connection-state" }, n) : /* @__PURE__ */ e.createElement(e.Fragment, null); | ||
| } | ||
| const xa = /* @__PURE__ */ e.forwardRef( | ||
| function({ entry: n, hideName: a = !1, hideTimestamp: c = !1, messageFormatter: r, ...s }, o) { | ||
| var f, p, E, h; | ||
| const l = e.useMemo(() => r ? r(n.message) : n.message, [n.message, r]), i = !!n.editTimestamp, d = new Date(n.timestamp), u = typeof navigator < "u" ? navigator.language : "en-US", v = ((f = n.from) == null ? void 0 : f.name) ?? ((p = n.from) == null ? void 0 : p.identity); | ||
| return /* @__PURE__ */ e.createElement( | ||
| "li", | ||
| { | ||
| ref: o, | ||
| className: "lk-chat-entry", | ||
| title: d.toLocaleTimeString(u, { timeStyle: "full" }), | ||
| "data-lk-message-origin": (E = n.from) != null && E.isLocal ? "local" : "remote", | ||
| ...s | ||
| }, | ||
| (!c || !a || i) && /* @__PURE__ */ e.createElement("span", { className: "lk-meta-data" }, !a && /* @__PURE__ */ e.createElement("strong", { className: "lk-participant-name" }, v), (!c || i) && /* @__PURE__ */ e.createElement("span", { className: "lk-timestamp" }, i && "edited ", d.toLocaleTimeString(u, { timeStyle: "short" }))), | ||
| /* @__PURE__ */ e.createElement("span", { className: "lk-message-body" }, l), | ||
| /* @__PURE__ */ e.createElement("span", { className: "lk-message-attachements" }, (h = n.attachedFiles) == null ? void 0 : h.map( | ||
| (m) => m.type.startsWith("image/") && /* @__PURE__ */ e.createElement( | ||
| "img", | ||
| { | ||
| style: { maxWidth: "300px", maxHeight: "300px" }, | ||
| key: m.name, | ||
| src: URL.createObjectURL(m), | ||
| alt: m.name | ||
| } | ||
| ) | ||
| )) | ||
| ); | ||
| } | ||
| ); | ||
| function Pa(t) { | ||
| return ht(t, gt()).map((n, a) => { | ||
| if (typeof n == "string") | ||
| return n; | ||
| { | ||
| const c = n.content.toString(), r = n.type === "url" ? /^http(s?):\/\//.test(c) ? c : `https://${c}` : `mailto:${c}`; | ||
| return /* @__PURE__ */ e.createElement("a", { className: "lk-chat-link", key: a, href: r, target: "_blank", rel: "noreferrer" }, c); | ||
| } | ||
| }); | ||
| } | ||
| function Ta(t) { | ||
| return /* @__PURE__ */ e.createElement(vt.Provider, { value: t.session }, /* @__PURE__ */ e.createElement(Et.Provider, { value: t.session.room }, t.children)); | ||
| } | ||
| export { | ||
| Pt as $, | ||
| Ma as A, | ||
| Kt as B, | ||
| sa as C, | ||
| ia as D, | ||
| pt as E, | ||
| Ea as F, | ||
| wa as G, | ||
| wt as H, | ||
| ie as I, | ||
| kt as J, | ||
| Rt as K, | ||
| Ra as L, | ||
| fa as M, | ||
| Mt as N, | ||
| yt as O, | ||
| Ot as P, | ||
| bt as Q, | ||
| ba as R, | ||
| oa as S, | ||
| va as T, | ||
| St as U, | ||
| Bt as V, | ||
| Ct as W, | ||
| It as X, | ||
| Re as Y, | ||
| xt as Z, | ||
| oe as _, | ||
| xa as a, | ||
| Nt as b, | ||
| ua as c, | ||
| da as d, | ||
| ma as e, | ||
| ga as f, | ||
| ka as g, | ||
| pa as h, | ||
| Ia as i, | ||
| Ce as j, | ||
| Ca as k, | ||
| Gt as l, | ||
| Pa as m, | ||
| ca as n, | ||
| la as o, | ||
| Tt as p, | ||
| ha as q, | ||
| ye as r, | ||
| ne as s, | ||
| K as t, | ||
| be as u, | ||
| ya as v, | ||
| Sa as w, | ||
| jt as x, | ||
| _t as y, | ||
| Ta as z | ||
| }; | ||
| //# sourceMappingURL=components-DuRBtGp8.mjs.map |
Sorry, the diff of this file is too big to display
| import * as s from "react"; | ||
| import { useRef as ae, useMemo as Ne, useCallback as ee, useEffect as _e } from "react"; | ||
| import { u as U, r as Fe, a as Pe, b as xe, c as Q, d as Ue, e as He, f as oe, g as Ve, h as qe, i as ue, j as Be, k as je, m as ze, G as We, n as Ge, o as Je, p as le, q as $e, t as Qe, v as Le, w as de, x as Ae, y as Ke, l as V, z as Ye, A as Xe, B as fe, C as Ze, D as et, E as tt, F as nt, H as st, I as rt, J as ot, K as at, M as ve, N as ct, O as it, P as ut, Q as lt, S as dt, T as ft, U as mt, V as pt, W as Re, X as ht, Y as bt, Z as gt, _ as vt, $ as St, a0 as yt, a1 as Ct, a2 as Mt, a3 as Tt, a4 as Et, a5 as kt, a6 as wt, a7 as ie, a8 as W, a9 as Pt, aa as Lt, ab as At, ac as Rt, ad as Dt } from "./contexts-CsO1QZ3r.mjs"; | ||
| import { m as G } from "./room-Bb6uLxS5.mjs"; | ||
| import { ConnectionState as I, LocalTrackPublication as Ot, facingModeFromLocalTrack as It, Room as De, Track as E, createAudioAnalyser as me, ParticipantKind as se, Mutex as Nt, ParticipantEvent as X, RoomEvent as H, decodeTokenPayload as _t, TokenSourceConfigurable as Ft } from "livekit-client"; | ||
| const xt = (e) => { | ||
| const n = s.useRef(e); | ||
| return s.useEffect(() => { | ||
| n.current = e; | ||
| }), n; | ||
| }; | ||
| function Ut(e, n) { | ||
| const t = Vt(), r = xt(n); | ||
| return s.useLayoutEffect(() => { | ||
| let o = !1; | ||
| const c = e.current; | ||
| if (!c) return; | ||
| function a(i, u) { | ||
| o || r.current(i, u); | ||
| } | ||
| return t == null || t.subscribe(c, a), () => { | ||
| o = !0, t == null || t.unsubscribe(c, a); | ||
| }; | ||
| }, [e.current, t, r]), t == null ? void 0 : t.observer; | ||
| } | ||
| function Ht() { | ||
| let e = !1, n = []; | ||
| const t = /* @__PURE__ */ new Map(); | ||
| if (typeof window > "u") | ||
| return; | ||
| const r = new ResizeObserver((o, c) => { | ||
| n = n.concat(o), e || window.requestAnimationFrame(() => { | ||
| const a = /* @__PURE__ */ new Set(); | ||
| for (let i = 0; i < n.length; i++) { | ||
| if (a.has(n[i].target)) continue; | ||
| a.add(n[i].target); | ||
| const u = t.get(n[i].target); | ||
| u == null || u.forEach((p) => p(n[i], c)); | ||
| } | ||
| n = [], e = !1; | ||
| }), e = !0; | ||
| }); | ||
| return { | ||
| observer: r, | ||
| subscribe(o, c) { | ||
| r.observe(o); | ||
| const a = t.get(o) ?? []; | ||
| a.push(c), t.set(o, a); | ||
| }, | ||
| unsubscribe(o, c) { | ||
| const a = t.get(o) ?? []; | ||
| if (a.length === 1) { | ||
| r.unobserve(o), t.delete(o); | ||
| return; | ||
| } | ||
| const i = a.indexOf(c); | ||
| i !== -1 && a.splice(i, 1), t.set(o, a); | ||
| } | ||
| }; | ||
| } | ||
| let ce; | ||
| const Vt = () => ce || (ce = Ht()), qt = (e) => { | ||
| const [n, t] = s.useState({ width: 0, height: 0 }); | ||
| s.useLayoutEffect(() => { | ||
| if (e.current) { | ||
| const { width: o, height: c } = e.current.getBoundingClientRect(); | ||
| t({ width: o, height: c }); | ||
| } | ||
| }, [e.current]); | ||
| const r = s.useCallback( | ||
| (o) => t(o.contentRect), | ||
| [] | ||
| ); | ||
| return Ut(e, r), n; | ||
| }; | ||
| function D(e, n, t = !0) { | ||
| const [r, o] = s.useState(n); | ||
| return s.useEffect(() => { | ||
| if (t && o(n), typeof window > "u" || !e) return; | ||
| const c = e.subscribe(o); | ||
| return () => c.unsubscribe(); | ||
| }, [e, t]), r; | ||
| } | ||
| function kn(e) { | ||
| const n = (c) => typeof window < "u" ? window.matchMedia(c).matches : !1, [t, r] = s.useState(n(e)); | ||
| function o() { | ||
| r(n(e)); | ||
| } | ||
| return s.useEffect(() => { | ||
| const c = window.matchMedia(e); | ||
| return o(), c.addListener ? c.addListener(o) : c.addEventListener("change", o), () => { | ||
| c.removeListener ? c.removeListener(o) : c.removeEventListener("change", o); | ||
| }; | ||
| }, [e]), t; | ||
| } | ||
| function wn(e) { | ||
| const n = U(e), t = s.useCallback(async () => { | ||
| await n.startAudio(); | ||
| }, [n]), r = s.useMemo( | ||
| () => Fe(n), | ||
| [n] | ||
| ), { canPlayAudio: o } = D(r, { | ||
| canPlayAudio: n.canPlaybackAudio | ||
| }); | ||
| return { canPlayAudio: o, startAudio: t }; | ||
| } | ||
| function Pn(e) { | ||
| const { state: n, dispatch: t } = Pe().pin; | ||
| return { buttonProps: s.useMemo(() => { | ||
| const { className: o } = xe(); | ||
| return G(e, { | ||
| className: o, | ||
| disabled: !(n != null && n.length), | ||
| onClick: () => { | ||
| t && t({ msg: "clear_pin" }); | ||
| } | ||
| }); | ||
| }, [e, t, n]) }; | ||
| } | ||
| function Ln(e = {}) { | ||
| const n = Q(e.participant), { className: t, connectionQualityObserver: r } = s.useMemo( | ||
| () => Ue(n), | ||
| [n] | ||
| ), o = D(r, n.connectionQuality); | ||
| return { className: t, quality: o }; | ||
| } | ||
| function te(e) { | ||
| const n = U(e), t = s.useMemo(() => He(n), [n]); | ||
| return D(t, n.state); | ||
| } | ||
| function An(e, n) { | ||
| const t = typeof e == "function" ? e : n, r = typeof e == "string" ? e : void 0, o = oe(), { send: c, messageObservable: a, isSendingObservable: i } = s.useMemo( | ||
| () => Ve(o, r, t), | ||
| [o, r, t] | ||
| ), u = D(a, void 0), p = D(i, !1); | ||
| return { | ||
| message: u, | ||
| send: c, | ||
| isSending: p | ||
| }; | ||
| } | ||
| function Rn(e) { | ||
| const n = oe(), t = te(n); | ||
| return { buttonProps: s.useMemo(() => { | ||
| const { className: o, disconnect: c } = qe(n); | ||
| return G(e, { | ||
| className: o, | ||
| onClick: () => c(e.stopTracks ?? !0), | ||
| disabled: t === I.Disconnected | ||
| }); | ||
| }, [n, e, t]) }; | ||
| } | ||
| function Bt(e) { | ||
| if (e.publication instanceof Ot) { | ||
| const n = e.publication.track; | ||
| if (n) { | ||
| const { facingMode: t } = It(n); | ||
| return t; | ||
| } | ||
| } | ||
| return "undefined"; | ||
| } | ||
| function Dn({ trackRef: e, props: n }) { | ||
| const t = ue(e), r = Be(), { className: o } = s.useMemo(() => je(), []), c = s.useMemo(() => ze(t, r == null ? void 0 : r.pin.state), [t, r == null ? void 0 : r.pin.state]); | ||
| return { mergedProps: s.useMemo( | ||
| () => G(n, { | ||
| className: o, | ||
| onClick: (i) => { | ||
| var u, p, h, d, l; | ||
| (u = n.onClick) == null || u.call(n, i), c ? (h = r == null ? void 0 : (p = r.pin).dispatch) == null || h.call(p, { | ||
| msg: "clear_pin" | ||
| }) : (l = r == null ? void 0 : (d = r.pin).dispatch) == null || l.call(d, { | ||
| msg: "set_pin", | ||
| trackReference: t | ||
| }); | ||
| } | ||
| }), | ||
| [n, o, t, c, r == null ? void 0 : r.pin] | ||
| ), inFocus: c }; | ||
| } | ||
| function On(e, n, t = {}) { | ||
| const r = t.gridLayouts ?? We, { width: o, height: c } = qt(e), a = Ge(r, n, o, c); | ||
| return s.useEffect(() => { | ||
| e.current && a && (e.current.style.setProperty("--lk-col-count", a == null ? void 0 : a.columns.toString()), e.current.style.setProperty("--lk-row-count", a == null ? void 0 : a.rows.toString())); | ||
| }, [e, a]), { | ||
| layout: a, | ||
| containerWidth: o, | ||
| containerHeight: c | ||
| }; | ||
| } | ||
| function Se(e, n = {}) { | ||
| var i, u; | ||
| const t = typeof e == "string" ? n.participant : e.participant, r = Q(t), o = typeof e == "string" ? { participant: r, source: e } : e, [c, a] = s.useState( | ||
| !!((i = o.publication) != null && i.isMuted || (u = r.getTrackPublication(o.source)) != null && u.isMuted) | ||
| ); | ||
| return s.useEffect(() => { | ||
| const p = Je(o).subscribe(a); | ||
| return () => p.unsubscribe(); | ||
| }, [le(o)]), c; | ||
| } | ||
| function jt(e) { | ||
| const n = Q(e), t = s.useMemo(() => $e(n), [n]); | ||
| return D(t, n.isSpeaking); | ||
| } | ||
| function Oe(e = {}) { | ||
| const n = U(e.room), [t, r] = s.useState(n.localParticipant), [o, c] = s.useState( | ||
| t.isMicrophoneEnabled | ||
| ), [a, i] = s.useState(t.isCameraEnabled), [u, p] = s.useState( | ||
| t.isScreenShareEnabled | ||
| ), [h, d] = s.useState( | ||
| t.lastMicrophoneError | ||
| ), [l, v] = s.useState(t.lastCameraError), [C, k] = s.useState( | ||
| void 0 | ||
| ), [A, w] = s.useState(void 0), O = (R) => { | ||
| i(R.isCameraEnabled), c(R.isMicrophoneEnabled), p(R.isScreenShareEnabled), w(R.cameraTrack), k(R.microphoneTrack), d(R.participant.lastMicrophoneError), v(R.participant.lastCameraError), r(R.participant); | ||
| }; | ||
| return s.useEffect(() => { | ||
| const R = Qe(n.localParticipant).subscribe(O); | ||
| return () => R.unsubscribe(); | ||
| }, [n]), { | ||
| isMicrophoneEnabled: o, | ||
| isScreenShareEnabled: u, | ||
| isCameraEnabled: a, | ||
| microphoneTrack: C, | ||
| cameraTrack: A, | ||
| lastMicrophoneError: h, | ||
| lastCameraError: l, | ||
| localParticipant: t | ||
| }; | ||
| } | ||
| function In() { | ||
| const e = oe(), n = s.useMemo( | ||
| () => Le(e.localParticipant), | ||
| [e] | ||
| ); | ||
| return D(n, e.localParticipant.permissions); | ||
| } | ||
| function Nn({ | ||
| kind: e, | ||
| room: n, | ||
| track: t, | ||
| requestPermissions: r, | ||
| onError: o | ||
| }) { | ||
| const c = de(), a = s.useMemo(() => n ?? c ?? new De(), [n, c]), i = s.useMemo( | ||
| () => Ae(e, o, r), | ||
| [e, r, o] | ||
| ), u = D(i, []), [p, h] = s.useState( | ||
| (a == null ? void 0 : a.getActiveDevice(e)) ?? "default" | ||
| ), { className: d, activeDeviceObservable: l, setActiveMediaDevice: v } = s.useMemo( | ||
| () => Ke(e, a), | ||
| [e, a, t] | ||
| ); | ||
| return s.useEffect(() => { | ||
| const C = l.subscribe((k) => { | ||
| k && (V.info("setCurrentDeviceId", k), h(k)); | ||
| }); | ||
| return () => { | ||
| C == null || C.unsubscribe(); | ||
| }; | ||
| }, [l]), { devices: u, className: d, activeDeviceId: p, setActiveMediaDevice: v }; | ||
| } | ||
| function _n({ | ||
| kind: e, | ||
| onError: n | ||
| }) { | ||
| const t = s.useMemo( | ||
| () => Ae(e, n), | ||
| [e, n] | ||
| ); | ||
| return D(t, []); | ||
| } | ||
| function zt(e, n, t = {}) { | ||
| const r = s.useRef([]), o = s.useRef(-1), c = n !== o.current, a = typeof t.customSortFunction == "function" ? t.customSortFunction(e) : Ye(e); | ||
| let i = [...a]; | ||
| if (c === !1) | ||
| try { | ||
| i = Xe(r.current, a, n); | ||
| } catch (u) { | ||
| V.error("Error while running updatePages(): ", u); | ||
| } | ||
| return c ? r.current = a : r.current = i, o.current = n, i; | ||
| } | ||
| function Fn(e, n) { | ||
| const [t, r] = s.useState(1), o = Math.max(Math.ceil(n.length / e), 1); | ||
| t > o && r(o); | ||
| const c = t * e, a = c - e, i = (d) => { | ||
| r((l) => d === "next" ? l === o ? l : l + 1 : l === 1 ? l : l - 1); | ||
| }, u = (d) => { | ||
| d > o ? r(o) : d < 1 ? r(1) : r(d); | ||
| }, h = zt(n, e).slice(a, c); | ||
| return { | ||
| totalPageCount: o, | ||
| nextPage: () => i("next"), | ||
| prevPage: () => i("previous"), | ||
| setPage: u, | ||
| firstItemIndex: a, | ||
| lastItemIndex: c, | ||
| tracks: h, | ||
| currentPage: t | ||
| }; | ||
| } | ||
| function xn(e = {}) { | ||
| let n = fe(); | ||
| e.participant && (n = e.participant); | ||
| const t = s.useMemo(() => Ze(n), [n]), { identity: r, name: o, metadata: c } = D(t, { | ||
| name: n == null ? void 0 : n.name, | ||
| identity: n == null ? void 0 : n.identity, | ||
| metadata: n == null ? void 0 : n.metadata | ||
| }); | ||
| return { identity: r, name: o, metadata: c }; | ||
| } | ||
| function Un(e = {}) { | ||
| const n = Q(e.participant), t = s.useMemo(() => Le(n), [n]); | ||
| return D(t, n.permissions); | ||
| } | ||
| function Hn({ | ||
| trackRef: e, | ||
| onParticipantClick: n, | ||
| disableSpeakingIndicator: t, | ||
| htmlProps: r | ||
| }) { | ||
| const o = ue(e), c = s.useMemo(() => { | ||
| const { className: l } = et(); | ||
| return G(r, { | ||
| className: l, | ||
| onClick: (v) => { | ||
| var C; | ||
| if ((C = r.onClick) == null || C.call(r, v), typeof n == "function") { | ||
| const k = o.publication ?? o.participant.getTrackPublication(o.source); | ||
| n({ participant: o.participant, track: k }); | ||
| } | ||
| } | ||
| }); | ||
| }, [ | ||
| r, | ||
| n, | ||
| o.publication, | ||
| o.source, | ||
| o.participant | ||
| ]), a = o.participant.getTrackPublication(E.Source.Microphone), i = s.useMemo(() => ({ | ||
| participant: o.participant, | ||
| source: E.Source.Microphone, | ||
| publication: a | ||
| }), [a, o.participant]), u = Se(o), p = Se(i), h = jt(o.participant), d = Bt(o); | ||
| return { | ||
| elementProps: { | ||
| "data-lk-audio-muted": p, | ||
| "data-lk-video-muted": u, | ||
| "data-lk-speaking": t === !0 ? !1 : h, | ||
| "data-lk-local-participant": o.participant.isLocal, | ||
| "data-lk-source": o.source, | ||
| "data-lk-facing-mode": d, | ||
| ...c | ||
| } | ||
| }; | ||
| } | ||
| function pe(e = {}) { | ||
| const n = U(e.room), [t, r] = s.useState([]); | ||
| return s.useEffect(() => { | ||
| const o = tt(n, { | ||
| additionalRoomEvents: e.updateOnlyOn | ||
| }).subscribe(r); | ||
| return () => o.unsubscribe(); | ||
| }, [n, JSON.stringify(e.updateOnlyOn)]), t; | ||
| } | ||
| function Wt(e = {}) { | ||
| const n = pe(e), { localParticipant: t } = Oe(e); | ||
| return s.useMemo( | ||
| () => [t, ...n], | ||
| [t, n] | ||
| ); | ||
| } | ||
| function Vn(e) { | ||
| return e = nt(e), s.useMemo(() => (e == null ? void 0 : e.pin.state) !== void 0 && e.pin.state.length >= 1 ? e.pin.state : [], [e.pin.state]); | ||
| } | ||
| function qn(e, n = {}) { | ||
| const t = oe(), [r] = s.useState(n.updateOnlyOn), o = s.useMemo(() => typeof e == "string" ? st(t, e, { | ||
| additionalEvents: r | ||
| }) : rt(t, e, { | ||
| additionalEvents: r | ||
| }), [t, JSON.stringify(e), r]), [c, a] = s.useState({ | ||
| p: void 0 | ||
| }); | ||
| return s.useEffect(() => { | ||
| const i = o.subscribe((u) => a({ p: u })); | ||
| return () => i.unsubscribe(); | ||
| }, [o]), c.p; | ||
| } | ||
| function Bn(e = {}) { | ||
| const n = U(e.room), t = s.useMemo(() => ot(n), [n]), { name: r, metadata: o } = D(t, { | ||
| name: n.name, | ||
| metadata: n.metadata | ||
| }); | ||
| return { name: r, metadata: o }; | ||
| } | ||
| function Gt(e) { | ||
| const n = U(e == null ? void 0 : e.room), t = s.useMemo(() => at(n), [n]); | ||
| return D(t, n.activeSpeakers); | ||
| } | ||
| function jn(e) { | ||
| const [n, t] = s.useState( | ||
| ve(e) | ||
| ), r = Gt(); | ||
| return s.useEffect(() => { | ||
| t(ve(e)); | ||
| }, [r, e]), n; | ||
| } | ||
| function zn({ room: e, props: n }) { | ||
| const t = U(e), { className: r, roomAudioPlaybackAllowedObservable: o, handleStartAudioPlayback: c } = s.useMemo( | ||
| () => ct(), | ||
| [] | ||
| ), a = s.useMemo( | ||
| () => o(t), | ||
| [t, o] | ||
| ), { canPlayAudio: i } = D(a, { | ||
| canPlayAudio: t.canPlaybackAudio | ||
| }); | ||
| return { mergedProps: s.useMemo( | ||
| () => G(n, { | ||
| className: r, | ||
| onClick: () => { | ||
| c(t); | ||
| }, | ||
| style: { display: i ? "none" : "block" } | ||
| }), | ||
| [n, r, i, c, t] | ||
| ), canPlayAudio: i }; | ||
| } | ||
| function Wn({ room: e, props: n }) { | ||
| const t = U(e), { className: r, roomVideoPlaybackAllowedObservable: o, handleStartVideoPlayback: c } = s.useMemo( | ||
| () => it(), | ||
| [] | ||
| ), a = s.useMemo( | ||
| () => o(t), | ||
| [t, o] | ||
| ), { canPlayVideo: i } = D(a, { | ||
| canPlayVideo: t.canPlaybackVideo | ||
| }); | ||
| return { mergedProps: s.useMemo( | ||
| () => G(n, { | ||
| className: r, | ||
| onClick: () => { | ||
| c(t); | ||
| }, | ||
| style: { display: i ? "none" : "block" } | ||
| }), | ||
| [n, r, i, c, t] | ||
| ), canPlayVideo: i }; | ||
| } | ||
| function Gn(e, n = {}) { | ||
| const t = s.useRef(null), r = s.useRef(null), o = n.minSwipeDistance ?? 50, c = (u) => { | ||
| r.current = null, t.current = u.targetTouches[0].clientX; | ||
| }, a = (u) => { | ||
| r.current = u.targetTouches[0].clientX; | ||
| }, i = s.useCallback(() => { | ||
| if (!t.current || !r.current) | ||
| return; | ||
| const u = t.current - r.current, p = u > o, h = u < -o; | ||
| p && n.onLeftSwipe && n.onLeftSwipe(), h && n.onRightSwipe && n.onRightSwipe(); | ||
| }, [o, n]); | ||
| s.useEffect(() => { | ||
| const u = e.current; | ||
| return u && (u.addEventListener("touchstart", c, { passive: !0 }), u.addEventListener("touchmove", a, { passive: !0 }), u.addEventListener("touchend", i, { passive: !0 })), () => { | ||
| u && (u.removeEventListener("touchstart", c), u.removeEventListener("touchmove", a), u.removeEventListener("touchend", i)); | ||
| }; | ||
| }, [e, i]); | ||
| } | ||
| function Jn({ props: e }) { | ||
| const { dispatch: n, state: t } = Pe().widget, { className: r } = s.useMemo(() => ut(), []); | ||
| return { mergedProps: s.useMemo(() => G(e, { | ||
| className: r, | ||
| onClick: () => { | ||
| n && n({ msg: "toggle_chat" }); | ||
| }, | ||
| "aria-pressed": t != null && t.showChat ? "true" : "false", | ||
| "data-lk-unread-msgs": t ? t.unreadMessages < 10 ? t.unreadMessages.toFixed(0) : "9+" : "0" | ||
| }), [e, r, n, t]) }; | ||
| } | ||
| function $n(e, n, t = {}) { | ||
| const [r, o] = s.useState(void 0); | ||
| return s.useEffect(() => { | ||
| var a; | ||
| if (e === void 0) | ||
| throw Error("token endpoint needs to be defined"); | ||
| if (((a = t.userInfo) == null ? void 0 : a.identity) === void 0) | ||
| return; | ||
| (async () => { | ||
| V.debug("fetching token"); | ||
| const i = new URLSearchParams({ ...t.userInfo, roomName: n }), u = await fetch(`${e}?${i.toString()}`); | ||
| if (!u.ok) { | ||
| V.error( | ||
| `Could not fetch token. Server responded with status ${u.status}: ${u.statusText}` | ||
| ); | ||
| return; | ||
| } | ||
| const { accessToken: p } = await u.json(); | ||
| o(p); | ||
| })(); | ||
| }, [e, n, JSON.stringify(t)]), r; | ||
| } | ||
| function Qn(e) { | ||
| var c, a; | ||
| const n = ue(e), { className: t, mediaMutedObserver: r } = s.useMemo( | ||
| () => lt(n), | ||
| [le(n)] | ||
| ); | ||
| return { isMuted: D( | ||
| r, | ||
| !!((c = n.publication) != null && c.isMuted || (a = n.participant.getTrackPublication(n.source)) != null && a.isMuted) | ||
| ), className: t }; | ||
| } | ||
| function Kn({ | ||
| source: e, | ||
| onChange: n, | ||
| initialState: t, | ||
| captureOptions: r, | ||
| publishOptions: o, | ||
| onDeviceError: c, | ||
| room: a, | ||
| ...i | ||
| }) { | ||
| var m; | ||
| const u = de(), p = s.useMemo(() => a ?? u, [a, u]), h = (m = p == null ? void 0 : p.localParticipant) == null ? void 0 : m.getTrackPublication(e), d = s.useRef(!1), { toggle: l, className: v, pendingObserver: C, enabledObserver: k } = s.useMemo( | ||
| () => p ? dt(e, p, r, o, c) : ft(), | ||
| [p, e, JSON.stringify(r), o] | ||
| ), A = D(C, !1), w = D(k, t ?? !!(h != null && h.isEnabled)); | ||
| s.useEffect(() => { | ||
| n == null || n(w, d.current), d.current = !1; | ||
| }, [w, n]), s.useEffect(() => { | ||
| t !== void 0 && (V.debug("forcing initial toggle state", e, t), l(t)); | ||
| }, []); | ||
| const O = s.useMemo(() => G(i, { className: v }), [i, v]), R = s.useCallback( | ||
| (f) => { | ||
| var b; | ||
| d.current = !0, l().catch(() => d.current = !1), (b = i.onClick) == null || b.call(i, f); | ||
| }, | ||
| [i, l] | ||
| ); | ||
| return { | ||
| toggle: l, | ||
| enabled: w, | ||
| pending: A, | ||
| track: h, | ||
| buttonProps: { | ||
| ...O, | ||
| "aria-pressed": w, | ||
| "data-lk-source": e, | ||
| "data-lk-enabled": w, | ||
| disabled: A, | ||
| onClick: R | ||
| } | ||
| }; | ||
| } | ||
| function Yn(e = [ | ||
| E.Source.Camera, | ||
| E.Source.Microphone, | ||
| E.Source.ScreenShare, | ||
| E.Source.ScreenShareAudio, | ||
| E.Source.Unknown | ||
| ], n = {}) { | ||
| const t = U(n.room), [r, o] = s.useState([]), [c, a] = s.useState([]), i = s.useMemo(() => e.map((p) => mt(p) ? p.source : p), [JSON.stringify(e)]); | ||
| return s.useEffect(() => { | ||
| const p = pt(t, i, { | ||
| additionalRoomEvents: n.updateOnlyOn, | ||
| onlySubscribed: n.onlySubscribed | ||
| }).subscribe(({ trackReferences: h, participants: d }) => { | ||
| V.debug("setting track bundles", h, d), o(h), a(d); | ||
| }); | ||
| return () => p.unsubscribe(); | ||
| }, [ | ||
| t, | ||
| JSON.stringify(n.onlySubscribed), | ||
| JSON.stringify(n.updateOnlyOn), | ||
| JSON.stringify(e) | ||
| ]), s.useMemo(() => { | ||
| if (Re(e)) { | ||
| const p = $t(e, c), h = Array.from(r); | ||
| return c.forEach((d) => { | ||
| p.has(d.identity) && (p.get(d.identity) ?? []).forEach((v) => { | ||
| if (r.find( | ||
| ({ participant: k, publication: A }) => d.identity === k.identity && A.source === v | ||
| )) | ||
| return; | ||
| V.debug( | ||
| `Add ${v} placeholder for participant ${d.identity}.` | ||
| ); | ||
| const C = { | ||
| participant: d, | ||
| source: v | ||
| }; | ||
| h.push(C); | ||
| }); | ||
| }), h; | ||
| } else | ||
| return r; | ||
| }, [r, c, e]); | ||
| } | ||
| function Jt(e, n) { | ||
| const t = new Set(e); | ||
| for (const r of n) | ||
| t.delete(r); | ||
| return t; | ||
| } | ||
| function $t(e, n) { | ||
| const t = /* @__PURE__ */ new Map(); | ||
| if (Re(e)) { | ||
| const r = e.filter((o) => o.withPlaceholder).map((o) => o.source); | ||
| n.forEach((o) => { | ||
| const c = o.getTrackPublications().map((i) => { | ||
| var u; | ||
| return (u = i.track) == null ? void 0 : u.source; | ||
| }).filter((i) => i !== void 0), a = Array.from( | ||
| Jt(new Set(r), new Set(c)) | ||
| ); | ||
| a.length > 0 && t.set(o.identity, a); | ||
| }); | ||
| } | ||
| return t; | ||
| } | ||
| function Qt(e) { | ||
| const [n, t] = s.useState(ht(e)), { trackObserver: r } = s.useMemo(() => bt(e), [e.participant.sid ?? e.participant.identity, e.source]); | ||
| return s.useEffect(() => { | ||
| const o = r.subscribe((c) => { | ||
| t(c); | ||
| }); | ||
| return () => o == null ? void 0 : o.unsubscribe(); | ||
| }, [r]), { | ||
| participant: e.participant, | ||
| source: e.source ?? E.Source.Unknown, | ||
| publication: n | ||
| }; | ||
| } | ||
| function Xn(e, n) { | ||
| const t = Q(n); | ||
| return Qt({ name: e, participant: t }); | ||
| } | ||
| function Kt(e) { | ||
| const n = U(e == null ? void 0 : e.room), t = te(n), r = s.useMemo( | ||
| () => t === I.Disconnected, | ||
| [t] | ||
| ), o = s.useMemo( | ||
| () => gt(n, e), | ||
| [n, e, r] | ||
| ), c = D(o.isSendingObservable, !1), a = D(o.messageObservable, []); | ||
| return { send: o.send, chatMessages: a, isSending: c }; | ||
| } | ||
| function Zn(e = {}) { | ||
| const [n, t] = s.useState( | ||
| vt(e.defaults, e.preventLoad ?? !1) | ||
| ), r = s.useCallback((u) => { | ||
| t((p) => ({ ...p, audioEnabled: u })); | ||
| }, []), o = s.useCallback((u) => { | ||
| t((p) => ({ ...p, videoEnabled: u })); | ||
| }, []), c = s.useCallback((u) => { | ||
| t((p) => ({ ...p, audioDeviceId: u })); | ||
| }, []), a = s.useCallback((u) => { | ||
| t((p) => ({ ...p, videoDeviceId: u })); | ||
| }, []), i = s.useCallback((u) => { | ||
| t((p) => ({ ...p, username: u })); | ||
| }, []); | ||
| return s.useEffect(() => { | ||
| St(n, e.preventSave ?? !1); | ||
| }, [n, e.preventSave]), { | ||
| userChoices: n, | ||
| saveAudioInputEnabled: r, | ||
| saveVideoInputEnabled: o, | ||
| saveAudioInputDeviceId: c, | ||
| saveVideoInputDeviceId: a, | ||
| saveUsername: i | ||
| }; | ||
| } | ||
| function es(e, n = {}) { | ||
| const t = Q(e), r = U(n.room), o = s.useMemo(() => yt(r, t), [r, t]); | ||
| return D( | ||
| o, | ||
| t.isLocal ? t.isE2EEEnabled : !!(t != null && t.isEncrypted) | ||
| ); | ||
| } | ||
| function ts(e, n = { fftSize: 32, smoothingTimeConstant: 0 }) { | ||
| const t = Ct(e) ? e.publication.track : e, [r, o] = s.useState(0); | ||
| return s.useEffect(() => { | ||
| if (!t || !t.mediaStream) | ||
| return; | ||
| const { cleanup: c, analyser: a } = me(t, n), i = a.frequencyBinCount, u = new Uint8Array(i), h = setInterval(() => { | ||
| a.getByteFrequencyData(u); | ||
| let d = 0; | ||
| for (let l = 0; l < u.length; l++) { | ||
| const v = u[l]; | ||
| d += v * v; | ||
| } | ||
| o(Math.sqrt(d / u.length) / 255); | ||
| }, 1e3 / 30); | ||
| return () => { | ||
| c(), clearInterval(h); | ||
| }; | ||
| }, [t, t == null ? void 0 : t.mediaStream, JSON.stringify(n)]), r; | ||
| } | ||
| const Yt = (e) => { | ||
| const n = (t) => { | ||
| let c = 1 - Math.max(-100, Math.min(-10, t)) * -1 / 100; | ||
| return c = Math.sqrt(c), c; | ||
| }; | ||
| return e.map((t) => t === -1 / 0 ? 0 : n(t)); | ||
| }, Xt = { | ||
| bands: 5, | ||
| loPass: 100, | ||
| hiPass: 600, | ||
| updateInterval: 32, | ||
| analyserOptions: { fftSize: 2048 } | ||
| }; | ||
| function ns(e, n = {}) { | ||
| var a; | ||
| const t = e instanceof E ? e : (a = e == null ? void 0 : e.publication) == null ? void 0 : a.track, r = { ...Xt, ...n }, [o, c] = s.useState( | ||
| new Array(r.bands).fill(0) | ||
| ); | ||
| return s.useEffect(() => { | ||
| if (!t || !(t != null && t.mediaStream)) { | ||
| c((v) => v.slice().fill(0)); | ||
| return; | ||
| } | ||
| const { analyser: i, cleanup: u } = me(t, r.analyserOptions), p = i.frequencyBinCount, h = new Float32Array(p), l = setInterval(() => { | ||
| i.getFloatFrequencyData(h); | ||
| let v = new Float32Array(h.length); | ||
| for (let w = 0; w < h.length; w++) | ||
| v[w] = h[w]; | ||
| v = v.slice(n.loPass, n.hiPass); | ||
| const C = Yt(v), k = Math.ceil(C.length / r.bands), A = []; | ||
| for (let w = 0; w < r.bands; w++) { | ||
| const O = C.slice(w * k, (w + 1) * k).reduce((R, m) => R += m, 0); | ||
| A.push(O / k); | ||
| } | ||
| c(A); | ||
| }, r.updateInterval); | ||
| return () => { | ||
| u(), clearInterval(l); | ||
| }; | ||
| }, [t, t == null ? void 0 : t.mediaStream, JSON.stringify(n)]), o; | ||
| } | ||
| const Zt = { | ||
| barCount: 120, | ||
| volMultiplier: 5, | ||
| updateInterval: 20 | ||
| }; | ||
| function ss(e, n = {}) { | ||
| var h; | ||
| const t = e instanceof E ? e : (h = e == null ? void 0 : e.publication) == null ? void 0 : h.track, r = { ...Zt, ...n }, o = s.useRef(new Float32Array()), c = s.useRef(performance.now()), a = s.useRef(0), [i, u] = s.useState([]), p = s.useCallback((d) => { | ||
| u( | ||
| Array.from( | ||
| tn(d, r.barCount).map((l) => Math.sqrt(l) * r.volMultiplier) | ||
| // wave.slice(0, opts.barCount).map((v) => sigmoid(v * opts.volMultiplier, 0.08, 0.2)), | ||
| ) | ||
| ); | ||
| }, []); | ||
| return s.useEffect(() => { | ||
| if (!t || !(t != null && t.mediaStream)) | ||
| return; | ||
| const { analyser: d, cleanup: l } = me(t, { | ||
| fftSize: ye(r.barCount) | ||
| }), v = ye(r.barCount), C = new Float32Array(v), k = () => { | ||
| if (A = requestAnimationFrame(k), d.getFloatTimeDomainData(C), o.current.map((w, O) => w + C[O]), a.current += 1, performance.now() - c.current >= r.updateInterval) { | ||
| const w = C.map((O) => O / a.current); | ||
| p(w), c.current = performance.now(), a.current = 0; | ||
| } | ||
| }; | ||
| let A = requestAnimationFrame(k); | ||
| return () => { | ||
| l(), cancelAnimationFrame(A); | ||
| }; | ||
| }, [t, t == null ? void 0 : t.mediaStream, JSON.stringify(n), p]), { | ||
| bars: i | ||
| }; | ||
| } | ||
| function ye(e) { | ||
| return e < 32 ? 32 : en(e); | ||
| } | ||
| function en(e) { | ||
| let n = 2; | ||
| for (; e >>= 1; ) | ||
| n <<= 1; | ||
| return n; | ||
| } | ||
| function tn(e, n) { | ||
| const t = Math.floor(e.length / n), r = new Float32Array(n); | ||
| for (let o = 0; o < n; o++) { | ||
| const c = t * o; | ||
| let a = 0; | ||
| for (let i = 0; i < t; i++) | ||
| a = a + Math.abs(e[c + i]); | ||
| r[o] = a / t; | ||
| } | ||
| return r; | ||
| } | ||
| function re(e, n = {}) { | ||
| let t, r; | ||
| typeof n == "string" ? t = n : (t = n == null ? void 0 : n.participantIdentity, r = n == null ? void 0 : n.room); | ||
| const o = fe(), c = Wt({ room: r, updateOnlyOn: [] }), a = s.useMemo(() => t ? c.find((p) => p.identity === t) : o, [t, c, o]), i = s.useMemo(() => { | ||
| if (a) | ||
| return Mt(a, { sources: e }); | ||
| }, [a, JSON.stringify(e)]); | ||
| return D(i, []); | ||
| } | ||
| function nn(e) { | ||
| var t, r, o; | ||
| const n = s.useMemo( | ||
| () => { | ||
| var c; | ||
| return (c = e == null ? void 0 : e.publication) != null && c.track ? Tt(e == null ? void 0 : e.publication.track) : void 0; | ||
| }, | ||
| [(t = e == null ? void 0 : e.publication) == null ? void 0 : t.track] | ||
| ); | ||
| return D(n, { | ||
| timestamp: Date.now(), | ||
| rtpTimestamp: (o = (r = e == null ? void 0 : e.publication) == null ? void 0 : r.track) == null ? void 0 : o.rtpTimestamp | ||
| }); | ||
| } | ||
| const sn = { | ||
| bufferSize: 100 | ||
| // maxAge: 2_000, | ||
| }; | ||
| function rn(e, n) { | ||
| const t = { ...sn, ...n }, [r, o] = s.useState([]), c = nn(e), a = (i) => { | ||
| var u; | ||
| (u = t.onTranscription) == null || u.call(t, i), o( | ||
| (p) => kt( | ||
| p, | ||
| // when first receiving a segment, add the current media timestamp to it | ||
| i.map((h) => wt(h, c)), | ||
| t.bufferSize | ||
| ) | ||
| ); | ||
| }; | ||
| return s.useEffect(() => { | ||
| if (!(e != null && e.publication)) | ||
| return; | ||
| const i = Et(e.publication).subscribe((u) => { | ||
| a(...u); | ||
| }); | ||
| return () => { | ||
| i.unsubscribe(); | ||
| }; | ||
| }, [e && le(e), a]), { segments: r }; | ||
| } | ||
| function on(e = {}) { | ||
| const n = fe(), t = e.participant ?? n, r = s.useMemo( | ||
| // weird typescript constraint | ||
| () => t ? ie(t) : ie(t), | ||
| [t] | ||
| ); | ||
| return D(r, { | ||
| attributes: t == null ? void 0 : t.attributes | ||
| }); | ||
| } | ||
| function rs(e, n = {}) { | ||
| const t = Q(n.participant), [r, o] = s.useState(t.attributes[e]); | ||
| return s.useEffect(() => { | ||
| if (!t) | ||
| return; | ||
| const c = ie(t).subscribe((a) => { | ||
| a.changed[e] !== void 0 && o(a.attributes[e]); | ||
| }); | ||
| return () => { | ||
| c.unsubscribe(); | ||
| }; | ||
| }, [t, e]), r; | ||
| } | ||
| const Ce = W.AgentState; | ||
| function os() { | ||
| const e = pe(), n = e.find( | ||
| (d) => d.kind === se.AGENT && !(W.PublishOnBehalf in d.attributes) | ||
| ), t = e.find( | ||
| (d) => d.kind === se.AGENT && d.attributes[W.PublishOnBehalf] === (n == null ? void 0 : n.identity) | ||
| ), r = re( | ||
| [E.Source.Microphone, E.Source.Camera], | ||
| n == null ? void 0 : n.identity | ||
| ), o = re( | ||
| [E.Source.Microphone, E.Source.Camera], | ||
| t == null ? void 0 : t.identity | ||
| ), c = r.find((d) => d.source === E.Source.Microphone) ?? o.find((d) => d.source === E.Source.Microphone), a = r.find((d) => d.source === E.Source.Camera) ?? o.find((d) => d.source === E.Source.Camera), { segments: i } = rn(c), u = te(), { attributes: p } = on({ participant: n }), h = s.useMemo(() => u === I.Disconnected ? "disconnected" : u === I.Connecting || !n || !(p != null && p[Ce]) ? "connecting" : p[Ce], [p, n, u]); | ||
| return { | ||
| agent: n, | ||
| state: h, | ||
| audioTrack: c, | ||
| videoTrack: a, | ||
| agentTranscriptions: i, | ||
| agentAttributes: p | ||
| }; | ||
| } | ||
| function as(e) { | ||
| const n = U(e), t = te(n), r = s.useMemo(() => Pt(n), [n, t]); | ||
| return D(r, n.isRecording); | ||
| } | ||
| function an(e, n) { | ||
| const t = U(n == null ? void 0 : n.room), o = te(t) === I.Disconnected, c = s.useMemo(() => Lt(t, e), [t, e]); | ||
| return { textStreams: D(o ? void 0 : c, []) }; | ||
| } | ||
| function cn(e) { | ||
| const { participantIdentities: n, trackSids: t } = e ?? {}, { textStreams: r } = an(At.TRANSCRIPTION, { room: e == null ? void 0 : e.room }); | ||
| return s.useMemo( | ||
| () => r.filter( | ||
| (c) => n ? n.includes(c.participantInfo.identity) : !0 | ||
| ).filter( | ||
| (c) => { | ||
| var a; | ||
| return t ? t.includes( | ||
| ((a = c.streamInfo.attributes) == null ? void 0 : a[W.TranscribedTrackId]) ?? "" | ||
| ) : !0; | ||
| } | ||
| ), | ||
| [r, n, t] | ||
| ); | ||
| } | ||
| const Me = 2, Te = 400, Ee = 3, ke = 1e3; | ||
| function cs(e) { | ||
| const n = ae([]), t = Ne(() => new Nt(), []), r = ee(async () => t.lock().then(async (h) => { | ||
| for (; ; ) { | ||
| const d = n.current.pop(); | ||
| if (!d) { | ||
| h(); | ||
| break; | ||
| } | ||
| switch (d.type) { | ||
| case "connect": | ||
| await d.room.connect(...d.args).then(d.resolve).catch(d.reject); | ||
| break; | ||
| case "disconnect": | ||
| await d.room.disconnect(...d.args).then(d.resolve).catch(d.reject); | ||
| break; | ||
| } | ||
| } | ||
| }), []), o = ae([]), c = ee((h) => { | ||
| let d = 0; | ||
| o.current = o.current.filter((l) => { | ||
| const v = h.getTime() - l.getTime() < ke; | ||
| return v && (d += 1), v; | ||
| }), d > Ee && V.warn( | ||
| `useSequentialRoomConnectDisconnect: room changed reference rapidly (over ${Ee}x in ${ke}ms). This is not recommended.` | ||
| ); | ||
| }, []); | ||
| _e(() => { | ||
| n.current = []; | ||
| const h = /* @__PURE__ */ new Date(); | ||
| o.current.push(h), c(h); | ||
| }, [e, c]); | ||
| const a = ae([]), i = ee((h) => { | ||
| let d = 0; | ||
| a.current = a.current.filter((l) => { | ||
| const v = h.getTime() - l.getTime() < Te; | ||
| return v && (d += 1), v; | ||
| }), d > Me && V.warn( | ||
| `useSequentialRoomConnectDisconnect: room connect / disconnect occurring in rapid sequence (over ${Me}x in ${Te}ms). This is not recommended and may be the sign of a bug like a useEffect dependency changing every render.` | ||
| ); | ||
| }, []), u = ee( | ||
| async (...h) => new Promise((d, l) => { | ||
| if (!e) | ||
| throw new Error("Called connect(), but room was unset"); | ||
| const v = /* @__PURE__ */ new Date(); | ||
| i(v), n.current.push({ type: "connect", room: e, args: h, resolve: d, reject: l }), a.current.push(v), r(); | ||
| }), | ||
| [e, i, r] | ||
| ), p = ee( | ||
| async (...h) => new Promise((d, l) => { | ||
| if (!e) | ||
| throw new Error("Called discconnect(), but room was unset"); | ||
| const v = /* @__PURE__ */ new Date(); | ||
| i(v), n.current.push({ type: "disconnect", room: e, args: h, resolve: d, reject: l }), a.current.push(v), r(); | ||
| }), | ||
| [e, i, r] | ||
| ); | ||
| return { | ||
| connect: e ? u : null, | ||
| disconnect: e ? p : null | ||
| }; | ||
| } | ||
| var ne = { exports: {} }, we; | ||
| function un() { | ||
| if (we) return ne.exports; | ||
| we = 1; | ||
| var e = typeof Reflect == "object" ? Reflect : null, n = e && typeof e.apply == "function" ? e.apply : function(f, b, g) { | ||
| return Function.prototype.apply.call(f, b, g); | ||
| }, t; | ||
| e && typeof e.ownKeys == "function" ? t = e.ownKeys : Object.getOwnPropertySymbols ? t = function(f) { | ||
| return Object.getOwnPropertyNames(f).concat(Object.getOwnPropertySymbols(f)); | ||
| } : t = function(f) { | ||
| return Object.getOwnPropertyNames(f); | ||
| }; | ||
| function r(m) { | ||
| console && console.warn && console.warn(m); | ||
| } | ||
| var o = Number.isNaN || function(f) { | ||
| return f !== f; | ||
| }; | ||
| function c() { | ||
| c.init.call(this); | ||
| } | ||
| ne.exports = c, ne.exports.once = w, c.EventEmitter = c, c.prototype._events = void 0, c.prototype._eventsCount = 0, c.prototype._maxListeners = void 0; | ||
| var a = 10; | ||
| function i(m) { | ||
| if (typeof m != "function") | ||
| throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof m); | ||
| } | ||
| Object.defineProperty(c, "defaultMaxListeners", { | ||
| enumerable: !0, | ||
| get: function() { | ||
| return a; | ||
| }, | ||
| set: function(m) { | ||
| if (typeof m != "number" || m < 0 || o(m)) | ||
| throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received ' + m + "."); | ||
| a = m; | ||
| } | ||
| }), c.init = function() { | ||
| (this._events === void 0 || this._events === Object.getPrototypeOf(this)._events) && (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0), this._maxListeners = this._maxListeners || void 0; | ||
| }, c.prototype.setMaxListeners = function(f) { | ||
| if (typeof f != "number" || f < 0 || o(f)) | ||
| throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received ' + f + "."); | ||
| return this._maxListeners = f, this; | ||
| }; | ||
| function u(m) { | ||
| return m._maxListeners === void 0 ? c.defaultMaxListeners : m._maxListeners; | ||
| } | ||
| c.prototype.getMaxListeners = function() { | ||
| return u(this); | ||
| }, c.prototype.emit = function(f) { | ||
| for (var b = [], g = 1; g < arguments.length; g++) b.push(arguments[g]); | ||
| var y = f === "error", T = this._events; | ||
| if (T !== void 0) | ||
| y = y && T.error === void 0; | ||
| else if (!y) | ||
| return !1; | ||
| if (y) { | ||
| var M; | ||
| if (b.length > 0 && (M = b[0]), M instanceof Error) | ||
| throw M; | ||
| var P = new Error("Unhandled error." + (M ? " (" + M.message + ")" : "")); | ||
| throw P.context = M, P; | ||
| } | ||
| var F = T[f]; | ||
| if (F === void 0) | ||
| return !1; | ||
| if (typeof F == "function") | ||
| n(F, this, b); | ||
| else | ||
| for (var q = F.length, J = C(F, q), g = 0; g < q; ++g) | ||
| n(J[g], this, b); | ||
| return !0; | ||
| }; | ||
| function p(m, f, b, g) { | ||
| var y, T, M; | ||
| if (i(b), T = m._events, T === void 0 ? (T = m._events = /* @__PURE__ */ Object.create(null), m._eventsCount = 0) : (T.newListener !== void 0 && (m.emit( | ||
| "newListener", | ||
| f, | ||
| b.listener ? b.listener : b | ||
| ), T = m._events), M = T[f]), M === void 0) | ||
| M = T[f] = b, ++m._eventsCount; | ||
| else if (typeof M == "function" ? M = T[f] = g ? [b, M] : [M, b] : g ? M.unshift(b) : M.push(b), y = u(m), y > 0 && M.length > y && !M.warned) { | ||
| M.warned = !0; | ||
| var P = new Error("Possible EventEmitter memory leak detected. " + M.length + " " + String(f) + " listeners added. Use emitter.setMaxListeners() to increase limit"); | ||
| P.name = "MaxListenersExceededWarning", P.emitter = m, P.type = f, P.count = M.length, r(P); | ||
| } | ||
| return m; | ||
| } | ||
| c.prototype.addListener = function(f, b) { | ||
| return p(this, f, b, !1); | ||
| }, c.prototype.on = c.prototype.addListener, c.prototype.prependListener = function(f, b) { | ||
| return p(this, f, b, !0); | ||
| }; | ||
| function h() { | ||
| if (!this.fired) | ||
| return this.target.removeListener(this.type, this.wrapFn), this.fired = !0, arguments.length === 0 ? this.listener.call(this.target) : this.listener.apply(this.target, arguments); | ||
| } | ||
| function d(m, f, b) { | ||
| var g = { fired: !1, wrapFn: void 0, target: m, type: f, listener: b }, y = h.bind(g); | ||
| return y.listener = b, g.wrapFn = y, y; | ||
| } | ||
| c.prototype.once = function(f, b) { | ||
| return i(b), this.on(f, d(this, f, b)), this; | ||
| }, c.prototype.prependOnceListener = function(f, b) { | ||
| return i(b), this.prependListener(f, d(this, f, b)), this; | ||
| }, c.prototype.removeListener = function(f, b) { | ||
| var g, y, T, M, P; | ||
| if (i(b), y = this._events, y === void 0) | ||
| return this; | ||
| if (g = y[f], g === void 0) | ||
| return this; | ||
| if (g === b || g.listener === b) | ||
| --this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : (delete y[f], y.removeListener && this.emit("removeListener", f, g.listener || b)); | ||
| else if (typeof g != "function") { | ||
| for (T = -1, M = g.length - 1; M >= 0; M--) | ||
| if (g[M] === b || g[M].listener === b) { | ||
| P = g[M].listener, T = M; | ||
| break; | ||
| } | ||
| if (T < 0) | ||
| return this; | ||
| T === 0 ? g.shift() : k(g, T), g.length === 1 && (y[f] = g[0]), y.removeListener !== void 0 && this.emit("removeListener", f, P || b); | ||
| } | ||
| return this; | ||
| }, c.prototype.off = c.prototype.removeListener, c.prototype.removeAllListeners = function(f) { | ||
| var b, g, y; | ||
| if (g = this._events, g === void 0) | ||
| return this; | ||
| if (g.removeListener === void 0) | ||
| return arguments.length === 0 ? (this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0) : g[f] !== void 0 && (--this._eventsCount === 0 ? this._events = /* @__PURE__ */ Object.create(null) : delete g[f]), this; | ||
| if (arguments.length === 0) { | ||
| var T = Object.keys(g), M; | ||
| for (y = 0; y < T.length; ++y) | ||
| M = T[y], M !== "removeListener" && this.removeAllListeners(M); | ||
| return this.removeAllListeners("removeListener"), this._events = /* @__PURE__ */ Object.create(null), this._eventsCount = 0, this; | ||
| } | ||
| if (b = g[f], typeof b == "function") | ||
| this.removeListener(f, b); | ||
| else if (b !== void 0) | ||
| for (y = b.length - 1; y >= 0; y--) | ||
| this.removeListener(f, b[y]); | ||
| return this; | ||
| }; | ||
| function l(m, f, b) { | ||
| var g = m._events; | ||
| if (g === void 0) | ||
| return []; | ||
| var y = g[f]; | ||
| return y === void 0 ? [] : typeof y == "function" ? b ? [y.listener || y] : [y] : b ? A(y) : C(y, y.length); | ||
| } | ||
| c.prototype.listeners = function(f) { | ||
| return l(this, f, !0); | ||
| }, c.prototype.rawListeners = function(f) { | ||
| return l(this, f, !1); | ||
| }, c.listenerCount = function(m, f) { | ||
| return typeof m.listenerCount == "function" ? m.listenerCount(f) : v.call(m, f); | ||
| }, c.prototype.listenerCount = v; | ||
| function v(m) { | ||
| var f = this._events; | ||
| if (f !== void 0) { | ||
| var b = f[m]; | ||
| if (typeof b == "function") | ||
| return 1; | ||
| if (b !== void 0) | ||
| return b.length; | ||
| } | ||
| return 0; | ||
| } | ||
| c.prototype.eventNames = function() { | ||
| return this._eventsCount > 0 ? t(this._events) : []; | ||
| }; | ||
| function C(m, f) { | ||
| for (var b = new Array(f), g = 0; g < f; ++g) | ||
| b[g] = m[g]; | ||
| return b; | ||
| } | ||
| function k(m, f) { | ||
| for (; f + 1 < m.length; f++) | ||
| m[f] = m[f + 1]; | ||
| m.pop(); | ||
| } | ||
| function A(m) { | ||
| for (var f = new Array(m.length), b = 0; b < f.length; ++b) | ||
| f[b] = m[b].listener || m[b]; | ||
| return f; | ||
| } | ||
| function w(m, f) { | ||
| return new Promise(function(b, g) { | ||
| function y(M) { | ||
| m.removeListener(f, T), g(M); | ||
| } | ||
| function T() { | ||
| typeof m.removeListener == "function" && m.removeListener("error", y), b([].slice.call(arguments)); | ||
| } | ||
| R(m, f, T, { once: !0 }), f !== "error" && O(m, y, { once: !0 }); | ||
| }); | ||
| } | ||
| function O(m, f, b) { | ||
| typeof m.on == "function" && R(m, "error", f, b); | ||
| } | ||
| function R(m, f, b, g) { | ||
| if (typeof m.on == "function") | ||
| g.once ? m.once(f, b) : m.on(f, b); | ||
| else if (typeof m.addEventListener == "function") | ||
| m.addEventListener(f, function y(T) { | ||
| g.once && m.removeEventListener(f, y), b(T); | ||
| }); | ||
| else | ||
| throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type ' + typeof m); | ||
| } | ||
| return ne.exports; | ||
| } | ||
| var he = un(); | ||
| const ln = 2e4; | ||
| var dn = /* @__PURE__ */ ((e) => (e.CameraChanged = "cameraChanged", e.MicrophoneChanged = "microphoneChanged", e.StateChanged = "stateChanged", e))(dn || {}); | ||
| const x = (e) => ({ | ||
| isConnected: e === "listening" || e === "thinking" || e === "speaking", | ||
| canListen: e === "pre-connect-buffering" || e === "listening" || e === "thinking" || e === "speaking", | ||
| isFinished: e === "disconnected" || e === "failed", | ||
| isPending: e === "connecting" || e === "initializing" || e === "idle" | ||
| }), fn = () => { | ||
| const [e, n] = s.useState( | ||
| null | ||
| ), [t, r] = s.useState( | ||
| null | ||
| ), o = s.useRef("connecting"), c = s.useRef(!1), a = (i) => setTimeout(() => { | ||
| if (!c.current) { | ||
| n("Agent did not join the room."); | ||
| return; | ||
| } | ||
| const { isConnected: u } = x(o.current); | ||
| if (!u) { | ||
| n("Agent joined the room but did not complete initializing."); | ||
| return; | ||
| } | ||
| }, i ?? ln); | ||
| return { | ||
| agentTimeoutFailureReason: e, | ||
| startAgentTimeout: s.useCallback( | ||
| (i) => { | ||
| t && clearTimeout(t), n(null), r(a(i)), o.current = "connecting", c.current = !1; | ||
| }, | ||
| [t] | ||
| ), | ||
| clearAgentTimeout: s.useCallback(() => { | ||
| t && clearTimeout(t), n(null), r(null), o.current = "connecting", c.current = !1; | ||
| }, [t]), | ||
| clearAgentTimeoutFailureReason: s.useCallback(() => { | ||
| n(null); | ||
| }, []), | ||
| updateAgentTimeoutState: s.useCallback((i) => { | ||
| o.current = i; | ||
| }, []), | ||
| updateAgentTimeoutParticipantExists: s.useCallback((i) => { | ||
| c.current = i; | ||
| }, []) | ||
| }; | ||
| }; | ||
| function mn(e, n) { | ||
| const t = s.useRef(n); | ||
| s.useEffect(() => { | ||
| t.current = n; | ||
| }, [n]); | ||
| const r = s.useCallback( | ||
| async (a) => { | ||
| const { isConnected: i } = x(t.current); | ||
| if (!i) | ||
| return new Promise((u, p) => { | ||
| const h = (v) => { | ||
| const { isConnected: C } = x(v); | ||
| C && (l(), u()); | ||
| }, d = () => { | ||
| l(), p(new Error("useAgent(/* ... */).waitUntilConnected - signal aborted")); | ||
| }, l = () => { | ||
| e.off("stateChanged", h), a == null || a.removeEventListener("abort", d); | ||
| }; | ||
| e.on("stateChanged", h), a == null || a.addEventListener("abort", d); | ||
| }); | ||
| }, | ||
| [e] | ||
| ), o = s.useCallback( | ||
| async (a) => { | ||
| const { canListen: i } = x(t.current); | ||
| if (!i) | ||
| return new Promise((u, p) => { | ||
| const h = (v) => { | ||
| const { canListen: C } = x(v); | ||
| C && (l(), u()); | ||
| }, d = () => { | ||
| l(), p(new Error("useAgent(/* ... */).waitUntilCouldBeListening - signal aborted")); | ||
| }, l = () => { | ||
| e.off("stateChanged", h), a == null || a.removeEventListener("abort", d); | ||
| }; | ||
| e.on("stateChanged", h), a == null || a.addEventListener("abort", d); | ||
| }); | ||
| }, | ||
| [e] | ||
| ), c = s.useCallback( | ||
| async (a) => { | ||
| const { isFinished: i } = x(t.current); | ||
| if (!i) | ||
| return new Promise((u, p) => { | ||
| const h = (v) => { | ||
| const { isFinished: C } = x(v); | ||
| C && (l(), u()); | ||
| }, d = () => { | ||
| l(), p(new Error("useAgent(/* ... */).waitUntilFinished - signal aborted")); | ||
| }, l = () => { | ||
| e.off("stateChanged", h), a == null || a.removeEventListener("abort", d); | ||
| }; | ||
| e.on("stateChanged", h), a == null || a.addEventListener("abort", d); | ||
| }); | ||
| }, | ||
| [e] | ||
| ); | ||
| return { waitUntilConnected: r, waitUntilCouldBeListening: o, waitUntilFinished: c }; | ||
| } | ||
| function Ie(e) { | ||
| const n = Rt(); | ||
| if (e = e ?? n, !e) | ||
| throw new Error( | ||
| "No session provided, make sure you are inside a Session context or pass the session explicitly" | ||
| ); | ||
| const { | ||
| room: t, | ||
| internal: { | ||
| agentConnectTimeoutMilliseconds: r, | ||
| agentTimeoutFailureReason: o, | ||
| startAgentTimeout: c, | ||
| clearAgentTimeout: a, | ||
| clearAgentTimeoutFailureReason: i, | ||
| updateAgentTimeoutState: u, | ||
| updateAgentTimeoutParticipantExists: p | ||
| } | ||
| } = e, h = s.useMemo(() => new he.EventEmitter(), []), d = pe({ room: t }), l = s.useMemo(() => d.find( | ||
| (S) => S.kind === se.AGENT && !(W.PublishOnBehalf in S.attributes) | ||
| ) ?? null, [d]), v = s.useMemo(() => l ? d.find( | ||
| (S) => S.kind === se.AGENT && S.attributes[W.PublishOnBehalf] === l.identity | ||
| ) ?? null : null, [l, d]), [C, k] = s.useState({}); | ||
| s.useEffect(() => { | ||
| if (!l) | ||
| return; | ||
| const S = (_) => { | ||
| k(_); | ||
| }; | ||
| return l.on(X.AttributesChanged, S), () => { | ||
| l.off(X.AttributesChanged, S); | ||
| }; | ||
| }, [l, h]); | ||
| const A = re([E.Source.Camera, E.Source.Microphone], { | ||
| room: t, | ||
| participantIdentity: l == null ? void 0 : l.identity | ||
| }), w = re([E.Source.Camera, E.Source.Microphone], { | ||
| room: t, | ||
| participantIdentity: v == null ? void 0 : v.identity | ||
| }), O = s.useMemo( | ||
| () => A.find((S) => S.source === E.Source.Camera) ?? w.find((S) => S.source === E.Source.Camera), | ||
| [A, w] | ||
| ); | ||
| s.useEffect(() => { | ||
| h.emit("cameraChanged", O); | ||
| }, [h, O]); | ||
| const R = s.useMemo( | ||
| () => A.find((S) => S.source === E.Source.Microphone) ?? w.find((S) => S.source === E.Source.Microphone), | ||
| [A, w] | ||
| ); | ||
| s.useEffect(() => { | ||
| h.emit("microphoneChanged", R); | ||
| }, [h, R]); | ||
| const [m, f] = s.useState(t.state); | ||
| s.useEffect(() => { | ||
| const S = (_) => { | ||
| f(_); | ||
| }; | ||
| return t.on(H.ConnectionStateChanged, S), () => { | ||
| t.off(H.ConnectionStateChanged, S); | ||
| }; | ||
| }, [t]), s.useEffect(() => { | ||
| l && i(); | ||
| }, [l]); | ||
| const [b, g] = s.useState(null); | ||
| s.useEffect(() => { | ||
| if (!l) | ||
| return; | ||
| const S = (_) => { | ||
| _.identity === (l == null ? void 0 : l.identity) && g("Agent left the room unexpectedly."); | ||
| }; | ||
| return t.on(H.ParticipantDisconnected, S), () => { | ||
| t.off(H.ParticipantDisconnected, S); | ||
| }; | ||
| }, [l, t]), s.useEffect(() => { | ||
| m === I.Disconnected && g(null); | ||
| }, [m]); | ||
| const [y, T] = s.useState( | ||
| () => t.localParticipant.getTrackPublication(E.Source.Microphone) ?? null | ||
| ); | ||
| s.useEffect(() => { | ||
| const S = () => { | ||
| T(t.localParticipant.getTrackPublication(E.Source.Microphone) ?? null); | ||
| }, _ = () => { | ||
| T(null); | ||
| }; | ||
| return t.localParticipant.on( | ||
| X.LocalTrackPublished, | ||
| S | ||
| ), t.localParticipant.on( | ||
| X.LocalTrackUnpublished, | ||
| _ | ||
| ), () => { | ||
| t.localParticipant.off( | ||
| X.LocalTrackPublished, | ||
| S | ||
| ), t.localParticipant.off( | ||
| X.LocalTrackUnpublished, | ||
| _ | ||
| ); | ||
| }; | ||
| }, [t.localParticipant]); | ||
| const M = s.useMemo(() => { | ||
| const S = []; | ||
| return o && S.push(o), b && S.push(b), S; | ||
| }, [o, b]), P = s.useMemo(() => { | ||
| if (M.length > 0) | ||
| return "failed"; | ||
| let S = "disconnected"; | ||
| return m !== I.Disconnected && (S = "connecting"), y && (S = "pre-connect-buffering"), l && C[W.AgentState] && (S = C[W.AgentState]), S; | ||
| }, [ | ||
| M, | ||
| m, | ||
| y, | ||
| l, | ||
| C | ||
| ]); | ||
| s.useEffect(() => { | ||
| h.emit("stateChanged", P), u(P); | ||
| }, [h, P]), s.useEffect(() => { | ||
| p(l !== null); | ||
| }, [l]); | ||
| const F = e.connectionState === "disconnected"; | ||
| s.useEffect(() => { | ||
| if (!F) | ||
| return c(r), () => { | ||
| a(); | ||
| }; | ||
| }, [F, r]); | ||
| const q = s.useMemo(() => { | ||
| const S = { | ||
| attributes: C, | ||
| internal: { | ||
| agentParticipant: l, | ||
| workerParticipant: v, | ||
| emitter: h | ||
| } | ||
| }; | ||
| switch (P) { | ||
| case "disconnected": | ||
| return { | ||
| ...S, | ||
| state: P, | ||
| ...x(P), | ||
| failureReasons: null, | ||
| // Clear inner values if no longer connected | ||
| cameraTrack: void 0, | ||
| microphoneTrack: void 0 | ||
| }; | ||
| case "connecting": | ||
| return { | ||
| ...S, | ||
| state: P, | ||
| ...x(P), | ||
| failureReasons: null, | ||
| // Clear inner values if no longer connected | ||
| cameraTrack: void 0, | ||
| microphoneTrack: void 0 | ||
| }; | ||
| case "initializing": | ||
| case "idle": | ||
| return { | ||
| ...S, | ||
| state: P, | ||
| ...x(P), | ||
| failureReasons: null, | ||
| cameraTrack: O, | ||
| microphoneTrack: R | ||
| }; | ||
| case "pre-connect-buffering": | ||
| return { | ||
| ...S, | ||
| state: P, | ||
| ...x(P), | ||
| failureReasons: null, | ||
| cameraTrack: O, | ||
| microphoneTrack: R | ||
| }; | ||
| case "listening": | ||
| case "thinking": | ||
| case "speaking": | ||
| return { | ||
| ...S, | ||
| state: P, | ||
| ...x(P), | ||
| failureReasons: null, | ||
| cameraTrack: O, | ||
| microphoneTrack: R | ||
| }; | ||
| case "failed": | ||
| return { | ||
| ...S, | ||
| state: "failed", | ||
| ...x("failed"), | ||
| failureReasons: M, | ||
| // Clear inner values if no longer connected | ||
| cameraTrack: void 0, | ||
| microphoneTrack: void 0 | ||
| }; | ||
| } | ||
| }, [C, h, l, P, O, R]), { waitUntilConnected: J, waitUntilCouldBeListening: K, waitUntilFinished: L } = mn(h, P), N = s.useCallback( | ||
| (S) => new Promise((_, Y) => { | ||
| const B = (z) => { | ||
| z && ($(), _(z)); | ||
| }, j = () => { | ||
| $(), Y(new Error("useAgent(/* ... */).waitUntilCamera - signal aborted")); | ||
| }, $ = () => { | ||
| h.off("cameraChanged", B), S == null || S.removeEventListener("abort", j); | ||
| }; | ||
| h.on("cameraChanged", B), S == null || S.addEventListener("abort", j); | ||
| }), | ||
| [h] | ||
| ), Z = s.useCallback( | ||
| (S) => new Promise((_, Y) => { | ||
| const B = (z) => { | ||
| z && ($(), _(z)); | ||
| }, j = () => { | ||
| $(), Y(new Error("useAgent(/* ... */).waitUntilMicrophone - signal aborted")); | ||
| }, $ = () => { | ||
| h.off("microphoneChanged", B), S == null || S.removeEventListener("abort", j); | ||
| }; | ||
| h.on("microphoneChanged", B), S == null || S.addEventListener("abort", j); | ||
| }), | ||
| [h] | ||
| ); | ||
| return s.useMemo(() => ({ | ||
| ...q, | ||
| waitUntilConnected: J, | ||
| waitUntilCouldBeListening: K, | ||
| waitUntilFinished: L, | ||
| waitUntilCamera: N, | ||
| waitUntilMicrophone: Z | ||
| }), [ | ||
| q, | ||
| J, | ||
| K, | ||
| L, | ||
| N, | ||
| Z | ||
| ]); | ||
| } | ||
| var pn = /* @__PURE__ */ ((e) => (e.ConnectionStateChanged = "connectionStateChanged", e.MediaDevicesError = "mediaDevicesError", e.EncryptionError = "encryptionError", e))(pn || {}); | ||
| function hn(e, n) { | ||
| const t = /* @__PURE__ */ new Set([...Object.keys(e), ...Object.keys(n)]); | ||
| for (const r of t) | ||
| switch (r) { | ||
| case "roomName": | ||
| case "participantName": | ||
| case "participantIdentity": | ||
| case "participantMetadata": | ||
| case "participantAttributes": | ||
| case "agentName": | ||
| case "agentMetadata": | ||
| if (e[r] !== n[r]) | ||
| return !1; | ||
| break; | ||
| default: | ||
| const o = r; | ||
| throw new Error(`Options key ${o} not being checked for equality!`); | ||
| } | ||
| return !0; | ||
| } | ||
| function bn(e, n) { | ||
| const t = s.useRef(n); | ||
| return s.useEffect(() => { | ||
| t.current = n; | ||
| }, [n]), s.useCallback( | ||
| async (o, c) => { | ||
| if (t.current !== o) | ||
| return new Promise((a, i) => { | ||
| const u = (d) => { | ||
| d === o && (h(), a()); | ||
| }, p = () => { | ||
| h(), i( | ||
| new Error( | ||
| `useSession(/* ... */).waitUntilConnectionState(${o}, /* signal */) - signal aborted` | ||
| ) | ||
| ); | ||
| }, h = () => { | ||
| e.off("connectionStateChanged", u), c == null || c.removeEventListener("abort", p); | ||
| }; | ||
| e.on("connectionStateChanged", u), c == null || c.addEventListener("abort", p); | ||
| }); | ||
| }, | ||
| [e] | ||
| ); | ||
| } | ||
| function gn(e, n) { | ||
| const t = e instanceof Ft, r = s.useRef( | ||
| t ? n : null | ||
| ); | ||
| return s.useEffect(() => { | ||
| if (!t) { | ||
| r.current = null; | ||
| return; | ||
| } | ||
| r.current !== null && hn(r.current, n) || (r.current = n); | ||
| }, [t, n]), s.useCallback(async () => { | ||
| if (t) { | ||
| if (!r.current) | ||
| throw new Error( | ||
| "AgentSession - memoized token fetch options are not set, but the passed tokenSource was an instance of TokenSourceConfigurable. If you are seeing this please make a new GitHub issue!" | ||
| ); | ||
| return e.fetch(r.current); | ||
| } else | ||
| return e.fetch(); | ||
| }, [t, e]); | ||
| } | ||
| function is(e, n = {}) { | ||
| const { room: t, agentConnectTimeoutMilliseconds: r, ...o } = n, c = de(), a = s.useMemo( | ||
| () => c ?? t ?? new De(), | ||
| [c, t] | ||
| ), i = s.useMemo( | ||
| () => new he.EventEmitter(), | ||
| [] | ||
| ), u = s.useCallback( | ||
| (L) => ({ | ||
| isConnected: L === I.Connected || L === I.Reconnecting || L === I.SignalReconnecting | ||
| }), | ||
| [] | ||
| ), [p, h] = s.useState(a.state); | ||
| s.useEffect(() => { | ||
| const L = (N) => { | ||
| h(N); | ||
| }; | ||
| return a.on(H.ConnectionStateChanged, L), () => { | ||
| a.off(H.ConnectionStateChanged, L); | ||
| }; | ||
| }, [a]), s.useEffect(() => { | ||
| const L = async (N) => { | ||
| i.emit("mediaDevicesError", N); | ||
| }; | ||
| return a.on(H.MediaDevicesError, L), () => { | ||
| a.off(H.MediaDevicesError, L); | ||
| }; | ||
| }, [a, i]), s.useEffect(() => { | ||
| const L = async (N) => { | ||
| i.emit("encryptionError", N); | ||
| }; | ||
| return a.on(H.EncryptionError, L), () => { | ||
| a.off(H.EncryptionError, L); | ||
| }; | ||
| }, [a, i]); | ||
| const { localParticipant: d } = Oe({ room: a }), l = d.getTrackPublication(E.Source.Camera), v = s.useMemo(() => !l || l.isMuted ? null : { | ||
| source: E.Source.Camera, | ||
| participant: d, | ||
| publication: l | ||
| }, [d, l, l == null ? void 0 : l.isMuted]), C = d.getTrackPublication(E.Source.Microphone), k = s.useMemo(() => !C || C.isMuted ? null : { | ||
| source: E.Source.Microphone, | ||
| participant: d, | ||
| publication: C | ||
| }, [d, C, C == null ? void 0 : C.isMuted]), { | ||
| agentTimeoutFailureReason: A, | ||
| startAgentTimeout: w, | ||
| clearAgentTimeout: O, | ||
| clearAgentTimeoutFailureReason: R, | ||
| updateAgentTimeoutState: m, | ||
| updateAgentTimeoutParticipantExists: f | ||
| } = fn(), b = s.useMemo( | ||
| () => ({ | ||
| emitter: i, | ||
| tokenSource: e, | ||
| agentConnectTimeoutMilliseconds: r, | ||
| agentTimeoutFailureReason: A, | ||
| startAgentTimeout: w, | ||
| clearAgentTimeout: O, | ||
| clearAgentTimeoutFailureReason: R, | ||
| updateAgentTimeoutState: m, | ||
| updateAgentTimeoutParticipantExists: f | ||
| }), | ||
| [ | ||
| i, | ||
| r, | ||
| e, | ||
| A, | ||
| w, | ||
| O, | ||
| R, | ||
| m, | ||
| f | ||
| ] | ||
| ), g = s.useMemo(() => { | ||
| const L = { | ||
| room: a, | ||
| internal: b | ||
| }; | ||
| switch (p) { | ||
| case I.Connecting: | ||
| return { | ||
| ...L, | ||
| connectionState: I.Connecting, | ||
| ...u(I.Connecting), | ||
| local: { | ||
| cameraTrack: null, | ||
| microphoneTrack: null | ||
| } | ||
| }; | ||
| case I.Connected: | ||
| case I.Reconnecting: | ||
| case I.SignalReconnecting: | ||
| return { | ||
| ...L, | ||
| connectionState: p, | ||
| ...u(p), | ||
| local: { | ||
| cameraTrack: v, | ||
| microphoneTrack: k | ||
| } | ||
| }; | ||
| case I.Disconnected: | ||
| return { | ||
| ...L, | ||
| connectionState: I.Disconnected, | ||
| ...u(I.Disconnected), | ||
| local: { | ||
| cameraTrack: null, | ||
| microphoneTrack: null | ||
| } | ||
| }; | ||
| } | ||
| }, [ | ||
| b, | ||
| a, | ||
| p, | ||
| v, | ||
| k, | ||
| u | ||
| ]); | ||
| s.useEffect(() => { | ||
| i.emit("connectionStateChanged", g.connectionState); | ||
| }, [i, g.connectionState]); | ||
| const y = bn( | ||
| i, | ||
| g.connectionState | ||
| ), T = s.useCallback( | ||
| async (L) => y( | ||
| I.Connected, | ||
| L | ||
| ), | ||
| [y] | ||
| ), M = s.useCallback( | ||
| async (L) => y(I.Disconnected, L), | ||
| [y] | ||
| ), P = Ie( | ||
| s.useMemo( | ||
| () => ({ | ||
| connectionState: g.connectionState, | ||
| room: a, | ||
| internal: b | ||
| }), | ||
| [g, a, b] | ||
| ) | ||
| ), F = gn(e, o), q = s.useCallback( | ||
| async (L = {}) => { | ||
| var B, j; | ||
| const { | ||
| signal: N, | ||
| tracks: Z = { microphone: { enabled: !0, publishOptions: { preConnectBuffer: !0 } } }, | ||
| roomConnectOptions: S | ||
| } = L; | ||
| await M(N); | ||
| const _ = () => { | ||
| a.disconnect(); | ||
| }; | ||
| N == null || N.addEventListener("abort", _); | ||
| let Y = !1; | ||
| await Promise.all([ | ||
| F().then(({ serverUrl: $, participantToken: z }) => { | ||
| var be, ge; | ||
| return Y = (((ge = (be = _t(z).roomConfig) == null ? void 0 : be.agents) == null ? void 0 : ge.length) ?? 0) > 0, a.connect($, z, S); | ||
| }), | ||
| // Start microphone (with preconnect buffer) by default | ||
| (B = Z.microphone) != null && B.enabled ? a.localParticipant.setMicrophoneEnabled( | ||
| !0, | ||
| void 0, | ||
| ((j = Z.microphone) == null ? void 0 : j.publishOptions) ?? {} | ||
| ) : Promise.resolve() | ||
| ]), await T(N), Y && await P.waitUntilConnected(N), N == null || N.removeEventListener("abort", _); | ||
| }, | ||
| [a, M, F, T, P.waitUntilConnected] | ||
| ), J = s.useCallback(async () => { | ||
| await a.disconnect(); | ||
| }, [a]), K = s.useCallback(async () => { | ||
| const L = await F(); | ||
| await a.prepareConnection(L.serverUrl, L.participantToken); | ||
| }, [F, a]); | ||
| return s.useEffect( | ||
| () => { | ||
| K().catch((L) => { | ||
| console.warn("WARNING: Room.prepareConnection failed:", L); | ||
| }); | ||
| }, | ||
| [ | ||
| /* note: no prepareConnection here, this effect should only ever run once! */ | ||
| ] | ||
| ), s.useMemo( | ||
| () => ({ | ||
| ...g, | ||
| waitUntilConnected: T, | ||
| waitUntilDisconnected: M, | ||
| prepareConnection: K, | ||
| start: q, | ||
| end: J | ||
| }), | ||
| [g, T, M, K, q, J] | ||
| ); | ||
| } | ||
| function us(e, n, t, r) { | ||
| const o = s.useMemo(() => () => { | ||
| }, []), c = s.useCallback(t ?? o, r ?? []), a = r ? c : t, i = s.useMemo(() => e ? "internal" in e ? e.internal.emitter : e : null, [e]); | ||
| s.useEffect(() => { | ||
| if (!(!i || !a)) | ||
| return i.on(n, a), () => { | ||
| i.off(n, a); | ||
| }; | ||
| }, [i, n, a]); | ||
| } | ||
| var vn = /* @__PURE__ */ ((e) => (e.MessageReceived = "messageReceived", e))(vn || {}); | ||
| function ls(e) { | ||
| const { room: n } = Dt(e), t = s.useMemo( | ||
| () => new he.EventEmitter(), | ||
| [] | ||
| ), r = Ie(e), o = cn({ room: n }), c = s.useMemo(() => ({ room: n }), [n]), a = Kt(c), i = s.useMemo(() => o.map((l) => { | ||
| var v, C, k; | ||
| switch (l.participantInfo.identity) { | ||
| case n.localParticipant.identity: | ||
| return { | ||
| type: "userTranscript", | ||
| message: l.text, | ||
| id: l.streamInfo.id, | ||
| timestamp: l.streamInfo.timestamp, | ||
| from: n.localParticipant | ||
| }; | ||
| case ((v = r.internal.agentParticipant) == null ? void 0 : v.identity): | ||
| case ((C = r.internal.workerParticipant) == null ? void 0 : C.identity): | ||
| return { | ||
| type: "agentTranscript", | ||
| message: l.text, | ||
| id: l.streamInfo.id, | ||
| timestamp: l.streamInfo.timestamp, | ||
| from: ((k = r.internal.agentParticipant) == null ? void 0 : k.identity) === l.participantInfo.identity ? r.internal.agentParticipant : r.internal.workerParticipant | ||
| }; | ||
| default: | ||
| return { | ||
| type: "agentTranscript", | ||
| message: l.text, | ||
| id: l.streamInfo.id, | ||
| timestamp: l.streamInfo.timestamp, | ||
| from: Array.from(n.remoteParticipants.values()).find( | ||
| (A) => A.identity === l.participantInfo.identity | ||
| ) | ||
| }; | ||
| } | ||
| }), [o, n]), u = s.useMemo(() => [...i, ...a.chatMessages], [i, a.chatMessages]), p = s.useRef(/* @__PURE__ */ new Map()), h = s.useMemo(() => { | ||
| const l = /* @__PURE__ */ new Date(); | ||
| for (const v of u) | ||
| p.current.has(v.id) || p.current.set(v.id, l); | ||
| return u.sort((v, C) => { | ||
| const k = p.current.get(v.id), A = p.current.get(C.id); | ||
| return typeof k > "u" || typeof A > "u" ? 0 : k.getTime() - A.getTime(); | ||
| }); | ||
| }, [u]), d = s.useRef(/* @__PURE__ */ new Set()); | ||
| return s.useEffect(() => { | ||
| for (const l of h) | ||
| d.current.has(l.id) || (d.current.add(l.id), t.emit("messageReceived", l)); | ||
| }, [h]), s.useMemo( | ||
| () => ({ | ||
| messages: h, | ||
| send: a.send, | ||
| isSending: a.isSending, | ||
| internal: { emitter: t } | ||
| }), | ||
| [h, a.send, a.isSending] | ||
| ); | ||
| } | ||
| export { | ||
| an as $, | ||
| In as A, | ||
| Vn as B, | ||
| Oe as C, | ||
| wn as D, | ||
| An as E, | ||
| Bt as F, | ||
| Se as G, | ||
| jt as H, | ||
| xn as I, | ||
| Un as J, | ||
| Wt as K, | ||
| qn as L, | ||
| pe as M, | ||
| jn as N, | ||
| Gt as O, | ||
| $n as P, | ||
| Xn as Q, | ||
| dn as R, | ||
| Ie as S, | ||
| ts as T, | ||
| ss as U, | ||
| re as V, | ||
| rn as W, | ||
| os as X, | ||
| on as Y, | ||
| rs as Z, | ||
| as as _, | ||
| te as a, | ||
| cn as a0, | ||
| cs as a1, | ||
| pn as a2, | ||
| is as a3, | ||
| us as a4, | ||
| vn as a5, | ||
| ls as a6, | ||
| Jn as b, | ||
| Rn as c, | ||
| Dn as d, | ||
| Nn as e, | ||
| zn as f, | ||
| Wn as g, | ||
| Kn as h, | ||
| Ln as i, | ||
| D as j, | ||
| Qn as k, | ||
| Hn as l, | ||
| es as m, | ||
| On as n, | ||
| Fn as o, | ||
| Gn as p, | ||
| qt as q, | ||
| zt as r, | ||
| ns as s, | ||
| Yn as t, | ||
| Pn as u, | ||
| Bn as v, | ||
| Kt as w, | ||
| Zn as x, | ||
| _n as y, | ||
| kn as z | ||
| }; | ||
| //# sourceMappingURL=hooks-yU-srrIO.mjs.map |
Sorry, the diff of this file is too big to display
| "use strict";const k=require("livekit-client"),V=require("react"),S=require("./shared-CVy2Ouqp.js"),f=require("./shared-DoNgw2-D.js");function ct(t){const a=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(a,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return a.default=t,Object.freeze(a)}const e=ct(V);function lt(t){const a=s=>typeof window<"u"?window.matchMedia(s).matches:!1,[n,r]=e.useState(a(t));function c(){r(a(t))}return e.useEffect(()=>{const s=window.matchMedia(t);return c(),s.addListener?s.addListener(c):s.addEventListener("change",c),()=>{s.removeListener?s.removeListener(c):s.removeEventListener("change",c)}},[t]),n}const Ce=e.createContext(void 0);function Me(t){const a=e.useContext(Ce);if(t===!0){if(a)return a;throw Error("tried to access feature context, but none is present")}return a}const le=e.forwardRef(function(a,n){const{mergedProps:r}=f.useChatToggle({props:a});return e.createElement("button",{ref:n,...r},a.children)}),ie=e.forwardRef(function(a,n){const{buttonProps:r}=f.useDisconnectButton(a);return e.createElement("button",{ref:n,...r},a.children)}),Te=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{d:"M1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708L11 10.293V4.5A1.5 1.5 0 0 0 9.5 3H3.707zM0 4.5a1.5 1.5 0 0 1 .943-1.393l9.532 9.533c-.262.224-.603.36-.975.36h-8A1.5 1.5 0 0 1 0 11.5z"}),e.createElement("path",{d:"m15.2 3.6-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z"})),ye=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{d:"M0 4.5A1.5 1.5 0 0 1 1.5 3h8A1.5 1.5 0 0 1 11 4.5v7A1.5 1.5 0 0 1 9.5 13h-8A1.5 1.5 0 0 1 0 11.5zM15.2 3.6l-2.8 2.1a1 1 0 0 0-.4.8v3a1 1 0 0 0 .4.8l2.8 2.1a.5.5 0 0 0 .8-.4V4a.5.5 0 0 0-.8-.4z"})),Re=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,viewBox:"0 0 24 24",...t},e.createElement("path",{fill:"#FFF",d:"M4.99 3.99a1 1 0 0 0-.697 1.717L10.586 12l-6.293 6.293a1 1 0 1 0 1.414 1.414L12 13.414l6.293 6.293a1 1 0 1 0 1.414-1.414L13.414 12l6.293-6.293a1 1 0 0 0-.727-1.717 1 1 0 0 0-.687.303L12 10.586 5.707 4.293a1 1 0 0 0-.717-.303z"})),Ie=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:18,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M0 2.75A2.75 2.75 0 0 1 2.75 0h10.5A2.75 2.75 0 0 1 16 2.75v13.594a.75.75 0 0 1-1.234.572l-3.691-3.12a1.25 1.25 0 0 0-.807-.296H2.75A2.75 2.75 0 0 1 0 10.75v-8ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v8c0 .69.56 1.25 1.25 1.25h7.518c.65 0 1.279.23 1.775.65l2.457 2.077V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M3 4.5a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h9a.5.5 0 0 1 0 1h-9a.5.5 0 0 1-.5-.5Zm0 2a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 0 1h-5a.5.5 0 0 1-.5-.5Z",clipRule:"evenodd"})),re=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentcolor",fillRule:"evenodd",d:"M5.293 2.293a1 1 0 0 1 1.414 0l4.823 4.823a1.25 1.25 0 0 1 0 1.768l-4.823 4.823a1 1 0 0 1-1.414-1.414L9.586 8 5.293 3.707a1 1 0 0 1 0-1.414z",clipRule:"evenodd"})),Pe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5},e.createElement("path",{d:"M10 1.75h4.25m0 0V6m0-4.25L9 7M6 14.25H1.75m0 0V10m0 4.25L7 9"}))),Ae=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentcolor",fillRule:"evenodd",d:"M8.961.894C8.875-.298 7.125-.298 7.04.894c-.066.912-1.246 1.228-1.76.472-.67-.99-2.186-.115-1.664.96.399.824-.465 1.688-1.288 1.289-1.076-.522-1.95.994-.961 1.665.756.513.44 1.693-.472 1.759-1.192.086-1.192 1.836 0 1.922.912.066 1.228 1.246.472 1.76-.99.67-.115 2.186.96 1.664.824-.399 1.688.465 1.289 1.288-.522 1.076.994 1.95 1.665.961.513-.756 1.693-.44 1.759.472.086 1.192 1.836 1.192 1.922 0 .066-.912 1.246-1.228 1.76-.472.67.99 2.186.115 1.664-.96-.399-.824.465-1.688 1.288-1.289 1.076.522 1.95-.994.961-1.665-.756-.513-.44-1.693.472-1.759 1.192-.086 1.192-1.836 0-1.922-.912-.066-1.228-1.246-.472-1.76.99-.67.115-2.186-.96-1.664-.824.399-1.688-.465-1.289-1.288.522-1.076-.994-1.95-1.665-.961-.513.756-1.693.44-1.759-.472ZM8 13A5 5 0 1 0 8 3a5 5 0 0 0 0 10Z",clipRule:"evenodd"})),Ne=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M2 2.75A2.75 2.75 0 0 1 4.75 0h6.5A2.75 2.75 0 0 1 14 2.75v10.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-.5a.75.75 0 0 1 1.5 0v.5c0 .69.56 1.25 1.25 1.25h6.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25h-6.5c-.69 0-1.25.56-1.25 1.25v.5a.75.75 0 0 1-1.5 0v-.5Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8.78 7.47a.75.75 0 0 1 0 1.06l-2.25 2.25a.75.75 0 1 1-1.06-1.06l.97-.97H1.75a.75.75 0 0 1 0-1.5h4.69l-.97-.97a.75.75 0 0 1 1.06-1.06l2.25 2.25Z",clipRule:"evenodd"})),Le=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentcolor",fillRule:"evenodd",d:"M4 6.104V4a4 4 0 1 1 8 0v2.104c1.154.326 2 1.387 2 2.646v4.5A2.75 2.75 0 0 1 11.25 16h-6.5A2.75 2.75 0 0 1 2 13.25v-4.5c0-1.259.846-2.32 2-2.646ZM5.5 4a2.5 2.5 0 0 1 5 0v2h-5V4Z",clipRule:"evenodd"})),xe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{d:"M12.227 11.52a5.477 5.477 0 0 0 1.246-2.97.5.5 0 0 0-.995-.1 4.478 4.478 0 0 1-.962 2.359l-1.07-1.07C10.794 9.247 11 8.647 11 8V3a3 3 0 0 0-6 0v1.293L1.354.646a.5.5 0 1 0-.708.708l14 14a.5.5 0 0 0 .708-.708zM8 12.5c.683 0 1.33-.152 1.911-.425l.743.743c-.649.359-1.378.59-2.154.66V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .995-.098A4.5 4.5 0 0 0 8 12.5z"}),e.createElement("path",{d:"M8.743 10.907 5 7.164V8a3 3 0 0 0 3.743 2.907z"})),Ve=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("path",{fillRule:"evenodd",d:"M2.975 8.002a.5.5 0 0 1 .547.449 4.5 4.5 0 0 0 8.956 0 .5.5 0 1 1 .995.098A5.502 5.502 0 0 1 8.5 13.478V15h2a.5.5 0 0 1 0 1h-5a.5.5 0 0 1 0-1h2v-1.522a5.502 5.502 0 0 1-4.973-4.929.5.5 0 0 1 .448-.547z",clipRule:"evenodd"}),e.createElement("path",{d:"M5 3a3 3 0 1 1 6 0v5a3 3 0 0 1-6 0z"})),Fe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentcolor",...t},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"})),De=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentcolor",...t},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("g",{opacity:.25},e.createElement("path",{d:"M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}))),ze=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentcolor",...t},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("g",{opacity:.25},e.createElement("path",{d:"M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M6 6.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}),e.createElement("path",{d:"M12 .5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5z"}))),Oe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"currentColor",...t},e.createElement("g",{opacity:.25},e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z"}),e.createElement("path",{d:"M0 11.5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v4a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-4Zm6-5a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v9a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5v-9Zm6-6a.5.5 0 0 1 .5-.5h3a.5.5 0 0 1 .5.5v15a.5.5 0 0 1-.5.5h-3a.5.5 0 0 1-.5-.5V.5Z"}))),oe=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:16,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M0 2.75A2.75 2.75 0 0 1 2.75 0h14.5A2.75 2.75 0 0 1 20 2.75v10.5A2.75 2.75 0 0 1 17.25 16H2.75A2.75 2.75 0 0 1 0 13.25V2.75ZM2.75 1.5c-.69 0-1.25.56-1.25 1.25v10.5c0 .69.56 1.25 1.25 1.25h14.5c.69 0 1.25-.56 1.25-1.25V2.75c0-.69-.56-1.25-1.25-1.25H2.75Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M9.47 4.22a.75.75 0 0 1 1.06 0l2.25 2.25a.75.75 0 0 1-1.06 1.06l-.97-.97v4.69a.75.75 0 0 1-1.5 0V6.56l-.97.97a.75.75 0 0 1-1.06-1.06l2.25-2.25Z",clipRule:"evenodd"})),$e=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:20,height:16,fill:"none",...t},e.createElement("g",{fill:"currentColor"},e.createElement("path",{d:"M7.28 4.22a.75.75 0 0 0-1.06 1.06L8.94 8l-2.72 2.72a.75.75 0 1 0 1.06 1.06L10 9.06l2.72 2.72a.75.75 0 1 0 1.06-1.06L11.06 8l2.72-2.72a.75.75 0 0 0-1.06-1.06L10 6.94z"}),e.createElement("path",{fillRule:"evenodd",d:"M2.75 0A2.75 2.75 0 0 0 0 2.75v10.5A2.75 2.75 0 0 0 2.75 16h14.5A2.75 2.75 0 0 0 20 13.25V2.75A2.75 2.75 0 0 0 17.25 0zM1.5 2.75c0-.69.56-1.25 1.25-1.25h14.5c.69 0 1.25.56 1.25 1.25v10.5c0 .69-.56 1.25-1.25 1.25H2.75c-.69 0-1.25-.56-1.25-1.25z",clipRule:"evenodd"}))),ce=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8 0a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0V.75A.75.75 0 0 1 8 0Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M8 12a.75.75 0 0 1 .75.75v2.5a.75.75 0 0 1-1.5 0v-2.5A.75.75 0 0 1 8 12Z",clipRule:"evenodd",opacity:.7}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 1.072a.75.75 0 0 1 .274 1.024l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 12 1.072Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M6 11.464a.75.75 0 0 1 .274 1.025l-1.25 2.165a.75.75 0 0 1-1.299-.75l1.25-2.165A.75.75 0 0 1 6 11.464Z",clipRule:"evenodd",opacity:.6}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M14.928 4a.75.75 0 0 1-.274 1.025l-2.165 1.25a.75.75 0 1 1-.75-1.3l2.165-1.25A.75.75 0 0 1 14.928 4Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M4.536 10a.75.75 0 0 1-.275 1.024l-2.165 1.25a.75.75 0 0 1-.75-1.298l2.165-1.25A.75.75 0 0 1 4.536 10Z",clipRule:"evenodd",opacity:.5}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M16 8a.75.75 0 0 1-.75.75h-2.5a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 16 8Z",clipRule:"evenodd"}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M4 8a.75.75 0 0 1-.75.75H.75a.75.75 0 0 1 0-1.5h2.5A.75.75 0 0 1 4 8Z",clipRule:"evenodd",opacity:.4}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M14.928 12a.75.75 0 0 1-1.024.274l-2.165-1.25a.75.75 0 0 1 .75-1.299l2.165 1.25A.75.75 0 0 1 14.928 12Z",clipRule:"evenodd",opacity:.9}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M4.536 6a.75.75 0 0 1-1.025.275l-2.165-1.25a.75.75 0 1 1 .75-1.3l2.165 1.25A.75.75 0 0 1 4.536 6Z",clipRule:"evenodd",opacity:.3}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M12 14.928a.75.75 0 0 1-1.024-.274l-1.25-2.165a.75.75 0 0 1 1.298-.75l1.25 2.165A.75.75 0 0 1 12 14.928Z",clipRule:"evenodd",opacity:.8}),e.createElement("path",{fill:"currentColor",fillRule:"evenodd",d:"M6 4.536a.75.75 0 0 1-1.024-.275l-1.25-2.165a.75.75 0 1 1 1.299-.75l1.25 2.165A.75.75 0 0 1 6 4.536Z",clipRule:"evenodd",opacity:.2})),Ze=t=>e.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",width:16,height:16,fill:"none",...t},e.createElement("g",{stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:1.5},e.createElement("path",{d:"M13.25 7H9m0 0V2.75M9 7l5.25-5.25M2.75 9H7m0 0v4.25M7 9l-5.25 5.25"}))),_e=e.forwardRef(function({trackRef:a,...n},r){const c=f.useMaybeTrackRefContext(),{mergedProps:s,inFocus:u}=f.useFocusToggle({trackRef:a??c,props:n});return e.createElement(f.LayoutContext.Consumer,null,l=>l!==void 0&&e.createElement("button",{ref:r,...s},n.children?n.children:u?e.createElement(Ze,null):e.createElement(Pe,null)))}),G=e.forwardRef(function({kind:a,initialSelection:n,onActiveDeviceChange:r,onDeviceListChange:c,onDeviceSelectError:s,exactMatch:u,track:l,requestPermissions:i,onError:v,...o},p){const m=S.useMaybeRoomContext(),w=e.useRef("default"),h=e.useCallback(T=>{m&&m.emit(k.RoomEvent.MediaDevicesError,T),v==null||v(T)},[m,v]),{devices:g,activeDeviceId:d,setActiveMediaDevice:C,className:E}=f.useMediaDeviceSelect({kind:a,room:m,track:l,requestPermissions:i,onError:h});e.useEffect(()=>{n!==void 0&&C(n)},[C]),e.useEffect(()=>{typeof c=="function"&&c(g)},[c,g]),e.useEffect(()=>{d!==w.current&&(r==null||r(d)),w.current=d},[d]);const I=async T=>{try{await C(T,{exact:u??!0})}catch(P){if(P instanceof Error)s==null||s(P);else throw P}},R=e.useMemo(()=>f.mergeProps$1(o,{className:E},{className:"lk-list"}),[E,o]),b=!!g.find(T=>T.label.toLowerCase().startsWith("default"));function M(T,P,z){return T===P||!b&&z===0&&P==="default"}return e.createElement("ul",{ref:p,...R},g.map((T,P)=>e.createElement("li",{key:T.deviceId,id:T.deviceId,"data-lk-active":M(T.deviceId,d,P),"aria-selected":M(T.deviceId,d,P),role:"option"},e.createElement("button",{className:"lk-button",onClick:()=>I(T.deviceId)},T.label))))}),se=e.forwardRef(function({label:a,...n},r){const c=S.useRoomContext(),{mergedProps:s,canPlayAudio:u}=f.useStartAudio({room:c,props:n}),{mergedProps:l,canPlayVideo:i}=f.useStartVideo({room:c,props:s}),{style:v,...o}=l;return v.display=u&&i?"none":"block",e.createElement("button",{ref:r,style:v,...o},a??`Start ${u?"Video":"Audio"}`)});function je(t,a){switch(t){case k.Track.Source.Microphone:return a?e.createElement(Ve,null):e.createElement(xe,null);case k.Track.Source.Camera:return a?e.createElement(ye,null):e.createElement(Te,null);case k.Track.Source.ScreenShare:return a?e.createElement($e,null):e.createElement(oe,null);default:return}}function it(t){switch(t){case k.ConnectionQuality.Excellent:return e.createElement(Fe,null);case k.ConnectionQuality.Good:return e.createElement(De,null);case k.ConnectionQuality.Poor:return e.createElement(ze,null);default:return e.createElement(Oe,null)}}const Z=e.forwardRef(function({showIcon:a,...n},r){const{buttonProps:c,enabled:s}=f.useTrackToggle(n),[u,l]=e.useState(!1);return e.useEffect(()=>{l(!0)},[]),u&&e.createElement("button",{ref:r,...c},(a??!0)&&je(n.source,s),n.children)}),ue=e.forwardRef(function(a,n){const{className:r,quality:c}=f.useConnectionQualityIndicator(a),s=e.useMemo(()=>({...f.mergeProps$1(a,{className:r}),"data-lk-quality":c}),[c,a,r]);return e.createElement("div",{ref:n,...s},a.children??it(c))}),K=e.forwardRef(function({participant:a,...n},r){const c=f.useEnsureParticipant(a),{className:s,infoObserver:u}=e.useMemo(()=>S.setupParticipantName(c),[c]),{identity:l,name:i}=f.useObservableState(u,{name:c.name,identity:c.identity,metadata:c.metadata}),v=e.useMemo(()=>f.mergeProps$1(n,{className:s,"data-lk-participant-name":i}),[n,s,i]);return e.createElement("span",{ref:r,...v},i!==""?i:l,n.children)}),de=e.forwardRef(function({trackRef:a,show:n="always",...r},c){const{className:s,isMuted:u}=f.useTrackMutedIndicator(a),l=n==="always"||n==="muted"&&u||n==="unmuted"&&!u,i=e.useMemo(()=>f.mergeProps$1(r,{className:s}),[s,r]);return l?e.createElement("div",{ref:c,...i,"data-lk-muted":u},r.children??je(a.source,!u)):null}),me=t=>e.createElement("svg",{width:320,height:320,viewBox:"0 0 320 320",preserveAspectRatio:"xMidYMid meet",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},e.createElement("path",{d:"M160 180C204.182 180 240 144.183 240 100C240 55.8172 204.182 20 160 20C115.817 20 79.9997 55.8172 79.9997 100C79.9997 144.183 115.817 180 160 180Z",fill:"white",fillOpacity:.25}),e.createElement("path",{d:"M97.6542 194.614C103.267 191.818 109.841 192.481 115.519 195.141C129.025 201.466 144.1 205 159.999 205C175.899 205 190.973 201.466 204.48 195.141C210.158 192.481 216.732 191.818 222.345 194.614C262.703 214.719 291.985 253.736 298.591 300.062C300.15 310.997 291.045 320 280 320H39.9997C28.954 320 19.8495 310.997 21.4087 300.062C28.014 253.736 57.2966 214.72 97.6542 194.614Z",fill:"white",fillOpacity:.25}));function Be(t,a={}){const[n,r]=e.useState(S.getTrackByIdentifier(t)),[c,s]=e.useState(n==null?void 0:n.isMuted),[u,l]=e.useState(n==null?void 0:n.isSubscribed),[i,v]=e.useState(n==null?void 0:n.track),[o,p]=e.useState("landscape"),m=e.useRef(),{className:w,trackObserver:h}=e.useMemo(()=>S.setupMediaTrack(t),[t.participant.sid??t.participant.identity,t.source,S.isTrackReference(t)&&t.publication.trackSid]);return e.useEffect(()=>{const g=h.subscribe(d=>{S.log.debug("update track",d),r(d),s(d==null?void 0:d.isMuted),l(d==null?void 0:d.isSubscribed),v(d==null?void 0:d.track)});return()=>g==null?void 0:g.unsubscribe()},[h]),e.useEffect(()=>{var g,d;return i&&(m.current&&i.detach(m.current),(g=a.element)!=null&&g.current&&!(t.participant.isLocal&&(i==null?void 0:i.kind)==="audio")&&i.attach(a.element.current)),m.current=(d=a.element)==null?void 0:d.current,()=>{m.current&&(i==null||i.detach(m.current))}},[i,a.element]),e.useEffect(()=>{var g,d;if(typeof((g=n==null?void 0:n.dimensions)==null?void 0:g.width)=="number"&&typeof((d=n==null?void 0:n.dimensions)==null?void 0:d.height)=="number"){const C=n.dimensions.width>n.dimensions.height?"landscape":"portrait";p(C)}},[n]),{publication:n,isMuted:c,isSubscribed:u,track:i,elementProps:f.mergeProps$1(a.props,{className:w,"data-lk-local-participant":t.participant.isLocal,"data-lk-source":n==null?void 0:n.source,...(n==null?void 0:n.kind)==="video"&&{"data-lk-orientation":o}})}}var ae,ke;function ot(){if(ke)return ae;ke=1;var t="Expected a function",a=NaN,n="[object Symbol]",r=/^\s+|\s+$/g,c=/^[-+]0x[0-9a-f]+$/i,s=/^0b[01]+$/i,u=/^0o[0-7]+$/i,l=parseInt,i=typeof S.commonjsGlobal=="object"&&S.commonjsGlobal&&S.commonjsGlobal.Object===Object&&S.commonjsGlobal,v=typeof self=="object"&&self&&self.Object===Object&&self,o=i||v||Function("return this")(),p=Object.prototype,m=p.toString,w=Math.max,h=Math.min,g=function(){return o.Date.now()};function d(b,M,T){var P,z,y,N,F,O,D=0,_=!1,L=!1,q=!0;if(typeof b!="function")throw new TypeError(t);M=R(M)||0,C(T)&&(_=!!T.leading,L="maxWait"in T,y=L?w(R(T.maxWait)||0,M):y,q="trailing"in T?!!T.trailing:q);function j(x){var $=P,Q=z;return P=z=void 0,D=x,N=b.apply(Q,$),N}function ee(x){return D=x,F=setTimeout(H,M),_?j(x):N}function te(x){var $=x-O,Q=x-D,Ee=M-$;return L?h(Ee,y-Q):Ee}function B(x){var $=x-O,Q=x-D;return O===void 0||$>=M||$<0||L&&Q>=y}function H(){var x=g();if(B(x))return A(x);F=setTimeout(H,te(x))}function A(x){return F=void 0,q&&P?j(x):(P=z=void 0,N)}function W(){F!==void 0&&clearTimeout(F),D=0,P=O=z=F=void 0}function rt(){return F===void 0?N:A(g())}function ne(){var x=g(),$=B(x);if(P=arguments,z=this,O=x,$){if(F===void 0)return ee(O);if(L)return F=setTimeout(H,M),j(O)}return F===void 0&&(F=setTimeout(H,M)),N}return ne.cancel=W,ne.flush=rt,ne}function C(b){var M=typeof b;return!!b&&(M=="object"||M=="function")}function E(b){return!!b&&typeof b=="object"}function I(b){return typeof b=="symbol"||E(b)&&m.call(b)==n}function R(b){if(typeof b=="number")return b;if(I(b))return a;if(C(b)){var M=typeof b.valueOf=="function"?b.valueOf():b;b=C(M)?M+"":M}if(typeof b!="string")return b===0?b:+b;b=b.replace(r,"");var T=s.test(b);return T||u.test(b)?l(b.slice(2),T?2:8):c.test(b)?a:+b}return ae=d,ae}var st=ot();const Se=S.getDefaultExportFromCjs(st);function ut(t){const a=V.useRef(t);a.current=t,V.useEffect(()=>()=>{a.current()},[])}function dt(t,a=500,n){const r=V.useRef();ut(()=>{r.current&&r.current.cancel()});const c=V.useMemo(()=>{const s=Se(t,a,n),u=(...l)=>s(...l);return u.cancel=()=>{s.cancel()},u.isPending=()=>!!r.current,u.flush=()=>s.flush(),u},[t,a,n]);return V.useEffect(()=>{r.current=Se(t,a,n)},[t,a,n]),c}function mt(t,a,n){const r=((v,o)=>v===o),c=t instanceof Function?t():t,[s,u]=V.useState(c),l=V.useRef(c),i=dt(u,a,n);return r(l.current,c)||(i(c),l.current=c),[s,i]}function ft({threshold:t=0,root:a=null,rootMargin:n="0%",freezeOnceVisible:r=!1,initialIsIntersecting:c=!1,onChange:s}={}){var u;const[l,i]=V.useState(null),[v,o]=V.useState(()=>({isIntersecting:c,entry:void 0})),p=V.useRef();p.current=s;const m=((u=v.entry)==null?void 0:u.isIntersecting)&&r;V.useEffect(()=>{if(!l||!("IntersectionObserver"in window)||m)return;const g=new IntersectionObserver(d=>{const C=Array.isArray(g.thresholds)?g.thresholds:[g.thresholds];d.forEach(E=>{const I=E.isIntersecting&&C.some(R=>E.intersectionRatio>=R);o({isIntersecting:I,entry:E}),p.current&&p.current(I,E)})},{threshold:t,root:a,rootMargin:n});return g.observe(l),()=>{g.disconnect()}},[l,JSON.stringify(t),a,n,m,r]);const w=V.useRef(null);V.useEffect(()=>{var g;!l&&((g=v.entry)!=null&&g.target)&&!r&&!m&&w.current!==v.entry.target&&(w.current=v.entry.target,o({isIntersecting:c,entry:void 0}))},[l,v.entry,r,m,c]);const h=[i,!!v.isIntersecting,v.entry];return h.ref=h[0],h.isIntersecting=h[1],h.entry=h[2],h}const He=e.forwardRef(function({onTrackClick:a,onClick:n,onSubscriptionStatusChanged:r,trackRef:c,manageSubscription:s,...u},l){const i=f.useEnsureTrackRef(c),v=e.useRef(null);e.useImperativeHandle(l,()=>v.current);const o=ft({root:v.current}),[p]=mt(o,3e3);e.useEffect(()=>{s&&i.publication instanceof k.RemoteTrackPublication&&(p==null?void 0:p.isIntersecting)===!1&&(o==null?void 0:o.isIntersecting)===!1&&i.publication.setSubscribed(!1)},[p,i,s]),e.useEffect(()=>{s&&i.publication instanceof k.RemoteTrackPublication&&(o==null?void 0:o.isIntersecting)===!0&&i.publication.setSubscribed(!0)},[o,i,s]);const{elementProps:m,publication:w,isSubscribed:h}=Be(i,{element:v,props:u});e.useEffect(()=>{r==null||r(!!h)},[h,r]);const g=d=>{n==null||n(d),a==null||a({participant:i==null?void 0:i.participant,track:w})};return e.createElement("video",{ref:v,...m,muted:!0,onClick:g})}),X=e.forwardRef(function({trackRef:a,onSubscriptionStatusChanged:n,volume:r,...c},s){const u=f.useEnsureTrackRef(a),l=e.useRef(null);e.useImperativeHandle(s,()=>l.current);const{elementProps:i,isSubscribed:v,track:o,publication:p}=Be(u,{element:l,props:c});return e.useEffect(()=>{n==null||n(!!v)},[v,n]),e.useEffect(()=>{o===void 0||r===void 0||(o instanceof k.RemoteAudioTrack?o.setVolume(r):S.log.warn("Volume can only be set on remote audio tracks."))},[r,o]),e.useEffect(()=>{p===void 0||c.muted===void 0||(p instanceof k.RemoteTrackPublication?p.setEnabled(!c.muted):S.log.warn("Can only call setEnabled on remote track publications."))},[c.muted,p,o]),e.createElement("audio",{ref:l,...i})});function Ue(t){const a=!!f.useMaybeParticipantContext();return t.participant&&!a?e.createElement(f.ParticipantContext.Provider,{value:t.participant},t.children):e.createElement(e.Fragment,null,t.children)}function qe(t){const a=!!f.useMaybeTrackRefContext();return t.trackRef&&!a?e.createElement(f.TrackRefContext.Provider,{value:t.trackRef},t.children):e.createElement(e.Fragment,null,t.children)}const J=e.forwardRef(function({trackRef:a,children:n,onParticipantClick:r,disableSpeakingIndicator:c,...s},u){var w,h;const l=f.useEnsureTrackRef(a),{elementProps:i}=f.useParticipantTile({htmlProps:s,disableSpeakingIndicator:c,onParticipantClick:r,trackRef:l}),v=f.useIsEncrypted(l.participant),o=f.useMaybeLayoutContext(),p=(w=Me())==null?void 0:w.autoSubscription,m=e.useCallback(g=>{l.source&&!g&&o&&o.pin.dispatch&&S.isTrackReferencePinned(l,o.pin.state)&&o.pin.dispatch({msg:"clear_pin"})},[l,o]);return e.createElement("div",{ref:u,style:{position:"relative"},...i},e.createElement(qe,{trackRef:l},e.createElement(Ue,{participant:l.participant},n??e.createElement(e.Fragment,null,S.isTrackReference(l)&&(((h=l.publication)==null?void 0:h.kind)==="video"||l.source===k.Track.Source.Camera||l.source===k.Track.Source.ScreenShare)?e.createElement(He,{trackRef:l,onSubscriptionStatusChanged:m,manageSubscription:p}):S.isTrackReference(l)&&e.createElement(X,{trackRef:l,onSubscriptionStatusChanged:m}),e.createElement("div",{className:"lk-participant-placeholder"},e.createElement(me,null)),e.createElement("div",{className:"lk-participant-metadata"},e.createElement("div",{className:"lk-participant-metadata-item"},l.source===k.Track.Source.Camera?e.createElement(e.Fragment,null,v&&e.createElement(Le,{style:{marginRight:"0.25rem"}}),e.createElement(de,{trackRef:{participant:l.participant,source:k.Track.Source.Microphone},show:"muted"}),e.createElement(K,null)):e.createElement(e.Fragment,null,e.createElement(oe,{style:{marginRight:"0.25rem"}}),e.createElement(K,null,"'s screen"))),e.createElement(ue,{className:"lk-participant-metadata-item"}))),e.createElement(_e,{trackRef:l}))))});function We(t){const a=f.mergeProps$1(t,{className:"lk-focus-layout"});return e.createElement("div",{...a},t.children)}function Qe({trackRef:t,...a}){return e.createElement(J,{trackRef:t,...a})}function Y({tracks:t,...a}){return e.createElement(e.Fragment,null,t.map(n=>e.createElement(f.TrackRefContext.Provider,{value:n,key:S.getTrackReferenceId(n)},f.cloneSingleChild(a.children))))}function ht({totalPageCount:t,nextPage:a,prevPage:n,currentPage:r,pagesContainer:c}){const[s,u]=e.useState(!1);return e.useEffect(()=>{let l;return c&&(l=S.createInteractingObservable(c.current,2e3).subscribe(u)),()=>{l&&l.unsubscribe()}},[c]),e.createElement("div",{className:"lk-pagination-control","data-lk-user-interaction":s},e.createElement("button",{className:"lk-button",onClick:n},e.createElement(re,null)),e.createElement("span",{className:"lk-pagination-count"},`${r} of ${t}`),e.createElement("button",{className:"lk-button",onClick:a},e.createElement(re,null)))}const gt=e.forwardRef(function({totalPageCount:a,currentPage:n},r){const c=new Array(a).fill("").map((s,u)=>u+1===n?e.createElement("span",{"data-lk-active":!0,key:u}):e.createElement("span",{key:u}));return e.createElement("div",{ref:r,className:"lk-pagination-indicator"},c)});function Ge({tracks:t,...a}){const n=e.createRef(),r=e.useMemo(()=>f.mergeProps$1(a,{className:"lk-grid-layout"}),[a]),{layout:c}=f.useGridLayout(n,t.length),s=f.usePagination(c.maxTiles,t);return f.useSwipe(n,{onLeftSwipe:s.nextPage,onRightSwipe:s.prevPage}),e.createElement("div",{ref:n,"data-lk-pagination":s.totalPageCount>1,...r},e.createElement(Y,{tracks:s.tracks},a.children),t.length>c.maxTiles&&e.createElement(e.Fragment,null,e.createElement(gt,{totalPageCount:s.totalPageCount,currentPage:s.currentPage}),e.createElement(ht,{pagesContainer:n,...s})))}const vt=130,pt=140,we=1,Ke=16/10,Et=(1-Ke)*-1;function Je({tracks:t,orientation:a,...n}){const r=e.useRef(null),[c,s]=e.useState(0),{width:u,height:l}=f.useSize(r),i=a||(l>=u?"vertical":"horizontal"),v=i==="vertical"?Math.max(u*Et,vt):Math.max(l*Ke,pt),o=S.getScrollBarWidth(),p=Math.max(i==="vertical"?(l-o)/v:(u-o)/v,we);let m=Math.round(p);Math.abs(p-c)<.5?m=Math.round(c):c!==p&&s(p);const w=f.useVisualStableUpdate(t,m);return e.useLayoutEffect(()=>{r.current&&(r.current.dataset.lkOrientation=i,r.current.style.setProperty("--lk-max-visible-tiles",m.toString()))},[m,i]),e.createElement("aside",{key:i,className:"lk-carousel",ref:r,...n},e.createElement(Y,{tracks:w},n.children))}function fe({value:t,onPinChange:a,onWidgetChange:n,children:r}){const c=f.useEnsureCreateLayoutContext(t);return e.useEffect(()=>{S.log.debug("PinState Updated",{state:c.pin.state}),a&&c.pin.state&&a(c.pin.state)},[c.pin.state,a]),e.useEffect(()=>{S.log.debug("Widget Updated",{widgetState:c.widget.state}),n&&c.widget.state&&n(c.widget.state)},[n,c.widget.state]),e.createElement(f.LayoutContext.Provider,{value:c},r)}function Xe({room:t,volume:a,muted:n}){const r=f.useTracks([k.Track.Source.Microphone,k.Track.Source.ScreenShareAudio,k.Track.Source.Unknown],{updateOnlyOn:[],onlySubscribed:!0,room:t}).filter(c=>!c.participant.isLocal&&c.publication.kind===k.Track.Kind.Audio);return e.createElement("div",{style:{display:"none"}},r.map(c=>e.createElement(X,{key:S.getTrackReferenceId(c),trackRef:c,volume:a,muted:n})))}function Ye(t){const a=e.useMemo(()=>f.mergeProps$1(t,{className:"lk-toast"}),[t]);return e.createElement("div",{...a},t.children)}const kt=t=>{const a=[];for(let n=0;n<t;n++)a.push([n,t-1-n]);return a},be=t=>[[Math.floor(t/2)],[-1]],St=(t,a,n)=>{const[r,c]=V.useState(0),[s,u]=V.useState([[]]);V.useEffect(()=>{if(t==="thinking")u(be(a));else if(t==="connecting"||t==="initializing"){const i=[...kt(a)];u(i)}else u(t==="listening"?be(a):t===void 0||t==="speaking"?[new Array(a).fill(0).map((i,v)=>v)]:[[]]);c(0)},[t,a]);const l=V.useRef(null);return V.useEffect(()=>{let i=performance.now();const v=o=>{o-i>=n&&(c(m=>m+1),i=o),l.current=requestAnimationFrame(v)};return l.current=requestAnimationFrame(v),()=>{l.current!==null&&cancelAnimationFrame(l.current)}},[n,a,t,s.length]),s[r%s.length]},wt=new Map([["connecting",2e3],["initializing",2e3],["listening",500],["thinking",150]]),bt=(t,a)=>{if(t===void 0)return 1e3;let n=wt.get(t);if(n)switch(t){case"connecting":n/=a;break}return n},he=e.forwardRef(function({state:a,options:n,barCount:r=15,trackRef:c,track:s,children:u,...l},i){const v=f.mergeProps$1(l,{className:"lk-audio-bar-visualizer"});let o=f.useMaybeTrackRefContext();(c||s)&&(o=c||s);const p=f.useMultibandTrackVolume(o,{bands:r,loPass:100,hiPass:200}),m=(n==null?void 0:n.minHeight)??20,w=(n==null?void 0:n.maxHeight)??100,h=St(a,r,bt(a,r)??100);return e.createElement("div",{ref:i,...v,"data-lk-va-state":a},p.map((g,d)=>u?f.cloneSingleChild(u,{"data-lk-highlighted":h.includes(d),"data-lk-bar-index":d,className:"lk-audio-bar",style:{height:`${Math.min(w,Math.max(m,g*100+5))}%`}}):e.createElement("span",{key:d,"data-lk-highlighted":h.includes(d),"data-lk-bar-index":d,className:`lk-audio-bar ${h.includes(d)&&"lk-highlighted"}`,style:{height:`${Math.min(w,Math.max(m,g*100+5))}%`}})))}),et=e.forwardRef(function({children:a,disableSpeakingIndicator:n,onParticipantClick:r,trackRef:c,...s},u){const l=f.useEnsureTrackRef(c),{elementProps:i}=f.useParticipantTile({trackRef:l,htmlProps:s,disableSpeakingIndicator:n,onParticipantClick:r});return e.createElement("div",{ref:u,style:{position:"relative",minHeight:"160px"},...i},e.createElement(f.TrackRefContext.Provider,{value:l},a??e.createElement(e.Fragment,null,S.isTrackReference(l)&&e.createElement(X,{trackRef:l}),e.createElement(he,{barCount:7,options:{minHeight:8}}),e.createElement("div",{className:"lk-participant-metadata"},e.createElement("div",{className:"lk-participant-metadata-item"},e.createElement(de,{trackRef:l}),e.createElement(K,null)),e.createElement(ue,{className:"lk-participant-metadata-item"})))))});function tt(t){const[a,n]=e.useState(void 0),r=f.useConnectionState(t.room);return e.useEffect(()=>{switch(r){case k.ConnectionState.Reconnecting:n(e.createElement(e.Fragment,null,e.createElement(ce,{className:"lk-spinner"})," Reconnecting"));break;case k.ConnectionState.Connecting:n(e.createElement(e.Fragment,null,e.createElement(ce,{className:"lk-spinner"})," Connecting"));break;case k.ConnectionState.Disconnected:n(e.createElement(e.Fragment,null,"Disconnected"));break;default:n(void 0);break}},[r]),a?e.createElement(Ye,{className:"lk-toast-connection-state"},a):e.createElement(e.Fragment,null)}const nt=e.forwardRef(function({entry:a,hideName:n=!1,hideTimestamp:r=!1,messageFormatter:c,...s},u){var m,w,h,g;const l=e.useMemo(()=>c?c(a.message):a.message,[a.message,c]),i=!!a.editTimestamp,v=new Date(a.timestamp),o=typeof navigator<"u"?navigator.language:"en-US",p=((m=a.from)==null?void 0:m.name)??((w=a.from)==null?void 0:w.identity);return e.createElement("li",{ref:u,className:"lk-chat-entry",title:v.toLocaleTimeString(o,{timeStyle:"full"}),"data-lk-message-origin":(h=a.from)!=null&&h.isLocal?"local":"remote",...s},(!r||!n||i)&&e.createElement("span",{className:"lk-meta-data"},!n&&e.createElement("strong",{className:"lk-participant-name"},p),(!r||i)&&e.createElement("span",{className:"lk-timestamp"},i&&"edited ",v.toLocaleTimeString(o,{timeStyle:"short"}))),e.createElement("span",{className:"lk-message-body"},l),e.createElement("span",{className:"lk-message-attachements"},(g=a.attachedFiles)==null?void 0:g.map(d=>d.type.startsWith("image/")&&e.createElement("img",{style:{maxWidth:"300px",maxHeight:"300px"},key:d.name,src:URL.createObjectURL(d),alt:d.name}))))});function Ct(t){return S.tokenize(t,S.createDefaultGrammar()).map((a,n)=>{if(typeof a=="string")return a;{const r=a.content.toString(),c=a.type==="url"?/^http(s?):\/\//.test(r)?r:`https://${r}`:`mailto:${r}`;return e.createElement("a",{className:"lk-chat-link",key:n,href:c,target:"_blank",rel:"noreferrer"},r)}})}function ge({messageFormatter:t,messageDecoder:a,messageEncoder:n,channelTopic:r,...c}){const s=e.useRef(null),u=e.useRef(null),l=e.useMemo(()=>({messageDecoder:a,messageEncoder:n,channelTopic:r}),[a,n,r]),{chatMessages:i,send:v,isSending:o}=f.useChat(l),p=f.useMaybeLayoutContext(),m=e.useRef(0);async function w(h){h.preventDefault(),u.current&&u.current.value.trim()!==""&&(await v(u.current.value),u.current.value="",u.current.focus())}return e.useEffect(()=>{var h;s&&((h=s.current)==null||h.scrollTo({top:s.current.scrollHeight}))},[s,i]),e.useEffect(()=>{var d,C,E,I,R;if(!p||i.length===0)return;if((d=p.widget.state)!=null&&d.showChat&&i.length>0&&m.current!==((C=i[i.length-1])==null?void 0:C.timestamp)){m.current=(E=i[i.length-1])==null?void 0:E.timestamp;return}const h=i.filter(b=>!m.current||b.timestamp>m.current).length,{widget:g}=p;h>0&&((I=g.state)==null?void 0:I.unreadMessages)!==h&&((R=g.dispatch)==null||R.call(g,{msg:"unread_msg",count:h}))},[i,p==null?void 0:p.widget]),e.createElement("div",{...c,className:"lk-chat"},e.createElement("div",{className:"lk-chat-header"},"Messages",p&&e.createElement(le,{className:"lk-close-button"},e.createElement(Re,null))),e.createElement("ul",{className:"lk-list lk-chat-messages",ref:s},c.children?i.map((h,g)=>f.cloneSingleChild(c.children,{entry:h,key:h.id??g,messageFormatter:t})):i.map((h,g,d)=>{const C=g>=1&&d[g-1].from===h.from,E=g>=1&&h.timestamp-d[g-1].timestamp<6e4;return e.createElement(nt,{key:h.id??g,hideName:C,hideTimestamp:C===!1?!1:E,entry:h,messageFormatter:t})})),e.createElement("form",{className:"lk-chat-form",onSubmit:w},e.createElement("input",{className:"lk-form-control lk-chat-form-input",disabled:o,ref:u,type:"text",placeholder:"Enter a message...",onInput:h=>h.stopPropagation(),onKeyDown:h=>h.stopPropagation(),onKeyUp:h=>h.stopPropagation()}),e.createElement("button",{type:"submit",className:"lk-button lk-chat-form-button",disabled:o},"Send")))}function U({kind:t,initialSelection:a,onActiveDeviceChange:n,tracks:r,requestPermissions:c=!1,...s}){const[u,l]=e.useState(!1),[i,v]=e.useState([]),[o,p]=e.useState(!0),[m,w]=e.useState(c),h=(E,I)=>{S.log.debug("handle device change"),l(!1),n==null||n(E,I)},g=e.useRef(null),d=e.useRef(null);e.useLayoutEffect(()=>{u&&w(!0)},[u]),e.useLayoutEffect(()=>{let E;return g.current&&d.current&&(i||o)&&(E=S.computeMenuPosition(g.current,d.current,(I,R)=>{d.current&&Object.assign(d.current.style,{left:`${I}px`,top:`${R}px`})})),p(!1),()=>{E==null||E()}},[g,d,i,o]);const C=e.useCallback(E=>{d.current&&E.target!==g.current&&u&&S.wasClickOutside(d.current,E)&&l(!1)},[u,d,g]);return e.useEffect(()=>(document.addEventListener("click",C),()=>{document.removeEventListener("click",C)}),[C]),e.createElement(e.Fragment,null,e.createElement("button",{className:"lk-button lk-button-menu","aria-pressed":u,...s,onClick:()=>l(!u),ref:g},s.children),!s.disabled&&e.createElement("div",{className:"lk-device-menu",ref:d,style:{visibility:u?"visible":"hidden"}},t?e.createElement(G,{initialSelection:a,onActiveDeviceChange:E=>h(t,E),onDeviceListChange:v,kind:t,track:r==null?void 0:r[t],requestPermissions:m}):e.createElement(e.Fragment,null,e.createElement("div",{className:"lk-device-menu-heading"},"Audio inputs"),e.createElement(G,{kind:"audioinput",onActiveDeviceChange:E=>h("audioinput",E),onDeviceListChange:v,track:r==null?void 0:r.audioinput,requestPermissions:m}),e.createElement("div",{className:"lk-device-menu-heading"},"Video inputs"),e.createElement(G,{kind:"videoinput",onActiveDeviceChange:E=>h("videoinput",E),onDeviceListChange:v,track:r==null?void 0:r.videoinput,requestPermissions:m}))))}function ve(){e.useEffect(()=>{f.warnAboutMissingStyles()},[])}function at(t,a){const[n,r]=e.useState(),c=e.useMemo(()=>new k.Mutex,[]);return e.useEffect(()=>{let s=!1,u=[];return c.lock().then(async l=>{try{(t.audio||t.video)&&(u=await k.createLocalTracks(t),s?u.forEach(i=>i.stop()):r(u))}catch(i){a&&i instanceof Error?a(i):S.log.error(i)}finally{l()}}),()=>{s=!0,u.forEach(l=>{l.stop()})}},[JSON.stringify(t,f.roomOptionsStringifyReplacer),a,c]),n}function Mt(t,a,n){const[r,c]=e.useState(null),[s,u]=e.useState(!1),l=f.useMediaDevices({kind:n}),[i,v]=e.useState(void 0),[o,p]=e.useState(),[m,w]=e.useState(a);e.useEffect(()=>{w(a)},[a]);const h=async(C,E)=>{try{const I=E==="videoinput"?await k.createLocalVideoTrack({deviceId:C,resolution:k.VideoPresets.h720.resolution}):await k.createLocalAudioTrack({deviceId:C}),R=await I.getDeviceId(!1);R&&C!==R&&(d.current=R,w(R)),p(I)}catch(I){I instanceof Error&&c(I)}},g=async(C,E)=>{await C.setDeviceId(E),d.current=E},d=e.useRef(m);return e.useEffect(()=>{t&&!o&&!r&&!s&&(S.log.debug("creating track",n),u(!0),h(m,n).finally(()=>{u(!1)}))},[t,o,r,s]),e.useEffect(()=>{o&&(t?i!=null&&i.deviceId&&d.current!==(i==null?void 0:i.deviceId)?(S.log.debug(`switching ${n} device from`,d.current,i.deviceId),g(o,i.deviceId)):(S.log.debug(`unmuting local ${n} track`),o.unmute()):(S.log.debug(`muting ${n} track`),o.mute().then(()=>S.log.debug(o.mediaStreamTrack))))},[o,i,t,n]),e.useEffect(()=>()=>{o&&(S.log.debug(`stopping local ${n} track`),o.stop(),o.mute())},[]),e.useEffect(()=>{v(l==null?void 0:l.find(C=>C.deviceId===m))},[m,l]),{selectedDevice:i,localTrack:o,deviceError:r}}function Tt({defaults:t={},onValidate:a,onSubmit:n,onError:r,debug:c,joinLabel:s="Join Room",micLabel:u="Microphone",camLabel:l="Camera",userLabel:i="Username",persistUserChoices:v=!0,videoProcessor:o,...p}){const{userChoices:m,saveAudioInputDeviceId:w,saveAudioInputEnabled:h,saveVideoInputDeviceId:g,saveVideoInputEnabled:d,saveUsername:C}=f.usePersistentUserChoices({defaults:t,preventSave:!v,preventLoad:!v}),[E,I]=e.useState(m),[R,b]=e.useState(E.audioEnabled),[M,T]=e.useState(E.videoEnabled),[P,z]=e.useState(E.audioDeviceId),[y,N]=e.useState(E.videoDeviceId),[F,O]=e.useState(E.username);e.useEffect(()=>{h(R)},[R,h]),e.useEffect(()=>{d(M)},[M,d]),e.useEffect(()=>{w(P)},[P,w]),e.useEffect(()=>{g(y)},[y,g]),e.useEffect(()=>{C(F)},[F,C]);const D=at({audio:R?{deviceId:m.audioDeviceId}:!1,video:M?{deviceId:m.videoDeviceId,processor:o}:!1},r),_=e.useRef(null),L=e.useMemo(()=>D==null?void 0:D.filter(A=>A.kind===k.Track.Kind.Video)[0],[D]),q=e.useMemo(()=>{if(L){const{facingMode:A}=k.facingModeFromLocalTrack(L);return A}else return"undefined"},[L]),j=e.useMemo(()=>D==null?void 0:D.filter(A=>A.kind===k.Track.Kind.Audio)[0],[D]);e.useEffect(()=>(_.current&&L&&(L.unmute(),L.attach(_.current)),()=>{L==null||L.detach()}),[L]);const[ee,te]=e.useState(),B=e.useCallback(A=>typeof a=="function"?a(A):A.username!=="",[a]);e.useEffect(()=>{const A={username:F,videoEnabled:M,videoDeviceId:y,audioEnabled:R,audioDeviceId:P};I(A),te(B(A))},[F,M,B,R,P,y]);function H(A){A.preventDefault(),B(E)?typeof n=="function"&&n(E):S.log.warn("Validation failed with: ",E)}return ve(),e.createElement("div",{className:"lk-prejoin",...p},e.createElement("div",{className:"lk-video-container"},L&&e.createElement("video",{ref:_,width:"1280",height:"720","data-lk-facing-mode":q}),(!L||!M)&&e.createElement("div",{className:"lk-camera-off-note"},e.createElement(me,null))),e.createElement("div",{className:"lk-button-group-container"},e.createElement("div",{className:"lk-button-group audio"},e.createElement(Z,{initialState:R,source:k.Track.Source.Microphone,onChange:A=>b(A)},u),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{initialSelection:P,kind:"audioinput",disabled:!j,tracks:{audioinput:j},onActiveDeviceChange:(A,W)=>z(W)}))),e.createElement("div",{className:"lk-button-group video"},e.createElement(Z,{initialState:M,source:k.Track.Source.Camera,onChange:A=>T(A)},l),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{initialSelection:y,kind:"videoinput",disabled:!L,tracks:{videoinput:L},onActiveDeviceChange:(A,W)=>N(W)})))),e.createElement("form",{className:"lk-username-container"},e.createElement("input",{className:"lk-form-control",id:"username",name:"username",type:"text",defaultValue:F,placeholder:i,onChange:A=>O(A.target.value),autoComplete:"off"}),e.createElement("button",{className:"lk-button lk-join-button",type:"submit",onClick:H,disabled:!ee},s)),c&&e.createElement(e.Fragment,null,e.createElement("strong",null,"User Choices:"),e.createElement("ul",{className:"lk-list",style:{overflow:"hidden",maxWidth:"15rem"}},e.createElement("li",null,"Username: ",`${E.username}`),e.createElement("li",null,"Video Enabled: ",`${E.videoEnabled}`),e.createElement("li",null,"Audio Enabled: ",`${E.audioEnabled}`),e.createElement("li",null,"Video Device: ",`${E.videoDeviceId}`),e.createElement("li",null,"Audio Device: ",`${E.audioDeviceId}`))))}function yt({props:t}){const{dispatch:a,state:n}=f.useLayoutContext().widget,r="lk-button lk-settings-toggle";return{mergedProps:e.useMemo(()=>f.mergeProps(t,{className:r,onClick:()=>{a&&a({msg:"toggle_settings"})},"aria-pressed":n!=null&&n.showSettings?"true":"false"}),[t,r,a,n])}}const Rt=e.forwardRef(function(a,n){const{mergedProps:r}=yt({props:a});return e.createElement("button",{ref:n,...r},a.children)}),It=t=>{switch(t){case k.Track.Source.Camera:return 1;case k.Track.Source.Microphone:return 2;case k.Track.Source.ScreenShare:return 3;default:return 0}};function pe({variation:t,controls:a,saveUserChoices:n=!0,onDeviceError:r,...c}){var z;const[s,u]=e.useState(!1),l=f.useMaybeLayoutContext();e.useEffect(()=>{var y,N;((y=l==null?void 0:l.widget.state)==null?void 0:y.showChat)!==void 0&&u((N=l==null?void 0:l.widget.state)==null?void 0:N.showChat)},[(z=l==null?void 0:l.widget.state)==null?void 0:z.showChat]);const v=lt(`(max-width: ${s?1e3:760}px)`)?"minimal":"verbose";t??(t=v);const o={leave:!0,...a},p=f.useLocalParticipantPermissions();if(!p)o.camera=!1,o.chat=!1,o.microphone=!1,o.screenShare=!1;else{const y=N=>p.canPublish&&(p.canPublishSources.length===0||p.canPublishSources.includes(It(N)));o.camera??(o.camera=y(k.Track.Source.Camera)),o.microphone??(o.microphone=y(k.Track.Source.Microphone)),o.screenShare??(o.screenShare=y(k.Track.Source.ScreenShare)),o.chat??(o.chat=p.canPublishData&&(a==null?void 0:a.chat))}const m=e.useMemo(()=>t==="minimal"||t==="verbose",[t]),w=e.useMemo(()=>t==="textOnly"||t==="verbose",[t]),h=S.supportsScreenSharing(),[g,d]=e.useState(!1),C=e.useCallback(y=>{d(y)},[d]),E=f.mergeProps$1({className:"lk-control-bar"},c),{saveAudioInputEnabled:I,saveVideoInputEnabled:R,saveAudioInputDeviceId:b,saveVideoInputDeviceId:M}=f.usePersistentUserChoices({preventSave:!n}),T=e.useCallback((y,N)=>N?I(y):null,[I]),P=e.useCallback((y,N)=>N?R(y):null,[R]);return e.createElement("div",{...E},o.microphone&&e.createElement("div",{className:"lk-button-group"},e.createElement(Z,{source:k.Track.Source.Microphone,showIcon:m,onChange:T,onDeviceError:y=>r==null?void 0:r({source:k.Track.Source.Microphone,error:y})},w&&"Microphone"),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{kind:"audioinput",onActiveDeviceChange:(y,N)=>b(N??"default")}))),o.camera&&e.createElement("div",{className:"lk-button-group"},e.createElement(Z,{source:k.Track.Source.Camera,showIcon:m,onChange:P,onDeviceError:y=>r==null?void 0:r({source:k.Track.Source.Camera,error:y})},w&&"Camera"),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{kind:"videoinput",onActiveDeviceChange:(y,N)=>M(N??"default")}))),o.screenShare&&h&&e.createElement(Z,{source:k.Track.Source.ScreenShare,captureOptions:{audio:!0,selfBrowserSurface:"include"},showIcon:m,onChange:C,onDeviceError:y=>r==null?void 0:r({source:k.Track.Source.ScreenShare,error:y})},w&&(g?"Stop screen share":"Share screen")),o.chat&&e.createElement(le,null,m&&e.createElement(Ie,null),w&&"Chat"),o.settings&&e.createElement(Rt,null,m&&e.createElement(Ae,null),w&&"Settings"),o.leave&&e.createElement(ie,null,m&&e.createElement(Ne,null),w&&"Leave"),e.createElement(se,null))}function Pt({chatMessageFormatter:t,chatMessageDecoder:a,chatMessageEncoder:n,SettingsComponent:r,...c}){var h,g;const[s,u]=e.useState({showChat:!1,unreadMessages:0,showSettings:!1}),l=e.useRef(null),i=f.useTracks([{source:k.Track.Source.Camera,withPlaceholder:!0},{source:k.Track.Source.ScreenShare,withPlaceholder:!1}],{updateOnlyOn:[k.RoomEvent.ActiveSpeakersChanged],onlySubscribed:!1}),v=d=>{S.log.debug("updating widget state",d),u(d)},o=f.useCreateLayoutContext(),p=i.filter(S.isTrackReference).filter(d=>d.publication.source===k.Track.Source.ScreenShare),m=(h=f.usePinnedTracks(o))==null?void 0:h[0],w=i.filter(d=>!S.isEqualTrackRef(d,m));return e.useEffect(()=>{var d,C,E,I,R,b;if(p.some(M=>M.publication.isSubscribed)&&l.current===null?(S.log.debug("Auto set screen share focus:",{newScreenShareTrack:p[0]}),(C=(d=o.pin).dispatch)==null||C.call(d,{msg:"set_pin",trackReference:p[0]}),l.current=p[0]):l.current&&!p.some(M=>{var T,P;return M.publication.trackSid===((P=(T=l.current)==null?void 0:T.publication)==null?void 0:P.trackSid)})&&(S.log.debug("Auto clearing screen share focus."),(I=(E=o.pin).dispatch)==null||I.call(E,{msg:"clear_pin"}),l.current=null),m&&!S.isTrackReference(m)){const M=i.find(T=>T.participant.identity===m.participant.identity&&T.source===m.source);M!==m&&S.isTrackReference(M)&&((b=(R=o.pin).dispatch)==null||b.call(R,{msg:"set_pin",trackReference:M}))}},[p.map(d=>`${d.publication.trackSid}_${d.publication.isSubscribed}`).join(),(g=m==null?void 0:m.publication)==null?void 0:g.trackSid,i]),ve(),e.createElement("div",{className:"lk-video-conference",...c},S.isWeb()&&e.createElement(fe,{value:o,onWidgetChange:v},e.createElement("div",{className:"lk-video-conference-inner"},m?e.createElement("div",{className:"lk-focus-layout-wrapper"},e.createElement(We,null,e.createElement(Je,{tracks:w},e.createElement(J,null)),m&&e.createElement(Qe,{trackRef:m}))):e.createElement("div",{className:"lk-grid-layout-wrapper"},e.createElement(Ge,{tracks:i},e.createElement(J,null))),e.createElement(pe,{controls:{chat:!0,settings:!!r}})),e.createElement(ge,{style:{display:s.showChat?"grid":"none"},messageFormatter:t,messageEncoder:n,messageDecoder:a}),r&&e.createElement("div",{className:"lk-settings-menu-modal",style:{display:s.showSettings?"block":"none"}},e.createElement(r,null))),e.createElement(Xe,null),e.createElement(tt,null))}function At({...t}){const[a,n]=e.useState({showChat:!1,unreadMessages:0}),r=f.useTracks([k.Track.Source.Microphone]);return ve(),e.createElement(fe,{onWidgetChange:n},e.createElement("div",{className:"lk-audio-conference",...t},e.createElement("div",{className:"lk-audio-conference-stage"},e.createElement(Y,{tracks:r},e.createElement(et,null))),e.createElement(pe,{controls:{microphone:!0,screenShare:!1,camera:!1,chat:!0}}),a.showChat&&e.createElement(ge,null)))}function Nt({controls:t,saveUserChoices:a=!0,onDeviceError:n,...r}){const c={leave:!0,microphone:!0,...t},s=f.useLocalParticipantPermissions(),{microphoneTrack:u,localParticipant:l}=S.useLocalParticipant(),i=e.useMemo(()=>({participant:l,source:k.Track.Source.Microphone,publication:u}),[l,u]);s?c.microphone??(c.microphone=s.canPublish):c.microphone=!1;const v=f.mergeProps$1({className:"lk-agent-control-bar"},r),{saveAudioInputEnabled:o,saveAudioInputDeviceId:p}=f.usePersistentUserChoices({preventSave:!a}),m=e.useCallback((w,h)=>{h&&o(w)},[o]);return e.createElement("div",{...v},c.microphone&&e.createElement("div",{className:"lk-button-group"},e.createElement(Z,{source:k.Track.Source.Microphone,showIcon:!0,onChange:m,onDeviceError:w=>n==null?void 0:n({source:k.Track.Source.Microphone,error:w})},e.createElement(he,{trackRef:i,barCount:7,options:{minHeight:5}})),e.createElement("div",{className:"lk-button-group-menu"},e.createElement(U,{kind:"audioinput",onActiveDeviceChange:(w,h)=>p(h??"default")}))),c.leave&&e.createElement(ie,null,"Disconnect"),e.createElement(se,null))}exports.AudioConference=At;exports.AudioTrack=X;exports.BarVisualizer=he;exports.CarouselLayout=Je;exports.Chat=ge;exports.ChatEntry=nt;exports.ChatToggle=le;exports.ConnectionQualityIndicator=ue;exports.ConnectionStateToast=tt;exports.ControlBar=pe;exports.DisconnectButton=ie;exports.FocusLayout=Qe;exports.FocusLayoutContainer=We;exports.FocusToggle=_e;exports.GridLayout=Ge;exports.LKFeatureContext=Ce;exports.LayoutContextProvider=fe;exports.MediaDeviceMenu=U;exports.MediaDeviceSelect=G;exports.ParticipantAudioTile=et;exports.ParticipantContextIfNeeded=Ue;exports.ParticipantName=K;exports.ParticipantTile=J;exports.PreJoin=Tt;exports.RoomAudioRenderer=Xe;exports.StartMediaButton=se;exports.SvgCameraDisabledIcon=Te;exports.SvgCameraIcon=ye;exports.SvgChatCloseIcon=Re;exports.SvgChatIcon=Ie;exports.SvgChevron=re;exports.SvgFocusToggleIcon=Pe;exports.SvgGearIcon=Ae;exports.SvgLeaveIcon=Ne;exports.SvgLockLockedIcon=Le;exports.SvgMicDisabledIcon=xe;exports.SvgMicIcon=Ve;exports.SvgParticipantPlaceholder=me;exports.SvgQualityExcellentIcon=Fe;exports.SvgQualityGoodIcon=De;exports.SvgQualityPoorIcon=ze;exports.SvgQualityUnknownIcon=Oe;exports.SvgScreenShareIcon=oe;exports.SvgScreenShareStopIcon=$e;exports.SvgSpinnerIcon=ce;exports.SvgUnfocusToggleIcon=Ze;exports.Toast=Ye;exports.TrackLoop=Y;exports.TrackMutedIndicator=de;exports.TrackRefContextIfNeeded=qe;exports.TrackToggle=Z;exports.VideoConference=Pt;exports.VideoTrack=He;exports.VoiceAssistantControlBar=Nt;exports.formatChatMessageLinks=Ct;exports.useFeatureContext=Me;exports.usePreviewDevice=Mt;exports.usePreviewTracks=at; | ||
| //# sourceMappingURL=shared-BGEsyR2K.js.map |
Sorry, the diff of this file is too big to display
| "use strict";const U=require("react"),v=require("./shared-CVy2Ouqp.js"),M=require("./shared-DoNgw2-D.js"),f=require("livekit-client");function Ce(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,i.get?i:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const r=Ce(U),Y=r.createContext(void 0);function Se(){const e=r.useContext(Y);if(!e)throw Error("tried to access session context outside of SessionProvider component");return e}function X(){return r.useContext(Y)}function ue(e){const t=X(),n=e??t;if(!n)throw new Error("No session provided, make sure you are inside a Session context or pass the session explicitly");return n}function Te(e){const t=v.useEnsureRoom(e),n=r.useCallback(async()=>{await t.startAudio()},[t]),i=r.useMemo(()=>v.roomAudioPlaybackAllowedObservable(t),[t]),{canPlayAudio:d}=M.useObservableState(i,{canPlayAudio:t.canPlaybackAudio});return{canPlayAudio:d,startAudio:n}}function Ee(e){const{state:t,dispatch:n}=M.useLayoutContext().pin;return{buttonProps:r.useMemo(()=>{const{className:d}=v.setupClearPinButton();return M.mergeProps(e,{className:d,disabled:!(t!=null&&t.length),onClick:()=>{n&&n({msg:"clear_pin"})}})},[e,n,t])}}function ke(e,t){const n=typeof e=="function"?e:t,i=typeof e=="string"?e:void 0,d=v.useRoomContext(),{send:a,messageObservable:o,isSendingObservable:p}=r.useMemo(()=>v.setupDataMessageHandler(d,i,n),[d,i,n]),T=M.useObservableState(o,void 0),E=M.useObservableState(p,!1);return{message:T,send:a,isSending:E}}const ye={connect:!0,audio:!1,video:!1};function we(e){const{token:t,serverUrl:n,options:i,room:d,connectOptions:a,connect:o,audio:p,video:T,screen:E,onConnected:b,onDisconnected:m,onError:u,onMediaDeviceFailure:k,onEncryptionError:P,simulateParticipants:x,...O}={...ye,...e};i&&d&&v.log.warn("when using a manually created room, the options object will be ignored. set the desired options directly when creating the room instead.");const[A,I]=r.useState(),D=r.useRef(o);r.useEffect(()=>{I(d??new f.Room(i))},[d,JSON.stringify(i,M.roomOptionsStringifyReplacer)]);const c=r.useMemo(()=>{const{className:s}=v.setupLiveKitRoom();return M.mergeProps(O,{className:s})},[O]);return r.useEffect(()=>{if(!A)return;const s=()=>{const S=A.localParticipant;v.log.debug("trying to publish local tracks"),Promise.all([S.setMicrophoneEnabled(!!p,typeof p!="boolean"?p:void 0),S.setCameraEnabled(!!T,typeof T!="boolean"?T:void 0),S.setScreenShareEnabled(!!E,typeof E!="boolean"?E:void 0)]).catch(w=>{v.log.warn(w),u==null||u(w)})},l=(S,w)=>{const _=f.MediaDeviceFailure.getFailure(S);k==null||k(_,w)},h=S=>{P==null||P(S)},C=S=>{m==null||m(S)},y=()=>{b==null||b()};return A.on(f.RoomEvent.SignalConnected,s).on(f.RoomEvent.MediaDevicesError,l).on(f.RoomEvent.EncryptionError,h).on(f.RoomEvent.Disconnected,C).on(f.RoomEvent.Connected,y),()=>{A.off(f.RoomEvent.SignalConnected,s).off(f.RoomEvent.MediaDevicesError,l).off(f.RoomEvent.EncryptionError,h).off(f.RoomEvent.Disconnected,C).off(f.RoomEvent.Connected,y)}},[A,p,T,E,u,P,k,b,m]),r.useEffect(()=>{if(A){if(x){A.simulateParticipants({participants:{count:x},publish:{audio:!0,useRealTracks:!0}});return}if(o){if(D.current=!0,v.log.debug("connecting"),!t){v.log.debug("no token yet");return}if(!n){v.log.warn("no livekit url provided"),u==null||u(Error("no livekit url provided"));return}A.connect(n,t,a).catch(s=>{v.log.warn(s),D.current===!0&&(u==null||u(s))})}else v.log.debug("disconnecting because connect is false"),D.current=!1,A.disconnect()}},[o,t,JSON.stringify(a),A,u,n,x]),r.useEffect(()=>{if(A)return()=>{v.log.info("disconnecting on onmount"),A.disconnect()}},[A]),{room:A,htmlProps:c}}function Pe(e={}){let t=M.useMaybeParticipantContext();e.participant&&(t=e.participant);const n=r.useMemo(()=>v.participantInfoObserver(t),[t]),{identity:i,name:d,metadata:a}=M.useObservableState(n,{name:t==null?void 0:t.name,identity:t==null?void 0:t.identity,metadata:t==null?void 0:t.metadata});return{identity:i,name:d,metadata:a}}function Re(e={}){const t=M.useEnsureParticipant(e.participant),n=r.useMemo(()=>v.participantPermissionObserver(t),[t]);return M.useObservableState(n,t.permissions)}function Q(e={}){const t=v.useEnsureRoom(e.room),[n,i]=r.useState([]);return r.useEffect(()=>{const d=v.connectedParticipantsObserver(t,{additionalRoomEvents:e.updateOnlyOn}).subscribe(i);return()=>d.unsubscribe()},[t,JSON.stringify(e.updateOnlyOn)]),n}function le(e={}){const t=Q(e),{localParticipant:n}=v.useLocalParticipant(e);return r.useMemo(()=>[n,...t],[n,t])}function Me(e,t={}){const n=v.useRoomContext(),[i]=r.useState(t.updateOnlyOn),d=r.useMemo(()=>typeof e=="string"?v.connectedParticipantObserver(n,e,{additionalEvents:i}):v.participantByIdentifierObserver(n,e,{additionalEvents:i}),[n,JSON.stringify(e),i]),[a,o]=r.useState({p:void 0});return r.useEffect(()=>{const p=d.subscribe(T=>o({p:T}));return()=>p.unsubscribe()},[d]),a.p}function Ae(e={}){const t=v.useEnsureRoom(e.room),n=r.useMemo(()=>v.roomInfoObserver(t),[t]),{name:i,metadata:d}=M.useObservableState(n,{name:t.name,metadata:t.metadata});return{name:i,metadata:d}}function fe(e){const t=v.useEnsureRoom(e==null?void 0:e.room),n=r.useMemo(()=>v.activeSpeakerObserver(t),[t]);return M.useObservableState(n,t.activeSpeakers)}function Le(e){const[t,n]=r.useState(v.sortParticipants(e)),i=fe();return r.useEffect(()=>{n(v.sortParticipants(e))},[i,e]),t}function Oe(e,t,n={}){const[i,d]=r.useState(void 0);return r.useEffect(()=>{var o;if(e===void 0)throw Error("token endpoint needs to be defined");if(((o=n.userInfo)==null?void 0:o.identity)===void 0)return;(async()=>{v.log.debug("fetching token");const p=new URLSearchParams({...n.userInfo,roomName:t}),T=await fetch(`${e}?${p.toString()}`);if(!T.ok){v.log.error(`Could not fetch token. Server responded with status ${T.status}: ${T.statusText}`);return}const{accessToken:E}=await T.json();d(E)})()},[e,t,JSON.stringify(n)]),i}function xe(e){const[t,n]=r.useState(v.getTrackByIdentifier(e)),{trackObserver:i}=r.useMemo(()=>v.setupMediaTrack(e),[e.participant.sid??e.participant.identity,e.source]);return r.useEffect(()=>{const d=i.subscribe(a=>{n(a)});return()=>d==null?void 0:d.unsubscribe()},[i]),{participant:e.participant,source:e.source??f.Track.Source.Unknown,publication:t}}function De(e,t){const n=M.useEnsureParticipant(t);return xe({name:e,participant:n})}function J(e,t={}){let n,i;typeof t=="string"?n=t:(n=t==null?void 0:t.participantIdentity,i=t==null?void 0:t.room);const d=M.useMaybeParticipantContext(),a=le({room:i,updateOnlyOn:[]}),o=r.useMemo(()=>n?a.find(E=>E.identity===n):d,[n,a,d]),p=r.useMemo(()=>{if(o)return v.participantTracksObservable(o,{sources:e})},[o,JSON.stringify(e)]);return M.useObservableState(p,[])}function _e(e){var n,i,d;const t=r.useMemo(()=>{var a;return(a=e==null?void 0:e.publication)!=null&&a.track?v.trackSyncTimeObserver(e==null?void 0:e.publication.track):void 0},[(n=e==null?void 0:e.publication)==null?void 0:n.track]);return M.useObservableState(t,{timestamp:Date.now(),rtpTimestamp:(d=(i=e==null?void 0:e.publication)==null?void 0:i.track)==null?void 0:d.rtpTimestamp})}const Ne={bufferSize:100};function de(e,t){const n={...Ne,...t},[i,d]=r.useState([]),a=_e(e),o=p=>{var T;(T=n.onTranscription)==null||T.call(n,p),d(E=>v.dedupeSegments(E,p.map(b=>v.addMediaTimestampToTranscription(b,a)),n.bufferSize))};return r.useEffect(()=>{if(!(e!=null&&e.publication))return;const p=v.trackTranscriptionObserver(e.publication).subscribe(T=>{o(...T)});return()=>{p.unsubscribe()}},[e&&v.getTrackReferenceId(e),o]),{segments:i}}function me(e={}){const t=M.useMaybeParticipantContext(),n=e.participant??t,i=r.useMemo(()=>v.participantAttributesObserver(n),[n]);return M.useObservableState(i,{attributes:n==null?void 0:n.attributes})}function Ie(e,t={}){const n=M.useEnsureParticipant(t.participant),[i,d]=r.useState(n.attributes[e]);return r.useEffect(()=>{if(!n)return;const a=v.participantAttributesObserver(n).subscribe(o=>{o.changed[e]!==void 0&&d(o.attributes[e])});return()=>{a.unsubscribe()}},[n,e]),i}const re=v.ParticipantAgentAttributes.AgentState;function Fe(){const e=Q(),t=e.find(m=>m.kind===f.ParticipantKind.AGENT&&!(v.ParticipantAgentAttributes.PublishOnBehalf in m.attributes)),n=e.find(m=>m.kind===f.ParticipantKind.AGENT&&m.attributes[v.ParticipantAgentAttributes.PublishOnBehalf]===(t==null?void 0:t.identity)),i=J([f.Track.Source.Microphone,f.Track.Source.Camera],t==null?void 0:t.identity),d=J([f.Track.Source.Microphone,f.Track.Source.Camera],n==null?void 0:n.identity),a=i.find(m=>m.source===f.Track.Source.Microphone)??d.find(m=>m.source===f.Track.Source.Microphone),o=i.find(m=>m.source===f.Track.Source.Camera)??d.find(m=>m.source===f.Track.Source.Camera),{segments:p}=de(a),T=M.useConnectionState(),{attributes:E}=me({participant:t}),b=r.useMemo(()=>T===f.ConnectionState.Disconnected?"disconnected":T===f.ConnectionState.Connecting||!t||!(E!=null&&E[re])?"connecting":E[re],[E,t,T]);return{agent:t,state:b,audioTrack:a,videoTrack:o,agentTranscriptions:p,agentAttributes:E}}function Ue(e){const t=v.useEnsureRoom(e),n=M.useConnectionState(t),i=r.useMemo(()=>v.recordingStatusObservable(t),[t,n]);return M.useObservableState(i,t.isRecording)}function pe(e,t){const n=v.useEnsureRoom(t==null?void 0:t.room),d=M.useConnectionState(n)===f.ConnectionState.Disconnected,a=r.useMemo(()=>v.setupTextStream(n,e),[n,e]),o=d?void 0:a;return{textStreams:M.useObservableState(o,[])}}function he(e){const{participantIdentities:t,trackSids:n}=e??{},{textStreams:i}=pe(v.DataTopic.TRANSCRIPTION,{room:e==null?void 0:e.room});return r.useMemo(()=>i.filter(a=>t?t.includes(a.participantInfo.identity):!0).filter(a=>{var o;return n?n.includes(((o=a.streamInfo.attributes)==null?void 0:o[v.ParticipantAgentAttributes.TranscribedTrackId])??""):!0}),[i,t,n])}const oe=2,se=400,ie=3,ce=1e3;function je(e){const t=U.useRef([]),n=U.useMemo(()=>new f.Mutex,[]),i=U.useCallback(async()=>n.lock().then(async b=>{for(;;){const m=t.current.pop();if(!m){b();break}switch(m.type){case"connect":await m.room.connect(...m.args).then(m.resolve).catch(m.reject);break;case"disconnect":await m.room.disconnect(...m.args).then(m.resolve).catch(m.reject);break}}}),[]),d=U.useRef([]),a=U.useCallback(b=>{let m=0;d.current=d.current.filter(u=>{const k=b.getTime()-u.getTime()<ce;return k&&(m+=1),k}),m>ie&&v.log.warn(`useSequentialRoomConnectDisconnect: room changed reference rapidly (over ${ie}x in ${ce}ms). This is not recommended.`)},[]);U.useEffect(()=>{t.current=[];const b=new Date;d.current.push(b),a(b)},[e,a]);const o=U.useRef([]),p=U.useCallback(b=>{let m=0;o.current=o.current.filter(u=>{const k=b.getTime()-u.getTime()<se;return k&&(m+=1),k}),m>oe&&v.log.warn(`useSequentialRoomConnectDisconnect: room connect / disconnect occurring in rapid sequence (over ${oe}x in ${se}ms). This is not recommended and may be the sign of a bug like a useEffect dependency changing every render.`)},[]),T=U.useCallback(async(...b)=>new Promise((m,u)=>{if(!e)throw new Error("Called connect(), but room was unset");const k=new Date;p(k),t.current.push({type:"connect",room:e,args:b,resolve:m,reject:u}),o.current.push(k),i()}),[e,p,i]),E=U.useCallback(async(...b)=>new Promise((m,u)=>{if(!e)throw new Error("Called discconnect(), but room was unset");const k=new Date;p(k),t.current.push({type:"disconnect",room:e,args:b,resolve:m,reject:u}),o.current.push(k),i()}),[e,p,i]);return{connect:e?T:null,disconnect:e?E:null}}var V={exports:{}},ae;function He(){if(ae)return V.exports;ae=1;var e=typeof Reflect=="object"?Reflect:null,t=e&&typeof e.apply=="function"?e.apply:function(s,l,h){return Function.prototype.apply.call(s,l,h)},n;e&&typeof e.ownKeys=="function"?n=e.ownKeys:Object.getOwnPropertySymbols?n=function(s){return Object.getOwnPropertyNames(s).concat(Object.getOwnPropertySymbols(s))}:n=function(s){return Object.getOwnPropertyNames(s)};function i(c){console&&console.warn&&console.warn(c)}var d=Number.isNaN||function(s){return s!==s};function a(){a.init.call(this)}V.exports=a,V.exports.once=A,a.EventEmitter=a,a.prototype._events=void 0,a.prototype._eventsCount=0,a.prototype._maxListeners=void 0;var o=10;function p(c){if(typeof c!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof c)}Object.defineProperty(a,"defaultMaxListeners",{enumerable:!0,get:function(){return o},set:function(c){if(typeof c!="number"||c<0||d(c))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+c+".");o=c}}),a.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},a.prototype.setMaxListeners=function(s){if(typeof s!="number"||s<0||d(s))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+s+".");return this._maxListeners=s,this};function T(c){return c._maxListeners===void 0?a.defaultMaxListeners:c._maxListeners}a.prototype.getMaxListeners=function(){return T(this)},a.prototype.emit=function(s){for(var l=[],h=1;h<arguments.length;h++)l.push(arguments[h]);var C=s==="error",y=this._events;if(y!==void 0)C=C&&y.error===void 0;else if(!C)return!1;if(C){var S;if(l.length>0&&(S=l[0]),S instanceof Error)throw S;var w=new Error("Unhandled error."+(S?" ("+S.message+")":""));throw w.context=S,w}var _=y[s];if(_===void 0)return!1;if(typeof _=="function")t(_,this,l);else for(var j=_.length,q=P(_,j),h=0;h<j;++h)t(q[h],this,l);return!0};function E(c,s,l,h){var C,y,S;if(p(l),y=c._events,y===void 0?(y=c._events=Object.create(null),c._eventsCount=0):(y.newListener!==void 0&&(c.emit("newListener",s,l.listener?l.listener:l),y=c._events),S=y[s]),S===void 0)S=y[s]=l,++c._eventsCount;else if(typeof S=="function"?S=y[s]=h?[l,S]:[S,l]:h?S.unshift(l):S.push(l),C=T(c),C>0&&S.length>C&&!S.warned){S.warned=!0;var w=new Error("Possible EventEmitter memory leak detected. "+S.length+" "+String(s)+" listeners added. Use emitter.setMaxListeners() to increase limit");w.name="MaxListenersExceededWarning",w.emitter=c,w.type=s,w.count=S.length,i(w)}return c}a.prototype.addListener=function(s,l){return E(this,s,l,!1)},a.prototype.on=a.prototype.addListener,a.prototype.prependListener=function(s,l){return E(this,s,l,!0)};function b(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function m(c,s,l){var h={fired:!1,wrapFn:void 0,target:c,type:s,listener:l},C=b.bind(h);return C.listener=l,h.wrapFn=C,C}a.prototype.once=function(s,l){return p(l),this.on(s,m(this,s,l)),this},a.prototype.prependOnceListener=function(s,l){return p(l),this.prependListener(s,m(this,s,l)),this},a.prototype.removeListener=function(s,l){var h,C,y,S,w;if(p(l),C=this._events,C===void 0)return this;if(h=C[s],h===void 0)return this;if(h===l||h.listener===l)--this._eventsCount===0?this._events=Object.create(null):(delete C[s],C.removeListener&&this.emit("removeListener",s,h.listener||l));else if(typeof h!="function"){for(y=-1,S=h.length-1;S>=0;S--)if(h[S]===l||h[S].listener===l){w=h[S].listener,y=S;break}if(y<0)return this;y===0?h.shift():x(h,y),h.length===1&&(C[s]=h[0]),C.removeListener!==void 0&&this.emit("removeListener",s,w||l)}return this},a.prototype.off=a.prototype.removeListener,a.prototype.removeAllListeners=function(s){var l,h,C;if(h=this._events,h===void 0)return this;if(h.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):h[s]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete h[s]),this;if(arguments.length===0){var y=Object.keys(h),S;for(C=0;C<y.length;++C)S=y[C],S!=="removeListener"&&this.removeAllListeners(S);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(l=h[s],typeof l=="function")this.removeListener(s,l);else if(l!==void 0)for(C=l.length-1;C>=0;C--)this.removeListener(s,l[C]);return this};function u(c,s,l){var h=c._events;if(h===void 0)return[];var C=h[s];return C===void 0?[]:typeof C=="function"?l?[C.listener||C]:[C]:l?O(C):P(C,C.length)}a.prototype.listeners=function(s){return u(this,s,!0)},a.prototype.rawListeners=function(s){return u(this,s,!1)},a.listenerCount=function(c,s){return typeof c.listenerCount=="function"?c.listenerCount(s):k.call(c,s)},a.prototype.listenerCount=k;function k(c){var s=this._events;if(s!==void 0){var l=s[c];if(typeof l=="function")return 1;if(l!==void 0)return l.length}return 0}a.prototype.eventNames=function(){return this._eventsCount>0?n(this._events):[]};function P(c,s){for(var l=new Array(s),h=0;h<s;++h)l[h]=c[h];return l}function x(c,s){for(;s+1<c.length;s++)c[s]=c[s+1];c.pop()}function O(c){for(var s=new Array(c.length),l=0;l<s.length;++l)s[l]=c[l].listener||c[l];return s}function A(c,s){return new Promise(function(l,h){function C(S){c.removeListener(s,y),h(S)}function y(){typeof c.removeListener=="function"&&c.removeListener("error",C),l([].slice.call(arguments))}D(c,s,y,{once:!0}),s!=="error"&&I(c,C,{once:!0})})}function I(c,s,l){typeof c.on=="function"&&D(c,"error",s,l)}function D(c,s,l,h){if(typeof c.on=="function")h.once?c.once(s,l):c.on(s,l);else if(typeof c.addEventListener=="function")c.addEventListener(s,function C(y){h.once&&c.removeEventListener(s,C),l(y)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof c)}return V.exports}var Z=He();const Be=2e4;var be=(e=>(e.CameraChanged="cameraChanged",e.MicrophoneChanged="microphoneChanged",e.StateChanged="stateChanged",e))(be||{});const F=e=>({isConnected:e==="listening"||e==="thinking"||e==="speaking",canListen:e==="pre-connect-buffering"||e==="listening"||e==="thinking"||e==="speaking",isFinished:e==="disconnected"||e==="failed",isPending:e==="connecting"||e==="initializing"||e==="idle"}),We=()=>{const[e,t]=r.useState(null),[n,i]=r.useState(null),d=r.useRef("connecting"),a=r.useRef(!1),o=p=>setTimeout(()=>{if(!a.current){t("Agent did not join the room.");return}const{isConnected:T}=F(d.current);if(!T){t("Agent joined the room but did not complete initializing.");return}},p??Be);return{agentTimeoutFailureReason:e,startAgentTimeout:r.useCallback(p=>{n&&clearTimeout(n),t(null),i(o(p)),d.current="connecting",a.current=!1},[n]),clearAgentTimeout:r.useCallback(()=>{n&&clearTimeout(n),t(null),i(null),d.current="connecting",a.current=!1},[n]),clearAgentTimeoutFailureReason:r.useCallback(()=>{t(null)},[]),updateAgentTimeoutState:r.useCallback(p=>{d.current=p},[]),updateAgentTimeoutParticipantExists:r.useCallback(p=>{a.current=p},[])}};function qe(e,t){const n=r.useRef(t);r.useEffect(()=>{n.current=t},[t]);const i=r.useCallback(async o=>{const{isConnected:p}=F(n.current);if(!p)return new Promise((T,E)=>{const b=k=>{const{isConnected:P}=F(k);P&&(u(),T())},m=()=>{u(),E(new Error("useAgent(/* ... */).waitUntilConnected - signal aborted"))},u=()=>{e.off("stateChanged",b),o==null||o.removeEventListener("abort",m)};e.on("stateChanged",b),o==null||o.addEventListener("abort",m)})},[e]),d=r.useCallback(async o=>{const{canListen:p}=F(n.current);if(!p)return new Promise((T,E)=>{const b=k=>{const{canListen:P}=F(k);P&&(u(),T())},m=()=>{u(),E(new Error("useAgent(/* ... */).waitUntilCouldBeListening - signal aborted"))},u=()=>{e.off("stateChanged",b),o==null||o.removeEventListener("abort",m)};e.on("stateChanged",b),o==null||o.addEventListener("abort",m)})},[e]),a=r.useCallback(async o=>{const{isFinished:p}=F(n.current);if(!p)return new Promise((T,E)=>{const b=k=>{const{isFinished:P}=F(k);P&&(u(),T())},m=()=>{u(),E(new Error("useAgent(/* ... */).waitUntilFinished - signal aborted"))},u=()=>{e.off("stateChanged",b),o==null||o.removeEventListener("abort",m)};e.on("stateChanged",b),o==null||o.addEventListener("abort",m)})},[e]);return{waitUntilConnected:i,waitUntilCouldBeListening:d,waitUntilFinished:a}}function ee(e){const t=X();if(e=e??t,!e)throw new Error("No session provided, make sure you are inside a Session context or pass the session explicitly");const{room:n,internal:{agentConnectTimeoutMilliseconds:i,agentTimeoutFailureReason:d,startAgentTimeout:a,clearAgentTimeout:o,clearAgentTimeoutFailureReason:p,updateAgentTimeoutState:T,updateAgentTimeoutParticipantExists:E}}=e,b=r.useMemo(()=>new Z.EventEmitter,[]),m=Q({room:n}),u=r.useMemo(()=>m.find(g=>g.kind===f.ParticipantKind.AGENT&&!(v.ParticipantAgentAttributes.PublishOnBehalf in g.attributes))??null,[m]),k=r.useMemo(()=>u?m.find(g=>g.kind===f.ParticipantKind.AGENT&&g.attributes[v.ParticipantAgentAttributes.PublishOnBehalf]===u.identity)??null:null,[u,m]),[P,x]=r.useState({});r.useEffect(()=>{if(!u)return;const g=N=>{x(N)};return u.on(f.ParticipantEvent.AttributesChanged,g),()=>{u.off(f.ParticipantEvent.AttributesChanged,g)}},[u,b]);const O=J([f.Track.Source.Camera,f.Track.Source.Microphone],{room:n,participantIdentity:u==null?void 0:u.identity}),A=J([f.Track.Source.Camera,f.Track.Source.Microphone],{room:n,participantIdentity:k==null?void 0:k.identity}),I=r.useMemo(()=>O.find(g=>g.source===f.Track.Source.Camera)??A.find(g=>g.source===f.Track.Source.Camera),[O,A]);r.useEffect(()=>{b.emit("cameraChanged",I)},[b,I]);const D=r.useMemo(()=>O.find(g=>g.source===f.Track.Source.Microphone)??A.find(g=>g.source===f.Track.Source.Microphone),[O,A]);r.useEffect(()=>{b.emit("microphoneChanged",D)},[b,D]);const[c,s]=r.useState(n.state);r.useEffect(()=>{const g=N=>{s(N)};return n.on(f.RoomEvent.ConnectionStateChanged,g),()=>{n.off(f.RoomEvent.ConnectionStateChanged,g)}},[n]),r.useEffect(()=>{u&&p()},[u]);const[l,h]=r.useState(null);r.useEffect(()=>{if(!u)return;const g=N=>{N.identity===(u==null?void 0:u.identity)&&h("Agent left the room unexpectedly.")};return n.on(f.RoomEvent.ParticipantDisconnected,g),()=>{n.off(f.RoomEvent.ParticipantDisconnected,g)}},[u,n]),r.useEffect(()=>{c===f.ConnectionState.Disconnected&&h(null)},[c]);const[C,y]=r.useState(()=>n.localParticipant.getTrackPublication(f.Track.Source.Microphone)??null);r.useEffect(()=>{const g=()=>{y(n.localParticipant.getTrackPublication(f.Track.Source.Microphone)??null)},N=()=>{y(null)};return n.localParticipant.on(f.ParticipantEvent.LocalTrackPublished,g),n.localParticipant.on(f.ParticipantEvent.LocalTrackUnpublished,N),()=>{n.localParticipant.off(f.ParticipantEvent.LocalTrackPublished,g),n.localParticipant.off(f.ParticipantEvent.LocalTrackUnpublished,N)}},[n.localParticipant]);const S=r.useMemo(()=>{const g=[];return d&&g.push(d),l&&g.push(l),g},[d,l]),w=r.useMemo(()=>{if(S.length>0)return"failed";let g="disconnected";return c!==f.ConnectionState.Disconnected&&(g="connecting"),C&&(g="pre-connect-buffering"),u&&P[v.ParticipantAgentAttributes.AgentState]&&(g=P[v.ParticipantAgentAttributes.AgentState]),g},[S,c,C,u,P]);r.useEffect(()=>{b.emit("stateChanged",w),T(w)},[b,w]),r.useEffect(()=>{E(u!==null)},[u]);const _=e.connectionState==="disconnected";r.useEffect(()=>{if(!_)return a(i),()=>{o()}},[_,i]);const j=r.useMemo(()=>{const g={attributes:P,internal:{agentParticipant:u,workerParticipant:k,emitter:b}};switch(w){case"disconnected":return{...g,state:w,...F(w),failureReasons:null,cameraTrack:void 0,microphoneTrack:void 0};case"connecting":return{...g,state:w,...F(w),failureReasons:null,cameraTrack:void 0,microphoneTrack:void 0};case"initializing":case"idle":return{...g,state:w,...F(w),failureReasons:null,cameraTrack:I,microphoneTrack:D};case"pre-connect-buffering":return{...g,state:w,...F(w),failureReasons:null,cameraTrack:I,microphoneTrack:D};case"listening":case"thinking":case"speaking":return{...g,state:w,...F(w),failureReasons:null,cameraTrack:I,microphoneTrack:D};case"failed":return{...g,state:"failed",...F("failed"),failureReasons:S,cameraTrack:void 0,microphoneTrack:void 0}}},[P,b,u,w,I,D]),{waitUntilConnected:q,waitUntilCouldBeListening:K,waitUntilFinished:R}=qe(b,w),L=r.useCallback(g=>new Promise((N,$)=>{const H=W=>{W&&(G(),N(W))},B=()=>{G(),$(new Error("useAgent(/* ... */).waitUntilCamera - signal aborted"))},G=()=>{b.off("cameraChanged",H),g==null||g.removeEventListener("abort",B)};b.on("cameraChanged",H),g==null||g.addEventListener("abort",B)}),[b]),z=r.useCallback(g=>new Promise((N,$)=>{const H=W=>{W&&(G(),N(W))},B=()=>{G(),$(new Error("useAgent(/* ... */).waitUntilMicrophone - signal aborted"))},G=()=>{b.off("microphoneChanged",H),g==null||g.removeEventListener("abort",B)};b.on("microphoneChanged",H),g==null||g.addEventListener("abort",B)}),[b]);return r.useMemo(()=>({...j,waitUntilConnected:q,waitUntilCouldBeListening:K,waitUntilFinished:R,waitUntilCamera:L,waitUntilMicrophone:z}),[j,q,K,R,L,z])}var ve=(e=>(e.ConnectionStateChanged="connectionStateChanged",e.MediaDevicesError="mediaDevicesError",e.EncryptionError="encryptionError",e))(ve||{});function Ge(e,t){const n=new Set([...Object.keys(e),...Object.keys(t)]);for(const i of n)switch(i){case"roomName":case"participantName":case"participantIdentity":case"participantMetadata":case"participantAttributes":case"agentName":case"agentMetadata":if(e[i]!==t[i])return!1;break;default:const d=i;throw new Error(`Options key ${d} not being checked for equality!`)}return!0}function Ke(e,t){const n=r.useRef(t);return r.useEffect(()=>{n.current=t},[t]),r.useCallback(async(d,a)=>{if(n.current!==d)return new Promise((o,p)=>{const T=m=>{m===d&&(b(),o())},E=()=>{b(),p(new Error(`useSession(/* ... */).waitUntilConnectionState(${d}, /* signal */) - signal aborted`))},b=()=>{e.off("connectionStateChanged",T),a==null||a.removeEventListener("abort",E)};e.on("connectionStateChanged",T),a==null||a.addEventListener("abort",E)})},[e])}function $e(e,t){const n=e instanceof f.TokenSourceConfigurable,i=r.useRef(n?t:null);return r.useEffect(()=>{if(!n){i.current=null;return}i.current!==null&&Ge(i.current,t)||(i.current=t)},[n,t]),r.useCallback(async()=>{if(n){if(!i.current)throw new Error("AgentSession - memoized token fetch options are not set, but the passed tokenSource was an instance of TokenSourceConfigurable. If you are seeing this please make a new GitHub issue!");return e.fetch(i.current)}else return e.fetch()},[n,e])}function ze(e,t={}){const{room:n,agentConnectTimeoutMilliseconds:i,...d}=t,a=v.useMaybeRoomContext(),o=r.useMemo(()=>a??n??new f.Room,[a,n]),p=r.useMemo(()=>new Z.EventEmitter,[]),T=r.useCallback(R=>({isConnected:R===f.ConnectionState.Connected||R===f.ConnectionState.Reconnecting||R===f.ConnectionState.SignalReconnecting}),[]),[E,b]=r.useState(o.state);r.useEffect(()=>{const R=L=>{b(L)};return o.on(f.RoomEvent.ConnectionStateChanged,R),()=>{o.off(f.RoomEvent.ConnectionStateChanged,R)}},[o]),r.useEffect(()=>{const R=async L=>{p.emit("mediaDevicesError",L)};return o.on(f.RoomEvent.MediaDevicesError,R),()=>{o.off(f.RoomEvent.MediaDevicesError,R)}},[o,p]),r.useEffect(()=>{const R=async L=>{p.emit("encryptionError",L)};return o.on(f.RoomEvent.EncryptionError,R),()=>{o.off(f.RoomEvent.EncryptionError,R)}},[o,p]);const{localParticipant:m}=v.useLocalParticipant({room:o}),u=m.getTrackPublication(f.Track.Source.Camera),k=r.useMemo(()=>!u||u.isMuted?null:{source:f.Track.Source.Camera,participant:m,publication:u},[m,u,u==null?void 0:u.isMuted]),P=m.getTrackPublication(f.Track.Source.Microphone),x=r.useMemo(()=>!P||P.isMuted?null:{source:f.Track.Source.Microphone,participant:m,publication:P},[m,P,P==null?void 0:P.isMuted]),{agentTimeoutFailureReason:O,startAgentTimeout:A,clearAgentTimeout:I,clearAgentTimeoutFailureReason:D,updateAgentTimeoutState:c,updateAgentTimeoutParticipantExists:s}=We(),l=r.useMemo(()=>({emitter:p,tokenSource:e,agentConnectTimeoutMilliseconds:i,agentTimeoutFailureReason:O,startAgentTimeout:A,clearAgentTimeout:I,clearAgentTimeoutFailureReason:D,updateAgentTimeoutState:c,updateAgentTimeoutParticipantExists:s}),[p,i,e,O,A,I,D,c,s]),h=r.useMemo(()=>{const R={room:o,internal:l};switch(E){case f.ConnectionState.Connecting:return{...R,connectionState:f.ConnectionState.Connecting,...T(f.ConnectionState.Connecting),local:{cameraTrack:null,microphoneTrack:null}};case f.ConnectionState.Connected:case f.ConnectionState.Reconnecting:case f.ConnectionState.SignalReconnecting:return{...R,connectionState:E,...T(E),local:{cameraTrack:k,microphoneTrack:x}};case f.ConnectionState.Disconnected:return{...R,connectionState:f.ConnectionState.Disconnected,...T(f.ConnectionState.Disconnected),local:{cameraTrack:null,microphoneTrack:null}}}},[l,o,E,k,x,T]);r.useEffect(()=>{p.emit("connectionStateChanged",h.connectionState)},[p,h.connectionState]);const C=Ke(p,h.connectionState),y=r.useCallback(async R=>C(f.ConnectionState.Connected,R),[C]),S=r.useCallback(async R=>C(f.ConnectionState.Disconnected,R),[C]),w=ee(r.useMemo(()=>({connectionState:h.connectionState,room:o,internal:l}),[h,o,l])),_=$e(e,d),j=r.useCallback(async(R={})=>{var H,B;const{signal:L,tracks:z={microphone:{enabled:!0,publishOptions:{preConnectBuffer:!0}}},roomConnectOptions:g}=R;await S(L);const N=()=>{o.disconnect()};L==null||L.addEventListener("abort",N);let $=!1;await Promise.all([_().then(({serverUrl:G,participantToken:W})=>{var te,ne;return $=(((ne=(te=f.decodeTokenPayload(W).roomConfig)==null?void 0:te.agents)==null?void 0:ne.length)??0)>0,o.connect(G,W,g)}),(H=z.microphone)!=null&&H.enabled?o.localParticipant.setMicrophoneEnabled(!0,void 0,((B=z.microphone)==null?void 0:B.publishOptions)??{}):Promise.resolve()]),await y(L),$&&await w.waitUntilConnected(L),L==null||L.removeEventListener("abort",N)},[o,S,_,y,w.waitUntilConnected]),q=r.useCallback(async()=>{await o.disconnect()},[o]),K=r.useCallback(async()=>{const R=await _();await o.prepareConnection(R.serverUrl,R.participantToken)},[_,o]);return r.useEffect(()=>{K().catch(R=>{console.warn("WARNING: Room.prepareConnection failed:",R)})},[]),r.useMemo(()=>({...h,waitUntilConnected:y,waitUntilDisconnected:S,prepareConnection:K,start:j,end:q}),[h,y,S,K,j,q])}function Je(e,t,n,i){const d=r.useMemo(()=>()=>{},[]),a=r.useCallback(n??d,i??[]),o=i?a:n,p=r.useMemo(()=>e?"internal"in e?e.internal.emitter:e:null,[e]);r.useEffect(()=>{if(!(!p||!o))return p.on(t,o),()=>{p.off(t,o)}},[p,t,o])}var ge=(e=>(e.MessageReceived="messageReceived",e))(ge||{});function Ve(e){const{room:t}=ue(e),n=r.useMemo(()=>new Z.EventEmitter,[]),i=ee(e),d=he({room:t}),a=r.useMemo(()=>({room:t}),[t]),o=M.useChat(a),p=r.useMemo(()=>d.map(u=>{var k,P,x;switch(u.participantInfo.identity){case t.localParticipant.identity:return{type:"userTranscript",message:u.text,id:u.streamInfo.id,timestamp:u.streamInfo.timestamp,from:t.localParticipant};case((k=i.internal.agentParticipant)==null?void 0:k.identity):case((P=i.internal.workerParticipant)==null?void 0:P.identity):return{type:"agentTranscript",message:u.text,id:u.streamInfo.id,timestamp:u.streamInfo.timestamp,from:((x=i.internal.agentParticipant)==null?void 0:x.identity)===u.participantInfo.identity?i.internal.agentParticipant:i.internal.workerParticipant};default:return{type:"agentTranscript",message:u.text,id:u.streamInfo.id,timestamp:u.streamInfo.timestamp,from:Array.from(t.remoteParticipants.values()).find(O=>O.identity===u.participantInfo.identity)}}}),[d,t]),T=r.useMemo(()=>[...p,...o.chatMessages],[p,o.chatMessages]),E=r.useRef(new Map),b=r.useMemo(()=>{const u=new Date;for(const k of T)E.current.has(k.id)||E.current.set(k.id,u);return T.sort((k,P)=>{const x=E.current.get(k.id),O=E.current.get(P.id);return typeof x>"u"||typeof O>"u"?0:x.getTime()-O.getTime()})},[T]),m=r.useRef(new Set);return r.useEffect(()=>{for(const u of b)m.current.has(u.id)||(m.current.add(u.id),n.emit("messageReceived",u))},[b]),r.useMemo(()=>({messages:b,send:o.send,isSending:o.isSending,internal:{emitter:n}}),[b,o.send,o.isSending])}exports.AgentEvent=be;exports.MessagesEvent=ge;exports.SessionContext=Y;exports.SessionEvent=ve;exports.useAgent=ee;exports.useAudioPlayback=Te;exports.useClearPinButton=Ee;exports.useDataChannel=ke;exports.useEnsureSession=ue;exports.useEvents=Je;exports.useIsRecording=Ue;exports.useLiveKitRoom=we;exports.useMaybeSessionContext=X;exports.useParticipantAttribute=Ie;exports.useParticipantAttributes=me;exports.useParticipantInfo=Pe;exports.useParticipantPermissions=Re;exports.useParticipantTracks=J;exports.useParticipants=le;exports.useRemoteParticipant=Me;exports.useRemoteParticipants=Q;exports.useRoomInfo=Ae;exports.useSequentialRoomConnectDisconnect=je;exports.useSession=ze;exports.useSessionContext=Se;exports.useSessionMessages=Ve;exports.useSortedParticipants=Le;exports.useSpeakingParticipants=fe;exports.useTextStream=pe;exports.useToken=Oe;exports.useTrackByName=De;exports.useTrackTranscription=de;exports.useTranscriptions=he;exports.useVoiceAssistant=Fe; | ||
| //# sourceMappingURL=shared-D30bmTxp.js.map |
Sorry, the diff of this file is too big to display
| "use strict";const l=require("./shared-CVy2Ouqp.js"),X=require("react"),y=require("livekit-client");function Y(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const n in e)if(n!=="default"){const s=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(t,n,s.get?s:{enumerable:!0,get:()=>e[n]})}}return t.default=e,Object.freeze(t)}const o=Y(X),K=e=>{const t=o.useRef(e);return o.useEffect(()=>{t.current=e}),t};function Z(e,t){const n=te(),s=K(t);return o.useLayoutEffect(()=>{let r=!1;const i=e.current;if(!i)return;function c(u,a){r||s.current(u,a)}return n==null||n.subscribe(i,c),()=>{r=!0,n==null||n.unsubscribe(i,c)}},[e.current,n,s]),n==null?void 0:n.observer}function ee(){let e=!1,t=[];const n=new Map;if(typeof window>"u")return;const s=new ResizeObserver((r,i)=>{t=t.concat(r),e||window.requestAnimationFrame(()=>{const c=new Set;for(let u=0;u<t.length;u++){if(c.has(t[u].target))continue;c.add(t[u].target);const a=n.get(t[u].target);a==null||a.forEach(d=>d(t[u],i))}t=[],e=!1}),e=!0});return{observer:s,subscribe(r,i){s.observe(r);const c=n.get(r)??[];c.push(i),n.set(r,c)},unsubscribe(r,i){const c=n.get(r)??[];if(c.length===1){s.unobserve(r),n.delete(r);return}const u=c.indexOf(i);u!==-1&&c.splice(u,1),n.set(r,c)}}}let A;const te=()=>A||(A=ee()),_=e=>{const[t,n]=o.useState({width:0,height:0});o.useLayoutEffect(()=>{if(e.current){const{width:r,height:i}=e.current.getBoundingClientRect();n({width:r,height:i})}},[e.current]);const s=o.useCallback(r=>n(r.contentRect),[]);return Z(e,s),t};function v(e,t,n=!0){const[s,r]=o.useState(t);return o.useEffect(()=>{if(n&&r(t),typeof window>"u"||!e)return;const i=e.subscribe(r);return()=>i.unsubscribe()},[e,n]),s}function q(e,t){if(t.msg==="show_chat")return{...e,showChat:!0,unreadMessages:0};if(t.msg==="hide_chat")return{...e,showChat:!1};if(t.msg==="toggle_chat"){const n={...e,showChat:!e.showChat};return n.showChat===!0&&(n.unreadMessages=0),n}else return t.msg==="unread_msg"?{...e,unreadMessages:t.count}:t.msg==="toggle_settings"?{...e,showSettings:!e.showSettings}:{...e}}function U(e,t){return t.msg==="set_pin"?[t.trackReference]:t.msg==="clear_pin"?[]:{...e}}const D=o.createContext(void 0);function z(){const e=o.useContext(D);if(!e)throw Error("Tried to access LayoutContext context outside a LayoutContextProvider provider.");return e}function B(e){const t=L();if(e??(e=t),!e)throw Error("Tried to access LayoutContext context outside a LayoutContextProvider provider.");return e}function ne(){const[e,t]=o.useReducer(U,l.PIN_DEFAULT_STATE),[n,s]=o.useReducer(q,l.WIDGET_DEFAULT_STATE);return{pin:{dispatch:t,state:e},widget:{dispatch:s,state:n}}}function se(e){const[t,n]=o.useReducer(U,l.PIN_DEFAULT_STATE),[s,r]=o.useReducer(q,l.WIDGET_DEFAULT_STATE);return e??{pin:{dispatch:n,state:t},widget:{dispatch:r,state:s}}}function L(){return o.useContext(D)}const I=o.createContext(void 0);function re(){const e=o.useContext(I);if(!e)throw Error("tried to access track context outside of track context provider");return e}function x(){return o.useContext(I)}function w(e){const t=x(),n=e??t;if(!n)throw new Error("No TrackRef, make sure you are inside a TrackRefContext or pass the TrackRef explicitly");return n}const N=o.createContext(void 0);function oe(){const e=o.useContext(N);if(!e)throw Error("tried to access participant context outside of participant context provider");return e}function W(){return o.useContext(N)}function T(e){const t=W(),n=x(),s=e??t??(n==null?void 0:n.participant);if(!s)throw new Error("No participant provided, make sure you are inside a participant context or pass the participant explicitly");return s}function J(e){var t,n,s="";if(typeof e=="string"||typeof e=="number")s+=e;else if(typeof e=="object")if(Array.isArray(e)){var r=e.length;for(t=0;t<r;t++)e[t]&&(n=J(e[t]))&&(s&&(s+=" "),s+=n)}else for(n in e)e[n]&&(s&&(s+=" "),s+=n);return s}function j(){for(var e,t,n=0,s="",r=arguments.length;n<r;n++)(e=arguments[n])&&(t=J(e))&&(s&&(s+=" "),s+=t);return s}function ce(...e){return(...t)=>{for(const n of e)if(typeof n=="function")try{n(...t)}catch(s){console.error(s)}}}function k(...e){const t={...e[0]};for(let n=1;n<e.length;n++){const s=e[n];for(const r in s){const i=t[r],c=s[r];typeof i=="function"&&typeof c=="function"&&r[0]==="o"&&r[1]==="n"&&r.charCodeAt(2)>=65&&r.charCodeAt(2)<=90?t[r]=ce(i,c):(r==="className"||r==="UNSAFE_className")&&typeof i=="string"&&typeof c=="string"?t[r]=j(i,c):t[r]=c!==void 0?c:i}}return t}function ie(e={}){const t=T(e.participant),{className:n,connectionQualityObserver:s}=o.useMemo(()=>l.setupConnectionQualityIndicator(t),[t]),r=v(s,t.connectionQuality);return{className:n,quality:r}}function F(e){const t=l.useEnsureRoom(e),n=o.useMemo(()=>l.connectionStateObserver(t),[t]);return v(n,t.state)}function ue(e){const t=l.useRoomContext(),n=F(t);return{buttonProps:o.useMemo(()=>{const{className:r,disconnect:i}=l.setupDisconnectButton(t);return k(e,{className:r,onClick:()=>i(e.stopTracks??!0),disabled:n===y.ConnectionState.Disconnected})},[t,e,n])}}function G(e){if(e.publication instanceof y.LocalTrackPublication){const t=e.publication.track;if(t){const{facingMode:n}=y.facingModeFromLocalTrack(t);return n}}return"undefined"}function ae({trackRef:e,props:t}){const n=w(e),s=L(),{className:r}=o.useMemo(()=>l.setupFocusToggle(),[]),i=o.useMemo(()=>l.isTrackReferencePinned(n,s==null?void 0:s.pin.state),[n,s==null?void 0:s.pin.state]);return{mergedProps:o.useMemo(()=>k(t,{className:r,onClick:u=>{var a,d,p,f,m;(a=t.onClick)==null||a.call(t,u),i?(p=s==null?void 0:(d=s.pin).dispatch)==null||p.call(d,{msg:"clear_pin"}):(m=s==null?void 0:(f=s.pin).dispatch)==null||m.call(f,{msg:"set_pin",trackReference:n})}}),[t,r,n,i,s==null?void 0:s.pin]),inFocus:i}}function le(e,t,n={}){const s=n.gridLayouts??l.GRID_LAYOUTS,{width:r,height:i}=_(e),c=l.selectGridLayout(s,t,r,i);return o.useEffect(()=>{e.current&&c&&(e.current.style.setProperty("--lk-col-count",c==null?void 0:c.columns.toString()),e.current.style.setProperty("--lk-row-count",c==null?void 0:c.rows.toString()))},[e,c]),{layout:c,containerWidth:r,containerHeight:i}}function R(e,t={}){var u,a;const n=typeof e=="string"?t.participant:e.participant,s=T(n),r=typeof e=="string"?{participant:s,source:e}:e,[i,c]=o.useState(!!((u=r.publication)!=null&&u.isMuted||(a=s.getTrackPublication(r.source))!=null&&a.isMuted));return o.useEffect(()=>{const d=l.mutedObserver(r).subscribe(c);return()=>d.unsubscribe()},[l.getTrackReferenceId(r)]),i}function Q(e){const t=T(e),n=o.useMemo(()=>l.createIsSpeakingObserver(t),[t]);return v(n,t.isSpeaking)}function de(e){return e!==void 0}function fe(...e){return k(...e.filter(de))}function pe(e,t,n){return o.Children.map(e,s=>o.isValidElement(s)&&o.Children.only(e)?(s.props.className&&(t??(t={}),t.className=j(s.props.className,t.className),t.style={...s.props.style,...t.style}),o.cloneElement(s,{...t,key:n})):s)}function me(e){var t,n;if(typeof window<"u"&&typeof process<"u"&&(((t=process==null?void 0:process.env)==null?void 0:t.NODE_ENV)==="dev"||((n=process==null?void 0:process.env)==null?void 0:n.NODE_ENV)==="development")){const s=document.querySelector(".lk-room-container");s&&!getComputedStyle(s).getPropertyValue("--lk-has-imported-styles")&&l.log.warn("It looks like you're not using the `@livekit/components-styles package`. To render the UI with the default styling, please import it in your layout or page.")}}function ge(e,t){return e==="processor"&&t&&typeof t=="object"&&"name"in t?t.name:e==="e2ee"&&t?"e2ee-enabled":t}function be(){const e=l.useRoomContext(),t=o.useMemo(()=>l.participantPermissionObserver(e.localParticipant),[e]);return v(t,e.localParticipant.permissions)}function he({kind:e,room:t,track:n,requestPermissions:s,onError:r}){const i=l.useMaybeRoomContext(),c=o.useMemo(()=>t??i??new y.Room,[t,i]),u=o.useMemo(()=>l.createMediaDeviceObserver(e,r,s),[e,s,r]),a=v(u,[]),[d,p]=o.useState((c==null?void 0:c.getActiveDevice(e))??"default"),{className:f,activeDeviceObservable:m,setActiveMediaDevice:g}=o.useMemo(()=>l.setupDeviceSelector(e,c),[e,c,n]);return o.useEffect(()=>{const h=m.subscribe(S=>{S&&(l.log.info("setCurrentDeviceId",S),p(S))});return()=>{h==null||h.unsubscribe()}},[m]),{devices:a,className:f,activeDeviceId:d,setActiveMediaDevice:g}}function ye({kind:e,onError:t}){const n=o.useMemo(()=>l.createMediaDeviceObserver(e,t),[e,t]);return v(n,[])}function $(e,t,n={}){const s=o.useRef([]),r=o.useRef(-1),i=t!==r.current,c=typeof n.customSortFunction=="function"?n.customSortFunction(e):l.sortTrackReferences(e);let u=[...c];if(i===!1)try{u=l.updatePages(s.current,c,t)}catch(a){l.log.error("Error while running updatePages(): ",a)}return i?s.current=c:s.current=u,r.current=t,u}function Se(e,t){const[n,s]=o.useState(1),r=Math.max(Math.ceil(t.length/e),1);n>r&&s(r);const i=n*e,c=i-e,u=f=>{s(m=>f==="next"?m===r?m:m+1:m===1?m:m-1)},a=f=>{f>r?s(r):f<1?s(1):s(f)},p=$(t,e).slice(c,i);return{totalPageCount:r,nextPage:()=>u("next"),prevPage:()=>u("previous"),setPage:a,firstItemIndex:c,lastItemIndex:i,tracks:p,currentPage:n}}function ve({trackRef:e,onParticipantClick:t,disableSpeakingIndicator:n,htmlProps:s}){const r=w(e),i=o.useMemo(()=>{const{className:m}=l.setupParticipantTile();return k(s,{className:m,onClick:g=>{var h;if((h=s.onClick)==null||h.call(s,g),typeof t=="function"){const S=r.publication??r.participant.getTrackPublication(r.source);t({participant:r.participant,track:S})}}})},[s,t,r.publication,r.source,r.participant]),c=r.participant.getTrackPublication(y.Track.Source.Microphone),u=o.useMemo(()=>({participant:r.participant,source:y.Track.Source.Microphone,publication:c}),[c,r.participant]),a=R(r),d=R(u),p=Q(r.participant),f=G(r);return{elementProps:{"data-lk-audio-muted":d,"data-lk-video-muted":a,"data-lk-speaking":n===!0?!1:p,"data-lk-local-participant":r.participant.isLocal,"data-lk-source":r.source,"data-lk-facing-mode":f,...i}}}function Me(e){return e=B(e),o.useMemo(()=>(e==null?void 0:e.pin.state)!==void 0&&e.pin.state.length>=1?e.pin.state:[],[e.pin.state])}function ke({room:e,props:t}){const n=l.useEnsureRoom(e),{className:s,roomAudioPlaybackAllowedObservable:r,handleStartAudioPlayback:i}=o.useMemo(()=>l.setupStartAudio(),[]),c=o.useMemo(()=>r(n),[n,r]),{canPlayAudio:u}=v(c,{canPlayAudio:n.canPlaybackAudio});return{mergedProps:o.useMemo(()=>k(t,{className:s,onClick:()=>{i(n)},style:{display:u?"none":"block"}}),[t,s,u,i,n]),canPlayAudio:u}}function Ce({room:e,props:t}){const n=l.useEnsureRoom(e),{className:s,roomVideoPlaybackAllowedObservable:r,handleStartVideoPlayback:i}=o.useMemo(()=>l.setupStartVideo(),[]),c=o.useMemo(()=>r(n),[n,r]),{canPlayVideo:u}=v(c,{canPlayVideo:n.canPlaybackVideo});return{mergedProps:o.useMemo(()=>k(t,{className:s,onClick:()=>{i(n)},style:{display:u?"none":"block"}}),[t,s,u,i,n]),canPlayVideo:u}}function Te(e,t={}){const n=o.useRef(null),s=o.useRef(null),r=t.minSwipeDistance??50,i=a=>{s.current=null,n.current=a.targetTouches[0].clientX},c=a=>{s.current=a.targetTouches[0].clientX},u=o.useCallback(()=>{if(!n.current||!s.current)return;const a=n.current-s.current,d=a>r,p=a<-r;d&&t.onLeftSwipe&&t.onLeftSwipe(),p&&t.onRightSwipe&&t.onRightSwipe()},[r,t]);o.useEffect(()=>{const a=e.current;return a&&(a.addEventListener("touchstart",i,{passive:!0}),a.addEventListener("touchmove",c,{passive:!0}),a.addEventListener("touchend",u,{passive:!0})),()=>{a&&(a.removeEventListener("touchstart",i),a.removeEventListener("touchmove",c),a.removeEventListener("touchend",u))}},[e,u])}function Pe({props:e}){const{dispatch:t,state:n}=z().widget,{className:s}=o.useMemo(()=>l.setupChatToggle(),[]);return{mergedProps:o.useMemo(()=>k(e,{className:s,onClick:()=>{t&&t({msg:"toggle_chat"})},"aria-pressed":n!=null&&n.showChat?"true":"false","data-lk-unread-msgs":n?n.unreadMessages<10?n.unreadMessages.toFixed(0):"9+":"0"}),[e,s,t,n])}}function we(e){var i,c;const t=w(e),{className:n,mediaMutedObserver:s}=o.useMemo(()=>l.setupTrackMutedIndicator(t),[l.getTrackReferenceId(t)]);return{isMuted:v(s,!!((i=t.publication)!=null&&i.isMuted||(c=t.participant.getTrackPublication(t.source))!=null&&c.isMuted)),className:n}}function Ee({source:e,onChange:t,initialState:n,captureOptions:s,publishOptions:r,onDeviceError:i,room:c,...u}){var P;const a=l.useMaybeRoomContext(),d=o.useMemo(()=>c??a,[c,a]),p=(P=d==null?void 0:d.localParticipant)==null?void 0:P.getTrackPublication(e),f=o.useRef(!1),{toggle:m,className:g,pendingObserver:h,enabledObserver:S}=o.useMemo(()=>d?l.setupMediaToggle(e,d,s,r,i):l.setupManualToggle(),[d,e,JSON.stringify(s),r]),M=v(h,!1),b=v(S,n??!!(p!=null&&p.isEnabled));o.useEffect(()=>{t==null||t(b,f.current),f.current=!1},[b,t]),o.useEffect(()=>{n!==void 0&&(l.log.debug("forcing initial toggle state",e,n),m(n))},[]);const C=o.useMemo(()=>k(u,{className:g}),[u,g]),E=o.useCallback(H=>{var O;f.current=!0,m().catch(()=>f.current=!1),(O=u.onClick)==null||O.call(u,H)},[u,m]);return{toggle:m,enabled:b,pending:M,track:p,buttonProps:{...C,"aria-pressed":b,"data-lk-source":e,"data-lk-enabled":b,disabled:M,onClick:E}}}function Ae(e=[y.Track.Source.Camera,y.Track.Source.Microphone,y.Track.Source.ScreenShare,y.Track.Source.ScreenShareAudio,y.Track.Source.Unknown],t={}){const n=l.useEnsureRoom(t.room),[s,r]=o.useState([]),[i,c]=o.useState([]),u=o.useMemo(()=>e.map(d=>l.isSourceWitOptions(d)?d.source:d),[JSON.stringify(e)]);return o.useEffect(()=>{const d=l.trackReferencesObservable(n,u,{additionalRoomEvents:t.updateOnlyOn,onlySubscribed:t.onlySubscribed}).subscribe(({trackReferences:p,participants:f})=>{l.log.debug("setting track bundles",p,f),r(p),c(f)});return()=>d.unsubscribe()},[n,JSON.stringify(t.onlySubscribed),JSON.stringify(t.updateOnlyOn),JSON.stringify(e)]),o.useMemo(()=>{if(l.isSourcesWithOptions(e)){const d=De(e,i),p=Array.from(s);return i.forEach(f=>{d.has(f.identity)&&(d.get(f.identity)??[]).forEach(g=>{if(s.find(({participant:S,publication:M})=>f.identity===S.identity&&M.source===g))return;l.log.debug(`Add ${g} placeholder for participant ${f.identity}.`);const h={participant:f,source:g};p.push(h)})}),p}else return s},[s,i,e])}function Re(e,t){const n=new Set(e);for(const s of t)n.delete(s);return n}function De(e,t){const n=new Map;if(l.isSourcesWithOptions(e)){const s=e.filter(r=>r.withPlaceholder).map(r=>r.source);t.forEach(r=>{const i=r.getTrackPublications().map(u=>{var a;return(a=u.track)==null?void 0:a.source}).filter(u=>u!==void 0),c=Array.from(Re(new Set(s),new Set(i)));c.length>0&&n.set(r.identity,c)})}return n}function Le(e){const t=l.useEnsureRoom(e==null?void 0:e.room),n=F(t),s=o.useMemo(()=>n===y.ConnectionState.Disconnected,[n]),r=o.useMemo(()=>l.setupChat(t,e),[t,e,s]),i=v(r.isSendingObservable,!1),c=v(r.messageObservable,[]);return{send:r.send,chatMessages:c,isSending:i}}function Ie(e={}){const[t,n]=o.useState(l.loadUserChoices(e.defaults,e.preventLoad??!1)),s=o.useCallback(a=>{n(d=>({...d,audioEnabled:a}))},[]),r=o.useCallback(a=>{n(d=>({...d,videoEnabled:a}))},[]),i=o.useCallback(a=>{n(d=>({...d,audioDeviceId:a}))},[]),c=o.useCallback(a=>{n(d=>({...d,videoDeviceId:a}))},[]),u=o.useCallback(a=>{n(d=>({...d,username:a}))},[]);return o.useEffect(()=>{l.saveUserChoices(t,e.preventSave??!1)},[t,e.preventSave]),{userChoices:t,saveAudioInputEnabled:s,saveVideoInputEnabled:r,saveAudioInputDeviceId:i,saveVideoInputDeviceId:c,saveUsername:u}}function xe(e,t={}){const n=T(e),s=l.useEnsureRoom(t.room),r=o.useMemo(()=>l.encryptionStatusObservable(s,n),[s,n]);return v(r,n.isLocal?n.isE2EEEnabled:!!(n!=null&&n.isEncrypted))}function Ne(e,t={fftSize:32,smoothingTimeConstant:0}){const n=l.isTrackReference(e)?e.publication.track:e,[s,r]=o.useState(0);return o.useEffect(()=>{if(!n||!n.mediaStream)return;const{cleanup:i,analyser:c}=y.createAudioAnalyser(n,t),u=c.frequencyBinCount,a=new Uint8Array(u),p=setInterval(()=>{c.getByteFrequencyData(a);let f=0;for(let m=0;m<a.length;m++){const g=a[m];f+=g*g}r(Math.sqrt(f/a.length)/255)},1e3/30);return()=>{i(),clearInterval(p)}},[n,n==null?void 0:n.mediaStream,JSON.stringify(t)]),s}const Fe=e=>{const t=n=>{let i=1-Math.max(-100,Math.min(-10,n))*-1/100;return i=Math.sqrt(i),i};return e.map(n=>n===-1/0?0:t(n))},Oe={bands:5,loPass:100,hiPass:600,updateInterval:32,analyserOptions:{fftSize:2048}};function Ve(e,t={}){var c;const n=e instanceof y.Track?e:(c=e==null?void 0:e.publication)==null?void 0:c.track,s={...Oe,...t},[r,i]=o.useState(new Array(s.bands).fill(0));return o.useEffect(()=>{if(!n||!(n!=null&&n.mediaStream)){i(g=>g.slice().fill(0));return}const{analyser:u,cleanup:a}=y.createAudioAnalyser(n,s.analyserOptions),d=u.frequencyBinCount,p=new Float32Array(d),m=setInterval(()=>{u.getFloatFrequencyData(p);let g=new Float32Array(p.length);for(let b=0;b<p.length;b++)g[b]=p[b];g=g.slice(t.loPass,t.hiPass);const h=Fe(g),S=Math.ceil(h.length/s.bands),M=[];for(let b=0;b<s.bands;b++){const C=h.slice(b*S,(b+1)*S).reduce((E,P)=>E+=P,0);M.push(C/S)}i(M)},s.updateInterval);return()=>{a(),clearInterval(m)}},[n,n==null?void 0:n.mediaStream,JSON.stringify(t)]),r}const _e={barCount:120,volMultiplier:5,updateInterval:20};function qe(e,t={}){var p;const n=e instanceof y.Track?e:(p=e==null?void 0:e.publication)==null?void 0:p.track,s={..._e,...t},r=o.useRef(new Float32Array),i=o.useRef(performance.now()),c=o.useRef(0),[u,a]=o.useState([]),d=o.useCallback(f=>{a(Array.from(ze(f,s.barCount).map(m=>Math.sqrt(m)*s.volMultiplier)))},[]);return o.useEffect(()=>{if(!n||!(n!=null&&n.mediaStream))return;const{analyser:f,cleanup:m}=y.createAudioAnalyser(n,{fftSize:V(s.barCount)}),g=V(s.barCount),h=new Float32Array(g),S=()=>{if(M=requestAnimationFrame(S),f.getFloatTimeDomainData(h),r.current.map((b,C)=>b+h[C]),c.current+=1,performance.now()-i.current>=s.updateInterval){const b=h.map(C=>C/c.current);d(b),i.current=performance.now(),c.current=0}};let M=requestAnimationFrame(S);return()=>{m(),cancelAnimationFrame(M)}},[n,n==null?void 0:n.mediaStream,JSON.stringify(t),d]),{bars:u}}function V(e){return e<32?32:Ue(e)}function Ue(e){let t=2;for(;e>>=1;)t<<=1;return t}function ze(e,t){const n=Math.floor(e.length/t),s=new Float32Array(t);for(let r=0;r<t;r++){const i=n*r;let c=0;for(let u=0;u<n;u++)c=c+Math.abs(e[i+u]);s[r]=c/n}return s}exports.LayoutContext=D;exports.ParticipantContext=N;exports.TrackRefContext=I;exports.cloneSingleChild=pe;exports.mergeProps=k;exports.mergeProps$1=fe;exports.roomOptionsStringifyReplacer=ge;exports.useAudioWaveform=qe;exports.useChat=Le;exports.useChatToggle=Pe;exports.useConnectionQualityIndicator=ie;exports.useConnectionState=F;exports.useCreateLayoutContext=ne;exports.useDisconnectButton=ue;exports.useEnsureCreateLayoutContext=se;exports.useEnsureLayoutContext=B;exports.useEnsureParticipant=T;exports.useEnsureTrackRef=w;exports.useFacingMode=G;exports.useFocusToggle=ae;exports.useGridLayout=le;exports.useIsEncrypted=xe;exports.useIsMuted=R;exports.useIsSpeaking=Q;exports.useLayoutContext=z;exports.useLocalParticipantPermissions=be;exports.useMaybeLayoutContext=L;exports.useMaybeParticipantContext=W;exports.useMaybeTrackRefContext=x;exports.useMediaDeviceSelect=he;exports.useMediaDevices=ye;exports.useMultibandTrackVolume=Ve;exports.useObservableState=v;exports.usePagination=Se;exports.useParticipantContext=oe;exports.useParticipantTile=ve;exports.usePersistentUserChoices=Ie;exports.usePinnedTracks=Me;exports.useSize=_;exports.useStartAudio=ke;exports.useStartVideo=Ce;exports.useSwipe=Te;exports.useTrackMutedIndicator=we;exports.useTrackRefContext=re;exports.useTrackToggle=Ee;exports.useTrackVolume=Ne;exports.useTracks=Ae;exports.useVisualStableUpdate=$;exports.warnAboutMissingStyles=me; | ||
| //# sourceMappingURL=shared-DoNgw2-D.js.map |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
3001281
0.65%24057
1.02%23
4.55%1
Infinity%50
2.04%