dsh-mobile-plugin 0.5.77 → 0.5.78
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/lib/frpc/runner.cjs +30 -2
- package/lib/impl.js +4 -4
- package/lib/p2p/wiring.cjs +4 -2
- package/lib/panel/index.html +1 -1
- package/lib/relay/control.js +10 -0
- package/lib/relay/lan-proxy.js +3 -3
- package/lib/relay/tunnel-forwarder.cjs +15 -5
- package/lib/relay/tunnel.js +5 -2
- package/lib/remote/runtime.cjs +2 -1
- package/lib/sidecar-facade-worker.cjs +11 -4
- package/lib/tailcat/wiring.cjs +4 -2
- package/package.json +1 -1
package/lib/frpc/runner.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
// 2026-11-19:启动失败时把「系统拒绝执行」的具体原因和排查方向讲清楚,不再只甩一句 spawn UNKNOWN。
|
|
4
|
+
|
|
3
5
|
/**
|
|
4
6
|
* 在本机跑一个 frpc 进程,让面板导入的 FRP 配置真正生效。
|
|
5
7
|
*
|
|
@@ -47,6 +49,32 @@ function withAdminPort(text, port) {
|
|
|
47
49
|
return source.replace(/(\[\[\s*proxies\s*\]\])/i, `${block}$1`);
|
|
48
50
|
}
|
|
49
51
|
|
|
52
|
+
/**
|
|
53
|
+
* 把「进程起不来」的底层报错翻成用户能照着排查的话。
|
|
54
|
+
*
|
|
55
|
+
* 最常见的两种:Windows 上安全软件不让跑刚下载的 exe(Node 报 `spawn UNKNOWN`),以及文件
|
|
56
|
+
* 根本不是这台机器能执行的东西(`ENOEXEC`、架构不符)。这两种在 Node 里都只是一句干巴巴的
|
|
57
|
+
* `spawn UNKNOWN`,直接甩给用户等于什么也没说——所以带上文件位置,并指明该往哪查。
|
|
58
|
+
*/
|
|
59
|
+
function describeSpawnFailure(err, binary) {
|
|
60
|
+
const code = err && err.code ? String(err.code) : '';
|
|
61
|
+
const raw = err && err.message ? err.message : String(err || '未知错误');
|
|
62
|
+
const where = binary ? `(${binary})` : '';
|
|
63
|
+
if (code === 'UNKNOWN') {
|
|
64
|
+
return `系统拒绝运行 frpc${where}:多半是安全软件(如 Windows Defender)拦了这个程序,或下载到的版本与本机芯片不符。请把它加入杀毒/安全软件的信任名单,或换成与本机匹配的 frpc 版本。`;
|
|
65
|
+
}
|
|
66
|
+
if (code === 'ENOEXEC') {
|
|
67
|
+
return `frpc${where} 不是这台机器能执行的程序:文件可能已损坏,或版本/架构不对。请重新获取一份与本机匹配的 frpc。`;
|
|
68
|
+
}
|
|
69
|
+
if (code === 'EACCES' || code === 'EPERM') {
|
|
70
|
+
return `系统不允许运行 frpc${where}:权限被拒。请检查这个文件是否被禁止执行或被安全策略拦截。`;
|
|
71
|
+
}
|
|
72
|
+
if (code === 'ENOENT') {
|
|
73
|
+
return `找不到 frpc 可执行文件${where}:它可能已被删除或路径失效,请重新获取。`;
|
|
74
|
+
}
|
|
75
|
+
return `启动 frpc 失败:${raw}`;
|
|
76
|
+
}
|
|
77
|
+
|
|
50
78
|
function frpcPaths(root) {
|
|
51
79
|
// 配置与「启用」标记放在**单独目录**:`provision` 的缓存根是 `<DSH 数据目录>/frpc`,它在
|
|
52
80
|
// 装好新二进制后会清掉那里除版本号外的条目——放一起会把正在用的 frpc.toml 一起删掉。
|
|
@@ -173,7 +201,7 @@ function createFrpcRunner(options = {}) {
|
|
|
173
201
|
try {
|
|
174
202
|
proc = spawnImpl(binary, ['-c', paths.config], { stdio: ['ignore', 'ignore', 'pipe'], windowsHide: true });
|
|
175
203
|
} catch (err) {
|
|
176
|
-
error =
|
|
204
|
+
error = describeSpawnFailure(err, binary);
|
|
177
205
|
child = null;
|
|
178
206
|
return status();
|
|
179
207
|
}
|
|
@@ -190,7 +218,7 @@ function createFrpcRunner(options = {}) {
|
|
|
190
218
|
stream.on('data', (chunk) => { tail = (tail + String(chunk)).slice(-1500); });
|
|
191
219
|
}
|
|
192
220
|
if (typeof proc.on === 'function') {
|
|
193
|
-
proc.on('error', (err) => { error =
|
|
221
|
+
proc.on('error', (err) => { error = describeSpawnFailure(err, binary); });
|
|
194
222
|
// 用 close 而不是 exit:exit 触发时 stdio 里可能还有没读完的输出,太早拼文案会把
|
|
195
223
|
// 刚写出来的原因丢掉;close 保证流都关了、tail 收全。
|
|
196
224
|
proc.on('close', (code, signal) => {
|
package/lib/impl.js
CHANGED
|
@@ -373,8 +373,8 @@ function apply(ctx) {
|
|
|
373
373
|
getHistoryKey: () => core.ensureHistoryKey(state),
|
|
374
374
|
getRelayConnected: () => relayConnectedOf(),
|
|
375
375
|
})
|
|
376
|
-
const tailcat = mountTailcat({ mount, warn, state, saveState: core.saveState, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () => ctx.webServer.port, hostName: () => state.name, ctx, name })
|
|
377
|
-
const p2p = mountP2P({ mount, warn, state, saveState: core.saveState, localPort: lanPortInUse, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () => ctx.webServer.port, ctx, name })
|
|
376
|
+
const tailcat = mountTailcat({ mount, warn, state, saveState: core.saveState, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () => ctx.webServer.port, webHost: () => ctx.webServer.host, hostName: () => state.name, ctx, name })
|
|
377
|
+
const p2p = mountP2P({ mount, warn, state, saveState: core.saveState, localPort: lanPortInUse, lanEnabled: () => state.lanEnabled, lanPort: lanPortInUse, webPort: () => ctx.webServer.port, webHost: () => ctx.webServer.host, ctx, name })
|
|
378
378
|
|
|
379
379
|
// sidecar 子进程的全部生命周期:起停、配置下发、自重启、健康轮询。
|
|
380
380
|
const sidecarLifecycle = createSidecarLifecycle({
|
|
@@ -391,7 +391,7 @@ function apply(ctx) {
|
|
|
391
391
|
// 密钥(协议 v2 的请求在旁路里解封)。漏了票据时旁路读到的是空串,任何一次扫码配对
|
|
392
392
|
// 都回「配对码错误或桌面端已拒绝」,而主进程那条 `/pair` 一切正常 —— 症状是「同一个
|
|
393
393
|
// 二维码,走中转能配、走局域网不能」。
|
|
394
|
-
buildConfig: (lanPort) => ({ enabled: state.enabled, relayUrl: state.relayUrl, relayUrls: core.relayAddressesOf(state).relayUrls, instanceId: state.instanceId, pairingCode: state.pairingCode, pairingTicket: state.pairingTicket || '', pairingTier: permissions.isKnownTier(state.pairingTier) ? state.pairingTier : permissions.DEFAULT_TIER, name: state.name, upstreamPort: ctx.webServer.port, lanPort, lanEnabled: effectiveLanEnabled(), lanSecret: state.lanSecret, registerSecret: state.registerSecret }),
|
|
394
|
+
buildConfig: (lanPort) => ({ enabled: state.enabled, relayUrl: state.relayUrl, relayUrls: core.relayAddressesOf(state).relayUrls, instanceId: state.instanceId, pairingCode: state.pairingCode, pairingTicket: state.pairingTicket || '', pairingTier: permissions.isKnownTier(state.pairingTier) ? state.pairingTier : permissions.DEFAULT_TIER, name: state.name, upstreamPort: ctx.webServer.port, upstreamHost: ctx.webServer.host, lanPort, lanEnabled: effectiveLanEnabled(), lanSecret: state.lanSecret, registerSecret: state.registerSecret }),
|
|
395
395
|
})
|
|
396
396
|
const { sidecarToken, syncSidecar, restartSidecar, tunnelConnected } = sidecarLifecycle
|
|
397
397
|
relayConnectedOf = tunnelConnected
|
|
@@ -602,7 +602,7 @@ function apply(ctx) {
|
|
|
602
602
|
// mux 只是搬运工,不另立权限面。帧契约见 `docs/mux-long-connection-design.md` §11。
|
|
603
603
|
const muxPermission = permissions.createUpgradePermission({ credentials, instanceId: state.instanceId, presentedCredential })
|
|
604
604
|
const mux = createMuxService({
|
|
605
|
-
upstream: { host:
|
|
605
|
+
upstream: { host: ctx.webServer.host, port: ctx.webServer.port },
|
|
606
606
|
authorize: (req) => { try { return Boolean(muxPermission.recordOf(req)) } catch { return false } },
|
|
607
607
|
onLog: (message) => ctx.logger?.info?.(`${name}: %s`, message),
|
|
608
608
|
})
|
package/lib/p2p/wiring.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// 隧道始终走独立的带来源标记入口,不依赖局域网监听。
|
|
3
|
+
// 落点代理转给宿主时跟随宿主实际绑定地址(见 relay/tunnel-forwarder.cjs)。
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 把点对点隧道挂进装配层:一条助手会话,外加一个局域网关着时用的落点代理。
|
|
@@ -33,13 +34,14 @@ function chooseP2PTarget({ tunnelPort }) {
|
|
|
33
34
|
* @param {() => boolean} options.lanEnabled 局域网直连开着没有
|
|
34
35
|
* @param {() => number} options.lanPort 当前局域网端口(会漂)
|
|
35
36
|
* @param {() => number} options.webPort 宿主 web 端口(落点代理最终转给它)
|
|
37
|
+
* @param {() => string} [options.webHost] 宿主 web 绑定地址(落点代理转给它;缺省回环)
|
|
36
38
|
* @param {object} options.ctx 插件 ctx(只为 `ctx.effect`)
|
|
37
39
|
* @param {string} options.name 插件名,用于 effect 标签
|
|
38
40
|
* @param {() => (string|null)} [options.resolveBinary] 测试缝:钉住「本机有没有助手」,
|
|
39
41
|
* 不让用例的结果取决于开发机上刚好有没有编译好的助手。
|
|
40
42
|
* @returns {object|undefined} 会话;起不来就是 undefined(路由与面板按「不可用」处理)
|
|
41
43
|
*/
|
|
42
|
-
function mountP2P({ mount, warn, state, saveState, localPort, lanEnabled, lanPort, webPort, ctx, name, resolveBinary }) {
|
|
44
|
+
function mountP2P({ mount, warn, state, saveState, localPort, lanEnabled, lanPort, webPort, webHost, ctx, name, resolveBinary }) {
|
|
43
45
|
// 局域网那几格没给就是老形状(只有 `localPort`):不建落点代理,判据退回 `localPort`,
|
|
44
46
|
// 行为一字不变。给了才建 —— 它是在「局域网关着」时唯一能用的落点。
|
|
45
47
|
//
|
|
@@ -47,7 +49,7 @@ function mountP2P({ mount, warn, state, saveState, localPort, lanEnabled, lanPor
|
|
|
47
49
|
// listen 已经晚了一步。
|
|
48
50
|
const forwarder = typeof lanEnabled === 'function'
|
|
49
51
|
? mount('点对点隧道落点代理', () =>
|
|
50
|
-
createTunnelForwarder({ upstreamPort: webPort, log: message => warn(message) }),
|
|
52
|
+
createTunnelForwarder({ upstreamPort: webPort, upstreamHost: webHost, log: message => warn(message) }),
|
|
51
53
|
)
|
|
52
54
|
: null;
|
|
53
55
|
if (forwarder) void forwarder.start();
|
package/lib/panel/index.html
CHANGED
|
@@ -84,7 +84,7 @@ Sugerimos que pergunte à sua IA para configurar uma solução de rede adequada
|
|
|
84
84
|
`);e.setCustomValidity(r),S.current=[e,r,n]}function C(){let e=S.current;S.current=null,e&&(!e[0].willValidate||e[0].validationMessage===e[1])&&e[0].setCustomValidity(e[2])}function w(e,t,n){let i=g(e,t);h(i,n),r(i)}function T(e){let t=xk.reduce((t,n)=>(t[n]=e.validity[n],t),{}),n=!1;for(let e of xk)if(e!==`valid`){if(e===`valueMissing`&&t[e])n=!0;else if(t[e])return t}return n&&!c.current&&(t.valid=!0,t.valueMissing=!1),t}function E(){return b.size>0?Ck(b,t.current):v.current}let D=E();function O(){return D=E(),D?.willValidate?T(D):wk(!1)}if(o){if(l.valid!==!1||!D)return;if(!D.validity.valueMissing){C();let e=E(),t=e?.validity.customError?Tk(e):[];w(wk(t.length>0),t,!1);return}for(let e of xk)if(e!==`valid`&&e!==`valueMissing`&&e!==`customError`&&D.validity[e])return}_.clear(),C();let k=O(),A=Tk(D),j=u();if(A.length===0||j){let t=Array.from(n.current.fields.values()).reduce((e,t)=>(t.name&&(e[t.name]=t.getValue()),e),{}),r=i(e,t),o;if(typeof r==`object`&&r&&`then`in r){if(k.valid===!1?w(k,A):(d===`onSubmit`||!a.state.customError)&&(k.valid=null,w(k,A)),o=await r,m!==x.current)return;k=O()}else o=r;A=o?[].concat(o).filter(Boolean):[],A.length>0?(k.valid=!1,k.customError=!0,D?.willValidate&&y(D,A.join(`
|
|
85
85
|
`))):A=Tk(D)}w(k,A)}),E=Y((e,t=!1)=>{if(_.clear(),x.current+=1,t)return;let n=u();n&&e!==``&&o?_.start(o,()=>{T(e)}):T(e,!n)}),D=g.useCallback((e,t={})=>Er(m(t),l.valid===!1&&!l.disabled&&!e?{"aria-invalid":!0}:h),[m,l.disabled,l.valid]);return g.useMemo(()=>({getValidationProps:D,inputRef:v,registeredInputs:b,registerInput:C,getInputControl:w,commit:T,change:E}),[D,b,C,w,T,E])}var Dk=g.createContext(void 0);function Ok(e=!1){let t=g.useContext(Dk);if(!t&&!e)throw Error(S(86));return t}var kk=[Zd],Ak=g.forwardRef(function(e,t){let{render:n,className:r,disabled:i,readOnly:a,required:o,onValueChange:s,value:c,defaultValue:l,form:u,name:d,inputRef:f,id:p,style:m,...h}=e,{setTouched:_,setFocused:v,validationMode:y,name:b,disabled:x,state:S,validation:C,setDirty:w,setFilled:T,validityData:E}=ID(),{labelId:D}=VD(),{clearErrors:O,elementRef:k}=zD(),A=Ok(!0),j=x||i,M=b??d,N=Pd(p),[P,F]=bf({controlled:c,default:l,name:`RadioGroup`,state:`value`}),[I,L]=g.useState(!1),R=Y((e,t)=>{s?.(e,t),!t.isCanceled&&F(e)}),z=C.getInputControl,B=g.useMemo(()=>({get current(){return z()}}),[z]),V=g.useRef(null),H=g.useRef(null);function U(e){let t;return f&&(typeof f==`function`?t=f(e):f.current=e),V.current=e,t}let W=Y(e=>{if(!e||e.disabled)return;H.current||=e;let t=V.current,n=e.checked||t==null||t.disabled?U(e):void 0;return()=>{H.current===e&&(H.current=null),V.current===e?n?(n(),V.current=null):U(null):n?.()}}),ee=Y(()=>{let e=k.current;if(!e)return P??null;for(let t of C.registeredInputs.keys())if(t.checked&&Sk(t,e))return P??null;return null});LD(B,N,P??null,ee,!j,d),Jf(P,()=>{O(M),w(P!==E.initialValue),T(P!=null),C.change(P);let e=H.current;P==null&&e&&!e.disabled&&U(e)});let K=D??A?.legendId,te={...S,disabled:j??!1,required:o??!1,readOnly:a??!1},q=g.useMemo(()=>({checkedValue:P,disabled:j,form:u,validation:C,name:M,readOnly:a,registerInputRef:W,required:o,setCheckedValue:R,setTouched:L,touched:I}),[P,j,u,C,M,a,W,o,R,L,I]),J={id:p,role:`radiogroup`,"aria-required":o||void 0,"aria-disabled":j||void 0,"aria-readonly":a||void 0,"aria-labelledby":K,onFocus(){v(!0)},onBlur(e){X(e.currentTarget,e.relatedTarget)||(_(!0),v(!1),y===`onBlur`&&C.commit(P))},onKeyDownCapture(e){e.key.startsWith(`Arrow`)&&(L(!0),v(!0))}};return(0,G.jsx)(rk.Provider,{value:q,children:(0,G.jsx)(yk,{render:n,className:r,style:m,state:te,props:[J,h,e=>C.getValidationProps(j??!1,e)],refs:[t],stateAttributesMapping:AD,enableHomeAndEndKeys:!1,modifierKeys:kk})})});function jk({className:e,orientation:t=`vertical`,...n}){return(0,G.jsx)(Ak,{"data-slot":`radio-group`,"aria-orientation":t,className:Z(`flex`,t===`horizontal`?`flex-wrap gap-4`:`flex-col gap-2`,e),...n})}function Mk(e){if(!Array.isArray(e))return`full`;if(e.length===0)return`none`;let t=new Set(e);return[`input`,`dispatch`,`operate`,`files.write`,`transfer`,`manage`,`config`].some(e=>t.has(e))?`full`:t.has(`approve`)?`approve`:`readonly`}var Nk=3e4,Pk=1e3;function Fk(e,t=Date.now()){let n=e?.tailcat?.expiresAt??0;if(!Number.isFinite(n)||n<=0)return null;let r=n*1e3-t;return r<=0?null:Math.max(r-Nk,Pk)}var Ik=class extends Error{constructor(e,t,n){super(e),q(this,`code`,void 0),q(this,`status`,void 0),this.name=`ApiError`,this.code=t,this.status=n}};async function Lk(e){let t=null;try{t=await e.json()}catch{t=null}let n=t?.error;if(typeof n==`string`&&n)return new Ik(n,`http_${e.status}`,e.status);if(n&&typeof n==`object`){let t=n,r=typeof t.code==`string`&&t.code?t.code:`http_${e.status}`;return new Ik(typeof t.message==`string`&&t.message?t.message:$(`panel.net.requestFailed`,{status:e.status}),r,e.status)}return new Ik($(`panel.net.requestFailed`,{status:e.status}),`http_${e.status}`,e.status)}async function Rk(e){let t=e.split(`?`)[0]===`/api/relay/pairing`,n=t?3e4:e===`/api/relay/status`?12e3:0,r=n?new AbortController:null,i=r?window.setTimeout(()=>r.abort(),n):null;try{let n=await fetch(e,{headers:{accept:`application/json`},...r?{signal:r.signal}:{}});if(!n.ok)throw await Lk(n);let i=await n.json();if(t&&(i?.ok!==!0||typeof i.svg!=`string`||!i.svg.includes(`<svg`)))throw new Ik($(`panel.pairing.qrFailed`),`pairing_invalid`,n.status);return i}catch(e){throw r?.signal.aborted?new Ik($(t?`panel.console.pairingTimeout`:`panel.console.statusTimeout`),t?`pairing_timeout`:`status_timeout`,0):e}finally{i!==null&&window.clearTimeout(i)}}async function zk(e,t){let n=await fetch(e,{method:`POST`,headers:{"content-type":`application/json`,accept:`application/json`},body:JSON.stringify(t??{})});if(!n.ok)throw await Lk(n);let r=await n.json();return Bk(r),r}function Bk(e){let t=e?.applyError;if(typeof t==`string`&&t)throw new Ik($(`panel.shell.applyFailed`,{message:t}),`apply_failed`,200)}function Vk(e){return zk(`/api/relay/frp/import`,{config:e})}function Hk(e,t){return zk(`/api/relay/devices/permissions`,{deviceId:e,tier:t})}function Uk(e){return e instanceof Ik?e.message:e instanceof Error?e.message||$(`panel.net.requestFailedNoStatus`):String(e)}function Wk(e){let t=g.useRef(!0);t.current&&(t.current=!1,e())}var Gk=g.createContext(void 0),Kk=g.createContext(void 0),qk=g.createContext(void 0);function Jk(){let e=g.useContext(Gk);if(e===void 0)throw Error(S(60));return e}function Yk(){let e=g.useContext(Kk);if(e===void 0)throw Error(S(101));return e}function Xk(){let e=g.useContext(qk);if(e===void 0)throw Error(S(61));return e}function Zk(e,t,n=Object.is){let{length:r}=e;if(r!==t.length)return!1;for(let i=0;i<r;i+=1)if(!n(e[i],t[i]))return!1;return!0}var Qk=(e,t)=>Object.is(e,t);function $k(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function eA(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!Zk(e,t,(e,t)=>$k(e,t,n)):e!==t}function tA(e,t,n){return e?e.some(e=>e!==void 0&&$k(t,e,n)):!1}function nA(e,t,n){return e?e.findIndex(e=>e!==void 0&&$k(e,t,n)):-1}function rA(e,t){if(t!==Qk)return n=>tA(e,n,t);let n=new Set(e);return n.delete(void 0),t=>n.has(t)&&(t!==0||e.some(e=>Object.is(t,e)))}function iA(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(rA(t,n)):nA(e,t,n);return i===-1?null:i}function aA(e,t,n,r,i,a){return tA(r,t,i)?a!=null&&e>a&&tA(r,n[a],i)?a:e:e===a?iA(n,r,i,!0):a}function oA(e,t,n){return e.filter(e=>!$k(t,e,n))}function sA(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function cA(e){return sA(e?.[0])}function lA(e){return cA(e)?e.flatMap(e=>e.items):e}function uA(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(cA(t)){for(let e of t)for(let t of e.items)if(t&&t.value==null&&t.label!=null)return!0;return!1}for(let e of t)if(e&&e.value==null&&e.label!=null)return!0;return!1}function dA(e,t){if(t&&e!=null)return t(e)??``;if(e&&typeof e==`object`){if(`label`in e&&e.label!=null)return String(e.label);if(`value`in e)return String(e.value)}return ak(e)}function fA(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?ak(e.value):ak(e)}function pA(e,t,n){function r(){return dA(e,n)}if(n&&e!=null)return n(e);if(e&&typeof e==`object`&&`label`in e&&e.label!=null)return e.label;if(t&&!Array.isArray(t))return(Object.hasOwn(t,e)?t[e]:void 0)??r();if(Array.isArray(t)){let n=lA(t);if(typeof e!=`object`||!e){let t=n.find(t=>t.value===e);return t&&t.label!=null?t.label:r()}if(`value`in e){let t=n.find(t=>t&&t.value===e.value);if(t&&t.label!=null)return t.label}}return r()}function mA(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,G.jsx)(g.Fragment,{children:pA(r,t,n)},i)),e),[])}var hA={id:e=>e.id,labelId:e=>e.labelId,modal:e=>e.modal,items:e=>e.items,itemToStringLabel:e=>e.itemToStringLabel,isItemEqualToValue:e=>e.isItemEqualToValue,value:e=>e.value,hasSelectedValue:e=>{let{value:t,multiple:n,itemToStringValue:r}=e;return t==null?!1:n&&Array.isArray(t)?t.length>0:fA(t,r)!==``},hasNullItemLabel:(e,t)=>t?uA(e.items):!1,open:e=>e.open,mounted:e=>e.mounted,forceMount:e=>e.forceMount,transitionStatus:e=>e.transitionStatus,openMethod:e=>e.openMethod,activeIndex:e=>e.activeIndex,selectedIndex:e=>e.selectedIndex,isActive:(e,t)=>e.activeIndex===t,isSelected:(e,t)=>{let n=e.isItemEqualToValue,r=e.value;return e.multiple?Array.isArray(r)&&r.some(e=>$k(t,e,n)):$k(t,r,n)},isSelectedByFocus:(e,t)=>e.selectedIndex===t,popupProps:e=>e.popupProps,triggerProps:e=>e.triggerProps,triggerElement:e=>e.triggerElement,positionerElement:e=>e.positionerElement,listElement:e=>e.listElement,popupSide:e=>e.popupSide,scrollUpArrowVisible:e=>e.scrollUpArrowVisible,scrollDownArrowVisible:e=>e.scrollDownArrowVisible,hasScrollArrows:e=>e.hasScrollArrows};function gA(e,t){return Math.max(0,e-t)}function _A(e,t){if(t<=0)return 0;let n=pi(e,0,t),r=n,i=t-n,a=r<=1,o=i<=1;return a&&o?r<=i?0:t:a?0:o?t:n}function vA(e){let{id:t,value:n,defaultValue:r=null,onValueChange:i,open:a,defaultOpen:o=!1,onOpenChange:s,name:c,form:l,autoComplete:u,disabled:d=!1,readOnly:f=!1,required:_=!1,modal:v=!0,actionsRef:x,inputRef:S,onOpenChangeComplete:C,items:w,multiple:T=!1,itemToStringLabel:E,itemToStringValue:D,isItemEqualToValue:O=Qk,highlightItemOnHover:k=!0,children:A}=e,{clearErrors:j}=zD(),{setDirty:M,setTouched:N,setFocused:P,validityData:F,setFilled:I,name:L,disabled:R,validation:z,validationMode:B}=ID(),V=GD({id:t}),H=R||d,U=L??c,[W,ee]=bf({controlled:n,default:T?r??m:r,name:`Select`,state:`value`}),[K,te]=bf({controlled:a,default:o,name:`Select`,state:`open`}),q=g.useRef([]),J=g.useRef([]),ne=g.useRef(null),re=g.useRef(null),ie=g.useRef(0),ae=g.useRef(null),oe=g.useRef([]),ce=g.useRef(!1),le=g.useRef(null),ue=g.useRef(null),de=g.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),fe=g.useRef(!1),pe=g.useRef(W),{mounted:me,setMounted:he,transitionStatus:ge}=Hs(K),{openMethod:_e,triggerProps:ve}=Xf(K),ye=y(()=>new se({id:V,labelId:void 0,modal:v,multiple:T,itemToStringLabel:E,itemToStringValue:D,isItemEqualToValue:O,value:W,open:K,mounted:me,transitionStatus:ge,items:w,forceMount:!1,openMethod:null,activeIndex:null,selectedIndex:null,popupProps:h,triggerProps:h,triggerElement:null,positionerElement:null,listElement:null,popupSide:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1,hasScrollArrows:!1},{setValue:p,setOpen:p,handleScrollArrowVisibility:p,onOpenChangeComplete:p,listRef:q,popupRef:ne,scrollHandlerRef:re,scrollArrowsMountedCountRef:ie,valueRef:ae,valuesRef:oe,labelsRef:J,typingRef:ce,selectionRef:de,firstItemTextRef:le,selectedItemTextRef:ue,alignItemWithTriggerActiveRef:fe,initialValueRef:pe},hA)).current,be=ye.useState(`activeIndex`),xe=ye.useState(`selectedIndex`),Se=ye.useState(`triggerElement`),Ce=ye.useState(`positionerElement`),we=fh(_e),Te=_e??we,Ee=g.useMemo(()=>T?``:fA(W,D),[T,W,D]),De=g.useMemo(()=>T&&Array.isArray(W)?W.map(e=>fA(e,D)):fA(W,D),[T,W,D]);LD(za(Se),V,W,Y(()=>De),!H,c);let Oe=T?Array.isArray(W)&&W.length>0:W!=null&&Ee!==``;b(()=>{I(Oe)},[Oe,I]),b(function(){let e=iA(oe.current,W,O,T);e===null&&(ue.current=null),!K&&ye.set(`selectedIndex`,e)},[T,K,W,O,ye]),Jf(W,()=>{j(U),M(eA(W,F.initialValue,O)),z.change(W)});let ke=Y((e,t)=>{s?.(e,t),!t.isCanceled&&(te(e),!e&&(t.reason===`focus-out`||t.reason===`outside-press`)&&(N(!0),P(!1),B===`onBlur`&&z.commit(W)))}),Ae=Y(()=>{he(!1),ye.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),C?.(!1)});ri({enabled:!x,open:K,ref:ne,onComplete(){K||Ae()}}),g.useImperativeHandle(x,()=>({unmount:Ae}),[Ae]);let je=Y((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),Me=Y(e=>{let t=gA(e.scrollHeight,e.clientHeight),n=_A(e.scrollTop,t),r=n>0,i=n<t;ye.set(`scrollUpArrowVisible`,r),ye.set(`scrollDownArrowVisible`,i)}),Ne=fc({open:K,onOpenChange:ke,elements:{reference:Se,floating:Ce}}),Pe=Oo(Ne,{enabled:!H,event:`mousedown`}),Fe=Po(Ne),Ie=Mc(Ne,{enabled:!H,listRef:q,activeIndex:be,selectedIndex:xe,disabledIndices:m,onNavigate(e){(e!==null||K)&&ye.set(`activeIndex`,e)},focusItemOnHover:k}),Le=Nc(Ne,{enabled:!H&&(K||!f&&!T),listRef:J,activeIndex:be,selectedIndex:xe,disabledIndices:e=>mh(q.current[e]),onMatch(e){K?ye.set(`activeIndex`,e):je(oe.current[e],Aa(pa))},onTyping(e){ce.current=e}}),Re=g.useMemo(()=>Er(Le.reference,Ie.reference,Fe.reference,Pe.reference,ve),[Pe.reference,Le.reference,Ie.reference,Fe.reference,ve]),ze=g.useMemo(()=>Er(Us,Le.floating,Ie.floating,Fe.floating),[Le.floating,Ie.floating,Fe.floating]),Be=Ie.item??h;ye.useContextCallback(`setValue`,je),ye.useContextCallback(`setOpen`,ke),ye.useContextCallback(`handleScrollArrowVisibility`,Me),ye.useContextCallback(`onOpenChangeComplete`,C),Wk(()=>{ye.update({popupProps:ze,triggerProps:Re})}),ye.useSyncedValues({id:V,modal:v,multiple:T,value:W,open:K,mounted:me,transitionStatus:ge,popupProps:ze,triggerProps:Re,items:w,itemToStringLabel:E,itemToStringValue:D,isItemEqualToValue:O,openMethod:Te});let Ve=g.useMemo(()=>({disabled:H,readOnly:f,required:_,multiple:T,highlightItemOnHover:k,itemProps:Be}),[H,f,_,T,k,Be]),He=mr(S,z.inputRef),Ue=T?void 0:U,We=g.useMemo(()=>!T||!Array.isArray(W)||!U?null:W.map(e=>{let t=fA(e,D);return(0,G.jsx)(`input`,{type:`hidden`,form:l,name:U,value:t,disabled:H},t)}),[T,W,l,U,D,H]);return(0,G.jsxs)(Gk.Provider,{value:ye,children:[(0,G.jsx)(Kk.Provider,{value:Ve,children:(0,G.jsx)(qk.Provider,{value:Ne,children:A})}),(0,G.jsx)(`input`,{...z.getValidationProps(H,{onFocus(){ye.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||H||f)return;let t=e.currentTarget.value,n=Aa(pa,e.nativeEvent);function r(){if(T)return;let e=t.toLowerCase(),r=oe.current.findIndex(t=>fA(t,D).toLowerCase()===e||dA(t,E).toLowerCase()===e);r===-1&&(r=oe.current.findIndex((t,n)=>{let r=J.current[n];return r!=null&&r.toLowerCase()===e}));let i=oe.current[r];i!=null&&je(i,n)}ye.set(`forceMount`,!0),queueMicrotask(r)}}),id:V&&Ue==null?`${V}-hidden-input`:void 0,form:l,name:Ue,autoComplete:u,value:Ee,disabled:H,required:_&&!(T&&Oe),readOnly:f,ref:He,style:U?fr:dr,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),We]})}function yA(e,t){let n=Pd(e);return b(()=>(t(n),()=>{t(e=>e===n?void 0:e)}),[n,t]),n}function bA(e={}){let{id:t,fallbackControlId:n,native:r=!1,setLabelId:i,focusControl:a}=e,{controlId:o,setLabelId:s}=VD(),c=yA(t,Y(e=>{s(e),i?.(e)})),l=o??n;function u(e){if(a){a(e,l);return}if(!l)return;let t=Ie(e.currentTarget).getElementById(l);ge(t)&&xA(t)}function d(e){lt(e.nativeEvent)?.closest(`button,input,select,textarea`)||(!e.defaultPrevented&&e.detail>1&&e.preventDefault(),!r&&u(e))}return r?{id:c,htmlFor:l,onMouseDown:d}:{id:c,onClick:d,onPointerDown(e){e.preventDefault()}}}function xA(e){e.focus({focusVisible:!0})}function SA(e,t){return e??t}var CA=`data-popup-side`,wA=400,TA={...Mt,...AD,popupSide:e=>e?{[CA]:e}:null,value:()=>null},EA=g.forwardRef(function(e,t){let{render:n,className:r,id:i,disabled:a=!1,nativeButton:o=!0,style:s,...c}=e,{setTouched:l,setFocused:u,validationMode:d,validation:f,state:p,disabled:m}=ID(),{labelId:h}=VD(),_=Jk(),{readOnly:v,required:y,disabled:b}=Yk(),x=m||b||a,S=_.useState(`open`),C=_.useState(`mounted`),w=_.useState(`value`),T=_.useState(`triggerProps`),E=_.useState(`positionerElement`),D=_.useState(`listElement`),O=_.useState(`popupSide`),k=_.useState(`id`),A=_.useState(`labelId`),j=_.useState(`hasSelectedValue`),M=C&&E?O:null,N=i??k,P=SA(h,A);GD({id:i});let F=za(E),I=g.useRef(null),{getButtonProps:L,buttonRef:R}=ca({disabled:x,native:o}),z=_.useStateSetter(`triggerElement`),B=We(),V=We(),H=We();g.useEffect(()=>{if(S)return H.start(wA,()=>{_.context.selectionRef.current.allowUnselectedMouseUp=!0,_.context.selectionRef.current.allowSelectedMouseUp=!0}),()=>{H.clear()};_.context.selectionRef.current={allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0},V.clear()},[S,_,V,H]);let U=Er(T,{id:N,role:`combobox`,"aria-expanded":S,"aria-haspopup":`listbox`,"aria-controls":S?D?.id??Ut(E)?.id:void 0,"aria-labelledby":P,"aria-readonly":v||void 0,"aria-required":y||void 0,tabIndex:x?-1:0,onFocus(e){u(!0),S&&_.context.alignItemWithTriggerActiveRef.current&&_.context.setOpen(!1,Aa(pa,e.nativeEvent)),B.start(0,()=>{_.set(`forceMount`,!0)})},onBlur(e){X(E,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&f.commit(w))},onMouseDown(e){if(S)return;let t=Ie(e.currentTarget);function n(e){if(!I.current)return;let t=e.target;X(I.current,t)||X(F.current,t)||nh(e,I.current)||_.context.setOpen(!1,Aa(wa,e))}V.start(0,()=>{t.addEventListener(`mouseup`,n,{once:!0})})}},c,L),W=f.getValidationProps(x,U);W.role=`combobox`;let G={...p,open:S,disabled:x,value:w,readOnly:v,popupSide:M,placeholder:!j};return Br(`button`,e,{ref:[t,I,R,z],state:G,stateAttributesMapping:TA,props:W})}),DA={value:()=>null},OA=g.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=Jk(),l=c.useState(`value`),u=c.useState(`items`),d=c.useState(`itemToStringLabel`),f=c.useState(`hasSelectedValue`),p=!f&&a!=null&&i==null,m=c.useState(`hasNullItemLabel`,p),h={value:l,placeholder:!f},g=null;return g=typeof i==`function`?i(l):i??(p&&!m?a:Array.isArray(l)?mA(l,u,d):pA(l,u,d)),Br(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:DA})}),kA=g.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Br(`span`,e,{state:{open:Jk().useState(`open`)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:jt})}),AA=g.forwardRef(function(e,t){let n=Jk(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,G.jsx)(Ia,{ref:t,...e}):null}),jA=g.createContext(void 0);function MA(){let e=g.useContext(jA);if(!e)throw Error(S(59));return e}function NA(e,t){e&&Object.assign(e.style,t)}var PA={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},FA={position:`fixed`},IA=g.forwardRef(function(e,t){let{anchor:n,className:r,render:i,positionMethod:a,side:o,align:s,sideOffset:c,alignOffset:l,collisionBoundary:u=`clipping-ancestors`,collisionPadding:d,arrowPadding:f,sticky:p,disableAnchorTracking:m,alignItemWithTrigger:h=!0,collisionAvoidance:_=ui,style:v,...y}=e,x=Jk(),S=Xk(),C=x.useState(`open`),w=x.useState(`mounted`),T=x.useState(`modal`),E=x.useState(`value`),D=x.useState(`openMethod`),O=x.useState(`positionerElement`),k=x.useState(`triggerElement`),A=x.useState(`isItemEqualToValue`),j=x.useState(`transitionStatus`),M=g.useRef(null),N=g.useRef(null),[P,F]=g.useState(h),I=w&&P&&D!==`touch`;!w&&P!==h&&F(h),g.useImperativeHandle(x.context.alignItemWithTriggerActiveRef,()=>I),Im((I||T)&&C,D===`touch`,O,k);let L=rl({anchor:n,floatingRootContext:S,positionMethod:a,mounted:w,side:o,sideOffset:c,align:s,alignOffset:l,arrowPadding:f,collisionBoundary:u,collisionPadding:d,sticky:p,disableAnchorTracking:m??I,collisionAvoidance:_,keepMounted:!0}),R=I?`none`:L.side,z=I?FA:L.positionerStyles,B={open:C,side:R,align:L.align,anchorHidden:L.anchorHidden};b(()=>{x.set(`popupSide`,L.side)},[x,L.side]);let V=sl(e,B,{styles:z,transitionStatus:j,props:y,refs:[t,x.useStateSetter(`positionerElement`)],hidden:!w,inert:!C}),H=g.useRef(0),U=Y(e=>{if(x.context.valuesRef.current.length===0)return;let t=H.current;H.current=e.size;let n=Aa(pa);if(t!==0&&!x.state.multiple&&E!==null&&nA(x.context.valuesRef.current,E,A)===-1){let e=x.context.initialValueRef.current,t=e!=null&&nA(x.context.valuesRef.current,e,A)!==-1?e:null;x.context.setValue(t,n),t===null&&(x.set(`selectedIndex`,null),x.context.selectedItemTextRef.current=null)}if(t!==0&&x.state.multiple&&Array.isArray(E)){let e=E.filter(e=>nA(x.context.valuesRef.current,e,A)!==-1);e.length!==E.length&&(x.context.setValue(e,n),e.length===0&&(x.set(`selectedIndex`,null),x.context.selectedItemTextRef.current=null))}if(C&&I){x.update({scrollUpArrowVisible:!1,scrollDownArrowVisible:!1});let e={height:``};NA(O,e),NA(x.context.popupRef.current,e)}}),W=g.useMemo(()=>({...L,side:R,alignItemWithTriggerActive:I,setControlledAlignItemWithTrigger:F,scrollUpArrowRef:M,scrollDownArrowRef:N}),[L,R,I,F]);return(0,G.jsx)(Om,{elementsRef:x.context.listRef,labelsRef:x.context.labelsRef,onMapChange:U,children:(0,G.jsxs)(jA.Provider,{value:W,children:[w&&T&&(0,G.jsx)(_f,{inert:Yr(!C),cutout:k}),V]})})}),LA=`base-ui-disable-scrollbar`,RA={className:LA,getElement(e){return(0,G.jsx)(`style`,{nonce:e,href:LA,precedence:`base-ui:low`,children:`.${LA}{scrollbar-width:none}.${LA}::-webkit-scrollbar{display:none}`})}},zA=g.createContext(void 0),BA={disableStyleElements:!1};function VA(){return g.useContext(zA)??BA}var HA=`--transform-origin`,UA={...Nt,...bt},WA=g.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=Jk(),{multiple:c,readOnly:l,highlightItemOnHover:u}=Yk(),d=Xk(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:_}=MA(),v=Cm(!0)!=null,y=Uc(),{nonce:x,disableStyleElements:S}=VA(),C=s.useState(`id`),w=s.useState(`open`),T=s.useState(`openMethod`),E=s.useState(`mounted`),D=s.useState(`popupProps`),O=s.useState(`transitionStatus`),k=s.useState(`triggerElement`),A=s.useState(`positionerElement`),j=s.useState(`listElement`),M=g.useRef(!1),N=g.useRef(!1),P=g.useRef({}),F=Ve(),I=Y(e=>{if(!A||!s.context.popupRef.current||!N.current)return;let t=A.style.top===`0px`,n=A.style.bottom===`0px`;if(M.current||!m||!t&&!n){s.context.handleScrollArrowVisibility(e);return}let r=qA(A),i=JA(A.getBoundingClientRect().height,`y`,r),a=Ie(A),o=fe(A),c=o.getComputedStyle(A),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=GA(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=KA(e),g=null,_=e=>{A.style.height=`${e}px`},v=t?h-p:p,y=Math.min(i+v,f);if(v<=1){let n=pi(v,0,f-i);n>0&&_(i+n),e.scrollTop=t?h:0,f-(i+n)<=1&&(M.current=!0),s.context.handleScrollArrowVisibility(e);return}f-y>1?g=t?1/0:0:n&&p<h&&(g=p-(v-(i+v-f)));let b=Math.ceil(y);if(b!==0&&_(b),g!=null){let t=pi(g,0,KA(e));Math.abs(e.scrollTop-t)>1&&(e.scrollTop=t)}b>=f-1&&(M.current=!0),s.context.handleScrollArrowVisibility(e)});g.useImperativeHandle(s.context.scrollHandlerRef,()=>I,[I]),ri({open:w,ref:s.context.popupRef,onComplete(){w&&s.context.onOpenChangeComplete(!0)}});let L={open:w,transitionStatus:O,side:f,align:p};b(()=>{A&&s.context.popupRef.current&&!Object.keys(P.current).length&&(P.current={top:A.style.top||`0`,left:A.style.left||`0`,right:A.style.right,height:A.style.height,bottom:A.style.bottom,minHeight:A.style.minHeight,maxHeight:A.style.maxHeight,marginTop:A.style.marginTop,marginBottom:A.style.marginBottom})},[s,A]),b(()=>{w||m||(N.current=!1,M.current=!1,NA(A,P.current))},[w,m,A]),b(()=>{let e=s.context.popupRef.current;if(!w||!k||!A||!e||m&&!h||s.state.transitionStatus===`ending`)return;if(N.current=!0,e.style.removeProperty(HA),!m){F.request(()=>s.context.handleScrollArrowVisibility(j||e));return}let t=ZA(e);try{let t=s.context.selectedItemTextRef.current;t?.isConnected||(t=!s.select(`hasSelectedValue`)&&s.context.firstItemTextRef.current?.isConnected?s.context.firstItemTextRef.current:null);let n=s.context.valueRef.current,r=fe(A),i=r.getComputedStyle(A),a=r.getComputedStyle(e),o=Ie(k),c=qA(k),l=YA(k.getBoundingClientRect(),c),d=YA(A.getBoundingClientRect(),c),f=l.height,p=j||e,m=p.scrollHeight,h=parseFloat(a.borderBottomWidth),g=parseFloat(i.marginTop)||10,v=parseFloat(i.marginBottom)||10,b=parseFloat(i.minHeight)||100,x=GA(a),S=o.documentElement.clientHeight-g-v,C=o.documentElement.clientWidth,w=S-l.bottom+f,T,E=y===`rtl`?l.right-d.width:l.left,D=0;if(t&&n){let e=YA(n.getBoundingClientRect(),c);T=YA(t.getBoundingClientRect(),c),E=d.left+(y===`rtl`?e.right-T.right:e.left-T.left);let r=e.top-l.top+e.height/2;D=T.top-d.top+T.height/2-r}let O=w+D+v+h,N=Math.min(S,O),F=S-g-v,I=O-N,L=C-5;A.style.left=`${pi(E,5,L-d.width)}px`,A.style.height=`${N}px`,A.style.maxHeight=`none`,A.style.marginTop=`${g}px`,A.style.marginBottom=`${v}px`,e.style.height=`100%`;let R=KA(p),z=I>=R-1;z&&(N=Math.min(S,d.height)-(I-R));let B=l.top<20||l.bottom>S-20||Math.ceil(N)+1<Math.min(m,b),V=(r.visualViewport?.scale??1)!==1&&at;if(B||V){NA(A,P.current),_(!1);return}let H=Math.max(b,N);if(z){let e=Math.max(0,S-O);A.style.top=d.height>=F?`0`:`${e}px`,A.style.height=`${N}px`,p.scrollTop=KA(p)}else A.style.bottom=`0`,p.scrollTop=I;if(T){let t=d.top,n=d.height,r=T.top+T.height/2,i=pi(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(HA,`50% ${i}%`)}(H===S||N>=x)&&(M.current=!0),s.context.handleScrollArrowVisibility(p),u&&s.state.selectedIndex===null&&s.state.activeIndex===null&&s.context.listRef.current[0]!=null&&s.set(`activeIndex`,0)}finally{t()}},[s,w,A,k,m,_,F,j,u,y,h]),g.useEffect(()=>{if(!m||!A||!w)return;let e=fe(A);function t(e){s.context.setOpen(!1,Aa(ka,e))}return Le(e,`resize`,t)},[s,m,A,w]);let R={...j?{role:`presentation`}:{role:`listbox`,"aria-multiselectable":c||void 0,"aria-readonly":l||void 0,id:`${C}-list`},onKeyDown(e){v&&Xd.has(e.key)&&e.stopPropagation()},onScroll(e){j||I(e.currentTarget)},...m&&{style:j?{height:`100%`}:PA},className:!j&&m?RA.className:void 0},z=Br(`div`,e,{ref:[t,s.context.popupRef],state:L,stateAttributesMapping:UA,props:[D,R,ol(O),o]});return(0,G.jsxs)(g.Fragment,{children:[!S&&RA.getElement(x),(0,G.jsx)(Do,{context:d,modal:!1,disabled:!E,openInteractionType:T,returnFocus:a,restoreFocus:!0,children:z})]})});function GA(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function KA(e){return gA(e.scrollHeight,e.clientHeight)}function qA(e){return _s.getScale(e)}function JA(e,t,n){return e/n[t]}function YA(e,t){return Tn({x:JA(e.x,`x`,t),y:JA(e.y,`y`,t),width:JA(e.width,`x`,t),height:JA(e.height,`y`,t)})}var XA=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function ZA(e){let{style:t}=e,n={};for(let[e,r]of XA)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of XA){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var QA=g.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Jk(),{multiple:s,readOnly:c}=Yk(),{alignItemWithTriggerActive:l}=MA(),u=o.useState(`hasScrollArrows`),d=o.useState(`openMethod`),f={id:`${o.useState(`id`)}-list`,role:`listbox`,"aria-multiselectable":s||void 0,"aria-readonly":c||void 0,onScroll(e){o.context.scrollHandlerRef.current?.(e.currentTarget)},...l&&{style:PA},className:u&&d!==`touch`?RA.className:void 0};return Br(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),$A=g.createContext(void 0);function ej(){let e=g.useContext($A);if(!e)throw Error(S(57));return e}var tj=g.memo(g.forwardRef(function(e,t){let{render:n,className:r,style:i,value:a=null,label:o,disabled:s=!1,nativeButton:c=!1,...l}=e,u=g.useRef(null),d=_m({guess:!0,label:o,textRef:u}),f=Jk(),{itemProps:p,multiple:m,disabled:h,readOnly:_}=Yk(),v=h||s,y=f.useState(`isActive`,d.index),x=f.useState(`open`),S=f.useState(`isSelected`,a),C=f.useState(`isSelectedByFocus`,d.index),w=f.useState(`isItemEqualToValue`),T=d.index,E=g.useRef(null);b(()=>{let e=f.context.valuesRef.current;return e[T]=a,()=>{delete e[T]}},[T,a,f]),b(()=>{let e=f.state.value,t=f.state.selectedIndex,n=t,r;m&&Array.isArray(e)?(n=aA(T,a,f.context.valuesRef.current,e,w,t),r=n===T,T===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&$k(a,e,w),r&&(n=T)),f.set(`selectedIndex`,n),r&&u.current&&(f.context.selectedItemTextRef.current=u.current)},[T,m,w,f,a]);let D=g.useRef(`mouse`),O=g.useRef(!1),{getButtonProps:k,buttonRef:A}=ca({disabled:v,focusableWhenDisabled:!0,native:c,composite:!0}),j={disabled:v,selected:S,highlighted:y};function M(e){if(h||_)return;let t=f.state.value;if(m){let n=Array.isArray(t)?t:[],r=S?oA(n,a,w):[...n,a];f.context.setValue(r,Aa(va,e))}else f.context.setValue(a,Aa(va,e)),f.context.setOpen(!1,Aa(va,e))}function N(){f.context.selectionRef.current.dragY=0}let P={role:`option`,"aria-selected":S,tabIndex:x&&y?0:-1,onKeyDown(e){f.set(`activeIndex`,T),e.key===` `&&f.context.typingRef.current&&e.preventDefault()},onClick(e){let t=D.current!==`touch`,n=e.nativeEvent.pointerType,r=t&&Jt(e.nativeEvent)&&(n!==void 0||y),i=t&&!r&&!O.current;O.current=!1,!(v||i)&&M(e.nativeEvent)},onPointerEnter(e){D.current=e.pointerType},onPointerMove(e){if(e.pointerType===`mouse`&&e.buttons===1){let t=f.context.selectionRef.current;t.dragY+=e.movementY,t.dragY**2>=64&&(t.allowUnselectedMouseUp=!0)}},onPointerDown(e){D.current=e.pointerType,O.current=!0,N()},onMouseUp(){if(N(),v||D.current===`touch`||O.current)return;let e=!f.context.selectionRef.current.allowSelectedMouseUp&&S,t=!f.context.selectionRef.current.allowUnselectedMouseUp&&!S;e||t||(O.current=!0,E.current?.click(),O.current=!1)}},F=Br(`div`,e,{ref:[A,t,d.ref,E],state:j,props:[p,P,l,k]}),I=g.useMemo(()=>({selected:S,index:T,textRef:u,selectedByFocus:C}),[S,T,u,C]);return(0,G.jsx)($A.Provider,{value:I,children:F})})),nj=g.forwardRef(function(e,t){let{selected:n}=ej();return e.keepMounted||n?(0,G.jsx)(rj,{...e,ref:t}):null}),rj=g.memo(g.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=ej(),c=g.useRef(null),{transitionStatus:l,setMounted:u}=Hs(s),d=Br(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:bt});return ri({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||u(!1)}}),d})),ij=g.memo(g.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=ej(),a=Jk(),{render:o,className:s,style:c,...l}=e;return Br(`div`,e,{ref:[g.useCallback(e=>{e&&(n===0&&(a.context.firstItemTextRef.current=e),i&&(a.context.selectedItemTextRef.current=e))},[a,n,i]),t,r],props:l})})),aj=g.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,l=Jk(),{side:u,scrollDownArrowRef:d,scrollUpArrowRef:f}=MA(),p=c?`scrollUpArrowVisible`:`scrollDownArrowVisible`,m=l.useState(p),h=l.useState(`openMethod`),g=m&&h!==`touch`,_=We(),v=c?f:d,{mounted:y,transitionStatus:x,setMounted:S}=Hs(g);b(()=>(l.context.scrollArrowsMountedCountRef.current+=1,l.set(`hasScrollArrows`,!0),()=>{l.context.scrollArrowsMountedCountRef.current=Math.max(0,l.context.scrollArrowsMountedCountRef.current-1),l.context.scrollArrowsMountedCountRef.current===0&&l.set(`hasScrollArrows`,!1)}),[l]),ri({open:g,ref:v,onComplete(){g||S(!1)}});let C=Br(`div`,e,{ref:[t,v],state:{direction:a,visible:g,side:u,transitionStatus:x},props:[{"aria-hidden":!0,children:c?`▲`:`▼`,style:{position:`absolute`},onMouseMove(e){if(e.movementX===0&&e.movementY===0||_.isStarted())return;l.set(`activeIndex`,null);function t(){let e=l.state.listElement??l.context.popupRef.current;if(!e)return;l.set(`activeIndex`,null),l.context.handleScrollArrowVisibility(e);let n=gA(e.scrollHeight,e.clientHeight),r=_A(e.scrollTop,n),i=r===(c?0:n),a=l.context.listRef.current;if(r!==e.scrollTop&&(e.scrollTop=r),i){_.clear();return}if(a.length>0){let t=v.current?.offsetHeight||0;e.scrollTop=oj(a,c,r,e.clientHeight,t,n)}_.start(40,t)}_.start(40,t)},onMouseLeave(){_.clear()}},s],stateAttributesMapping:bt});return y||o?C:null});function oj(e,t,n,r,i,a){if(t){let t=0,r=n+i-1;for(let n=0;n<e.length;n+=1){let i=e[n];if(i&&i.offsetTop>=r){t=n;break}}let o=Math.max(0,t-1),s=e[o];return o<t&&s?_A(s.offsetTop-i,a):0}let o=e.length-1,s=n+r-i+1;for(let t=0;t<e.length;t+=1){let n=e[t];if(n&&n.offsetTop+n.offsetHeight>s){o=Math.max(0,t-1);break}}let c=Math.min(e.length-1,o+1),l=e[c];return c>o&&l?_A(l.offsetTop+l.offsetHeight-r+i,a):a}var sj=g.forwardRef(function(e,t){return(0,G.jsx)(aj,{...e,ref:t,direction:`down`})}),cj=g.forwardRef(function(e,t){return(0,G.jsx)(aj,{...e,ref:t,direction:`up`})}),lj=Gu(`w-full border text-foreground outline-none transition-[background-color,border-color,box-shadow] duration-200 motion-reduce:transition-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,{variants:{variant:{outline:`bg-background border-border-strong hover:not-focus:not-focus-visible:not-has-focus:not-has-focus-visible:not-data-popup-open:not-has-data-popup-open:not-data-pressed:not-has-data-pressed:not-data-invalid:not-has-data-invalid:border-border-emphasis`,soft:`bg-background-muted border-transparent hover:not-focus:not-focus-visible:not-has-focus:not-has-focus-visible:not-data-popup-open:not-has-data-popup-open:not-data-pressed:not-has-data-pressed:not-data-invalid:not-has-data-invalid:border-border-strong`},size:{sm:`h-8 px-3 text-xs pointer-coarse:text-base rounded-sm gap-1.5 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75]`,md:`h-10 px-3.5 text-sm pointer-coarse:text-base rounded-md gap-2 [&_svg:not([class*='size-'])]:size-4.5 [&_svg:not([class*='stroke-'])]:stroke-[1.65]`,lg:`h-12 px-4 text-base rounded-lg gap-2 [&_svg:not([class*='size-'])]:size-5 [&_svg:not([class*='stroke-'])]:stroke-[1.65]`},state:{self:Z(`focus-visible:ring-3 focus-visible:ring-ring-input focus-visible:border-transparent focus-visible:bg-background`,`data-popup-open:ring-3 data-popup-open:ring-ring-input data-popup-open:border-transparent data-popup-open:bg-background`,`data-pressed:ring-3 data-pressed:ring-ring-input data-pressed:border-transparent data-pressed:bg-background`,`data-invalid:bg-error-subtle data-invalid:border-error`,`data-invalid:focus-visible:border-transparent data-invalid:focus-visible:ring-ring-error data-invalid:focus-visible:bg-background`,`data-invalid:data-popup-open:border-transparent data-invalid:data-popup-open:ring-ring-error data-invalid:data-popup-open:bg-background`,`data-invalid:data-pressed:border-transparent data-invalid:data-pressed:ring-ring-error data-invalid:data-pressed:bg-background`,`data-disabled:border-border-strong! data-disabled:bg-background-subtle! data-disabled:cursor-not-allowed data-disabled:border-dashed data-disabled:opacity-disabled`),within:Z(`flex items-center`,`has-focus:ring-[3px] has-focus:ring-ring-input has-focus:border-transparent has-focus:bg-background`,`has-data-popup-open:ring-3 has-data-popup-open:ring-ring-input has-data-popup-open:border-transparent has-data-popup-open:bg-background`,`has-data-pressed:ring-3 has-data-pressed:ring-ring-input has-data-pressed:border-transparent has-data-pressed:bg-background`,`data-invalid:bg-error-subtle data-invalid:border-error data-invalid:has-focus:border-transparent data-invalid:has-focus:ring-ring-error data-invalid:has-focus:bg-background`,`data-invalid:has-data-popup-open:border-transparent data-invalid:has-data-popup-open:ring-ring-error data-invalid:has-data-popup-open:bg-background`,`data-invalid:has-data-pressed:border-transparent data-invalid:has-data-pressed:ring-ring-error data-invalid:has-data-pressed:bg-background`,`has-data-invalid:bg-error-subtle has-data-invalid:border-error has-data-invalid:has-focus:border-transparent has-data-invalid:has-focus:ring-ring-error has-data-invalid:has-focus:bg-background`,`has-data-invalid:has-data-popup-open:border-transparent has-data-invalid:has-data-popup-open:ring-ring-error has-data-invalid:has-data-popup-open:bg-background`,`has-data-invalid:has-data-pressed:border-transparent has-data-invalid:has-data-pressed:ring-ring-error has-data-invalid:has-data-pressed:bg-background`,`has-[input:disabled]:border-border-strong! has-[input:disabled]:bg-background-subtle! has-[input:disabled]:cursor-not-allowed has-[input:disabled]:border-dashed has-[input:disabled]:opacity-disabled`)}},defaultVariants:{variant:`outline`,size:`md`,state:`self`}}),uj=g.createContext(null);function dj(){let e=g.useContext(uj);if(!e)throw Error(`Select sub-components must be rendered inside <Select>`);return e}function fj({size:e=`md`,variant:t=`outline`,alignItemWithTrigger:n=!0,value:r,defaultValue:i,onValueChange:a,multiple:o=!1,children:s,...c}){let l=yh(),u=r!==void 0,[d,f]=g.useState(i??(o?[]:null)),p=u?r:d,m=o?Array.isArray(p)&&p.length>0:p!=null&&p!==``,h=g.useCallback((e,t)=>{u||f(e),a?.(e,t)},[u,a]),_=g.useCallback(e=>{let t=o?[]:null,n={reason:`none`,event:e?.nativeEvent??new Event(`clear`),trigger:void 0,cancel:()=>{},allowPropagation:()=>{},isCanceled:!1,isPropagationAllowed:!1};h(t,n)},[o,h]),v=g.useMemo(()=>({size:e,variant:t,alignItemWithTrigger:n,hasValue:m,clear:_,multiple:o,reducedMotion:l}),[e,t,n,m,_,o,l]);return(0,G.jsx)(uj.Provider,{value:v,children:(0,G.jsx)(vA,{value:p,onValueChange:h,multiple:o,...c,children:s})})}var pj={sm:`size-4`,md:`size-4.5`,lg:`size-5`};function mj({className:e,clearable:t,startSlot:n,endSlot:r,children:i,onKeyDown:a,...o}){let{size:s,variant:c,alignItemWithTrigger:l,hasValue:u,clear:d}=dj(),f=pj[s],p=o[`aria-invalid`],m=p===!0||p===`true`,h=t&&u,g=e=>{a?.(e),!e.defaultPrevented&&h&&(e.key===`Delete`||e.key===`Backspace`)&&(e.preventDefault(),d(e))};return(0,G.jsxs)(EA,{"data-slot":`select-trigger`,className:Z(lj({variant:c,size:s,state:`self`}),`data-placeholder:text-foreground-subtle flex items-center justify-between`,e),...o,onKeyDown:g,...m?{"data-invalid":``}:{},children:[n&&(0,G.jsx)(`span`,{"data-slot":`select-trigger-start`,className:`-ms-1 shrink-0`,children:n}),(0,G.jsx)(`span`,{className:`flex min-w-0 flex-1 items-center truncate text-start`,children:i}),h?(0,G.jsx)(`span`,{"data-slot":`select-clear`,"aria-hidden":`true`,onPointerDown:e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation(),e.preventDefault(),d(e)},onClick:e=>{e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},className:`text-foreground-subtle hover:text-foreground shrink-0 cursor-pointer transition-colors duration-200 motion-reduce:transition-none`,children:(0,G.jsx)(Dj,{className:`size-[1em]`})}):null,r&&(0,G.jsx)(`span`,{"data-slot":`select-trigger-end`,className:`shrink-0`,children:r}),(0,G.jsx)(kA,{"data-slot":`select-icon`,className:`text-foreground -me-1 shrink-0`,render:l?(0,G.jsx)(Tj,{className:f}):(0,G.jsx)(wj,{className:Z(f,`motion-safe:transition-transform motion-safe:duration-200`,`data-popup-open:rotate-180`)})})]})}function hj({className:e,...t}){return(0,G.jsx)(OA,{"data-slot":`select-value`,className:Z(`min-w-0 flex-1 truncate text-start`,e),...t})}var gj={sm:`rounded-md`,md:`rounded-lg`,lg:`rounded-xl`};function _j({className:e,alignItemWithTrigger:t,children:n,...r}){let{size:i,alignItemWithTrigger:a}=dj(),o=t??a,{positioner:s,portal:c,popup:l}=Sh(r);return(0,G.jsx)(AA,{...c,children:(0,G.jsx)(IA,{sideOffset:6,...s,alignItemWithTrigger:o,className:Z(`isolate z-50`,s.className),children:(0,G.jsxs)(WA,{"data-slot":`select-content`,"data-align-trigger":o||void 0,className:Z(`bg-background border-border-overlay flex flex-col border shadow-2xl outline-none`,gj[i],`min-w-36`,o?`w-[calc(var(--anchor-width)+1rem)]`:`w-(--anchor-width)`,o?`origin-center`:`origin-(--transform-origin)`,`motion-safe:transition-[opacity,scale] motion-safe:duration-200 motion-safe:ease-[cubic-bezier(0.175,0.885,0.32,1.5)]`,`data-starting-style:motion-safe:scale-90 data-starting-style:motion-safe:opacity-0`,`data-ending-style:motion-safe:scale-95 data-ending-style:motion-safe:opacity-0 data-ending-style:motion-safe:duration-100 data-ending-style:motion-safe:ease-out`,e),...l,children:[(0,G.jsx)(yj,{}),(0,G.jsx)(QA,{className:`flex max-h-(--available-height) flex-col gap-0.5 overflow-y-auto p-2`,children:n}),(0,G.jsx)(bj,{})]})})})}var vj=Z(`bg-background text-foreground z-1 flex h-6 w-[calc(100%-var(--border-width)*2)] cursor-default items-center justify-center`);function yj(){let{size:e}=dj();return(0,G.jsx)(cj,{"data-slot":`select-scroll-up`,"aria-hidden":`true`,className:Z(vj,gj[e],`top-px rounded-b-none`),children:(0,G.jsx)(wj,{className:Z(pj[e],`rotate-180`)})})}function bj(){let{size:e}=dj();return(0,G.jsx)(sj,{"data-slot":`select-scroll-down`,"aria-hidden":`true`,className:Z(vj,gj[e],`bottom-px rounded-t-none`),children:(0,G.jsx)(wj,{className:pj[e]})})}var xj={sm:`gap-1 rounded-xs py-1.5 px-2.5 text-xs has-data-[icon=end]:pe-1.5 has-data-[icon=start]:ps-1.5 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='stroke-'])]:stroke-[1.75]`,md:`gap-1.5 rounded-sm py-2 px-3 text-sm has-data-[icon=end]:pe-2 has-data-[icon=start]:ps-2 [&_svg:not([class*='size-'])]:size-4.5 [&_svg:not([class*='stroke-'])]:stroke-[1.65]`,lg:`gap-1.5 rounded-md py-2.5 px-3.5 text-base has-data-[icon=end]:pe-2.5 has-data-[icon=start]:ps-2.5 [&_svg:not([class*='size-'])]:size-5 [&_svg:not([class*='stroke-'])]:stroke-[1.65]`},Sj={sm:`gap-1`,md:`gap-1.5`,lg:`gap-1.5`};function Cj({className:e,children:t,...n}){let{size:r,reducedMotion:i}=dj();return(0,G.jsxs)(tj,{"data-slot":`select-item`,className:Z(`text-foreground relative isolate flex w-full cursor-default items-center justify-between outline-hidden select-none [&_svg]:pointer-events-none [&_svg]:shrink-0`,`before:bg-background-muted before:absolute before:inset-0 before:-z-10 before:rounded-[inherit] before:opacity-0`,`active:translate-y-px active:scale-[0.98]`,`data-highlighted:not-data-disabled:text-foreground-intense data-highlighted:not-data-disabled:before:opacity-100`,`motion-safe:transition motion-safe:duration-250 motion-safe:ease-[cubic-bezier(0.175,0.885,0.32,1.5)]`,`motion-safe:active:duration-100 motion-safe:active:ease-in-out`,`motion-safe:before:transition-opacity motion-safe:before:duration-200 motion-safe:before:ease-out`,`data-disabled:opacity-disabled data-disabled:pointer-events-none`,xj[r],e),...n,children:[(0,G.jsx)(ij,{className:Z(`flex items-center text-start`,Sj[r]),children:t}),(0,G.jsx)(nj,{"data-slot":`select-item-indicator`,keepMounted:!i,className:`group/check text-foreground-intense shrink-0`,children:(0,G.jsx)(Ej,{"data-icon":`end`,className:`me-0.5 size-[1.125em]`})})]})}function wj(e){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,...e,children:(0,G.jsx)(`path`,{d:`M11.594 5.594c.225-.225.588-.225.813 0s.225.588 0 .813l-4 4c-.225.225-.588.225-.812 0l-4-4c-.225-.225-.225-.588 0-.812s.588-.225.812 0L8 9.187l3.594-3.594z`})})}function Tj(e){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,...e,children:(0,G.jsx)(`path`,{d:`M10.26 9.593c.225-.224.589-.224.814 0s.224.589 0 .813l-2.667 2.667c-.225.224-.589.224-.813 0l-2.666-2.667c-.225-.225-.225-.589 0-.813s.588-.224.813 0l2.26 2.26 2.261-2.26zM7.593 2.927c.225-.225.589-.225.813 0l2.667 2.666c.224.224.224.589 0 .813s-.589.225-.814 0L7.999 4.146 5.74 6.407c-.225.224-.588.224-.812 0s-.225-.589 0-.813l2.666-2.666z`})})}function Ej({className:e,...t}){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,className:Z(`stroke-2`,e),...t,children:(0,G.jsx)(`path`,{d:`M4.3 12.55 L9.25 17.5 L19.7 6.5`,pathLength:1,strokeDasharray:`1 2`,className:Z(`opacity-0 [stroke-dashoffset:1.02]`,`group-data-selected/check:opacity-100 group-data-selected/check:[stroke-dashoffset:0]`,`motion-safe:transition-[opacity,stroke-dashoffset] motion-safe:ease-out`,`motion-safe:delay-[0ms,150ms] motion-safe:duration-[150ms,0ms]`,`motion-safe:group-data-selected/check:delay-[0ms] motion-safe:group-data-selected/check:duration-[0ms,300ms]`)})})}function Dj(e){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`2 2 16 16`,fill:`currentColor`,"aria-hidden":`true`,...e,children:(0,G.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}function Oj(e){return e?e.lan.length>0?e.lan:e.public:[]}function kj(e){return!e||e.lan.length===0?[]:e.public}function Aj(e){return e?.ipv6??[]}function jj(e,t){let n=$(e===`lan`?`panel.address.lan`:e===`ipv6`?`panel.address.ipv6`:`panel.address.public`);return t?`${n} · ${t}`:n}function Mj(e,t){return`http://${e.includes(`:`)?`[${e}]`:e}:${String(t??``)}`}function Nj({book:e,port:t,value:n,busy:r=!1,onChange:i,fallbackUrls:a=[],align:o=`end`}){let s=o===`start`?`items-start`:`items-end`,c=o===`start`?`justify-start`:`justify-end`,l=o===`start`?`text-start`:`text-end`,u=String(t??``),d=Oj(e),f=kj(e),p=Aj(e),m=e&&e.lan.length>0?`lan`:`public`,h=d.some(e=>e.address===n)?n:d[0]?.address??``;return d.length===0?p.length===0&&a.length>0?(0,G.jsx)(`span`,{className:`flex flex-col gap-0.5 ${s}`,children:a.map(e=>(0,G.jsx)(`span`,{children:e},e))}):p.length===0?(0,G.jsx)(`span`,{className:`font-sans text-foreground-muted`,children:$(`panel.address.empty`)}):(0,G.jsx)(`span`,{className:`flex w-full flex-col gap-1 ${s}`,children:p.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-baseline gap-x-2 ${c}`,children:[(0,G.jsx)(`span`,{className:`font-mono text-xs text-foreground-muted`,children:Mj(e.address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-subtle`,children:`${jj(`ipv6`,e.interface)}${$(`panel.address.ipv6Hint`)}`})]},e.address))}):(0,G.jsxs)(`span`,{className:`flex w-full flex-col gap-1 ${s}`,children:[d.length>1?(0,G.jsx)(jk,{className:pg(`w-full gap-1`,s,r&&`pointer-events-none opacity-60`),value:h,onValueChange:e=>{typeof e==`string`&&e!==h&&i(e)},children:d.map(e=>(0,G.jsxs)(`label`,{className:`flex w-full cursor-pointer flex-wrap items-baseline gap-x-2 ${c}`,children:[(0,G.jsx)(hk,{value:e.address,"aria-label":Mj(e.address,u)}),(0,G.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:Mj(e.address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-muted`,children:jj(m,e.interface)})]},e.address))}):(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-baseline gap-x-2 ${c}`,children:[(0,G.jsx)(`span`,{className:`font-mono`,children:Mj(d[0].address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-muted`,children:jj(m,d[0].interface)})]}),f.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-baseline gap-x-2 ${c}`,children:[(0,G.jsx)(`span`,{className:`font-mono text-xs text-foreground-muted`,children:Mj(e.address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-subtle`,children:`${jj(`public`,e.interface)}${$(`panel.address.publicHint`)}`})]},e.address)),p.map(e=>(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-baseline gap-x-2 ${c}`,children:[(0,G.jsx)(`span`,{className:`font-mono text-xs text-foreground-muted`,children:Mj(e.address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-subtle`,children:$(`panel.address.ipv6Pick`,{kind:jj(`ipv6`,e.interface)})})]},e.address)),d.length>1?(0,G.jsx)(`span`,{className:`font-sans text-xs text-foreground-muted ${l}`,children:$(`panel.address.hint`)}):null]})}var Pj=`data:image/png;base64,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`,Fj=`https://github.com/WNLUO/dsh-mobile-server`,Ij=`https://github.com/WNLUO/dsh-mobile-plugin`,Lj=[{platform:`android`,channels:[{nameKey:`panel.links.distPlatform`,hintKey:`panel.links.domesticRecommended`,url:`https://app.wnluo.com/api/public/apps/14/download-latest`},{name:`GitHub`,hintKey:`panel.links.overseasRecommended`,url:`https://github.com/WNLUO/dsh-mobile-plugin/releases/latest/download/ai-hub-android.apk`}]},{platform:`apple`,channels:[{name:`App Store`,hintKey:`panel.links.appStore`,url:`https://apps.apple.com/cn/app/ai-hub/id6821681438`},{name:`TestFlight`,hintKey:`panel.links.testFlight`,url:`https://testflight.apple.com/join/4fn5PCMD`}]}],Rj=[{nameKey:`panel.links.publicRelay`,url:`https://ai-hub-de-1.wnluo.com`},{nameKey:`panel.links.publicRelay`,url:`https://dsh.iouf.cn`},{nameKey:`panel.links.publicRelay`,url:`https://dsh.yfyidc.cn`}];Rj[0].url;function zj(e){let t=e=>e.trim().replace(/\/+$/,``),n=t(e);return!!n&&Rj.some(e=>t(e.url)===n)}function Bj(e){return e.name===`GitHub`?(0,G.jsx)(qj,{}):e.name===`App Store`||e.name===`TestFlight`?(0,G.jsx)(Kj,{}):(0,G.jsx)(Jj,{})}function Vj(e){return e===`android`?(0,G.jsx)(Gj,{}):(0,G.jsx)(Kj,{})}function Hj({channel:e}){return(0,G.jsxs)(`a`,{className:`flex items-center gap-3 rounded-lg border border-border-muted px-3 py-2.5 transition-colors hover:bg-background-muted`,href:e.url,target:`_blank`,rel:`noreferrer noopener`,children:[(0,G.jsx)(`span`,{className:`flex size-9 shrink-0 items-center justify-center rounded-lg bg-background-muted text-foreground`,children:Bj(e)}),(0,G.jsxs)(`span`,{className:`flex min-w-0 flex-col gap-0.5`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground-intense`,children:e.name??(e.nameKey?$(e.nameKey):``)}),(0,G.jsx)(`span`,{className:`truncate text-xs text-foreground-muted`,children:$(e.hintKey)})]})]})}function Uj(){return(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:Lj.map(e=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-center gap-1.5 pb-0.5 text-xs text-foreground-muted`,children:[Vj(e.platform),(0,G.jsx)(`span`,{children:$(e.platform===`android`?`panel.links.android`:`panel.links.apple`)})]}),e.channels.map(e=>(0,G.jsx)(Hj,{channel:e},e.url))]},e.platform))})}function Wj({size:e=`md`,variant:t=`outline`,className:n}){let[r,i]=(0,g.useState)(!1),a=(0,g.useRef)(null);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Q,{variant:t,size:e,className:n,onClick:()=>i(!0),children:$(`panel.download.open`)}),(0,G.jsx)(cD,{open:r,onOpenChange:i,children:(0,G.jsxs)(lD,{className:`max-w-xl`,closeLabel:$(`panel.common.close`),initialFocus:a,children:[(0,G.jsx)(uD,{children:(0,G.jsxs)(dD,{className:`flex flex-wrap items-center gap-2.5 pr-8`,children:[(0,G.jsx)(`img`,{src:Pj,alt:``,className:`size-8 rounded-lg bg-white p-0.5`}),(0,G.jsx)(`span`,{className:`min-w-0 break-words`,children:$(`panel.download.title`)})]})}),(0,G.jsx)(`div`,{ref:a,tabIndex:-1,className:`outline-none`,children:(0,G.jsx)(pD,{children:(0,G.jsx)(Uj,{})})})]})})]})}function Gj(){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-3.5 stroke-0`,fill:`currentColor`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`M17.523 15.3414c-.5511 0-.9993-.4486-.9993-.9997s.4483-.9993.9993-.9993c.5511 0 .9993.4483.9993.9993.0001.5511-.4482.9997-.9993.9997m-11.046 0c-.5511 0-.9993-.4486-.9993-.9997s.4482-.9993.9993-.9993c.551 0 .9993.4483.9993.9993 0 .5511-.4483.9997-.9993.9997m11.4045-6.02 1.9973-3.4592a.416.416 0 0 0-.1521-.5676.416.416 0 0 0-.5676.1521l-2.0223 3.503C15.5902 8.2439 13.8533 7.8508 12 7.8508s-3.5902.3931-5.1367 1.0989L4.841 5.4467a.4161.4161 0 0 0-.5677-.1521.4157.4157 0 0 0-.1521.5676l1.9973 3.4592C2.6889 11.1867.3432 14.6589 0 18.761h24c-.3435-4.1021-2.6892-7.5743-6.1185-9.4396`})})}function Kj(){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4 stroke-0`,fill:`currentColor`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`M12.152 6.896c-.948 0-2.415-1.078-3.96-1.04-2.04.027-3.91 1.183-4.961 3.014-2.117 3.675-.546 9.103 1.519 12.09 1.013 1.454 2.208 3.09 3.792 3.039 1.52-.065 2.09-.987 3.935-.987 1.831 0 2.35.987 3.96.948 1.637-.026 2.676-1.48 3.676-2.948 1.156-1.688 1.636-3.325 1.662-3.415-.039-.013-3.182-1.221-3.22-4.857-.026-3.04 2.48-4.494 2.597-4.559-1.429-2.09-3.623-2.324-4.39-2.376-2-.156-3.675 1.09-4.61 1.09zM15.53 3.83c.843-1.012 1.4-2.427 1.245-3.83-1.207.052-2.662.805-3.532 1.818-.78.896-1.454 2.338-1.273 3.714 1.338.104 2.715-.688 3.559-1.701`})})}function qj(){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-[18px] stroke-0`,fill:`currentColor`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function Jj(){return(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:`size-[18px]`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.85`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M12 4v10`}),(0,G.jsx)(`path`,{d:`m8 10.5 4 4 4-4`}),(0,G.jsx)(`path`,{d:`M4 18.5h16`})]})}function Yj({on:e,what:t,label:n,className:r,disabled:i,onClick:a}){let o=n??$(e?`panel.common.hide`:`panel.common.show`);return(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:r,"aria-label":`${o}${t}`,disabled:i,onClick:a,children:o})}function Xj(){return(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-6`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.6`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`rect`,{x:`3`,y:`3`,width:`7`,height:`7`,rx:`1`}),(0,G.jsx)(`rect`,{x:`14`,y:`3`,width:`7`,height:`7`,rx:`1`}),(0,G.jsx)(`rect`,{x:`3`,y:`14`,width:`7`,height:`7`,rx:`1`}),(0,G.jsx)(`path`,{d:`M14 14h3v3M21 14v.01M14 21h.01M17 21h4v-4`})]})}function Zj({status:e,pairing:t,addressBook:n,busy:r,error:i,restartError:a,onOpenConfig:o,onChangePolicy:s,onChangeTier:c,onChangeAutoReview:l,onOpenSelfCheck:u,onRetryPairing:d,onSavePreferred:f,onEditPort:p,fill:m}){let h=r!==``,_=e.pairingPolicy===`code`,v=e.pairingTier??`full`,y=e.approvalAutoReview===!0,b=t?.relayUrl||e.relayUrl||`—`,x=Qj(n,t),[S,C]=g.useState({relay:!1}),[w,T]=g.useState(!1),[E,D]=g.useState(!1),[O,k]=g.useState(!1),A=e=>C(t=>({...t,[e]:!t[e]}));return(0,G.jsxs)(xD,{frame:`solid`,className:m?`flex h-full min-h-0 flex-col`:void 0,children:[(0,G.jsx)(SD,{className:`flex-none px-4 py-3`,children:(0,G.jsxs)(CD,{className:`flex flex-wrap items-center justify-between gap-x-2 gap-y-1 text-base lg:text-lg`,children:[(0,G.jsx)(`span`,{children:$(`panel.pairing.cardTitle`)}),(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`px-2 xl:px-4 xl:before:border xl:before:border-border xl:before:bg-background`,disabled:h,onClick:o,children:$(`panel.pairing.openConfig`)}),(0,G.jsx)(Wj,{size:`sm`,variant:`ghost`,className:`px-2 xl:px-4 xl:before:border xl:before:border-border xl:before:bg-background`}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`px-2`,onClick:()=>k(!0),children:$(`panel.common.more`)})]})]})}),i?(0,G.jsxs)(YE,{variant:`warning`,className:`mt-3`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:$(`panel.pairing.qrFailed`)}),(0,G.jsx)($E,{children:i})]}):null,(0,G.jsxs)(`div`,{className:`mt-3 flex flex-col gap-4 sm:flex-row sm:items-stretch ${m?`min-h-0 flex-1`:``}`,children:[(0,G.jsx)(`div`,{className:`relative mx-auto aspect-square w-full max-w-[200px] shrink-0 self-center sm:mx-0 sm:w-[150px] sm:max-w-none sm:self-start`,children:t?.svg?(0,G.jsxs)(`button`,{type:`button`,className:`absolute inset-0 flex cursor-zoom-in flex-col items-center justify-center gap-2 rounded-md border border-border-muted bg-background-muted p-3 text-foreground-subtle transition-colors hover:bg-background-subtle focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,onClick:()=>D(!0),"aria-label":`${$(`panel.pairing.qrZoom`)}:${$(`panel.pairing.qr`)}`,children:[(0,G.jsx)(Xj,{}),(0,G.jsx)(`span`,{className:`text-xs`,children:$(`panel.pairing.qrHidden`)}),(0,G.jsx)(`span`,{className:`text-xs`,children:$(`panel.common.show`)})]}):(0,G.jsx)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-2 rounded-md border border-border-muted bg-background-muted p-3 text-foreground-subtle`,children:i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`span`,{className:`text-xs`,children:$(`panel.pairing.qrFailed`)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:h,onClick:d,children:$(`panel.console.retryPairing`)})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(VE,{}),(0,G.jsx)(`span`,{className:`text-xs`,children:$(`panel.pairing.noQr`)})]})})}),(0,G.jsx)(`div`,{className:`flex min-w-0 flex-1 flex-col`,children:(0,G.jsx)(`div`,{className:`hscroll -mx-1 px-1`,children:(0,G.jsxs)(DO,{className:`min-w-max`,children:[(0,G.jsx)(EO,{label:$(`panel.connection.relayUrl`),nowrap:!0,children:(0,G.jsxs)(`span`,{className:`inline-flex min-w-0 flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[S.relay?(0,G.jsx)(`span`,{className:`min-w-0 font-mono text-xs text-foreground-strong`,children:b}):(0,G.jsx)(`span`,{className:`text-xs text-foreground-subtle`,children:$(`panel.pairing.hidden`)}),(0,G.jsx)(Yj,{on:S.relay,what:$(`panel.connection.relayUrl`),label:S.relay?$(`panel.common.hide`):$(`panel.common.show`),onClick:()=>A(`relay`)})]})}),(0,G.jsx)(EO,{label:$(`panel.pairing.port`),mono:!0,nowrap:!0,children:(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[(0,G.jsxs)(`span`,{children:[t?.lanPort??e.lan.port,t?.lanPortAdjusted?(0,G.jsx)(`span`,{className:`ml-2 font-sans text-xs text-foreground-muted`,children:$(`panel.pairing.portFallback`)}):null]}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,"aria-label":$(`panel.pairing.portTitle`),disabled:h,onClick:p,children:$(`panel.common.edit`)})]})}),(0,G.jsx)(EO,{label:$(`panel.pairing.phoneAddress`),nowrap:!0,children:(0,G.jsxs)(`span`,{className:`inline-flex flex-wrap items-center justify-end gap-x-2 gap-y-1`,children:[x?null:(0,G.jsx)(`span`,{className:`text-xs text-foreground-subtle`,children:$(`panel.pairing.noAddress`)}),(0,G.jsx)(Yj,{on:!1,what:$(`panel.pairing.phoneAddress`),label:$(`panel.common.show`),onClick:()=>T(!0)})]})})]})})})]}),a?(0,G.jsxs)(YE,{variant:`error`,className:`mt-3`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:$(`panel.pairing.sidecarRestartFailed`)}),(0,G.jsx)($E,{children:a})]}):null,(0,G.jsx)(cD,{open:E,onOpenChange:D,children:(0,G.jsxs)(lD,{className:`w-[min(680px,94vw)] max-h-[90vh] max-w-none`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.pairing.qr`)})}),(0,G.jsx)(pD,{children:(0,G.jsx)(`div`,{className:`flex items-center justify-center overflow-auto rounded-md bg-white p-2 sm:p-4`,children:t?.svg?(0,G.jsx)(`div`,{className:`aspect-square h-[min(64vh,560px)] w-auto max-w-full [&_svg]:h-full [&_svg]:w-full`,dangerouslySetInnerHTML:{__html:t.svg}}):null})})]})}),(0,G.jsx)(cD,{open:w,onOpenChange:T,children:(0,G.jsxs)(lD,{className:`max-w-xl`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.pairing.phoneAddress`)})}),(0,G.jsx)(pD,{children:(0,G.jsx)(Nj,{book:n,port:t?.lanPort??e.lan.port,value:n?.preferred??``,busy:h,onChange:f,fallbackUrls:t?.lanUrls??[]})}),(0,G.jsx)(mD,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>T(!1),children:$(`panel.common.close`)})})]})}),(0,G.jsx)(cD,{open:O,onOpenChange:k,children:(0,G.jsxs)(lD,{className:`max-w-md`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.common.more`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.pairing.policy`),children:(0,G.jsx)(QD,{size:`md`,checked:_,disabled:h,onCheckedChange:e=>s(e?`code`:`deny`),"aria-label":$(`panel.devices.allowTitle`)})}),(0,G.jsx)(EO,{label:$(`panel.pairing.tier`),hint:$(`panel.pairing.tierHint`),children:(0,G.jsxs)(fj,{size:`sm`,value:v,disabled:h,itemToStringLabel:e=>eM(e),onValueChange:e=>{typeof e==`string`&&e!==v&&c(e)},children:[(0,G.jsx)(mj,{className:`min-w-0 max-w-full`,"aria-label":$(`panel.pairing.tier`),children:(0,G.jsx)(hj,{})}),(0,G.jsx)(_j,{children:$j.map(e=>(0,G.jsx)(Cj,{value:e,children:eM(e)},e))})]})}),(0,G.jsx)(EO,{label:$(`panel.pairing.autoReview`),hint:$(`panel.pairing.autoReviewHint`),children:(0,G.jsx)(QD,{size:`sm`,checked:y,disabled:h,"aria-label":$(`panel.pairing.autoReview`),onCheckedChange:e=>{e!==y&&l(e)}})})]}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`outline`,size:`sm`,onClick:u,children:$(`panel.pairing.checkNetwork`)})})]})]})})]})}function Qj(e,t){return e&&e.lan.length+e.public.length>0?`book`:t?.lanUrls?.[0]??``}var $j=[`readonly`,`approve`,`full`];function eM(e){return $(e===`readonly`?`panel.pairing.tierReadonly`:e===`approve`?`panel.pairing.tierApprove`:`panel.pairing.tierFull`)}var tM={ok:4e3,soft:6e3,error:9e3};function nM(){let e=(0,g.useRef)(fd());return e.current=fd(),(0,g.useCallback)((t,n)=>{e.current.add({title:n,type:t,timeout:tM[t],priority:t===`error`?`high`:`low`})},[])}function rM(e){return e===`none`?$(`panel.devices.tierNone`):eM(e)}function iM(e){return e===`none`?`readonly`:e}function aM(e,t){if(!e)return``;let n=Math.max(0,t-e);if(n<6e4)return $(`panel.devices.justNow`);let r=Math.floor(n/6e4);if(r<60)return $(`panel.devices.minutesAgo`,{count:r});let i=Math.floor(r/60);return i<24?$(`panel.devices.hoursAgo`,{count:i}):$(`panel.devices.daysAgo`,{count:Math.floor(i/24)})}function oM(e,t){return e?sM(e,t)?$(`panel.devices.online`):aM(e,t):$(`panel.devices.noRecord`)}function sM(e,t){return e>0&&t-e<=3e5}function cM(e){return{ios:`iOS`,android:`Android`,linux:`Linux`,darwin:`macOS`,win32:`Windows`}[e]??(e||$(`panel.devices.unknownPlatform`))}function lM(e){return $(e===`relay`?`panel.devices.channelRelay`:e===`lan`?`panel.devices.channelLan`:`panel.devices.channelUnknown`)}function uM(e){let t=e?.model||e?.name||$(`panel.devices.unknown`);return e?.suffix?`${t} · ${e.suffix}`:t}function dM(){return(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M12 3l7 3v5c0 4.5-3 7.5-7 9-4-1.5-7-4.5-7-9V6l7-3Z`}),(0,G.jsx)(`path`,{d:`m9 12 2 2 4-4`})]})}function fM(){return(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M9 15l6-6`}),(0,G.jsx)(`path`,{d:`M7 17l-1 1a3 3 0 0 1-4-4l2-2a3 3 0 0 1 4 0`}),(0,G.jsx)(`path`,{d:`M17 7l1-1a3 3 0 0 1 4 4l-2 2a3 3 0 0 1-4 0`})]})}function pM({onRevokeAll:e,busy:t,fill:n=!1}){let r=nM(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(`full`),[m,h]=(0,g.useState)(!1),_=(0,g.useRef)(!1),v=(0,g.useRef)(null),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(null),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),[D,O]=(0,g.useState)(!1),k=(0,g.useRef)(0),A=(0,g.useCallback)(async()=>{let e=++k.current;w(!1);try{let t=await Rk(`/api/relay/devices?history=1`);e===k.current&&S(t)}catch{e===k.current&&w(!0)}},[]),j=(0,g.useCallback)(async()=>{try{let e=await Rk(`/api/relay/devices`),t=e.revokedCount??0,n=v.current!==null&&v.current!==t;v.current=t,a(e),n&&_.current&&A()}catch{}},[A]);(0,g.useEffect)(()=>{let e=()=>{l_()&&j()};e();let t=window.setInterval(e,3e3);return document.addEventListener(`visibilitychange`,e),()=>{window.clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[j]);let M=i?.devices??[],N=i?.serverNow??0,P=i?.revokedCount??0;(0,g.useEffect)(()=>{_.current=y},[y]),(0,g.useEffect)(()=>{y&&A()},[y,A]);function F(e){let t=aM(e.revokedAt||e.expiresAt,N)||`—`;return $(e.kind===`revoked`?`panel.devices.historyRevoked`:`panel.devices.historyExpired`,{time:t})}let I=(x?.devices??[]).filter(e=>e.kind===`revoked`||e.kind===`expired`),L=C||(x?.devices.length??0)>0&&I.length===0;async function R(e){l(!0);try{let t=await zk(`/api/relay/devices/revoke`,{deviceId:e.deviceId});s(null),await j(),y&&A(),r(`soft`,$(t.closed>0?`panel.devices.unbindDoneClosed`:`panel.devices.unbindDone`,{name:uM(e),count:t.revoked,closed:t.closed}))}catch(e){r(`error`,$(`panel.devices.unbindFailed`,{message:Uk(e)}))}finally{l(!1)}}async function z(){O(!0);try{let e=await zk(`/api/relay/devices/history/clear`,{});E(!1),await j(),y&&A(),r(`soft`,$(`panel.devices.historyClearDone`,{count:e.cleared}))}catch(e){r(`error`,$(`panel.devices.historyClearFailed`,{message:Uk(e)}))}finally{O(!1)}}async function B(e,t){h(!0);try{await Hk(e.deviceId,t),d(null),await j(),r(`soft`,$(`panel.devices.permissionsDone`,{name:uM(e),tier:eM(t)}))}catch(e){r(`error`,$(`panel.devices.permissionsFailed`,{message:Uk(e)}))}finally{h(!1)}}return M.length===0&&P===0?null:(0,G.jsxs)(xD,{frame:`solid`,className:n?`flex h-full min-h-0 flex-col`:void 0,children:[(0,G.jsx)(SD,{className:n?`flex-none px-4 py-3`:`px-4 py-3`,children:(0,G.jsxs)(CD,{className:`flex flex-wrap items-center justify-between gap-x-2 gap-y-1 text-base lg:text-lg`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[$(`panel.devices.title`),M.length>0?(0,G.jsx)(rD,{variant:`secondary`,size:`sm`,children:M.length}):null]}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`shrink-0 px-2 xl:px-4 xl:before:border xl:before:border-border xl:before:bg-background`,disabled:t!==``,onClick:e,children:$(`panel.pairing.revokeAll`)})]})}),(0,G.jsxs)(`div`,{className:n?`hvscroll mt-1 min-h-0 flex-1`:`hscroll mt-1`,children:[(0,G.jsx)(`div`,{className:`min-w-max`,children:M.map(e=>{let t=sM(e.lastSeenAt,N);return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border-muted py-2 whitespace-nowrap last:border-b-0`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground-strong`,children:uM(e)}),(0,G.jsx)(rD,{variant:`secondary`,size:`xs`,children:rM(Mk(e.permissions))}),(0,G.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1 whitespace-nowrap text-xs text-foreground-muted`,children:[(0,G.jsx)(`span`,{children:cM(e.platform)}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,G.jsx)(`span`,{children:lM(e.lastChannel)}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t?(0,G.jsx)(TO,{tone:`ok`}):null,(0,G.jsx)(`span`,{children:oM(e.lastSeenAt,N)})]})]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`icon-md`,"aria-label":$(`panel.devices.permissions`),title:$(`panel.devices.permissions`),onClick:()=>{p(iM(Mk(e.permissions))),d(e)},children:(0,G.jsx)(dM,{})}),(0,G.jsx)(Q,{variant:`ghost`,size:`icon-md`,"aria-label":$(`panel.devices.unbind`),title:$(`panel.devices.unbind`),onClick:()=>s(e),children:(0,G.jsx)(fM,{})})]})]},e.deviceId)})}),(0,G.jsxs)(`div`,{className:`mt-1 border-t border-border-muted pt-2`,children:[(0,G.jsxs)(`div`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,G.jsxs)(`button`,{type:`button`,"aria-expanded":y,className:`flex min-w-0 cursor-pointer items-center gap-2 text-xs text-foreground-muted focus-visible:outline-none`,onClick:()=>b(e=>!e),children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[$(`panel.devices.historyTitle`),(0,G.jsx)(rD,{variant:`secondary`,size:`xs`,children:$(`panel.devices.historyCount`,{count:P})})]}),(0,G.jsx)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 shrink-0 transition-transform ${y?`rotate-90`:``}`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`m4.5 2.5 3.5 3.5-3.5 3.5`})})]}),P>0?(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`shrink-0`,disabled:D||t!==``,onClick:()=>E(!0),children:$(`panel.devices.historyClear`)}):null]}),y?(0,G.jsxs)(`div`,{className:`mt-2`,children:[I.map(e=>(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-2 gap-y-1`,children:[(0,G.jsx)(`span`,{className:`text-xs text-foreground`,children:uM(e)}),(0,G.jsxs)(`span`,{className:`text-xs text-foreground-muted`,children:[cM(e.platform),e.osVersion?` ${e.osVersion}`:``,e.appVersion?$(`panel.devices.appVersion`,{version:e.appVersion}):``]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 text-xs text-foreground-muted`,children:[(0,G.jsx)(`span`,{children:$(`panel.devices.historyBoundAt`,{time:aM(e.boundAt,N)||`—`})}),(0,G.jsx)(`span`,{children:$(`panel.devices.historyLastSeen`,{time:e.lastSeenAt?aM(e.lastSeenAt,N):$(`panel.devices.noRecord`)})}),(0,G.jsx)(`span`,{children:F(e)})]})]},e.deviceId)),L?(0,G.jsx)(`p`,{className:`py-2 text-xs text-foreground-muted`,children:$(`panel.devices.historyFailed`)}):null,(0,G.jsx)(`p`,{className:`py-2 text-xs text-foreground-muted`,children:$(`panel.devices.historyRetention`,{days:30})})]}):null]})]}),(0,G.jsx)(WO,{open:o!==null,onOpenChange:e=>{!e&&!c&&s(null)},children:(0,G.jsxs)(GO,{children:[(0,G.jsx)(KO,{children:(0,G.jsx)(qO,{children:$(`panel.devices.unbindTitle`)})}),(0,G.jsxs)(YO,{className:`flex flex-col gap-2 text-sm`,children:[(0,G.jsx)(JO,{children:$(`panel.devices.unbindConfirm`,{name:uM(o)})}),(0,G.jsx)(`p`,{className:`text-foreground-muted`,children:$(o?.legacy?`panel.devices.effectLegacy`:`panel.devices.effectIdentity`)})]}),(0,G.jsxs)(XO,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:c,onClick:()=>s(null),children:$(`panel.devices.cancel`)}),(0,G.jsx)(Q,{variant:`destructive`,disabled:c,onClick:()=>{o&&R(o)},children:c?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(VE,{}),$(`panel.devices.unbinding`)]}):$(`panel.devices.unbind`)})]})]})}),(0,G.jsx)(WO,{open:u!==null,onOpenChange:e=>{!e&&!m&&d(null)},children:(0,G.jsxs)(GO,{children:[(0,G.jsx)(KO,{children:(0,G.jsx)(qO,{children:$(`panel.devices.permissionsTitle`)})}),(0,G.jsxs)(YO,{className:`flex flex-col gap-3 text-sm`,children:[(0,G.jsx)(JO,{children:$(`panel.devices.permissionsHint`)}),(0,G.jsx)(jk,{className:`flex flex-col gap-2`,value:f,onValueChange:e=>{typeof e==`string`&&p(e)},children:$j.map(e=>(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2`,children:[(0,G.jsx)(hk,{value:e}),(0,G.jsx)(`span`,{children:eM(e)})]},e))})]}),(0,G.jsxs)(XO,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:m,onClick:()=>d(null),children:$(`panel.devices.cancel`)}),(0,G.jsx)(Q,{variant:`secondary`,disabled:m,onClick:()=>{u&&B(u,f)},children:m?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(VE,{}),$(`panel.devices.permissionsApply`)]}):$(`panel.devices.permissionsApply`)})]})]})}),(0,G.jsx)(WO,{open:T,onOpenChange:e=>{!e&&!D&&E(!1)},children:(0,G.jsxs)(GO,{children:[(0,G.jsx)(KO,{children:(0,G.jsx)(qO,{children:$(`panel.devices.historyClearTitle`)})}),(0,G.jsxs)(YO,{className:`flex flex-col gap-2 text-sm`,children:[(0,G.jsx)(JO,{children:$(`panel.devices.historyClearConfirm`,{count:P})}),(0,G.jsx)(`p`,{className:`text-foreground-muted`,children:$(`panel.devices.historyClearHint`)})]}),(0,G.jsxs)(XO,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:D,onClick:()=>E(!1),children:$(`panel.devices.cancel`)}),(0,G.jsx)(Q,{variant:`destructive`,disabled:D,onClick:()=>void z(),children:D?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,G.jsx)(VE,{}),$(`panel.devices.historyClearing`)]}):$(`panel.devices.historyClear`)})]})]})})]})}var mM=`data:image/png;base64,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`,hM=()=>$(`panel.links.wechatQrAlt`);function gM(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`stroke-0`,fill:`currentColor`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`M8.691 2.188C3.891 2.188 0 5.476 0 9.53c0 2.212 1.17 4.203 3.002 5.55a.59.59 0 0 1 .213.665l-.39 1.48c-.019.07-.048.141-.048.213 0 .163.13.295.29.295a.326.326 0 0 0 .167-.054l1.903-1.114a.864.864 0 0 1 .717-.098 10.16 10.16 0 0 0 2.837.403c.276 0 .543-.027.811-.05-.857-2.578.157-4.972 1.932-6.446 1.703-1.415 3.882-1.98 5.853-1.838-.576-3.583-4.196-6.348-8.596-6.348zM5.785 5.991c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178A1.17 1.17 0 0 1 4.623 7.17c0-.651.52-1.18 1.162-1.18zm5.813 0c.642 0 1.162.529 1.162 1.18a1.17 1.17 0 0 1-1.162 1.178 1.17 1.17 0 0 1-1.162-1.178c0-.651.52-1.18 1.162-1.18zm5.34 2.867c-1.797-.052-3.746.512-5.28 1.786-1.72 1.428-2.687 3.72-1.78 6.22.942 2.453 3.666 4.229 6.884 4.229.826 0 1.622-.12 2.361-.336a.722.722 0 0 1 .598.082l1.584.926a.272.272 0 0 0 .14.047c.134 0 .24-.111.24-.247 0-.06-.023-.12-.038-.177l-.327-1.233a.582.582 0 0 1-.023-.156.49.49 0 0 1 .201-.398C23.024 18.48 24 16.82 24 14.98c0-3.21-2.931-5.837-6.656-6.088V8.89c-.135-.01-.27-.027-.407-.03zm-2.53 3.274c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.97-.982zm4.844 0c.535 0 .969.44.969.982a.976.976 0 0 1-.969.983.976.976 0 0 1-.969-.983c0-.542.434-.982.969-.982z`})})}function _M({compact:e=!1}={}){let[t,n]=(0,g.useState)(!1),r=Sg();return r!==`zh-Hans`&&r!==`zh-Hant`?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`primary`,size:e?`sm`:`lg`,className:`pointer-events-auto rounded-full shadow-lg`,onClick:()=>n(!0),children:[(0,G.jsx)(gM,{}),$(`panel.links.joinGroup`)]}),(0,G.jsx)(cD,{open:t,onOpenChange:n,children:(0,G.jsxs)(lD,{className:`max-w-sm`,children:[(0,G.jsx)(dD,{className:`sr-only`,children:$(`panel.links.joinGroup`)}),(0,G.jsx)(pD,{className:`flex justify-center`,children:(0,G.jsx)(`img`,{src:mM,alt:hM(),className:`w-full rounded-md`})})]})})]})}var vM=Gu(``,{variants:{size:{sm:`h-6 gap-0.75 rounded-xs px-2 text-xs has-data-[icon=end]:pe-1.5 has-data-[icon=start]:ps-1.5 [&_svg:not([class*='size-'])]:size-3.5`,md:`h-8 gap-1 rounded-sm px-3 text-sm has-data-[icon=end]:pe-2 has-data-[icon=start]:ps-2 [&_svg:not([class*='size-'])]:size-4`,lg:`h-10 gap-1.25 rounded-md px-3.5 text-base has-data-[icon=end]:pe-2.5 has-data-[icon=start]:ps-2.5 [&_svg:not([class*='size-'])]:size-4.5`}},defaultVariants:{size:`md`}}),yM=g.createContext(null),bM={opacity:0,scale:.85,filter:`blur(8px)`},xM={opacity:0},SM={duration:.28,ease:[.4,0,.2,1]},CM={duration:0},wM={sm:`size-3`,md:`size-3.5`,lg:`size-4`};function TM({className:e,variant:t,size:n,render:r,dismissible:i=!1,open:a,onOpenChange:o,onDismiss:s,closeLabel:c=`Dismiss`,children:l,onClick:u,...d}){let f=g.useContext(yM),p=t??f?.variant??`soft`,m=n??f?.size??`md`,h=yh(),[_,v]=g.useState(!0),y=a!==void 0,b=y?a:_,x=g.useCallback(()=>{y||v(!1),o?.(!1)},[y,o]);g.useEffect(()=>{if(f&&i)return f.register(x)},[f,i,x]);let S=e=>{u?.(e),!e.defaultPrevented&&i&&x()},C=i?(0,G.jsxs)(G.Fragment,{children:[l,(0,G.jsx)(EM,{size:m}),(0,G.jsx)(`span`,{className:`sr-only`,children:c})]}):l,w=eD({defaultTagName:`button`,render:r,state:{variant:p,size:m,dismissible:i},props:Er({"data-slot":`chip`,"data-dismissible":i||void 0,type:r?void 0:`button`,...Hu(d.disabled),className:Z(qu({variant:p}),vM({size:m}),i&&`group/chip`,e),onClick:S,children:C},d)});return i?(0,G.jsx)(Iw,{features:VT,strict:!0,children:(0,G.jsx)(kw,{initial:!1,onExitComplete:()=>s?.(),children:b&&(0,G.jsx)(bE.span,{initial:!1,exit:h?xM:bM,transition:h?CM:SM,className:`inline-flex align-middle`,children:w},`chip`)})}):w}function EM({size:e}){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 16 16`,fill:`currentColor`,"aria-hidden":`true`,"data-slot":`chip-close-icon`,"data-icon":`end`,className:Z(wM[e],`opacity-60 transition-opacity duration-200 group-hover/chip:opacity-100 motion-reduce:transition-none`),children:(0,G.jsx)(`path`,{d:`M11.523 3.522c.264-.264.691-.264.955 0s.264.691 0 .955L8.955 8l3.522 3.522c.264.264.264.691 0 .955s-.691.264-.955 0L8 8.955l-3.522 3.522c-.264.264-.691.264-.955 0s-.264-.691 0-.955L7.045 8 3.522 4.478c-.264-.264-.264-.691 0-.955s.691-.264.955 0L8 7.045l3.523-3.522z`})})}var DM=`M4.3 12.55 L9.25 17.5 L19.7 6.5`,OM={xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:1.5,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":!0};async function kM(e){if(typeof e==`string`)return e;if(typeof e==`function`)return await e();let t=e.current;if(!t)throw Error("CopyButton: the `value` ref is not attached to an element");return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement?t.value:t.textContent??``}async function AM(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}let t=document.createElement(`textarea`);t.value=e,t.setAttribute(`readonly`,``),t.style.position=`fixed`,t.style.opacity=`0`,document.body.appendChild(t),t.select();try{if(!document.execCommand(`copy`))throw Error(`Copying to clipboard is not supported`)}finally{t.remove()}}function jM({value:e,timeout:t=2e3,label:n=`Copy`,copiedLabel:r=`Copied`,onCopy:i,onCopyError:a,icon:o,onClick:s,variant:c=`ghost`,size:l=`icon-sm`,className:u,children:d,...f}){let[p,m]=g.useState(!1),h=g.useRef(void 0);return g.useEffect(()=>()=>clearTimeout(h.current),[]),(0,G.jsxs)(Q,{"data-slot":`copy-button`,"data-copied":p||void 0,type:`button`,variant:c,size:l,"aria-label":p?r:n,onClick:async n=>{if(s?.(n),n.defaultPrevented)return;let r;try{r=await kM(e),await AM(r)}catch(e){a?.(e);return}i?.(r),m(!0),clearTimeout(h.current),h.current=setTimeout(()=>m(!1),t)},className:Z(`group/copy`,u),...f,children:[(0,G.jsxs)(`span`,{"data-icon":d==null?void 0:`start`,className:`grid place-items-center *:[grid-area:1/1]`,children:[(0,G.jsx)(`span`,{className:Z(`grid place-items-center transition-[opacity,scale] delay-150 duration-150 ease-out group-data-copied/copy:delay-0`,`group-data-copied/copy:scale-50 group-data-copied/copy:opacity-0`,`motion-reduce:transition-none`),children:o??(0,G.jsx)(`svg`,{...OM,children:(0,G.jsx)(`path`,{d:`M4.012 16.737c-.307-.175-.562-.427-.739-.732S3.001 15.353 3 15V5c0-1.1.9-2 2-2h10c.75 0 1.158.385 1.5 1M7 9.667c0-.707.281-1.386.781-1.886S8.96 7 9.667 7h8.666c.35 0 .697.069 1.021.203s.618.33.865.578.444.542.578.865A2.67 2.67 0 0 1 21 9.667v8.666a2.67 2.67 0 0 1-.781 1.886 2.67 2.67 0 0 1-1.886.781H9.667a2.67 2.67 0 0 1-1.021-.203c-.324-.134-.618-.331-.865-.578s-.444-.542-.578-.865S7 18.683 7 18.333V9.667z`})})}),(0,G.jsx)(`svg`,{...OM,children:(0,G.jsx)(`path`,{d:DM,pathLength:1,strokeDasharray:`1 2`,className:Z(`[stroke-dashoffset:1.02] group-data-copied/copy:[stroke-dashoffset:0]`,`transition-[stroke-dashoffset] duration-200 ease-in`,`group-data-copied/copy:delay-100 group-data-copied/copy:duration-350 group-data-copied/copy:ease-out`,`motion-reduce:transition-none`)})})]}),typeof d==`string`&&p?r:d,(0,G.jsx)(`span`,{role:`status`,className:`sr-only`,children:p?r:``})]})}var MM=`data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAewAAAHsAQAAAAA4UaPNAAACeUlEQVR42u2dQW7DMAwEhX5A//+lfsA2sU0umRg9BChKYQwfDNlzEVbKkqKUYZ9ca4CDg4OD/398+DXt5360zOvtcT+vn/flY1tf46MLHPzv8REKfz48Wi6dn89P8R/PPihOCs2Dt9V8muTLW/8JuL6Jj9E8eH/Nx7O/mmJ1DM2Db6d5fbVOP+PennkefE8/b5ba1/CxUD5G8+BdNZ/zNr/c5G3A+2v+Lo2pI8In//wNPQ/eVvNXfHpI/TDz48pPapY+t9Pz4D01v8ZrWsYv179nMmWA0PPgjf18Cl2XCNvD25LMRPPgnb3N8MxkdjWh/7e/AmgevLXmtfYgx7AlOU8MC76Bt0lpmVxjE2r38jO392gevHPextM1teQml1aqsUfz4F3neamoOa/s2+9TPfQ8eGNv46l4jVvVvetbvA14b2+T0+9j1PWpVGY5IquD5sFb5200/a55mzD8MyV20Dx4b2/jlqbYezH2Ec/ibcC3mOfTDpFQdQ5azTS9g+bBW8ewVerTSngbQ2Dh58H7x7BZzyr+aJl5xQrNgzf387EaNWtCPlpyaSWaB288z4uko7Ty7dE3Q2vp6XnwtjFsOehDqmsiq2MS4VJ7AN7a20yTsFTqykYsxeoQkAVZeh68q7fR/VBpJ+xMu6VeBgg9D941hq0HGljdA6uFB/EZmgdv6+ff7H7Nx4BouhLNg+8wz4eMo/G25Ib6efANYtibauF0XqVZqb1E8+B9Ne8K1xTNq8iT1UHz4FtoPkSuZcOl8JL6efC95nldgS2nfNQt4WgefAM/b/Us4pHrE/IJCfQ8+C55m5XWqkpUy5oUeHfN8/dz4ODg4Pvi3/5iKXEUjwVUAAAAAElFTkSuQmCC`,NM=`0x62744c084c272ddba4680920edc3239cb7180718`;function PM(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`stroke-0`,fill:`currentColor`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`M12 21.35l-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54L12 21.35z`})})}function FM({compact:e=!1}={}){let[t,n]=(0,g.useState)(!1),[r,i]=(0,g.useState)(!1);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`secondary`,size:e?`sm`:`lg`,className:`pointer-events-auto rounded-full shadow-lg`,onClick:()=>{i(!1),n(!0)},children:[(0,G.jsx)(PM,{}),$(`panel.links.sponsor`)]}),(0,G.jsx)(IM,{open:t,onOpenChange:n,copyFailed:r,setCopyFailed:i})]})}function IM({open:e,onOpenChange:t,copyFailed:n,setCopyFailed:r}){return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`max-w-sm`,children:[(0,G.jsxs)(uD,{className:`gap-1.5`,children:[(0,G.jsx)(dD,{className:`text-xl`,children:$(`panel.links.sponsorTitle`)}),(0,G.jsx)(fD,{children:$(`panel.links.sponsorIntro`)})]}),(0,G.jsxs)(pD,{className:`flex flex-col gap-4`,children:[(0,G.jsx)(`div`,{className:`flex justify-center`,children:(0,G.jsx)(`img`,{src:MM,alt:$(`panel.links.sponsorQrAlt`),className:`size-44 rounded-lg border border-border-muted bg-white p-2`})}),(0,G.jsxs)(`div`,{className:`flex justify-center gap-2`,children:[(0,G.jsx)(TM,{variant:`soft`,size:`sm`,children:`USDT`}),(0,G.jsx)(TM,{variant:`soft`,size:`sm`,children:`Polygon`})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-2 rounded-lg border border-border-muted bg-background-muted p-3`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.links.sponsorAddress`)}),(0,G.jsx)(jM,{value:NM,label:$(`panel.links.sponsorCopy`),copiedLabel:$(`panel.links.sponsorCopied`),size:`sm`,variant:`outline`,onCopyError:()=>r(!0),onCopy:()=>r(!1),children:$(`panel.links.sponsorCopy`)})]}),(0,G.jsx)(`code`,{className:`block select-all break-all font-mono text-[11px] leading-4 text-foreground-strong`,children:NM}),n?(0,G.jsx)(`p`,{className:`text-[11px] leading-4 text-foreground-strong`,children:$(`panel.links.sponsorCopyFailed`)}):null]})]}),(0,G.jsx)(`div`,{className:`px-6 pt-4 pb-6`,children:(0,G.jsx)(`p`,{className:`text-center text-sm text-foreground-muted`,children:$(`panel.links.sponsorNote`)})})]})})}function LM(){return(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-[18px] stroke-0`,fill:`currentColor`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12`})})}function RM({compact:e=!1}={}){return(0,G.jsxs)(`a`,{href:Ij,target:`_blank`,rel:`noreferrer noopener`,className:`${qu({variant:`secondary`,size:e?`sm`:`lg`})} pointer-events-auto rounded-full shadow-lg`,children:[(0,G.jsx)(LM,{}),$(`panel.links.star`)]})}function zM({compact:e=!1}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(RM,{compact:e}),(0,G.jsx)(FM,{compact:e}),(0,G.jsx)(_M,{compact:e})]})}function BM(e){let t=Number.isFinite(e)&&e>0?e:0;return t===0?`0 MB`:t<1048576?`${Math.max(1,Math.round(t/1024))} KB`:`${(t/1024/1024).toFixed(1)} MB`}function VM(e,t=Date.now()){if(!e)return``;let n=Math.floor((t-e)/36e5);return n<1?$(`panel.inbox.ageLessThanHour`):n<24?$(`panel.inbox.ageHours`,{hours:n}):$(`panel.inbox.ageDays`,{days:Math.floor(n/24)})}function HM({framed:e=!0}){let t=nM(),[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(!1),u=(0,g.useCallback)(async()=>{try{r(await Rk(`/api/relay/inbox/status`))}catch{r(null)}finally{a(!0)}},[]);(0,g.useEffect)(()=>{u()},[u]);let d=n?.deletableFiles??0,f=VM(n?.oldestAt??null),p=n?.stagingFiles??0;async function m(e){if(!c){l(!0);try{let t=await zk(`/api/relay/inbox/auto`,{enabled:e});r(e=>e&&{...e,autoClear:t.data.autoClear})}catch(e){t(`error`,$(`panel.inbox.autoFailed`,{message:Uk(e)}))}finally{l(!1)}}}async function h(){if(o)return;let e=d>0?$(`panel.inbox.confirmDetail`,{count:d,hours:n?.keepHours??24,bytes:BM(n?.deletableBytes??0)}):$(`panel.inbox.confirmNothing`,{hours:n?.keepHours??24});if(window.confirm(`${$(`panel.inbox.confirmTitle`)}\n\n${e}\n\n${$(`panel.inbox.confirmIrreversible`)}`)){s(!0);try{let e=await zk(`/api/relay/inbox/clear`),n=BM(e.freedBytes);t(e.failedFiles>0?`soft`:`ok`,e.deletedFiles>0?`${$(`panel.inbox.cleared`,{bytes:n,count:e.deletedFiles})}${e.failedFiles>0?$(`panel.inbox.clearedSomeFailed`,{count:e.failedFiles}):``}`:$(`panel.inbox.nothingToClear`)),await u()}catch(e){t(`error`,$(`panel.inbox.clearFailed`,{message:Uk(e)}))}finally{s(!1)}}}let _=(0,G.jsxs)(G.Fragment,{children:[i?null:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.inbox.reading`)]}),i&&n===null?(0,G.jsxs)(YE,{variant:`info`,className:`mt-2`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:$(`panel.inbox.unreadableTitle`)}),(0,G.jsx)($E,{children:$(`panel.inbox.unreadableBody`)})]}):null,n===null?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`mt-1`,children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`dt`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.inbox.used`)}),(0,G.jsx)(`dd`,{className:`min-w-0 text-right text-sm break-all`,children:$(`panel.inbox.usedValue`,{bytes:BM(n.bytes),count:n.files})})]}),(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`dt`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.inbox.deletable`)}),(0,G.jsx)(`dd`,{className:`min-w-0 text-right text-sm break-all`,children:d>0?$(`panel.inbox.deletableValue`,{bytes:BM(n.deletableBytes),count:d}):$(`panel.common.none`)})]}),(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-2`,children:[(0,G.jsx)(`dt`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.inbox.keep`)}),(0,G.jsx)(`dd`,{className:`min-w-0 text-right text-sm break-all`,children:f?$(`panel.inbox.keepValueOldest`,{hours:n.keepHours,age:f}):$(`panel.inbox.keepValue`,{hours:n.keepHours})})]})]}),p>0?(0,G.jsx)(`p`,{className:`mt-1 text-xs text-foreground-muted`,children:$(`panel.inbox.staging`,{bytes:BM(n.stagingBytes??0),count:n.stagingFiles??0})}):null,(0,G.jsxs)(`label`,{className:`mt-3 flex items-center justify-between gap-4 border-t border-border-muted pt-3`,children:[(0,G.jsx)(`span`,{className:`block text-sm text-foreground`,children:$(`panel.inbox.auto`)}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[c?(0,G.jsx)(VE,{}):null,(0,G.jsx)(QD,{size:`md`,checked:n.autoClear===!0,disabled:o||c,onCheckedChange:e=>void m(e),"aria-label":$(`panel.inbox.autoA11y`)})]})]}),(0,G.jsx)(`div`,{className:`mt-3 flex justify-center`,children:(0,G.jsx)(Q,{variant:d>0?`primary`:`outline`,size:`md`,disabled:o,onClick:()=>void h(),children:$(o?`panel.inbox.clearing`:`panel.inbox.clear`)})})]})]});return e?(0,G.jsxs)(xD,{frame:`solid`,children:[(0,G.jsx)(SD,{className:`px-4 py-3`,children:(0,G.jsx)(CD,{className:`flex items-center gap-2`,children:(0,G.jsx)(`span`,{children:$(`panel.inbox.title`)})})}),_]}):_}var UM=`https://github.com/WNLUO/dsh-mobile-server`;function WM(){return[$(`panel.notice.promptIntro`),``,`${$(`panel.notice.promptRepo`)}: ${UM}`,``,$(`panel.notice.promptAsk`),``,$(`panel.notice.promptDo`),``,$(`panel.notice.promptAfter`),``,$(`panel.notice.promptStyle`)].join(`
|
|
86
86
|
`)}function GM({title:e,summary:t,children:n}){return(0,G.jsxs)(`details`,{className:`group rounded-lg border border-border-muted bg-background-muted`,children:[(0,G.jsxs)(`summary`,{className:`flex cursor-pointer list-none flex-col gap-0.5 px-3 py-2.5 marker:content-none`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2 text-sm font-semibold text-foreground-strong`,children:[(0,G.jsx)(`svg`,{viewBox:`0 0 12 12`,className:`size-3 shrink-0 text-foreground-muted transition-transform group-open:rotate-90`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:`m4.5 2.5 3.5 3.5-3.5 3.5`})}),e]}),(0,G.jsx)(`span`,{className:`pl-5 text-xs leading-5 text-foreground-muted`,children:t})]}),(0,G.jsx)(`div`,{className:`flex flex-col gap-2.5 border-t border-border-muted px-3 py-3`,children:n})]})}function KM({lines:e}){return(0,G.jsx)(`pre`,{className:`overflow-x-auto rounded bg-background-subtle px-2.5 py-2 font-mono text-[11px] leading-5 break-words whitespace-pre-wrap text-foreground-strong`,children:e.join(`
|
|
87
|
-
`)})}function qM({open:e,onOpenChange:t,port:n}){let r=(0,g.useRef)(null),[i,a]=(0,g.useState)(!1);async function o(){try{await navigator.clipboard.writeText(WM()),a(!0),window.setTimeout(()=>a(!1),2e3)}catch{a(!1)}}return(0,G.jsx)(cD,{open:e,onOpenChange:e=>{e||a(!1),t(e)},children:(0,G.jsxs)(lD,{className:`w-[min(860px,92vw)] max-w-none`,closeLabel:$(`panel.common.close`),initialFocus:r,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.notice.setupGuideTitle`)})}),(0,G.jsx)(`div`,{ref:r,tabIndex:-1,className:`flex min-h-0 flex-col outline-none`,children:(0,G.jsxs)(pD,{className:`flex flex-col gap-3 overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:[(0,G.jsxs)(GM,{title:$(`panel.notice.guideRelayTitle`),summary:$(`panel.notice.guideRelaySummary`),children:[(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideRelayReady`)}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.guideRelayCopyHint`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(Q,{variant:`outline`,size:`sm`,onClick:()=>void o(),children:$(`panel.notice.guideRelayCopy`)}),i?(0,G.jsx)(`span`,{className:`text-xs text-success`,children:$(`panel.notice.guideRelayCopied`)}):null]}),(0,G.jsx)(`p`,{className:`rounded-md border border-border-muted bg-background px-2.5 py-2 text-xs leading-5 text-warning`,children:$(`panel.notice.guideRelayWarn`)})]}),(0,G.jsxs)(GM,{title:$(`panel.notice.guideTunnelTitle`),summary:$(`panel.notice.guideTunnelSummary`),children:[(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTunnelOS`)}),(0,G.jsx)(KM,{lines:[`# macOS`,`brew install cloudflared`,`# Linux`,`curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared`,`chmod +x cloudflared && sudo mv cloudflared /usr/local/bin/`,`# Windows (PowerShell)`,`winget install --id Cloudflare.cloudflared`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTunnelTry`)}),(0,G.jsx)(KM,{lines:[`cloudflared tunnel --url http://127.0.0.1:${n}`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTunnelFixed`)}),(0,G.jsx)(KM,{lines:[`cloudflared tunnel login`,`cloudflared tunnel create dsh`,`cloudflared tunnel route dns dsh dsh.example.com`,`cloudflared tunnel run --url http://127.0.0.1:${n} dsh`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.guideTunnelFill`)}),(0,G.jsx)(`p`,{className:`mt-1 border-t border-border-muted pt-3 text-sm font-semibold text-foreground-strong`,children:$(`panel.notice.guideTailscaleTitle`)}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTailscaleInstall`)}),(0,G.jsx)(KM,{lines:[`# macOS`,`brew install tailscale`,`# Linux`,`curl -fsSL https://tailscale.com/install.sh | sh`,`# Windows`,`winget install --id Tailscale.Tailscale`,`sudo tailscale up`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTailscaleServe`)}),(0,G.jsx)(KM,{lines:[`tailscale serve --bg http://127.0.0.1:${n}`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.guideTailscaleFill`)})]})]})})]})})}var JM=`0.4.9`;function YM({lanPort:e}){let[t,n]=(0,g.useState)(!1),[r,i]=(0,g.useState)(!1);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`ghost`,size:`sm`,className:`gap-1.5`,onClick:()=>n(!0),children:[(0,G.jsx)(`span`,{children:$(`panel.notice.title`)}),(0,G.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:`${$(`panel.notice.versionLabel`)} ≥ ${JM}`})]}),(0,G.jsx)(cD,{open:t,onOpenChange:n,children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.notice.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground-muted`,children:$(`panel.notice.versionLabel`)}),(0,G.jsx)(rD,{variant:`warning`,size:`sm`,children:`≥ ${JM}`})]}),(0,G.jsxs)(`p`,{className:`flex items-start gap-2 text-sm leading-5 text-foreground-muted`,children:[(0,G.jsx)(`span`,{className:`flex h-5 shrink-0 items-center`,children:(0,G.jsx)(TO,{tone:`warn`})}),(0,G.jsx)(`span`,{className:`min-w-0`,children:$(`panel.notice.effective`)})]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.body`,{version:JM})})]}),(0,G.jsxs)(`section`,{className:`flex flex-col gap-1.5 border-t border-border-muted pt-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-foreground-strong`,children:$(`panel.notice.selfHostTitle`)}),(0,G.jsx)(`button`,{type:`button`,className:`cursor-pointer text-sm text-foreground-intense underline underline-offset-2 hover:text-foreground-strong`,onClick:()=>{n(!1),i(!0)},children:$(`panel.notice.selfHostAction`)})]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.selfHostBody`)})]})]})]})}),(0,G.jsx)(qM,{open:r,onOpenChange:i,port:e})]})}function XM(e){return e.available?e.enabled?e.path===`direct`&&e.active?`panel.p2p.open`:e.error?`panel.p2p.error`:e.path===`failed`?`panel.p2p.blocked`:e.ready?e.path===`waiting`?`panel.p2p.waiting`:`panel.p2p.punching`:e.started?`panel.p2p.punching`:`panel.p2p.waiting`:`panel.p2p.disabled`:`panel.p2p.unavailable`}function ZM(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function QM({open:e,onOpenChange:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),o=(0,g.useCallback)(async()=>{try{let e=await Rk(`/api/relay/p2p`);r(e.status??null),a(``)}catch(e){a(Uk(e))}},[]);(0,g.useEffect)(()=>{if(!e)return;let t=()=>{l_()&&o()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,o]);let s=n;return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.p2p.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.p2p.hint`)}),i?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:i}):null,s===null?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.readingStatus`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.stateLabel`)}),(0,G.jsxs)(`span`,{className:`min-w-0 text-right text-sm break-all`,children:[$(XM(s)),s.error?(0,G.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:s.error}):null]})]}),(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.addressLabel`)}),(0,G.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:s.url||$(`panel.p2p.noAddress`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border-muted py-2`,children:[(0,G.jsxs)(`span`,{className:`text-sm text-foreground-muted`,children:[$(`panel.p2p.candidatesLabel`),` (`,s.candidates.length,`)`]}),s.candidates.length===0?(0,G.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.p2p.noCandidates`)}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-1`,children:s.candidates.map(e=>(0,G.jsx)(`li`,{className:`font-mono text-xs break-all text-foreground-strong`,children:e},e))})]}),(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.keyLabel`)}),(0,G.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:s.publicKey?ZM(s.publicKey):$(`panel.p2p.noKey`)})]})]})]}),(0,G.jsx)(mD,{className:`flex justify-end gap-2`,children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var $M=function(e){let t=Pd(),[n,r]=g.useState(t),[i,a]=g.useState(),[o,s]=g.useState([]),c=n===void 0?t:n,l=y(()=>new Map),{messageIds:u}=VD(),d=Y((e,t)=>{let n=l.current;t===void 0?n.delete(e):n.set(e,t),r(e=>{if(n.size===0)return e;let t;for(let r of n.values()){if(r===e)return e;t===void 0&&(t=r)}return t})}),f=Y(()=>{l.current.size===0&&r(t)}),p=g.useCallback(e=>{let t=e[`aria-describedby`]?e[`aria-describedby`].split(` `):[];return t.push(...u,...o),{...e,"aria-describedby":Array.from(new Set(t)).join(` `)||void 0}},[u,o]),m=g.useMemo(()=>({controlId:c,registerControlId:d,resetControlId:f,labelId:i,setLabelId:a,messageIds:o,setMessageIds:s,getDescriptionProps:p}),[c,d,f,i,a,o,s,p]);return(0,G.jsx)(BD.Provider,{value:m,children:e.children})};function eN(e){let{change:t,commit:n,invalid:r,markedDirtyRef:i,name:a,setRegisteredFieldName:o,registeredFieldIdRef:s,setValidityData:c,validityData:l}=e,{formRef:u}=zD(),d=g.useRef(null),f=g.useRef(null),p=g.useRef(!1),m=Y(()=>{let e=f.current;if(e)return e.getValue?e.getValue():e.value});function h(e){return e.value===void 0?m():e.value}let _=Y(()=>{let e=f.current;if(i.current=!0,!e){n(l.value);return}n(h(e))});function v(){let e=f.current;e&&e.id&&u.current.fields.set(e.id,{getValue:m,name:a??e.name,controlRef:e.controlRef,validityData:bk(l,r),validate:_})}function y(e=f.current?.id){e&&u.current.fields.delete(e)}function x(e){if(p.current)return;p.current=!0;let t=h(e);c(e=>e.initialValue===t?e:{...e,initialValue:t})}return b(()=>{let e=f.current;e&&e.id&&(o(a?void 0:e.name),u.current.fields.set(e.id,{getValue:m,name:a??e.name,controlRef:e.controlRef,validityData:bk(l,r),validate:_}))},[u,m,r,a,o,_,l]),b(()=>{let e=u.current.fields;return()=>{let t=f.current?.id;t&&e.delete(t)}},[u]),[_,Y((e,n)=>{if(!n){d.current===e&&(d.current=null,t(void 0,!0),y(),f.current=null,o(void 0),s.current=void 0);return}let r=f.current?.id,i=d.current;i&&i!==e&&t(void 0,!0),d.current=e,f.current=n,a||o(n.name),s.current=n.id,r&&r!==n.id&&y(r),x(n),v()})]}var tN=g.forwardRef(function(e,t){let{errors:n,validationMode:r,submitCountRef:i}=zD(),{render:a,className:o,validate:s,validationDebounceTime:c=0,validationMode:l=r,name:u,disabled:d=!1,invalid:f,dirty:p,touched:m,actionsRef:h,style:_,...v}=e,y=Ok(!0)?.disabled,x=Y(s||(()=>null)),S=y||d,[C,w]=g.useState(!1),[T,E]=g.useState(!1),[D,O]=g.useState(!1),[k,A]=g.useState(!1),j=p??T,M=m??C,N=g.useRef(j),P=g.useRef(void 0),[F,I]=g.useState(),L=u??F;b(()=>{p!==void 0&&(N.current=p)},[p]);let R=Y(e=>{p===void 0&&(e&&(N.current=!0),E(e))}),z=Y(e=>{m===void 0&&w(e)}),B=Y(()=>l===`onChange`||l===`onSubmit`&&i.current>0),V=L&&Object.hasOwn(n,L)?n[L]:null,H=!!(Array.isArray(V)?V.length:V),U=f===!0||H,[W,ee]=g.useState({state:OD,error:``,errors:[],value:null,initialValue:null}),K=!U&&(S?null:W.state.valid),te=g.useMemo(()=>({disabled:S,touched:M,dirty:j,valid:K,filled:D,focused:k}),[S,M,j,K,D,k]),q=Ek({setValidityData:ee,validate:x,validityData:W,validationDebounceTime:c,invalid:U,markedDirtyRef:N,state:te,shouldValidateOnChange:B,validationMode:l,registeredFieldIdRef:P}),[J,ne]=eN({change:q.change,commit:q.commit,invalid:U,markedDirtyRef:N,name:u,setRegisteredFieldName:I,registeredFieldIdRef:P,setValidityData:ee,validityData:W});g.useImperativeHandle(h,()=>({validate:J}),[J]);let re=g.useMemo(()=>({invalid:U,name:L,validityData:W,setValidityData:ee,disabled:S,setTouched:z,setDirty:R,setFilled:O,setFocused:A,validationMode:l,shouldValidateOnChange:B,state:te,registerFieldControl:ne,validation:q}),[U,L,W,S,z,R,O,A,l,B,te,ne,q]),ie=Br(`div`,e,{ref:t,state:te,props:v,stateAttributesMapping:AD});return(0,G.jsx)(FD.Provider,{value:re,children:ie})}),nN=g.forwardRef(function(e,t){return(0,G.jsx)($M,{children:(0,G.jsx)(tN,{...e,ref:t})})}),rN=g.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,nativeLabel:o=!0,...s}=e,c=ID(!1),l=nk(),{labelId:u}=VD(),d={...c.state,disabled:c.disabled||l.disabled},f=g.useRef(null),p=bA({id:u??a,native:o});return Br(`label`,e,{ref:[t,f],state:d,props:[p,s],stateAttributesMapping:AD})}),iN=g.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:_,setDirty:v,validityData:y,setFocused:x,setFilled:S,validationMode:C,validation:w}=ID(),{clearErrors:T,elementRef:E,submitCountRef:D}=zD(),O=h||s,k=m??a,A={...p,disabled:O},{labelId:j}=VD(),M=GD({id:i}),[N]=bf({controlled:o,default:l,name:`FieldControl`,state:`value`}),P=o!==void 0,F=P?N:void 0,I=F==null?void 0:String(F),L=Y(()=>w.inputRef.current?.value);LD(w.inputRef,M,I,L,!O,a),b(()=>{let e=I??w.inputRef.current?.value;e!==void 0&&S(e!==``)},[I,w.inputRef,S]),Jf(I,()=>{I!==void 0&&(T(k),v(I!==(y.initialValue??``)),w.change(I))});let R=g.useRef(null),z=We();return b(()=>{u&&R.current===ct(Ie(R.current))&&x(!0)},[u,x]),Br(`input`,e,{ref:[t,R],state:A,props:[{id:M,disabled:O,name:k,ref:w.inputRef,"aria-labelledby":j,autoFocus:u,...P?{value:F}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=Aa(pa,e.nativeEvent);c?.(t,n),!P&&(v(t!==(y.initialValue??``)),S(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(T(k),w.change(t)))},onFocus(){x(!0)},onBlur(e){if(_(!0),x(!1),C===`onBlur`){let t=e.currentTarget.value;w.commit(t),P&&queueMicrotask(()=>{let e=w.inputRef.current?.value;e!==void 0&&e!==t&&e!==(y.initialValue??``)&&w.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){_(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===E.current&&!e.defaultPrevented){let t=e.currentTarget,n=D.current;z.start(0,()=>{D.current===n&&w.commit(t.value)})}else w.commit(t)}}},f,e=>w.getValidationProps(O,e)],stateAttributesMapping:AD})});function aN({className:e,...t}){return(0,G.jsx)(nN,{"data-slot":`field`,className:Z(e),...t})}function oN({className:e,...t}){return(0,G.jsx)(rN,{"data-slot":`field-label`,className:Z(`text-foreground-intense mb-1.5 flex w-fit items-center text-sm font-medium select-none`,`data-disabled:opacity-disabled`,e),...t})}var sN=g.forwardRef(function(e,t){return(0,G.jsx)(iN,{ref:t,...e})});function cN(e,t){(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function lN({className:e,variant:t=`outline`,inputSize:n=`md`,clearable:r,startSlot:i,endSlot:a,onClear:o,inputProps:s,ref:c,...l}){let u=g.useRef(null),d=!!(r||i||a),f=l[`aria-invalid`],p=f===!0||f===`true`,m=Vu(c,u),h=()=>{u.current&&l.value===void 0&&cN(u.current,``),u.current?.focus(),o?.()};return d?(0,G.jsxs)(`div`,{"data-slot":`input-wrapper`,className:Z(lj({variant:t,size:n,state:`within`}),e),...p?{"data-invalid":``}:{},children:[i&&(0,G.jsx)(`div`,{"data-slot":`input-start`,className:`-ms-1 flex shrink-0 items-center`,children:i}),(0,G.jsx)(sN,{"data-slot":`input`,ref:m,placeholder:l.placeholder??` `,...s,className:Z(`peer text-foreground placeholder:text-foreground-subtle h-full min-w-0 flex-1 bg-transparent outline-none disabled:cursor-not-allowed`,s?.className),...l}),r&&(0,G.jsx)(`button`,{"data-slot":`input-clear`,type:`button`,onClick:h,className:`text-foreground-subtle hover:text-foreground pointer-events-none shrink-0 cursor-pointer opacity-0 transition-[opacity,color] duration-200 peer-not-placeholder-shown:pointer-events-auto peer-not-placeholder-shown:opacity-100`,tabIndex:-1,"aria-label":`Clear input`,children:(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`2 2 16 16`,fill:`currentColor`,className:`size-[1em]`,children:(0,G.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}),a&&(0,G.jsx)(`div`,{"data-slot":`input-end`,className:`-me-1 flex shrink-0 items-center`,children:a})]}):(0,G.jsx)(sN,{"data-slot":`input`,ref:m,...s,className:Z(lj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle`,s?.className,e),...l,...p?{"data-invalid":``}:{}})}var uN=1024,dN=65535;function fN({open:e,onOpenChange:t,port:n,busy:r,onSave:i}){let[a,o]=(0,g.useState)(String(n));(0,g.useEffect)(()=>{e&&o(String(n))},[e]);let s=a.trim(),c=Number(s),l=s!==``&&Number.isInteger(c)&&c>=uN&&c<=dN&&r===``;return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`max-w-sm`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.pairing.portTitle`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`relay-lan-port`,children:$(`panel.pairing.port`)}),(0,G.jsx)(lN,{inputProps:{id:`relay-lan-port`,inputMode:`numeric`},value:a,onChange:e=>o(e.target.value)})]}),(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.pairing.portHint`)})]}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:r!==``,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,G.jsx)(Q,{variant:`primary`,disabled:!l,onClick:()=>i(c),children:$(`panel.common.save`)})]})]})})}function pN({visible:e,onOpenConfig:t}){let[n,r]=(0,g.useState)(!1);return!e||n?null:(0,G.jsx)(cD,{open:!0,onOpenChange:e=>{e||r(!0)},children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.publicRelayNotice.title`)})}),(0,G.jsx)(pD,{className:`whitespace-pre-line text-sm leading-6 text-foreground-muted`,children:$(`panel.publicRelayNotice.body`)}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,onClick:()=>{r(!0),t()},children:$(`panel.pairing.openConfig`)}),(0,G.jsx)(Q,{variant:`primary`,onClick:()=>r(!0),children:$(`panel.publicRelayNotice.action`)})]})]})})}var mN={sm:`py-2`,md:`py-2.5`,lg:`py-3`},hN={sm:`min-h-16`,md:`min-h-20`,lg:`min-h-24`},gN={sm:`0.5rem`,md:`0.625rem`,lg:`0.75rem`};function _N(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function vN({className:e,variant:t=`outline`,inputSize:n=`md`,clearable:r,startSlot:i,endSlot:a,onClear:o,ref:s,rows:c=3,...l}){let u=g.useRef(null),d=Vu(s,u),f=!!(r||i||a),p=l[`aria-invalid`],m=p===!0||p===`true`,h=()=>{u.current&&l.value===void 0&&_N(u.current,``),u.current?.focus(),o?.()};return f?(0,G.jsxs)(`div`,{"data-slot":`textarea-wrapper`,"data-invalid":m?``:void 0,style:{"--textarea-h":`calc(${c} * 1lh + 2 * ${gN[n]} + 2px)`},className:Z(lj({variant:t,size:n,state:`within`}),`h-(--textarea-h) resize-y items-start overflow-hidden`,hN[n],mN[n],`has-[textarea:disabled]:border-border-strong! has-[textarea:disabled]:bg-background-subtle! has-[textarea:disabled]:opacity-disabled has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:border-dashed`,e),children:[i&&(0,G.jsx)(`div`,{"data-slot":`textarea-start`,className:`-ms-1 inline-flex h-lh shrink-0 items-center`,children:i}),(0,G.jsx)(iN,{"data-slot":`textarea`,ref:d,render:(0,G.jsx)(`textarea`,{rows:c}),placeholder:l.placeholder??` `,className:`peer text-foreground placeholder:text-foreground-subtle min-w-0 flex-1 resize-none self-stretch bg-transparent outline-none disabled:cursor-not-allowed`,...l}),r&&(0,G.jsx)(`button`,{"data-slot":`textarea-clear`,type:`button`,onClick:h,className:`text-foreground-subtle hover:text-foreground pointer-events-none inline-flex h-lh shrink-0 cursor-pointer items-center opacity-0 transition-[opacity,color] duration-200 peer-not-placeholder-shown:pointer-events-auto peer-not-placeholder-shown:opacity-100 motion-reduce:transition-none`,tabIndex:-1,"aria-label":`Clear input`,children:(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`2 2 16 16`,fill:`currentColor`,className:`size-[1em]`,children:(0,G.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}),a&&(0,G.jsx)(`div`,{"data-slot":`textarea-end`,className:`-me-1 inline-flex h-lh shrink-0 items-center`,children:a})]}):(0,G.jsx)(iN,{"data-slot":`textarea`,ref:d,render:(0,G.jsx)(`textarea`,{rows:c}),className:Z(lj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle h-auto resize-y`,mN[n],hN[n],e),...l,...m?{"data-invalid":``}:{}})}function yN(e){return String(e||``).replace(/\s+#.*$/,``).trim().replace(/^["']/,``).replace(/["']$/,``).trim()}function bN(e){let t={};for(let n of String(e||``).split(/\r?\n/)){let e=n.trim();if(!e||e.startsWith(`#`)||e.startsWith(`;`)||e.startsWith(`[`))continue;let r=/^([A-Za-z0-9_.]+)\s*[=:]\s*(.+)$/.exec(e);if(!r)continue;let i=r[1].toLowerCase();i in t||(t[i]=yN(r[2]))}return t}function xN(e){let t=String(e||``).trim();if(!t)return[];let n=[...t.matchAll(/["']([^"']+)["']/g)].map(e=>e[1].trim()).filter(Boolean);return n.length?n:t.replace(/^\[|\]$/g,``).split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}function SN(e){let t=(...t)=>{for(let n of t)if(e[n])return e[n];return``};return{type:(t(`type`)||``).toLowerCase(),remotePort:t(`remoteport`,`remote_port`),localPort:t(`localport`,`local_port`),domains:xN(t(`customdomains`,`custom_domains`))}}function CN(e){let t=e.split(/\[\[\s*proxies\s*\]\]/i),n=bN(t[0]);return{serverAddr:n.serveraddr||n.server_addr||``,proxies:t.slice(1).map(e=>SN(bN(e)))}}function wN(e){let t=[{name:`__global__`,pairs:{}}];for(let n of e.split(/\r?\n/)){let e=n.trim();if(!e||e.startsWith(`#`)||e.startsWith(`;`))continue;let r=/^\[([^\]]+)\]$/.exec(e);if(r){t.push({name:r[1].trim().toLowerCase(),pairs:{}});continue}let i=/^([A-Za-z0-9_.]+)\s*[=:]\s*(.+)$/.exec(e);if(!i)continue;let a=t[t.length-1],o=i[1].toLowerCase();o in a.pairs||(a.pairs[o]=yN(i[2]))}let n=t.find(e=>e.name===`common`)||t[0];return{serverAddr:n.pairs.server_addr||n.pairs.serveraddr||``,proxies:t.filter(e=>e.name!==`__global__`&&e.name!==`common`).map(e=>SN(e.pairs))}}function TN(e){let t;try{t=JSON.parse(e)}catch{return null}let n=t&&typeof t==`object`?t:{};return{serverAddr:typeof n.serverAddr==`string`?n.serverAddr:typeof n.server_addr==`string`?n.server_addr:``,proxies:(Array.isArray(n.proxies)?n.proxies:[]).map(e=>{let t=e&&typeof e==`object`?e:{},n=e=>typeof e==`string`||typeof e==`number`?String(e):``,r=t.customDomains??t.custom_domains;return{type:n(t.type).toLowerCase(),remotePort:n(t.remotePort??t.remote_port),localPort:n(t.localPort??t.local_port),domains:Array.isArray(r)?r.map(e=>String(e)):xN(n(r))}})}}function EN(e){if(!/^\d+$/.test(String(e||``)))return null;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function DN(e,t){for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=EN(n.remotePort);if(e&&t!==null)return{ok:!0,field:`tcp`,value:`${e}:${t}`,kind:`tcp`}}for(let e of t)if((e.type===`https`||e.type===`http`)&&e.domains.length)return{ok:!0,field:`direct`,value:`https://${e.domains[0]}`,kind:`https`};for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=EN(n.localPort);if(e&&t!==null)return{ok:!0,field:`tcp`,value:`${e}:${t}`,kind:`tcp`,note:`inferred-local-port`,port:t}}return{ok:!1,reason:`no-address`}}function ON(e){let t=String(e||``).trim();if(!t)return{ok:!1,reason:`empty`};let n=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).replace(/\/+$/,``).trim(),r=/^(\[[^\]]+\]|[^\s/:?#]+):(\d+)$/.exec(n);if(r){let e=Number(r[2]);return Number.isInteger(e)&&e>=1&&e<=65535?{ok:!0,field:`tcp`,value:`${r[1]}:${e}`,kind:`tcp`}:{ok:!1,reason:`bad-tcp`}}let i;return i=t.startsWith(`{`)?TN(t)||{serverAddr:``,proxies:[]}:/\[\[\s*proxies\s*\]\]/i.test(t)?CN(t):/^\s*\[common\]\s*$/im.test(t)||/(?:^|[\r\n])\s*server_addr\s*=/i.test(t)?wN(t):CN(t),DN(i.serverAddr,i.proxies)}function kN(e){return/serverAddr|server_addr|\[\[\s*proxies\s*\]\]|\[common\]/i.test(e)}function AN({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(``),l=(0,g.useMemo)(()=>ON(r),[r]);(0,g.useEffect)(()=>{e&&c(``)},[e]);async function u(){if(!l.ok||a)return;c(``);let e=``;if(kN(r)){o(!0);try{let t=await Vk(r);if(t?.status&&t.status.error){c(t.status.error),o(!1);return}e=t?.status?.remoteAddress||``}catch(e){c(Uk(e)),o(!1);return}o(!1)}let i=l.field===`tcp`&&e?e:l.value;n({field:l.field,value:i}),t(!1)}return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`w-[min(560px,92vw)]`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.frp.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.frp.hint`)}),(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`frp-import`,children:$(`panel.frp.label`)}),(0,G.jsx)(vN,{id:`frp-import`,rows:6,value:r,onChange:e=>i(e.target.value),autoComplete:`off`,spellCheck:!1})]}),r.trim()?l.ok?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{role:`status`,className:`text-xs text-foreground-muted`,children:$(l.field===`tcp`?`panel.frp.detectedTcp`:`panel.frp.detectedDirect`,{address:l.value})}),l.note===`inferred-local-port`?(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.frp.inferredPort`,{port:l.port??``})}):null]}):(0,G.jsx)(`p`,{className:`text-xs text-error`,children:$(l.reason===`empty`?`panel.frp.empty`:`panel.frp.badFormat`)}):null,s?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:s}):null]}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:a,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,G.jsx)(Q,{variant:`primary`,disabled:!l.ok||a,onClick:u,children:$(`panel.frp.fill`)})]})]})})}var jN=.7,MN=2;function NN(e){let t=Number.isFinite(e)&&e>0?e:0;return t>=600?1:t<=100?t/100*jN:jN+(t-100)/500*.30000000000000004}function PN(e,t,n){let r=e.map(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:null);if(!r.some(e=>e!==null))return``;let i=r.length>1?t/(r.length-1):0,a=Math.max(1,n-4),o=[],s=!1;return r.forEach((e,n)=>{if(e===null){s=!1;return}let c=r.length>1?n*i:t/2,l=MN+NN(e)*a;o.push(`${s?`L`:`M`}${c.toFixed(1)} ${l.toFixed(1)}`),s=!0}),o.join(` `)}function FN(e){return typeof e!=`number`||!Number.isFinite(e)?`none`:e<=100?`fast`:e<=600?`ok`:`slow`}var IN=5e3,LN=132,RN=28;function zN(e){return e===`fast`?`text-success`:e===`ok`?`text-warning`:e===`slow`?`text-destructive`:`text-foreground-muted`}function BN(e){return e===`fast`?`#16a34a`:e===`ok`?`#d97706`:e===`slow`?`#dc2626`:`#9ca3af`}function VN(e){return typeof e!=`number`||!Number.isFinite(e)?`—`:`${Math.round(e)} ms`}function HN({open:e,onOpenChange:t,activeUrl:n}){let[r,i]=(0,g.useState)({}),[a,o]=(0,g.useState)(``),s=(0,g.useRef)(!1),c=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!e){s.current=!1,c.current!==null&&(clearInterval(c.current),c.current=null);return}s.current=!0,o(``);let t=Rj.map(e=>e.url);i(Object.fromEntries(t.map(e=>[e,[null]])));async function n(){if(s.current)try{let e=await zk(`/api/relay/probe-relays`,{urls:t});if(!s.current)return;let n=new Map((e.results||[]).map(e=>[e.url,e.ms]));i(e=>{let r={};for(let i of t)r[i]=[...e[i]||[],n.get(i)??null].slice(-14);return r}),o(``)}catch(e){s.current&&o(Uk(e))}}return n(),c.current=setInterval(()=>{n()},IN),()=>{s.current=!1,c.current!==null&&(clearInterval(c.current),c.current=null)}},[e]),(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.relay.panelTitle`)})}),(0,G.jsxs)(pD,{className:`flex max-h-[60vh] flex-col gap-1 overflow-y-auto`,children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs text-foreground-muted`,children:$(`panel.relay.panelHint`)}),Rj.map(e=>{let t=r[e.url]||[null],i=[...t].reverse().find(e=>typeof e==`number`)??null,a=FN(i),o=PN(t,LN,RN),s=e.url===n;return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border-muted px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono text-sm`,children:e.url}),s?(0,G.jsx)(`span`,{className:`text-xs text-primary`,children:$(`panel.relay.selected`)}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[o?(0,G.jsx)(`svg`,{width:LN,height:RN,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:o,stroke:BN(a),strokeWidth:1.5,fill:`none`})}):null,(0,G.jsx)(`span`,{className:`w-16 text-right text-sm tabular-nums ${zN(a)}`,children:VN(i)})]})]},e.url)}),a?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:a}):null]}),(0,G.jsx)(mD,{children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}function UN({open:e,onOpenChange:t,status:n,addressBook:r,lanUrls:i,busy:a,onSave:o,onSavePreferred:s}){let[c,l]=(0,g.useState)(n.relayUrl),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(``),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),k=(0,g.useRef)(!1),A=(0,g.useRef)(!1),j=(0,g.useRef)(!1),M=(0,g.useRef)(!1),N=r?r.lan.length>0?r.lan:r.public:[];(0,g.useEffect)(()=>{e&&l(n.relayUrl)},[e]),(0,g.useEffect)(()=>{e||(S(!1),w(!1))},[e]),(0,g.useEffect)(()=>{if(!e){k.current=!1,A.current=!1,j.current=!1,M.current=!1,b(``);return}if(k.current||d(r?.manual??``),A.current||p(r?.manualIpv6??``),j.current||h(r?.manualTcp??``),!M.current){let e=r?r.lan.length>0?r.lan:r.public:[];v((r?.preferred||``).trim()||(e[0]?.address??``))}},[e,r]);let P=a===``,F=Rj.find(e=>e.url===c.trim())??null,I=n.publicRelayBlocked===!0,L=e=>e.trim().replace(/\/+$/,``);function R(){if(!P)return;let e={};F?e.relayUrls=Rj.map(e=>e.url):c.trim()!==n.relayUrl&&(e.relayUrl=c.trim());let t=L(u);t!==L(r?.manual??``)&&(e.manualLanUrl=t);let i=L(f);i!==L(r?.manualIpv6??``)&&(e.manualIpv6Url=i);let a=L(m);a!==L(r?.manualTcp??``)&&(e.manualTcpUrl=a);let s=_.trim();if(M.current&&s!==(r?.preferred??``).trim()){if(s&&!N.some(e=>e.address===s)){b($(`panel.address.lanUnknown`));return}e.preferredLanAddress=s}o(e)}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`w-[min(1100px,92vw)]`,initialFocus:O,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.pairing.openConfig`)})}),(0,G.jsx)(`div`,{ref:O,tabIndex:-1,className:`outline-none`,children:(0,G.jsxs)(pD,{className:`grid max-h-[calc(100vh-13rem)] grid-cols-2 items-start gap-x-8 gap-y-4 overflow-y-auto`,children:[(0,G.jsxs)(aN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(oN,{children:$(`panel.relay.publicKind`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>E(!0),children:$(`panel.relay.viewPanel`)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:!P||I,onClick:()=>l(F?``:Rj[0].url),children:$(F?`panel.relay.disablePublic`:`panel.relay.enablePublic`)})]})]}),I?(0,G.jsx)(lN,{inputProps:{className:`text-foreground-muted`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:$(`panel.relay.publicDisabled`)}):(0,G.jsx)(`div`,{className:`flex flex-col gap-1`,children:Rj.map(e=>(0,G.jsx)(lN,{inputProps:{className:`font-mono`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:e.url},e.url))})]}),(0,G.jsxs)(aN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(oN,{htmlFor:`relay-url`,children:$(`panel.relay.selfKind`)}),(0,G.jsx)(`a`,{href:Fj,target:`_blank`,rel:`noreferrer noopener`,className:qu({variant:`ghost`,size:`sm`}),children:$(`panel.relay.selfRepo`)})]}),(0,G.jsx)(lN,{inputProps:{id:`relay-url`,className:`font-mono`},value:F?``:c,placeholder:`https://example.com`,onChange:e=>l(e.target.value)})]}),(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`relay-manual-lan`,children:$(`panel.address.direct`)}),(0,G.jsx)(lN,{inputProps:{id:`relay-manual-lan`,className:`font-mono`},value:u,placeholder:$(`panel.address.directPlaceholder`),onChange:e=>{k.current=!0,d(e.target.value)}})]}),(0,G.jsxs)(aN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(oN,{htmlFor:`relay-manual-tcp`,children:$(`panel.address.tcp`)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>w(!0),children:$(`panel.address.frpImport`)})]}),(0,G.jsx)(lN,{inputProps:{id:`relay-manual-tcp`,className:`font-mono`},value:m,placeholder:$(`panel.address.tcpPlaceholder`),onChange:e=>{j.current=!0,h(e.target.value)}})]}),(0,G.jsxs)(aN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(oN,{htmlFor:`relay-preferred-lan`,children:$(`panel.address.lan`)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>S(!0),children:$(`panel.onboarding.chooseAddress`)})]}),(0,G.jsx)(lN,{inputProps:{id:`relay-preferred-lan`,className:`font-mono`,list:`relay-lan-candidates`},value:_,placeholder:$(`panel.address.lanPlaceholder`),onChange:e=>{M.current=!0,b(``),v(e.target.value)}}),(0,G.jsx)(`datalist`,{id:`relay-lan-candidates`,children:N.map(e=>(0,G.jsx)(`option`,{value:e.address,children:e.url},e.address))}),y?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:y}):null]}),(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`relay-manual-ipv6`,children:$(`panel.address.ipv6Url`)}),(0,G.jsx)(lN,{inputProps:{id:`relay-manual-ipv6`,className:`font-mono`},value:f,placeholder:$(`panel.address.ipv6Placeholder`),onChange:e=>{A.current=!0,p(e.target.value)}})]})]})}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:a===`config`,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,G.jsx)(Q,{variant:`primary`,disabled:!P,onClick:R,children:$(`panel.relay.saveConfig`)})]})]})}),(0,G.jsx)(cD,{open:x,onOpenChange:S,children:(0,G.jsxs)(lD,{className:`w-[min(560px,92vw)]`,initialFocus:D,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.address.lan`)})}),(0,G.jsx)(`div`,{ref:D,tabIndex:-1,className:`outline-none`,children:(0,G.jsx)(pD,{className:`max-h-[60vh] overflow-y-auto px-1 py-2`,children:(0,G.jsx)(Nj,{align:`start`,book:r,port:n.lan.port,value:r?.preferred??``,busy:a!==``,fallbackUrls:i,onChange:e=>{s(e),S(!1)}})})}),(0,G.jsx)(mD,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>S(!1),children:$(`panel.common.close`)})})]})}),(0,G.jsx)(AN,{open:C,onOpenChange:w,onImport:e=>{e.field===`tcp`?(j.current=!0,h(e.value)):(k.current=!0,d(e.value))}}),(0,G.jsx)(HN,{open:T,onOpenChange:E,activeUrl:F?.url??``})]})}var WN=18e5,GN=3e5,KN=15e3,qN=null,JN=0,YN=0,XN=null;function ZN(e){return typeof e!=`number`||!Number.isFinite(e)?!1:e===0||Date.now()-e>WN}function QN(e){if(!e&&XN)return XN;let t=(async()=>{let t=await Rk(e?`/api/relay/selfcheck?force=1`:`/api/relay/selfcheck`);return qN=t,JN=Date.now(),t})();return e||(XN=t,t.finally(()=>{XN===t&&(XN=null)})),t}function $N(e,t=``){let[n,r]=(0,g.useState)(qN),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(!1),u=(0,g.useRef)(!0);(0,g.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let d=(0,g.useCallback)(async e=>{if(!e&&qN&&Date.now()-JN<KN){r(qN);return}a(!0);try{let t=await QN(e);if(!u.current)return;r(t),s(``),l(!1)}catch(e){if(!u.current)return;l(e instanceof Ik&&e.status===404),s(Uk(e))}finally{u.current&&a(!1)}},[]);(0,g.useEffect)(()=>{e&&(Date.now()-YN<GN||qN&&Date.now()-JN<KN||(YN=Date.now(),d(!1)))},[e,d]);let f=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(t){if(f.current===null){f.current=t;return}f.current!==t&&(f.current=t,d(!0))}},[t,d]),{data:n,checking:i,error:o,missing:c,ensure:(0,g.useCallback)(()=>void d(!1),[d]),refresh:(0,g.useCallback)(()=>void d(!0),[d])}}function eP(e){return e===`ok`?`ok`:e===`unknown`?`warn`:`error`}var tP={ok:{long:`panel.selfcheck.verdict.ok`,short:`panel.selfcheck.short.ok`},"not-listening":{long:`panel.selfcheck.verdict.notListening`,short:`panel.selfcheck.short.notListening`},"firewall-blocked":{long:`panel.selfcheck.verdict.firewallBlocked`,short:`panel.selfcheck.short.firewallBlocked`},unknown:{long:`panel.selfcheck.verdict.unknown`,short:`panel.selfcheck.short.unknown`},network:{long:`panel.selfcheck.verdict.network`,short:`panel.selfcheck.short.network`}};function nP(e){return $(tP[e]?.long??`panel.selfcheck.verdict.unknown`)}function rP(e){if(!e)return{tone:`off`,text:$(`panel.selfcheck.notChecked`)};let t=e.firewall,n=oP(t.appPath);return!t.supported||t.enabled===null?{tone:`warn`,text:$(`panel.selfcheck.unknown`)}:t.enabled===!1?{tone:`ok`,text:$(`panel.selfcheck.firewallOff`),...n?{detail:n}:{}}:t.allowsApp===!1?{tone:`error`,text:$(`panel.selfcheck.blocked`),...n?{detail:n}:{}}:t.allowsApp===!0?{tone:`ok`,text:$(`panel.selfcheck.allowed`),...n?{detail:n}:{}}:{tone:`warn`,text:$(`panel.selfcheck.unknown`)}}function iP(e,t){let n=typeof e?.mobile?.lastMobileAt==`number`?e.mobile.lastMobileAt:t;return typeof n!=`number`||!Number.isFinite(n)?{tone:`off`,text:$(`panel.selfcheck.notChecked`)}:n===0?{tone:`warn`,text:$(`panel.selfcheck.mobileNever`)}:(typeof e?.mobile?.idle==`boolean`?e.mobile.idle:ZN(n))?{tone:`warn`,text:$(`panel.selfcheck.mobileIdle`),detail:gg(n)}:{tone:`ok`,text:$(`panel.selfcheck.mobileRecent`),detail:gg(n)}}function aP(e){let t={listening:`panel.lan.listening`,off:`panel.status.off`,error:`panel.lan.error`};return t[e]?$(t[e]):e}function oP(e){let t=String(e??``).trim();if(!t)return``;let n=t.split(/[\\/]/);return n[n.length-1]??``}function sP({open:e,onOpenChange:t,state:n,lastMobileAt:r}){(0,g.useEffect)(()=>{e&&n.ensure()},[e,n.ensure]);let i=n.data,a=rP(i),o=iP(i,r),s=i?eP(i.verdict):`warn`;return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`max-w-xl`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.selfcheck.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[n.error?(0,G.jsxs)(YE,{variant:n.missing?`warning`:`error`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:n.missing?$(`panel.selfcheck.unavailable`):$(`panel.selfcheck.failed`)}),n.missing?null:(0,G.jsx)($E,{children:n.error})]}):null,i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:pg(`text-sm`,s===`ok`?`text-foreground`:hg[s]),children:nP(i.verdict)}),(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.connection.lan`),children:(0,G.jsx)(OO,{tone:i.listening.state===`listening`?`ok`:i.listening.state===`error`?`error`:`off`,text:aP(i.listening.state),detail:$(`panel.selfcheck.port`,{port:i.listening.port})})}),(0,G.jsx)(EO,{label:$(`panel.connection.tunnel`),children:(0,G.jsx)(OO,{tone:_g(i.tunnel.state),text:vg(i.tunnel.state)})}),(0,G.jsx)(EO,{label:$(`panel.selfcheck.firewall`),children:(0,G.jsx)(OO,{tone:a.tone,text:a.text,detail:a.detail})}),(0,G.jsx)(EO,{label:$(`panel.selfcheck.mobile`),children:(0,G.jsx)(OO,{tone:o.tone,text:o.text,detail:o.detail})})]}),(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.selfcheck.checkedAt`,{time:gg(i.checkedAt)})})]}):n.checking?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.selfcheck.checking`)]}):null]}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)}),(0,G.jsx)(Q,{variant:`primary`,disabled:n.checking,onClick:n.refresh,children:n.checking?$(`panel.selfcheck.checking`):$(`panel.selfcheck.recheck`)})]})]})})}function cP(e){return e.available?e.enabled?e.error?`panel.tailcat.error`:e.ready?`panel.tailcat.ready`:`panel.tailcat.starting`:`panel.tailcat.disabled`:`panel.tailcat.unavailable`}function lP(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function uP({open:e,onOpenChange:t,onChanged:n}){let r=nM(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{a(await Rk(`/api/relay/tailcat`)),s(``)}catch(e){s(Uk(e))}},[]);(0,g.useEffect)(()=>{if(!e)return;let t=()=>{l_()&&u()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,u]);let d=(0,g.useCallback)(async(e,t,i)=>{l(e);try{a(await t()),r(`soft`,i),n?.()}catch(e){r(`error`,Uk(e))}finally{l(``)}},[r,n]),f=e=>void d(`toggle`,()=>zk(`/api/relay/tailcat/enabled`,{enabled:e}),$(e?`panel.tailcat.enabledToast`:`panel.tailcat.disabledToast`)),p=e=>{window.confirm($(`panel.tailcat.revokeConfirm`))&&d(`revoke`,()=>zk(`/api/relay/tailcat/revoke`,{client:e}),$(`panel.tailcat.revokedToast`))},m=i?.status??null,h=i?.allowedClients??[];return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.tailcat.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.tailcat.hint`)}),o?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:o}):null,i===null?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.readingStatus`)]}):m===null?(0,G.jsx)(`p`,{className:`text-sm text-foreground-muted`,children:$(`panel.tailcat.unavailable`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.tailcat.title`)}),(0,G.jsxs)(`span`,{className:`min-w-0 text-right text-sm break-all`,children:[$(cP(m)),m.error?(0,G.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:m.error}):null]})]}),(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.tailcat.addressLabel`)}),(0,G.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:m.address||$(`panel.tailcat.noAddress`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground-muted`,children:$(`panel.tailcat.enableLabel`)}),(0,G.jsx)(QD,{size:`md`,checked:m.enabled,disabled:!m.available||c!==``,onCheckedChange:e=>f(e),"aria-label":$(`panel.tailcat.enableLabel`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsxs)(`span`,{className:`text-sm text-foreground-muted`,children:[$(`panel.tailcat.pairedLabel`),` (`,m.paired,`)`]}),h.length===0?(0,G.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.tailcat.noClients`)}):(0,G.jsx)(`ul`,{className:`flex flex-col`,children:h.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border-muted py-1.5 last:border-b-0`,children:[(0,G.jsx)(`span`,{className:`min-w-0 font-mono text-xs break-all text-foreground-strong`,children:lP(e)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:c!==``,onClick:()=>p(e),children:$(`panel.tailcat.revoke`)})]},e))})]})]})]}),(0,G.jsx)(mD,{className:`flex justify-end gap-2`,children:(0,G.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var dP=`/dsh-market/api/v1`,fP=`dsh-mobile-plugin`,pP=class extends Error{constructor(e,t,n){super(n),q(this,`status`,void 0),q(this,`code`,void 0),this.name=`MarketError`,this.status=e,this.code=t}},mP=e=>e&&typeof e==`object`?e:{},hP=e=>typeof e==`string`&&e!==``?e:null;async function gP(e,t){let n;try{n=await fetch(`${dP}${e}`,{credentials:`same-origin`,...t})}catch(e){throw new pP(0,`market_unreachable`,$(`panel.net.marketUnreachable`,{message:String(e?.message||e)}))}let r=await n.json().catch(()=>null);if(!n.ok){let e=mP(r),t=mP(e.failure),i=hP(t.code)??(typeof e.error==`string`?e.error:`HTTP ${n.status}`),a=hP(t.message)??hP(e.error)??$(`panel.net.marketHttp`,{status:n.status});throw new pP(n.status,i,a)}return r}async function _P(){try{return{available:!0,restartSupported:mP(mP(await gP(`/capabilities`)).restart).supported===!0}}catch{return{available:!1,restartSupported:!1}}}async function vP(e=fP,t=!1){let n=mP(await gP(`/updates${`?name=${encodeURIComponent(e)}${t?`&force=1`:``}`}`)),r=mP(n.package??n);return{installedVersion:hP(r.installedVersion),latestVersion:hP(r.latestVersion),updateAvailable:r.updateAvailable===!0,source:hP(r.source)}}var yP={status:`/api/relay/update/status`,check:`/api/relay/update/check`,apply:`/api/relay/update/apply`,auto:`/api/relay/update/auto`,otaStatus:`/api/relay/update/ota/status`,otaCheck:`/api/relay/update/ota/check`,otaApply:`/api/relay/update/ota/apply`},bP=e=>e&&typeof e==`object`?e:{},xP=e=>typeof e==`string`&&e!==``?e:null,SP=e=>typeof e==`boolean`?e:null,CP=e=>typeof e==`number`&&Number.isFinite(e)?e:null;async function wP(e,t){let n=await fetch(e,{credentials:`same-origin`,headers:{accept:`application/json`,...t?.body?{"content-type":`application/json`}:{}},...t}),r=null;try{r=await n.json()}catch{r=null}let i=bP(r),a=bP(i.error);if(!n.ok){let e=xP(a.code)??`http_${n.status}`;throw new Ik(xP(a.message)??$(`panel.net.hostHttp`,{status:n.status}),e,n.status)}return i}function TP(e){return e instanceof Ik?e.status===404:e instanceof SyntaxError}function EP(e){return e instanceof Ik&&e.code===`update_unavailable`}function DP(e){let t=bP(e);return Object.keys(t).length===0?null:{installedVersion:xP(t.installedVersion),latestVersion:xP(t.latestVersion),updateAvailable:t.updateAvailable===!0,source:xP(t.source),checkedAt:xP(t.checkedAt)}}function OP(e){let t=bP(e),n=bP(t.failure),r=xP(n.code);return{installed:SP(t.installed),skipped:SP(t.skipped),state:xP(t.state),beforeVersion:xP(t.beforeVersion),installedVersion:xP(t.installedVersion),swapped:SP(t.swapped),restartRequired:SP(t.restartRequired),refreshRequired:SP(t.refreshRequired),failure:r?{code:r,message:xP(n.message)??r}:null}}function kP(e){let t=bP(e);return{available:t.available===!0,version:xP(t.version),installedVersion:xP(t.installedVersion),source:xP(t.source),previousVersion:xP(t.previousVersion),activatedAt:xP(t.activatedAt),lastError:xP(t.lastError),inFlight:CP(t.inFlight)??0,swapping:t.swapping===!0,autoUpdate:t.autoUpdate===!0,autoIntervalMs:CP(t.autoIntervalMs)??6e5,marketBase:xP(t.marketBase),marketLastCheckedAt:xP(t.marketLastCheckedAt),marketLastError:xP(t.marketLastError),marketResult:DP(t.marketResult),lastApply:t.lastApply?OP(t.lastApply):null,appliedAt:xP(t.appliedAt),runningShellHash:xP(t.runningShellHash),installedShellHash:xP(t.installedShellHash),shellChanged:t.shellChanged===!0}}async function AP(){return kP((await wP(yP.status)).data)}async function jP(){let e=bP((await wP(yP.check,{method:`POST`,body:JSON.stringify({})})).data);return{update:DP(e.update),status:e.status?kP(e.status):null}}async function MP(e=!1){let t=bP((await wP(yP.apply,{method:`POST`,body:JSON.stringify({force:e})})).data),n=bP(t.status);return{...OP(t),status:Object.keys(n).length>0?kP(n):null}}async function NP(e){let t=bP((await wP(yP.auto,{method:`POST`,body:JSON.stringify({enabled:e})})).data);return{enabled:t.enabled===!0,status:t.status?kP(t.status):null}}var PP=new Set([`OPERATION_BUSY`,`RELEASE_TOO_FRESH`,`VERSION_UNCHANGED`,`PLUGIN_NOT_INSTALLED`,`AGENTS_RUNNING`]);function FP(e){let t=e.installedVersion??e.beforeVersion;return e.failure?{text:$(`panel.update.applyFailed`,{message:e.failure.message}),ok:!1}:e.installed===!1?e.skipped?{text:t?$(`panel.update.applyUpToDate`,{version:t}):$(`panel.update.applyUpToDatePlain`),ok:!0}:{text:t?$(`panel.update.applyDiskUnchanged`,{version:t}):$(`panel.update.applyFailedRetry`),ok:!1}:{text:t?$(`panel.update.applySwitched`,{version:t}):$(`panel.update.applySwitchedPlain`),ok:!0}}function IP({version:e,busy:t,onRestartSidecar:n}){let[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(``),h=nM(),[_,v]=(0,g.useState)(!1),y=(0,g.useCallback)(e=>{e&&i(t=>({...e,available:e.available===!0||t?.available===!0}))},[]),b=r!==null&&r.available&&!s,x=t!==``||p!==``,S=(0,g.useCallback)(async()=>{try{let e=await AP();i(e),c(e.available!==!0)}catch(e){i(null),c(EP(e))}finally{o(!0)}},[]);(0,g.useEffect)(()=>{S()},[S]),(0,g.useEffect)(()=>{if(!a)return;let e=!0;return jP().then(t=>{e&&(t.update&&f(t.update),t.status&&y(t.status))}).catch(()=>{}),()=>{e=!1}},[a]);let C=r?.swapping===!0;(0,g.useEffect)(()=>{if(!C)return;let e=window.setInterval(()=>void S(),1500);return()=>window.clearInterval(e)},[C,S]),(0,g.useEffect)(()=>{if(b||!a)return;let e=!0;return _P().then(t=>{e&&u(t)}),()=>{e=!1}},[b,a]);let w=(0,g.useCallback)(e=>{if(e instanceof pP&&PP.has(e.code)){h(`soft`,`${e.message}(${e.code})`);return}h(`error`,Uk(e))},[]),T=(0,g.useCallback)(async()=>{m(`check`);try{let e=await jP();e.status&&y(e.status),e.update&&f(e.update)}catch(e){TP(e)||EP(e)?await S():h(`error`,Uk(e))}finally{m(``)}},[S]),E=(0,g.useCallback)(async e=>{m(`apply`);try{let t=await MP(e);t.status&&y(t.status);let n=FP(t),r=t.failure!==null&&PP.has(t.failure.code);n.ok||r?h(`soft`,n.text):h(`error`,n.text)}catch(e){TP(e)||EP(e)?await S():h(`error`,Uk(e))}finally{m(``)}},[S]),D=(0,g.useCallback)(async()=>{m(`check`);try{let e=await jP();e.status&&y(e.status),f(e.update)}catch(e){if(!TP(e))f(null),h(`error`,Uk(e));else try{f(await vP(void 0,!0))}catch(e){f(null),w(e)}}finally{m(``)}},[w]),O=(0,g.useCallback)(async e=>{v(!0);try{let t=await NP(e);t.status&&y(t.status);let n=Math.round((t.status?.autoIntervalMs??r?.autoIntervalMs??6e5)/6e4);h(`soft`,t.enabled?$(`panel.update.autoOn`,{minutes:n}):$(`panel.update.autoOff`))}catch(e){h(`error`,$(`panel.update.autoToggleFailed`,{message:Uk(e)})),await S()}finally{v(!1)}},[r?.autoIntervalMs,S]),k=d?.latestVersion??r?.marketResult?.latestVersion??null,A=d?.source??r?.marketResult?.source??null,j=A===`linked`||A===`file`||A===`workspace`,M=d?.updateAvailable??r?.marketResult?.updateAvailable??!1,N=r?.lastApply?FP(r.lastApply):null,P=e||`—`,F=r?.version??null,I=b&&!!F&&!!e&&F!==e,L=r?.installedVersion??null,R=b&&!!L&&!!e&&L!==e;return(0,G.jsxs)(xD,{frame:`solid`,children:[(0,G.jsx)(SD,{className:`px-4 py-3`,children:(0,G.jsxs)(CD,{className:`flex items-center gap-2 text-base lg:text-lg`,children:[(0,G.jsx)(`span`,{children:$(`panel.update.title`)}),(0,G.jsx)(rD,{variant:`soft`,size:`sm`,children:e||$(`panel.update.unknownVersion`)})]})}),a?null:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.update.reading`)]}),s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.update.runningVersion`),mono:!0,children:P}),(0,G.jsx)(EO,{label:$(`panel.update.latestOnline`),mono:!0,children:k??$(`panel.update.notChecked`)})]}),(0,G.jsxs)(`p`,{className:`mt-3 text-xs text-foreground-muted`,children:[M?$(`panel.update.hasNew`):``,$(`panel.update.nothingToInstall`)]})]}):null,a&&!b&&!s&&l!==null&&!l.available?(0,G.jsxs)(YE,{variant:`info`,className:`mt-3`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:$(`panel.update.noMarketTitle`)}),(0,G.jsx)($E,{children:$(`panel.update.noMarketBody`)})]}):null,b&&r?(0,G.jsxs)(G.Fragment,{children:[j?null:(0,G.jsxs)(`label`,{className:`mt-1 flex items-start justify-between gap-4 border-b border-border-muted py-3`,children:[(0,G.jsxs)(`span`,{className:`min-w-0`,children:[(0,G.jsx)(`span`,{className:`block text-sm text-foreground`,children:$(`panel.update.autoUpdate`)}),(0,G.jsx)(`span`,{className:`mt-1 block text-xs text-foreground-muted`,children:$(`panel.update.autoDefaultHint`)})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[_?(0,G.jsx)(VE,{}):null,(0,G.jsx)(QD,{size:`md`,checked:r.autoUpdate,disabled:x||_,onCheckedChange:e=>void O(e),"aria-label":$(`panel.update.autoUpdate`)})]})]}),(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.update.runningVersion`),mono:!0,children:P}),L?(0,G.jsx)(EO,{label:$(`panel.update.diskVersion`),mono:!0,children:L}):null,(0,G.jsx)(EO,{label:$(`panel.update.latestOnline`),mono:!0,children:k??$(`panel.update.notChecked`)})]}),I?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.versionDrift`,{version:e??``,shell:F??``})}):null,R?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.diskDrift`,{disk:L??``,running:e??``})}):null,r.lastError?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.lastErrorLine`,{message:r.lastError})}):null,(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:x,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:x,onClick:()=>void T(),children:$(p===`check`?`panel.update.checking`:`panel.update.check`)}),j?null:(0,G.jsx)(Q,{variant:`primary`,size:`md`,disabled:x,onClick:()=>void E(!1),children:$(p===`apply`?`panel.update.updating`:`panel.update.updateNow`)})]}),!j&&(M||N!==null&&!N.ok)?(0,G.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:x,onClick:()=>void E(!0),children:$(`panel.update.forceHint`)})}):null]}):null,a&&!b&&!s&&l?.available?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.update.runningVersion`),mono:!0,children:P}),(0,G.jsx)(EO,{label:$(`panel.update.latestOnline`),mono:!0,children:k??$(`panel.update.notChecked`)}),(0,G.jsx)(EO,{label:$(`panel.update.checkResult`),children:$(M?`panel.update.resultHasNew`:`panel.update.resultUpToDate`)})]}),(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:x,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:x,onClick:()=>void D(),children:$(p===`check`?`panel.update.checking`:`panel.update.check`)}),r!==null&&!j?(0,G.jsx)(Q,{variant:`primary`,size:`md`,disabled:x,onClick:()=>void E(!1),children:$(p===`apply`?`panel.update.updating`:`panel.update.updateNow`)}):null]})]}):null]})}function LP({webAccess:e,busy:t,onToggle:n}){let r=e?.enabled===!0,i=typeof e?.expiresAt==`number`?e.expiresAt:0;return(0,G.jsxs)(xD,{frame:`solid`,children:[(0,G.jsx)(SD,{className:`px-4 py-3`,children:(0,G.jsx)(CD,{className:`text-base lg:text-lg`,children:$(`panel.webAccess.title`)})}),(0,G.jsx)(DO,{children:(0,G.jsx)(EO,{label:$(`panel.webAccess.state`),tone:r?`ok`:`off`,children:r?$(`panel.webAccess.expires`,{time:gg(i)}):$(`panel.webAccess.closed`)})}),(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-foreground-muted`,children:$(`panel.webAccess.hint`)}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:r?(0,G.jsx)(Q,{variant:`outline`,size:`sm`,disabled:t===`webAccess`,onClick:()=>n(!1),children:$(`panel.webAccess.close`)}):(0,G.jsx)(Q,{variant:`outline`,size:`sm`,disabled:t===`webAccess`,onClick:()=>n(!0),children:$(`panel.webAccess.open`)})})]})}function RP(e,t=``){let n=document.documentElement;n.setAttribute(`data-dshm-panel-state`,e),t?n.setAttribute(`data-dshm-panel-error`,t):n.removeAttribute(`data-dshm-panel-error`),window.parent!==window&&window.parent.postMessage({type:`dsh-mobile-plugin:panel-state`,state:e,message:t},`*`)}var zP=1500,BP=600;function VP(){return(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M4 7h16`}),(0,G.jsx)(`path`,{d:`M9 7V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V7`}),(0,G.jsx)(`path`,{d:`M6 7l1 12.5A2 2 0 0 0 9 21h6a2 2 0 0 0 2-1.5L18 7`}),(0,G.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})}function HP(){let[e,t]=(0,g.useState)(null),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(!1),T=nM();(0,g.useEffect)(()=>{e?RP(`ready`):n&&RP(`error`,n)},[e,n]);let E=(0,g.useRef)(null),[D,O]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=E.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>O(e.getBoundingClientRect().height);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]);let k=$N(ZN(e?.lastMobileAt),e?`${+!!e.enabled}|${+!!e.lan.enabled}|${e.lan.state}|${e.tunnel.state}|${+((e.lastMobileAt??0)>0)}`:``),A=(0,g.useCallback)(async()=>{try{t(await Rk(`/api/relay/status`)),r(``)}catch(e){r(Uk(e))}},[]),j=(0,g.useCallback)(async()=>{l(``);try{s(await Rk(`/api/relay/pairing`)),l(``)}catch(e){s(null),l(Uk(e))}},[]),M=(0,g.useCallback)(async()=>{try{d(await Rk(`/api/relay/addresses`))}catch{d(null)}},[]);(0,g.useEffect)(()=>{let e=()=>{l_()&&A()};e();let t=0,n=window.setTimeout(()=>{t=window.setInterval(e,3e3)},zP);return document.addEventListener(`visibilitychange`,e),()=>{window.clearTimeout(n),t&&window.clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[A]),(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=window.setTimeout(()=>void j(),BP);return()=>window.clearTimeout(t)},[e?.enabled,j]),(0,g.useEffect)(()=>{e?.enabled&&o&&e.pairingCode&&o.pairingCode!==e.pairingCode&&j()},[e?.pairingCode,e?.enabled,o,j]);let N=(0,g.useCallback)(async()=>{try{s(await Rk(`/api/relay/pairing`)),l(``)}catch{}},[]);(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=Fk(o);if(t===null)return;let n=window.setTimeout(()=>void N(),t);return()=>window.clearTimeout(n)},[o,e?.enabled,N]),(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=window.setTimeout(()=>void M(),BP);return()=>window.clearTimeout(t)},[e?.enabled,o,M]),(0,g.useEffect)(()=>{f&&e?.enabled&&(j(),M())},[f,e?.enabled,j,M]);let P=(0,g.useCallback)(async(e,t)=>{a(e);try{await t()}catch(e){T(`error`,Uk(e))}finally{a(``)}},[T]),F=e=>P(`toggle`,async()=>{t(await zk(`/api/relay/toggle`,{enabled:e})),e?await j():(s(null),l(``)),T(`soft`,$(e?`panel.shell.remoteEnabled`:`panel.shell.remoteDisabled`))}),I=()=>P(`restart`,async()=>{let e=await zk(`/api/relay/restart-sidecar`);t(e.status),T(`soft`,$(`panel.shell.sidecarRestarted`))}),L=()=>{window.confirm($(`panel.shell.revokeConfirm`))&&P(`revoke`,async()=>{let e=await zk(`/api/relay/revoke-all`);await A(),await j(),T(`soft`,`${$(`panel.shell.revoked`,{count:e.revoked})}${e.revokedRelay?$(`panel.shell.revokedRelay`,{count:e.revokedRelay}):``}`)})},R=e=>P(`webAccess`,async()=>{let n=await zk(`/api/relay/web-access`,{enabled:e});t(e=>e&&{...e,webAccess:n.webAccess}),T(`soft`,$(e?`panel.webAccess.opened`:`panel.webAccess.closedNotice`))}),z=e=>P(`config`,async()=>{t(await zk(`/api/relay/config`,e)),p(!1),await j(),T(`soft`,$(`panel.shell.configSaved`))}),B=e=>P(`policy`,async()=>{t(await zk(`/api/relay/config`,{pairingPolicy:e})),T(`soft`,$(e===`code`?`panel.shell.deviceAllowed`:`panel.shell.deviceDenied`))}),V=e=>P(`tier`,async()=>{t(await zk(`/api/relay/config`,{pairingTier:e})),T(`soft`,$(`panel.shell.configSaved`))}),H=e=>P(`autoReview`,async()=>{t(await zk(`/api/relay/config`,{approvalAutoReview:e})),T(`soft`,$(e?`panel.shell.autoReviewOn`:`panel.shell.autoReviewOff`))}),U=e=>P(`lan`,async()=>{t(await zk(`/api/relay/config`,{lanPort:e})),h(!1),await j(),T(`soft`,$(`panel.shell.lanSaved`))}),W=e=>P(`lan`,async()=>{t(await zk(`/api/relay/config`,{preferredLanAddress:e})),await Promise.all([j(),M()]),T(`soft`,e?$(`panel.shell.preferredAddress`,{address:e}):$(`panel.shell.preferredAuto`))}),ee=e?e.tunnel.state===`connected`||e.lan.state===`listening`?`ok`:e.enabled?`warn`:`off`:null;return e?(0,G.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-col gap-3 p-4 sm:p-5`,children:[(0,G.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[ee?(0,G.jsx)(TO,{tone:ee}):null,(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name||e.instanceId}),(0,G.jsx)(rD,{variant:`soft`,size:`sm`,children:e.appVersion||$(`panel.shell.unknownVersion`)}),(0,G.jsx)(zM,{compact:!0})]}),i?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.busy`)]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,G.jsx)(YM,{lanPort:e.lan.port}),(0,G.jsx)(Dg,{}),(0,G.jsx)(a_,{}),(0,G.jsx)(Q,{variant:`ghost`,size:`icon-md`,"aria-label":$(`panel.inbox.title`),title:$(`panel.inbox.title`),onClick:()=>w(!0),children:(0,G.jsx)(VP,{})}),(0,G.jsx)(BO,{})]})]}),n?(0,G.jsxs)(YE,{variant:`error`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:$(`panel.shell.statusFailed`)}),(0,G.jsx)($E,{children:n})]}):null,(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 items-stretch gap-3 md:grid-cols-5`,children:[(0,G.jsx)(`div`,{className:`md:col-span-3`,children:(0,G.jsx)(Zj,{fill:!0,status:e,pairing:o,addressBook:u,busy:i,error:c,restartError:e.sidecar.restartError,onOpenConfig:()=>p(!0),onChangePolicy:e=>void B(e),onChangeTier:e=>void V(e),onChangeAutoReview:e=>void H(e),onOpenSelfCheck:()=>v(!0),onRetryPairing:()=>void j(),onSavePreferred:e=>void W(e),onEditPort:()=>h(!0)})}),(0,G.jsx)(`div`,{className:`md:col-span-2`,children:(0,G.jsx)(IP,{version:e.appVersion||``,busy:i,onRestartSidecar:()=>void I()})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsx)(`div`,{ref:E,children:(0,G.jsx)(NO,{status:e,addressBook:u,busy:i,onToggle:F,onManageTailcat:()=>b(!0),onManageP2P:()=>S(!0)})}),(0,G.jsx)(`div`,{className:`min-h-0`,style:D>0?{height:`${D}px`}:void 0,children:(0,G.jsx)(pM,{onRevokeAll:L,busy:i,fill:!0})})]}),(0,G.jsx)(`div`,{className:`columns-1 gap-3 md:columns-2 xl:columns-3 [&>*]:mb-3 [&>*]:break-inside-avoid`,children:e.webAccess?.enabled&&e.panelScope!==`loopback`?(0,G.jsx)(LP,{webAccess:e.webAccess,busy:i,onToggle:e=>void R(e)}):null})]}),(0,G.jsx)(UN,{open:f,onOpenChange:p,status:e,addressBook:u,lanUrls:o?.lanUrls??[],busy:i,onSave:e=>void z(e),onSavePreferred:e=>void W(e)}),(0,G.jsx)(sP,{open:_,onOpenChange:v,state:k,lastMobileAt:e.lastMobileAt}),(0,G.jsx)(uP,{open:y,onOpenChange:b,onChanged:()=>void A()}),(0,G.jsx)(QM,{open:x,onOpenChange:S}),(0,G.jsx)(fN,{open:m,onOpenChange:h,port:o?.lanPort??e.lan.requestedPort??e.lan.port,busy:i,onSave:e=>void U(e)}),(0,G.jsx)(cD,{open:C,onOpenChange:w,children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.inbox.title`)})}),(0,G.jsx)(pD,{children:(0,G.jsx)(HM,{framed:!1})})]})}),(0,G.jsx)(pN,{visible:zj(e.relayUrl),onOpenConfig:()=>p(!0)})]}):(0,G.jsx)(`main`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-3 p-5`,children:n?(0,G.jsx)(`p`,{className:`text-sm text-error`,children:n}):(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.readingStatus`)]})})}var UP=[{textKey:`panel.onboarding.linuxStep1`},{text:`systemctl status firewalld`,cmd:!0},{text:`sudo ufw status`,cmd:!0},{textKey:`panel.onboarding.linuxStep2`},{text:`sudo firewall-cmd --permanent --add-port={port}/tcp
|
|
87
|
+
`)})}function qM({open:e,onOpenChange:t,port:n}){let r=(0,g.useRef)(null),[i,a]=(0,g.useState)(!1);async function o(){try{await navigator.clipboard.writeText(WM()),a(!0),window.setTimeout(()=>a(!1),2e3)}catch{a(!1)}}return(0,G.jsx)(cD,{open:e,onOpenChange:e=>{e||a(!1),t(e)},children:(0,G.jsxs)(lD,{className:`w-[min(860px,92vw)] max-w-none`,closeLabel:$(`panel.common.close`),initialFocus:r,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.notice.setupGuideTitle`)})}),(0,G.jsx)(`div`,{ref:r,tabIndex:-1,className:`flex min-h-0 flex-col outline-none`,children:(0,G.jsxs)(pD,{className:`flex flex-col gap-3 overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:[(0,G.jsxs)(GM,{title:$(`panel.notice.guideRelayTitle`),summary:$(`panel.notice.guideRelaySummary`),children:[(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideRelayReady`)}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.guideRelayCopyHint`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,G.jsx)(Q,{variant:`outline`,size:`sm`,onClick:()=>void o(),children:$(`panel.notice.guideRelayCopy`)}),i?(0,G.jsx)(`span`,{className:`text-xs text-success`,children:$(`panel.notice.guideRelayCopied`)}):null]}),(0,G.jsx)(`p`,{className:`rounded-md border border-border-muted bg-background px-2.5 py-2 text-xs leading-5 text-warning`,children:$(`panel.notice.guideRelayWarn`)})]}),(0,G.jsxs)(GM,{title:$(`panel.notice.guideTunnelTitle`),summary:$(`panel.notice.guideTunnelSummary`),children:[(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTunnelOS`)}),(0,G.jsx)(KM,{lines:[`# macOS`,`brew install cloudflared`,`# Linux`,`curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o cloudflared`,`chmod +x cloudflared && sudo mv cloudflared /usr/local/bin/`,`# Windows (PowerShell)`,`winget install --id Cloudflare.cloudflared`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTunnelTry`)}),(0,G.jsx)(KM,{lines:[`cloudflared tunnel --url http://127.0.0.1:${n}`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTunnelFixed`)}),(0,G.jsx)(KM,{lines:[`cloudflared tunnel login`,`cloudflared tunnel create dsh`,`cloudflared tunnel route dns dsh dsh.example.com`,`cloudflared tunnel run --url http://127.0.0.1:${n} dsh`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.guideTunnelFill`)}),(0,G.jsx)(`p`,{className:`mt-1 border-t border-border-muted pt-3 text-sm font-semibold text-foreground-strong`,children:$(`panel.notice.guideTailscaleTitle`)}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTailscaleInstall`)}),(0,G.jsx)(KM,{lines:[`# macOS`,`brew install tailscale`,`# Linux`,`curl -fsSL https://tailscale.com/install.sh | sh`,`# Windows`,`winget install --id Tailscale.Tailscale`,`sudo tailscale up`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground`,children:$(`panel.notice.guideTailscaleServe`)}),(0,G.jsx)(KM,{lines:[`tailscale serve --bg http://127.0.0.1:${n}`]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.guideTailscaleFill`)})]})]})})]})})}var JM=`0.4.9`;function YM({lanPort:e}){let[t,n]=(0,g.useState)(!1),[r,i]=(0,g.useState)(!1);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(Q,{variant:`ghost`,size:`sm`,className:`gap-1.5`,onClick:()=>n(!0),children:[(0,G.jsx)(`span`,{children:$(`panel.notice.title`)}),(0,G.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:`${$(`panel.notice.versionLabel`)} ≥ ${JM}`})]}),(0,G.jsx)(cD,{open:t,onOpenChange:n,children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.notice.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(`section`,{className:`flex flex-col gap-1.5`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground-muted`,children:$(`panel.notice.versionLabel`)}),(0,G.jsx)(rD,{variant:`warning`,size:`sm`,children:`≥ ${JM}`})]}),(0,G.jsxs)(`p`,{className:`flex items-start gap-2 text-sm leading-5 text-foreground-muted`,children:[(0,G.jsx)(`span`,{className:`flex h-5 shrink-0 items-center`,children:(0,G.jsx)(TO,{tone:`warn`})}),(0,G.jsx)(`span`,{className:`min-w-0`,children:$(`panel.notice.effective`)})]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.body`,{version:JM})})]}),(0,G.jsxs)(`section`,{className:`flex flex-col gap-1.5 border-t border-border-muted pt-3`,children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(`h3`,{className:`text-sm font-medium text-foreground-strong`,children:$(`panel.notice.selfHostTitle`)}),(0,G.jsx)(`button`,{type:`button`,className:`cursor-pointer text-sm text-foreground-intense underline underline-offset-2 hover:text-foreground-strong`,onClick:()=>{n(!1),i(!0)},children:$(`panel.notice.selfHostAction`)})]}),(0,G.jsx)(`p`,{className:`text-sm leading-6 text-foreground-muted`,children:$(`panel.notice.selfHostBody`)})]})]})]})}),(0,G.jsx)(qM,{open:r,onOpenChange:i,port:e})]})}function XM(e){return e.available?e.enabled?e.path===`direct`&&e.active?`panel.p2p.open`:e.error?`panel.p2p.error`:e.path===`failed`?`panel.p2p.blocked`:e.ready?e.path===`waiting`?`panel.p2p.waiting`:`panel.p2p.punching`:e.started?`panel.p2p.punching`:`panel.p2p.waiting`:`panel.p2p.disabled`:`panel.p2p.unavailable`}function ZM(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function QM({open:e,onOpenChange:t}){let[n,r]=(0,g.useState)(null),[i,a]=(0,g.useState)(``),o=(0,g.useCallback)(async()=>{try{let e=await Rk(`/api/relay/p2p`);r(e.status??null),a(``)}catch(e){a(Uk(e))}},[]);(0,g.useEffect)(()=>{if(!e)return;let t=()=>{l_()&&o()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,o]);let s=n;return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.p2p.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.p2p.hint`)}),i?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:i}):null,s===null?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.readingStatus`)]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.stateLabel`)}),(0,G.jsxs)(`span`,{className:`min-w-0 text-right text-sm break-all`,children:[$(XM(s)),s.error?(0,G.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:s.error}):null]})]}),(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.addressLabel`)}),(0,G.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:s.url||$(`panel.p2p.noAddress`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1 border-b border-border-muted py-2`,children:[(0,G.jsxs)(`span`,{className:`text-sm text-foreground-muted`,children:[$(`panel.p2p.candidatesLabel`),` (`,s.candidates.length,`)`]}),s.candidates.length===0?(0,G.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.p2p.noCandidates`)}):(0,G.jsx)(`ul`,{className:`flex flex-col gap-1`,children:s.candidates.map(e=>(0,G.jsx)(`li`,{className:`font-mono text-xs break-all text-foreground-strong`,children:e},e))})]}),(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.p2p.keyLabel`)}),(0,G.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:s.publicKey?ZM(s.publicKey):$(`panel.p2p.noKey`)})]})]})]}),(0,G.jsx)(mD,{className:`flex justify-end gap-2`,children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var $M=function(e){let t=Pd(),[n,r]=g.useState(t),[i,a]=g.useState(),[o,s]=g.useState([]),c=n===void 0?t:n,l=y(()=>new Map),{messageIds:u}=VD(),d=Y((e,t)=>{let n=l.current;t===void 0?n.delete(e):n.set(e,t),r(e=>{if(n.size===0)return e;let t;for(let r of n.values()){if(r===e)return e;t===void 0&&(t=r)}return t})}),f=Y(()=>{l.current.size===0&&r(t)}),p=g.useCallback(e=>{let t=e[`aria-describedby`]?e[`aria-describedby`].split(` `):[];return t.push(...u,...o),{...e,"aria-describedby":Array.from(new Set(t)).join(` `)||void 0}},[u,o]),m=g.useMemo(()=>({controlId:c,registerControlId:d,resetControlId:f,labelId:i,setLabelId:a,messageIds:o,setMessageIds:s,getDescriptionProps:p}),[c,d,f,i,a,o,s,p]);return(0,G.jsx)(BD.Provider,{value:m,children:e.children})};function eN(e){let{change:t,commit:n,invalid:r,markedDirtyRef:i,name:a,setRegisteredFieldName:o,registeredFieldIdRef:s,setValidityData:c,validityData:l}=e,{formRef:u}=zD(),d=g.useRef(null),f=g.useRef(null),p=g.useRef(!1),m=Y(()=>{let e=f.current;if(e)return e.getValue?e.getValue():e.value});function h(e){return e.value===void 0?m():e.value}let _=Y(()=>{let e=f.current;if(i.current=!0,!e){n(l.value);return}n(h(e))});function v(){let e=f.current;e&&e.id&&u.current.fields.set(e.id,{getValue:m,name:a??e.name,controlRef:e.controlRef,validityData:bk(l,r),validate:_})}function y(e=f.current?.id){e&&u.current.fields.delete(e)}function x(e){if(p.current)return;p.current=!0;let t=h(e);c(e=>e.initialValue===t?e:{...e,initialValue:t})}return b(()=>{let e=f.current;e&&e.id&&(o(a?void 0:e.name),u.current.fields.set(e.id,{getValue:m,name:a??e.name,controlRef:e.controlRef,validityData:bk(l,r),validate:_}))},[u,m,r,a,o,_,l]),b(()=>{let e=u.current.fields;return()=>{let t=f.current?.id;t&&e.delete(t)}},[u]),[_,Y((e,n)=>{if(!n){d.current===e&&(d.current=null,t(void 0,!0),y(),f.current=null,o(void 0),s.current=void 0);return}let r=f.current?.id,i=d.current;i&&i!==e&&t(void 0,!0),d.current=e,f.current=n,a||o(n.name),s.current=n.id,r&&r!==n.id&&y(r),x(n),v()})]}var tN=g.forwardRef(function(e,t){let{errors:n,validationMode:r,submitCountRef:i}=zD(),{render:a,className:o,validate:s,validationDebounceTime:c=0,validationMode:l=r,name:u,disabled:d=!1,invalid:f,dirty:p,touched:m,actionsRef:h,style:_,...v}=e,y=Ok(!0)?.disabled,x=Y(s||(()=>null)),S=y||d,[C,w]=g.useState(!1),[T,E]=g.useState(!1),[D,O]=g.useState(!1),[k,A]=g.useState(!1),j=p??T,M=m??C,N=g.useRef(j),P=g.useRef(void 0),[F,I]=g.useState(),L=u??F;b(()=>{p!==void 0&&(N.current=p)},[p]);let R=Y(e=>{p===void 0&&(e&&(N.current=!0),E(e))}),z=Y(e=>{m===void 0&&w(e)}),B=Y(()=>l===`onChange`||l===`onSubmit`&&i.current>0),V=L&&Object.hasOwn(n,L)?n[L]:null,H=!!(Array.isArray(V)?V.length:V),U=f===!0||H,[W,ee]=g.useState({state:OD,error:``,errors:[],value:null,initialValue:null}),K=!U&&(S?null:W.state.valid),te=g.useMemo(()=>({disabled:S,touched:M,dirty:j,valid:K,filled:D,focused:k}),[S,M,j,K,D,k]),q=Ek({setValidityData:ee,validate:x,validityData:W,validationDebounceTime:c,invalid:U,markedDirtyRef:N,state:te,shouldValidateOnChange:B,validationMode:l,registeredFieldIdRef:P}),[J,ne]=eN({change:q.change,commit:q.commit,invalid:U,markedDirtyRef:N,name:u,setRegisteredFieldName:I,registeredFieldIdRef:P,setValidityData:ee,validityData:W});g.useImperativeHandle(h,()=>({validate:J}),[J]);let re=g.useMemo(()=>({invalid:U,name:L,validityData:W,setValidityData:ee,disabled:S,setTouched:z,setDirty:R,setFilled:O,setFocused:A,validationMode:l,shouldValidateOnChange:B,state:te,registerFieldControl:ne,validation:q}),[U,L,W,S,z,R,O,A,l,B,te,ne,q]),ie=Br(`div`,e,{ref:t,state:te,props:v,stateAttributesMapping:AD});return(0,G.jsx)(FD.Provider,{value:re,children:ie})}),nN=g.forwardRef(function(e,t){return(0,G.jsx)($M,{children:(0,G.jsx)(tN,{...e,ref:t})})}),rN=g.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,nativeLabel:o=!0,...s}=e,c=ID(!1),l=nk(),{labelId:u}=VD(),d={...c.state,disabled:c.disabled||l.disabled},f=g.useRef(null),p=bA({id:u??a,native:o});return Br(`label`,e,{ref:[t,f],state:d,props:[p,s],stateAttributesMapping:AD})}),iN=g.forwardRef(function(e,t){let{render:n,className:r,id:i,name:a,value:o,disabled:s=!1,onValueChange:c,defaultValue:l,autoFocus:u=!1,style:d,...f}=e,{state:p,name:m,disabled:h,setTouched:_,setDirty:v,validityData:y,setFocused:x,setFilled:S,validationMode:C,validation:w}=ID(),{clearErrors:T,elementRef:E,submitCountRef:D}=zD(),O=h||s,k=m??a,A={...p,disabled:O},{labelId:j}=VD(),M=GD({id:i}),[N]=bf({controlled:o,default:l,name:`FieldControl`,state:`value`}),P=o!==void 0,F=P?N:void 0,I=F==null?void 0:String(F),L=Y(()=>w.inputRef.current?.value);LD(w.inputRef,M,I,L,!O,a),b(()=>{let e=I??w.inputRef.current?.value;e!==void 0&&S(e!==``)},[I,w.inputRef,S]),Jf(I,()=>{I!==void 0&&(T(k),v(I!==(y.initialValue??``)),w.change(I))});let R=g.useRef(null),z=We();return b(()=>{u&&R.current===ct(Ie(R.current))&&x(!0)},[u,x]),Br(`input`,e,{ref:[t,R],state:A,props:[{id:M,disabled:O,name:k,ref:w.inputRef,"aria-labelledby":j,autoFocus:u,...P?{value:F}:{defaultValue:l},onChange(e){let t=e.currentTarget.value,n=Aa(pa,e.nativeEvent);c?.(t,n),!P&&(v(t!==(y.initialValue??``)),S(t!==``),!e.nativeEvent.defaultPrevented&&!n.isCanceled&&(T(k),w.change(t)))},onFocus(){x(!0)},onBlur(e){if(_(!0),x(!1),C===`onBlur`){let t=e.currentTarget.value;w.commit(t),P&&queueMicrotask(()=>{let e=w.inputRef.current?.value;e!==void 0&&e!==t&&e!==(y.initialValue??``)&&w.commit(e)})}},onKeyDown(e){if(e.currentTarget.tagName===`INPUT`&&e.key===`Enter`){_(!0);let t=e.currentTarget.value,n=e.currentTarget.form;if(n&&n===E.current&&!e.defaultPrevented){let t=e.currentTarget,n=D.current;z.start(0,()=>{D.current===n&&w.commit(t.value)})}else w.commit(t)}}},f,e=>w.getValidationProps(O,e)],stateAttributesMapping:AD})});function aN({className:e,...t}){return(0,G.jsx)(nN,{"data-slot":`field`,className:Z(e),...t})}function oN({className:e,...t}){return(0,G.jsx)(rN,{"data-slot":`field-label`,className:Z(`text-foreground-intense mb-1.5 flex w-fit items-center text-sm font-medium select-none`,`data-disabled:opacity-disabled`,e),...t})}var sN=g.forwardRef(function(e,t){return(0,G.jsx)(iN,{ref:t,...e})});function cN(e,t){(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function lN({className:e,variant:t=`outline`,inputSize:n=`md`,clearable:r,startSlot:i,endSlot:a,onClear:o,inputProps:s,ref:c,...l}){let u=g.useRef(null),d=!!(r||i||a),f=l[`aria-invalid`],p=f===!0||f===`true`,m=Vu(c,u),h=()=>{u.current&&l.value===void 0&&cN(u.current,``),u.current?.focus(),o?.()};return d?(0,G.jsxs)(`div`,{"data-slot":`input-wrapper`,className:Z(lj({variant:t,size:n,state:`within`}),e),...p?{"data-invalid":``}:{},children:[i&&(0,G.jsx)(`div`,{"data-slot":`input-start`,className:`-ms-1 flex shrink-0 items-center`,children:i}),(0,G.jsx)(sN,{"data-slot":`input`,ref:m,placeholder:l.placeholder??` `,...s,className:Z(`peer text-foreground placeholder:text-foreground-subtle h-full min-w-0 flex-1 bg-transparent outline-none disabled:cursor-not-allowed`,s?.className),...l}),r&&(0,G.jsx)(`button`,{"data-slot":`input-clear`,type:`button`,onClick:h,className:`text-foreground-subtle hover:text-foreground pointer-events-none shrink-0 cursor-pointer opacity-0 transition-[opacity,color] duration-200 peer-not-placeholder-shown:pointer-events-auto peer-not-placeholder-shown:opacity-100`,tabIndex:-1,"aria-label":`Clear input`,children:(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`2 2 16 16`,fill:`currentColor`,className:`size-[1em]`,children:(0,G.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}),a&&(0,G.jsx)(`div`,{"data-slot":`input-end`,className:`-me-1 flex shrink-0 items-center`,children:a})]}):(0,G.jsx)(sN,{"data-slot":`input`,ref:m,...s,className:Z(lj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle`,s?.className,e),...l,...p?{"data-invalid":``}:{}})}var uN=1024,dN=65535;function fN({open:e,onOpenChange:t,port:n,busy:r,onSave:i}){let[a,o]=(0,g.useState)(String(n));(0,g.useEffect)(()=>{e&&o(String(n))},[e]);let s=a.trim(),c=Number(s),l=s!==``&&Number.isInteger(c)&&c>=uN&&c<=dN&&r===``;return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`max-w-sm`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.pairing.portTitle`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`relay-lan-port`,children:$(`panel.pairing.port`)}),(0,G.jsx)(lN,{inputProps:{id:`relay-lan-port`,inputMode:`numeric`},value:a,onChange:e=>o(e.target.value)})]}),(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.pairing.portHint`)})]}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:r!==``,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,G.jsx)(Q,{variant:`primary`,disabled:!l,onClick:()=>i(c),children:$(`panel.common.save`)})]})]})})}function pN({visible:e,onOpenConfig:t}){let[n,r]=(0,g.useState)(!1);return!e||n?null:(0,G.jsx)(cD,{open:!0,onOpenChange:e=>{e||r(!0)},children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.publicRelayNotice.title`)})}),(0,G.jsx)(pD,{className:`whitespace-pre-line text-sm leading-6 text-foreground-muted`,children:$(`panel.publicRelayNotice.body`)}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,onClick:()=>{r(!0),t()},children:$(`panel.pairing.openConfig`)}),(0,G.jsx)(Q,{variant:`primary`,onClick:()=>r(!0),children:$(`panel.publicRelayNotice.action`)})]})]})})}var mN={sm:`py-2`,md:`py-2.5`,lg:`py-3`},hN={sm:`min-h-16`,md:`min-h-20`,lg:`min-h-24`},gN={sm:`0.5rem`,md:`0.625rem`,lg:`0.75rem`};function _N(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function vN({className:e,variant:t=`outline`,inputSize:n=`md`,clearable:r,startSlot:i,endSlot:a,onClear:o,ref:s,rows:c=3,...l}){let u=g.useRef(null),d=Vu(s,u),f=!!(r||i||a),p=l[`aria-invalid`],m=p===!0||p===`true`,h=()=>{u.current&&l.value===void 0&&_N(u.current,``),u.current?.focus(),o?.()};return f?(0,G.jsxs)(`div`,{"data-slot":`textarea-wrapper`,"data-invalid":m?``:void 0,style:{"--textarea-h":`calc(${c} * 1lh + 2 * ${gN[n]} + 2px)`},className:Z(lj({variant:t,size:n,state:`within`}),`h-(--textarea-h) resize-y items-start overflow-hidden`,hN[n],mN[n],`has-[textarea:disabled]:border-border-strong! has-[textarea:disabled]:bg-background-subtle! has-[textarea:disabled]:opacity-disabled has-[textarea:disabled]:cursor-not-allowed has-[textarea:disabled]:border-dashed`,e),children:[i&&(0,G.jsx)(`div`,{"data-slot":`textarea-start`,className:`-ms-1 inline-flex h-lh shrink-0 items-center`,children:i}),(0,G.jsx)(iN,{"data-slot":`textarea`,ref:d,render:(0,G.jsx)(`textarea`,{rows:c}),placeholder:l.placeholder??` `,className:`peer text-foreground placeholder:text-foreground-subtle min-w-0 flex-1 resize-none self-stretch bg-transparent outline-none disabled:cursor-not-allowed`,...l}),r&&(0,G.jsx)(`button`,{"data-slot":`textarea-clear`,type:`button`,onClick:h,className:`text-foreground-subtle hover:text-foreground pointer-events-none inline-flex h-lh shrink-0 cursor-pointer items-center opacity-0 transition-[opacity,color] duration-200 peer-not-placeholder-shown:pointer-events-auto peer-not-placeholder-shown:opacity-100 motion-reduce:transition-none`,tabIndex:-1,"aria-label":`Clear input`,children:(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`2 2 16 16`,fill:`currentColor`,className:`size-[1em]`,children:(0,G.jsx)(`path`,{d:`M6.28 5.22a.75.75 0 0 0-1.06 1.06L8.94 10l-3.72 3.72a.75.75 0 1 0 1.06 1.06L10 11.06l3.72 3.72a.75.75 0 1 0 1.06-1.06L11.06 10l3.72-3.72a.75.75 0 0 0-1.06-1.06L10 8.94 6.28 5.22Z`})})}),a&&(0,G.jsx)(`div`,{"data-slot":`textarea-end`,className:`-me-1 inline-flex h-lh shrink-0 items-center`,children:a})]}):(0,G.jsx)(iN,{"data-slot":`textarea`,ref:d,render:(0,G.jsx)(`textarea`,{rows:c}),className:Z(lj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle h-auto resize-y`,mN[n],hN[n],e),...l,...m?{"data-invalid":``}:{}})}function yN(e){return String(e||``).replace(/\s+#.*$/,``).trim().replace(/^["']/,``).replace(/["']$/,``).trim()}function bN(e){let t={};for(let n of String(e||``).split(/\r?\n/)){let e=n.trim();if(!e||e.startsWith(`#`)||e.startsWith(`;`)||e.startsWith(`[`))continue;let r=/^([A-Za-z0-9_.]+)\s*[=:]\s*(.+)$/.exec(e);if(!r)continue;let i=r[1].toLowerCase();i in t||(t[i]=yN(r[2]))}return t}function xN(e){let t=String(e||``).trim();if(!t)return[];let n=[...t.matchAll(/["']([^"']+)["']/g)].map(e=>e[1].trim()).filter(Boolean);return n.length?n:t.replace(/^\[|\]$/g,``).split(/[,\s]+/).map(e=>e.trim()).filter(Boolean)}function SN(e){let t=(...t)=>{for(let n of t)if(e[n])return e[n];return``};return{type:(t(`type`)||``).toLowerCase(),remotePort:t(`remoteport`,`remote_port`),localPort:t(`localport`,`local_port`),domains:xN(t(`customdomains`,`custom_domains`))}}function CN(e){let t=e.split(/\[\[\s*proxies\s*\]\]/i),n=bN(t[0]);return{serverAddr:n.serveraddr||n.server_addr||``,proxies:t.slice(1).map(e=>SN(bN(e)))}}function wN(e){let t=[{name:`__global__`,pairs:{}}];for(let n of e.split(/\r?\n/)){let e=n.trim();if(!e||e.startsWith(`#`)||e.startsWith(`;`))continue;let r=/^\[([^\]]+)\]$/.exec(e);if(r){t.push({name:r[1].trim().toLowerCase(),pairs:{}});continue}let i=/^([A-Za-z0-9_.]+)\s*[=:]\s*(.+)$/.exec(e);if(!i)continue;let a=t[t.length-1],o=i[1].toLowerCase();o in a.pairs||(a.pairs[o]=yN(i[2]))}let n=t.find(e=>e.name===`common`)||t[0];return{serverAddr:n.pairs.server_addr||n.pairs.serveraddr||``,proxies:t.filter(e=>e.name!==`__global__`&&e.name!==`common`).map(e=>SN(e.pairs))}}function TN(e){let t;try{t=JSON.parse(e)}catch{return null}let n=t&&typeof t==`object`?t:{};return{serverAddr:typeof n.serverAddr==`string`?n.serverAddr:typeof n.server_addr==`string`?n.server_addr:``,proxies:(Array.isArray(n.proxies)?n.proxies:[]).map(e=>{let t=e&&typeof e==`object`?e:{},n=e=>typeof e==`string`||typeof e==`number`?String(e):``,r=t.customDomains??t.custom_domains;return{type:n(t.type).toLowerCase(),remotePort:n(t.remotePort??t.remote_port),localPort:n(t.localPort??t.local_port),domains:Array.isArray(r)?r.map(e=>String(e)):xN(n(r))}})}}function EN(e){if(!/^\d+$/.test(String(e||``)))return null;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function DN(e,t){for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=EN(n.remotePort);if(e&&t!==null)return{ok:!0,field:`tcp`,value:`${e}:${t}`,kind:`tcp`}}for(let e of t)if((e.type===`https`||e.type===`http`)&&e.domains.length)return{ok:!0,field:`direct`,value:`https://${e.domains[0]}`,kind:`https`};for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=EN(n.localPort);if(e&&t!==null)return{ok:!0,field:`tcp`,value:`${e}:${t}`,kind:`tcp`,note:`inferred-local-port`,port:t}}return{ok:!1,reason:`no-address`}}function ON(e){let t=String(e||``).trim();if(!t)return{ok:!1,reason:`empty`};let n=t.replace(/^[a-z][a-z0-9+.-]*:\/\//i,``).replace(/\/+$/,``).trim(),r=/^(\[[^\]]+\]|[^\s/:?#]+):(\d+)$/.exec(n);if(r){let e=Number(r[2]);return Number.isInteger(e)&&e>=1&&e<=65535?{ok:!0,field:`tcp`,value:`${r[1]}:${e}`,kind:`tcp`}:{ok:!1,reason:`bad-tcp`}}let i;return i=t.startsWith(`{`)?TN(t)||{serverAddr:``,proxies:[]}:/\[\[\s*proxies\s*\]\]/i.test(t)?CN(t):/^\s*\[common\]\s*$/im.test(t)||/(?:^|[\r\n])\s*server_addr\s*=/i.test(t)?wN(t):CN(t),DN(i.serverAddr,i.proxies)}function kN(e){return/serverAddr|server_addr|\[\[\s*proxies\s*\]\]|\[common\]/i.test(e)}function AN({open:e,onOpenChange:t,onImport:n}){let[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(``),l=(0,g.useMemo)(()=>ON(r),[r]);(0,g.useEffect)(()=>{e&&c(``)},[e]);async function u(){if(!l.ok||a)return;c(``);let e=``;if(kN(r)){o(!0);try{let t=await Vk(r);if(t?.status&&t.status.error){c(t.status.error),o(!1);return}e=t?.status?.remoteAddress||``}catch(e){c(Uk(e)),o(!1);return}o(!1)}let i=l.field===`tcp`&&e?e:l.value;n({field:l.field,value:i}),t(!1)}return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`w-[min(560px,92vw)]`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.frp.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.frp.hint`)}),(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`frp-import`,children:$(`panel.frp.label`)}),(0,G.jsx)(vN,{id:`frp-import`,rows:6,value:r,onChange:e=>i(e.target.value),autoComplete:`off`,spellCheck:!1})]}),r.trim()?l.ok?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{role:`status`,className:`text-xs text-foreground-muted`,children:$(l.field===`tcp`?`panel.frp.detectedTcp`:`panel.frp.detectedDirect`,{address:l.value})}),l.note===`inferred-local-port`?(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.frp.inferredPort`,{port:l.port??``})}):null]}):(0,G.jsx)(`p`,{className:`text-xs text-error`,children:$(l.reason===`empty`?`panel.frp.empty`:`panel.frp.badFormat`)}):null,s?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:s}):null]}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:a,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,G.jsx)(Q,{variant:`primary`,disabled:!l.ok||a,onClick:u,children:$(`panel.frp.fill`)})]})]})})}var jN=.7,MN=2;function NN(e){let t=Number.isFinite(e)&&e>0?e:0;return t>=600?1:t<=100?t/100*jN:jN+(t-100)/500*.30000000000000004}function PN(e,t,n){let r=e.map(e=>typeof e==`number`&&Number.isFinite(e)&&e>=0?e:null);if(!r.some(e=>e!==null))return``;let i=r.length>1?t/(r.length-1):0,a=Math.max(1,n-4),o=[],s=!1;return r.forEach((e,n)=>{if(e===null){s=!1;return}let c=r.length>1?n*i:t/2,l=MN+NN(e)*a;o.push(`${s?`L`:`M`}${c.toFixed(1)} ${l.toFixed(1)}`),s=!0}),o.join(` `)}function FN(e){return typeof e!=`number`||!Number.isFinite(e)?`none`:e<=100?`fast`:e<=600?`ok`:`slow`}var IN=5e3,LN=132,RN=28;function zN(e){return e===`fast`?`text-success`:e===`ok`?`text-warning`:e===`slow`?`text-destructive`:`text-foreground-muted`}function BN(e){return e===`fast`?`#16a34a`:e===`ok`?`#d97706`:e===`slow`?`#dc2626`:`#9ca3af`}function VN(e){return typeof e!=`number`||!Number.isFinite(e)?`—`:`${Math.round(e)} ms`}function HN({open:e,onOpenChange:t,activeUrl:n}){let[r,i]=(0,g.useState)({}),[a,o]=(0,g.useState)(``),s=(0,g.useRef)(!1),c=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(!e){s.current=!1,c.current!==null&&(clearInterval(c.current),c.current=null);return}s.current=!0,o(``);let t=Rj.map(e=>e.url);i(Object.fromEntries(t.map(e=>[e,[null]])));async function n(){if(s.current)try{let e=await zk(`/api/relay/probe-relays`,{urls:t});if(!s.current)return;let n=new Map((e.results||[]).map(e=>[e.url,e.ms]));i(e=>{let r={};for(let i of t)r[i]=[...e[i]||[],n.get(i)??null].slice(-14);return r}),o(``)}catch(e){s.current&&o(Uk(e))}}return n(),c.current=setInterval(()=>{n()},IN),()=>{s.current=!1,c.current!==null&&(clearInterval(c.current),c.current=null)}},[e]),(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.relay.panelTitle`)})}),(0,G.jsxs)(pD,{className:`flex max-h-[60vh] flex-col gap-1 overflow-y-auto`,children:[(0,G.jsx)(`p`,{className:`mb-2 text-xs text-foreground-muted`,children:$(`panel.relay.panelHint`)}),Rj.map(e=>{let t=r[e.url]||[null],i=[...t].reverse().find(e=>typeof e==`number`)??null,a=FN(i),o=PN(t,LN,RN),s=e.url===n;return(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-3 rounded-md border border-border-muted px-3 py-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col`,children:[(0,G.jsx)(`span`,{className:`truncate font-mono text-sm`,children:e.url}),s?(0,G.jsx)(`span`,{className:`text-xs text-primary`,children:$(`panel.relay.selected`)}):null]}),(0,G.jsxs)(`div`,{className:`flex shrink-0 items-center gap-3`,children:[o?(0,G.jsx)(`svg`,{width:LN,height:RN,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:o,stroke:BN(a),strokeWidth:1.5,fill:`none`})}):null,(0,G.jsx)(`span`,{className:`w-16 text-right text-sm tabular-nums ${zN(a)}`,children:VN(i)})]})]},e.url)}),a?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:a}):null]}),(0,G.jsx)(mD,{children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}function UN({open:e,onOpenChange:t,status:n,addressBook:r,lanUrls:i,busy:a,onSave:o,onSavePreferred:s}){let[c,l]=(0,g.useState)(n.relayUrl),[u,d]=(0,g.useState)(``),[f,p]=(0,g.useState)(``),[m,h]=(0,g.useState)(``),[_,v]=(0,g.useState)(``),[y,b]=(0,g.useState)(``),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(!1),[T,E]=(0,g.useState)(!1),D=(0,g.useRef)(null),O=(0,g.useRef)(null),k=(0,g.useRef)(!1),A=(0,g.useRef)(!1),j=(0,g.useRef)(!1),M=(0,g.useRef)(!1),N=r?r.lan.length>0?r.lan:r.public:[];(0,g.useEffect)(()=>{e&&l(n.relayUrl)},[e]),(0,g.useEffect)(()=>{e||(S(!1),w(!1))},[e]),(0,g.useEffect)(()=>{if(!e){k.current=!1,A.current=!1,j.current=!1,M.current=!1,b(``);return}if(k.current||d(r?.manual??``),A.current||p(r?.manualIpv6??``),j.current||h(r?.manualTcp??``),!M.current){let e=r?r.lan.length>0?r.lan:r.public:[];v((r?.preferred||``).trim()||(e[0]?.address??``))}},[e,r]);let P=a===``,F=Rj.find(e=>e.url===c.trim())??null,I=n.publicRelayBlocked===!0,L=e=>e.trim().replace(/\/+$/,``);function R(){if(!P)return;let e={};F?e.relayUrls=Rj.map(e=>e.url):c.trim()!==n.relayUrl&&(e.relayUrl=c.trim());let t=L(u);t!==L(r?.manual??``)&&(e.manualLanUrl=t);let i=L(f);i!==L(r?.manualIpv6??``)&&(e.manualIpv6Url=i);let a=L(m);a!==L(r?.manualTcp??``)&&(e.manualTcpUrl=a);let s=_.trim();if(M.current&&s!==(r?.preferred??``).trim()){if(s&&!N.some(e=>e.address===s)){b($(`panel.address.lanUnknown`));return}e.preferredLanAddress=s}o(e)}return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`w-[min(1100px,92vw)]`,initialFocus:O,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.pairing.openConfig`)})}),(0,G.jsx)(`div`,{ref:O,tabIndex:-1,className:`outline-none`,children:(0,G.jsxs)(pD,{className:`grid max-h-[calc(100vh-13rem)] grid-cols-2 items-start gap-x-8 gap-y-4 overflow-y-auto`,children:[(0,G.jsxs)(aN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(oN,{children:$(`panel.relay.publicKind`)}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>E(!0),children:$(`panel.relay.viewPanel`)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:!P||I,onClick:()=>l(F?``:Rj[0].url),children:$(F?`panel.relay.disablePublic`:`panel.relay.enablePublic`)})]})]}),I?(0,G.jsx)(lN,{inputProps:{className:`text-foreground-muted`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:$(`panel.relay.publicDisabled`)}):(0,G.jsx)(`div`,{className:`flex flex-col gap-1`,children:Rj.map(e=>(0,G.jsx)(lN,{inputProps:{className:`font-mono`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:e.url},e.url))})]}),(0,G.jsxs)(aN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(oN,{htmlFor:`relay-url`,children:$(`panel.relay.selfKind`)}),(0,G.jsx)(`a`,{href:Fj,target:`_blank`,rel:`noreferrer noopener`,className:qu({variant:`ghost`,size:`sm`}),children:$(`panel.relay.selfRepo`)})]}),(0,G.jsx)(lN,{inputProps:{id:`relay-url`,className:`font-mono`},value:F?``:c,placeholder:`https://example.com`,onChange:e=>l(e.target.value)})]}),(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`relay-manual-lan`,children:$(`panel.address.direct`)}),(0,G.jsx)(lN,{inputProps:{id:`relay-manual-lan`,className:`font-mono`},value:u,placeholder:$(`panel.address.directPlaceholder`),onChange:e=>{k.current=!0,d(e.target.value)}})]}),(0,G.jsxs)(aN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(oN,{htmlFor:`relay-manual-tcp`,children:$(`panel.address.tcp`)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>w(!0),children:$(`panel.address.frpImport`)})]}),(0,G.jsx)(lN,{inputProps:{id:`relay-manual-tcp`,className:`font-mono`},value:m,placeholder:$(`panel.address.tcpPlaceholder`),onChange:e=>{j.current=!0,h(e.target.value)}})]}),(0,G.jsxs)(aN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(oN,{htmlFor:`relay-preferred-lan`,children:$(`panel.address.lan`)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>S(!0),children:$(`panel.onboarding.chooseAddress`)})]}),(0,G.jsx)(lN,{inputProps:{id:`relay-preferred-lan`,className:`font-mono`,list:`relay-lan-candidates`},value:_,placeholder:$(`panel.address.lanPlaceholder`),onChange:e=>{M.current=!0,b(``),v(e.target.value)}}),(0,G.jsx)(`datalist`,{id:`relay-lan-candidates`,children:N.map(e=>(0,G.jsx)(`option`,{value:e.address,children:e.url},e.address))}),y?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:y}):null]}),(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`relay-manual-ipv6`,children:$(`panel.address.ipv6Url`)}),(0,G.jsx)(lN,{inputProps:{id:`relay-manual-ipv6`,className:`font-mono`,list:`relay-manual-ipv6-candidates`},value:f,placeholder:$(`panel.address.ipv6Placeholder`),onChange:e=>{A.current=!0,p(e.target.value)}}),(0,G.jsx)(`datalist`,{id:`relay-manual-ipv6-candidates`,children:(r?.ipv6??[]).map(e=>(0,G.jsx)(`option`,{value:e.url,children:e.interface?`${e.address} · ${e.interface}`:e.address},e.address))})]})]})}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:a===`config`,onClick:()=>t(!1),children:$(`panel.common.cancel`)}),(0,G.jsx)(Q,{variant:`primary`,disabled:!P,onClick:R,children:$(`panel.relay.saveConfig`)})]})]})}),(0,G.jsx)(cD,{open:x,onOpenChange:S,children:(0,G.jsxs)(lD,{className:`w-[min(560px,92vw)]`,initialFocus:D,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.address.lan`)})}),(0,G.jsx)(`div`,{ref:D,tabIndex:-1,className:`outline-none`,children:(0,G.jsx)(pD,{className:`max-h-[60vh] overflow-y-auto px-1 py-2`,children:(0,G.jsx)(Nj,{align:`start`,book:r,port:n.lan.port,value:r?.preferred??``,busy:a!==``,fallbackUrls:i,onChange:e=>{s(e),S(!1)}})})}),(0,G.jsx)(mD,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>S(!1),children:$(`panel.common.close`)})})]})}),(0,G.jsx)(AN,{open:C,onOpenChange:w,onImport:e=>{e.field===`tcp`?(j.current=!0,h(e.value)):(k.current=!0,d(e.value))}}),(0,G.jsx)(HN,{open:T,onOpenChange:E,activeUrl:F?.url??``})]})}var WN=18e5,GN=3e5,KN=15e3,qN=null,JN=0,YN=0,XN=null;function ZN(e){return typeof e!=`number`||!Number.isFinite(e)?!1:e===0||Date.now()-e>WN}function QN(e){if(!e&&XN)return XN;let t=(async()=>{let t=await Rk(e?`/api/relay/selfcheck?force=1`:`/api/relay/selfcheck`);return qN=t,JN=Date.now(),t})();return e||(XN=t,t.finally(()=>{XN===t&&(XN=null)})),t}function $N(e,t=``){let[n,r]=(0,g.useState)(qN),[i,a]=(0,g.useState)(!1),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(!1),u=(0,g.useRef)(!0);(0,g.useEffect)(()=>(u.current=!0,()=>{u.current=!1}),[]);let d=(0,g.useCallback)(async e=>{if(!e&&qN&&Date.now()-JN<KN){r(qN);return}a(!0);try{let t=await QN(e);if(!u.current)return;r(t),s(``),l(!1)}catch(e){if(!u.current)return;l(e instanceof Ik&&e.status===404),s(Uk(e))}finally{u.current&&a(!1)}},[]);(0,g.useEffect)(()=>{e&&(Date.now()-YN<GN||qN&&Date.now()-JN<KN||(YN=Date.now(),d(!1)))},[e,d]);let f=(0,g.useRef)(null);return(0,g.useEffect)(()=>{if(t){if(f.current===null){f.current=t;return}f.current!==t&&(f.current=t,d(!0))}},[t,d]),{data:n,checking:i,error:o,missing:c,ensure:(0,g.useCallback)(()=>void d(!1),[d]),refresh:(0,g.useCallback)(()=>void d(!0),[d])}}function eP(e){return e===`ok`?`ok`:e===`unknown`?`warn`:`error`}var tP={ok:{long:`panel.selfcheck.verdict.ok`,short:`panel.selfcheck.short.ok`},"not-listening":{long:`panel.selfcheck.verdict.notListening`,short:`panel.selfcheck.short.notListening`},"firewall-blocked":{long:`panel.selfcheck.verdict.firewallBlocked`,short:`panel.selfcheck.short.firewallBlocked`},unknown:{long:`panel.selfcheck.verdict.unknown`,short:`panel.selfcheck.short.unknown`},network:{long:`panel.selfcheck.verdict.network`,short:`panel.selfcheck.short.network`}};function nP(e){return $(tP[e]?.long??`panel.selfcheck.verdict.unknown`)}function rP(e){if(!e)return{tone:`off`,text:$(`panel.selfcheck.notChecked`)};let t=e.firewall,n=oP(t.appPath);return!t.supported||t.enabled===null?{tone:`warn`,text:$(`panel.selfcheck.unknown`)}:t.enabled===!1?{tone:`ok`,text:$(`panel.selfcheck.firewallOff`),...n?{detail:n}:{}}:t.allowsApp===!1?{tone:`error`,text:$(`panel.selfcheck.blocked`),...n?{detail:n}:{}}:t.allowsApp===!0?{tone:`ok`,text:$(`panel.selfcheck.allowed`),...n?{detail:n}:{}}:{tone:`warn`,text:$(`panel.selfcheck.unknown`)}}function iP(e,t){let n=typeof e?.mobile?.lastMobileAt==`number`?e.mobile.lastMobileAt:t;return typeof n!=`number`||!Number.isFinite(n)?{tone:`off`,text:$(`panel.selfcheck.notChecked`)}:n===0?{tone:`warn`,text:$(`panel.selfcheck.mobileNever`)}:(typeof e?.mobile?.idle==`boolean`?e.mobile.idle:ZN(n))?{tone:`warn`,text:$(`panel.selfcheck.mobileIdle`),detail:gg(n)}:{tone:`ok`,text:$(`panel.selfcheck.mobileRecent`),detail:gg(n)}}function aP(e){let t={listening:`panel.lan.listening`,off:`panel.status.off`,error:`panel.lan.error`};return t[e]?$(t[e]):e}function oP(e){let t=String(e??``).trim();if(!t)return``;let n=t.split(/[\\/]/);return n[n.length-1]??``}function sP({open:e,onOpenChange:t,state:n,lastMobileAt:r}){(0,g.useEffect)(()=>{e&&n.ensure()},[e,n.ensure]);let i=n.data,a=rP(i),o=iP(i,r),s=i?eP(i.verdict):`warn`;return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`max-w-xl`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.selfcheck.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[n.error?(0,G.jsxs)(YE,{variant:n.missing?`warning`:`error`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:n.missing?$(`panel.selfcheck.unavailable`):$(`panel.selfcheck.failed`)}),n.missing?null:(0,G.jsx)($E,{children:n.error})]}):null,i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:pg(`text-sm`,s===`ok`?`text-foreground`:hg[s]),children:nP(i.verdict)}),(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.connection.lan`),children:(0,G.jsx)(OO,{tone:i.listening.state===`listening`?`ok`:i.listening.state===`error`?`error`:`off`,text:aP(i.listening.state),detail:$(`panel.selfcheck.port`,{port:i.listening.port})})}),(0,G.jsx)(EO,{label:$(`panel.connection.tunnel`),children:(0,G.jsx)(OO,{tone:_g(i.tunnel.state),text:vg(i.tunnel.state)})}),(0,G.jsx)(EO,{label:$(`panel.selfcheck.firewall`),children:(0,G.jsx)(OO,{tone:a.tone,text:a.text,detail:a.detail})}),(0,G.jsx)(EO,{label:$(`panel.selfcheck.mobile`),children:(0,G.jsx)(OO,{tone:o.tone,text:o.text,detail:o.detail})})]}),(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.selfcheck.checkedAt`,{time:gg(i.checkedAt)})})]}):n.checking?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.selfcheck.checking`)]}):null]}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)}),(0,G.jsx)(Q,{variant:`primary`,disabled:n.checking,onClick:n.refresh,children:n.checking?$(`panel.selfcheck.checking`):$(`panel.selfcheck.recheck`)})]})]})})}function cP(e){return e.available?e.enabled?e.error?`panel.tailcat.error`:e.ready?`panel.tailcat.ready`:`panel.tailcat.starting`:`panel.tailcat.disabled`:`panel.tailcat.unavailable`}function lP(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function uP({open:e,onOpenChange:t,onChanged:n}){let r=nM(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{a(await Rk(`/api/relay/tailcat`)),s(``)}catch(e){s(Uk(e))}},[]);(0,g.useEffect)(()=>{if(!e)return;let t=()=>{l_()&&u()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,u]);let d=(0,g.useCallback)(async(e,t,i)=>{l(e);try{a(await t()),r(`soft`,i),n?.()}catch(e){r(`error`,Uk(e))}finally{l(``)}},[r,n]),f=e=>void d(`toggle`,()=>zk(`/api/relay/tailcat/enabled`,{enabled:e}),$(e?`panel.tailcat.enabledToast`:`panel.tailcat.disabledToast`)),p=e=>{window.confirm($(`panel.tailcat.revokeConfirm`))&&d(`revoke`,()=>zk(`/api/relay/tailcat/revoke`,{client:e}),$(`panel.tailcat.revokedToast`))},m=i?.status??null,h=i?.allowedClients??[];return(0,G.jsx)(cD,{open:e,onOpenChange:t,children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.tailcat.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.tailcat.hint`)}),o?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:o}):null,i===null?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.readingStatus`)]}):m===null?(0,G.jsx)(`p`,{className:`text-sm text-foreground-muted`,children:$(`panel.tailcat.unavailable`)}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.tailcat.title`)}),(0,G.jsxs)(`span`,{className:`min-w-0 text-right text-sm break-all`,children:[$(cP(m)),m.error?(0,G.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:m.error}):null]})]}),(0,G.jsxs)(`div`,{className:`flex items-baseline justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`shrink-0 text-sm text-foreground-muted`,children:$(`panel.tailcat.addressLabel`)}),(0,G.jsx)(`span`,{className:`min-w-0 text-right font-mono text-xs break-all text-foreground-strong`,children:m.address||$(`panel.tailcat.noAddress`)})]}),(0,G.jsxs)(`label`,{className:`flex items-center justify-between gap-4 border-b border-border-muted py-2`,children:[(0,G.jsx)(`span`,{className:`text-sm text-foreground-muted`,children:$(`panel.tailcat.enableLabel`)}),(0,G.jsx)(QD,{size:`md`,checked:m.enabled,disabled:!m.available||c!==``,onCheckedChange:e=>f(e),"aria-label":$(`panel.tailcat.enableLabel`)})]}),(0,G.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,G.jsxs)(`span`,{className:`text-sm text-foreground-muted`,children:[$(`panel.tailcat.pairedLabel`),` (`,m.paired,`)`]}),h.length===0?(0,G.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.tailcat.noClients`)}):(0,G.jsx)(`ul`,{className:`flex flex-col`,children:h.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center justify-between gap-3 border-b border-border-muted py-1.5 last:border-b-0`,children:[(0,G.jsx)(`span`,{className:`min-w-0 font-mono text-xs break-all text-foreground-strong`,children:lP(e)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:c!==``,onClick:()=>p(e),children:$(`panel.tailcat.revoke`)})]},e))})]})]})]}),(0,G.jsx)(mD,{className:`flex justify-end gap-2`,children:(0,G.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var dP=`/dsh-market/api/v1`,fP=`dsh-mobile-plugin`,pP=class extends Error{constructor(e,t,n){super(n),q(this,`status`,void 0),q(this,`code`,void 0),this.name=`MarketError`,this.status=e,this.code=t}},mP=e=>e&&typeof e==`object`?e:{},hP=e=>typeof e==`string`&&e!==``?e:null;async function gP(e,t){let n;try{n=await fetch(`${dP}${e}`,{credentials:`same-origin`,...t})}catch(e){throw new pP(0,`market_unreachable`,$(`panel.net.marketUnreachable`,{message:String(e?.message||e)}))}let r=await n.json().catch(()=>null);if(!n.ok){let e=mP(r),t=mP(e.failure),i=hP(t.code)??(typeof e.error==`string`?e.error:`HTTP ${n.status}`),a=hP(t.message)??hP(e.error)??$(`panel.net.marketHttp`,{status:n.status});throw new pP(n.status,i,a)}return r}async function _P(){try{return{available:!0,restartSupported:mP(mP(await gP(`/capabilities`)).restart).supported===!0}}catch{return{available:!1,restartSupported:!1}}}async function vP(e=fP,t=!1){let n=mP(await gP(`/updates${`?name=${encodeURIComponent(e)}${t?`&force=1`:``}`}`)),r=mP(n.package??n);return{installedVersion:hP(r.installedVersion),latestVersion:hP(r.latestVersion),updateAvailable:r.updateAvailable===!0,source:hP(r.source)}}var yP={status:`/api/relay/update/status`,check:`/api/relay/update/check`,apply:`/api/relay/update/apply`,auto:`/api/relay/update/auto`,otaStatus:`/api/relay/update/ota/status`,otaCheck:`/api/relay/update/ota/check`,otaApply:`/api/relay/update/ota/apply`},bP=e=>e&&typeof e==`object`?e:{},xP=e=>typeof e==`string`&&e!==``?e:null,SP=e=>typeof e==`boolean`?e:null,CP=e=>typeof e==`number`&&Number.isFinite(e)?e:null;async function wP(e,t){let n=await fetch(e,{credentials:`same-origin`,headers:{accept:`application/json`,...t?.body?{"content-type":`application/json`}:{}},...t}),r=null;try{r=await n.json()}catch{r=null}let i=bP(r),a=bP(i.error);if(!n.ok){let e=xP(a.code)??`http_${n.status}`;throw new Ik(xP(a.message)??$(`panel.net.hostHttp`,{status:n.status}),e,n.status)}return i}function TP(e){return e instanceof Ik?e.status===404:e instanceof SyntaxError}function EP(e){return e instanceof Ik&&e.code===`update_unavailable`}function DP(e){let t=bP(e);return Object.keys(t).length===0?null:{installedVersion:xP(t.installedVersion),latestVersion:xP(t.latestVersion),updateAvailable:t.updateAvailable===!0,source:xP(t.source),checkedAt:xP(t.checkedAt)}}function OP(e){let t=bP(e),n=bP(t.failure),r=xP(n.code);return{installed:SP(t.installed),skipped:SP(t.skipped),state:xP(t.state),beforeVersion:xP(t.beforeVersion),installedVersion:xP(t.installedVersion),swapped:SP(t.swapped),restartRequired:SP(t.restartRequired),refreshRequired:SP(t.refreshRequired),failure:r?{code:r,message:xP(n.message)??r}:null}}function kP(e){let t=bP(e);return{available:t.available===!0,version:xP(t.version),installedVersion:xP(t.installedVersion),source:xP(t.source),previousVersion:xP(t.previousVersion),activatedAt:xP(t.activatedAt),lastError:xP(t.lastError),inFlight:CP(t.inFlight)??0,swapping:t.swapping===!0,autoUpdate:t.autoUpdate===!0,autoIntervalMs:CP(t.autoIntervalMs)??6e5,marketBase:xP(t.marketBase),marketLastCheckedAt:xP(t.marketLastCheckedAt),marketLastError:xP(t.marketLastError),marketResult:DP(t.marketResult),lastApply:t.lastApply?OP(t.lastApply):null,appliedAt:xP(t.appliedAt),runningShellHash:xP(t.runningShellHash),installedShellHash:xP(t.installedShellHash),shellChanged:t.shellChanged===!0}}async function AP(){return kP((await wP(yP.status)).data)}async function jP(){let e=bP((await wP(yP.check,{method:`POST`,body:JSON.stringify({})})).data);return{update:DP(e.update),status:e.status?kP(e.status):null}}async function MP(e=!1){let t=bP((await wP(yP.apply,{method:`POST`,body:JSON.stringify({force:e})})).data),n=bP(t.status);return{...OP(t),status:Object.keys(n).length>0?kP(n):null}}async function NP(e){let t=bP((await wP(yP.auto,{method:`POST`,body:JSON.stringify({enabled:e})})).data);return{enabled:t.enabled===!0,status:t.status?kP(t.status):null}}var PP=new Set([`OPERATION_BUSY`,`RELEASE_TOO_FRESH`,`VERSION_UNCHANGED`,`PLUGIN_NOT_INSTALLED`,`AGENTS_RUNNING`]);function FP(e){let t=e.installedVersion??e.beforeVersion;return e.failure?{text:$(`panel.update.applyFailed`,{message:e.failure.message}),ok:!1}:e.installed===!1?e.skipped?{text:t?$(`panel.update.applyUpToDate`,{version:t}):$(`panel.update.applyUpToDatePlain`),ok:!0}:{text:t?$(`panel.update.applyDiskUnchanged`,{version:t}):$(`panel.update.applyFailedRetry`),ok:!1}:{text:t?$(`panel.update.applySwitched`,{version:t}):$(`panel.update.applySwitchedPlain`),ok:!0}}function IP({version:e,busy:t,onRestartSidecar:n}){let[r,i]=(0,g.useState)(null),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(null),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(``),h=nM(),[_,v]=(0,g.useState)(!1),y=(0,g.useCallback)(e=>{e&&i(t=>({...e,available:e.available===!0||t?.available===!0}))},[]),b=r!==null&&r.available&&!s,x=t!==``||p!==``,S=(0,g.useCallback)(async()=>{try{let e=await AP();i(e),c(e.available!==!0)}catch(e){i(null),c(EP(e))}finally{o(!0)}},[]);(0,g.useEffect)(()=>{S()},[S]),(0,g.useEffect)(()=>{if(!a)return;let e=!0;return jP().then(t=>{e&&(t.update&&f(t.update),t.status&&y(t.status))}).catch(()=>{}),()=>{e=!1}},[a]);let C=r?.swapping===!0;(0,g.useEffect)(()=>{if(!C)return;let e=window.setInterval(()=>void S(),1500);return()=>window.clearInterval(e)},[C,S]),(0,g.useEffect)(()=>{if(b||!a)return;let e=!0;return _P().then(t=>{e&&u(t)}),()=>{e=!1}},[b,a]);let w=(0,g.useCallback)(e=>{if(e instanceof pP&&PP.has(e.code)){h(`soft`,`${e.message}(${e.code})`);return}h(`error`,Uk(e))},[]),T=(0,g.useCallback)(async()=>{m(`check`);try{let e=await jP();e.status&&y(e.status),e.update&&f(e.update)}catch(e){TP(e)||EP(e)?await S():h(`error`,Uk(e))}finally{m(``)}},[S]),E=(0,g.useCallback)(async e=>{m(`apply`);try{let t=await MP(e);t.status&&y(t.status);let n=FP(t),r=t.failure!==null&&PP.has(t.failure.code);n.ok||r?h(`soft`,n.text):h(`error`,n.text)}catch(e){TP(e)||EP(e)?await S():h(`error`,Uk(e))}finally{m(``)}},[S]),D=(0,g.useCallback)(async()=>{m(`check`);try{let e=await jP();e.status&&y(e.status),f(e.update)}catch(e){if(!TP(e))f(null),h(`error`,Uk(e));else try{f(await vP(void 0,!0))}catch(e){f(null),w(e)}}finally{m(``)}},[w]),O=(0,g.useCallback)(async e=>{v(!0);try{let t=await NP(e);t.status&&y(t.status);let n=Math.round((t.status?.autoIntervalMs??r?.autoIntervalMs??6e5)/6e4);h(`soft`,t.enabled?$(`panel.update.autoOn`,{minutes:n}):$(`panel.update.autoOff`))}catch(e){h(`error`,$(`panel.update.autoToggleFailed`,{message:Uk(e)})),await S()}finally{v(!1)}},[r?.autoIntervalMs,S]),k=d?.latestVersion??r?.marketResult?.latestVersion??null,A=d?.source??r?.marketResult?.source??null,j=A===`linked`||A===`file`||A===`workspace`,M=d?.updateAvailable??r?.marketResult?.updateAvailable??!1,N=r?.lastApply?FP(r.lastApply):null,P=e||`—`,F=r?.version??null,I=b&&!!F&&!!e&&F!==e,L=r?.installedVersion??null,R=b&&!!L&&!!e&&L!==e;return(0,G.jsxs)(xD,{frame:`solid`,children:[(0,G.jsx)(SD,{className:`px-4 py-3`,children:(0,G.jsxs)(CD,{className:`flex items-center gap-2 text-base lg:text-lg`,children:[(0,G.jsx)(`span`,{children:$(`panel.update.title`)}),(0,G.jsx)(rD,{variant:`soft`,size:`sm`,children:e||$(`panel.update.unknownVersion`)})]})}),a?null:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.update.reading`)]}),s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.update.runningVersion`),mono:!0,children:P}),(0,G.jsx)(EO,{label:$(`panel.update.latestOnline`),mono:!0,children:k??$(`panel.update.notChecked`)})]}),(0,G.jsxs)(`p`,{className:`mt-3 text-xs text-foreground-muted`,children:[M?$(`panel.update.hasNew`):``,$(`panel.update.nothingToInstall`)]})]}):null,a&&!b&&!s&&l!==null&&!l.available?(0,G.jsxs)(YE,{variant:`info`,className:`mt-3`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:$(`panel.update.noMarketTitle`)}),(0,G.jsx)($E,{children:$(`panel.update.noMarketBody`)})]}):null,b&&r?(0,G.jsxs)(G.Fragment,{children:[j?null:(0,G.jsxs)(`label`,{className:`mt-1 flex items-start justify-between gap-4 border-b border-border-muted py-3`,children:[(0,G.jsxs)(`span`,{className:`min-w-0`,children:[(0,G.jsx)(`span`,{className:`block text-sm text-foreground`,children:$(`panel.update.autoUpdate`)}),(0,G.jsx)(`span`,{className:`mt-1 block text-xs text-foreground-muted`,children:$(`panel.update.autoDefaultHint`)})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-2`,children:[_?(0,G.jsx)(VE,{}):null,(0,G.jsx)(QD,{size:`md`,checked:r.autoUpdate,disabled:x||_,onCheckedChange:e=>void O(e),"aria-label":$(`panel.update.autoUpdate`)})]})]}),(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.update.runningVersion`),mono:!0,children:P}),L?(0,G.jsx)(EO,{label:$(`panel.update.diskVersion`),mono:!0,children:L}):null,(0,G.jsx)(EO,{label:$(`panel.update.latestOnline`),mono:!0,children:k??$(`panel.update.notChecked`)})]}),I?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.versionDrift`,{version:e??``,shell:F??``})}):null,R?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.diskDrift`,{disk:L??``,running:e??``})}):null,r.lastError?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.lastErrorLine`,{message:r.lastError})}):null,(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:x,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:x,onClick:()=>void T(),children:$(p===`check`?`panel.update.checking`:`panel.update.check`)}),j?null:(0,G.jsx)(Q,{variant:`primary`,size:`md`,disabled:x,onClick:()=>void E(!1),children:$(p===`apply`?`panel.update.updating`:`panel.update.updateNow`)})]}),!j&&(M||N!==null&&!N.ok)?(0,G.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:x,onClick:()=>void E(!0),children:$(`panel.update.forceHint`)})}):null]}):null,a&&!b&&!s&&l?.available?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.update.runningVersion`),mono:!0,children:P}),(0,G.jsx)(EO,{label:$(`panel.update.latestOnline`),mono:!0,children:k??$(`panel.update.notChecked`)}),(0,G.jsx)(EO,{label:$(`panel.update.checkResult`),children:$(M?`panel.update.resultHasNew`:`panel.update.resultUpToDate`)})]}),(0,G.jsxs)(`div`,{className:`mt-3 flex flex-wrap justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:x,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:x,onClick:()=>void D(),children:$(p===`check`?`panel.update.checking`:`panel.update.check`)}),r!==null&&!j?(0,G.jsx)(Q,{variant:`primary`,size:`md`,disabled:x,onClick:()=>void E(!1),children:$(p===`apply`?`panel.update.updating`:`panel.update.updateNow`)}):null]})]}):null]})}function LP({webAccess:e,busy:t,onToggle:n}){let r=e?.enabled===!0,i=typeof e?.expiresAt==`number`?e.expiresAt:0;return(0,G.jsxs)(xD,{frame:`solid`,children:[(0,G.jsx)(SD,{className:`px-4 py-3`,children:(0,G.jsx)(CD,{className:`text-base lg:text-lg`,children:$(`panel.webAccess.title`)})}),(0,G.jsx)(DO,{children:(0,G.jsx)(EO,{label:$(`panel.webAccess.state`),tone:r?`ok`:`off`,children:r?$(`panel.webAccess.expires`,{time:gg(i)}):$(`panel.webAccess.closed`)})}),(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-foreground-muted`,children:$(`panel.webAccess.hint`)}),(0,G.jsx)(`div`,{className:`mt-3 flex flex-wrap gap-2`,children:r?(0,G.jsx)(Q,{variant:`outline`,size:`sm`,disabled:t===`webAccess`,onClick:()=>n(!1),children:$(`panel.webAccess.close`)}):(0,G.jsx)(Q,{variant:`outline`,size:`sm`,disabled:t===`webAccess`,onClick:()=>n(!0),children:$(`panel.webAccess.open`)})})]})}function RP(e,t=``){let n=document.documentElement;n.setAttribute(`data-dshm-panel-state`,e),t?n.setAttribute(`data-dshm-panel-error`,t):n.removeAttribute(`data-dshm-panel-error`),window.parent!==window&&window.parent.postMessage({type:`dsh-mobile-plugin:panel-state`,state:e,message:t},`*`)}var zP=1500,BP=600;function VP(){return(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M4 7h16`}),(0,G.jsx)(`path`,{d:`M9 7V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V7`}),(0,G.jsx)(`path`,{d:`M6 7l1 12.5A2 2 0 0 0 9 21h6a2 2 0 0 0 2-1.5L18 7`}),(0,G.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})}function HP(){let[e,t]=(0,g.useState)(null),[n,r]=(0,g.useState)(``),[i,a]=(0,g.useState)(``),[o,s]=(0,g.useState)(null),[c,l]=(0,g.useState)(``),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(!1),[m,h]=(0,g.useState)(!1),[_,v]=(0,g.useState)(!1),[y,b]=(0,g.useState)(!1),[x,S]=(0,g.useState)(!1),[C,w]=(0,g.useState)(!1),T=nM();(0,g.useEffect)(()=>{e?RP(`ready`):n&&RP(`error`,n)},[e,n]);let E=(0,g.useRef)(null),[D,O]=(0,g.useState)(0);(0,g.useEffect)(()=>{let e=E.current;if(!e||typeof ResizeObserver>`u`)return;let t=()=>O(e.getBoundingClientRect().height);t();let n=new ResizeObserver(t);return n.observe(e),()=>n.disconnect()},[e]);let k=$N(ZN(e?.lastMobileAt),e?`${+!!e.enabled}|${+!!e.lan.enabled}|${e.lan.state}|${e.tunnel.state}|${+((e.lastMobileAt??0)>0)}`:``),A=(0,g.useCallback)(async()=>{try{t(await Rk(`/api/relay/status`)),r(``)}catch(e){r(Uk(e))}},[]),j=(0,g.useCallback)(async()=>{l(``);try{s(await Rk(`/api/relay/pairing`)),l(``)}catch(e){s(null),l(Uk(e))}},[]),M=(0,g.useCallback)(async()=>{try{d(await Rk(`/api/relay/addresses`))}catch{d(null)}},[]);(0,g.useEffect)(()=>{let e=()=>{l_()&&A()};e();let t=0,n=window.setTimeout(()=>{t=window.setInterval(e,3e3)},zP);return document.addEventListener(`visibilitychange`,e),()=>{window.clearTimeout(n),t&&window.clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[A]),(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=window.setTimeout(()=>void j(),BP);return()=>window.clearTimeout(t)},[e?.enabled,j]),(0,g.useEffect)(()=>{e?.enabled&&o&&e.pairingCode&&o.pairingCode!==e.pairingCode&&j()},[e?.pairingCode,e?.enabled,o,j]);let N=(0,g.useCallback)(async()=>{try{s(await Rk(`/api/relay/pairing`)),l(``)}catch{}},[]);(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=Fk(o);if(t===null)return;let n=window.setTimeout(()=>void N(),t);return()=>window.clearTimeout(n)},[o,e?.enabled,N]),(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=window.setTimeout(()=>void M(),BP);return()=>window.clearTimeout(t)},[e?.enabled,o,M]),(0,g.useEffect)(()=>{f&&e?.enabled&&(j(),M())},[f,e?.enabled,j,M]);let P=(0,g.useCallback)(async(e,t)=>{a(e);try{await t()}catch(e){T(`error`,Uk(e))}finally{a(``)}},[T]),F=e=>P(`toggle`,async()=>{t(await zk(`/api/relay/toggle`,{enabled:e})),e?await j():(s(null),l(``)),T(`soft`,$(e?`panel.shell.remoteEnabled`:`panel.shell.remoteDisabled`))}),I=()=>P(`restart`,async()=>{let e=await zk(`/api/relay/restart-sidecar`);t(e.status),T(`soft`,$(`panel.shell.sidecarRestarted`))}),L=()=>{window.confirm($(`panel.shell.revokeConfirm`))&&P(`revoke`,async()=>{let e=await zk(`/api/relay/revoke-all`);await A(),await j(),T(`soft`,`${$(`panel.shell.revoked`,{count:e.revoked})}${e.revokedRelay?$(`panel.shell.revokedRelay`,{count:e.revokedRelay}):``}`)})},R=e=>P(`webAccess`,async()=>{let n=await zk(`/api/relay/web-access`,{enabled:e});t(e=>e&&{...e,webAccess:n.webAccess}),T(`soft`,$(e?`panel.webAccess.opened`:`panel.webAccess.closedNotice`))}),z=e=>P(`config`,async()=>{t(await zk(`/api/relay/config`,e)),p(!1),await j(),T(`soft`,$(`panel.shell.configSaved`))}),B=e=>P(`policy`,async()=>{t(await zk(`/api/relay/config`,{pairingPolicy:e})),T(`soft`,$(e===`code`?`panel.shell.deviceAllowed`:`panel.shell.deviceDenied`))}),V=e=>P(`tier`,async()=>{t(await zk(`/api/relay/config`,{pairingTier:e})),T(`soft`,$(`panel.shell.configSaved`))}),H=e=>P(`autoReview`,async()=>{t(await zk(`/api/relay/config`,{approvalAutoReview:e})),T(`soft`,$(e?`panel.shell.autoReviewOn`:`panel.shell.autoReviewOff`))}),U=e=>P(`lan`,async()=>{t(await zk(`/api/relay/config`,{lanPort:e})),h(!1),await j(),T(`soft`,$(`panel.shell.lanSaved`))}),W=e=>P(`lan`,async()=>{t(await zk(`/api/relay/config`,{preferredLanAddress:e})),await Promise.all([j(),M()]),T(`soft`,e?$(`panel.shell.preferredAddress`,{address:e}):$(`panel.shell.preferredAuto`))}),ee=e?e.tunnel.state===`connected`||e.lan.state===`listening`?`ok`:e.enabled?`warn`:`off`:null;return e?(0,G.jsxs)(`main`,{className:`mx-auto flex w-full max-w-[1200px] flex-col gap-3 p-4 sm:p-5`,children:[(0,G.jsxs)(`header`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-1 items-center gap-2`,children:[ee?(0,G.jsx)(TO,{tone:ee}):null,(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name||e.instanceId}),(0,G.jsx)(rD,{variant:`soft`,size:`sm`,children:e.appVersion||$(`panel.shell.unknownVersion`)}),(0,G.jsx)(zM,{compact:!0})]}),i?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.busy`)]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,G.jsx)(YM,{lanPort:e.lan.port}),(0,G.jsx)(Dg,{}),(0,G.jsx)(a_,{}),(0,G.jsx)(Q,{variant:`ghost`,size:`icon-md`,"aria-label":$(`panel.inbox.title`),title:$(`panel.inbox.title`),onClick:()=>w(!0),children:(0,G.jsx)(VP,{})}),(0,G.jsx)(BO,{})]})]}),n?(0,G.jsxs)(YE,{variant:`error`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:$(`panel.shell.statusFailed`)}),(0,G.jsx)($E,{children:n})]}):null,(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3`,children:[(0,G.jsxs)(`div`,{className:`grid grid-cols-1 items-stretch gap-3 md:grid-cols-5`,children:[(0,G.jsx)(`div`,{className:`md:col-span-3`,children:(0,G.jsx)(Zj,{fill:!0,status:e,pairing:o,addressBook:u,busy:i,error:c,restartError:e.sidecar.restartError,onOpenConfig:()=>p(!0),onChangePolicy:e=>void B(e),onChangeTier:e=>void V(e),onChangeAutoReview:e=>void H(e),onOpenSelfCheck:()=>v(!0),onRetryPairing:()=>void j(),onSavePreferred:e=>void W(e),onEditPort:()=>h(!0)})}),(0,G.jsx)(`div`,{className:`md:col-span-2`,children:(0,G.jsx)(IP,{version:e.appVersion||``,busy:i,onRestartSidecar:()=>void I()})})]}),(0,G.jsxs)(`div`,{className:`grid grid-cols-1 gap-3 md:grid-cols-2`,children:[(0,G.jsx)(`div`,{ref:E,children:(0,G.jsx)(NO,{status:e,addressBook:u,busy:i,onToggle:F,onManageTailcat:()=>b(!0),onManageP2P:()=>S(!0)})}),(0,G.jsx)(`div`,{className:`min-h-0`,style:D>0?{height:`${D}px`}:void 0,children:(0,G.jsx)(pM,{onRevokeAll:L,busy:i,fill:!0})})]}),(0,G.jsx)(`div`,{className:`columns-1 gap-3 md:columns-2 xl:columns-3 [&>*]:mb-3 [&>*]:break-inside-avoid`,children:e.webAccess?.enabled&&e.panelScope!==`loopback`?(0,G.jsx)(LP,{webAccess:e.webAccess,busy:i,onToggle:e=>void R(e)}):null})]}),(0,G.jsx)(UN,{open:f,onOpenChange:p,status:e,addressBook:u,lanUrls:o?.lanUrls??[],busy:i,onSave:e=>void z(e),onSavePreferred:e=>void W(e)}),(0,G.jsx)(sP,{open:_,onOpenChange:v,state:k,lastMobileAt:e.lastMobileAt}),(0,G.jsx)(uP,{open:y,onOpenChange:b,onChanged:()=>void A()}),(0,G.jsx)(QM,{open:x,onOpenChange:S}),(0,G.jsx)(fN,{open:m,onOpenChange:h,port:o?.lanPort??e.lan.requestedPort??e.lan.port,busy:i,onSave:e=>void U(e)}),(0,G.jsx)(cD,{open:C,onOpenChange:w,children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.inbox.title`)})}),(0,G.jsx)(pD,{children:(0,G.jsx)(HM,{framed:!1})})]})}),(0,G.jsx)(pN,{visible:zj(e.relayUrl),onOpenConfig:()=>p(!0)})]}):(0,G.jsx)(`main`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-3 p-5`,children:n?(0,G.jsx)(`p`,{className:`text-sm text-error`,children:n}):(0,G.jsxs)(`p`,{className:`flex items-center gap-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.readingStatus`)]})})}var UP=[{textKey:`panel.onboarding.linuxStep1`},{text:`systemctl status firewalld`,cmd:!0},{text:`sudo ufw status`,cmd:!0},{textKey:`panel.onboarding.linuxStep2`},{text:`sudo firewall-cmd --permanent --add-port={port}/tcp
|
|
88
88
|
sudo firewall-cmd --reload`,cmd:!0},{text:`sudo ufw allow {port}/tcp`,cmd:!0},{textKey:`panel.onboarding.linuxStep3`}],WP=[{textKey:`panel.onboarding.macStep1`},{text:`/usr/libexec/ApplicationFirewall/socketfilterfw --getglobalstate`,cmd:!0},{textKey:`panel.onboarding.macStep2`},{text:`sudo /usr/libexec/ApplicationFirewall/socketfilterfw --setglobalstate off`,cmd:!0},{textKey:`panel.onboarding.macStep3`}],GP=[{textKey:`panel.onboarding.winStep1`},{text:`Get-NetFirewallProfile | Select-Object Name, Enabled`,cmd:!0},{textKey:`panel.onboarding.winStep2`},{text:`New-NetFirewallRule -DisplayName "DSH Mobile {port}" -Direction Inbound -LocalPort {port} -Protocol TCP -Action Allow`,cmd:!0},{textKey:`panel.onboarding.winStep3`}];function KP(){return[$(`panel.onboarding.prompt.intro`),``,$(`panel.onboarding.prompt.situation`),$(`panel.onboarding.prompt.address`),$(`panel.onboarding.prompt.guess`),``,$(`panel.onboarding.prompt.ask`),$(`panel.onboarding.prompt.ask1`),$(`panel.onboarding.prompt.ask2`),$(`panel.onboarding.prompt.ask3`),$(`panel.onboarding.prompt.ask4`),``,$(`panel.onboarding.prompt.extra`)].join(`
|
|
89
89
|
`)}function qP({title:e,steps:t,port:n,onCopied:r}){async function i(){try{await navigator.clipboard.writeText(KP()),r(!0)}catch{r(!1)}}return(0,G.jsxs)(`section`,{className:`flex flex-col gap-1.5 rounded-lg border border-border-muted bg-background-muted p-3`,children:[(0,G.jsx)(`h3`,{className:`text-center text-sm font-semibold text-foreground-intense`,children:e}),t.map(e=>{let t=(e.text??(e.textKey?$(e.textKey):``)).replace(/\{port\}/g,n);return e.cmd?(0,G.jsx)(`pre`,{className:`rounded bg-background-subtle px-2 py-1.5 font-mono text-[11px] leading-5 break-words whitespace-pre-wrap text-foreground-strong`,children:t},t):(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:t},t)}),(0,G.jsx)(Q,{className:`mt-auto`,variant:`outline`,size:`sm`,onClick:()=>void i(),children:$(`panel.onboarding.copyPromptHint`)})]})}function JP({open:e,onOpenChange:t,port:n}){let[r,i]=(0,g.useState)(``),a=e=>i(e?`ok`:`failed`);return(0,G.jsx)(cD,{open:e,onOpenChange:e=>{e||i(``),t(e)},children:(0,G.jsxs)(lD,{className:`w-[min(1200px,92vw)] max-w-none`,backdropProps:{className:`z-[80]`},viewportProps:{className:`z-[80]`},children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.onboarding.firewallTitle`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-4`,children:[(0,G.jsxs)(`p`,{className:`text-sm text-foreground-muted`,children:[$(`panel.onboarding.firewallIntro`),` `,(0,G.jsx)(`span`,{className:`font-mono`,children:n}),$(`panel.onboarding.firewallIntroTail`)]}),(0,G.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-3`,children:[(0,G.jsx)(qP,{title:`Linux`,steps:UP,port:n,onCopied:a}),(0,G.jsx)(qP,{title:`Mac`,steps:WP,port:n,onCopied:a}),(0,G.jsx)(qP,{title:`Windows`,steps:GP,port:n,onCopied:a})]})]}),r?(0,G.jsx)(mD,{className:`flex justify-end`,children:(0,G.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(r===`ok`?`panel.onboarding.copiedOk`:`panel.onboarding.copiedFailed`)})}):null]})})}function YP(e){let t=(e.preferred||``).trim();return t&&e.lan.some(e=>e.address===t)?t:e.lan[0]?.address??``}function XP({onDone:e}){let[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(``),[a,o]=(0,g.useState)(``),[s,c]=(0,g.useState)(!1),[l,u]=(0,g.useState)(!1),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(``),[b,x]=(0,g.useState)(!1),[S,C]=(0,g.useState)(!1),[w,T]=(0,g.useState)(!1),[E,D]=(0,g.useState)(``),O=$N(ZN(t?.lastMobileAt),t?`${+!!t.enabled}|${+!!t.lan.enabled}|${t.lan.state}|${t.tunnel.state}|${+((t.lastMobileAt??0)>0)}`:``),k=rP(O.data),A=O.data?.verdict??``,j=(0,g.useRef)(!0);(0,g.useEffect)(()=>(j.current=!0,()=>{j.current=!1}),[]),(0,g.useEffect)(()=>{(async()=>{try{let e=await Rk(`/api/relay/addresses`);f(e),y(YP(e))}catch{f(null),u(!0)}})()},[]),(0,g.useEffect)(()=>{(async()=>{try{let e=await Rk(`/api/relay/status`);n(e),e.enabled&&u(!0)}catch(e){i(Uk(e))}await N()})()},[]);let M=(0,g.useRef)(!1);(0,g.useEffect)(()=>{M.current||d!==null&&(M.current=!0,!(t&&t.enabled)&&z())},[d,t]);async function N(){_(``);try{m(await Rk(`/api/relay/pairing`))}catch(e){_(Uk(e))}}(0,g.useEffect)(()=>{let e=Fk(p);if(e===null)return;let t=window.setTimeout(()=>{j.current&&N()},e);return()=>window.clearTimeout(t)},[p]);let P=String(t?.lan.port||d?.port||18787),F=t!==null&&(t.lan.state===`listening`||t.tunnel.state===`connected`),I=t!==null&&l&&!O.checking&&A!==`ok`&&!(A===`not-listening`&&F);async function L(){let e=Date.now();for(;j.current&&Date.now()-e<2e4;){if(await new Promise(e=>window.setTimeout(e,1500)),!j.current)return;let e;try{e=await Rk(`/api/relay/status`)}catch{continue}if(n(e),e.lan.state===`listening`||e.tunnel.state===`connected`||e.lan.state===`error`&&e.tunnel.state===`error`)return}}async function R(e){if(s)return;c(!0),e&&u(!1),o(``);let t={relayUrls:Rj.map(e=>e.url),lanEnabled:!0,pairingPolicy:`code`};v&&(t.preferredLanAddress=v);try{n(await zk(`/api/relay/config`,t)),e&&(n(await zk(`/api/relay/toggle`,{enabled:!0})),await zk(`/api/relay/onboarded`,{}).catch(()=>void 0)),await N(),e&&L().finally(()=>{j.current&&u(!0)})}catch(t){e&&j.current&&u(!0),o(Uk(t))}finally{c(!1)}}async function z(){await R(!0)}function B(){e?e():window.location.assign(`/`)}async function V(){let e=[$(`panel.onboarding.tailcatPrompt.intro`),``,$(`panel.onboarding.tailcatPrompt.situation`),$(`panel.onboarding.tailcatPrompt.state`,{state:K}),$(`panel.onboarding.tailcatPrompt.guess`),``,$(`panel.onboarding.tailcatPrompt.ask`),$(`panel.onboarding.tailcatPrompt.ask1`),$(`panel.onboarding.tailcatPrompt.ask2`),$(`panel.onboarding.tailcatPrompt.ask3`)].join(`
|
|
90
90
|
`);try{return await navigator.clipboard.writeText(e),!0}catch{return!1}}let H=p?.svg??``,U=t?.tailcat??null,W=!U||!U.available?`unavailable`:U.enabled?U.error?`error`:U.ready?`ready`:`starting`:`disabled`,ee=W!==`ready`&&W!==`starting`,K={ready:$(`panel.tailcat.ready`),starting:$(`panel.tailcat.starting`),disabled:$(`panel.tailcat.disabled`),error:$(`panel.tailcat.error`),unavailable:$(`panel.tailcat.unavailable`)}[W],te=W===`ready`?`ok`:W===`starting`?`warn`:`off`;return(0,G.jsxs)(`main`,{className:`flex min-h-screen flex-col items-center justify-center gap-4 px-6 pt-6 pb-24`,children:[r?(0,G.jsxs)(YE,{className:`w-full max-w-4xl`,variant:`error`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:$(`panel.onboarding.statusFailed`)}),(0,G.jsx)($E,{children:r})]}):null,a?(0,G.jsxs)(YE,{className:`w-full max-w-4xl`,variant:`error`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:$(`panel.onboarding.stepFailed`)}),(0,G.jsx)($E,{children:a})]}):null,(0,G.jsxs)(xD,{frame:`solid`,className:`w-full max-w-4xl`,children:[(0,G.jsxs)(`div`,{className:`grid items-center gap-6 px-4 pb-2 md:grid-cols-[minmax(320px,1fr)_minmax(0,1fr)]`,children:[(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-2 md:col-start-1 md:row-start-1`,children:[(0,G.jsxs)(`div`,{className:`flex h-5 w-full max-w-[320px] items-center justify-center gap-1.5`,children:[(0,G.jsx)(`p`,{className:`text-sm font-medium leading-5 text-foreground-strong`,children:$(`panel.onboarding.pairingHint`)}),H?(0,G.jsx)(`button`,{type:`button`,"aria-label":`${$(`panel.pairing.qrZoom`)}:${$(`panel.pairing.qr`)}`,title:$(`panel.pairing.qrZoom`),className:`cursor-pointer text-foreground-muted hover:text-foreground-strong focus-visible:outline-none`,onClick:()=>C(!0),children:(0,G.jsxs)(`svg`,{viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,children:[(0,G.jsx)(`circle`,{cx:`10.5`,cy:`10.5`,r:`6`}),(0,G.jsx)(`path`,{d:`m15 15 4.5 4.5M8.5 10.5h4M10.5 8.5v4`})]})}):null]}),H?(0,G.jsx)(`button`,{type:`button`,className:`cursor-zoom-in rounded-lg focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-none`,onClick:()=>C(!0),"aria-label":`${$(`panel.pairing.qrZoom`)}:${$(`panel.pairing.qr`)}`,children:(0,G.jsx)(`div`,{className:`size-[320px] max-w-full rounded-lg bg-white p-3 [&_svg]:h-full [&_svg]:w-full`,dangerouslySetInnerHTML:{__html:H}})}):(0,G.jsx)(`div`,{className:`flex size-[320px] max-w-full items-center justify-center rounded-lg border border-border-muted text-xs text-foreground-muted`,children:h?(0,G.jsxs)(`div`,{className:`flex flex-col items-center gap-2 p-3 text-center`,children:[(0,G.jsx)(`span`,{role:`alert`,children:h}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:s,onClick:()=>void N(),children:$(`panel.console.retryPairing`)})]}):s?(0,G.jsx)(VE,{}):$(`panel.onboarding.noQr`)}),(0,G.jsx)(`p`,{className:`min-h-4 max-w-[320px] text-center text-xs leading-4 text-foreground-muted`,children:!F&&H?$(`panel.onboarding.relayNotConnected`):``})]}),(0,G.jsxs)(`div`,{className:`flex min-w-0 flex-col justify-center gap-3 md:col-start-2 md:row-start-1`,children:[(0,G.jsx)(`p`,{className:`text-center text-sm font-medium text-foreground-strong`,children:$(`panel.download.title`)}),(0,G.jsx)(Uj,{})]}),(0,G.jsxs)(`div`,{className:`w-full md:col-span-2 md:row-start-2 [&_dt]:text-foreground-strong`,children:[(0,G.jsxs)(DO,{children:[(0,G.jsx)(EO,{label:$(`panel.onboarding.direct`),children:(0,G.jsx)(OO,{tone:yg(t?.lan.state??`off`,!0),text:bg(t?.lan.state??`off`,!0)})}),(0,G.jsx)(EO,{label:$(`panel.connection.tunnel`),children:(0,G.jsx)(OO,{tone:_g(t?.tunnel.state??`off`),text:vg(t?.tunnel.state??`off`)})}),(0,G.jsx)(EO,{label:$(`panel.tailcat.title`),children:(0,G.jsxs)(`span`,{className:`inline-flex items-center justify-end gap-1.5`,children:[(0,G.jsx)(OO,{tone:te,text:K}),ee?(0,G.jsx)(`button`,{type:`button`,"aria-label":$(`panel.onboarding.tailcatWhy`),title:$(`panel.onboarding.tailcatWhy`),className:`cursor-pointer text-foreground-muted hover:text-foreground-strong focus-visible:outline-none`,onClick:()=>T(!0),children:(0,G.jsx)(wO,{})}):null]})}),(0,G.jsx)(EO,{label:$(`panel.selfcheck.firewall`),children:(0,G.jsx)(OO,{tone:k.tone,text:k.text,detail:k.detail})})]}),I?(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed break-words ${hg[eP(A)]}`,children:nP(A)}):null,t!==null&&(t.lan.state===`error`||t.tunnel.state===`error`)?(0,G.jsxs)(YE,{className:`mt-2`,variant:`error`,children:[(0,G.jsx)(ZE,{}),(0,G.jsx)(QE,{children:t.lan.state===`error`?$(`panel.onboarding.lanFailed`):$(`panel.onboarding.relayFailed`)}),(0,G.jsx)($E,{children:t.lan.state===`error`?t.lan.error?$(`panel.onboarding.lanErrorWithPort`,{error:t.lan.error}):$(`panel.onboarding.lanNoStart`):t.tunnel.error?$(`panel.onboarding.tunnelErrorHint`,{error:t.tunnel.error}):$(`panel.onboarding.tunnelNoStart`)})]}):null]})]}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-end gap-2 px-4 py-4`,children:[(0,G.jsx)(`button`,{type:`button`,className:`cursor-pointer text-sm text-foreground-intense underline underline-offset-2 hover:text-foreground-strong`,onClick:()=>x(!0),children:$(`panel.onboarding.checkFirewall`)}),F?(0,G.jsx)(Q,{variant:`primary`,onClick:B,children:$(`panel.onboarding.enterPlugin`)}):(0,G.jsx)(Q,{variant:`primary`,disabled:s||r!==``,onClick:()=>void z(),children:$(s?`panel.onboarding.opening`:`panel.onboarding.connectRelay`)})]})]}),(0,G.jsx)(JP,{open:b,onOpenChange:x,port:P}),(0,G.jsx)(cD,{open:S,onOpenChange:C,children:(0,G.jsxs)(lD,{className:`w-[min(680px,94vw)] max-w-none`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.pairing.qr`)})}),(0,G.jsx)(pD,{children:(0,G.jsx)(`div`,{className:`flex flex-col items-center gap-3`,children:(0,G.jsx)(`div`,{className:`flex items-center justify-center rounded-md bg-white p-4`,children:H?(0,G.jsx)(`div`,{className:`size-[min(72vh,600px)] [&_svg]:h-full [&_svg]:w-full`,dangerouslySetInnerHTML:{__html:H}}):null})})})]})}),(0,G.jsx)(cD,{open:w,onOpenChange:T,children:(0,G.jsxs)(lD,{className:`max-w-md`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.tailcat.title`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-2.5`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.onboarding.tailcatWhat`)}),(0,G.jsx)(`p`,{className:`text-sm text-foreground`,children:$(`panel.onboarding.tailcat.${W}`)}),(0,G.jsx)(Q,{variant:`outline`,size:`sm`,onClick:()=>{V().then(e=>D($(e?`panel.onboarding.copiedOk`:`panel.onboarding.copiedFailed`)))},children:$(`panel.onboarding.copyPromptHint`)}),E?(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:E}):null]})]})})]})}function ZP(e){let t=typeof e==`string`?e:e instanceof Ik?e.code:``,n={"credentials-unavailable":`errorAuth`,REMOTE_AUTH:`errorAuth`,REMOTE_REVOKED:`errorAuth`,REMOTE_EXPIRED:`errorExpired`,REMOTE_TIMEOUT:`errorTimeout`,REMOTE_CONNECT:`errorConnect`,REMOTE_INVITATION:`errorInvitation`,REMOTE_OPEN_URL:`invalidOpenUrl`,REMOTE_POPUP:`popupBlocked`,REMOTE_EXTERNAL_OPEN:`externalOpenFailed`,REMOTE_VERSION:`errorVersion`,SHELL_UNAVAILABLE:`shellUnavailable`,REMOTE_UNAVAILABLE:`errorUnavailable`,REMOTE_NOT_FOUND:`errorNotFound`,"bad-invite":`errorInvitation`,"bad-id":`errorBadRequest`,"bad-mode":`errorBadRequest`};return $(n[t]?`panel.remote.${n[t]}`:`panel.remote.failed`)}var QP=`/api/relay/remote-computers`,$P={list:()=>Rk(QP),invite:()=>zk(`${QP}/invite`,{}),add:e=>zk(`${QP}/add`,{invite:e}),open:e=>zk(`${QP}/open`,{id:e}),openShell:e=>zk(`${QP}/open-shell`,{id:e}),diagnose:e=>zk(`${QP}/diagnose`,{id:e}),remove:e=>zk(`${QP}/remove`,{id:e}),mode:(e,t)=>zk(`${QP}/mode`,{id:e,mode:t}),revoke:e=>zk(`${QP}/revoke`,{deviceId:e})};function eF(e){return[`auto`,...new Set(e.map(e=>e.channel).filter(e=>e&&e!==`auto`&&e!==`direct`))]}function tF(e){let t;try{t=new URL(e)}catch{throw new Ik($(`panel.remote.invalidOpenUrl`),`REMOTE_OPEN_URL`,0)}if(t.protocol!==`http:`||t.hostname!==`127.0.0.1`||!t.port||t.username||t.password)throw new Ik($(`panel.remote.invalidOpenUrl`),`REMOTE_OPEN_URL`,0);return t.href}function nF(e){return e instanceof Ik?e.code===`SHELL_UNAVAILABLE`||e.status===404||e.status===405||e.status===0:e instanceof TypeError}async function rF(e){try{let t=await $P.openShell(e);return tF(t.url),t.shellOpened===!1?{...await iF(e),shellOpened:!1}:t}catch(t){if(!nF(t))throw t;return{...await iF(e),shellMissing:!0}}}async function iF(e){let t=window.location.protocol===`http:`||window.location.protocol===`https:`,n=t?window.open(`about:blank`,`_blank`):null;if(t&&!n)throw new Ik($(`panel.remote.popupBlocked`),`REMOTE_POPUP`,0);try{n&&(n.opener=null);let t=await $P.open(e),r=tF(t.url);if(n)n.location.replace(r);else try{let e=window.top;if(!e||e.location.origin!==window.location.origin)throw Error(`origin`);e.location.href=r}catch{throw new Ik($(`panel.remote.externalOpenFailed`),`REMOTE_EXTERNAL_OPEN`,0)}return t}catch(e){throw n?.close(),e}}function aF(){return(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`13`,rx:`2`}),(0,G.jsx)(`path`,{d:`M8 21h8M12 17v4`})]})}function oF(){return(0,G.jsxs)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`path`,{d:`M4 7h16`}),(0,G.jsx)(`path`,{d:`M9 7V4.5A1.5 1.5 0 0 1 10.5 3h3A1.5 1.5 0 0 1 15 4.5V7`}),(0,G.jsx)(`path`,{d:`M6 7l1 12.5A2 2 0 0 0 9 21h6a2 2 0 0 0 2-1.5L18 7`}),(0,G.jsx)(`path`,{d:`M10 11v6M14 11v6`})]})}function sF(e){let t={auto:`auto`,lan:`lan`,direct:`direct`,ipv6:`ipv6`,relay:`relay`,tunnel:`tailcat`,tailcat:`tailcat`,p2p:`p2p`};return e?t[e]?$(`panel.remote.channel.${t[e]}`):e:$(`panel.common.none`)}function cF(e){try{return new URL(e).host}catch{return e}}function lF(){let e=nM(),[t,n]=(0,g.useState)(null),[r,i]=(0,g.useState)(!1),[a,o]=(0,g.useState)(!1),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)([]),[d,f]=(0,g.useState)(null),[p,m]=(0,g.useState)(null),[h,_]=(0,g.useState)(``),[v,y]=(0,g.useState)(!1),[b,x]=(0,g.useState)(null),[S,C]=(0,g.useState)(`auto`),[w,T]=(0,g.useState)(null),[E,D]=(0,g.useState)(!1),[O,k]=(0,g.useState)(0),A=(0,g.useRef)(0),j=(0,g.useRef)(!1),M=(0,g.useRef)(!1),N=(0,g.useCallback)(async()=>{if(!j.current){j.current=!0;try{let e=await $P.list();if(!M.current)return;A.current=e.serverNow-Date.now(),k(e.serverNow),n(e),o(!1),c(``)}catch(e){if(!M.current)return;let t=e instanceof Ik&&e.status===403;o(t),c(t?``:ZP(e)),t&&n(null)}finally{j.current=!1,M.current&&i(!0)}}},[]);(0,g.useEffect)(()=>{M.current=!0;let e=()=>{l_()&&(k(Date.now()+A.current),N())};e();let t=window.setInterval(e,3e3);return document.addEventListener(`visibilitychange`,e),()=>{M.current=!1,window.clearInterval(t),document.removeEventListener(`visibilitychange`,e)}},[N]);let P=e=>l.includes(e),F=e=>l.some(t=>t.endsWith(`:${e}`));async function I(t,r,i){if(!l.includes(t)){u(e=>[...e,t]);try{await r(),i&&e(`ok`,$(i)),await N()}catch(t){t instanceof Ik&&t.status===403&&(o(!0),n(null),f(null),x(null),m(null)),e(`error`,t instanceof Ik&&t.status===403?$(`panel.remote.localOnly`):ZP(t))}finally{u(e=>e.filter(e=>e!==t))}}}async function L(t){if(!E){D(!0);try{T((await $P.diagnose(t.id)).routes)}catch(t){e(`error`,ZP(t))}finally{D(!1)}}}function R(){m(null),y(!1),f(`invite`),I(`invite`,async()=>{m(await $P.invite())})}async function z(){if(!(!p||p.expiresAt<=O))try{await navigator.clipboard.writeText(p.invite),y(!1),e(`ok`,$(`panel.remote.copied`))}catch{y(!0)}}function B(t){I(`open:${t.id}`,async()=>{let n=await rF(t.id);n.shellMissing?e(`ok`,$(`panel.remote.shellUnavailable`)):n.shellOpened===!1&&e(`ok`,$(`panel.remote.shellFellBack`))})}function V(e){window.confirm($(`panel.remote.removeConfirm`,{name:e.name||e.instanceId}))&&I(`remove:${e.id}`,()=>$P.remove(e.id),`panel.remote.removed`)}let H=t?.devices??[],U=t?.authorizedComputers??[],W=r&&!a&&t!==null,ee=p!==null&&p.expiresAt<=O,K=d===`invite`?P(`invite`):d===`add`&&P(`add`),te=b!==null&&P(`mode:${b.id}`);return(0,G.jsxs)(xD,{frame:`solid`,className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsx)(SD,{className:`flex-none px-4 py-3`,children:(0,G.jsxs)(CD,{className:`flex flex-wrap items-center justify-between gap-x-2 gap-y-1 text-base lg:text-lg`,children:[(0,G.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,G.jsx)(`span`,{children:$(`panel.remote.title`)}),H.length>0?(0,G.jsx)(rD,{variant:`secondary`,size:`sm`,children:H.length}):null]}),W?(0,G.jsxs)(`span`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`px-2 text-xs xl:px-4 xl:text-sm xl:before:border xl:before:border-border xl:before:bg-background`,disabled:P(`invite`),onClick:R,children:$(`panel.remote.createInvite`)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`px-2 text-xs xl:px-4 xl:text-sm xl:before:border xl:before:border-border xl:before:bg-background`,disabled:P(`add`),onClick:()=>{_(``),f(`add`)},children:$(`panel.remote.add`)})]}):null]})}),W?(0,G.jsx)(`p`,{className:`mt-2 text-xs leading-5 text-foreground-muted`,children:$(`panel.remote.hint`)}):null,r?null:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.readingStatus`)]}),a?(0,G.jsx)(`p`,{className:`mt-2 text-sm text-foreground-muted`,children:$(`panel.remote.localOnly`)}):null,s?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-error`,children:s}):null,W?(0,G.jsxs)(G.Fragment,{children:[H.length===0?(0,G.jsx)(`p`,{className:`mt-3 text-xs text-foreground-muted`,children:$(`panel.remote.empty`)}):null,(0,G.jsx)(`div`,{className:`mt-1 flex min-h-0 flex-1 flex-col`,children:H.map(e=>{let t=e.expiresAt??0,n=e.state===`expired`||t>0&&t<=O,r=e.state===`revoked`?`revoked`:n?`expired`:e.state,i=e.attached&&e.state!==`revoked`,a=F(e.id);return(0,G.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col justify-between gap-2 border-b border-border-muted py-2 last:border-b-0`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,G.jsx)(`span`,{className:`truncate text-sm text-foreground-strong`,children:e.name||e.instanceId}),(0,G.jsx)(rD,{variant:`secondary`,size:`xs`,children:$(`panel.remote.state.${r}`)})]}),(0,G.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`px-2 text-xs xl:px-2 xl:text-sm`,disabled:a,onClick:()=>{C(e.mode),T(null),x(e)},children:$(`panel.remote.route`)}),i?(0,G.jsxs)(`span`,{className:`whitespace-nowrap px-1 text-xs text-foreground-muted`,children:[sF(e.mode),` · `,sF(e.channel),e.latencyMs!==null&&Number.isFinite(e.latencyMs)?` · ${Math.round(e.latencyMs)} ms`:``]}):(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`px-2`,"aria-label":$(`panel.remote.open`),disabled:a||e.state===`revoked`||e.state===`connecting`,onClick:()=>B(e),children:(0,G.jsx)(aF,{})}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`px-2`,"aria-label":$(`panel.remote.remove`),disabled:a,onClick:()=>V(e),children:(0,G.jsx)(oF,{})}),a?(0,G.jsx)(VE,{}):null]})]}),n&&e.state!==`revoked`?(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.remote.expiredHint`)}):null,e.lastError||e.lastErrorCode?(0,G.jsx)(`p`,{className:`text-xs break-all text-error`,children:ZP(e.lastErrorCode)}):null]},e.id)})}),U.length>0?(0,G.jsxs)(`div`,{className:`mt-1 border-t border-border-muted pt-2`,children:[(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.remote.authorizedTitle`)}),U.map(e=>(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-border-muted py-3 last:border-b-0`,children:[(0,G.jsx)(`div`,{className:`min-w-0`,children:(0,G.jsx)(`p`,{className:`truncate text-sm text-foreground-strong`,children:e.name||$(`panel.remote.unknownComputer`)})}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`px-2`,"aria-label":$(`panel.remote.revoke`),disabled:P(`revoke:${e.deviceId}`),onClick:()=>{window.confirm($(`panel.remote.revokeConfirm`,{name:e.name||$(`panel.remote.unknownComputer`)}))&&I(`revoke:${e.deviceId}`,()=>$P.revoke(e.deviceId),`panel.remote.revoked`)},children:(0,G.jsx)(oF,{})})]},e.deviceId))]}):null]}):null,(0,G.jsx)(cD,{open:d!==null,onOpenChange:e=>{!e&&!K&&(f(null),m(null))},children:(0,G.jsxs)(lD,{className:`max-w-md`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(d===`invite`?`panel.remote.createInvite`:`panel.remote.add`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3`,children:[d===`invite`||d===`add`?(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(d===`invite`?`panel.remote.inviteHint`:`panel.remote.addHint`)}):null,d===`invite`?p?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`remote-computer-invite`,children:$(`panel.remote.inviteLabel`)}),(0,G.jsx)(vN,{id:`remote-computer-invite`,rows:4,readOnly:!0,value:p.invite,onFocus:e=>e.target.select()})]}),(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(ee?`panel.remote.inviteExpired`:`panel.remote.inviteRemaining`,{minutes:Math.max(0,Math.ceil((p.expiresAt-O)/6e4))})}),v?(0,G.jsx)(`p`,{role:`status`,className:`text-xs text-foreground-muted`,children:$(`panel.remote.manualCopy`)}):null]}):K?(0,G.jsx)(VE,{}):null:(0,G.jsxs)(aN,{children:[(0,G.jsx)(oN,{htmlFor:`remote-computer-add`,children:$(`panel.remote.inviteLabel`)}),(0,G.jsx)(vN,{id:`remote-computer-add`,rows:4,value:h,onChange:e=>_(e.target.value),autoComplete:`off`,spellCheck:!1})]})]}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:K,onClick:()=>{f(null),m(null)},children:$(`panel.common.close`)}),d===`invite`?(0,G.jsx)(Q,{variant:`primary`,disabled:K||!p||ee,onClick:()=>void z(),children:$(`panel.remote.copy`)}):(0,G.jsx)(Q,{variant:`primary`,disabled:K||!h.trim(),onClick:()=>void I(`add`,async()=>{await $P.add(h.trim()),_(``),f(null)},`panel.remote.added`),children:$(`panel.remote.add`)})]})]})}),(0,G.jsx)(cD,{open:b!==null,onOpenChange:e=>{!e&&!te&&(x(null),T(null))},children:(0,G.jsxs)(lD,{className:`max-w-sm`,children:[(0,G.jsx)(uD,{children:(0,G.jsx)(dD,{children:$(`panel.remote.route`)})}),(0,G.jsxs)(pD,{className:`flex flex-col gap-3 text-sm`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.remote.routeHint`)}),b?.attached?(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.remote.routeReopenNote`)}):null,(0,G.jsx)(jk,{className:`flex flex-col gap-2`,value:S,onValueChange:e=>{typeof e==`string`&&C(e)},children:eF(b?.routes??[]).map(e=>(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2`,children:[(0,G.jsx)(hk,{value:e}),(0,G.jsx)(`span`,{children:sF(e)})]},e))}),(0,G.jsxs)(`div`,{className:`border-t border-border-muted pt-2`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,G.jsx)(`span`,{className:`text-xs text-foreground-muted`,children:$(`panel.remote.diagnoseHint`)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,className:`px-2 text-xs`,disabled:E,onClick:()=>{b&&L(b)},children:$(`panel.remote.diagnose`)})]}),E?(0,G.jsx)(VE,{}):null,w?(0,G.jsx)(`ul`,{className:`mt-1 flex flex-col gap-1`,children:w.map(e=>(0,G.jsxs)(`li`,{className:`flex items-center justify-between gap-2 text-xs`,children:[(0,G.jsxs)(`span`,{className:`truncate`,children:[sF(e.channel),` · `,cF(e.url)]}),(0,G.jsxs)(`span`,{className:`shrink-0 whitespace-nowrap text-foreground-muted`,children:[e.ok?$(`panel.remote.diagnoseOk`):$(`panel.remote.diagnoseFail`),e.ok&&e.latencyMs!==null?` · ${e.latencyMs} ms`:``,!e.ok&&e.errorCode?` · ${ZP(e.errorCode)}`:``]})]},`${e.channel}:${e.url}`))}):null]})]}),(0,G.jsxs)(mD,{className:`flex justify-end gap-2`,children:[(0,G.jsx)(Q,{variant:`outline`,disabled:te,onClick:()=>x(null),children:$(`panel.common.cancel`)}),(0,G.jsx)(Q,{variant:`primary`,disabled:te||!eF(b?.routes??[]).includes(S),onClick:()=>{b&&I(`mode:${b.id}`,async()=>{await $P.mode(b.id,S),x(null)},`panel.remote.modeSaved`)},children:$(`panel.common.save`)})]})]})})]})}function uF(){try{let e=new URL(document.baseURI);return e.pathname=e.pathname.replace(/\/remote\/?$/,`/console`),e.search=``,e.hash=``,e.href}catch{return``}}function dF(){return(0,G.jsxs)(`main`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-3 p-5`,children:[(0,G.jsxs)(`header`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,G.jsx)(`h1`,{className:`text-lg font-semibold text-foreground-strong`,children:$(`panel.remote.title`)}),(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>{window.location.href=uF()},children:$(`panel.remote.backConsole`)}),(0,G.jsx)(BO,{})]})]}),(0,G.jsx)(lF,{})]})}function fF(){let e=window.location.pathname.replace(/\/+$/,``),t=e.endsWith(`/setup`),n=e.endsWith(`/settings`),r=e.endsWith(`/remote`),i=!t&&!n&&!r,[a,o]=(0,g.useState)(n?!0:null),[s,c]=(0,g.useState)(``),[l,u]=(0,g.useState)(!1);return(0,g.useEffect)(()=>{s?RP(`error`,s):(!i||a!==null)&&RP(`ready`)},[a,s,i]),(0,g.useEffect)(()=>{if(!i)return;let e=!0;return(async()=>{try{let t=await Rk(`/api/relay/status`);e&&o(t.onboarded===!0||t.enabled===!0)}catch(t){e&&c(Uk(t))}})(),()=>{e=!1}},[i]),s?(0,G.jsxs)(`main`,{className:`mx-auto flex w-full max-w-5xl flex-col gap-3 p-5`,children:[(0,G.jsx)(`p`,{className:`text-sm text-error`,role:`alert`,children:s}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,onClick:()=>window.location.reload(),children:$(`panel.console.reload`)})]}):r?(0,G.jsx)(dF,{}):t?l?(0,G.jsx)(HP,{}):(0,G.jsx)(XP,{onDone:()=>u(!0)}):a===null?(0,G.jsxs)(`main`,{className:`flex min-h-screen items-center justify-center gap-2 p-6 text-sm text-foreground-muted`,children:[(0,G.jsx)(VE,{}),$(`panel.shell.loading`)]}):!a&&!l?(0,G.jsx)(XP,{onDone:()=>u(!0)}):(0,G.jsx)(HP,{})}function pF(){let e=Sg();(0,g.useEffect)(()=>{typeof document<`u`&&(document.documentElement.lang=e,document.title=$(`panel.shell.title`))},[e]);let t=window.location.pathname.replace(/\/+$/,``),n=!/\/demo(\.html)?$/.test(t);return(0,g.useEffect)(()=>{if(n)return e_()},[n]),(0,g.useEffect)(()=>u_(),[]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fF,{}),n?null:(0,G.jsx)(o_,{})]})}function mF(){if(!/Android/i.test(navigator.userAgent)||window.parent===window)return;let e=window.frameElement;e&&e.tagName===`IFRAME`&&e.classList.contains(`dshm_frame`)&&(e.style.transform=`translateZ(0)`,e.style.isolation=`isolate`,e.style.contain=`paint`)}mF();function hF(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(pF,{}),(0,G.jsx)(td,{position:`top-right`})]})}(0,gd.createRoot)(document.getElementById(`root`),{onUncaughtError:e=>RP(`error`,Uk(e))}).render((0,G.jsx)(g.StrictMode,{children:(0,G.jsx)(ed,{children:(0,G.jsx)(hF,{})})}));</script>
|
package/lib/relay/control.js
CHANGED
|
@@ -21,6 +21,7 @@ const {
|
|
|
21
21
|
phoneCandidates,
|
|
22
22
|
ipv6Candidates,
|
|
23
23
|
withManualIpv6Candidate,
|
|
24
|
+
tcpDirectTarget,
|
|
24
25
|
} = require('./lan-network.cjs');
|
|
25
26
|
const { relayAddressesOf } = require('./core.js');
|
|
26
27
|
const { sealHistoryBlob } = require('../mirror/history-blob.cjs');
|
|
@@ -37,6 +38,10 @@ function controlWsUrl(base = CONTROL_BASE_URL) {
|
|
|
37
38
|
* 折出本机要上报的全部连接地址(明文,上送前再加密)。
|
|
38
39
|
* 与配对二维码同源:中转取 `relayUrls`;局域网走 `phoneCandidates(advertisedCandidates)`;
|
|
39
40
|
* IPv6 走 `ipv6Candidates` 并缀上手填那条。`lanEnabled` 关掉或端口拿不到时不含局域网/IPv6。
|
|
41
|
+
* 「TCP 直连」目标(`manualTcpUrl`)单独一条,**不受 `lanEnabled` 影响**:它不挂在局域网监听上,
|
|
42
|
+
* 是一条独立的裸 TCP 出站通道。这一格必须报上来——配了 TCP(或手填直连)时公用中转会被规则关掉,
|
|
43
|
+
* 而 TCP 又替换不了「宿主地址」在手机上的同步:手机离开局域网后连不上宿主,只能靠总控把 TCP
|
|
44
|
+
* 目标补给它。漏了这一格,总控这条兜底就等于空转。
|
|
40
45
|
*/
|
|
41
46
|
function controlAddresses(state, port) {
|
|
42
47
|
const out = [];
|
|
@@ -67,6 +72,11 @@ function controlAddresses(state, port) {
|
|
|
67
72
|
/* 同上 */
|
|
68
73
|
}
|
|
69
74
|
}
|
|
75
|
+
// TCP 直连:用户填的 `host:port`(可能带方括号 IPv6)。不受 `lanEnabled` 管——它是一条独立的
|
|
76
|
+
// 裸 TCP 出站通道,关掉局域网直连时它照样能用;而它恰恰是「公用中转被关掉」那种配置下手机
|
|
77
|
+
// 唯一还能连上的地址,必须进总控这份兜底清单。
|
|
78
|
+
const tcp = tcpDirectTarget(state.manualTcpUrl);
|
|
79
|
+
if (tcp) out.push({ kind: 'tcp', url: tcp });
|
|
70
80
|
const seen = new Set();
|
|
71
81
|
const dedup = [];
|
|
72
82
|
for (const a of out) {
|
package/lib/relay/lan-proxy.js
CHANGED
|
@@ -377,7 +377,7 @@ function createLanProxy(opts) {
|
|
|
377
377
|
const headers = withViaHeader(
|
|
378
378
|
Object.fromEntries(Object.entries(req.headers).filter(([k]) => !HOP_BY_HOP.has(k))),
|
|
379
379
|
'lan',
|
|
380
|
-
`${upstreamHost}:${upstreamPort}`,
|
|
380
|
+
`${formatHost(upstreamHost)}:${upstreamPort}`,
|
|
381
381
|
);
|
|
382
382
|
const isSse = String(req.headers.accept || '').toLowerCase().includes('text/event-stream');
|
|
383
383
|
if (isSse && upstreamSseOpen >= maxUpstreamSse) {
|
|
@@ -487,7 +487,7 @@ function createLanProxy(opts) {
|
|
|
487
487
|
const headers = withViaHeader(
|
|
488
488
|
Object.fromEntries(Object.entries(req.headers).filter(([key, value]) => !HOP_BY_HOP.has(key) && value !== undefined)),
|
|
489
489
|
'lan',
|
|
490
|
-
`${upstreamHost}:${upstreamPort}`,
|
|
490
|
+
`${formatHost(upstreamHost)}:${upstreamPort}`,
|
|
491
491
|
);
|
|
492
492
|
// 上游要认得这条请求:新 T1 记录没有存下来的宿主令牌,就把请求里出示的那一枚
|
|
493
493
|
// 原样带上去;旧 HMAC 记录仍用它自己的 hostToken。
|
|
@@ -496,7 +496,7 @@ function createLanProxy(opts) {
|
|
|
496
496
|
|
|
497
497
|
let up;
|
|
498
498
|
try {
|
|
499
|
-
up = new WebSocket(`ws://${upstreamHost}:${upstreamPort}${req.url}`, {
|
|
499
|
+
up = new WebSocket(`ws://${formatHost(upstreamHost)}:${upstreamPort}${req.url}`, {
|
|
500
500
|
headers,
|
|
501
501
|
handshakeTimeout: WS_UPSTREAM_HANDSHAKE_MS,
|
|
502
502
|
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
// 落点代理转给宿主 web 服务时跟随宿主实际绑定地址(不再写死回环),回环绑定行为不变。
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 隧道数据的落脚代理:隧道里进来的请求先到这里,打上转发标记,再转给宿主 web 端口。
|
|
@@ -25,7 +26,7 @@ const http = require('node:http');
|
|
|
25
26
|
const net = require('node:net');
|
|
26
27
|
const { VIA_HEADER, VIA_TUNNEL, withViaHeader } = require('../shared/via-header');
|
|
27
28
|
|
|
28
|
-
const
|
|
29
|
+
const DEFAULT_UPSTREAM_HOST = '127.0.0.1';
|
|
29
30
|
|
|
30
31
|
// 与局域网代理同一份逐跳头名单:两条路转给同一个上游,头的处理口径必须一致。
|
|
31
32
|
const HOP_BY_HOP = new Set([
|
|
@@ -36,17 +37,26 @@ const HOP_BY_HOP = new Set([
|
|
|
36
37
|
/**
|
|
37
38
|
* @param {object} options
|
|
38
39
|
* @param {() => number} options.upstreamPort 宿主 web 端口(每次请求现读,允许变化)
|
|
40
|
+
* @param {() => string} [options.upstreamHost] 宿主 web 绑定地址(取值器;缺省回环)
|
|
39
41
|
* @param {(message: string) => void} [options.log]
|
|
40
42
|
*/
|
|
41
43
|
function createTunnelForwarder(options) {
|
|
42
44
|
const upstreamPort = options.upstreamPort;
|
|
45
|
+
const upstreamHost = typeof options.upstreamHost === 'function'
|
|
46
|
+
? options.upstreamHost
|
|
47
|
+
: () => options.upstreamHost || DEFAULT_UPSTREAM_HOST;
|
|
43
48
|
const log = options.log || (() => {});
|
|
44
49
|
let server = null;
|
|
45
50
|
let port = 0;
|
|
46
51
|
let starting = null;
|
|
47
52
|
const live = new Set();
|
|
48
53
|
|
|
49
|
-
|
|
54
|
+
// 写 Host 头时 IPv6 字面量要带方括号;连接本身用裸地址。
|
|
55
|
+
const hostText = () => {
|
|
56
|
+
const host = upstreamHost();
|
|
57
|
+
return host.includes(':') ? `[${host}]` : host;
|
|
58
|
+
};
|
|
59
|
+
const upstreamOf = () => `${hostText()}:${Number(upstreamPort())}`;
|
|
50
60
|
|
|
51
61
|
/** 转发用的头:与局域网代理同源,客户端自带的同名标记会被覆盖掉。 */
|
|
52
62
|
function forwardedHeaders(incoming) {
|
|
@@ -59,7 +69,7 @@ function createTunnelForwarder(options) {
|
|
|
59
69
|
|
|
60
70
|
function forwardRequest(req, res) {
|
|
61
71
|
const up = http.request(
|
|
62
|
-
{ hostname:
|
|
72
|
+
{ hostname: upstreamHost(), port: Number(upstreamPort()), method: req.method, path: req.url, headers: forwardedHeaders(req.headers) },
|
|
63
73
|
(ures) => {
|
|
64
74
|
const out = {};
|
|
65
75
|
for (const [key, value] of Object.entries(ures.headers)) {
|
|
@@ -108,7 +118,7 @@ function createTunnelForwarder(options) {
|
|
|
108
118
|
}
|
|
109
119
|
|
|
110
120
|
function forwardUpgrade(req, socket, head) {
|
|
111
|
-
const upstream = net.connect({ host:
|
|
121
|
+
const upstream = net.connect({ host: upstreamHost(), port: Number(upstreamPort()) });
|
|
112
122
|
live.add(socket);
|
|
113
123
|
live.add(upstream);
|
|
114
124
|
const drop = () => {
|
|
@@ -145,7 +155,7 @@ function createTunnelForwarder(options) {
|
|
|
145
155
|
});
|
|
146
156
|
starting = new Promise((resolve) => {
|
|
147
157
|
try {
|
|
148
|
-
server.listen(0,
|
|
158
|
+
server.listen(0, '127.0.0.1', () => {
|
|
149
159
|
// 这条监听不该把进程钉住:它只是个转发口,真正撑住宿主的是别的东西。
|
|
150
160
|
server.unref?.();
|
|
151
161
|
const address = server.address();
|
package/lib/relay/tunnel.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
'use strict';
|
|
2
|
+
// 中转隧道把请求转给宿主 web 服务时,上游地址跟随宿主实际绑定地址(可能不是回环)。
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* 出站隧道客户端 v2:连接 dsh-mobile-server 中转,把中转发来的 HTTP/WS 请求转发到
|
|
5
|
-
* 本机 dsh web
|
|
6
|
+
* 本机 dsh web(宿主实际绑定的地址:<port>,默认回环)。
|
|
6
7
|
*
|
|
7
8
|
* 协议 v2 相对 v1 的变更(协议定义见中转仓库 relay-core 的 `PROTOCOL.md`):
|
|
8
9
|
* - 二进制帧取代 JSON/base64 文本帧(数据通道不再 base64);
|
|
@@ -86,6 +87,8 @@ class RelayTunnel {
|
|
|
86
87
|
this.lanUrls = Array.isArray(opts.lanUrls) ? opts.lanUrls.slice() : [];
|
|
87
88
|
this.lanCandidates = Array.isArray(opts.lanCandidates) ? opts.lanCandidates.slice() : [];
|
|
88
89
|
this.upstream = new URL(opts.upstream);
|
|
90
|
+
// `URL.hostname` 对 IPv6 字面量保留方括号(如 `[::1]`),而 `http.request` 的 host 要裸地址。
|
|
91
|
+
this.upstreamHost = this.upstream.hostname.replace(/^\[|\]$/g, '');
|
|
89
92
|
// 注册密钥:relay.json 里的显式值优先,环境变量作为无头/命令行场景的兜底。
|
|
90
93
|
this.registerSecret = typeof opts.registerSecret === 'string' && opts.registerSecret
|
|
91
94
|
? opts.registerSecret
|
|
@@ -668,7 +671,7 @@ class RelayTunnel {
|
|
|
668
671
|
}
|
|
669
672
|
const req = http.request(
|
|
670
673
|
{
|
|
671
|
-
host: this.
|
|
674
|
+
host: this.upstreamHost,
|
|
672
675
|
port: this.upstream.port,
|
|
673
676
|
method: msg.method,
|
|
674
677
|
path: msg.path,
|
package/lib/remote/runtime.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// 电脑间远程网页的装配与生命周期;入口只在可信本机界面签发。
|
|
3
|
+
// 落点代理转给宿主 web 服务时跟随宿主实际绑定地址(见 relay/tunnel-forwarder.cjs)。
|
|
3
4
|
const os = require('node:os');
|
|
4
5
|
const { createRemoteStore } = require('./store.cjs');
|
|
5
6
|
const { createRemoteHost } = require('./host.cjs');
|
|
@@ -11,7 +12,7 @@ const { createTunnelForwarder } = require('../relay/tunnel-forwarder.cjs');
|
|
|
11
12
|
|
|
12
13
|
function mountRemoteComputers({ ctx, state, credentials, registerRoute, lanPortInUse, tailcat, p2p, lanAvailable, onBindingsChanged, onInvite, log = () => {} }) {
|
|
13
14
|
const store = createRemoteStore({ credentials: () => ctx.get('credentials') });
|
|
14
|
-
const forwarder = createTunnelForwarder({ upstreamPort: () => ctx.webServer.port, log });
|
|
15
|
+
const forwarder = createTunnelForwarder({ upstreamPort: () => ctx.webServer.port, upstreamHost: () => ctx.webServer.host, log });
|
|
15
16
|
const control = createHostControl({ state, tailcat, p2p, lanPortInUse, lanAvailable });
|
|
16
17
|
const host = createRemoteHost({
|
|
17
18
|
state, credentials, routesOf: control.routesOf,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
// LAN 生命周期等待旧监听释放,并由同一处绑定与发布入口。
|
|
3
|
+
// 转发给宿主 web 服务的上游地址跟随宿主实际绑定地址(不再写死回环)。
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* sidecar worker:真正持有「中转隧道 + 局域网代理」的那个子进程。
|
|
@@ -280,7 +281,11 @@ async function parentJson(path, body, signal) {
|
|
|
280
281
|
if (res.statusCode !== 200) throw new Error(value.error?.message || value.error || `parent RPC failed: ${res.statusCode}`)
|
|
281
282
|
return value.data ?? value
|
|
282
283
|
}
|
|
283
|
-
function upstream() {
|
|
284
|
+
function upstream() {
|
|
285
|
+
const host = config.upstreamHost || '127.0.0.1'
|
|
286
|
+
// URL 里的 IPv6 字面量要方括号,否则 `new URL` 解析不出来。
|
|
287
|
+
return `http://${host.includes(':') ? `[${host}]` : host}:${config.upstreamPort}`
|
|
288
|
+
}
|
|
284
289
|
// 读取隔离:把移动端高频读请求(sessions/workspaces/messages/stats)从本地快照直接回,
|
|
285
290
|
// 不再打扰主进程。快照缺失或路径不在清单内时返回 null → 调用方回源主进程。
|
|
286
291
|
function snapshotRead(info) {
|
|
@@ -358,13 +363,13 @@ function snapshotRead(info) {
|
|
|
358
363
|
* 的信号。这也意味着写回队首之后**不能**再触发一次配置下发 —— 见 adoptRoute 那一段。
|
|
359
364
|
*/
|
|
360
365
|
function tunnelSignature(c) {
|
|
361
|
-
return JSON.stringify([Boolean(c.enabled), c.relayUrl || '', Array.isArray(c.relayUrls) ? c.relayUrls : [], c.instanceId || '', c.upstreamPort || 0, c.registerSecret || ''])
|
|
366
|
+
return JSON.stringify([Boolean(c.enabled), c.relayUrl || '', Array.isArray(c.relayUrls) ? c.relayUrls : [], c.instanceId || '', c.upstreamPort || 0, c.upstreamHost || '', c.registerSecret || ''])
|
|
362
367
|
}
|
|
363
368
|
/** 「这份配置里哪几项决定局域网代理要重建」。 */
|
|
364
369
|
function lanSignature(c) {
|
|
365
370
|
// **配对码与票据不在其中**:它们由 `currentPairing` 现读,改它们不该重建监听 ——
|
|
366
371
|
// 配对成功就要换一次(§5.1),跟着重建会把刚握上的连接掐掉。
|
|
367
|
-
return JSON.stringify([Boolean(c.enabled), Boolean(c.lanEnabled), c.lanPort || 0, c.upstreamPort || 0, c.instanceId || '', c.lanSecret || '', c.pairingTier || 'full'])
|
|
372
|
+
return JSON.stringify([Boolean(c.enabled), Boolean(c.lanEnabled), c.lanPort || 0, c.upstreamPort || 0, c.upstreamHost || '', c.instanceId || '', c.lanSecret || '', c.pairingTier || 'full'])
|
|
368
373
|
}
|
|
369
374
|
/** 「这份配置里哪几项决定网络监视器要不要重排」。 */
|
|
370
375
|
function monitorSignature(c) {
|
|
@@ -683,6 +688,7 @@ async function startLan() {
|
|
|
683
688
|
// 新配对权限档位(电脑侧选定):局域网这条配对入口按它展开权限位。
|
|
684
689
|
pairingTier: config.pairingTier || 'full',
|
|
685
690
|
upstreamPort: config.upstreamPort,
|
|
691
|
+
upstreamHost: config.upstreamHost || '127.0.0.1',
|
|
686
692
|
readSnapshot: snapshotRead,
|
|
687
693
|
onLog: (...args) => process.stderr.write(`[dsh-ai-hub sidecar] ${args.join(' ')}\n`),
|
|
688
694
|
// 配对成功之后换码 + 换票据:走宿主的控制面(那是唯一能写状态文件的地方)。
|
|
@@ -726,13 +732,14 @@ async function configure(next) {
|
|
|
726
732
|
// `relayUrls` 在白名单里,而且从这一轮起**进签名**(见 tunnelSignature):地址组或它的
|
|
727
733
|
// 顺序变了就要重新择路。白名单缺了它,宿主下发这一格会直接抛 unknown configuration
|
|
728
734
|
// field,整次配置下发失败。
|
|
729
|
-
const allowed = ['enabled', 'relayUrl', 'relayUrls', 'instanceId', 'pairingCode', 'pairingTicket', 'pairingTier', 'name', 'upstreamPort', 'lanPort', 'lanEnabled', 'lanSecret', 'registerSecret']
|
|
735
|
+
const allowed = ['enabled', 'relayUrl', 'relayUrls', 'instanceId', 'pairingCode', 'pairingTicket', 'pairingTier', 'name', 'upstreamPort', 'upstreamHost', 'lanPort', 'lanEnabled', 'lanSecret', 'registerSecret']
|
|
730
736
|
if (Object.keys(next).some(key => !allowed.includes(key))) throw new Error('unknown configuration field')
|
|
731
737
|
if (typeof next.instanceId !== 'string' || next.instanceId.length > 128) throw new Error('invalid instanceId')
|
|
732
738
|
if (typeof next.pairingCode !== 'string' || !/^\d{6}$/.test(next.pairingCode)) throw new Error('invalid pairingCode')
|
|
733
739
|
if (next.pairingTicket !== undefined && (typeof next.pairingTicket !== 'string' || !/^[A-Za-z0-9_-]{0,64}$/.test(next.pairingTicket))) throw new Error('invalid pairingTicket')
|
|
734
740
|
if (next.pairingTier !== undefined && !['readonly', 'approve', 'full'].includes(next.pairingTier)) throw new Error('invalid pairingTier')
|
|
735
741
|
if (typeof next.upstreamPort !== 'number' || !Number.isInteger(next.upstreamPort) || next.upstreamPort < 1 || next.upstreamPort > 65535) throw new Error('invalid upstreamPort')
|
|
742
|
+
if (next.upstreamHost !== undefined && (typeof next.upstreamHost !== 'string' || !next.upstreamHost || next.upstreamHost.length > 64)) throw new Error('invalid upstreamHost')
|
|
736
743
|
if (next.lanPort !== undefined && (!Number.isInteger(next.lanPort) || next.lanPort < 1024 || next.lanPort > 65535)) throw new Error('invalid lanPort')
|
|
737
744
|
if (next.registerSecret !== undefined && (typeof next.registerSecret !== 'string' || next.registerSecret.length > 512)) throw new Error('invalid registerSecret')
|
|
738
745
|
// 只重建真正变了的那一半:
|
package/lib/tailcat/wiring.cjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
// 隧道始终走独立的带来源标记入口,不依赖局域网监听。
|
|
3
|
+
// 落点代理转给宿主时跟随宿主实际绑定地址(见 relay/tunnel-forwarder.cjs)。
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 把直连隧道挂进装配层:回环入口 + 落点代理 + 助手会话 + 一条自己的启停 effect。
|
|
@@ -27,6 +28,7 @@ const { createTunnelForwarder } = require('../relay/tunnel-forwarder.cjs');
|
|
|
27
28
|
* @param {() => boolean} options.lanEnabled 局域网直连开着没有
|
|
28
29
|
* @param {() => number} options.lanPort 当前局域网端口(会漂)
|
|
29
30
|
* @param {() => number} options.webPort 宿主 web 端口(落点代理最终转给它)
|
|
31
|
+
* @param {() => string} [options.webHost] 宿主 web 绑定地址(落点代理转给它;缺省回环)
|
|
30
32
|
* @param {() => string} options.hostName 电脑名
|
|
31
33
|
* @param {object} options.ctx 插件 ctx(只为 `ctx.effect`)
|
|
32
34
|
* @param {string} options.name 插件名,用于 effect 标签
|
|
@@ -38,10 +40,10 @@ function chooseTailcatTarget({ tunnelPort }) {
|
|
|
38
40
|
}
|
|
39
41
|
|
|
40
42
|
function mountTailcat(options) {
|
|
41
|
-
const { mount, warn, state, saveState, lanEnabled, lanPort, webPort, hostName, ctx, name } = options;
|
|
43
|
+
const { mount, warn, state, saveState, lanEnabled, lanPort, webPort, webHost, hostName, ctx, name } = options;
|
|
42
44
|
// 落点代理与入口各是一条回环监听,都得活着;任何一个起不来就只是这块不可用(`mount` 兜住)。
|
|
43
45
|
const forwarder = mount('隧道落点代理', () =>
|
|
44
|
-
createTunnelForwarder({ upstreamPort: webPort, log: message => warn(message) }),
|
|
46
|
+
createTunnelForwarder({ upstreamPort: webPort, upstreamHost: webHost, log: message => warn(message) }),
|
|
45
47
|
);
|
|
46
48
|
// 与入口一起先把端口开出来:第一条连接进来时(可能比 effect 跑得还早)落点就得有值。
|
|
47
49
|
if (forwarder) void forwarder.start();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-mobile-plugin",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.78",
|
|
4
4
|
"description": "Mobile API (/api/mobile/v1) and relay client for the DSH mobile app — desktop profile build (dsh 0.2.x, peers resolved by the host)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"icon": "./icon.png",
|