@ikonai/sdk 1.1.1 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { A as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, R as d, S as f, T as p, _ as m, a as h, b as g, c as ee, d as _, f as te, g as ne, h as re, i as ie, j as v, k as y, l as ae, m as oe, o as se, p as ce, r as le, s as ue, t as de, u as fe, v as b, w as pe, x as me, y as he } from "./ikon-media-DuCadOIe.js";
2
- import { _ as ge, a as _e, c as ve, d as x, f as S, g as ye, h as be, l as xe, m as Se, n as Ce, p as we, s as Te, t as Ee, u as De, v as C } from "./capabilities-Dm_Nog1J.js";
1
+ import { A as e, C as t, D as n, E as r, F as i, I as a, L as o, M as s, N as c, O as l, P as u, R as d, S as f, T as p, _ as m, a as h, b as g, c as ee, d as _, f as te, g as ne, h as re, i as ie, j as v, k as y, l as ae, m as oe, o as se, p as ce, r as le, s as ue, t as de, u as fe, v as b, w as pe, x as me, y as he } from "./ikon-media-ZZqVys00.js";
2
+ import { _ as ge, a as _e, c as ve, d as x, f as S, g as ye, h as be, l as xe, m as Se, n as Ce, p as we, s as Te, t as Ee, u as De, v as C } from "./capabilities-z1yDaWz3.js";
3
3
  //#region ../../shared/protocol/src/compression.ts
4
4
  var Oe;
5
5
  function ke() {
@@ -1755,6 +1755,10 @@ var Dl = class extends Error {
1755
1755
  constructor(e) {
1756
1756
  super(`App session provisioning timeout after ${e}ms`), this.name = "ProvisioningTimeoutError";
1757
1757
  }
1758
+ }, D = class extends w {
1759
+ constructor(e = "The app failed to start") {
1760
+ super(e), this.name = "AppStartupFailedError";
1761
+ }
1758
1762
  }, jl = class extends w {
1759
1763
  constructor(e) {
1760
1764
  super(`Space not found for domain: ${e}`), this.name = "SpaceNotFoundError";
@@ -1803,7 +1807,7 @@ function Ll(e, t) {
1803
1807
  //#endregion
1804
1808
  //#region src/utils/query-params.ts
1805
1809
  var Rl = "ikon-proxy", zl = "ikon-websocket", Bl = "ikon-webtransport", Vl = "ikon-debug", Hl = "ikon-lang", Ul = "ikon-server-url", Wl = "ikon-audio", Gl = "ikon-video", Kl = "ikon-webrtc", ql = "ikon-ice-transport", Jl = "ikon-inspect", Yl = "ikon-debug-overlay", Xl = "ikon-auth", Zl = "ikon-retry", Ql = "ikon-api", $l = "ikon-snapshot", eu = "ikon-session";
1806
- function D(e, t) {
1810
+ function tu(e, t) {
1807
1811
  if (typeof window > "u") return null;
1808
1812
  let n = new URLSearchParams(window.location.search), r = n.get(e);
1809
1813
  if (r !== null) return r;
@@ -1811,70 +1815,70 @@ function D(e, t) {
1811
1815
  return i === null ? t ? n.get(t) : null : i;
1812
1816
  }
1813
1817
  function O(e, t) {
1814
- let n = D(e, t);
1818
+ let n = tu(e, t);
1815
1819
  return n === "true" || n !== "false" && null;
1816
1820
  }
1817
- function tu(e, t) {
1821
+ function nu(e, t) {
1818
1822
  if (typeof window > "u") return;
1819
1823
  let n = new URL(window.location.href);
1820
1824
  n.searchParams.get(e) !== t && (n.searchParams.set(e, t), window.history.replaceState(null, "", n.toString()));
1821
1825
  }
1822
- function nu() {
1823
- return O(Rl);
1824
- }
1825
1826
  function ru() {
1826
- return O(zl);
1827
+ return O(Rl);
1827
1828
  }
1828
1829
  function iu() {
1829
- return O(Bl);
1830
+ return O(zl);
1830
1831
  }
1831
1832
  function au() {
1832
- return O(Vl) === !0;
1833
+ return O(Bl);
1833
1834
  }
1834
1835
  function ou() {
1835
- return D(Hl);
1836
+ return O(Vl) === !0;
1836
1837
  }
1837
1838
  function su() {
1838
- return D(Ul);
1839
+ return tu(Hl);
1839
1840
  }
1840
1841
  function cu() {
1841
- return O(Wl);
1842
+ return tu(Ul);
1842
1843
  }
1843
1844
  function lu() {
1844
- return O(Gl);
1845
+ return O(Wl);
1845
1846
  }
1846
1847
  function uu() {
1847
- return O(Kl);
1848
+ return O(Gl);
1848
1849
  }
1849
1850
  function du() {
1850
- let e = D(ql);
1851
- return e === "relay" ? "relay" : e === "all" ? "all" : null;
1851
+ return O(Kl);
1852
1852
  }
1853
1853
  function fu() {
1854
- return O(Jl) === !0;
1854
+ let e = tu(ql);
1855
+ return e === "relay" ? "relay" : e === "all" ? "all" : null;
1855
1856
  }
1856
1857
  function pu() {
1857
- return O(Yl) === !0;
1858
+ return O(Jl) === !0;
1858
1859
  }
1859
1860
  function mu() {
1860
- let e = D(Xl);
1861
+ return O(Yl) === !0;
1862
+ }
1863
+ function hu() {
1864
+ let e = tu(Xl);
1861
1865
  return e === "true" || e === "same";
1862
1866
  }
1863
1867
  function k() {
1864
1868
  return O(Zl) !== !1;
1865
1869
  }
1866
- function hu() {
1870
+ function gu() {
1867
1871
  return O(Ql);
1868
1872
  }
1869
- function gu() {
1873
+ function _u() {
1870
1874
  return O($l) === !0;
1871
1875
  }
1872
- function _u() {
1873
- return D(eu);
1876
+ function vu() {
1877
+ return tu(eu);
1874
1878
  }
1875
1879
  //#endregion
1876
1880
  //#region src/transport/web-socket-transport.ts
1877
- var A = S("WebSocketTransport"), vu = 1e4, yu = class {
1881
+ var A = S("WebSocketTransport"), yu = 1e4, bu = class {
1878
1882
  ws = null;
1879
1883
  keepaliveTimeout = null;
1880
1884
  isClosed = !1;
@@ -1885,7 +1889,7 @@ var A = S("WebSocketTransport"), vu = 1e4, yu = class {
1885
1889
  callbacks;
1886
1890
  sessionId;
1887
1891
  constructor(e) {
1888
- this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ?? vu;
1892
+ this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ?? yu;
1889
1893
  }
1890
1894
  get isConnected() {
1891
1895
  return this.ws?.readyState === WebSocket.OPEN;
@@ -1957,11 +1961,11 @@ var A = S("WebSocketTransport"), vu = 1e4, yu = class {
1957
1961
  clearKeepaliveTimeout() {
1958
1962
  this.keepaliveTimeout &&= (clearTimeout(this.keepaliveTimeout), null);
1959
1963
  }
1960
- }, j = S("WebTransportTransport"), bu = 1e4, xu = 4, Su = 65536;
1961
- function Cu() {
1964
+ }, j = S("WebTransportTransport"), xu = 1e4, Su = 4, Cu = 65536;
1965
+ function wu() {
1962
1966
  return typeof WebTransport < "u";
1963
1967
  }
1964
- var wu = class {
1968
+ var Tu = class {
1965
1969
  transport = null;
1966
1970
  stream = null;
1967
1971
  reader = null;
@@ -1969,7 +1973,7 @@ var wu = class {
1969
1973
  keepaliveTimeout = null;
1970
1974
  readLoopActive = !1;
1971
1975
  isClosed = !1;
1972
- receiveBuffer = new Uint8Array(Su);
1976
+ receiveBuffer = new Uint8Array(Cu);
1973
1977
  receiveBufferOffset = 0;
1974
1978
  receiveBufferLength = 0;
1975
1979
  receiveDataView = null;
@@ -1982,13 +1986,13 @@ var wu = class {
1982
1986
  callbacks;
1983
1987
  sessionId;
1984
1988
  constructor(e) {
1985
- this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ?? bu;
1989
+ this.callbacks = e.callbacks, this.sessionId = e.sessionId, this.keepaliveTimeoutMs = e.keepaliveTimeoutMs, this.connectionTimeoutMs = e.connectionTimeoutMs ?? xu;
1986
1990
  }
1987
1991
  get isConnected() {
1988
1992
  return this.transport !== null && this.writer !== null;
1989
1993
  }
1990
1994
  async connect(e, t) {
1991
- if (!Cu()) throw new T("WebTransport is not supported in this browser");
1995
+ if (!wu()) throw new T("WebTransport is not supported in this browser");
1992
1996
  this.isClosed = !1;
1993
1997
  let n = Date.now(), r = new Promise((e, t) => {
1994
1998
  this.firstMessageResolver = e, this.firstMessageRejecter = t;
@@ -2069,9 +2073,9 @@ var wu = class {
2069
2073
  }
2070
2074
  processBufferedMessages() {
2071
2075
  let e = this.getReceiveDataView();
2072
- for (; this.receiveBufferLength >= xu;) {
2076
+ for (; this.receiveBufferLength >= Su;) {
2073
2077
  let t = e.getUint32(this.receiveBufferOffset, !0);
2074
- if (t < xu) {
2078
+ if (t < Su) {
2075
2079
  j.error(`Invalid message length: ${t}`), this.callbacks.onError(/* @__PURE__ */ Error(`Invalid protocol message length: ${t}`)), this.receiveBufferOffset = 0, this.receiveBufferLength = 0;
2076
2080
  return;
2077
2081
  }
@@ -2118,7 +2122,7 @@ var wu = class {
2118
2122
  this.transport = null;
2119
2123
  }
2120
2124
  }
2121
- }, Tu = S("Channel"), Eu = class {
2125
+ }, Eu = S("Channel"), Du = class {
2122
2126
  state = "disconnected";
2123
2127
  transport = null;
2124
2128
  config;
@@ -2158,7 +2162,7 @@ var wu = class {
2158
2162
  }
2159
2163
  send(e) {
2160
2164
  if (!this.transport?.isConnected) {
2161
- Tu.warn("Cannot send: channel not connected");
2165
+ Eu.warn("Cannot send: channel not connected");
2162
2166
  return;
2163
2167
  }
2164
2168
  this.transport.send(e);
@@ -2177,12 +2181,12 @@ var wu = class {
2177
2181
  switch (e.Type) {
2178
2182
  case b.WebSocket:
2179
2183
  case b.WebSocketProxy:
2180
- this.transport = new yu(t);
2184
+ this.transport = new bu(t);
2181
2185
  break;
2182
2186
  case b.WebTransport:
2183
2187
  case b.WebTransportProxy:
2184
- if (!Cu()) throw Error("WebTransport is not supported in this browser");
2185
- this.transport = new wu(t);
2188
+ if (!wu()) throw Error("WebTransport is not supported in this browser");
2189
+ this.transport = new Tu(t);
2186
2190
  break;
2187
2191
  default: throw Error(`Unsupported entrypoint type: ${b[e.Type]}`);
2188
2192
  }
@@ -2192,12 +2196,12 @@ var wu = class {
2192
2196
  try {
2193
2197
  let t = v(e);
2194
2198
  if (c(t) === C.CORE_ON_SERVER_STOPPING) {
2195
- Tu.debug("Received server stopping message"), this.setState("stopped"), this.transport?.close();
2199
+ Eu.debug("Received server stopping message"), this.setState("stopped"), this.transport?.close();
2196
2200
  return;
2197
2201
  }
2198
2202
  this.config.onProtocolMessage?.(t);
2199
2203
  } catch (e) {
2200
- Tu.error("Failed to handle protocol message:", e), this.config.onError?.(e instanceof Error ? e : Error(String(e)));
2204
+ Eu.error("Failed to handle protocol message:", e), this.config.onError?.(e instanceof Error ? e : Error(String(e)));
2201
2205
  }
2202
2206
  }
2203
2207
  handleClose(e, t) {
@@ -2209,7 +2213,7 @@ var wu = class {
2209
2213
  setState(e) {
2210
2214
  this.state !== e && (this.state = e, this.config.onStateChange?.(e));
2211
2215
  }
2212
- }, M = S("ChannelManager"), Du = 5e3, Ou = class {
2216
+ }, M = S("ChannelManager"), Ou = 5e3, ku = class {
2213
2217
  channels = /* @__PURE__ */ new Map();
2214
2218
  activeType = null;
2215
2219
  state = "idle";
@@ -2303,7 +2307,7 @@ var wu = class {
2303
2307
  }
2304
2308
  }
2305
2309
  async connectChannel(e) {
2306
- let t = new Eu({
2310
+ let t = new Du({
2307
2311
  entrypoint: e,
2308
2312
  sessionId: this.config.sessionId,
2309
2313
  keepaliveTimeoutMs: this.config.keepaliveTimeoutMs,
@@ -2376,12 +2380,12 @@ var wu = class {
2376
2380
  startStabilityTimer() {
2377
2381
  this.clearStabilityTimer(), this.stabilityTimer = setTimeout(() => {
2378
2382
  this.stabilityTimer = null, this.state === "connected" && (this.reconnectAttempts = 0);
2379
- }, Du);
2383
+ }, Ou);
2380
2384
  }
2381
2385
  clearStabilityTimer() {
2382
2386
  this.stabilityTimer &&= (clearTimeout(this.stabilityTimer), null);
2383
2387
  }
2384
- }, ku = "opus", Au = 48e3, ju = 2, Mu = 64e3, Nu = 150, Pu = "VP8", Fu = 5e6, Iu = 30, Lu = .05, Ru = "max-bundle", zu = "require", Bu = 5e3, Vu = 8e3, Hu = 16, Uu = 16, Wu = "ikon-data", Gu = !1, Ku = 0, N = S("WebRTCConnection"), qu = class {
2388
+ }, Au = "opus", ju = 48e3, Mu = 2, Nu = 64e3, Pu = 150, Fu = "VP8", Iu = 5e6, Lu = 30, Ru = .05, zu = "max-bundle", Bu = "require", Vu = 5e3, Hu = 8e3, Uu = 16, Wu = 16, Gu = "ikon-data", Ku = !1, qu = 0, N = S("WebRTCConnection"), Ju = class {
2385
2389
  pc = null;
2386
2390
  dataChannel = null;
2387
2391
  _state = "new";
@@ -2406,11 +2410,11 @@ var wu = class {
2406
2410
  if (this.pc = new RTCPeerConnection({
2407
2411
  iceServers: this.config.iceServers ?? [],
2408
2412
  iceTransportPolicy: this.config.iceTransportPolicy,
2409
- bundlePolicy: Ru,
2410
- rtcpMuxPolicy: zu
2413
+ bundlePolicy: zu,
2414
+ rtcpMuxPolicy: Bu
2411
2415
  }), this.setupEventHandlers(), this.config.useAudioTrack) for (let e = 0; e < 16; e++) this.pc.addTransceiver("audio", { direction: "sendrecv" });
2412
2416
  if (this.config.useVideoTrack) for (let e = 0; e < 16; e++) this.pc.addTransceiver("video", { direction: "sendrecv" });
2413
- this.config.useDataChannel && (this.dataChannel = this.pc.createDataChannel(Wu, {
2417
+ this.config.useDataChannel && (this.dataChannel = this.pc.createDataChannel(Gu, {
2414
2418
  ordered: !1,
2415
2419
  maxRetransmits: 0
2416
2420
  }), this.setupDataChannelHandlers(this.dataChannel));
@@ -2500,7 +2504,7 @@ var wu = class {
2500
2504
  this.config.onAudioTrack?.(r, t, n);
2501
2505
  } else if (t.kind === "video") {
2502
2506
  try {
2503
- e.receiver.playoutDelayHint = Lu;
2507
+ e.receiver.playoutDelayHint = Ru;
2504
2508
  } catch (e) {
2505
2509
  N.warn("Failed to set playoutDelayHint:", e);
2506
2510
  }
@@ -2525,7 +2529,7 @@ var wu = class {
2525
2529
  setState(e) {
2526
2530
  this._state !== e && (this._state = e, this.config.onStateChange?.(e));
2527
2531
  }
2528
- }, P = S("WebRTCSignaling"), Ju = class {
2532
+ }, P = S("WebRTCSignaling"), Yu = class {
2529
2533
  config;
2530
2534
  connection = null;
2531
2535
  sendMessage = null;
@@ -2552,7 +2556,12 @@ var wu = class {
2552
2556
  }
2553
2557
  P.debug(`Starting WebRTC connection (audio=${this.config.useAudioTrack}, video=${this.config.useVideoTrack}, dataChannel=${this.config.useDataChannel})`), this.isConnecting = !0, this.audioTrackCount = 0, this.videoTrackCount = 0, this.sendMessage = e;
2554
2558
  try {
2555
- let e = await this.requestIceServers(), t = {
2559
+ let e = await this.requestIceServers();
2560
+ if (e.length === 0 && this.config.shouldAttemptWithoutIceServers?.() === !1) {
2561
+ P.debug("No ICE servers and no remembered direct success — abandoning WebRTC so media starts on the protocol channel"), this.isConnecting = !1, this.config.onStateChange?.("failed");
2562
+ return;
2563
+ }
2564
+ let t = {
2556
2565
  useAudioTrack: this.config.useAudioTrack,
2557
2566
  useVideoTrack: this.config.useVideoTrack,
2558
2567
  useDataChannel: this.config.useDataChannel,
@@ -2572,7 +2581,7 @@ var wu = class {
2572
2581
  this.videoTrackCount++, this.config.onVideoTrack?.(e, t, n);
2573
2582
  }
2574
2583
  };
2575
- this.connection = new qu(t), await this.connection.initialize();
2584
+ this.connection = new Ju(t), await this.connection.initialize();
2576
2585
  let n = await this.connection.createOffer();
2577
2586
  this.sendOffer(n);
2578
2587
  } catch (e) {
@@ -2777,7 +2786,7 @@ var wu = class {
2777
2786
  }), n, r = new Promise((t) => {
2778
2787
  n = setTimeout(() => {
2779
2788
  P.warn("Timed out waiting for ICE servers from server, proceeding without TURN"), t(e);
2780
- }, Bu);
2789
+ }, Vu);
2781
2790
  }), i = Dc();
2782
2791
  this.sendMessage(kc(i, this.config.sessionId));
2783
2792
  let a = await Promise.race([t, r]);
@@ -2847,60 +2856,120 @@ var wu = class {
2847
2856
  P.error("Failed to handle WebRTC track map:", e);
2848
2857
  }
2849
2858
  }
2850
- }, Yu = 3e4, Xu = 3e5, Zu = 1e4, Qu = "ikon-login-pending-call", $u = /* @__PURE__ */ new Set(), ed = {
2859
+ }, Xu = S("WebRtcReachability"), Zu = "ikon-webrtc-reachability", Qu = /* @__PURE__ */ new Set([
2860
+ "direct",
2861
+ "relay",
2862
+ "failed"
2863
+ ]), $u = class {
2864
+ _remembered = null;
2865
+ constructor() {
2866
+ try {
2867
+ let e = localStorage.getItem(Zu);
2868
+ e !== null && Qu.has(e) && (this._remembered = e, Xu.debug(`Loaded remembered WebRTC reachability: ${e}`));
2869
+ } catch {}
2870
+ }
2871
+ get remembered() {
2872
+ return this._remembered;
2873
+ }
2874
+ get iceTransportPolicy() {
2875
+ return this._remembered === "relay" ? "relay" : void 0;
2876
+ }
2877
+ get shouldStartOnProtocolMedia() {
2878
+ return this._remembered === "failed";
2879
+ }
2880
+ get shouldAttemptWithoutIceServers() {
2881
+ return this._remembered === "direct";
2882
+ }
2883
+ recordConnected(e) {
2884
+ this.store(e ? "relay" : "direct");
2885
+ }
2886
+ recordFailed() {
2887
+ this.store("failed");
2888
+ }
2889
+ store(e) {
2890
+ if (this._remembered !== e) {
2891
+ this._remembered = e;
2892
+ try {
2893
+ localStorage.setItem(Zu, e);
2894
+ } catch {}
2895
+ Xu.debug(`Remembered WebRTC reachability: ${e}`);
2896
+ }
2897
+ }
2898
+ };
2899
+ async function ed(e) {
2900
+ let t;
2901
+ try {
2902
+ t = await e.getStats();
2903
+ } catch {
2904
+ return null;
2905
+ }
2906
+ let n, r = [];
2907
+ t.forEach((e) => {
2908
+ let t = e;
2909
+ if (t.type === "transport" && t.selectedCandidatePairId && (n = t.selectedCandidatePairId), t.type === "candidate-pair") {
2910
+ let e = t;
2911
+ e.state === "succeeded" && r.push(e);
2912
+ }
2913
+ });
2914
+ let i = (n === void 0 ? void 0 : t.get(n)) ?? r.find((e) => e.nominated) ?? r[0];
2915
+ if (i?.localCandidateId === void 0) return null;
2916
+ let a = t.get(i.localCandidateId);
2917
+ return a?.candidateType === void 0 ? null : a.candidateType === "relay";
2918
+ }
2919
+ var td = 3e4, nd = 3e5, rd = 1e4, id = "ikon-login-pending-call", ad = /* @__PURE__ */ new Set(), od = {
2851
2920
  required: !1,
2852
2921
  reason: null
2853
2922
  };
2854
- function td() {
2855
- for (let e of $u) e();
2923
+ function sd() {
2924
+ for (let e of ad) e();
2856
2925
  }
2857
- function nd() {
2858
- return ed;
2926
+ function cd() {
2927
+ return od;
2859
2928
  }
2860
- function rd(e) {
2861
- ed = {
2929
+ function ld(e) {
2930
+ od = {
2862
2931
  required: !0,
2863
2932
  reason: e
2864
- }, td();
2933
+ }, sd();
2865
2934
  }
2866
- function id() {
2867
- ed = {
2935
+ function ud() {
2936
+ od = {
2868
2937
  required: !1,
2869
2938
  reason: null
2870
- }, td();
2939
+ }, sd();
2871
2940
  }
2872
- function ad(e) {
2873
- return $u.add(e), () => $u.delete(e);
2941
+ function dd(e) {
2942
+ return ad.add(e), () => ad.delete(e);
2874
2943
  }
2875
- function od(e) {
2944
+ function fd(e) {
2876
2945
  try {
2877
- sessionStorage.setItem(Qu, JSON.stringify(e));
2946
+ sessionStorage.setItem(id, JSON.stringify(e));
2878
2947
  } catch {}
2879
2948
  }
2880
- function sd() {
2949
+ function pd() {
2881
2950
  try {
2882
- let e = sessionStorage.getItem(Qu);
2883
- return sessionStorage.removeItem(Qu), e ? JSON.parse(e) : null;
2951
+ let e = sessionStorage.getItem(id);
2952
+ return sessionStorage.removeItem(id), e ? JSON.parse(e) : null;
2884
2953
  } catch {
2885
2954
  return null;
2886
2955
  }
2887
2956
  }
2888
2957
  //#endregion
2889
2958
  //#region src/utils/abort-signal.ts
2890
- function cd() {
2959
+ function md() {
2891
2960
  return globalThis.AbortSignal;
2892
2961
  }
2893
- function ld() {
2962
+ function hd() {
2894
2963
  return typeof DOMException == "function" ? new DOMException("The operation timed out.", "TimeoutError") : /* @__PURE__ */ Error("The operation timed out.");
2895
2964
  }
2896
2965
  function F(e) {
2897
- let t = cd();
2966
+ let t = md();
2898
2967
  if (t && typeof t.timeout == "function") return t.timeout(e);
2899
2968
  let n = new AbortController();
2900
- return setTimeout(() => n.abort(ld()), e), n.signal;
2969
+ return setTimeout(() => n.abort(hd()), e), n.signal;
2901
2970
  }
2902
- function ud(e) {
2903
- let t = cd();
2971
+ function gd(e) {
2972
+ let t = md();
2904
2973
  if (t && typeof t.any == "function") return t.any(e);
2905
2974
  let n = new AbortController(), r = (e) => {
2906
2975
  n.abort(e.reason);
@@ -2916,53 +2985,54 @@ function ud(e) {
2916
2985
  }
2917
2986
  //#endregion
2918
2987
  //#region src/connection/urls.ts
2919
- var dd = "https://api.prod.ikon.live", fd = "https://api.dev.ikon.live", pd = "https://auth.ikonai.com", md = "https://auth.dev.ikonai.com", hd = "https://auth.ikonai.com", gd = [
2988
+ var _d = "https://api.prod.ikon.live", vd = "https://api.dev.ikon.live", yd = "https://auth.ikonai.com", bd = "https://auth.dev.ikonai.com", xd = "https://auth.ikonai.com", Sd = [
2920
2989
  ".ikonai.app",
2921
2990
  ".ikonai.com",
2922
2991
  ".ikonai.run",
2923
2992
  ".ikon.live"
2924
2993
  ];
2925
- function _d(e) {
2926
- return gd.some((t) => e.endsWith(t)) ? e.includes(".dev.") ? "development" : "production" : null;
2994
+ function Cd(e) {
2995
+ return Sd.some((t) => e.endsWith(t)) ? e.includes(".dev.") ? "development" : "production" : null;
2927
2996
  }
2928
- var vd = null, yd = null;
2929
- async function bd() {
2930
- return vd || (typeof window > "u" ? null : yd || (yd = (async () => {
2997
+ var wd = null, Td = null;
2998
+ async function Ed() {
2999
+ return wd || (typeof window > "u" ? null : Td || (Td = (async () => {
2931
3000
  try {
2932
3001
  let e = await fetch(`${window.location.origin}/ikon/api/env`, { signal: F(5e3) });
2933
3002
  if (!e.ok) return null;
2934
3003
  let t = await e.json();
2935
- return t.env === "development" || t.env === "production" ? (vd = t.env, t.env) : null;
3004
+ return t.env === "development" || t.env === "production" ? (wd = t.env, t.env) : null;
2936
3005
  } catch {
2937
3006
  return null;
2938
3007
  } finally {
2939
- yd = null;
3008
+ Td = null;
2940
3009
  }
2941
- })(), yd));
3010
+ })(), Td));
2942
3011
  }
2943
- function xd() {
2944
- return typeof window > "u" || hu() === !1 || !I() ? null : `${window.location.origin}/ikon/api`;
3012
+ function Dd() {
3013
+ return typeof window > "u" || gu() === !1 || !I() ? null : `${window.location.origin}/ikon/api`;
2945
3014
  }
2946
- function Sd() {
3015
+ function Od() {
2947
3016
  return typeof window > "u" || !I() ? null : `${window.location.origin}/ikon/auth`;
2948
3017
  }
2949
- var Cd = !1;
2950
- function wd() {
2951
- return mu() || Cd;
3018
+ function kd(e) {
3019
+ return e.startsWith("/") ? typeof window > "u" ? Md() === "development" ? vd : _d : `${window.location.origin}${e}` : e;
2952
3020
  }
2953
- function Td(e) {
2954
- return xd() || (e === "development" ? fd : dd);
3021
+ function Ad(e) {
3022
+ return Dd() || (e === "development" ? vd : _d);
2955
3023
  }
2956
- function Ed(e) {
2957
- return e || {
3024
+ function jd(e) {
3025
+ if (e) return kd(e);
3026
+ let t = {
2958
3027
  BASE_URL: "./",
2959
3028
  DEV: !1,
2960
3029
  MODE: "production",
2961
3030
  PROD: !0,
2962
3031
  SSR: !1
2963
- }.VITE_IKON_BACKEND_URL || xd() || (typeof window > "u" ? dd : I() ? (_d(window.location.hostname) ?? vd ?? "production") === "development" ? fd : dd : fd);
3032
+ }.VITE_IKON_BACKEND_URL;
3033
+ return t ? kd(t) : Dd() || (typeof window > "u" ? _d : I() ? (Cd(window.location.hostname) ?? wd ?? "production") === "development" ? vd : _d : vd);
2964
3034
  }
2965
- function Dd() {
3035
+ function Md() {
2966
3036
  let e = {
2967
3037
  BASE_URL: "./",
2968
3038
  DEV: !1,
@@ -2978,11 +3048,11 @@ function Dd() {
2978
3048
  PROD: !0,
2979
3049
  SSR: !1
2980
3050
  }.VITE_IKON_BACKEND_URL;
2981
- return t ? t.includes(".dev.") ? "development" : "production" : typeof window > "u" ? "production" : I() ? _d(window.location.hostname) ?? vd ?? "production" : "development";
3051
+ return t && !t.startsWith("/") ? t.includes(".dev.") ? "development" : "production" : typeof window > "u" ? "production" : I() ? Cd(window.location.hostname) ?? wd ?? "production" : "development";
2982
3052
  }
2983
- async function Od(e) {
2984
- if (wd()) {
2985
- let e = Sd();
3053
+ async function Nd(e) {
3054
+ if (hu()) {
3055
+ let e = Od();
2986
3056
  if (e) return e;
2987
3057
  }
2988
3058
  if (e) return e;
@@ -2994,35 +3064,42 @@ async function Od(e) {
2994
3064
  SSR: !1
2995
3065
  }.VITE_IKON_AUTH_URL;
2996
3066
  if (t) return t;
2997
- if (typeof window > "u") return pd;
2998
- if (!I()) return md;
2999
- let n = _d(window.location.hostname);
3000
- return n ? n === "development" ? md : pd : await bd() === "development" ? md : pd;
3067
+ {
3068
+ let e = Od();
3069
+ if (e) return e;
3070
+ }
3071
+ return Pd();
3001
3072
  }
3002
- function kd() {
3073
+ async function Pd() {
3074
+ if (typeof window > "u") return yd;
3075
+ if (!I()) return bd;
3076
+ let e = Cd(window.location.hostname);
3077
+ return e ? e === "development" ? bd : yd : await Ed() === "development" ? bd : yd;
3078
+ }
3079
+ function Fd() {
3003
3080
  if (typeof window > "u") return {};
3004
3081
  let e = new URLSearchParams(window.location.search), t = {};
3005
3082
  for (let [n, r] of e.entries()) t[n] = r;
3006
3083
  return t;
3007
3084
  }
3008
- var Ad = [
3085
+ var Id = [
3009
3086
  "ikon_token",
3010
3087
  "ikon_provider",
3011
3088
  "error"
3012
- ], jd = [eu, eu.replace(/-/g, "_")];
3013
- function Md() {
3089
+ ], Ld = [eu, eu.replace(/-/g, "_")];
3090
+ function Rd() {
3014
3091
  let e = window.location.pathname.match(/^\/(s|c)\/([^/]+)(.*)$/);
3015
3092
  if (!e) return;
3016
3093
  let t = new URL(window.location.href);
3017
3094
  t.pathname = e[3] || "/", t.searchParams.set(eu, decodeURIComponent(e[2])), window.history.replaceState(null, "", t.toString());
3018
3095
  }
3019
- function Nd() {
3096
+ function zd() {
3020
3097
  if (typeof window > "u") return { parameters: {} };
3021
- Md();
3022
- let e = kd(), t = {};
3023
- for (let [n, r] of Object.entries(e)) !Ad.includes(n) && !jd.includes(n) && (t[n] = r);
3098
+ Rd();
3099
+ let e = Fd(), t = {};
3100
+ for (let [n, r] of Object.entries(e)) !Id.includes(n) && !Ld.includes(n) && (t[n] = r);
3024
3101
  return {
3025
- sessionIdentityHash: _u() ?? void 0,
3102
+ sessionIdentityHash: vu() ?? void 0,
3026
3103
  parameters: t
3027
3104
  };
3028
3105
  }
@@ -3036,29 +3113,41 @@ function I() {
3036
3113
  }
3037
3114
  return !0;
3038
3115
  }
3039
- function Pd() {
3040
- return typeof window > "u" ? "" : window.location.pathname || "/";
3116
+ function Bd() {
3117
+ if (typeof window > "u") return "";
3118
+ let e = window.location.pathname || "/", t = new URLSearchParams(window.location.search);
3119
+ for (let e of [...t.keys()]) (e.startsWith("ikon-") || e.startsWith("ikon_")) && t.delete(e);
3120
+ let n = t.toString();
3121
+ return n.length > 0 ? `${e}?${n}` : e;
3041
3122
  }
3042
3123
  //#endregion
3043
3124
  //#region src/utils/user-gesture.ts
3044
- function Fd(e) {
3125
+ function Vd(e) {
3045
3126
  if (!e || typeof e != "object") return !1;
3046
3127
  let t = e, n = typeof t.name == "string" ? t.name : "", r = typeof t.message == "string" ? t.message : "";
3047
3128
  return !!(n === "NotAllowedError" || n === "SecurityError" || r.toLowerCase().includes("permission") || r.toLowerCase().includes("user gesture"));
3048
3129
  }
3049
3130
  //#endregion
3131
+ //#region src/utils/app-routes.ts
3132
+ var Hd = ["/ikon", "/api"];
3133
+ function Ud(e) {
3134
+ if (!e) return !1;
3135
+ let t = e.split(/[?#]/)[0], n = t.startsWith("/") ? t : "/" + t;
3136
+ return Hd.some((e) => n === e || n.startsWith(e + "/"));
3137
+ }
3138
+ //#endregion
3050
3139
  //#region src/functions/browser-functions.ts
3051
- var Id = "ikon-theme", Ld = "ikon-theme-user", Rd = "ikon-theme-change";
3052
- function zd(e) {
3140
+ var Wd = "ikon-theme", Gd = "ikon-theme-user", Kd = "ikon-theme-change";
3141
+ function qd(e) {
3053
3142
  typeof document < "u" && document.documentElement && document.documentElement.setAttribute("data-theme", e);
3054
3143
  }
3055
- function Bd() {
3144
+ function Jd() {
3056
3145
  return typeof window < "u" && window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
3057
3146
  }
3058
- function Vd() {
3059
- return typeof window > "u" || !window.localStorage ? "light" : window.localStorage.getItem(Ld) || window.localStorage.getItem(Id) || Bd();
3147
+ function Yd() {
3148
+ return typeof window > "u" || !window.localStorage ? "light" : window.localStorage.getItem(Gd) || window.localStorage.getItem(Wd) || Jd();
3060
3149
  }
3061
- function Hd() {
3150
+ function Xd() {
3062
3151
  return typeof window > "u" ? {
3063
3152
  width: 0,
3064
3153
  height: 0
@@ -3067,17 +3156,17 @@ function Hd() {
3067
3156
  height: window.innerHeight
3068
3157
  };
3069
3158
  }
3070
- function Ud() {
3159
+ function Zd() {
3071
3160
  if (typeof window > "u" || !window.localStorage) return "light";
3072
- let e = window.localStorage.getItem(Ld), t = window.localStorage.getItem(Id);
3161
+ let e = window.localStorage.getItem(Gd), t = window.localStorage.getItem(Wd);
3073
3162
  if (e || t) {
3074
3163
  let n = e ?? t;
3075
- return zd(n), n;
3164
+ return qd(n), n;
3076
3165
  }
3077
- let n = Bd();
3078
- return window.localStorage.setItem(Id, n), zd(n), n;
3166
+ let n = Jd();
3167
+ return window.localStorage.setItem(Wd, n), qd(n), n;
3079
3168
  }
3080
- var Wd = {
3169
+ var Qd = {
3081
3170
  name: "ikon.client.getTheme",
3082
3171
  description: "Get the currently selected client theme",
3083
3172
  returnType: {
@@ -3085,12 +3174,12 @@ var Wd = {
3085
3174
  nullable: !0
3086
3175
  }
3087
3176
  };
3088
- function Gd() {
3177
+ function $d() {
3089
3178
  if (typeof window > "u" || !window.localStorage) return null;
3090
- let e = window.localStorage.getItem(Ld), t = window.localStorage.getItem(Id);
3179
+ let e = window.localStorage.getItem(Gd), t = window.localStorage.getItem(Wd);
3091
3180
  return e ?? t ?? null;
3092
3181
  }
3093
- var Kd = {
3182
+ var ef = {
3094
3183
  name: "ikon.client.setTheme",
3095
3184
  description: "Update the client UI theme",
3096
3185
  returnType: { kind: "boolean" },
@@ -3107,38 +3196,38 @@ var Kd = {
3107
3196
  description: "Whether to persist as user preference"
3108
3197
  }]
3109
3198
  };
3110
- function qd(e, t) {
3199
+ function tf(e, t) {
3111
3200
  if (typeof window > "u" || !window.localStorage || typeof e != "string") return !1;
3112
3201
  let n = e.trim().toLowerCase();
3113
3202
  if (!n) return !1;
3114
3203
  let r = t === void 0 || !!t, i = window.localStorage;
3115
- r ? i.setItem(Ld, n) : i.removeItem(Ld), i.setItem(Id, n);
3204
+ r ? i.setItem(Gd, n) : i.removeItem(Gd), i.setItem(Wd, n);
3116
3205
  try {
3117
- window.dispatchEvent(new CustomEvent(Rd, { detail: { mode: n } }));
3206
+ window.dispatchEvent(new CustomEvent(Kd, { detail: { mode: n } }));
3118
3207
  } catch {}
3119
- return zd(n), !0;
3208
+ return qd(n), !0;
3120
3209
  }
3121
- var Jd = {
3210
+ var nf = {
3122
3211
  name: "ikon.client.getLanguage",
3123
3212
  description: "Get the browser language preference",
3124
3213
  returnType: { kind: "string" }
3125
3214
  };
3126
- function Yd() {
3215
+ function rf() {
3127
3216
  return typeof navigator > "u" ? "en-US" : navigator.language || "en-US";
3128
3217
  }
3129
- var Xd = {
3218
+ var af = {
3130
3219
  name: "ikon.client.getTimezone",
3131
3220
  description: "Get the browser timezone (IANA format)",
3132
3221
  returnType: { kind: "string" }
3133
3222
  };
3134
- function Zd() {
3223
+ function of() {
3135
3224
  try {
3136
3225
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
3137
3226
  } catch {
3138
3227
  return "UTC";
3139
3228
  }
3140
3229
  }
3141
- function Qd() {
3230
+ function sf() {
3142
3231
  if (typeof Intl > "u") return "";
3143
3232
  try {
3144
3233
  return Intl.DateTimeFormat().resolvedOptions().timeZone;
@@ -3146,15 +3235,15 @@ function Qd() {
3146
3235
  return "";
3147
3236
  }
3148
3237
  }
3149
- function $d() {
3238
+ function cf() {
3150
3239
  return typeof navigator > "u" ? !1 : navigator.maxTouchPoints > 0;
3151
3240
  }
3152
- function ef() {
3241
+ function lf() {
3153
3242
  if (typeof navigator > "u" || typeof window > "u") return ne.Unknown;
3154
3243
  let e = navigator.maxTouchPoints > 0, t = window.innerWidth <= 1024;
3155
3244
  return e && t ? ne.MobileWeb : ne.DesktopWeb;
3156
3245
  }
3157
- var tf = {
3246
+ var uf = {
3158
3247
  name: "ikon.client.getUrl",
3159
3248
  description: "Get the current browser URL path and query string",
3160
3249
  returnType: {
@@ -3162,10 +3251,10 @@ var tf = {
3162
3251
  nullable: !0
3163
3252
  }
3164
3253
  };
3165
- function nf() {
3254
+ function df() {
3166
3255
  return typeof window > "u" ? null : window.location.pathname + window.location.search;
3167
3256
  }
3168
- var rf = {
3257
+ var ff = {
3169
3258
  name: "ikon.client.setUrl",
3170
3259
  description: "Update the browser URL without triggering a page reload",
3171
3260
  returnType: { kind: "boolean" },
@@ -3193,12 +3282,10 @@ var rf = {
3193
3282
  }
3194
3283
  ]
3195
3284
  };
3196
- function af(e, t, n) {
3285
+ function pf(e, t, n) {
3197
3286
  if (typeof window > "u" || !window.history || typeof e != "string") return !1;
3198
3287
  let r = e.trim();
3199
- if (!r || /^[a-z][a-z0-9+.-]*:/i.test(r) || r.startsWith("//")) return !1;
3200
- let i = r.split(/[?#]/)[0], a = i.startsWith("/") ? i : "/" + i;
3201
- if (a === "/ikon" || a.startsWith("/ikon/") || a === "/api" || a.startsWith("/api/")) return !1;
3288
+ if (!r || /^[a-z][a-z0-9+.-]*:/i.test(r) || r.startsWith("//") || Ud(r)) return !1;
3202
3289
  try {
3203
3290
  let e = !!t, i = n && !r.includes("?") ? r + window.location.search : r;
3204
3291
  return e ? window.history.replaceState(null, "", i) : window.history.pushState(null, "", i), !0;
@@ -3206,7 +3293,7 @@ function af(e, t, n) {
3206
3293
  return !1;
3207
3294
  }
3208
3295
  }
3209
- var of = {
3296
+ var mf = {
3210
3297
  name: "ikon.client.openExternalUrl",
3211
3298
  description: "Open an external URL in a new browser tab",
3212
3299
  returnType: { kind: "boolean" },
@@ -3216,7 +3303,7 @@ var of = {
3216
3303
  description: "The URL to open. Must be absolute (e.g., starts with https://)."
3217
3304
  }]
3218
3305
  };
3219
- function sf(e) {
3306
+ function hf(e) {
3220
3307
  if (typeof window > "u" || typeof window.open != "function" || typeof e != "string") return !1;
3221
3308
  let t = e.trim();
3222
3309
  if (!t || /^javascript:/i.test(t)) return !1;
@@ -3226,7 +3313,7 @@ function sf(e) {
3226
3313
  return !1;
3227
3314
  }
3228
3315
  }
3229
- var cf = {
3316
+ var gf = {
3230
3317
  name: "ikon.client.vibrate",
3231
3318
  description: "Trigger haptic feedback on supported devices",
3232
3319
  returnType: { kind: "boolean" },
@@ -3236,7 +3323,7 @@ var cf = {
3236
3323
  description: "Duration in ms, or comma-separated pattern (e.g., \"200\" or \"100,50,100\")"
3237
3324
  }]
3238
3325
  };
3239
- function lf(e) {
3326
+ function _f(e) {
3240
3327
  if (typeof navigator > "u" || !navigator.vibrate || typeof e != "string") return !1;
3241
3328
  try {
3242
3329
  let t = e.split(",").map((e) => parseInt(e.trim(), 10));
@@ -3245,16 +3332,16 @@ function lf(e) {
3245
3332
  return !1;
3246
3333
  }
3247
3334
  }
3248
- var L = null, uf = !1, df = !1;
3249
- async function ff() {
3335
+ var L = null, vf = !1, yf = !1;
3336
+ async function bf() {
3250
3337
  if (!(typeof navigator > "u" || !("wakeLock" in navigator))) try {
3251
3338
  L = await navigator.wakeLock.request("screen");
3252
3339
  } catch {}
3253
3340
  }
3254
- function pf() {
3255
- document.visibilityState === "visible" && uf && (!L || L.released) && ff();
3341
+ function xf() {
3342
+ document.visibilityState === "visible" && vf && (!L || L.released) && bf();
3256
3343
  }
3257
- var mf = {
3344
+ var Sf = {
3258
3345
  name: "ikon.client.keepScreenAwake",
3259
3346
  description: "Prevent or allow the screen to sleep",
3260
3347
  returnType: { kind: "boolean" },
@@ -3264,15 +3351,15 @@ var mf = {
3264
3351
  description: "Whether to keep the screen awake"
3265
3352
  }]
3266
3353
  };
3267
- async function hf(e) {
3354
+ async function Cf(e) {
3268
3355
  if (typeof navigator > "u" || !("wakeLock" in navigator)) return !1;
3269
3356
  try {
3270
- return e ? (uf = !0, (!L || L.released) && (L = await navigator.wakeLock.request("screen")), df ||= (document.addEventListener("visibilitychange", pf), !0)) : (uf = !1, df &&= (document.removeEventListener("visibilitychange", pf), !1), L &&= (await L.release(), null)), !0;
3357
+ return e ? (vf = !0, (!L || L.released) && (L = await navigator.wakeLock.request("screen")), yf ||= (document.addEventListener("visibilitychange", xf), !0)) : (vf = !1, yf &&= (document.removeEventListener("visibilitychange", xf), !1), L &&= (await L.release(), null)), !0;
3271
3358
  } catch {
3272
3359
  return !1;
3273
3360
  }
3274
3361
  }
3275
- var gf = {
3362
+ var wf = {
3276
3363
  name: "ikon.client.getVisibility",
3277
3364
  description: "Get the current page visibility state",
3278
3365
  returnType: {
@@ -3280,10 +3367,10 @@ var gf = {
3280
3367
  nullable: !0
3281
3368
  }
3282
3369
  };
3283
- function _f() {
3370
+ function Tf() {
3284
3371
  return typeof document > "u" ? null : document.visibilityState || null;
3285
3372
  }
3286
- var vf = {
3373
+ var Ef = {
3287
3374
  name: "ikon.client.scrollTo",
3288
3375
  description: "Scroll the page to a specific position",
3289
3376
  returnType: { kind: "boolean" },
@@ -3308,7 +3395,7 @@ var vf = {
3308
3395
  }
3309
3396
  ]
3310
3397
  };
3311
- function yf(e, t, n) {
3398
+ function Df(e, t, n) {
3312
3399
  if (typeof window > "u" || typeof e != "number" || typeof t != "number") return !1;
3313
3400
  try {
3314
3401
  return window.scrollTo({
@@ -3320,7 +3407,7 @@ function yf(e, t, n) {
3320
3407
  return !1;
3321
3408
  }
3322
3409
  }
3323
- var bf = {
3410
+ var Of = {
3324
3411
  name: "ikon.client.getBatteryLevel",
3325
3412
  description: "Get the current battery level (0-100)",
3326
3413
  returnType: {
@@ -3328,7 +3415,7 @@ var bf = {
3328
3415
  nullable: !0
3329
3416
  }
3330
3417
  };
3331
- async function xf() {
3418
+ async function kf() {
3332
3419
  if (typeof navigator > "u" || !("getBattery" in navigator)) return null;
3333
3420
  try {
3334
3421
  let e = await navigator.getBattery();
@@ -3337,7 +3424,7 @@ async function xf() {
3337
3424
  return null;
3338
3425
  }
3339
3426
  }
3340
- var Sf = {
3427
+ var Af = {
3341
3428
  name: "ikon.client.getNetworkType",
3342
3429
  description: "Get the current network connection type",
3343
3430
  returnType: {
@@ -3345,17 +3432,17 @@ var Sf = {
3345
3432
  nullable: !0
3346
3433
  }
3347
3434
  };
3348
- function Cf() {
3435
+ function jf() {
3349
3436
  if (typeof navigator > "u") return null;
3350
3437
  let e = navigator.connection;
3351
3438
  return e && (e.effectiveType || e.type) || null;
3352
3439
  }
3353
- var wf = {
3440
+ var Mf = {
3354
3441
  name: "ikon.client.requestFullscreen",
3355
3442
  description: "Request the browser to enter fullscreen mode",
3356
3443
  returnType: { kind: "boolean" }
3357
3444
  };
3358
- async function Tf() {
3445
+ async function Nf() {
3359
3446
  if (typeof document > "u" || !document.documentElement) return !1;
3360
3447
  try {
3361
3448
  let e = document.documentElement, t = e.requestFullscreen?.bind(e) ?? e.webkitRequestFullscreen?.bind(e);
@@ -3364,12 +3451,12 @@ async function Tf() {
3364
3451
  return !1;
3365
3452
  }
3366
3453
  }
3367
- var Ef = {
3454
+ var Pf = {
3368
3455
  name: "ikon.client.exitFullscreen",
3369
3456
  description: "Exit browser fullscreen mode",
3370
3457
  returnType: { kind: "boolean" }
3371
3458
  };
3372
- function Df() {
3459
+ function Ff() {
3373
3460
  if (typeof document > "u") return !1;
3374
3461
  try {
3375
3462
  let e = document.exitFullscreen?.bind(document) ?? document.webkitExitFullscreen?.bind(document);
@@ -3378,25 +3465,25 @@ function Df() {
3378
3465
  return !1;
3379
3466
  }
3380
3467
  }
3381
- var Of = {
3468
+ var If = {
3382
3469
  name: "ikon.client.logout",
3383
3470
  description: "Clear the auth session and return to the login screen at the site root",
3384
3471
  returnType: { kind: "boolean" }
3385
- }, kf = ["ikon-auth-", "ikon-live-snapshot"];
3386
- function Af() {
3472
+ }, Lf = ["ikon-auth-", "ikon-live-snapshot"];
3473
+ function Rf() {
3387
3474
  if (typeof window > "u" || !window.localStorage) return !1;
3388
3475
  try {
3389
3476
  let e = [];
3390
3477
  for (let t = 0; t < window.localStorage.length; t++) {
3391
3478
  let n = window.localStorage.key(t);
3392
- n && kf.some((e) => n.startsWith(e)) && e.push(n);
3479
+ n && Lf.some((e) => n.startsWith(e)) && e.push(n);
3393
3480
  }
3394
3481
  return e.forEach((e) => window.localStorage.removeItem(e)), setTimeout(() => window.location.replace(window.location.origin + "/"), 100), !0;
3395
3482
  } catch {
3396
3483
  return !1;
3397
3484
  }
3398
3485
  }
3399
- var jf = {
3486
+ var zf = {
3400
3487
  name: "ikon.client.login",
3401
3488
  description: "Start the sign-in flow for an OAuth provider (e.g. google, microsoft)",
3402
3489
  parameters: [{
@@ -3405,14 +3492,14 @@ var jf = {
3405
3492
  }],
3406
3493
  returnType: { kind: "boolean" }
3407
3494
  };
3408
- async function Mf(e) {
3495
+ async function Bf(e) {
3409
3496
  if (typeof window > "u" || typeof e != "string" || e.length === 0 || e === "guest" || e === "global" || e === "email" || e === "passkey") return !1;
3410
3497
  let t = window.__IKON_AUTH_CONFIG__, n = t?.spaceId;
3411
3498
  if (!n) return !1;
3412
- let r = await Od(t?.authUrl), i = window.location.origin + window.location.pathname + window.location.search;
3499
+ let r = await Nd(t?.authUrl), i = window.location.origin + window.location.pathname + window.location.search;
3413
3500
  return window.location.href = `${r}/oauth/${encodeURIComponent(e)}?space=${encodeURIComponent(n)}&return=${encodeURIComponent(i)}`, !0;
3414
3501
  }
3415
- var Nf = {
3502
+ var Vf = {
3416
3503
  name: "ikon.client.loginShow",
3417
3504
  description: "Show the login UI with an optional reason",
3418
3505
  parameters: [{
@@ -3421,15 +3508,15 @@ var Nf = {
3421
3508
  }],
3422
3509
  returnType: { kind: "boolean" }
3423
3510
  };
3424
- function Pf(e) {
3425
- return typeof window > "u" ? !1 : (rd(typeof e == "string" ? e : null), !0);
3511
+ function Hf(e) {
3512
+ return typeof window > "u" ? !1 : (ld(typeof e == "string" ? e : null), !0);
3426
3513
  }
3427
- var Ff = {
3514
+ var Uf = {
3428
3515
  name: "ikon.client.getLocation",
3429
3516
  description: "Get the current GPS location",
3430
3517
  returnType: { kind: "string" }
3431
3518
  };
3432
- function If() {
3519
+ function Wf() {
3433
3520
  return typeof navigator > "u" || !navigator.geolocation ? Promise.resolve(null) : new Promise((e) => {
3434
3521
  navigator.geolocation.getCurrentPosition((t) => {
3435
3522
  e({
@@ -3443,15 +3530,15 @@ function If() {
3443
3530
  });
3444
3531
  });
3445
3532
  }
3446
- var Lf = [], Rf = !1;
3447
- function zf() {
3533
+ var Gf = [], Kf = !1;
3534
+ function qf() {
3448
3535
  return typeof window < "u" && "Notification" in window;
3449
3536
  }
3450
- function Bf(e, t, n, r) {
3537
+ function Jf(e, t, n, r) {
3451
3538
  let i = {};
3452
3539
  return e?.trim() && (i.body = e.trim()), t?.trim() && (i.icon = t.trim()), n?.trim() && (i.tag = n.trim()), r && (i.data = r), i;
3453
3540
  }
3454
- function Vf(e, t, n, r) {
3541
+ function Yf(e, t, n, r) {
3455
3542
  try {
3456
3543
  let i = new Notification(e, t);
3457
3544
  i.onclick = () => {
@@ -3466,40 +3553,40 @@ function Vf(e, t, n, r) {
3466
3553
  };
3467
3554
  } catch {}
3468
3555
  }
3469
- function Hf() {
3556
+ function Xf() {
3470
3557
  if (Notification.permission !== "granted") {
3471
- Lf = [];
3558
+ Gf = [];
3472
3559
  return;
3473
3560
  }
3474
- let e = Lf;
3475
- Lf = [];
3476
- for (let t of e) Vf(t.title, t.options, t.launchUrl, t.data);
3561
+ let e = Gf;
3562
+ Gf = [];
3563
+ for (let t of e) Yf(t.title, t.options, t.launchUrl, t.data);
3477
3564
  }
3478
- function Uf() {
3479
- if (Rf || typeof window > "u") return;
3480
- Rf = !0;
3565
+ function Zf() {
3566
+ if (Kf || typeof window > "u") return;
3567
+ Kf = !0;
3481
3568
  let e = async () => {
3482
3569
  try {
3483
3570
  if (await Notification.requestPermission() === "granted") {
3484
- Hf();
3571
+ Xf();
3485
3572
  return;
3486
3573
  }
3487
3574
  } catch {}
3488
- Lf = [];
3575
+ Gf = [];
3489
3576
  }, t = () => {
3490
- window.removeEventListener("pointerdown", t), window.removeEventListener("keydown", t), Rf = !1, e();
3577
+ window.removeEventListener("pointerdown", t), window.removeEventListener("keydown", t), Kf = !1, e();
3491
3578
  };
3492
3579
  window.addEventListener("pointerdown", t), window.addEventListener("keydown", t);
3493
3580
  }
3494
- var Wf = {
3581
+ var Qf = {
3495
3582
  name: "ikon.client.getNotificationPermission",
3496
3583
  description: "Get the current notification permission state (granted, denied, default, or unsupported)",
3497
3584
  returnType: { kind: "string" }
3498
3585
  };
3499
- function Gf() {
3500
- return zf() ? Notification.permission : "unsupported";
3586
+ function $f() {
3587
+ return qf() ? Notification.permission : "unsupported";
3501
3588
  }
3502
- var Kf = {
3589
+ var ep = {
3503
3590
  name: "ikon.client.showNotification",
3504
3591
  description: "Show a notification, requesting permission lazily on the first send",
3505
3592
  returnType: { kind: "string" },
@@ -3545,33 +3632,33 @@ var Kf = {
3545
3632
  }
3546
3633
  ]
3547
3634
  };
3548
- async function qf(e, t, n, r, i, a) {
3549
- if (!zf() || typeof e != "string" || !e.trim()) return "unsupported";
3550
- let o = e.trim(), s = Bf(typeof t == "string" ? t : void 0, typeof n == "string" ? n : void 0, typeof r == "string" ? r : void 0, typeof a == "string" ? a : void 0), c = typeof i == "string" && i.trim() ? i.trim() : void 0, l = typeof a == "string" && a ? a : void 0;
3551
- if (Notification.permission === "granted") return Vf(o, s, c, l), "granted";
3635
+ async function tp(e, t, n, r, i, a) {
3636
+ if (!qf() || typeof e != "string" || !e.trim()) return "unsupported";
3637
+ let o = e.trim(), s = Jf(typeof t == "string" ? t : void 0, typeof n == "string" ? n : void 0, typeof r == "string" ? r : void 0, typeof a == "string" ? a : void 0), c = typeof i == "string" && i.trim() ? i.trim() : void 0, l = typeof a == "string" && a ? a : void 0;
3638
+ if (Notification.permission === "granted") return Yf(o, s, c, l), "granted";
3552
3639
  if (Notification.permission === "denied") return "denied";
3553
3640
  try {
3554
3641
  let e = await Notification.requestPermission();
3555
- return e === "granted" && Vf(o, s, c, l), e;
3642
+ return e === "granted" && Yf(o, s, c, l), e;
3556
3643
  } catch (e) {
3557
- return Fd(e) ? (Lf.push({
3644
+ return Vd(e) ? (Gf.push({
3558
3645
  title: o,
3559
3646
  options: s,
3560
3647
  launchUrl: c,
3561
3648
  data: l
3562
- }), Uf(), "default") : "denied";
3649
+ }), Zf(), "default") : "denied";
3563
3650
  }
3564
3651
  }
3565
- var Jf = null;
3566
- function Yf(e) {
3567
- Jf = e ?? null;
3652
+ var np = null;
3653
+ function rp(e) {
3654
+ np = e ?? null;
3568
3655
  }
3569
- function Xf(e) {
3656
+ function ip(e) {
3570
3657
  let t = (e + "=".repeat((4 - e.length % 4) % 4)).replace(/-/g, "+").replace(/_/g, "/"), n = atob(t), r = new Uint8Array(n.length);
3571
3658
  for (let e = 0; e < n.length; e++) r[e] = n.charCodeAt(e);
3572
3659
  return r;
3573
3660
  }
3574
- var Zf = {
3661
+ var ap = {
3575
3662
  name: "ikon.client.getPushSubscription",
3576
3663
  description: "Subscribe to Web Push and return the subscription, for offline push registration",
3577
3664
  returnType: {
@@ -3579,14 +3666,14 @@ var Zf = {
3579
3666
  nullable: !0
3580
3667
  }
3581
3668
  };
3582
- async function Qf() {
3583
- if (typeof window > "u" || !Jf?.enabled || !Jf.vapidPublicKey || !("serviceWorker" in navigator) || !("PushManager" in window) || !zf() || Notification.permission !== "granted") return null;
3669
+ async function op() {
3670
+ if (typeof window > "u" || !np?.enabled || !np.vapidPublicKey || !("serviceWorker" in navigator) || !("PushManager" in window) || !qf() || Notification.permission !== "granted") return null;
3584
3671
  try {
3585
3672
  let e = await navigator.serviceWorker.register("/push-service-worker.js");
3586
3673
  await navigator.serviceWorker.ready;
3587
3674
  let t = (await e.pushManager.getSubscription() ?? await e.pushManager.subscribe({
3588
3675
  userVisibleOnly: !0,
3589
- applicationServerKey: Xf(Jf.vapidPublicKey)
3676
+ applicationServerKey: ip(np.vapidPublicKey)
3590
3677
  })).toJSON();
3591
3678
  return !t.endpoint || !t.keys?.p256dh || !t.keys?.auth ? null : {
3592
3679
  Platform: "web",
@@ -3599,38 +3686,30 @@ async function Qf() {
3599
3686
  return null;
3600
3687
  }
3601
3688
  }
3602
- var $f = [
3689
+ var sp = [
3603
3690
  {
3604
- definition: Wd,
3605
- handler: Gd
3691
+ definition: Qd,
3692
+ handler: $d
3606
3693
  },
3607
3694
  {
3608
- definition: Kd,
3609
- handler: qd
3695
+ definition: ef,
3696
+ handler: tf
3610
3697
  },
3611
3698
  {
3612
- definition: Jd,
3613
- handler: Yd
3699
+ definition: nf,
3700
+ handler: rf
3614
3701
  },
3615
3702
  {
3616
- definition: Xd,
3617
- handler: Zd
3703
+ definition: af,
3704
+ handler: of
3618
3705
  },
3619
3706
  {
3620
- definition: tf,
3621
- handler: nf
3707
+ definition: uf,
3708
+ handler: df
3622
3709
  },
3623
3710
  {
3624
- definition: rf,
3625
- handler: af
3626
- },
3627
- {
3628
- definition: of,
3629
- handler: sf
3630
- },
3631
- {
3632
- definition: cf,
3633
- handler: lf
3711
+ definition: ff,
3712
+ handler: pf
3634
3713
  },
3635
3714
  {
3636
3715
  definition: mf,
@@ -3640,14 +3719,6 @@ var $f = [
3640
3719
  definition: gf,
3641
3720
  handler: _f
3642
3721
  },
3643
- {
3644
- definition: vf,
3645
- handler: yf
3646
- },
3647
- {
3648
- definition: bf,
3649
- handler: xf
3650
- },
3651
3722
  {
3652
3723
  definition: Sf,
3653
3724
  handler: Cf
@@ -3662,35 +3733,51 @@ var $f = [
3662
3733
  },
3663
3734
  {
3664
3735
  definition: Of,
3665
- handler: Af
3736
+ handler: kf
3737
+ },
3738
+ {
3739
+ definition: Af,
3740
+ handler: jf
3741
+ },
3742
+ {
3743
+ definition: Mf,
3744
+ handler: Nf
3666
3745
  },
3667
3746
  {
3668
- definition: jf,
3669
- handler: Mf
3747
+ definition: Pf,
3748
+ handler: Ff
3670
3749
  },
3671
3750
  {
3672
- definition: Nf,
3673
- handler: Pf
3751
+ definition: If,
3752
+ handler: Rf
3674
3753
  },
3675
3754
  {
3676
- definition: Ff,
3677
- handler: If
3755
+ definition: zf,
3756
+ handler: Bf
3678
3757
  },
3679
3758
  {
3680
- definition: Wf,
3681
- handler: Gf
3759
+ definition: Vf,
3760
+ handler: Hf
3682
3761
  },
3683
3762
  {
3684
- definition: Kf,
3685
- handler: qf
3763
+ definition: Uf,
3764
+ handler: Wf
3686
3765
  },
3687
3766
  {
3688
- definition: Zf,
3689
- handler: Qf
3767
+ definition: Qf,
3768
+ handler: $f
3769
+ },
3770
+ {
3771
+ definition: ep,
3772
+ handler: tp
3773
+ },
3774
+ {
3775
+ definition: ap,
3776
+ handler: op
3690
3777
  }
3691
3778
  ];
3692
- function ep(e) {
3693
- let t = $f.map(({ definition: t, handler: n }) => e.register(t, n));
3779
+ function cp(e) {
3780
+ let t = sp.map(({ definition: t, handler: n }) => e.register(t, n));
3694
3781
  return () => t.forEach((e) => e());
3695
3782
  }
3696
3783
  function R() {
@@ -3698,126 +3785,126 @@ function R() {
3698
3785
  }
3699
3786
  //#endregion
3700
3787
  //#region src/utils/log-sink.ts
3701
- var tp = 1e3, np = x.INFO, z = [], rp = tp, ip = np, ap = null;
3702
- function op(e) {
3703
- e.level < ip || (z.push(e), z.length > rp && (z = z.slice(-rp)));
3788
+ var lp = 1e3, up = x.INFO, z = [], dp = lp, fp = up, pp = null;
3789
+ function mp(e) {
3790
+ e.level < fp || (z.push(e), z.length > dp && (z = z.slice(-dp)));
3704
3791
  }
3705
- function sp(e) {
3706
- rp = e?.maxBufferSize ?? tp, ip = e?.minLevel ?? np, z = [], ye(op);
3792
+ function hp(e) {
3793
+ dp = e?.maxBufferSize ?? lp, fp = e?.minLevel ?? up, z = [], ye(mp);
3707
3794
  }
3708
- function cp(e) {
3709
- ap = e;
3795
+ function gp(e) {
3796
+ pp = e;
3710
3797
  }
3711
- function lp() {
3798
+ function _p() {
3712
3799
  return z;
3713
3800
  }
3714
- function up() {
3801
+ function vp() {
3715
3802
  let e = z;
3716
3803
  return z = [], e;
3717
3804
  }
3718
- function dp() {
3719
- if (!ap || z.length === 0) return 0;
3720
- let e = up();
3721
- return ap(e), e.length;
3805
+ function yp() {
3806
+ if (!pp || z.length === 0) return 0;
3807
+ let e = vp();
3808
+ return pp(e), e.length;
3722
3809
  }
3723
- function fp() {
3810
+ function bp() {
3724
3811
  z = [];
3725
3812
  }
3726
- function pp() {
3813
+ function xp() {
3727
3814
  return z.length;
3728
3815
  }
3729
- sp();
3816
+ hp();
3730
3817
  //#endregion
3731
3818
  //#region src/utils/log-sender.ts
3732
- var mp = S("LogSender"), hp = 1e3, gp = 6e4, _p = 15e3, vp = 10240, yp = 409600, bp = "…[truncated]", xp = {
3819
+ var Sp = S("LogSender"), Cp = 1e3, wp = 6e4, Tp = 15e3, Ep = 10240, Dp = 409600, Op = "…[truncated]", kp = {
3733
3820
  [x.DEBUG]: he.Debug,
3734
3821
  [x.INFO]: he.Info,
3735
3822
  [x.WARN]: he.Warning,
3736
3823
  [x.ERROR]: he.Error
3737
- }, B, Sp, V, H = [], U = 0, Cp;
3738
- function wp(e) {
3739
- return e.length <= vp ? e : e.slice(0, 10228) + bp;
3824
+ }, B, Ap, V, H = [], U = 0, jp;
3825
+ function Mp(e) {
3826
+ return e.length <= Ep ? e : e.slice(0, 10228) + Op;
3740
3827
  }
3741
- function Tp(e) {
3828
+ function Np(e) {
3742
3829
  return {
3743
3830
  Time: e.timestamp,
3744
- Type: xp[e.level] ?? he.Info,
3745
- Message: wp(`[${e.component}] ${e.message}`),
3831
+ Type: kp[e.level] ?? he.Info,
3832
+ Message: Mp(`[${e.component}] ${e.message}`),
3746
3833
  Parameters: "{}"
3747
3834
  };
3748
3835
  }
3749
- function Ep(e) {
3836
+ function Pp(e) {
3750
3837
  return JSON.stringify({
3751
3838
  type: "sdk-typescript",
3752
3839
  event: { Logs: e }
3753
3840
  });
3754
3841
  }
3755
- function Dp(e) {
3842
+ function Fp(e) {
3756
3843
  if (e.length === 0) return [];
3757
- let t = yp - Ep([]).length, n = [], r = [], i = 0;
3844
+ let t = Dp - Pp([]).length, n = [], r = [], i = 0;
3758
3845
  for (let a of e) {
3759
3846
  let e = JSON.stringify(a).length + 1;
3760
3847
  r.length > 0 && i + e > t && (n.push(r), r = [], i = 0), r.push(a), i += e;
3761
3848
  }
3762
3849
  return r.length > 0 && n.push(r), n;
3763
3850
  }
3764
- async function Op(e) {
3851
+ async function Ip(e) {
3765
3852
  if (e.length === 0 || !B) return;
3766
3853
  let t = `${B}/events/logs/json`, n = {
3767
3854
  "Content-Type": "application/json",
3768
- Authorization: `Bearer ${Sp}`
3855
+ Authorization: `Bearer ${Ap}`
3769
3856
  }, r = await fetch(t, {
3770
3857
  method: "POST",
3771
3858
  headers: n,
3772
- body: Ep(e),
3773
- signal: F(_p)
3859
+ body: Pp(e),
3860
+ signal: F(Tp)
3774
3861
  });
3775
3862
  if (!r.ok) {
3776
3863
  if (r.status >= 400 && r.status < 500) {
3777
- mp.warn(`Dropping ${e.length} log entries due to ${r.status}`);
3864
+ Sp.warn(`Dropping ${e.length} log entries due to ${r.status}`);
3778
3865
  return;
3779
3866
  }
3780
3867
  throw Error(`Failed to send logs: ${r.status}`);
3781
3868
  }
3782
3869
  }
3783
- function kp() {
3784
- if (U === 0) return hp;
3785
- let e = hp * (1 << Math.min(U, 6));
3786
- return Math.min(e, gp);
3870
+ function Lp() {
3871
+ if (U === 0) return Cp;
3872
+ let e = Cp * (1 << Math.min(U, 6));
3873
+ return Math.min(e, wp);
3787
3874
  }
3788
- function Ap(e) {
3789
- B && (V = setTimeout(() => void jp(), e));
3875
+ function Rp(e) {
3876
+ B && (V = setTimeout(() => void zp(), e));
3790
3877
  }
3791
- async function jp() {
3878
+ async function zp() {
3792
3879
  V = void 0;
3793
- let e = up();
3794
- if (H = H.concat(e.map(Tp)), typeof navigator < "u" && navigator.onLine === !1) {
3795
- Ap(hp);
3880
+ let e = vp();
3881
+ if (H = H.concat(e.map(Np)), typeof navigator < "u" && navigator.onLine === !1) {
3882
+ Rp(Cp);
3796
3883
  return;
3797
3884
  }
3798
3885
  if (H.length === 0) {
3799
- Ap(hp);
3886
+ Rp(Cp);
3800
3887
  return;
3801
3888
  }
3802
3889
  let t = H;
3803
3890
  H = [];
3804
- let n = Dp(t), r = !1;
3891
+ let n = Fp(t), r = !1;
3805
3892
  for (let e = 0; e < n.length; e++) try {
3806
- await Op(n[e]);
3893
+ await Ip(n[e]);
3807
3894
  } catch {
3808
3895
  H = n.slice(e).flat().concat(H), r = !0;
3809
3896
  break;
3810
3897
  }
3811
- r ? U++ : U = 0, Ap(kp());
3898
+ r ? U++ : U = 0, Rp(Lp());
3812
3899
  }
3813
- function Mp() {
3814
- V !== void 0 && (clearTimeout(V), V = void 0), Ap(0);
3900
+ function Bp() {
3901
+ V !== void 0 && (clearTimeout(V), V = void 0), Rp(0);
3815
3902
  }
3816
- function Np(e, t) {
3817
- Fp(), B = e, Sp = t, U = 0, typeof window < "u" && (Cp = Mp, window.addEventListener("online", Cp)), Ap(hp);
3903
+ function Vp(e, t) {
3904
+ Up(), B = e, Ap = t, U = 0, typeof window < "u" && (jp = Bp, window.addEventListener("online", jp)), Rp(Cp);
3818
3905
  }
3819
- function Pp(e, t) {
3820
- if (!B || !Sp) return;
3906
+ function Hp(e, t) {
3907
+ if (!B || !Ap) return;
3821
3908
  let n = { Events: [{
3822
3909
  Time: (/* @__PURE__ */ new Date()).toISOString(),
3823
3910
  EventName: e,
@@ -3831,60 +3918,60 @@ function Pp(e, t) {
3831
3918
  method: "POST",
3832
3919
  headers: {
3833
3920
  "Content-Type": "application/json",
3834
- Authorization: `Bearer ${Sp}`
3921
+ Authorization: `Bearer ${Ap}`
3835
3922
  },
3836
3923
  body: r
3837
- }).catch((t) => mp.warn(`Failed to send analytics event ${e}: ${t}`));
3924
+ }).catch((t) => Sp.warn(`Failed to send analytics event ${e}: ${t}`));
3838
3925
  }
3839
- function Fp() {
3840
- V !== void 0 && (clearTimeout(V), V = void 0), Cp !== void 0 && typeof window < "u" && (window.removeEventListener("online", Cp), Cp = void 0), B = void 0, Sp = void 0, H = [], U = 0;
3926
+ function Up() {
3927
+ V !== void 0 && (clearTimeout(V), V = void 0), jp !== void 0 && typeof window < "u" && (window.removeEventListener("online", jp), jp = void 0), B = void 0, Ap = void 0, H = [], U = 0;
3841
3928
  }
3842
3929
  //#endregion
3843
3930
  //#region src/utils/connect-timeline.ts
3844
- var Ip = S("ConnectTimeline"), Lp = "ikon-connect-trace-id", Rp, zp = !1;
3845
- function Bp() {
3931
+ var Wp = S("ConnectTimeline"), Gp = "ikon-connect-trace-id", Kp, qp = !1;
3932
+ function Jp() {
3846
3933
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(16)}-${Math.random().toString(16).slice(2)}`;
3847
3934
  }
3848
- function Vp() {
3935
+ function Yp() {
3849
3936
  try {
3850
- let e = sessionStorage.getItem(Lp);
3937
+ let e = sessionStorage.getItem(Gp);
3851
3938
  if (e) return e;
3852
- let t = Bp();
3853
- return sessionStorage.setItem(Lp, t), t;
3939
+ let t = Jp();
3940
+ return sessionStorage.setItem(Gp, t), t;
3854
3941
  } catch {
3855
- return Rp ??= Bp(), Rp;
3942
+ return Kp ??= Jp(), Kp;
3856
3943
  }
3857
3944
  }
3858
- function Hp(e) {
3945
+ function Xp(e) {
3859
3946
  if (typeof performance > "u" || typeof performance.getEntriesByType != "function") return;
3860
3947
  let t = performance.getEntriesByType("resource");
3861
3948
  for (let n = t.length - 1; n >= 0; n--) if (t[n].name.includes(e)) return Math.round(t[n].duration);
3862
3949
  }
3863
- function Up(e = {}) {
3864
- if (zp) return;
3865
- zp = !0;
3866
- let t = { connectTraceId: Vp() };
3950
+ function Zp(e = {}) {
3951
+ if (qp) return;
3952
+ qp = !0;
3953
+ let t = { connectTraceId: Yp() };
3867
3954
  e.snapshotSeeded !== void 0 && (t.snapshotSeeded = String(e.snapshotSeeded));
3868
3955
  try {
3869
3956
  if (typeof performance < "u") {
3870
3957
  t.firstPaintMs = String(Math.round(performance.now()));
3871
3958
  let e = performance.getEntriesByType("navigation")[0];
3872
3959
  e && (t.cdnHtmlMs = String(Math.round(e.responseEnd - e.fetchStart)), t.domContentLoadedMs = String(Math.round(e.domContentLoadedEventEnd)));
3873
- let n = Hp("/anonymous");
3960
+ let n = Xp("/anonymous");
3874
3961
  n !== void 0 && (t.authMs = String(n));
3875
- let r = Hp("/init");
3962
+ let r = Xp("/init");
3876
3963
  r !== void 0 && (t.initMs = String(r));
3877
- let i = Hp("/connect");
3964
+ let i = Xp("/connect");
3878
3965
  i !== void 0 && (t.connectMs = String(i));
3879
3966
  }
3880
3967
  } catch (e) {
3881
- Ip.warn(`Failed to read performance timeline: ${e}`);
3968
+ Wp.warn(`Failed to read performance timeline: ${e}`);
3882
3969
  }
3883
- Pp("client_connect_timeline", t);
3970
+ Hp("client_connect_timeline", t);
3884
3971
  }
3885
3972
  //#endregion
3886
3973
  //#region src/utils/uuid.ts
3887
- function Wp() {
3974
+ function Qp() {
3888
3975
  let e = globalThis.crypto;
3889
3976
  if (e && typeof e.randomUUID == "function") return e.randomUUID();
3890
3977
  let t = /* @__PURE__ */ new Uint8Array(16);
@@ -3897,34 +3984,34 @@ function Wp() {
3897
3984
  }
3898
3985
  //#endregion
3899
3986
  //#region src/storage.ts
3900
- var Gp = "ikon-device-id";
3901
- function Kp() {
3902
- if (typeof window > "u" || typeof localStorage > "u") return Wp();
3987
+ var $p = "ikon-device-id";
3988
+ function em() {
3989
+ if (typeof window > "u" || typeof localStorage > "u") return Qp();
3903
3990
  try {
3904
- let e = localStorage.getItem(Gp);
3905
- return e || (e = Wp(), localStorage.setItem(Gp, e)), e;
3991
+ let e = localStorage.getItem($p);
3992
+ return e || (e = Qp(), localStorage.setItem($p, e)), e;
3906
3993
  } catch {
3907
- return Wp();
3994
+ return Qp();
3908
3995
  }
3909
3996
  }
3910
- function qp() {
3997
+ function tm() {
3911
3998
  if (!(typeof localStorage > "u")) try {
3912
- localStorage.removeItem(Gp);
3999
+ localStorage.removeItem($p);
3913
4000
  } catch {}
3914
4001
  }
3915
- function Jp(e) {
3916
- let t = Xp(e);
4002
+ function nm(e) {
4003
+ let t = im(e);
3917
4004
  return typeof t?.id == "string" ? t.id : null;
3918
4005
  }
3919
- function Yp(e) {
3920
- let t = Xp(e);
4006
+ function rm(e) {
4007
+ let t = im(e);
3921
4008
  return t ? {
3922
4009
  userId: typeof t.id == "string" ? t.id : null,
3923
4010
  authSession: typeof t.authSession == "string" ? t.authSession : null,
3924
4011
  role: typeof t.role == "string" ? t.role : null
3925
4012
  } : null;
3926
4013
  }
3927
- function Xp(e) {
4014
+ function im(e) {
3928
4015
  try {
3929
4016
  let t = e.split(".");
3930
4017
  if (t.length !== 3) return null;
@@ -3936,8 +4023,8 @@ function Xp(e) {
3936
4023
  }
3937
4024
  //#endregion
3938
4025
  //#region src/connection/authenticator.ts
3939
- var W = S("Authenticator"), G = C.GROUP_CORE | C.GROUP_KEEPALIVE | C.GROUP_EVENTS | C.GROUP_ACTIONS | C.GROUP_UI | C.GROUP_AUDIO | C.GROUP_VIDEO | C.GROUP_ANALYTICS | C.GROUP_APP_LOCAL, Zp = 2, Qp = 6e4, $p = 2e3, em = 1e4, tm = 3e3, nm = 3e3, rm = 3, im = 1e3, am = 4;
3940
- async function om(e, t, n, r) {
4026
+ var W = S("Authenticator"), G = C.GROUP_CORE | C.GROUP_KEEPALIVE | C.GROUP_EVENTS | C.GROUP_ACTIONS | C.GROUP_UI | C.GROUP_AUDIO | C.GROUP_VIDEO | C.GROUP_ANALYTICS | C.GROUP_APP_LOCAL, am = 2, om = 6e4, sm = 2e3, cm = 1e4, lm = 3e3, um = 3e3, dm = 3, fm = "X-Ikon-Startup-Failed", pm = "startup_failed", mm = 1e3, hm = 4;
4027
+ async function gm(e, t, n, r) {
3941
4028
  if (e) try {
3942
4029
  let i = await fetch(`${n}/anonymous`, {
3943
4030
  method: "POST",
@@ -3958,7 +4045,7 @@ async function om(e, t, n, r) {
3958
4045
  W.warn("Anonymous auth returned no token");
3959
4046
  return;
3960
4047
  }
3961
- let o = Jp(a.token);
4048
+ let o = nm(a.token);
3962
4049
  if (!o) {
3963
4050
  W.warn("Anonymous auth token had no extractable userId");
3964
4051
  return;
@@ -3972,7 +4059,7 @@ async function om(e, t, n, r) {
3972
4059
  return;
3973
4060
  }
3974
4061
  }
3975
- async function sm(e, t, n, r) {
4062
+ async function _m(e, t, n, r) {
3976
4063
  try {
3977
4064
  let i = await fetch(`${e}/profiles/me?space=${encodeURIComponent(t)}`, {
3978
4065
  method: "GET",
@@ -3984,7 +4071,7 @@ async function sm(e, t, n, r) {
3984
4071
  W.warn("Failed to ensure profile:", e);
3985
4072
  }
3986
4073
  }
3987
- async function cm(e) {
4074
+ async function vm(e) {
3988
4075
  let t = await e.text().catch(() => "Unknown error");
3989
4076
  try {
3990
4077
  let e = JSON.parse(t);
@@ -3992,16 +4079,16 @@ async function cm(e) {
3992
4079
  } catch {}
3993
4080
  return t;
3994
4081
  }
3995
- async function lm(e) {
4082
+ async function ym(e) {
3996
4083
  if (e.ok) return;
3997
- let t = await cm(e);
3998
- throw e.status === 403 ? new Ml(`Access denied: ${t}`, t) : um("Failed to get or create profile", e.status, t);
4084
+ let t = await vm(e);
4085
+ throw e.status === 403 ? new Ml(`Access denied: ${t}`, t) : bm("Failed to get or create profile", e.status, t);
3999
4086
  }
4000
- function um(e, t, n) {
4087
+ function bm(e, t, n) {
4001
4088
  let r = `${e}: ${t} ${n}`;
4002
4089
  return t >= 500 ? new Fl(r, t) : new w(r);
4003
4090
  }
4004
- function dm(e, t, n) {
4091
+ function xm(e, t, n) {
4005
4092
  let r = {
4006
4093
  method: "POST",
4007
4094
  headers: {
@@ -4013,32 +4100,35 @@ function dm(e, t, n) {
4013
4100
  };
4014
4101
  return t || (r.credentials = "include"), r;
4015
4102
  }
4016
- async function fm(e, t, n, r) {
4017
- let i = `${e}/init`, a = await fetch(i, dm(t, n, r));
4103
+ async function Sm(e, t, n, r) {
4104
+ let i = `${e}/init`, a = await fetch(i, xm(t, n, r));
4018
4105
  if (!a.ok) {
4019
- let e = await cm(a);
4020
- throw a.status === 403 ? new Ml(`Access denied: ${e}`, e) : a.status === 404 && t.sessionIdentityHash ? new Nl(t.sessionIdentityHash) : um("Backend init failed", a.status, e);
4106
+ let e = await vm(a);
4107
+ throw a.status === 403 ? new Ml(`Access denied: ${e}`, e) : a.status === 404 && t.sessionIdentityHash ? new Nl(t.sessionIdentityHash) : bm("Backend init failed", a.status, e);
4021
4108
  }
4022
4109
  return a.json();
4023
4110
  }
4111
+ function Cm(e, t) {
4112
+ return e.startupFailed ? new D() : new Al(t);
4113
+ }
4024
4114
  async function K(e, t, n) {
4025
- let r = F(n ?? em), i = t ? ud([t, r]) : r, a = Date.now(), o = await fetch(e, { signal: i });
4115
+ let r = F(n ?? cm), i = t ? gd([t, r]) : r, a = Date.now(), o = await fetch(e, { signal: i });
4026
4116
  if (!o.ok) {
4027
4117
  let e = await o.text().catch(() => "Unknown error");
4028
- throw o.status === 429 ? new Pl(`Server is at capacity: ${e}`) : um("Failed to connect", o.status, e);
4118
+ throw o.status === 429 ? new Pl(`Server is at capacity: ${e}`) : o.headers.get(fm) || e.includes(pm) ? new D() : bm("Failed to connect", o.status, e);
4029
4119
  }
4030
4120
  let s = await o.arrayBuffer(), c = await An(new Uint8Array(s));
4031
4121
  return W.debug(`Connect URL fetched in ${Date.now() - a}ms`), { authResponse: c };
4032
4122
  }
4033
- async function pm(e, t) {
4123
+ async function wm(e, t) {
4034
4124
  try {
4035
- let n = new URL(e), r = `${n.protocol}//${n.host}/health`, i = F(nm), a = t ? ud([t, i]) : i;
4125
+ let n = new URL(e), r = `${n.protocol}//${n.host}/health`, i = F(um), a = t ? gd([t, i]) : i;
4036
4126
  return (await fetch(r, { signal: a })).ok;
4037
4127
  } catch {
4038
4128
  return !1;
4039
4129
  }
4040
4130
  }
4041
- async function mm(e, t, n, r, i) {
4131
+ async function Tm(e, t, n, r, i) {
4042
4132
  let a = [];
4043
4133
  if (n === "force-proxy" ? t && a.push({
4044
4134
  url: t,
@@ -4061,33 +4151,33 @@ async function mm(e, t, n, r, i) {
4061
4151
  })), a.length === 0) throw new w("No connect URL available");
4062
4152
  W.debug(`Auth URL order: [${a.map((e) => e.isProxy ? "proxy" : "direct").join(", ")}], mode: ${n}, proxyPreferred: ${r}`);
4063
4153
  let o = n === "auto" && a.length > 1 && !a[0].isProxy, s = Date.now(), c = 0;
4064
- for (; c < Zp || Date.now() - s < Qp;) {
4154
+ for (; c < am || Date.now() - s < om;) {
4065
4155
  for (let t = 0; t < a.length; t++) {
4066
- let n = a[t], r = c === 0 && t === 0 && o ? tm : em;
4156
+ let n = a[t], r = c === 0 && t === 0 && o ? lm : cm;
4067
4157
  try {
4068
4158
  let t = await K(n.url, i, r);
4069
4159
  return t.usedProxyUrl = n.isProxy, t.directUrl = e, W.debug(`Auth succeeded via ${n.isProxy ? "proxy" : "direct"} URL`), t;
4070
4160
  } catch (e) {
4071
- if (i?.aborted || e instanceof Pl) throw e;
4161
+ if (i?.aborted || e instanceof Pl || e instanceof D) throw e;
4072
4162
  W.warn(`Auth via ${n.isProxy ? "proxy" : "direct"} URL failed (round ${c + 1}, timeout ${r}ms): ${e}`);
4073
4163
  }
4074
4164
  }
4075
- c++, await Ll($p, i);
4165
+ c++, await Ll(sm, i);
4076
4166
  }
4077
4167
  throw new w("Failed to connect after exhausting all URL attempts");
4078
4168
  }
4079
- function hm(e, t, n = "", r = !0) {
4080
- let i = Hd();
4169
+ function Em(e, t, n = "", r = !0) {
4170
+ let i = Xd();
4081
4171
  return Zt({
4082
4172
  ServerSessionId: "",
4083
4173
  ContextType: m.Browser,
4084
4174
  UserType: p.Human,
4085
4175
  PayloadType: me.Teleport,
4086
4176
  IsInternal: !1,
4087
- IsSnapshot: gu(),
4177
+ IsSnapshot: _u(),
4088
4178
  Description: e.description ?? "Ikon SDK TypeScript",
4089
4179
  UserId: t,
4090
- DeviceId: e.deviceId ?? Kp(),
4180
+ DeviceId: e.deviceId ?? em(),
4091
4181
  ProductId: e.productId ?? "ikon-sdk",
4092
4182
  VersionId: e.versionId ?? "1.0.0",
4093
4183
  InstallId: e.installId ?? "",
@@ -4095,25 +4185,25 @@ function hm(e, t, n = "", r = !0) {
4095
4185
  OpcodeGroupsFromServer: e.opcodeGroupsFromServer ?? G,
4096
4186
  OpcodeGroupsToServer: e.opcodeGroupsToServer ?? G,
4097
4187
  ProtocolVersion: 1,
4098
- SdkCapability: am,
4188
+ SdkCapability: hm,
4099
4189
  HasInput: !1,
4100
4190
  AuthSessionId: n,
4101
4191
  IsAnonymous: r,
4102
4192
  IsGlobal: !1,
4103
4193
  ReceiveAllMessages: !1,
4104
4194
  UserAgent: typeof navigator < "u" ? navigator.userAgent : "",
4105
- ClientType: ef(),
4195
+ ClientType: lf(),
4106
4196
  Parameters: e.parameters ?? {},
4107
4197
  ViewportWidth: i.width,
4108
4198
  ViewportHeight: i.height,
4109
- Theme: Vd(),
4110
- Timezone: Qd(),
4111
- IsTouchDevice: $d(),
4112
- InitialPath: Pd(),
4199
+ Theme: Yd(),
4200
+ Timezone: sf(),
4201
+ IsTouchDevice: cf(),
4202
+ InitialPath: Bd(),
4113
4203
  SupportsCompression: ke()
4114
4204
  });
4115
4205
  }
4116
- function gm(e) {
4206
+ function Dm(e) {
4117
4207
  return {
4118
4208
  ServerSessionId: e.ServerSessionId,
4119
4209
  ContextType: e.ContextType,
@@ -4149,26 +4239,26 @@ function gm(e) {
4149
4239
  SupportsCompression: e.SupportsCompression
4150
4240
  };
4151
4241
  }
4152
- async function _m(e, t) {
4242
+ async function Om(e, t) {
4153
4243
  let n = `https://${e.host}:${e.httpsPort}`;
4154
4244
  W.debug(`Authenticating with local server: ${n}`);
4155
4245
  let r = {
4156
- ...kd(),
4246
+ ...Fd(),
4157
4247
  ...e.parameters
4158
- }, i = e.deviceId ?? Kp(), a = e.userId, o = e.token;
4248
+ }, i = e.deviceId ?? em(), a = e.userId, o = e.token;
4159
4249
  if (!a) {
4160
- let n = await om(e.spaceId, i, await Od(e.authUrl), t);
4250
+ let n = await gm(e.spaceId, i, await Nd(e.authUrl), t);
4161
4251
  n && (a = n.userId, o = n.token);
4162
4252
  }
4163
4253
  if (a || (a = i, W.debug("Using deviceId as userId fallback")), e.spaceId && o) if (e.token) {
4164
- let n = Ed(e.backendUrl);
4165
- await lm(await fetch(`${n}/profiles/me?space=${encodeURIComponent(e.spaceId)}`, {
4254
+ let n = jd(e.backendUrl);
4255
+ await ym(await fetch(`${n}/profiles/me?space=${encodeURIComponent(e.spaceId)}`, {
4166
4256
  method: "GET",
4167
4257
  headers: { Authorization: `Bearer ${o}` },
4168
4258
  signal: t
4169
4259
  }));
4170
- } else await sm(Ed(e.backendUrl), e.spaceId, o, t);
4171
- let s = e.token ?? e.identityToken ?? o, c = s ? Yp(s) : null, l = c?.authSession ?? (e.token ? "authenticated" : ""), u = c?.role ? c.role === "anonymous" : !e.token, d = gm(hm({
4260
+ } else await _m(jd(e.backendUrl), e.spaceId, o, t);
4261
+ let s = e.token ?? e.identityToken ?? o, c = s ? rm(s) : null, l = c?.authSession ?? (e.token ? "authenticated" : ""), u = c?.role ? c.role === "anonymous" : !e.token, d = Dm(Em({
4172
4262
  ...e,
4173
4263
  parameters: r
4174
4264
  }, a, l, u)), f = await fetch(`${n}/connect-token`, {
@@ -4179,15 +4269,15 @@ async function _m(e, t) {
4179
4269
  });
4180
4270
  if (!f.ok) {
4181
4271
  let e = await f.text().catch(() => "Unknown error");
4182
- throw um("Failed to get connect token", f.status, e);
4272
+ throw bm("Failed to get connect token", f.status, e);
4183
4273
  }
4184
4274
  let p = (await f.json()).token;
4185
4275
  if (!p) throw new w("Server did not return a token");
4186
4276
  let m = `${n}/connect?token=${encodeURIComponent(p)}`, h = await K(m, t);
4187
- return h.directUrl = m, h.backendUrl = Ed(e.backendUrl), h.authToken = o, h;
4277
+ return h.directUrl = m, h.backendUrl = jd(e.backendUrl), h.authToken = o, h;
4188
4278
  }
4189
- async function vm(e, t, n = "auto", r = !1) {
4190
- let i = Td(e.backendType);
4279
+ async function km(e, t, n = "auto", r = !1) {
4280
+ let i = Ad(e.backendType);
4191
4281
  W.debug(`Authenticating with cloud server: ${i}, space ID: ${e.spaceId}`);
4192
4282
  let a = await fetch(`${i}/auth/api-key`, {
4193
4283
  method: "POST",
@@ -4201,14 +4291,14 @@ async function vm(e, t, n = "auto", r = !1) {
4201
4291
  });
4202
4292
  if (!a.ok) {
4203
4293
  let e = await a.text().catch(() => "Unknown error");
4204
- throw um("API key authentication failed", a.status, e);
4294
+ throw bm("API key authentication failed", a.status, e);
4205
4295
  }
4206
4296
  let o = (await a.json()).token;
4207
4297
  if (!o) throw new w("Backend did not return a token");
4208
- let s = kd(), c = e.provisioningTimeoutMs ?? 6e4, l = {
4298
+ let s = Fd(), c = e.provisioningTimeoutMs ?? 6e4, l = {
4209
4299
  ...s,
4210
4300
  ...e.parameters
4211
- }, u = Hd(), d = k() ? rm : 1;
4301
+ }, u = Xd(), d = k() ? dm : 1;
4212
4302
  for (let a = 0; a < d; a++) try {
4213
4303
  let a = {
4214
4304
  space: e.spaceId,
@@ -4216,13 +4306,13 @@ async function vm(e, t, n = "auto", r = !1) {
4216
4306
  params: e.parameters,
4217
4307
  waitForRunning: !0,
4218
4308
  waitForRunningTimeoutMs: c,
4219
- connectTraceId: Vp(),
4309
+ connectTraceId: Yp(),
4220
4310
  contextType: m.Plugin,
4221
4311
  userType: e.userType ?? p.Human,
4222
- clientType: e.clientType ?? ef(),
4312
+ clientType: e.clientType ?? lf(),
4223
4313
  payloadType: me.Teleport,
4224
4314
  description: e.description ?? "Ikon SDK TypeScript",
4225
- deviceId: e.deviceId ?? Kp(),
4315
+ deviceId: e.deviceId ?? em(),
4226
4316
  productId: e.productId ?? "",
4227
4317
  versionId: e.versionId ?? "",
4228
4318
  installId: e.installId ?? "",
@@ -4234,31 +4324,31 @@ async function vm(e, t, n = "auto", r = !1) {
4234
4324
  launchParams: l,
4235
4325
  viewportWidth: u.width,
4236
4326
  viewportHeight: u.height,
4237
- theme: Vd(),
4238
- timezone: Qd(),
4239
- isTouchDevice: $d(),
4240
- initialPath: Pd(),
4327
+ theme: Yd(),
4328
+ timezone: sf(),
4329
+ isTouchDevice: cf(),
4330
+ initialPath: Bd(),
4241
4331
  sdkType: 2,
4242
- sdkCapability: am,
4332
+ sdkCapability: hm,
4243
4333
  supportsCompression: ke(),
4244
- isSnapshot: gu()
4245
- }, s = t ? ud([t, F(c)]) : F(c), d = await fm(i, a, o, s);
4246
- if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw new Al(c);
4247
- let f = await mm(d.configuration.url, d.configuration.proxyUrl, n, r, s);
4248
- return f.backendUrl = i, f.authToken = o, f.brandingRequired = d.configuration.brandingRequired ?? !1, Yf(d.configuration.push), f;
4334
+ isSnapshot: _u()
4335
+ }, s = t ? gd([t, F(c)]) : F(c), d = await Sm(i, a, o, s);
4336
+ if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw Cm(d, c);
4337
+ let f = await Tm(d.configuration.url, d.configuration.proxyUrl, n, r, s);
4338
+ return f.backendUrl = i, f.authToken = o, f.brandingRequired = d.configuration.brandingRequired ?? !1, rp(d.configuration.push), f;
4249
4339
  } catch (e) {
4250
- if (e instanceof Ml || e instanceof Pl || e instanceof Nl || a === d - 1) throw e;
4251
- W.debug(`Init attempt ${a + 1}/${d} failed, retrying: ${e}`), await Ll(im * (a + 1), t);
4340
+ if (e instanceof Ml || e instanceof Pl || e instanceof Nl || e instanceof D || a === d - 1) throw e;
4341
+ W.debug(`Init attempt ${a + 1}/${d} failed, retrying: ${e}`), await Ll(mm * (a + 1), t);
4252
4342
  }
4253
4343
  throw new w("Failed to init after all attempts");
4254
4344
  }
4255
- async function ym(e, t, n = "auto", r = !1) {
4256
- let i = Td(e.backendType), a = e.token;
4345
+ async function Am(e, t, n = "auto", r = !1) {
4346
+ let i = Ad(e.backendType), a = e.token;
4257
4347
  W.debug(`Authenticating with session token to: ${i}, space ID: ${e.spaceId}`);
4258
- let o = kd(), s = e.provisioningTimeoutMs ?? 6e4, c = {
4348
+ let o = Fd(), s = e.provisioningTimeoutMs ?? 6e4, c = {
4259
4349
  ...o,
4260
4350
  ...e.parameters
4261
- }, l = Hd(), u = k() ? rm : 1;
4351
+ }, l = Xd(), u = k() ? dm : 1;
4262
4352
  for (let o = 0; o < u; o++) try {
4263
4353
  let o = {
4264
4354
  space: e.spaceId,
@@ -4266,13 +4356,13 @@ async function ym(e, t, n = "auto", r = !1) {
4266
4356
  params: e.parameters,
4267
4357
  waitForRunning: !0,
4268
4358
  waitForRunningTimeoutMs: s,
4269
- connectTraceId: Vp(),
4359
+ connectTraceId: Yp(),
4270
4360
  contextType: m.Browser,
4271
4361
  userType: p.Human,
4272
- clientType: ef(),
4362
+ clientType: lf(),
4273
4363
  payloadType: me.Teleport,
4274
4364
  description: e.description ?? "Ikon SDK TypeScript",
4275
- deviceId: e.deviceId ?? Kp(),
4365
+ deviceId: e.deviceId ?? em(),
4276
4366
  productId: e.productId ?? "",
4277
4367
  versionId: e.versionId ?? "",
4278
4368
  installId: e.installId ?? "",
@@ -4284,38 +4374,38 @@ async function ym(e, t, n = "auto", r = !1) {
4284
4374
  launchParams: c,
4285
4375
  viewportWidth: l.width,
4286
4376
  viewportHeight: l.height,
4287
- theme: Vd(),
4288
- timezone: Qd(),
4289
- isTouchDevice: $d(),
4290
- initialPath: Pd(),
4377
+ theme: Yd(),
4378
+ timezone: sf(),
4379
+ isTouchDevice: cf(),
4380
+ initialPath: Bd(),
4291
4381
  sdkType: 2,
4292
- sdkCapability: am,
4382
+ sdkCapability: hm,
4293
4383
  supportsCompression: ke(),
4294
- isSnapshot: gu()
4295
- }, u = t ? ud([t, F(s)]) : F(s), d = await fm(i, o, a, u);
4296
- if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw new Al(s);
4297
- let f = await mm(d.configuration.url, d.configuration.proxyUrl, n, r, u);
4298
- return f.backendUrl = i, f.authToken = a, f.brandingRequired = d.configuration.brandingRequired ?? !1, Yf(d.configuration.push), f;
4384
+ isSnapshot: _u()
4385
+ }, u = t ? gd([t, F(s)]) : F(s), d = await Sm(i, o, a, u);
4386
+ if (d.state?.toLowerCase() !== "running" || !d.configuration?.url) throw Cm(d, s);
4387
+ let f = await Tm(d.configuration.url, d.configuration.proxyUrl, n, r, u);
4388
+ return f.backendUrl = i, f.authToken = a, f.brandingRequired = d.configuration.brandingRequired ?? !1, rp(d.configuration.push), f;
4299
4389
  } catch (e) {
4300
- if (e instanceof Ml || e instanceof Pl || e instanceof Nl || o === u - 1) throw e;
4301
- W.debug(`Init attempt ${o + 1}/${u} failed, retrying: ${e}`), await Ll(im * (o + 1), t);
4390
+ if (e instanceof Ml || e instanceof Pl || e instanceof Nl || e instanceof D || o === u - 1) throw e;
4391
+ W.debug(`Init attempt ${o + 1}/${u} failed, retrying: ${e}`), await Ll(mm * (o + 1), t);
4302
4392
  }
4303
4393
  throw new w("Failed to init after all attempts");
4304
4394
  }
4305
4395
  //#endregion
4306
4396
  //#region src/functions/type-conversion.ts
4307
- var bm = /* @__PURE__ */ new Uint8Array();
4308
- function xm(e) {
4397
+ var jm = /* @__PURE__ */ new Uint8Array();
4398
+ function Mm(e) {
4309
4399
  switch (e.kind) {
4310
4400
  case "array": return {
4311
4401
  kind: "array",
4312
- element: xm(e.element),
4402
+ element: Mm(e.element),
4313
4403
  nullable: e.nullable ?? !1
4314
4404
  };
4315
4405
  case "dictionary": return {
4316
4406
  kind: "dictionary",
4317
4407
  keyType: e.keyType ?? "string",
4318
- value: xm(e.value),
4408
+ value: Mm(e.value),
4319
4409
  nullable: e.nullable ?? !1
4320
4410
  };
4321
4411
  default: return {
@@ -4324,17 +4414,17 @@ function xm(e) {
4324
4414
  };
4325
4415
  }
4326
4416
  }
4327
- function Sm(e) {
4417
+ function Nm(e) {
4328
4418
  switch (e.kind) {
4329
4419
  case "boolean": return "System.Boolean";
4330
4420
  case "number": return "System.Double";
4331
4421
  case "string": return "System.String";
4332
- case "array": return `System.Collections.Generic.List\`1[${Sm(e.element)}]`;
4333
- case "dictionary": return `System.Collections.Generic.Dictionary\`2[${e.keyType === "int" ? "System.Int32" : "System.String"},${Sm(e.value)}]`;
4422
+ case "array": return `System.Collections.Generic.List\`1[${Nm(e.element)}]`;
4423
+ case "dictionary": return `System.Collections.Generic.Dictionary\`2[${e.keyType === "int" ? "System.Int32" : "System.String"},${Nm(e.value)}]`;
4334
4424
  default: return e;
4335
4425
  }
4336
4426
  }
4337
- function Cm(e, t) {
4427
+ function Pm(e, t) {
4338
4428
  if (e === void 0 || e === "") return;
4339
4429
  let n = JSON.parse(e);
4340
4430
  if (n === null) {
@@ -4343,7 +4433,7 @@ function Cm(e, t) {
4343
4433
  }
4344
4434
  return n;
4345
4435
  }
4346
- function wm(e, t) {
4436
+ function Fm(e, t) {
4347
4437
  if (e === void 0) return "null";
4348
4438
  if (e === null) {
4349
4439
  if (!t.nullable) throw Error("Value cannot be null for non-nullable type");
@@ -4351,9 +4441,9 @@ function wm(e, t) {
4351
4441
  }
4352
4442
  return JSON.stringify(e);
4353
4443
  }
4354
- function Tm(e, t) {
4444
+ function Im(e, t) {
4355
4445
  let r = (e.parameters ?? []).map((e) => {
4356
- let t = xm(e.type), n = Object.prototype.hasOwnProperty.call(e, "defaultValue"), r = n ? wm(e.defaultValue, t) : "";
4446
+ let t = Mm(e.type), n = Object.prototype.hasOwnProperty.call(e, "defaultValue"), r = n ? Fm(e.defaultValue, t) : "";
4357
4447
  return {
4358
4448
  name: e.name,
4359
4449
  descriptor: t,
@@ -4361,7 +4451,7 @@ function Tm(e, t) {
4361
4451
  defaultValueJson: r,
4362
4452
  description: e.description
4363
4453
  };
4364
- }), i = xm(e.returnType);
4454
+ }), i = Mm(e.returnType);
4365
4455
  return {
4366
4456
  definition: e,
4367
4457
  handler: t,
@@ -4371,7 +4461,7 @@ function Tm(e, t) {
4371
4461
  Description: e.description ?? "",
4372
4462
  LlmInlineResult: e.llmInlineResult ?? !1,
4373
4463
  LlmCallOnlyOnce: e.llmCallOnlyOnce ?? !1,
4374
- ResultTypeName: Sm(i),
4464
+ ResultTypeName: Nm(i),
4375
4465
  IsEnumerable: !1,
4376
4466
  EnumerableItemTypeName: "",
4377
4467
  IsCancellable: !1,
@@ -4380,10 +4470,10 @@ function Tm(e, t) {
4380
4470
  Parameters: r.map((e, t) => ({
4381
4471
  ParameterIndex: t,
4382
4472
  ParameterName: e.name,
4383
- TypeName: Sm(e.descriptor),
4473
+ TypeName: Nm(e.descriptor),
4384
4474
  HasDefaultValue: e.hasDefaultValue,
4385
4475
  DefaultValueJson: e.defaultValueJson,
4386
- DefaultValueData: bm,
4476
+ DefaultValueData: jm,
4387
4477
  IsEnumerable: !1,
4388
4478
  EnumerableItemTypeName: "",
4389
4479
  Description: e.description ?? ""
@@ -4395,24 +4485,24 @@ function Tm(e, t) {
4395
4485
  }
4396
4486
  //#endregion
4397
4487
  //#region src/functions/types.ts
4398
- function Em(e, t) {
4488
+ function Lm(e, t) {
4399
4489
  return {
4400
4490
  value: e,
4401
4491
  data: t
4402
4492
  };
4403
4493
  }
4404
- var Dm = class extends Error {
4494
+ var Rm = class extends Error {
4405
4495
  remoteErrorType;
4406
4496
  remoteStackTrace;
4407
4497
  code;
4408
4498
  constructor(e, t, n, r = "") {
4409
4499
  super(e), this.remoteErrorType = t, this.remoteStackTrace = n, this.code = r, this.name = "FunctionCallError";
4410
4500
  }
4411
- }, Om = S("FunctionRegistry"), km = /* @__PURE__ */ new Uint8Array(), Am = 3e4;
4412
- function jm(e) {
4501
+ }, zm = S("FunctionRegistry"), Bm = /* @__PURE__ */ new Uint8Array(), Vm = 3e4;
4502
+ function Hm(e) {
4413
4503
  return !e || typeof e != "object" ? !1 : e.data instanceof Uint8Array;
4414
4504
  }
4415
- var Mm = class {
4505
+ var Um = class {
4416
4506
  functions = /* @__PURE__ */ new Map();
4417
4507
  remoteFunctions = /* @__PURE__ */ new Map();
4418
4508
  pendingCalls = /* @__PURE__ */ new Map();
@@ -4434,7 +4524,7 @@ var Mm = class {
4434
4524
  };
4435
4525
  }
4436
4526
  register(e, t) {
4437
- let n = Tm(e, t);
4527
+ let n = Im(e, t);
4438
4528
  return this.functions.set(e.name, n), this.isConnected && this.config && this.sendRegistration(n), () => this.unregister(e.name);
4439
4529
  }
4440
4530
  unregister(e) {
@@ -4475,7 +4565,7 @@ var Mm = class {
4475
4565
  ParameterIndex: t,
4476
4566
  TypeName: n ? n.TypeName : this.inferTypeName(e),
4477
4567
  ValueJson: JSON.stringify(e ?? null),
4478
- ValueData: km
4568
+ ValueData: Bm
4479
4569
  });
4480
4570
  }), c = r?.instanceId ? n.fromString(r.instanceId) : n.createZero(), l = rr(Xn({
4481
4571
  FunctionId: n.fromString(i.id),
@@ -4488,8 +4578,8 @@ var Mm = class {
4488
4578
  }), this.config.sessionId, { targetIds: [i.clientSessionId] });
4489
4579
  return new Promise((t, n) => {
4490
4580
  let r = setTimeout(() => {
4491
- this.pendingCalls.delete(o.toString()), n(/* @__PURE__ */ Error(`Function call '${e}' timed out after ${Am}ms`));
4492
- }, Am);
4581
+ this.pendingCalls.delete(o.toString()), n(/* @__PURE__ */ Error(`Function call '${e}' timed out after ${Vm}ms`));
4582
+ }, Vm);
4493
4583
  this.pendingCalls.set(o.toString(), {
4494
4584
  resolve: t,
4495
4585
  reject: n,
@@ -4556,7 +4646,7 @@ var Mm = class {
4556
4646
  if (t === C.ACTION_FUNCTION_CALL) {
4557
4647
  let t = i(e);
4558
4648
  return this.handleFunctionCall(e, t.senderId).catch((e) => {
4559
- Om.error("Failed to handle function call:", e);
4649
+ zm.error("Failed to handle function call:", e);
4560
4650
  }), !0;
4561
4651
  }
4562
4652
  if (t === C.ACTION_FUNCTION_RESULT) return this.handleFunctionResult(e), !0;
@@ -4578,7 +4668,7 @@ var Mm = class {
4578
4668
  handleFunctionResult(e) {
4579
4669
  let t = ra(e), n = t.CallId.toString(), r = this.pendingCalls.get(n);
4580
4670
  if (!r) {
4581
- Om.warn(`Received result for unknown call: ${n}`);
4671
+ zm.warn(`Received result for unknown call: ${n}`);
4582
4672
  return;
4583
4673
  }
4584
4674
  if (this.pendingCalls.delete(n), clearTimeout(r.timeout), t.ResultData && t.ResultData.length > 0 && !t.ResultJson) {
@@ -4591,11 +4681,11 @@ var Mm = class {
4591
4681
  handleFunctionError(e) {
4592
4682
  let t = Gr(e), n = t.CallId.toString(), r = this.pendingCalls.get(n);
4593
4683
  if (!r) {
4594
- Om.warn(`Received error for unknown call: ${n}`);
4684
+ zm.warn(`Received error for unknown call: ${n}`);
4595
4685
  return;
4596
4686
  }
4597
4687
  this.pendingCalls.delete(n), clearTimeout(r.timeout);
4598
- let i = new Dm(t.ErrorMessage, t.ErrorTypeName, t.StackTrace, t.ErrorCode), a = {
4688
+ let i = new Rm(t.ErrorMessage, t.ErrorTypeName, t.StackTrace, t.ErrorCode), a = {
4599
4689
  functionName: r.functionName,
4600
4690
  args: r.args
4601
4691
  };
@@ -4631,7 +4721,7 @@ var Mm = class {
4631
4721
  async handleFunctionCall(e, t) {
4632
4722
  let n = await ir(e), r = this.functions.get(n.FunctionName);
4633
4723
  if (!r) {
4634
- Om.warn(`Received call for unknown function: ${n.FunctionName}`), this.sendError(n.CallId, n.InstanceId, t, /* @__PURE__ */ Error(`Unknown function: ${n.FunctionName}`));
4724
+ zm.warn(`Received call for unknown function: ${n.FunctionName}`), this.sendError(n.CallId, n.InstanceId, t, /* @__PURE__ */ Error(`Unknown function: ${n.FunctionName}`));
4635
4725
  return;
4636
4726
  }
4637
4727
  this.sendAck(n.CallId, n.InstanceId, t), this.executeFunction(r, n, t);
@@ -4646,14 +4736,14 @@ var Mm = class {
4646
4736
  continue;
4647
4737
  }
4648
4738
  let o = a?.ValueJson;
4649
- o === void 0 || o === "" ? i.hasDefaultValue ? r.push(Cm(i.defaultValueJson, i.descriptor)) : r.push(void 0) : r.push(Cm(o, i.descriptor));
4739
+ o === void 0 || o === "" ? i.hasDefaultValue ? r.push(Pm(i.defaultValueJson, i.descriptor)) : r.push(void 0) : r.push(Pm(o, i.descriptor));
4650
4740
  }
4651
- let i = await e.handler(...r), a = i, o = km;
4652
- jm(i) && (a = i.value, o = new Uint8Array(i.data));
4653
- let s = wm(a, e.returnType);
4741
+ let i = await e.handler(...r), a = i, o = Bm;
4742
+ Hm(i) && (a = i.value, o = new Uint8Array(i.data));
4743
+ let s = Fm(a, e.returnType);
4654
4744
  this.sendResult(t.CallId, t.InstanceId, n, e, s, o);
4655
4745
  } catch (e) {
4656
- Om.error(`Function ${t.FunctionName} execution failed:`, e), this.sendError(t.CallId, t.InstanceId, n, e instanceof Error ? e : Error(String(e)));
4746
+ zm.error(`Function ${t.FunctionName} execution failed:`, e), this.sendError(t.CallId, t.InstanceId, n, e instanceof Error ? e : Error(String(e)));
4657
4747
  }
4658
4748
  }
4659
4749
  sendAck(e, t, n) {
@@ -4669,7 +4759,7 @@ var Mm = class {
4669
4759
  let o = na(Yi({
4670
4760
  CallId: e,
4671
4761
  InstanceId: t,
4672
- ResultTypeName: Sm(r.returnType),
4762
+ ResultTypeName: Nm(r.returnType),
4673
4763
  ResultJson: i,
4674
4764
  ResultData: a
4675
4765
  }), this.config.sessionId, { targetIds: [n] });
@@ -4686,7 +4776,7 @@ var Mm = class {
4686
4776
  }), this.config.sessionId, { targetIds: [n] });
4687
4777
  this.config.sendProtocolMessage(i);
4688
4778
  }
4689
- }, Nm = S("ReactiveRegistry"), Pm = "Ikon.Reactive.Subscribe", Fm = "Ikon.Reactive.Unsubscribe", Im = {
4779
+ }, Wm = S("ReactiveRegistry"), Gm = "Ikon.Reactive.Subscribe", Km = "Ikon.Reactive.Unsubscribe", qm = {
4690
4780
  name: "Ikon.Reactive.Update",
4691
4781
  description: "Receives reactive value updates pushed from the server when a subscribed reactive changes",
4692
4782
  returnType: { kind: "string" },
@@ -4704,7 +4794,7 @@ var Mm = class {
4704
4794
  type: { kind: "string" }
4705
4795
  }
4706
4796
  ]
4707
- }, Lm = class {
4797
+ }, Jm = class {
4708
4798
  subscribersByKey = /* @__PURE__ */ new Map();
4709
4799
  functionRegistry;
4710
4800
  updateHandlerUnregister = null;
@@ -4712,9 +4802,9 @@ var Mm = class {
4712
4802
  this.functionRegistry = e, this.registerUpdateHandler();
4713
4803
  }
4714
4804
  async subscribe(e, t, n) {
4715
- let r = n?.mount ?? "", i = Rm(e, r), a = t, o = this.subscribersByKey.get(i), s = !o;
4805
+ let r = n?.mount ?? "", i = Ym(e, r), a = t, o = this.subscribersByKey.get(i), s = !o;
4716
4806
  if (o || (o = /* @__PURE__ */ new Set(), this.subscribersByKey.set(i, o)), o.add(a), s) try {
4717
- t(zm(await this.functionRegistry.call(Pm, [e, r])));
4807
+ t(Xm(await this.functionRegistry.call(Gm, [e, r])));
4718
4808
  } catch (e) {
4719
4809
  throw o.delete(a), o.size === 0 && this.subscribersByKey.delete(i), e;
4720
4810
  }
@@ -4726,46 +4816,46 @@ var Mm = class {
4726
4816
  this.subscribersByKey.clear(), this.updateHandlerUnregister &&= (this.updateHandlerUnregister(), null);
4727
4817
  }
4728
4818
  unsubscribeOne(e, t, n) {
4729
- let r = Rm(e, t), i = this.subscribersByKey.get(r);
4730
- i && (i.delete(n), !(i.size > 0) && (this.subscribersByKey.delete(r), this.functionRegistry.call(Fm, [e, t]).catch((n) => {
4731
- Nm.warn(`Failed to unsubscribe from '${e}' (mount='${t}'):`, n);
4819
+ let r = Ym(e, t), i = this.subscribersByKey.get(r);
4820
+ i && (i.delete(n), !(i.size > 0) && (this.subscribersByKey.delete(r), this.functionRegistry.call(Km, [e, t]).catch((n) => {
4821
+ Wm.warn(`Failed to unsubscribe from '${e}' (mount='${t}'):`, n);
4732
4822
  })));
4733
4823
  }
4734
4824
  registerUpdateHandler() {
4735
4825
  let e = (...e) => {
4736
- let t = e[0], n = e[1] ?? "", r = e[2], i = Rm(t, n), a = this.subscribersByKey.get(i);
4826
+ let t = e[0], n = e[1] ?? "", r = e[2], i = Ym(t, n), a = this.subscribersByKey.get(i);
4737
4827
  if (!a || a.size === 0) return "";
4738
- let o = zm(r);
4828
+ let o = Xm(r);
4739
4829
  for (let e of a) try {
4740
4830
  e(o);
4741
4831
  } catch (e) {
4742
- Nm.warn(`Reactive update callback for '${t}' (mount='${n}') threw:`, e);
4832
+ Wm.warn(`Reactive update callback for '${t}' (mount='${n}') threw:`, e);
4743
4833
  }
4744
4834
  return "";
4745
4835
  };
4746
- this.updateHandlerUnregister = this.functionRegistry.register(Im, e);
4836
+ this.updateHandlerUnregister = this.functionRegistry.register(qm, e);
4747
4837
  }
4748
4838
  };
4749
- function Rm(e, t) {
4839
+ function Ym(e, t) {
4750
4840
  return t.length === 0 ? e : `${e}\0${t}`;
4751
4841
  }
4752
- function zm(e) {
4842
+ function Xm(e) {
4753
4843
  if (e == null || e === "") return null;
4754
4844
  try {
4755
4845
  return JSON.parse(e);
4756
4846
  } catch (t) {
4757
- return Nm.warn("Failed to parse reactive value JSON, returning raw string:", t), e;
4847
+ return Wm.warn("Failed to parse reactive value JSON, returning raw string:", t), e;
4758
4848
  }
4759
4849
  }
4760
4850
  //#endregion
4761
4851
  //#region src/login/login-error-interceptor.ts
4762
- var Bm = "login_required", Vm = (e, t) => e.code === Bm ? (od({
4852
+ var Zm = "login_required", Qm = (e, t) => e.code === Zm ? (fd({
4763
4853
  functionName: t.functionName,
4764
4854
  args: t.args
4765
- }), rd(e.message), null) : null;
4855
+ }), ld(e.message), null) : null;
4766
4856
  //#endregion
4767
4857
  //#region src/media/device-detection.ts
4768
- function Hm() {
4858
+ function $m() {
4769
4859
  if (typeof navigator > "u") return !1;
4770
4860
  let e = navigator.userAgentData;
4771
4861
  if (typeof e?.mobile == "boolean") return e.mobile;
@@ -4774,7 +4864,7 @@ function Hm() {
4774
4864
  }
4775
4865
  //#endregion
4776
4866
  //#region src/functions/media-capture-functions.ts
4777
- function Um(e) {
4867
+ function eh(e) {
4778
4868
  let t = e?.facingMode;
4779
4869
  if (typeof t == "string") return t === "user" || t === "environment" ? t : void 0;
4780
4870
  if (Array.isArray(t)) return t.find((e) => typeof e == "string" && (e === "user" || e === "environment")) ?? void 0;
@@ -4784,21 +4874,21 @@ function Um(e) {
4784
4874
  if (Array.isArray(e)) return e.find((e) => e === "user" || e === "environment") ?? void 0;
4785
4875
  }
4786
4876
  }
4787
- function Wm(e) {
4877
+ function th(e) {
4788
4878
  if (!(typeof e != "string" || !e.trim())) try {
4789
4879
  return JSON.parse(e);
4790
4880
  } catch {
4791
4881
  return;
4792
4882
  }
4793
4883
  }
4794
- var Gm = {
4884
+ var nh = {
4795
4885
  StartVideoCapture: "ikon.client.startVideoCapture",
4796
4886
  StartAudioCapture: "ikon.client.startAudioCapture",
4797
4887
  StopCapture: "ikon.client.stopCapture",
4798
4888
  CaptureImage: "ikon.client.captureImage",
4799
4889
  GetMediaDevices: "ikon.client.getMediaDevices"
4800
- }, Km = {
4801
- name: Gm.StartVideoCapture,
4890
+ }, rh = {
4891
+ name: nh.StartVideoCapture,
4802
4892
  description: "Start camera or screen capture and stream video frames to the server",
4803
4893
  returnType: { kind: "string" },
4804
4894
  parameters: [{
@@ -4816,8 +4906,8 @@ var Gm = {
4816
4906
  },
4817
4907
  description: "JSON encoded capture options"
4818
4908
  }]
4819
- }, qm = {
4820
- name: Gm.StartAudioCapture,
4909
+ }, ih = {
4910
+ name: nh.StartAudioCapture,
4821
4911
  description: "Start microphone capture and stream audio frames to the server",
4822
4912
  returnType: { kind: "string" },
4823
4913
  parameters: [{
@@ -4828,8 +4918,8 @@ var Gm = {
4828
4918
  },
4829
4919
  description: "JSON encoded capture options"
4830
4920
  }]
4831
- }, Jm = {
4832
- name: Gm.StopCapture,
4921
+ }, ah = {
4922
+ name: nh.StopCapture,
4833
4923
  description: "Stop a previously started capture by streamId",
4834
4924
  returnType: { kind: "boolean" },
4835
4925
  parameters: [{
@@ -4837,8 +4927,8 @@ var Gm = {
4837
4927
  type: { kind: "string" },
4838
4928
  description: "Stream ID to stop"
4839
4929
  }]
4840
- }, Ym = {
4841
- name: Gm.CaptureImage,
4930
+ }, oh = {
4931
+ name: nh.CaptureImage,
4842
4932
  description: "Capture a single image from the camera and return metadata (JSON) plus binary image data",
4843
4933
  returnType: { kind: "string" },
4844
4934
  parameters: [{
@@ -4849,24 +4939,24 @@ var Gm = {
4849
4939
  },
4850
4940
  description: "JSON encoded capture options"
4851
4941
  }]
4852
- }, Xm = {
4853
- name: Gm.GetMediaDevices,
4942
+ }, sh = {
4943
+ name: nh.GetMediaDevices,
4854
4944
  description: "Get list of available media input devices",
4855
4945
  returnType: { kind: "string" },
4856
4946
  parameters: []
4857
4947
  };
4858
- function Zm(e, t) {
4948
+ function ch(e, t) {
4859
4949
  let n = [];
4860
- return n.push(e.register(Km, async (e, n) => {
4950
+ return n.push(e.register(rh, async (e, n) => {
4861
4951
  if (t.isWebRtcCaptureAvailable) {
4862
4952
  let e = t.webRtcSignaling;
4863
4953
  if (!e) throw Error("WebRTC signaling is not connected");
4864
- let r = Wm(n);
4954
+ let r = th(n);
4865
4955
  return await e.startVideoCapture(r?.constraints), "webrtc-video";
4866
4956
  }
4867
4957
  let r = await t.ensureMediaCapture();
4868
4958
  if (!r) throw Error("Media capture is not available in this environment");
4869
- let i = Wm(n);
4959
+ let i = th(n);
4870
4960
  return ((typeof e == "string" && e.trim().toLowerCase() === "screen" ? "screen" : "camera") == "screen" ? await r.video.startScreen({
4871
4961
  userGesture: !1,
4872
4962
  options: i,
@@ -4876,22 +4966,22 @@ function Zm(e, t) {
4876
4966
  options: i,
4877
4967
  constraints: i?.constraints
4878
4968
  })).streamId;
4879
- })), n.push(e.register(qm, async (e) => {
4969
+ })), n.push(e.register(ih, async (e) => {
4880
4970
  if (t.isWebRtcCaptureAvailable) {
4881
4971
  let n = t.webRtcSignaling;
4882
4972
  if (!n) throw Error("WebRTC signaling is not connected");
4883
- let r = Wm(e);
4973
+ let r = th(e);
4884
4974
  return await n.startAudioCapture(r?.constraints), "webrtc-audio";
4885
4975
  }
4886
4976
  let n = await t.ensureMediaCapture();
4887
4977
  if (!n) throw Error("Media capture is not available in this environment");
4888
- let r = Wm(e);
4978
+ let r = th(e);
4889
4979
  return (await n.audio.startMic({
4890
4980
  userGesture: !1,
4891
4981
  options: r,
4892
4982
  constraints: r?.constraints
4893
4983
  })).streamId;
4894
- })), n.push(e.register(Jm, async (e) => {
4984
+ })), n.push(e.register(ah, async (e) => {
4895
4985
  if (t.isWebRtcCaptureAvailable) {
4896
4986
  let e = t.webRtcSignaling;
4897
4987
  return e && await e.stopCapture(), !0;
@@ -4900,20 +4990,20 @@ function Zm(e, t) {
4900
4990
  if (!n || typeof e != "string" || !e.trim()) return !1;
4901
4991
  let r = await n.video.stop(e), i = await n.audio.stop(e);
4902
4992
  return r || i;
4903
- })), n.push(e.register(Ym, async (e) => {
4993
+ })), n.push(e.register(oh, async (e) => {
4904
4994
  let n = await t.ensureMediaCapture();
4905
4995
  if (!n) throw Error("Media capture is not available in this environment");
4906
- let r = Wm(e) ?? {};
4907
- if (r.mode === "native" && Hm()) {
4996
+ let r = th(e) ?? {};
4997
+ if (r.mode === "native" && $m()) {
4908
4998
  let e = await n.image.captureFromNativeCamera({
4909
- facing: Um(r.constraints),
4999
+ facing: eh(r.constraints),
4910
5000
  mime: r.mime,
4911
5001
  quality: r.quality,
4912
5002
  width: r.width,
4913
5003
  height: r.height
4914
5004
  });
4915
5005
  if (!e) throw Error("Native camera capture was cancelled");
4916
- return Em(JSON.stringify({
5006
+ return Lm(JSON.stringify({
4917
5007
  mime: e.mime,
4918
5008
  width: e.width,
4919
5009
  height: e.height
@@ -4934,12 +5024,12 @@ function Zm(e, t) {
4934
5024
  quality: r.quality,
4935
5025
  width: r.width,
4936
5026
  height: r.height
4937
- }), Em(JSON.stringify({
5027
+ }), Lm(JSON.stringify({
4938
5028
  mime: a.mime,
4939
5029
  width: a.width,
4940
5030
  height: a.height
4941
5031
  }), a.data);
4942
- })), n.push(e.register(Xm, async () => {
5032
+ })), n.push(e.register(sh, async () => {
4943
5033
  if (!navigator.mediaDevices || !navigator.mediaDevices.enumerateDevices) return JSON.stringify([]);
4944
5034
  let e = (await navigator.mediaDevices.enumerateDevices()).filter((e) => e.kind === "audioinput" || e.kind === "videoinput").map((e) => ({
4945
5035
  deviceId: e.deviceId,
@@ -4954,45 +5044,45 @@ function Zm(e, t) {
4954
5044
  }
4955
5045
  //#endregion
4956
5046
  //#region src/functions/sound-functions.ts
4957
- var Qm = {
5047
+ var lh = {
4958
5048
  PlaySound: "ikon.client.playSound",
4959
5049
  StopSound: "ikon.client.stopSound"
4960
- }, $m = /* @__PURE__ */ new Map(), q = /* @__PURE__ */ new Map(), eh = 1, th = "data:audio/wav;base64,UklGRjIAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQYAAAAAAAAAAAA=", nh = 8, rh = [], ih = !1, J = null;
4961
- function ah() {
4962
- if (!(rh.length > 0 || typeof Audio > "u")) for (let e = 0; e < nh; e++) {
5050
+ }, uh = /* @__PURE__ */ new Map(), dh = /* @__PURE__ */ new Map(), fh = 1, ph = "data:audio/wav;base64,UklGRjIAAABXQVZFZm10IBAAAAABAAEAQB8AAEAfAAABAAgAZGF0YQYAAAAAAAAAAAA=", mh = 8, hh = [], gh = !1, q = null;
5051
+ function _h() {
5052
+ if (!(hh.length > 0 || typeof Audio > "u")) for (let e = 0; e < mh; e++) {
4963
5053
  let e = new Audio();
4964
- e.preload = "auto", rh.push(e);
5054
+ e.preload = "auto", hh.push(e);
4965
5055
  }
4966
5056
  }
4967
- function oh() {
4968
- if (!ih) {
4969
- ah();
4970
- for (let e of rh) try {
4971
- e.src = th;
5057
+ function vh() {
5058
+ if (!gh) {
5059
+ _h();
5060
+ for (let e of hh) try {
5061
+ e.src = ph;
4972
5062
  let t = e.play();
4973
5063
  typeof t?.then == "function" ? t.then(() => {
4974
- e.pause(), e.currentTime = 0, ih = !0, ch();
4975
- }, () => {}) : ih = !0;
5064
+ e.pause(), e.currentTime = 0, gh = !0, bh();
5065
+ }, () => {}) : gh = !0;
4976
5066
  } catch {}
4977
- ih && ch();
5067
+ gh && bh();
4978
5068
  }
4979
5069
  }
4980
- function sh() {
4981
- if (J || typeof window > "u") return;
4982
- let e = () => oh();
4983
- J = e, window.addEventListener("pointerdown", e, { capture: !0 }), window.addEventListener("touchend", e, { capture: !0 }), window.addEventListener("mousedown", e, { capture: !0 }), window.addEventListener("keydown", e, { capture: !0 });
5070
+ function yh() {
5071
+ if (q || typeof window > "u") return;
5072
+ let e = () => vh();
5073
+ q = e, window.addEventListener("pointerdown", e, { capture: !0 }), window.addEventListener("touchend", e, { capture: !0 }), window.addEventListener("mousedown", e, { capture: !0 }), window.addEventListener("keydown", e, { capture: !0 });
4984
5074
  }
4985
- function ch() {
4986
- !J || typeof window > "u" || (window.removeEventListener("pointerdown", J, { capture: !0 }), window.removeEventListener("touchend", J, { capture: !0 }), window.removeEventListener("mousedown", J, { capture: !0 }), window.removeEventListener("keydown", J, { capture: !0 }), J = null);
5075
+ function bh() {
5076
+ !q || typeof window > "u" || (window.removeEventListener("pointerdown", q, { capture: !0 }), window.removeEventListener("touchend", q, { capture: !0 }), window.removeEventListener("mousedown", q, { capture: !0 }), window.removeEventListener("keydown", q, { capture: !0 }), q = null);
4987
5077
  }
4988
- function lh() {
4989
- ah();
4990
- for (let e of rh) if (e.paused || e.ended) return e;
5078
+ function xh() {
5079
+ _h();
5080
+ for (let e of hh) if (e.paused || e.ended) return e;
4991
5081
  let e = new Audio();
4992
- return e.preload = "auto", rh.push(e), e;
5082
+ return e.preload = "auto", hh.push(e), e;
4993
5083
  }
4994
- var uh = {
4995
- name: Qm.PlaySound,
5084
+ var Sh = {
5085
+ name: lh.PlaySound,
4996
5086
  description: "Play a sound effect",
4997
5087
  returnType: {
4998
5088
  kind: "string",
@@ -5030,22 +5120,22 @@ var uh = {
5030
5120
  }
5031
5121
  ]
5032
5122
  };
5033
- function dh(e, t, n, r) {
5123
+ function Ch(e, t, n, r) {
5034
5124
  if (typeof window > "u" || typeof Audio > "u" || typeof e != "string" || !e.trim()) return Promise.resolve(null);
5035
5125
  let i = e;
5036
- if (typeof t == "string" && t && $m.set(t, e), e.startsWith("sound:")) {
5037
- let t = e.slice(6), n = $m.get(t);
5126
+ if (typeof t == "string" && t && uh.set(t, e), e.startsWith("sound:")) {
5127
+ let t = e.slice(6), n = uh.get(t);
5038
5128
  if (!n) return Promise.resolve(null);
5039
5129
  i = n;
5040
5130
  }
5041
5131
  return new Promise((e) => {
5042
5132
  try {
5043
- let t = lh();
5133
+ let t = xh();
5044
5134
  t.src = i, t.currentTime = 0, t.loop = r === !0, t.volume = typeof n == "number" ? Math.max(0, Math.min(1, n)) : 1;
5045
- let a = `sound-${eh++}`, o = () => {
5046
- q.delete(a), t.removeEventListener("ended", o), t.removeEventListener("error", o);
5135
+ let a = `sound-${fh++}`, o = () => {
5136
+ dh.delete(a), t.removeEventListener("ended", o), t.removeEventListener("error", o);
5047
5137
  };
5048
- t.addEventListener("ended", o), t.addEventListener("error", o), q.set(a, t), t.play().then(() => e(a), () => {
5138
+ t.addEventListener("ended", o), t.addEventListener("error", o), dh.set(a, t), t.play().then(() => e(a), () => {
5049
5139
  o(), e(null);
5050
5140
  });
5051
5141
  } catch {
@@ -5053,8 +5143,8 @@ function dh(e, t, n, r) {
5053
5143
  }
5054
5144
  });
5055
5145
  }
5056
- var fh = {
5057
- name: Qm.StopSound,
5146
+ var wh = {
5147
+ name: lh.StopSound,
5058
5148
  description: "Stop a playing sound by ID",
5059
5149
  returnType: { kind: "boolean" },
5060
5150
  parameters: [{
@@ -5063,51 +5153,51 @@ var fh = {
5063
5153
  description: "Playback ID from playSound"
5064
5154
  }]
5065
5155
  };
5066
- function ph(e) {
5156
+ function Th(e) {
5067
5157
  if (typeof e != "string") return !1;
5068
- let t = q.get(e);
5158
+ let t = dh.get(e);
5069
5159
  if (!t) return !1;
5070
5160
  try {
5071
- return t.pause(), t.currentTime = 0, q.delete(e), !0;
5161
+ return t.pause(), t.currentTime = 0, dh.delete(e), !0;
5072
5162
  } catch {
5073
5163
  return !1;
5074
5164
  }
5075
5165
  }
5076
- function mh() {
5077
- $m.clear();
5078
- for (let [e, t] of q) {
5166
+ function Eh() {
5167
+ uh.clear();
5168
+ for (let [e, t] of dh) {
5079
5169
  try {
5080
5170
  t.pause(), t.currentTime = 0;
5081
5171
  } catch {}
5082
- q.delete(e);
5172
+ dh.delete(e);
5083
5173
  }
5084
- ch();
5174
+ bh();
5085
5175
  }
5086
- var hh = [{
5087
- definition: uh,
5088
- handler: dh
5176
+ var Dh = [{
5177
+ definition: Sh,
5178
+ handler: Ch
5089
5179
  }, {
5090
- definition: fh,
5091
- handler: ph
5180
+ definition: wh,
5181
+ handler: Th
5092
5182
  }];
5093
- function gh(e) {
5094
- sh();
5095
- let t = hh.map(({ definition: t, handler: n }) => e.register(t, n));
5183
+ function Oh(e) {
5184
+ yh();
5185
+ let t = Dh.map(({ definition: t, handler: n }) => e.register(t, n));
5096
5186
  return () => {
5097
- t.forEach((e) => e()), mh();
5187
+ t.forEach((e) => e()), Eh();
5098
5188
  };
5099
5189
  }
5100
5190
  //#endregion
5101
5191
  //#region src/worker/viseme-worker.ts?worker
5102
- function _h(e) {
5103
- return new Worker("" + new URL("assets/viseme-worker-DoO4M4Te.js", import.meta.url).href, {
5192
+ function kh(e) {
5193
+ return new Worker("" + new URL("assets/viseme-worker-DFgMth_1.js", import.meta.url).href, {
5104
5194
  type: "module",
5105
5195
  name: e?.name
5106
5196
  });
5107
5197
  }
5108
5198
  //#endregion
5109
5199
  //#region src/media/viseme-tracker.ts
5110
- var vh = S("VisemeTracker"), yh = _e * 2, bh = class e {
5200
+ var Ah = S("VisemeTracker"), jh = _e * 2, Mh = class e {
5111
5201
  static MAX_WORKER_REBUILD_ATTEMPTS = 3;
5112
5202
  client;
5113
5203
  worker = null;
@@ -5127,16 +5217,16 @@ var vh = S("VisemeTracker"), yh = _e * 2, bh = class e {
5127
5217
  enable() {
5128
5218
  if (this.worker) return;
5129
5219
  if (typeof Worker > "u") {
5130
- vh.warn("Viseme worker unavailable (Workers not supported)");
5220
+ Ah.warn("Viseme worker unavailable (Workers not supported)");
5131
5221
  return;
5132
5222
  }
5133
5223
  let t = this.client.createProtocolMessagePort({ opcodeGroupsMask: C.GROUP_AUDIO });
5134
5224
  if (!t) return;
5135
5225
  this.protocolPort = t;
5136
5226
  try {
5137
- this.worker = new _h();
5227
+ this.worker = new kh();
5138
5228
  } catch (e) {
5139
- vh.warn(`Failed to create viseme worker: ${e}`), this.protocolPort.close(), this.protocolPort = null;
5229
+ Ah.warn(`Failed to create viseme worker: ${e}`), this.protocolPort.close(), this.protocolPort = null;
5140
5230
  return;
5141
5231
  }
5142
5232
  let n = this.worker;
@@ -5147,7 +5237,7 @@ var vh = S("VisemeTracker"), yh = _e * 2, bh = class e {
5147
5237
  t.lineno,
5148
5238
  t.colno
5149
5239
  ].filter((e) => e != null && String(e).length > 0);
5150
- vh.error(`Viseme worker failed: ${n.join(" ")}`.trim()), this.dispose(), this.workerRebuildAttempts < e.MAX_WORKER_REBUILD_ATTEMPTS ? (this.workerRebuildAttempts++, this.enable()) : vh.error("Viseme worker crashed repeatedly, giving up on rebuilds");
5240
+ Ah.error(`Viseme worker failed: ${n.join(" ")}`.trim()), this.dispose(), this.workerRebuildAttempts < e.MAX_WORKER_REBUILD_ATTEMPTS ? (this.workerRebuildAttempts++, this.enable()) : Ah.error("Viseme worker crashed repeatedly, giving up on rebuilds");
5151
5241
  }), n.postMessage({
5152
5242
  type: "attachProtocolPort",
5153
5243
  port: t.port
@@ -5202,7 +5292,7 @@ var vh = S("VisemeTracker"), yh = _e * 2, bh = class e {
5202
5292
  if (!t.timingEstablished || t.count === 0) continue;
5203
5293
  let n = e - t.playbackStartTime;
5204
5294
  if (n < 0) continue;
5205
- let r = n * yh, i = t.frames, a = t.count, o = (t.head - a + ve) % ve, s = null, c = null;
5295
+ let r = n * jh, i = t.frames, a = t.count, o = (t.head - a + ve) % ve, s = null, c = null;
5206
5296
  for (let e = 0; e < a; e++) {
5207
5297
  let t = i[(o + e) % ve], n = t.samplePosition + Math.max(t.frameSamples, 1);
5208
5298
  if (t.samplePosition <= r && (s = t), n > r && !c && (c = t, t.samplePosition <= r)) break;
@@ -5276,35 +5366,35 @@ var vh = S("VisemeTracker"), yh = _e * 2, bh = class e {
5276
5366
  }
5277
5367
  }
5278
5368
  }
5279
- }, xh = S("DebugMode"), Y = !1;
5280
- function Sh() {
5281
- return Y ? !0 : (Y = au(), Y && (be(x.DEBUG), xh.info("Debug mode enabled")), Y);
5369
+ }, Nh = S("DebugMode"), J = !1;
5370
+ function Ph() {
5371
+ return J ? !0 : (J = ou(), J && (be(x.DEBUG), Nh.info("Debug mode enabled")), J);
5282
5372
  }
5283
- function Ch() {
5284
- return Y;
5373
+ function Fh() {
5374
+ return J;
5285
5375
  }
5286
- function wh() {
5287
- Y || (Y = !0, be(x.DEBUG), xh.info("Debug mode enabled"), tu(Vl, "true"));
5376
+ function Ih() {
5377
+ J || (J = !0, be(x.DEBUG), Nh.info("Debug mode enabled"), nu(Vl, "true"));
5288
5378
  }
5289
5379
  //#endregion
5290
5380
  //#region src/utils/inspect-mode.ts
5291
- var Th = "ikon-inspect-mode-changed", Eh = !1;
5292
- function Dh() {
5293
- typeof window < "u" && window.dispatchEvent(new Event(Th));
5381
+ var Lh = "ikon-inspect-mode-changed", Y = !1;
5382
+ function Rh() {
5383
+ typeof window < "u" && window.dispatchEvent(new Event(Lh));
5294
5384
  }
5295
- function Oh() {
5296
- let e = fu();
5297
- return e !== Eh && (Eh = e, Dh()), Eh;
5385
+ function zh() {
5386
+ let e = pu();
5387
+ return e !== Y && (Y = e, Rh()), Y;
5298
5388
  }
5299
- function kh() {
5300
- return Eh;
5389
+ function Bh() {
5390
+ return Y;
5301
5391
  }
5302
- function Ah() {
5303
- Eh || (Eh = !0, tu(Jl, "true"), Dh());
5392
+ function Vh() {
5393
+ Y || (Y = !0, nu(Jl, "true"), Rh());
5304
5394
  }
5305
5395
  //#endregion
5306
5396
  //#region src/utils/external-link.ts
5307
- var jh = /* @__PURE__ */ new Set([
5397
+ var Hh = /* @__PURE__ */ new Set([
5308
5398
  "http",
5309
5399
  "https",
5310
5400
  "file",
@@ -5321,12 +5411,12 @@ var jh = /* @__PURE__ */ new Set([
5321
5411
  "edge",
5322
5412
  "moz-extension",
5323
5413
  "safari-web-extension"
5324
- ]), Mh = /^([a-z][a-z0-9+.-]*):/i;
5325
- function Nh(e) {
5326
- let t = Mh.exec(e.trim());
5327
- return t ? !jh.has(t[1].toLowerCase()) : !1;
5414
+ ]), Uh = /^([a-z][a-z0-9+.-]*):/i;
5415
+ function Wh(e) {
5416
+ let t = Uh.exec(e.trim());
5417
+ return t ? !Hh.has(t[1].toLowerCase()) : !1;
5328
5418
  }
5329
- function Ph(e) {
5419
+ function Gh(e) {
5330
5420
  if (typeof document > "u") return;
5331
5421
  let t = document.createElement("iframe");
5332
5422
  t.setAttribute("aria-hidden", "true"), t.style.display = "none", document.body.appendChild(t);
@@ -5340,7 +5430,7 @@ function Ph(e) {
5340
5430
  }
5341
5431
  //#endregion
5342
5432
  //#region src/utils/browser-support.ts
5343
- var Fh = [
5433
+ var Kh = [
5344
5434
  {
5345
5435
  name: "WebSocket",
5346
5436
  isPresent: () => typeof WebSocket < "u"
@@ -5362,9 +5452,9 @@ var Fh = [
5362
5452
  isPresent: () => typeof Promise < "u" && typeof Promise.allSettled == "function"
5363
5453
  }
5364
5454
  ];
5365
- function Ih() {
5455
+ function qh() {
5366
5456
  let e = [];
5367
- for (let t of Fh) {
5457
+ for (let t of Kh) {
5368
5458
  let n;
5369
5459
  try {
5370
5460
  n = t.isPresent();
@@ -5379,21 +5469,69 @@ function Ih() {
5379
5469
  };
5380
5470
  }
5381
5471
  //#endregion
5472
+ //#region src/transport/transport-probe.ts
5473
+ var Jh = S("TransportProbe"), Yh = 3e3;
5474
+ async function Xh(e, t, n) {
5475
+ let r = n?.timeoutMs ?? Yh, i = n?.signal;
5476
+ if (i?.aborted) return !1;
5477
+ let a = Date.now();
5478
+ try {
5479
+ let n = Zh(e) ? await $h(t, r, i) : await Qh(t, r, i);
5480
+ return Jh.debug(`Probe ${b[e]} ${t}: ${n ? "reachable" : "unreachable"} in ${Date.now() - a}ms`), n;
5481
+ } catch (n) {
5482
+ return Jh.debug(`Probe ${b[e]} ${t} failed after ${Date.now() - a}ms: ${n instanceof Error ? n.message : n}`), !1;
5483
+ }
5484
+ }
5485
+ function Zh(e) {
5486
+ return e === b.WebTransport || e === b.WebTransportProxy;
5487
+ }
5488
+ function Qh(e, t, n) {
5489
+ return typeof WebSocket > "u" ? Promise.resolve(!1) : new Promise((r) => {
5490
+ let i = new WebSocket(e), a = !1, o = (e) => {
5491
+ if (!a) {
5492
+ a = !0, clearTimeout(c), n?.removeEventListener("abort", s), i.onopen = null, i.onerror = null, i.onclose = null;
5493
+ try {
5494
+ i.close();
5495
+ } catch {}
5496
+ r(e);
5497
+ }
5498
+ }, s = () => o(!1), c = setTimeout(() => o(!1), t);
5499
+ n?.addEventListener("abort", s, { once: !0 }), i.onopen = () => o(!0), i.onerror = () => o(!1), i.onclose = () => o(!1);
5500
+ });
5501
+ }
5502
+ async function $h(e, t, n) {
5503
+ if (!wu()) return !1;
5504
+ let r = new WebTransport(e), i;
5505
+ try {
5506
+ let e = new Promise((e, r) => {
5507
+ i = setTimeout(() => r(/* @__PURE__ */ Error("probe timeout")), t), n?.addEventListener("abort", () => r(/* @__PURE__ */ Error("probe aborted")), { once: !0 });
5508
+ });
5509
+ return await Promise.race([r.ready, e]), !0;
5510
+ } catch {
5511
+ return !1;
5512
+ } finally {
5513
+ clearTimeout(i);
5514
+ try {
5515
+ r.close();
5516
+ } catch {}
5517
+ }
5518
+ }
5519
+ //#endregion
5382
5520
  //#region src/worker/protocol-worker.ts?worker
5383
- function Lh(e) {
5384
- return new Worker("" + new URL("assets/protocol-worker-DwwqSFAV.js", import.meta.url).href, {
5521
+ function eg(e) {
5522
+ return new Worker("" + new URL("assets/protocol-worker-G-c3_38g.js", import.meta.url).href, {
5385
5523
  type: "module",
5386
5524
  name: e?.name
5387
5525
  });
5388
5526
  }
5389
5527
  //#endregion
5390
5528
  //#region src/client/endpoint-selector.ts
5391
- var Rh = {
5529
+ var tg = {
5392
5530
  [b.WebTransport]: 0,
5393
5531
  [b.WebSocket]: 1,
5394
5532
  [b.WebTransportProxy]: 2,
5395
5533
  [b.WebSocketProxy]: 3
5396
- }, zh = /* @__PURE__ */ new Set([b.WebTransportProxy, b.WebSocketProxy]), Bh = /* @__PURE__ */ new Set([b.WebTransport, b.WebSocket]), Vh = /* @__PURE__ */ new Set([b.WebSocket, b.WebSocketProxy]), Hh = /* @__PURE__ */ new Set([b.WebTransport, b.WebTransportProxy]), Uh = S("EndpointSelector"), Wh = "ikon-endpoint-type", X = "ikon-proxy-preferred", Gh = "ikon-endpoint-timestamp", Kh = 864e5, qh = class {
5534
+ }, ng = /* @__PURE__ */ new Set([b.WebTransportProxy, b.WebSocketProxy]), rg = /* @__PURE__ */ new Set([b.WebTransport, b.WebSocket]), ig = /* @__PURE__ */ new Set([b.WebSocket, b.WebSocketProxy]), ag = /* @__PURE__ */ new Set([b.WebTransport, b.WebTransportProxy]), X = S("EndpointSelector"), og = "ikon-endpoint-type", sg = "ikon-proxy-preferred", cg = "ikon-endpoint-timestamp", lg = "ikon-endpoint-revalidated", ug = 864e5, dg = class {
5397
5535
  isLocal;
5398
5536
  _proxyMode;
5399
5537
  _websocket;
@@ -5409,34 +5547,37 @@ var Rh = {
5409
5547
  get proxyPreferred() {
5410
5548
  return this._proxyPreferred;
5411
5549
  }
5550
+ get rememberedType() {
5551
+ return this.workingEndpointType;
5552
+ }
5412
5553
  markProxyPreferred() {
5413
5554
  this._proxyPreferred = !0;
5414
5555
  try {
5415
- localStorage.setItem(X, "true"), localStorage.setItem(Gh, String(Date.now()));
5556
+ localStorage.setItem(sg, "true"), localStorage.setItem(cg, String(Date.now()));
5416
5557
  } catch {}
5417
- Uh.debug("Marked proxy as preferred");
5558
+ X.debug("Marked proxy as preferred");
5418
5559
  }
5419
5560
  clearProxyPreference() {
5420
5561
  this._proxyPreferred = !1;
5421
5562
  try {
5422
- localStorage.removeItem(X);
5563
+ localStorage.removeItem(sg);
5423
5564
  } catch {}
5424
5565
  }
5425
5566
  getOrderedTypes(e) {
5426
5567
  let t = Array.from(e.keys());
5427
5568
  if (this.isLocal) return t;
5428
5569
  let n;
5429
- n = this._proxyMode === "force-proxy" ? t.filter((e) => zh.has(e)) : this._proxyMode === "force-direct" ? t.filter((e) => Bh.has(e)) : t, n = this.filterByTransport(n);
5430
- let r = [...n].sort((e, t) => (Rh[e] ?? 999) - (Rh[t] ?? 999));
5570
+ n = this._proxyMode === "force-proxy" ? t.filter((e) => ng.has(e)) : this._proxyMode === "force-direct" ? t.filter((e) => rg.has(e)) : t, n = this.filterByTransport(n);
5571
+ let r = [...n].sort((e, t) => (tg[e] ?? 999) - (tg[t] ?? 999));
5431
5572
  if (this._proxyMode === "auto" && this._proxyPreferred) {
5432
- let e = r.filter((e) => zh.has(e)), t = r.filter((e) => Bh.has(e));
5573
+ let e = r.filter((e) => ng.has(e)), t = r.filter((e) => rg.has(e));
5433
5574
  r.length = 0, r.push(...e, ...t);
5434
5575
  }
5435
- if (this.workingEndpointType !== null && e.has(this.workingEndpointType) && (!this._proxyPreferred || zh.has(this.workingEndpointType))) {
5576
+ if (this.workingEndpointType !== null && e.has(this.workingEndpointType) && (!this._proxyPreferred || ng.has(this.workingEndpointType))) {
5436
5577
  let e = r.indexOf(this.workingEndpointType);
5437
5578
  e > 0 && (r.splice(e, 1), r.unshift(this.workingEndpointType));
5438
5579
  }
5439
- return Uh.debug(`Ordered types: [${r.map((e) => b[e]).join(", ")}] (remembered: ${this.workingEndpointType === null ? "none" : b[this.workingEndpointType]}, proxyPreferred: ${this._proxyPreferred})`), r;
5580
+ return X.debug(`Ordered types: [${r.map((e) => b[e]).join(", ")}] (remembered: ${this.workingEndpointType === null ? "none" : b[this.workingEndpointType]}, proxyPreferred: ${this._proxyPreferred})`), r;
5440
5581
  }
5441
5582
  rememberWorkingType(e) {
5442
5583
  if (!this.isLocal) {
@@ -5446,65 +5587,86 @@ var Rh = {
5446
5587
  }
5447
5588
  this.workingEndpointType = e;
5448
5589
  try {
5449
- localStorage.setItem(Wh, String(e)), localStorage.setItem(Gh, String(Date.now()));
5590
+ localStorage.setItem(og, String(e)), localStorage.setItem(cg, String(Date.now())), localStorage.getItem(lg) === null && localStorage.setItem(lg, String(Date.now()));
5450
5591
  } catch {}
5451
- if (zh.has(e)) {
5592
+ if (ng.has(e)) {
5452
5593
  this._proxyPreferred = !0;
5453
5594
  try {
5454
- localStorage.setItem(X, "true");
5595
+ localStorage.setItem(sg, "true");
5455
5596
  } catch {}
5456
- } else if (Bh.has(e)) {
5597
+ } else if (rg.has(e)) {
5457
5598
  this._proxyPreferred = !1;
5458
5599
  try {
5459
- localStorage.removeItem(X);
5600
+ localStorage.removeItem(sg);
5460
5601
  } catch {}
5461
5602
  }
5462
- Uh.debug(`Remembered working type: ${b[e]}`);
5603
+ X.debug(`Remembered working type: ${b[e]}`);
5463
5604
  }
5464
5605
  }
5465
5606
  clearRememberedType() {
5466
5607
  this.workingEndpointType = null;
5467
5608
  try {
5468
- localStorage.removeItem(Wh);
5609
+ localStorage.removeItem(og);
5610
+ } catch {}
5611
+ }
5612
+ needsRevalidation() {
5613
+ if (this.isLocal || this._proxyMode !== "auto" || this.workingEndpointType === null && !this._proxyPreferred) return !1;
5614
+ let e = this.revalidationAgeMs();
5615
+ return e !== null && e > ug;
5616
+ }
5617
+ getFasterTypes(e, t) {
5618
+ let n = tg[e] ?? 999;
5619
+ return this.filterByTransport(Array.from(t.keys())).filter((e) => (tg[e] ?? 999) < n).sort((e, t) => (tg[e] ?? 999) - (tg[t] ?? 999));
5620
+ }
5621
+ recordFasterTypeReachable(e) {
5622
+ X.debug(`Faster endpoint type ${b[e]} is reachable again, dropping learned preference`), this.clearRememberedType(), this.clearProxyPreference();
5623
+ try {
5624
+ localStorage.removeItem(cg), localStorage.removeItem(lg);
5469
5625
  } catch {}
5470
5626
  }
5627
+ recordFasterTypesUnreachable() {
5628
+ try {
5629
+ localStorage.setItem(lg, String(Date.now()));
5630
+ } catch {}
5631
+ X.debug("Faster endpoint types still unreachable, keeping the learned preference");
5632
+ }
5471
5633
  filterByTransport(e) {
5472
5634
  let t = this._websocket, n = this._webtransport;
5473
- return t === void 0 && n === void 0 || t === !0 && n === !0 ? e : e.filter((e) => t === !0 && n === void 0 ? Vh.has(e) : n === !0 && t === void 0 ? Hh.has(e) : t === !1 ? !Vh.has(e) : n !== !1 || !Hh.has(e));
5635
+ return t === void 0 && n === void 0 || t === !0 && n === !0 ? e : e.filter((e) => t === !0 && n === void 0 ? ig.has(e) : n === !0 && t === void 0 ? ag.has(e) : t === !1 ? !ig.has(e) : n !== !1 || !ag.has(e));
5474
5636
  }
5475
- checkPreferenceExpiry() {
5637
+ revalidationAgeMs() {
5476
5638
  try {
5477
- let e = localStorage.getItem(Gh);
5478
- if (e !== null) {
5479
- let t = Date.now() - Number(e);
5480
- if (t > Kh) return Uh.warn(`Preferences expired (age: ${Math.round(t / 36e5)}h), clearing`), localStorage.removeItem(Wh), localStorage.removeItem(X), localStorage.removeItem(Gh), !0;
5481
- }
5482
- } catch {}
5483
- return !1;
5639
+ let e = localStorage.getItem(lg);
5640
+ if (e === null) return null;
5641
+ let t = Date.now() - Number(e);
5642
+ return Number.isFinite(t) ? t : null;
5643
+ } catch {
5644
+ return null;
5645
+ }
5484
5646
  }
5485
5647
  loadRememberedType() {
5486
- if (!this.checkPreferenceExpiry()) try {
5487
- let e = localStorage.getItem(Wh);
5648
+ try {
5649
+ let e = localStorage.getItem(og);
5488
5650
  if (e !== null) {
5489
5651
  let t = Number(e);
5490
5652
  if (b[t] !== void 0) {
5491
5653
  this.workingEndpointType = t;
5492
- let e = localStorage.getItem(Gh), n = e ? Math.round((Date.now() - Number(e)) / 36e5) : "?";
5493
- Uh.debug(`Loaded remembered type: ${b[t]} (age: ${n}h)`);
5654
+ let e = localStorage.getItem(cg), n = e ? Math.round((Date.now() - Number(e)) / 36e5) : "?";
5655
+ X.debug(`Loaded remembered type: ${b[t]} (age: ${n}h)`);
5494
5656
  }
5495
5657
  }
5496
5658
  } catch {}
5497
5659
  }
5498
5660
  loadProxyPreference() {
5499
5661
  try {
5500
- this._proxyPreferred = localStorage.getItem(X) === "true", this._proxyPreferred && Uh.debug("Loaded proxy preference: preferred");
5662
+ this._proxyPreferred = localStorage.getItem(sg) === "true", this._proxyPreferred && X.debug("Loaded proxy preference: preferred");
5501
5663
  } catch {}
5502
5664
  }
5503
- }, Z = S("IkonClient"), Jh = [1e4, 3e4];
5504
- function Yh() {
5665
+ }, Z = S("IkonClient"), fg = [1e4, 3e4];
5666
+ function pg() {
5505
5667
  return typeof __IKON_WAIT_FOR_EXTERNAL_CONNECT_URL__ < "u" && __IKON_WAIT_FOR_EXTERNAL_CONNECT_URL__;
5506
5668
  }
5507
- var Xh = class {
5669
+ var mg = class {
5508
5670
  channelManager = null;
5509
5671
  protocolWorker = null;
5510
5672
  preloadedWorker = null;
@@ -5532,6 +5694,9 @@ var Xh = class {
5532
5694
  _actionIdByCallId = /* @__PURE__ */ new Map();
5533
5695
  _pendingActionResults = /* @__PURE__ */ new Map();
5534
5696
  endpointSelector;
5697
+ _webRtcReachability = new $u();
5698
+ _connectedEntrypoints = [];
5699
+ _revalidationDone = !1;
5535
5700
  _isUnloading = !1;
5536
5701
  boundBeforeUnload = null;
5537
5702
  boundPageHide = null;
@@ -5539,7 +5704,7 @@ var Xh = class {
5539
5704
  boundPopstate = null;
5540
5705
  boundOnline = null;
5541
5706
  boundOffline = null;
5542
- boundExternalLinkClick = null;
5707
+ boundAnchorClick = null;
5543
5708
  _globalState = null;
5544
5709
  _globalStateReceived = !1;
5545
5710
  _channelsConnected = !1;
@@ -5581,7 +5746,7 @@ var Xh = class {
5581
5746
  _reconnectTimer = null;
5582
5747
  _serverStopped = !1;
5583
5748
  _hasBeenConnected = !1;
5584
- _waitForExternalConnectUrl = Yh();
5749
+ _waitForExternalConnectUrl = pg();
5585
5750
  _externalConnectUrlCleanup = null;
5586
5751
  get media() {
5587
5752
  return this._media;
@@ -5598,10 +5763,10 @@ var Xh = class {
5598
5763
  return this._mediaCapture;
5599
5764
  }
5600
5765
  async ensureMediaCapture() {
5601
- return this._mediaCapture ? this._mediaCapture : R() ? (this._mediaCapturePromise ||= Promise.resolve().then(() => Ag).then(({ IkonMediaCapture: e }) => (this._mediaCapture = new e(this, this._mediaCaptureConfig), this._mediaCapture)), this._mediaCapturePromise) : null;
5766
+ return this._mediaCapture ? this._mediaCapture : R() ? (this._mediaCapturePromise ||= Promise.resolve().then(() => Jg).then(({ IkonMediaCapture: e }) => (this._mediaCapture = new e(this, this._mediaCaptureConfig), this._mediaCapture)), this._mediaCapturePromise) : null;
5602
5767
  }
5603
5768
  async ensureMedia() {
5604
- return this._media ? this._media : (this._mediaPromise ||= import("./ikon-media-DuCadOIe.js").then((e) => e.n).then(({ IkonMedia: e }) => (this._media = new e(this, this._mediaConfig), this._media)), this._mediaPromise);
5769
+ return this._media ? this._media : (this._mediaPromise ||= import("./ikon-media-ZZqVys00.js").then((e) => e.n).then(({ IkonMedia: e }) => (this._media = new e(this, this._mediaConfig), this._media)), this._mediaPromise);
5605
5770
  }
5606
5771
  get isAudioEnabled() {
5607
5772
  return this._audioEnabled;
@@ -5610,7 +5775,7 @@ var Xh = class {
5610
5775
  return this._videoEnabled;
5611
5776
  }
5612
5777
  get isWebRtcEnabled() {
5613
- return (uu() ?? this.config.webRtc?.enabled ?? !0) && (this._audioEnabled || this._videoEnabled);
5778
+ return (du() ?? this.config.webRtc?.enabled ?? !0) && (this._audioEnabled || this._videoEnabled);
5614
5779
  }
5615
5780
  get isWebRtcMediaActive() {
5616
5781
  return this.isWebRtcEnabled && !this._webRtcFallbackActive;
@@ -5644,15 +5809,15 @@ var Xh = class {
5644
5809
  ].filter(Boolean).length;
5645
5810
  if (t === 0) throw Error("IkonClient requires one of: \"local\", \"apiKey\", or \"sessionToken\" configuration");
5646
5811
  if (t > 1) throw Error("IkonClient accepts only one of: \"local\", \"apiKey\", or \"sessionToken\" configuration");
5647
- Sh(), R() && Ud();
5648
- let n = e.local ? null : nu() ?? e.proxy ?? null, r = n === !0 ? "force-proxy" : n === !1 ? "force-direct" : "auto", i = e.local ? null : ru(), a = e.local ? null : iu(), o = i ?? e.websocket, s = a ?? e.webtransport ?? !1;
5649
- this.endpointSelector = new qh({
5812
+ Ph(), R() && Zd();
5813
+ let n = e.local ? null : ru() ?? e.proxy ?? null, r = n === !0 ? "force-proxy" : n === !1 ? "force-direct" : "auto", i = e.local ? null : iu(), a = e.local ? null : au(), o = i ?? e.websocket, s = a ?? e.webtransport ?? !1;
5814
+ this.endpointSelector = new dg({
5650
5815
  local: e.local,
5651
5816
  proxyMode: r,
5652
5817
  websocket: o,
5653
5818
  webtransport: s
5654
- }), r === "auto" ? this.endpointSelector.proxyPreferred && Z.debug("Proxy preferred (from previous session)") : Z.debug(`Proxy mode: ${r}`), (o !== void 0 || s !== void 0) && Z.debug(`Transport filter: websocket=${o ?? "auto"}, webtransport=${s ?? "auto"}`), this._functionRegistry = new Mm(), this._reactiveRegistry = new Lm(this._functionRegistry), R() && !e.disableBrowserFunctions && (this.unregisterBrowserFunctions = ep(this._functionRegistry), this.unregisterSoundFunctions = gh(this._functionRegistry)), R() && (this.unregisterLoginInterceptor = this._functionRegistry.addErrorInterceptor(Vm));
5655
- let c = cu(), l = lu();
5819
+ }), r === "auto" ? this.endpointSelector.proxyPreferred && Z.debug("Proxy preferred (from previous session)") : Z.debug(`Proxy mode: ${r}`), (o !== void 0 || s !== void 0) && Z.debug(`Transport filter: websocket=${o ?? "auto"}, webtransport=${s ?? "auto"}`), this._functionRegistry = new Um(), this._reactiveRegistry = new Jm(this._functionRegistry), R() && !e.disableBrowserFunctions && (this.unregisterBrowserFunctions = cp(this._functionRegistry), this.unregisterSoundFunctions = Oh(this._functionRegistry)), R() && (this.unregisterLoginInterceptor = this._functionRegistry.addErrorInterceptor(Qm));
5820
+ let c = lu(), l = uu();
5656
5821
  this._audioEnabled = c ?? e.audio?.enabled ?? !0, this._videoEnabled = l ?? e.video?.enabled ?? !0;
5657
5822
  let u = e.audio ? {
5658
5823
  performance: e.audio.performance,
@@ -5663,7 +5828,7 @@ var Xh = class {
5663
5828
  audio: u,
5664
5829
  video: d,
5665
5830
  mediaSession: e.mediaSession
5666
- }, this._mediaCaptureConfig = { audio: { performance: { preferWebCodecs: e.audio?.performance?.preferWebCodecs } } }, R() && (this.unregisterMediaCaptureFunctions = Zm(this._functionRegistry, this));
5831
+ }, this._mediaCaptureConfig = { audio: { performance: { preferWebCodecs: e.audio?.performance?.preferWebCodecs } } }, R() && (this.unregisterMediaCaptureFunctions = ch(this._functionRegistry, this));
5667
5832
  }
5668
5833
  _lastError = void 0;
5669
5834
  get lastError() {
@@ -5716,13 +5881,13 @@ var Xh = class {
5716
5881
  async connect() {
5717
5882
  if (this._connectStarted) throw Error(`Cannot connect: already started (state: ${this.currentState})`);
5718
5883
  this._connectStarted = !0;
5719
- let e = Ih();
5884
+ let e = qh();
5720
5885
  if (!e.supported) {
5721
5886
  this.setErrorState(new Il(e.missingFeatures));
5722
5887
  return;
5723
5888
  }
5724
5889
  this.setupLifecycleHandlers();
5725
- let t = su();
5890
+ let t = cu();
5726
5891
  if (t) {
5727
5892
  Z.info("Found external connect URL in query parameter"), await this.executeConnection(() => K(t, this.abortController.signal));
5728
5893
  return;
@@ -5735,17 +5900,17 @@ var Xh = class {
5735
5900
  }
5736
5901
  async executeConnection(e) {
5737
5902
  if (this._lastError = void 0, this.abortController = new AbortController(), typeof Worker < "u" && !this.preloadedWorker) try {
5738
- this.preloadedWorker = new Lh();
5903
+ this.preloadedWorker = new eg();
5739
5904
  } catch {}
5740
5905
  this.setState("connecting"), this.connectionTimer = setTimeout(() => {
5741
5906
  this.currentState === "connecting" && (Z.error("Connection timeout"), this.abortController?.abort("Connection timeout"), this.setState("offline"), this.config.onError?.(/* @__PURE__ */ Error("Connection timeout")));
5742
5907
  }, this.connectionTimeoutMs);
5743
5908
  try {
5744
5909
  let t = await e();
5745
- if (this.authResponse = t.authResponse, this._sessionId = t.authResponse.ClientContext.SessionId, this._connectUrl = t.directUrl, this._brandingRequired = t.brandingRequired ?? !1, Z.info(`Authenticated to Ikon server (ikonServerId=${t.authResponse.IkonServerId}, appSessionId=${t.authResponse.AppSessionId})`), !this.config.local && t.backendUrl && t.authToken && Np(t.backendUrl, t.authToken), t.usedProxyUrl && t.directUrl) {
5910
+ if (this.authResponse = t.authResponse, this._sessionId = t.authResponse.ClientContext.SessionId, this._connectUrl = t.directUrl, this._brandingRequired = t.brandingRequired ?? !1, Z.info(`Authenticated to Ikon server (ikonServerId=${t.authResponse.IkonServerId}, appSessionId=${t.authResponse.AppSessionId})`), !this.config.local && t.backendUrl && t.authToken && Vp(t.backendUrl, t.authToken), t.usedProxyUrl && t.directUrl) {
5746
5911
  Z.debug("Auth fell back to proxy, marking proxy preferred");
5747
5912
  let e = t.directUrl;
5748
- pm(e).then((e) => {
5913
+ wm(e).then((e) => {
5749
5914
  e && (Z.debug("Background probe: direct server reachable, clearing proxy preference for next connection"), this.endpointSelector.clearProxyPreference());
5750
5915
  }).catch(() => {});
5751
5916
  }
@@ -5756,7 +5921,7 @@ var Xh = class {
5756
5921
  }
5757
5922
  }
5758
5923
  disconnect() {
5759
- Z.info("Disconnecting from Ikon server"), this.sendDisconnectSignal(), Fp(), this.clearTimers(), this.cleanupLifecycleHandlers(), this._externalConnectUrlCleanup &&= (this._externalConnectUrlCleanup(), null), this._media?.dispose(), this._mediaCapture?.dispose(), this.unregisterMediaCaptureFunctions &&= (this.unregisterMediaCaptureFunctions(), null), this.unregisterSoundFunctions &&= (this.unregisterSoundFunctions(), null), this.unregisterBrowserFunctions &&= (this.unregisterBrowserFunctions(), null), this.unregisterLoginInterceptor &&= (this.unregisterLoginInterceptor(), null), this.abortController?.abort(), this.abortController = null, this._fullReauthAttempted = !1, this._softReconnectAttempted = !1, this._lastFailureWasAuthRejected = !1, this._reauthInProgress = !1, this._disconnectedAt = null, this._serverStopped = !1, this._hasBeenConnected = !1, this.releaseKeepaliveLock(), this.disconnectProtocol(), this.authResponse = null, this._sessionId = void 0, this._globalState = null, this._globalStateReceived = !1, this._channelsConnected = !1, this._joinedHandled = !1, this._environmentTrackingSetup = !1;
5924
+ Z.info("Disconnecting from Ikon server"), this.sendDisconnectSignal(), Up(), this.clearTimers(), this.cleanupLifecycleHandlers(), this._externalConnectUrlCleanup &&= (this._externalConnectUrlCleanup(), null), this._media?.dispose(), this._mediaCapture?.dispose(), this.unregisterMediaCaptureFunctions &&= (this.unregisterMediaCaptureFunctions(), null), this.unregisterSoundFunctions &&= (this.unregisterSoundFunctions(), null), this.unregisterBrowserFunctions &&= (this.unregisterBrowserFunctions(), null), this.unregisterLoginInterceptor &&= (this.unregisterLoginInterceptor(), null), this.abortController?.abort(), this.abortController = null, this._fullReauthAttempted = !1, this._softReconnectAttempted = !1, this._lastFailureWasAuthRejected = !1, this._reauthInProgress = !1, this._disconnectedAt = null, this._serverStopped = !1, this._hasBeenConnected = !1, this.releaseKeepaliveLock(), this.disconnectProtocol(), this.authResponse = null, this._sessionId = void 0, this._globalState = null, this._globalStateReceived = !1, this._channelsConnected = !1, this._joinedHandled = !1, this._environmentTrackingSetup = !1;
5760
5925
  for (let e of this._webRtcAudioElements.values()) e.pause(), e.srcObject = null, e.remove();
5761
5926
  this._webRtcAudioElements.clear(), this._webRtcAudioStreams.clear(), this._webRtcVideoStreams.clear(), this._webRtcTrackMap.clear(), this._pendingActiveAudioTracks.clear(), this.removeWebRtcAudioUnlockHandler(), this._webRtcMediaSession.cleanup(), this._functionRegistry.detach(), this._reactiveRegistry.detach(), this.setState("offline");
5762
5927
  }
@@ -5963,10 +6128,10 @@ var Xh = class {
5963
6128
  }
5964
6129
  async authenticate() {
5965
6130
  let e = this.abortController?.signal;
5966
- if (this.config.local) return _m(this.config.local, e);
6131
+ if (this.config.local) return Om(this.config.local, e);
5967
6132
  let t = this.endpointSelector.proxyMode, n = this.endpointSelector.proxyPreferred, r;
5968
- if (this.config.apiKey) r = await vm(this.config.apiKey, e, t, n);
5969
- else if (this.config.sessionToken) r = await ym(this.config.sessionToken, e, t, n);
6133
+ if (this.config.apiKey) r = await km(this.config.apiKey, e, t, n);
6134
+ else if (this.config.sessionToken) r = await Am(this.config.sessionToken, e, t, n);
5970
6135
  else throw Error("No connection configuration provided (need local, apiKey, or sessionToken)");
5971
6136
  return r.usedProxyUrl && t === "auto" && this.endpointSelector.markProxyPreferred(), r;
5972
6137
  }
@@ -6001,7 +6166,7 @@ var Xh = class {
6001
6166
  return;
6002
6167
  }
6003
6168
  if (t === C.CORE_GLOBAL_STATE && uo(e).then((e) => {
6004
- this._globalState = e, this._sessionId !== void 0 && this._functionRegistry.syncFromGlobalState(e, this._sessionId), this._media?.audio.syncStreamsFromGlobalState(e), this._media?.video.syncStreamsFromGlobalState(e), this._visemeTracker?.syncStreamsFromGlobalState(e), this._globalState.DebugMode && wh(), Ch() && this.protocolWorker && (this.protocolWorker.postMessage({
6169
+ this._globalState = e, this._sessionId !== void 0 && this._functionRegistry.syncFromGlobalState(e, this._sessionId), this._media?.audio.syncStreamsFromGlobalState(e), this._media?.video.syncStreamsFromGlobalState(e), this._visemeTracker?.syncStreamsFromGlobalState(e), this._globalState.DebugMode && Ih(), Fh() && this.protocolWorker && (this.protocolWorker.postMessage({
6005
6170
  type: "enableDevtools",
6006
6171
  enabled: !0
6007
6172
  }), this.protocolWorker.postMessage({
@@ -6077,7 +6242,7 @@ var Xh = class {
6077
6242
  try {
6078
6243
  switch (e) {
6079
6244
  case "connected":
6080
- this.clearTimers(), this.setState("connected"), this._channelsConnected = !0, this._hasBeenConnected = !0, this.acquireKeepaliveLock(), this.tryHandleJoined();
6245
+ this.clearTimers(), this.setState("connected"), this._channelsConnected = !0, this._hasBeenConnected = !0, this.acquireKeepaliveLock(), this.tryHandleJoined(), this.revalidateEndpointPreference();
6081
6246
  break;
6082
6247
  case "reconnecting":
6083
6248
  this.currentState === "connected" && (this._channelsConnected = !1, this._globalStateReceived = !1, this._joinedHandled = !1, this._functionRegistry.detach(), this._reactiveRegistry.detach(), this.releaseKeepaliveLock(), this.setState("reconnecting"));
@@ -6132,14 +6297,14 @@ var Xh = class {
6132
6297
  this.config.onError?.(e);
6133
6298
  }
6134
6299
  async connectProtocol(e, t = !1) {
6135
- if (typeof Worker > "u") {
6300
+ if (this._connectedEntrypoints = e, typeof Worker > "u") {
6136
6301
  await this.connectProtocolOnMainThread(e, t);
6137
6302
  return;
6138
6303
  }
6139
6304
  let n;
6140
6305
  if (this.preloadedWorker) n = this.preloadedWorker, this.preloadedWorker = null;
6141
6306
  else try {
6142
- n = new Lh();
6307
+ n = new eg();
6143
6308
  } catch (n) {
6144
6309
  Z.warn(`Failed to create protocol worker, falling back to main thread: ${n}`), await this.connectProtocolOnMainThread(e, t);
6145
6310
  return;
@@ -6193,16 +6358,16 @@ var Xh = class {
6193
6358
  a(), t(Error(`Protocol worker failed: ${n.join(" ")}`.trim()));
6194
6359
  }), i = setTimeout(() => {
6195
6360
  r || (i = void 0, t(/* @__PURE__ */ Error("Protocol worker connect timed out")));
6196
- }, Yu);
6361
+ }, td);
6197
6362
  }), i = this.computeOrderedEndpointTypes(e), a = this.getServerKeepaliveTimeoutMs(), o = this.config.timeouts?.reconnectBackoffMs ?? 2e3, s = this.config.timeouts?.maxReconnectAttempts ?? 2;
6198
- this.updateWorkerInterestMask(), Ch() && (n.postMessage({
6363
+ this.updateWorkerInterestMask(), Fh() && (n.postMessage({
6199
6364
  type: "enableDevtools",
6200
6365
  enabled: !0
6201
6366
  }), n.postMessage({
6202
6367
  type: "setLogLevel",
6203
6368
  level: we()
6204
- })), Oh();
6205
- let c = uu() ?? this.config.webRtc?.enabled ?? !0;
6369
+ })), zh();
6370
+ let c = du() ?? this.config.webRtc?.enabled ?? !0;
6206
6371
  n.postMessage({
6207
6372
  type: "connect",
6208
6373
  sessionId: this._sessionId,
@@ -6223,13 +6388,13 @@ var Xh = class {
6223
6388
  }
6224
6389
  Z.warn(`Protocol worker connect failed, falling back to main thread: ${n}`), this.disconnectProtocol(), await this.connectProtocolOnMainThread(e, t);
6225
6390
  }
6226
- this._audioEnabled && this.ensureVisemeTracker(), c && (this._audioEnabled || this._videoEnabled) ? this.setupWebRtcSignaling().catch((e) => {
6391
+ this._audioEnabled && this.ensureVisemeTracker(), c && (this._audioEnabled || this._videoEnabled) && this._webRtcReachability.shouldStartOnProtocolMedia ? (Z.debug("WebRTC previously failed on this device, starting on protocol-channel media"), this._webRtcFallbackActive = !0, await this.enableCustomPlayback(), this.scheduleWebRtcRetry()) : c && (this._audioEnabled || this._videoEnabled) ? this.setupWebRtcSignaling().catch((e) => {
6227
6392
  this.fallbackToCustomPlayback(`webrtc setup error: ${e}`);
6228
6393
  }) : (this._audioEnabled || this._videoEnabled) && await this.enableCustomPlayback();
6229
6394
  }
6230
6395
  ensureVisemeTracker() {
6231
6396
  if (!this._visemeTracker) try {
6232
- this._visemeTracker = new bh(this), this._visemeTracker.enable();
6397
+ this._visemeTracker = new Mh(this), this._visemeTracker.enable();
6233
6398
  } catch (e) {
6234
6399
  Z.warn(`Viseme tracker setup failed: ${e}`), this._visemeTracker = null;
6235
6400
  }
@@ -6253,9 +6418,10 @@ var Xh = class {
6253
6418
  useVideoTrack: this._videoEnabled,
6254
6419
  useDataChannel: !0,
6255
6420
  iceServers: this.config.webRtc?.iceServers,
6256
- iceTransportPolicy: du() ?? this.config.webRtc?.iceTransportPolicy,
6421
+ iceTransportPolicy: fu() ?? this.config.webRtc?.iceTransportPolicy ?? this._webRtcReachability.iceTransportPolicy,
6422
+ shouldAttemptWithoutIceServers: () => this._webRtcReachability.shouldAttemptWithoutIceServers || this._webRtcRetryCount > 0,
6257
6423
  onStateChange: (e) => {
6258
- e === "connected" ? (this.clearWebRtcConnectWatchdog(), this._webRtcRetryCount = 0, this._media?.audio.setWebRtcActive(!0), this._media?.video.setWebRtcActive(!0)) : e === "failed" && this.fallbackToCustomPlayback(`webrtc connection ${e}`);
6424
+ e === "connected" ? (this.clearWebRtcConnectWatchdog(), this._webRtcRetryCount = 0, this.rememberWebRtcReachability(), this._media?.audio.setWebRtcActive(!0), this._media?.video.setWebRtcActive(!0)) : e === "failed" && this.fallbackToCustomPlayback(`webrtc connection ${e}`);
6259
6425
  },
6260
6426
  onDataChannelMessage: (e) => {
6261
6427
  this.handleDataChannelMessage(e);
@@ -6282,9 +6448,9 @@ var Xh = class {
6282
6448
  } else this._pendingActiveAudioTracks.delete(e.TrackIndex), this.destroyWebRtcAudioElement(e.TrackIndex);
6283
6449
  }
6284
6450
  };
6285
- this._webRtcFallbackActive = !1, this._webRtcSignaling = new Ju(t), this.clearWebRtcConnectWatchdog(), this._webRtcConnectWatchdog = setTimeout(() => {
6451
+ this._webRtcFallbackActive = !1, this._webRtcSignaling = new Yu(t), this.clearWebRtcConnectWatchdog(), this._webRtcConnectWatchdog = setTimeout(() => {
6286
6452
  this._webRtcSignaling?.state !== "connected" && this.fallbackToCustomPlayback("webrtc connection timed out");
6287
- }, Vu);
6453
+ }, Hu);
6288
6454
  try {
6289
6455
  await this._webRtcSignaling.connect((e) => {
6290
6456
  this.sendProtocolMessage(e);
@@ -6293,6 +6459,12 @@ var Xh = class {
6293
6459
  this.fallbackToCustomPlayback(`webrtc signaling setup failed: ${e}`);
6294
6460
  }
6295
6461
  }
6462
+ async rememberWebRtcReachability() {
6463
+ let e = this._webRtcSignaling?.peerConnection;
6464
+ if (!e) return;
6465
+ let t = await ed(e);
6466
+ t !== null && this._webRtcReachability.recordConnected(t);
6467
+ }
6296
6468
  clearWebRtcConnectWatchdog() {
6297
6469
  this._webRtcConnectWatchdog &&= (clearTimeout(this._webRtcConnectWatchdog), null);
6298
6470
  }
@@ -6300,9 +6472,9 @@ var Xh = class {
6300
6472
  this._webRtcRetryTimer &&= (clearTimeout(this._webRtcRetryTimer), null);
6301
6473
  }
6302
6474
  scheduleWebRtcRetry() {
6303
- if (this._webRtcRetryTimer || this._webRtcRetryCount >= Jh.length) return;
6304
- let e = Jh[this._webRtcRetryCount++];
6305
- Z.info(`Retrying WebRTC in ${Math.round(e / 1e3)}s (attempt ${this._webRtcRetryCount}/${Jh.length})`), this._webRtcRetryTimer = setTimeout(() => {
6475
+ if (this._webRtcRetryTimer || this._webRtcRetryCount >= fg.length) return;
6476
+ let e = fg[this._webRtcRetryCount++];
6477
+ Z.info(`Retrying WebRTC in ${Math.round(e / 1e3)}s (attempt ${this._webRtcRetryCount}/${fg.length})`), this._webRtcRetryTimer = setTimeout(() => {
6306
6478
  this._webRtcRetryTimer = null, !(this.currentState !== "connected" || this._webRtcSignaling || !this.isWebRtcEnabled) && this.setupWebRtcSignaling();
6307
6479
  }, e);
6308
6480
  }
@@ -6312,7 +6484,7 @@ var Xh = class {
6312
6484
  this.teardownWebRtcPlayback();
6313
6485
  return;
6314
6486
  }
6315
- this._webRtcFallbackActive = !0, Z.warn(`WebRTC unavailable, falling back to custom playback: ${e}`), this._webRtcSignaling?.notifyServerClose(), this.teardownWebRtcPlayback(), this._media?.audio.setWebRtcActive(!1), this._media?.video.setWebRtcActive(!1), this.enableCustomPlayback(), this.scheduleWebRtcRetry();
6487
+ this._webRtcSignaling?.peerConnection != null && this._webRtcReachability.recordFailed(), this._webRtcFallbackActive = !0, Z.warn(`WebRTC unavailable, falling back to custom playback: ${e}`), this._webRtcSignaling?.notifyServerClose(), this.teardownWebRtcPlayback(), this._media?.audio.setWebRtcActive(!1), this._media?.video.setWebRtcActive(!1), this.enableCustomPlayback(), this.scheduleWebRtcRetry();
6316
6488
  }
6317
6489
  }
6318
6490
  teardownWebRtcPlayback() {
@@ -6434,8 +6606,8 @@ var Xh = class {
6434
6606
  }
6435
6607
  async connectProtocolOnMainThread(e, t = !1) {
6436
6608
  this.workerManagerState = null, this.protocolWorker = null;
6437
- let n = uu() ?? this.config.webRtc?.enabled ?? !0;
6438
- Z.debug(`Connecting on main thread (webRtcEnabled=${n}, entrypoints=${e.length})`), this.channelManager = new Ou({
6609
+ let n = du() ?? this.config.webRtc?.enabled ?? !0;
6610
+ Z.debug(`Connecting on main thread (webRtcEnabled=${n}, entrypoints=${e.length})`), this.channelManager = new ku({
6439
6611
  sessionId: this._sessionId,
6440
6612
  keepaliveTimeoutMs: this.getServerKeepaliveTimeoutMs(),
6441
6613
  reconnectBackoffMs: this.config.timeouts?.reconnectBackoffMs ?? 2e3,
@@ -6472,14 +6644,34 @@ var Xh = class {
6472
6644
  getServerKeepaliveTimeoutMs() {
6473
6645
  return this.authResponse?.KeepaliveTimeoutMs ?? 0;
6474
6646
  }
6475
- computeOrderedEndpointTypes(e) {
6647
+ groupEntrypointsByType(e) {
6476
6648
  let t = /* @__PURE__ */ new Map();
6477
6649
  for (let n of e) {
6478
6650
  if (n.Type === b.WebRTC) continue;
6479
6651
  let e = t.get(n.Type) ?? [];
6480
6652
  e.push(n), t.set(n.Type, e);
6481
6653
  }
6482
- return this.endpointSelector.getOrderedTypes(t);
6654
+ return t;
6655
+ }
6656
+ computeOrderedEndpointTypes(e) {
6657
+ return this.endpointSelector.getOrderedTypes(this.groupEntrypointsByType(e));
6658
+ }
6659
+ async revalidateEndpointPreference() {
6660
+ if (this._revalidationDone || !this.endpointSelector.needsRevalidation()) return;
6661
+ let e = this.endpointSelector.rememberedType;
6662
+ if (e === null) return;
6663
+ let t = this.endpointSelector.getFasterTypes(e, this.groupEntrypointsByType(this._connectedEntrypoints));
6664
+ if (t.length === 0) return;
6665
+ this._revalidationDone = !0;
6666
+ let n = this.groupEntrypointsByType(this._connectedEntrypoints), r = this.abortController?.signal;
6667
+ for (let e of t) {
6668
+ let t = n.get(e)?.[0]?.Uri;
6669
+ if (!(t === void 0 || r?.aborted) && await Xh(e, t, { signal: r })) {
6670
+ this.endpointSelector.recordFasterTypeReachable(e);
6671
+ return;
6672
+ }
6673
+ }
6674
+ r?.aborted !== !0 && this.endpointSelector.recordFasterTypesUnreachable();
6483
6675
  }
6484
6676
  updateWorkerInterestMask() {
6485
6677
  if (!this.protocolWorker) return;
@@ -6546,7 +6738,7 @@ var Xh = class {
6546
6738
  }
6547
6739
  if (this._reauthInProgress) return;
6548
6740
  this.clearReconnectTimer();
6549
- let e = this._disconnectedAt === null ? Infinity : Date.now() - this._disconnectedAt, t = e > Xu;
6741
+ let e = this._disconnectedAt === null ? Infinity : Date.now() - this._disconnectedAt, t = e > nd;
6550
6742
  if (Z.debug(`Reconnect decision: disconnected ${e === Infinity ? "?" : Math.round(e / 1e3)}s, softExpired=${t}, softAttempted=${this._softReconnectAttempted}, fullAttempted=${this._fullReauthAttempted}, authRejected=${this._lastFailureWasAuthRejected}`), this._lastFailureWasAuthRejected) Z.info("Skipping soft reconnect — last failure was auth-rejected, going straight to full re-auth"), this._lastFailureWasAuthRejected = !1, this._softReconnectAttempted = !0;
6551
6743
  else if (!t && !this._softReconnectAttempted && !this._fullReauthAttempted && this.authResponse) {
6552
6744
  Z.info("Attempting soft reconnect with cached entrypoints"), this._softReconnectAttempted = !0, this._channelsConnected = !1, this._globalStateReceived = !1, this._joinedHandled = !1, this.disconnectProtocol(), this.connectProtocol(this.authResponse.Entrypoints, !0);
@@ -6573,7 +6765,7 @@ var Xh = class {
6573
6765
  }
6574
6766
  this.clearReconnectTimer(), Z.info("Scheduling reconnect retry in 10 seconds"), this._reconnectTimer = setTimeout(() => {
6575
6767
  this._reconnectTimer = null, this.attemptReconnect();
6576
- }, Zu);
6768
+ }, rd);
6577
6769
  }
6578
6770
  clearReconnectTimer() {
6579
6771
  this._reconnectTimer &&= (clearTimeout(this._reconnectTimer), null);
@@ -6594,17 +6786,37 @@ var Xh = class {
6594
6786
  this.connectionTimer &&= (clearTimeout(this.connectionTimer), null), this.clearReconnectTimer();
6595
6787
  }
6596
6788
  setupLifecycleHandlers() {
6597
- typeof window > "u" || (this.boundBeforeUnload = () => this.handleBeforeUnload(), window.addEventListener("beforeunload", this.boundBeforeUnload), this.boundPageHide = (e) => this.handlePageHide(e), window.addEventListener("pagehide", this.boundPageHide), this.boundVisibilityChange = () => this.handleVisibilityChange(), document.addEventListener("visibilitychange", this.boundVisibilityChange), this.boundPopstate = () => this.handlePopstate(), window.addEventListener("popstate", this.boundPopstate), this.boundOnline = () => this.attemptReconnectOnVisible(), window.addEventListener("online", this.boundOnline), this.boundOffline = () => this.handleBrowserOffline(), window.addEventListener("offline", this.boundOffline), this.boundExternalLinkClick = (e) => this.handleExternalLinkClick(e), document.addEventListener("click", this.boundExternalLinkClick, !0));
6789
+ typeof window > "u" || (this.boundBeforeUnload = () => this.handleBeforeUnload(), window.addEventListener("beforeunload", this.boundBeforeUnload), this.boundPageHide = (e) => this.handlePageHide(e), window.addEventListener("pagehide", this.boundPageHide), this.boundVisibilityChange = () => this.handleVisibilityChange(), document.addEventListener("visibilitychange", this.boundVisibilityChange), this.boundPopstate = () => this.handlePopstate(), window.addEventListener("popstate", this.boundPopstate), this.boundOnline = () => this.attemptReconnectOnVisible(), window.addEventListener("online", this.boundOnline), this.boundOffline = () => this.handleBrowserOffline(), window.addEventListener("offline", this.boundOffline), this.boundAnchorClick = (e) => this.handleAnchorClick(e), document.addEventListener("click", this.boundAnchorClick, !0));
6598
6790
  }
6599
6791
  cleanupLifecycleHandlers() {
6600
- typeof window > "u" || (this.boundBeforeUnload &&= (window.removeEventListener("beforeunload", this.boundBeforeUnload), null), this.boundPageHide &&= (window.removeEventListener("pagehide", this.boundPageHide), null), this.boundVisibilityChange &&= (document.removeEventListener("visibilitychange", this.boundVisibilityChange), null), this.boundPopstate &&= (window.removeEventListener("popstate", this.boundPopstate), null), this.boundOnline &&= (window.removeEventListener("online", this.boundOnline), null), this.boundOffline &&= (window.removeEventListener("offline", this.boundOffline), null), this.boundExternalLinkClick &&= (document.removeEventListener("click", this.boundExternalLinkClick, !0), null));
6792
+ typeof window > "u" || (this.boundBeforeUnload &&= (window.removeEventListener("beforeunload", this.boundBeforeUnload), null), this.boundPageHide &&= (window.removeEventListener("pagehide", this.boundPageHide), null), this.boundVisibilityChange &&= (document.removeEventListener("visibilitychange", this.boundVisibilityChange), null), this.boundPopstate &&= (window.removeEventListener("popstate", this.boundPopstate), null), this.boundOnline &&= (window.removeEventListener("online", this.boundOnline), null), this.boundOffline &&= (window.removeEventListener("offline", this.boundOffline), null), this.boundAnchorClick &&= (document.removeEventListener("click", this.boundAnchorClick, !0), null));
6601
6793
  }
6602
- handleExternalLinkClick(e) {
6794
+ handleAnchorClick(e) {
6603
6795
  if (e.defaultPrevented || e.button !== 0 || e.metaKey || e.ctrlKey || e.shiftKey || e.altKey) return;
6604
6796
  let t = e.target?.closest?.("a[href]");
6605
6797
  if (!t || t.target && t.target !== "_self") return;
6606
6798
  let n = t.getAttribute("href") ?? "";
6607
- Nh(n) && (e.preventDefault(), Ph(n));
6799
+ if (Wh(n)) {
6800
+ e.preventDefault(), Gh(n);
6801
+ return;
6802
+ }
6803
+ let r = this.resolveInPlaceDestination(t, n);
6804
+ r && (e.preventDefault(), (r.pathname !== window.location.pathname || r.search !== window.location.search) && (window.history.pushState(null, "", r.href), this.sendUrlChanged()), this.scrollNewRouteToTop());
6805
+ }
6806
+ scrollNewRouteToTop() {
6807
+ window.scrollTo(0, 0);
6808
+ let e = [...document.querySelectorAll("*")].filter((e) => e.scrollTop > 0);
6809
+ for (let t of e) t.scrollTop = 0;
6810
+ }
6811
+ resolveInPlaceDestination(e, t) {
6812
+ if (this.config.interceptInternalLinks === !1 || e.dataset.ikonNavigate === "reload" || e.hasAttribute("download") || e.rel.split(/\s+/).includes("external") || this.currentState !== "connected" || this._sessionId === void 0) return null;
6813
+ let n;
6814
+ try {
6815
+ n = new URL(t, window.location.href);
6816
+ } catch {
6817
+ return null;
6818
+ }
6819
+ return n.origin !== window.location.origin || n.protocol !== "http:" && n.protocol !== "https:" || n.hash && n.pathname === window.location.pathname && n.search === window.location.search || Ud(n.pathname) ? null : n;
6608
6820
  }
6609
6821
  sendDisconnectSignal() {
6610
6822
  if (this._sessionId !== void 0 && this.currentState === "connected") try {
@@ -6637,6 +6849,9 @@ var Xh = class {
6637
6849
  e && (this._isUnloading = !1, this.checkConnectionHealth(), this.protocolWorker && (this.protocolWorker.postMessage({ type: "checkHealth" }), setTimeout(() => this.checkConnectionHealth(), 500)), this.channelManager && this.channelManager.checkHealth(), this.attemptReconnectOnVisible(), this._webRtcAudioElements.size > 0 && this.requestAudioRecovery()), this.config.onVisibilityChange?.(e);
6638
6850
  }
6639
6851
  handlePopstate() {
6852
+ this.sendUrlChanged();
6853
+ }
6854
+ sendUrlChanged() {
6640
6855
  if (!this._sessionId) return;
6641
6856
  let e = st(rt({ Path: window.location.pathname + window.location.search }), this._sessionId);
6642
6857
  this.sendProtocolMessage(e);
@@ -6677,7 +6892,7 @@ var Xh = class {
6677
6892
  });
6678
6893
  }, 150);
6679
6894
  }), window.matchMedia("(prefers-color-scheme: dark)").addEventListener("change", () => {
6680
- this.sendUpdateClientContext({ theme: Vd() });
6895
+ this.sendUpdateClientContext({ theme: Yd() });
6681
6896
  });
6682
6897
  }
6683
6898
  setupExternalConnectUrlListener() {
@@ -6708,7 +6923,7 @@ var Xh = class {
6708
6923
  this._externalConnectUrlCleanup &&= (this._externalConnectUrlCleanup(), null);
6709
6924
  }
6710
6925
  }
6711
- }, Zh = class {
6926
+ }, hg = class {
6712
6927
  client;
6713
6928
  constructor(e) {
6714
6929
  this.client = e;
@@ -6726,54 +6941,54 @@ var Xh = class {
6726
6941
  }, { close: () => n.close() }) : { close: () => {} };
6727
6942
  }
6728
6943
  };
6729
- function Qh(e) {
6730
- return new Zh(e);
6944
+ function gg(e) {
6945
+ return new hg(e);
6731
6946
  }
6732
6947
  //#endregion
6733
6948
  //#region src/client/connection-state.ts
6734
- function $h(e) {
6949
+ function _g(e) {
6735
6950
  return e === "waitingForExternalConnectUrl" || e === "connecting" || e === "connectingSlow" || e === "reconnecting";
6736
6951
  }
6737
- function eg(e) {
6952
+ function vg(e) {
6738
6953
  return e === "connected";
6739
6954
  }
6740
- function tg(e) {
6955
+ function yg(e) {
6741
6956
  return e === "offline" || e === "offlineError";
6742
6957
  }
6743
- function ng(e) {
6958
+ function bg(e) {
6744
6959
  return e === "offlineError";
6745
6960
  }
6746
6961
  //#endregion
6747
6962
  //#region src/utils/opcode-names.ts
6748
- var rg = /* @__PURE__ */ new Map();
6749
- for (let [e, t] of Object.entries(C)) typeof t == "number" && rg.set(t, e);
6750
- function ig(e) {
6751
- return rg.get(e) ?? `UNKNOWN_${e}`;
6963
+ var xg = /* @__PURE__ */ new Map();
6964
+ for (let [e, t] of Object.entries(C)) typeof t == "number" && xg.set(t, e);
6965
+ function Sg(e) {
6966
+ return xg.get(e) ?? `UNKNOWN_${e}`;
6752
6967
  }
6753
6968
  //#endregion
6754
6969
  //#region src/login/reprovision.ts
6755
- var ag = "ikon-login-app-route";
6756
- function og(e) {
6970
+ var Cg = "ikon-login-app-route";
6971
+ function wg(e) {
6757
6972
  if (typeof window > "u") return;
6758
6973
  try {
6759
- sessionStorage.setItem(ag, window.location.pathname);
6974
+ sessionStorage.setItem(Cg, window.location.pathname);
6760
6975
  } catch {}
6761
6976
  let t = new URL(window.location.href);
6762
6977
  t.searchParams.set(Ul, e), window.location.href = t.toString();
6763
6978
  }
6764
- function sg() {
6979
+ function Tg() {
6765
6980
  let e = null;
6766
6981
  try {
6767
- e = sessionStorage.getItem(ag), sessionStorage.removeItem(ag);
6982
+ e = sessionStorage.getItem(Cg), sessionStorage.removeItem(Cg);
6768
6983
  } catch {}
6769
6984
  return {
6770
6985
  appRoute: e,
6771
- pendingCall: sd()
6986
+ pendingCall: pd()
6772
6987
  };
6773
6988
  }
6774
6989
  //#endregion
6775
6990
  //#region src/media/ring-buffer.ts
6776
- var cg = class {
6991
+ var Eg = class {
6777
6992
  static getStorageForCapacity(e, t) {
6778
6993
  let n = Int32Array.BYTES_PER_ELEMENT * 2, r = t.BYTES_PER_ELEMENT * e;
6779
6994
  return new SharedArrayBuffer(n + r);
@@ -6824,7 +7039,7 @@ var cg = class {
6824
7039
  };
6825
7040
  //#endregion
6826
7041
  //#region src/worker/audio-capture-worker.ts?worker
6827
- function lg(e) {
7042
+ function Dg(e) {
6828
7043
  return new Worker("" + new URL("assets/audio-capture-worker-CJ5S-nQt.js", import.meta.url).href, {
6829
7044
  type: "module",
6830
7045
  name: e?.name
@@ -6832,11 +7047,11 @@ function lg(e) {
6832
7047
  }
6833
7048
  //#endregion
6834
7049
  //#region src/media/ikon-audio-capture.ts
6835
- var Q = S("IkonAudioCapture"), ug = 3, dg = 200, fg = 2e3, pg = 5e3, mg = 3e3;
6836
- function hg(e) {
7050
+ var Q = S("IkonAudioCapture"), Og = 3, kg = 200, Ag = 2e3, jg = 5e3, Mg = 3e3;
7051
+ function Ng(e) {
6837
7052
  return new Promise((t) => setTimeout(t, e));
6838
7053
  }
6839
- function gg(e) {
7054
+ function Pg(e) {
6840
7055
  switch (e.name) {
6841
7056
  case "NotReadableError": return {
6842
7057
  action: "retry",
@@ -6872,14 +7087,14 @@ function gg(e) {
6872
7087
  };
6873
7088
  }
6874
7089
  }
6875
- function _g() {
7090
+ function Fg() {
6876
7091
  let e = globalThis.crypto;
6877
7092
  return e?.randomUUID ? e.randomUUID() : `cap_${Date.now()}_${Math.floor(Math.random() * 1e9)}`;
6878
7093
  }
6879
- function vg() {
7094
+ function Ig() {
6880
7095
  return "\nclass RingBuffer {\n static getStorageForCapacity(capacity, type) {\n const indexBytes = Int32Array.BYTES_PER_ELEMENT * 2;\n const dataBytes = type.BYTES_PER_ELEMENT * capacity;\n return new SharedArrayBuffer(indexBytes + dataBytes);\n }\n\n constructor(sharedArrayBuffer, type) {\n this.buf = sharedArrayBuffer;\n this.readWrite = new Int32Array(sharedArrayBuffer, 0, 2);\n const dataOffset = Int32Array.BYTES_PER_ELEMENT * 2;\n const dataLength = (sharedArrayBuffer.byteLength - dataOffset) / Float32Array.BYTES_PER_ELEMENT;\n this.storage = new type(sharedArrayBuffer, dataOffset, dataLength);\n }\n\n get capacity() {\n return this.storage.length;\n }\n\n available_read() {\n const read = Atomics.load(this.readWrite, 0);\n const write = Atomics.load(this.readWrite, 1);\n if (write >= read) return write - read;\n return this.capacity - (read - write);\n }\n\n available_write() {\n return this.capacity - this.available_read() - 1;\n }\n\n push(input) {\n const writable = Math.min(this.available_write(), input.length);\n if (writable <= 0) return 0;\n\n const read = Atomics.load(this.readWrite, 0);\n let write = Atomics.load(this.readWrite, 1);\n\n const firstPart = Math.min(writable, this.capacity - write);\n this.storage.set(input.subarray(0, firstPart), write);\n const remaining = writable - firstPart;\n if (remaining > 0) {\n this.storage.set(input.subarray(firstPart, firstPart + remaining), 0);\n }\n\n write = (write + writable) % this.capacity;\n Atomics.store(this.readWrite, 1, write);\n Atomics.notify(this.readWrite, 1);\n if (this.available_read() > this.capacity - 2) {\n Atomics.store(this.readWrite, 0, read);\n }\n\n return writable;\n }\n}\n\nconst RENDER_QUANTUM_SIZE = 128;\n\nclass IkonAudioCaptureProcessor extends AudioWorkletProcessor {\n constructor(options) {\n super();\n const cfg = options?.processorOptions || {};\n this.channels = cfg.channels || 1;\n this.transport = cfg.transport || 'pcm';\n this.ring = null;\n this.temp = new Float32Array(RENDER_QUANTUM_SIZE * this.channels);\n\n if (this.transport === 'sab' && cfg.sharedArrayBuffer) {\n this.ring = new RingBuffer(cfg.sharedArrayBuffer, Float32Array);\n }\n\n // Pre-allocated rotating transfer buffers for PCM mode\n // We use two buffers and alternate between them since postMessage transfers ownership\n this.transferBuffers = [\n new Float32Array(RENDER_QUANTUM_SIZE),\n new Float32Array(RENDER_QUANTUM_SIZE)\n ];\n this.transferBufferIndex = 0;\n\n this.port.postMessage({ type: 'ready' });\n }\n\n process(inputs) {\n const input = inputs[0];\n if (!input || input.length === 0) {\n return true;\n }\n\n const frames = input[0]?.length || 0;\n if (frames === 0) {\n return true;\n }\n\n const channelCount = input.length;\n for (let i = 0; i < frames; i++) {\n let sum = 0;\n for (let ch = 0; ch < channelCount; ch++) {\n const channel = input[ch];\n sum += channel ? (channel[i] || 0) : 0;\n }\n this.temp[i] = sum / channelCount;\n }\n\n const out = this.temp.subarray(0, frames);\n if (this.transport === 'sab' && this.ring) {\n this.ring.push(out);\n return true;\n }\n\n // Use rotating pre-allocated transfer buffer\n let buffer = this.transferBuffers[this.transferBufferIndex];\n // If buffer was transferred (detached), recreate it\n if (buffer.byteLength === 0) {\n buffer = new Float32Array(RENDER_QUANTUM_SIZE);\n this.transferBuffers[this.transferBufferIndex] = buffer;\n }\n buffer.set(out);\n const toSend = buffer.subarray(0, frames);\n this.port.postMessage({ type: 'pcm', pcm: toSend }, [buffer.buffer]);\n // Flip to next buffer for next call\n this.transferBufferIndex = (this.transferBufferIndex + 1) % 2;\n return true;\n }\n}\n\nregisterProcessor('ikon-audio-capture', IkonAudioCaptureProcessor);\n";
6881
7096
  }
6882
- var yg = class e {
7097
+ var Lg = class e {
6883
7098
  client;
6884
7099
  static RESUME_TIMEOUT_MS = 3e3;
6885
7100
  worker = null;
@@ -6940,7 +7155,7 @@ var yg = class e {
6940
7155
  notifyError(e, t, n, r) {
6941
7156
  if (e.stopped) return;
6942
7157
  let i = Date.now(), a = t.name;
6943
- if (e.lastErrorReason === n && e.lastErrorName === a && i - e.lastErrorTime < pg) return;
7158
+ if (e.lastErrorReason === n && e.lastErrorName === a && i - e.lastErrorTime < jg) return;
6944
7159
  e.lastErrorTime = i, e.lastErrorReason = n, e.lastErrorName = a;
6945
7160
  let o = this.config.autoRestartPolicy;
6946
7161
  if (o?.enabled && r) {
@@ -6998,7 +7213,7 @@ var yg = class e {
6998
7213
  if (e.ctx.state === "running") return !0;
6999
7214
  if (e.ctx.state !== "suspended") return !1;
7000
7215
  let r = Date.now();
7001
- if (!n && r - e.lastResumeAttemptTime < mg) return Q.debug(`Resume attempt from ${t} skipped (cooldown)`), !1;
7216
+ if (!n && r - e.lastResumeAttemptTime < Mg) return Q.debug(`Resume attempt from ${t} skipped (cooldown)`), !1;
7002
7217
  e.lastResumeAttemptTime = r, this.emitDiagnostic({
7003
7218
  event: "resume-attempt",
7004
7219
  captureId: e.captureId,
@@ -7034,7 +7249,7 @@ var yg = class e {
7034
7249
  attemptResume(e, t, n = !1) {
7035
7250
  if (e.stopped || e.ctx.state !== "suspended") return;
7036
7251
  let r = Date.now();
7037
- if (!n && r - e.lastResumeAttemptTime < mg) {
7252
+ if (!n && r - e.lastResumeAttemptTime < Mg) {
7038
7253
  Q.debug(`Resume attempt from ${t} skipped (cooldown)`);
7039
7254
  return;
7040
7255
  }
@@ -7133,7 +7348,7 @@ var yg = class e {
7133
7348
  }
7134
7349
  ensureWorker() {
7135
7350
  if (this.worker) return this.worker;
7136
- let e = new lg();
7351
+ let e = new Dg();
7137
7352
  return this.worker = e, e.addEventListener("message", (e) => {
7138
7353
  let t = e.data;
7139
7354
  if (t?.type === "error") {
@@ -7231,25 +7446,25 @@ var yg = class e {
7231
7446
  reason: "unknown",
7232
7447
  canRetry: !1
7233
7448
  };
7234
- for (let r = 0; r < ug; r++) try {
7449
+ for (let r = 0; r < Og; r++) try {
7235
7450
  return {
7236
7451
  stream: await navigator.mediaDevices.getUserMedia({ audio: e }),
7237
7452
  error: t,
7238
7453
  errorInfo: n
7239
7454
  };
7240
7455
  } catch (e) {
7241
- if (t = e instanceof Error ? e : Error(String(e)), n = gg(t), Q.debug(`getUserMedia attempt ${r + 1}/${ug} failed: ${t.name} (action: ${n.action})`), this.emitDiagnostic({
7456
+ if (t = e instanceof Error ? e : Error(String(e)), n = Pg(t), Q.debug(`getUserMedia attempt ${r + 1}/${Og} failed: ${t.name} (action: ${n.action})`), this.emitDiagnostic({
7242
7457
  event: "retry",
7243
7458
  details: {
7244
7459
  attempt: r + 1,
7245
- maxAttempts: ug,
7460
+ maxAttempts: Og,
7246
7461
  errorName: t.name,
7247
7462
  action: n.action
7248
7463
  }
7249
7464
  }), n.action !== "retry") break;
7250
7465
  if (r < 2) {
7251
- let e = dg * (r + 1);
7252
- Q.debug(`Retrying getUserMedia in ${e}ms`), await hg(e);
7466
+ let e = kg * (r + 1);
7467
+ Q.debug(`Retrying getUserMedia in ${e}ms`), await Ng(e);
7253
7468
  }
7254
7469
  }
7255
7470
  return {
@@ -7260,7 +7475,7 @@ var yg = class e {
7260
7475
  }
7261
7476
  async ensureWorklet(e) {
7262
7477
  if (!Ee(e)) throw Error("AudioWorklet is not supported in this browser");
7263
- if (this.workletModuleUrl ||= URL.createObjectURL(new Blob([vg()], { type: "text/javascript" })), this.workletReady && this.workletContext === e) try {
7478
+ if (this.workletModuleUrl ||= URL.createObjectURL(new Blob([Ig()], { type: "text/javascript" })), this.workletReady && this.workletContext === e) try {
7264
7479
  await this.workletReady;
7265
7480
  return;
7266
7481
  } catch {
@@ -7287,7 +7502,7 @@ var yg = class e {
7287
7502
  if (!t) throw Error("Cannot start audio capture before client is connected");
7288
7503
  if (this.client.isWebRtcCaptureAvailable) return this.startMicWebRtc(e);
7289
7504
  this.client.isWebRtcEnabled && Q.warn("WebRTC unavailable, capturing audio via protocol channel");
7290
- let n = _g(), r = {
7505
+ let n = Fg(), r = {
7291
7506
  captureId: n,
7292
7507
  aborted: !1,
7293
7508
  stream: null,
@@ -7325,7 +7540,7 @@ var yg = class e {
7325
7540
  let f = Ce() ? "sab" : "pcm", p;
7326
7541
  if (f === "sab") {
7327
7542
  let e = Math.floor(a.sampleRate * 10);
7328
- p = cg.getStorageForCapacity(e, Float32Array);
7543
+ p = Eg.getStorageForCapacity(e, Float32Array);
7329
7544
  }
7330
7545
  let m = this.ensureWorker(), h = e.onStopped;
7331
7546
  m.postMessage({
@@ -7473,7 +7688,7 @@ var yg = class e {
7473
7688
  };
7474
7689
  this.setupAudioContextStateListener(a, _), this.setupVisibilityChangeListener(_), this.setupBFCacheHandlers(_), _.healthCheckTimer = setInterval(() => {
7475
7690
  this.performHealthCheck(_);
7476
- }, fg);
7691
+ }, Ag);
7477
7692
  let te = () => {
7478
7693
  _.stopped || (Q.warn(`Microphone track ended unexpectedly, captureId=${n.substring(0, 8)}`), this.handleRecoverableError(_, /* @__PURE__ */ Error("Microphone track ended unexpectedly"), "track-ended"));
7479
7694
  };
@@ -7622,8 +7837,8 @@ var yg = class e {
7622
7837
  let t = this.captures.get(e);
7623
7838
  return !t || t.stopped ? !1 : this.attemptResumeAsync(t, "userGesture", !0);
7624
7839
  }
7625
- }, bg = 3e3;
7626
- function xg(e, t, n, r) {
7840
+ }, Rg = 3e3;
7841
+ function zg(e, t, n, r) {
7627
7842
  if (!n && !r) return {
7628
7843
  width: e,
7629
7844
  height: t
@@ -7634,7 +7849,7 @@ function xg(e, t, n, r) {
7634
7849
  height: Math.max(1, Math.floor(t * o))
7635
7850
  };
7636
7851
  }
7637
- async function Sg(e, t) {
7852
+ async function Bg(e, t) {
7638
7853
  let n = t.mime ?? "image/jpeg", r = t.quality ?? .92;
7639
7854
  if (typeof OffscreenCanvas < "u" && e instanceof OffscreenCanvas) try {
7640
7855
  return await e.convertToBlob({
@@ -7649,7 +7864,7 @@ async function Sg(e, t) {
7649
7864
  }, n, r);
7650
7865
  });
7651
7866
  }
7652
- var Cg = class {
7867
+ var Vg = class {
7653
7868
  async captureFromStream(e, t = {}) {
7654
7869
  let n = e.getVideoTracks()[0];
7655
7870
  if (!n) throw Error("No video track available in the provided stream");
@@ -7660,7 +7875,7 @@ var Cg = class {
7660
7875
  } catch {}
7661
7876
  try {
7662
7877
  await new Promise((e, t) => {
7663
- let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")), bg);
7878
+ let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")), Rg);
7664
7879
  r.addEventListener("loadedmetadata", () => {
7665
7880
  clearTimeout(n), e();
7666
7881
  }, { once: !0 }), r.addEventListener("error", () => {
@@ -7670,7 +7885,7 @@ var Cg = class {
7670
7885
  try {
7671
7886
  await r.play();
7672
7887
  } catch {}
7673
- let { width: e, height: i } = xg(r.videoWidth || (n.getSettings().width ?? 1280), r.videoHeight || (n.getSettings().height ?? 720), t.width, t.height), a;
7888
+ let { width: e, height: i } = zg(r.videoWidth || (n.getSettings().width ?? 1280), r.videoHeight || (n.getSettings().height ?? 720), t.width, t.height), a;
7674
7889
  if (typeof OffscreenCanvas < "u") a = new OffscreenCanvas(e, i);
7675
7890
  else {
7676
7891
  let t = document.createElement("canvas");
@@ -7679,7 +7894,7 @@ var Cg = class {
7679
7894
  let o = a.getContext("2d", { alpha: !1 });
7680
7895
  if (!o) throw Error("2D canvas context unavailable");
7681
7896
  o.drawImage(r, 0, 0, e, i);
7682
- let s = await Sg(a, t), c = await s.arrayBuffer();
7897
+ let s = await Bg(a, t), c = await s.arrayBuffer();
7683
7898
  return {
7684
7899
  mime: s.type || t.mime || "image/jpeg",
7685
7900
  width: e,
@@ -7720,7 +7935,7 @@ var Cg = class {
7720
7935
  } catch {}
7721
7936
  try {
7722
7937
  await new Promise((e, t) => {
7723
- let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")), bg);
7938
+ let n = setTimeout(() => t(/* @__PURE__ */ Error("Timed out waiting for video metadata")), Rg);
7724
7939
  r.addEventListener("loadedmetadata", () => {
7725
7940
  clearTimeout(n), e();
7726
7941
  }, { once: !0 }), r.addEventListener("error", () => {
@@ -7730,7 +7945,7 @@ var Cg = class {
7730
7945
  try {
7731
7946
  await r.play();
7732
7947
  } catch {}
7733
- let { width: t, height: i } = xg(r.videoWidth || (n.getSettings().width ?? 1280), r.videoHeight || (n.getSettings().height ?? 720), e.width, e.height), a;
7948
+ let { width: t, height: i } = zg(r.videoWidth || (n.getSettings().width ?? 1280), r.videoHeight || (n.getSettings().height ?? 720), e.width, e.height), a;
7734
7949
  if (typeof OffscreenCanvas < "u") a = new OffscreenCanvas(t, i);
7735
7950
  else {
7736
7951
  let e = document.createElement("canvas");
@@ -7739,7 +7954,7 @@ var Cg = class {
7739
7954
  let o = a.getContext("2d", { alpha: !1 });
7740
7955
  if (!o) throw Error("2D canvas context unavailable");
7741
7956
  o.drawImage(r, 0, 0, t, i);
7742
- let s = await Sg(a, e), c = await s.arrayBuffer();
7957
+ let s = await Bg(a, e), c = await s.arrayBuffer();
7743
7958
  return {
7744
7959
  mime: s.type || e.mime || "image/jpeg",
7745
7960
  width: t,
@@ -7763,11 +7978,11 @@ var Cg = class {
7763
7978
  }
7764
7979
  async captureFromNativeCamera(e = {}) {
7765
7980
  if (typeof document > "u") throw Error("Native camera capture requires a DOM environment");
7766
- let t = await wg(e.facing);
7767
- return t ? await Tg(t, e) : null;
7981
+ let t = await Hg(e.facing);
7982
+ return t ? await Ug(t, e) : null;
7768
7983
  }
7769
7984
  };
7770
- function wg(e) {
7985
+ function Hg(e) {
7771
7986
  return new Promise((t) => {
7772
7987
  let n = document.createElement("input");
7773
7988
  n.type = "file", n.accept = "image/*", n.setAttribute("capture", e ?? "environment"), n.style.position = "fixed", n.style.left = "-99999px", n.style.top = "0";
@@ -7793,7 +8008,7 @@ function wg(e) {
7793
8008
  n.click();
7794
8009
  });
7795
8010
  }
7796
- async function Tg(e, t) {
8011
+ async function Ug(e, t) {
7797
8012
  let n = URL.createObjectURL(e), r;
7798
8013
  try {
7799
8014
  r = await new Promise((e, t) => {
@@ -7803,7 +8018,7 @@ async function Tg(e, t) {
7803
8018
  } finally {
7804
8019
  URL.revokeObjectURL(n);
7805
8020
  }
7806
- let i = r.naturalWidth || r.width, a = r.naturalHeight || r.height, { width: o, height: s } = xg(i, a, t.width, t.height), c = t.mime ?? (e.type === "image/png" ? "image/png" : "image/jpeg"), l = t.quality ?? .92;
8021
+ let i = r.naturalWidth || r.width, a = r.naturalHeight || r.height, { width: o, height: s } = zg(i, a, t.width, t.height), c = t.mime ?? (e.type === "image/png" ? "image/png" : "image/jpeg"), l = t.quality ?? .92;
7807
8022
  if (o === i && s === a && e.type === c) {
7808
8023
  let t = await e.arrayBuffer();
7809
8024
  return {
@@ -7830,8 +8045,8 @@ async function Tg(e, t) {
7830
8045
  }
7831
8046
  //#endregion
7832
8047
  //#region src/worker/video-capture-worker.ts?worker
7833
- function Eg(e) {
7834
- return new Worker("" + new URL("assets/video-capture-worker-BQGOFbZt.js", import.meta.url).href, {
8048
+ function Wg(e) {
8049
+ return new Worker("" + new URL("assets/video-capture-worker-CXXGkUg0.js", import.meta.url).href, {
7835
8050
  type: "module",
7836
8051
  name: e?.name
7837
8052
  });
@@ -7839,16 +8054,16 @@ function Eg(e) {
7839
8054
  //#endregion
7840
8055
  //#region src/media/ikon-video-capture.ts
7841
8056
  var $ = S("IkonVideoCapture");
7842
- function Dg() {
8057
+ function Gg() {
7843
8058
  let e = globalThis.crypto;
7844
8059
  return e?.randomUUID ? e.randomUUID() : `cap_${Date.now()}_${Math.floor(Math.random() * 1e9)}`;
7845
8060
  }
7846
- function Og() {
8061
+ function Kg() {
7847
8062
  let e = globalThis.MediaStreamTrackProcessor;
7848
8063
  if (!e) throw Error("MediaStreamTrackProcessor is not available in this browser");
7849
8064
  return e;
7850
8065
  }
7851
- var kg = class {
8066
+ var qg = class {
7852
8067
  client;
7853
8068
  worker = null;
7854
8069
  protocolPort = null;
@@ -7864,7 +8079,7 @@ var kg = class {
7864
8079
  }
7865
8080
  ensureWorker() {
7866
8081
  if (this.worker) return this.worker;
7867
- let e = new Eg();
8082
+ let e = new Wg();
7868
8083
  return this.worker = e, e.addEventListener("message", (e) => {
7869
8084
  let t = e.data;
7870
8085
  if (t?.type === "error") {
@@ -7974,10 +8189,10 @@ var kg = class {
7974
8189
  if (this.client.isWebRtcCaptureAvailable && e.sourceType === "camera") return this.startCameraWebRtc(e);
7975
8190
  if (this.client.isWebRtcCaptureAvailable && e.sourceType === "screen") return this.startScreenWebRtc(e);
7976
8191
  this.client.isWebRtcEnabled && $.warn("WebRTC unavailable, capturing video via protocol channel"), this.ensurePorts();
7977
- let n = Dg(), r = await this.getMediaStream(e), i = r.getVideoTracks()[0];
8192
+ let n = Gg(), r = await this.getMediaStream(e), i = r.getVideoTracks()[0];
7978
8193
  if (!i) throw r.getTracks().forEach((e) => e.stop()), Error("No video track available");
7979
8194
  e.sourceType === "screen" && await new Promise((e) => setTimeout(e, 200));
7980
- let a = i.getSettings(), o = e.sourceType === "screen" ? a.width ?? 1280 : e.options?.width ?? a.width ?? 1280, s = e.sourceType === "screen" ? a.height ?? 720 : e.options?.height ?? a.height ?? 720, c = new (Og())({ track: i }).readable, l = this.allocateTrackId(), u = this.ensureWorker(), d = e.sourceType, f = e.onStopped;
8195
+ let a = i.getSettings(), o = e.sourceType === "screen" ? a.width ?? 1280 : e.options?.width ?? a.width ?? 1280, s = e.sourceType === "screen" ? a.height ?? 720 : e.options?.height ?? a.height ?? 720, c = new (Kg())({ track: i }).readable, l = this.allocateTrackId(), u = this.ensureWorker(), d = e.sourceType, f = e.onStopped;
7981
8196
  u.postMessage({
7982
8197
  type: "start",
7983
8198
  captureId: n,
@@ -8100,16 +8315,16 @@ var kg = class {
8100
8315
  }
8101
8316
  this.protocolPort?.close(), this.protocolPort = null, this.sendPort?.close(), this.sendPort = null;
8102
8317
  }
8103
- }, Ag = /* @__PURE__ */ d({ IkonMediaCapture: () => jg }), jg = class {
8318
+ }, Jg = /* @__PURE__ */ d({ IkonMediaCapture: () => Yg }), Yg = class {
8104
8319
  audio;
8105
8320
  video;
8106
8321
  image;
8107
8322
  constructor(e, t) {
8108
- this.audio = new yg(e, t?.audio), this.video = new kg(e), this.image = new Cg();
8323
+ this.audio = new Lg(e, t?.audio), this.video = new qg(e), this.image = new Vg();
8109
8324
  }
8110
8325
  dispose() {
8111
8326
  this.audio.dispose(), this.video.dispose();
8112
8327
  }
8113
8328
  };
8114
8329
  //#endregion
8115
- export { Ml as AccessDeniedError, Zh as AppMessaging, E as AuthRejectedError, w as AuthenticationError, Il as BrowserNotSupportedError, Eu as Channel, Ou as ChannelManager, ne as ClientType, Dl as ConnectionError, m as ContextType, qh as EndpointSelector, b as EntrypointType, Dm as FunctionCallError, Mm as FunctionRegistry, hd as IKON_AUTH_BASE_URL, md as IKON_AUTH_URL_DEV, pd as IKON_AUTH_URL_PROD, fd as IKON_BACKEND_URL_DEV, dd as IKON_BACKEND_URL_PROD, Th as IKON_INSPECT_MODE_CHANGED_EVENT, Wl as IKON_PARAM_AUDIO, Xl as IKON_PARAM_AUTH, Vl as IKON_PARAM_DEBUG, Yl as IKON_PARAM_DEBUG_OVERLAY, Jl as IKON_PARAM_INSPECT, Hl as IKON_PARAM_LANG, Rl as IKON_PARAM_PROXY, Zl as IKON_PARAM_RETRY, Ul as IKON_PARAM_SERVER_URL, Gl as IKON_PARAM_VIDEO, Kl as IKON_PARAM_WEBRTC, zl as IKON_PARAM_WEBSOCKET, Bl as IKON_PARAM_WEBTRANSPORT, yg as IkonAudioCapture, ie as IkonAudioPlayback, Xh as IkonClient, Cg as IkonImageCapture, de as IkonMedia, jg as IkonMediaCapture, kg as IkonVideoCapture, le as IkonVideoPlayback, Ol as KeepaliveTimeoutError, x as LogLevel, kl as MaxRetriesExceededError, C as Opcode, Al as ProvisioningTimeoutError, Pl as ServerFullError, Fl as ServerUnavailableError, Nl as SessionNotFoundError, jl as SpaceNotFoundError, T as TransportError, p as UserType, bh as VisemeTracker, Mu as WEBRTC_AUDIO_BITRATE, ju as WEBRTC_AUDIO_CHANNELS, ku as WEBRTC_AUDIO_CODEC, Nu as WEBRTC_AUDIO_JITTER_BUFFER_TARGET_MS, Au as WEBRTC_AUDIO_SAMPLE_RATE, Ru as WEBRTC_BUNDLE_POLICY, Wu as WEBRTC_DATA_CHANNEL_LABEL, Ku as WEBRTC_DATA_CHANNEL_MAX_RETRANSMITS, Gu as WEBRTC_DATA_CHANNEL_ORDERED, Hu as WEBRTC_MAX_AUDIO_TRACKS, Uu as WEBRTC_MAX_VIDEO_TRACKS, zu as WEBRTC_RTCP_MUX_POLICY, Pu as WEBRTC_VIDEO_CODEC, Fu as WEBRTC_VIDEO_MAX_BITRATE, Iu as WEBRTC_VIDEO_MAX_FRAMERATE, qu as WebRTCConnection, Ju as WebRTCSignaling, ud as abortSignalAny, F as abortSignalTimeout, Qh as appMessaging, v as asProtocolMessage, Ih as checkBrowserSupport, qp as clearDeviceId, fp as clearLogBuffer, id as clearLoginPrompt, sg as consumeLoginHandoff, sd as consumeLoginPendingCall, S as createLogger, Od as deriveAuthUrl, Dd as deriveBackendType, Ed as deriveBackendUrl, Ah as enableInspectMode, Jp as extractUserIdFromToken, dp as flushLogs, cu as getAudioParam, mu as getAuthSameOriginParam, lp as getBufferedLogs, Vp as getConnectTraceId, pu as getDebugOverlayParam, au as getDebugParam, fu as getInspectParam, ou as getLangParam, pp as getLogBufferSize, we as getLogLevel, Se as getLogSink, nd as getLoginPromptState, ig as getOpcodeName, Kp as getOrCreateDeviceId, nu as getProxyParam, k as getRetryParam, Sd as getSameOriginAuthUrl, su as getServerUrlParam, lu as getVideoParam, uu as getWebRtcParam, ru as getWebSocketParam, iu as getWebTransportParam, Sh as initializeDebugMode, Oh as initializeInspectMode, sp as initializeLogSink, Ee as isAudioWorkletSupported, R as isBrowserEnvironment, I as isCloudEnvironment, eg as isConnected, $h as isConnecting, Ch as isDebugModeEnabled, ng as isError, kh as isInspectModeEnabled, Hm as isMobileBrowserLikely, tg as isOffline, Ce as isSharedArrayBufferSupported, Cu as isWebTransportSupported, Vm as loginErrorInterceptor, Nd as parseUrlParams, Wp as randomUuid, c as readOpcode, u as readOpcodeGroup, i as readProtocolMessageHeaders, ep as registerBrowserFunctions, Up as reportConnectTimeline, og as reprovisionAfterLogin, be as setLogLevel, ye as setLogSink, tu as setSdkUrlParam, cp as setSendLogsCallback, Np as startLogSender, Fp as stopLogSender, ad as subscribeLoginPrompt, ge as subscribeToLogEvents, up as takeBufferedLogs, Em as withResultData };
8330
+ export { Ml as AccessDeniedError, hg as AppMessaging, D as AppStartupFailedError, E as AuthRejectedError, w as AuthenticationError, Il as BrowserNotSupportedError, Du as Channel, ku as ChannelManager, ne as ClientType, Dl as ConnectionError, m as ContextType, dg as EndpointSelector, b as EntrypointType, Rm as FunctionCallError, Um as FunctionRegistry, xd as IKON_AUTH_BASE_URL, bd as IKON_AUTH_URL_DEV, yd as IKON_AUTH_URL_PROD, vd as IKON_BACKEND_URL_DEV, _d as IKON_BACKEND_URL_PROD, Lh as IKON_INSPECT_MODE_CHANGED_EVENT, Wl as IKON_PARAM_AUDIO, Xl as IKON_PARAM_AUTH, Vl as IKON_PARAM_DEBUG, Yl as IKON_PARAM_DEBUG_OVERLAY, Jl as IKON_PARAM_INSPECT, Hl as IKON_PARAM_LANG, Rl as IKON_PARAM_PROXY, Zl as IKON_PARAM_RETRY, Ul as IKON_PARAM_SERVER_URL, Gl as IKON_PARAM_VIDEO, Kl as IKON_PARAM_WEBRTC, zl as IKON_PARAM_WEBSOCKET, Bl as IKON_PARAM_WEBTRANSPORT, Lg as IkonAudioCapture, ie as IkonAudioPlayback, mg as IkonClient, Vg as IkonImageCapture, de as IkonMedia, Yg as IkonMediaCapture, qg as IkonVideoCapture, le as IkonVideoPlayback, Ol as KeepaliveTimeoutError, x as LogLevel, kl as MaxRetriesExceededError, C as Opcode, Al as ProvisioningTimeoutError, Pl as ServerFullError, Fl as ServerUnavailableError, Nl as SessionNotFoundError, jl as SpaceNotFoundError, T as TransportError, p as UserType, Mh as VisemeTracker, Nu as WEBRTC_AUDIO_BITRATE, Mu as WEBRTC_AUDIO_CHANNELS, Au as WEBRTC_AUDIO_CODEC, Pu as WEBRTC_AUDIO_JITTER_BUFFER_TARGET_MS, ju as WEBRTC_AUDIO_SAMPLE_RATE, zu as WEBRTC_BUNDLE_POLICY, Gu as WEBRTC_DATA_CHANNEL_LABEL, qu as WEBRTC_DATA_CHANNEL_MAX_RETRANSMITS, Ku as WEBRTC_DATA_CHANNEL_ORDERED, Uu as WEBRTC_MAX_AUDIO_TRACKS, Wu as WEBRTC_MAX_VIDEO_TRACKS, Bu as WEBRTC_RTCP_MUX_POLICY, Fu as WEBRTC_VIDEO_CODEC, Iu as WEBRTC_VIDEO_MAX_BITRATE, Lu as WEBRTC_VIDEO_MAX_FRAMERATE, Ju as WebRTCConnection, Yu as WebRTCSignaling, gd as abortSignalAny, F as abortSignalTimeout, gg as appMessaging, v as asProtocolMessage, qh as checkBrowserSupport, tm as clearDeviceId, bp as clearLogBuffer, ud as clearLoginPrompt, Tg as consumeLoginHandoff, pd as consumeLoginPendingCall, S as createLogger, Nd as deriveAuthUrl, Md as deriveBackendType, jd as deriveBackendUrl, Pd as deriveCrossOriginAuthUrl, Vh as enableInspectMode, nm as extractUserIdFromToken, yp as flushLogs, lu as getAudioParam, hu as getAuthSameOriginParam, _p as getBufferedLogs, Yp as getConnectTraceId, mu as getDebugOverlayParam, ou as getDebugParam, pu as getInspectParam, su as getLangParam, xp as getLogBufferSize, we as getLogLevel, Se as getLogSink, cd as getLoginPromptState, Sg as getOpcodeName, em as getOrCreateDeviceId, ru as getProxyParam, k as getRetryParam, Od as getSameOriginAuthUrl, cu as getServerUrlParam, uu as getVideoParam, du as getWebRtcParam, iu as getWebSocketParam, au as getWebTransportParam, Ph as initializeDebugMode, zh as initializeInspectMode, hp as initializeLogSink, Ee as isAudioWorkletSupported, R as isBrowserEnvironment, I as isCloudEnvironment, vg as isConnected, _g as isConnecting, Fh as isDebugModeEnabled, bg as isError, Bh as isInspectModeEnabled, $m as isMobileBrowserLikely, yg as isOffline, Ce as isSharedArrayBufferSupported, wu as isWebTransportSupported, Qm as loginErrorInterceptor, zd as parseUrlParams, Qp as randomUuid, c as readOpcode, u as readOpcodeGroup, i as readProtocolMessageHeaders, cp as registerBrowserFunctions, Zp as reportConnectTimeline, wg as reprovisionAfterLogin, be as setLogLevel, ye as setLogSink, nu as setSdkUrlParam, gp as setSendLogsCallback, Vp as startLogSender, Up as stopLogSender, dd as subscribeLoginPrompt, ge as subscribeToLogEvents, vp as takeBufferedLogs, Lm as withResultData };