@limrun/ui 0.20.4 → 0.20.6

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.
@@ -0,0 +1,1175 @@
1
+ import { jsx as m, jsxs as z, Fragment as yt } from "react/jsx-runtime";
2
+ import { f as qt, c as wt, d as Gt, b as Jt, h as Qt, i as Zt, s as Te, j as en, e as tn, k as D, l as je, m as nn, o as De, p as M, q as We, a as on, r as rn, t as g, u as cn } from "./core-BpV73M0K.mjs";
3
+ import { memo as qe, useState as O, useEffect as F, useMemo as fe, useCallback as sn, lazy as an, forwardRef as ln, useRef as S, useImperativeHandle as dn, Suspense as un } from "react";
4
+ import { createPortal as hn } from "react-dom";
5
+ import './index.css';const fn = async (d) => {
6
+ if (!d) return !1;
7
+ try {
8
+ if (typeof navigator < "u" && navigator.clipboard?.writeText)
9
+ return await navigator.clipboard.writeText(d), !0;
10
+ } catch {
11
+ }
12
+ try {
13
+ const r = document.createElement("textarea");
14
+ r.value = d, r.style.position = "fixed", r.style.opacity = "0", document.body.appendChild(r), r.select();
15
+ const u = document.execCommand("copy");
16
+ return document.body.removeChild(r), u;
17
+ } catch {
18
+ return !1;
19
+ }
20
+ }, pn = qe(
21
+ function({ element: r, screen: u, highlighted: h, selected: C, selectable: V, onClick: R }) {
22
+ const p = qt(r.frame, u);
23
+ if (!p) return null;
24
+ const U = wt(r);
25
+ return /* @__PURE__ */ m(
26
+ "button",
27
+ {
28
+ type: "button",
29
+ className: r.enabled ? "rc-inspect-box" : "rc-inspect-box rc-inspect-box-disabled",
30
+ "data-ax-id": r.id,
31
+ "data-ax-path": r.path,
32
+ "data-ax-label": r.label || void 0,
33
+ "data-ax-role": r.role || void 0,
34
+ "data-highlighted": h ? "true" : "false",
35
+ "data-selected": C ? "true" : "false",
36
+ "aria-label": U,
37
+ onClick: (v) => {
38
+ V && (v.preventDefault(), v.stopPropagation(), R(r, { x: v.clientX, y: v.clientY }));
39
+ },
40
+ style: {
41
+ left: `${p.x / u.width * 100}%`,
42
+ top: `${p.y / u.height * 100}%`,
43
+ width: `${p.width / u.width * 100}%`,
44
+ height: `${p.height / u.height * 100}%`
45
+ }
46
+ }
47
+ );
48
+ },
49
+ (d, r) => d.highlighted === r.highlighted && d.selected === r.selected && d.selectable === r.selectable && d.screen.width === r.screen.width && d.screen.height === r.screen.height && d.onClick === r.onClick && Gt(d.element, r.element)
50
+ ), mn = 260, gn = 220, vn = 6, yn = 8, wn = qe(function({
51
+ element: r,
52
+ platform: u,
53
+ anchor: h,
54
+ cursorAnchored: C,
55
+ showActions: V,
56
+ onTap: R
57
+ }) {
58
+ const [p, U] = O(null);
59
+ F(() => {
60
+ if (!p) return;
61
+ const b = window.setTimeout(() => U(null), 1100);
62
+ return () => window.clearTimeout(b);
63
+ }, [p]);
64
+ const v = fe(() => {
65
+ const b = mn, B = gn, W = vn, y = yn, J = typeof window < "u" ? window.innerWidth : 1024, Ie = typeof window < "u" ? window.innerHeight : 768, j = h.x + W + b <= J - y, te = h.y - W - B >= y;
66
+ let re = j ? h.x + W : h.x - W, pe = te ? h.y - W : h.y + W;
67
+ const ie = `translate(${j ? "0" : "-100%"}, ${te ? "-100%" : "0"})`;
68
+ return re = Math.max(y + (j ? 0 : b), Math.min(J - y - (j ? b : 0), re)), pe = Math.max(y + (te ? B : 0), Math.min(Ie - y - (te ? 0 : B), pe)), { left: `${re}px`, top: `${pe}px`, transform: ie };
69
+ }, [h.x, h.y]), _ = fe(() => Jt(r, u), [r, u]), N = u === "ios" ? r.selectors.AXUniqueId : r.selectors.resourceId, L = u === "ios" ? "AXUniqueId" : "resourceId", G = sn(async (b, B) => {
70
+ if (!b) return;
71
+ await fn(b) && U(B);
72
+ }, []), ee = Qt(r), $ = r.label || r.value || ee, oe = wt(r);
73
+ return hn(
74
+ /* @__PURE__ */ z(
75
+ "div",
76
+ {
77
+ className: "rc-inspect-card",
78
+ "data-cursor-anchored": C ? "true" : "false",
79
+ style: v,
80
+ onClick: (b) => b.stopPropagation(),
81
+ onMouseDown: (b) => b.stopPropagation(),
82
+ onMouseMove: (b) => b.stopPropagation(),
83
+ children: [
84
+ /* @__PURE__ */ z("div", { className: "rc-inspect-card-header", children: [
85
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-role", children: ee }),
86
+ !r.enabled && /* @__PURE__ */ m("span", { className: "rc-inspect-card-tag", children: "disabled" }),
87
+ r.focused && /* @__PURE__ */ m("span", { className: "rc-inspect-card-tag rc-inspect-card-tag-blue", children: "focused" })
88
+ ] }),
89
+ /* @__PURE__ */ m("p", { className: "rc-inspect-card-title", title: oe, children: $ }),
90
+ N && /* @__PURE__ */ z("div", { className: "rc-inspect-card-row", children: [
91
+ /* @__PURE__ */ z("span", { className: "rc-inspect-card-row-label", children: [
92
+ L,
93
+ ":"
94
+ ] }),
95
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-row-value", children: N })
96
+ ] }),
97
+ r.value && r.value !== r.label && /* @__PURE__ */ z("div", { className: "rc-inspect-card-row", children: [
98
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-row-label", children: "value:" }),
99
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-row-value", children: r.value })
100
+ ] }),
101
+ /* @__PURE__ */ z("div", { className: "rc-inspect-card-row", children: [
102
+ /* @__PURE__ */ m("span", { className: "rc-inspect-card-row-label", children: "frame:" }),
103
+ /* @__PURE__ */ z("span", { className: "rc-inspect-card-row-value", children: [
104
+ Math.round(r.frame.width),
105
+ "×",
106
+ Math.round(r.frame.height),
107
+ " @ ",
108
+ Math.round(r.frame.x),
109
+ ",",
110
+ Math.round(r.frame.y)
111
+ ] })
112
+ ] }),
113
+ V && /* @__PURE__ */ z("div", { className: "rc-inspect-card-actions", children: [
114
+ /* @__PURE__ */ m(
115
+ "button",
116
+ {
117
+ type: "button",
118
+ className: "rc-inspect-card-btn rc-inspect-card-btn-primary",
119
+ disabled: !R,
120
+ onClick: () => R?.(r, h),
121
+ children: "Tap"
122
+ }
123
+ ),
124
+ /* @__PURE__ */ m(
125
+ "button",
126
+ {
127
+ type: "button",
128
+ className: p === "selector" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
129
+ disabled: !_,
130
+ title: _ ?? "No usable selector for this element",
131
+ onClick: () => G(_ ?? void 0, "selector"),
132
+ children: p === "selector" ? "Copied!" : "Copy selector"
133
+ }
134
+ ),
135
+ /* @__PURE__ */ m(
136
+ "button",
137
+ {
138
+ type: "button",
139
+ className: p === "id" ? "rc-inspect-card-btn rc-inspect-card-btn-copied" : "rc-inspect-card-btn",
140
+ disabled: !N,
141
+ title: N ?? `No ${L}`,
142
+ onClick: () => G(N, "id"),
143
+ children: p === "id" ? "Copied!" : `Copy ${L}`
144
+ }
145
+ )
146
+ ] })
147
+ ]
148
+ }
149
+ ),
150
+ document.body
151
+ );
152
+ }), An = qe(function({
153
+ snapshot: r,
154
+ geometry: u,
155
+ highlightedId: h,
156
+ selectedId: C,
157
+ mode: V,
158
+ cursorPosition: R,
159
+ frozenCursorPosition: p,
160
+ onSelectChange: U,
161
+ onTapElement: v
162
+ }) {
163
+ const _ = V === "select", N = _ ? h !== null && h !== C : h !== null, L = _ ? h ?? C : h, G = fe(() => {
164
+ const y = /* @__PURE__ */ new Map();
165
+ if (!r) return y;
166
+ for (const J of r.elements) y.set(J.id, J);
167
+ return y;
168
+ }, [r]), ee = fe(() => L ? G.get(L) ?? null : null, [L, G]);
169
+ if (!(!!r && !!u && r.screen.width > 0 && r.screen.height > 0 && r.elements.length > 0)) return null;
170
+ const oe = N ? R : p ?? R, b = N, B = _ && !N && C !== null, W = (y) => {
171
+ _ && y.target === y.currentTarget && U(null, null);
172
+ };
173
+ return /* @__PURE__ */ z(yt, { children: [
174
+ /* @__PURE__ */ m(
175
+ "div",
176
+ {
177
+ className: _ ? "rc-inspect-overlay rc-inspect-overlay-select" : "rc-inspect-overlay",
178
+ style: {
179
+ left: `${u.left}px`,
180
+ top: `${u.top}px`,
181
+ width: `${u.width}px`,
182
+ height: `${u.height}px`
183
+ },
184
+ onClick: W,
185
+ children: r.elements.map((y) => /* @__PURE__ */ m(
186
+ pn,
187
+ {
188
+ element: y,
189
+ screen: r.screen,
190
+ highlighted: y.id === h,
191
+ selected: y.id === C,
192
+ selectable: _,
193
+ onClick: U
194
+ },
195
+ y.id
196
+ ))
197
+ }
198
+ ),
199
+ ee && oe && /* @__PURE__ */ m(
200
+ wn,
201
+ {
202
+ element: ee,
203
+ platform: r.platform,
204
+ anchor: oe,
205
+ cursorAnchored: b,
206
+ showActions: B,
207
+ onTap: v
208
+ }
209
+ )
210
+ ] });
211
+ });
212
+ function bn(d, r) {
213
+ if (!r.startsWith("lim_st_")) return !1;
214
+ try {
215
+ const u = new URL(d).pathname.split("/").map(decodeURIComponent).find((v) => /^(ios|android)_[a-z0-9_]+$/.test(v));
216
+ if (!u) return !1;
217
+ const h = u.split("_")[0], C = r.slice(7).split(".");
218
+ if (C.length !== 3 || C.some((v) => !v)) return !1;
219
+ const V = atob(C[1].replace(/-/g, "+").replace(/_/g, "/")), R = JSON.parse(
220
+ new TextDecoder().decode(Uint8Array.from(V, (v) => v.charCodeAt(0)))
221
+ );
222
+ if (!R || typeof R != "object" || !("scopes" in R)) return !1;
223
+ const p = R.scopes;
224
+ if (!Array.isArray(p) || !p.every((v) => typeof v == "string")) return !1;
225
+ let U = !1;
226
+ for (const v of p) {
227
+ const [_, N, L, G] = v.split(":");
228
+ if (!(G !== void 0 || _ !== h && _ !== "*") && !(N !== u && N !== "*")) {
229
+ if (L === "stream" || L === "all") return !1;
230
+ L === "watch" && (U = !0);
231
+ }
232
+ }
233
+ return U;
234
+ } catch {
235
+ return !1;
236
+ }
237
+ }
238
+ const Tn = an(() => import("./duo-view-DWqQXwdZ.mjs").then((d) => d.d)), He = (d) => Object.entries(g).find(
239
+ ([u, h]) => u.startsWith("ACTION_") && h === d
240
+ )?.[0] ?? String(d), gt = 1920, vt = 1200, Cn = (d, r) => d === gt && r === vt || d === vt && r === gt, Rn = {
241
+ ios: {
242
+ videoBorderRadiusMultiplier: 0.15,
243
+ loadingLogoSize: "20%",
244
+ // Video position as percentage of frame dimensions
245
+ videoPosition: {
246
+ portrait: { heightMultiplier: 0.9678 },
247
+ landscape: { widthMultiplier: 0.9678 }
248
+ }
249
+ },
250
+ android: {
251
+ videoBorderRadiusMultiplier: 0.13,
252
+ loadingLogoSize: "40%",
253
+ // Video position as percentage of frame dimensions
254
+ videoPosition: {
255
+ portrait: { heightMultiplier: 0.967 },
256
+ landscape: { widthMultiplier: 0.962 }
257
+ }
258
+ }
259
+ }, Nn = {
260
+ videoBorderRadiusMultiplier: 32 / 1837,
261
+ loadingLogoSize: "40%",
262
+ videoPosition: {
263
+ portrait: { heightMultiplier: 2560 / 2798 },
264
+ landscape: { widthMultiplier: 2560 / 2798 }
265
+ }
266
+ };
267
+ function En(d) {
268
+ const r = d.code, u = rn[r];
269
+ if (!u)
270
+ return je(`Unknown event.code: ${r}, key: ${d.key}`), null;
271
+ let h = M.META_NONE;
272
+ const C = r >= "KeyA" && r <= "KeyZ", V = d.getModifierState("CapsLock"), R = d.shiftKey;
273
+ let p = R;
274
+ return C && (p = R !== V), p && (h |= M.META_SHIFT_ON), d.ctrlKey && (h |= M.META_CTRL_ON), d.altKey && (h |= M.META_ALT_ON), d.metaKey && (h |= M.META_META_ON), { keycode: u, metaState: h };
275
+ }
276
+ function In(d, r) {
277
+ const u = Object.keys(d);
278
+ return u.length === Object.keys(r).length && u.every((h) => d[h] === r[h]);
279
+ }
280
+ const Pn = ln(
281
+ ({
282
+ className: d,
283
+ url: r,
284
+ token: u,
285
+ sessionId: h,
286
+ openUrl: C,
287
+ watchOnly: V = !1,
288
+ showFrame: R = !0,
289
+ deviceModel: p,
290
+ duoModelUrl: U,
291
+ autoReconnect: v,
292
+ jitterBufferTargetMs: _,
293
+ onPlaybackStats: N,
294
+ onTerminated: L,
295
+ assets: G,
296
+ onConnectionStateChange: ee,
297
+ inspectMode: $,
298
+ onAxSnapshotChange: oe,
299
+ onInspectSelectionChange: b,
300
+ onAxStatusChange: B,
301
+ axPollIntervalMs: W,
302
+ axMaxBackoffMs: y,
303
+ androidElementTreeOptions: J,
304
+ onCameraDemandChange: Ie,
305
+ onCameraStats: j,
306
+ onTrace: te,
307
+ microphoneEnabled: re = !1,
308
+ onMicrophoneStateChange: pe
309
+ }, Ge) => {
310
+ const Je = fe(() => bn(r, u), [r, u]), ie = V || Je, Oe = S(null), P = S(null), Qe = S(null), [At, bt] = O(!1), K = p === "iphone-duo" || At, Me = S(null), [Ze, Tt] = O(null), [et, Ct] = O(), [Rt, Nt] = O(!1), [Et, It] = O(!1), [Ot, Mt] = O(!1), [tt, nt] = O(!1), [ot, rt] = O(!1), [_t, it] = O({}), xe = S(null), k = S(/* @__PURE__ */ new Map()), ce = S(!1), [St, Pt] = O(!1), E = S(null), me = S(null), Ce = S({
311
+ handle: () => {
312
+ },
313
+ end: () => {
314
+ }
315
+ }), [se, _e] = O(null), [ct, Ue] = O(null), [$e, Re] = O(null), [Fe, Se] = O(null), [kt, st] = O(null), [Yt, at] = O(null), Pe = S(null), Q = S(void 0), lt = (e) => {
316
+ Pe.current = e, Q.current === void 0 && (Q.current = window.requestAnimationFrame(() => {
317
+ Q.current = void 0, at(Pe.current);
318
+ }));
319
+ }, [Lt, ge] = O(null), ae = S(null);
320
+ ae.current = ct;
321
+ const ve = S(b);
322
+ ve.current = b;
323
+ const le = $ === !0 || $ === "hover-only", dt = S(le);
324
+ dt.current = le;
325
+ const Xt = $ === "hover-only" ? "hover-only" : "select", Z = fe(() => Zt(r), [r]), Dt = fe(
326
+ () => h || Array.from(crypto.getRandomValues(new Uint32Array(4)), (e) => e.toString(36)).join(""),
327
+ [h]
328
+ ), ye = Z === "android" && ot ? Nn : Rn[Z], Ne = G?.[Z], ut = Z === "android" && ot ? tt ? Ne?.tabletFrameLandscape : Ne?.tabletFrame : tt ? Ne?.frameLandscape : Ne?.frame, ht = Ne?.loadingLogo, ke = !K && R && !!ut, w = S(null), q = (e) => w.current?.sendControl(e), ze = (e, t) => w.current?.sendDuoControl(e, t) ?? Promise.reject(new Error("Simulator disconnected")), ft = -10, pt = (e, t) => {
329
+ const o = Ee();
330
+ if (!o) return;
331
+ const n = Ae(o, e, t);
332
+ if (!n) return;
333
+ const { videoX: c, videoY: a, videoWidth: i, videoHeight: l } = n, s = We(
334
+ g.ACTION_DOWN,
335
+ ft,
336
+ i,
337
+ l,
338
+ c,
339
+ a,
340
+ 1,
341
+ g.BUTTON_PRIMARY,
342
+ g.BUTTON_PRIMARY
343
+ );
344
+ s && q(s), window.setTimeout(() => {
345
+ const f = We(
346
+ g.ACTION_UP,
347
+ ft,
348
+ i,
349
+ l,
350
+ c,
351
+ a,
352
+ 0,
353
+ g.BUTTON_PRIMARY,
354
+ g.BUTTON_PRIMARY
355
+ );
356
+ f && q(f);
357
+ }, 60);
358
+ }, Wt = (e, t) => {
359
+ const o = Ee();
360
+ if (!o || t.screen.width <= 0 || t.screen.height <= 0) return;
361
+ const n = e.frame.x + e.frame.width / 2, c = e.frame.y + e.frame.height / 2, a = n / t.screen.width * o.actualWidth, i = c / t.screen.height * o.actualHeight, l = o.videoRect.left + o.offsetX + a, s = o.videoRect.top + o.offsetY + i;
362
+ pt(l, s);
363
+ }, Ye = -1, Le = -2, de = -3, we = (e, t, o, n, c, a) => {
364
+ const i = We(
365
+ e,
366
+ t,
367
+ o,
368
+ n,
369
+ c,
370
+ a,
371
+ 1,
372
+ // pressure
373
+ g.BUTTON_PRIMARY,
374
+ g.BUTTON_PRIMARY
375
+ );
376
+ i && (D("[rc-touch] sendSingleTouch", {
377
+ action: e,
378
+ actionName: He(e),
379
+ pointerId: t,
380
+ x: c,
381
+ y: a,
382
+ video: { width: o, height: n }
383
+ }), q(i));
384
+ }, ue = (e, t, o) => {
385
+ if (!o) return;
386
+ const { videoX: n, videoY: c, videoWidth: a, videoHeight: i } = o;
387
+ let l = null, s = null, f = 1;
388
+ const I = g.BUTTON_PRIMARY;
389
+ switch (t) {
390
+ case "down":
391
+ e !== de && Ce.current.end(), l = k.current.size === 0 ? g.ACTION_DOWN : g.ACTION_POINTER_DOWN, s = { x: n, y: c }, k.current.set(e, s), e === -1 && P.current?.focus();
392
+ break;
393
+ case "move":
394
+ k.current.has(e) && (l = g.ACTION_MOVE, s = { x: n, y: c }, k.current.set(e, s));
395
+ break;
396
+ case "up":
397
+ case "cancel":
398
+ k.current.has(e) && (s = k.current.get(e), k.current.delete(e), t === "cancel" ? l = g.ACTION_CANCEL : l = k.current.size === 0 ? g.ACTION_UP : g.ACTION_POINTER_UP);
399
+ break;
400
+ }
401
+ if (l !== null && s !== null) {
402
+ D("[rc-touch][mouse->touch] sending", {
403
+ pointerId: e,
404
+ eventType: t,
405
+ action: l,
406
+ actionName: He(l),
407
+ positionToSend: s,
408
+ video: { width: a, height: i },
409
+ altHeld: ce.current,
410
+ activePointersAfter: Array.from(k.current.entries()).map(([X, T]) => ({
411
+ id: X,
412
+ x: T.x,
413
+ y: T.y
414
+ }))
415
+ });
416
+ const A = We(
417
+ l,
418
+ e,
419
+ a,
420
+ i,
421
+ s.x,
422
+ s.y,
423
+ f,
424
+ I,
425
+ I
426
+ );
427
+ A && (D("[rc-touch][mouse->touch] buffer", {
428
+ pointerId: e,
429
+ actionName: He(l),
430
+ byteLength: A.byteLength
431
+ }), q(A));
432
+ } else (t === "up" || t === "cancel") && k.current.delete(e);
433
+ }, Ve = (e) => {
434
+ if (ce.current !== e && (ce.current = e, Pt(e), e || _e(null), D("[rc-touch][alt] updateAltHeld", {
435
+ nextHeld: e,
436
+ activePointerIds: Array.from(k.current.keys())
437
+ }), Z === "ios" && w.current?.getState().controlReady)) {
438
+ const t = e ? M.ACTION_DOWN : M.ACTION_UP, o = De(
439
+ t,
440
+ M.KEYCODE_ALT_LEFT,
441
+ 0,
442
+ M.META_NONE
443
+ );
444
+ D("[rc-touch][alt] sending Indigo modifier keycode", {
445
+ action: t,
446
+ keycode: M.KEYCODE_ALT_LEFT
447
+ }), o && q(o);
448
+ }
449
+ }, Ee = () => {
450
+ const e = P.current, t = Oe.current;
451
+ if (!e || !t) return null;
452
+ const o = e.videoWidth, n = e.videoHeight;
453
+ if (!o || !n) return null;
454
+ const c = e.getBoundingClientRect(), a = t.getBoundingClientRect(), i = c.width, l = c.height, s = o / n, f = i / l;
455
+ let I = i, A = l;
456
+ s > f ? A = i / s : I = l * s;
457
+ const X = (i - I) / 2, T = (l - A) / 2;
458
+ return {
459
+ videoWidth: o,
460
+ videoHeight: n,
461
+ videoRect: c,
462
+ containerRect: a,
463
+ actualWidth: I,
464
+ actualHeight: A,
465
+ offsetX: X,
466
+ offsetY: T
467
+ };
468
+ }, Ae = (e, t, o) => {
469
+ const n = t - e.videoRect.left - e.offsetX, c = o - e.videoRect.top - e.offsetY, a = Math.max(0, Math.min(e.actualWidth, n)), i = Math.max(0, Math.min(e.actualHeight, c)), l = Math.max(
470
+ 0,
471
+ Math.min(e.videoWidth, a / e.actualWidth * e.videoWidth)
472
+ ), s = Math.max(
473
+ 0,
474
+ Math.min(e.videoHeight, i / e.actualHeight * e.videoHeight)
475
+ );
476
+ return {
477
+ videoX: l,
478
+ videoY: s,
479
+ videoWidth: e.videoWidth,
480
+ videoHeight: e.videoHeight
481
+ };
482
+ }, Ht = (e, t, o) => {
483
+ const n = t - e.videoRect.left - e.offsetX, c = o - e.videoRect.top - e.offsetY, a = Math.max(0, Math.min(e.actualWidth, n)), i = Math.max(0, Math.min(e.actualHeight, c)), l = Math.max(
484
+ 0,
485
+ Math.min(e.videoWidth, a / e.actualWidth * e.videoWidth)
486
+ ), s = Math.max(
487
+ 0,
488
+ Math.min(e.videoHeight, i / e.actualHeight * e.videoHeight)
489
+ ), f = e.videoWidth - l, I = e.videoHeight - s, A = e.videoRect.left + e.offsetX, X = e.videoRect.top + e.offsetY, T = A - e.containerRect.left + a, Y = X - e.containerRect.top + i, he = A - e.containerRect.left + (e.actualWidth - a), x = X - e.containerRect.top + (e.actualHeight - i);
490
+ return {
491
+ containerX: T,
492
+ containerY: Y,
493
+ mirrorContainerX: he,
494
+ mirrorContainerY: x,
495
+ videoX: l,
496
+ videoY: s,
497
+ mirrorVideoX: f,
498
+ mirrorVideoY: I,
499
+ videoWidth: e.videoWidth,
500
+ videoHeight: e.videoHeight
501
+ };
502
+ }, xt = (e, t, o, n, c, a, i) => {
503
+ const l = cn(e, t, o, n, c, a, i);
504
+ D("[rc-touch2] sendTwoFingerMessage (iOS)", {
505
+ actionName: He(e),
506
+ video: { width: t, height: o },
507
+ p0: { x: n, y: c },
508
+ p1: { x: a, y: i },
509
+ byteLength: l.byteLength
510
+ }), q(l);
511
+ }, be = (e, t, o, n, c, a, i, l, s) => {
512
+ if (D("[rc-touch2] applyTwoFingerEvent", {
513
+ platform: Z,
514
+ eventType: e,
515
+ video: { width: t, height: o },
516
+ p0: { x: n, y: c, id: l },
517
+ p1: { x: a, y: i, id: s }
518
+ }), e === "down" && Ce.current.end(), Z === "ios") {
519
+ const f = e === "down" ? g.ACTION_DOWN : e === "move" ? g.ACTION_MOVE : g.ACTION_UP;
520
+ xt(f, t, o, n, c, a, i);
521
+ } else
522
+ e === "down" ? (we(g.ACTION_DOWN, l, t, o, n, c), we(g.ACTION_POINTER_DOWN, s, t, o, a, i)) : e === "move" ? (we(g.ACTION_MOVE, l, t, o, n, c), we(g.ACTION_MOVE, s, t, o, a, i)) : (we(g.ACTION_POINTER_UP, s, t, o, a, i), we(g.ACTION_UP, l, t, o, n, c));
523
+ }, Ut = (e, t, o) => {
524
+ if (!ce.current) {
525
+ se !== null && _e(null);
526
+ return;
527
+ }
528
+ const n = Ht(e, t, o);
529
+ _e(n);
530
+ }, $t = (e, t, o) => {
531
+ const n = ae.current;
532
+ if (!n || n.screen.width <= 0 || n.screen.height <= 0) return null;
533
+ const c = t - e.videoRect.left - e.offsetX, a = o - e.videoRect.top - e.offsetY;
534
+ if (c < 0 || a < 0 || c > e.actualWidth || a > e.actualHeight) return null;
535
+ const i = c / e.actualWidth * n.screen.width, l = a / e.actualHeight * n.screen.height;
536
+ return on(n, i, l);
537
+ }, ne = (e) => {
538
+ if (K) return;
539
+ e.preventDefault(), e.stopPropagation();
540
+ const t = Ee();
541
+ if (($ === !0 || $ === "hover-only") && !("touches" in e))
542
+ if (e.type === "mousemove") {
543
+ if (lt({ x: e.clientX, y: e.clientY }), t) {
544
+ const n = $t(t, e.clientX, e.clientY);
545
+ Re(n?.id ?? null);
546
+ }
547
+ } else e.type === "mouseleave" && (lt(null), Re(null));
548
+ if ($ !== !0 && (!("touches" in e) && t && (e.type === "mousemove" ? Ut(t, e.clientX, e.clientY) : e.type === "mouseleave" && _e(null)), !(!w.current?.getState().controlReady || !P.current || !t)))
549
+ if ("touches" in e) {
550
+ const n = e.touches, c = e.changedTouches;
551
+ let a;
552
+ switch (e.type) {
553
+ case "touchstart":
554
+ a = "down";
555
+ break;
556
+ case "touchmove":
557
+ a = "move";
558
+ break;
559
+ case "touchend":
560
+ a = "up";
561
+ break;
562
+ case "touchcancel":
563
+ a = "cancel";
564
+ break;
565
+ default:
566
+ return;
567
+ }
568
+ if (n.length === 2) {
569
+ const i = n[0], l = n[1], s = Ae(t, i.clientX, i.clientY), f = Ae(t, l.clientX, l.clientY);
570
+ if (!s || !f) return;
571
+ E.current ? E.current.source === "real-touch" && (E.current.finger0 = { x: s.videoX, y: s.videoY }, E.current.finger1 = { x: f.videoX, y: f.videoY }, be(
572
+ "move",
573
+ s.videoWidth,
574
+ s.videoHeight,
575
+ s.videoX,
576
+ s.videoY,
577
+ f.videoX,
578
+ f.videoY,
579
+ E.current.pointerId0,
580
+ E.current.pointerId1
581
+ )) : (E.current = {
582
+ finger0: { x: s.videoX, y: s.videoY },
583
+ finger1: { x: f.videoX, y: f.videoY },
584
+ videoSize: { width: s.videoWidth, height: s.videoHeight },
585
+ source: "real-touch",
586
+ pointerId0: i.identifier,
587
+ pointerId1: l.identifier
588
+ }, be(
589
+ "down",
590
+ s.videoWidth,
591
+ s.videoHeight,
592
+ s.videoX,
593
+ s.videoY,
594
+ f.videoX,
595
+ f.videoY,
596
+ i.identifier,
597
+ l.identifier
598
+ ));
599
+ } else if (n.length < 2 && E.current?.source === "real-touch") {
600
+ const i = E.current;
601
+ be(
602
+ "up",
603
+ i.videoSize.width,
604
+ i.videoSize.height,
605
+ i.finger0.x,
606
+ i.finger0.y,
607
+ i.finger1.x,
608
+ i.finger1.y,
609
+ i.pointerId0,
610
+ i.pointerId1
611
+ ), E.current = null;
612
+ return;
613
+ } else {
614
+ if (n.length > 2)
615
+ return;
616
+ {
617
+ const i = c[0];
618
+ if (i) {
619
+ const l = Ae(t, i.clientX, i.clientY);
620
+ ue(i.identifier, a, l);
621
+ }
622
+ }
623
+ }
624
+ } else {
625
+ let c = null;
626
+ const a = E.current?.source === "alt-mouse";
627
+ switch (e.type) {
628
+ case "mousedown":
629
+ e.button === 0 && (c = "down");
630
+ break;
631
+ case "mousemove":
632
+ (a || k.current.has(-1)) && (c = "move");
633
+ break;
634
+ case "mouseup":
635
+ e.button === 0 && (c = "up");
636
+ break;
637
+ case "mouseleave":
638
+ (a || k.current.has(-1)) && (c = "up");
639
+ break;
640
+ }
641
+ if (c) {
642
+ const i = Ae(t, e.clientX, e.clientY);
643
+ if (!i)
644
+ return;
645
+ D("[rc-touch][mouse] event", {
646
+ domType: e.type,
647
+ eventType: c,
648
+ button: e.button,
649
+ buttons: e.buttons,
650
+ client: { x: e.clientX, y: e.clientY },
651
+ altHeldRef: ce.current,
652
+ inTwoFingerMode: a,
653
+ geometry: {
654
+ videoX: i.videoX,
655
+ videoY: i.videoY,
656
+ videoWidth: i.videoWidth,
657
+ videoHeight: i.videoHeight
658
+ },
659
+ activePointerIds: Array.from(k.current.keys())
660
+ }), ce.current || a ? Ft(c, i) : ue(-1, c, i);
661
+ }
662
+ }
663
+ }, Ft = (e, t) => {
664
+ const { videoX: o, videoY: n, videoWidth: c, videoHeight: a } = t, i = c - o, l = a - n;
665
+ if (e === "down") {
666
+ E.current = {
667
+ finger0: { x: o, y: n },
668
+ finger1: { x: i, y: l },
669
+ videoSize: { width: c, height: a },
670
+ source: "alt-mouse",
671
+ pointerId0: Ye,
672
+ pointerId1: Le
673
+ }, P.current?.focus(), be(
674
+ "down",
675
+ c,
676
+ a,
677
+ o,
678
+ n,
679
+ i,
680
+ l,
681
+ Ye,
682
+ Le
683
+ );
684
+ return;
685
+ }
686
+ if (e === "move") {
687
+ E.current?.source === "alt-mouse" && (E.current.finger0 = { x: o, y: n }, E.current.finger1 = { x: i, y: l }, be(
688
+ "move",
689
+ c,
690
+ a,
691
+ o,
692
+ n,
693
+ i,
694
+ l,
695
+ Ye,
696
+ Le
697
+ ));
698
+ return;
699
+ }
700
+ if (e === "up" || e === "cancel") {
701
+ const s = E.current;
702
+ if (s?.source === "alt-mouse") {
703
+ const { finger0: f, finger1: I, videoSize: A } = s;
704
+ be(
705
+ "up",
706
+ A.width,
707
+ A.height,
708
+ f.x,
709
+ f.y,
710
+ I.x,
711
+ I.y,
712
+ Ye,
713
+ Le
714
+ ), E.current = null;
715
+ }
716
+ return;
717
+ }
718
+ }, zt = 150, mt = () => {
719
+ const e = me.current;
720
+ e && (window.clearTimeout(e.endTimer), ue(de, "up", e.pos), me.current = null);
721
+ }, Vt = (e) => {
722
+ if (!w.current?.getState().controlReady || e.ctrlKey || ce.current || E.current) return;
723
+ const t = k.current.size;
724
+ if (t > 1 || t === 1 && !k.current.has(de)) return;
725
+ const o = Ee();
726
+ if (!o) return;
727
+ const n = e.clientX - o.videoRect.left - o.offsetX, c = e.clientY - o.videoRect.top - o.offsetY;
728
+ if (n < 0 || n > o.actualWidth || c < 0 || c > o.actualHeight)
729
+ return;
730
+ const a = Ae(o, e.clientX, e.clientY);
731
+ if (!a) return;
732
+ e.preventDefault();
733
+ const i = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualWidth : 1) * (o.videoWidth / o.actualWidth), l = (e.deltaMode === 1 ? 16 : e.deltaMode === 2 ? o.actualHeight : 1) * (o.videoHeight / o.actualHeight), s = -e.deltaX * i, f = -e.deltaY * l, I = (x) => {
734
+ window.clearTimeout(x.endTimer), x.endTimer = window.setTimeout(mt, zt);
735
+ };
736
+ if (s === 0 && f === 0) {
737
+ me.current && I(me.current);
738
+ return;
739
+ }
740
+ const A = () => ({
741
+ videoWidth: a.videoWidth,
742
+ videoHeight: a.videoHeight,
743
+ videoX: Math.abs(s) > Math.abs(f) ? Math.min(Math.max(a.videoX, a.videoWidth * 0.2), a.videoWidth * 0.8) : a.videoX,
744
+ videoY: Math.abs(f) >= Math.abs(s) ? Math.min(Math.max(a.videoY, a.videoHeight * 0.2), a.videoHeight * 0.8) : a.videoY
745
+ }), X = (x) => ({
746
+ ...x,
747
+ videoX: Math.min(Math.max(x.videoX + s, 0), x.videoWidth),
748
+ videoY: Math.min(Math.max(x.videoY + f, 0), x.videoHeight)
749
+ });
750
+ let T = me.current;
751
+ if (T)
752
+ window.clearTimeout(T.endTimer);
753
+ else {
754
+ const x = A();
755
+ ue(de, "down", x), T = { pos: x, endTimer: 0 }, me.current = T;
756
+ }
757
+ let Y = T.pos, he = X(Y);
758
+ he.videoX === Y.videoX && he.videoY === Y.videoY && (ue(de, "up", Y), Y = A(), ue(de, "down", Y), he = X(Y)), ue(de, "move", he), T.pos = he, I(T);
759
+ };
760
+ F(() => {
761
+ Ce.current = { handle: Vt, end: mt };
762
+ }), F(() => {
763
+ const e = Oe.current;
764
+ if (!e) return;
765
+ const t = (o) => Ce.current.handle(o);
766
+ return e.addEventListener("wheel", t, { passive: !1 }), () => {
767
+ Ce.current.end(), e.removeEventListener("wheel", t);
768
+ };
769
+ }, []), F(() => {
770
+ const e = (n) => {
771
+ n.key === "Alt" && Ve(!0);
772
+ }, t = (n) => {
773
+ n.key === "Alt" && Ve(!1);
774
+ }, o = () => {
775
+ Ve(!1);
776
+ };
777
+ return window.addEventListener("keydown", e, !0), window.addEventListener("keyup", t, !0), window.addEventListener("blur", o), () => {
778
+ window.removeEventListener("keydown", e, !0), window.removeEventListener("keyup", t, !0), window.removeEventListener("blur", o);
779
+ };
780
+ }, []);
781
+ const Xe = (e) => {
782
+ e.preventDefault(), e.stopPropagation();
783
+ const t = document.activeElement === P.current || K && document.activeElement === e.currentTarget;
784
+ if (D("Keyboard event:", {
785
+ type: e.type,
786
+ key: e.key,
787
+ keyCode: e.keyCode,
788
+ code: e.code,
789
+ target: e.target.tagName,
790
+ focused: t
791
+ }), !t) {
792
+ je("Simulator input not focused, skipping keyboard event");
793
+ return;
794
+ }
795
+ if (!w.current?.getState().controlReady) {
796
+ je("Data channel not ready for keyboard event:", w.current?.getState().connection);
797
+ return;
798
+ }
799
+ if (e.type === "keydown") {
800
+ if (e.key.toLowerCase() === "v" && (e.metaKey || e.ctrlKey)) {
801
+ D("Paste shortcut detected"), navigator.clipboard.readText().then((n) => {
802
+ if (n) {
803
+ D(
804
+ "Pasting text via SET_CLIPBOARD:",
805
+ n.substring(0, 20) + (n.length > 20 ? "..." : "")
806
+ );
807
+ const c = nn(n, !0);
808
+ q(c);
809
+ }
810
+ }).catch((n) => {
811
+ console.error("Failed to read clipboard contents: ", n);
812
+ });
813
+ return;
814
+ }
815
+ if (e.key.toLowerCase() === "m" && (e.metaKey || e.ctrlKey)) {
816
+ D("Menu shortcut detected");
817
+ const n = De(
818
+ M.ACTION_DOWN,
819
+ M.MENU,
820
+ 0,
821
+ M.META_NONE
822
+ // Modifiers are handled by the shortcut check, not passed down
823
+ );
824
+ q(n);
825
+ const c = De(
826
+ M.ACTION_UP,
827
+ M.MENU,
828
+ 0,
829
+ M.META_NONE
830
+ );
831
+ q(c);
832
+ return;
833
+ }
834
+ }
835
+ const o = En(e);
836
+ if (o) {
837
+ const { keycode: n, metaState: c } = o, a = e.type === "keydown" ? M.ACTION_DOWN : M.ACTION_UP;
838
+ D(`Sending Keycode: key=${e.key}, code=${n}, action=${a}, meta=${c}`);
839
+ const i = De(
840
+ a,
841
+ n,
842
+ 0,
843
+ // repeat count, typically 0 for single presses
844
+ c
845
+ );
846
+ q(i);
847
+ } else
848
+ D(`Ignoring unhandled key event: type=${e.type}, key=${e.key}`);
849
+ }, Kt = (e) => {
850
+ e.stopPropagation(), w.current?.reconnect();
851
+ }, H = S({
852
+ onAxSnapshotChange: oe,
853
+ onAxStatusChange: B,
854
+ onCameraDemandChange: Ie,
855
+ onCameraStats: j,
856
+ onMicrophoneStateChange: pe,
857
+ onTrace: te,
858
+ onTerminated: L,
859
+ onConnectionStateChange: ee,
860
+ onPlaybackStats: N
861
+ });
862
+ H.current = {
863
+ onAxSnapshotChange: oe,
864
+ onAxStatusChange: B,
865
+ onCameraDemandChange: Ie,
866
+ onCameraStats: j,
867
+ onMicrophoneStateChange: pe,
868
+ onTrace: te,
869
+ onTerminated: L,
870
+ onConnectionStateChange: ee,
871
+ onPlaybackStats: N
872
+ };
873
+ const Ke = !!te;
874
+ F(() => {
875
+ xe.current = null, nt(!1), rt(!1), it({});
876
+ }, [r, p]), F(() => {
877
+ let e = !0;
878
+ ae.current !== null && (ae.current = null, Ue(null), Te("onAxSnapshotChange", H.current.onAxSnapshotChange, null));
879
+ const t = en({
880
+ url: r,
881
+ token: u,
882
+ sessionId: Dt,
883
+ watchOnly: ie,
884
+ deviceModel: p,
885
+ autoReconnect: v,
886
+ jitterBufferTargetMs: _,
887
+ openUrl: C,
888
+ inspectMode: $,
889
+ axPollIntervalMs: W,
890
+ axMaxBackoffMs: y,
891
+ androidElementTreeOptions: J,
892
+ microphoneEnabled: re,
893
+ onStateChange: (n) => {
894
+ (n.videoReady || n.connection === "idle" || n.connection === "connecting" || n.connection === "reconnecting") && Nt(n.videoReady), It(n.connection === "failed"), Mt(n.connection === "terminated"), bt(n.duo), Tt(n.duoState), Ct(n.duoError);
895
+ },
896
+ onAxSnapshotChange: (n) => {
897
+ e && (Ue((c) => tn(c, n) ? c : n), H.current.onAxSnapshotChange?.(n));
898
+ },
899
+ onAxStatusChange: (...n) => H.current.onAxStatusChange?.(...n),
900
+ onCameraDemandChange: (...n) => H.current.onCameraDemandChange?.(...n),
901
+ onCameraStats: j ? (...n) => H.current.onCameraStats?.(...n) : void 0,
902
+ onMicrophoneStateChange: (...n) => H.current.onMicrophoneStateChange?.(...n),
903
+ onTrace: Ke ? (...n) => H.current.onTrace?.(...n) : void 0,
904
+ onTerminated: () => H.current.onTerminated?.(),
905
+ onConnectionStateChange: (...n) => H.current.onConnectionStateChange?.(...n),
906
+ onPlaybackStats: N ? (...n) => H.current.onPlaybackStats?.(...n) : void 0
907
+ });
908
+ w.current = t;
909
+ const o = P.current ? t.attachVideo(P.current) : void 0;
910
+ return t.start(), () => {
911
+ e = !1, t.dispose(), o?.(), w.current = null;
912
+ };
913
+ }, [r, h, p, Ke, ie]), F(() => {
914
+ if (K && Me.current)
915
+ return w.current?.attachVideo(Me.current, "inner");
916
+ }, [K, r, h, p, Ke, ie]), F(() => {
917
+ w.current?.updateOptions({
918
+ token: u,
919
+ openUrl: C,
920
+ axPollIntervalMs: W,
921
+ axMaxBackoffMs: y,
922
+ androidElementTreeOptions: J,
923
+ autoReconnect: v,
924
+ jitterBufferTargetMs: _,
925
+ microphoneEnabled: re,
926
+ inspectMode: $,
927
+ onPlaybackStats: N ? (...e) => H.current.onPlaybackStats?.(...e) : void 0,
928
+ onCameraStats: j ? (...e) => H.current.onCameraStats?.(...e) : void 0
929
+ });
930
+ }, [
931
+ u,
932
+ v,
933
+ _,
934
+ re,
935
+ $,
936
+ !!N,
937
+ !!j,
938
+ C,
939
+ W,
940
+ y,
941
+ J
942
+ ]);
943
+ const Be = () => {
944
+ if (!dt.current) return;
945
+ const e = Ee();
946
+ if (!e) {
947
+ st(null);
948
+ return;
949
+ }
950
+ const t = {
951
+ left: e.videoRect.left - e.containerRect.left + e.offsetX,
952
+ top: e.videoRect.top - e.containerRect.top + e.offsetY,
953
+ width: e.actualWidth,
954
+ height: e.actualHeight
955
+ };
956
+ st(
957
+ (o) => o && o.left === t.left && o.top === t.top && o.width === t.width && o.height === t.height ? o : t
958
+ );
959
+ };
960
+ F(() => {
961
+ const e = P.current, t = Qe.current, o = Oe.current;
962
+ if (!e) return;
963
+ const n = (l) => it((s) => In(s, l) ? s : l), c = () => {
964
+ const l = e.videoWidth > 0 && e.videoHeight > 0;
965
+ l && (xe.current = { width: e.videoWidth, height: e.videoHeight });
966
+ const s = xe.current, f = s ? `${s.width} / ${s.height}` : void 0;
967
+ if (!ke || !t) {
968
+ n(
969
+ !l && s ? {
970
+ aspectRatio: f,
971
+ contain: "size",
972
+ containIntrinsicSize: `${s.width}px ${s.height}px`
973
+ } : {}
974
+ ), Be();
975
+ return;
976
+ }
977
+ const I = t.clientWidth, A = t.clientHeight;
978
+ if (I === 0 || A === 0) return;
979
+ const X = s ? s.width > s.height : !1;
980
+ nt(X), rt(
981
+ Z === "android" && !!s && Cn(s.width, s.height)
982
+ );
983
+ const T = X ? ye.videoPosition.landscape : ye.videoPosition.portrait;
984
+ let Y = { aspectRatio: f };
985
+ T.heightMultiplier ? (Y.height = `${A * T.heightMultiplier}px`, Y.width = "auto") : T.widthMultiplier && (Y.width = `${I * T.widthMultiplier}px`, Y.height = "auto"), Y.borderRadius = `${X ? A * ye.videoBorderRadiusMultiplier : I * ye.videoBorderRadiusMultiplier}px`, n(Y), Be();
986
+ }, a = new ResizeObserver(() => {
987
+ c();
988
+ });
989
+ t && a.observe(t), a.observe(e), o && a.observe(o), t && t.addEventListener("load", c), e.addEventListener("loadedmetadata", c), e.addEventListener("resize", c);
990
+ const i = () => w.current?.bumpActivity();
991
+ return e.addEventListener("resize", i), c(), () => {
992
+ a.disconnect(), e.removeEventListener("loadedmetadata", c), e.removeEventListener("resize", c), e.removeEventListener("resize", i), t && t.removeEventListener("load", c);
993
+ };
994
+ }, [ye, ke, r, p]), F(() => {
995
+ le ? Be() : (Ue(null), Re(null), Se(null), at(null), ge(null), Pe.current = null, Q.current !== void 0 && (window.cancelAnimationFrame(Q.current), Q.current = void 0));
996
+ }, [le]), F(() => () => {
997
+ Q.current !== void 0 && (window.cancelAnimationFrame(Q.current), Q.current = void 0);
998
+ }, []), F(() => {
999
+ if (!le) return;
1000
+ const e = (t) => {
1001
+ t.key === "Escape" && (Fe || $e) && (Se(null), Re(null), ge(null), Te("onInspectSelectionChange", ve.current, null));
1002
+ };
1003
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
1004
+ }, [le, Fe, $e]);
1005
+ const Bt = () => {
1006
+ P.current && P.current.focus();
1007
+ };
1008
+ dn(Ge, () => ({
1009
+ openUrl: (e) => w.current?.openUrl(e),
1010
+ sendKeyEvent: (e) => w.current?.sendKeyEvent(e),
1011
+ screenshot: (e) => w.current?.screenshot(e) ?? Promise.reject(new Error("Simulator disconnected")),
1012
+ terminateApp: (e) => w.current?.terminateApp(e) ?? Promise.reject(new Error("Simulator disconnected")),
1013
+ reconnect: () => w.current?.reconnect(),
1014
+ refreshAxTree: () => w.current?.refreshAxTree() ?? Promise.reject(new Error("Simulator disconnected")),
1015
+ getAxSnapshot: () => w.current?.getAxSnapshot() ?? null,
1016
+ setInspectHighlight: (e) => {
1017
+ Re(e?.id ?? null);
1018
+ },
1019
+ setInspectSelection: (e) => {
1020
+ Se(e?.id ?? null), ge(e ? Pe.current : null);
1021
+ const t = ae.current;
1022
+ e && t ? Te("onInspectSelectionChange", ve.current, { element: e, snapshot: t }) : Te("onInspectSelectionChange", ve.current, null);
1023
+ },
1024
+ getAxStatus: () => w.current?.getAxStatus() ?? "idle"
1025
+ }));
1026
+ const jt = St && se !== null;
1027
+ return /* @__PURE__ */ z(
1028
+ "div",
1029
+ {
1030
+ ref: Oe,
1031
+ className: ["rc-container", d].filter(Boolean).join(" "),
1032
+ style: { touchAction: "none" },
1033
+ onMouseDown: ne,
1034
+ onMouseMove: ne,
1035
+ onMouseUp: ne,
1036
+ onMouseLeave: ne,
1037
+ onTouchStart: ne,
1038
+ onTouchMove: ne,
1039
+ onTouchEnd: ne,
1040
+ onTouchCancel: ne,
1041
+ children: [
1042
+ jt && se && /* @__PURE__ */ z(yt, { children: [
1043
+ /* @__PURE__ */ m(
1044
+ "div",
1045
+ {
1046
+ className: "rc-touch-indicator",
1047
+ style: {
1048
+ left: `${se.containerX}px`,
1049
+ top: `${se.containerY}px`
1050
+ }
1051
+ }
1052
+ ),
1053
+ /* @__PURE__ */ m(
1054
+ "div",
1055
+ {
1056
+ className: "rc-touch-indicator",
1057
+ style: {
1058
+ left: `${se.mirrorContainerX}px`,
1059
+ top: `${se.mirrorContainerY}px`
1060
+ }
1061
+ }
1062
+ )
1063
+ ] }),
1064
+ ke && /* @__PURE__ */ m(
1065
+ "img",
1066
+ {
1067
+ ref: Qe,
1068
+ src: ut,
1069
+ alt: "",
1070
+ className: Z === "ios" ? "rc-phone-frame rc-phone-frame-ios" : "rc-phone-frame",
1071
+ draggable: !1
1072
+ }
1073
+ ),
1074
+ /* @__PURE__ */ m(
1075
+ "video",
1076
+ {
1077
+ ref: P,
1078
+ className: ["rc-video", !ke && "rc-video-frameless", !Rt && "rc-video-loading"].filter(Boolean).join(" "),
1079
+ style: {
1080
+ ..._t,
1081
+ ...K ? { opacity: 0, width: 1, height: 1, pointerEvents: "none" } : {},
1082
+ ...ht ? {
1083
+ backgroundImage: `url("${ht}")`,
1084
+ backgroundRepeat: "no-repeat",
1085
+ backgroundPosition: "center",
1086
+ backgroundSize: ye.loadingLogoSize
1087
+ } : {}
1088
+ },
1089
+ autoPlay: !0,
1090
+ playsInline: !0,
1091
+ muted: !0,
1092
+ tabIndex: K ? -1 : 0,
1093
+ onKeyDown: Xe,
1094
+ onKeyUp: Xe,
1095
+ onClick: Bt,
1096
+ onFocus: () => {
1097
+ P.current && (P.current.style.outline = "none");
1098
+ },
1099
+ onBlur: () => {
1100
+ P.current && (P.current.style.outline = "none");
1101
+ }
1102
+ }
1103
+ ),
1104
+ K && /* @__PURE__ */ m(
1105
+ "video",
1106
+ {
1107
+ ref: Me,
1108
+ autoPlay: !0,
1109
+ playsInline: !0,
1110
+ muted: !0,
1111
+ style: { position: "absolute", width: 1, height: 1, opacity: 0, pointerEvents: "none" }
1112
+ }
1113
+ ),
1114
+ K && Ze && /* @__PURE__ */ m(un, { fallback: /* @__PURE__ */ m("div", { children: "Loading iPhone Duo…" }), children: /* @__PURE__ */ m(
1115
+ Tn,
1116
+ {
1117
+ watchOnly: ie,
1118
+ showFrame: R,
1119
+ modelUrl: U,
1120
+ outer: P.current,
1121
+ inner: Me.current,
1122
+ state: Ze,
1123
+ setAngle: (e) => ze("setHingeAngle", { angleDegrees: e }),
1124
+ setOrientation: (e) => ze("setDuoOrientation", { orientation: e }),
1125
+ button: (e, t) => ze("performActions", {
1126
+ actions: [{ type: t ? "buttonDown" : "buttonUp", button: e }]
1127
+ }),
1128
+ touch: (e, t, o, n) => {
1129
+ w.current?.sendDisplayTouch(e, t, o, n);
1130
+ },
1131
+ onKeyDown: Xe,
1132
+ onKeyUp: Xe
1133
+ }
1134
+ ) }),
1135
+ K && et && /* @__PURE__ */ m("div", { role: "alert", className: "rc-duo-error", children: et }),
1136
+ !K && le && /* @__PURE__ */ m(
1137
+ An,
1138
+ {
1139
+ snapshot: ct,
1140
+ geometry: kt,
1141
+ highlightedId: $e,
1142
+ selectedId: Fe,
1143
+ mode: Xt,
1144
+ cursorPosition: Yt,
1145
+ frozenCursorPosition: Lt,
1146
+ onSelectChange: (e, t) => {
1147
+ Se(e?.id ?? null), e && t ? ge(t) : e || ge(null);
1148
+ const o = ae.current;
1149
+ e && o ? Te("onInspectSelectionChange", ve.current, {
1150
+ element: e,
1151
+ snapshot: o
1152
+ }) : Te("onInspectSelectionChange", ve.current, null);
1153
+ },
1154
+ onTapElement: ie ? void 0 : ((e, t) => {
1155
+ if (t) {
1156
+ pt(t.x, t.y);
1157
+ return;
1158
+ }
1159
+ const o = ae.current;
1160
+ o && Wt(e, o);
1161
+ })
1162
+ }
1163
+ ),
1164
+ Ot ? /* @__PURE__ */ z("div", { className: "rc-terminated", role: "status", children: [
1165
+ /* @__PURE__ */ m("div", { className: "rc-terminated-title", children: "Instance terminated" }),
1166
+ /* @__PURE__ */ m("div", { className: "rc-terminated-message", children: "This instance no longer exists and can't be reconnected." })
1167
+ ] }) : Et && /* @__PURE__ */ m("button", { type: "button", className: "rc-retry-button", onClick: Kt, children: "Retry" })
1168
+ ]
1169
+ }
1170
+ );
1171
+ }
1172
+ );
1173
+ export {
1174
+ Pn as R
1175
+ };