@limrun/ui 0.18.0 → 0.18.2

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.
@@ -1,39 +1,39 @@
1
- import { jsx as k, jsxs as ae, Fragment as Fr } from "react/jsx-runtime";
2
- import { memo as rr, useState as V, useEffect as pe, useMemo as Ke, useCallback as In, lazy as Yn, forwardRef as Kn, useRef as O, useImperativeHandle as kn, Suspense as Pn } from "react";
3
- import { createPortal as Un } from "react-dom";
4
- import './index.css';function Wr(r) {
1
+ import { jsx as P, jsxs as ue, Fragment as $r } from "react/jsx-runtime";
2
+ import { memo as cr, useState as G, useEffect as me, useMemo as ke, useCallback as Un, lazy as Ln, forwardRef as xn, useRef as v, useImperativeHandle as Fn, Suspense as Wn } from "react";
3
+ import { createPortal as Hn } from "react-dom";
4
+ import './index.css';function Xr(r) {
5
5
  var t, c, a = "";
6
6
  if (typeof r == "string" || typeof r == "number") a += r;
7
7
  else if (typeof r == "object") if (Array.isArray(r)) {
8
8
  var m = r.length;
9
- for (t = 0; t < m; t++) r[t] && (c = Wr(r[t])) && (a && (a += " "), a += c);
9
+ for (t = 0; t < m; t++) r[t] && (c = Xr(r[t])) && (a && (a += " "), a += c);
10
10
  } else for (c in r) r[c] && (a && (a += " "), a += c);
11
11
  return a;
12
12
  }
13
- function ke() {
14
- for (var r, t, c = 0, a = "", m = arguments.length; c < m; c++) (r = arguments[c]) && (t = Wr(r)) && (a && (a += " "), a += t);
13
+ function Pe() {
14
+ for (var r, t, c = 0, a = "", m = arguments.length; c < m; c++) (r = arguments[c]) && (t = Xr(r)) && (a && (a += " "), a += t);
15
15
  return a;
16
16
  }
17
- const Uo = { width: 164.6, height: 117.8, depth: 5.2 };
18
- function Lo(r, t, c) {
17
+ const $o = { width: 164.6, height: 117.8, depth: 5.2 };
18
+ function Xo(r, t, c) {
19
19
  return r = Math.max(0, Math.min(1, r)), t = Math.max(0, Math.min(1, t)), c === 1 ? { x: t, y: 1 - r } : c === 2 ? { x: 1 - r, y: 1 - t } : c === 3 ? { x: 1 - t, y: r } : { x: r, y: t };
20
20
  }
21
- function Ln(r) {
21
+ function $n(r) {
22
22
  return Number.isFinite(r) && r >= 0 && r <= 180;
23
23
  }
24
- function xo(r, t) {
24
+ function Bo(r, t) {
25
25
  return { x: Math.max(0, Math.min(1, r)), y: Math.max(0, Math.min(1, 1 - t)) };
26
26
  }
27
- function Fo(r, t, c) {
27
+ function qo(r, t, c) {
28
28
  return t && (r || !c) ? "touch" : r ? "ignore" : "orbit";
29
29
  }
30
- function xn(r, t, c, a) {
30
+ function Xn(r, t, c, a) {
31
31
  if (!Number.isInteger(r) || r < 0 || r > 3 || !Number.isInteger(t) || t < 1 || t > 255 || !Number.isFinite(c) || !Number.isFinite(a) || c < 0 || c > 1 || a < 0 || a > 1)
32
32
  throw new RangeError("Invalid display touch coordinates");
33
33
  const m = new ArrayBuffer(12), p = new DataView(m);
34
34
  return p.setUint8(0, 19), p.setUint8(1, r), p.setUint8(2, t), p.setFloat32(4, c, !0), p.setFloat32(8, a, !0), m;
35
35
  }
36
- class Wo {
36
+ class Vo {
37
37
  constructor(t, c) {
38
38
  this.send = t, this.failed = c;
39
39
  }
@@ -43,7 +43,7 @@ class Wo {
43
43
  running = !1;
44
44
  stopped = !1;
45
45
  set(t) {
46
- this.stopped || !Ln(t) || (this.latest = t, this.flush());
46
+ this.stopped || !$n(t) || (this.latest = t, this.flush());
47
47
  }
48
48
  stop() {
49
49
  this.stopped = !0, this.latest = void 0;
@@ -64,12 +64,12 @@ class Wo {
64
64
  }
65
65
  }
66
66
  }
67
- const Ho = {
67
+ const Go = {
68
68
  side: "Sleep/Wake",
69
69
  volumeUp: "Volume Up",
70
70
  volumeDown: "Volume Down"
71
71
  };
72
- class $o {
72
+ class Jo {
73
73
  constructor(t, c) {
74
74
  this.send = t, this.failed = c;
75
75
  }
@@ -91,13 +91,13 @@ class $o {
91
91
  this.tail = this.tail.then(() => this.send(t, c)).catch(this.failed);
92
92
  }
93
93
  }
94
- const Pt = {
94
+ const xt = {
95
95
  INJECT_KEYCODE: 0,
96
96
  INJECT_TOUCH_EVENT: 2,
97
97
  // iOS-specific: send two touch points in one message (Option/Alt+drag pinch)
98
98
  INJECT_TWO_FINGER_TOUCH_EVENT: 18,
99
99
  SET_CLIPBOARD: 9
100
- }, U = {
100
+ }, K = {
101
101
  ACTION_DOWN: 0,
102
102
  ACTION_UP: 1,
103
103
  ACTION_MOVE: 2,
@@ -233,7 +233,7 @@ const Pt = {
233
233
  KEYCODE_NUMPAD_COMMA: 159,
234
234
  KEYCODE_NUMPAD_ENTER: 160,
235
235
  KEYCODE_NUMPAD_EQUALS: 161
236
- }, Hr = {
236
+ }, Br = {
237
237
  KeyA: s.KEYCODE_A,
238
238
  KeyB: s.KEYCODE_B,
239
239
  KeyC: s.KEYCODE_C,
@@ -339,12 +339,12 @@ const Pt = {
339
339
  // Some numpads have comma
340
340
  NumpadEnter: s.KEYCODE_NUMPAD_ENTER,
341
341
  NumpadEqual: s.KEYCODE_NUMPAD_EQUALS
342
- }, $r = `(function(){"use strict";let e,t;self.onmessage=async({data:s})=>{s.type==="start"?(e=new AbortController,t=s.readable.pipeTo(s.writable,{signal:e.signal}).catch(o=>{e?.signal.aborted||self.postMessage({type:"error",message:String(o)})})):s.type==="stop"&&(e?.abort(),await t,self.postMessage({type:"stopped"}),self.close())}})();
343
- `, Kr = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", $r], { type: "text/javascript;charset=utf-8" });
344
- function Fn(r) {
342
+ }, qr = `(function(){"use strict";let e,t;self.onmessage=async({data:s})=>{s.type==="start"?(e=new AbortController,t=s.readable.pipeTo(s.writable,{signal:e.signal}).catch(o=>{e?.signal.aborted||self.postMessage({type:"error",message:String(o)})})):s.type==="stop"&&(e?.abort(),await t,self.postMessage({type:"stopped"}),self.close())}})();
343
+ `, Ur = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", qr], { type: "text/javascript;charset=utf-8" });
344
+ function Bn(r) {
345
345
  let t;
346
346
  try {
347
- if (t = Kr && (self.URL || self.webkitURL).createObjectURL(Kr), !t) throw "";
347
+ if (t = Ur && (self.URL || self.webkitURL).createObjectURL(Ur), !t) throw "";
348
348
  const c = new Worker(t, {
349
349
  name: r?.name
350
350
  });
@@ -353,100 +353,137 @@ function Fn(r) {
353
353
  }), c;
354
354
  } catch {
355
355
  return new Worker(
356
- "data:text/javascript;charset=utf-8," + encodeURIComponent($r),
356
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(qr),
357
357
  {
358
358
  name: r?.name
359
359
  }
360
360
  );
361
361
  }
362
362
  }
363
- function Wn(r, t, c) {
363
+ function qn(r, t, c) {
364
364
  const { MediaStreamTrackProcessor: a, MediaStreamTrackGenerator: m } = globalThis, p = t.getVideoTracks()[0];
365
- let C, y, b, _, M = !1;
365
+ let g, C, w, O, M = !1;
366
366
  const S = () => {
367
- M || (M = !0, C?.stop(), y?.stop(), b && (b.postMessage({ type: "stop" }), _ = setTimeout(() => b?.terminate(), 1e3)));
368
- }, G = (J) => {
367
+ M || (M = !0, g?.stop(), C?.stop(), w && (w.postMessage({ type: "stop" }), O = setTimeout(() => w?.terminate(), 1e3)));
368
+ }, X = (J) => {
369
369
  r.srcObject = J, r.play().catch(() => {
370
370
  });
371
- }, ie = (J) => {
372
- M || (S(), c(J), G(t));
371
+ }, ce = (J) => {
372
+ M || (S(), c(J), X(t));
373
373
  };
374
374
  try {
375
375
  if (p && a && m) {
376
- C = p.clone();
377
- const J = new a({ track: C, maxBufferSize: 1 }), de = new m({ kind: "video" });
378
- y = de, b = new Fn(), b.onmessage = ({ data: Z }) => {
379
- Z.type === "error" ? ie(new Error(Z.message)) : Z.type === "stopped" && (clearTimeout(_), b?.terminate());
380
- }, b.onerror = (Z) => ie(new Error(Z.message)), b.postMessage({ type: "start", readable: J.readable, writable: de.writable }, [
376
+ g = p.clone();
377
+ const J = new a({ track: g, maxBufferSize: 1 }), fe = new m({ kind: "video" });
378
+ C = fe, w = new Bn(), w.onmessage = ({ data: ee }) => {
379
+ ee.type === "error" ? ce(new Error(ee.message)) : ee.type === "stopped" && (clearTimeout(O), w?.terminate());
380
+ }, w.onerror = (ee) => ce(new Error(ee.message)), w.postMessage({ type: "start", readable: J.readable, writable: fe.writable }, [
381
381
  J.readable,
382
- de.writable
383
- ]), G(new MediaStream(t.getTracks().map((Z) => Z === p ? de : Z)));
382
+ fe.writable
383
+ ]), X(new MediaStream(t.getTracks().map((ee) => ee === p ? fe : ee)));
384
384
  } else
385
- G(t);
385
+ X(t);
386
386
  } catch (J) {
387
- ie(J);
387
+ ce(J);
388
388
  }
389
389
  return S;
390
390
  }
391
- function Yt(r, t, c, a, m, p, C = 1, y = 0, b = 0) {
392
- const _ = new ArrayBuffer(32), M = new DataView(_);
391
+ function Vn(r, t) {
392
+ const c = r.createDataChannel("latency-trace-v1", {
393
+ ordered: !0,
394
+ negotiated: !0,
395
+ id: 2
396
+ });
397
+ let a = !1, m = !1, p = 0;
398
+ return c.onmessage = (g) => {
399
+ if (m) return;
400
+ let C;
401
+ try {
402
+ C = JSON.parse(g.data);
403
+ } catch (w) {
404
+ console.warn("Invalid latency trace message", w);
405
+ return;
406
+ }
407
+ C && typeof C == "object" && !Array.isArray(C) && t(C);
408
+ }, c.onclose = () => {
409
+ m = !0, a = !1;
410
+ }, {
411
+ accept(g) {
412
+ a = !m && g === 1;
413
+ },
414
+ wrap(g) {
415
+ if (!a || g.byteLength !== 32) return g;
416
+ const C = new DataView(g);
417
+ if (C.getUint8(0) !== 2 || C.getUint8(1) > 2) return g;
418
+ const w = new ArrayBuffer(38), O = new DataView(w);
419
+ return O.setUint8(0, 240), O.setUint8(1, 1), O.setUint32(2, ++p, !0), new Uint8Array(w, 6).set(new Uint8Array(g)), w;
420
+ },
421
+ close() {
422
+ m = !0, a = !1, c.onmessage = null, c.onclose = null, c.close();
423
+ }
424
+ };
425
+ }
426
+ function Pt(r, t, c, a, m, p, g = 1, C = 0, w = 0) {
427
+ const O = new ArrayBuffer(32), M = new DataView(O);
393
428
  let S = 0;
394
- return M.setUint8(S, Pt.INJECT_TOUCH_EVENT), S += 1, M.setUint8(S, r), S += 1, M.setBigInt64(S, BigInt(t), !0), S += 8, M.setInt32(S, Math.round(m), !0), S += 4, M.setInt32(S, Math.round(p), !0), S += 4, M.setUint16(S, c, !0), S += 2, M.setUint16(S, a, !0), S += 2, M.setInt16(S, Math.round(C * 65535), !0), S += 2, M.setInt32(S, y, !0), S += 4, M.setInt32(S, b, !0), _;
429
+ M.setUint8(S, xt.INJECT_TOUCH_EVENT), S += 1;
430
+ const X = r === K.ACTION_POINTER_DOWN ? K.ACTION_DOWN : r === K.ACTION_POINTER_UP ? K.ACTION_UP : r;
431
+ return M.setUint8(S, X), S += 1, M.setBigInt64(S, BigInt(t), !0), S += 8, M.setInt32(S, Math.round(m), !0), S += 4, M.setInt32(S, Math.round(p), !0), S += 4, M.setUint16(S, c, !0), S += 2, M.setUint16(S, a, !0), S += 2, M.setInt16(S, Math.round(g * 65535), !0), S += 2, M.setInt32(S, C, !0), S += 4, M.setInt32(S, w, !0), O;
395
432
  }
396
- function Hn(r, t, c, a, m, p, C) {
397
- const y = new ArrayBuffer(24), b = new DataView(y);
398
- let _ = 0;
399
- return b.setUint8(_, Pt.INJECT_TWO_FINGER_TOUCH_EVENT), _ += 1, b.setUint8(_, r), _ += 1, b.setInt32(_, Math.round(a), !0), _ += 4, b.setInt32(_, Math.round(m), !0), _ += 4, b.setInt32(_, Math.round(p), !0), _ += 4, b.setInt32(_, Math.round(C), !0), _ += 4, b.setUint16(_, t, !0), _ += 2, b.setUint16(_, c, !0), _ += 2, b.setUint16(_, 0, !0), y;
433
+ function Gn(r, t, c, a, m, p, g) {
434
+ const C = new ArrayBuffer(24), w = new DataView(C);
435
+ let O = 0;
436
+ return w.setUint8(O, xt.INJECT_TWO_FINGER_TOUCH_EVENT), O += 1, w.setUint8(O, r), O += 1, w.setInt32(O, Math.round(a), !0), O += 4, w.setInt32(O, Math.round(m), !0), O += 4, w.setInt32(O, Math.round(p), !0), O += 4, w.setInt32(O, Math.round(g), !0), O += 4, w.setUint16(O, t, !0), O += 2, w.setUint16(O, c, !0), O += 2, w.setUint16(O, 0, !0), C;
400
437
  }
401
- function $n(r, t = !0) {
438
+ function Jn(r, t = !0) {
402
439
  const a = new TextEncoder().encode(r), m = new ArrayBuffer(14 + a.length), p = new DataView(m);
403
- let C = 0;
404
- return p.setUint8(C, Pt.SET_CLIPBOARD), C += 1, p.setBigInt64(C, BigInt(0), !1), C += 8, p.setUint8(C, t ? 1 : 0), C += 1, p.setUint32(C, a.length, !1), C += 4, new Uint8Array(m, C).set(a), m;
440
+ let g = 0;
441
+ return p.setUint8(g, xt.SET_CLIPBOARD), g += 1, p.setBigInt64(g, BigInt(0), !1), g += 8, p.setUint8(g, t ? 1 : 0), g += 1, p.setUint32(g, a.length, !1), g += 4, new Uint8Array(m, g).set(a), m;
405
442
  }
406
- function pt(r, t, c = 0, a = 0) {
443
+ function gt(r, t, c = 0, a = 0) {
407
444
  const m = new ArrayBuffer(14), p = new DataView(m);
408
- let C = 0;
409
- return p.setUint8(C, Pt.INJECT_KEYCODE), C += 1, p.setUint8(C, r), C += 1, p.setInt32(C, t, !0), C += 4, p.setInt32(C, c, !0), C += 4, p.setInt32(C, a, !0), m;
445
+ let g = 0;
446
+ return p.setUint8(g, xt.INJECT_KEYCODE), g += 1, p.setUint8(g, r), g += 1, p.setInt32(g, t, !0), g += 4, p.setInt32(g, c, !0), g += 4, p.setInt32(g, a, !0), m;
410
447
  }
411
- const er = "Accessibility unavailable on this device.", kt = 500, Xr = (r, t) => Math.abs(r.x - t.x) < 0.5 && Math.abs(r.y - t.y) < 0.5 && Math.abs(r.width - t.width) < 0.5 && Math.abs(r.height - t.height) < 0.5, Xn = (r) => Math.max(0, r.width) * Math.max(0, r.height), Bn = (r) => {
448
+ const or = "Accessibility unavailable on this device.", Lt = 500, Vr = (r, t) => Math.abs(r.x - t.x) < 0.5 && Math.abs(r.y - t.y) < 0.5 && Math.abs(r.width - t.width) < 0.5 && Math.abs(r.height - t.height) < 0.5, jn = (r) => Math.max(0, r.width) * Math.max(0, r.height), zn = (r) => {
412
449
  const t = r.find((c) => c.frame && c.frame.width > 0 && c.frame.height > 0);
413
450
  return t?.frame ? ((Math.abs(t.frame.x) > 0.5 || Math.abs(t.frame.y) > 0.5) && console.warn(
414
451
  `[ax-tree] iOS root frame is not anchored at (0,0): (${t.frame.x},${t.frame.y}). Element positions may be slightly off from the rendered video.`
415
452
  ), { x: 0, y: 0, width: t.frame.width, height: t.frame.height }) : { x: 0, y: 0, width: 1, height: 1 };
416
- }, qn = (r) => {
453
+ }, Qn = (r) => {
417
454
  const t = {};
418
455
  return typeof r.AXUniqueId == "string" && r.AXUniqueId.length > 0 && (t.AXUniqueId = r.AXUniqueId), typeof r.AXLabel == "string" && r.AXLabel.length > 0 && (t.AXLabel = r.AXLabel), typeof r.type == "string" && r.type.length > 0 && (t.className = r.type), t;
419
- }, Vn = (r) => {
456
+ }, Zn = (r) => {
420
457
  const t = {};
421
458
  for (const [c, a] of Object.entries(r))
422
459
  c !== "children" && (t[c] = a);
423
460
  return t;
424
461
  };
425
- function Gn(r) {
426
- const t = Array.isArray(r) ? r : [r], c = Bn(t), a = [], m = (p, C) => {
427
- if (a.length >= kt) return;
428
- const y = p.frame;
429
- if (y && y.width > 0 && y.height > 0 && !Xr(y, c)) {
430
- const _ = p.role_description || p.role || "", M = (typeof p.AXLabel == "string" ? p.AXLabel : "") || (typeof p.title == "string" ? p.title : "") || "";
462
+ function eo(r) {
463
+ const t = Array.isArray(r) ? r : [r], c = zn(t), a = [], m = (p, g) => {
464
+ if (a.length >= Lt) return;
465
+ const C = p.frame;
466
+ if (C && C.width > 0 && C.height > 0 && !Vr(C, c)) {
467
+ const O = p.role_description || p.role || "", M = (typeof p.AXLabel == "string" ? p.AXLabel : "") || (typeof p.title == "string" ? p.title : "") || "";
431
468
  a.push({
432
- id: typeof p.AXUniqueId == "string" && p.AXUniqueId.length > 0 ? p.AXUniqueId : C,
433
- path: C,
469
+ id: typeof p.AXUniqueId == "string" && p.AXUniqueId.length > 0 ? p.AXUniqueId : g,
470
+ path: g,
434
471
  label: M,
435
472
  value: typeof p.AXValue == "string" ? p.AXValue : "",
436
- role: _,
473
+ role: O,
437
474
  type: typeof p.type == "string" ? p.type : "",
438
475
  enabled: p.enabled !== !1,
439
476
  focused: p.focused === !0,
440
- frame: { x: y.x, y: y.y, width: y.width, height: y.height },
441
- selectors: qn(p),
442
- raw: Vn(p)
477
+ frame: { x: C.x, y: C.y, width: C.width, height: C.height },
478
+ selectors: Qn(p),
479
+ raw: Zn(p)
443
480
  });
444
481
  }
445
- const b = Array.isArray(p.children) ? p.children : [];
446
- for (let _ = 0; _ < b.length && a.length < kt; _++)
447
- m(b[_], `${C}.${_}`);
482
+ const w = Array.isArray(p.children) ? p.children : [];
483
+ for (let O = 0; O < w.length && a.length < Lt; O++)
484
+ m(w[O], `${g}.${O}`);
448
485
  };
449
- for (let p = 0; p < t.length && a.length < kt; p++)
486
+ for (let p = 0; p < t.length && a.length < Lt; p++)
450
487
  m(t[p], String(p));
451
488
  return {
452
489
  platform: "ios",
@@ -455,40 +492,40 @@ function Gn(r) {
455
492
  capturedAt: Date.now()
456
493
  };
457
494
  }
458
- const Jn = (r) => {
495
+ const to = (r) => {
459
496
  let t = { x: 0, y: 0, width: 1, height: 1 }, c = 0;
460
497
  for (const a of r) {
461
498
  const m = a.parsedBounds;
462
499
  if (!m) continue;
463
- const p = m.right - m.left, C = m.bottom - m.top, y = Math.max(0, p) * Math.max(0, C);
464
- y > c && (c = y, t = { x: 0, y: 0, width: p, height: C });
500
+ const p = m.right - m.left, g = m.bottom - m.top, C = Math.max(0, p) * Math.max(0, g);
501
+ C > c && (c = C, t = { x: 0, y: 0, width: p, height: g });
465
502
  }
466
503
  return t;
467
- }, jn = (r) => {
504
+ }, ro = (r) => {
468
505
  const t = {};
469
506
  return typeof r.resourceId == "string" && r.resourceId.length > 0 && (t.resourceId = r.resourceId), typeof r.contentDesc == "string" && r.contentDesc.length > 0 && (t.contentDesc = r.contentDesc), typeof r.text == "string" && r.text.length > 0 && (t.text = r.text), typeof r.className == "string" && r.className.length > 0 && (t.className = r.className), t;
470
507
  };
471
- function zn(r) {
472
- const t = Jn(r), c = [];
473
- for (let a = 0; a < r.length && c.length < kt; a++) {
508
+ function no(r) {
509
+ const t = to(r), c = [];
510
+ for (let a = 0; a < r.length && c.length < Lt; a++) {
474
511
  const m = r[a], p = m.parsedBounds;
475
512
  if (!p) continue;
476
- const C = Math.max(0, p.right - p.left), y = Math.max(0, p.bottom - p.top);
477
- if (C <= 0 || y <= 0) continue;
478
- const b = { x: p.left, y: p.top, width: C, height: y };
479
- if (Xr(b, { x: 0, y: 0, width: t.width, height: t.height })) continue;
480
- const _ = m.contentDesc || m.text || "", M = m.className || "";
513
+ const g = Math.max(0, p.right - p.left), C = Math.max(0, p.bottom - p.top);
514
+ if (g <= 0 || C <= 0) continue;
515
+ const w = { x: p.left, y: p.top, width: g, height: C };
516
+ if (Vr(w, { x: 0, y: 0, width: t.width, height: t.height })) continue;
517
+ const O = m.contentDesc || m.text || "", M = m.className || "";
481
518
  c.push({
482
519
  id: m.resourceId && m.resourceId.length > 0 ? m.resourceId : m.contentDesc && m.contentDesc.length > 0 ? `cd:${m.contentDesc}` : String(a),
483
520
  path: String(a),
484
- label: _,
521
+ label: O,
485
522
  value: typeof m.text == "string" ? m.text : "",
486
523
  role: M,
487
524
  type: M,
488
525
  enabled: m.enabled !== !1,
489
526
  focused: m.focused === !0,
490
- frame: b,
491
- selectors: jn(m),
527
+ frame: w,
528
+ selectors: ro(m),
492
529
  raw: { ...m }
493
530
  });
494
531
  }
@@ -499,34 +536,34 @@ function zn(r) {
499
536
  capturedAt: Date.now()
500
537
  };
501
538
  }
502
- function Qn(r, t) {
503
- const c = Math.max(0, r.x), a = Math.max(0, r.y), m = Math.min(t.width, r.x + r.width), p = Math.min(t.height, r.y + r.height), C = Math.max(0, m - c), y = Math.max(0, p - a);
504
- return C > 0 && y > 0 ? { x: c, y: a, width: C, height: y } : null;
539
+ function oo(r, t) {
540
+ const c = Math.max(0, r.x), a = Math.max(0, r.y), m = Math.min(t.width, r.x + r.width), p = Math.min(t.height, r.y + r.height), g = Math.max(0, m - c), C = Math.max(0, p - a);
541
+ return g > 0 && C > 0 ? { x: c, y: a, width: g, height: C } : null;
505
542
  }
506
- function Br(r, t) {
543
+ function Gr(r, t) {
507
544
  if (r === t) return !0;
508
545
  if (r.id !== t.id || r.path !== t.path || r.label !== t.label || r.value !== t.value || r.role !== t.role || r.type !== t.type || r.enabled !== t.enabled || r.focused !== t.focused) return !1;
509
546
  const c = r.frame, a = t.frame;
510
547
  return c.x === a.x && c.y === a.y && c.width === a.width && c.height === a.height;
511
548
  }
512
- function qr(r, t) {
549
+ function Jr(r, t) {
513
550
  if (r === t) return !0;
514
551
  if (!r || !t || r.platform !== t.platform || r.screen.width !== t.screen.width || r.screen.height !== t.screen.height || r.elements.length !== t.elements.length) return !1;
515
552
  for (let c = 0; c < r.elements.length; c++)
516
- if (!Br(r.elements[c], t.elements[c])) return !1;
553
+ if (!Gr(r.elements[c], t.elements[c])) return !1;
517
554
  return !0;
518
555
  }
519
- function Zn(r, t, c) {
556
+ function io(r, t, c) {
520
557
  let a = null, m = 1 / 0;
521
558
  for (const p of r.elements) {
522
- const C = p.frame;
523
- if (t < C.x || c < C.y || t > C.x + C.width || c > C.y + C.height) continue;
524
- const y = Xn(C);
525
- y < m && (m = y, a = p);
559
+ const g = p.frame;
560
+ if (t < g.x || c < g.y || t > g.x + g.width || c > g.y + g.height) continue;
561
+ const C = jn(g);
562
+ C < m && (m = C, a = p);
526
563
  }
527
564
  return a;
528
565
  }
529
- function eo(r, t) {
566
+ function co(r, t) {
530
567
  if (t === "ios") {
531
568
  if (r.selectors.AXUniqueId)
532
569
  return `client.tapElement({ AXUniqueId: ${JSON.stringify(r.selectors.AXUniqueId)} })`;
@@ -538,21 +575,21 @@ function eo(r, t) {
538
575
  }
539
576
  return r.selectors.resourceId ? `client.tap({ selector: { resourceId: ${JSON.stringify(r.selectors.resourceId)} } })` : r.selectors.contentDesc ? `client.tap({ selector: { contentDesc: ${JSON.stringify(r.selectors.contentDesc)} } })` : r.selectors.text ? `client.tap({ selector: { text: ${JSON.stringify(r.selectors.text)} } })` : null;
540
577
  }
541
- function Vr(r) {
578
+ function jr(r) {
542
579
  const t = r.role || r.type || "";
543
580
  if (!t) return "element";
544
581
  let c = t.replace(/^AX/, "");
545
582
  return c.includes(".") && (c = c.split(".").pop()), c === "GenericElement" ? "Element" : (c = c.replace(/([a-z])([A-Z])/g, "$1 $2"), c);
546
583
  }
547
- const kr = 80;
548
- function Gr(r) {
549
- const t = Vr(r), c = r.label || r.value || "";
584
+ const Lr = 80;
585
+ function zr(r) {
586
+ const t = jr(r), c = r.label || r.value || "";
550
587
  if (!c) return t;
551
- const a = c.length > kr ? c.slice(0, kr).trimEnd() + "…" : c;
588
+ const a = c.length > Lr ? c.slice(0, Lr).trimEnd() + "…" : c;
552
589
  return `${t} · ${a}`;
553
590
  }
554
- const to = 500, ro = 2e3, Pr = 5e3, no = 8e3, oo = 1200, io = 250, co = () => `ax-rc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
555
- class so {
591
+ const so = 500, ao = 2e3, xr = 5e3, uo = 8e3, lo = 1200, fo = 250, ho = () => `ax-rc-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
592
+ class po {
556
593
  platform;
557
594
  send;
558
595
  onSnapshot;
@@ -579,7 +616,7 @@ class so {
579
616
  // identical-to-current transitions are no-ops.
580
617
  status = "idle";
581
618
  constructor(t) {
582
- this.platform = t.platform, this.send = t.send, this.onSnapshot = t.onSnapshot, this.onStatusChange = t.onStatusChange, this.baseIntervalMs = t.baseIntervalMs ?? to, this.maxBackoffMs = t.maxBackoffMs ?? ro, this.androidElementTreeOptions = t.androidElementTreeOptions, this.currentInterval = this.baseIntervalMs;
619
+ this.platform = t.platform, this.send = t.send, this.onSnapshot = t.onSnapshot, this.onStatusChange = t.onStatusChange, this.baseIntervalMs = t.baseIntervalMs ?? so, this.maxBackoffMs = t.maxBackoffMs ?? ao, this.androidElementTreeOptions = t.androidElementTreeOptions, this.currentInterval = this.baseIntervalMs;
583
620
  }
584
621
  start() {
585
622
  this.running || (this.running = !0, this.currentInterval = this.baseIntervalMs, this.boostUntilMs = 0, this.setStatus("starting"), this.runOnce());
@@ -611,7 +648,7 @@ class so {
611
648
  bumpActivity() {
612
649
  if (!this.running) return;
613
650
  const t = Date.now();
614
- this.boostUntilMs = t + oo;
651
+ this.boostUntilMs = t + lo;
615
652
  const c = Math.max(150, Math.floor(this.baseIntervalMs / 2));
616
653
  if (t - this.lastBumpAtMs < c) {
617
654
  this.currentInterval = this.baseIntervalMs;
@@ -643,30 +680,30 @@ class so {
643
680
  if (!this.pending.get(c)) return !1;
644
681
  if (this.platform === "ios") {
645
682
  if (t.type !== "elementTreeResult") return !1;
646
- const y = typeof t.error == "string" ? t.error : null;
647
- if (y)
648
- return this.settleReject(c, new Error(y)), !0;
649
- const b = typeof t.json == "string" ? t.json : "";
683
+ const C = typeof t.error == "string" ? t.error : null;
684
+ if (C)
685
+ return this.settleReject(c, new Error(C)), !0;
686
+ const w = typeof t.json == "string" ? t.json : "";
650
687
  try {
651
- const _ = JSON.parse(b), M = Gn(_);
688
+ const O = JSON.parse(w), M = eo(O);
652
689
  this.settleResolve(c, M);
653
- } catch (_) {
654
- this.settleReject(c, _ instanceof Error ? _ : new Error(String(_)));
690
+ } catch (O) {
691
+ this.settleReject(c, O instanceof Error ? O : new Error(String(O)));
655
692
  }
656
693
  return !0;
657
694
  }
658
695
  if (t.type !== "getElementTreeResult") return !1;
659
696
  const m = t.error;
660
697
  if (m && typeof m == "object") {
661
- const y = typeof m.message == "string" ? m.message : "getElementTree failed";
662
- return this.settleReject(c, new Error(y)), !0;
698
+ const C = typeof m.message == "string" ? m.message : "getElementTree failed";
699
+ return this.settleReject(c, new Error(C)), !0;
663
700
  }
664
- const p = t.payload, C = Array.isArray(p?.nodes) ? p.nodes : [];
701
+ const p = t.payload, g = Array.isArray(p?.nodes) ? p.nodes : [];
665
702
  try {
666
- const y = zn(C);
667
- this.settleResolve(c, y);
668
- } catch (y) {
669
- this.settleReject(c, y instanceof Error ? y : new Error(String(y)));
703
+ const C = no(g);
704
+ this.settleResolve(c, C);
705
+ } catch (C) {
706
+ this.settleReject(c, C instanceof Error ? C : new Error(String(C)));
670
707
  }
671
708
  return !0;
672
709
  }
@@ -674,13 +711,13 @@ class so {
674
711
  return this.platform === "ios" ? { type: "elementTree", id: t } : { type: "getElementTree", id: t, ...this.androidElementTreeOptions };
675
712
  }
676
713
  async requestOnce() {
677
- const t = co();
714
+ const t = ho();
678
715
  return new Promise((c, a) => {
679
716
  const m = window.setTimeout(
680
717
  () => {
681
718
  this.pending.delete(t), a(new Error("elementTree request timed out"));
682
719
  },
683
- no + (this.androidElementTreeOptions?.waitForIdleTimeoutMs ?? 0)
720
+ uo + (this.androidElementTreeOptions?.waitForIdleTimeoutMs ?? 0)
684
721
  );
685
722
  this.pending.set(t, { resolve: c, reject: a, timer: m }), this.send(this.buildRequest(t)) || (window.clearTimeout(m), this.pending.delete(t), a(new Error("elementTree send failed (WebSocket not open)")));
686
723
  });
@@ -695,7 +732,7 @@ class so {
695
732
  } catch (t) {
696
733
  if (!this.running) return;
697
734
  const c = t instanceof Error ? t.message : String(t), a = /unavailable|not (yet )?running|failed|timeout/i.test(c);
698
- this.currentInterval = a ? Pr : Math.min(this.currentInterval * 2, this.maxBackoffMs), this.setStatus(a ? "unavailable" : "error", c);
735
+ this.currentInterval = a ? xr : Math.min(this.currentInterval * 2, this.maxBackoffMs), this.setStatus(a ? "unavailable" : "error", c);
699
736
  } finally {
700
737
  this.inflight = !1, this.scheduleNext();
701
738
  }
@@ -703,16 +740,16 @@ class so {
703
740
  }
704
741
  deliver(t) {
705
742
  const c = this.lastSnapshot;
706
- if (qr(c, t)) {
707
- this.currentInterval = Math.min(this.currentInterval * 2, this.maxBackoffMs), this.lastSnapshot = t, t.errors?.includes(er) || this.setStatus("ready");
743
+ if (Jr(c, t)) {
744
+ this.currentInterval = Math.min(this.currentInterval * 2, this.maxBackoffMs), this.lastSnapshot = t, t.errors?.includes(or) || this.setStatus("ready");
708
745
  return;
709
746
  }
710
- this.lastSnapshot = t, this.currentInterval = this.baseIntervalMs, t.errors?.includes(er) ? (this.currentInterval = Pr, this.setStatus("unavailable", er)) : this.setStatus("ready"), this.onSnapshot(t);
747
+ this.lastSnapshot = t, this.currentInterval = this.baseIntervalMs, t.errors?.includes(or) ? (this.currentInterval = xr, this.setStatus("unavailable", or)) : this.setStatus("ready"), this.onSnapshot(t);
711
748
  }
712
749
  scheduleNext() {
713
750
  if (!this.running) return;
714
751
  this.timer !== void 0 && window.clearTimeout(this.timer);
715
- const t = Date.now() < this.boostUntilMs ? Math.min(io, this.currentInterval) : this.currentInterval;
752
+ const t = Date.now() < this.boostUntilMs ? Math.min(fo, this.currentInterval) : this.currentInterval;
716
753
  this.timer = window.setTimeout(() => {
717
754
  this.timer = void 0, this.runOnce();
718
755
  }, t);
@@ -730,7 +767,7 @@ class so {
730
767
  window.clearTimeout(a.timer), a.reject(new Error(t)), this.pending.delete(c);
731
768
  }
732
769
  }
733
- class ao {
770
+ class mo {
734
771
  generation = 0;
735
772
  tail = Promise.resolve();
736
773
  get currentGeneration() {
@@ -761,23 +798,23 @@ class ao {
761
798
  ++this.generation;
762
799
  }
763
800
  }
764
- function uo(r) {
801
+ function Eo(r) {
765
802
  if (!r || typeof r != "object") return null;
766
803
  const t = r;
767
804
  if (t.type !== "cameraRequest" || typeof t.active != "boolean") return null;
768
805
  const c = { active: t.active };
769
806
  return (t.facingMode === "user" || t.facingMode === "environment") && (c.facingMode = t.facingMode), c;
770
807
  }
771
- function lo(r) {
808
+ function go(r) {
772
809
  const t = {
773
810
  frameRate: { ideal: 30, max: 30 }
774
811
  };
775
812
  return r?.facingMode && (t.facingMode = { ideal: r.facingMode }), t;
776
813
  }
777
- function fo(r, t) {
814
+ function yo(r, t) {
778
815
  return !r || r.facingMode !== t.facingMode;
779
816
  }
780
- function ho(r) {
817
+ function Co(r) {
781
818
  const t = r.getSettings();
782
819
  return {
783
820
  width: t.width,
@@ -788,14 +825,14 @@ function ho(r) {
788
825
  facingMode: t.facingMode
789
826
  };
790
827
  }
791
- function po(r) {
828
+ function vo(r) {
792
829
  return {
793
830
  type: "cameraResult",
794
831
  granted: !0,
795
- camera: ho(r)
832
+ camera: Co(r)
796
833
  };
797
834
  }
798
- const mo = async (r) => {
835
+ const Oo = async (r) => {
799
836
  if (!r) return !1;
800
837
  try {
801
838
  if (typeof navigator < "u" && navigator.clipboard?.writeText)
@@ -810,90 +847,90 @@ const mo = async (r) => {
810
847
  } catch {
811
848
  return !1;
812
849
  }
813
- }, Eo = rr(
814
- function({ element: t, screen: c, highlighted: a, selected: m, selectable: p, onClick: C }) {
815
- const y = Qn(t.frame, c);
816
- if (!y) return null;
817
- const b = Gr(t);
818
- return /* @__PURE__ */ k(
850
+ }, _o = cr(
851
+ function({ element: t, screen: c, highlighted: a, selected: m, selectable: p, onClick: g }) {
852
+ const C = oo(t.frame, c);
853
+ if (!C) return null;
854
+ const w = zr(t);
855
+ return /* @__PURE__ */ P(
819
856
  "button",
820
857
  {
821
858
  type: "button",
822
- className: ke("rc-inspect-box", !t.enabled && "rc-inspect-box-disabled"),
859
+ className: Pe("rc-inspect-box", !t.enabled && "rc-inspect-box-disabled"),
823
860
  "data-ax-id": t.id,
824
861
  "data-ax-path": t.path,
825
862
  "data-ax-label": t.label || void 0,
826
863
  "data-ax-role": t.role || void 0,
827
864
  "data-highlighted": a ? "true" : "false",
828
865
  "data-selected": m ? "true" : "false",
829
- "aria-label": b,
830
- onClick: (_) => {
831
- p && (_.preventDefault(), _.stopPropagation(), C(t, { x: _.clientX, y: _.clientY }));
866
+ "aria-label": w,
867
+ onClick: (O) => {
868
+ p && (O.preventDefault(), O.stopPropagation(), g(t, { x: O.clientX, y: O.clientY }));
832
869
  },
833
870
  style: {
834
- left: `${y.x / c.width * 100}%`,
835
- top: `${y.y / c.height * 100}%`,
836
- width: `${y.width / c.width * 100}%`,
837
- height: `${y.height / c.height * 100}%`
871
+ left: `${C.x / c.width * 100}%`,
872
+ top: `${C.y / c.height * 100}%`,
873
+ width: `${C.width / c.width * 100}%`,
874
+ height: `${C.height / c.height * 100}%`
838
875
  }
839
876
  }
840
877
  );
841
878
  },
842
- (r, t) => r.highlighted === t.highlighted && r.selected === t.selected && r.selectable === t.selectable && r.screen.width === t.screen.width && r.screen.height === t.screen.height && r.onClick === t.onClick && Br(r.element, t.element)
843
- ), go = 260, Co = 220, yo = 6, vo = 8, Oo = rr(function({
879
+ (r, t) => r.highlighted === t.highlighted && r.selected === t.selected && r.selectable === t.selectable && r.screen.width === t.screen.width && r.screen.height === t.screen.height && r.onClick === t.onClick && Gr(r.element, t.element)
880
+ ), To = 260, wo = 220, Do = 6, Ao = 8, bo = cr(function({
844
881
  element: t,
845
882
  platform: c,
846
883
  anchor: a,
847
884
  cursorAnchored: m,
848
885
  showActions: p,
849
- onTap: C
886
+ onTap: g
850
887
  }) {
851
- const [y, b] = V(null);
852
- pe(() => {
853
- if (!y) return;
854
- const X = window.setTimeout(() => b(null), 1100);
855
- return () => window.clearTimeout(X);
856
- }, [y]);
857
- const _ = Ke(() => {
858
- const X = go, me = Co, ce = yo, H = vo, Ee = typeof window < "u" ? window.innerWidth : 1024, mt = typeof window < "u" ? window.innerHeight : 768, Pe = a.x + ce + X <= Ee - H, ge = a.y - ce - me >= H;
859
- let F = Pe ? a.x + ce : a.x - ce, _e = ge ? a.y - ce : a.y + ce;
860
- const Lt = `translate(${Pe ? "0" : "-100%"}, ${ge ? "-100%" : "0"})`;
861
- return F = Math.max(H + (Pe ? 0 : X), Math.min(Ee - H - (Pe ? X : 0), F)), _e = Math.max(H + (ge ? me : 0), Math.min(mt - H - (ge ? 0 : me), _e)), { left: `${F}px`, top: `${_e}px`, transform: Lt };
862
- }, [a.x, a.y]), M = Ke(() => eo(t, c), [t, c]), S = c === "ios" ? t.selectors.AXUniqueId : t.selectors.resourceId, G = c === "ios" ? "AXUniqueId" : "resourceId", ie = In(async (X, me) => {
863
- if (!X) return;
864
- await mo(X) && b(me);
865
- }, []), J = Vr(t), de = t.label || t.value || J, Z = Gr(t);
866
- return Un(
867
- /* @__PURE__ */ ae(
888
+ const [C, w] = G(null);
889
+ me(() => {
890
+ if (!C) return;
891
+ const B = window.setTimeout(() => w(null), 1100);
892
+ return () => window.clearTimeout(B);
893
+ }, [C]);
894
+ const O = ke(() => {
895
+ const B = To, Ee = wo, se = Do, H = Ao, ge = typeof window < "u" ? window.innerWidth : 1024, tt = typeof window < "u" ? window.innerHeight : 768, De = a.x + se + B <= ge - H, Ue = a.y - se - Ee >= H;
896
+ let _e = De ? a.x + se : a.x - se, W = Ue ? a.y - se : a.y + se;
897
+ const Wt = `translate(${De ? "0" : "-100%"}, ${Ue ? "-100%" : "0"})`;
898
+ return _e = Math.max(H + (De ? 0 : B), Math.min(ge - H - (De ? B : 0), _e)), W = Math.max(H + (Ue ? Ee : 0), Math.min(tt - H - (Ue ? 0 : Ee), W)), { left: `${_e}px`, top: `${W}px`, transform: Wt };
899
+ }, [a.x, a.y]), M = ke(() => co(t, c), [t, c]), S = c === "ios" ? t.selectors.AXUniqueId : t.selectors.resourceId, X = c === "ios" ? "AXUniqueId" : "resourceId", ce = Un(async (B, Ee) => {
900
+ if (!B) return;
901
+ await Oo(B) && w(Ee);
902
+ }, []), J = jr(t), fe = t.label || t.value || J, ee = zr(t);
903
+ return Hn(
904
+ /* @__PURE__ */ ue(
868
905
  "div",
869
906
  {
870
907
  className: "rc-inspect-card",
871
908
  "data-cursor-anchored": m ? "true" : "false",
872
- style: _,
873
- onClick: (X) => X.stopPropagation(),
874
- onMouseDown: (X) => X.stopPropagation(),
875
- onMouseMove: (X) => X.stopPropagation(),
909
+ style: O,
910
+ onClick: (B) => B.stopPropagation(),
911
+ onMouseDown: (B) => B.stopPropagation(),
912
+ onMouseMove: (B) => B.stopPropagation(),
876
913
  children: [
877
- /* @__PURE__ */ ae("div", { className: "rc-inspect-card-header", children: [
878
- /* @__PURE__ */ k("span", { className: "rc-inspect-card-role", children: J }),
879
- !t.enabled && /* @__PURE__ */ k("span", { className: "rc-inspect-card-tag", children: "disabled" }),
880
- t.focused && /* @__PURE__ */ k("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
914
+ /* @__PURE__ */ ue("div", { className: "rc-inspect-card-header", children: [
915
+ /* @__PURE__ */ P("span", { className: "rc-inspect-card-role", children: J }),
916
+ !t.enabled && /* @__PURE__ */ P("span", { className: "rc-inspect-card-tag", children: "disabled" }),
917
+ t.focused && /* @__PURE__ */ P("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
881
918
  ] }),
882
- /* @__PURE__ */ k("p", { className: "rc-inspect-card-title", title: Z, children: de }),
883
- S && /* @__PURE__ */ ae("div", { className: "rc-inspect-card-row", children: [
884
- /* @__PURE__ */ ae("span", { className: "rc-inspect-card-row-label", children: [
885
- G,
919
+ /* @__PURE__ */ P("p", { className: "rc-inspect-card-title", title: ee, children: fe }),
920
+ S && /* @__PURE__ */ ue("div", { className: "rc-inspect-card-row", children: [
921
+ /* @__PURE__ */ ue("span", { className: "rc-inspect-card-row-label", children: [
922
+ X,
886
923
  ":"
887
924
  ] }),
888
- /* @__PURE__ */ k("span", { className: "rc-inspect-card-row-value", children: S })
925
+ /* @__PURE__ */ P("span", { className: "rc-inspect-card-row-value", children: S })
889
926
  ] }),
890
- t.value && t.value !== t.label && /* @__PURE__ */ ae("div", { className: "rc-inspect-card-row", children: [
891
- /* @__PURE__ */ k("span", { className: "rc-inspect-card-row-label", children: "value:" }),
892
- /* @__PURE__ */ k("span", { className: "rc-inspect-card-row-value", children: t.value })
927
+ t.value && t.value !== t.label && /* @__PURE__ */ ue("div", { className: "rc-inspect-card-row", children: [
928
+ /* @__PURE__ */ P("span", { className: "rc-inspect-card-row-label", children: "value:" }),
929
+ /* @__PURE__ */ P("span", { className: "rc-inspect-card-row-value", children: t.value })
893
930
  ] }),
894
- /* @__PURE__ */ ae("div", { className: "rc-inspect-card-row", children: [
895
- /* @__PURE__ */ k("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
896
- /* @__PURE__ */ ae("span", { className: "rc-inspect-card-row-value", children: [
931
+ /* @__PURE__ */ ue("div", { className: "rc-inspect-card-row", children: [
932
+ /* @__PURE__ */ P("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
933
+ /* @__PURE__ */ ue("span", { className: "rc-inspect-card-row-value", children: [
897
934
  Math.round(t.frame.width),
898
935
  "×",
899
936
  Math.round(t.frame.height),
@@ -903,36 +940,36 @@ const mo = async (r) => {
903
940
  Math.round(t.frame.y)
904
941
  ] })
905
942
  ] }),
906
- p && /* @__PURE__ */ ae("div", { className: "rc-inspect-card-actions", children: [
907
- /* @__PURE__ */ k(
943
+ p && /* @__PURE__ */ ue("div", { className: "rc-inspect-card-actions", children: [
944
+ /* @__PURE__ */ P(
908
945
  "button",
909
946
  {
910
947
  type: "button",
911
948
  className: "rc-inspect-card-btn rc-inspect-card-btn-primary",
912
- onClick: () => C(t, a),
949
+ onClick: () => g(t, a),
913
950
  children: "Tap"
914
951
  }
915
952
  ),
916
- /* @__PURE__ */ k(
953
+ /* @__PURE__ */ P(
917
954
  "button",
918
955
  {
919
956
  type: "button",
920
- className: ke("rc-inspect-card-btn", y === "selector" && "rc-inspect-card-btn-copied"),
957
+ className: Pe("rc-inspect-card-btn", C === "selector" && "rc-inspect-card-btn-copied"),
921
958
  disabled: !M,
922
959
  title: M ?? "No usable selector for this element",
923
- onClick: () => ie(M ?? void 0, "selector"),
924
- children: y === "selector" ? "Copied!" : "Copy selector"
960
+ onClick: () => ce(M ?? void 0, "selector"),
961
+ children: C === "selector" ? "Copied!" : "Copy selector"
925
962
  }
926
963
  ),
927
- /* @__PURE__ */ k(
964
+ /* @__PURE__ */ P(
928
965
  "button",
929
966
  {
930
967
  type: "button",
931
- className: ke("rc-inspect-card-btn", y === "id" && "rc-inspect-card-btn-copied"),
968
+ className: Pe("rc-inspect-card-btn", C === "id" && "rc-inspect-card-btn-copied"),
932
969
  disabled: !S,
933
- title: S ?? `No ${G}`,
934
- onClick: () => ie(S, "id"),
935
- children: y === "id" ? "Copied!" : `Copy ${G}`
970
+ title: S ?? `No ${X}`,
971
+ onClick: () => ce(S, "id"),
972
+ children: C === "id" ? "Copied!" : `Copy ${X}`
936
973
  }
937
974
  )
938
975
  ] })
@@ -941,68 +978,68 @@ const mo = async (r) => {
941
978
  ),
942
979
  document.body
943
980
  );
944
- }), _o = rr(function({
981
+ }), So = cr(function({
945
982
  snapshot: t,
946
983
  geometry: c,
947
984
  highlightedId: a,
948
985
  selectedId: m,
949
986
  mode: p,
950
- cursorPosition: C,
951
- frozenCursorPosition: y,
952
- onSelectChange: b,
953
- onTapElement: _
987
+ cursorPosition: g,
988
+ frozenCursorPosition: C,
989
+ onSelectChange: w,
990
+ onTapElement: O
954
991
  }) {
955
- const M = p === "select", S = M ? a !== null && a !== m : a !== null, G = M ? a ?? m : a, ie = Ke(() => {
992
+ const M = p === "select", S = M ? a !== null && a !== m : a !== null, X = M ? a ?? m : a, ce = ke(() => {
956
993
  const H = /* @__PURE__ */ new Map();
957
994
  if (!t) return H;
958
- for (const Ee of t.elements) H.set(Ee.id, Ee);
995
+ for (const ge of t.elements) H.set(ge.id, ge);
959
996
  return H;
960
- }, [t]), J = Ke(() => G ? ie.get(G) ?? null : null, [G, ie]);
997
+ }, [t]), J = ke(() => X ? ce.get(X) ?? null : null, [X, ce]);
961
998
  if (!(!!t && !!c && t.screen.width > 0 && t.screen.height > 0 && t.elements.length > 0)) return null;
962
- const Z = S ? C : y ?? C, X = S, me = M && !S && m !== null, ce = (H) => {
963
- M && H.target === H.currentTarget && b(null, null);
999
+ const ee = S ? g : C ?? g, B = S, Ee = M && !S && m !== null, se = (H) => {
1000
+ M && H.target === H.currentTarget && w(null, null);
964
1001
  };
965
- return /* @__PURE__ */ ae(Fr, { children: [
966
- /* @__PURE__ */ k(
1002
+ return /* @__PURE__ */ ue($r, { children: [
1003
+ /* @__PURE__ */ P(
967
1004
  "div",
968
1005
  {
969
- className: ke("rc-inspect-overlay", M && "rc-inspect-overlay-select"),
1006
+ className: Pe("rc-inspect-overlay", M && "rc-inspect-overlay-select"),
970
1007
  style: {
971
1008
  left: `${c.left}px`,
972
1009
  top: `${c.top}px`,
973
1010
  width: `${c.width}px`,
974
1011
  height: `${c.height}px`
975
1012
  },
976
- onClick: ce,
977
- children: t.elements.map((H) => /* @__PURE__ */ k(
978
- Eo,
1013
+ onClick: se,
1014
+ children: t.elements.map((H) => /* @__PURE__ */ P(
1015
+ _o,
979
1016
  {
980
1017
  element: H,
981
1018
  screen: t.screen,
982
1019
  highlighted: H.id === a,
983
1020
  selected: H.id === m,
984
1021
  selectable: M,
985
- onClick: b
1022
+ onClick: w
986
1023
  },
987
1024
  H.id
988
1025
  ))
989
1026
  }
990
1027
  ),
991
- J && Z && /* @__PURE__ */ k(
992
- Oo,
1028
+ J && ee && /* @__PURE__ */ P(
1029
+ bo,
993
1030
  {
994
1031
  element: J,
995
1032
  platform: t.platform,
996
- anchor: Z,
997
- cursorAnchored: X,
998
- showActions: me,
999
- onTap: _
1033
+ anchor: ee,
1034
+ cursorAnchored: B,
1035
+ showActions: Ee,
1036
+ onTap: O
1000
1037
  }
1001
1038
  )
1002
1039
  ] });
1003
- }), Do = Yn(() => import("./duo-view-C0jN3Y-c.mjs").then((r) => r.d)), x = (...r) => {
1040
+ }), Mo = Ln(() => import("./duo-view-DSZO0-zg.mjs").then((r) => r.d)), F = (...r) => {
1004
1041
  window.debugRemoteControl && console.log(...r);
1005
- }, w = (...r) => {
1042
+ }, A = (...r) => {
1006
1043
  window.debugRemoteControl && console.warn(...r);
1007
1044
  }, L = (r, t, ...c) => {
1008
1045
  if (t)
@@ -1011,12 +1048,12 @@ const mo = async (r) => {
1011
1048
  } catch (a) {
1012
1049
  console.error(`[RemoteControl] customer callback "${r}" threw:`, a);
1013
1050
  }
1014
- }, Kt = (r) => Object.entries(U).find(
1051
+ }, Ut = (r) => Object.entries(K).find(
1015
1052
  ([c, a]) => c.startsWith("ACTION_") && a === r
1016
- )?.[0] ?? String(r), To = (r) => r.includes("/android_") ? "android" : "ios", Ur = (r, t) => {
1053
+ )?.[0] ?? String(r), Ro = (r) => r.includes("/android_") ? "android" : "ios", Fr = (r, t) => {
1017
1054
  const c = new URL(r);
1018
1055
  return c.searchParams.set("token", t), c.toString();
1019
- }, Lr = 1920, xr = 1200, tr = 3, wo = 1e3, Ao = 15e3, bo = 3e3, So = 4e3, Mo = (r, t) => r === Lr && t === xr || r === xr && t === Lr, Ro = {
1056
+ }, Wr = 1920, Hr = 1200, ir = 3, No = 1e3, Io = 15e3, Yo = 3e3, Ko = 4e3, ko = (r, t) => r === Wr && t === Hr || r === Hr && t === Wr, Po = {
1020
1057
  ios: {
1021
1058
  videoBorderRadiusMultiplier: 0.15,
1022
1059
  loadingLogoSize: "20%",
@@ -1036,16 +1073,16 @@ const mo = async (r) => {
1036
1073
  }
1037
1074
  }
1038
1075
  };
1039
- function No(r) {
1040
- const t = r.code, c = Hr[t];
1076
+ function Uo(r) {
1077
+ const t = r.code, c = Br[t];
1041
1078
  if (!c)
1042
- return w(`Unknown event.code: ${t}, key: ${r.key}`), null;
1079
+ return A(`Unknown event.code: ${t}, key: ${r.key}`), null;
1043
1080
  let a = s.META_NONE;
1044
- const m = t >= "KeyA" && t <= "KeyZ", p = r.getModifierState("CapsLock"), C = r.shiftKey;
1045
- let y = C;
1046
- return m && (y = C !== p), y && (a |= s.META_SHIFT_ON), r.ctrlKey && (a |= s.META_CTRL_ON), r.altKey && (a |= s.META_ALT_ON), r.metaKey && (a |= s.META_META_ON), { keycode: c, metaState: a };
1081
+ const m = t >= "KeyA" && t <= "KeyZ", p = r.getModifierState("CapsLock"), g = r.shiftKey;
1082
+ let C = g;
1083
+ return m && (C = g !== p), C && (a |= s.META_SHIFT_ON), r.ctrlKey && (a |= s.META_CTRL_ON), r.altKey && (a |= s.META_ALT_ON), r.metaKey && (a |= s.META_META_ON), { keycode: c, metaState: a };
1047
1084
  }
1048
- const Xo = Kn(
1085
+ const jo = xn(
1049
1086
  ({
1050
1087
  className: r,
1051
1088
  url: t,
@@ -1053,115 +1090,118 @@ const Xo = Kn(
1053
1090
  sessionId: a,
1054
1091
  openUrl: m,
1055
1092
  showFrame: p = !0,
1056
- deviceModel: C,
1057
- duoModelUrl: y,
1058
- autoReconnect: b = !1,
1059
- onTerminated: _,
1093
+ deviceModel: g,
1094
+ duoModelUrl: C,
1095
+ autoReconnect: w = !1,
1096
+ onTerminated: O,
1060
1097
  assets: M,
1061
1098
  onConnectionStateChange: S,
1062
- inspectMode: G,
1063
- onAxSnapshotChange: ie,
1099
+ inspectMode: X,
1100
+ onAxSnapshotChange: ce,
1064
1101
  onInspectSelectionChange: J,
1065
- onAxStatusChange: de,
1066
- axPollIntervalMs: Z,
1067
- axMaxBackoffMs: X,
1068
- androidElementTreeOptions: me,
1069
- onCameraDemandChange: ce,
1102
+ onAxStatusChange: fe,
1103
+ axPollIntervalMs: ee,
1104
+ axMaxBackoffMs: B,
1105
+ androidElementTreeOptions: Ee,
1106
+ onCameraDemandChange: se,
1070
1107
  onCameraStats: H,
1071
- microphoneEnabled: Ee = !1,
1072
- onMicrophoneStateChange: mt
1073
- }, Pe) => {
1074
- const ge = O(null), F = O(null), _e = O(/* @__PURE__ */ new Map()), Ut = O(null), [nr, Lt] = V(!1), Ce = C === "iphone-duo" || nr, et = O(null), [or, ir] = V(null), [cr, sr] = V(), Ue = O(
1108
+ onTrace: ge,
1109
+ microphoneEnabled: tt = !1,
1110
+ onMicrophoneStateChange: De
1111
+ }, Ue) => {
1112
+ const _e = v(null), W = v(null), rt = v(/* @__PURE__ */ new Map()), Ft = v(null), [Wt, Qr] = G(!1), ye = g === "iphone-duo" || Wt, nt = v(null), [sr, ar] = G(null), [ur, lr] = G(), Le = v(
1075
1113
  /* @__PURE__ */ new Map()
1076
- ), xt = (e, i) => new Promise((o, n) => {
1077
- const l = T.current;
1114
+ ), Ht = (e, i) => new Promise((o, n) => {
1115
+ const l = D.current;
1078
1116
  if (!l || l.readyState !== WebSocket.OPEN) {
1079
1117
  n(new Error("Simulator disconnected"));
1080
1118
  return;
1081
1119
  }
1082
1120
  const u = crypto.randomUUID(), f = setTimeout(() => {
1083
- Ue.current.delete(u), n(new Error("Device control timed out"));
1121
+ Le.current.delete(u), n(new Error("Device control timed out"));
1084
1122
  }, 5e3);
1085
- Ue.current.set(u, { resolve: o, reject: n, timer: f }), l.send(JSON.stringify({ type: e, id: u, ...i }));
1086
- }), [Jr, Ft] = V(!1), [jr, Et] = V(!1), [zr, ar] = V(!1), Le = O(!1), Wt = O(!1), [ur, Qr] = V(!1), [Zr, en] = V(!1), [tn, lr] = V({}), T = O(null), W = O(null), P = O(null), xe = O(void 0), tt = O(void 0), rt = O(void 0), gt = O(void 0), Fe = O(void 0), we = O(0), Ct = O(0), ye = O(!1), Ht = O(b);
1087
- Ht.current = b;
1088
- const Ae = O(null), re = O(null), be = O(void 0), $t = Ke(() => new ao(), []), ve = O(ce);
1089
- ve.current = ce;
1090
- const yt = O(H);
1091
- yt.current = H;
1092
- const nt = O(null), vt = O(null), Xt = O(Ee);
1093
- Xt.current = Ee;
1094
- const Bt = O(!1), ot = O(mt);
1095
- ot.current = mt;
1096
- const it = O(null), fe = O(null), Ot = O(0), dr = O(Promise.resolve()), We = O(null), ct = O(!1), De = O(/* @__PURE__ */ new Map()), Oe = O(/* @__PURE__ */ new Map()), Se = O(/* @__PURE__ */ new Map()), Me = O(/* @__PURE__ */ new Map()), Q = O(/* @__PURE__ */ new Map()), Re = O(!1), [rn, nn] = V(!1), B = O(null), He = O(null), st = O({
1123
+ Le.current.set(u, { resolve: o, reject: n, timer: f }), l.send(JSON.stringify({ type: e, id: u, ...i }));
1124
+ }), [Zr, $t] = G(!1), [en, yt] = G(!1), [tn, dr] = G(!1), xe = v(!1), Xt = v(!1), [fr, rn] = G(!1), [nn, on] = G(!1), [cn, hr] = G({}), D = v(null), x = v(null), U = v(null), Ct = v(null), Bt = v(ge);
1125
+ Bt.current = ge;
1126
+ const sn = !!ge, Fe = v(void 0), ot = v(void 0), it = v(void 0), vt = v(void 0), We = v(void 0), Ae = v(0), Ot = v(0), Ce = v(!1), qt = v(w);
1127
+ qt.current = w;
1128
+ const be = v(null), ne = v(null), Se = v(void 0), Vt = ke(() => new mo(), []), ve = v(se);
1129
+ ve.current = se;
1130
+ const _t = v(H);
1131
+ _t.current = H;
1132
+ const ct = v(null), Tt = v(null), Gt = v(tt);
1133
+ Gt.current = tt;
1134
+ const Jt = v(!1), st = v(De);
1135
+ st.current = De;
1136
+ const at = v(null), he = v(null), wt = v(0), pr = v(Promise.resolve()), He = v(null), ut = v(!1), Te = v(/* @__PURE__ */ new Map()), Oe = v(/* @__PURE__ */ new Map()), Me = v(/* @__PURE__ */ new Map()), Re = v(/* @__PURE__ */ new Map()), Z = v(/* @__PURE__ */ new Map()), Ne = v(!1), [an, un] = G(!1), q = v(null), $e = v(null), lt = v({
1097
1137
  handle: () => {
1098
1138
  },
1099
1139
  end: () => {
1100
1140
  }
1101
- }), [Ne, _t] = V(null), ee = O(null), [fr, hr] = V(null), [qt, at] = V(null), [Vt, Dt] = V(null), [on, pr] = V(null), [cn, mr] = V(null), Tt = O(null), se = O(void 0), Er = (e) => {
1102
- Tt.current = e, se.current === void 0 && (se.current = window.requestAnimationFrame(() => {
1103
- se.current = void 0, mr(Tt.current);
1141
+ }), [Ie, Dt] = G(null), te = v(null), [mr, Er] = G(null), [jt, dt] = G(null), [zt, At] = G(null), [ln, gr] = G(null), [dn, yr] = G(null), bt = v(null), ae = v(void 0), Cr = (e) => {
1142
+ bt.current = e, ae.current === void 0 && (ae.current = window.requestAnimationFrame(() => {
1143
+ ae.current = void 0, yr(bt.current);
1104
1144
  }));
1105
- }, [sn, $e] = V(null), Xe = O(G);
1106
- Xe.current = G;
1107
- const Be = O(null);
1108
- Be.current = fr;
1109
- const Gt = O(ie);
1110
- Gt.current = ie;
1111
- const qe = O(J);
1112
- qe.current = J;
1113
- const gr = O(de);
1114
- gr.current = de;
1115
- const Cr = O(_);
1116
- Cr.current = _;
1117
- const yr = O(S);
1118
- yr.current = S;
1119
- const Jt = O(null), Ve = (e) => {
1120
- Jt.current !== e && (Jt.current = e, L("onConnectionStateChange", yr.current, e));
1121
- }, ut = G === !0 || G === "hover-only", an = G === "hover-only" ? "hover-only" : "select", ue = Ke(
1145
+ }, [fn, Xe] = G(null), Be = v(X);
1146
+ Be.current = X;
1147
+ const qe = v(null);
1148
+ qe.current = mr;
1149
+ const Qt = v(ce);
1150
+ Qt.current = ce;
1151
+ const Ve = v(J);
1152
+ Ve.current = J;
1153
+ const vr = v(fe);
1154
+ vr.current = fe;
1155
+ const Or = v(O);
1156
+ Or.current = O;
1157
+ const _r = v(S);
1158
+ _r.current = S;
1159
+ const Zt = v(null), Ge = (e) => {
1160
+ Zt.current !== e && (Zt.current = e, L("onConnectionStateChange", _r.current, e));
1161
+ }, ft = X === !0 || X === "hover-only", hn = X === "hover-only" ? "hover-only" : "select", le = ke(
1122
1162
  () => a || Math.random().toString(36).substring(2, 15) + Math.random().toString(36).substring(2, 15),
1123
1163
  [a]
1124
- ), he = Ke(() => To(t), [t]), Ge = Ro[he], lt = M?.[he], vr = he === "android" && Zr ? ur ? lt?.tabletFrameLandscape : lt?.tabletFrame : ur ? lt?.frameLandscape : lt?.frame, Or = lt?.loadingLogo, wt = !Ce && p && !!vr, K = (e) => {
1125
- x(e);
1126
- }, le = (e) => {
1127
- !P.current || P.current.readyState !== "open" || (P.current.send(e), ee.current?.bumpActivity());
1128
- }, _r = -10, Dr = (e, i) => {
1129
- const o = dt();
1164
+ ), pe = ke(() => Ro(t), [t]), Je = Po[pe], ht = M?.[pe], Tr = pe === "android" && nn ? fr ? ht?.tabletFrameLandscape : ht?.tabletFrame : fr ? ht?.frameLandscape : ht?.frame, wr = ht?.loadingLogo, St = !ye && p && !!Tr, k = (e) => {
1165
+ F(e);
1166
+ }, de = (e) => {
1167
+ !U.current || U.current.readyState !== "open" || (U.current.send(Ct.current?.wrap(e) ?? e), te.current?.bumpActivity());
1168
+ }, Dr = -10, Ar = (e, i) => {
1169
+ const o = pt();
1130
1170
  if (!o) return;
1131
- const n = je(o, e, i);
1171
+ const n = ze(o, e, i);
1132
1172
  if (!n) return;
1133
- const { videoX: l, videoY: u, videoWidth: f, videoHeight: E } = n, g = Yt(
1134
- U.ACTION_DOWN,
1135
- _r,
1173
+ const { videoX: l, videoY: u, videoWidth: f, videoHeight: E } = n, y = Pt(
1174
+ K.ACTION_DOWN,
1175
+ Dr,
1136
1176
  f,
1137
1177
  E,
1138
1178
  l,
1139
1179
  u,
1140
1180
  1,
1141
- U.BUTTON_PRIMARY,
1142
- U.BUTTON_PRIMARY
1181
+ K.BUTTON_PRIMARY,
1182
+ K.BUTTON_PRIMARY
1143
1183
  );
1144
- g && le(g), window.setTimeout(() => {
1145
- const h = Yt(
1146
- U.ACTION_UP,
1147
- _r,
1184
+ y && de(y), window.setTimeout(() => {
1185
+ const h = Pt(
1186
+ K.ACTION_UP,
1187
+ Dr,
1148
1188
  f,
1149
1189
  E,
1150
1190
  l,
1151
1191
  u,
1152
1192
  0,
1153
- U.BUTTON_PRIMARY,
1154
- U.BUTTON_PRIMARY
1193
+ K.BUTTON_PRIMARY,
1194
+ K.BUTTON_PRIMARY
1155
1195
  );
1156
- h && le(h);
1196
+ h && de(h);
1157
1197
  }, 60);
1158
- }, un = (e, i) => {
1159
- const o = dt();
1198
+ }, pn = (e, i) => {
1199
+ const o = pt();
1160
1200
  if (!o || i.screen.width <= 0 || i.screen.height <= 0) return;
1161
- const n = e.frame.x + e.frame.width / 2, l = e.frame.y + e.frame.height / 2, u = n / i.screen.width * o.actualWidth, f = l / i.screen.height * o.actualHeight, E = o.videoRect.left + o.offsetX + u, g = o.videoRect.top + o.offsetY + f;
1162
- Dr(E, g);
1163
- }, At = -1, bt = -2, Ie = -3, Je = (e, i, o, n, l, u) => {
1164
- const f = Yt(
1201
+ const n = e.frame.x + e.frame.width / 2, l = e.frame.y + e.frame.height / 2, u = n / i.screen.width * o.actualWidth, f = l / i.screen.height * o.actualHeight, E = o.videoRect.left + o.offsetX + u, y = o.videoRect.top + o.offsetY + f;
1202
+ Ar(E, y);
1203
+ }, Mt = -1, Rt = -2, Ye = -3, je = (e, i, o, n, l, u) => {
1204
+ const f = Pt(
1165
1205
  e,
1166
1206
  i,
1167
1207
  o,
@@ -1170,182 +1210,182 @@ const Xo = Kn(
1170
1210
  u,
1171
1211
  1,
1172
1212
  // pressure
1173
- U.BUTTON_PRIMARY,
1174
- U.BUTTON_PRIMARY
1213
+ K.BUTTON_PRIMARY,
1214
+ K.BUTTON_PRIMARY
1175
1215
  );
1176
- f && (x("[rc-touch] sendSingleTouch", {
1216
+ f && (F("[rc-touch] sendSingleTouch", {
1177
1217
  action: e,
1178
- actionName: Kt(e),
1218
+ actionName: Ut(e),
1179
1219
  pointerId: i,
1180
1220
  x: l,
1181
1221
  y: u,
1182
1222
  video: { width: o, height: n }
1183
- }), le(f));
1184
- }, Ye = (e, i, o) => {
1223
+ }), de(f));
1224
+ }, Ke = (e, i, o) => {
1185
1225
  if (!o) return;
1186
1226
  const { videoX: n, videoY: l, videoWidth: u, videoHeight: f } = o;
1187
- let E = null, g = null, h = 1;
1188
- const R = U.BUTTON_PRIMARY;
1227
+ let E = null, y = null, h = 1;
1228
+ const R = K.BUTTON_PRIMARY;
1189
1229
  switch (i) {
1190
1230
  case "down":
1191
- e !== Ie && st.current.end(), E = Q.current.size === 0 ? U.ACTION_DOWN : U.ACTION_POINTER_DOWN, g = { x: n, y: l }, Q.current.set(e, g), e === -1 && F.current?.focus();
1231
+ e !== Ye && lt.current.end(), E = Z.current.size === 0 ? K.ACTION_DOWN : K.ACTION_POINTER_DOWN, y = { x: n, y: l }, Z.current.set(e, y), e === -1 && W.current?.focus();
1192
1232
  break;
1193
1233
  case "move":
1194
- Q.current.has(e) && (E = U.ACTION_MOVE, g = { x: n, y: l }, Q.current.set(e, g));
1234
+ Z.current.has(e) && (E = K.ACTION_MOVE, y = { x: n, y: l }, Z.current.set(e, y));
1195
1235
  break;
1196
1236
  case "up":
1197
1237
  case "cancel":
1198
- Q.current.has(e) && (g = Q.current.get(e), Q.current.delete(e), i === "cancel" ? E = U.ACTION_CANCEL : E = Q.current.size === 0 ? U.ACTION_UP : U.ACTION_POINTER_UP);
1238
+ Z.current.has(e) && (y = Z.current.get(e), Z.current.delete(e), i === "cancel" ? E = K.ACTION_CANCEL : E = Z.current.size === 0 ? K.ACTION_UP : K.ACTION_POINTER_UP);
1199
1239
  break;
1200
1240
  }
1201
- if (E !== null && g !== null) {
1202
- x("[rc-touch][mouse->touch] sending", {
1241
+ if (E !== null && y !== null) {
1242
+ F("[rc-touch][mouse->touch] sending", {
1203
1243
  pointerId: e,
1204
1244
  eventType: i,
1205
1245
  action: E,
1206
- actionName: Kt(E),
1207
- positionToSend: g,
1246
+ actionName: Ut(E),
1247
+ positionToSend: y,
1208
1248
  video: { width: u, height: f },
1209
- altHeld: Re.current,
1210
- activePointersAfter: Array.from(Q.current.entries()).map(([N, $]) => ({
1249
+ altHeld: Ne.current,
1250
+ activePointersAfter: Array.from(Z.current.entries()).map(([N, $]) => ({
1211
1251
  id: N,
1212
1252
  x: $.x,
1213
1253
  y: $.y
1214
1254
  }))
1215
1255
  });
1216
- const D = Yt(
1256
+ const _ = Pt(
1217
1257
  E,
1218
1258
  e,
1219
1259
  u,
1220
1260
  f,
1221
- g.x,
1222
- g.y,
1261
+ y.x,
1262
+ y.y,
1223
1263
  h,
1224
1264
  R,
1225
1265
  R
1226
1266
  );
1227
- D && (x("[rc-touch][mouse->touch] buffer", {
1267
+ _ && (F("[rc-touch][mouse->touch] buffer", {
1228
1268
  pointerId: e,
1229
- actionName: Kt(E),
1230
- byteLength: D.byteLength
1231
- }), le(D));
1232
- } else (i === "up" || i === "cancel") && Q.current.delete(e);
1233
- }, jt = (e) => {
1234
- if (Re.current !== e && (Re.current = e, nn(e), e || _t(null), x("[rc-touch][alt] updateAltHeld", {
1269
+ actionName: Ut(E),
1270
+ byteLength: _.byteLength
1271
+ }), de(_));
1272
+ } else (i === "up" || i === "cancel") && Z.current.delete(e);
1273
+ }, er = (e) => {
1274
+ if (Ne.current !== e && (Ne.current = e, un(e), e || Dt(null), F("[rc-touch][alt] updateAltHeld", {
1235
1275
  nextHeld: e,
1236
- activePointerIds: Array.from(Q.current.keys())
1237
- }), he === "ios" && P.current && P.current.readyState === "open")) {
1238
- const i = e ? s.ACTION_DOWN : s.ACTION_UP, o = pt(
1276
+ activePointerIds: Array.from(Z.current.keys())
1277
+ }), pe === "ios" && U.current && U.current.readyState === "open")) {
1278
+ const i = e ? s.ACTION_DOWN : s.ACTION_UP, o = gt(
1239
1279
  i,
1240
1280
  s.KEYCODE_ALT_LEFT,
1241
1281
  0,
1242
1282
  s.META_NONE
1243
1283
  );
1244
- x("[rc-touch][alt] sending Indigo modifier keycode", {
1284
+ F("[rc-touch][alt] sending Indigo modifier keycode", {
1245
1285
  action: i,
1246
1286
  keycode: s.KEYCODE_ALT_LEFT
1247
- }), o && le(o);
1287
+ }), o && de(o);
1248
1288
  }
1249
- }, dt = () => {
1250
- const e = F.current, i = ge.current;
1289
+ }, pt = () => {
1290
+ const e = W.current, i = _e.current;
1251
1291
  if (!e || !i) return null;
1252
1292
  const o = e.videoWidth, n = e.videoHeight;
1253
1293
  if (!o || !n) return null;
1254
- const l = e.getBoundingClientRect(), u = i.getBoundingClientRect(), f = l.width, E = l.height, g = o / n, h = f / E;
1255
- let R = f, D = E;
1256
- g > h ? D = f / g : R = E * g;
1257
- const N = (f - R) / 2, $ = (E - D) / 2;
1294
+ const l = e.getBoundingClientRect(), u = i.getBoundingClientRect(), f = l.width, E = l.height, y = o / n, h = f / E;
1295
+ let R = f, _ = E;
1296
+ y > h ? _ = f / y : R = E * y;
1297
+ const N = (f - R) / 2, $ = (E - _) / 2;
1258
1298
  return {
1259
1299
  videoWidth: o,
1260
1300
  videoHeight: n,
1261
1301
  videoRect: l,
1262
1302
  containerRect: u,
1263
1303
  actualWidth: R,
1264
- actualHeight: D,
1304
+ actualHeight: _,
1265
1305
  offsetX: N,
1266
1306
  offsetY: $
1267
1307
  };
1268
- }, je = (e, i, o) => {
1308
+ }, ze = (e, i, o) => {
1269
1309
  const n = i - e.videoRect.left - e.offsetX, l = o - e.videoRect.top - e.offsetY, u = Math.max(0, Math.min(e.actualWidth, n)), f = Math.max(0, Math.min(e.actualHeight, l)), E = Math.max(
1270
1310
  0,
1271
1311
  Math.min(e.videoWidth, u / e.actualWidth * e.videoWidth)
1272
- ), g = Math.max(
1312
+ ), y = Math.max(
1273
1313
  0,
1274
1314
  Math.min(e.videoHeight, f / e.actualHeight * e.videoHeight)
1275
1315
  );
1276
1316
  return {
1277
1317
  videoX: E,
1278
- videoY: g,
1318
+ videoY: y,
1279
1319
  videoWidth: e.videoWidth,
1280
1320
  videoHeight: e.videoHeight
1281
1321
  };
1282
- }, ln = (e, i, o) => {
1322
+ }, mn = (e, i, o) => {
1283
1323
  const n = i - e.videoRect.left - e.offsetX, l = o - e.videoRect.top - e.offsetY, u = Math.max(0, Math.min(e.actualWidth, n)), f = Math.max(0, Math.min(e.actualHeight, l)), E = Math.max(
1284
1324
  0,
1285
1325
  Math.min(e.videoWidth, u / e.actualWidth * e.videoWidth)
1286
- ), g = Math.max(
1326
+ ), y = Math.max(
1287
1327
  0,
1288
1328
  Math.min(e.videoHeight, f / e.actualHeight * e.videoHeight)
1289
- ), h = e.videoWidth - E, R = e.videoHeight - g, D = e.videoRect.left + e.offsetX, N = e.videoRect.top + e.offsetY, $ = D - e.containerRect.left + u, ne = N - e.containerRect.top + f, j = D - e.containerRect.left + (e.actualWidth - u), v = N - e.containerRect.top + (e.actualHeight - f);
1329
+ ), h = e.videoWidth - E, R = e.videoHeight - y, _ = e.videoRect.left + e.offsetX, N = e.videoRect.top + e.offsetY, $ = _ - e.containerRect.left + u, oe = N - e.containerRect.top + f, j = _ - e.containerRect.left + (e.actualWidth - u), z = N - e.containerRect.top + (e.actualHeight - f);
1290
1330
  return {
1291
1331
  containerX: $,
1292
- containerY: ne,
1332
+ containerY: oe,
1293
1333
  mirrorContainerX: j,
1294
- mirrorContainerY: v,
1334
+ mirrorContainerY: z,
1295
1335
  videoX: E,
1296
- videoY: g,
1336
+ videoY: y,
1297
1337
  mirrorVideoX: h,
1298
1338
  mirrorVideoY: R,
1299
1339
  videoWidth: e.videoWidth,
1300
1340
  videoHeight: e.videoHeight
1301
1341
  };
1302
- }, dn = (e, i, o, n, l, u, f) => {
1303
- const E = Hn(e, i, o, n, l, u, f);
1304
- x("[rc-touch2] sendTwoFingerMessage (iOS)", {
1305
- actionName: Kt(e),
1342
+ }, En = (e, i, o, n, l, u, f) => {
1343
+ const E = Gn(e, i, o, n, l, u, f);
1344
+ F("[rc-touch2] sendTwoFingerMessage (iOS)", {
1345
+ actionName: Ut(e),
1306
1346
  video: { width: i, height: o },
1307
1347
  p0: { x: n, y: l },
1308
1348
  p1: { x: u, y: f },
1309
1349
  byteLength: E.byteLength
1310
- }), le(E);
1311
- }, ze = (e, i, o, n, l, u, f, E, g) => {
1312
- if (x("[rc-touch2] applyTwoFingerEvent", {
1313
- platform: he,
1350
+ }), de(E);
1351
+ }, Qe = (e, i, o, n, l, u, f, E, y) => {
1352
+ if (F("[rc-touch2] applyTwoFingerEvent", {
1353
+ platform: pe,
1314
1354
  eventType: e,
1315
1355
  video: { width: i, height: o },
1316
1356
  p0: { x: n, y: l, id: E },
1317
- p1: { x: u, y: f, id: g }
1318
- }), e === "down" && st.current.end(), he === "ios") {
1319
- const h = e === "down" ? U.ACTION_DOWN : e === "move" ? U.ACTION_MOVE : U.ACTION_UP;
1320
- dn(h, i, o, n, l, u, f);
1357
+ p1: { x: u, y: f, id: y }
1358
+ }), e === "down" && lt.current.end(), pe === "ios") {
1359
+ const h = e === "down" ? K.ACTION_DOWN : e === "move" ? K.ACTION_MOVE : K.ACTION_UP;
1360
+ En(h, i, o, n, l, u, f);
1321
1361
  } else
1322
- e === "down" ? (Je(U.ACTION_DOWN, E, i, o, n, l), Je(U.ACTION_POINTER_DOWN, g, i, o, u, f)) : e === "move" ? (Je(U.ACTION_MOVE, E, i, o, n, l), Je(U.ACTION_MOVE, g, i, o, u, f)) : (Je(U.ACTION_POINTER_UP, g, i, o, u, f), Je(U.ACTION_UP, E, i, o, n, l));
1323
- }, fn = (e, i, o) => {
1324
- if (!Re.current) {
1325
- Ne !== null && _t(null);
1362
+ e === "down" ? (je(K.ACTION_DOWN, E, i, o, n, l), je(K.ACTION_POINTER_DOWN, y, i, o, u, f)) : e === "move" ? (je(K.ACTION_MOVE, E, i, o, n, l), je(K.ACTION_MOVE, y, i, o, u, f)) : (je(K.ACTION_POINTER_UP, y, i, o, u, f), je(K.ACTION_UP, E, i, o, n, l));
1363
+ }, gn = (e, i, o) => {
1364
+ if (!Ne.current) {
1365
+ Ie !== null && Dt(null);
1326
1366
  return;
1327
1367
  }
1328
- const n = ln(e, i, o);
1329
- _t(n);
1330
- }, hn = (e, i, o) => {
1331
- const n = Be.current;
1368
+ const n = mn(e, i, o);
1369
+ Dt(n);
1370
+ }, yn = (e, i, o) => {
1371
+ const n = qe.current;
1332
1372
  if (!n || n.screen.width <= 0 || n.screen.height <= 0) return null;
1333
1373
  const l = i - e.videoRect.left - e.offsetX, u = o - e.videoRect.top - e.offsetY;
1334
1374
  if (l < 0 || u < 0 || l > e.actualWidth || u > e.actualHeight) return null;
1335
1375
  const f = l / e.actualWidth * n.screen.width, E = u / e.actualHeight * n.screen.height;
1336
- return Zn(n, f, E);
1337
- }, Te = (e) => {
1338
- if (Ce) return;
1376
+ return io(n, f, E);
1377
+ }, we = (e) => {
1378
+ if (ye) return;
1339
1379
  e.preventDefault(), e.stopPropagation();
1340
- const i = dt();
1341
- if ((Xe.current === !0 || Xe.current === "hover-only") && !("touches" in e))
1380
+ const i = pt();
1381
+ if ((Be.current === !0 || Be.current === "hover-only") && !("touches" in e))
1342
1382
  if (e.type === "mousemove") {
1343
- if (Er({ x: e.clientX, y: e.clientY }), i) {
1344
- const n = hn(i, e.clientX, e.clientY);
1345
- at(n?.id ?? null);
1383
+ if (Cr({ x: e.clientX, y: e.clientY }), i) {
1384
+ const n = yn(i, e.clientX, e.clientY);
1385
+ dt(n?.id ?? null);
1346
1386
  }
1347
- } else e.type === "mouseleave" && (Er(null), at(null));
1348
- if (Xe.current !== !0 && (!("touches" in e) && i && (e.type === "mousemove" ? fn(i, e.clientX, e.clientY) : e.type === "mouseleave" && _t(null)), !(!P.current || P.current.readyState !== "open" || !F.current || !i)))
1387
+ } else e.type === "mouseleave" && (Cr(null), dt(null));
1388
+ if (Be.current !== !0 && (!("touches" in e) && i && (e.type === "mousemove" ? gn(i, e.clientX, e.clientY) : e.type === "mouseleave" && Dt(null)), !(!U.current || U.current.readyState !== "open" || !W.current || !i)))
1349
1389
  if ("touches" in e) {
1350
1390
  const n = e.touches, l = e.changedTouches;
1351
1391
  let u;
@@ -1366,39 +1406,39 @@ const Xo = Kn(
1366
1406
  return;
1367
1407
  }
1368
1408
  if (n.length === 2) {
1369
- const f = n[0], E = n[1], g = je(i, f.clientX, f.clientY), h = je(i, E.clientX, E.clientY);
1370
- if (!g || !h) return;
1371
- B.current ? B.current.source === "real-touch" && (B.current.finger0 = { x: g.videoX, y: g.videoY }, B.current.finger1 = { x: h.videoX, y: h.videoY }, ze(
1409
+ const f = n[0], E = n[1], y = ze(i, f.clientX, f.clientY), h = ze(i, E.clientX, E.clientY);
1410
+ if (!y || !h) return;
1411
+ q.current ? q.current.source === "real-touch" && (q.current.finger0 = { x: y.videoX, y: y.videoY }, q.current.finger1 = { x: h.videoX, y: h.videoY }, Qe(
1372
1412
  "move",
1373
- g.videoWidth,
1374
- g.videoHeight,
1375
- g.videoX,
1376
- g.videoY,
1413
+ y.videoWidth,
1414
+ y.videoHeight,
1415
+ y.videoX,
1416
+ y.videoY,
1377
1417
  h.videoX,
1378
1418
  h.videoY,
1379
- B.current.pointerId0,
1380
- B.current.pointerId1
1381
- )) : (B.current = {
1382
- finger0: { x: g.videoX, y: g.videoY },
1419
+ q.current.pointerId0,
1420
+ q.current.pointerId1
1421
+ )) : (q.current = {
1422
+ finger0: { x: y.videoX, y: y.videoY },
1383
1423
  finger1: { x: h.videoX, y: h.videoY },
1384
- videoSize: { width: g.videoWidth, height: g.videoHeight },
1424
+ videoSize: { width: y.videoWidth, height: y.videoHeight },
1385
1425
  source: "real-touch",
1386
1426
  pointerId0: f.identifier,
1387
1427
  pointerId1: E.identifier
1388
- }, ze(
1428
+ }, Qe(
1389
1429
  "down",
1390
- g.videoWidth,
1391
- g.videoHeight,
1392
- g.videoX,
1393
- g.videoY,
1430
+ y.videoWidth,
1431
+ y.videoHeight,
1432
+ y.videoX,
1433
+ y.videoY,
1394
1434
  h.videoX,
1395
1435
  h.videoY,
1396
1436
  f.identifier,
1397
1437
  E.identifier
1398
1438
  ));
1399
- } else if (n.length < 2 && B.current?.source === "real-touch") {
1400
- const f = B.current;
1401
- ze(
1439
+ } else if (n.length < 2 && q.current?.source === "real-touch") {
1440
+ const f = q.current;
1441
+ Qe(
1402
1442
  "up",
1403
1443
  f.videoSize.width,
1404
1444
  f.videoSize.height,
@@ -1408,7 +1448,7 @@ const Xo = Kn(
1408
1448
  f.finger1.y,
1409
1449
  f.pointerId0,
1410
1450
  f.pointerId1
1411
- ), B.current = null;
1451
+ ), q.current = null;
1412
1452
  return;
1413
1453
  } else {
1414
1454
  if (n.length > 2)
@@ -1416,39 +1456,39 @@ const Xo = Kn(
1416
1456
  {
1417
1457
  const f = l[0];
1418
1458
  if (f) {
1419
- const E = je(i, f.clientX, f.clientY);
1420
- Ye(f.identifier, u, E);
1459
+ const E = ze(i, f.clientX, f.clientY);
1460
+ Ke(f.identifier, u, E);
1421
1461
  }
1422
1462
  }
1423
1463
  }
1424
1464
  } else {
1425
1465
  let l = null;
1426
- const u = B.current?.source === "alt-mouse";
1466
+ const u = q.current?.source === "alt-mouse";
1427
1467
  switch (e.type) {
1428
1468
  case "mousedown":
1429
1469
  e.button === 0 && (l = "down");
1430
1470
  break;
1431
1471
  case "mousemove":
1432
- (u || Q.current.has(-1)) && (l = "move");
1472
+ (u || Z.current.has(-1)) && (l = "move");
1433
1473
  break;
1434
1474
  case "mouseup":
1435
1475
  e.button === 0 && (l = "up");
1436
1476
  break;
1437
1477
  case "mouseleave":
1438
- (u || Q.current.has(-1)) && (l = "up");
1478
+ (u || Z.current.has(-1)) && (l = "up");
1439
1479
  break;
1440
1480
  }
1441
1481
  if (l) {
1442
- const f = je(i, e.clientX, e.clientY);
1482
+ const f = ze(i, e.clientX, e.clientY);
1443
1483
  if (!f)
1444
1484
  return;
1445
- x("[rc-touch][mouse] event", {
1485
+ F("[rc-touch][mouse] event", {
1446
1486
  domType: e.type,
1447
1487
  eventType: l,
1448
1488
  button: e.button,
1449
1489
  buttons: e.buttons,
1450
1490
  client: { x: e.clientX, y: e.clientY },
1451
- altHeldRef: Re.current,
1491
+ altHeldRef: Ne.current,
1452
1492
  inTwoFingerMode: u,
1453
1493
  geometry: {
1454
1494
  videoX: f.videoX,
@@ -1456,21 +1496,21 @@ const Xo = Kn(
1456
1496
  videoWidth: f.videoWidth,
1457
1497
  videoHeight: f.videoHeight
1458
1498
  },
1459
- activePointerIds: Array.from(Q.current.keys())
1460
- }), Re.current || u ? pn(l, f) : Ye(-1, l, f);
1499
+ activePointerIds: Array.from(Z.current.keys())
1500
+ }), Ne.current || u ? Cn(l, f) : Ke(-1, l, f);
1461
1501
  }
1462
1502
  }
1463
- }, pn = (e, i) => {
1503
+ }, Cn = (e, i) => {
1464
1504
  const { videoX: o, videoY: n, videoWidth: l, videoHeight: u } = i, f = l - o, E = u - n;
1465
1505
  if (e === "down") {
1466
- B.current = {
1506
+ q.current = {
1467
1507
  finger0: { x: o, y: n },
1468
1508
  finger1: { x: f, y: E },
1469
1509
  videoSize: { width: l, height: u },
1470
1510
  source: "alt-mouse",
1471
- pointerId0: At,
1472
- pointerId1: bt
1473
- }, F.current?.focus(), ze(
1511
+ pointerId0: Mt,
1512
+ pointerId1: Rt
1513
+ }, W.current?.focus(), Qe(
1474
1514
  "down",
1475
1515
  l,
1476
1516
  u,
@@ -1478,13 +1518,13 @@ const Xo = Kn(
1478
1518
  n,
1479
1519
  f,
1480
1520
  E,
1481
- At,
1482
- bt
1521
+ Mt,
1522
+ Rt
1483
1523
  );
1484
1524
  return;
1485
1525
  }
1486
1526
  if (e === "move") {
1487
- B.current?.source === "alt-mouse" && (B.current.finger0 = { x: o, y: n }, B.current.finger1 = { x: f, y: E }, ze(
1527
+ q.current?.source === "alt-mouse" && (q.current.finger0 = { x: o, y: n }, q.current.finger1 = { x: f, y: E }, Qe(
1488
1528
  "move",
1489
1529
  l,
1490
1530
  u,
@@ -1492,96 +1532,96 @@ const Xo = Kn(
1492
1532
  n,
1493
1533
  f,
1494
1534
  E,
1495
- At,
1496
- bt
1535
+ Mt,
1536
+ Rt
1497
1537
  ));
1498
1538
  return;
1499
1539
  }
1500
1540
  if (e === "up" || e === "cancel") {
1501
- const g = B.current;
1502
- if (g?.source === "alt-mouse") {
1503
- const { finger0: h, finger1: R, videoSize: D } = g;
1504
- ze(
1541
+ const y = q.current;
1542
+ if (y?.source === "alt-mouse") {
1543
+ const { finger0: h, finger1: R, videoSize: _ } = y;
1544
+ Qe(
1505
1545
  "up",
1506
- D.width,
1507
- D.height,
1546
+ _.width,
1547
+ _.height,
1508
1548
  h.x,
1509
1549
  h.y,
1510
1550
  R.x,
1511
1551
  R.y,
1512
- At,
1513
- bt
1514
- ), B.current = null;
1552
+ Mt,
1553
+ Rt
1554
+ ), q.current = null;
1515
1555
  }
1516
1556
  return;
1517
1557
  }
1518
- }, mn = 150, Tr = () => {
1519
- const e = He.current;
1520
- e && (window.clearTimeout(e.endTimer), Ye(Ie, "up", e.pos), He.current = null);
1521
- }, En = (e) => {
1522
- if (e.ctrlKey || Re.current || B.current) return;
1523
- const i = Q.current.size;
1524
- if (i > 1 || i === 1 && !Q.current.has(Ie)) return;
1525
- const o = dt();
1558
+ }, vn = 150, br = () => {
1559
+ const e = $e.current;
1560
+ e && (window.clearTimeout(e.endTimer), Ke(Ye, "up", e.pos), $e.current = null);
1561
+ }, On = (e) => {
1562
+ if (e.ctrlKey || Ne.current || q.current) return;
1563
+ const i = Z.current.size;
1564
+ if (i > 1 || i === 1 && !Z.current.has(Ye)) return;
1565
+ const o = pt();
1526
1566
  if (!o) return;
1527
1567
  const n = e.clientX - o.videoRect.left - o.offsetX, l = e.clientY - o.videoRect.top - o.offsetY;
1528
1568
  if (n < 0 || n > o.actualWidth || l < 0 || l > o.actualHeight)
1529
1569
  return;
1530
- const u = je(o, e.clientX, e.clientY);
1570
+ const u = ze(o, e.clientX, e.clientY);
1531
1571
  if (!u) return;
1532
1572
  e.preventDefault();
1533
- const f = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualWidth : 1) * (o.videoWidth / o.actualWidth), E = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualHeight : 1) * (o.videoHeight / o.actualHeight), g = -e.deltaX * f, h = -e.deltaY * E, R = (v) => {
1534
- window.clearTimeout(v.endTimer), v.endTimer = window.setTimeout(Tr, mn);
1573
+ const f = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualWidth : 1) * (o.videoWidth / o.actualWidth), E = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualHeight : 1) * (o.videoHeight / o.actualHeight), y = -e.deltaX * f, h = -e.deltaY * E, R = (z) => {
1574
+ window.clearTimeout(z.endTimer), z.endTimer = window.setTimeout(br, vn);
1535
1575
  };
1536
- if (g === 0 && h === 0) {
1537
- He.current && R(He.current);
1576
+ if (y === 0 && h === 0) {
1577
+ $e.current && R($e.current);
1538
1578
  return;
1539
1579
  }
1540
- const D = () => ({
1580
+ const _ = () => ({
1541
1581
  videoWidth: u.videoWidth,
1542
1582
  videoHeight: u.videoHeight,
1543
- videoX: Math.abs(g) > Math.abs(h) ? Math.min(Math.max(u.videoX, u.videoWidth * 0.2), u.videoWidth * 0.8) : u.videoX,
1544
- videoY: Math.abs(h) >= Math.abs(g) ? Math.min(Math.max(u.videoY, u.videoHeight * 0.2), u.videoHeight * 0.8) : u.videoY
1545
- }), N = (v) => ({
1546
- ...v,
1547
- videoX: Math.min(Math.max(v.videoX + g, 0), v.videoWidth),
1548
- videoY: Math.min(Math.max(v.videoY + h, 0), v.videoHeight)
1583
+ videoX: Math.abs(y) > Math.abs(h) ? Math.min(Math.max(u.videoX, u.videoWidth * 0.2), u.videoWidth * 0.8) : u.videoX,
1584
+ videoY: Math.abs(h) >= Math.abs(y) ? Math.min(Math.max(u.videoY, u.videoHeight * 0.2), u.videoHeight * 0.8) : u.videoY
1585
+ }), N = (z) => ({
1586
+ ...z,
1587
+ videoX: Math.min(Math.max(z.videoX + y, 0), z.videoWidth),
1588
+ videoY: Math.min(Math.max(z.videoY + h, 0), z.videoHeight)
1549
1589
  });
1550
- let $ = He.current;
1590
+ let $ = $e.current;
1551
1591
  if ($)
1552
1592
  window.clearTimeout($.endTimer);
1553
1593
  else {
1554
- const v = D();
1555
- Ye(Ie, "down", v), $ = { pos: v, endTimer: 0 }, He.current = $;
1594
+ const z = _();
1595
+ Ke(Ye, "down", z), $ = { pos: z, endTimer: 0 }, $e.current = $;
1556
1596
  }
1557
- let ne = $.pos, j = N(ne);
1558
- j.videoX === ne.videoX && j.videoY === ne.videoY && (Ye(Ie, "up", ne), ne = D(), Ye(Ie, "down", ne), j = N(ne)), Ye(Ie, "move", j), $.pos = j, R($);
1597
+ let oe = $.pos, j = N(oe);
1598
+ j.videoX === oe.videoX && j.videoY === oe.videoY && (Ke(Ye, "up", oe), oe = _(), Ke(Ye, "down", oe), j = N(oe)), Ke(Ye, "move", j), $.pos = j, R($);
1559
1599
  };
1560
- pe(() => {
1561
- st.current = { handle: En, end: Tr };
1562
- }), pe(() => {
1563
- const e = ge.current;
1600
+ me(() => {
1601
+ lt.current = { handle: On, end: br };
1602
+ }), me(() => {
1603
+ const e = _e.current;
1564
1604
  if (!e) return;
1565
- const i = (o) => st.current.handle(o);
1605
+ const i = (o) => lt.current.handle(o);
1566
1606
  return e.addEventListener("wheel", i, { passive: !1 }), () => {
1567
- st.current.end(), e.removeEventListener("wheel", i);
1607
+ lt.current.end(), e.removeEventListener("wheel", i);
1568
1608
  };
1569
- }, []), pe(() => {
1609
+ }, []), me(() => {
1570
1610
  const e = (n) => {
1571
- n.key === "Alt" && jt(!0);
1611
+ n.key === "Alt" && er(!0);
1572
1612
  }, i = (n) => {
1573
- n.key === "Alt" && jt(!1);
1613
+ n.key === "Alt" && er(!1);
1574
1614
  }, o = () => {
1575
- jt(!1);
1615
+ er(!1);
1576
1616
  };
1577
1617
  return window.addEventListener("keydown", e, !0), window.addEventListener("keyup", i, !0), window.addEventListener("blur", o), () => {
1578
1618
  window.removeEventListener("keydown", e, !0), window.removeEventListener("keyup", i, !0), window.removeEventListener("blur", o);
1579
1619
  };
1580
1620
  }, []);
1581
- const St = (e) => {
1621
+ const Nt = (e) => {
1582
1622
  e.preventDefault(), e.stopPropagation();
1583
- const i = document.activeElement === F.current || Ce && document.activeElement === e.currentTarget;
1584
- if (x("Keyboard event:", {
1623
+ const i = document.activeElement === W.current || ye && document.activeElement === e.currentTarget;
1624
+ if (F("Keyboard event:", {
1585
1625
  type: e.type,
1586
1626
  key: e.key,
1587
1627
  keyCode: e.keyCode,
@@ -1589,23 +1629,23 @@ const Xo = Kn(
1589
1629
  target: e.target.tagName,
1590
1630
  focused: i
1591
1631
  }), !i) {
1592
- w("Simulator input not focused, skipping keyboard event");
1632
+ A("Simulator input not focused, skipping keyboard event");
1593
1633
  return;
1594
1634
  }
1595
- if (!P.current || P.current.readyState !== "open") {
1596
- w("Data channel not ready for keyboard event:", P.current?.readyState);
1635
+ if (!U.current || U.current.readyState !== "open") {
1636
+ A("Data channel not ready for keyboard event:", U.current?.readyState);
1597
1637
  return;
1598
1638
  }
1599
1639
  if (e.type === "keydown") {
1600
1640
  if (e.key.toLowerCase() === "v" && (e.metaKey || e.ctrlKey)) {
1601
- x("Paste shortcut detected"), navigator.clipboard.readText().then((n) => {
1641
+ F("Paste shortcut detected"), navigator.clipboard.readText().then((n) => {
1602
1642
  if (n) {
1603
- x(
1643
+ F(
1604
1644
  "Pasting text via SET_CLIPBOARD:",
1605
1645
  n.substring(0, 20) + (n.length > 20 ? "..." : "")
1606
1646
  );
1607
- const l = $n(n, !0);
1608
- le(l);
1647
+ const l = Jn(n, !0);
1648
+ de(l);
1609
1649
  }
1610
1650
  }).catch((n) => {
1611
1651
  console.error("Failed to read clipboard contents: ", n);
@@ -1613,88 +1653,88 @@ const Xo = Kn(
1613
1653
  return;
1614
1654
  }
1615
1655
  if (e.key.toLowerCase() === "m" && (e.metaKey || e.ctrlKey)) {
1616
- x("Menu shortcut detected");
1617
- const n = pt(
1656
+ F("Menu shortcut detected");
1657
+ const n = gt(
1618
1658
  s.ACTION_DOWN,
1619
1659
  s.MENU,
1620
1660
  0,
1621
1661
  s.META_NONE
1622
1662
  // Modifiers are handled by the shortcut check, not passed down
1623
1663
  );
1624
- le(n);
1625
- const l = pt(
1664
+ de(n);
1665
+ const l = gt(
1626
1666
  s.ACTION_UP,
1627
1667
  s.MENU,
1628
1668
  0,
1629
1669
  s.META_NONE
1630
1670
  );
1631
- le(l);
1671
+ de(l);
1632
1672
  return;
1633
1673
  }
1634
1674
  }
1635
- const o = No(e);
1675
+ const o = Uo(e);
1636
1676
  if (o) {
1637
1677
  const { keycode: n, metaState: l } = o, u = e.type === "keydown" ? s.ACTION_DOWN : s.ACTION_UP;
1638
- x(`Sending Keycode: key=${e.key}, code=${n}, action=${u}, meta=${l}`);
1639
- const f = pt(
1678
+ F(`Sending Keycode: key=${e.key}, code=${n}, action=${u}, meta=${l}`);
1679
+ const f = gt(
1640
1680
  u,
1641
1681
  n,
1642
1682
  0,
1643
1683
  // repeat count, typically 0 for single presses
1644
1684
  l
1645
1685
  );
1646
- le(f);
1686
+ de(f);
1647
1687
  } else
1648
- x(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
1649
- }, gn = () => {
1650
- T.current && T.current.readyState === WebSocket.OPEN && T.current.send(
1688
+ F(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
1689
+ }, _n = () => {
1690
+ D.current && D.current.readyState === WebSocket.OPEN && D.current.send(
1651
1691
  JSON.stringify({
1652
1692
  type: "keepAlive",
1653
- sessionId: ue
1693
+ sessionId: le
1654
1694
  })
1655
1695
  );
1656
- }, wr = () => {
1657
- xe.current && window.clearInterval(xe.current), xe.current = window.setInterval(gn, 1e4);
1658
- }, Ar = () => {
1659
- xe.current && (window.clearInterval(xe.current), xe.current = void 0);
1660
- }, Mt = () => {
1661
- tt.current && (window.clearTimeout(tt.current), tt.current = void 0);
1662
- }, Rt = () => {
1663
- rt.current && (window.clearTimeout(rt.current), rt.current = void 0);
1664
- }, ft = () => {
1665
- gt.current && (window.clearInterval(gt.current), gt.current = void 0);
1666
- }, ht = () => {
1667
- Fe.current !== void 0 && (window.clearTimeout(Fe.current), Fe.current = void 0);
1668
- }, Cn = () => {
1669
- ct.current || (ct.current = !0, ft(), Ft(!0), Ve("connected"));
1670
- }, te = (e) => {
1696
+ }, Sr = () => {
1697
+ Fe.current && window.clearInterval(Fe.current), Fe.current = window.setInterval(_n, 1e4);
1698
+ }, Mr = () => {
1699
+ Fe.current && (window.clearInterval(Fe.current), Fe.current = void 0);
1700
+ }, It = () => {
1701
+ ot.current && (window.clearTimeout(ot.current), ot.current = void 0);
1702
+ }, Yt = () => {
1703
+ it.current && (window.clearTimeout(it.current), it.current = void 0);
1704
+ }, mt = () => {
1705
+ vt.current && (window.clearInterval(vt.current), vt.current = void 0);
1706
+ }, Et = () => {
1707
+ We.current !== void 0 && (window.clearTimeout(We.current), We.current = void 0);
1708
+ }, Tn = () => {
1709
+ ut.current || (ut.current = !0, mt(), $t(!0), Ge("connected"));
1710
+ }, re = (e) => {
1671
1711
  for (const i of e.getTracks())
1672
1712
  try {
1673
1713
  i.stop();
1674
1714
  } catch (o) {
1675
- w("track.stop() failed:", o);
1715
+ A("track.stop() failed:", o);
1676
1716
  }
1677
- }, yn = () => {
1678
- const e = re.current;
1679
- e && (re.current = null, te(e));
1680
- }, br = (e) => {
1681
- const i = dr.current.then(e).catch((o) => {
1682
- w("microphone operation failed:", o);
1717
+ }, wn = () => {
1718
+ const e = ne.current;
1719
+ e && (ne.current = null, re(e));
1720
+ }, Rr = (e) => {
1721
+ const i = pr.current.then(e).catch((o) => {
1722
+ A("microphone operation failed:", o);
1683
1723
  });
1684
- return dr.current = i, i;
1685
- }, zt = () => Xt.current || Bt.current, Sr = (e) => {
1724
+ return pr.current = i, i;
1725
+ }, tr = () => Gt.current || Jt.current, Nr = (e) => {
1686
1726
  const i = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
1687
- We.current = i, e.send(JSON.stringify({ type: "microphoneStart", id: i }));
1688
- }, Qt = () => br(() => vn()), vn = async () => {
1689
- const e = Ot.current, i = () => e === Ot.current && zt(), o = (E) => {
1690
- L("onMicrophoneStateChange", ot.current, {
1727
+ He.current = i, e.send(JSON.stringify({ type: "microphoneStart", id: i }));
1728
+ }, rr = () => Rr(() => Dn()), Dn = async () => {
1729
+ const e = wt.current, i = () => e === wt.current && tr(), o = (E) => {
1730
+ L("onMicrophoneStateChange", st.current, {
1691
1731
  active: !1,
1692
1732
  error: E
1693
1733
  });
1694
1734
  };
1695
1735
  if (!i()) return;
1696
- const n = T.current, l = it.current;
1697
- if (!n || n.readyState !== WebSocket.OPEN || !l || fe.current) return;
1736
+ const n = D.current, l = at.current;
1737
+ if (!n || n.readyState !== WebSocket.OPEN || !l || he.current) return;
1698
1738
  if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
1699
1739
  console.warn(
1700
1740
  "[RemoteControl] navigator.mediaDevices.getUserMedia unavailable. getUserMedia requires a secure context (https or http://localhost)."
@@ -1708,7 +1748,7 @@ const Xo = Kn(
1708
1748
  console.warn("[RemoteControl] microphone getUserMedia denied/failed:", E);
1709
1749
  }
1710
1750
  if (!i()) {
1711
- u && te(u);
1751
+ u && re(u);
1712
1752
  return;
1713
1753
  }
1714
1754
  if (!u) {
@@ -1717,56 +1757,56 @@ const Xo = Kn(
1717
1757
  }
1718
1758
  const f = u.getAudioTracks()[0] ?? null;
1719
1759
  if (!f) {
1720
- te(u), o("Captured stream has no audio track");
1760
+ re(u), o("Captured stream has no audio track");
1721
1761
  return;
1722
1762
  }
1723
1763
  try {
1724
1764
  await l.replaceTrack(f);
1725
1765
  } catch (E) {
1726
- w("replaceTrack(audioTrack) failed:", E), te(u), o("Failed to attach the microphone track to the connection");
1766
+ A("replaceTrack(audioTrack) failed:", E), re(u), o("Failed to attach the microphone track to the connection");
1727
1767
  return;
1728
1768
  }
1729
1769
  if (!i()) {
1730
1770
  try {
1731
1771
  await l.replaceTrack(null);
1732
1772
  } catch (E) {
1733
- w("replaceTrack(null) on stale mic attach failed:", E);
1773
+ A("replaceTrack(null) on stale mic attach failed:", E);
1734
1774
  }
1735
- te(u);
1775
+ re(u);
1736
1776
  return;
1737
1777
  }
1738
- fe.current = u, f.onended = () => {
1739
- fe.current === u && Nt("microphone capture ended by the browser");
1740
- }, Sr(n), L("onMicrophoneStateChange", ot.current, {
1778
+ he.current = u, f.onended = () => {
1779
+ he.current === u && Kt("microphone capture ended by the browser");
1780
+ }, Nr(n), L("onMicrophoneStateChange", st.current, {
1741
1781
  active: !0,
1742
1782
  label: f.label || void 0
1743
1783
  });
1744
- }, Nt = (e) => (++Ot.current, We.current = null, br(async () => {
1745
- const i = it.current, o = fe.current;
1746
- if (fe.current = null, i && o)
1784
+ }, Kt = (e) => (++wt.current, He.current = null, Rr(async () => {
1785
+ const i = at.current, o = he.current;
1786
+ if (he.current = null, i && o)
1747
1787
  try {
1748
1788
  await i.replaceTrack(null);
1749
1789
  } catch (l) {
1750
- w("replaceTrack(null) on mic detach failed:", l);
1790
+ A("replaceTrack(null) on mic detach failed:", l);
1751
1791
  }
1752
- o && te(o);
1753
- const n = T.current;
1792
+ o && re(o);
1793
+ const n = D.current;
1754
1794
  if (o && n && n.readyState === WebSocket.OPEN) {
1755
1795
  const l = `ui-mic-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`;
1756
1796
  n.send(JSON.stringify({ type: "microphoneStop", id: l }));
1757
1797
  }
1758
- (o || e) && L("onMicrophoneStateChange", ot.current, {
1798
+ (o || e) && L("onMicrophoneStateChange", st.current, {
1759
1799
  active: !1,
1760
1800
  ...e !== void 0 && { error: e }
1761
1801
  });
1762
- })), Mr = (e, i) => {
1802
+ })), Ir = (e, i) => {
1763
1803
  let o;
1764
1804
  try {
1765
- o = po(i), console.info(
1805
+ o = vo(i), console.info(
1766
1806
  `[RemoteControl] camera capture: ${o.camera?.width}x${o.camera?.height} @ ${o.camera?.frameRate ?? "?"}fps` + (o.camera?.label ? ` — ${o.camera.label}` : "")
1767
1807
  );
1768
1808
  } catch (n) {
1769
- w("getSettings() on outbound camera track failed:", n), o = {
1809
+ A("getSettings() on outbound camera track failed:", n), o = {
1770
1810
  type: "cameraResult",
1771
1811
  granted: !0,
1772
1812
  camera: {
@@ -1775,12 +1815,12 @@ const Xo = Kn(
1775
1815
  };
1776
1816
  }
1777
1817
  e.send(JSON.stringify(o)), L("onCameraDemandChange", ve.current, !0, !0, o.camera);
1778
- }, On = (e) => {
1818
+ }, An = (e) => {
1779
1819
  if (!e) return;
1780
1820
  const i = e.indexOf("/"), n = (i >= 0 ? e.slice(i + 1) : e).toUpperCase();
1781
1821
  return n === "HEVC" ? "H265" : n;
1782
- }, _n = async () => {
1783
- const e = Ae.current, i = yt.current;
1822
+ }, bn = async () => {
1823
+ const e = be.current, i = _t.current;
1784
1824
  if (!e || !i) return;
1785
1825
  let o;
1786
1826
  try {
@@ -1796,27 +1836,27 @@ const Xo = Kn(
1796
1836
  N && (l = N.mimeType);
1797
1837
  }
1798
1838
  if (!n) return;
1799
- const f = n.timestamp ?? Date.now(), E = vt.current;
1800
- let g, h, R;
1839
+ const f = n.timestamp ?? Date.now(), E = Tt.current;
1840
+ let y, h, R;
1801
1841
  if (E && f > E.timestamp) {
1802
1842
  const N = (f - E.timestamp) / 1e3;
1803
- if (typeof n.framesEncoded == "number" && typeof E.framesEncoded == "number" && (g = Math.max(0, (n.framesEncoded - E.framesEncoded) / N)), typeof n.bytesSent == "number" && typeof E.bytesSent == "number" && (h = Math.max(0, (n.bytesSent - E.bytesSent) * 8 / N)), typeof n.packetsSent == "number" && typeof E.packetsSent == "number" && u && typeof u.packetsLost == "number" && typeof E.packetsLost == "number") {
1804
- const $ = n.packetsSent - E.packetsSent, ne = u.packetsLost - E.packetsLost;
1805
- $ > 0 && (R = Math.max(0, Math.min(100, ne / $ * 100)));
1843
+ if (typeof n.framesEncoded == "number" && typeof E.framesEncoded == "number" && (y = Math.max(0, (n.framesEncoded - E.framesEncoded) / N)), typeof n.bytesSent == "number" && typeof E.bytesSent == "number" && (h = Math.max(0, (n.bytesSent - E.bytesSent) * 8 / N)), typeof n.packetsSent == "number" && typeof E.packetsSent == "number" && u && typeof u.packetsLost == "number" && typeof E.packetsLost == "number") {
1844
+ const $ = n.packetsSent - E.packetsSent, oe = u.packetsLost - E.packetsLost;
1845
+ $ > 0 && (R = Math.max(0, Math.min(100, oe / $ * 100)));
1806
1846
  }
1807
1847
  }
1808
- vt.current = {
1848
+ Tt.current = {
1809
1849
  timestamp: f,
1810
1850
  framesEncoded: n.framesEncoded,
1811
1851
  bytesSent: n.bytesSent,
1812
1852
  packetsSent: n.packetsSent,
1813
1853
  packetsLost: u?.packetsLost
1814
1854
  };
1815
- const D = {
1816
- codec: On(l),
1855
+ const _ = {
1856
+ codec: An(l),
1817
1857
  encoderImplementation: n.encoderImplementation,
1818
1858
  hardwareAccelerated: typeof n.powerEfficientEncoder == "boolean" ? n.powerEfficientEncoder : void 0,
1819
- framesPerSecond: g,
1859
+ framesPerSecond: y,
1820
1860
  framesEncoded: n.framesEncoded,
1821
1861
  bitrateBps: h,
1822
1862
  width: n.frameWidth,
@@ -1825,40 +1865,40 @@ const Xo = Kn(
1825
1865
  rttMs: typeof u?.roundTripTime == "number" ? u.roundTripTime * 1e3 : void 0,
1826
1866
  packetsLostPct: R
1827
1867
  };
1828
- L("onCameraStats", yt.current, D);
1829
- }, Rr = () => {
1830
- nt.current === null && (vt.current = null, nt.current = setInterval(() => {
1831
- _n();
1868
+ L("onCameraStats", _t.current, _);
1869
+ }, Yr = () => {
1870
+ ct.current === null && (Tt.current = null, ct.current = setInterval(() => {
1871
+ bn();
1832
1872
  }, 1e3));
1833
- }, It = () => {
1834
- nt.current !== null && (clearInterval(nt.current), nt.current = null), vt.current = null, L("onCameraStats", yt.current, null);
1835
- }, Dn = (e, i, o, n) => $t.enqueue(async ({ isCurrent: l }) => {
1836
- const u = () => l() && n() && T.current === i && Ae.current === o;
1873
+ }, kt = () => {
1874
+ ct.current !== null && (clearInterval(ct.current), ct.current = null), Tt.current = null, L("onCameraStats", _t.current, null);
1875
+ }, Sn = (e, i, o, n) => Vt.enqueue(async ({ isCurrent: l }) => {
1876
+ const u = () => l() && n() && D.current === i && be.current === o;
1837
1877
  if (!u()) return;
1838
1878
  if (!e.active) {
1839
- const D = re.current;
1879
+ const _ = ne.current;
1840
1880
  try {
1841
1881
  await o.replaceTrack(null);
1842
1882
  } catch (N) {
1843
- w("replaceTrack(null) on camera detach failed:", N);
1883
+ A("replaceTrack(null) on camera detach failed:", N);
1844
1884
  }
1845
- if (re.current === D && (re.current = null, be.current = void 0, D && te(D)), It(), !u()) return;
1885
+ if (ne.current === _ && (ne.current = null, Se.current = void 0, _ && re(_)), kt(), !u()) return;
1846
1886
  L("onCameraDemandChange", ve.current, !1);
1847
1887
  return;
1848
1888
  }
1849
1889
  L("onCameraDemandChange", ve.current, !0);
1850
- const f = re.current, E = f?.getVideoTracks()[0], g = be.current;
1851
- if (E?.readyState === "live" && g && !fo(g, e)) {
1852
- be.current = e, Mr(i, E), Rr();
1890
+ const f = ne.current, E = f?.getVideoTracks()[0], y = Se.current;
1891
+ if (E?.readyState === "live" && y && !yo(y, e)) {
1892
+ Se.current = e, Ir(i, E), Yr();
1853
1893
  return;
1854
1894
  }
1855
1895
  if (f) {
1856
1896
  try {
1857
1897
  await o.replaceTrack(null);
1858
- } catch (D) {
1859
- w("replaceTrack(null) before camera switch failed:", D);
1898
+ } catch (_) {
1899
+ A("replaceTrack(null) before camera switch failed:", _);
1860
1900
  }
1861
- if (re.current === f && (re.current = null, be.current = void 0, te(f)), It(), !u()) return;
1901
+ if (ne.current === f && (ne.current = null, Se.current = void 0, re(f)), kt(), !u()) return;
1862
1902
  }
1863
1903
  if (!navigator.mediaDevices || typeof navigator.mediaDevices.getUserMedia != "function") {
1864
1904
  if (console.warn(
@@ -1870,14 +1910,14 @@ const Xo = Kn(
1870
1910
  let h = null;
1871
1911
  try {
1872
1912
  h = await navigator.mediaDevices.getUserMedia({
1873
- video: lo(e),
1913
+ video: go(e),
1874
1914
  audio: !1
1875
1915
  });
1876
- } catch (D) {
1877
- console.warn("[RemoteControl] getUserMedia denied/failed:", D);
1916
+ } catch (_) {
1917
+ console.warn("[RemoteControl] getUserMedia denied/failed:", _);
1878
1918
  }
1879
1919
  if (!u()) {
1880
- h && te(h);
1920
+ h && re(h);
1881
1921
  return;
1882
1922
  }
1883
1923
  if (!h) {
@@ -1886,7 +1926,7 @@ const Xo = Kn(
1886
1926
  }
1887
1927
  const R = h.getVideoTracks()[0] ?? null;
1888
1928
  if (!R) {
1889
- if (te(h), !u()) return;
1929
+ if (re(h), !u()) return;
1890
1930
  i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1);
1891
1931
  return;
1892
1932
  }
@@ -1896,68 +1936,68 @@ const Xo = Kn(
1896
1936
  }
1897
1937
  try {
1898
1938
  await o.replaceTrack(R);
1899
- } catch (D) {
1900
- if (w("replaceTrack(videoTrack) failed:", D), te(h), !u()) return;
1939
+ } catch (_) {
1940
+ if (A("replaceTrack(videoTrack) failed:", _), re(h), !u()) return;
1901
1941
  i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1);
1902
1942
  return;
1903
1943
  }
1904
1944
  if (!u()) {
1905
1945
  try {
1906
1946
  await o.replaceTrack(null);
1907
- } catch (D) {
1908
- w("replaceTrack(null) for stale camera attach failed:", D);
1947
+ } catch (_) {
1948
+ A("replaceTrack(null) for stale camera attach failed:", _);
1909
1949
  }
1910
- te(h);
1950
+ re(h);
1911
1951
  return;
1912
1952
  }
1913
1953
  try {
1914
- const D = o.getParameters();
1915
- (!D.encodings || D.encodings.length === 0) && (D.encodings = [{}]), D.encodings[0].maxBitrate = 8e6, D.encodings[0].maxFramerate = 30, D.degradationPreference = "maintain-framerate", await o.setParameters(D);
1916
- } catch (D) {
1917
- w("setParameters on outbound camera failed:", D);
1954
+ const _ = o.getParameters();
1955
+ (!_.encodings || _.encodings.length === 0) && (_.encodings = [{}]), _.encodings[0].maxBitrate = 8e6, _.encodings[0].maxFramerate = 30, _.degradationPreference = "maintain-framerate", await o.setParameters(_);
1956
+ } catch (_) {
1957
+ A("setParameters on outbound camera failed:", _);
1918
1958
  }
1919
1959
  if (!u()) {
1920
1960
  try {
1921
1961
  await o.replaceTrack(null);
1922
- } catch (D) {
1923
- w("replaceTrack(null) for stale camera finalize failed:", D);
1962
+ } catch (_) {
1963
+ A("replaceTrack(null) for stale camera finalize failed:", _);
1924
1964
  }
1925
- te(h);
1965
+ re(h);
1926
1966
  return;
1927
1967
  }
1928
- re.current = h, be.current = e, R.onended = () => {
1929
- re.current === h && $t.enqueueCurrent(async ({ isCurrent: D }) => {
1930
- if (!(!D() || re.current !== h || !n() || T.current !== i || Ae.current !== o)) {
1968
+ ne.current = h, Se.current = e, R.onended = () => {
1969
+ ne.current === h && Vt.enqueueCurrent(async ({ isCurrent: _ }) => {
1970
+ if (!(!_() || ne.current !== h || !n() || D.current !== i || be.current !== o)) {
1931
1971
  try {
1932
1972
  await o.replaceTrack(null);
1933
1973
  } catch (N) {
1934
- w("replaceTrack(null) after camera ended failed:", N);
1974
+ A("replaceTrack(null) after camera ended failed:", N);
1935
1975
  }
1936
- !D() || re.current !== h || !n() || T.current !== i || Ae.current !== o || (re.current = null, be.current = void 0, te(h), It(), i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1));
1976
+ !_() || ne.current !== h || !n() || D.current !== i || be.current !== o || (ne.current = null, Se.current = void 0, re(h), kt(), i.send(JSON.stringify({ type: "cameraResult", granted: !1 })), L("onCameraDemandChange", ve.current, !0, !1));
1937
1977
  }
1938
- }).catch((D) => w("camera ended cleanup failed:", D));
1939
- }, u() && (Mr(i, R), Rr());
1940
- }), Qe = () => {
1941
- for (const e of _e.current.values()) e();
1942
- _e.current.clear();
1943
- for (const e of Ue.current.values())
1978
+ }).catch((_) => A("camera ended cleanup failed:", _));
1979
+ }, u() && (Ir(i, R), Yr());
1980
+ }), Ze = () => {
1981
+ for (const e of rt.current.values()) e();
1982
+ rt.current.clear();
1983
+ for (const e of Le.current.values())
1944
1984
  clearTimeout(e.timer), e.reject(new Error("Simulator disconnected"));
1945
- Ue.current.clear(), ir(null), et.current && (et.current.srcObject = null), Rt(), ht(), ft(), ee.current && (ee.current.stop(), ee.current = null), $t.invalidate(), It(), yn(), be.current = void 0, Ae.current = null, ++Ot.current, Bt.current = !1, We.current = null, fe.current && (te(fe.current), fe.current = null, L("onMicrophoneStateChange", ot.current, {
1985
+ Le.current.clear(), ar(null), nt.current && (nt.current.srcObject = null), Yt(), Et(), mt(), te.current && (te.current.stop(), te.current = null), Vt.invalidate(), kt(), wn(), Se.current = void 0, be.current = null, ++wt.current, Jt.current = !1, He.current = null, he.current && (re(he.current), he.current = null, L("onMicrophoneStateChange", st.current, {
1946
1986
  active: !1
1947
- })), it.current = null, se.current !== void 0 && (window.cancelAnimationFrame(se.current), se.current = void 0), T.current && (T.current.onopen = null, T.current.onmessage = null, T.current.onerror = null, T.current.onclose = null, T.current.close(), T.current = null), W.current && (W.current.onconnectionstatechange = null, W.current.oniceconnectionstatechange = null, W.current.ontrack = null, W.current.onicecandidate = null, W.current.close(), W.current = null), F.current && (F.current.srcObject = null), P.current && (P.current.onopen = null, P.current.onclose = null, P.current.onerror = null, P.current.close(), P.current = null);
1948
- }, Nr = () => {
1949
- document.hidden ? Ar() : wr();
1950
- }, Tn = async () => {
1987
+ })), at.current = null, ae.current !== void 0 && (window.cancelAnimationFrame(ae.current), ae.current = void 0), D.current && (D.current.onopen = null, D.current.onmessage = null, D.current.onerror = null, D.current.onclose = null, D.current.close(), D.current = null), Ct.current?.close(), Ct.current = null, x.current && (x.current.onconnectionstatechange = null, x.current.oniceconnectionstatechange = null, x.current.ontrack = null, x.current.onicecandidate = null, x.current.close(), x.current = null), W.current && (W.current.srcObject = null), U.current && (U.current.onopen = null, U.current.onclose = null, U.current.onerror = null, U.current.close(), U.current = null);
1988
+ }, Kr = () => {
1989
+ document.hidden ? Mr() : Sr();
1990
+ }, Mn = async () => {
1951
1991
  if (typeof navigator < "u" && navigator.onLine === !1)
1952
1992
  return !1;
1953
1993
  let e;
1954
1994
  try {
1955
1995
  const n = new URL(t);
1956
- n.protocol = n.protocol === "wss:" ? "https:" : n.protocol === "ws:" ? "http:" : n.protocol, e = Ur(n.toString(), c);
1996
+ n.protocol = n.protocol === "wss:" ? "https:" : n.protocol === "ws:" ? "http:" : n.protocol, e = Fr(n.toString(), c);
1957
1997
  } catch {
1958
1998
  return !1;
1959
1999
  }
1960
- const i = new AbortController(), o = window.setTimeout(() => i.abort(), So);
2000
+ const i = new AbortController(), o = window.setTimeout(() => i.abort(), Ko);
1961
2001
  try {
1962
2002
  return (await fetch(e, { method: "GET", cache: "no-store", signal: i.signal })).status === 404;
1963
2003
  } catch {
@@ -1965,88 +2005,88 @@ const Xo = Kn(
1965
2005
  } finally {
1966
2006
  window.clearTimeout(o);
1967
2007
  }
1968
- }, wn = () => {
1969
- Le.current || (Le.current = !0, ar(!0), Et(!1), we.current += 1, Mt(), Rt(), ht(), Qe(), K("Instance terminated"), Ve("terminated"), L("onTerminated", Cr.current));
1970
- }, An = () => {
1971
- Le.current || Wt.current || (Wt.current = !0, Tn().then((e) => {
1972
- Wt.current = !1, e && wn();
2008
+ }, Rn = () => {
2009
+ xe.current || (xe.current = !0, dr(!0), yt(!1), Ae.current += 1, It(), Yt(), Et(), Ze(), k("Instance terminated"), Ge("terminated"), L("onTerminated", Or.current));
2010
+ }, Nn = () => {
2011
+ xe.current || Xt.current || (Xt.current = !0, Mn().then((e) => {
2012
+ Xt.current = !1, e && Rn();
1973
2013
  }));
1974
- }, Ze = (e, i) => {
1975
- if (Le.current || i !== we.current)
2014
+ }, et = (e, i) => {
2015
+ if (xe.current || i !== Ae.current)
1976
2016
  return;
1977
- if (An(), ye.current) {
1978
- if (!Ht.current) {
1979
- K(`Connection failed after it was established: ${e}`), Et(!0), Ve("failed"), Qe();
2017
+ if (Nn(), Ce.current) {
2018
+ if (!qt.current) {
2019
+ k(`Connection failed after it was established: ${e}`), yt(!0), Ge("failed"), Ze();
1980
2020
  return;
1981
2021
  }
1982
- K(`Reconnecting after established session dropped: ${e}`), ye.current = !1, Ct.current = -1;
2022
+ k(`Reconnecting after established session dropped: ${e}`), Ce.current = !1, Ot.current = -1;
1983
2023
  }
1984
- Mt();
1985
- const o = Ct.current + 1;
1986
- if (o >= tr) {
1987
- K(`Connection failed after ${tr} attempts: ${e}`), Et(!0), Ve("failed"), Qe();
2024
+ It();
2025
+ const o = Ot.current + 1;
2026
+ if (o >= ir) {
2027
+ k(`Connection failed after ${ir} attempts: ${e}`), yt(!0), Ge("failed"), Ze();
1988
2028
  return;
1989
2029
  }
1990
- K(`Retrying connection (${o + 1}/${tr})`), Ve("reconnecting"), Qe(), tt.current = window.setTimeout(() => {
1991
- tt.current = void 0, i === we.current && Ir(o);
1992
- }, wo);
1993
- }, Ir = async (e = 0) => {
1994
- if (Le.current) return;
1995
- const i = we.current + 1;
1996
- we.current = i, Ct.current = e, ye.current = !1, Et(!1), e === 0 && Jt.current !== "reconnecting" && Ve("connecting"), Mt(), Rt(), ft(), ct.current = !1, Ft(!1), Qe();
1997
- const o = () => i === we.current;
1998
- rt.current = window.setTimeout(() => {
1999
- rt.current = void 0, !(!o() || ye.current) && Ze("Connection did not succeed within 15 seconds", i);
2000
- }, Ao);
2030
+ k(`Retrying connection (${o + 1}/${ir})`), Ge("reconnecting"), Ze(), ot.current = window.setTimeout(() => {
2031
+ ot.current = void 0, i === Ae.current && kr(o);
2032
+ }, No);
2033
+ }, kr = async (e = 0) => {
2034
+ if (xe.current) return;
2035
+ const i = Ae.current + 1;
2036
+ Ae.current = i, Ot.current = e, Ce.current = !1, yt(!1), e === 0 && Zt.current !== "reconnecting" && Ge("connecting"), It(), Yt(), mt(), ut.current = !1, $t(!1), Ze();
2037
+ const o = () => i === Ae.current;
2038
+ it.current = window.setTimeout(() => {
2039
+ it.current = void 0, !(!o() || Ce.current) && et("Connection did not succeed within 15 seconds", i);
2040
+ }, Io);
2001
2041
  try {
2002
- const n = new WebSocket(Ur(t, c));
2003
- if (T.current = n, await new Promise((v, d) => {
2042
+ const n = new WebSocket(Fr(t, c));
2043
+ if (D.current = n, await new Promise((T, d) => {
2004
2044
  let Y = !1;
2005
- const z = window.setTimeout(() => d(new Error("WebSocket connection timeout")), 3e4), A = (I) => {
2006
- Y || (Y = !0, window.clearTimeout(z), I());
2045
+ const Q = window.setTimeout(() => d(new Error("WebSocket connection timeout")), 3e4), b = (I) => {
2046
+ Y || (Y = !0, window.clearTimeout(Q), I());
2007
2047
  };
2008
2048
  n.onopen = () => {
2009
- !o() || T.current !== n || A(v);
2049
+ !o() || D.current !== n || b(T);
2010
2050
  }, n.onerror = (I) => {
2011
- !o() || T.current !== n || (K("WebSocket error: " + I), A(() => d(new Error("WebSocket connection failed"))));
2051
+ !o() || D.current !== n || (k("WebSocket error: " + I), b(() => d(new Error("WebSocket connection failed"))));
2012
2052
  }, n.onclose = () => {
2013
- !o() || T.current !== n || (K("WebSocket closed"), A(() => d(new Error("WebSocket closed before connection was established"))));
2053
+ !o() || D.current !== n || (k("WebSocket closed"), b(() => d(new Error("WebSocket closed before connection was established"))));
2014
2054
  };
2015
- }), !o() || T.current !== n)
2055
+ }), !o() || D.current !== n)
2016
2056
  return;
2017
- n.onerror = (v) => {
2018
- !o() || T.current !== n || K("WebSocket error: " + v);
2057
+ n.onerror = (T) => {
2058
+ !o() || D.current !== n || k("WebSocket error: " + T);
2019
2059
  }, n.onclose = () => {
2020
- !o() || T.current !== n || K("WebSocket closed");
2060
+ !o() || D.current !== n || k("WebSocket closed");
2021
2061
  };
2022
- const l = new Promise((v, d) => {
2062
+ const l = new Promise((T, d) => {
2023
2063
  const Y = (I) => {
2024
- window.clearTimeout(z), n.removeEventListener("message", A), I();
2025
- }, z = window.setTimeout(
2064
+ window.clearTimeout(Q), n.removeEventListener("message", b), I();
2065
+ }, Q = window.setTimeout(
2026
2066
  () => Y(() => d(new Error("RTCConfiguration timeout"))),
2027
2067
  3e4
2028
- ), A = (I) => {
2029
- if (!(!o() || T.current !== n))
2068
+ ), b = (I) => {
2069
+ if (!(!o() || D.current !== n))
2030
2070
  try {
2031
- const q = JSON.parse(I.data);
2032
- if (q.type === "signalingError" && q.requestType === "requestRtcConfiguration" && q.sessionId === ue) {
2033
- const oe = typeof q.error == "string" ? q.error : "Unable to load streaming configuration";
2034
- Y(() => d(new Error(oe)));
2035
- } else q.type === "rtcConfiguration" && Y(
2036
- () => v({
2037
- rtcConfiguration: q.rtcConfiguration,
2038
- cameraSupported: q.cameraSupported === !0,
2039
- foldSupported: q.foldSupported === !0
2071
+ const V = JSON.parse(I.data);
2072
+ if (V.type === "signalingError" && V.requestType === "requestRtcConfiguration" && V.sessionId === le) {
2073
+ const ie = typeof V.error == "string" ? V.error : "Unable to load streaming configuration";
2074
+ Y(() => d(new Error(ie)));
2075
+ } else V.type === "rtcConfiguration" && Y(
2076
+ () => T({
2077
+ rtcConfiguration: V.rtcConfiguration,
2078
+ cameraSupported: V.cameraSupported === !0,
2079
+ foldSupported: V.foldSupported === !0
2040
2080
  })
2041
2081
  );
2042
- } catch (q) {
2043
- console.error("Error handling RTC configuration:", q), Y(() => d(q));
2082
+ } catch (V) {
2083
+ console.error("Error handling RTC configuration:", V), Y(() => d(V));
2044
2084
  }
2045
2085
  };
2046
- n.addEventListener("message", A), n.send(
2086
+ n.addEventListener("message", b), n.send(
2047
2087
  JSON.stringify({
2048
2088
  type: "requestRtcConfiguration",
2049
- sessionId: ue
2089
+ sessionId: le
2050
2090
  })
2051
2091
  );
2052
2092
  }), {
@@ -2054,46 +2094,46 @@ const Xo = Kn(
2054
2094
  cameraSupported: f,
2055
2095
  foldSupported: E
2056
2096
  } = await l;
2057
- if (!o() || T.current !== n)
2097
+ if (!o() || D.current !== n)
2058
2098
  return;
2059
- const g = C === "iphone-duo" || E;
2060
- Lt(g);
2099
+ const y = g === "iphone-duo" || E;
2100
+ Qr(y);
2061
2101
  const h = new RTCPeerConnection({ ...u, iceTransportPolicy: "relay" });
2062
- W.current = h, h.addTransceiver("audio", { direction: "recvonly" });
2063
- const R = h.addTransceiver("video", { direction: "recvonly" }), D = g ? h.addTransceiver("video", { direction: "recvonly" }) : null, N = he === "ios" || f, $ = N ? h.addTransceiver("video", {
2102
+ x.current = h, h.addTransceiver("audio", { direction: "recvonly" });
2103
+ const R = h.addTransceiver("video", { direction: "recvonly" }), _ = y ? h.addTransceiver("video", { direction: "recvonly" }) : null, N = pe === "ios" || f, $ = N ? h.addTransceiver("video", {
2064
2104
  direction: "sendonly"
2065
2105
  }) : null;
2066
- Ae.current = $?.sender ?? null;
2067
- const ne = N ? h.addTransceiver("audio", {
2106
+ be.current = $?.sender ?? null;
2107
+ const oe = N ? h.addTransceiver("audio", {
2068
2108
  direction: "sendonly"
2069
2109
  }) : null;
2070
- if (it.current = ne?.sender ?? null, RTCRtpReceiver.getCapabilities) {
2071
- const v = RTCRtpReceiver.getCapabilities("video");
2072
- if (v && v.codecs) {
2073
- const Y = v.codecs.sort((z, A) => {
2074
- const I = (q) => {
2075
- const oe = q.mimeType.toLowerCase();
2076
- return oe.includes("vp9") ? 1 : oe.includes("h265") || oe.includes("hevc") ? 2 : oe.includes("h264") || oe.includes("avc") ? 3 : 4;
2110
+ if (at.current = oe?.sender ?? null, RTCRtpReceiver.getCapabilities) {
2111
+ const T = RTCRtpReceiver.getCapabilities("video");
2112
+ if (T && T.codecs) {
2113
+ const Y = T.codecs.sort((Q, b) => {
2114
+ const I = (V) => {
2115
+ const ie = V.mimeType.toLowerCase();
2116
+ return ie.includes("vp9") ? 1 : ie.includes("h265") || ie.includes("hevc") ? 2 : ie.includes("h264") || ie.includes("avc") ? 3 : 4;
2077
2117
  };
2078
- return I(z) - I(A);
2118
+ return I(Q) - I(b);
2079
2119
  });
2080
- R.setCodecPreferences(Y), D?.setCodecPreferences(Y), x("Set codec preferences:", Y.map((z) => z.mimeType).join(", "));
2120
+ R.setCodecPreferences(Y), _?.setCodecPreferences(Y), F("Set codec preferences:", Y.map((Q) => Q.mimeType).join(", "));
2081
2121
  }
2082
2122
  }
2083
2123
  if ($ && RTCRtpSender.getCapabilities) {
2084
- const v = RTCRtpSender.getCapabilities("video");
2085
- if (v && v.codecs) {
2086
- const d = /* @__PURE__ */ new Set(["42e01f", "42e028", "640c1f"]), Y = (A) => {
2087
- const I = A.mimeType.toLowerCase(), oe = (A.sdpFmtpLine || "").toLowerCase().match(/profile-level-id=([0-9a-f]{6})/), Nn = oe ? oe[1] : "";
2088
- return I === "video/h265" || I === "video/hevc" ? 1 : I === "video/h264" && d.has(Nn) ? 2 : I === "video/h264" ? 3 : I === "video/vp9" ? 4 : I === "video/vp8" ? 5 : I === "video/rtx" || I === "video/red" || I === "video/ulpfec" ? 0 : 6;
2089
- }, z = [...v.codecs].sort((A, I) => Y(A) - Y(I));
2124
+ const T = RTCRtpSender.getCapabilities("video");
2125
+ if (T && T.codecs) {
2126
+ const d = /* @__PURE__ */ new Set(["42e01f", "42e028", "640c1f"]), Y = (b) => {
2127
+ const I = b.mimeType.toLowerCase(), ie = (b.sdpFmtpLine || "").toLowerCase().match(/profile-level-id=([0-9a-f]{6})/), Pn = ie ? ie[1] : "";
2128
+ return I === "video/h265" || I === "video/hevc" ? 1 : I === "video/h264" && d.has(Pn) ? 2 : I === "video/h264" ? 3 : I === "video/vp9" ? 4 : I === "video/vp8" ? 5 : I === "video/rtx" || I === "video/red" || I === "video/ulpfec" ? 0 : 6;
2129
+ }, Q = [...T.codecs].sort((b, I) => Y(b) - Y(I));
2090
2130
  try {
2091
- $.setCodecPreferences(z), x(
2131
+ $.setCodecPreferences(Q), F(
2092
2132
  "Outbound camera codec preferences:",
2093
- z.map((A) => `${A.mimeType}${A.sdpFmtpLine ? `[${A.sdpFmtpLine}]` : ""}`).join(", ")
2133
+ Q.map((b) => `${b.mimeType}${b.sdpFmtpLine ? `[${b.sdpFmtpLine}]` : ""}`).join(", ")
2094
2134
  );
2095
- } catch (A) {
2096
- w("Failed to set outbound camera codec preferences:", A);
2135
+ } catch (b) {
2136
+ A("Failed to set outbound camera codec preferences:", b);
2097
2137
  }
2098
2138
  }
2099
2139
  }
@@ -2102,48 +2142,52 @@ const Xo = Kn(
2102
2142
  negotiated: !0,
2103
2143
  id: 1
2104
2144
  });
2105
- if (P.current = j, j.onopen = () => {
2106
- if (!o() || P.current !== j || T.current !== n)
2145
+ U.current = j;
2146
+ const z = !y && Bt.current ? Vn(h, (T) => {
2147
+ o() && x.current === h && L("onTrace", Bt.current, T);
2148
+ }) : null;
2149
+ if (Ct.current = z, j.onopen = () => {
2150
+ if (!o() || U.current !== j || D.current !== n)
2107
2151
  return;
2108
- ye.current = !0, Rt(), K("Control channel opened"), g && n.send(JSON.stringify({ type: "getFoldState", id: "duo-capabilities" })), ee.current || (ee.current = new so({
2109
- platform: he,
2110
- baseIntervalMs: Z,
2111
- maxBackoffMs: X,
2112
- androidElementTreeOptions: me,
2152
+ Ce.current = !0, Yt(), k("Control channel opened"), y && n.send(JSON.stringify({ type: "getFoldState", id: "duo-capabilities" })), te.current || (te.current = new po({
2153
+ platform: pe,
2154
+ baseIntervalMs: ee,
2155
+ maxBackoffMs: B,
2156
+ androidElementTreeOptions: Ee,
2113
2157
  send: (d) => {
2114
- if (!T.current || T.current.readyState !== WebSocket.OPEN) return !1;
2158
+ if (!D.current || D.current.readyState !== WebSocket.OPEN) return !1;
2115
2159
  try {
2116
- return T.current.send(JSON.stringify(d)), !0;
2160
+ return D.current.send(JSON.stringify(d)), !0;
2117
2161
  } catch {
2118
2162
  return !1;
2119
2163
  }
2120
2164
  },
2121
2165
  onSnapshot: (d) => {
2122
- hr((Y) => qr(Y, d) ? Y : d), queueMicrotask(() => {
2123
- L("onAxSnapshotChange", Gt.current, d);
2166
+ Er((Y) => Jr(Y, d) ? Y : d), queueMicrotask(() => {
2167
+ L("onAxSnapshotChange", Qt.current, d);
2124
2168
  });
2125
2169
  },
2126
2170
  onStatusChange: (d, Y) => {
2127
- L("onAxStatusChange", gr.current, d, Y);
2171
+ L("onAxStatusChange", vr.current, d, Y);
2128
2172
  }
2129
- }), (Xe.current === !0 || Xe.current === "hover-only") && ee.current.start());
2130
- const v = () => {
2131
- !o() || ct.current || P.current !== j || T.current !== n || n.readyState !== WebSocket.OPEN || n.send(JSON.stringify({ type: "requestFrame", sessionId: ue }));
2173
+ }), (Be.current === !0 || Be.current === "hover-only") && te.current.start());
2174
+ const T = () => {
2175
+ !o() || ut.current || U.current !== j || D.current !== n || n.readyState !== WebSocket.OPEN || n.send(JSON.stringify({ type: "requestFrame", sessionId: le }));
2132
2176
  };
2133
- if (v(), ft(), gt.current = window.setInterval(() => {
2134
- if (!o() || ct.current || P.current !== j || T.current !== n || n.readyState !== WebSocket.OPEN) {
2135
- ft();
2177
+ if (T(), mt(), vt.current = window.setInterval(() => {
2178
+ if (!o() || ut.current || U.current !== j || D.current !== n || n.readyState !== WebSocket.OPEN) {
2179
+ mt();
2136
2180
  return;
2137
2181
  }
2138
- v();
2182
+ T();
2139
2183
  }, 250), m) {
2140
2184
  try {
2141
2185
  const d = decodeURIComponent(m);
2142
- K("Opening URL"), n.send(
2186
+ k("Opening URL"), n.send(
2143
2187
  JSON.stringify({
2144
2188
  type: "openUrl",
2145
2189
  url: d,
2146
- sessionId: ue
2190
+ sessionId: le
2147
2191
  })
2148
2192
  );
2149
2193
  } catch (d) {
@@ -2151,103 +2195,103 @@ const Xo = Kn(
2151
2195
  JSON.stringify({
2152
2196
  type: "openUrl",
2153
2197
  url: m,
2154
- sessionId: ue
2198
+ sessionId: le
2155
2199
  })
2156
2200
  );
2157
2201
  }
2158
- ee.current?.bumpActivity();
2202
+ te.current?.bumpActivity();
2159
2203
  }
2160
2204
  }, j.onclose = () => {
2161
- !o() || P.current !== j || K("Control channel closed");
2162
- }, j.onerror = (v) => {
2163
- !o() || P.current !== j || (console.error("Control channel error:", v), K("Control channel error: " + v));
2205
+ !o() || U.current !== j || k("Control channel closed");
2206
+ }, j.onerror = (T) => {
2207
+ !o() || U.current !== j || (console.error("Control channel error:", T), k("Control channel error: " + T));
2164
2208
  }, h.onconnectionstatechange = () => {
2165
- !o() || W.current !== h || (K("Connection state: " + h.connectionState), h.connectionState === "failed" && ye.current && Ze("WebRTC connection entered failed state", i));
2209
+ !o() || x.current !== h || (k("Connection state: " + h.connectionState), h.connectionState === "failed" && Ce.current && et("WebRTC connection entered failed state", i));
2166
2210
  }, h.oniceconnectionstatechange = () => {
2167
- if (!o() || W.current !== h)
2211
+ if (!o() || x.current !== h)
2168
2212
  return;
2169
- const v = h.iceConnectionState;
2170
- if (K("ICE state: " + v), v === "connected" || v === "completed") {
2171
- ht(), zt() && !fe.current && Qt();
2213
+ const T = h.iceConnectionState;
2214
+ if (k("ICE state: " + T), T === "connected" || T === "completed") {
2215
+ Et(), tr() && !he.current && rr();
2172
2216
  return;
2173
2217
  }
2174
- if (v === "failed") {
2175
- ht(), ye.current && Ze("ICE connection entered failed state", i);
2218
+ if (T === "failed") {
2219
+ Et(), Ce.current && et("ICE connection entered failed state", i);
2176
2220
  return;
2177
2221
  }
2178
- v === "disconnected" && ye.current && Ht.current && Fe.current === void 0 && (Fe.current = window.setTimeout(() => {
2179
- Fe.current = void 0, !(!o() || W.current !== h) && h.iceConnectionState === "disconnected" && Ze("ICE stayed disconnected past grace period", i);
2180
- }, bo));
2181
- }, h.ontrack = (v) => {
2182
- if (!(!o() || W.current !== h) && (K("Received remote track: " + v.track.kind), v.track.kind === "video" && F.current)) {
2183
- x(`[${(/* @__PURE__ */ new Date()).toISOString()}] Video track received:`, v.track);
2184
- const Y = v.track.id === "duo-inner" || v.streams.some((z) => z.id === "duo-inner") ? et.current : F.current;
2222
+ T === "disconnected" && Ce.current && qt.current && We.current === void 0 && (We.current = window.setTimeout(() => {
2223
+ We.current = void 0, !(!o() || x.current !== h) && h.iceConnectionState === "disconnected" && et("ICE stayed disconnected past grace period", i);
2224
+ }, Yo));
2225
+ }, h.ontrack = (T) => {
2226
+ if (!(!o() || x.current !== h) && (k("Received remote track: " + T.track.kind), T.track.kind === "video" && W.current)) {
2227
+ F(`[${(/* @__PURE__ */ new Date()).toISOString()}] Video track received:`, T.track);
2228
+ const Y = T.track.id === "duo-inner" || T.streams.some((Q) => Q.id === "duo-inner") ? nt.current : W.current;
2185
2229
  if (Y) {
2186
- const z = g ? new MediaStream([v.track]) : v.streams[0] ?? new MediaStream([v.track]);
2187
- _e.current.get(Y)?.(), _e.current.set(
2230
+ const Q = y ? new MediaStream([T.track]) : T.streams[0] ?? new MediaStream([T.track]);
2231
+ rt.current.get(Y)?.(), rt.current.set(
2188
2232
  Y,
2189
- Wn(Y, z, (A) => w("Video playback fallback:", A))
2233
+ qn(Y, Q, (b) => A("Video playback fallback:", b))
2190
2234
  );
2191
2235
  }
2192
2236
  }
2193
- }, h.onicecandidate = (v) => {
2194
- if (!(!o() || W.current !== h || T.current !== n))
2195
- if (v.candidate && n.readyState === WebSocket.OPEN) {
2237
+ }, h.onicecandidate = (T) => {
2238
+ if (!(!o() || x.current !== h || D.current !== n))
2239
+ if (T.candidate && n.readyState === WebSocket.OPEN) {
2196
2240
  const d = {
2197
2241
  type: "candidate",
2198
- candidate: v.candidate.candidate,
2199
- sdpMid: v.candidate.sdpMid,
2200
- sdpMLineIndex: v.candidate.sdpMLineIndex,
2201
- sessionId: ue
2242
+ candidate: T.candidate.candidate,
2243
+ sdpMid: T.candidate.sdpMid,
2244
+ sdpMLineIndex: T.candidate.sdpMLineIndex,
2245
+ sessionId: le
2202
2246
  };
2203
- n.send(JSON.stringify(d)), K("Sent ICE candidate");
2247
+ n.send(JSON.stringify(d)), k("Sent ICE candidate");
2204
2248
  } else
2205
- K("ICE candidate gathering completed");
2206
- }, n.onmessage = async (v) => {
2207
- if (!o() || T.current !== n)
2249
+ k("ICE candidate gathering completed");
2250
+ }, n.onmessage = async (T) => {
2251
+ if (!o() || D.current !== n)
2208
2252
  return;
2209
2253
  let d;
2210
2254
  try {
2211
- d = JSON.parse(v.data);
2255
+ d = JSON.parse(T.data);
2212
2256
  } catch (Y) {
2213
- w("Error parsing message:", Y);
2257
+ A("Error parsing message:", Y);
2214
2258
  return;
2215
2259
  }
2216
- if (!ee.current?.handleMessage(d))
2217
- switch (K("Received: " + d.type), d.type) {
2260
+ if (!te.current?.handleMessage(d))
2261
+ switch (k("Received: " + d.type), d.type) {
2218
2262
  case "performActionsResult":
2219
2263
  case "foldStateResult":
2220
2264
  case "foldStateChanged": {
2221
- if (!g) break;
2222
- d.state ? (ir(d.state), sr(void 0)) : d.id === "duo-capabilities" && sr(d.error || "This instance does not support native iPhone Duo displays.");
2223
- const A = Ue.current.get(d.id);
2224
- A && (clearTimeout(A.timer), Ue.current.delete(d.id), d.error ? A.reject(new Error(d.error)) : A.resolve());
2265
+ if (!y) break;
2266
+ d.state ? (ar(d.state), lr(void 0)) : d.id === "duo-capabilities" && lr(d.error || "This instance does not support native iPhone Duo displays.");
2267
+ const b = Le.current.get(d.id);
2268
+ b && (clearTimeout(b.timer), Le.current.delete(d.id), d.error ? b.reject(new Error(d.error)) : b.resolve());
2225
2269
  break;
2226
2270
  }
2227
2271
  case "signalingError": {
2228
- if (d.requestType !== "offer" || d.sessionId !== ue)
2272
+ if (d.requestType !== "offer" || d.sessionId !== le)
2229
2273
  break;
2230
- const A = typeof d.error == "string" ? d.error : "Unable to establish the streaming connection";
2231
- K("Error: " + A), Ze(A, i);
2274
+ const b = typeof d.error == "string" ? d.error : "Unable to establish the streaming connection";
2275
+ k("Error: " + b), et(b, i);
2232
2276
  break;
2233
2277
  }
2234
2278
  case "answer":
2235
- if (!W.current || W.current !== h) {
2236
- K("No peer connection, skipping answer");
2279
+ if (!x.current || x.current !== h) {
2280
+ k("No peer connection, skipping answer");
2237
2281
  break;
2238
2282
  }
2239
- if (await h.setRemoteDescription(
2283
+ if (z?.accept(d.latencyTraceVersion), await h.setRemoteDescription(
2240
2284
  new RTCSessionDescription({
2241
2285
  type: "answer",
2242
2286
  sdp: d.sdp
2243
2287
  })
2244
- ), !o() || W.current !== h)
2288
+ ), !o() || x.current !== h)
2245
2289
  return;
2246
- K("Set remote description");
2290
+ k("Set remote description");
2247
2291
  break;
2248
2292
  case "candidate":
2249
- if (!W.current || W.current !== h) {
2250
- K("No peer connection, skipping candidate");
2293
+ if (!x.current || x.current !== h) {
2294
+ k("No peer connection, skipping candidate");
2251
2295
  break;
2252
2296
  }
2253
2297
  if (await h.addIceCandidate(
@@ -2256,147 +2300,148 @@ const Xo = Kn(
2256
2300
  sdpMid: d.sdpMid,
2257
2301
  sdpMLineIndex: d.sdpMLineIndex
2258
2302
  })
2259
- ), !o() || W.current !== h)
2303
+ ), !o() || x.current !== h)
2260
2304
  return;
2261
- K("Added ICE candidate");
2305
+ k("Added ICE candidate");
2262
2306
  break;
2263
2307
  case "screenshot":
2264
2308
  case "screenshotResult": {
2265
2309
  if (typeof d.id != "string") {
2266
- w("Received invalid screenshot success message:", d);
2310
+ A("Received invalid screenshot success message:", d);
2267
2311
  break;
2268
2312
  }
2269
- const A = Io(d);
2270
- if (A) {
2271
- const oe = Oe.current.get(d.id);
2272
- if (!oe) {
2273
- w(`Received screenshot error for unknown or handled id: ${d.id}`);
2313
+ const b = Lo(d);
2314
+ if (b) {
2315
+ const ie = Oe.current.get(d.id);
2316
+ if (!ie) {
2317
+ A(`Received screenshot error for unknown or handled id: ${d.id}`);
2274
2318
  break;
2275
2319
  }
2276
- w(`Received screenshot error for id ${d.id}: ${A}`), oe(new Error(A)), De.current.delete(d.id), Oe.current.delete(d.id);
2320
+ A(`Received screenshot error for id ${d.id}: ${b}`), ie(new Error(b)), Te.current.delete(d.id), Oe.current.delete(d.id);
2277
2321
  break;
2278
2322
  }
2279
- const I = Yo(d);
2323
+ const I = xo(d);
2280
2324
  if (!I) {
2281
- w("Received screenshot message without image data:", d);
2325
+ A("Received screenshot message without image data:", d);
2282
2326
  break;
2283
2327
  }
2284
- const q = De.current.get(d.id);
2285
- if (!q) {
2286
- w(`Received screenshot data for unknown or handled id: ${d.id}`);
2328
+ const V = Te.current.get(d.id);
2329
+ if (!V) {
2330
+ A(`Received screenshot data for unknown or handled id: ${d.id}`);
2287
2331
  break;
2288
2332
  }
2289
- x(`Received screenshot data for id ${d.id}`), q(I), De.current.delete(d.id), Oe.current.delete(d.id);
2333
+ F(`Received screenshot data for id ${d.id}`), V(I), Te.current.delete(d.id), Oe.current.delete(d.id);
2290
2334
  break;
2291
2335
  }
2292
2336
  case "screenshotError":
2293
2337
  if (typeof d.id != "string" || typeof d.message != "string") {
2294
- w("Received invalid screenshot error message:", d);
2338
+ A("Received invalid screenshot error message:", d);
2295
2339
  break;
2296
2340
  }
2297
2341
  const Y = Oe.current.get(d.id);
2298
2342
  if (!Y) {
2299
- w(`Received screenshot error for unknown or handled id: ${d.id}`);
2343
+ A(`Received screenshot error for unknown or handled id: ${d.id}`);
2300
2344
  break;
2301
2345
  }
2302
- w(`Received screenshot error for id ${d.id}: ${d.message}`), Y(new Error(d.message)), De.current.delete(d.id), Oe.current.delete(d.id);
2346
+ A(`Received screenshot error for id ${d.id}: ${d.message}`), Y(new Error(d.message)), Te.current.delete(d.id), Oe.current.delete(d.id);
2303
2347
  break;
2304
2348
  case "cameraRequest": {
2305
- const A = Ae.current;
2306
- if (!A)
2349
+ const b = be.current;
2350
+ if (!b)
2307
2351
  break;
2308
- const I = uo(d);
2352
+ const I = Eo(d);
2309
2353
  if (!I) {
2310
- w("Received invalid cameraRequest:", d);
2354
+ A("Received invalid cameraRequest:", d);
2311
2355
  break;
2312
2356
  }
2313
- console.info("[RemoteControl] cameraRequest received:", I.active, I.facingMode), await Dn(I, n, A, o);
2357
+ console.info("[RemoteControl] cameraRequest received:", I.active, I.facingMode), await Sn(I, n, b, o);
2314
2358
  break;
2315
2359
  }
2316
2360
  case "microphoneRequest": {
2317
- if (!it.current)
2361
+ if (!at.current)
2318
2362
  break;
2319
- const A = d.active === !0;
2320
- if (Bt.current = A, console.info("[RemoteControl] microphoneRequest received, active=", A), !A) {
2321
- Xt.current || await Nt();
2363
+ const b = d.active === !0;
2364
+ if (Jt.current = b, console.info("[RemoteControl] microphoneRequest received, active=", b), !b) {
2365
+ Gt.current || await Kt();
2322
2366
  break;
2323
2367
  }
2324
- if (fe.current) {
2325
- Sr(n);
2368
+ if (he.current) {
2369
+ Nr(n);
2326
2370
  break;
2327
2371
  }
2328
- await Qt();
2372
+ await rr();
2329
2373
  break;
2330
2374
  }
2331
2375
  case "microphoneStartResult": {
2332
- if (We.current === null || d.id !== We.current)
2376
+ if (He.current === null || d.id !== He.current)
2333
2377
  break;
2334
- We.current = null, typeof d.error == "string" && (console.warn("[RemoteControl] microphoneStart rejected by host:", d.error), Nt(d.error));
2378
+ He.current = null, typeof d.error == "string" && (console.warn("[RemoteControl] microphoneStart rejected by host:", d.error), Kt(d.error));
2335
2379
  break;
2336
2380
  }
2337
2381
  case "terminateAppResult":
2338
2382
  if (typeof d.id != "string") {
2339
- w("Received invalid terminateApp result message:", d);
2383
+ A("Received invalid terminateApp result message:", d);
2340
2384
  break;
2341
2385
  }
2342
2386
  if (typeof d.error == "string") {
2343
- const A = Me.current.get(d.id);
2344
- if (!A) {
2345
- w(`Received terminateApp error for unknown or handled id: ${d.id}`);
2387
+ const b = Re.current.get(d.id);
2388
+ if (!b) {
2389
+ A(`Received terminateApp error for unknown or handled id: ${d.id}`);
2346
2390
  break;
2347
2391
  }
2348
- w(`Received terminateApp error for id ${d.id}: ${d.error}`), A(new Error(d.error)), Se.current.delete(d.id), Me.current.delete(d.id);
2392
+ A(`Received terminateApp error for id ${d.id}: ${d.error}`), b(new Error(d.error)), Me.current.delete(d.id), Re.current.delete(d.id);
2349
2393
  break;
2350
2394
  }
2351
- const z = Se.current.get(d.id);
2352
- if (!z) {
2353
- w(`Received terminateApp result for unknown or handled id: ${d.id}`);
2395
+ const Q = Me.current.get(d.id);
2396
+ if (!Q) {
2397
+ A(`Received terminateApp result for unknown or handled id: ${d.id}`);
2354
2398
  break;
2355
2399
  }
2356
- x(`Received terminateApp success for id ${d.id}`), z(), Se.current.delete(d.id), Me.current.delete(d.id);
2400
+ F(`Received terminateApp success for id ${d.id}`), Q(), Me.current.delete(d.id), Re.current.delete(d.id);
2357
2401
  break;
2358
2402
  default:
2359
- w(`Received unhandled message type: ${d.type}`, d);
2403
+ A(`Received unhandled message type: ${d.type}`, d);
2360
2404
  break;
2361
2405
  }
2362
- }, W.current === h) {
2363
- const v = await h.createOffer({
2406
+ }, x.current === h) {
2407
+ const T = await h.createOffer({
2364
2408
  offerToReceiveVideo: !0,
2365
2409
  offerToReceiveAudio: !1
2366
2410
  });
2367
- if (!o() || W.current !== h || (await h.setLocalDescription(v), !o() || W.current !== h))
2411
+ if (!o() || x.current !== h || (await h.setLocalDescription(T), !o() || x.current !== h))
2368
2412
  return;
2369
- o() && T.current === n && n.readyState === WebSocket.OPEN && n.send(
2413
+ o() && D.current === n && n.readyState === WebSocket.OPEN && n.send(
2370
2414
  JSON.stringify({
2371
2415
  type: "offer",
2372
- ...g ? { displayStreams: !0 } : {},
2373
- sdp: v.sdp,
2374
- sessionId: ue
2416
+ ...y ? { displayStreams: !0 } : {},
2417
+ ...z ? { latencyTraceVersion: 1 } : {},
2418
+ sdp: T.sdp,
2419
+ sessionId: le
2375
2420
  })
2376
- ), K("Sent offer");
2421
+ ), k("Sent offer");
2377
2422
  }
2378
2423
  } catch (n) {
2379
2424
  if (!o())
2380
2425
  return;
2381
2426
  const l = n instanceof Error ? n.message : String(n);
2382
- K("Error: " + l), Ze(l, i);
2427
+ k("Error: " + l), et(l, i);
2383
2428
  }
2384
- }, Zt = () => {
2385
- Le.current = !1, ar(!1), Ir(0);
2386
- }, bn = () => {
2387
- we.current += 1, Ct.current = 0, ye.current = !1, Mt(), ht(), Qe(), K("Stopped");
2388
- }, Sn = (e) => {
2389
- e.stopPropagation(), Zt();
2429
+ }, nr = () => {
2430
+ xe.current = !1, dr(!1), kr(0);
2431
+ }, In = () => {
2432
+ Ae.current += 1, Ot.current = 0, Ce.current = !1, It(), Et(), Ze(), k("Stopped");
2433
+ }, Yn = (e) => {
2434
+ e.stopPropagation(), nr();
2390
2435
  };
2391
- pe(() => {
2392
- zt() ? Qt() : Nt();
2393
- }, [Ee]), pe(() => (Ft(!1), Zt(), document.hidden || wr(), document.addEventListener("visibilitychange", Nr), () => {
2394
- Ar(), bn(), document.removeEventListener("visibilitychange", Nr);
2395
- }), [t, c, a, C]);
2396
- const Yr = () => {
2397
- const e = dt();
2436
+ me(() => {
2437
+ tr() ? rr() : Kt();
2438
+ }, [tt]), me(() => ($t(!1), nr(), document.hidden || Sr(), document.addEventListener("visibilitychange", Kr), () => {
2439
+ Mr(), In(), document.removeEventListener("visibilitychange", Kr);
2440
+ }), [t, c, a, g, sn]);
2441
+ const Pr = () => {
2442
+ const e = pt();
2398
2443
  if (!e) {
2399
- pr(null);
2444
+ gr(null);
2400
2445
  return;
2401
2446
  }
2402
2447
  const i = {
@@ -2405,325 +2450,325 @@ const Xo = Kn(
2405
2450
  width: e.actualWidth,
2406
2451
  height: e.actualHeight
2407
2452
  };
2408
- pr(
2453
+ gr(
2409
2454
  (o) => o && o.left === i.left && o.top === i.top && o.width === i.width && o.height === i.height ? o : i
2410
2455
  );
2411
2456
  };
2412
- pe(() => {
2413
- const e = F.current, i = Ut.current, o = ge.current;
2457
+ me(() => {
2458
+ const e = W.current, i = Ft.current, o = _e.current;
2414
2459
  if (!e) return;
2415
2460
  const n = () => {
2416
- if (!wt || !i) {
2417
- lr({}), Yr();
2461
+ if (!St || !i) {
2462
+ hr({}), Pr();
2418
2463
  return;
2419
2464
  }
2420
2465
  const f = i.clientWidth, E = i.clientHeight;
2421
2466
  if (f === 0 || E === 0) return;
2422
- const g = e.videoWidth > e.videoHeight;
2423
- Qr(g), en(
2424
- he === "android" && Mo(e.videoWidth, e.videoHeight)
2467
+ const y = e.videoWidth > e.videoHeight;
2468
+ rn(y), on(
2469
+ pe === "android" && ko(e.videoWidth, e.videoHeight)
2425
2470
  );
2426
- const h = g ? Ge.videoPosition.landscape : Ge.videoPosition.portrait;
2471
+ const h = y ? Je.videoPosition.landscape : Je.videoPosition.portrait;
2427
2472
  let R = {};
2428
- h.heightMultiplier ? (R.height = `${E * h.heightMultiplier}px`, R.width = "auto") : h.widthMultiplier && (R.width = `${f * h.widthMultiplier}px`, R.height = "auto"), R.borderRadius = `${g ? E * Ge.videoBorderRadiusMultiplier : f * Ge.videoBorderRadiusMultiplier}px`, lr(R), Yr();
2473
+ h.heightMultiplier ? (R.height = `${E * h.heightMultiplier}px`, R.width = "auto") : h.widthMultiplier && (R.width = `${f * h.widthMultiplier}px`, R.height = "auto"), R.borderRadius = `${y ? E * Je.videoBorderRadiusMultiplier : f * Je.videoBorderRadiusMultiplier}px`, hr(R), Pr();
2429
2474
  }, l = new ResizeObserver(() => {
2430
2475
  n();
2431
2476
  });
2432
2477
  i && l.observe(i), l.observe(e), o && l.observe(o), i && i.addEventListener("load", n), e.addEventListener("loadedmetadata", n), e.addEventListener("resize", n);
2433
- const u = () => ee.current?.bumpActivity();
2478
+ const u = () => te.current?.bumpActivity();
2434
2479
  return e.addEventListener("resize", u), n(), () => {
2435
2480
  l.disconnect(), e.removeEventListener("loadedmetadata", n), e.removeEventListener("resize", n), e.removeEventListener("resize", u), i && i.removeEventListener("load", n);
2436
2481
  };
2437
- }, [Ge, wt]), pe(() => {
2438
- const e = ee.current;
2439
- ut ? e?.start() : (e?.stop(), hr(null), at(null), Dt(null), mr(null), $e(null), Tt.current = null, se.current !== void 0 && (window.cancelAnimationFrame(se.current), se.current = void 0), L("onAxSnapshotChange", Gt.current, null));
2440
- }, [ut]), pe(() => () => {
2441
- se.current !== void 0 && (window.cancelAnimationFrame(se.current), se.current = void 0);
2442
- }, []), pe(() => {
2443
- if (!ut) return;
2482
+ }, [Je, St]), me(() => {
2483
+ const e = te.current;
2484
+ ft ? e?.start() : (e?.stop(), Er(null), dt(null), At(null), yr(null), Xe(null), bt.current = null, ae.current !== void 0 && (window.cancelAnimationFrame(ae.current), ae.current = void 0), L("onAxSnapshotChange", Qt.current, null));
2485
+ }, [ft]), me(() => () => {
2486
+ ae.current !== void 0 && (window.cancelAnimationFrame(ae.current), ae.current = void 0);
2487
+ }, []), me(() => {
2488
+ if (!ft) return;
2444
2489
  const e = (i) => {
2445
- i.key === "Escape" && (Vt || qt) && (Dt(null), at(null), $e(null), L("onInspectSelectionChange", qe.current, null));
2490
+ i.key === "Escape" && (zt || jt) && (At(null), dt(null), Xe(null), L("onInspectSelectionChange", Ve.current, null));
2446
2491
  };
2447
2492
  return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
2448
- }, [ut, Vt, qt]);
2449
- const Mn = () => {
2450
- F.current && F.current.focus();
2493
+ }, [ft, zt, jt]);
2494
+ const Kn = () => {
2495
+ W.current && W.current.focus();
2451
2496
  };
2452
- kn(Pe, () => ({
2497
+ Fn(Ue, () => ({
2453
2498
  openUrl: (e) => {
2454
- if (!T.current || T.current.readyState !== WebSocket.OPEN) {
2455
- w("WebSocket not open, cannot send open_url command via ref.");
2499
+ if (!D.current || D.current.readyState !== WebSocket.OPEN) {
2500
+ A("WebSocket not open, cannot send open_url command via ref.");
2456
2501
  return;
2457
2502
  }
2458
2503
  try {
2459
2504
  const i = decodeURIComponent(e);
2460
- K("Opening URL"), T.current.send(
2505
+ k("Opening URL"), D.current.send(
2461
2506
  JSON.stringify({
2462
2507
  type: "openUrl",
2463
2508
  url: i,
2464
- sessionId: ue
2509
+ sessionId: le
2465
2510
  })
2466
2511
  );
2467
2512
  } catch (i) {
2468
- w("Error decoding or sending URL via ref:", { error: i, url: e }), T.current.send(
2513
+ A("Error decoding or sending URL via ref:", { error: i, url: e }), D.current.send(
2469
2514
  JSON.stringify({
2470
2515
  type: "openUrl",
2471
2516
  url: e,
2472
- sessionId: ue
2517
+ sessionId: le
2473
2518
  })
2474
2519
  );
2475
2520
  }
2476
- ee.current?.bumpActivity();
2521
+ te.current?.bumpActivity();
2477
2522
  },
2478
2523
  sendKeyEvent: (e) => {
2479
- if (!P.current || P.current.readyState !== "open") {
2480
- w("Data channel not ready for imperative key command:", P.current?.readyState);
2524
+ if (!U.current || U.current.readyState !== "open") {
2525
+ A("Data channel not ready for imperative key command:", U.current?.readyState);
2481
2526
  return;
2482
2527
  }
2483
- const i = Hr[e.code];
2528
+ const i = Br[e.code];
2484
2529
  if (!i) {
2485
- w(`Unknown event.code for imperative command: ${e.code}`);
2530
+ A(`Unknown event.code for imperative command: ${e.code}`);
2486
2531
  return;
2487
2532
  }
2488
2533
  let o = s.META_NONE;
2489
2534
  e.shiftKey && (o |= s.META_SHIFT_ON), e.altKey && (o |= s.META_ALT_ON), e.ctrlKey && (o |= s.META_CTRL_ON), e.metaKey && (o |= s.META_META_ON);
2490
2535
  const n = e.type === "keydown" ? s.ACTION_DOWN : s.ACTION_UP;
2491
- x(
2536
+ F(
2492
2537
  `Sending Imperative Key Command: code=${e.code}, keycode=${i}, action=${n}, meta=${o}`
2493
2538
  );
2494
- const l = pt(
2539
+ const l = gt(
2495
2540
  n,
2496
2541
  i,
2497
2542
  0,
2498
2543
  // repeat count, typically 0 for single presses
2499
2544
  o
2500
2545
  );
2501
- l && le(l);
2546
+ l && de(l);
2502
2547
  },
2503
2548
  screenshot: (e) => new Promise((i, o) => {
2504
- if (!T.current || T.current.readyState !== WebSocket.OPEN)
2505
- return w("WebSocket not open, cannot send screenshot command."), o(new Error("WebSocket is not connected or connection is not open."));
2549
+ if (!D.current || D.current.readyState !== WebSocket.OPEN)
2550
+ return A("WebSocket not open, cannot send screenshot command."), o(new Error("WebSocket is not connected or connection is not open."));
2506
2551
  const n = `ui-ss-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, l = {
2507
2552
  type: e ? "screenshotDisplay" : "screenshot",
2508
2553
  ...e ? { display: e } : {},
2509
2554
  id: n
2510
2555
  };
2511
- De.current.set(n, i), Oe.current.set(n, o), x("Sending screenshot request:", l);
2556
+ Te.current.set(n, i), Oe.current.set(n, o), F("Sending screenshot request:", l);
2512
2557
  try {
2513
- T.current.send(JSON.stringify(l));
2558
+ D.current.send(JSON.stringify(l));
2514
2559
  } catch (u) {
2515
- w("Failed to send screenshot request immediately:", u), De.current.delete(n), Oe.current.delete(n), o(u);
2560
+ A("Failed to send screenshot request immediately:", u), Te.current.delete(n), Oe.current.delete(n), o(u);
2516
2561
  return;
2517
2562
  }
2518
2563
  setTimeout(() => {
2519
- De.current.has(n) && (w(`Screenshot request timed out for id ${n}`), Oe.current.get(n)?.(new Error("Screenshot request timed out")), De.current.delete(n), Oe.current.delete(n));
2564
+ Te.current.has(n) && (A(`Screenshot request timed out for id ${n}`), Oe.current.get(n)?.(new Error("Screenshot request timed out")), Te.current.delete(n), Oe.current.delete(n));
2520
2565
  }, 3e4);
2521
2566
  }),
2522
2567
  terminateApp: (e) => new Promise((i, o) => {
2523
- if (!T.current || T.current.readyState !== WebSocket.OPEN)
2524
- return w("WebSocket not open, cannot send terminateApp command."), o(new Error("WebSocket is not connected or connection is not open."));
2568
+ if (!D.current || D.current.readyState !== WebSocket.OPEN)
2569
+ return A("WebSocket not open, cannot send terminateApp command."), o(new Error("WebSocket is not connected or connection is not open."));
2525
2570
  const n = `ui-term-${Date.now()}-${Math.random().toString(36).substring(2, 9)}`, l = {
2526
2571
  type: "terminateApp",
2527
2572
  id: n,
2528
2573
  bundleId: e
2529
2574
  };
2530
- Se.current.set(n, i), Me.current.set(n, o), x("Sending terminateApp request:", l);
2575
+ Me.current.set(n, i), Re.current.set(n, o), F("Sending terminateApp request:", l);
2531
2576
  try {
2532
- T.current.send(JSON.stringify(l));
2577
+ D.current.send(JSON.stringify(l));
2533
2578
  } catch (u) {
2534
- w("Failed to send terminateApp request immediately:", u), Se.current.delete(n), Me.current.delete(n), o(u);
2579
+ A("Failed to send terminateApp request immediately:", u), Me.current.delete(n), Re.current.delete(n), o(u);
2535
2580
  return;
2536
2581
  }
2537
- ee.current?.bumpActivity(), setTimeout(() => {
2538
- Se.current.has(n) && (w(`terminateApp request timed out for id ${n}`), Me.current.get(n)?.(new Error("terminateApp request timed out")), Se.current.delete(n), Me.current.delete(n));
2582
+ te.current?.bumpActivity(), setTimeout(() => {
2583
+ Me.current.has(n) && (A(`terminateApp request timed out for id ${n}`), Re.current.get(n)?.(new Error("terminateApp request timed out")), Me.current.delete(n), Re.current.delete(n));
2539
2584
  }, 3e4);
2540
2585
  }),
2541
- reconnect: () => Zt(),
2586
+ reconnect: () => nr(),
2542
2587
  refreshAxTree: async () => {
2543
- const e = ee.current;
2588
+ const e = te.current;
2544
2589
  if (!e)
2545
2590
  throw new Error("Inspect mode is not active");
2546
2591
  return e.refresh();
2547
2592
  },
2548
- getAxSnapshot: () => Be.current,
2593
+ getAxSnapshot: () => qe.current,
2549
2594
  setInspectHighlight: (e) => {
2550
- at(e?.id ?? null);
2595
+ dt(e?.id ?? null);
2551
2596
  },
2552
2597
  setInspectSelection: (e) => {
2553
- Dt(e?.id ?? null), $e(e ? Tt.current : null);
2554
- const i = Be.current;
2555
- e && i ? L("onInspectSelectionChange", qe.current, { element: e, snapshot: i }) : L("onInspectSelectionChange", qe.current, null);
2598
+ At(e?.id ?? null), Xe(e ? bt.current : null);
2599
+ const i = qe.current;
2600
+ e && i ? L("onInspectSelectionChange", Ve.current, { element: e, snapshot: i }) : L("onInspectSelectionChange", Ve.current, null);
2556
2601
  },
2557
- getAxStatus: () => ee.current?.getStatus() ?? "idle"
2602
+ getAxStatus: () => te.current?.getStatus() ?? "idle"
2558
2603
  }));
2559
- const Rn = rn && Ne !== null;
2560
- return /* @__PURE__ */ ae(
2604
+ const kn = an && Ie !== null;
2605
+ return /* @__PURE__ */ ue(
2561
2606
  "div",
2562
2607
  {
2563
- ref: ge,
2564
- className: ke("rc-container", r),
2608
+ ref: _e,
2609
+ className: Pe("rc-container", r),
2565
2610
  style: { touchAction: "none" },
2566
- onMouseDown: Te,
2567
- onMouseMove: Te,
2568
- onMouseUp: Te,
2569
- onMouseLeave: Te,
2570
- onTouchStart: Te,
2571
- onTouchMove: Te,
2572
- onTouchEnd: Te,
2573
- onTouchCancel: Te,
2611
+ onMouseDown: we,
2612
+ onMouseMove: we,
2613
+ onMouseUp: we,
2614
+ onMouseLeave: we,
2615
+ onTouchStart: we,
2616
+ onTouchMove: we,
2617
+ onTouchEnd: we,
2618
+ onTouchCancel: we,
2574
2619
  children: [
2575
- Rn && Ne && /* @__PURE__ */ ae(Fr, { children: [
2576
- /* @__PURE__ */ k(
2620
+ kn && Ie && /* @__PURE__ */ ue($r, { children: [
2621
+ /* @__PURE__ */ P(
2577
2622
  "div",
2578
2623
  {
2579
2624
  className: "rc-touch-indicator",
2580
2625
  style: {
2581
- left: `${Ne.containerX}px`,
2582
- top: `${Ne.containerY}px`
2626
+ left: `${Ie.containerX}px`,
2627
+ top: `${Ie.containerY}px`
2583
2628
  }
2584
2629
  }
2585
2630
  ),
2586
- /* @__PURE__ */ k(
2631
+ /* @__PURE__ */ P(
2587
2632
  "div",
2588
2633
  {
2589
2634
  className: "rc-touch-indicator",
2590
2635
  style: {
2591
- left: `${Ne.mirrorContainerX}px`,
2592
- top: `${Ne.mirrorContainerY}px`
2636
+ left: `${Ie.mirrorContainerX}px`,
2637
+ top: `${Ie.mirrorContainerY}px`
2593
2638
  }
2594
2639
  }
2595
2640
  )
2596
2641
  ] }),
2597
- wt && /* @__PURE__ */ k(
2642
+ St && /* @__PURE__ */ P(
2598
2643
  "img",
2599
2644
  {
2600
- ref: Ut,
2601
- src: vr,
2645
+ ref: Ft,
2646
+ src: Tr,
2602
2647
  alt: "",
2603
- className: he === "ios" ? ke("rc-phone-frame", "rc-phone-frame-ios") : "rc-phone-frame",
2648
+ className: pe === "ios" ? Pe("rc-phone-frame", "rc-phone-frame-ios") : "rc-phone-frame",
2604
2649
  draggable: !1
2605
2650
  }
2606
2651
  ),
2607
- /* @__PURE__ */ k(
2652
+ /* @__PURE__ */ P(
2608
2653
  "video",
2609
2654
  {
2610
- ref: F,
2611
- className: ke(
2655
+ ref: W,
2656
+ className: Pe(
2612
2657
  "rc-video",
2613
- !wt && "rc-video-frameless",
2614
- !Jr && "rc-video-loading"
2658
+ !St && "rc-video-frameless",
2659
+ !Zr && "rc-video-loading"
2615
2660
  ),
2616
2661
  style: {
2617
- ...tn,
2618
- ...Ce ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
2619
- ...Or ? {
2620
- backgroundImage: `url("${Or}")`,
2662
+ ...cn,
2663
+ ...ye ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
2664
+ ...wr ? {
2665
+ backgroundImage: `url("${wr}")`,
2621
2666
  backgroundRepeat: "no-repeat",
2622
2667
  backgroundPosition: "center",
2623
- backgroundSize: Ge.loadingLogoSize
2668
+ backgroundSize: Je.loadingLogoSize
2624
2669
  } : {}
2625
2670
  },
2626
2671
  autoPlay: !0,
2627
2672
  playsInline: !0,
2628
2673
  muted: !0,
2629
- tabIndex: Ce ? -1 : 0,
2630
- onKeyDown: St,
2631
- onKeyUp: St,
2632
- onClick: Mn,
2633
- onLoadedData: Cn,
2674
+ tabIndex: ye ? -1 : 0,
2675
+ onKeyDown: Nt,
2676
+ onKeyUp: Nt,
2677
+ onClick: Kn,
2678
+ onLoadedData: Tn,
2634
2679
  onFocus: () => {
2635
- F.current && (F.current.style.outline = "none");
2680
+ W.current && (W.current.style.outline = "none");
2636
2681
  },
2637
2682
  onBlur: () => {
2638
- F.current && (F.current.style.outline = "none");
2683
+ W.current && (W.current.style.outline = "none");
2639
2684
  }
2640
2685
  }
2641
2686
  ),
2642
- Ce && /* @__PURE__ */ k(
2687
+ ye && /* @__PURE__ */ P(
2643
2688
  "video",
2644
2689
  {
2645
- ref: et,
2690
+ ref: nt,
2646
2691
  autoPlay: !0,
2647
2692
  playsInline: !0,
2648
2693
  muted: !0,
2649
2694
  style: { position: "absolute", width: 1, height: 1, opacity: 0, pointerEvents: "none" }
2650
2695
  }
2651
2696
  ),
2652
- Ce && or && /* @__PURE__ */ k(Pn, { fallback: /* @__PURE__ */ k("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ k(
2653
- Do,
2697
+ ye && sr && /* @__PURE__ */ P(Wn, { fallback: /* @__PURE__ */ P("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ P(
2698
+ Mo,
2654
2699
  {
2655
2700
  showFrame: p,
2656
- modelUrl: y,
2657
- outer: F.current,
2658
- inner: et.current,
2659
- state: or,
2660
- setAngle: (e) => xt("setHingeAngle", { angleDegrees: e }),
2661
- setOrientation: (e) => xt("setDuoOrientation", { orientation: e }),
2662
- button: (e, i) => xt("performActions", {
2701
+ modelUrl: C,
2702
+ outer: W.current,
2703
+ inner: nt.current,
2704
+ state: sr,
2705
+ setAngle: (e) => Ht("setHingeAngle", { angleDegrees: e }),
2706
+ setOrientation: (e) => Ht("setDuoOrientation", { orientation: e }),
2707
+ button: (e, i) => Ht("performActions", {
2663
2708
  actions: [{ type: i ? "buttonDown" : "buttonUp", button: e }]
2664
2709
  }),
2665
2710
  touch: (e, i, o, n) => {
2666
- const l = P.current;
2667
- l?.readyState === "open" && l.send(xn(e, i, o, n));
2711
+ const l = U.current;
2712
+ l?.readyState === "open" && l.send(Xn(e, i, o, n));
2668
2713
  },
2669
- onKeyDown: St,
2670
- onKeyUp: St
2714
+ onKeyDown: Nt,
2715
+ onKeyUp: Nt
2671
2716
  }
2672
2717
  ) }),
2673
- Ce && cr && /* @__PURE__ */ k("div", { role: "alert", className: "rc-duo-error", children: cr }),
2674
- !Ce && ut && /* @__PURE__ */ k(
2675
- _o,
2718
+ ye && ur && /* @__PURE__ */ P("div", { role: "alert", className: "rc-duo-error", children: ur }),
2719
+ !ye && ft && /* @__PURE__ */ P(
2720
+ So,
2676
2721
  {
2677
- snapshot: fr,
2678
- geometry: on,
2679
- highlightedId: qt,
2680
- selectedId: Vt,
2681
- mode: an,
2682
- cursorPosition: cn,
2683
- frozenCursorPosition: sn,
2722
+ snapshot: mr,
2723
+ geometry: ln,
2724
+ highlightedId: jt,
2725
+ selectedId: zt,
2726
+ mode: hn,
2727
+ cursorPosition: dn,
2728
+ frozenCursorPosition: fn,
2684
2729
  onSelectChange: (e, i) => {
2685
- Dt(e?.id ?? null), e && i ? $e(i) : e || $e(null);
2686
- const o = Be.current;
2687
- e && o ? L("onInspectSelectionChange", qe.current, {
2730
+ At(e?.id ?? null), e && i ? Xe(i) : e || Xe(null);
2731
+ const o = qe.current;
2732
+ e && o ? L("onInspectSelectionChange", Ve.current, {
2688
2733
  element: e,
2689
2734
  snapshot: o
2690
- }) : L("onInspectSelectionChange", qe.current, null);
2735
+ }) : L("onInspectSelectionChange", Ve.current, null);
2691
2736
  },
2692
2737
  onTapElement: (e, i) => {
2693
2738
  if (i) {
2694
- Dr(i.x, i.y);
2739
+ Ar(i.x, i.y);
2695
2740
  return;
2696
2741
  }
2697
- const o = Be.current;
2698
- o && un(e, o);
2742
+ const o = qe.current;
2743
+ o && pn(e, o);
2699
2744
  }
2700
2745
  }
2701
2746
  ),
2702
- zr ? /* @__PURE__ */ ae("div", { className: "rc-terminated", role: "status", children: [
2703
- /* @__PURE__ */ k("div", { className: "rc-terminated-title", children: "Instance terminated" }),
2704
- /* @__PURE__ */ k("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
2705
- ] }) : jr && /* @__PURE__ */ k("button", { type: "button", className: "rc-retry-button", onClick: Sn, children: "Retry" })
2747
+ tn ? /* @__PURE__ */ ue("div", { className: "rc-terminated", role: "status", children: [
2748
+ /* @__PURE__ */ P("div", { className: "rc-terminated-title", children: "Instance terminated" }),
2749
+ /* @__PURE__ */ P("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
2750
+ ] }) : en && /* @__PURE__ */ P("button", { type: "button", className: "rc-retry-button", onClick: Yn, children: "Retry" })
2706
2751
  ]
2707
2752
  }
2708
2753
  );
2709
2754
  }
2710
- ), Io = (r) => typeof r.message == "string" ? r.message : typeof r.error == "string" ? r.error : null, Yo = (r) => typeof r.dataUri == "string" ? { dataUri: r.dataUri } : typeof r.base64 == "string" ? r.base64.startsWith("data:") ? { dataUri: r.base64 } : { dataUri: `data:${r.base64.startsWith("/9j/") ? "image/jpeg" : "image/png"};base64,${r.base64}` } : null;
2755
+ ), Lo = (r) => typeof r.message == "string" ? r.message : typeof r.error == "string" ? r.error : null, xo = (r) => typeof r.dataUri == "string" ? { dataUri: r.dataUri } : typeof r.base64 == "string" ? r.base64.startsWith("data:") ? { dataUri: r.base64 } : { dataUri: `data:${r.base64.startsWith("/9j/") ? "image/jpeg" : "image/png"};base64,${r.base64}` } : null;
2711
2756
  export {
2712
- er as A,
2713
- Uo as D,
2714
- Wo as H,
2715
- Xo as R,
2716
- Zn as a,
2717
- eo as b,
2718
- Gr as c,
2719
- Br as d,
2720
- qr as e,
2721
- Qn as f,
2722
- Gn as g,
2723
- $o as h,
2724
- Ho as i,
2725
- Lo as j,
2726
- Fo as k,
2727
- zn as n,
2728
- xo as p
2757
+ or as A,
2758
+ $o as D,
2759
+ Vo as H,
2760
+ jo as R,
2761
+ io as a,
2762
+ co as b,
2763
+ zr as c,
2764
+ Gr as d,
2765
+ Jr as e,
2766
+ oo as f,
2767
+ eo as g,
2768
+ Jo as h,
2769
+ Go as i,
2770
+ Xo as j,
2771
+ qo as k,
2772
+ no as n,
2773
+ Bo as p
2729
2774
  };