@limrun/ui 0.21.0 → 0.22.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/README.md +36 -8
  2. package/dist/BufferGeometryUtils-Dm5SmmmT.mjs +64 -0
  3. package/dist/BufferGeometryUtils-Dne8i0aT.js +1 -0
  4. package/dist/GLTFLoader-DzSwAt9C.js +1 -0
  5. package/dist/{GLTFLoader-D4AITfgZ.mjs → GLTFLoader-L51A9w-A.mjs} +138 -137
  6. package/dist/components/device-view.d.ts +29 -0
  7. package/dist/components/duo-frame.d.ts +5 -1
  8. package/dist/components/duo-model.d.ts +2 -1
  9. package/dist/components/macbook-frame.d.ts +30 -0
  10. package/dist/components/macbook-geometry.d.ts +77 -0
  11. package/dist/components/model-source.d.ts +8 -0
  12. package/dist/components/remote-control.d.ts +40 -1
  13. package/dist/components/studio-environment.d.ts +6 -0
  14. package/dist/core/mac-pointer.d.ts +56 -0
  15. package/dist/{core-CRIachT9.mjs → core-nbvkIrvp.mjs} +24 -24
  16. package/dist/core.js +12 -12
  17. package/dist/duo-frame-CHI6g7BR.mjs +758 -0
  18. package/dist/duo-frame-Cj-xHHW3.js +11 -0
  19. package/dist/duo-model-BYgtCaCR.mjs +4 -0
  20. package/dist/duo-model-CDWgmLRF.js +1 -0
  21. package/dist/duo-model.d.ts +2 -0
  22. package/dist/{duo-view-BeqYIqfQ.mjs → duo-view-Biy9MAlH.mjs} +84 -86
  23. package/dist/duo-view-D0Ndj2Ee.js +1 -0
  24. package/dist/index.cjs +1 -1
  25. package/dist/index.css +1 -1
  26. package/dist/index.js +32 -25
  27. package/dist/lite.cjs +1 -1
  28. package/dist/lite.js +2 -2
  29. package/dist/macbook-frame-BHQtQNGV.mjs +349 -0
  30. package/dist/macbook-frame-CQyZhRFn.js +3 -0
  31. package/dist/macbook-model-BiMxLpmf.mjs +4 -0
  32. package/dist/macbook-model-BpUdvtlU.js +1 -0
  33. package/dist/macbook-model.d.ts +2 -0
  34. package/dist/meshopt_decoder.module-C4Z_evpr.mjs +217 -0
  35. package/dist/meshopt_decoder.module-DxJdu6ez.js +1 -0
  36. package/dist/{duo-frame-D1JK_cRk.mjs → model-source-BjSq5Any.mjs} +5353 -6125
  37. package/dist/model-source-S12HoOoQ.js +4049 -0
  38. package/dist/remote-control-BGKETUbE.mjs +1746 -0
  39. package/dist/remote-control-OLgfUSR1.js +1 -0
  40. package/package.json +1 -1
  41. package/dist/GLTFLoader-C25N9Y4j.js +0 -1
  42. package/dist/duo-frame-B1NXSk6a.js +0 -4059
  43. package/dist/duo-view-PsR5b045.js +0 -1
  44. package/dist/remote-control-DNr0Pyrx.js +0 -1
  45. package/dist/remote-control-rdm3mDtI.mjs +0 -1299
@@ -0,0 +1,1746 @@
1
+ import { jsxs as ee, jsx as w, Fragment as So } from "react/jsx-runtime";
2
+ import { M as Q, o as gn, q as yn, f as vn, c as xo, d as bn, b as wn, r as Mn, s as An, t as ko, u as nt, v as Cn, e as Tn, w as G, x as Ft, y as Rn, z as On, B as Tt, C as B, E as Rt, a as En, F as kn, G as x, I as Nn } from "./core-nbvkIrvp.mjs";
3
+ import { useReducer as In, useRef as P, useCallback as kt, memo as zt, useState as W, useEffect as j, useMemo as Ke, lazy as Po, forwardRef as _n, useImperativeHandle as Sn, Suspense as No } from "react";
4
+ import { createPortal as xn } from "react-dom";
5
+ import './index.css';const se = {
6
+ sideBezel: 1.7,
7
+ topBezel: 2.4,
8
+ chin: 2.4,
9
+ baseHeight: 2.2,
10
+ baseOverhang: 4,
11
+ screenRadius: 0.9,
12
+ lidThickness: 0.7
13
+ }, Kt = 100 + 2 * se.sideBezel, ht = Kt + 2 * se.baseOverhang, Vt = se.topBezel + se.chin + se.baseHeight, Pn = (Vt - 2 * se.topBezel) / 2, li = 8;
14
+ function Hn(a) {
15
+ const t = 100 / a, r = t + se.topBezel + se.chin;
16
+ return {
17
+ screenHeight: t,
18
+ lidHeight: r,
19
+ // A closed lid covers the base back to front.
20
+ depth: r
21
+ };
22
+ }
23
+ const Wn = Math.PI / 2, di = 135, ui = 100, hi = 2400;
24
+ function fi(a) {
25
+ return Wn - a * Math.PI / 180;
26
+ }
27
+ function mi(a) {
28
+ const t = Math.max(0, Math.min(1, a));
29
+ return 1 - Math.pow(1 - t, 3);
30
+ }
31
+ function Fe(a, t, r, l = 6) {
32
+ const p = [], v = [
33
+ [a / 2 - r.top, t / 2 - r.top, r.top, 0],
34
+ [-a / 2 + r.top, t / 2 - r.top, r.top, Math.PI / 2],
35
+ [-a / 2 + r.bottom, -t / 2 + r.bottom, r.bottom, Math.PI],
36
+ [a / 2 - r.bottom, -t / 2 + r.bottom, r.bottom, Math.PI * 1.5]
37
+ ];
38
+ for (const [f, b, A, N] of v)
39
+ for (let _ = 0; _ <= l; _++) {
40
+ const E = N + _ * Math.PI / 2 / l;
41
+ p.push({ x: f + A * Math.cos(E), y: b + A * Math.sin(E), nx: Math.cos(E), ny: Math.sin(E) });
42
+ }
43
+ return p;
44
+ }
45
+ function pi(a) {
46
+ const { screenHeight: t, lidHeight: r, depth: l } = Hn(a), p = [], v = (h, y, M) => p.push({ part: h, kind: y, vertices: new Float32Array(M) }), f = (h, y, M, D, H) => {
47
+ const Y = M.map((ne) => ne.x), q = M.map((ne) => ne.y), [de, te, ye, Z] = [Math.min(...Y), Math.max(...Y), Math.min(...q), Math.max(...q)], oe = (de + te) / 2, C = (ye + Z) / 2, Re = (ne, F) => [
48
+ ...D(ne, F),
49
+ ...H,
50
+ (ne - de) / (te - de || 1),
51
+ (F - ye) / (Z - ye || 1)
52
+ ], ft = [];
53
+ for (let ne = 0; ne < M.length; ne++) {
54
+ const F = M[ne], Ie = M[(ne + 1) % M.length];
55
+ for (const Ve of [Re(oe, C), Re(F.x, F.y), Re(Ie.x, Ie.y)]) ft.push(...Ve);
56
+ }
57
+ v(h, y, ft);
58
+ }, b = (h, y, M, D, H, Y, q) => {
59
+ const de = [];
60
+ for (let te = 0; te < M.length; te++) {
61
+ const ye = M[te], Z = M[(te + 1) % M.length], oe = (C, Re) => [...D(C.x, C.y, Re), ...H(C.nx, C.ny), 0, 0];
62
+ for (const C of [
63
+ oe(ye, Y),
64
+ oe(Z, Y),
65
+ oe(Z, q),
66
+ oe(ye, Y),
67
+ oe(Z, q),
68
+ oe(ye, q)
69
+ ])
70
+ de.push(...C);
71
+ }
72
+ v(h, y, de);
73
+ }, A = Fe(Kt, r, { top: 2.2, bottom: 0.4 }), N = (h) => h + r / 2, _ = se.lidThickness;
74
+ b(
75
+ "lid",
76
+ "shell",
77
+ A,
78
+ (h, y, M) => [h, N(y), M],
79
+ (h, y) => [h, y, 0],
80
+ -_,
81
+ 0
82
+ ), f("lid", "shell", A, (h, y) => [h, N(y), -_], [0, 0, -1]), f(
83
+ "lid",
84
+ "glass",
85
+ Fe(Kt - 0.5, r - 0.5, { top: 1.95, bottom: 0.2 }),
86
+ (h, y) => [h, N(y), 0.01],
87
+ [0, 0, 1]
88
+ );
89
+ const E = se.chin;
90
+ f(
91
+ "lid",
92
+ "screen",
93
+ Fe(100, t, { top: se.screenRadius, bottom: 0 }),
94
+ (h, y) => [h, E + t / 2 + y, 0.02],
95
+ [0, 0, 1]
96
+ ), f(
97
+ "lid",
98
+ "camera",
99
+ Fe(0.5, 0.5, { top: 0.25, bottom: 0.25 }, 4),
100
+ (h, y) => [h, r - se.topBezel / 2 + y, 0.02],
101
+ [0, 0, 1]
102
+ );
103
+ const L = Fe(ht, l + _, { top: 3, bottom: 3 }), U = (h) => (l - _) / 2 - h;
104
+ b(
105
+ "base",
106
+ "shell",
107
+ L,
108
+ (h, y, M) => [h, M, U(y)],
109
+ (h, y) => [h, 0, -y],
110
+ -2.2,
111
+ 0
112
+ ), f("base", "shell", L, (h, y) => [h, 0, U(y)], [0, 1, 0]), f("base", "shell", L, (h, y) => [h, -2.2, U(y)], [0, -1, 0]);
113
+ const ae = (h, y, M, D, H, Y, q) => f("base", h, Fe(D, H, { top: q, bottom: q }, 3), (de, te) => [y + de, Y, M - te], [0, 1, 0]), Te = ht * 0.72, me = l * 0.08, R = [0.55, 1, 1, 1, 1, 1], le = l * 0.4 / R.reduce((h, y) => h + y, 0);
114
+ ae("well", 0, me + l * 0.4 / 2, Te + 1.4, l * 0.4 + 1.4, 0.01, 0.8);
115
+ let z = me;
116
+ for (const [h, y] of R.entries()) {
117
+ const M = y * le, D = Te / 14;
118
+ for (let H = 0; H < 14; H++) {
119
+ if (h === 5 && H > 4 && H < 9) continue;
120
+ const Y = h === 5 && H === 4 ? 5 : 1;
121
+ ae(
122
+ "keys",
123
+ -Te / 2 + D * (H + Y / 2),
124
+ z + M / 2,
125
+ D * Y - 0.5,
126
+ M - 0.5,
127
+ 0.03,
128
+ 0.3
129
+ );
130
+ }
131
+ z += M;
132
+ }
133
+ ae("trackpad", 0, l * 0.72, ht * 0.4, l * 0.36, 0.01, 1.2), f(
134
+ "base",
135
+ "scoop",
136
+ Fe(14, 0.9, { top: 0, bottom: 0.45 }, 3),
137
+ (h, y) => [h, -0.45 + y, l + 0.01],
138
+ [0, 0, 1]
139
+ );
140
+ const S = /* @__PURE__ */ new Map();
141
+ for (const h of p) {
142
+ const y = `${h.part}:${h.kind}`;
143
+ S.set(y, [...S.get(y) ?? [], h]);
144
+ }
145
+ return [...S.values()].map((h) => {
146
+ const y = new Float32Array(h.reduce((D, H) => D + H.vertices.length, 0));
147
+ let M = 0;
148
+ for (const D of h)
149
+ y.set(D.vertices, M), M += D.vertices.length;
150
+ return { part: h[0].part, kind: h[0].kind, vertices: y };
151
+ });
152
+ }
153
+ function gi(a, t, r = 0) {
154
+ const l = 1 - r, p = t / l, v = a >= p ? 1 : a / p, f = (a >= p ? p / a : 1) * l, b = (1 - v) / 2, A = r > 0 ? l - f : (l - f) / 2;
155
+ return { repeat: [1 / v, 1 / f], offset: [(0 - b) / v, (0 - A) / f] };
156
+ }
157
+ function yi(a, t, r) {
158
+ const l = a * r.repeat[0] + r.offset[0], p = t * r.repeat[1] + r.offset[1], v = 1e-9;
159
+ if (l < -v || l > 1 + v || p < -v || p > 1 + v) return;
160
+ const f = (b) => Math.max(0, Math.min(1, b));
161
+ return { x: f(l), y: f(1 - p) };
162
+ }
163
+ const Dn = 150, Ln = 8;
164
+ class Yn {
165
+ constructor(t, r = () => !1) {
166
+ this.send = t, this.blocked = r;
167
+ }
168
+ send;
169
+ blocked;
170
+ // The last pointer event sent, whose buttons the guest holds.
171
+ last;
172
+ gesture;
173
+ screen;
174
+ pointer(t, r, l) {
175
+ const p = t === Q.UP && !!this.last?.buttons;
176
+ this.blocked() && !p || (this.last = { ...r, buttons: l }, this.send(gn(t, r.width, r.height, r.x, r.y, l)));
177
+ }
178
+ scroll(t, r, l) {
179
+ this.blocked() || this.send(yn(t.width, t.height, t.x, t.y, r, l));
180
+ }
181
+ /**
182
+ * A touch event, its fingers in client coordinates. Returns true when a finger lands on the screen
183
+ * and starts a gesture, so the caller can give the screen the keyboard.
184
+ */
185
+ touch(t, r, l) {
186
+ const p = this.gesture;
187
+ if (r.length >= 2) {
188
+ const f = {
189
+ x: r.reduce((b, A) => b + A.x, 0) / r.length,
190
+ y: r.reduce((b, A) => b + A.y, 0) / r.length
191
+ };
192
+ if (p?.mode === "scroll") {
193
+ const b = l.map(f.x, f.y);
194
+ b && t === "touchmove" && this.scroll(b, (p.x - f.x) * l.scale, (p.y - f.y) * l.scale);
195
+ } else p?.mode === "press" ? this.lift(p, l) : p?.mode === "pending" && clearTimeout(p.timer);
196
+ return this.gesture = { mode: "scroll", ...f }, !1;
197
+ }
198
+ const v = r[0];
199
+ if (v && t === "touchstart" && !p)
200
+ return this.blocked() || !l.contains(v.x, v.y) ? !1 : (this.screen = l, this.gesture = {
201
+ mode: "pending",
202
+ x: v.x,
203
+ y: v.y,
204
+ timer: setTimeout(() => this.press(), Dn)
205
+ }, !0);
206
+ if (v && p?.mode === "pending") {
207
+ if (Math.hypot(v.x - p.x, v.y - p.y) < Ln) return !1;
208
+ this.press();
209
+ }
210
+ if (v && this.gesture?.mode === "press") {
211
+ this.gesture = { mode: "press", x: v.x, y: v.y };
212
+ const f = l.map(v.x, v.y);
213
+ return f && this.pointer(Q.MOVE, f, 1), !1;
214
+ }
215
+ if (r.length === 0) {
216
+ p?.mode === "pending" && (t === "touchcancel" ? clearTimeout(p.timer) : this.press());
217
+ const f = this.gesture;
218
+ f?.mode === "press" && this.lift(f, l), this.gesture = void 0;
219
+ }
220
+ return !1;
221
+ }
222
+ /** Drops a pending touch and lets go of any button the guest holds, where it was pressed. */
223
+ release() {
224
+ clearTimeout(this.gesture?.timer), this.gesture = void 0;
225
+ const t = this.last;
226
+ t?.buttons && this.pointer(Q.UP, t, 0);
227
+ }
228
+ // A pending finger's press, where it landed.
229
+ press() {
230
+ const t = this.gesture;
231
+ if (t?.mode !== "pending") return;
232
+ clearTimeout(t.timer), this.gesture = { mode: "press", x: t.x, y: t.y };
233
+ const r = this.screen?.map(t.x, t.y);
234
+ r && this.pointer(Q.DOWN, r, 1);
235
+ }
236
+ lift(t, r) {
237
+ const l = r.map(t.x, t.y);
238
+ l && this.pointer(Q.UP, l, 0);
239
+ }
240
+ }
241
+ function Xn(a, t) {
242
+ return t.type === "choose" ? t.mode === a.mode ? a : t.mode === "3d" ? { ...a, mode: "3d", selection: a.selection + 1 } : { ...a, mode: "2d" } : a.mode !== "3d" || t.selection !== a.selection || a.ready === t.selection ? a : { ...a, ready: t.selection };
243
+ }
244
+ function $n(a) {
245
+ const [t, r] = In(Xn, { mode: "2d", selection: 0, ready: 0 }), l = P(t);
246
+ l.current = t;
247
+ const p = P(a);
248
+ p.current = a;
249
+ const { mode: v, selection: f, ready: b } = t, A = kt((E) => r({ type: "choose", mode: E }), []), N = kt(() => {
250
+ const E = l.current;
251
+ E.mode !== "3d" || E.selection !== f || E.ready === f || (p.current?.(), r({ type: "ready", selection: f }));
252
+ }, [f]), _ = v === "3d" && b !== f;
253
+ return { mode: v, shown: v === "3d" && !_ ? "3d" : "2d", loading: _, choose: A, onReady: N };
254
+ }
255
+ function Bn({ view: a, label: t }) {
256
+ return /* @__PURE__ */ ee("div", { className: "rc-duo-mode", role: "group", "aria-label": t, children: [
257
+ /* @__PURE__ */ w("button", { type: "button", "aria-pressed": a.mode === "2d", onClick: () => a.choose("2d"), children: "2D" }),
258
+ /* @__PURE__ */ w(
259
+ "button",
260
+ {
261
+ type: "button",
262
+ "aria-pressed": a.mode === "3d",
263
+ "aria-busy": a.loading,
264
+ title: a.loading ? "Loading 3D" : void 0,
265
+ onClick: () => a.choose("3d"),
266
+ children: "3D"
267
+ }
268
+ )
269
+ ] });
270
+ }
271
+ const Un = async (a) => {
272
+ if (!a) return !1;
273
+ try {
274
+ if (typeof navigator < "u" && navigator.clipboard?.writeText)
275
+ return await navigator.clipboard.writeText(a), !0;
276
+ } catch {
277
+ }
278
+ try {
279
+ const t = document.createElement("textarea");
280
+ t.value = a, t.style.position = "fixed", t.style.opacity = "0", document.body.appendChild(t), t.select();
281
+ const r = document.execCommand("copy");
282
+ return document.body.removeChild(t), r;
283
+ } catch {
284
+ return !1;
285
+ }
286
+ }, Fn = zt(
287
+ function({ element: t, screen: r, highlighted: l, selected: p, selectable: v, onClick: f }) {
288
+ const b = vn(t.frame, r);
289
+ if (!b) return null;
290
+ const A = xo(t);
291
+ return /* @__PURE__ */ w(
292
+ "button",
293
+ {
294
+ type: "button",
295
+ className: t.enabled ? "rc-inspect-box" : "rc-inspect-box rc-inspect-box-disabled",
296
+ "data-ax-id": t.id,
297
+ "data-ax-path": t.path,
298
+ "data-ax-label": t.label || void 0,
299
+ "data-ax-role": t.role || void 0,
300
+ "data-highlighted": l ? "true" : "false",
301
+ "data-selected": p ? "true" : "false",
302
+ "aria-label": A,
303
+ onClick: (N) => {
304
+ v && (N.preventDefault(), N.stopPropagation(), f(t, { x: N.clientX, y: N.clientY }));
305
+ },
306
+ style: {
307
+ left: `${b.x / r.width * 100}%`,
308
+ top: `${b.y / r.height * 100}%`,
309
+ width: `${b.width / r.width * 100}%`,
310
+ height: `${b.height / r.height * 100}%`
311
+ }
312
+ }
313
+ );
314
+ },
315
+ (a, t) => a.highlighted === t.highlighted && a.selected === t.selected && a.selectable === t.selectable && a.screen.width === t.screen.width && a.screen.height === t.screen.height && a.onClick === t.onClick && bn(a.element, t.element)
316
+ ), Kn = 260, Vn = 220, zn = 6, Gn = 8, jn = zt(function({
317
+ element: t,
318
+ platform: r,
319
+ anchor: l,
320
+ cursorAnchored: p,
321
+ showActions: v,
322
+ onTap: f
323
+ }) {
324
+ const [b, A] = W(null);
325
+ j(() => {
326
+ if (!b) return;
327
+ const R = window.setTimeout(() => A(null), 1100);
328
+ return () => window.clearTimeout(R);
329
+ }, [b]);
330
+ const N = Ke(() => {
331
+ const R = Kn, le = Vn, z = zn, S = Gn, h = typeof window < "u" ? window.innerWidth : 1024, y = typeof window < "u" ? window.innerHeight : 768, M = l.x + z + R <= h - S, D = l.y - z - le >= S;
332
+ let H = M ? l.x + z : l.x - z, Y = D ? l.y - z : l.y + z;
333
+ const te = `translate(${M ? "0" : "-100%"}, ${D ? "-100%" : "0"})`;
334
+ return H = Math.max(S + (M ? 0 : R), Math.min(h - S - (M ? R : 0), H)), Y = Math.max(S + (D ? le : 0), Math.min(y - S - (D ? 0 : le), Y)), { left: `${H}px`, top: `${Y}px`, transform: te };
335
+ }, [l.x, l.y]), _ = Ke(() => wn(t, r), [t, r]), E = r === "ios" ? t.selectors.AXUniqueId : t.selectors.resourceId, L = r === "ios" ? "AXUniqueId" : "resourceId", U = kt(async (R, le) => {
336
+ if (!R) return;
337
+ await Un(R) && A(le);
338
+ }, []), ae = Mn(t), Te = t.label || t.value || ae, me = xo(t);
339
+ return xn(
340
+ /* @__PURE__ */ ee(
341
+ "div",
342
+ {
343
+ className: "rc-inspect-card",
344
+ "data-cursor-anchored": p ? "true" : "false",
345
+ style: N,
346
+ onClick: (R) => R.stopPropagation(),
347
+ onMouseDown: (R) => R.stopPropagation(),
348
+ onMouseMove: (R) => R.stopPropagation(),
349
+ children: [
350
+ /* @__PURE__ */ ee("div", { className: "rc-inspect-card-header", children: [
351
+ /* @__PURE__ */ w("span", { className: "rc-inspect-card-role", children: ae }),
352
+ !t.enabled && /* @__PURE__ */ w("span", { className: "rc-inspect-card-tag", children: "disabled" }),
353
+ t.focused && /* @__PURE__ */ w("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
354
+ ] }),
355
+ /* @__PURE__ */ w("p", { className: "rc-inspect-card-title", title: me, children: Te }),
356
+ E && /* @__PURE__ */ ee("div", { className: "rc-inspect-card-row", children: [
357
+ /* @__PURE__ */ ee("span", { className: "rc-inspect-card-row-label", children: [
358
+ L,
359
+ ":"
360
+ ] }),
361
+ /* @__PURE__ */ w("span", { className: "rc-inspect-card-row-value", children: E })
362
+ ] }),
363
+ t.value && t.value !== t.label && /* @__PURE__ */ ee("div", { className: "rc-inspect-card-row", children: [
364
+ /* @__PURE__ */ w("span", { className: "rc-inspect-card-row-label", children: "value:" }),
365
+ /* @__PURE__ */ w("span", { className: "rc-inspect-card-row-value", children: t.value })
366
+ ] }),
367
+ /* @__PURE__ */ ee("div", { className: "rc-inspect-card-row", children: [
368
+ /* @__PURE__ */ w("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
369
+ /* @__PURE__ */ ee("span", { className: "rc-inspect-card-row-value", children: [
370
+ Math.round(t.frame.width),
371
+ "×",
372
+ Math.round(t.frame.height),
373
+ " @ ",
374
+ Math.round(t.frame.x),
375
+ ",",
376
+ Math.round(t.frame.y)
377
+ ] })
378
+ ] }),
379
+ v && /* @__PURE__ */ ee("div", { className: "rc-inspect-card-actions", children: [
380
+ /* @__PURE__ */ w(
381
+ "button",
382
+ {
383
+ type: "button",
384
+ className: "rc-inspect-card-btn rc-inspect-card-btn-primary",
385
+ disabled: !f,
386
+ onClick: () => f?.(t, l),
387
+ children: "Tap"
388
+ }
389
+ ),
390
+ /* @__PURE__ */ w(
391
+ "button",
392
+ {
393
+ type: "button",
394
+ className: b === "selector" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
395
+ disabled: !_,
396
+ title: _ ?? "No usable selector for this element",
397
+ onClick: () => U(_ ?? void 0, "selector"),
398
+ children: b === "selector" ? "Copied!" : "Copy selector"
399
+ }
400
+ ),
401
+ /* @__PURE__ */ w(
402
+ "button",
403
+ {
404
+ type: "button",
405
+ className: b === "id" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
406
+ disabled: !E,
407
+ title: E ?? `No ${L}`,
408
+ onClick: () => U(E, "id"),
409
+ children: b === "id" ? "Copied!" : `Copy ${L}`
410
+ }
411
+ )
412
+ ] })
413
+ ]
414
+ }
415
+ ),
416
+ document.body
417
+ );
418
+ }), qn = zt(function({
419
+ snapshot: t,
420
+ geometry: r,
421
+ highlightedId: l,
422
+ selectedId: p,
423
+ mode: v,
424
+ cursorPosition: f,
425
+ frozenCursorPosition: b,
426
+ onSelectChange: A,
427
+ onTapElement: N
428
+ }) {
429
+ const _ = v === "select", E = _ ? l !== null && l !== p : l !== null, L = _ ? l ?? p : l, U = Ke(() => {
430
+ const S = /* @__PURE__ */ new Map();
431
+ if (!t) return S;
432
+ for (const h of t.elements) S.set(h.id, h);
433
+ return S;
434
+ }, [t]), ae = Ke(() => L ? U.get(L) ?? null : null, [L, U]);
435
+ if (!(!!t && !!r && t.screen.width > 0 && t.screen.height > 0 && t.elements.length > 0)) return null;
436
+ const me = E ? f : b ?? f, R = E, le = _ && !E && p !== null, z = (S) => {
437
+ _ && S.target === S.currentTarget && A(null, null);
438
+ };
439
+ return /* @__PURE__ */ ee(So, { children: [
440
+ /* @__PURE__ */ w(
441
+ "div",
442
+ {
443
+ className: _ ? "rc-inspect-overlay rc-inspect-overlay-select" : "rc-inspect-overlay",
444
+ style: {
445
+ left: `${r.left}px`,
446
+ top: `${r.top}px`,
447
+ width: `${r.width}px`,
448
+ height: `${r.height}px`
449
+ },
450
+ onClick: z,
451
+ children: t.elements.map((S) => /* @__PURE__ */ w(
452
+ Fn,
453
+ {
454
+ element: S,
455
+ screen: t.screen,
456
+ highlighted: S.id === l,
457
+ selected: S.id === p,
458
+ selectable: _,
459
+ onClick: A
460
+ },
461
+ S.id
462
+ ))
463
+ }
464
+ ),
465
+ ae && me && /* @__PURE__ */ w(
466
+ jn,
467
+ {
468
+ element: ae,
469
+ platform: t.platform,
470
+ anchor: me,
471
+ cursorAnchored: R,
472
+ showActions: le,
473
+ onTap: N
474
+ }
475
+ )
476
+ ] });
477
+ });
478
+ function Zn(a, t) {
479
+ if (!t.startsWith("lim_st_")) return !1;
480
+ try {
481
+ const r = new URL(a).pathname.split("/").map(decodeURIComponent).find((N) => /^(ios|android)_[a-z0-9_]+$/.test(N));
482
+ if (!r) return !1;
483
+ const l = r.split("_")[0], p = t.slice(7).split(".");
484
+ if (p.length !== 3 || p.some((N) => !N)) return !1;
485
+ const v = atob(p[1].replace(/-/g, "+").replace(/_/g, "/")), f = JSON.parse(
486
+ new TextDecoder().decode(Uint8Array.from(v, (N) => N.charCodeAt(0)))
487
+ );
488
+ if (!f || typeof f != "object" || !("scopes" in f)) return !1;
489
+ const b = f.scopes;
490
+ if (!Array.isArray(b) || !b.every((N) => typeof N == "string")) return !1;
491
+ let A = !1;
492
+ for (const N of b) {
493
+ const [_, E, L, U] = N.split(":");
494
+ if (!(U !== void 0 || _ !== l && _ !== "*") && !(E !== r && E !== "*")) {
495
+ if (L === "stream" || L === "all") return !1;
496
+ L === "watch" && (A = !0);
497
+ }
498
+ }
499
+ return A;
500
+ } catch {
501
+ return !1;
502
+ }
503
+ }
504
+ const Jn = Po(() => import("./duo-view-Biy9MAlH.mjs").then((a) => a.d)), Qn = Po(() => import("./macbook-frame-BHQtQNGV.mjs")), Ot = (a) => Object.entries(x).find(
505
+ ([r, l]) => r.startsWith("ACTION_") && l === a
506
+ )?.[0] ?? String(a), Io = 1920, _o = 1200, ei = (a, t) => a === Io && t === _o || a === _o && t === Io, ti = {
507
+ ios: {
508
+ videoBorderRadiusMultiplier: 0.15,
509
+ loadingLogoSize: "20%",
510
+ // Video position as percentage of frame dimensions
511
+ videoPosition: {
512
+ portrait: { heightMultiplier: 0.9678 },
513
+ landscape: { widthMultiplier: 0.9678 }
514
+ }
515
+ },
516
+ android: {
517
+ videoBorderRadiusMultiplier: 0.13,
518
+ loadingLogoSize: "40%",
519
+ // Video position as percentage of frame dimensions
520
+ videoPosition: {
521
+ portrait: { heightMultiplier: 0.967 },
522
+ landscape: { widthMultiplier: 0.962 }
523
+ }
524
+ },
525
+ // A macOS virtual machine is a desktop display. Its MacBook Pro frame is drawn in CSS around
526
+ // whatever size the guest display has; see MACBOOK below.
527
+ macos: {
528
+ videoBorderRadiusMultiplier: 0,
529
+ loadingLogoSize: "10%",
530
+ videoPosition: {
531
+ portrait: { heightMultiplier: 1 },
532
+ landscape: { widthMultiplier: 1 }
533
+ }
534
+ }
535
+ }, oi = {
536
+ "iphone-se": {
537
+ videoBorderRadiusMultiplier: 0,
538
+ loadingLogoSize: "20%",
539
+ videoPosition: {
540
+ portrait: { heightMultiplier: 667 / 889 },
541
+ landscape: { widthMultiplier: 667 / 889 }
542
+ },
543
+ // The SE has no home indicator, so its frame's home button is the way home: 64 points across,
544
+ // centered in the bottom bezel 389 points below the frame's center.
545
+ homeButton: { offset: 389 / 889, diameter: 64 / 889 }
546
+ },
547
+ "iphone-17e": {
548
+ videoBorderRadiusMultiplier: 47.33 / 452,
549
+ loadingLogoSize: "20%",
550
+ videoPosition: {
551
+ portrait: { heightMultiplier: 844 / 888 },
552
+ landscape: { widthMultiplier: 844 / 888 }
553
+ }
554
+ }
555
+ }, Ut = 16 / 10, Et = 44, ni = {
556
+ videoBorderRadiusMultiplier: 32 / 1837,
557
+ loadingLogoSize: "40%",
558
+ videoPosition: {
559
+ portrait: { heightMultiplier: 2560 / 2798 },
560
+ landscape: { widthMultiplier: 2560 / 2798 }
561
+ }
562
+ };
563
+ function ii(a) {
564
+ const t = a.code, r = kn[t];
565
+ if (!r)
566
+ return Ft(`Unknown event.code: ${t}, key: ${a.key}`), null;
567
+ let l = B.META_NONE;
568
+ const p = t >= "KeyA" && t <= "KeyZ", v = a.getModifierState("CapsLock"), f = a.shiftKey;
569
+ let b = f;
570
+ return p && (b = f !== v), b && (l |= B.META_SHIFT_ON), a.ctrlKey && (l |= B.META_CTRL_ON), a.altKey && (l |= B.META_ALT_ON), a.metaKey && (l |= B.META_META_ON), { keycode: r, metaState: l };
571
+ }
572
+ function ut(a, t) {
573
+ const r = Object.keys(a);
574
+ return r.length === Object.keys(t).length && r.every((l) => a[l] === t[l]);
575
+ }
576
+ const vi = _n(
577
+ ({
578
+ className: a,
579
+ url: t,
580
+ token: r,
581
+ sessionId: l,
582
+ openUrl: p,
583
+ watchOnly: v = !1,
584
+ showFrame: f = !0,
585
+ animateLid: b = !0,
586
+ deviceModel: A,
587
+ duoModelUrl: N,
588
+ macbookModelUrl: _,
589
+ autoReconnect: E,
590
+ jitterBufferTargetMs: L,
591
+ onPlaybackStats: U,
592
+ onTerminated: ae,
593
+ assets: Te,
594
+ onConnectionStateChange: me,
595
+ inspectMode: R,
596
+ onAxSnapshotChange: le,
597
+ onInspectSelectionChange: z,
598
+ onAxStatusChange: S,
599
+ axPollIntervalMs: h,
600
+ axMaxBackoffMs: y,
601
+ androidElementTreeOptions: M,
602
+ onCameraDemandChange: D,
603
+ onCameraStats: H,
604
+ onTrace: Y,
605
+ microphoneEnabled: q = !1,
606
+ onMicrophoneStateChange: de
607
+ }, te) => {
608
+ const ye = Ke(() => Zn(t, r), [t, r]), Z = v || ye, oe = P(null), C = P(null), Re = P(null), [ft, ne] = W(!1), F = A === "iphone-duo" || ft, Ie = A === "iphone-duo" ? A : void 0, Ve = P(null), [Gt, Ho] = W(null), [jt, Wo] = W(), [Do, Lo] = W(!1), [Yo, Xo] = W(!1), [$o, Bo] = W(!1), [Nt, qt] = W(!1), [Zt, Jt] = W(!1), [Uo, Qt] = W({}), [eo, to] = W(null), [It, Fo] = W(null), [_t, Ko] = W(null), oo = P(null), [no, Vo] = W(null), [io, ro] = W(null), it = $n(() => bt.current?.release()), mt = P(!1), St = P(null), V = P(/* @__PURE__ */ new Map()), _e = P(!1), [zo, Go] = W(!1), X = P(null), ze = P(null), rt = P({
609
+ handle: () => {
610
+ },
611
+ end: () => {
612
+ }
613
+ }), [Se, pt] = W(null), [co, xt] = W(null), [Pt, ct] = W(null), [Ht, gt] = W(null), [jo, so] = W(null), [qo, ao] = W(null), yt = P(null), ve = P(void 0), lo = (e) => {
614
+ yt.current = e, ve.current === void 0 && (ve.current = window.requestAnimationFrame(() => {
615
+ ve.current = void 0, ao(yt.current);
616
+ }));
617
+ }, [Zo, Ge] = W(null), xe = P(null);
618
+ xe.current = co;
619
+ const je = P(z);
620
+ je.current = z;
621
+ const Pe = R === !0 || R === "hover-only", uo = P(Pe);
622
+ uo.current = Pe;
623
+ const Jo = R === "hover-only" ? "hover-only" : "select", K = Ke(() => An(t), [t]), Qo = Ke(
624
+ () => l || Array.from(crypto.getRandomValues(new Uint32Array(4)), (e) => e.toString(36)).join(""),
625
+ [l]
626
+ ), st = K === "ios" && A && A !== "iphone-duo" ? A : void 0, He = K === "android" && Zt ? ni : st ? oi[st] : ti[K], ue = Te?.[K], ho = st && ue?.modelFrames?.[st], fo = K === "android" && Zt ? Nt ? ue?.tabletFrameLandscape : ue?.tabletFrame : st ? Nt ? ho?.frameLandscape : ho?.frame : Nt ? ue?.frameLandscape : ue?.frame, mo = ue?.loadingLogo, at = !F && K !== "macos" && f && !!fo, pe = K === "macos" && f, be = pe && ue?.frame && ue.screen ? { src: ue.frame, screen: ue.screen } : void 0, Wt = P(null), en = pe && it.mode === "3d", we = pe && it.shown === "3d";
627
+ mt.current = we;
628
+ const po = it.choose;
629
+ j(() => {
630
+ pe || po("2d");
631
+ }, [pe, po]);
632
+ const go = !!be && !we && !!_t;
633
+ j(() => {
634
+ const e = C.current, n = oo.current, i = n?.getContext("2d");
635
+ if (!go || !e || !n || !i) return;
636
+ const o = () => {
637
+ if (e.videoWidth) {
638
+ n.width !== e.videoWidth && (n.width = e.videoWidth);
639
+ try {
640
+ i.drawImage(e, 0, 0, e.videoWidth, 1, 0, 0, n.width, 1);
641
+ } catch {
642
+ }
643
+ }
644
+ };
645
+ let c = !1, d;
646
+ const s = () => {
647
+ c || (o(), d = e.requestVideoFrameCallback(s));
648
+ }, u = "requestVideoFrameCallback" in e ? void 0 : window.setInterval(o, 1e3 / 30);
649
+ return u === void 0 && (d = e.requestVideoFrameCallback(s)), o(), () => {
650
+ c = !0, d !== void 0 && e.cancelVideoFrameCallback(d), window.clearInterval(u);
651
+ };
652
+ }, [go]);
653
+ const k = P(null), fe = (e) => k.current?.sendControl(e), vt = P(/* @__PURE__ */ new Set()), yo = P(!1);
654
+ yo.current = R === !0;
655
+ const bt = P(null);
656
+ bt.current || (bt.current = new Yn(
657
+ (e) => k.current?.sendControl(e),
658
+ () => yo.current
659
+ ));
660
+ const We = bt.current;
661
+ j(() => () => We.release(), [We]);
662
+ const lt = kt(() => {
663
+ for (const e of vt.current)
664
+ k.current?.sendControl(ko(Q.UP, e));
665
+ vt.current.clear();
666
+ }, []), Dt = (e, n) => k.current?.sendDuoControl(e, n) ?? Promise.reject(new Error("Simulator disconnected")), vo = -10, bo = (e, n) => {
667
+ const i = Ze();
668
+ if (!i) return;
669
+ const o = Me(i, e, n);
670
+ if (!o) return;
671
+ const { videoX: c, videoY: d, videoWidth: s, videoHeight: u } = o, m = Rt(
672
+ x.ACTION_DOWN,
673
+ vo,
674
+ s,
675
+ u,
676
+ c,
677
+ d,
678
+ 1,
679
+ x.BUTTON_PRIMARY,
680
+ x.BUTTON_PRIMARY
681
+ );
682
+ m && fe(m), window.setTimeout(() => {
683
+ const T = Rt(
684
+ x.ACTION_UP,
685
+ vo,
686
+ s,
687
+ u,
688
+ c,
689
+ d,
690
+ 0,
691
+ x.BUTTON_PRIMARY,
692
+ x.BUTTON_PRIMARY
693
+ );
694
+ T && fe(T);
695
+ }, 60);
696
+ }, tn = (e, n) => {
697
+ const i = Ze();
698
+ if (!i || n.screen.width <= 0 || n.screen.height <= 0) return;
699
+ const o = e.frame.x + e.frame.width / 2, c = e.frame.y + e.frame.height / 2, d = o / n.screen.width * i.actualWidth, s = c / n.screen.height * i.actualHeight, u = i.videoRect.left + i.offsetX + d, m = i.videoRect.top + i.offsetY + s;
700
+ bo(u, m);
701
+ }, wt = -1, Mt = -2, De = -3, qe = (e, n, i, o, c, d) => {
702
+ const s = Rt(
703
+ e,
704
+ n,
705
+ i,
706
+ o,
707
+ c,
708
+ d,
709
+ 1,
710
+ // pressure
711
+ x.BUTTON_PRIMARY,
712
+ x.BUTTON_PRIMARY
713
+ );
714
+ s && (G("[rc-touch] sendSingleTouch", {
715
+ action: e,
716
+ actionName: Ot(e),
717
+ pointerId: n,
718
+ x: c,
719
+ y: d,
720
+ video: { width: i, height: o }
721
+ }), fe(s));
722
+ }, Le = (e, n, i) => {
723
+ if (!i) return;
724
+ const { videoX: o, videoY: c, videoWidth: d, videoHeight: s } = i;
725
+ let u = null, m = null, T = 1;
726
+ const I = x.BUTTON_PRIMARY;
727
+ switch (n) {
728
+ case "down":
729
+ e !== De && rt.current.end(), u = V.current.size === 0 ? x.ACTION_DOWN : x.ACTION_POINTER_DOWN, m = { x: o, y: c }, V.current.set(e, m), e === -1 && C.current?.focus();
730
+ break;
731
+ case "move":
732
+ V.current.has(e) && (u = x.ACTION_MOVE, m = { x: o, y: c }, V.current.set(e, m));
733
+ break;
734
+ case "up":
735
+ case "cancel":
736
+ V.current.has(e) && (m = V.current.get(e), V.current.delete(e), n === "cancel" ? u = x.ACTION_CANCEL : u = V.current.size === 0 ? x.ACTION_UP : x.ACTION_POINTER_UP);
737
+ break;
738
+ }
739
+ if (u !== null && m !== null) {
740
+ G("[rc-touch][mouse->touch] sending", {
741
+ pointerId: e,
742
+ eventType: n,
743
+ action: u,
744
+ actionName: Ot(u),
745
+ positionToSend: m,
746
+ video: { width: d, height: s },
747
+ altHeld: _e.current,
748
+ activePointersAfter: Array.from(V.current.entries()).map(([re, $]) => ({
749
+ id: re,
750
+ x: $.x,
751
+ y: $.y
752
+ }))
753
+ });
754
+ const g = Rt(
755
+ u,
756
+ e,
757
+ d,
758
+ s,
759
+ m.x,
760
+ m.y,
761
+ T,
762
+ I,
763
+ I
764
+ );
765
+ g && (G("[rc-touch][mouse->touch] buffer", {
766
+ pointerId: e,
767
+ actionName: Ot(u),
768
+ byteLength: g.byteLength
769
+ }), fe(g));
770
+ } else (n === "up" || n === "cancel") && V.current.delete(e);
771
+ }, Lt = (e) => {
772
+ if (_e.current !== e && (_e.current = e, Go(e), e || pt(null), G("[rc-touch][alt] updateAltHeld", {
773
+ nextHeld: e,
774
+ activePointerIds: Array.from(V.current.keys())
775
+ }), K === "ios" && k.current?.getState().controlReady)) {
776
+ const n = e ? B.ACTION_DOWN : B.ACTION_UP, i = Tt(
777
+ n,
778
+ B.KEYCODE_ALT_LEFT,
779
+ 0,
780
+ B.META_NONE
781
+ );
782
+ G("[rc-touch][alt] sending Indigo modifier keycode", {
783
+ action: n,
784
+ keycode: B.KEYCODE_ALT_LEFT
785
+ }), i && fe(i);
786
+ }
787
+ }, Ze = () => {
788
+ const e = C.current, n = oe.current;
789
+ if (!e || !n) return null;
790
+ const i = e.videoWidth, o = e.videoHeight;
791
+ if (!i || !o) return null;
792
+ const c = e.getBoundingClientRect(), d = n.getBoundingClientRect(), s = c.width, u = c.height, m = i / o, T = s / u;
793
+ let I = s, g = u;
794
+ m > T ? g = s / m : I = u * m;
795
+ const re = (s - I) / 2, $ = (u - g) / 2;
796
+ return {
797
+ videoWidth: i,
798
+ videoHeight: o,
799
+ videoRect: c,
800
+ containerRect: d,
801
+ actualWidth: I,
802
+ actualHeight: g,
803
+ offsetX: re,
804
+ offsetY: $
805
+ };
806
+ }, Me = (e, n, i) => {
807
+ const o = n - e.videoRect.left - e.offsetX, c = i - e.videoRect.top - e.offsetY, d = Math.max(0, Math.min(e.actualWidth, o)), s = Math.max(0, Math.min(e.actualHeight, c)), u = Math.max(
808
+ 0,
809
+ Math.min(e.videoWidth, d / e.actualWidth * e.videoWidth)
810
+ ), m = Math.max(
811
+ 0,
812
+ Math.min(e.videoHeight, s / e.actualHeight * e.videoHeight)
813
+ );
814
+ return {
815
+ videoX: u,
816
+ videoY: m,
817
+ videoWidth: e.videoWidth,
818
+ videoHeight: e.videoHeight
819
+ };
820
+ }, on = (e, n, i) => {
821
+ const o = n - e.videoRect.left - e.offsetX, c = i - e.videoRect.top - e.offsetY, d = Math.max(0, Math.min(e.actualWidth, o)), s = Math.max(0, Math.min(e.actualHeight, c)), u = Math.max(
822
+ 0,
823
+ Math.min(e.videoWidth, d / e.actualWidth * e.videoWidth)
824
+ ), m = Math.max(
825
+ 0,
826
+ Math.min(e.videoHeight, s / e.actualHeight * e.videoHeight)
827
+ ), T = e.videoWidth - u, I = e.videoHeight - m, g = e.videoRect.left + e.offsetX, re = e.videoRect.top + e.offsetY, $ = g - e.containerRect.left + d, J = re - e.containerRect.top + s, he = g - e.containerRect.left + (e.actualWidth - d), O = re - e.containerRect.top + (e.actualHeight - s);
828
+ return {
829
+ containerX: $,
830
+ containerY: J,
831
+ mirrorContainerX: he,
832
+ mirrorContainerY: O,
833
+ videoX: u,
834
+ videoY: m,
835
+ mirrorVideoX: T,
836
+ mirrorVideoY: I,
837
+ videoWidth: e.videoWidth,
838
+ videoHeight: e.videoHeight
839
+ };
840
+ }, nn = (e, n, i, o, c, d, s) => {
841
+ const u = Nn(e, n, i, o, c, d, s);
842
+ G("[rc-touch2] sendTwoFingerMessage (iOS)", {
843
+ actionName: Ot(e),
844
+ video: { width: n, height: i },
845
+ p0: { x: o, y: c },
846
+ p1: { x: d, y: s },
847
+ byteLength: u.byteLength
848
+ }), fe(u);
849
+ }, Je = (e, n, i, o, c, d, s, u, m) => {
850
+ if (G("[rc-touch2] applyTwoFingerEvent", {
851
+ platform: K,
852
+ eventType: e,
853
+ video: { width: n, height: i },
854
+ p0: { x: o, y: c, id: u },
855
+ p1: { x: d, y: s, id: m }
856
+ }), e === "down" && rt.current.end(), K === "ios") {
857
+ const T = e === "down" ? x.ACTION_DOWN : e === "move" ? x.ACTION_MOVE : x.ACTION_UP;
858
+ nn(T, n, i, o, c, d, s);
859
+ } else
860
+ e === "down" ? (qe(x.ACTION_DOWN, u, n, i, o, c), qe(x.ACTION_POINTER_DOWN, m, n, i, d, s)) : e === "move" ? (qe(x.ACTION_MOVE, u, n, i, o, c), qe(x.ACTION_MOVE, m, n, i, d, s)) : (qe(x.ACTION_POINTER_UP, m, n, i, d, s), qe(x.ACTION_UP, u, n, i, o, c));
861
+ }, rn = (e, n, i) => {
862
+ if (!_e.current) {
863
+ Se !== null && pt(null);
864
+ return;
865
+ }
866
+ const o = on(e, n, i);
867
+ pt(o);
868
+ }, cn = (e, n, i) => {
869
+ const o = xe.current;
870
+ if (!o || o.screen.width <= 0 || o.screen.height <= 0) return null;
871
+ const c = n - e.videoRect.left - e.offsetX, d = i - e.videoRect.top - e.offsetY;
872
+ if (c < 0 || d < 0 || c > e.actualWidth || d > e.actualHeight) return null;
873
+ const s = c / e.actualWidth * o.screen.width, u = d / e.actualHeight * o.screen.height;
874
+ return En(o, s, u);
875
+ }, sn = (e) => ({
876
+ map: (n, i) => {
877
+ const o = Me(e, n, i);
878
+ if (o)
879
+ return {
880
+ x: o.videoX,
881
+ y: o.videoY,
882
+ width: o.videoWidth,
883
+ height: o.videoHeight
884
+ };
885
+ },
886
+ // A finger on the frame, or a letterbox bar, is not on the guest's screen.
887
+ contains: (n, i) => {
888
+ const o = n - e.videoRect.left - e.offsetX, c = i - e.videoRect.top - e.offsetY;
889
+ return o >= 0 && o <= e.actualWidth && c >= 0 && c <= e.actualHeight;
890
+ },
891
+ scale: e.actualWidth > 0 ? e.videoWidth / e.actualWidth : 1
892
+ }), Oe = (e) => {
893
+ if (F || mt.current) return;
894
+ e.preventDefault(), e.stopPropagation();
895
+ const n = Ze();
896
+ if ((R === !0 || R === "hover-only") && !("touches" in e))
897
+ if (e.type === "mousemove") {
898
+ if (lo({ x: e.clientX, y: e.clientY }), n) {
899
+ const o = cn(n, e.clientX, e.clientY);
900
+ ct(o?.id ?? null);
901
+ }
902
+ } else e.type === "mouseleave" && (lo(null), ct(null));
903
+ if (R !== !0) {
904
+ if (K === "macos") {
905
+ if (!n || !k.current?.getState().controlReady) return;
906
+ if ("touches" in e) {
907
+ const s = Array.from(e.touches, (u) => ({ x: u.clientX, y: u.clientY }));
908
+ We.touch(e.type, s, sn(n)) && C.current?.focus();
909
+ return;
910
+ }
911
+ const o = Me(n, e.clientX, e.clientY);
912
+ if (!o) return;
913
+ const c = e.type === "mousedown" ? Q.DOWN : e.type === "mouseup" ? Q.UP : Q.MOVE, d = e.type === "mouseleave" ? 0 : e.buttons;
914
+ e.type === "mousedown" && C.current?.focus(), We.pointer(
915
+ c,
916
+ {
917
+ x: o.videoX,
918
+ y: o.videoY,
919
+ width: o.videoWidth,
920
+ height: o.videoHeight
921
+ },
922
+ d
923
+ );
924
+ return;
925
+ }
926
+ if (!("touches" in e) && n && (e.type === "mousemove" ? rn(n, e.clientX, e.clientY) : e.type === "mouseleave" && pt(null)), !(!k.current?.getState().controlReady || !C.current || !n))
927
+ if ("touches" in e) {
928
+ const o = e.touches, c = e.changedTouches;
929
+ let d;
930
+ switch (e.type) {
931
+ case "touchstart":
932
+ d = "down";
933
+ break;
934
+ case "touchmove":
935
+ d = "move";
936
+ break;
937
+ case "touchend":
938
+ d = "up";
939
+ break;
940
+ case "touchcancel":
941
+ d = "cancel";
942
+ break;
943
+ default:
944
+ return;
945
+ }
946
+ if (o.length === 2) {
947
+ const s = o[0], u = o[1], m = Me(n, s.clientX, s.clientY), T = Me(n, u.clientX, u.clientY);
948
+ if (!m || !T) return;
949
+ X.current ? X.current.source === "real-touch" && (X.current.finger0 = { x: m.videoX, y: m.videoY }, X.current.finger1 = { x: T.videoX, y: T.videoY }, Je(
950
+ "move",
951
+ m.videoWidth,
952
+ m.videoHeight,
953
+ m.videoX,
954
+ m.videoY,
955
+ T.videoX,
956
+ T.videoY,
957
+ X.current.pointerId0,
958
+ X.current.pointerId1
959
+ )) : (X.current = {
960
+ finger0: { x: m.videoX, y: m.videoY },
961
+ finger1: { x: T.videoX, y: T.videoY },
962
+ videoSize: { width: m.videoWidth, height: m.videoHeight },
963
+ source: "real-touch",
964
+ pointerId0: s.identifier,
965
+ pointerId1: u.identifier
966
+ }, Je(
967
+ "down",
968
+ m.videoWidth,
969
+ m.videoHeight,
970
+ m.videoX,
971
+ m.videoY,
972
+ T.videoX,
973
+ T.videoY,
974
+ s.identifier,
975
+ u.identifier
976
+ ));
977
+ } else if (o.length < 2 && X.current?.source === "real-touch") {
978
+ const s = X.current;
979
+ Je(
980
+ "up",
981
+ s.videoSize.width,
982
+ s.videoSize.height,
983
+ s.finger0.x,
984
+ s.finger0.y,
985
+ s.finger1.x,
986
+ s.finger1.y,
987
+ s.pointerId0,
988
+ s.pointerId1
989
+ ), X.current = null;
990
+ return;
991
+ } else {
992
+ if (o.length > 2)
993
+ return;
994
+ {
995
+ const s = c[0];
996
+ if (s) {
997
+ const u = Me(n, s.clientX, s.clientY);
998
+ Le(s.identifier, d, u);
999
+ }
1000
+ }
1001
+ }
1002
+ } else {
1003
+ let c = null;
1004
+ const d = X.current?.source === "alt-mouse";
1005
+ switch (e.type) {
1006
+ case "mousedown":
1007
+ e.button === 0 && (c = "down");
1008
+ break;
1009
+ case "mousemove":
1010
+ (d || V.current.has(-1)) && (c = "move");
1011
+ break;
1012
+ case "mouseup":
1013
+ e.button === 0 && (c = "up");
1014
+ break;
1015
+ case "mouseleave":
1016
+ (d || V.current.has(-1)) && (c = "up");
1017
+ break;
1018
+ }
1019
+ if (c) {
1020
+ const s = Me(n, e.clientX, e.clientY);
1021
+ if (!s)
1022
+ return;
1023
+ G("[rc-touch][mouse] event", {
1024
+ domType: e.type,
1025
+ eventType: c,
1026
+ button: e.button,
1027
+ buttons: e.buttons,
1028
+ client: { x: e.clientX, y: e.clientY },
1029
+ altHeldRef: _e.current,
1030
+ inTwoFingerMode: d,
1031
+ geometry: {
1032
+ videoX: s.videoX,
1033
+ videoY: s.videoY,
1034
+ videoWidth: s.videoWidth,
1035
+ videoHeight: s.videoHeight
1036
+ },
1037
+ activePointerIds: Array.from(V.current.keys())
1038
+ }), _e.current || d ? an(c, s) : Le(-1, c, s);
1039
+ }
1040
+ }
1041
+ }
1042
+ }, an = (e, n) => {
1043
+ const { videoX: i, videoY: o, videoWidth: c, videoHeight: d } = n, s = c - i, u = d - o;
1044
+ if (e === "down") {
1045
+ X.current = {
1046
+ finger0: { x: i, y: o },
1047
+ finger1: { x: s, y: u },
1048
+ videoSize: { width: c, height: d },
1049
+ source: "alt-mouse",
1050
+ pointerId0: wt,
1051
+ pointerId1: Mt
1052
+ }, C.current?.focus(), Je(
1053
+ "down",
1054
+ c,
1055
+ d,
1056
+ i,
1057
+ o,
1058
+ s,
1059
+ u,
1060
+ wt,
1061
+ Mt
1062
+ );
1063
+ return;
1064
+ }
1065
+ if (e === "move") {
1066
+ X.current?.source === "alt-mouse" && (X.current.finger0 = { x: i, y: o }, X.current.finger1 = { x: s, y: u }, Je(
1067
+ "move",
1068
+ c,
1069
+ d,
1070
+ i,
1071
+ o,
1072
+ s,
1073
+ u,
1074
+ wt,
1075
+ Mt
1076
+ ));
1077
+ return;
1078
+ }
1079
+ if (e === "up" || e === "cancel") {
1080
+ const m = X.current;
1081
+ if (m?.source === "alt-mouse") {
1082
+ const { finger0: T, finger1: I, videoSize: g } = m;
1083
+ Je(
1084
+ "up",
1085
+ g.width,
1086
+ g.height,
1087
+ T.x,
1088
+ T.y,
1089
+ I.x,
1090
+ I.y,
1091
+ wt,
1092
+ Mt
1093
+ ), X.current = null;
1094
+ }
1095
+ return;
1096
+ }
1097
+ }, ln = 150, wo = () => {
1098
+ const e = ze.current;
1099
+ e && (window.clearTimeout(e.endTimer), Le(De, "up", e.pos), ze.current = null);
1100
+ }, dn = (e) => {
1101
+ if (!k.current?.getState().controlReady || e.ctrlKey) return;
1102
+ if (K === "macos") {
1103
+ if (mt.current) return;
1104
+ const O = Ze();
1105
+ if (!O) return;
1106
+ const Ye = e.clientX - O.videoRect.left - O.offsetX, Ae = e.clientY - O.videoRect.top - O.offsetY;
1107
+ if (Ye < 0 || Ye > O.actualWidth || Ae < 0 || Ae > O.actualHeight)
1108
+ return;
1109
+ const ge = Me(O, e.clientX, e.clientY);
1110
+ if (!ge) return;
1111
+ e.preventDefault();
1112
+ const et = e.deltaMode === WheelEvent.DOM_DELTA_LINE ? 16 : e.deltaMode === WheelEvent.DOM_DELTA_PAGE ? O.actualHeight : 1;
1113
+ We.scroll(
1114
+ { x: ge.videoX, y: ge.videoY, width: ge.videoWidth, height: ge.videoHeight },
1115
+ e.deltaX * et,
1116
+ e.deltaY * et
1117
+ );
1118
+ return;
1119
+ }
1120
+ if (_e.current || X.current) return;
1121
+ const n = V.current.size;
1122
+ if (n > 1 || n === 1 && !V.current.has(De)) return;
1123
+ const i = Ze();
1124
+ if (!i) return;
1125
+ const o = e.clientX - i.videoRect.left - i.offsetX, c = e.clientY - i.videoRect.top - i.offsetY;
1126
+ if (o < 0 || o > i.actualWidth || c < 0 || c > i.actualHeight)
1127
+ return;
1128
+ const d = Me(i, e.clientX, e.clientY);
1129
+ if (!d) return;
1130
+ e.preventDefault();
1131
+ const s = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? i.actualWidth : 1) * (i.videoWidth / i.actualWidth), u = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? i.actualHeight : 1) * (i.videoHeight / i.actualHeight), m = -e.deltaX * s, T = -e.deltaY * u, I = (O) => {
1132
+ window.clearTimeout(O.endTimer), O.endTimer = window.setTimeout(wo, ln);
1133
+ };
1134
+ if (m === 0 && T === 0) {
1135
+ ze.current && I(ze.current);
1136
+ return;
1137
+ }
1138
+ const g = () => ({
1139
+ videoWidth: d.videoWidth,
1140
+ videoHeight: d.videoHeight,
1141
+ videoX: Math.abs(m) > Math.abs(T) ? Math.min(Math.max(d.videoX, d.videoWidth * 0.2), d.videoWidth * 0.8) : d.videoX,
1142
+ videoY: Math.abs(T) >= Math.abs(m) ? Math.min(Math.max(d.videoY, d.videoHeight * 0.2), d.videoHeight * 0.8) : d.videoY
1143
+ }), re = (O) => ({
1144
+ ...O,
1145
+ videoX: Math.min(Math.max(O.videoX + m, 0), O.videoWidth),
1146
+ videoY: Math.min(Math.max(O.videoY + T, 0), O.videoHeight)
1147
+ });
1148
+ let $ = ze.current;
1149
+ if ($)
1150
+ window.clearTimeout($.endTimer);
1151
+ else {
1152
+ const O = g();
1153
+ Le(De, "down", O), $ = { pos: O, endTimer: 0 }, ze.current = $;
1154
+ }
1155
+ let J = $.pos, he = re(J);
1156
+ he.videoX === J.videoX && he.videoY === J.videoY && (Le(De, "up", J), J = g(), Le(De, "down", J), he = re(J)), Le(De, "move", he), $.pos = he, I($);
1157
+ };
1158
+ j(() => {
1159
+ rt.current = { handle: dn, end: wo };
1160
+ }), j(() => {
1161
+ const e = oe.current;
1162
+ if (!e) return;
1163
+ const n = (i) => rt.current.handle(i);
1164
+ return e.addEventListener("wheel", n, { passive: !1 }), () => {
1165
+ rt.current.end(), e.removeEventListener("wheel", n);
1166
+ };
1167
+ }, []), j(() => {
1168
+ const e = (c) => {
1169
+ c.key === "Alt" && Lt(!0);
1170
+ }, n = (c) => {
1171
+ c.key === "Alt" && Lt(!1);
1172
+ }, i = () => {
1173
+ Lt(!1), lt();
1174
+ }, o = () => {
1175
+ document.hidden && lt();
1176
+ };
1177
+ return window.addEventListener("keydown", e, !0), window.addEventListener("keyup", n, !0), window.addEventListener("blur", i), document.addEventListener("visibilitychange", o), () => {
1178
+ window.removeEventListener("keydown", e, !0), window.removeEventListener("keyup", n, !0), window.removeEventListener("blur", i), document.removeEventListener("visibilitychange", o);
1179
+ };
1180
+ }, [lt]);
1181
+ const Qe = (e) => {
1182
+ e.preventDefault(), e.stopPropagation();
1183
+ const n = document.activeElement === C.current || (F || mt.current) && document.activeElement === e.currentTarget;
1184
+ if (G("Keyboard event:", {
1185
+ type: e.type,
1186
+ key: e.key,
1187
+ keyCode: e.keyCode,
1188
+ code: e.code,
1189
+ target: e.target.tagName,
1190
+ focused: n
1191
+ }), !n) {
1192
+ Ft("Simulator input not focused, skipping keyboard event");
1193
+ return;
1194
+ }
1195
+ if (!k.current?.getState().controlReady) {
1196
+ Ft("Data channel not ready for keyboard event:", k.current?.getState().connection);
1197
+ return;
1198
+ }
1199
+ if (K === "macos") {
1200
+ if (e.type === "keydown" && e.repeat) return;
1201
+ const o = Rn(e.code);
1202
+ if (o === void 0) {
1203
+ G(`Ignoring unmapped key for macOS: code=${e.code}`);
1204
+ return;
1205
+ }
1206
+ e.type === "keydown" ? vt.current.add(o) : vt.current.delete(o), fe(
1207
+ ko(
1208
+ e.type === "keydown" ? Q.DOWN : Q.UP,
1209
+ o
1210
+ )
1211
+ );
1212
+ return;
1213
+ }
1214
+ if (e.type === "keydown") {
1215
+ if (e.key.toLowerCase() === "v" && (e.metaKey || e.ctrlKey)) {
1216
+ G("Paste shortcut detected"), navigator.clipboard.readText().then((o) => {
1217
+ if (o) {
1218
+ G(
1219
+ "Pasting text via SET_CLIPBOARD:",
1220
+ o.substring(0, 20) + (o.length > 20 ? "..." : "")
1221
+ );
1222
+ const c = On(o, !0);
1223
+ fe(c);
1224
+ }
1225
+ }).catch((o) => {
1226
+ console.error("Failed to read clipboard contents: ", o);
1227
+ });
1228
+ return;
1229
+ }
1230
+ if (e.key.toLowerCase() === "m" && (e.metaKey || e.ctrlKey)) {
1231
+ G("Menu shortcut detected");
1232
+ const o = Tt(
1233
+ B.ACTION_DOWN,
1234
+ B.MENU,
1235
+ 0,
1236
+ B.META_NONE
1237
+ // Modifiers are handled by the shortcut check, not passed down
1238
+ );
1239
+ fe(o);
1240
+ const c = Tt(
1241
+ B.ACTION_UP,
1242
+ B.MENU,
1243
+ 0,
1244
+ B.META_NONE
1245
+ );
1246
+ fe(c);
1247
+ return;
1248
+ }
1249
+ }
1250
+ const i = ii(e);
1251
+ if (i) {
1252
+ const { keycode: o, metaState: c } = i, d = e.type === "keydown" ? B.ACTION_DOWN : B.ACTION_UP;
1253
+ G(`Sending Keycode: key=${e.key}, code=${o}, action=${d}, meta=${c}`);
1254
+ const s = Tt(
1255
+ d,
1256
+ o,
1257
+ 0,
1258
+ // repeat count, typically 0 for single presses
1259
+ c
1260
+ );
1261
+ fe(s);
1262
+ } else
1263
+ G(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
1264
+ }, un = (e) => {
1265
+ e.stopPropagation(), k.current?.reconnect();
1266
+ }, ie = P({
1267
+ onAxSnapshotChange: le,
1268
+ onAxStatusChange: S,
1269
+ onCameraDemandChange: D,
1270
+ onCameraStats: H,
1271
+ onMicrophoneStateChange: de,
1272
+ onTrace: Y,
1273
+ onTerminated: ae,
1274
+ onConnectionStateChange: me,
1275
+ onPlaybackStats: U
1276
+ });
1277
+ ie.current = {
1278
+ onAxSnapshotChange: le,
1279
+ onAxStatusChange: S,
1280
+ onCameraDemandChange: D,
1281
+ onCameraStats: H,
1282
+ onMicrophoneStateChange: de,
1283
+ onTrace: Y,
1284
+ onTerminated: ae,
1285
+ onConnectionStateChange: me,
1286
+ onPlaybackStats: U
1287
+ };
1288
+ const Yt = !!Y;
1289
+ j(() => {
1290
+ St.current = null, qt(!1), Jt(!1), Qt({}), to(null);
1291
+ }, [t, Ie]), j(() => {
1292
+ let e = !0;
1293
+ xe.current !== null && (xe.current = null, xt(null), nt("onAxSnapshotChange", ie.current.onAxSnapshotChange, null));
1294
+ const n = Cn({
1295
+ url: t,
1296
+ token: r,
1297
+ sessionId: Qo,
1298
+ watchOnly: Z,
1299
+ deviceModel: Ie,
1300
+ autoReconnect: E,
1301
+ jitterBufferTargetMs: L,
1302
+ openUrl: p,
1303
+ inspectMode: R,
1304
+ axPollIntervalMs: h,
1305
+ axMaxBackoffMs: y,
1306
+ androidElementTreeOptions: M,
1307
+ microphoneEnabled: q,
1308
+ onStateChange: (o) => {
1309
+ (o.videoReady || o.connection === "idle" || o.connection === "connecting" || o.connection === "reconnecting") && Lo(o.videoReady), Xo(o.connection === "failed"), Bo(o.connection === "terminated"), ne(o.duo), Ho(o.duoState), Wo(o.duoError);
1310
+ },
1311
+ onAxSnapshotChange: (o) => {
1312
+ e && (xt((c) => Tn(c, o) ? c : o), ie.current.onAxSnapshotChange?.(o));
1313
+ },
1314
+ onAxStatusChange: (...o) => ie.current.onAxStatusChange?.(...o),
1315
+ onCameraDemandChange: (...o) => ie.current.onCameraDemandChange?.(...o),
1316
+ onCameraStats: H ? (...o) => ie.current.onCameraStats?.(...o) : void 0,
1317
+ onMicrophoneStateChange: (...o) => ie.current.onMicrophoneStateChange?.(...o),
1318
+ onTrace: Yt ? (...o) => ie.current.onTrace?.(...o) : void 0,
1319
+ onTerminated: () => ie.current.onTerminated?.(),
1320
+ onConnectionStateChange: (...o) => ie.current.onConnectionStateChange?.(...o),
1321
+ onPlaybackStats: U ? (...o) => ie.current.onPlaybackStats?.(...o) : void 0
1322
+ });
1323
+ k.current = n;
1324
+ const i = C.current ? n.attachVideo(C.current) : void 0;
1325
+ return n.start(), () => {
1326
+ e = !1, n.dispose(), i?.(), k.current = null;
1327
+ };
1328
+ }, [t, l, Ie, Yt, Z]), j(() => {
1329
+ if (F && Ve.current)
1330
+ return k.current?.attachVideo(Ve.current, "inner");
1331
+ }, [F, t, l, Ie, Yt, Z]), j(() => {
1332
+ k.current?.updateOptions({
1333
+ token: r,
1334
+ openUrl: p,
1335
+ axPollIntervalMs: h,
1336
+ axMaxBackoffMs: y,
1337
+ androidElementTreeOptions: M,
1338
+ autoReconnect: E,
1339
+ jitterBufferTargetMs: L,
1340
+ microphoneEnabled: q,
1341
+ inspectMode: R,
1342
+ onPlaybackStats: U ? (...e) => ie.current.onPlaybackStats?.(...e) : void 0,
1343
+ onCameraStats: H ? (...e) => ie.current.onCameraStats?.(...e) : void 0
1344
+ });
1345
+ }, [
1346
+ r,
1347
+ E,
1348
+ L,
1349
+ q,
1350
+ R,
1351
+ !!U,
1352
+ !!H,
1353
+ p,
1354
+ h,
1355
+ y,
1356
+ M
1357
+ ]);
1358
+ const dt = () => {
1359
+ if (!uo.current) return;
1360
+ const e = Ze();
1361
+ if (!e) {
1362
+ so(null);
1363
+ return;
1364
+ }
1365
+ const n = {
1366
+ left: e.videoRect.left - e.containerRect.left + e.offsetX,
1367
+ top: e.videoRect.top - e.containerRect.top + e.offsetY,
1368
+ width: e.actualWidth,
1369
+ height: e.actualHeight
1370
+ };
1371
+ so(
1372
+ (i) => i && i.left === n.left && i.top === n.top && i.width === n.width && i.height === n.height ? i : n
1373
+ );
1374
+ };
1375
+ j(() => {
1376
+ const e = C.current, n = Re.current, i = oe.current;
1377
+ if (!e) return;
1378
+ const o = (I) => Qt((g) => ut(g, I) ? g : I), c = (I) => to((g) => g && I && ut(g, I) ? g : I), d = (I) => Fo((g) => g && I && ut(g, I) ? g : I), s = () => {
1379
+ const I = e.videoWidth > 0 && e.videoHeight > 0;
1380
+ I && (St.current = { width: e.videoWidth, height: e.videoHeight });
1381
+ const g = St.current, re = g ? `${g.width} / ${g.height}` : void 0, $ = Wt.current;
1382
+ if (be && i) {
1383
+ if (ro(g ? g.width / g.height : Ut), !$?.naturalWidth) return;
1384
+ const Xe = $.naturalWidth / $.naturalHeight, At = i.clientHeight - Et, $e = i.clientHeight > 0 ? Math.min(i.clientWidth, At * Xe) : i.clientWidth;
1385
+ if ($e <= 0) return;
1386
+ const Ee = $e / Xe, ke = i.clientHeight > 0 ? Et / 2 : 0, { screen: ce } = be, Be = ce.notch ?? 0, tt = ce.left * $e, Ue = ce.top * Ee, Ct = ce.width * $e, Ao = Ue + Be * ce.height * Ee, Co = (1 - Be) * ce.height * Ee, To = g ? g.width / g.height : Ut, ot = Math.min(Ct, Co * To), Xt = ot / To, Ro = tt + (Ct - ot) / 2, Oo = Be > 0 ? Ao : Ao + (Co - Xt) / 2, $t = (Ce, Ne, mn, pn) => `translate(calc(-50% + ${Ce + mn / 2 - $e / 2}px), calc(-50% + ${Ne + pn / 2 - Ee / 2 + ke}px))`;
1387
+ o({
1388
+ width: `${ot}px`,
1389
+ height: `${Xt}px`,
1390
+ transform: $t(Ro, Oo, ot, Xt)
1391
+ });
1392
+ const Bt = Oo - Ue;
1393
+ Ko((Ce) => {
1394
+ const Ne = Be > 0 && Bt > 0 ? {
1395
+ width: `${ot}px`,
1396
+ // A pixel under the stream's edge, so no seam shows between them.
1397
+ height: `${Bt + 1}px`,
1398
+ transform: $t(Ro, Ue, ot, Bt + 1)
1399
+ } : null;
1400
+ return Ce && Ne && ut(Ce, Ne) ? Ce : Ne;
1401
+ });
1402
+ const Eo = ce.height * Ee;
1403
+ Vo((Ce) => {
1404
+ const Ne = {
1405
+ width: `${Ct}px`,
1406
+ height: `${Eo}px`,
1407
+ transform: $t(tt, Ue, Ct, Eo)
1408
+ };
1409
+ return Ce && ut(Ce, Ne) ? Ce : Ne;
1410
+ }), d({
1411
+ width: `${$e}px`,
1412
+ height: `${Ee}px`,
1413
+ transform: ke ? `translateY(${ke}px)` : void 0
1414
+ }), c(null), dt();
1415
+ return;
1416
+ }
1417
+ if (pe && i) {
1418
+ const Xe = g ? g.width / g.height : Ut, At = i.clientWidth * 100 / ht, Ee = (i.clientHeight - Et) / (1 / Xe + Vt / 100), ke = i.clientHeight > 0 ? Math.min(At, Ee) : At;
1419
+ if (ke <= 0) return;
1420
+ const ce = ke / 100, Be = ke / Xe, tt = i.clientHeight > 0 ? Et / 2 : 0, Ue = `${ce * se.screenRadius}px`;
1421
+ o({
1422
+ aspectRatio: `${Xe}`,
1423
+ width: `${ke}px`,
1424
+ height: `${Be}px`,
1425
+ borderRadius: `${Ue} ${Ue} 0 0`,
1426
+ transform: `translate(-50%, calc(-50% - ${ce * Pn - tt}px))`
1427
+ }), d({
1428
+ width: `${ce * ht}px`,
1429
+ height: `${Be + ce * Vt}px`,
1430
+ transform: tt ? `translateY(${tt}px)` : void 0,
1431
+ "--rc-macbook-unit": `${ce}px`
1432
+ }), ro(Xe), c(null), dt();
1433
+ return;
1434
+ }
1435
+ if (d(null), !at || !n) {
1436
+ o(
1437
+ !I && g ? {
1438
+ aspectRatio: re,
1439
+ contain: "size",
1440
+ containIntrinsicSize: `${g.width}px ${g.height}px`
1441
+ } : {}
1442
+ ), c(null), dt();
1443
+ return;
1444
+ }
1445
+ const J = n.clientWidth, he = n.clientHeight;
1446
+ if (J === 0 || he === 0) return;
1447
+ const O = g ? g.width > g.height : !1;
1448
+ qt(O), Jt(
1449
+ K === "android" && !!g && ei(g.width, g.height)
1450
+ );
1451
+ const Ye = O ? He.videoPosition.landscape : He.videoPosition.portrait;
1452
+ let Ae = { aspectRatio: re };
1453
+ Ye.heightMultiplier ? (Ae.height = `${he * Ye.heightMultiplier}px`, Ae.width = "auto") : Ye.widthMultiplier && (Ae.width = `${J * Ye.widthMultiplier}px`, Ae.height = "auto"), Ae.borderRadius = `${O ? he * He.videoBorderRadiusMultiplier : J * He.videoBorderRadiusMultiplier}px`, o(Ae);
1454
+ const ge = He.homeButton, et = O ? J : he, Mo = `calc(50% + ${et * (ge?.offset ?? 0)}px)`;
1455
+ c(
1456
+ ge ? {
1457
+ width: `${et * ge.diameter}px`,
1458
+ height: `${et * ge.diameter}px`,
1459
+ left: O ? Mo : "50%",
1460
+ top: O ? "50%" : Mo
1461
+ } : null
1462
+ ), dt();
1463
+ }, u = new ResizeObserver(() => {
1464
+ s();
1465
+ });
1466
+ n && u.observe(n), u.observe(e), i && u.observe(i), n && n.addEventListener("load", s);
1467
+ const m = Wt.current;
1468
+ m?.addEventListener("load", s), e.addEventListener("loadedmetadata", s), e.addEventListener("resize", s);
1469
+ const T = () => k.current?.bumpActivity();
1470
+ return e.addEventListener("resize", T), s(), () => {
1471
+ u.disconnect(), e.removeEventListener("loadedmetadata", s), e.removeEventListener("resize", s), e.removeEventListener("resize", T), n && n.removeEventListener("load", s), m?.removeEventListener("load", s);
1472
+ };
1473
+ }, [He, at, pe, be?.src, we, t, A]), j(() => {
1474
+ Pe ? dt() : (xt(null), ct(null), gt(null), ao(null), Ge(null), yt.current = null, ve.current !== void 0 && (window.cancelAnimationFrame(ve.current), ve.current = void 0));
1475
+ }, [Pe]), j(() => () => {
1476
+ ve.current !== void 0 && (window.cancelAnimationFrame(ve.current), ve.current = void 0);
1477
+ }, []), j(() => {
1478
+ if (!Pe) return;
1479
+ const e = (n) => {
1480
+ n.key === "Escape" && (Ht || Pt) && (gt(null), ct(null), Ge(null), nt("onInspectSelectionChange", je.current, null));
1481
+ };
1482
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1483
+ }, [Pe, Ht, Pt]);
1484
+ const hn = () => {
1485
+ C.current && C.current.focus();
1486
+ };
1487
+ Sn(te, () => ({
1488
+ openUrl: (e) => k.current?.openUrl(e),
1489
+ sendKeyEvent: (e) => k.current?.sendKeyEvent(e),
1490
+ screenshot: (e) => k.current?.screenshot(e) ?? Promise.reject(new Error("Simulator disconnected")),
1491
+ terminateApp: (e) => k.current?.terminateApp(e) ?? Promise.reject(new Error("Simulator disconnected")),
1492
+ reconnect: () => k.current?.reconnect(),
1493
+ refreshAxTree: () => k.current?.refreshAxTree() ?? Promise.reject(new Error("Simulator disconnected")),
1494
+ getAxSnapshot: () => k.current?.getAxSnapshot() ?? null,
1495
+ setInspectHighlight: (e) => {
1496
+ ct(e?.id ?? null);
1497
+ },
1498
+ setInspectSelection: (e) => {
1499
+ gt(e?.id ?? null), Ge(e ? yt.current : null);
1500
+ const n = xe.current;
1501
+ e && n ? nt("onInspectSelectionChange", je.current, { element: e, snapshot: n }) : nt("onInspectSelectionChange", je.current, null);
1502
+ },
1503
+ getAxStatus: () => k.current?.getAxStatus() ?? "idle"
1504
+ }));
1505
+ const fn = zo && Se !== null;
1506
+ return /* @__PURE__ */ ee(
1507
+ "div",
1508
+ {
1509
+ ref: oe,
1510
+ className: ["rc-container", a].filter(Boolean).join(" "),
1511
+ style: { touchAction: "none" },
1512
+ onMouseDown: Oe,
1513
+ onMouseMove: Oe,
1514
+ onMouseUp: Oe,
1515
+ onMouseLeave: Oe,
1516
+ onTouchStart: Oe,
1517
+ onTouchMove: Oe,
1518
+ onTouchEnd: Oe,
1519
+ onTouchCancel: Oe,
1520
+ onContextMenu: K === "macos" ? (e) => e.preventDefault() : void 0,
1521
+ children: [
1522
+ fn && Se && /* @__PURE__ */ ee(So, { children: [
1523
+ /* @__PURE__ */ w(
1524
+ "div",
1525
+ {
1526
+ className: "rc-touch-indicator",
1527
+ style: {
1528
+ left: `${Se.containerX}px`,
1529
+ top: `${Se.containerY}px`
1530
+ }
1531
+ }
1532
+ ),
1533
+ /* @__PURE__ */ w(
1534
+ "div",
1535
+ {
1536
+ className: "rc-touch-indicator",
1537
+ style: {
1538
+ left: `${Se.mirrorContainerX}px`,
1539
+ top: `${Se.mirrorContainerY}px`
1540
+ }
1541
+ }
1542
+ )
1543
+ ] }),
1544
+ at && /* @__PURE__ */ w(
1545
+ "img",
1546
+ {
1547
+ ref: Re,
1548
+ src: fo,
1549
+ alt: "",
1550
+ className: K === "ios" ? "rc-phone-frame rc-phone-frame-ios" : "rc-phone-frame",
1551
+ draggable: !1
1552
+ }
1553
+ ),
1554
+ be && !we && no && /* @__PURE__ */ w("div", { className: "rc-macbook-screen", style: no, "aria-hidden": "true" }),
1555
+ be && !we && _t && /* @__PURE__ */ w("canvas", { ref: oo, className: "rc-macbook-band", style: _t, height: 1 }),
1556
+ be && !we && /* @__PURE__ */ w(
1557
+ "img",
1558
+ {
1559
+ ref: Wt,
1560
+ src: be.src,
1561
+ alt: "",
1562
+ className: "rc-macbook-image",
1563
+ style: It ?? { visibility: "hidden" },
1564
+ draggable: !1
1565
+ }
1566
+ ),
1567
+ pe && !be && It && !we && /* @__PURE__ */ ee("div", { className: "rc-macbook", style: It, "aria-hidden": "true", children: [
1568
+ /* @__PURE__ */ w("div", { className: "rc-macbook-lid", children: /* @__PURE__ */ w("div", { className: "rc-macbook-camera" }) }),
1569
+ /* @__PURE__ */ w("div", { className: "rc-macbook-base" })
1570
+ ] }),
1571
+ at && eo && !Z && /* @__PURE__ */ w(
1572
+ "button",
1573
+ {
1574
+ type: "button",
1575
+ className: "rc-home-button",
1576
+ "aria-label": "Home",
1577
+ title: "Home",
1578
+ style: eo,
1579
+ onMouseDown: (e) => e.stopPropagation(),
1580
+ onTouchStart: (e) => e.stopPropagation(),
1581
+ onTouchEnd: (e) => {
1582
+ e.stopPropagation(), e.preventDefault(), k.current?.pressButton("home");
1583
+ },
1584
+ onClick: (e) => {
1585
+ e.stopPropagation(), k.current?.pressButton("home");
1586
+ }
1587
+ }
1588
+ ),
1589
+ /* @__PURE__ */ w(
1590
+ "video",
1591
+ {
1592
+ ref: C,
1593
+ className: [
1594
+ "rc-video",
1595
+ !at && !pe && "rc-video-frameless",
1596
+ !Do && (K === "macos" ? "rc-video-loading-desktop" : "rc-video-loading")
1597
+ ].filter(Boolean).join(" "),
1598
+ style: {
1599
+ ...Uo,
1600
+ ...F || we ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
1601
+ ...mo ? {
1602
+ backgroundImage: `url("${mo}")`,
1603
+ backgroundRepeat: "no-repeat",
1604
+ backgroundPosition: "center",
1605
+ backgroundSize: He.loadingLogoSize
1606
+ } : {}
1607
+ },
1608
+ autoPlay: !0,
1609
+ playsInline: !0,
1610
+ muted: !0,
1611
+ tabIndex: F || we ? -1 : 0,
1612
+ onKeyDown: Qe,
1613
+ onKeyUp: Qe,
1614
+ onClick: hn,
1615
+ onFocus: () => {
1616
+ C.current && (C.current.style.outline = "none");
1617
+ },
1618
+ onBlur: () => {
1619
+ C.current && (C.current.style.outline = "none"), lt();
1620
+ }
1621
+ }
1622
+ ),
1623
+ en && io && /* @__PURE__ */ w(No, { fallback: null, children: /* @__PURE__ */ w(
1624
+ Qn,
1625
+ {
1626
+ video: C.current,
1627
+ aspect: io,
1628
+ model: _ ?? ue?.model,
1629
+ animateLid: b,
1630
+ watchOnly: Z,
1631
+ onReady: it.onReady,
1632
+ pointer: (e, n, i, o) => {
1633
+ const c = C.current;
1634
+ !c?.videoWidth || !k.current?.getState().controlReady || We.pointer(
1635
+ e === "down" ? Q.DOWN : e === "up" ? Q.UP : Q.MOVE,
1636
+ {
1637
+ x: n * c.videoWidth,
1638
+ y: i * c.videoHeight,
1639
+ width: c.videoWidth,
1640
+ height: c.videoHeight
1641
+ },
1642
+ o
1643
+ );
1644
+ },
1645
+ scroll: (e, n, i, o) => {
1646
+ const c = C.current;
1647
+ !c?.videoWidth || !k.current?.getState().controlReady || We.scroll(
1648
+ {
1649
+ x: e * c.videoWidth,
1650
+ y: n * c.videoHeight,
1651
+ width: c.videoWidth,
1652
+ height: c.videoHeight
1653
+ },
1654
+ i,
1655
+ o
1656
+ );
1657
+ },
1658
+ onKeyDown: Qe,
1659
+ onKeyUp: Qe,
1660
+ onBlur: lt
1661
+ }
1662
+ ) }),
1663
+ pe && /* @__PURE__ */ w(Bn, { view: it, label: "MacBook rendering" }),
1664
+ F && /* @__PURE__ */ w(
1665
+ "video",
1666
+ {
1667
+ ref: Ve,
1668
+ autoPlay: !0,
1669
+ playsInline: !0,
1670
+ muted: !0,
1671
+ style: { position: "absolute", width: 1, height: 1, opacity: 0, pointerEvents: "none" }
1672
+ }
1673
+ ),
1674
+ F && Gt && /* @__PURE__ */ w(No, { fallback: /* @__PURE__ */ w("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ w(
1675
+ Jn,
1676
+ {
1677
+ watchOnly: Z,
1678
+ showFrame: f,
1679
+ model: N ?? ue?.model,
1680
+ outer: C.current,
1681
+ inner: Ve.current,
1682
+ state: Gt,
1683
+ setAngle: (e) => Dt("setHingeAngle", { angleDegrees: e }),
1684
+ setOrientation: (e) => Dt("setDuoOrientation", { orientation: e }),
1685
+ button: (e, n) => Dt("performActions", {
1686
+ actions: [{ type: n ? "buttonDown" : "buttonUp", button: e }]
1687
+ }),
1688
+ touch: (e, n, i, o) => {
1689
+ k.current?.sendDisplayTouch(e, n, i, o);
1690
+ },
1691
+ onKeyDown: Qe,
1692
+ onKeyUp: Qe
1693
+ }
1694
+ ) }),
1695
+ F && jt && /* @__PURE__ */ w("div", { role: "alert", className: "rc-duo-error", children: jt }),
1696
+ !F && Pe && /* @__PURE__ */ w(
1697
+ qn,
1698
+ {
1699
+ snapshot: co,
1700
+ geometry: jo,
1701
+ highlightedId: Pt,
1702
+ selectedId: Ht,
1703
+ mode: Jo,
1704
+ cursorPosition: qo,
1705
+ frozenCursorPosition: Zo,
1706
+ onSelectChange: (e, n) => {
1707
+ gt(e?.id ?? null), e && n ? Ge(n) : e || Ge(null);
1708
+ const i = xe.current;
1709
+ e && i ? nt("onInspectSelectionChange", je.current, {
1710
+ element: e,
1711
+ snapshot: i
1712
+ }) : nt("onInspectSelectionChange", je.current, null);
1713
+ },
1714
+ onTapElement: Z ? void 0 : ((e, n) => {
1715
+ if (n) {
1716
+ bo(n.x, n.y);
1717
+ return;
1718
+ }
1719
+ const i = xe.current;
1720
+ i && tn(e, i);
1721
+ })
1722
+ }
1723
+ ),
1724
+ $o ? /* @__PURE__ */ ee("div", { className: "rc-terminated", role: "status", children: [
1725
+ /* @__PURE__ */ w("div", { className: "rc-terminated-title", children: "Instance terminated" }),
1726
+ /* @__PURE__ */ w("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
1727
+ ] }) : Yo && /* @__PURE__ */ w("button", { type: "button", className: "rc-retry-button", onClick: un, children: "Retry" })
1728
+ ]
1729
+ }
1730
+ );
1731
+ }
1732
+ );
1733
+ export {
1734
+ Bn as D,
1735
+ ui as M,
1736
+ vi as R,
1737
+ li as a,
1738
+ di as b,
1739
+ hi as c,
1740
+ mi as d,
1741
+ gi as e,
1742
+ fi as l,
1743
+ pi as m,
1744
+ yi as s,
1745
+ $n as u
1746
+ };