@tapflowio/relay 0.17.0 → 0.19.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/RelayServer.d.ts +313 -2
- package/dist/RelayServer.d.ts.map +1 -1
- package/dist/RelayServer.js +1245 -211
- package/dist/RelayServer.js.map +1 -1
- package/dist/SessionManager.d.ts +124 -21
- package/dist/SessionManager.d.ts.map +1 -1
- package/dist/SessionManager.js +201 -22
- package/dist/SessionManager.js.map +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/types.d.ts +3 -44
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +13 -0
- package/dist/types.js.map +1 -1
- package/package.json +10 -8
- package/public/assets/{AppCenter-BRmG2FEm.js → AppCenter-DyP0aqfF.js} +2 -2
- package/public/assets/AppCenter-DyP0aqfF.js.br +0 -0
- package/public/assets/Default-D7ScPE30.js +1 -0
- package/public/assets/Default-D7ScPE30.js.br +0 -0
- package/public/assets/Invite-UmhV5rAf.js +1 -0
- package/public/assets/Invite-UmhV5rAf.js.br +0 -0
- package/public/assets/MacResources-MS4E00w3.js +1 -0
- package/public/assets/MacResources-MS4E00w3.js.br +0 -0
- package/public/assets/NotFound-BoDDivK5.js +1 -0
- package/public/assets/NotFound-BoDDivK5.js.br +0 -0
- package/public/assets/QASession-CjgJHDZ3.js +125 -0
- package/public/assets/QASession-CjgJHDZ3.js.br +0 -0
- package/public/assets/ResetPassword-CAlB6CfP.js +1 -0
- package/public/assets/ResetPassword-CAlB6CfP.js.br +0 -0
- package/public/assets/Setup-CPm2-hPJ.js +1 -0
- package/public/assets/Setup-CPm2-hPJ.js.br +0 -0
- package/public/assets/{Team-D1iwg2vL.js → Team-GEIzrM1D.js} +2 -2
- package/public/assets/Team-GEIzrM1D.js.br +0 -0
- package/public/assets/Tokens-DSeBz_CJ.js +1 -0
- package/public/assets/Tokens-DSeBz_CJ.js.br +0 -0
- package/public/assets/alert-dialog-BsXI9SVV.js +1 -0
- package/public/assets/alert-dialog-BsXI9SVV.js.br +0 -0
- package/public/assets/badge-BkdYQFsh.js +1 -0
- package/public/assets/badge-BkdYQFsh.js.br +0 -0
- package/public/assets/{build-format-BZV6gt41.js → build-format-CXuQt1X2.js} +3 -3
- package/public/assets/build-format-CXuQt1X2.js.br +0 -0
- package/public/assets/dialog-DuXZpbiF.js +11 -0
- package/public/assets/dialog-DuXZpbiF.js.br +0 -0
- package/public/assets/index-Bk2hqaHZ.css +1 -0
- package/public/assets/index-Bk2hqaHZ.css.br +0 -0
- package/public/assets/index-bitr6DIC.js +215 -0
- package/public/assets/index-bitr6DIC.js.br +0 -0
- package/public/assets/{pencil-BGrOEXS6.js → pencil-iRR275s8.js} +1 -1
- package/public/assets/pencil-iRR275s8.js.br +0 -0
- package/public/assets/table-CHmhGpHG.js +1 -0
- package/public/assets/table-CHmhGpHG.js.br +0 -0
- package/public/assets/tabs-BnbeuAOe.js +1 -0
- package/public/assets/tabs-BnbeuAOe.js.br +0 -0
- package/public/assets/{trash-2-CwlFrbEF.js → trash-2-QI162w2K.js} +1 -1
- package/public/assets/trash-2-QI162w2K.js.br +0 -0
- package/public/assets/vendor-charts-DyX5CBcf.js +5 -0
- package/public/assets/vendor-charts-DyX5CBcf.js.br +0 -0
- package/public/assets/vendor-react-AJpf4YZ0.js +49 -0
- package/public/assets/vendor-react-AJpf4YZ0.js.br +0 -0
- package/public/assets/vendor-router-ChFy8CZ1.js +12 -0
- package/public/assets/vendor-router-ChFy8CZ1.js.br +0 -0
- package/public/index.html +4 -2
- package/public/index.html.br +0 -0
- package/public/assets/AppCenter-BRmG2FEm.js.br +0 -0
- package/public/assets/Default-DTr0wqds.js +0 -1
- package/public/assets/Default-DTr0wqds.js.br +0 -0
- package/public/assets/Invite-DKsNh2GB.js +0 -1
- package/public/assets/Invite-DKsNh2GB.js.br +0 -0
- package/public/assets/MacResources-CLDdcibL.js +0 -5
- package/public/assets/MacResources-CLDdcibL.js.br +0 -0
- package/public/assets/NotFound-BtKq2uv6.js +0 -1
- package/public/assets/NotFound-BtKq2uv6.js.br +0 -0
- package/public/assets/QASession-B_5aJ67l.js +0 -130
- package/public/assets/QASession-B_5aJ67l.js.br +0 -0
- package/public/assets/ResetPassword-gp6hVQrf.js +0 -1
- package/public/assets/ResetPassword-gp6hVQrf.js.br +0 -0
- package/public/assets/Setup-DiG4Nbs7.js +0 -1
- package/public/assets/Setup-DiG4Nbs7.js.br +0 -0
- package/public/assets/Team-D1iwg2vL.js.br +0 -0
- package/public/assets/Tokens-DGtE4Xcy.js +0 -1
- package/public/assets/Tokens-DGtE4Xcy.js.br +0 -0
- package/public/assets/alert-dialog-CXwkFlF3.js +0 -1
- package/public/assets/alert-dialog-CXwkFlF3.js.br +0 -0
- package/public/assets/badge-CavXTq2x.js +0 -1
- package/public/assets/badge-CavXTq2x.js.br +0 -0
- package/public/assets/build-format-BZV6gt41.js.br +0 -0
- package/public/assets/dialog-JbKwqqS0.js +0 -11
- package/public/assets/dialog-JbKwqqS0.js.br +0 -0
- package/public/assets/index-CBnxiD7-.js +0 -274
- package/public/assets/index-CBnxiD7-.js.br +0 -0
- package/public/assets/index-Ctx3_cYz.css +0 -1
- package/public/assets/index-Ctx3_cYz.css.br +0 -0
- package/public/assets/pencil-BGrOEXS6.js.br +0 -0
- package/public/assets/table-CqOA0Bb1.js +0 -1
- package/public/assets/table-CqOA0Bb1.js.br +0 -0
- package/public/assets/tabs-BVBbhCFG.js +0 -1
- package/public/assets/tabs-BVBbhCFG.js.br +0 -0
- package/public/assets/trash-2-CwlFrbEF.js.br +0 -0
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import{W as te,a6 as o,al as un,a3 as n,J as Z,y as Pt,T as Ce,z as ke,B as ae,x as Ee,S as dn,a8 as tt,r as Jn,s as Ct,K as Le,ad as Oe,t as ze,O as fn,ac as et,aj as Zn,af as Qn,U as er,w as tr,f as nr,am as rr,ae as sr,ak as or,ab as ar,L as ir}from"./index-CBnxiD7-.js";import{f as cr,a as lr,P as hn,c as Gt,S as ur,b as dr}from"./build-format-BZV6gt41.js";import{u as pn,T as fr,b as hr,c as qt,a as Jt}from"./tabs-BVBbhCFG.js";import{D as mn,a as gn,d as pr,e as xn,b as mr,c as gr,k as xr,S as br,i as yr,j as vr,g as wr,h as Zt}from"./dialog-JbKwqqS0.js";import{B as Sr}from"./badge-CavXTq2x.js";/**
|
|
2
|
-
* @license lucide-react v0.577.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Rr=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],jr=te("arrow-left",Rr);/**
|
|
7
|
-
* @license lucide-react v0.577.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const Cr=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],kr=te("arrow-up",Cr);/**
|
|
12
|
-
* @license lucide-react v0.577.0 - ISC
|
|
13
|
-
*
|
|
14
|
-
* This source code is licensed under the ISC license.
|
|
15
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
-
*/const Er=[["path",{d:"M13.997 4a2 2 0 0 1 1.76 1.05l.486.9A2 2 0 0 0 18.003 7H20a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V9a2 2 0 0 1 2-2h1.997a2 2 0 0 0 1.759-1.048l.489-.904A2 2 0 0 1 10.004 4z",key:"18u6gg"}],["circle",{cx:"12",cy:"13",r:"3",key:"1vg3eu"}]],Tr=te("camera",Er);/**
|
|
17
|
-
* @license lucide-react v0.577.0 - ISC
|
|
18
|
-
*
|
|
19
|
-
* This source code is licensed under the ISC license.
|
|
20
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
-
*/const _r=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],Ar=te("download",_r);/**
|
|
22
|
-
* @license lucide-react v0.577.0 - ISC
|
|
23
|
-
*
|
|
24
|
-
* This source code is licensed under the ISC license.
|
|
25
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
-
*/const Pr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M7 3v18",key:"bbkbws"}],["path",{d:"M3 7.5h4",key:"zfgn84"}],["path",{d:"M3 12h18",key:"1i2n21"}],["path",{d:"M3 16.5h4",key:"1230mu"}],["path",{d:"M17 3v18",key:"in4fa5"}],["path",{d:"M17 7.5h4",key:"myr1c1"}],["path",{d:"M17 16.5h4",key:"go4c1d"}]],Nr=te("film",Pr);/**
|
|
27
|
-
* @license lucide-react v0.577.0 - ISC
|
|
28
|
-
*
|
|
29
|
-
* This source code is licensed under the ISC license.
|
|
30
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
-
*/const Dr=[["path",{d:"M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8",key:"5wwlr5"}],["path",{d:"M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z",key:"r6nss1"}]],bn=te("house",Dr);/**
|
|
32
|
-
* @license lucide-react v0.577.0 - ISC
|
|
33
|
-
*
|
|
34
|
-
* This source code is licensed under the ISC license.
|
|
35
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
-
*/const Lr=[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]],Mr=te("image-plus",Lr);/**
|
|
37
|
-
* @license lucide-react v0.577.0 - ISC
|
|
38
|
-
*
|
|
39
|
-
* This source code is licensed under the ISC license.
|
|
40
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
-
*/const Ir=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ur=te("info",Ir);/**
|
|
42
|
-
* @license lucide-react v0.577.0 - ISC
|
|
43
|
-
*
|
|
44
|
-
* This source code is licensed under the ISC license.
|
|
45
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
-
*/const Hr=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Fr=te("keyboard",Hr);/**
|
|
47
|
-
* @license lucide-react v0.577.0 - ISC
|
|
48
|
-
*
|
|
49
|
-
* This source code is licensed under the ISC license.
|
|
50
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
-
*/const Br=[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]],yn=te("link-2",Br);/**
|
|
52
|
-
* @license lucide-react v0.577.0 - ISC
|
|
53
|
-
*
|
|
54
|
-
* This source code is licensed under the ISC license.
|
|
55
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
-
*/const $r=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Rt=te("loader-circle",$r);/**
|
|
57
|
-
* @license lucide-react v0.577.0 - ISC
|
|
58
|
-
*
|
|
59
|
-
* This source code is licensed under the ISC license.
|
|
60
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
-
*/const Or=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],zr=te("message-square",Or);/**
|
|
62
|
-
* @license lucide-react v0.577.0 - ISC
|
|
63
|
-
*
|
|
64
|
-
* This source code is licensed under the ISC license.
|
|
65
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
-
*/const Wr=[["path",{d:"M12 2v10",key:"mnfbl"}],["path",{d:"M18.4 6.6a9 9 0 1 1-12.77.04",key:"obofu9"}]],Vr=te("power",Wr);/**
|
|
67
|
-
* @license lucide-react v0.577.0 - ISC
|
|
68
|
-
*
|
|
69
|
-
* This source code is licensed under the ISC license.
|
|
70
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
-
*/const Kr=[["path",{d:"M21 12a9 9 0 1 1-9-9c2.52 0 4.93 1 6.74 2.74L21 8",key:"1p45f6"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}]],Xr=te("rotate-cw",Kr);/**
|
|
72
|
-
* @license lucide-react v0.577.0 - ISC
|
|
73
|
-
*
|
|
74
|
-
* This source code is licensed under the ISC license.
|
|
75
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
-
*/const Yr=[["path",{d:"M3 7V5a2 2 0 0 1 2-2h2",key:"aa7l1z"}],["path",{d:"M17 3h2a2 2 0 0 1 2 2v2",key:"4qcy5o"}],["path",{d:"M21 17v2a2 2 0 0 1-2 2h-2",key:"6vwrx8"}],["path",{d:"M7 21H5a2 2 0 0 1-2-2v-2",key:"ioqczr"}],["path",{d:"M7 12h10",key:"b7w52i"}]],Gr=te("scan-line",Yr);/**
|
|
77
|
-
* @license lucide-react v0.577.0 - ISC
|
|
78
|
-
*
|
|
79
|
-
* This source code is licensed under the ISC license.
|
|
80
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
81
|
-
*/const qr=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}]],Jr=te("square",qr);/**
|
|
82
|
-
* @license lucide-react v0.577.0 - ISC
|
|
83
|
-
*
|
|
84
|
-
* This source code is licensed under the ISC license.
|
|
85
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
86
|
-
*/const Zr=[["path",{d:"m16 13 5.223 3.482a.5.5 0 0 0 .777-.416V7.87a.5.5 0 0 0-.752-.432L16 10.5",key:"ftymec"}],["rect",{x:"2",y:"6",width:"14",height:"12",rx:"2",key:"158x01"}]],Qr=te("video",Zr);/**
|
|
87
|
-
* @license lucide-react v0.577.0 - ISC
|
|
88
|
-
*
|
|
89
|
-
* This source code is licensed under the ISC license.
|
|
90
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
91
|
-
*/const es=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}],["path",{d:"M19.364 18.364a9 9 0 0 0 0-12.728",key:"ijwkga"}]],ts=te("volume-2",es);/**
|
|
92
|
-
* @license lucide-react v0.577.0 - ISC
|
|
93
|
-
*
|
|
94
|
-
* This source code is licensed under the ISC license.
|
|
95
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
96
|
-
*/const ns=[["path",{d:"M11 4.702a.705.705 0 0 0-1.203-.498L6.413 7.587A1.4 1.4 0 0 1 5.416 8H3a1 1 0 0 0-1 1v6a1 1 0 0 0 1 1h2.416a1.4 1.4 0 0 1 .997.413l3.383 3.384A.705.705 0 0 0 11 19.298z",key:"uqj9uw"}],["path",{d:"M16 9a5 5 0 0 1 0 6",key:"1q6k2b"}]],rs=te("volume-1",ns);function ss(t){const[e,r]=o.useState(null);return o.useEffect(()=>{t&&cr(t).then(r)},[t]),{build:e}}function os(t){const[e,r]=o.useState([]),[s,i]=o.useState(null),[a,c]=o.useState(null),[f,u]=o.useState(""),[p,m]=o.useState(!1),[g,d]=o.useState(""),x=o.useCallback(E=>{E.type==="agents:listed"&&r(E.sessions),E.type==="session:joined"&&(m(!1),d("Connected")),E.type==="error"&&(m(!1),d(`Error: ${E.message}`))},[]),{send:y,connected:R}=pn(x);o.useEffect(()=>{if(!R)return;y({type:"agents:list"});const E=setInterval(()=>y({type:"agents:list"}),5e3);return()=>clearInterval(E)},[R,y]);const C=o.useRef({sessionId:a,deviceId:f});o.useEffect(()=>{C.current={sessionId:a,deviceId:f}},[a,f]),o.useEffect(()=>()=>{const{sessionId:E,deviceId:M}=C.current;E&&M&&y({type:"device:shutdown",sessionId:E,payload:{deviceId:M}})},[y]);const A=e.filter(E=>E.devices.some(M=>M.platform===t)),j=o.useCallback(E=>{u(E.id),m(!0),d("Booting…"),c(E.sessionId)},[]),P=o.useCallback(()=>u(""),[]),_=o.useCallback(()=>{const{sessionId:E,deviceId:M}=C.current;E&&M&&y({type:"device:shutdown",sessionId:E,payload:{deviceId:M}}),c(null),m(!1),d("")},[y]),L=o.useCallback(()=>{const{sessionId:E,deviceId:M}=C.current;E&&M&&y({type:"device:shutdown",sessionId:E,payload:{deviceId:M}}),c(null),i(null),m(!1),d("")},[y]);return{sessions:e,selectedAgent:s,setSelectedAgent:i,activeSessionId:a,deviceId:f,booting:p,status:g,send:y,connected:R,agentGroups:A,startDevice:j,resetDevice:P,handleBack:_,handleBackToMacs:L}}function as(t,e){const[r,s]=o.useState(""),[i,a]=o.useState(""),[c,f]=o.useState("app-only"),u=(t==null?void 0:t.devices.filter(g=>g.platform===e))??[],p=[...new Set(u.map(g=>g.osVersion).filter(Boolean))].sort((g,d)=>{const x=C=>C.replace(/^[^\d]*/,"").split(".").map(Number),[y,R]=[x(g),x(d)];for(let C=0;C<Math.max(y.length,R.length);C++){const A=(R[C]??0)-(y[C]??0);if(A!==0)return A}return 0}),m=(r?u.filter(g=>g.osVersion===r):u).filter(g=>!i||g.name.toLowerCase().includes(i.toLowerCase()));return{filteredDevices:u,osVersions:p,osVersion:r,setOsVersion:s,deviceSearch:i,setDeviceSearch:a,versionedDevices:m,resetMode:c,setResetMode:f}}function is(){const[t]=un(),e=t.get("perf")==="1",[r,s]=o.useState(e);return o.useEffect(()=>{if(!e){s(!1);return}s(!0);const i=a=>{a.ctrlKey&&a.shiftKey&&a.key==="P"&&s(c=>!c)};return window.addEventListener("keydown",i),()=>window.removeEventListener("keydown",i)},[e]),{perfMode:e,visible:r}}const cs=["video/mp4;codecs=avc1","video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm"];function vn({sessionId:t,buildId:e,onRecordingUploaded:r}){const[s,i]=o.useState("idle"),a=o.useRef(null),c=o.useRef(r);o.useEffect(()=>{c.current=r},[r]);const f=o.useRef(!1),u=o.useRef(null),p=o.useRef([]),m=o.useRef(""),g=o.useRef(0),d=o.useRef(null),x=o.useCallback(()=>{var C;f.current&&((C=d.current)==null||C.call(d),g.current=requestAnimationFrame(x))},[]),y=o.useCallback(C=>{const A=a.current;if(!A)return;const j=A.getContext("2d");j&&(j.fillStyle="#000",j.fillRect(0,0,A.width,A.height));const P=cs.find(L=>MediaRecorder.isTypeSupported(L))??"";if(!P)return;m.current=P,p.current=[];const _=new MediaRecorder(A.captureStream(30),{mimeType:P});_.ondataavailable=L=>{L.data.size>0&&p.current.push(L.data)},u.current=_,_.start(1e3),d.current=C,f.current=!0,g.current=requestAnimationFrame(x),i("recording")},[x]),R=o.useCallback(async()=>{var L;i("uploading"),f.current=!1,cancelAnimationFrame(g.current);const C=u.current;if(!C){i("idle");return}await new Promise(E=>{const M=setTimeout(E,5e3);C.onstop=()=>{clearTimeout(M),E()};try{C.stop()}catch{clearTimeout(M),E()}}),u.current=null;const A=m.current,j=A.includes("mp4")?".mp4":".webm",P=new Blob(p.current,{type:A});p.current=[];const _=new FormData;_.append("file",P,`tapflow-${Date.now()}${j}`);try{const E=new URLSearchParams({sessionId:t});e&&E.set("buildId",String(e));const M=await fetch(`/api/v1/recordings/upload?${E}`,{method:"POST",credentials:"include",body:_}),G=await M.json();if(M.ok&&G.url){const Q=document.createElement("a");Q.href=G.url,Q.download="",Q.click(),(L=c.current)==null||L.call(c),i("done"),setTimeout(()=>i("idle"),2e3)}else i("idle")}catch{i("idle")}},[t,e]);return o.useEffect(()=>{if(s!=="recording")return;const C=()=>{document.visibilityState==="hidden"&&R()};return document.addEventListener("visibilitychange",C),()=>{var A;document.removeEventListener("visibilitychange",C),f.current&&(f.current=!1,cancelAnimationFrame(g.current),(A=u.current)==null||A.stop(),u.current=null)}},[s,R]),{recordState:s,recordCanvasRef:a,startClientRecording:y,stopClientRecording:R}}function wn(){const t=o.useRef(0),[e,r]=o.useState(0);return o.useEffect(()=>{const s=setInterval(()=>{r(t.current),t.current=0},1e3);return()=>clearInterval(s)},[]),{fps:e,frameCount:t}}function Qe({className:t,...e}){return n.jsx("kbd",{"data-slot":"kbd",className:Z("bg-muted text-muted-foreground pointer-events-none inline-flex h-5 w-fit min-w-5 select-none items-center justify-center gap-1 rounded-sm px-1 font-sans text-xs font-medium","[&_svg:not([class*='size-'])]:size-3","[[data-slot=tooltip-content]_&]:bg-background/20 [[data-slot=tooltip-content]_&]:text-background dark:[[data-slot=tooltip-content]_&]:bg-background/10",t),...e})}function Nt({className:t,...e}){return n.jsx("kbd",{"data-slot":"kbd-group",className:Z("inline-flex items-center gap-1",t),...e})}function lt({label:t,keys:e}){return n.jsxs("span",{className:"flex items-center gap-3",children:[t,n.jsx(Nt,{children:e.map(r=>n.jsx(Qe,{children:r},r))})]})}function Sn({joined:t,onScreenshot:e,onRecordToggle:r,recordState:s,onRotate:i,onDeepLink:a,platformSlot:c,launchSlot:f}){return t?n.jsx(Pt,{delayDuration:400,children:n.jsxs("div",{className:"flex flex-col items-center gap-0.5 rounded-2xl border bg-background/90 backdrop-blur-sm px-1.5 py-2.5 shrink-0 mt-3",children:[f,c,n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:a,children:n.jsx(yn,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:n.jsx(lt,{label:"Deeplink",keys:["⌘","K"]})})]}),n.jsx("div",{className:"w-4 h-px bg-border my-1"}),n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:e,children:n.jsx(Tr,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:n.jsx(lt,{label:"Screenshot",keys:["⌘","S"]})})]}),n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:Z("h-8 w-8",s==="recording"&&"text-red-500 hover:text-red-500"),disabled:s==="uploading"||s==="done",onClick:r,children:s==="uploading"?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):s==="recording"?n.jsx(Jr,{className:"h-4 w-4 fill-current"}):n.jsx(Qr,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:s==="idle"?n.jsx(lt,{label:"Start recording",keys:["⌘","⇧","Y"]}):s==="recording"?n.jsx(lt,{label:"Stop recording",keys:["⌘","⇧","Y"]}):"Processing…"})]}),n.jsx("div",{className:"w-4 h-px bg-border my-1"}),n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:i,children:n.jsx(Xr,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:n.jsx(lt,{label:"Rotate",keys:["⌘","⇧","O"]})})]})]})}):null}class Dt{constructor(e){this.bytes=e,this.bitPos=0}get position(){return this.bitPos}bit(){const e=this.bitPos>>3,r=7-(this.bitPos&7);return this.bitPos++,e>=this.bytes.length?0:this.bytes[e]>>r&1}bits(e){let r=0;for(let s=0;s<e;s++)r=r<<1|this.bit();return r>>>0}flag(){return this.bit()===1}ue(){let e=0;for(;this.bit()===0&&e<32;)e++;return e===0?0:(1<<e)-1+this.bits(e)}se(){const e=this.ue();return e&1?Math.ceil(e/2):-Math.ceil(e/2)}}class ls{constructor(){this.bitsArr=[]}bit(e){this.bitsArr.push(e&1)}ue(e){const r=e+1,s=Math.floor(Math.log2(r));for(let i=0;i<s;i++)this.bit(0);for(let i=s;i>=0;i--)this.bit(r>>i&1)}toBytes(){const e=[];for(let r=0;r<this.bitsArr.length;r+=8){let s=0;for(let i=0;i<8;i++)s=s<<1|(this.bitsArr[r+i]??0);e.push(s)}return new Uint8Array(e)}}function Rn(t){const e=[];let r=0;for(let s=1;s<t.length;s++){const i=t[s];if(r>=2&&i===3){r=0;continue}e.push(i),r=i===0?r+1:0}return new Uint8Array(e)}function us(t){const e=[];let r=0;for(const s of t)r>=2&&s<=3&&(e.push(3),r=0),e.push(s),r=s===0?r+1:0;return new Uint8Array(e)}const ds=new Set([100,110,122,244,44,83,86,118,128,138,139,134,135]);function Qt(t){const e=t.ue()+1;t.bits(4),t.bits(4);for(let r=0;r<e;r++)t.ue(),t.ue(),t.flag();t.bits(5),t.bits(5),t.bits(5),t.bits(5)}function jn(t){const e=t.bits(8);t.bits(8);const r=t.bits(8);if(t.ue(),ds.has(e)){const g=t.ue();if(g===3&&t.flag(),t.ue(),t.ue(),t.flag(),t.flag()){const d=g!==3?8:12;for(let x=0;x<d;x++)if(t.flag()){const y=x<6?16:64;let R=8,C=8;for(let A=0;A<y;A++)C!==0&&(C=(R+t.se()+256)%256),R=C===0?R:C}}}t.ue();const s=t.ue();if(s===0)t.ue();else if(s===1){t.flag(),t.se(),t.se();const g=t.ue();for(let d=0;d<g;d++)t.se()}const i=t.ue();t.flag(),t.ue(),t.ue(),t.flag()||t.flag(),t.flag(),t.flag()&&(t.ue(),t.ue(),t.ue(),t.ue());const a={profileIdc:e,levelIdc:r,numRefFrames:i,bitstreamRestriction:!1,maxNumReorderFrames:null,maxDecFrameBuffering:null};if(!t.flag())return{...a,vuiPresent:!1,restrictionFlagPos:-1};t.flag()&&t.bits(8)===255&&(t.bits(16),t.bits(16)),t.flag()&&t.flag(),t.flag()&&(t.bits(3),t.flag(),t.flag()&&(t.bits(8),t.bits(8),t.bits(8))),t.flag()&&(t.ue(),t.ue()),t.flag()&&(t.bits(32),t.bits(32),t.flag());const f=t.flag();f&&Qt(t);const u=t.flag();u&&Qt(t),(f||u)&&t.flag(),t.flag();const p=t.position;return t.flag()?(t.flag(),t.ue(),t.ue(),t.ue(),t.ue(),{...a,vuiPresent:!0,bitstreamRestriction:!0,maxNumReorderFrames:t.ue(),maxDecFrameBuffering:t.ue(),restrictionFlagPos:p}):{...a,vuiPresent:!0,restrictionFlagPos:p}}function fs(t){const e=jn(new Dt(Rn(t)));return{profileIdc:e.profileIdc,levelIdc:e.levelIdc,vuiPresent:e.vuiPresent,bitstreamRestriction:e.bitstreamRestriction,maxNumReorderFrames:e.maxNumReorderFrames,maxDecFrameBuffering:e.maxDecFrameBuffering}}function hs(t){const e=Rn(t),r=jn(new Dt(e));if(!r.vuiPresent||r.restrictionFlagPos<0||r.bitstreamRestriction)return null;const s=new ls,i=new Dt(e);for(let a=0;a<r.restrictionFlagPos;a++)s.bit(i.bit());return s.bit(1),s.bit(1),s.ue(0),s.ue(0),s.ue(0),s.ue(0),s.ue(0),s.ue(r.numRefFrames),s.bit(1),Uint8Array.from([t[0],...us(s.toBytes())])}function ps(t){const e=[],r=t.length;let s=-1,i=0;for(;i+2<r;){const a=i+3<r&&t[i]===0&&t[i+1]===0&&t[i+2]===0&&t[i+3]===1,c=t[i]===0&&t[i+1]===0&&t[i+2]===1;a||c?(s>=0&&e.push(t.subarray(s,i)),i+=a?4:3,s=i):i++}return s>=0&&e.push(t.subarray(s,r)),e}class ms{constructor(e){this.onFrame=e,this.decoder=null,this.sps=null,this.pps=null,this.frameCount=0,this.submitAt=new Map,this.spsLogged=!1}setDecodeSampler(e){this.decodeSampler=e}decode(e){const r=[];let s=!1;for(const p of ps(new Uint8Array(e))){const m=p[0]&31;if(m===7){const g=!this.sps||p.length!==this.sps.length||p.some((d,x)=>d!==this.sps[x]);this.sps=p,g&&this.decoder&&(this.decoder.close(),this.decoder=null)}else m===8?this.pps=p:m>=1&&m<=5&&(m===5&&(s=!0),r.push(p))}if(s&&this.sps&&this.pps&&!this.decoder&&this.initDecoder(this.sps,this.pps),!this.decoder||r.length===0)return;let i=0;for(const p of r)i+=4+p.length;const a=new Uint8Array(i),c=new DataView(a.buffer);let f=0;for(const p of r)c.setUint32(f,p.length,!1),f+=4,a.set(p,f),f+=p.length;const u=Math.round(this.frameCount++*(1e6/30));if(this.decodeSampler&&(this.submitAt.set(u,performance.now()),this.submitAt.size>120)){const p=this.submitAt.keys().next().value;p!==void 0&&this.submitAt.delete(p)}try{this.decoder.decode(new EncodedVideoChunk({type:s?"key":"delta",timestamp:u,data:a}))}catch{}}sampleDecode(e){var s;if(!this.decodeSampler)return;const r=this.submitAt.get(e.timestamp);r!==void 0&&(this.submitAt.delete(e.timestamp),this.decodeSampler({decodeMs:performance.now()-r,queueSize:((s=this.decoder)==null?void 0:s.decodeQueueSize)??0}))}close(){var e;(e=this.decoder)==null||e.close(),this.decoder=null}logSpsVui(e){if(!(this.spsLogged||!this.decodeSampler)){this.spsLogged=!0;try{console.log("[sps-vui]",JSON.stringify(fs(e)))}catch(r){console.warn("[sps-vui] parse failed",r)}}}initDecoder(e,r){this.logSpsVui(e);const s=hs(e)??e,i=s[0]===0?s.subarray(4):s,a=`avc1.${i[1].toString(16).padStart(2,"0")}${i[2].toString(16).padStart(2,"0")}${i[3].toString(16).padStart(2,"0")}`,c=this.buildAVCC(s,r);this.decoder=new VideoDecoder({output:f=>{this.sampleDecode(f),this.onFrame(f)},error:f=>console.error("[WebCodecsCore]",f)}),this.decoder.configure({codec:a,description:c,optimizeForLatency:!0})}buildAVCC(e,r){const s=e[0]===0?e.subarray(4):e,i=r[0]===0?r.subarray(4):r,a=new Uint8Array(8+s.length+1+2+i.length);let c=0;return a[c++]=1,a[c++]=s[1],a[c++]=s[2],a[c++]=s[3],a[c++]=255,a[c++]=225,a[c++]=s.length>>8&255,a[c++]=s.length&255,a.set(s,c),c+=s.length,a[c++]=1,a[c++]=i.length>>8&255,a[c++]=i.length&255,a.set(i,c),a}}const gs=`#version 300 es
|
|
97
|
-
in vec2 a_pos;
|
|
98
|
-
out vec2 v_uv;
|
|
99
|
-
void main() {
|
|
100
|
-
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
101
|
-
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
102
|
-
}`,xs=`#version 300 es
|
|
103
|
-
precision mediump float;
|
|
104
|
-
in vec2 v_uv;
|
|
105
|
-
uniform sampler2D u_tex;
|
|
106
|
-
out vec4 out_color;
|
|
107
|
-
void main() {
|
|
108
|
-
out_color = texture(u_tex, v_uv);
|
|
109
|
-
}`;function bs(t){const e=t.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!e)return null;const r=(m,g)=>{const d=e.createShader(m);return e.shaderSource(d,g),e.compileShader(d),d},s=e.createProgram(),i=r(e.VERTEX_SHADER,gs),a=r(e.FRAGMENT_SHADER,xs);e.attachShader(s,i),e.attachShader(s,a),e.linkProgram(s),e.deleteShader(i),e.deleteShader(a),e.useProgram(s);const c=e.createVertexArray();e.bindVertexArray(c);const f=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);const u=e.getAttribLocation(s,"a_pos");e.enableVertexAttribArray(u),e.vertexAttribPointer(u,2,e.FLOAT,!1,0,0),e.bindVertexArray(null);const p=e.createTexture();return e.activeTexture(e.TEXTURE0),e.bindTexture(e.TEXTURE_2D,p),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MIN_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_MAG_FILTER,e.LINEAR),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_S,e.CLAMP_TO_EDGE),e.texParameteri(e.TEXTURE_2D,e.TEXTURE_WRAP_T,e.CLAMP_TO_EDGE),e.uniform1i(e.getUniformLocation(s,"u_tex"),0),{gl:e,program:s,tex:p,vao:c}}class ys{constructor(e){this.canvas=e,this.state=null}init(){return this.state=bs(this.canvas),this.state!==null}drawFrame(e){const r=this.state;if(!r)return e.close(),null;const s=e.displayWidth,i=e.displayHeight;try{return(this.canvas.width!==s||this.canvas.height!==i)&&(this.canvas.width=s,this.canvas.height=i,r.gl.viewport(0,0,s,i)),r.gl.activeTexture(r.gl.TEXTURE0),r.gl.bindTexture(r.gl.TEXTURE_2D,r.tex),r.gl.texImage2D(r.gl.TEXTURE_2D,0,r.gl.RGBA,r.gl.RGBA,r.gl.UNSIGNED_BYTE,e),r.gl.bindVertexArray(r.vao),r.gl.drawArrays(r.gl.TRIANGLES,0,6),r.gl.bindVertexArray(null),r.gl.bindTexture(r.gl.TEXTURE_2D,null),{width:s,height:i}}finally{e.close()}}dispose(){const e=this.state;e&&(e.gl.deleteTexture(e.tex),e.gl.deleteVertexArray(e.vao),e.gl.deleteProgram(e.program),this.state=null)}}function vs(t){const e=new ys(t);return e.init(),e}class ws{constructor(e=vs){this._size=null,this.canvas=document.createElement("canvas"),this.renderer=e(this.canvas),this.core=new ms(r=>this.render(r))}get surface(){return this.canvas}get size(){return this._size}onResize(e){this.resizeCb=e}onDecodedFrame(e){this.decodedCb=e,this.core.setDecodeSampler(r=>{this.lastSample=r})}decode(e){this.core.decode(e)}close(){this.core.close(),this.renderer.dispose()}render(e){var s,i;const r=this.renderer.drawFrame(e);r&&((s=this.decodedCb)==null||s.call(this,performance.now(),this.lastSample),this.lastSample=void 0,(!this._size||this._size.width!==r.width||this._size.height!==r.height)&&(this._size=r,(i=this.resizeCb)==null||i.call(this,r)))}}const Ss=`#version 300 es
|
|
110
|
-
in vec2 a_pos;
|
|
111
|
-
out vec2 v_uv;
|
|
112
|
-
void main() {
|
|
113
|
-
v_uv = vec2(a_pos.x * 0.5 + 0.5, 0.5 - a_pos.y * 0.5);
|
|
114
|
-
gl_Position = vec4(a_pos, 0.0, 1.0);
|
|
115
|
-
}`,Rs=`#version 300 es
|
|
116
|
-
precision mediump float;
|
|
117
|
-
in vec2 v_uv;
|
|
118
|
-
uniform sampler2D u_texY;
|
|
119
|
-
uniform sampler2D u_texU;
|
|
120
|
-
uniform sampler2D u_texV;
|
|
121
|
-
out vec4 out_color;
|
|
122
|
-
void main() {
|
|
123
|
-
float Y = (texture(u_texY, v_uv).r - 0.0627451) * 1.1643836; // (y-16/255)*255/219
|
|
124
|
-
float U = (texture(u_texU, v_uv).r - 0.5019608) * 1.1383929; // (u-128/255)*255/224
|
|
125
|
-
float V = (texture(u_texV, v_uv).r - 0.5019608) * 1.1383929;
|
|
126
|
-
float r = Y + 1.5748 * V;
|
|
127
|
-
float g = Y - 0.1873 * U - 0.4681 * V;
|
|
128
|
-
float b = Y + 1.8556 * U;
|
|
129
|
-
out_color = vec4(r, g, b, 1.0);
|
|
130
|
-
}`;function Tt(t,e,r,s){const i=t.createTexture();return t.activeTexture(t.TEXTURE0+e),t.bindTexture(t.TEXTURE_2D,i),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MIN_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_MAG_FILTER,t.LINEAR),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_S,t.CLAMP_TO_EDGE),t.texParameteri(t.TEXTURE_2D,t.TEXTURE_WRAP_T,t.CLAMP_TO_EDGE),t.uniform1i(t.getUniformLocation(s,r),e),i}function js(t){const e=t.getContext("webgl2",{alpha:!1,antialias:!1,powerPreference:"high-performance",preserveDrawingBuffer:!0});if(!e)return null;const r=(d,x)=>{const y=e.createShader(d);return e.shaderSource(y,x),e.compileShader(y),y},s=e.createProgram(),i=r(e.VERTEX_SHADER,Ss),a=r(e.FRAGMENT_SHADER,Rs);e.attachShader(s,i),e.attachShader(s,a),e.linkProgram(s),e.deleteShader(i),e.deleteShader(a),e.useProgram(s);const c=e.createVertexArray();e.bindVertexArray(c);const f=e.createBuffer();e.bindBuffer(e.ARRAY_BUFFER,f),e.bufferData(e.ARRAY_BUFFER,new Float32Array([-1,-1,1,-1,-1,1,-1,1,1,-1,1,1]),e.STATIC_DRAW);const u=e.getAttribLocation(s,"a_pos");e.enableVertexAttribArray(u),e.vertexAttribPointer(u,2,e.FLOAT,!1,0,0),e.bindVertexArray(null),e.pixelStorei(e.UNPACK_ALIGNMENT,1);const p=Tt(e,0,"u_texY",s),m=Tt(e,1,"u_texU",s),g=Tt(e,2,"u_texV",s);return{gl:e,program:s,texY:p,texU:m,texV:g,vao:c}}class Cs{constructor(e){this.canvas=e,this.state=null}init(){return this.state=js(this.canvas),this.state!==null}drawI420(e,r,s){const i=this.state;if(!i)return null;const{gl:a}=i,c=r+1>>1,f=s+1>>1,u=r*s,p=c*f,m=e.subarray(0,u),g=e.subarray(u,u+p),d=e.subarray(u+p,u+2*p);(this.canvas.width!==r||this.canvas.height!==s)&&(this.canvas.width=r,this.canvas.height=s,a.viewport(0,0,r,s));const x=(y,R,C,A,j)=>{a.activeTexture(a.TEXTURE0+y),a.bindTexture(a.TEXTURE_2D,R),a.texImage2D(a.TEXTURE_2D,0,a.R8,C,A,0,a.RED,a.UNSIGNED_BYTE,j)};return x(0,i.texY,r,s,m),x(1,i.texU,c,f,g),x(2,i.texV,c,f,d),a.bindVertexArray(i.vao),a.drawArrays(a.TRIANGLES,0,6),a.bindVertexArray(null),{width:r,height:s}}dispose(){const e=this.state;e&&(e.gl.deleteTexture(e.texY),e.gl.deleteTexture(e.texU),e.gl.deleteTexture(e.texV),e.gl.deleteVertexArray(e.vao),e.gl.deleteProgram(e.program),this.state=null)}}const ks=0;function Es(t){const e=new Cs(t);return e.init(),e}function Ts(){return new Worker(new URL("/assets/tinyh264.worker-DiJ50Hai.js",import.meta.url),{type:"module"})}class _s{constructor(e=Es,r=Ts){this.ready=!1,this.pending=[],this._size=null,this.canvas=document.createElement("canvas"),this.renderer=e(this.canvas),this.worker=r(),this.worker.onmessage=s=>this.onMessage(s.data)}get surface(){return this.canvas}get size(){return this._size}onResize(e){this.resizeCb=e}onDecodedFrame(e){this.decodedCb=e}decode(e){if(!this.ready){this.pending.push(e);return}this.post(e)}close(){this.worker.terminate(),this.renderer.dispose()}post(e){this.worker.postMessage({type:"decode",data:e,offset:0,length:e.byteLength,renderStateId:ks},[e])}onMessage(e){var s,i;if(e.type==="decoderReady"){this.ready=!0;for(const a of this.pending)this.post(a);this.pending.length=0;return}const r=this.renderer.drawI420(new Uint8Array(e.data),e.width,e.height);r&&((s=this.decodedCb)==null||s.call(this,performance.now()),(!this._size||this._size.width!==r.width||this._size.height!==r.height)&&(this._size=r,(i=this.resizeCb)==null||i.call(this,r)))}}function Ut(){const t=typeof window<"u";let e=!1;try{e=!!document.createElement("canvas").getContext("webgl2")}catch{e=!1}return{secureContext:t&&window.isSecureContext===!0,webCodecs:t&&"VideoDecoder"in window,webgl2:e,wasm:typeof WebAssembly<"u"&&typeof Worker<"u"}}function As(t=Ut()){return t.secureContext&&t.webCodecs&&t.webgl2?new ws:t.wasm&&t.webgl2?new _s:null}function Ps(t=Ut()){return t.secureContext&&t.webCodecs&&t.webgl2||t.wasm&&t.webgl2}function Ns(t=Ut()){return t.secureContext&&t.webCodecs&&t.webgl2?"high":t.wasm&&t.webgl2?"standard":"unsupported"}const en="tapflow.perfModeNoticeDismissed",Ds="https://www.tapflow.dev/reference/configuration#https-secure-context";function Ls(t,e){return t==="standard"&&!e}function Ms({open:t,onOpenChange:e}){return n.jsx(mn,{open:t,onOpenChange:e,children:n.jsxs(gn,{className:"sm:max-w-[440px]",children:[n.jsxs(pr,{children:[n.jsx(xn,{children:"Streaming in Standard mode"}),n.jsxs(mr,{className:"space-y-3 pt-1",children:[n.jsx("span",{className:"block",children:"This screen is running in Standard mode. For a faster, smoother picture, switch to Smooth."}),n.jsx("span",{className:"block",children:"Smooth needs the relay served over HTTPS. If you didn't set up tapflow, ask whoever did."})]})]}),n.jsxs(gr,{children:[n.jsx(ae,{variant:"outline",onClick:()=>window.open(Ds,"_blank","noopener,noreferrer"),children:"How to enable"}),n.jsx(ae,{onClick:()=>e(!1),children:"Got it"})]})]})})}const Is={high:"Smooth",standard:"Standard",unsupported:null};function Us(t){const{connected:e,joined:r,bootError:s,deviceReady:i,installing:a,installError:c}=t;return e?r?s?`Boot failed: ${s.length>40?s.slice(0,40)+"…":s}`:i?a?"Installing app…":c?`Install failed: ${c}`:null:"Starting device…":"Joining session…":"Connecting…"}function Ht(t){const{joined:e,fps:r,keyboardActive:s}=t,i=Us(t),a=r>15,c=a?"#10b981":"#94a3b8",f=a?"Active":"Idle",u=o.useMemo(()=>Ns(),[]),p=Is[u],[m,g]=o.useState(!1);o.useEffect(()=>{let x=!1;try{x=localStorage.getItem(en)==="1"}catch{}Ls(u,x)&&g(!0)},[u]);const d=x=>{if(g(x),!x)try{localStorage.setItem(en,"1")}catch{}};return n.jsxs("div",{className:"w-[300px] shrink-0 mt-3 rounded-xl border bg-background px-4 py-4 flex flex-col gap-3",children:[n.jsxs("div",{className:Z("flex items-center",s?"text-emerald-500":"text-muted-foreground"),style:{gap:6},children:[n.jsx(Gr,{className:"h-3.5 w-3.5 shrink-0"}),n.jsx("span",{className:"text-[12px] font-medium",children:"Focus"})]}),e&&n.jsxs("div",{className:"flex items-center gap-[12px]",children:[n.jsxs("div",{className:"flex items-center gap-[4px]",children:[n.jsx("span",{className:"h-2 w-2 rounded-full shrink-0 mr-1",style:{background:c}}),n.jsx("span",{className:"text-[12px] font-mono text-foreground/75",children:r}),n.jsx("span",{className:"text-[12px] text-muted-foreground",children:"fps"}),n.jsx("span",{className:"text-[11px] text-muted-foreground/60",children:"·"}),n.jsx("span",{className:Z("text-[11px]",a?"text-emerald-500":"text-muted-foreground/60"),children:f})]}),p&&n.jsxs(n.Fragment,{children:[n.jsx(dn,{orientation:"vertical",className:"h-3"}),u==="standard"?n.jsx("button",{type:"button",onClick:()=>g(!0),className:"text-[11px] text-foreground/70 hover:text-foreground underline-offset-2 hover:underline",children:p}):n.jsx("span",{className:"text-[11px] text-muted-foreground",children:p})]})]}),i&&n.jsx("p",{className:"text-[12px] text-muted-foreground leading-relaxed break-all",children:i}),n.jsx(Ms,{open:m,onOpenChange:d})]})}function Cn({open:t,onOpenChange:e,sessionId:r,send:s}){const[i,a]=o.useState(""),c=o.useRef(null);o.useEffect(()=>{t?setTimeout(()=>{var u;return(u=c.current)==null?void 0:u.focus()},0):a("")},[t]);const f=()=>{i.trim()&&(s({type:"open-url",sessionId:r,payload:{url:i.trim()}}),e(!1))};return n.jsx(mn,{open:t,onOpenChange:e,children:n.jsxs(gn,{className:"w-[500px] max-w-[500px] h-[52px] !rounded-[18px] p-[10px] border border-border bg-background shadow-lg overflow-hidden [&>button]:hidden","aria-describedby":void 0,children:[n.jsx(xn,{className:"sr-only",children:"Open Deeplink"}),n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsxs("div",{className:"flex-1 h-[32px] flex items-center gap-2 pl-[4px] pb-[1px]",children:[n.jsx(lr,{className:"h-4 w-4 text-muted-foreground shrink-0"}),n.jsx("input",{ref:c,className:"flex-1 bg-transparent text-sm outline-none placeholder:text-muted-foreground min-w-0",placeholder:"myapp://home...",value:i,onChange:u=>a(u.target.value),onKeyDown:u=>{u.key==="Enter"&&f()}})]}),n.jsx(ae,{size:"sm",disabled:!i.trim(),onClick:f,className:"shrink-0 rounded-xl h-8 px-4",children:"Open"})]})]})})}function Hs(t,e,r,s,i,a){const{x:c,y:f,width:u,height:p}=i;let m,g;if(a){const d=(t.x-e.left)/e.width;m=(1-(t.y-e.top)/e.height)*r,g=d*s}else m=(t.x-e.left)*(r/e.width),g=(t.y-e.top)*(s/e.height);return m<c||m>c+u||g<f||g>f+p?null:{x:(m-c)/u,y:(g-f)/p}}function Fs(t,e,r){const s=(t.x-e.left)/e.width,i=(t.y-e.top)/e.height;return s<0||s>1||i<0||i>1?null:r?{x:i,y:1-s}:{x:s,y:i}}function kn(t){return{f0:{x:1-t.x,y:1-t.y},f1:t}}function Bs(t,e){return t>0?Math.min(1,e/t):1}const Lt=22,tn=[84,70,70,69],$s=1,Os=0,jt=1,En=2,zs=1,Ws=2,Vs=4;function Ks(t){if(t.byteLength<Lt)return null;const e=new DataView(t);for(let i=0;i<tn.length;i++)if(e.getUint8(i)!==tn[i])return null;if(e.getUint8(4)!==$s)return null;const r=e.getUint8(5),s=r&Vs?En:r&zs?jt:Os;return{capturedAt:Number(e.getBigUint64(6)),relayedAt:Number(e.getBigUint64(14)),codec:s,keyframe:s===jt&&(r&Ws)!==0}}function Tn(t){const{binaryFrameHandlerRef:e,perfHookRef:r,frameCount:s}=t,i=o.useRef(t);i.current=t,o.useEffect(()=>{let a=null,c=!1,f=!1,u;const p=()=>{if(a)return a;if(c)return null;const m=As();return m?(a=m,m.onResize(g=>i.current.onResize(g)),u=i.current.onDecoderReady(m),m):(c=!0,i.current.onUnsupported(),console.warn("[decoder] none available — set up HTTPS or use a supported browser"),null)};return e.current=(m,g)=>{const d=i.current.onJpegFrame;if(d&&(g==null?void 0:g.codec)!==jt){d(m,g);return}const x=p();if(x){if(!f){if(!(g!=null&&g.keyframe))return;f=!0}x.decode(m),s.current+=1}},()=>{e.current=void 0,typeof u=="function"&&u(),a==null||a.close(),a==null||a.surface.remove(),a=null}},[e,r,s])}const Xs=3e3+5*300,Ys=Xs+500,bt=8;function Gs(){var t;return window.isSecureContext&&typeof ClipboardItem<"u"&&!!((t=navigator.clipboard)!=null&&t.write)}class yt extends Error{}function qs(t){const e=t.then(r=>new Blob([r],{type:"text/plain"}));return navigator.clipboard.write([new ClipboardItem({"text/plain":e})])}function Js(){const t=new Uint8Array(16);return crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}function Ft(t){return!(t.metaKey||t.ctrlKey)||t.altKey?!1:t.code==="KeyV"?!0:!t.shiftKey&&(t.code==="KeyC"||t.code==="KeyX")}const Zs=1024*1024,Qs=t=>new TextEncoder().encode(t).length,eo=t=>{var e;return!!((e=t.payload)!=null&&e.unsupported)},to=t=>{const e=t.payload;return(e==null?void 0:e.sentinelParked)===!1||(e==null?void 0:e.unsupported)===!0};function no(){const t=window.getSelection();return!!t&&!t.isCollapsed&&t.toString().length>0}function nn(){const t=document.activeElement;return!!t&&(t.tagName==="INPUT"||t.tagName==="TEXTAREA"||t.isContentEditable)}function _n({sessionId:t,send:e,active:r,supported:s,handlerRef:i,sendChord:a,onError:c}){const f=o.useRef(new Map),u=o.useRef(null),p=o.useRef(c);o.useLayoutEffect(()=>{p.current=c});const m=o.useCallback(d=>{var x;u.current!==d&&(u.current=d,(x=p.current)==null||x.call(p,d))},[]);o.useEffect(()=>(i.current=d=>{if(!d.requestId)return;const x=f.current.get(d.requestId);x&&(f.current.delete(d.requestId),x(d))},()=>{i.current=void 0}),[i]);const g=o.useCallback((d,x)=>{const y=Js();return new Promise(R=>{const C=setTimeout(()=>{f.current.delete(y),R(null)},Ys);f.current.set(y,A=>{clearTimeout(C),R(A)}),e({type:d,sessionId:t,requestId:y,payload:x})})},[e,t]);o.useEffect(()=>{if(!r||!s)return;const d=async y=>{if(y.code==="KeyV"||!Ft(y))return;const R=y.code==="KeyX";if(nn()||no()||(y.preventDefault(),y.repeat))return;if(!Gs()){a(R?"KeyX":"KeyC",bt),m("Copied on the device. Serving the dashboard over HTTPS also brings it to your clipboard.");return}let C,A;const j=new Promise((E,M)=>{C=E,A=M});j.catch(()=>{});const P=qs(j).catch(E=>{E instanceof yt||m(E instanceof Error&&E.name==="NotAllowedError"?"Your browser blocked the clipboard write":"Could not write to your clipboard")}),_=await g("clipboard:read",{press:R?"cut":"copy"});if(!_){A(new yt("timeout")),m("The device is taking too long — try again");return}if(_.type==="clipboard:error"){A(new yt(_.message??"read failed")),m(_.message??"Clipboard read failed"),to(_)&&a(R?"KeyX":"KeyC",bt);return}const{text:L}=_.payload??{};if(u.current=null,!L){A(new yt("empty"));return}C(L),await P},x=y=>{var C;if(nn())return;const R=((C=y.clipboardData)==null?void 0:C.getData("text"))??"";if(y.preventDefault(),!R){a("KeyV",bt);return}if(Qs(R)>Zs){m("That text is too large to send to the device");return}g("clipboard:write",{text:R,pasteAfter:!0}).then(A=>{if((A==null?void 0:A.type)==="clipboard:write-done"){u.current=null;return}if(!A){m("The device is taking too long — try again");return}m(A.message??"Clipboard write failed"),eo(A)&&a("KeyV",bt)})};return document.addEventListener("keydown",d),document.addEventListener("paste",x),()=>{document.removeEventListener("keydown",d),document.removeEventListener("paste",x)}},[r,s,g,a,m])}const Ae=13,Je=8,rn=16,ro=.02,so=100;function oo({sessionId:t,buildId:e,send:r,connected:s,joined:i,deviceReady:a,installing:c,installed:f,installError:u,bootError:p,launching:m,setLaunching:g,chrome:d,binaryFrameHandlerRef:x,clipboardHandlerRef:y,clipboardSupported:R,onRecordingUploaded:C,swKeyboardVisible:A,swKeyboardPending:j,onKbdToggle:P,perfHookRef:_}){const L=o.useRef(null),E=o.useRef(null),M=o.useRef(null),{fps:G,frameCount:Q}=wn(),$=o.useRef(0),{recordState:W,recordCanvasRef:Y,startClientRecording:Re,stopClientRecording:ce}=vn({sessionId:t,buildId:e,onRecordingUploaded:C}),le=o.useRef(0),[he,xe]=o.useState(!1),[F,X]=o.useState(!1),[z,pe]=o.useState(!1),[se,oe]=o.useState(!1),[Ie,q]=o.useState(null),[Te,H]=o.useState(null),[V,ne]=o.useState(!1),[ee,re]=o.useState(null),be=o.useRef(ee);o.useEffect(()=>{be.current=ee},[ee]);const ue=o.useRef(null),me=o.useRef(null),de=o.useRef(!1),fe=o.useRef(!1),ye=o.useRef(0),ie=o.useRef(null),ve=o.useRef(null),_e=o.useRef("idle"),Pe=o.useRef(null),We=o.useRef(null),Ue=o.useRef(null);o.useEffect(()=>{Ue.current=d},[d]),o.useEffect(()=>{const l=new Image;l.onload=()=>{We.current=l},l.src=`data:image/png;base64,${d.framePng}`},[d.framePng]),Tn({binaryFrameHandlerRef:x,perfHookRef:_,frameCount:Q,onUnsupported:()=>{},onResize:l=>{const b=L.current;if(b&&(b.width!==l.width||b.height!==l.height)&&(b.width=l.width,b.height=l.height,!Ue.current)){const h=Y.current;h&&(h.width=l.width,h.height=l.height)}X(!0)},onDecoderReady:l=>{var w;const b=l.surface,h=L.current;b.style.position="absolute",h&&(b.style.left=h.style.left,b.style.top=h.style.top,b.style.width=h.style.width,b.style.height=h.style.height,b.style.borderRadius=h.style.borderRadius),b.style.objectFit="fill",b.style.zIndex="3",b.style.pointerEvents="none",(w=E.current)==null||w.appendChild(b);let k=null;const T=()=>{const D=L.current,I=D==null?void 0:D.getContext("2d");if(D&&I&&l.size)try{I.drawImage(l.surface,0,0,D.width,D.height)}catch{}k=requestAnimationFrame(T)};return k=requestAnimationFrame(T),()=>{k!==null&&cancelAnimationFrame(k)}},onJpegFrame:l=>{const b=performance.now();$.current&&b-$.current,$.current=b;const h=le.current;createImageBitmap(new Blob([l],{type:"image/jpeg"})).then(k=>{if(performance.now()-b,le.current!==h){k.close();return}const T=L.current,w=T==null?void 0:T.getContext("2d");if(!T||!w){k.close();return}if((T.width!==k.width||T.height!==k.height)&&(T.width=k.width,T.height=k.height,!Ue.current)){const I=Y.current;I&&(I.width=k.width,I.height=k.height)}const D=performance.now();w.drawImage(k,0,0),performance.now()-D,k.close(),X(!0),Q.current+=1}).catch(()=>{})}}),o.useEffect(()=>{const l=Y.current,b=E.current;l&&b&&(l.width=b.clientWidth,l.height=b.clientHeight)},[d]);const at=o.useCallback(()=>{const l=Y.current,b=L.current;if(!l||!b)return;const h=l.getContext("2d");if(!h)return;const k=Ue.current;if(h.clearRect(0,0,l.width,l.height),k){We.current&&h.drawImage(We.current,0,0,l.width,l.height);const D=Math.round(k.screenCornerRadius/2*(l.height/(k.compositeHeight/2)));h.save(),h.beginPath(),D>0?h.roundRect(b.offsetLeft,b.offsetTop,b.clientWidth,b.clientHeight,D):h.rect(b.offsetLeft,b.offsetTop,b.clientWidth,b.clientHeight),h.clip(),h.drawImage(b,b.offsetLeft,b.offsetTop,b.clientWidth,b.clientHeight),h.restore()}else h.drawImage(b,0,0,l.width,l.height);const T=be.current;if(T)for(const D of[T.f0,T.f1]){const I=k?b.offsetLeft+D.x*b.clientWidth:D.x*l.width,K=k?b.offsetTop+D.y*b.clientHeight:D.y*l.height;de.current?(h.beginPath(),h.arc(I,K,Je,0,Math.PI*2),h.fillStyle="rgba(255,255,255,0.92)",h.fill(),h.strokeStyle="rgba(0,0,0,0.2)",h.lineWidth=1,h.stroke()):(h.beginPath(),h.arc(I,K,Ae,0,Math.PI*2),h.strokeStyle="rgba(0,0,0,0.3)",h.lineWidth=3,h.stroke(),h.beginPath(),h.arc(I,K,Ae,0,Math.PI*2),h.strokeStyle="rgba(255,255,255,0.65)",h.lineWidth=1.5,h.stroke())}const w=ve.current;if(w){const D=_e.current,I=Pe.current;if(h.save(),D==="down")h.beginPath(),h.arc(w.x,w.y,Je,0,Math.PI*2),h.fillStyle="rgba(255,255,255,0.92)",h.fill(),h.strokeStyle="rgba(0,0,0,0.2)",h.lineWidth=1,h.stroke();else if(D==="release"&&I){const K=Math.min((performance.now()-I.startTime)/350,1);h.beginPath(),h.arc(w.x,w.y,Je+26*K,0,Math.PI*2),h.strokeStyle=`rgba(255,255,255,${(1-K)*.55})`,h.lineWidth=1.5,h.stroke(),K>=1&&(_e.current="idle",Pe.current=null)}else h.beginPath(),h.arc(w.x,w.y,Ae,0,Math.PI*2),h.strokeStyle="rgba(0,0,0,0.3)",h.lineWidth=3,h.stroke(),h.beginPath(),h.arc(w.x,w.y,Ae,0,Math.PI*2),h.strokeStyle="rgba(255,255,255,0.65)",h.lineWidth=1.5,h.stroke();h.restore()}},[]),it=o.useCallback(()=>{const l=L.current;if(!l)return;const b=document.createElement("canvas"),h=b.getContext("2d");h&&(b.width=l.width,b.height=l.height,h.drawImage(l,0,0),b.toBlob(k=>{if(!k)return;const T=URL.createObjectURL(k),w=document.createElement("a");w.href=T,w.download=`tapflow-${Date.now()}.png`,w.click(),URL.revokeObjectURL(T)},"image/png"))},[]),Ve=o.useCallback(()=>{if(W==="idle"){const l=Y.current;if(!l)return;const b=E.current;if(b&&b.clientWidth>0)l.width=b.clientWidth,l.height=b.clientHeight;else{const h=L.current;if(h&&h.width>0)l.width=h.width,l.height=h.height;else return}Re(at)}else W==="recording"&&ce()},[W,Re,ce,at]),je=o.useCallback(()=>{r({type:"input:rotate",sessionId:t}),pe(l=>!l)},[r,t]),He=o.useRef(z);o.useEffect(()=>{He.current=z},[z]),o.useEffect(()=>()=>{He.current&&r({type:"input:rotate",sessionId:t})},[]);const kt=o.useCallback((l,b)=>{r({type:"input:key",sessionId:t,payload:{code:l,modifiers:b}})},[r,t]);_n({sessionId:t,send:r,active:se,supported:R,handlerRef:y,sendChord:kt,onError:l=>tt.error(l)}),o.useEffect(()=>{const l=new Set(["ShiftLeft","ShiftRight","ControlLeft","ControlRight","MetaLeft","MetaRight"]),b=w=>{if(w.code==="AltLeft"||w.code==="AltRight"){fe.current=!0;return}if(w.metaKey){const I=document.activeElement;if(!I||I.tagName!=="INPUT"&&I.tagName!=="TEXTAREA"){if(!w.shiftKey&&w.code==="KeyK"){w.preventDefault(),xe(!0);return}if(!w.shiftKey&&w.code==="KeyS"){w.preventDefault(),it();return}if(w.shiftKey&&w.code==="KeyY"){w.preventDefault(),Ve();return}if(w.shiftKey&&w.code==="KeyO"){w.preventDefault(),je();return}if(w.shiftKey&&w.code==="KeyU"){w.preventDefault(),r({type:"input:button",sessionId:t,payload:{name:"home"}});return}if(w.shiftKey&&w.code==="KeyK"){w.preventDefault(),j||P();return}}}if(!se||l.has(w.code)||R&&Ft(w))return;w.preventDefault();const D=(w.shiftKey?2:0)|(w.ctrlKey?1:0)|(w.metaKey?8:0);r({type:"input:key",sessionId:t,payload:{code:w.code,modifiers:D}})},h=()=>{de.current&&(de.current=!1,ne(!1),r({type:"input:pinch:end",sessionId:t})),fe.current=!1,re(null)},k=w=>{(w.code==="AltLeft"||w.code==="AltRight")&&h()},T=()=>{fe.current&&h()};return window.addEventListener("keydown",b),window.addEventListener("keyup",k),window.addEventListener("blur",T),()=>{window.removeEventListener("keydown",b),window.removeEventListener("keyup",k),window.removeEventListener("blur",T)}},[se,R,r,t,it,Ve,je,P,j]),o.useEffect(()=>{if(!se)return;const l=b=>{const h=E.current??L.current;h&&!h.contains(b.target)&&oe(!1)};return document.addEventListener("pointerdown",l),()=>document.removeEventListener("pointerdown",l)},[se]);const Ne=o.useCallback(l=>{const b=(z?M.current:null)??E.current;if(!b)return null;const h=b.getBoundingClientRect(),k=d.compositeWidth/2,T=d.compositeHeight/2,w=d.screenRect.x/2,D=d.screenRect.y/2,I=d.screenRect.width/2,K=d.screenRect.height/2;return Hs({x:l.clientX,y:l.clientY},h,k,T,{x:w,y:D,width:I,height:K},z)},[d,z]),Ke=o.useCallback(l=>{const b=Ne(l);return b?kn(b):null},[Ne]),rt=o.useCallback(l=>{const b=z?M.current:E.current;if(!b)return null;const h=b.getBoundingClientRect();let k,T;if(z){const D=h.height-(l.clientY-h.top),I=l.clientX-h.left;k=D*(d.compositeWidth/h.height),T=I*(d.compositeHeight/h.width)}else k=(l.clientX-h.left)*(d.compositeWidth/h.width),T=(l.clientY-h.top)*(d.compositeHeight/h.height);const w=d.screenRect;if(k>=w.x&&k<=w.x+w.width&&T>=w.y&&T<=w.y+w.height)return null;for(const D of d.buttons){const I=k-D.normalOffset.x,K=T-D.normalOffset.y;if(I*I+K*K<so**2)return D.name}return null},[d,z]),Xe=o.useCallback(l=>{const b=L.current,h=Y.current;return b&&b.clientWidth>0?{x:b.offsetLeft+l.x*b.clientWidth,y:b.offsetTop+l.y*b.clientHeight}:{x:l.x*((h==null?void 0:h.width)??1),y:l.y*((h==null?void 0:h.height)??1)}},[]),we=o.useCallback(l=>{if(oe(!0),fe.current){const w=Ke(l);if(!w)return;de.current=!0,ne(!0),l.target.setPointerCapture(l.pointerId),re(w),r({type:"input:pinch:start",sessionId:t,payload:w});return}const b=rt(l);if(b){ue.current=b,q(b),l.target.setPointerCapture(l.pointerId),r({type:"input:button",sessionId:t,payload:{name:b,phase:"down"}});return}const h=Ne(l);if(!h)return;me.current=h,l.target.setPointerCapture(l.pointerId),ve.current=Xe(h),_e.current="down",Pe.current=null;const k=l.currentTarget.getBoundingClientRect(),T=ie.current;T&&(T.style.display="block",T.style.left=`${l.clientX-k.left}px`,T.style.top=`${l.clientY-k.top}px`,T.style.width=`${Je*2}px`,T.style.height=`${Je*2}px`,T.style.background="rgba(255,255,255,0.92)",T.style.border="1.5px solid rgba(0,0,0,0.2)",T.style.boxShadow="0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"),r({type:"input:touch:start",sessionId:t,payload:h})},[rt,Ne,Ke,Xe,r,t]),mt=o.useCallback(l=>{if(l.buttons===0){if(H(rt(l)),fe.current){re(Ke(l)),ve.current=null;const D=ie.current;D&&(D.style.display="none")}else{re(null);const D=Ne(l);ve.current=D?Xe(D):null,_e.current!=="down"&&(_e.current="idle");const I=ie.current;if(I)if(D){const K=l.currentTarget.getBoundingClientRect();I.style.display="block",I.style.left=`${l.clientX-K.left}px`,I.style.top=`${l.clientY-K.top}px`,I.style.width=`${Ae*2}px`,I.style.height=`${Ae*2}px`,I.style.background="transparent",I.style.border="1.5px solid rgba(255,255,255,0.6)",I.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"}else I.style.display="none"}return}if(de.current){const D=Ke(l);if(!D)return;const I=performance.now();if(I-ye.current<rn)return;ye.current=I,re(D),r({type:"input:pinch:move",sessionId:t,payload:D});return}if(ue.current||!me.current)return;const b=Ne(l);if(!b)return;const h=b.x-me.current.x,k=b.y-me.current.y;if(Math.sqrt(h*h+k*k)<ro)return;const T=performance.now();if(T-ye.current<rn)return;ye.current=T,ve.current=Xe(b);const w=ie.current;if(w&&w.style.display!=="none"){const D=l.currentTarget.getBoundingClientRect();w.style.left=`${l.clientX-D.left}px`,w.style.top=`${l.clientY-D.top}px`}r({type:"input:touch:move",sessionId:t,payload:b})},[rt,Ne,Ke,Xe,r,t]),Fe=o.useCallback(()=>{if(de.current){de.current=!1,ne(!1),re(null),r({type:"input:pinch:end",sessionId:t});return}if(me.current=null,ue.current){r({type:"input:button",sessionId:t,payload:{name:ue.current,phase:"up"}}),ue.current=null,setTimeout(()=>q(null),100);return}_e.current="release",Pe.current={startTime:performance.now()};const l=ie.current;l&&(l.style.width=`${Ae*2}px`,l.style.height=`${Ae*2}px`,l.style.background="transparent",l.style.border="1.5px solid rgba(255,255,255,0.6)",l.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"),r({type:"input:touch:end",sessionId:t})},[r,t]),Ye=o.useCallback(()=>{if(de.current){de.current=!1,ne(!1),re(null),r({type:"input:pinch:end",sessionId:t});return}if(me.current=null,ue.current){r({type:"input:button",sessionId:t,payload:{name:ue.current,phase:"up"}}),ue.current=null,q(null);return}_e.current="release",Pe.current={startTime:performance.now()},r({type:"input:touch:end",sessionId:t})},[r,t]),Et=o.useCallback(()=>{H(null),re(null),ve.current=null;const l=ie.current;l&&(l.style.display="none")},[]),Be=d.compositeWidth/2,gt=d.compositeHeight/2,st=Bs(gt,750),Ge=Math.round(Be*st),qe=Math.round(gt*st),ot=d.screenRect.x/d.compositeWidth*100,v=d.screenRect.y/d.compositeHeight*100,N=d.screenRect.width/d.compositeWidth*100,O=d.screenRect.height/d.compositeHeight*100,S=Math.round(d.screenCornerRadius/2*st),J=n.jsxs(n.Fragment,{children:[n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>r({type:"input:button",sessionId:t,payload:{name:"home"}}),children:n.jsx(bn,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:n.jsxs("span",{className:"flex items-center gap-3",children:["Home ",n.jsxs(Nt,{children:[n.jsx(Qe,{children:"⌘"}),n.jsx(Qe,{children:"⇧"}),n.jsx(Qe,{children:"U"})]})]})})]}),n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:j,onClick:P,"data-active":A,children:j?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):n.jsx(Fr,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:n.jsxs("span",{className:"flex items-center gap-3",children:["Software keyboard ",n.jsxs(Nt,{children:[n.jsx(Qe,{children:"⌘"}),n.jsx(Qe,{children:"⇧"}),n.jsx(Qe,{children:"K"})]})]})})]})]}),U=f&&e?n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:m,onClick:()=>{g(!0),r({type:"app:launch",sessionId:t,buildId:e})},children:m?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):n.jsx(hn,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:m?"Launching…":"Launch app"})]}):null;return n.jsxs("div",{className:"flex items-start justify-center gap-16",children:[n.jsx("canvas",{ref:Y,style:{display:"none"}}),n.jsx(Cn,{open:he,onOpenChange:xe,sessionId:t,send:r}),n.jsx(Sn,{joined:i,onDeepLink:()=>xe(!0),onScreenshot:it,onRecordToggle:Ve,recordState:W,onRotate:je,platformSlot:J,launchSlot:U}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsxs("div",{ref:M,style:{width:z?qe:Ge,height:z?Ge:qe,position:"relative",flexShrink:0},children:[n.jsxs("div",{ref:E,className:`relative ${Te?"cursor-pointer":"cursor-default"}`,style:{width:Ge,height:qe,...z?{position:"absolute",top:(Ge-qe)/2,left:(qe-Ge)/2,transform:"rotate(-90deg)",transformOrigin:"center center"}:{}},onPointerDown:we,onPointerMove:mt,onPointerUp:Fe,onPointerCancel:Ye,onPointerLeave:Et,children:[n.jsx("img",{src:`data:image/png;base64,${d.framePng}`,style:{position:"absolute",top:0,left:0,zIndex:2,width:"100%",height:"100%",display:"block",pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),n.jsx("canvas",{ref:L,style:{position:"absolute",zIndex:3,left:`${ot}%`,top:`${v}%`,width:`${N}%`,height:`${O}%`,borderRadius:S>0?`${S}px`:void 0,backgroundColor:"#010101",cursor:"none",visibility:F?"visible":"hidden"}}),!F&&n.jsx("div",{className:"absolute animate-pulse bg-zinc-700",style:{zIndex:3,left:`${ot}%`,top:`${v}%`,width:`${N}%`,height:`${O}%`,borderRadius:S>0?`${S}px`:void 0}}),ee&&(()=>{const l=ot/100,b=v/100,h=N/100,k=O/100,T=(w,D)=>({left:`${(l+w*h)*100}%`,top:`${(b+D*k)*100}%`});return n.jsx(n.Fragment,{children:[ee.f0,ee.f1].map((w,D)=>n.jsx("div",{style:{position:"absolute",zIndex:10,borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",transition:"width 0.1s ease, height 0.1s ease, background 0.1s ease",...V?{width:Je*2,height:Je*2,background:"rgba(255,255,255,0.92)",border:"1.5px solid rgba(0,0,0,0.2)",boxShadow:"0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"}:{width:Ae*2,height:Ae*2,background:"transparent",border:"1.5px solid rgba(255,255,255,0.6)",boxShadow:"0 0 0 1px rgba(0,0,0,0.3)"},...T(w.x,w.y)}},D))})})(),i&&G===0&&n.jsx("div",{style:{position:"absolute",zIndex:8,left:`${ot}%`,top:`${v}%`,width:`${N}%`,height:`${O}%`,display:"flex",alignItems:"center",justifyContent:"center",pointerEvents:"none"},children:n.jsx("span",{style:{color:"white",fontSize:"0.875rem"},children:"Waiting for first frame..."})}),d.buttons.map(l=>{const b=Ie===l.name,h=Te===l.name,k=l.anchor==="bottom",T=l.anchor==="top",w=k?(l.normalOffset.y-l.buttonH/2)/d.compositeHeight*100:T?l.rolloverOffset.y/d.compositeHeight*100:(l.normalOffset.y-l.buttonH/2)/d.compositeHeight*100,D=l.buttonH/d.compositeHeight*100,I=l.buttonW/d.compositeWidth*100,K=l.buttonW/2,ge=(l.rolloverOffset.x-K)/d.compositeWidth*100,De=(2*l.rolloverOffset.x-l.normalOffset.x-K)/d.compositeWidth*100,xt=l.rolloverOffset.x/d.compositeWidth*100,ct=k?(l.normalOffset.y-l.buttonH/2)/d.compositeHeight*100:T?l.rolloverOffset.y/d.compositeHeight*100:(l.normalOffset.y-l.buttonH/2)/d.compositeHeight*100,Yt=T?(2*l.rolloverOffset.y-l.normalOffset.y)/d.compositeHeight*100:0,qn=l.onTop?4:1;return n.jsxs(o.Fragment,{children:[l.buttonPng&&n.jsx("img",{src:`data:image/png;base64,${l.buttonPng}`,style:{position:"absolute",zIndex:qn,top:`${T&&h?Yt:w}%`,left:`${T?ge:h?De:ge}%`,width:`${I}%`,height:`${D}%`,transition:T?"top 0.15s ease":"left 0.15s ease",pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),b&&l.pressedPng&&l.pressedRect&&n.jsx("img",{src:`data:image/png;base64,${l.pressedPng}`,style:{position:"absolute",zIndex:l.onTop?3:1,left:`${T?ge:h?De:ge}%`,top:`${T&&h?Yt:w}%`,width:`${l.pressedRect.width/d.compositeWidth*100}%`,height:`${l.pressedRect.height/d.compositeHeight*100}%`,pointerEvents:"none",userSelect:"none"},draggable:!1,alt:""}),h&&n.jsx("div",{className:"bg-foreground/85 text-background text-[11px] px-[7px] py-1.5 rounded-lg whitespace-nowrap pointer-events-none",style:{position:"absolute",zIndex:5,left:`${xt}%`,top:`${ct}%`,transform:"translate(-50%, calc(-100% - 8px))"},children:l.accessibilityTitle})]},l.name)})]}),n.jsx("div",{ref:ie,style:{display:"none",position:"absolute",zIndex:20,borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",transition:"width 0.1s ease, height 0.1s ease, background 0.1s ease, box-shadow 0.1s ease"}})]}),n.jsx(Ht,{joined:i,fps:G,connected:s,deviceReady:a,bootError:p,installing:c,installError:u,keyboardActive:se})]})]})}const Ze=13,ut=8,sn=16,ao=.02,_t=720;function io({sessionId:t,buildId:e,send:r,connected:s,joined:i,deviceReady:a,installing:c,installed:f,installError:u,bootError:p,launching:m,setLaunching:g,androidButtons:d,binaryFrameHandlerRef:x,clipboardHandlerRef:y,clipboardSupported:R,onRecordingUploaded:C,screenWidth:A,screenHeight:j,cornerRadius:P,perfHookRef:_}){const L=o.useRef(null),E=o.useRef(null),M=o.useRef(null),{fps:G,frameCount:Q}=wn(),{recordState:$,recordCanvasRef:W,startClientRecording:Y,stopClientRecording:Re}=vn({sessionId:t,buildId:e,onRecordingUploaded:C}),[ce,le]=o.useState(!1),[he,xe]=o.useState(!1),[F,X]=o.useState(!1),z=o.useRef(null),[pe,se]=o.useState(null),[oe,Ie]=o.useState(!1),[q,Te]=o.useState(!1),[H,V]=o.useState(!1),[ne,ee]=o.useState(null),re=o.useRef(ne);o.useEffect(()=>{re.current=ne},[ne]);const be=o.useRef(!1),ue=o.useRef(!1),me=o.useRef(null),de=o.useRef(0),fe=o.useRef(null),ye=o.useRef(null),ie=o.useRef("idle"),ve=o.useRef(null);Tn({binaryFrameHandlerRef:x,perfHookRef:_,frameCount:Q,onUnsupported:()=>X(!0),onResize:v=>{xe(!0);const N=z.current;(!N||N.width!==v.width||N.height!==v.height)&&(z.current=v,se(v))},onDecoderReady:v=>{var O;M.current=v;const N=v.surface;N.style.display="block",N.style.width="100%",N.style.height="100%",N.style.objectFit="fill",(O=L.current)==null||O.appendChild(N)}});const _e=o.useCallback(()=>{var I;const v=W.current,N=(I=M.current)==null?void 0:I.surface,O=z.current;if(!v||!N||!O)return;const S=v.getContext("2d");if(!S)return;const J=O.width,U=O.height,l=v.width>v.height!=J>U;S.save(),l&&(S.translate(v.width,0),S.rotate(Math.PI/2)),S.drawImage(N,0,0,J,U);const b=Math.max(J,U),h=b>_t?b/_t:1,k=Ze*h,T=ut*h,w=re.current;if(w)for(const K of[w.f0,w.f1]){const ge=K.x*J,De=K.y*U;be.current?(S.beginPath(),S.arc(ge,De,T,0,Math.PI*2),S.fillStyle="rgba(255,255,255,0.92)",S.fill(),S.strokeStyle="rgba(0,0,0,0.2)",S.lineWidth=h,S.stroke()):(S.beginPath(),S.arc(ge,De,k,0,Math.PI*2),S.strokeStyle="rgba(0,0,0,0.3)",S.lineWidth=3*h,S.stroke(),S.beginPath(),S.arc(ge,De,k,0,Math.PI*2),S.strokeStyle="rgba(255,255,255,0.65)",S.lineWidth=1.5*h,S.stroke())}const D=ye.current;if(D){const K=D.x*J,ge=D.y*U,De=ie.current,xt=ve.current;if(De==="down")S.beginPath(),S.arc(K,ge,T,0,Math.PI*2),S.fillStyle="rgba(255,255,255,0.92)",S.fill(),S.strokeStyle="rgba(0,0,0,0.2)",S.lineWidth=h,S.stroke();else if(De==="release"&&xt){const ct=Math.min((performance.now()-xt.startTime)/350,1);S.beginPath(),S.arc(K,ge,T+26*h*ct,0,Math.PI*2),S.strokeStyle=`rgba(255,255,255,${(1-ct)*.55})`,S.lineWidth=1.5*h,S.stroke(),ct>=1&&(ie.current="idle",ve.current=null)}else S.beginPath(),S.arc(K,ge,k,0,Math.PI*2),S.strokeStyle="rgba(0,0,0,0.3)",S.lineWidth=3*h,S.stroke(),S.beginPath(),S.arc(K,ge,k,0,Math.PI*2),S.strokeStyle="rgba(255,255,255,0.65)",S.lineWidth=1.5*h,S.stroke()}S.restore()},[]),Pe=o.useCallback(()=>{var J;const v=(J=M.current)==null?void 0:J.surface,N=z.current;if(!v||!N)return;const O=document.createElement("canvas"),S=O.getContext("2d");S&&(O.width=N.width,O.height=N.height,S.drawImage(v,0,0,N.width,N.height),O.toBlob(U=>{if(!U)return;const l=URL.createObjectURL(U),b=document.createElement("a");b.href=l,b.download=`tapflow-${Date.now()}.png`,b.click(),URL.revokeObjectURL(l)},"image/png"))},[]),We=o.useCallback(()=>{if($==="idle"){const v=W.current;if(!v)return;const N=z.current;if(!N)return;const O=Ve.current;v.width=O?N.height:N.width,v.height=O?N.width:N.height,Y(_e)}else $==="recording"&&Re()},[$,Y,Re,_e]),Ue=o.useCallback(()=>{r({type:"input:rotate",sessionId:t}),Ie(v=>!v)},[r,t]),at=o.useRef(oe);o.useEffect(()=>{at.current=oe},[oe]),o.useEffect(()=>()=>{at.current&&r({type:"input:rotate",sessionId:t})},[]);const it=o.useCallback((v,N)=>{r({type:"input:key",sessionId:t,payload:{code:v,modifiers:N}})},[r,t]);_n({sessionId:t,send:r,active:q,supported:R,handlerRef:y,sendChord:it,onError:v=>tt.error(v)}),o.useEffect(()=>{const v=new Set(["ShiftLeft","ShiftRight","ControlLeft","ControlRight","MetaLeft","MetaRight"]),N=U=>{if(U.code==="AltLeft"||U.code==="AltRight"){ue.current=!0;return}if(U.metaKey){const b=document.activeElement;if(!b||b.tagName!=="INPUT"&&b.tagName!=="TEXTAREA"){if(!U.shiftKey&&U.code==="KeyK"){U.preventDefault(),le(!0);return}if(!U.shiftKey&&U.code==="KeyS"){U.preventDefault(),Pe();return}if(U.shiftKey&&U.code==="KeyY"){U.preventDefault(),We();return}if(U.shiftKey&&U.code==="KeyO"){U.preventDefault(),Ue();return}}}if(!q||v.has(U.code)||R&&Ft(U))return;U.preventDefault();const l=(U.shiftKey?2:0)|(U.ctrlKey?1:0)|(U.metaKey?8:0);r({type:"input:key",sessionId:t,payload:{code:U.code,modifiers:l}})},O=()=>{be.current&&(be.current=!1,V(!1),r({type:"input:pinch:end",sessionId:t})),ue.current=!1,ee(null)},S=U=>{(U.code==="AltLeft"||U.code==="AltRight")&&O()},J=()=>{ue.current&&O()};return window.addEventListener("keydown",N),window.addEventListener("keyup",S),window.addEventListener("blur",J),()=>{window.removeEventListener("keydown",N),window.removeEventListener("keyup",S),window.removeEventListener("blur",J)}},[q,R,r,t,Pe,We,Ue]),o.useEffect(()=>{if(!q)return;const v=N=>{const O=E.current??L.current;O&&!O.contains(N.target)&&Te(!1)};return document.addEventListener("pointerdown",v),()=>document.removeEventListener("pointerdown",v)},[q]);const Ve=o.useRef(!1),je=o.useCallback(v=>{const N=L.current;if(!N)return null;const O=N.getBoundingClientRect();return Fs({x:v.clientX,y:v.clientY},O,Ve.current)},[]),He=o.useCallback(v=>{const N=je(v);return N?kn(N):null},[je]),kt=o.useCallback(v=>{if(ue.current){const J=He(v);if(!J)return;be.current=!0,V(!0),v.target.setPointerCapture(v.pointerId);const U=fe.current;U&&(U.style.display="none"),ee(J),r({type:"input:pinch:start",sessionId:t,payload:J});return}const N=je(v);if(!N)return;Te(!0),me.current=N,v.target.setPointerCapture(v.pointerId);const O=v.currentTarget.getBoundingClientRect();ye.current=N,ie.current="down",ve.current=null;const S=fe.current;S&&(S.style.display="block",S.style.left=`${v.clientX-O.left}px`,S.style.top=`${v.clientY-O.top}px`,S.style.width=`${ut*2}px`,S.style.height=`${ut*2}px`,S.style.background="rgba(255,255,255,0.92)",S.style.border="1.5px solid rgba(0,0,0,0.2)",S.style.boxShadow="0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"),r({type:"input:touch:start",sessionId:t,payload:N})},[je,He,r,t]),Ne=o.useCallback(v=>{if(v.buttons===0){if(ue.current){ee(He(v)),ye.current=null;const T=fe.current;T&&(T.style.display="none");return}const b=je(v),h=v.currentTarget.getBoundingClientRect(),k=fe.current;b?(ye.current=b,ie.current!=="down"&&(ie.current="idle"),k&&(k.style.display="block",k.style.left=`${v.clientX-h.left}px`,k.style.top=`${v.clientY-h.top}px`,k.style.width=`${Ze*2}px`,k.style.height=`${Ze*2}px`,k.style.background="transparent",k.style.border="1.5px solid rgba(255,255,255,0.6)",k.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)")):(ye.current=null,k&&(k.style.display="none"));return}if(be.current){const b=He(v);if(!b)return;const h=performance.now();if(h-de.current<sn)return;de.current=h,ee(b),r({type:"input:pinch:move",sessionId:t,payload:b});return}if(!me.current)return;const N=je(v);if(!N)return;const O=N.x-me.current.x,S=N.y-me.current.y;if(Math.sqrt(O*O+S*S)<ao)return;const J=performance.now();if(J-de.current<sn)return;de.current=J;const U=v.currentTarget.getBoundingClientRect();ye.current=N;const l=fe.current;l&&l.style.display!=="none"&&(l.style.left=`${v.clientX-U.left}px`,l.style.top=`${v.clientY-U.top}px`),r({type:"input:touch:move",sessionId:t,payload:N})},[je,He,r,t]),Ke=o.useCallback(()=>{if(be.current){be.current=!1,V(!1),ee(null),r({type:"input:pinch:end",sessionId:t});return}me.current=null,ie.current="release",ve.current={startTime:performance.now()};const v=fe.current;v&&(v.style.width=`${Ze*2}px`,v.style.height=`${Ze*2}px`,v.style.background="transparent",v.style.border="1.5px solid rgba(255,255,255,0.6)",v.style.boxShadow="0 0 0 1px rgba(0,0,0,0.3)"),r({type:"input:touch:end",sessionId:t})},[r,t]),rt=o.useCallback(()=>{if(be.current){be.current=!1,V(!1),ee(null),r({type:"input:pinch:end",sessionId:t});return}me.current=null,ie.current="release",ve.current={startTime:performance.now()},r({type:"input:touch:end",sessionId:t})},[r,t]),Xe=o.useCallback(()=>{ee(null),ye.current=null;const v=fe.current;v&&(v.style.display="none")},[]),we=pe??(A&&j?{width:A,height:j}:null),mt=we?Math.min(1,_t/Math.max(we.width,we.height)):.3,Fe=we?Math.round(we.width*mt):324,Ye=we?Math.round(we.height*mt):720,Et=we?we.width>we.height:!1,Be=oe&&!Et;o.useLayoutEffect(()=>{Ve.current=Be},[Be]);const gt=Be?Ye:Fe,Xt=Be?Fe:Ye,st=P!=null?Math.round(P*Fe):22,Ge=Be?{position:"absolute",width:Fe,height:Ye,top:(Fe-Ye)/2,left:(Ye-Fe)/2,transform:"rotate(90deg)",transformOrigin:"center center",visibility:he?"visible":"hidden",cursor:"none"}:{visibility:he?"visible":"hidden",cursor:"none"},qe=n.jsx(n.Fragment,{children:d==null?void 0:d.map(v=>n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",onClick:()=>r({type:"input:button",sessionId:t,payload:{name:v.name}}),children:v.name==="back"?n.jsx(jr,{className:"h-4 w-4"}):v.name==="recent_apps"?n.jsx(Jn,{className:"h-4 w-4"}):v.name==="volume_up"?n.jsx(ts,{className:"h-4 w-4"}):v.name==="volume_down"?n.jsx(rs,{className:"h-4 w-4"}):v.name==="power"?n.jsx(Vr,{className:"h-4 w-4"}):n.jsx(bn,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:v.accessibilityTitle})]},v.name))}),ot=f&&e?n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx(ae,{variant:"ghost",size:"icon",className:"h-8 w-8",disabled:m||c,onClick:()=>{g(!0),r({type:"app:launch",sessionId:t,buildId:e})},children:m?n.jsx(Rt,{className:"h-4 w-4 animate-spin"}):n.jsx(hn,{className:"h-4 w-4"})})}),n.jsx(Ee,{side:"left",children:m?"Launching…":c?"Installing…":"Launch app"})]}):null;return n.jsxs("div",{className:"flex items-start justify-center gap-16",children:[n.jsx("canvas",{ref:W,style:{display:"none"}}),n.jsx(Cn,{open:ce,onOpenChange:le,sessionId:t,send:r}),n.jsx(Sn,{joined:i,onDeepLink:()=>le(!0),onScreenshot:Pe,onRecordToggle:We,recordState:$,onRotate:Ue,platformSlot:qe,launchSlot:ot}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsx("div",{style:{background:"#1c1c1e",borderRadius:`${st+12}px`,padding:"12px",flexShrink:0,boxShadow:"0 8px 32px rgba(0,0,0,0.45), inset 0 1px 0 rgba(255,255,255,0.06)"},children:n.jsx("div",{ref:E,className:"relative",style:{width:gt,height:Xt,backgroundColor:"#010101",borderRadius:`${st}px`,overflow:"hidden"},children:F?n.jsx("div",{className:"absolute inset-0 flex items-center justify-center p-4 text-center",children:n.jsxs("span",{style:{color:"rgba(255,255,255,0.6)",fontSize:"0.875rem"},children:["이 환경에서는 스트리밍을 표시할 수 없습니다.",n.jsx("br",{}),"Chrome/Edge 또는 HTTPS 환경에서 다시 시도해 주세요."]})}):n.jsxs(n.Fragment,{children:[n.jsx("div",{ref:L,className:Be?void 0:"block w-full h-full",style:Ge,onPointerDown:kt,onPointerMove:Ne,onPointerUp:Ke,onPointerCancel:rt,onPointerLeave:Xe}),!he&&n.jsx("div",{className:"absolute inset-0 animate-pulse bg-zinc-700"}),!he&&a&&n.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:n.jsx("span",{style:{color:"rgba(255,255,255,0.6)",fontSize:"0.875rem"},children:"Waiting for stream…"})}),n.jsx("div",{ref:fe,style:{display:"none",position:"absolute",zIndex:20,borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",transition:"width 0.1s ease, height 0.1s ease, background 0.1s ease, box-shadow 0.1s ease"}}),ne&&n.jsx(n.Fragment,{children:[ne.f0,ne.f1].map((v,N)=>n.jsx("div",{style:{position:"absolute",zIndex:10,borderRadius:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",transition:"width 0.1s ease, height 0.1s ease, background 0.1s ease",left:`${v.x*100}%`,top:`${v.y*100}%`,...H?{width:ut*2,height:ut*2,background:"rgba(255,255,255,0.92)",border:"1.5px solid rgba(0,0,0,0.2)",boxShadow:"0 0 0 1px rgba(0,0,0,0.15), 0 0 8px rgba(255,255,255,0.25)"}:{width:Ze*2,height:Ze*2,background:"transparent",border:"1.5px solid rgba(255,255,255,0.6)",boxShadow:"0 0 0 1px rgba(0,0,0,0.3)"}}},N))})]})})}),n.jsx(Ht,{joined:i,fps:G,connected:s,deviceReady:a,bootError:p,installing:c,installError:u,keyboardActive:q})]})]})}function co(t,e){const r=new DataView(t),s=Math.floor(t.byteLength/2),i=Math.floor(s/e),a=[];for(let c=0;c<e;c++)a.push(new Float32Array(i));for(let c=0;c<i;c++)for(let f=0;f<e;f++){const u=r.getInt16((c*e+f)*2,!0);a[f][c]=u/32768}return a}const lo=44100,At=2,on=.06,uo=.3;function fo(){const t=o.useRef(null),e=o.useRef(0),r=o.useCallback(()=>{if(t.current)return t.current;const i=window.AudioContext??window.webkitAudioContext;return i?(t.current=new i,t.current):null},[]),s=o.useCallback(i=>{var d;const a=r();if(!a)return;a.state==="suspended"&&a.resume();const c=co(i,At),f=((d=c[0])==null?void 0:d.length)??0;if(f===0)return;const u=a.createBuffer(At,f,lo);for(let x=0;x<At;x++)u.getChannelData(x).set(c[x]);const p=a.createBufferSource();p.buffer=u,p.connect(a.destination);const m=a.currentTime;let g=e.current;(g<m+.005||g>m+uo+on)&&(g=m+on),p.start(g),e.current=g+u.duration},[r]);return o.useEffect(()=>()=>{var i;(i=t.current)==null||i.close(),t.current=null},[]),{pushFrame:s}}function ho({sessionId:t,deviceId:e,buildId:r,resetMode:s,onRecordingUploaded:i}){const a=o.useRef(()=>{});is();const c=o.useRef(null),f=o.useRef(null),u=o.useRef([]);o.useRef({onFrameBegin:()=>{var H;return(H=c.current)==null?void 0:H.onFrameBegin()},onFrameEnd:H=>{var ee,re;const V=u.current.shift()??null,ne=V?{...H,capturedAt:V.capturedAt,relayedAt:V.relayedAt}:H;(ee=c.current)==null||ee.onFrameEnd(ne),(re=f.current)==null||re.call(f,ne)}});const[p,m]=o.useState(!1),[g,d]=o.useState(!1),[x,y]=o.useState(null),[R,C]=o.useState(!1),[A,j]=o.useState(!1),[P,_]=o.useState(null),[L,E]=o.useState(null),[M,G]=o.useState(!1),[Q,$]=o.useState([]),[W,Y]=o.useState(!1),[Re,ce]=o.useState(!1),le=o.useRef(void 0),he=o.useRef(void 0),{pushFrame:xe}=fo(),F=o.useCallback(H=>{var V;if(H.type==="session:joined"&&(m(!0),$(H.capabilities??[]),a.current({type:"device:boot",sessionId:t,payload:{deviceId:e,resetMode:s,acceptH264:Ps(),secureContext:window.isSecureContext}})),H.type==="device:boot-error"&&E(H.message),H.type==="device:booting"&&(d(!1),C(!1),j(!1),_(null),E(null),y(null)),H.type==="device:ready"&&(d(!0),r&&(C(!0),a.current({type:"app:install",sessionId:t,buildId:r}))),H.type==="app:install-done"&&(C(!1),j(!0)),H.type==="app:install-error"&&(C(!1),_(H.message)),H.type==="app:launch-done"&&G(!1),H.type==="app:launch-error"&&G(!1),H.type==="session:chrome"&&y(H.payload),H.type==="keyboard:toggled"){const{visible:ne}=H.payload;Y(ne),ce(!1)}(H.type==="clipboard:data"||H.type==="clipboard:write-done"||H.type==="clipboard:error")&&((V=he.current)==null||V.call(he,H)),H.type==="open-url:done"&&tt.success("Deeplink opened"),H.type==="open-url:error"&&tt.error(H.message),H.type==="error"&&H.message==="Agent resources exhausted"&&tt.error("Could not start session — this Mac is currently overloaded.",{description:"Go back and select a different Mac."})},[t,e,r]),X=o.useCallback(H=>{var re;const V=Ks(H);if(V&&V.codec===En){xe(H.slice(Lt));return}V&&V.codec===jt||u.current.push(V);const ne=V?H.slice(Lt):H,ee=V?{codec:V.codec,keyframe:V.keyframe,capturedAt:V.capturedAt,relayedAt:V.relayedAt}:void 0;(re=le.current)==null||re.call(le,ne,ee)},[xe]),{send:z,connected:pe}=pn(F,X);o.useLayoutEffect(()=>{a.current=z}),o.useEffect(()=>{pe&&z({type:"session:start",sessionId:t})},[pe,z,t]);const se=x!==null&&"framePng"in x?x:null,oe=x!==null&&!("framePng"in x)?x:null,Ie=()=>{ce(!0),z({type:"input:keyboard:toggle",sessionId:t})},q={sessionId:t,buildId:r,send:z,connected:pe,joined:p,deviceReady:g,installing:R,installed:A,installError:P,bootError:L,launching:M,setLaunching:G,binaryFrameHandlerRef:le,clipboardHandlerRef:he,clipboardSupported:Q.includes("clipboard"),onRecordingUploaded:i,swKeyboardVisible:W,swKeyboardPending:Re,onKbdToggle:Ie};if(!se&&!oe)return n.jsxs("div",{className:"flex items-start justify-center gap-16",children:[n.jsx("div",{className:"flex flex-col items-center gap-0.5 rounded-2xl border bg-background/90 px-1.5 py-2.5 shrink-0 mt-3 opacity-40",children:Array.from({length:5}).map((H,V)=>n.jsx("div",{className:"h-8 w-8 rounded-md bg-muted animate-pulse"},V))}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsx("div",{style:{background:"#1c1c1e",borderRadius:"34px",padding:"12px",flexShrink:0},children:n.jsx("div",{className:"animate-pulse bg-zinc-700",style:{width:324,height:720,borderRadius:"22px"}})}),n.jsx(Ht,{joined:p,fps:0,connected:pe,deviceReady:g,bootError:L,installing:R,installError:P,keyboardActive:!1})]})]});const Te=void 0;return n.jsxs(n.Fragment,{children:[se&&n.jsx(oo,{...q,chrome:se,perfHookRef:Te}),oe&&n.jsx(io,{...q,androidButtons:oe.buttons,screenWidth:oe.screenWidth,screenHeight:oe.screenHeight,cornerRadius:oe.cornerRadius,perfHookRef:Te}),!1]})}const An=o.forwardRef(({className:t,...e},r)=>n.jsx("textarea",{className:Z("flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-base ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 md:text-sm",t),ref:r,...e}));An.displayName="Textarea";var po=Object.defineProperty,B=(t,e)=>po(t,"name",{value:e,configurable:!0});function Pn(t,e){return o.useReducer((r,s)=>e[r][s]??r,t)}B(Pn,"useStateMachine");var Nn="ScrollArea",[Dn]=fn(Nn),[mo,Se]=Dn(Nn),go=o.forwardRef(B(function(e,r){const{__scopeScrollArea:s,type:i="hover",dir:a,scrollHideDelay:c=600,...f}=e,[u,p]=o.useState(null),[m,g]=o.useState(null),[d,x]=o.useState(null),[y,R]=o.useState(null),[C,A]=o.useState(null),[j,P]=o.useState(0),[_,L]=o.useState(0),[E,M]=o.useState(!1),[G,Q]=o.useState(!1),$=Oe(r,p),W=Qn(a);return n.jsx(mo,{scope:s,type:i,dir:W,scrollHideDelay:c,scrollArea:u,viewport:m,onViewportChange:g,content:d,onContentChange:x,scrollbarX:y,onScrollbarXChange:R,scrollbarXEnabled:E,onScrollbarXEnabledChange:M,scrollbarY:C,onScrollbarYChange:A,scrollbarYEnabled:G,onScrollbarYEnabledChange:Q,onCornerWidthChange:P,onCornerHeightChange:L,children:n.jsx(ze.div,{dir:W,...f,ref:$,style:{position:"relative","--radix-scroll-area-corner-width":j+"px","--radix-scroll-area-corner-height":_+"px",...e.style}})})},"ScrollArea")),xo="ScrollAreaViewport",bo=o.forwardRef(B(function(e,r){const{__scopeScrollArea:s,children:i,nonce:a,...c}=e,f=Se(xo,s),u=o.useRef(null),p=Oe(r,u,f.onViewportChange);return n.jsxs(n.Fragment,{children:[n.jsx(yo,{nonce:a}),n.jsx(ze.div,{"data-radix-scroll-area-viewport":"",...c,ref:p,style:{overflowX:f.scrollbarXEnabled?"scroll":"hidden",overflowY:f.scrollbarYEnabled?"scroll":"hidden",...e.style},children:n.jsx("div",{ref:f.onContentChange,style:{minWidth:"100%",display:"table"},children:i})})]})},"ScrollAreaViewport")),yo=o.memo(B(function({nonce:e}){return n.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-scroll-area-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-scroll-area-viewport]::-webkit-scrollbar{display:none}"},nonce:e})},"ScrollAreaViewportStyle"),(t,e)=>t.nonce===e.nonce),Me="ScrollAreaScrollbar",Ln=o.forwardRef(B(function(e,r){const{forceMount:s,...i}=e,a=Se(Me,e.__scopeScrollArea),{onScrollbarXEnabledChange:c,onScrollbarYEnabledChange:f}=a,u=e.orientation==="horizontal";return o.useEffect(()=>(u?c(!0):f(!0),()=>{u?c(!1):f(!1)}),[u,c,f]),a.type==="hover"?n.jsx(vo,{...i,ref:r,forceMount:s}):a.type==="scroll"?n.jsx(wo,{...i,ref:r,forceMount:s}):a.type==="auto"?n.jsx(Mn,{...i,ref:r,forceMount:s}):a.type==="always"?n.jsx(Bt,{...i,ref:r,"data-state":"visible"}):null},"ScrollAreaScrollbar")),vo=o.forwardRef(B(function(e,r){const{forceMount:s,...i}=e,a=Se(Me,e.__scopeScrollArea),[c,f]=o.useState(!1);return o.useEffect(()=>{const u=a.scrollArea;let p=0;if(u){const m=B(()=>{window.clearTimeout(p),f(!0)},"handlePointerEnter"),g=B(()=>{p=window.setTimeout(()=>f(!1),a.scrollHideDelay)},"handlePointerLeave");return u.addEventListener("pointerenter",m),u.addEventListener("pointerleave",g),()=>{window.clearTimeout(p),u.removeEventListener("pointerenter",m),u.removeEventListener("pointerleave",g)}}},[a.scrollArea,a.scrollHideDelay]),n.jsx(Ct,{present:s||c,children:n.jsx(Mn,{"data-state":c?"visible":"hidden",...i,ref:r})})},"ScrollAreaScrollbarHover")),wo=o.forwardRef(B(function(e,r){const{forceMount:s,...i}=e,a=Se(Me,e.__scopeScrollArea),c=e.orientation==="horizontal",f=pt(()=>p("SCROLL_END"),100),[u,p]=Pn("hidden",{hidden:{SCROLL:"scrolling"},scrolling:{SCROLL_END:"idle",POINTER_ENTER:"interacting"},interacting:{SCROLL:"interacting",POINTER_LEAVE:"idle"},idle:{HIDE:"hidden",SCROLL:"scrolling",POINTER_ENTER:"interacting"}});return o.useEffect(()=>{if(u==="idle"){const m=window.setTimeout(()=>p("HIDE"),a.scrollHideDelay);return()=>window.clearTimeout(m)}},[u,a.scrollHideDelay,p]),o.useEffect(()=>{const m=a.viewport,g=c?"scrollLeft":"scrollTop";if(m){let d=m[g];const x=B(()=>{const y=m[g];d!==y&&(p("SCROLL"),f()),d=y},"handleScroll");return m.addEventListener("scroll",x),()=>m.removeEventListener("scroll",x)}},[a.viewport,c,p,f]),n.jsx(Ct,{present:s||u!=="hidden",children:n.jsx(Bt,{"data-state":u==="hidden"?"hidden":"visible",...i,ref:r,onPointerEnter:Le(e.onPointerEnter,()=>p("POINTER_ENTER")),onPointerLeave:Le(e.onPointerLeave,()=>p("POINTER_LEAVE"))})})},"ScrollAreaScrollbarScroll")),Mn=o.forwardRef(B(function(e,r){const s=Se(Me,e.__scopeScrollArea),{forceMount:i,...a}=e,[c,f]=o.useState(!1),u=e.orientation==="horizontal",p=pt(()=>{if(s.viewport){const m=s.viewport.offsetWidth<s.viewport.scrollWidth,g=s.viewport.offsetHeight<s.viewport.scrollHeight;f(u?m:g)}},10);return nt(s.viewport,p),nt(s.content,p),n.jsx(Ct,{present:i||c,children:n.jsx(Bt,{"data-state":c?"visible":"hidden",...a,ref:r})})},"ScrollAreaScrollbarAuto")),Bt=o.forwardRef(B(function(e,r){const{orientation:s="vertical",...i}=e,a=Se(Me,e.__scopeScrollArea),c=o.useRef(null),f=o.useRef(0),[u,p]=o.useState({content:0,viewport:0,scrollbar:{size:0,paddingStart:0,paddingEnd:0}}),m=$t(u.viewport,u.content),g={...i,sizes:u,onSizesChange:p,hasThumb:m>0&&m<1,onThumbChange:B(x=>c.current=x,"onThumbChange"),onThumbPointerUp:B(()=>f.current=0,"onThumbPointerUp"),onThumbPointerDown:B(x=>f.current=x,"onThumbPointerDown")};function d(x,y){return Fn(x,f.current,u,y)}return B(d,"getScrollPosition"),s==="horizontal"?n.jsx(So,{...g,ref:r,onThumbPositionChange:()=>{if(a.viewport&&c.current){const x=a.viewport.scrollLeft,y=It(x,u,a.dir);c.current.style.transform=`translate3d(${y}px, 0, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollLeft=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollLeft=d(x,a.dir))}}):s==="vertical"?n.jsx(Ro,{...g,ref:r,onThumbPositionChange:()=>{if(a.viewport&&c.current){const x=a.viewport.scrollTop,y=It(x,u);c.current.style.transform=`translate3d(0, ${y}px, 0)`}},onWheelScroll:x=>{a.viewport&&(a.viewport.scrollTop=x)},onDragScroll:x=>{a.viewport&&(a.viewport.scrollTop=d(x))}}):null},"ScrollAreaScrollbarVisible")),So=o.forwardRef(B(function(e,r){const{sizes:s,onSizesChange:i,...a}=e,c=Se(Me,e.__scopeScrollArea),[f,u]=o.useState(),p=o.useRef(null),m=Oe(r,p,c.onScrollbarXChange);return o.useEffect(()=>{p.current&&u(getComputedStyle(p.current))},[p]),n.jsx(Un,{"data-orientation":"horizontal",...a,ref:m,sizes:s,style:{bottom:0,left:c.dir==="rtl"?"var(--radix-scroll-area-corner-width)":0,right:c.dir==="ltr"?"var(--radix-scroll-area-corner-width)":0,"--radix-scroll-area-thumb-width":ht(s)+"px",...e.style},onThumbPointerDown:g=>e.onThumbPointerDown(g.x),onDragScroll:g=>e.onDragScroll(g.x),onWheelScroll:(g,d)=>{if(c.viewport){const x=c.viewport.scrollLeft+g.deltaX;e.onWheelScroll(x),zt(x,d)&&g.preventDefault()}},onResize:()=>{p.current&&c.viewport&&f&&i({content:c.viewport.scrollWidth,viewport:c.viewport.offsetWidth,scrollbar:{size:p.current.clientWidth,paddingStart:ft(f.paddingLeft),paddingEnd:ft(f.paddingRight)}})}})},"ScrollAreaScrollbarX")),Ro=o.forwardRef(B(function(e,r){const{sizes:s,onSizesChange:i,...a}=e,c=Se(Me,e.__scopeScrollArea),[f,u]=o.useState(),p=o.useRef(null),m=Oe(r,p,c.onScrollbarYChange);return o.useEffect(()=>{p.current&&u(getComputedStyle(p.current))},[p]),n.jsx(Un,{"data-orientation":"vertical",...a,ref:m,sizes:s,style:{top:0,right:c.dir==="ltr"?0:void 0,left:c.dir==="rtl"?0:void 0,bottom:"var(--radix-scroll-area-corner-height)","--radix-scroll-area-thumb-height":ht(s)+"px",...e.style},onThumbPointerDown:g=>e.onThumbPointerDown(g.y),onDragScroll:g=>e.onDragScroll(g.y),onWheelScroll:(g,d)=>{if(c.viewport){const x=c.viewport.scrollTop+g.deltaY;e.onWheelScroll(x),zt(x,d)&&g.preventDefault()}},onResize:()=>{p.current&&c.viewport&&f&&i({content:c.viewport.scrollHeight,viewport:c.viewport.offsetHeight,scrollbar:{size:p.current.clientHeight,paddingStart:ft(f.paddingTop),paddingEnd:ft(f.paddingBottom)}})}})},"ScrollAreaScrollbarY")),[jo,In]=Dn(Me),Un=o.forwardRef(B(function(e,r){const{__scopeScrollArea:s,sizes:i,hasThumb:a,onThumbChange:c,onThumbPointerUp:f,onThumbPointerDown:u,onThumbPositionChange:p,onDragScroll:m,onWheelScroll:g,onResize:d,...x}=e,y=Se(Me,s),[R,C]=o.useState(null),A=Oe(r,C),j=o.useRef(null),P=o.useRef(""),_=y.viewport,L=i.content-i.viewport,E=et(g),M=et(p),G=pt(d,10);function Q($){if(j.current){const W=$.clientX-j.current.left,Y=$.clientY-j.current.top;m({x:W,y:Y})}}return B(Q,"handleDragScroll"),o.useEffect(()=>{const $=B(W=>{const Y=W.target;(R==null?void 0:R.contains(Y))&&E(W,L)},"handleWheel");return document.addEventListener("wheel",$,{passive:!1}),()=>document.removeEventListener("wheel",$,{passive:!1})},[_,R,L,E]),o.useEffect(M,[i,M]),nt(R,G),nt(y.content,G),n.jsx(jo,{scope:s,scrollbar:R,hasThumb:a,onThumbChange:et(c),onThumbPointerUp:et(f),onThumbPositionChange:M,onThumbPointerDown:et(u),children:n.jsx(ze.div,{...x,ref:A,style:{position:"absolute",...x.style},onPointerDown:Le(e.onPointerDown,$=>{$.button===0&&($.target.setPointerCapture($.pointerId),j.current=R.getBoundingClientRect(),P.current=document.body.style.webkitUserSelect,document.body.style.webkitUserSelect="none",y.viewport&&(y.viewport.style.scrollBehavior="auto"),Q($))}),onPointerMove:Le(e.onPointerMove,Q),onPointerUp:Le(e.onPointerUp,$=>{const W=$.target;W.hasPointerCapture($.pointerId)&&W.releasePointerCapture($.pointerId),document.body.style.webkitUserSelect=P.current,y.viewport&&(y.viewport.style.scrollBehavior=""),j.current=null})})})},"ScrollAreaScrollbarImpl")),Mt="ScrollAreaThumb",Co=o.forwardRef(B(function(e,r){const{forceMount:s,...i}=e,a=In(Mt,e.__scopeScrollArea);return n.jsx(Ct,{present:s||a.hasThumb,children:n.jsx(ko,{ref:r,...i})})},"ScrollAreaThumb")),ko=o.forwardRef(B(function(e,r){const{__scopeScrollArea:s,style:i,...a}=e,c=Se(Mt,s),f=In(Mt,s),{onThumbPositionChange:u}=f,p=Oe(r,f.onThumbChange),m=o.useRef(void 0),g=pt(()=>{m.current&&(m.current(),m.current=void 0)},100);return o.useEffect(()=>{const d=c.viewport;if(d){const x=B(()=>{if(g(),!m.current){const y=_o(d,u);m.current=y,u()}},"handleScroll");return u(),d.addEventListener("scroll",x),()=>d.removeEventListener("scroll",x)}},[c.viewport,g,u]),n.jsx(ze.div,{"data-state":f.hasThumb?"visible":"hidden",...a,ref:p,style:{width:"var(--radix-scroll-area-thumb-width)",height:"var(--radix-scroll-area-thumb-height)",...i},onPointerDownCapture:Le(e.onPointerDownCapture,d=>{const y=d.target.getBoundingClientRect(),R=d.clientX-y.left,C=d.clientY-y.top;f.onThumbPointerDown({x:R,y:C})}),onPointerUp:Le(e.onPointerUp,f.onThumbPointerUp)})},"ScrollAreaThumbImpl")),Hn="ScrollAreaCorner",Eo=o.forwardRef(B(function(e,r){const s=Se(Hn,e.__scopeScrollArea),i=!!(s.scrollbarX&&s.scrollbarY);return s.type!=="scroll"&&i?n.jsx(To,{...e,ref:r}):null},"ScrollAreaCorner")),To=o.forwardRef(B(function(e,r){const{__scopeScrollArea:s,...i}=e,a=Se(Hn,s),[c,f]=o.useState(0),[u,p]=o.useState(0),m=!!(c&&u),{onCornerWidthChange:g,onCornerHeightChange:d}=a;return nt(a.scrollbarX,()=>{var y;const x=((y=a.scrollbarX)==null?void 0:y.offsetHeight)||0;a.onCornerHeightChange(x),p(x)}),nt(a.scrollbarY,()=>{var y;const x=((y=a.scrollbarY)==null?void 0:y.offsetWidth)||0;a.onCornerWidthChange(x),f(x)}),o.useEffect(()=>()=>{g(0),d(0)},[g,d]),m?n.jsx(ze.div,{...i,ref:r,style:{width:c,height:u,position:"absolute",right:a.dir==="ltr"?0:void 0,left:a.dir==="rtl"?0:void 0,bottom:0,...e.style}}):null},"ScrollAreaCornerImpl"));function ft(t){return t?parseInt(t,10):0}B(ft,"toInt");function $t(t,e){const r=t/e;return isNaN(r)?0:r}B($t,"getThumbRatio");function ht(t){const e=$t(t.viewport,t.content),r=t.scrollbar.paddingStart+t.scrollbar.paddingEnd,s=(t.scrollbar.size-r)*e;return Math.max(s,18)}B(ht,"getThumbSize");function Fn(t,e,r,s="ltr"){const i=ht(r),a=i/2,c=e||a,f=i-c,u=r.scrollbar.paddingStart+c,p=r.scrollbar.size-r.scrollbar.paddingEnd-f,m=r.content-r.viewport,g=s==="ltr"?[0,m]:[m*-1,0];return Ot([u,p],g)(t)}B(Fn,"getScrollPositionFromPointer");function It(t,e,r="ltr"){const s=ht(e),i=e.scrollbar.paddingStart+e.scrollbar.paddingEnd,a=e.scrollbar.size-i,c=e.content-e.viewport,f=a-s,u=r==="ltr"?[0,c]:[c*-1,0],p=xr(t,u);return Ot([0,c],[0,f])(p)}B(It,"getThumbOffsetFromScroll");function Ot(t,e){return r=>{if(t[0]===t[1]||e[0]===e[1])return e[0];const s=(e[1]-e[0])/(t[1]-t[0]);return e[0]+s*(r-t[0])}}B(Ot,"linearScale");function zt(t,e){return t>0&&t<e}B(zt,"isScrollingWithinScrollbarBounds");var _o=B((t,e=()=>{})=>{let r={left:t.scrollLeft,top:t.scrollTop},s=0;return B((function i(){const a={left:t.scrollLeft,top:t.scrollTop},c=r.left!==a.left,f=r.top!==a.top;(c||f)&&e(),r=a,s=window.requestAnimationFrame(i)}),"loop")(),()=>window.cancelAnimationFrame(s)},"addUnlinkedScrollListener");function pt(t,e){const r=et(t),s=o.useRef(0);return o.useEffect(()=>()=>window.clearTimeout(s.current),[]),o.useCallback(()=>{window.clearTimeout(s.current),s.current=window.setTimeout(r,e)},[r,e])}B(pt,"useDebounceCallback");function nt(t,e){const r=et(e);Zn(()=>{let s=0;if(t){const i=new ResizeObserver(()=>{cancelAnimationFrame(s),s=window.requestAnimationFrame(r)});return i.observe(t),()=>{window.cancelAnimationFrame(s),i.unobserve(t)}}},[t,r])}B(nt,"useResizeObserver");var Bn=go,Ao=bo,Po=Eo;const $n=o.forwardRef(({className:t,children:e,...r},s)=>n.jsxs(Bn,{ref:s,className:Z("relative overflow-hidden",t),...r,children:[n.jsx(Ao,{className:"h-full w-full rounded-[inherit]",children:e}),n.jsx(On,{}),n.jsx(Po,{})]}));$n.displayName=Bn.displayName;const On=o.forwardRef(({className:t,orientation:e="vertical",...r},s)=>n.jsx(Ln,{ref:s,orientation:e,className:Z("flex touch-none select-none transition-colors",e==="vertical"&&"h-full w-2.5 border-l border-l-transparent p-[1px]",e==="horizontal"&&"h-2.5 flex-col border-t border-t-transparent p-[1px]",t),...r,children:n.jsx(Co,{className:"relative flex-1 rounded-full bg-border"})}));On.displayName=Ln.displayName;function zn(t){return/[Zz]|[+-]\d{2}/.test(t)?new Date(t):new Date(t.replace(" ","T")+"Z")}function No(t){const e=new Map;for(const i of t){const a=zn(i.created_at).toDateString();e.has(a)||e.set(a,[]),e.get(a).push(i)}const r=new Date().toDateString(),s=new Date(Date.now()-864e5).toDateString();return Array.from(e.entries()).map(([i,a])=>{let c;if(i===r)c="Today";else if(i===s)c="Yesterday";else{const f=new Date(i);c=f.toLocaleDateString(void 0,{month:"short",day:"numeric",...f.getFullYear()!==new Date().getFullYear()?{year:"numeric"}:{}})}return{label:c,items:a}})}function Do(t){return zn(t).toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})}const Lo=5*1024*1024,Mo=["image/png","image/jpeg","image/webp"];function Io({buildId:t}){const[e,r]=o.useState([]),[s,i]=o.useState(""),[a,c]=o.useState(null),[f,u]=o.useState(!1),[p,m]=o.useState(""),g=o.useRef(null),d=o.useRef({});function x(){fetch(`/api/v1/comments?build_id=${t}`,{credentials:"include"}).then(j=>j.ok?j.json():[]).then(r)}o.useEffect(()=>{x()},[t]),o.useEffect(()=>{const j=window.location.hash;if(!j.startsWith("#comment-"))return;const P=Number(j.replace("#comment-","")),_=d.current[P];if(!_)return;_.scrollIntoView({behavior:"smooth"});const L=document.documentElement.classList.contains("dark");_.style.backgroundColor=L?"rgb(0 112 243 / 0.18)":"#d3e5ff",setTimeout(()=>{_.style.backgroundColor=""},2e3)},[e]);function y(j){const P=`${location.origin}${location.pathname}${location.search}#comment-${j}`;navigator.clipboard.writeText(P).then(()=>tt.success("Link copied")).catch(()=>tt.error("Could not copy link"))}function R(j){if(m(""),!Mo.includes(j.type)){m("Only png, jpg, webp allowed");return}if(j.size>Lo){m("Max 5MB");return}c(j)}async function C(j){if(j.preventDefault(),!s.trim()&&!a)return;u(!0);const P=new FormData;P.append("build_id",String(t)),P.append("body",s),a&&P.append("attachment",a),(await fetch("/api/v1/comments",{method:"POST",credentials:"include",body:P})).ok&&(i(""),c(null),x()),u(!1)}const A=No(e);return n.jsxs("div",{className:"flex h-full flex-col gap-3 px-1",children:[n.jsx($n,{className:"flex-1 rounded-md border",children:n.jsx("div",{className:"p-3",children:e.length===0?n.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"No comments yet."}):n.jsx("div",{className:"flex flex-col",children:A.map(({label:j,items:P})=>n.jsxs("div",{children:[n.jsxs("div",{className:"flex items-center gap-2 py-3",children:[n.jsx("div",{className:"h-px flex-1 bg-border"}),n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground px-1 select-none",children:j}),n.jsx("div",{className:"h-px flex-1 bg-border"})]}),n.jsx("div",{className:"flex flex-col gap-4",children:P.map(_=>n.jsxs("div",{id:`comment-${_.id}`,ref:L=>{d.current[_.id]=L},className:"group flex gap-2.5 rounded-md px-2 py-1.5 transition-all",children:[n.jsx("div",{className:"mt-0.5 shrink-0",children:n.jsx(er,{name:_.author,avatarUrl:_.authorAvatarUrl,size:28})}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-sm font-semibold leading-none",children:_.author}),n.jsx("span",{className:"text-[11px] text-muted-foreground leading-none",children:Do(_.created_at)}),n.jsx(ae,{variant:"ghost",size:"icon",className:"h-4 w-4 ml-0.5 opacity-0 group-hover:opacity-50 hover:!opacity-100 transition-opacity",onClick:()=>y(_.id),children:n.jsx(yn,{className:"h-3 w-3"})})]}),n.jsx("p",{className:"text-sm leading-relaxed whitespace-pre-wrap mt-1",children:_.body}),_.attachments.map(L=>n.jsx("a",{href:L.file_path,target:"_blank",rel:"noreferrer",className:"mt-1.5 block",children:n.jsx("img",{src:L.file_path,alt:"attachment",className:"max-h-48 rounded border object-contain"})},L.id))]})]},_.id))})]},j))})})}),n.jsx("div",{className:"pb-1",children:n.jsx("form",{onSubmit:C,children:n.jsxs("div",{className:"rounded-xl border border-input bg-background ring-offset-background transition-shadow focus-within:outline-none focus-within:ring-2 focus-within:ring-ring focus-within:ring-offset-2",children:[n.jsx(An,{placeholder:"Leave a comment…",value:s,onChange:j=>i(j.target.value),className:"min-h-16 resize-none border-0 bg-transparent shadow-none focus-visible:ring-0 focus-visible:ring-offset-0 text-sm"}),(a||p)&&n.jsxs("div",{className:"px-3 -mt-1 pb-1",children:[a&&n.jsx("p",{className:"text-xs text-muted-foreground",children:a.name}),p&&n.jsx("p",{className:"text-xs text-destructive",children:p})]}),n.jsxs("div",{className:"flex items-center gap-2 px-2 py-2",children:[n.jsx(ae,{type:"button",variant:"ghost",size:"icon",className:"h-7 w-7 text-muted-foreground",onClick:()=>{var j;return(j=g.current)==null?void 0:j.click()},children:n.jsx(Mr,{className:"h-4 w-4"})}),n.jsx("input",{ref:g,type:"file",accept:"image/png,image/jpeg,image/webp",className:"hidden",onChange:j=>{var _;const P=(_=j.target.files)==null?void 0:_[0];P&&R(P)}}),n.jsx("div",{className:"flex-1"}),n.jsx(ae,{type:"submit",size:"icon",className:"h-7 w-7 rounded-full",disabled:f||!s.trim()&&!a,children:n.jsx(kr,{className:"h-3.5 w-3.5"})})]})]})})})]})}function Uo(t){return t<1024*1024?`${(t/1024).toFixed(0)} KB`:`${(t/1024/1024).toFixed(1)} MB`}function Ho(t){return new Date(t).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Fo(t){const e=new Date(t).getTime()-Date.now();if(e<=0)return{label:"Expired",urgent:!0};const r=Math.floor(e/36e5);return r<1?{label:"< 1 hour left",urgent:!0}:r<24?{label:`Expires in ${r}h`,urgent:r<6}:{label:`Expires in ${Math.floor(r/24)}d`,urgent:!1}}function Bo({buildId:t,refreshKey:e}){const[r,s]=o.useState([]),[i,a]=o.useState(!0),[c,f]=o.useState(!1);return o.useEffect(()=>{a(!0),f(!1);const u=setTimeout(()=>f(!0),250);return fetch(`/api/v1/recordings?buildId=${t}`,{credentials:"include"}).then(p=>p.ok?p.json():[]).then(p=>s(p)).catch(()=>s([])).finally(()=>{clearTimeout(u),a(!1)}),()=>clearTimeout(u)},[t,e]),i?c?n.jsx("p",{className:"text-xs text-muted-foreground",children:"Loading recordings…"}):null:r.length===0?n.jsx("p",{className:"py-8 text-center text-sm text-muted-foreground",children:"No recordings yet."}):n.jsx("div",{className:"flex flex-col gap-2",children:r.map(u=>{const p=Fo(u.expiresAt);return n.jsxs("div",{className:"flex items-center justify-between rounded-md border border-border px-3 py-2 text-sm",children:[n.jsxs("div",{className:"flex flex-col gap-0.5 min-w-0",children:[n.jsx("span",{className:"text-xs font-medium truncate",children:Ho(u.createdAt)}),n.jsxs("span",{className:`text-xs ${p.urgent?"text-destructive":"text-muted-foreground"}`,children:[p.label," · ",Uo(u.fileSize)]})]}),n.jsx(ae,{variant:"ghost",size:"icon",className:"h-7 w-7 shrink-0 ml-2",title:"Download",onClick:()=>{const m=document.createElement("a");m.href=u.url,m.download="",m.click()},children:n.jsx(Ar,{className:"h-3.5 w-3.5"})})]},u.id)})})}function $o({buildId:t,recordingsRefreshKey:e=0}){return n.jsxs(fr,{defaultValue:"comments",className:"flex h-full flex-col",children:[n.jsx("div",{className:"shrink-0 px-1",children:n.jsxs(hr,{className:"w-full",children:[n.jsxs(qt,{value:"comments",className:"flex-1 gap-1.5",children:[n.jsx(zr,{className:"h-3.5 w-3.5"}),"Comments"]}),n.jsxs(qt,{value:"recordings",className:"flex-1 gap-1.5",children:[n.jsx(Nr,{className:"h-3.5 w-3.5"}),"Recordings"]})]})}),n.jsx(Jt,{value:"comments",className:"mt-3 min-h-0 flex-1 overflow-hidden",children:n.jsx(Io,{buildId:t})}),n.jsx(Jt,{value:"recordings",className:"mt-3 min-h-0 flex-1 overflow-y-auto",children:n.jsx(Bo,{buildId:t,refreshKey:e})})]})}const Wn=o.forwardRef(({...t},e)=>n.jsx("nav",{ref:e,"aria-label":"breadcrumb",...t}));Wn.displayName="Breadcrumb";const Vn=o.forwardRef(({className:t,...e},r)=>n.jsx("ol",{ref:r,className:Z("flex flex-wrap items-center gap-1.5 break-words text-sm text-muted-foreground sm:gap-2.5",t),...e}));Vn.displayName="BreadcrumbList";const dt=o.forwardRef(({className:t,...e},r)=>n.jsx("li",{ref:r,className:Z("inline-flex items-center gap-1.5",t),...e}));dt.displayName="BreadcrumbItem";const vt=o.forwardRef(({asChild:t,className:e,...r},s)=>{const i=t?tr:"a";return n.jsx(i,{ref:s,className:Z("transition-colors hover:text-foreground cursor-pointer",e),...r})});vt.displayName="BreadcrumbLink";const wt=o.forwardRef(({className:t,...e},r)=>n.jsx("span",{ref:r,role:"link","aria-disabled":"true","aria-current":"page",className:Z("font-medium text-foreground",t),...e}));wt.displayName="BreadcrumbPage";const St=({children:t,className:e,...r})=>n.jsx("li",{role:"presentation","aria-hidden":"true",className:Z("[&>svg]:h-3.5 [&>svg]:w-3.5",e),...r,children:t??n.jsx(nr,{})});St.displayName="BreadcrumbSeparator";var Oo=Object.defineProperty,$e=(t,e)=>Oo(t,"name",{value:e,configurable:!0}),Wt="Switch",[zo]=fn(Wt),[Wo,Vt]=zo(Wt);function Kn(t){const{__scopeSwitch:e,checked:r,children:s,defaultChecked:i,disabled:a,form:c,name:f,onCheckedChange:u,required:p,value:m="on",internal_do_not_use_render:g}=t,[d,x]=sr({prop:r,defaultProp:i??!1,onChange:u,caller:Wt}),[y,R]=o.useState(null),[C,A]=o.useState(null),j=o.useRef(!1),[P,_]=o.useReducer(M=>M+1,0),L=y?!!c||!!y.closest("form"):!0,E={checked:d,setChecked:x,disabled:a,control:y,setControl:R,name:f,form:c,value:m,hasConsumerStoppedPropagationRef:j,userInteractionCount:P,onUserInteraction:_,required:p,defaultChecked:i,isFormControl:L,bubbleInput:C,setBubbleInput:A};return n.jsx(Wo,{scope:e,...E,children:Yn(g)?g(E):s})}$e(Kn,"SwitchProvider");var Vo="SwitchTrigger",Ko=o.forwardRef($e(function({__scopeSwitch:e,onClick:r,...s},i){const{control:a,form:c,value:f,disabled:u,checked:p,required:m,setControl:g,setChecked:d,hasConsumerStoppedPropagationRef:x,onUserInteraction:y,isFormControl:R,bubbleInput:C}=Vt(Vo,e),A=Oe(i,g),j=o.useRef(p);return o.useEffect(()=>{const P=c?a==null?void 0:a.ownerDocument.getElementById(c):a==null?void 0:a.form;if(P instanceof HTMLFormElement){const _=$e(()=>d(j.current),"reset");return P.addEventListener("reset",_),()=>P.removeEventListener("reset",_)}},[a,c,d]),n.jsx(ze.button,{type:"button",role:"switch","aria-checked":p,"aria-required":m,"data-state":Kt(p),"data-disabled":u?"":void 0,disabled:u,value:f,...s,ref:A,onClick:Le(r,P=>{y(),d(_=>!_),C&&R&&(x.current=P.isPropagationStopped(),x.current||P.stopPropagation())})})},"SwitchTrigger")),Xn=o.forwardRef($e(function(e,r){const{__scopeSwitch:s,name:i,checked:a,defaultChecked:c,required:f,disabled:u,value:p,onCheckedChange:m,form:g,...d}=e;return n.jsx(Kn,{__scopeSwitch:s,checked:a,defaultChecked:c,disabled:u,required:f,onCheckedChange:m,name:i,form:g,value:p,internal_do_not_use_render:({isFormControl:x})=>n.jsxs(n.Fragment,{children:[n.jsx(Ko,{...d,ref:r,__scopeSwitch:s}),x&&n.jsx(qo,{__scopeSwitch:s})]})})},"Switch")),Xo="SwitchThumb",Yo=o.forwardRef($e(function(e,r){const{__scopeSwitch:s,...i}=e,a=Vt(Xo,s);return n.jsx(ze.span,{"data-state":Kt(a.checked),"data-disabled":a.disabled?"":void 0,...i,ref:r})},"SwitchThumb")),Go="SwitchBubbleInput",qo=o.forwardRef($e(function({__scopeSwitch:e,onClick:r,...s},i){const{control:a,hasConsumerStoppedPropagationRef:c,userInteractionCount:f,checked:u,defaultChecked:p,required:m,disabled:g,name:d,value:x,form:y,bubbleInput:R,setBubbleInput:C}=Vt(Go,e),A=Oe(i,C),j=rr(a),P=o.useRef(!1),_=o.useRef(u),L=o.useRef(f);o.useEffect(()=>{const M=R;if(!M)return;const G=window.HTMLInputElement.prototype,$=Object.getOwnPropertyDescriptor(G,"checked").set,W=f!==L.current;L.current=f;const Y=_.current!==u;_.current=u;const Re=!(W&&c.current);if(Y&&$){P.current=!W;const ce=new Event("click",{bubbles:Re});$.call(M,u),M.dispatchEvent(ce),P.current=!1}},[R,u,c,f]);const E=o.useRef(u);return n.jsx(ze.input,{type:"checkbox","aria-hidden":!0,defaultChecked:p??E.current,required:m,disabled:g,name:d,value:x,form:y,...s,tabIndex:-1,ref:A,onClick:Le(r,M=>{P.current&&M.stopPropagation()}),style:{...s.style,...j,position:"absolute",pointerEvents:"none",opacity:0,margin:0,transform:"translateX(-100%)"}})},"SwitchBubbleInput"));function Yn(t){return typeof t=="function"}$e(Yn,"isFunction");function Kt(t){return t?"checked":"unchecked"}$e(Kt,"getState");const Gn=o.forwardRef(({className:t,...e},r)=>n.jsx(Xn,{className:Z("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",t),...e,ref:r,children:n.jsx(Yo,{className:Z("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})}));Gn.displayName=Xn.displayName;const an=70,cn=80;function Jo(t,e){if(!t||e)return"unknown";const r=t.memUsedMB/t.memTotalMB*100;return t.cpuPercent>cn||r>cn?"overloaded":t.cpuPercent>=an||r>=an?"warning":"healthy"}function sa(){const[t]=un(),e=or(),r=t.get("id"),{build:s}=ss(r),[i,a]=o.useState(0),c=(s==null?void 0:s.platform)??"ios",{sessions:f,selectedAgent:u,setSelectedAgent:p,activeSessionId:m,deviceId:g,booting:d,status:x,connected:y,agentGroups:R,startDevice:C,resetDevice:A,handleBack:j,handleBackToMacs:P}=os(c),_=R.find(F=>F.agentName===u),{osVersions:L,osVersion:E,setOsVersion:M,deviceSearch:G,setDeviceSearch:Q,versionedDevices:$,resetMode:W,setResetMode:Y}=as(_,c),ce=f.flatMap(F=>F.devices).find(F=>F.id===g),le=ce?`${ce.name}${ce.osVersion?` · ${ce.osVersion}`:""}`:"",he=o.useCallback(()=>a(F=>F+1),[]),{setNode:xe}=ar();return o.useEffect(()=>{if(s)return xe(n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx(Wn,{children:n.jsxs(Vn,{children:[n.jsx(dt,{children:n.jsx(vt,{asChild:!0,children:n.jsx("button",{onClick:()=>e(`/app-center?appId=${s.app_id}`),children:s.name})})}),n.jsx(St,{}),n.jsx(dt,{children:u?n.jsx(vt,{asChild:!0,children:n.jsx("button",{onClick:P,children:Gt(s)})}):n.jsx(wt,{children:Gt(s)})}),u&&n.jsxs(n.Fragment,{children:[n.jsx(St,{}),n.jsx(dt,{children:m?n.jsx(vt,{asChild:!0,children:n.jsx("button",{onClick:j,children:u})}):n.jsx(wt,{children:u})})]}),m&&n.jsxs(n.Fragment,{children:[n.jsx(St,{}),n.jsx(dt,{children:n.jsx(wt,{children:le})})]})]})}),!u&&s.status_label&&n.jsx(Sr,{tone:ur[s.status_label],children:s.status_label})]})),()=>xe(null)},[s,u,m,le,e,j,P,xe]),n.jsxs("div",{className:"flex h-full min-h-0 gap-6 p-6",children:[n.jsx("div",{className:"flex flex-col gap-3 flex-1 min-w-0 min-h-0",children:n.jsx("div",{className:"flex-1 min-h-0 overflow-auto -ml-1 pl-1 -mr-4 pr-4",children:m?n.jsx("div",{className:"min-h-full flex items-center justify-center py-6 px-8 min-w-max",children:n.jsx(ho,{sessionId:m,deviceId:g,buildId:s==null?void 0:s.id,resetMode:W,onRecordingUploaded:he})}):u?n.jsxs("div",{className:"flex flex-col gap-5",children:[n.jsxs("div",{className:"flex items-center gap-3",children:[n.jsx("button",{onClick:P,className:"text-sm text-muted-foreground hover:text-foreground transition-colors",children:"← All Macs"}),n.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Select device"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(dr,{placeholder:"Search device…",value:G,onChange:Q}),L.length>0&&n.jsxs(br,{value:E||"__all__",onValueChange:F=>{M(F==="__all__"?"":F),A()},children:[n.jsx(yr,{className:"h-8 w-36 shrink-0",children:n.jsx(vr,{})}),n.jsxs(wr,{children:[n.jsx(Zt,{value:"__all__",children:"Any version"}),L.map(F=>n.jsx(Zt,{value:F,children:F},F))]})]}),n.jsx(Pt,{children:n.jsxs(Ce,{children:[n.jsxs("div",{className:"ml-auto flex items-center gap-2 shrink-0",children:[n.jsx(ke,{asChild:!0,children:n.jsxs(ir,{htmlFor:"reset-mode",className:"flex items-center gap-1 text-sm cursor-pointer whitespace-nowrap",children:[n.jsx(Ur,{className:"h-3.5 w-3.5 text-muted-foreground"}),"Full reset"]})}),n.jsx(Gn,{id:"reset-mode",checked:W==="full-erase",onCheckedChange:F=>Y(F?"full-erase":"app-only")})]}),n.jsx(Ee,{children:W==="full-erase"?"Erase all data before booting":"Keep existing data"})]})})]}),$.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:y?"No devices available for this OS.":"Connecting to relay…"}):n.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-2",children:$.map(F=>{const X=F.status==="booted",z=F.busy,pe=z?"In use":X?"Booted":"Available",se=z?"bg-amber-400":X?"bg-emerald-400":"bg-muted-foreground/40";return n.jsxs("button",{disabled:z||d||!y,onClick:()=>C(F),className:Z("flex flex-col gap-3 rounded-lg border p-3 text-left transition-colors min-h-[100px]","hover:bg-accent disabled:cursor-not-allowed disabled:opacity-50"),children:[n.jsx("span",{className:"text-sm font-medium leading-tight",children:F.name}),F.osVersion&&n.jsx("span",{className:"font-mono text-xs text-muted-foreground",children:F.osVersion}),n.jsxs("span",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[n.jsx("span",{className:Z("inline-block h-1.5 w-1.5 rounded-full",se)}),pe]})]},F.id)})}),x&&n.jsx("p",{className:"text-sm text-muted-foreground",children:x})]}):n.jsxs("div",{className:"flex flex-col gap-5",children:[n.jsx("h1",{className:"text-xl font-semibold tracking-tight",children:"Select Mac"}),R.length===0?n.jsx("p",{className:"text-sm text-muted-foreground",children:y?`No agents available for ${c}.`:"Connecting to relay…"}):n.jsx("div",{className:"grid grid-cols-1 lg:grid-cols-2 2xl:grid-cols-3 gap-2",children:R.map(F=>{const X=F.resources,z=X?Date.now()-X.reportedAt>3e4:!1,pe=F.devices.filter(Te=>Te.platform===c).length,se=(X==null?void 0:X.cpuPercent)??0,oe=X?X.memUsedMB/X.memTotalMB*100:0,Ie=Jo(X,z),q=Ie==="overloaded";return n.jsx(Pt,{children:n.jsxs(Ce,{children:[n.jsx(ke,{asChild:!0,children:n.jsx("span",{tabIndex:q?0:void 0,className:q?"cursor-not-allowed":void 0,children:n.jsxs("button",{disabled:q,"aria-disabled":q,onClick:()=>p(F.agentName??null),className:Z("flex flex-col gap-3 rounded-lg border p-3 text-left transition-colors min-h-[100px] w-full",q?"pointer-events-none":"hover:bg-accent"),children:[n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[n.jsx(Zo,{health:Ie}),n.jsx("span",{className:"text-sm font-medium leading-tight truncate",children:F.agentName??"Unknown"})]}),z&&n.jsx("span",{className:"shrink-0 text-[10px] font-medium text-amber-500",children:"Stale"})]}),n.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-muted-foreground",children:[n.jsxs("span",{children:[pe," device",pe!==1?"s":""]}),X&&n.jsxs(n.Fragment,{children:[n.jsx("span",{children:"·"}),n.jsxs("span",{children:[X.slotsAvailable,"/",X.slotsTotal," slots"]})]})]}),X&&!z&&n.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[n.jsx(ln,{label:"CPU",percent:se,colorClass:"bg-blue-400"}),n.jsx(ln,{label:"RAM",percent:oe,colorClass:"bg-violet-400"})]})]})})}),q&&n.jsx(Ee,{children:"This Mac is currently overloaded. Try again later."})]})},F.agentName)})})]})})}),r&&n.jsxs(n.Fragment,{children:[n.jsx(dn,{orientation:"vertical",className:"h-auto"}),n.jsx("div",{className:"w-80 shrink-0 h-full",children:n.jsx($o,{buildId:Number(r),recordingsRefreshKey:i})})]})]})}function Zo({health:t}){const e={unknown:"bg-muted-foreground/40",healthy:"bg-emerald-400",warning:"bg-amber-400",overloaded:"bg-red-500"}[t];return n.jsx("span",{"data-testid":"resource-health-dot",className:Z("inline-block h-2 w-2 shrink-0 rounded-full",e)})}function ln({label:t,percent:e,colorClass:r}){return n.jsxs("div",{className:"flex flex-col gap-0.5",children:[n.jsxs("div",{className:"flex justify-between text-[10px] text-muted-foreground",children:[n.jsx("span",{children:t}),n.jsxs("span",{children:[e.toFixed(0),"%"]})]}),n.jsx("div",{className:"h-1 w-full rounded-full bg-muted overflow-hidden",children:n.jsx("div",{className:Z("h-full rounded-full transition-all",r),style:{width:`${Math.min(100,e)}%`}})})]})}export{sa as QASession};
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ak as b,al as S,a6 as m,ah as k,a9 as C,a3 as s,C as h,c as p,d as x,b as f,a as P,L as u,I as w,B as E,a4 as F,a7 as j}from"./index-CBnxiD7-.js";const T=F({password:j().min(8),confirm:j()}).refine(r=>r.password===r.confirm,{message:"Passwords do not match",path:["confirm"]});function L(){const r=b(),[g]=S(),a=g.get("token")??"",[n,t]=m.useState("loading"),{register:o,handleSubmit:v,setError:d,formState:{errors:e,isSubmitting:c}}=k({resolver:C(T),mode:"onBlur"});m.useEffect(()=>{if(!a){t("invalid");return}fetch(`/api/v1/auth/reset-password/verify?token=${a}`).then(i=>i.ok?t("valid"):Promise.reject()).catch(()=>t("invalid"))},[a]);async function N(i){try{const l=await fetch("/api/v1/auth/reset-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:a,password:i.password})});if(!l.ok){const y=await l.json();d("root",{message:y.error??"Failed to reset password"});return}r("/login",{replace:!0})}catch{d("root",{message:"Network error. Please try again."})}}return n==="loading"?s.jsx("div",{className:"flex min-h-svh items-center justify-center"}):n==="invalid"?s.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:s.jsx(h,{level:4,className:"w-full max-w-sm text-center",children:s.jsxs(p,{children:[s.jsx(x,{children:"Link expired"}),s.jsx(f,{children:"This password reset link is invalid or has expired. Ask your admin to send a new one."})]})})}):s.jsx("div",{className:"bg-mesh-gradient flex min-h-svh items-center justify-center overflow-hidden p-4",children:s.jsxs(h,{level:4,className:"w-full max-w-sm",children:[s.jsxs(p,{className:"text-center",children:[s.jsx(x,{children:"Reset password"}),s.jsx(f,{children:"Enter your new password below."})]}),s.jsx(P,{children:s.jsxs("form",{onSubmit:v(N),className:"flex flex-col gap-4",children:[s.jsxs("div",{className:"grid gap-2",children:[s.jsx(u,{htmlFor:"password",children:"New password"}),s.jsx(w,{id:"password",type:"password",...o("password")}),e.password&&s.jsx("p",{className:"text-sm text-destructive",children:e.password.message})]}),s.jsxs("div",{className:"grid gap-2",children:[s.jsx(u,{htmlFor:"confirm",children:"Confirm password"}),s.jsx(w,{id:"confirm",type:"password",...o("confirm")}),e.confirm&&s.jsx("p",{className:"text-sm text-destructive",children:e.confirm.message})]}),e.root&&s.jsx("p",{className:"text-sm text-destructive",children:e.root.message}),s.jsx(E,{type:"submit",disabled:c,className:"w-full",children:c?"Saving…":"Set new password"})]})})]})})}export{L as ResetPassword};
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{ak as f,ao as g,ah as w,a9 as j,a6 as v,a3 as e,C as N,c as y,d as b,a as C,L as i,I as o,B as S,a4 as k,a7 as l}from"./index-CBnxiD7-.js";const E=k({email:l().email("Enter a valid email"),password:l().min(8,"Password must be at least 8 characters"),confirm:l()}).refine(a=>a.password===a.confirm,{message:"Passwords do not match",path:["confirm"]});function P(){const a=f(),{resolvedTheme:d}=g(),p=d==="dark"?"/logo-dark.svg":"/logo.svg",{register:r,handleSubmit:x,setError:c,formState:{errors:s,isSubmitting:n}}=w({resolver:j(E),mode:"onBlur"});v.useEffect(()=>{fetch("/api/v1/auth/status").then(t=>t.json()).then(({initialized:t})=>{t&&a("/login",{replace:!0})}).catch(()=>{})},[a]);async function h(t){try{const m=await fetch("/api/v1/auth/init",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:t.email,password:t.password})});if(!m.ok){const u=await m.json();c("root",{message:u.error??"Failed to create account"});return}a("/login",{replace:!0})}catch{c("root",{message:"Network error. Please try again."})}}return e.jsx("div",{className:"flex min-h-svh items-center justify-center overflow-hidden p-4",children:e.jsxs("div",{className:"flex flex-col items-center gap-6 w-full max-w-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("img",{src:p,alt:"tapflow",className:"w-6 h-6"}),e.jsx("span",{className:"text-base font-semibold tracking-tight",children:"tapflow"})]}),e.jsxs(N,{level:4,className:"w-full",children:[e.jsx(y,{className:"text-center",children:e.jsx(b,{className:"text-2xl tracking-display-md",children:"Set up tapflow"})}),e.jsx(C,{children:e.jsxs("form",{onSubmit:x(h),className:"flex flex-col gap-4",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"email",children:"Admin email"}),e.jsx(o,{id:"email",type:"email",placeholder:"admin@yourteam.com",autoComplete:"email",...r("email")}),s.email&&e.jsx("p",{className:"text-sm text-destructive",children:s.email.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"password",children:"Password"}),e.jsx(o,{id:"password",type:"password",autoComplete:"new-password",...r("password")}),s.password&&e.jsx("p",{className:"text-sm text-destructive",children:s.password.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(i,{htmlFor:"confirm",children:"Confirm password"}),e.jsx(o,{id:"confirm",type:"password",autoComplete:"new-password",...r("confirm")}),s.confirm&&e.jsx("p",{className:"text-sm text-destructive",children:s.confirm.message})]}),s.root&&e.jsx("p",{className:"text-sm text-destructive",children:s.root.message}),e.jsx(S,{type:"submit",size:"lg",disabled:n,className:"w-full mt-1",children:n?"Creating account…":"Create admin account"})]})})]})]})})}export{P as Setup};
|
|
Binary file
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a6 as n,ah as $,a9 as H,a3 as e,B as d,a8 as t,L as k,I as S,C as O,c as z,d as V,b as W,a as M,a4 as J,a7 as A}from"./index-CBnxiD7-.js";import{B as I}from"./badge-CavXTq2x.js";import{A as U,c as q,f as G,g as K,d as Q,e as X,b as Y}from"./alert-dialog-CXwkFlF3.js";import{D as Z,f as ee,a as se,d as te,e as ae,S as ne,i as re,j as oe,g as ie,h as B}from"./dialog-JbKwqqS0.js";import{T as le,d as ce,e as w,c as x,a as de,b as i}from"./table-CqOA0Bb1.js";import{P as xe,T as he}from"./trash-2-CwlFrbEF.js";async function me(){const a=window.location.protocol==="https:"?"wss":"ws";if(["localhost","127.0.0.1","[::1]"].includes(window.location.hostname))try{const h=await fetch("/api/v1/relay/host",{credentials:"include"});if(h.ok){const{lanHost:l,port:o}=await h.json();if(l)return`${a}://${l}:${o}`}}catch{}return`${a}://${window.location.host}`}const pe=J({name:A().min(1),expiresDays:A().refine(a=>{const r=parseInt(a,10);return!isNaN(r)&&r>=1&&r<=365},{message:"Must be between 1 and 365"})});function ye(){const[a,r]=n.useState([]),[h,l]=n.useState(!1),[o,y]=n.useState(""),[c,v]=n.useState("api"),[N,b]=n.useState(""),[u,j]=n.useState(null),{register:T,handleSubmit:E,reset:_,formState:{errors:m,isSubmitting:C}}=$({resolver:H(pe),mode:"onBlur",defaultValues:{name:"",expiresDays:"30"}});function g(){fetch("/api/v1/tokens",{credentials:"include"}).then(s=>s.json()).then(r)}n.useEffect(()=>{g()},[]);async function F(s){try{const p=await fetch("/api/v1/tokens",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json"},body:JSON.stringify({name:s.name,expires_in_days:parseInt(s.expiresDays,10),...c==="agent"?{scope:"agent"}:{}})});if(!p.ok){const f=await p.json().catch(()=>null);t.error((f==null?void 0:f.error)??"Failed to create token");return}const P=await p.json();c==="agent"&&b(await me()),t.success("Token created"),y(P.token),g()}catch{t.error("Network error")}}function R(s){l(s),s||(y(""),v("api"),b(""),_())}async function L(s){try{return(await fetch(`/api/v1/tokens/${s}`,{method:"DELETE",credentials:"include"})).ok?(t.success("Token revoked"),g(),!0):(t.error("Failed to revoke token"),!1)}catch{return t.error("Network error"),!1}}function D(s){return s.expires_at&&new Date(s.expires_at)<new Date}return e.jsxs("div",{className:"flex flex-col gap-6 max-w-[900px] mx-auto w-full p-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h1",{className:"text-xl font-semibold",children:"Personal Access Tokens"}),e.jsxs(Z,{open:h,onOpenChange:R,children:[e.jsx(ee,{asChild:!0,children:e.jsxs(d,{size:"sm",children:[e.jsx(xe,{className:"mr-2 h-4 w-4"}),"New token"]})}),e.jsxs(se,{className:"sm:max-w-md",children:[e.jsx(te,{children:e.jsx(ae,{children:"Create token"})}),o?e.jsxs("div",{className:"flex flex-col gap-3 pt-2",children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Copy this token now — it won't be shown again."}),e.jsx("code",{className:"rounded bg-muted px-3 py-2 text-xs break-all font-mono",children:o}),c==="agent"&&N&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:"Run this on the agent Mac to connect it to this relay:"}),e.jsx("code",{className:"rounded bg-muted px-3 py-2 text-xs break-all font-mono",children:`tapflow agent start --relay ${N} --token ${o}`})]}),e.jsx(d,{onClick:()=>{navigator.clipboard.writeText(o).then(()=>{t.success("Token copied to clipboard"),l(!1)}).catch(()=>t.error("Failed to copy — copy manually"))},children:"Copy & close"})]}):e.jsxs("form",{onSubmit:E(F),className:"flex flex-col gap-4 pt-2",children:[e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"token-name",children:"Name"}),e.jsx(S,{id:"token-name",placeholder:"e.g. ci-deploy",...T("name")}),m.name&&e.jsx("p",{className:"text-sm text-destructive",children:m.name.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"expires",children:"Expires in (days)"}),e.jsx(S,{id:"expires",type:"number",...T("expiresDays")}),m.expiresDays&&e.jsx("p",{className:"text-sm text-destructive",children:m.expiresDays.message})]}),e.jsxs("div",{className:"grid gap-2",children:[e.jsx(k,{htmlFor:"token-type",children:"Type"}),e.jsxs(ne,{value:c,onValueChange:s=>v(s),children:[e.jsx(re,{id:"token-type",children:e.jsx(oe,{})}),e.jsxs(ie,{children:[e.jsx(B,{value:"api",children:"API — CI uploads & API access"}),e.jsx(B,{value:"agent",children:"Agent — connect remote device agents (Admin only)"})]})]})]}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Scope: ",e.jsx(I,{variant:"secondary",children:c==="agent"?"agent":"view, builds:write"})]}),e.jsx(d,{type:"submit",disabled:C,children:C?"Creating…":"Create token"})]})]})]})]}),e.jsxs(O,{children:[e.jsxs(z,{children:[e.jsx(V,{children:"Active tokens"}),e.jsxs(W,{children:["Use these tokens with ",e.jsx("code",{className:"text-xs",children:"Authorization: Bearer <token>"})," for API deployments."]})]}),e.jsx(M,{className:"px-4 pt-0 pb-2",children:e.jsxs(le,{children:[e.jsx(ce,{children:e.jsxs(w,{children:[e.jsx(x,{children:"Name"}),e.jsx(x,{children:"Scope"}),e.jsx(x,{children:"Last used"}),e.jsx(x,{children:"Expires"}),e.jsx(x,{className:"w-10"})]})}),e.jsx(de,{children:a.length===0?e.jsx(w,{children:e.jsx(i,{colSpan:5,className:"h-20 text-center text-muted-foreground",children:"No tokens yet."})}):a.map(s=>e.jsxs(w,{className:"hover:bg-transparent",children:[e.jsx(i,{className:"font-medium",children:s.name}),e.jsx(i,{children:e.jsx(I,{variant:"secondary",children:s.scope})}),e.jsx(i,{className:"text-muted-foreground text-sm",children:s.last_used_at?new Date(s.last_used_at).toLocaleDateString():"Never"}),e.jsx(i,{children:s.expires_at?e.jsx("span",{className:D(s)?"text-destructive text-sm":"text-muted-foreground text-sm",children:D(s)?"Expired":new Date(s.expires_at).toLocaleDateString()}):e.jsx("span",{className:"text-muted-foreground text-sm",children:"Never"})}),e.jsx(i,{children:e.jsx(d,{variant:"destructive",size:"icon",className:"h-7 w-7","aria-label":"Revoke token",onClick:()=>j(s.id),children:e.jsx(he,{className:"h-4 w-4"})})})]},s.id))})]})})]}),e.jsx(U,{open:u!==null,onOpenChange:s=>{s||j(null)},children:e.jsxs(q,{children:[e.jsxs(G,{children:[e.jsx(K,{children:"Revoke token?"}),e.jsx(Q,{children:"Any active API calls using this token will immediately fail."})]}),e.jsxs(X,{children:[e.jsx(Y,{children:"Cancel"}),e.jsx(d,{variant:"destructive",onClick:async()=>{if(u===null)return;await L(u)&&j(null)},children:"Revoke"})]})]})})]})}export{ye as TokenSettings};
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a6 as r,a3 as o,m as O,ad as u,j as T,K as S,n as b,k as $,i as m,Q as v,l as E,O as h,D as z,o as F,J as g,H as x}from"./index-CBnxiD7-.js";var H=Object.defineProperty,n=(t,e)=>H(t,"name",{value:e,configurable:!0}),k="AlertDialog",[M]=h(k,[v]),c=v(),I=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(z,{...l,...a,modal:!0})},"AlertDialog"),J=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(F,{...s,...i,ref:a})},"AlertDialogTrigger")),K=n(t=>{const{__scopeAlertDialog:e,...a}=t,l=c(e);return o.jsx(O,{...l,...a})},"AlertDialogPortal"),L=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(E,{...s,...i,ref:a})},"AlertDialogOverlay")),Q="AlertDialogContent",[V,q]=M(Q),B=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,children:i,...s}=e,p=c(l),f=r.useRef(null),P=u(a,f),D=r.useRef(null);return o.jsx(V,{scope:l,cancelRef:D,children:o.jsx(T,{role:"alertdialog",...p,...s,ref:P,onOpenAutoFocus:S(s.onOpenAutoFocus,d=>{var A;d.preventDefault(),(A=D.current)==null||A.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:i})})},"AlertDialogContent")),G=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(b,{...s,...i,ref:a})},"AlertDialogTitle")),U=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx($,{...s,...i,ref:a})},"AlertDialogDescription")),W=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,s=c(l);return o.jsx(m,{...s,...i,ref:a})},"AlertDialogAction")),X="AlertDialogCancel",Y=r.forwardRef(n(function(e,a){const{__scopeAlertDialog:l,...i}=e,{cancelRef:s}=q(X,l),p=c(l),f=u(a,s);return o.jsx(m,{...p,...i,ref:f})},"AlertDialogCancel")),Z=I,ee=J,ae=K,N=L,y=B,_=W,j=Y,C=G,R=U;const de=Z,pe=ee,te=ae,w=r.forwardRef(({className:t,...e},a)=>o.jsx(N,{className:g("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",t),...e,ref:a}));w.displayName=N.displayName;const oe=r.forwardRef(({className:t,...e},a)=>o.jsxs(te,{children:[o.jsx(w,{}),o.jsx(y,{ref:a,className:g("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",t),...e})]}));oe.displayName=y.displayName;const le=({className:t,...e})=>o.jsx("div",{className:g("flex flex-col space-y-2 text-center sm:text-left",t),...e});le.displayName="AlertDialogHeader";const re=({className:t,...e})=>o.jsx("div",{className:g("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",t),...e});re.displayName="AlertDialogFooter";const se=r.forwardRef(({className:t,...e},a)=>o.jsx(C,{ref:a,className:g("text-lg font-semibold",t),...e}));se.displayName=C.displayName;const ie=r.forwardRef(({className:t,...e},a)=>o.jsx(R,{ref:a,className:g("text-sm text-muted-foreground",t),...e}));ie.displayName=R.displayName;const ne=r.forwardRef(({className:t,...e},a)=>o.jsx(_,{ref:a,className:g(x(),t),...e}));ne.displayName=_.displayName;const ce=r.forwardRef(({className:t,...e},a)=>o.jsx(j,{ref:a,className:g(x({variant:"outline"}),"mt-2 sm:mt-0",t),...e}));ce.displayName=j.displayName;export{de as A,ne as a,ce as b,oe as c,ie as d,re as e,le as f,se as g,pe as h};
|
|
Binary file
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a3 as n,J as d,a0 as o}from"./index-CBnxiD7-.js";const s=o("inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors",{variants:{variant:{default:"border-transparent bg-primary text-primary-foreground",secondary:"border-transparent bg-secondary text-secondary-foreground",destructive:"border-transparent bg-destructive text-destructive-foreground",outline:"text-foreground"},tone:{backlog:"border-transparent bg-zinc-100 text-zinc-600 dark:bg-zinc-800 dark:text-zinc-400",progress:"border-transparent bg-blue-50 text-blue-700 dark:bg-blue-950 dark:text-blue-300",done:"border-transparent bg-green-50 text-green-700 dark:bg-green-950 dark:text-green-300",rejected:"border-transparent bg-red-50 text-red-700 dark:bg-red-950 dark:text-red-300",ios:"border-transparent bg-sky-50 text-sky-700 dark:bg-sky-950 dark:text-sky-300",android:"border-transparent bg-emerald-50 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-300"}},defaultVariants:{variant:"default"}});function g({className:r,variant:e,tone:t,...a}){return n.jsx("div",{className:d(s({variant:e,tone:t}),r),...a})}export{g as B};
|
|
Binary file
|
|
Binary file
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import{W as je,a6 as t,ad as U,a3 as n,A as ot,t as L,K as j,P as nt,aj as X,s as rt,ac as we,ai as De,a5 as Me,Y as Oe,N as st,a2 as at,ag as lt,R as ct,F as it,p as dt,O as ut,$ as pt,g as ft,V as mt,af as ht,ae as Te,v as gt,J as M,e as St,D as xt,o as vt,m as wt,j as ke,i as yt,X as Ct,n as Le,l as Ae,k as Be}from"./index-CBnxiD7-.js";/**
|
|
2
|
-
* @license lucide-react v0.577.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const bt=[["path",{d:"m6 9 6 6 6-6",key:"qrunsl"}]],Ve=je("chevron-down",bt);/**
|
|
7
|
-
* @license lucide-react v0.577.0 - ISC
|
|
8
|
-
*
|
|
9
|
-
* This source code is licensed under the ISC license.
|
|
10
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
-
*/const It=[["path",{d:"m18 15-6-6-6 6",key:"153udz"}]],Tt=je("chevron-up",It);function Pe(s,[e,r]){return Math.min(r,Math.max(e,s))}function Pt(s){const e=t.useRef({value:s,previous:s});return t.useMemo(()=>(e.current.value!==s&&(e.current.previous=e.current.value,e.current.value=s),e.current.previous),[s])}var Nt=Object.defineProperty,x=(s,e)=>Nt(s,"name",{value:e,configurable:!0}),Rt=[" ","Enter","ArrowUp","ArrowDown"],_t=[" ","Enter"],ie="Select",[me,he,Et]=st(ie),[re]=ut(ie,[Et,Oe]),ye=Oe(),[jt,Z]=re(ie),[Dt,Mt]=re(ie);function He(s){const{__scopeSelect:e,children:r,open:o,defaultOpen:u,onOpenChange:i,value:f,defaultValue:c,onValueChange:l,dir:a,name:S,autoComplete:v,disabled:C,required:I,form:T,internal_do_not_use_render:R}=s,d=ye(e),[h,y]=t.useState(null),[m,p]=t.useState(null),[_,E]=t.useState(!1),J=ht(a),[k,B]=Te({prop:o,defaultProp:u??!1,onChange:i,caller:ie}),[Q,z]=Te({prop:f,defaultProp:c,onChange:l,caller:ie}),W=t.useRef(null),K=t.useRef(Q);t.useEffect(()=>{const D=T?h==null?void 0:h.ownerDocument.getElementById(T):h==null?void 0:h.form;if(D instanceof HTMLFormElement){const F=x(()=>z(K.current),"reset");return D.addEventListener("reset",F),()=>D.removeEventListener("reset",F)}},[T,h,z]);const ee=h?!!T||!!h.closest("form"):!0,[$,V]=t.useState(new Set),G=De(),Y=Array.from($).map(D=>D.props.value).join(";"),q=t.useCallback(D=>{V(F=>new Set(F).add(D))},[]),H=t.useCallback(D=>{V(F=>{const le=new Set(F);return le.delete(D),le})},[]),ae={required:I,trigger:h,onTriggerChange:y,valueNode:m,onValueNodeChange:p,valueNodeHasChildren:_,onValueNodeHasChildrenChange:E,contentId:G,value:Q,onValueChange:z,open:k,onOpenChange:B,dir:J,triggerPointerDownPosRef:W,disabled:C,name:S,autoComplete:v,form:T,nativeOptions:$,nativeSelectKey:Y,isFormControl:ee};return n.jsx(gt,{...d,children:n.jsx(jt,{scope:e,...ae,children:n.jsx(me.Provider,{scope:e,children:n.jsx(Dt,{scope:e,onNativeOptionAdd:q,onNativeOptionRemove:H,children:Ze(R)?R(ae):r})})})})}x(He,"SelectProvider");var Ot=x(s=>{const{__scopeSelect:e,children:r,...o}=s;return n.jsx(He,{__scopeSelect:e,...o,internal_do_not_use_render:({isFormControl:u})=>n.jsxs(n.Fragment,{children:[r,u?n.jsx(no,{__scopeSelect:e}):null]})})},"Select"),kt="SelectTrigger",Fe=t.forwardRef(x(function(e,r){const{__scopeSelect:o,disabled:u=!1,...i}=e,f=ye(o),c=Z(kt,o),l=c.disabled||u,a=U(r,c.onTriggerChange),S=he(o),v=t.useRef("touch"),[C,I,T]=be(d=>{const h=S().filter(p=>!p.disabled),y=h.find(p=>p.value===c.value),m=Ie(h,d,y);m!==void 0&&c.onValueChange(m.value)}),R=x(d=>{l||(c.onOpenChange(!0),T()),d&&(c.triggerPointerDownPosRef.current={x:Math.round(d.pageX),y:Math.round(d.pageY)})},"handleOpen");return n.jsx(ot,{asChild:!0,...f,children:n.jsx(L.button,{type:"button",role:"combobox","aria-controls":c.open?c.contentId:void 0,"aria-expanded":c.open,"aria-required":c.required,"aria-autocomplete":"none",dir:c.dir,"data-state":c.open?"open":"closed",disabled:l,"data-disabled":l?"":void 0,"data-placeholder":ue(c.value)?"":void 0,...i,ref:a,onClick:j(i.onClick,d=>{d.currentTarget.focus(),v.current!=="mouse"&&R(d)}),onPointerDown:j(i.onPointerDown,d=>{v.current=d.pointerType;const h=d.target;h.hasPointerCapture(d.pointerId)&&h.releasePointerCapture(d.pointerId),d.button===0&&d.ctrlKey===!1&&d.pointerType==="mouse"&&(R(d),d.preventDefault())}),onKeyDown:j(i.onKeyDown,d=>{const h=C.current!=="";!(d.ctrlKey||d.altKey||d.metaKey)&&d.key.length===1&&I(d.key),!(h&&d.key===" ")&&Rt.includes(d.key)&&(R(),d.preventDefault())})})})},"SelectTrigger")),Lt="SelectValue",At=t.forwardRef(x(function(e,r){const{__scopeSelect:o,className:u,style:i,children:f,placeholder:c="",...l}=e,a=Z(Lt,o),{onValueNodeHasChildrenChange:S}=a,v=f!==void 0,C=U(r,a.onValueNodeChange);X(()=>{S(v)},[S,v]);const I=ue(a.value);return n.jsx(L.span,{...l,asChild:I?!1:l.asChild,ref:C,style:{pointerEvents:"none"},children:n.jsx(t.Fragment,{children:I?c:f},I?"placeholder":"value")})},"SelectValue")),Bt=t.forwardRef(x(function(e,r){const{__scopeSelect:o,children:u,...i}=e;return n.jsx(L.span,{"aria-hidden":!0,...i,ref:r,children:u||"▼"})},"SelectIcon")),Vt="SelectPortal",[Ht,Ft]=re(Vt,{forceMount:void 0}),Ut=x(s=>{const{__scopeSelect:e,forceMount:r,...o}=s;return n.jsx(Ht,{scope:s.__scopeSelect,forceMount:r,children:n.jsx(nt,{asChild:!0,...o})})},"SelectPortal"),ne="SelectContent",Ue=t.forwardRef(x(function(e,r){const o=Ft(ne,e.__scopeSelect),{forceMount:u=o.forceMount,...i}=e,f=Z(ne,e.__scopeSelect),[c,l]=t.useState();return X(()=>{l(new DocumentFragment)},[]),n.jsx(rt,{present:u||f.open,children:({present:a})=>a?n.jsx($t,{...i,ref:r}):n.jsx(Wt,{...i,fragment:c})})},"SelectContent")),Wt=t.forwardRef(x(function(e,r){const{__scopeSelect:o,children:u,fragment:i}=e;return i?Me.createPortal(n.jsx(We,{scope:o,children:n.jsx(me.Slot,{scope:o,children:n.jsx("div",{ref:r,children:u})})}),i):null},"SelectContentFragment")),A=10,[We,se]=re(ne),Kt=pt("SelectContent.RemoveScroll"),$t=t.forwardRef(x(function(e,r){const{__scopeSelect:o}=e,{position:u="item-aligned",onCloseAutoFocus:i,onEscapeKeyDown:f,onPointerDownOutside:c,side:l,sideOffset:a,align:S,alignOffset:v,arrowPadding:C,collisionBoundary:I,collisionPadding:T,sticky:R,hideWhenDetached:d,avoidCollisions:h,...y}=e,m=Z(ne,o),[p,_]=t.useState(null),[E,J]=t.useState(null),k=U(r,_),[B,Q]=t.useState(null),[z,W]=t.useState(null),K=he(o),[ee,$]=t.useState(!1),V=t.useRef(!1);t.useEffect(()=>{if(p)return at(p)},[p]),lt();const G=t.useCallback(g=>{const[N,...O]=K().map(b=>b.ref.current),[P]=O.slice(-1),w=document.activeElement;for(const b of g)if(b===w||(b==null||b.scrollIntoView({block:"nearest"}),b===N&&E&&(E.scrollTop=0),b===P&&E&&(E.scrollTop=E.scrollHeight),b==null||b.focus(),document.activeElement!==w))return},[K,E]),Y=t.useCallback(()=>G([B,p]),[G,B,p]);t.useEffect(()=>{ee&&Y()},[ee,Y]);const{onOpenChange:q,triggerPointerDownPosRef:H}=m;t.useEffect(()=>{if(p){let g={x:0,y:0};const N=x(P=>{var w,b;g={x:Math.abs(Math.round(P.pageX)-(((w=H.current)==null?void 0:w.x)??0)),y:Math.abs(Math.round(P.pageY)-(((b=H.current)==null?void 0:b.y)??0))}},"handlePointerMove"),O=x(P=>{g.x<=10&&g.y<=10?P.preventDefault():P.composedPath().includes(p)||q(!1),document.removeEventListener("pointermove",N),H.current=null},"handlePointerUp");return H.current!==null&&(document.addEventListener("pointermove",N),document.addEventListener("pointerup",O,{capture:!0,once:!0})),()=>{document.removeEventListener("pointermove",N),document.removeEventListener("pointerup",O,{capture:!0})}}},[p,q,H]),t.useEffect(()=>{const g=x(()=>q(!1),"close");return window.addEventListener("blur",g),window.addEventListener("resize",g),()=>{window.removeEventListener("blur",g),window.removeEventListener("resize",g)}},[q]);const[ae,D]=be(g=>{const N=K().filter(w=>!w.disabled),O=N.find(w=>w.ref.current===document.activeElement),P=Ie(N,g,O);P&&setTimeout(()=>{var w;return(w=P.ref.current)==null?void 0:w.focus()})}),F=t.useCallback((g,N,O)=>{const P=!V.current&&!O;(m.value!==void 0&&m.value===N||P)&&(Q(g),P&&(V.current=!0))},[m.value]),le=t.useCallback(()=>p==null?void 0:p.focus(),[p]),ce=t.useCallback((g,N,O)=>{const P=!V.current&&!O;(m.value!==void 0&&m.value===N||P)&&W(g)},[m.value]),pe=u==="popper"?Ne:zt,de=pe===Ne?{side:l,sideOffset:a,align:S,alignOffset:v,arrowPadding:C,collisionBoundary:I,collisionPadding:T,sticky:R,hideWhenDetached:d,avoidCollisions:h}:{};return n.jsx(We,{scope:o,content:p,viewport:E,onViewportChange:J,itemRefCallback:F,selectedItem:B,onItemLeave:le,itemTextRefCallback:ce,focusSelectedItem:Y,selectedItemText:z,position:u,isPositioned:ee,searchRef:ae,children:n.jsx(ct,{as:Kt,allowPinchZoom:!0,children:n.jsx(it,{asChild:!0,trapped:m.open,onMountAutoFocus:g=>{g.preventDefault()},onUnmountAutoFocus:j(i,g=>{var N;(N=m.trigger)==null||N.focus({preventScroll:!0}),g.preventDefault()}),children:n.jsx(dt,{asChild:!0,disableOutsidePointerEvents:!0,onEscapeKeyDown:f,onPointerDownOutside:c,onFocusOutside:g=>g.preventDefault(),onDismiss:()=>m.onOpenChange(!1),children:n.jsx(pe,{role:"listbox",id:m.contentId,"data-state":m.open?"open":"closed",dir:m.dir,onContextMenu:g=>g.preventDefault(),...y,...de,onPlaced:()=>$(!0),ref:k,style:{display:"flex",flexDirection:"column",outline:"none",...y.style},onKeyDown:j(y.onKeyDown,g=>{const N=g.ctrlKey||g.altKey||g.metaKey;if(g.key==="Tab"&&g.preventDefault(),!N&&g.key.length===1&&D(g.key),["ArrowUp","ArrowDown","Home","End"].includes(g.key)){let P=K().filter(w=>!w.disabled).map(w=>w.ref.current);if(["ArrowUp","End"].includes(g.key)&&(P=P.slice().reverse()),["ArrowUp","ArrowDown"].includes(g.key)){const w=g.target,b=P.indexOf(w);P=P.slice(b+1)}setTimeout(()=>G(P)),g.preventDefault()}})})})})})})},"SelectContentImpl")),zt=t.forwardRef(x(function(e,r){const{__scopeSelect:o,onPlaced:u,...i}=e,f=Z(ne,o),c=se(ne,o),[l,a]=t.useState(null),[S,v]=t.useState(null),C=U(r,v),I=he(o),T=t.useRef(!1),R=t.useRef(!0),{viewport:d,selectedItem:h,selectedItemText:y,focusSelectedItem:m}=c,p=t.useCallback(()=>{if(f.trigger&&f.valueNode&&l&&S&&d&&h&&y){const k=f.trigger.getBoundingClientRect(),B=S.getBoundingClientRect(),Q=f.valueNode.getBoundingClientRect(),z=y.getBoundingClientRect();if(f.dir!=="rtl"){const w=z.left-B.left,b=Q.left-w,te=k.left-b,oe=k.width+te,ge=Math.max(oe,B.width),Se=window.innerWidth-A,xe=Pe(b,[A,Math.max(A,Se-ge)]);l.style.minWidth=oe+"px",l.style.left=xe+"px"}else{const w=B.right-z.right,b=window.innerWidth-Q.right-w,te=window.innerWidth-k.right-b,oe=k.width+te,ge=Math.max(oe,B.width),Se=window.innerWidth-A,xe=Pe(b,[A,Math.max(A,Se-ge)]);l.style.minWidth=oe+"px",l.style.right=xe+"px"}const W=I(),K=window.innerHeight-A*2,ee=d.scrollHeight,$=window.getComputedStyle(S),V=parseInt($.borderTopWidth,10),G=parseInt($.paddingTop,10),Y=parseInt($.borderBottomWidth,10),q=parseInt($.paddingBottom,10),H=V+G+ee+q+Y,ae=Math.min(h.offsetHeight*5,H),D=window.getComputedStyle(d),F=parseInt(D.paddingTop,10),le=parseInt(D.paddingBottom,10),ce=k.top+k.height/2-A,pe=K-ce,de=h.offsetHeight/2,g=h.offsetTop+de,N=V+G+g,O=H-N;if(N<=ce){const w=W.length>0&&h===W[W.length-1].ref.current;l.style.bottom="0px";const b=S.clientHeight-d.offsetTop-d.offsetHeight,te=Math.max(pe,de+(w?le:0)+b+Y),oe=N+te;l.style.height=oe+"px"}else{const w=W.length>0&&h===W[0].ref.current;l.style.top="0px";const te=Math.max(ce,V+d.offsetTop+(w?F:0)+de)+O;l.style.height=te+"px",d.scrollTop=N-ce+d.offsetTop}l.style.margin=`${A}px 0`,l.style.minHeight=ae+"px",l.style.maxHeight=K+"px",u==null||u(),requestAnimationFrame(()=>T.current=!0)}},[I,f.trigger,f.valueNode,l,S,d,h,y,f.dir,u]);X(()=>p(),[p]);const[_,E]=t.useState();X(()=>{S&&E(window.getComputedStyle(S).zIndex)},[S]);const J=t.useCallback(k=>{k&&R.current===!0&&(p(),m==null||m(),R.current=!1)},[p,m]);return n.jsx(Gt,{scope:o,contentWrapper:l,shouldExpandOnScrollRef:T,onScrollButtonChange:J,children:n.jsx("div",{ref:a,style:{display:"flex",flexDirection:"column",position:"fixed",zIndex:_},children:n.jsx(L.div,{...i,ref:C,style:{boxSizing:"border-box",maxHeight:"100%",...i.style}})})})},"SelectItemAlignedPosition")),Ne=t.forwardRef(x(function(e,r){const{__scopeSelect:o,align:u="start",collisionPadding:i=A,...f}=e,c=ye(o);return n.jsx(ft,{...c,...f,ref:r,align:u,collisionPadding:i,style:{boxSizing:"border-box",...f.style,"--radix-select-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-select-content-available-width":"var(--radix-popper-available-width)","--radix-select-content-available-height":"var(--radix-popper-available-height)","--radix-select-trigger-width":"var(--radix-popper-anchor-width)","--radix-select-trigger-height":"var(--radix-popper-anchor-height)"}})},"SelectPopperPosition")),[Gt,Ce]=re(ne,{}),Re="SelectViewport",Yt=t.forwardRef(x(function(e,r){const{__scopeSelect:o,nonce:u,...i}=e,f=se(Re,o),c=Ce(Re,o),l=U(r,f.onViewportChange),a=t.useRef(0);return n.jsxs(n.Fragment,{children:[n.jsx("style",{dangerouslySetInnerHTML:{__html:"[data-radix-select-viewport]{scrollbar-width:none;-ms-overflow-style:none;-webkit-overflow-scrolling:touch;}[data-radix-select-viewport]::-webkit-scrollbar{display:none}"},nonce:u}),n.jsx(me.Slot,{scope:o,children:n.jsx(L.div,{"data-radix-select-viewport":"",role:"presentation",...i,ref:l,style:{position:"relative",flex:1,overflow:"hidden auto",...i.style},onScroll:j(i.onScroll,S=>{const v=S.currentTarget,{contentWrapper:C,shouldExpandOnScrollRef:I}=c;if(I!=null&&I.current&&C){const T=Math.abs(a.current-v.scrollTop);if(T>0){const R=window.innerHeight-A*2,d=parseFloat(C.style.minHeight),h=parseFloat(C.style.height),y=Math.max(d,h);if(y<R){const m=y+T,p=Math.min(R,m),_=m-p;C.style.height=p+"px",C.style.bottom==="0px"&&(v.scrollTop=_>0?_:0,C.style.justifyContent="flex-end")}}}a.current=v.scrollTop})})})]})},"SelectViewport")),qt="SelectGroup",[So,Xt]=re(qt),Zt="SelectLabel",Ke=t.forwardRef(x(function(e,r){const{__scopeSelect:o,...u}=e,i=Xt(Zt,o);return n.jsx(L.div,{id:i.id,...u,ref:r})},"SelectLabel")),ve="SelectItem",[Jt,$e]=re(ve),ze=t.forwardRef(x(function(e,r){const{__scopeSelect:o,value:u,disabled:i=!1,textValue:f,...c}=e,l=Z(ve,o),a=se(ve,o),S=l.value===u,[v,C]=t.useState(f??""),[I,T]=t.useState(!1),R=we(p=>{var _;return(_=a.itemRefCallback)==null?void 0:_.call(a,p,u,i)}),d=U(r,R),h=De(),y=t.useRef("touch"),m=x(()=>{i||(l.onValueChange(u),l.onOpenChange(!1))},"handleSelect");return n.jsx(Jt,{scope:o,value:u,disabled:i,textId:h,isSelected:S,onItemTextChange:t.useCallback(p=>{C(_=>_||((p==null?void 0:p.textContent)??"").trim())},[]),children:n.jsx(me.ItemSlot,{scope:o,value:u,disabled:i,textValue:v,children:n.jsx(L.div,{role:"option","aria-labelledby":h,"data-highlighted":I?"":void 0,"aria-selected":S&&I,"data-state":S?"checked":"unchecked","aria-disabled":i||void 0,"data-disabled":i?"":void 0,tabIndex:i?void 0:-1,...c,ref:d,onFocus:j(c.onFocus,()=>T(!0)),onBlur:j(c.onBlur,()=>T(!1)),onClick:j(c.onClick,()=>{y.current!=="mouse"&&m()}),onPointerUp:j(c.onPointerUp,()=>{y.current==="mouse"&&m()}),onPointerDown:j(c.onPointerDown,p=>{y.current=p.pointerType}),onPointerMove:j(c.onPointerMove,p=>{var _;y.current=p.pointerType,i?(_=a.onItemLeave)==null||_.call(a):y.current==="mouse"&&p.currentTarget.focus({preventScroll:!0})}),onPointerLeave:j(c.onPointerLeave,p=>{var _;p.currentTarget===document.activeElement&&((_=a.onItemLeave)==null||_.call(a))}),onKeyDown:j(c.onKeyDown,p=>{var E;i||p.target!==p.currentTarget||((E=a.searchRef)==null?void 0:E.current)!==""&&p.key===" "||(_t.includes(p.key)&&m(),p.key===" "&&p.preventDefault())})})})})},"SelectItem")),fe="SelectItemText",Qt=t.forwardRef(x(function(e,r){const{__scopeSelect:o,className:u,style:i,...f}=e,c=Z(fe,o),l=se(fe,o),a=$e(fe,o),S=Mt(fe,o),[v,C]=t.useState(null),I=we(m=>{var p;return(p=l.itemTextRefCallback)==null?void 0:p.call(l,m,a.value,a.disabled)}),T=U(r,C,a.onItemTextChange,I),R=v==null?void 0:v.textContent,d=t.useMemo(()=>n.jsx("option",{value:a.value,disabled:a.disabled,children:R},a.value),[a.disabled,a.value,R]),{onNativeOptionAdd:h,onNativeOptionRemove:y}=S;return X(()=>(h(d),()=>y(d)),[h,y,d]),n.jsxs(n.Fragment,{children:[n.jsx(L.span,{id:a.textId,...f,ref:T}),a.isSelected&&c.valueNode&&!c.valueNodeHasChildren&&!ue(c.value)?Me.createPortal(f.children,c.valueNode):null]})},"SelectItemText")),eo="SelectItemIndicator",to=t.forwardRef(x(function(e,r){const{__scopeSelect:o,...u}=e;return $e(eo,o).isSelected?n.jsx(L.span,{"aria-hidden":!0,...u,ref:r}):null},"SelectItemIndicator")),_e="SelectScrollUpButton",Ge=t.forwardRef(x(function(e,r){const o=se(_e,e.__scopeSelect),u=Ce(_e,e.__scopeSelect),[i,f]=t.useState(!1),c=U(r,u.onScrollButtonChange);return X(()=>{if(o.viewport&&o.isPositioned){let l=function(){const S=a.scrollTop>0;f(S)};x(l,"handleScroll");const a=o.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[o.viewport,o.isPositioned]),i?n.jsx(qe,{...e,ref:c,onAutoScroll:()=>{const{viewport:l,selectedItem:a}=o;l&&a&&(l.scrollTop=l.scrollTop-a.offsetHeight)}}):null},"SelectScrollUpButton")),Ee="SelectScrollDownButton",Ye=t.forwardRef(x(function(e,r){const o=se(Ee,e.__scopeSelect),u=Ce(Ee,e.__scopeSelect),[i,f]=t.useState(!1),c=U(r,u.onScrollButtonChange);return X(()=>{if(o.viewport&&o.isPositioned){let l=function(){const S=a.scrollHeight-a.clientHeight,v=Math.ceil(a.scrollTop)<S;f(v)};x(l,"handleScroll");const a=o.viewport;return l(),a.addEventListener("scroll",l),()=>a.removeEventListener("scroll",l)}},[o.viewport,o.isPositioned]),i?n.jsx(qe,{...e,ref:c,onAutoScroll:()=>{const{viewport:l,selectedItem:a}=o;l&&a&&(l.scrollTop=l.scrollTop+a.offsetHeight)}}):null},"SelectScrollDownButton")),qe=t.forwardRef(x(function(e,r){const{__scopeSelect:o,onAutoScroll:u,...i}=e,f=se("SelectScrollButton",o),c=t.useRef(null),l=he(o),a=t.useCallback(()=>{c.current!==null&&(window.clearInterval(c.current),c.current=null)},[]);return t.useEffect(()=>()=>a(),[a]),X(()=>{var v;const S=l().find(C=>C.ref.current===document.activeElement);(v=S==null?void 0:S.ref.current)==null||v.scrollIntoView({block:"nearest"})},[l]),n.jsx(L.div,{"aria-hidden":!0,...i,ref:r,style:{flexShrink:0,...i.style},onPointerDown:j(i.onPointerDown,()=>{c.current===null&&(c.current=window.setInterval(u,50))}),onPointerMove:j(i.onPointerMove,()=>{var S;(S=f.onItemLeave)==null||S.call(f),c.current===null&&(c.current=window.setInterval(u,50))}),onPointerLeave:j(i.onPointerLeave,()=>{a()})})},"SelectScrollButtonImpl")),Xe=t.forwardRef(x(function(e,r){const{__scopeSelect:o,...u}=e;return n.jsx(L.div,{"aria-hidden":!0,...u,ref:r})},"SelectSeparator")),oo="SelectBubbleInput",no=t.forwardRef(x(function({__scopeSelect:e,...r},o){const u=Z(oo,e),{value:i,onValueChange:f,required:c,disabled:l,name:a,autoComplete:S,form:v}=u,{nativeOptions:C,nativeSelectKey:I}=u,T=t.useRef(null),R=U(o,T),d=i??"",h=Pt(d),y=Array.from(C).some(m=>(m.props.value??"")==="");return t.useEffect(()=>{const m=T.current;if(!m)return;const p=window.HTMLSelectElement.prototype,E=Object.getOwnPropertyDescriptor(p,"value").set;if(h!==d&&E){const J=new Event("change",{bubbles:!0});E.call(m,d),m.dispatchEvent(J)}},[h,d]),n.jsxs(L.select,{"aria-hidden":!0,required:c,tabIndex:-1,name:a,autoComplete:S,disabled:l,form:v,onChange:m=>f(m.target.value),...r,style:{...mt,...r.style},ref:R,defaultValue:d,children:[ue(i)&&!y?n.jsx("option",{value:""}):null,Array.from(C)]},I)},"SelectBubbleInput"));function Ze(s){return typeof s=="function"}x(Ze,"isFunction");function ue(s){return s===""||s===void 0}x(ue,"shouldShowPlaceholder");function be(s){const e=we(s),r=t.useRef(""),o=t.useRef(0),u=t.useCallback(f=>{const c=r.current+f;e(c),x((function l(a){r.current=a,window.clearTimeout(o.current),a!==""&&(o.current=window.setTimeout(()=>l(""),1e3))}),"updateSearch")(c)},[e]),i=t.useCallback(()=>{r.current="",window.clearTimeout(o.current)},[]);return t.useEffect(()=>()=>window.clearTimeout(o.current),[]),[r,u,i]}x(be,"useTypeaheadSearch");function Ie(s,e,r){const u=e.length>1&&Array.from(e).every(a=>a===e[0])?e[0]:e,i=r?s.indexOf(r):-1;let f=Je(s,Math.max(i,0));u.length===1&&(f=f.filter(a=>a!==r));const l=f.find(a=>a.textValue.toLowerCase().startsWith(u.toLowerCase()));return l!==r?l:void 0}x(Ie,"findNextItem");function Je(s,e){return s.map((r,o)=>s[(e+o)%s.length])}x(Je,"wrapArray");const xo=Ot,vo=At,ro=t.forwardRef(({className:s,children:e,...r},o)=>n.jsxs(Fe,{ref:o,className:M("flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background data-[placeholder]:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50 [&>span]:line-clamp-1",s),...r,children:[e,n.jsx(Bt,{asChild:!0,children:n.jsx(Ve,{className:"h-4 w-4 opacity-50"})})]}));ro.displayName=Fe.displayName;const Qe=t.forwardRef(({className:s,...e},r)=>n.jsx(Ge,{ref:r,className:M("flex cursor-default items-center justify-center py-1",s),...e,children:n.jsx(Tt,{className:"h-4 w-4"})}));Qe.displayName=Ge.displayName;const et=t.forwardRef(({className:s,...e},r)=>n.jsx(Ye,{ref:r,className:M("flex cursor-default items-center justify-center py-1",s),...e,children:n.jsx(Ve,{className:"h-4 w-4"})}));et.displayName=Ye.displayName;const so=t.forwardRef(({className:s,children:e,position:r="popper",...o},u)=>n.jsx(Ut,{children:n.jsxs(Ue,{ref:u,className:M("relative z-50 max-h-[--radix-select-content-available-height] min-w-[8rem] overflow-y-auto overflow-x-hidden rounded-md border bg-popover text-popover-foreground shadow-md data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-select-content-transform-origin]",r==="popper"&&"data-[side=bottom]:translate-y-1 data-[side=left]:-translate-x-1 data-[side=right]:translate-x-1 data-[side=top]:-translate-y-1",s),position:r,...o,children:[n.jsx(Qe,{}),n.jsx(Yt,{className:M("p-1",r==="popper"&&"h-[var(--radix-select-trigger-height)] w-full min-w-[var(--radix-select-trigger-width)]"),children:e}),n.jsx(et,{})]})}));so.displayName=Ue.displayName;const ao=t.forwardRef(({className:s,...e},r)=>n.jsx(Ke,{ref:r,className:M("py-1.5 pl-8 pr-2 text-sm font-semibold",s),...e}));ao.displayName=Ke.displayName;const lo=t.forwardRef(({className:s,children:e,...r},o)=>n.jsxs(ze,{ref:o,className:M("relative flex w-full cursor-default select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none focus:bg-accent focus:text-accent-foreground data-[disabled]:pointer-events-none data-[disabled]:opacity-50",s),...r,children:[n.jsx("span",{className:"absolute left-2 flex h-3.5 w-3.5 items-center justify-center",children:n.jsx(to,{children:n.jsx(St,{className:"h-4 w-4"})})}),n.jsx(Qt,{children:e})]}));lo.displayName=ze.displayName;const co=t.forwardRef(({className:s,...e},r)=>n.jsx(Xe,{ref:r,className:M("-mx-1 my-1 h-px bg-muted",s),...e}));co.displayName=Xe.displayName;const wo=xt,yo=vt,io=wt,tt=t.forwardRef(({className:s,...e},r)=>n.jsx(Ae,{ref:r,className:M("fixed inset-0 z-50 bg-black/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0",s),...e}));tt.displayName=Ae.displayName;const uo=t.forwardRef(({className:s,children:e,...r},o)=>n.jsxs(io,{children:[n.jsx(tt,{}),n.jsxs(ke,{ref:o,className:M("fixed left-[50%] top-[50%] z-50 grid w-full max-w-lg translate-x-[-50%] translate-y-[-50%] gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[state=closed]:slide-out-to-left-1/2 data-[state=closed]:slide-out-to-top-[48%] data-[state=open]:slide-in-from-left-1/2 data-[state=open]:slide-in-from-top-[48%] sm:rounded-lg",s),...r,children:[e,n.jsxs(yt,{className:"absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",children:[n.jsx(Ct,{className:"h-4 w-4"}),n.jsx("span",{className:"sr-only",children:"Close"})]})]})]}));uo.displayName=ke.displayName;const po=({className:s,...e})=>n.jsx("div",{className:M("flex flex-col space-y-1.5 text-center sm:text-left",s),...e});po.displayName="DialogHeader";const fo=({className:s,...e})=>n.jsx("div",{className:M("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",s),...e});fo.displayName="DialogFooter";const mo=t.forwardRef(({className:s,...e},r)=>n.jsx(Le,{ref:r,className:M("text-lg font-semibold leading-none tracking-tight",s),...e}));mo.displayName=Le.displayName;const ho=t.forwardRef(({className:s,...e},r)=>n.jsx(Be,{ref:r,className:M("text-sm text-muted-foreground",s),...e}));ho.displayName=Be.displayName;export{Ve as C,wo as D,xo as S,uo as a,ho as b,fo as c,po as d,mo as e,yo as f,so as g,lo as h,ro as i,vo as j,Pe as k};
|
|
Binary file
|