dsh-mobile-plugin 0.5.80 → 0.5.81
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/docs/extension-authoring.md +32 -0
- package/lib/impl.js +14 -2
- package/lib/mobile/auth.js +20 -5
- package/lib/mobile/claim-identity.js +116 -0
- package/lib/mobile/permissions.js +2 -0
- package/lib/panel/index.html +1 -1
- package/lib/relay/control.js +40 -4
- package/lib/relay/core.js +25 -1
- package/lib/relay/identity-rotate.cjs +27 -0
- package/lib/relay/lan-proxy.js +27 -5
- package/lib/routes/mobile-api.js +11 -0
- package/lib/shell/transport-host.js +6 -0
- package/lib/sidecar-facade-worker.cjs +20 -6
- package/package.json +1 -1
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=Ck.reduce((t,n)=>(t[n]=e.validity[n],t),{}),n=!1;for(let e of Ck)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?Tk(b,t.current):v.current}let D=E();function O(){return D=E(),D?.willValidate?T(D):Ek(!1)}if(o){if(l.valid!==!1||!D)return;if(!D.validity.valueMissing){C();let e=E(),t=e?.validity.customError?Dk(e):[];w(Ek(t.length>0),t,!1);return}for(let e of Ck)if(e!==`valid`&&e!==`valueMissing`&&e!==`customError`&&D.validity[e])return}_.clear(),C();let k=O(),A=Dk(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=Dk(D)}w(k,A)}),E=J((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={})=>Dr(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 kk=g.createContext(void 0);function Ak(e=!1){let t=g.useContext(kk);if(!t&&!e)throw Error(S(86));return t}var jk=[Zd],Mk=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}=RD(),{labelId:D}=UD(),{clearErrors:O,elementRef:k}=VD(),A=Ak(!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=J((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=J(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=J(()=>{let e=k.current;if(!e)return P??null;for(let t of C.registeredInputs.keys())if(t.checked&&wk(t,e))return P??null;return null});zD(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]),ne={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){Y(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)(ak.Provider,{value:q,children:(0,G.jsx)(xk,{render:n,className:r,style:m,state:te,props:[ne,h,e=>C.getValidationProps(j??!1,e)],refs:[t],stateAttributesMapping:MD,enableHomeAndEndKeys:!1,modifierKeys:jk})})});function Nk({className:e,orientation:t=`vertical`,...n}){return(0,G.jsx)(Mk,{"data-slot":`radio-group`,"aria-orientation":t,className:Z(`flex`,t===`horizontal`?`flex-wrap gap-4`:`flex-col gap-2`,e),...n})}function Pk(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 Fk=3e4,Ik=1e3;function Lk(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-Fk,Ik)}var Rk=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 zk(e){let t=null;try{t=await e.json()}catch{t=null}let n=t?.error;if(typeof n==`string`&&n)return new Rk(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 Rk(typeof t.message==`string`&&t.message?t.message:$(`panel.net.requestFailed`,{status:e.status}),r,e.status)}return new Rk($(`panel.net.requestFailed`,{status:e.status}),`http_${e.status}`,e.status)}async function Bk(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 zk(n);let i=await n.json();if(t&&(i?.ok!==!0||typeof i.svg!=`string`||!i.svg.includes(`<svg`)))throw new Rk($(`panel.pairing.qrFailed`),`pairing_invalid`,n.status);return i}catch(e){throw r?.signal.aborted?new Rk($(t?`panel.console.pairingTimeout`:`panel.console.statusTimeout`),t?`pairing_timeout`:`status_timeout`,0):e}finally{i!==null&&window.clearTimeout(i)}}async function Vk(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 zk(n);let r=await n.json();return Hk(r),r}function Hk(e){let t=e?.applyError;if(typeof t==`string`&&t)throw new Rk($(`panel.shell.applyFailed`,{message:t}),`apply_failed`,200)}function Uk(e){return Vk(`/api/relay/frp/import`,{config:e})}function Wk(e,t){return Vk(`/api/relay/devices/permissions`,{deviceId:e,tier:t})}function Gk(e){return e instanceof Rk?e.message:e instanceof Error?e.message||$(`panel.net.requestFailedNoStatus`):String(e)}function Kk(e){let t=g.useRef(!0);t.current&&(t.current=!1,e())}var qk=g.createContext(void 0),Jk=g.createContext(void 0),Yk=g.createContext(void 0);function Xk(){let e=g.useContext(qk);if(e===void 0)throw Error(S(60));return e}function Zk(){let e=g.useContext(Jk);if(e===void 0)throw Error(S(101));return e}function Qk(){let e=g.useContext(Yk);if(e===void 0)throw Error(S(61));return e}function $k(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 eA=(e,t)=>Object.is(e,t);function tA(e,t,n){return e==null||t==null?Object.is(e,t):n(e,t)}function nA(e,t,n){return Array.isArray(e)&&Array.isArray(t)?!$k(e,t,(e,t)=>tA(e,t,n)):e!==t}function rA(e,t,n){return e?e.some(e=>e!==void 0&&tA(t,e,n)):!1}function iA(e,t,n){return e?e.findIndex(e=>e!==void 0&&tA(e,t,n)):-1}function aA(e,t){if(t!==eA)return n=>rA(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 oA(e,t,n,r){let i=r&&Array.isArray(t)?e.findIndex(aA(t,n)):iA(e,t,n);return i===-1?null:i}function sA(e,t,n,r,i,a){return rA(r,t,i)?a!=null&&e>a&&rA(r,n[a],i)?a:e:e===a?oA(n,r,i,!0):a}function cA(e,t,n){return e.filter(e=>!tA(t,e,n))}function lA(e){return typeof e==`object`&&!!e&&Array.isArray(e.items)}function uA(e){return lA(e?.[0])}function dA(e){return uA(e)?e.flatMap(e=>e.items):e}function fA(e){if(!Array.isArray(e))return e!=null&&`null`in e;let t=e;if(uA(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 pA(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 sk(e)}function mA(e,t){return t&&e!=null?t(e)??``:e&&typeof e==`object`&&`value`in e&&`label`in e?sk(e.value):sk(e)}function hA(e,t,n){function r(){return pA(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=dA(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 gA(e,t,n){return e.reduce((e,r,i)=>(i>0&&e.push(`, `),e.push((0,G.jsx)(g.Fragment,{children:hA(r,t,n)},i)),e),[])}var _A={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:mA(t,r)!==``},hasNullItemLabel:(e,t)=>t?fA(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=>tA(t,e,n)):tA(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 vA(e,t){return Math.max(0,e-t)}function yA(e,t){if(t<=0)return 0;let n=mi(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 bA(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=eA,highlightItemOnHover:k=!0,children:A}=e,{clearErrors:j}=VD(),{setDirty:M,setTouched:N,setFocused:P,validityData:F,setFilled:I,name:L,disabled:R,validation:z,validationMode:B}=RD(),V=qD({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([]),ne=g.useRef([]),re=g.useRef(null),ie=g.useRef(null),ae=g.useRef(0),oe=g.useRef(null),se=g.useRef([]),le=g.useRef(!1),ue=g.useRef(null),de=g.useRef(null),fe=g.useRef({allowSelectedMouseUp:!1,allowUnselectedMouseUp:!1,dragY:0}),pe=g.useRef(!1),me=g.useRef(W),{mounted:he,setMounted:ge,transitionStatus:_e}=Us(K),{openMethod:ve,triggerProps:ye}=Xf(K),be=y(()=>new ce({id:V,labelId:void 0,modal:v,multiple:T,itemToStringLabel:E,itemToStringValue:D,isItemEqualToValue:O,value:W,open:K,mounted:he,transitionStatus:_e,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:re,scrollHandlerRef:ie,scrollArrowsMountedCountRef:ae,valueRef:oe,valuesRef:se,labelsRef:ne,typingRef:le,selectionRef:fe,firstItemTextRef:ue,selectedItemTextRef:de,alignItemWithTriggerActiveRef:pe,initialValueRef:me},_A)).current,xe=be.useState(`activeIndex`),Se=be.useState(`selectedIndex`),Ce=be.useState(`triggerElement`),we=be.useState(`positionerElement`),Te=ph(ve),Ee=ve??Te,De=g.useMemo(()=>T?``:mA(W,D),[T,W,D]),Oe=g.useMemo(()=>T&&Array.isArray(W)?W.map(e=>mA(e,D)):mA(W,D),[T,W,D]);zD(Ba(Ce),V,W,J(()=>Oe),!H,c);let ke=T?Array.isArray(W)&&W.length>0:W!=null&&De!==``;b(()=>{I(ke)},[ke,I]),b(function(){let e=oA(se.current,W,O,T);e===null&&(de.current=null),!K&&be.set(`selectedIndex`,e)},[T,K,W,O,be]),Jf(W,()=>{j(U),M(nA(W,F.initialValue,O)),z.change(W)});let Ae=J((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)))}),je=J(()=>{ge(!1),be.update({activeIndex:null,openMethod:null,scrollUpArrowVisible:!1,scrollDownArrowVisible:!1}),C?.(!1)});ii({enabled:!x,open:K,ref:re,onComplete(){K||je()}}),g.useImperativeHandle(x,()=>({unmount:je}),[je]);let Me=J((e,t)=>{i?.(e,t),!t.isCanceled&&ee(e)}),Ne=J(e=>{let t=vA(e.scrollHeight,e.clientHeight),n=yA(e.scrollTop,t),r=n>0,i=n<t;be.set(`scrollUpArrowVisible`,r),be.set(`scrollDownArrowVisible`,i)}),Pe=pc({open:K,onOpenChange:Ae,elements:{reference:Ce,floating:we}}),Fe=ko(Pe,{enabled:!H,event:`mousedown`}),Ie=Fo(Pe),Le=Nc(Pe,{enabled:!H,listRef:q,activeIndex:xe,selectedIndex:Se,disabledIndices:m,onNavigate(e){(e!==null||K)&&be.set(`activeIndex`,e)},focusItemOnHover:k}),Re=Pc(Pe,{enabled:!H&&(K||!f&&!T),listRef:ne,activeIndex:xe,selectedIndex:Se,disabledIndices:e=>hh(q.current[e]),onMatch(e){K?be.set(`activeIndex`,e):Me(se.current[e],ja(ma))},onTyping(e){le.current=e}}),ze=g.useMemo(()=>Dr(Re.reference,Le.reference,Ie.reference,Fe.reference,ye),[Fe.reference,Re.reference,Le.reference,Ie.reference,ye]),Be=g.useMemo(()=>Dr(Ws,Re.floating,Le.floating,Ie.floating),[Re.floating,Le.floating,Ie.floating]),Ve=Le.item??h;be.useContextCallback(`setValue`,Me),be.useContextCallback(`setOpen`,Ae),be.useContextCallback(`handleScrollArrowVisibility`,Ne),be.useContextCallback(`onOpenChangeComplete`,C),Kk(()=>{be.update({popupProps:Be,triggerProps:ze})}),be.useSyncedValues({id:V,modal:v,multiple:T,value:W,open:K,mounted:he,transitionStatus:_e,popupProps:Be,triggerProps:ze,items:w,itemToStringLabel:E,itemToStringValue:D,isItemEqualToValue:O,openMethod:Ee});let He=g.useMemo(()=>({disabled:H,readOnly:f,required:_,multiple:T,highlightItemOnHover:k,itemProps:Ve}),[H,f,_,T,k,Ve]),Ue=hr(S,z.inputRef),We=T?void 0:U,Ge=g.useMemo(()=>!T||!Array.isArray(W)||!U?null:W.map(e=>{let t=mA(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)(qk.Provider,{value:be,children:[(0,G.jsx)(Jk.Provider,{value:He,children:(0,G.jsx)(Yk.Provider,{value:Pe,children:A})}),(0,G.jsx)(`input`,{...z.getValidationProps(H,{onFocus(){be.state.triggerElement?.focus({focusVisible:!0})},onChange(e){if(e.nativeEvent.defaultPrevented||H||f)return;let t=e.currentTarget.value,n=ja(ma,e.nativeEvent);function r(){if(T)return;let e=t.toLowerCase(),r=se.current.findIndex(t=>mA(t,D).toLowerCase()===e||pA(t,E).toLowerCase()===e);r===-1&&(r=se.current.findIndex((t,n)=>{let r=ne.current[n];return r!=null&&r.toLowerCase()===e}));let i=se.current[r];i!=null&&Me(i,n)}be.set(`forceMount`,!0),queueMicrotask(r)}}),id:V&&We==null?`${V}-hidden-input`:void 0,form:l,name:We,autoComplete:u,value:De,disabled:H,required:_&&!(T&&ke),readOnly:f,ref:Ue,style:U?pr:fr,tabIndex:-1,"aria-hidden":!0,suppressHydrationWarning:!0}),Ge]})}function xA(e,t){let n=Pd(e);return b(()=>(t(n),()=>{t(e=>e===n?void 0:e)}),[n,t]),n}function SA(e={}){let{id:t,fallbackControlId:n,native:r=!1,setLabelId:i,focusControl:a}=e,{controlId:o,setLabelId:s}=UD(),c=xA(t,J(e=>{s(e),i?.(e)})),l=o??n;function u(e){if(a){a(e,l);return}if(!l)return;let t=Le(e.currentTarget).getElementById(l);_e(t)&&CA(t)}function d(e){ut(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 CA(e){e.focus({focusVisible:!0})}function wA(e,t){return e??t}var TA=`data-popup-side`,EA=400,DA={...Nt,...MD,popupSide:e=>e?{[TA]:e}:null,value:()=>null},OA=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}=RD(),{labelId:h}=UD(),_=Xk(),{readOnly:v,required:y,disabled:b}=Zk(),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=wA(h,A);qD({id:i});let F=Ba(E),I=g.useRef(null),{getButtonProps:L,buttonRef:R}=la({disabled:x,native:o}),z=_.useStateSetter(`triggerElement`),B=Ge(),V=Ge(),H=Ge();g.useEffect(()=>{if(S)return H.start(EA,()=>{_.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=Dr(T,{id:N,role:`combobox`,"aria-expanded":S,"aria-haspopup":`listbox`,"aria-controls":S?D?.id??Wt(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,ja(ma,e.nativeEvent)),B.start(0,()=>{_.set(`forceMount`,!0)})},onBlur(e){Y(E,e.relatedTarget)||(l(!0),u(!1),d===`onBlur`&&f.commit(w))},onMouseDown(e){if(S)return;let t=Le(e.currentTarget);function n(e){if(!I.current)return;let t=e.target;Y(I.current,t)||Y(F.current,t)||rh(e,I.current)||_.context.setOpen(!1,ja(Ta,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 Vr(`button`,e,{ref:[t,I,R,z],state:G,stateAttributesMapping:DA,props:W})}),kA={value:()=>null},AA=g.forwardRef(function(e,t){let{className:n,render:r,children:i,placeholder:a,style:o,...s}=e,c=Xk(),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)?gA(l,u,d):hA(l,u,d)),Vr(`span`,e,{state:h,ref:[t,c.context.valueRef],props:[{children:g},s],stateAttributesMapping:kA})}),jA=g.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e;return Vr(`span`,e,{state:{open:Xk().useState(`open`)},ref:t,props:[{"aria-hidden":!0,children:`▼`},a],stateAttributesMapping:Mt})}),MA=g.forwardRef(function(e,t){let n=Xk(),r=n.useState(`mounted`),i=n.useState(`forceMount`);return r||i?(0,G.jsx)(La,{ref:t,...e}):null}),NA=g.createContext(void 0);function PA(){let e=g.useContext(NA);if(!e)throw Error(S(59));return e}function FA(e,t){e&&Object.assign(e.style,t)}var IA={position:`relative`,maxHeight:`100%`,overflowX:`hidden`,overflowY:`auto`},LA={position:`fixed`},RA=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:_=di,style:v,...y}=e,x=Xk(),S=Qk(),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),Lm((I||T)&&C,D===`touch`,O,k);let L=il({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?LA:L.positionerStyles,B={open:C,side:R,align:L.align,anchorHidden:L.anchorHidden};b(()=>{x.set(`popupSide`,L.side)},[x,L.side]);let V=cl(e,B,{styles:z,transitionStatus:j,props:y,refs:[t,x.useStateSetter(`positionerElement`)],hidden:!w,inert:!C}),H=g.useRef(0),U=J(e=>{if(x.context.valuesRef.current.length===0)return;let t=H.current;H.current=e.size;let n=ja(ma);if(t!==0&&!x.state.multiple&&E!==null&&iA(x.context.valuesRef.current,E,A)===-1){let e=x.context.initialValueRef.current,t=e!=null&&iA(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=>iA(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:``};FA(O,e),FA(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)(km,{elementsRef:x.context.listRef,labelsRef:x.context.labelsRef,onMapChange:U,children:(0,G.jsxs)(NA.Provider,{value:W,children:[w&&T&&(0,G.jsx)(_f,{inert:Xr(!C),cutout:k}),V]})})}),zA=`base-ui-disable-scrollbar`,BA={className:zA,getElement(e){return(0,G.jsx)(`style`,{nonce:e,href:zA,precedence:`base-ui:low`,children:`.${zA}{scrollbar-width:none}.${zA}::-webkit-scrollbar{display:none}`})}},VA=g.createContext(void 0),HA={disableStyleElements:!1};function UA(){return g.useContext(VA)??HA}var WA=`--transform-origin`,GA={...Pt,...xt},KA=g.forwardRef(function(e,t){let{render:n,className:r,style:i,finalFocus:a,...o}=e,s=Xk(),{multiple:c,readOnly:l,highlightItemOnHover:u}=Zk(),d=Qk(),{side:f,align:p,alignItemWithTriggerActive:m,isPositioned:h,setControlledAlignItemWithTrigger:_}=PA(),v=wm(!0)!=null,y=Wc(),{nonce:x,disableStyleElements:S}=UA(),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=He(),I=J(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=YA(A),i=XA(A.getBoundingClientRect().height,`y`,r),a=Le(A),o=pe(A),c=o.getComputedStyle(A),l=parseFloat(c.marginTop),u=parseFloat(c.marginBottom),d=qA(o.getComputedStyle(s.context.popupRef.current)),f=Math.min(a.documentElement.clientHeight-l-u,d),p=e.scrollTop,h=JA(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=mi(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=mi(g,0,JA(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]),ii({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,FA(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(WA),!m){F.request(()=>s.context.handleScrollArrowVisibility(j||e));return}let t=$A(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=pe(A),i=r.getComputedStyle(A),a=r.getComputedStyle(e),o=Le(k),c=YA(k),l=ZA(k.getBoundingClientRect(),c),d=ZA(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=qA(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=ZA(n.getBoundingClientRect(),c);T=ZA(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=`${mi(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=JA(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&&ot;if(B||V){FA(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=JA(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=mi(n>0?(r-t)/n*100:50,0,100);e.style.setProperty(WA,`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=pe(A);function t(e){s.context.setOpen(!1,ja(Aa,e))}return Re(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%`}:IA},className:!j&&m?BA.className:void 0},z=Vr(`div`,e,{ref:[t,s.context.popupRef],state:L,stateAttributesMapping:GA,props:[D,R,sl(O),o]});return(0,G.jsxs)(g.Fragment,{children:[!S&&BA.getElement(x),(0,G.jsx)(Oo,{context:d,modal:!1,disabled:!E,openInteractionType:T,returnFocus:a,restoreFocus:!0,children:z})]})});function qA(e){let t=e.maxHeight;return t.endsWith(`px`)&&parseFloat(t)||1/0}function JA(e){return vA(e.scrollHeight,e.clientHeight)}function YA(e){return vs.getScale(e)}function XA(e,t,n){return e/n[t]}function ZA(e,t){return En({x:XA(e.x,`x`,t),y:XA(e.y,`y`,t),width:XA(e.width,`x`,t),height:XA(e.height,`y`,t)})}var QA=[[`transform`,`none`],[`scale`,`1`],[`translate`,`0 0`]];function $A(e){let{style:t}=e,n={};for(let[e,r]of QA)n[e]=t.getPropertyValue(e),t.setProperty(e,r,`important`);return()=>{for(let[e]of QA){let r=n[e];r?t.setProperty(e,r):t.removeProperty(e)}}}var ej=g.forwardRef(function(e,t){let{render:n,className:r,style:i,...a}=e,o=Xk(),{multiple:s,readOnly:c}=Zk(),{alignItemWithTriggerActive:l}=PA(),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:IA},className:u&&d!==`touch`?BA.className:void 0};return Vr(`div`,e,{ref:[t,o.useStateSetter(`listElement`)],props:[f,a]})}),tj=g.createContext(void 0);function nj(){let e=g.useContext(tj);if(!e)throw Error(S(57));return e}var rj=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=Xk(),{itemProps:p,multiple:m,disabled:h,readOnly:_}=Zk(),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=sA(T,a,f.context.valuesRef.current,e,w,t),r=n===T,T===t&&!r&&(f.context.selectedItemTextRef.current=null)):(r=e!==void 0&&tA(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}=la({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?cA(n,a,w):[...n,a];f.context.setValue(r,ja(ya,e))}else f.context.setValue(a,ja(ya,e)),f.context.setOpen(!1,ja(ya,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&&Yt(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=Vr(`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)(tj.Provider,{value:I,children:F})})),ij=g.forwardRef(function(e,t){let{selected:n}=nj();return e.keepMounted||n?(0,G.jsx)(aj,{...e,ref:t}):null}),aj=g.memo(g.forwardRef((e,t)=>{let{render:n,className:r,style:i,keepMounted:a,...o}=e,{selected:s}=nj(),c=g.useRef(null),{transitionStatus:l,setMounted:u}=Us(s),d=Vr(`span`,e,{ref:[t,c],state:{selected:s,transitionStatus:l},props:[{"aria-hidden":!0,children:`✔️`},o],stateAttributesMapping:xt});return ii({batch:!0,enabled:!s,open:s,ref:c,onComplete(){s||u(!1)}}),d})),oj=g.memo(g.forwardRef(function(e,t){let{index:n,textRef:r,selectedByFocus:i}=nj(),a=Xk(),{render:o,className:s,style:c,...l}=e;return Vr(`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})})),sj=g.forwardRef(function(e,t){let{render:n,className:r,style:i,direction:a,keepMounted:o,...s}=e,c=a===`up`,l=Xk(),{side:u,scrollDownArrowRef:d,scrollUpArrowRef:f}=PA(),p=c?`scrollUpArrowVisible`:`scrollDownArrowVisible`,m=l.useState(p),h=l.useState(`openMethod`),g=m&&h!==`touch`,_=Ge(),v=c?f:d,{mounted:y,transitionStatus:x,setMounted:S}=Us(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]),ii({open:g,ref:v,onComplete(){g||S(!1)}});let C=Vr(`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=vA(e.scrollHeight,e.clientHeight),r=yA(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=cj(a,c,r,e.clientHeight,t,n)}_.start(40,t)}_.start(40,t)},onMouseLeave(){_.clear()}},s],stateAttributesMapping:xt});return y||o?C:null});function cj(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?yA(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?yA(l.offsetTop+l.offsetHeight-r+i,a):a}var lj=g.forwardRef(function(e,t){return(0,G.jsx)(sj,{...e,ref:t,direction:`down`})}),uj=g.forwardRef(function(e,t){return(0,G.jsx)(sj,{...e,ref:t,direction:`up`})}),dj=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`}}),fj=g.createContext(null);function pj(){let e=g.useContext(fj);if(!e)throw Error(`Select sub-components must be rendered inside <Select>`);return e}function mj({size:e=`md`,variant:t=`outline`,alignItemWithTrigger:n=!0,value:r,defaultValue:i,onValueChange:a,multiple:o=!1,children:s,...c}){let l=bh(),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)(fj.Provider,{value:v,children:(0,G.jsx)(bA,{value:p,onValueChange:h,multiple:o,...c,children:s})})}var hj={sm:`size-4`,md:`size-4.5`,lg:`size-5`};function gj({className:e,clearable:t,startSlot:n,endSlot:r,children:i,onKeyDown:a,...o}){let{size:s,variant:c,alignItemWithTrigger:l,hasValue:u,clear:d}=pj(),f=hj[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)(OA,{"data-slot":`select-trigger`,className:Z(dj({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)(kj,{className:`size-[1em]`})}):null,r&&(0,G.jsx)(`span`,{"data-slot":`select-trigger-end`,className:`shrink-0`,children:r}),(0,G.jsx)(jA,{"data-slot":`select-icon`,className:`text-foreground -me-1 shrink-0`,render:l?(0,G.jsx)(Dj,{className:f}):(0,G.jsx)(Ej,{className:Z(f,`motion-safe:transition-transform motion-safe:duration-200`,`data-popup-open:rotate-180`)})})]})}function _j({className:e,...t}){return(0,G.jsx)(AA,{"data-slot":`select-value`,className:Z(`min-w-0 flex-1 truncate text-start`,e),...t})}var vj={sm:`rounded-md`,md:`rounded-lg`,lg:`rounded-xl`};function yj({className:e,alignItemWithTrigger:t,children:n,...r}){let{size:i,alignItemWithTrigger:a}=pj(),o=t??a,{positioner:s,portal:c,popup:l}=Ch(r);return(0,G.jsx)(MA,{...c,children:(0,G.jsx)(RA,{sideOffset:6,...s,alignItemWithTrigger:o,className:Z(`isolate z-50`,s.className),children:(0,G.jsxs)(KA,{"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`,vj[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)(xj,{}),(0,G.jsx)(ej,{className:`flex max-h-(--available-height) flex-col gap-0.5 overflow-y-auto p-2`,children:n}),(0,G.jsx)(Sj,{})]})})})}var bj=Z(`bg-background text-foreground z-1 flex h-6 w-[calc(100%-var(--border-width)*2)] cursor-default items-center justify-center`);function xj(){let{size:e}=pj();return(0,G.jsx)(uj,{"data-slot":`select-scroll-up`,"aria-hidden":`true`,className:Z(bj,vj[e],`top-px rounded-b-none`),children:(0,G.jsx)(Ej,{className:Z(hj[e],`rotate-180`)})})}function Sj(){let{size:e}=pj();return(0,G.jsx)(lj,{"data-slot":`select-scroll-down`,"aria-hidden":`true`,className:Z(bj,vj[e],`bottom-px rounded-t-none`),children:(0,G.jsx)(Ej,{className:hj[e]})})}var Cj={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]`},wj={sm:`gap-1`,md:`gap-1.5`,lg:`gap-1.5`};function Tj({className:e,children:t,...n}){let{size:r,reducedMotion:i}=pj();return(0,G.jsxs)(rj,{"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`,Cj[r],e),...n,children:[(0,G.jsx)(oj,{className:Z(`flex items-center text-start`,wj[r]),children:t}),(0,G.jsx)(ij,{"data-slot":`select-item-indicator`,keepMounted:!i,className:`group/check text-foreground-intense shrink-0`,children:(0,G.jsx)(Oj,{"data-icon":`end`,className:`me-0.5 size-[1.125em]`})})]})}function Ej(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 Dj(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 Oj({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 kj(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 Aj(e){return e?e.lan.length>0?e.lan:e.public:[]}function jj(e){return!e||e.lan.length===0?[]:e.public}function Mj(e){return e?.ipv6??[]}function Nj(e,t){let n=$(e===`lan`?`panel.address.lan`:e===`ipv6`?`panel.address.ipv6`:`panel.address.public`);return t?`${n} · ${t}`:n}function Pj(e,t){return`http://${e.includes(`:`)?`[${e}]`:e}:${String(t??``)}`}function Fj({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=Aj(e),f=jj(e),p=Mj(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:Pj(e.address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-subtle`,children:`${Nj(`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)(Nk,{className:hg(`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)(_k,{value:e.address,"aria-label":Pj(e.address,u)}),(0,G.jsx)(`span`,{className:`font-mono text-xs text-foreground`,children:Pj(e.address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-muted`,children:Nj(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:Pj(d[0].address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-muted`,children:Nj(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:Pj(e.address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-subtle`,children:`${Nj(`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:Pj(e.address,u)}),(0,G.jsx)(`span`,{className:`shrink-0 font-sans text-xs text-foreground-subtle`,children:$(`panel.address.ipv6Pick`,{kind:Nj(`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 Ij=`data:image/png;base64,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`,Lj=`https://github.com/WNLUO/dsh-mobile-server`,Rj=`https://github.com/WNLUO/dsh-mobile-plugin`,zj=[{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`}]}],Bj=[{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`}];Bj[0].url;function Vj(e){let t=e=>e.trim().replace(/\/+$/,``),n=t(e);return!!n&&Bj.some(e=>t(e.url)===n)}function Hj(e){return e.name===`GitHub`?(0,G.jsx)(Yj,{}):e.name===`App Store`||e.name===`TestFlight`?(0,G.jsx)(Jj,{}):(0,G.jsx)(Xj,{})}function Uj(e){return e===`android`?(0,G.jsx)(qj,{}):(0,G.jsx)(Jj,{})}function Wj({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:Hj(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 Gj(){return(0,G.jsx)(`div`,{className:`grid grid-cols-1 gap-4 sm:grid-cols-2`,children:zj.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:[Uj(e.platform),(0,G.jsx)(`span`,{children:$(e.platform===`android`?`panel.links.android`:`panel.links.apple`)})]}),e.channels.map(e=>(0,G.jsx)(Wj,{channel:e},e.url))]},e.platform))})}function Kj({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)(uD,{open:r,onOpenChange:i,children:(0,G.jsxs)(dD,{className:`max-w-xl`,closeLabel:$(`panel.common.close`),initialFocus:a,children:[(0,G.jsx)(fD,{children:(0,G.jsxs)(pD,{className:`flex flex-wrap items-center gap-2.5 pr-8`,children:[(0,G.jsx)(`img`,{src:Ij,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)(hD,{children:(0,G.jsx)(Gj,{})})})]})})]})}function qj(){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 Jj(){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 Yj(){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 Xj(){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 Zj({className:e}){return(0,G.jsxs)(`svg`,{viewBox:`0 0 16 16`,className:e??`size-3.5`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.3`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,G.jsx)(`circle`,{cx:`8`,cy:`8`,r:`6.2`}),(0,G.jsx)(`path`,{d:`M8 4.8v4.4`}),(0,G.jsx)(`path`,{d:`M8 11.4h.01`})]})}function Qj({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 $j(){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 eM({status:e,pairing:t,addressBook:n,busy:r,error:i,restartError:a,onOpenConfig:o,onChangePolicy:s,onChangeTier:c,onChangeAutoReview:l,onChangeControlReport:u,onOpenSelfCheck:d,onRetryPairing:f,onSavePreferred:p,onEditPort:m,fill:h}){let _=r!==``,v=e.pairingPolicy===`code`,y=e.pairingTier??`full`,b=e.approvalAutoReview===!0,x=e.controlReportEnabled!==!1,S=t?.relayUrl||e.relayUrl||`—`,C=tM(n,t),[w,T]=g.useState({relay:!1}),[E,D]=g.useState(!1),[O,k]=g.useState(!1),[A,j]=g.useState(!1),[M,N]=g.useState(!1),P=e=>T(t=>({...t,[e]:!t[e]}));return(0,G.jsxs)(CD,{frame:`solid`,className:h?`flex h-full min-h-0 flex-col`:void 0,children:[(0,G.jsx)(wD,{className:`flex-none px-4 py-3`,children:(0,G.jsxs)(TD,{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:_,onClick:o,children:$(`panel.pairing.openConfig`)}),(0,G.jsx)(Kj,{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:()=>j(!0),children:$(`panel.common.more`)})]})]})}),i?(0,G.jsxs)(ZE,{variant:`warning`,className:`mt-3`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:$(`panel.pairing.qrFailed`)}),(0,G.jsx)(tD,{children:i})]}):null,(0,G.jsxs)(`div`,{className:`mt-3 flex flex-col gap-4 sm:flex-row sm:items-stretch ${h?`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:()=>k(!0),"aria-label":`${$(`panel.pairing.qrZoom`)}:${$(`panel.pairing.qr`)}`,children:[(0,G.jsx)($j,{}),(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:_,onClick:f,children:$(`panel.console.retryPairing`)})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(UE,{}),(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)(kO,{className:`min-w-max`,children:[(0,G.jsx)(OO,{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:[w.relay?(0,G.jsx)(`span`,{className:`min-w-0 font-mono text-xs text-foreground-strong`,children:S}):(0,G.jsx)(`span`,{className:`text-xs text-foreground-subtle`,children:$(`panel.pairing.hidden`)}),(0,G.jsx)(Qj,{on:w.relay,what:$(`panel.connection.relayUrl`),label:w.relay?$(`panel.common.hide`):$(`panel.common.show`),onClick:()=>P(`relay`)})]})}),(0,G.jsx)(OO,{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:_,onClick:m,children:$(`panel.common.edit`)})]})}),(0,G.jsx)(OO,{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:[C?null:(0,G.jsx)(`span`,{className:`text-xs text-foreground-subtle`,children:$(`panel.pairing.noAddress`)}),(0,G.jsx)(Qj,{on:!1,what:$(`panel.pairing.phoneAddress`),label:$(`panel.common.show`),onClick:()=>D(!0)})]})}),(0,G.jsx)(OO,{label:$(`panel.pairing.controlReport`),nowrap:!0,labelExtra:(0,G.jsx)(`button`,{type:`button`,"aria-label":$(`panel.pairing.controlReportInfo`),title:$(`panel.pairing.controlReportInfo`),className:`shrink-0 cursor-pointer rounded text-foreground-muted transition-colors duration-200 hover:text-foreground-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring motion-reduce:transition-none`,onClick:()=>N(!0),children:(0,G.jsx)(Zj,{})}),children:(0,G.jsx)(eO,{size:`sm`,checked:x,disabled:_,"aria-label":$(`panel.pairing.controlReport`),onCheckedChange:e=>{e!==x&&u(e)}})})]})})})]}),a?(0,G.jsxs)(ZE,{variant:`error`,className:`mt-3`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:$(`panel.pairing.sidecarRestartFailed`)}),(0,G.jsx)(tD,{children:a})]}):null,(0,G.jsx)(uD,{open:O,onOpenChange:k,children:(0,G.jsxs)(dD,{className:`w-[min(680px,94vw)] max-h-[90vh] max-w-none`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.pairing.qr`)})}),(0,G.jsx)(hD,{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)(uD,{open:E,onOpenChange:D,children:(0,G.jsxs)(dD,{className:`max-w-xl`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.pairing.phoneAddress`)})}),(0,G.jsx)(hD,{children:(0,G.jsx)(Fj,{book:n,port:t?.lanPort??e.lan.port,value:n?.preferred??``,busy:_,onChange:p,fallbackUrls:t?.lanUrls??[]})}),(0,G.jsx)(gD,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>D(!1),children:$(`panel.common.close`)})})]})}),(0,G.jsx)(uD,{open:M,onOpenChange:N,children:(0,G.jsxs)(dD,{className:`max-w-md`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.pairing.controlReport`)})}),(0,G.jsx)(hD,{className:`whitespace-pre-line text-sm leading-6 text-foreground-muted`,children:$(`panel.pairing.controlReportDetail`)}),(0,G.jsx)(gD,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>N(!1),children:$(`panel.common.close`)})})]})}),(0,G.jsx)(uD,{open:A,onOpenChange:j,children:(0,G.jsxs)(dD,{className:`max-w-md`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.common.more`)})}),(0,G.jsxs)(hD,{className:`flex flex-col gap-3`,children:[(0,G.jsxs)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.pairing.policy`),children:(0,G.jsx)(eO,{size:`md`,checked:v,disabled:_,onCheckedChange:e=>s(e?`code`:`deny`),"aria-label":$(`panel.devices.allowTitle`)})}),(0,G.jsx)(OO,{label:$(`panel.pairing.tier`),hint:$(`panel.pairing.tierHint`),children:(0,G.jsxs)(mj,{size:`sm`,value:y,disabled:_,itemToStringLabel:e=>rM(e),onValueChange:e=>{typeof e==`string`&&e!==y&&c(e)},children:[(0,G.jsx)(gj,{className:`min-w-0 max-w-full`,"aria-label":$(`panel.pairing.tier`),children:(0,G.jsx)(_j,{})}),(0,G.jsx)(yj,{children:nM.map(e=>(0,G.jsx)(Tj,{value:e,children:rM(e)},e))})]})}),(0,G.jsx)(OO,{label:$(`panel.pairing.autoReview`),hint:$(`panel.pairing.autoReviewHint`),children:(0,G.jsx)(eO,{size:`sm`,checked:b,disabled:_,"aria-label":$(`panel.pairing.autoReview`),onCheckedChange:e=>{e!==b&&l(e)}})})]}),(0,G.jsx)(`div`,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`outline`,size:`sm`,onClick:d,children:$(`panel.pairing.checkNetwork`)})})]})]})})]})}function tM(e,t){return e&&e.lan.length+e.public.length>0?`book`:t?.lanUrls?.[0]??``}var nM=[`readonly`,`approve`,`full`];function rM(e){return $(e===`readonly`?`panel.pairing.tierReadonly`:e===`approve`?`panel.pairing.tierApprove`:`panel.pairing.tierFull`)}var iM={ok:4e3,soft:6e3,error:9e3};function aM(){let e=(0,g.useRef)(fd());return e.current=fd(),(0,g.useCallback)((t,n)=>{e.current.add({title:n,type:t,timeout:iM[t],priority:t===`error`?`high`:`low`})},[])}function oM(e){return e===`none`?$(`panel.devices.tierNone`):rM(e)}function sM(e){return e===`none`?`readonly`:e}function cM(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 lM(e,t){return e?uM(e,t)?$(`panel.devices.online`):cM(e,t):$(`panel.devices.noRecord`)}function uM(e,t){return e>0&&t-e<=3e5}function dM(e){return{ios:`iOS`,android:`Android`,linux:`Linux`,darwin:`macOS`,win32:`Windows`}[e]??(e||$(`panel.devices.unknownPlatform`))}function fM(e){return $(e===`relay`?`panel.devices.channelRelay`:e===`lan`?`panel.devices.channelLan`:`panel.devices.channelUnknown`)}function pM(e){let t=e?.model||e?.name||$(`panel.devices.unknown`);return e?.suffix?`${t} · ${e.suffix}`:t}function mM(){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 hM(){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 gM({onRevokeAll:e,busy:t,fill:n=!1}){let r=aM(),[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 Bk(`/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 Bk(`/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=()=>{d_()&&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=cM(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 Vk(`/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:pM(e),count:t.revoked,closed:t.closed}))}catch(e){r(`error`,$(`panel.devices.unbindFailed`,{message:Gk(e)}))}finally{l(!1)}}async function z(){O(!0);try{let e=await Vk(`/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:Gk(e)}))}finally{O(!1)}}async function B(e,t){h(!0);try{await Wk(e.deviceId,t),d(null),await j(),r(`soft`,$(`panel.devices.permissionsDone`,{name:pM(e),tier:rM(t)}))}catch(e){r(`error`,$(`panel.devices.permissionsFailed`,{message:Gk(e)}))}finally{h(!1)}}return M.length===0&&P===0?null:(0,G.jsxs)(CD,{frame:`solid`,className:n?`flex h-full min-h-0 flex-col`:void 0,children:[(0,G.jsx)(wD,{className:n?`flex-none px-4 py-3`:`px-4 py-3`,children:(0,G.jsxs)(TD,{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)(aD,{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=uM(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:pM(e)}),(0,G.jsx)(aD,{variant:`secondary`,size:`xs`,children:oM(Pk(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:dM(e.platform)}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`·`}),(0,G.jsx)(`span`,{children:fM(e.lastChannel)}),(0,G.jsx)(`span`,{"aria-hidden":!0,children:`·`}),t?(0,G.jsx)(DO,{tone:`ok`}):null,(0,G.jsx)(`span`,{children:lM(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(sM(Pk(e.permissions))),d(e)},children:(0,G.jsx)(mM,{})}),(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)(hM,{})})]})]},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)(aD,{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:pM(e)}),(0,G.jsxs)(`span`,{className:`text-xs text-foreground-muted`,children:[dM(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:cM(e.boundAt,N)||`—`})}),(0,G.jsx)(`span`,{children:$(`panel.devices.historyLastSeen`,{time:e.lastSeenAt?cM(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)(KO,{open:o!==null,onOpenChange:e=>{!e&&!c&&s(null)},children:(0,G.jsxs)(qO,{children:[(0,G.jsx)(JO,{children:(0,G.jsx)(YO,{children:$(`panel.devices.unbindTitle`)})}),(0,G.jsxs)(ZO,{className:`flex flex-col gap-2 text-sm`,children:[(0,G.jsx)(XO,{children:$(`panel.devices.unbindConfirm`,{name:pM(o)})}),(0,G.jsx)(`p`,{className:`text-foreground-muted`,children:$(o?.legacy?`panel.devices.effectLegacy`:`panel.devices.effectIdentity`)})]}),(0,G.jsxs)(QO,{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)(UE,{}),$(`panel.devices.unbinding`)]}):$(`panel.devices.unbind`)})]})]})}),(0,G.jsx)(KO,{open:u!==null,onOpenChange:e=>{!e&&!m&&d(null)},children:(0,G.jsxs)(qO,{children:[(0,G.jsx)(JO,{children:(0,G.jsx)(YO,{children:$(`panel.devices.permissionsTitle`)})}),(0,G.jsxs)(ZO,{className:`flex flex-col gap-3 text-sm`,children:[(0,G.jsx)(XO,{children:$(`panel.devices.permissionsHint`)}),(0,G.jsx)(Nk,{className:`flex flex-col gap-2`,value:f,onValueChange:e=>{typeof e==`string`&&p(e)},children:nM.map(e=>(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2`,children:[(0,G.jsx)(_k,{value:e}),(0,G.jsx)(`span`,{children:rM(e)})]},e))})]}),(0,G.jsxs)(QO,{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)(UE,{}),$(`panel.devices.permissionsApply`)]}):$(`panel.devices.permissionsApply`)})]})]})}),(0,G.jsx)(KO,{open:T,onOpenChange:e=>{!e&&!D&&E(!1)},children:(0,G.jsxs)(qO,{children:[(0,G.jsx)(JO,{children:(0,G.jsx)(YO,{children:$(`panel.devices.historyClearTitle`)})}),(0,G.jsxs)(ZO,{className:`flex flex-col gap-2 text-sm`,children:[(0,G.jsx)(XO,{children:$(`panel.devices.historyClearConfirm`,{count:P})}),(0,G.jsx)(`p`,{className:`text-foreground-muted`,children:$(`panel.devices.historyClearHint`)})]}),(0,G.jsxs)(QO,{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)(UE,{}),$(`panel.devices.historyClearing`)]}):$(`panel.devices.historyClear`)})]})]})})]})}var _M=`data:image/png;base64,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`,vM=()=>$(`panel.links.wechatQrAlt`);function yM(){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 bM({compact:e=!1}={}){let[t,n]=(0,g.useState)(!1),r=wg();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)(yM,{}),$(`panel.links.joinGroup`)]}),(0,G.jsx)(uD,{open:t,onOpenChange:n,children:(0,G.jsxs)(dD,{className:`max-w-sm`,children:[(0,G.jsx)(pD,{className:`sr-only`,children:$(`panel.links.joinGroup`)}),(0,G.jsx)(hD,{className:`flex justify-center`,children:(0,G.jsx)(`img`,{src:_M,alt:vM(),className:`w-full rounded-md`})})]})})]})}var xM=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`}}),SM=g.createContext(null),CM={opacity:0,scale:.85,filter:`blur(8px)`},wM={opacity:0},TM={duration:.28,ease:[.4,0,.2,1]},EM={duration:0},DM={sm:`size-3`,md:`size-3.5`,lg:`size-4`};function OM({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(SM),p=t??f?.variant??`soft`,m=n??f?.size??`md`,h=bh(),[_,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)(kM,{size:m}),(0,G.jsx)(`span`,{className:`sr-only`,children:c})]}):l,w=nD({defaultTagName:`button`,render:r,state:{variant:p,size:m,dismissible:i},props:Dr({"data-slot":`chip`,"data-dismissible":i||void 0,type:r?void 0:`button`,...Hu(d.disabled),className:Z(qu({variant:p}),xM({size:m}),i&&`group/chip`,e),onClick:S,children:C},d)});return i?(0,G.jsx)(Rw,{features:UT,strict:!0,children:(0,G.jsx)(jw,{initial:!1,onExitComplete:()=>s?.(),children:b&&(0,G.jsx)(SE.span,{initial:!1,exit:h?wM:CM,transition:h?EM:TM,className:`inline-flex align-middle`,children:w},`chip`)})}):w}function kM({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(DM[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 AM=`M4.3 12.55 L9.25 17.5 L19.7 6.5`,jM={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 MM(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 NM(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 PM({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 MM(e),await NM(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`,{...jM,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`,{...jM,children:(0,G.jsx)(`path`,{d:AM,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 FM=`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`,IM=`0x62744c084c272ddba4680920edc3239cb7180718`;function LM(){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 RM({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)(LM,{}),$(`panel.links.sponsor`)]}),(0,G.jsx)(zM,{open:t,onOpenChange:n,copyFailed:r,setCopyFailed:i})]})}function zM({open:e,onOpenChange:t,copyFailed:n,setCopyFailed:r}){return(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`max-w-sm`,children:[(0,G.jsxs)(fD,{className:`gap-1.5`,children:[(0,G.jsx)(pD,{className:`text-xl`,children:$(`panel.links.sponsorTitle`)}),(0,G.jsx)(mD,{children:$(`panel.links.sponsorIntro`)})]}),(0,G.jsxs)(hD,{className:`flex flex-col gap-4`,children:[(0,G.jsx)(`div`,{className:`flex justify-center`,children:(0,G.jsx)(`img`,{src:FM,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)(OM,{variant:`soft`,size:`sm`,children:`USDT`}),(0,G.jsx)(OM,{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)(PM,{value:IM,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:IM}),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 BM(){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 VM({compact:e=!1}={}){return(0,G.jsxs)(`a`,{href:Rj,target:`_blank`,rel:`noreferrer noopener`,className:`${qu({variant:`secondary`,size:e?`sm`:`lg`})} pointer-events-auto rounded-full shadow-lg`,children:[(0,G.jsx)(BM,{}),$(`panel.links.star`)]})}function HM({compact:e=!1}){return(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,G.jsx)(VM,{compact:e}),(0,G.jsx)(RM,{compact:e}),(0,G.jsx)(bM,{compact:e})]})}function UM(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 WM(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 GM({framed:e=!0}){let t=aM(),[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 Bk(`/api/relay/inbox/status`))}catch{r(null)}finally{a(!0)}},[]);(0,g.useEffect)(()=>{u()},[u]);let d=n?.deletableFiles??0,f=WM(n?.oldestAt??null),p=n?.stagingFiles??0;async function m(e){if(!c){l(!0);try{let t=await Vk(`/api/relay/inbox/auto`,{enabled:e});r(e=>e&&{...e,autoClear:t.data.autoClear})}catch(e){t(`error`,$(`panel.inbox.autoFailed`,{message:Gk(e)}))}finally{l(!1)}}}async function h(){if(o)return;let e=d>0?$(`panel.inbox.confirmDetail`,{count:d,hours:n?.keepHours??24,bytes:UM(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 Vk(`/api/relay/inbox/clear`),n=UM(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:Gk(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)(UE,{}),$(`panel.inbox.reading`)]}),i&&n===null?(0,G.jsxs)(ZE,{variant:`info`,className:`mt-2`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:$(`panel.inbox.unreadableTitle`)}),(0,G.jsx)(tD,{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:UM(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:UM(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:UM(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)(UE,{}):null,(0,G.jsx)(eO,{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)(CD,{frame:`solid`,children:[(0,G.jsx)(wD,{className:`px-4 py-3`,children:(0,G.jsx)(TD,{className:`flex items-center gap-2`,children:(0,G.jsx)(`span`,{children:$(`panel.inbox.title`)})})}),_]}):_}var KM=`https://github.com/WNLUO/dsh-mobile-server`;function qM(){return[$(`panel.notice.promptIntro`),``,`${$(`panel.notice.promptRepo`)}: ${KM}`,``,$(`panel.notice.promptAsk`),``,$(`panel.notice.promptDo`),``,$(`panel.notice.promptAfter`),``,$(`panel.notice.promptStyle`)].join(`
|
|
86
86
|
`)}function JM({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 YM({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 XM({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(qM()),a(!0),window.setTimeout(()=>a(!1),2e3)}catch{a(!1)}}return(0,G.jsx)(uD,{open:e,onOpenChange:e=>{e||a(!1),t(e)},children:(0,G.jsxs)(dD,{className:`w-[min(860px,92vw)] max-w-none`,closeLabel:$(`panel.common.close`),initialFocus:r,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{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)(hD,{className:`flex flex-col gap-3 overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:[(0,G.jsxs)(JM,{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)(JM,{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)(YM,{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)(YM,{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)(YM,{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)(YM,{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)(YM,{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 ZM=`0.4.9`;function QM({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`)} ≥ ${ZM}`})]}),(0,G.jsx)(uD,{open:t,onOpenChange:n,children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.notice.title`)})}),(0,G.jsxs)(hD,{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)(aD,{variant:`warning`,size:`sm`,children:`≥ ${ZM}`})]}),(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)(DO,{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:ZM})})]}),(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)(XM,{open:r,onOpenChange:i,port:e})]})}function $M(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 eN(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function tN({open:e,onOpenChange:t,onChanged:n}){let r=aM(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{let e=await Bk(`/api/relay/p2p`);a(e.status??null),s(``)}catch(e){s(Gk(e))}},[]),d=async e=>{l(`toggle`);try{let t=await Vk(`/api/relay/p2p/enabled`,{enabled:e});a(t.status??null),r(`soft`,$(e?`panel.p2p.enabledToast`:`panel.p2p.disabledToast`)),n?.()}catch(e){r(`error`,Gk(e))}finally{l(``)}};(0,g.useEffect)(()=>{if(!e)return;let t=()=>{d_()&&u()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,u]);let f=i;return(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.p2p.title`)})}),(0,G.jsxs)(hD,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.p2p.hint`)}),o?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:o}):null,f===null?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(UE,{}),$(`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:[$($M(f)),f.error?(0,G.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:f.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:f.url||$(`panel.p2p.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.p2p.enableLabel`)}),(0,G.jsx)(eO,{size:`md`,checked:f.enabled,disabled:!f.available||c!==``,onCheckedChange:e=>void d(e),"aria-label":$(`panel.p2p.enableLabel`)})]}),(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`),` (`,f.candidates.length,`)`]}),f.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:f.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:f.publicKey?eN(f.publicKey):$(`panel.p2p.noKey`)})]})]})]}),(0,G.jsx)(gD,{className:`flex justify-end gap-2`,children:(0,G.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var nN=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}=UD(),d=J((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=J(()=>{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)(HD.Provider,{value:m,children:e.children})};function rN(e){let{change:t,commit:n,invalid:r,markedDirtyRef:i,name:a,setRegisteredFieldName:o,registeredFieldIdRef:s,setValidityData:c,validityData:l}=e,{formRef:u}=VD(),d=g.useRef(null),f=g.useRef(null),p=g.useRef(!1),m=J(()=>{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 _=J(()=>{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:Sk(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:Sk(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]),[_,J((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 iN=g.forwardRef(function(e,t){let{errors:n,validationMode:r,submitCountRef:i}=VD(),{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=Ak(!0)?.disabled,x=J(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=J(e=>{p===void 0&&(e&&(N.current=!0),E(e))}),z=J(e=>{m===void 0&&w(e)}),B=J(()=>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:AD,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=Ok({setValidityData:ee,validate:x,validityData:W,validationDebounceTime:c,invalid:U,markedDirtyRef:N,state:te,shouldValidateOnChange:B,validationMode:l,registeredFieldIdRef:P}),[ne,re]=rN({change:q.change,commit:q.commit,invalid:U,markedDirtyRef:N,name:u,setRegisteredFieldName:I,registeredFieldIdRef:P,setValidityData:ee,validityData:W});g.useImperativeHandle(h,()=>({validate:ne}),[ne]);let ie=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:re,validation:q}),[U,L,W,S,z,R,O,A,l,B,te,re,q]),ae=Vr(`div`,e,{ref:t,state:te,props:v,stateAttributesMapping:MD});return(0,G.jsx)(LD.Provider,{value:ie,children:ae})}),aN=g.forwardRef(function(e,t){return(0,G.jsx)(nN,{children:(0,G.jsx)(iN,{...e,ref:t})})}),oN=g.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,nativeLabel:o=!0,...s}=e,c=RD(!1),l=ik(),{labelId:u}=UD(),d={...c.state,disabled:c.disabled||l.disabled},f=g.useRef(null),p=SA({id:u??a,native:o});return Vr(`label`,e,{ref:[t,f],state:d,props:[p,s],stateAttributesMapping:MD})}),sN=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}=RD(),{clearErrors:T,elementRef:E,submitCountRef:D}=VD(),O=h||s,k=m??a,A={...p,disabled:O},{labelId:j}=UD(),M=qD({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=J(()=>w.inputRef.current?.value);zD(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=Ge();return b(()=>{u&&R.current===lt(Le(R.current))&&x(!0)},[u,x]),Vr(`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=ja(ma,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:MD})});function cN({className:e,...t}){return(0,G.jsx)(aN,{"data-slot":`field`,className:Z(e),...t})}function lN({className:e,...t}){return(0,G.jsx)(oN,{"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 uN=g.forwardRef(function(e,t){return(0,G.jsx)(sN,{ref:t,...e})});function dN(e,t){(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function fN({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&&dN(u.current,``),u.current?.focus(),o?.()};return d?(0,G.jsxs)(`div`,{"data-slot":`input-wrapper`,className:Z(dj({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)(uN,{"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)(uN,{"data-slot":`input`,ref:m,...s,className:Z(dj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle`,s?.className,e),...l,...p?{"data-invalid":``}:{}})}var pN=1024,mN=65535;function hN({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>=pN&&c<=mN&&r===``;return(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`max-w-sm`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.pairing.portTitle`)})}),(0,G.jsxs)(hD,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`relay-lan-port`,children:$(`panel.pairing.port`)}),(0,G.jsx)(fN,{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)(gD,{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 gN({visible:e,onOpenConfig:t}){let[n,r]=(0,g.useState)(!1);return!e||n?null:(0,G.jsx)(uD,{open:!0,onOpenChange:e=>{e||r(!0)},children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.publicRelayNotice.title`)})}),(0,G.jsx)(hD,{className:`whitespace-pre-line text-sm leading-6 text-foreground-muted`,children:$(`panel.publicRelayNotice.body`)}),(0,G.jsxs)(gD,{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 _N={sm:`py-2`,md:`py-2.5`,lg:`py-3`},vN={sm:`min-h-16`,md:`min-h-20`,lg:`min-h-24`},yN={sm:`0.5rem`,md:`0.625rem`,lg:`0.75rem`};function bN(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function xN({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&&bN(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 * ${yN[n]} + 2px)`},className:Z(dj({variant:t,size:n,state:`within`}),`h-(--textarea-h) resize-y items-start overflow-hidden`,vN[n],_N[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)(sN,{"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)(sN,{"data-slot":`textarea`,ref:d,render:(0,G.jsx)(`textarea`,{rows:c}),className:Z(dj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle h-auto resize-y`,_N[n],vN[n],e),...l,...m?{"data-invalid":``}:{}})}function SN(e){return String(e||``).replace(/\s+#.*$/,``).trim().replace(/^["']/,``).replace(/["']$/,``).trim()}function CN(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]=SN(r[2]))}return t}function wN(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 TN(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:wN(t(`customdomains`,`custom_domains`))}}function EN(e){let t=e.split(/\[\[\s*proxies\s*\]\]/i),n=CN(t[0]);return{serverAddr:n.serveraddr||n.server_addr||``,proxies:t.slice(1).map(e=>TN(CN(e)))}}function DN(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]=SN(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=>TN(e.pairs))}}function ON(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)):wN(n(r))}})}}function kN(e){if(!/^\d+$/.test(String(e||``)))return null;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function AN(e,t){for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=kN(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=kN(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 jN(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(`{`)?ON(t)||{serverAddr:``,proxies:[]}:/\[\[\s*proxies\s*\]\]/i.test(t)?EN(t):/^\s*\[common\]\s*$/im.test(t)||/(?:^|[\r\n])\s*server_addr\s*=/i.test(t)?DN(t):EN(t),AN(i.serverAddr,i.proxies)}function MN(e){return/serverAddr|server_addr|\[\[\s*proxies\s*\]\]|\[common\]/i.test(e)}function NN({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)(()=>jN(r),[r]);(0,g.useEffect)(()=>{e&&c(``)},[e]);async function u(){if(!l.ok||a)return;c(``);let e=``;if(MN(r)){o(!0);try{let t=await Uk(r);if(t?.status&&t.status.error){c(t.status.error),o(!1);return}e=t?.status?.remoteAddress||``}catch(e){c(Gk(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)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`w-[min(560px,92vw)]`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.frp.title`)})}),(0,G.jsxs)(hD,{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)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`frp-import`,children:$(`panel.frp.label`)}),(0,G.jsx)(xN,{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)(gD,{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 PN=.7,FN=2;function IN(e){let t=Number.isFinite(e)&&e>0?e:0;return t>=600?1:t<=100?t/100*PN:PN+(t-100)/500*.30000000000000004}function LN(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=FN+IN(e)*a;o.push(`${s?`L`:`M`}${c.toFixed(1)} ${l.toFixed(1)}`),s=!0}),o.join(` `)}function RN(e){return typeof e!=`number`||!Number.isFinite(e)?`none`:e<=100?`fast`:e<=600?`ok`:`slow`}var zN=5e3,BN=132,VN=28;function HN(e){return e===`fast`?`text-success`:e===`ok`?`text-warning`:e===`slow`?`text-destructive`:`text-foreground-muted`}function UN(e){return e===`fast`?`#16a34a`:e===`ok`?`#d97706`:e===`slow`?`#dc2626`:`#9ca3af`}function WN(e){return typeof e!=`number`||!Number.isFinite(e)?`—`:`${Math.round(e)} ms`}function GN({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=Bj.map(e=>e.url);i(Object.fromEntries(t.map(e=>[e,[null]])));async function n(){if(s.current)try{let e=await Vk(`/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(Gk(e))}}return n(),c.current=setInterval(()=>{n()},zN),()=>{s.current=!1,c.current!==null&&(clearInterval(c.current),c.current=null)}},[e]),(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.relay.panelTitle`)})}),(0,G.jsxs)(hD,{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`)}),Bj.map(e=>{let t=r[e.url]||[null],i=[...t].reverse().find(e=>typeof e==`number`)??null,a=RN(i),o=LN(t,BN,VN),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:BN,height:VN,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:o,stroke:UN(a),strokeWidth:1.5,fill:`none`})}):null,(0,G.jsx)(`span`,{className:`w-16 text-right text-sm tabular-nums ${HN(a)}`,children:WN(i)})]})]},e.url)}),a?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:a}):null]}),(0,G.jsx)(gD,{children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}function KN({id:e,value:t,placeholder:n,ariaLabel:r,options:i,emptyText:a,onChange:o}){return(0,G.jsx)(fN,{inputProps:{id:e,className:`font-mono`},value:t,placeholder:n,onChange:e=>o(e.target.value),endSlot:(0,G.jsxs)(Mh,{children:[(0,G.jsx)(Nh,{"aria-label":r,className:`-mr-1 flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded text-foreground-muted hover:text-foreground-strong focus-visible:outline-none`,children:(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,G.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}),(0,G.jsx)(Ih,{align:`end`,style:{width:`auto`,minWidth:`18rem`,maxWidth:`32rem`},children:i.length===0?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground-muted`,children:a}):i.map(e=>(0,G.jsx)(zh,{onClick:()=>o(e.value),children:(0,G.jsx)(`span`,{className:`font-mono text-xs break-all`,children:e.label})},e.value))})]})})}function qN({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||r?.ipv6?.[0]?.url||``),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=Bj.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=Bj.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||r?.ipv6?.[0]?.url||``)&&(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)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`w-[min(1100px,92vw)]`,initialFocus:O,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.pairing.openConfig`)})}),(0,G.jsx)(`div`,{ref:O,tabIndex:-1,className:`outline-none`,children:(0,G.jsxs)(hD,{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)(cN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(lN,{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?``:Bj[0].url),children:$(F?`panel.relay.disablePublic`:`panel.relay.enablePublic`)})]})]}),I?(0,G.jsx)(fN,{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:Bj.map(e=>(0,G.jsx)(fN,{inputProps:{className:`font-mono`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:e.url},e.url))})]}),(0,G.jsxs)(cN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(lN,{htmlFor:`relay-url`,children:$(`panel.relay.selfKind`)}),(0,G.jsx)(`a`,{href:Lj,target:`_blank`,rel:`noreferrer noopener`,className:qu({variant:`ghost`,size:`sm`}),children:$(`panel.relay.selfRepo`)})]}),(0,G.jsx)(fN,{inputProps:{id:`relay-url`,className:`font-mono`},value:F?``:c,placeholder:`https://example.com`,onChange:e=>l(e.target.value)})]}),(0,G.jsxs)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`relay-manual-lan`,children:$(`panel.address.direct`)}),(0,G.jsx)(fN,{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)(cN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(lN,{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)(fN,{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)(cN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(lN,{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)(KN,{id:`relay-preferred-lan`,value:_,placeholder:$(`panel.address.lanPlaceholder`),ariaLabel:$(`panel.address.lan`),options:N.map(e=>({value:e.address,label:e.url})),emptyText:$(`panel.address.empty`),onChange:e=>{M.current=!0,b(``),v(e)}}),y?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:y}):null]}),(0,G.jsxs)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`relay-manual-ipv6`,children:$(`panel.address.ipv6Url`)}),(0,G.jsx)(KN,{id:`relay-manual-ipv6`,value:f,placeholder:$(`panel.address.ipv6Placeholder`),ariaLabel:$(`panel.address.ipv6Url`),options:(r?.ipv6??[]).map(e=>({value:e.url,label:e.interface?`${e.url} · ${e.interface}`:e.url})),emptyText:$(`panel.address.empty`),onChange:e=>{A.current=!0,p(e)}})]})]})}),(0,G.jsxs)(gD,{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)(uD,{open:x,onOpenChange:S,children:(0,G.jsxs)(dD,{className:`w-[min(560px,92vw)]`,initialFocus:D,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.address.lan`)})}),(0,G.jsx)(`div`,{ref:D,tabIndex:-1,className:`outline-none`,children:(0,G.jsx)(hD,{className:`max-h-[60vh] overflow-y-auto px-1 py-2`,children:(0,G.jsx)(Fj,{align:`start`,book:r,port:n.lan.port,value:r?.preferred??``,busy:a!==``,fallbackUrls:i,onChange:e=>{s(e),S(!1)}})})}),(0,G.jsx)(gD,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>S(!1),children:$(`panel.common.close`)})})]})}),(0,G.jsx)(NN,{open:C,onOpenChange:w,onImport:e=>{e.field===`tcp`?(j.current=!0,h(e.value)):(k.current=!0,d(e.value))}}),(0,G.jsx)(GN,{open:T,onOpenChange:E,activeUrl:F?.url??``})]})}var JN=18e5,YN=3e5,XN=15e3,ZN=null,QN=0,$N=0,eP=null;function tP(e){return typeof e!=`number`||!Number.isFinite(e)?!1:e===0||Date.now()-e>JN}function nP(e){if(!e&&eP)return eP;let t=(async()=>{let t=await Bk(e?`/api/relay/selfcheck?force=1`:`/api/relay/selfcheck`);return ZN=t,QN=Date.now(),t})();return e||(eP=t,t.finally(()=>{eP===t&&(eP=null)})),t}function rP(e,t=``){let[n,r]=(0,g.useState)(ZN),[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&&ZN&&Date.now()-QN<XN){r(ZN);return}a(!0);try{let t=await nP(e);if(!u.current)return;r(t),s(``),l(!1)}catch(e){if(!u.current)return;l(e instanceof Rk&&e.status===404),s(Gk(e))}finally{u.current&&a(!1)}},[]);(0,g.useEffect)(()=>{e&&(Date.now()-$N<YN||ZN&&Date.now()-QN<XN||($N=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 iP(e){return e===`ok`?`ok`:e===`unknown`?`warn`:`error`}var aP={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 oP(e){return $(aP[e]?.long??`panel.selfcheck.verdict.unknown`)}function sP(e){if(!e)return{tone:`off`,text:$(`panel.selfcheck.notChecked`)};let t=e.firewall,n=uP(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 cP(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:tP(n))?{tone:`warn`,text:$(`panel.selfcheck.mobileIdle`),detail:vg(n)}:{tone:`ok`,text:$(`panel.selfcheck.mobileRecent`),detail:vg(n)}}function lP(e){let t={listening:`panel.lan.listening`,off:`panel.status.off`,error:`panel.lan.error`};return t[e]?$(t[e]):e}function uP(e){let t=String(e??``).trim();if(!t)return``;let n=t.split(/[\\/]/);return n[n.length-1]??``}function dP({open:e,onOpenChange:t,state:n,lastMobileAt:r}){(0,g.useEffect)(()=>{e&&n.ensure()},[e,n.ensure]);let i=n.data,a=sP(i),o=cP(i,r),s=i?iP(i.verdict):`warn`;return(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`max-w-xl`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.selfcheck.title`)})}),(0,G.jsxs)(hD,{className:`flex flex-col gap-3`,children:[n.error?(0,G.jsxs)(ZE,{variant:n.missing?`warning`:`error`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:n.missing?$(`panel.selfcheck.unavailable`):$(`panel.selfcheck.failed`)}),n.missing?null:(0,G.jsx)(tD,{children:n.error})]}):null,i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:hg(`text-sm`,s===`ok`?`text-foreground`:_g[s]),children:oP(i.verdict)}),(0,G.jsxs)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.connection.lan`),children:(0,G.jsx)(AO,{tone:i.listening.state===`listening`?`ok`:i.listening.state===`error`?`error`:`off`,text:lP(i.listening.state),detail:$(`panel.selfcheck.port`,{port:i.listening.port})})}),(0,G.jsx)(OO,{label:$(`panel.connection.tunnel`),children:(0,G.jsx)(AO,{tone:yg(i.tunnel.state),text:bg(i.tunnel.state)})}),(0,G.jsx)(OO,{label:$(`panel.selfcheck.firewall`),children:(0,G.jsx)(AO,{tone:a.tone,text:a.text,detail:a.detail})}),(0,G.jsx)(OO,{label:$(`panel.selfcheck.mobile`),children:(0,G.jsx)(AO,{tone:o.tone,text:o.text,detail:o.detail})})]}),(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.selfcheck.checkedAt`,{time:vg(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)(UE,{}),$(`panel.selfcheck.checking`)]}):null]}),(0,G.jsxs)(gD,{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 fP(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 pP(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function mP({open:e,onOpenChange:t,onChanged:n}){let r=aM(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{a(await Bk(`/api/relay/tailcat`)),s(``)}catch(e){s(Gk(e))}},[]);(0,g.useEffect)(()=>{if(!e)return;let t=()=>{d_()&&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`,Gk(e))}finally{l(``)}},[r,n]),f=e=>void d(`toggle`,()=>Vk(`/api/relay/tailcat/enabled`,{enabled:e}),$(e?`panel.tailcat.enabledToast`:`panel.tailcat.disabledToast`)),p=e=>{window.confirm($(`panel.tailcat.revokeConfirm`))&&d(`revoke`,()=>Vk(`/api/relay/tailcat/revoke`,{client:e}),$(`panel.tailcat.revokedToast`))},m=i?.status??null,h=i?.allowedClients??[];return(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.tailcat.title`)})}),(0,G.jsxs)(hD,{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)(UE,{}),$(`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:[$(fP(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)(eO,{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:pP(e)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:c!==``,onClick:()=>p(e),children:$(`panel.tailcat.revoke`)})]},e))})]})]})]}),(0,G.jsx)(gD,{className:`flex justify-end gap-2`,children:(0,G.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var hP=`/dsh-market/api/v1`,gP=`dsh-mobile-plugin`,_P=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}},vP=e=>e&&typeof e==`object`?e:{},yP=e=>typeof e==`string`&&e!==``?e:null;async function bP(e,t){let n;try{n=await fetch(`${hP}${e}`,{credentials:`same-origin`,...t})}catch(e){throw new _P(0,`market_unreachable`,$(`panel.net.marketUnreachable`,{message:String(e?.message||e)}))}let r=await n.json().catch(()=>null);if(!n.ok){let e=vP(r),t=vP(e.failure),i=yP(t.code)??(typeof e.error==`string`?e.error:`HTTP ${n.status}`),a=yP(t.message)??yP(e.error)??$(`panel.net.marketHttp`,{status:n.status});throw new _P(n.status,i,a)}return r}async function xP(){try{return{available:!0,restartSupported:vP(vP(await bP(`/capabilities`)).restart).supported===!0}}catch{return{available:!1,restartSupported:!1}}}async function SP(e=gP,t=!1){let n=vP(await bP(`/updates${`?name=${encodeURIComponent(e)}${t?`&force=1`:``}`}`)),r=vP(n.package??n);return{installedVersion:yP(r.installedVersion),latestVersion:yP(r.latestVersion),updateAvailable:r.updateAvailable===!0,source:yP(r.source)}}var CP={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`},wP=e=>e&&typeof e==`object`?e:{},TP=e=>typeof e==`string`&&e!==``?e:null,EP=e=>typeof e==`boolean`?e:null,DP=e=>typeof e==`number`&&Number.isFinite(e)?e:null;async function OP(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=wP(r),a=wP(i.error);if(!n.ok){let e=TP(a.code)??`http_${n.status}`;throw new Rk(TP(a.message)??$(`panel.net.hostHttp`,{status:n.status}),e,n.status)}return i}function kP(e){return e instanceof Rk?e.status===404:e instanceof SyntaxError}function AP(e){return e instanceof Rk&&e.code===`update_unavailable`}function jP(e){let t=wP(e);return Object.keys(t).length===0?null:{installedVersion:TP(t.installedVersion),latestVersion:TP(t.latestVersion),updateAvailable:t.updateAvailable===!0,source:TP(t.source),checkedAt:TP(t.checkedAt)}}function MP(e){let t=wP(e),n=wP(t.failure),r=TP(n.code);return{installed:EP(t.installed),skipped:EP(t.skipped),state:TP(t.state),beforeVersion:TP(t.beforeVersion),installedVersion:TP(t.installedVersion),swapped:EP(t.swapped),restartRequired:EP(t.restartRequired),refreshRequired:EP(t.refreshRequired),failure:r?{code:r,message:TP(n.message)??r}:null}}function NP(e){let t=wP(e);return{available:t.available===!0,version:TP(t.version),installedVersion:TP(t.installedVersion),source:TP(t.source),previousVersion:TP(t.previousVersion),activatedAt:TP(t.activatedAt),lastError:TP(t.lastError),inFlight:DP(t.inFlight)??0,swapping:t.swapping===!0,autoUpdate:t.autoUpdate===!0,autoIntervalMs:DP(t.autoIntervalMs)??6e5,marketBase:TP(t.marketBase),marketLastCheckedAt:TP(t.marketLastCheckedAt),marketLastError:TP(t.marketLastError),marketResult:jP(t.marketResult),lastApply:t.lastApply?MP(t.lastApply):null,appliedAt:TP(t.appliedAt),runningShellHash:TP(t.runningShellHash),installedShellHash:TP(t.installedShellHash),shellChanged:t.shellChanged===!0}}async function PP(){return NP((await OP(CP.status)).data)}async function FP(){let e=wP((await OP(CP.check,{method:`POST`,body:JSON.stringify({})})).data);return{update:jP(e.update),status:e.status?NP(e.status):null}}async function IP(e=!1){let t=wP((await OP(CP.apply,{method:`POST`,body:JSON.stringify({force:e})})).data),n=wP(t.status);return{...MP(t),status:Object.keys(n).length>0?NP(n):null}}async function LP(e){let t=wP((await OP(CP.auto,{method:`POST`,body:JSON.stringify({enabled:e})})).data);return{enabled:t.enabled===!0,status:t.status?NP(t.status):null}}var RP=new Set([`OPERATION_BUSY`,`RELEASE_TOO_FRESH`,`VERSION_UNCHANGED`,`PLUGIN_NOT_INSTALLED`,`AGENTS_RUNNING`]);function zP(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 BP({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=aM(),[_,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 PP();i(e),c(e.available!==!0)}catch(e){i(null),c(AP(e))}finally{o(!0)}},[]);(0,g.useEffect)(()=>{S()},[S]),(0,g.useEffect)(()=>{if(!a)return;let e=!0;return FP().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 xP().then(t=>{e&&u(t)}),()=>{e=!1}},[b,a]);let w=(0,g.useCallback)(e=>{if(e instanceof _P&&RP.has(e.code)){h(`soft`,`${e.message}(${e.code})`);return}h(`error`,Gk(e))},[]),T=(0,g.useCallback)(async()=>{m(`check`);try{let e=await FP();e.status&&y(e.status),e.update&&f(e.update)}catch(e){kP(e)||AP(e)?await S():h(`error`,Gk(e))}finally{m(``)}},[S]),E=(0,g.useCallback)(async e=>{m(`apply`);try{let t=await IP(e);t.status&&y(t.status);let n=zP(t),r=t.failure!==null&&RP.has(t.failure.code);n.ok||r?h(`soft`,n.text):h(`error`,n.text)}catch(e){kP(e)||AP(e)?await S():h(`error`,Gk(e))}finally{m(``)}},[S]),D=(0,g.useCallback)(async()=>{m(`check`);try{let e=await FP();e.status&&y(e.status),f(e.update)}catch(e){if(!kP(e))f(null),h(`error`,Gk(e));else try{f(await SP(void 0,!0))}catch(e){f(null),w(e)}}finally{m(``)}},[w]),O=(0,g.useCallback)(async e=>{v(!0);try{let t=await LP(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:Gk(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?zP(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)(CD,{frame:`solid`,children:[(0,G.jsx)(wD,{className:`px-4 py-3`,children:(0,G.jsxs)(TD,{className:`flex items-center gap-2 text-base lg:text-lg`,children:[(0,G.jsx)(`span`,{children:$(`panel.update.title`)}),(0,G.jsx)(aD,{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)(UE,{}),$(`panel.update.reading`)]}),s?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.update.runningVersion`),mono:!0,children:P}),(0,G.jsx)(OO,{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)(ZE,{variant:`info`,className:`mt-3`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:$(`panel.update.noMarketTitle`)}),(0,G.jsx)(tD,{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)(UE,{}):null,(0,G.jsx)(eO,{size:`md`,checked:r.autoUpdate,disabled:x||_,onCheckedChange:e=>void O(e),"aria-label":$(`panel.update.autoUpdate`)})]})]}),(0,G.jsxs)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.update.runningVersion`),mono:!0,children:P}),L?(0,G.jsx)(OO,{label:$(`panel.update.diskVersion`),mono:!0,children:L}):null,(0,G.jsx)(OO,{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)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.update.runningVersion`),mono:!0,children:P}),(0,G.jsx)(OO,{label:$(`panel.update.latestOnline`),mono:!0,children:k??$(`panel.update.notChecked`)}),(0,G.jsx)(OO,{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 VP({webAccess:e,busy:t,onToggle:n}){let r=e?.enabled===!0,i=typeof e?.expiresAt==`number`?e.expiresAt:0;return(0,G.jsxs)(CD,{frame:`solid`,children:[(0,G.jsx)(wD,{className:`px-4 py-3`,children:(0,G.jsx)(TD,{className:`text-base lg:text-lg`,children:$(`panel.webAccess.title`)})}),(0,G.jsx)(kO,{children:(0,G.jsx)(OO,{label:$(`panel.webAccess.state`),tone:r?`ok`:`off`,children:r?$(`panel.webAccess.expires`,{time:vg(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 HP(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 UP=1500,WP=600;function GP(){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 KP(){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=aM();(0,g.useEffect)(()=>{e?HP(`ready`):n&&HP(`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=rP(tP(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 Bk(`/api/relay/status`)),r(``)}catch(e){r(Gk(e))}},[]),j=(0,g.useCallback)(async()=>{l(``);try{s(await Bk(`/api/relay/pairing`)),l(``)}catch(e){s(null),l(Gk(e))}},[]),M=(0,g.useCallback)(async()=>{try{d(await Bk(`/api/relay/addresses`))}catch{d(null)}},[]);(0,g.useEffect)(()=>{let e=()=>{d_()&&A()};e();let t=0,n=window.setTimeout(()=>{t=window.setInterval(e,3e3)},UP);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(),WP);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 Bk(`/api/relay/pairing`)),l(``)}catch{}},[]);(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=Lk(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(),WP);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`,Gk(e))}finally{a(``)}},[T]),F=e=>P(`toggle`,async()=>{t(await Vk(`/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 Vk(`/api/relay/restart-sidecar`);t(e.status),T(`soft`,$(`panel.shell.sidecarRestarted`))}),L=()=>{window.confirm($(`panel.shell.revokeConfirm`))&&P(`revoke`,async()=>{let e=await Vk(`/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 Vk(`/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 Vk(`/api/relay/config`,e)),p(!1),await j(),T(`soft`,$(`panel.shell.configSaved`))}),B=e=>P(`policy`,async()=>{t(await Vk(`/api/relay/config`,{pairingPolicy:e})),T(`soft`,$(e===`code`?`panel.shell.deviceAllowed`:`panel.shell.deviceDenied`))}),V=e=>P(`tier`,async()=>{t(await Vk(`/api/relay/config`,{pairingTier:e})),T(`soft`,$(`panel.shell.configSaved`))}),H=e=>P(`autoReview`,async()=>{t(await Vk(`/api/relay/config`,{approvalAutoReview:e})),T(`soft`,$(e?`panel.shell.autoReviewOn`:`panel.shell.autoReviewOff`))}),U=e=>P(`controlReport`,async()=>{t(await Vk(`/api/relay/config`,{controlReportEnabled:e})),T(`soft`,$(`panel.shell.configSaved`))}),W=e=>P(`lan`,async()=>{t(await Vk(`/api/relay/config`,{lanPort:e})),h(!1),await j(),T(`soft`,$(`panel.shell.lanSaved`))}),ee=e=>P(`lan`,async()=>{t(await Vk(`/api/relay/config`,{preferredLanAddress:e})),await Promise.all([j(),M()]),T(`soft`,e?$(`panel.shell.preferredAddress`,{address:e}):$(`panel.shell.preferredAuto`))}),K=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:[K?(0,G.jsx)(DO,{tone:K}):null,(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name||e.instanceId}),(0,G.jsx)(aD,{variant:`soft`,size:`sm`,children:e.appVersion||$(`panel.shell.unknownVersion`)}),(0,G.jsx)(HM,{compact:!0})]}),i?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-foreground-muted`,children:[(0,G.jsx)(UE,{}),$(`panel.shell.busy`)]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,G.jsx)(QM,{lanPort:e.lan.port}),(0,G.jsx)(kg,{}),(0,G.jsx)(s_,{}),(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)(GP,{})}),(0,G.jsx)(HO,{})]})]}),n?(0,G.jsxs)(ZE,{variant:`error`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:$(`panel.shell.statusFailed`)}),(0,G.jsx)(tD,{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)(eM,{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),onChangeControlReport:e=>void U(e),onOpenSelfCheck:()=>v(!0),onRetryPairing:()=>void j(),onSavePreferred:e=>void ee(e),onEditPort:()=>h(!0)})}),(0,G.jsx)(`div`,{className:`md:col-span-2`,children:(0,G.jsx)(BP,{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)(FO,{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)(gM,{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)(VP,{webAccess:e.webAccess,busy:i,onToggle:e=>void R(e)}):null})]}),(0,G.jsx)(qN,{open:f,onOpenChange:p,status:e,addressBook:u,lanUrls:o?.lanUrls??[],busy:i,onSave:e=>void z(e),onSavePreferred:e=>void ee(e)}),(0,G.jsx)(dP,{open:_,onOpenChange:v,state:k,lastMobileAt:e.lastMobileAt}),(0,G.jsx)(mP,{open:y,onOpenChange:b,onChanged:()=>void A()}),(0,G.jsx)(tN,{open:x,onOpenChange:S,onChanged:()=>void A()}),(0,G.jsx)(hN,{open:m,onOpenChange:h,port:o?.lanPort??e.lan.requestedPort??e.lan.port,busy:i,onSave:e=>void W(e)}),(0,G.jsx)(uD,{open:C,onOpenChange:w,children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.inbox.title`)})}),(0,G.jsx)(hD,{children:(0,G.jsx)(GM,{framed:!1})})]})}),(0,G.jsx)(gN,{visible:Vj(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)(UE,{}),$(`panel.shell.readingStatus`)]})})}var qP=[{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 XM({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(qM()),a(!0),window.setTimeout(()=>a(!1),2e3)}catch{a(!1)}}return(0,G.jsx)(uD,{open:e,onOpenChange:e=>{e||a(!1),t(e)},children:(0,G.jsxs)(dD,{className:`w-[min(860px,92vw)] max-w-none`,closeLabel:$(`panel.common.close`),initialFocus:r,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{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)(hD,{className:`flex flex-col gap-3 overflow-y-auto [scrollbar-width:none] [&::-webkit-scrollbar]:hidden`,children:[(0,G.jsxs)(JM,{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)(JM,{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)(YM,{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)(YM,{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)(YM,{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)(YM,{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)(YM,{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 ZM=`0.4.9`;function QM({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`)} ≥ ${ZM}`})]}),(0,G.jsx)(uD,{open:t,onOpenChange:n,children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.notice.title`)})}),(0,G.jsxs)(hD,{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)(aD,{variant:`warning`,size:`sm`,children:`≥ ${ZM}`})]}),(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)(DO,{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:ZM})})]}),(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)(XM,{open:r,onOpenChange:i,port:e})]})}function $M(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 eN(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function tN({open:e,onOpenChange:t,onChanged:n}){let r=aM(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{let e=await Bk(`/api/relay/p2p`);a(e.status??null),s(``)}catch(e){s(Gk(e))}},[]),d=async e=>{l(`toggle`);try{let t=await Vk(`/api/relay/p2p/enabled`,{enabled:e});a(t.status??null),r(`soft`,$(e?`panel.p2p.enabledToast`:`panel.p2p.disabledToast`)),n?.()}catch(e){r(`error`,Gk(e))}finally{l(``)}};(0,g.useEffect)(()=>{if(!e)return;let t=()=>{d_()&&u()};t();let n=window.setInterval(t,2e3);return document.addEventListener(`visibilitychange`,t),()=>{window.clearInterval(n),document.removeEventListener(`visibilitychange`,t)}},[e,u]);let f=i;return(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.p2p.title`)})}),(0,G.jsxs)(hD,{className:`flex flex-col gap-3`,children:[(0,G.jsx)(`p`,{className:`text-xs leading-5 text-foreground-muted`,children:$(`panel.p2p.hint`)}),o?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:o}):null,f===null?(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(UE,{}),$(`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:[$($M(f)),f.error?(0,G.jsx)(`span`,{className:`ml-1 text-xs text-foreground-muted`,children:f.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:f.url||$(`panel.p2p.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.p2p.enableLabel`)}),(0,G.jsx)(eO,{size:`md`,checked:f.enabled,disabled:!f.available||c!==``,onCheckedChange:e=>void d(e),"aria-label":$(`panel.p2p.enableLabel`)})]}),(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`),` (`,f.candidates.length,`)`]}),f.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:f.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:f.publicKey?eN(f.publicKey):$(`panel.p2p.noKey`)})]})]})]}),(0,G.jsx)(gD,{className:`flex justify-end gap-2`,children:(0,G.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var nN=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}=UD(),d=J((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=J(()=>{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)(HD.Provider,{value:m,children:e.children})};function rN(e){let{change:t,commit:n,invalid:r,markedDirtyRef:i,name:a,setRegisteredFieldName:o,registeredFieldIdRef:s,setValidityData:c,validityData:l}=e,{formRef:u}=VD(),d=g.useRef(null),f=g.useRef(null),p=g.useRef(!1),m=J(()=>{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 _=J(()=>{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:Sk(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:Sk(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]),[_,J((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 iN=g.forwardRef(function(e,t){let{errors:n,validationMode:r,submitCountRef:i}=VD(),{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=Ak(!0)?.disabled,x=J(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=J(e=>{p===void 0&&(e&&(N.current=!0),E(e))}),z=J(e=>{m===void 0&&w(e)}),B=J(()=>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:AD,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=Ok({setValidityData:ee,validate:x,validityData:W,validationDebounceTime:c,invalid:U,markedDirtyRef:N,state:te,shouldValidateOnChange:B,validationMode:l,registeredFieldIdRef:P}),[ne,re]=rN({change:q.change,commit:q.commit,invalid:U,markedDirtyRef:N,name:u,setRegisteredFieldName:I,registeredFieldIdRef:P,setValidityData:ee,validityData:W});g.useImperativeHandle(h,()=>({validate:ne}),[ne]);let ie=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:re,validation:q}),[U,L,W,S,z,R,O,A,l,B,te,re,q]),ae=Vr(`div`,e,{ref:t,state:te,props:v,stateAttributesMapping:MD});return(0,G.jsx)(LD.Provider,{value:ie,children:ae})}),aN=g.forwardRef(function(e,t){return(0,G.jsx)(nN,{children:(0,G.jsx)(iN,{...e,ref:t})})}),oN=g.forwardRef(function(e,t){let{render:n,className:r,style:i,id:a,nativeLabel:o=!0,...s}=e,c=RD(!1),l=ik(),{labelId:u}=UD(),d={...c.state,disabled:c.disabled||l.disabled},f=g.useRef(null),p=SA({id:u??a,native:o});return Vr(`label`,e,{ref:[t,f],state:d,props:[p,s],stateAttributesMapping:MD})}),sN=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}=RD(),{clearErrors:T,elementRef:E,submitCountRef:D}=VD(),O=h||s,k=m??a,A={...p,disabled:O},{labelId:j}=UD(),M=qD({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=J(()=>w.inputRef.current?.value);zD(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=Ge();return b(()=>{u&&R.current===lt(Le(R.current))&&x(!0)},[u,x]),Vr(`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=ja(ma,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:MD})});function cN({className:e,...t}){return(0,G.jsx)(aN,{"data-slot":`field`,className:Z(e),...t})}function lN({className:e,...t}){return(0,G.jsx)(oN,{"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 uN=g.forwardRef(function(e,t){return(0,G.jsx)(sN,{ref:t,...e})});function dN(e,t){(Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function fN({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&&dN(u.current,``),u.current?.focus(),o?.()};return d?(0,G.jsxs)(`div`,{"data-slot":`input-wrapper`,className:Z(dj({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)(uN,{"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)(uN,{"data-slot":`input`,ref:m,...s,className:Z(dj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle`,s?.className,e),...l,...p?{"data-invalid":``}:{}})}var pN=1024,mN=65535;function hN({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>=pN&&c<=mN&&r===``;return(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`max-w-sm`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.pairing.portTitle`)})}),(0,G.jsxs)(hD,{className:`flex flex-col gap-2`,children:[(0,G.jsxs)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`relay-lan-port`,children:$(`panel.pairing.port`)}),(0,G.jsx)(fN,{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)(gD,{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 gN({visible:e,onOpenConfig:t}){let[n,r]=(0,g.useState)(!1);return!e||n?null:(0,G.jsx)(uD,{open:!0,onOpenChange:e=>{e||r(!0)},children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.publicRelayNotice.title`)})}),(0,G.jsx)(hD,{className:`whitespace-pre-line text-sm leading-6 text-foreground-muted`,children:$(`panel.publicRelayNotice.body`)}),(0,G.jsxs)(gD,{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 _N={sm:`py-2`,md:`py-2.5`,lg:`py-3`},vN={sm:`min-h-16`,md:`min-h-20`,lg:`min-h-24`},yN={sm:`0.5rem`,md:`0.625rem`,lg:`0.75rem`};function bN(e,t){(Object.getOwnPropertyDescriptor(HTMLTextAreaElement.prototype,`value`)?.set)?.call(e,t),e.dispatchEvent(new Event(`input`,{bubbles:!0}))}function xN({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&&bN(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 * ${yN[n]} + 2px)`},className:Z(dj({variant:t,size:n,state:`within`}),`h-(--textarea-h) resize-y items-start overflow-hidden`,vN[n],_N[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)(sN,{"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)(sN,{"data-slot":`textarea`,ref:d,render:(0,G.jsx)(`textarea`,{rows:c}),className:Z(dj({variant:t,size:n,state:`self`}),`placeholder:text-foreground-subtle h-auto resize-y`,_N[n],vN[n],e),...l,...m?{"data-invalid":``}:{}})}function SN(e){return String(e||``).replace(/\s+#.*$/,``).trim().replace(/^["']/,``).replace(/["']$/,``).trim()}function CN(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]=SN(r[2]))}return t}function wN(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 TN(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:wN(t(`customdomains`,`custom_domains`))}}function EN(e){let t=e.split(/\[\[\s*proxies\s*\]\]/i),n=CN(t[0]);return{serverAddr:n.serveraddr||n.server_addr||``,proxies:t.slice(1).map(e=>TN(CN(e)))}}function DN(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]=SN(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=>TN(e.pairs))}}function ON(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)):wN(n(r))}})}}function kN(e){if(!/^\d+$/.test(String(e||``)))return null;let t=Number(e);return Number.isInteger(t)&&t>=1&&t<=65535?t:null}function AN(e,t){for(let n of t){if(n.type&&n.type!==`tcp`)continue;let t=kN(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=kN(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 jN(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(`{`)?ON(t)||{serverAddr:``,proxies:[]}:/\[\[\s*proxies\s*\]\]/i.test(t)?EN(t):/^\s*\[common\]\s*$/im.test(t)||/(?:^|[\r\n])\s*server_addr\s*=/i.test(t)?DN(t):EN(t),AN(i.serverAddr,i.proxies)}function MN(e){return/serverAddr|server_addr|\[\[\s*proxies\s*\]\]|\[common\]/i.test(e)}function NN({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)(()=>jN(r),[r]);(0,g.useEffect)(()=>{e&&c(``)},[e]);async function u(){if(!l.ok||a)return;c(``);let e=``;if(MN(r)){o(!0);try{let t=await Uk(r);if(t?.status&&t.status.error){c(t.status.error),o(!1);return}e=t?.status?.remoteAddress||``}catch(e){c(Gk(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)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`w-[min(560px,92vw)]`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.frp.title`)})}),(0,G.jsxs)(hD,{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)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`frp-import`,children:$(`panel.frp.label`)}),(0,G.jsx)(xN,{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)(gD,{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 PN=.7,FN=2;function IN(e){let t=Number.isFinite(e)&&e>0?e:0;return t>=600?1:t<=100?t/100*PN:PN+(t-100)/500*.30000000000000004}function LN(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=FN+IN(e)*a;o.push(`${s?`L`:`M`}${c.toFixed(1)} ${l.toFixed(1)}`),s=!0}),o.join(` `)}function RN(e){return typeof e!=`number`||!Number.isFinite(e)?`none`:e<=100?`fast`:e<=600?`ok`:`slow`}var zN=5e3,BN=132,VN=28;function HN(e){return e===`fast`?`text-success`:e===`ok`?`text-warning`:e===`slow`?`text-destructive`:`text-foreground-muted`}function UN(e){return e===`fast`?`#16a34a`:e===`ok`?`#d97706`:e===`slow`?`#dc2626`:`#9ca3af`}function WN(e){return typeof e!=`number`||!Number.isFinite(e)?`—`:`${Math.round(e)} ms`}function GN({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=Bj.map(e=>e.url);i(Object.fromEntries(t.map(e=>[e,[null]])));async function n(){if(s.current)try{let e=await Vk(`/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(Gk(e))}}return n(),c.current=setInterval(()=>{n()},zN),()=>{s.current=!1,c.current!==null&&(clearInterval(c.current),c.current=null)}},[e]),(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.relay.panelTitle`)})}),(0,G.jsxs)(hD,{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`)}),Bj.map(e=>{let t=r[e.url]||[null],i=[...t].reverse().find(e=>typeof e==`number`)??null,a=RN(i),o=LN(t,BN,VN),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:BN,height:VN,"aria-hidden":`true`,children:(0,G.jsx)(`path`,{d:o,stroke:UN(a),strokeWidth:1.5,fill:`none`})}):null,(0,G.jsx)(`span`,{className:`w-16 text-right text-sm tabular-nums ${HN(a)}`,children:WN(i)})]})]},e.url)}),a?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-destructive`,children:a}):null]}),(0,G.jsx)(gD,{children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}function KN({id:e,value:t,placeholder:n,ariaLabel:r,options:i,emptyText:a,onChange:o}){return(0,G.jsx)(fN,{inputProps:{id:e,className:`font-mono`},value:t,placeholder:n,onChange:e=>o(e.target.value),endSlot:(0,G.jsxs)(Mh,{children:[(0,G.jsx)(Nh,{"aria-label":r,className:`-mr-1 flex h-7 w-7 shrink-0 cursor-pointer items-center justify-center rounded text-foreground-muted hover:text-foreground-strong focus-visible:outline-none`,children:(0,G.jsx)(`svg`,{viewBox:`0 0 24 24`,className:`size-4`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,strokeLinejoin:`round`,children:(0,G.jsx)(`path`,{d:`m6 9 6 6 6-6`})})}),(0,G.jsx)(Ih,{align:`end`,style:{width:`auto`,minWidth:`18rem`,maxWidth:`32rem`},children:i.length===0?(0,G.jsx)(`div`,{className:`px-3 py-2 text-xs text-foreground-muted`,children:a}):i.map(e=>(0,G.jsx)(zh,{onClick:()=>o(e.value),children:(0,G.jsx)(`span`,{className:`font-mono text-xs break-all`,children:e.label})},e.value))})]})})}function qN({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||r?.ipv6?.[0]?.url||``),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=Bj.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=Bj.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||r?.ipv6?.[0]?.url||``)&&(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)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`w-[min(1100px,92vw)]`,initialFocus:O,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.pairing.openConfig`)})}),(0,G.jsx)(`div`,{ref:O,tabIndex:-1,className:`outline-none`,children:(0,G.jsxs)(hD,{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)(cN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(lN,{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?``:Bj[0].url),children:$(F?`panel.relay.disablePublic`:`panel.relay.enablePublic`)})]})]}),I?(0,G.jsx)(fN,{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:Bj.map(e=>(0,G.jsx)(fN,{inputProps:{className:`font-mono`,readOnly:!0,"aria-label":$(`panel.relay.publicKind`)},value:e.url},e.url))})]}),(0,G.jsxs)(cN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(lN,{htmlFor:`relay-url`,children:$(`panel.relay.selfKind`)}),(0,G.jsx)(`a`,{href:Lj,target:`_blank`,rel:`noreferrer noopener`,className:qu({variant:`ghost`,size:`sm`}),children:$(`panel.relay.selfRepo`)})]}),(0,G.jsx)(fN,{inputProps:{id:`relay-url`,className:`font-mono`},value:F?``:c,placeholder:`https://example.com`,onChange:e=>l(e.target.value)})]}),(0,G.jsxs)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`relay-manual-lan`,children:$(`panel.address.direct`)}),(0,G.jsx)(fN,{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)(cN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(lN,{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)(fN,{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)(cN,{children:[(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3 gap-y-1`,children:[(0,G.jsx)(lN,{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)(KN,{id:`relay-preferred-lan`,value:_,placeholder:$(`panel.address.lanPlaceholder`),ariaLabel:$(`panel.address.lan`),options:N.map(e=>({value:e.address,label:e.url})),emptyText:$(`panel.address.empty`),onChange:e=>{M.current=!0,b(``),v(e)}}),y?(0,G.jsx)(`p`,{className:`text-xs text-error`,children:y}):null]}),(0,G.jsxs)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`relay-manual-ipv6`,children:$(`panel.address.ipv6Url`)}),(0,G.jsx)(KN,{id:`relay-manual-ipv6`,value:f,placeholder:$(`panel.address.ipv6Placeholder`),ariaLabel:$(`panel.address.ipv6Url`),options:(r?.ipv6??[]).map(e=>({value:e.url,label:e.interface?`${e.url} · ${e.interface}`:e.url})),emptyText:$(`panel.address.empty`),onChange:e=>{A.current=!0,p(e)}})]})]})}),(0,G.jsxs)(gD,{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)(uD,{open:x,onOpenChange:S,children:(0,G.jsxs)(dD,{className:`w-[min(560px,92vw)]`,initialFocus:D,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.address.lan`)})}),(0,G.jsx)(`div`,{ref:D,tabIndex:-1,className:`outline-none`,children:(0,G.jsx)(hD,{className:`max-h-[60vh] overflow-y-auto px-1 py-2`,children:(0,G.jsx)(Fj,{align:`start`,book:r,port:n.lan.port,value:r?.preferred??``,busy:a!==``,fallbackUrls:i,onChange:e=>{s(e),S(!1)}})})}),(0,G.jsx)(gD,{className:`flex justify-end`,children:(0,G.jsx)(Q,{variant:`outline`,onClick:()=>S(!1),children:$(`panel.common.close`)})})]})}),(0,G.jsx)(NN,{open:C,onOpenChange:w,onImport:e=>{e.field===`tcp`?(j.current=!0,h(e.value)):(k.current=!0,d(e.value))}}),(0,G.jsx)(GN,{open:T,onOpenChange:E,activeUrl:F?.url??``})]})}var JN=18e5,YN=3e5,XN=15e3,ZN=null,QN=0,$N=0,eP=null;function tP(e){return typeof e!=`number`||!Number.isFinite(e)?!1:e===0||Date.now()-e>JN}function nP(e){if(!e&&eP)return eP;let t=(async()=>{let t=await Bk(e?`/api/relay/selfcheck?force=1`:`/api/relay/selfcheck`);return ZN=t,QN=Date.now(),t})();return e||(eP=t,t.finally(()=>{eP===t&&(eP=null)})),t}function rP(e,t=``){let[n,r]=(0,g.useState)(ZN),[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&&ZN&&Date.now()-QN<XN){r(ZN);return}a(!0);try{let t=await nP(e);if(!u.current)return;r(t),s(``),l(!1)}catch(e){if(!u.current)return;l(e instanceof Rk&&e.status===404),s(Gk(e))}finally{u.current&&a(!1)}},[]);(0,g.useEffect)(()=>{e&&(Date.now()-$N<YN||ZN&&Date.now()-QN<XN||($N=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 iP(e){return e===`ok`?`ok`:e===`unknown`?`warn`:`error`}var aP={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 oP(e){return $(aP[e]?.long??`panel.selfcheck.verdict.unknown`)}function sP(e){if(!e)return{tone:`off`,text:$(`panel.selfcheck.notChecked`)};let t=e.firewall,n=uP(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 cP(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:tP(n))?{tone:`warn`,text:$(`panel.selfcheck.mobileIdle`),detail:vg(n)}:{tone:`ok`,text:$(`panel.selfcheck.mobileRecent`),detail:vg(n)}}function lP(e){let t={listening:`panel.lan.listening`,off:`panel.status.off`,error:`panel.lan.error`};return t[e]?$(t[e]):e}function uP(e){let t=String(e??``).trim();if(!t)return``;let n=t.split(/[\\/]/);return n[n.length-1]??``}function dP({open:e,onOpenChange:t,state:n,lastMobileAt:r}){(0,g.useEffect)(()=>{e&&n.ensure()},[e,n.ensure]);let i=n.data,a=sP(i),o=cP(i,r),s=i?iP(i.verdict):`warn`;return(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`max-w-xl`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.selfcheck.title`)})}),(0,G.jsxs)(hD,{className:`flex flex-col gap-3`,children:[n.error?(0,G.jsxs)(ZE,{variant:n.missing?`warning`:`error`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:n.missing?$(`panel.selfcheck.unavailable`):$(`panel.selfcheck.failed`)}),n.missing?null:(0,G.jsx)(tD,{children:n.error})]}):null,i?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`p`,{className:hg(`text-sm`,s===`ok`?`text-foreground`:_g[s]),children:oP(i.verdict)}),(0,G.jsxs)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.connection.lan`),children:(0,G.jsx)(AO,{tone:i.listening.state===`listening`?`ok`:i.listening.state===`error`?`error`:`off`,text:lP(i.listening.state),detail:$(`panel.selfcheck.port`,{port:i.listening.port})})}),(0,G.jsx)(OO,{label:$(`panel.connection.tunnel`),children:(0,G.jsx)(AO,{tone:yg(i.tunnel.state),text:bg(i.tunnel.state)})}),(0,G.jsx)(OO,{label:$(`panel.selfcheck.firewall`),children:(0,G.jsx)(AO,{tone:a.tone,text:a.text,detail:a.detail})}),(0,G.jsx)(OO,{label:$(`panel.selfcheck.mobile`),children:(0,G.jsx)(AO,{tone:o.tone,text:o.text,detail:o.detail})})]}),(0,G.jsx)(`p`,{className:`text-xs text-foreground-muted`,children:$(`panel.selfcheck.checkedAt`,{time:vg(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)(UE,{}),$(`panel.selfcheck.checking`)]}):null]}),(0,G.jsxs)(gD,{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 fP(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 pP(e){return e.length>16?`${e.slice(0,12)}…${e.slice(-4)}`:e}function mP({open:e,onOpenChange:t,onChanged:n}){let r=aM(),[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(``),[c,l]=(0,g.useState)(``),u=(0,g.useCallback)(async()=>{try{a(await Bk(`/api/relay/tailcat`)),s(``)}catch(e){s(Gk(e))}},[]);(0,g.useEffect)(()=>{if(!e)return;let t=()=>{d_()&&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`,Gk(e))}finally{l(``)}},[r,n]),f=e=>void d(`toggle`,()=>Vk(`/api/relay/tailcat/enabled`,{enabled:e}),$(e?`panel.tailcat.enabledToast`:`panel.tailcat.disabledToast`)),p=e=>{window.confirm($(`panel.tailcat.revokeConfirm`))&&d(`revoke`,()=>Vk(`/api/relay/tailcat/revoke`,{client:e}),$(`panel.tailcat.revokedToast`))},m=i?.status??null,h=i?.allowedClients??[];return(0,G.jsx)(uD,{open:e,onOpenChange:t,children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.tailcat.title`)})}),(0,G.jsxs)(hD,{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)(UE,{}),$(`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:[$(fP(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)(eO,{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:pP(e)}),(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:c!==``,onClick:()=>p(e),children:$(`panel.tailcat.revoke`)})]},e))})]})]})]}),(0,G.jsx)(gD,{className:`flex justify-end gap-2`,children:(0,G.jsx)(Q,{variant:`outline`,disabled:c!==``,onClick:()=>t(!1),children:$(`panel.common.close`)})})]})})}var hP=`/dsh-market/api/v1`,gP=`dsh-mobile-plugin`,_P=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}},vP=e=>e&&typeof e==`object`?e:{},yP=e=>typeof e==`string`&&e!==``?e:null;async function bP(e,t){let n;try{n=await fetch(`${hP}${e}`,{credentials:`same-origin`,...t})}catch(e){throw new _P(0,`market_unreachable`,$(`panel.net.marketUnreachable`,{message:String(e?.message||e)}))}let r=await n.json().catch(()=>null);if(!n.ok){let e=vP(r),t=vP(e.failure),i=yP(t.code)??(typeof e.error==`string`?e.error:`HTTP ${n.status}`),a=yP(t.message)??yP(e.error)??$(`panel.net.marketHttp`,{status:n.status});throw new _P(n.status,i,a)}return r}async function xP(){try{return{available:!0,restartSupported:vP(vP(await bP(`/capabilities`)).restart).supported===!0}}catch{return{available:!1,restartSupported:!1}}}async function SP(e=gP,t=!1){let n=vP(await bP(`/updates${`?name=${encodeURIComponent(e)}${t?`&force=1`:``}`}`)),r=vP(n.package??n);return{installedVersion:yP(r.installedVersion),latestVersion:yP(r.latestVersion),updateAvailable:r.updateAvailable===!0,source:yP(r.source)}}var CP={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`},wP=e=>e&&typeof e==`object`?e:{},TP=e=>typeof e==`string`&&e!==``?e:null,EP=e=>typeof e==`boolean`?e:null,DP=e=>typeof e==`number`&&Number.isFinite(e)?e:null;async function OP(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=wP(r),a=wP(i.error);if(!n.ok){let e=TP(a.code)??`http_${n.status}`;throw new Rk(TP(a.message)??$(`panel.net.hostHttp`,{status:n.status}),e,n.status)}return i}function kP(e){return e instanceof Rk?e.status===404:e instanceof SyntaxError}function AP(e){return e instanceof Rk&&e.code===`update_unavailable`}function jP(e){let t=wP(e);return Object.keys(t).length===0?null:{installedVersion:TP(t.installedVersion),latestVersion:TP(t.latestVersion),updateAvailable:t.updateAvailable===!0,source:TP(t.source),checkedAt:TP(t.checkedAt)}}function MP(e){let t=wP(e),n=wP(t.failure),r=TP(n.code);return{installed:EP(t.installed),skipped:EP(t.skipped),state:TP(t.state),beforeVersion:TP(t.beforeVersion),installedVersion:TP(t.installedVersion),swapped:EP(t.swapped),restartRequired:EP(t.restartRequired),refreshRequired:EP(t.refreshRequired),failure:r?{code:r,message:TP(n.message)??r}:null}}function NP(e){let t=wP(e);return{available:t.available===!0,version:TP(t.version),installedVersion:TP(t.installedVersion),source:TP(t.source),previousVersion:TP(t.previousVersion),activatedAt:TP(t.activatedAt),lastError:TP(t.lastError),inFlight:DP(t.inFlight)??0,swapping:t.swapping===!0,autoUpdate:t.autoUpdate===!0,autoIntervalMs:DP(t.autoIntervalMs)??6e5,marketBase:TP(t.marketBase),marketLastCheckedAt:TP(t.marketLastCheckedAt),marketLastError:TP(t.marketLastError),marketResult:jP(t.marketResult),lastApply:t.lastApply?MP(t.lastApply):null,appliedAt:TP(t.appliedAt),runningShellHash:TP(t.runningShellHash),installedShellHash:TP(t.installedShellHash),shellChanged:t.shellChanged===!0}}async function PP(){return NP((await OP(CP.status)).data)}async function FP(){let e=wP((await OP(CP.check,{method:`POST`,body:JSON.stringify({})})).data);return{update:jP(e.update),status:e.status?NP(e.status):null}}async function IP(e=!1){let t=wP((await OP(CP.apply,{method:`POST`,body:JSON.stringify({force:e})})).data),n=wP(t.status);return{...MP(t),status:Object.keys(n).length>0?NP(n):null}}async function LP(e){let t=wP((await OP(CP.auto,{method:`POST`,body:JSON.stringify({enabled:e})})).data);return{enabled:t.enabled===!0,status:t.status?NP(t.status):null}}var RP=new Set([`OPERATION_BUSY`,`RELEASE_TOO_FRESH`,`VERSION_UNCHANGED`,`PLUGIN_NOT_INSTALLED`,`AGENTS_RUNNING`]);function zP(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 BP({version:e,busy:t,onRestartSidecar:n,fill:r=!1}){let[i,a]=(0,g.useState)(null),[o,s]=(0,g.useState)(!1),[c,l]=(0,g.useState)(!1),[u,d]=(0,g.useState)(null),[f,p]=(0,g.useState)(null),[m,h]=(0,g.useState)(``),_=aM(),[v,y]=(0,g.useState)(!1),b=(0,g.useCallback)(e=>{e&&a(t=>({...e,available:e.available===!0||t?.available===!0}))},[]),x=i!==null&&i.available&&!c,S=t!==``||m!==``,C=(0,g.useCallback)(async()=>{try{let e=await PP();a(e),l(e.available!==!0)}catch(e){a(null),l(AP(e))}finally{s(!0)}},[]);(0,g.useEffect)(()=>{C()},[C]),(0,g.useEffect)(()=>{if(!o)return;let e=!0;return FP().then(t=>{e&&(t.update&&p(t.update),t.status&&b(t.status))}).catch(()=>{}),()=>{e=!1}},[o]);let w=i?.swapping===!0;(0,g.useEffect)(()=>{if(!w)return;let e=window.setInterval(()=>void C(),1500);return()=>window.clearInterval(e)},[w,C]),(0,g.useEffect)(()=>{if(x||!o)return;let e=!0;return xP().then(t=>{e&&d(t)}),()=>{e=!1}},[x,o]);let T=(0,g.useCallback)(e=>{if(e instanceof _P&&RP.has(e.code)){_(`soft`,`${e.message}(${e.code})`);return}_(`error`,Gk(e))},[]),E=(0,g.useCallback)(async()=>{h(`check`);try{let e=await FP();e.status&&b(e.status),e.update&&p(e.update)}catch(e){kP(e)||AP(e)?await C():_(`error`,Gk(e))}finally{h(``)}},[C]),D=(0,g.useCallback)(async e=>{h(`apply`);try{let t=await IP(e);t.status&&b(t.status);let n=zP(t),r=t.failure!==null&&RP.has(t.failure.code);n.ok||r?_(`soft`,n.text):_(`error`,n.text)}catch(e){kP(e)||AP(e)?await C():_(`error`,Gk(e))}finally{h(``)}},[C]),O=(0,g.useCallback)(async()=>{h(`check`);try{let e=await FP();e.status&&b(e.status),p(e.update)}catch(e){if(!kP(e))p(null),_(`error`,Gk(e));else try{p(await SP(void 0,!0))}catch(e){p(null),T(e)}}finally{h(``)}},[T]),k=(0,g.useCallback)(async e=>{y(!0);try{let t=await LP(e);t.status&&b(t.status);let n=Math.round((t.status?.autoIntervalMs??i?.autoIntervalMs??6e5)/6e4);_(`soft`,t.enabled?$(`panel.update.autoOn`,{minutes:n}):$(`panel.update.autoOff`))}catch(e){_(`error`,$(`panel.update.autoToggleFailed`,{message:Gk(e)})),await C()}finally{y(!1)}},[i?.autoIntervalMs,C]),A=f?.latestVersion??i?.marketResult?.latestVersion??null,j=f?.source??i?.marketResult?.source??null,M=j===`linked`||j===`file`||j===`workspace`,N=f?.updateAvailable??i?.marketResult?.updateAvailable??!1,P=i?.lastApply?zP(i.lastApply):null,F=e||`—`,I=i?.version??null,L=x&&!!I&&!!e&&I!==e,R=i?.installedVersion??null,z=x&&!!R&&!!e&&R!==e;return(0,G.jsxs)(CD,{frame:`solid`,className:r?`flex h-full min-h-0 flex-col`:void 0,children:[(0,G.jsx)(wD,{className:`px-4 py-3`,children:(0,G.jsxs)(TD,{className:`flex items-center gap-2 text-base lg:text-lg`,children:[(0,G.jsx)(`span`,{children:$(`panel.update.title`)}),(0,G.jsx)(aD,{variant:`soft`,size:`sm`,children:e||$(`panel.update.unknownVersion`)})]})}),o?null:(0,G.jsxs)(`div`,{className:`flex items-center gap-2 py-2 text-sm text-foreground-muted`,children:[(0,G.jsx)(UE,{}),$(`panel.update.reading`)]}),c?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.update.runningVersion`),mono:!0,children:F}),(0,G.jsx)(OO,{label:$(`panel.update.latestOnline`),mono:!0,children:A??$(`panel.update.notChecked`)})]}),(0,G.jsxs)(`p`,{className:`mt-3 text-xs text-foreground-muted`,children:[N?$(`panel.update.hasNew`):``,$(`panel.update.nothingToInstall`)]})]}):null,o&&!x&&!c&&u!==null&&!u.available?(0,G.jsxs)(ZE,{variant:`info`,className:`mt-3`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:$(`panel.update.noMarketTitle`)}),(0,G.jsx)(tD,{children:$(`panel.update.noMarketBody`)})]}):null,x&&i?(0,G.jsxs)(G.Fragment,{children:[M?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:[v?(0,G.jsx)(UE,{}):null,(0,G.jsx)(eO,{size:`md`,checked:i.autoUpdate,disabled:S||v,onCheckedChange:e=>void k(e),"aria-label":$(`panel.update.autoUpdate`)})]})]}),(0,G.jsxs)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.update.runningVersion`),mono:!0,children:F}),R?(0,G.jsx)(OO,{label:$(`panel.update.diskVersion`),mono:!0,children:R}):null,(0,G.jsx)(OO,{label:$(`panel.update.latestOnline`),mono:!0,children:A??$(`panel.update.notChecked`)})]}),L?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.versionDrift`,{version:e??``,shell:I??``})}):null,z?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.diskDrift`,{disk:R??``,running:e??``})}):null,i.lastError?(0,G.jsx)(`p`,{className:`mt-2 text-xs text-foreground-muted`,children:$(`panel.update.lastErrorLine`,{message:i.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:S,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:S,onClick:()=>void E(),children:$(m===`check`?`panel.update.checking`:`panel.update.check`)}),M?null:(0,G.jsx)(Q,{variant:`primary`,size:`md`,disabled:S,onClick:()=>void D(!1),children:$(m===`apply`?`panel.update.updating`:`panel.update.updateNow`)})]}),!M&&(N||P!==null&&!P.ok)?(0,G.jsx)(`div`,{className:`mt-2 flex justify-end`,children:(0,G.jsx)(Q,{variant:`ghost`,size:`sm`,disabled:S,onClick:()=>void D(!0),children:$(`panel.update.forceHint`)})}):null]}):null,o&&!x&&!c&&u?.available?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.update.runningVersion`),mono:!0,children:F}),(0,G.jsx)(OO,{label:$(`panel.update.latestOnline`),mono:!0,children:A??$(`panel.update.notChecked`)}),(0,G.jsx)(OO,{label:$(`panel.update.checkResult`),children:$(N?`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:S,onClick:n,children:$(`panel.update.restartSidecar`)}),(0,G.jsx)(Q,{variant:`outline`,size:`md`,disabled:S,onClick:()=>void O(),children:$(m===`check`?`panel.update.checking`:`panel.update.check`)}),i!==null&&!M?(0,G.jsx)(Q,{variant:`primary`,size:`md`,disabled:S,onClick:()=>void D(!1),children:$(m===`apply`?`panel.update.updating`:`panel.update.updateNow`)}):null]})]}):null]})}function VP({webAccess:e,busy:t,onToggle:n}){let r=e?.enabled===!0,i=typeof e?.expiresAt==`number`?e.expiresAt:0;return(0,G.jsxs)(CD,{frame:`solid`,children:[(0,G.jsx)(wD,{className:`px-4 py-3`,children:(0,G.jsx)(TD,{className:`text-base lg:text-lg`,children:$(`panel.webAccess.title`)})}),(0,G.jsx)(kO,{children:(0,G.jsx)(OO,{label:$(`panel.webAccess.state`),tone:r?`ok`:`off`,children:r?$(`panel.webAccess.expires`,{time:vg(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 HP(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 UP=1500,WP=600;function GP(){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 KP(){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=aM();(0,g.useEffect)(()=>{e?HP(`ready`):n&&HP(`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=rP(tP(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 Bk(`/api/relay/status`)),r(``)}catch(e){r(Gk(e))}},[]),j=(0,g.useCallback)(async()=>{l(``);try{s(await Bk(`/api/relay/pairing`)),l(``)}catch(e){s(null),l(Gk(e))}},[]),M=(0,g.useCallback)(async()=>{try{d(await Bk(`/api/relay/addresses`))}catch{d(null)}},[]);(0,g.useEffect)(()=>{let e=()=>{d_()&&A()};e();let t=0,n=window.setTimeout(()=>{t=window.setInterval(e,3e3)},UP);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(),WP);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 Bk(`/api/relay/pairing`)),l(``)}catch{}},[]);(0,g.useEffect)(()=>{if(!e?.enabled)return;let t=Lk(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(),WP);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`,Gk(e))}finally{a(``)}},[T]),F=e=>P(`toggle`,async()=>{t(await Vk(`/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 Vk(`/api/relay/restart-sidecar`);t(e.status),T(`soft`,$(`panel.shell.sidecarRestarted`))}),L=()=>{window.confirm($(`panel.shell.revokeConfirm`))&&P(`revoke`,async()=>{let e=await Vk(`/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 Vk(`/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 Vk(`/api/relay/config`,e)),p(!1),await j(),T(`soft`,$(`panel.shell.configSaved`))}),B=e=>P(`policy`,async()=>{t(await Vk(`/api/relay/config`,{pairingPolicy:e})),T(`soft`,$(e===`code`?`panel.shell.deviceAllowed`:`panel.shell.deviceDenied`))}),V=e=>P(`tier`,async()=>{t(await Vk(`/api/relay/config`,{pairingTier:e})),T(`soft`,$(`panel.shell.configSaved`))}),H=e=>P(`autoReview`,async()=>{t(await Vk(`/api/relay/config`,{approvalAutoReview:e})),T(`soft`,$(e?`panel.shell.autoReviewOn`:`panel.shell.autoReviewOff`))}),U=e=>P(`controlReport`,async()=>{t(await Vk(`/api/relay/config`,{controlReportEnabled:e})),T(`soft`,$(`panel.shell.configSaved`))}),W=e=>P(`lan`,async()=>{t(await Vk(`/api/relay/config`,{lanPort:e})),h(!1),await j(),T(`soft`,$(`panel.shell.lanSaved`))}),ee=e=>P(`lan`,async()=>{t(await Vk(`/api/relay/config`,{preferredLanAddress:e})),await Promise.all([j(),M()]),T(`soft`,e?$(`panel.shell.preferredAddress`,{address:e}):$(`panel.shell.preferredAuto`))}),K=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:[K?(0,G.jsx)(DO,{tone:K}):null,(0,G.jsx)(`span`,{className:`truncate text-sm font-medium text-foreground`,children:e.name||e.instanceId}),(0,G.jsx)(aD,{variant:`soft`,size:`sm`,children:e.appVersion||$(`panel.shell.unknownVersion`)}),(0,G.jsx)(HM,{compact:!0})]}),i?(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-foreground-muted`,children:[(0,G.jsx)(UE,{}),$(`panel.shell.busy`)]}):null,(0,G.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[(0,G.jsx)(QM,{lanPort:e.lan.port}),(0,G.jsx)(kg,{}),(0,G.jsx)(s_,{}),(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)(GP,{})}),(0,G.jsx)(HO,{})]})]}),n?(0,G.jsxs)(ZE,{variant:`error`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:$(`panel.shell.statusFailed`)}),(0,G.jsx)(tD,{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)(eM,{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),onChangeControlReport:e=>void U(e),onOpenSelfCheck:()=>v(!0),onRetryPairing:()=>void j(),onSavePreferred:e=>void ee(e),onEditPort:()=>h(!0)})}),(0,G.jsx)(`div`,{className:`md:col-span-2`,children:(0,G.jsx)(BP,{fill:!0,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)(FO,{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)(gM,{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)(VP,{webAccess:e.webAccess,busy:i,onToggle:e=>void R(e)}):null})]}),(0,G.jsx)(qN,{open:f,onOpenChange:p,status:e,addressBook:u,lanUrls:o?.lanUrls??[],busy:i,onSave:e=>void z(e),onSavePreferred:e=>void ee(e)}),(0,G.jsx)(dP,{open:_,onOpenChange:v,state:k,lastMobileAt:e.lastMobileAt}),(0,G.jsx)(mP,{open:y,onOpenChange:b,onChanged:()=>void A()}),(0,G.jsx)(tN,{open:x,onOpenChange:S,onChanged:()=>void A()}),(0,G.jsx)(hN,{open:m,onOpenChange:h,port:o?.lanPort??e.lan.requestedPort??e.lan.port,busy:i,onSave:e=>void W(e)}),(0,G.jsx)(uD,{open:C,onOpenChange:w,children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.inbox.title`)})}),(0,G.jsx)(hD,{children:(0,G.jsx)(GM,{framed:!1})})]})}),(0,G.jsx)(gN,{visible:Vj(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)(UE,{}),$(`panel.shell.readingStatus`)]})})}var qP=[{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`}],JP=[{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`}],YP=[{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 XP(){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 ZP({title:e,steps:t,port:n,onCopied:r}){async function i(){try{await navigator.clipboard.writeText(XP()),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 QP({open:e,onOpenChange:t,port:n}){let[r,i]=(0,g.useState)(``),a=e=>i(e?`ok`:`failed`);return(0,G.jsx)(uD,{open:e,onOpenChange:e=>{e||i(``),t(e)},children:(0,G.jsxs)(dD,{className:`w-[min(1200px,92vw)] max-w-none`,backdropProps:{className:`z-[80]`},viewportProps:{className:`z-[80]`},children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.onboarding.firewallTitle`)})}),(0,G.jsxs)(hD,{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)(ZP,{title:`Linux`,steps:qP,port:n,onCopied:a}),(0,G.jsx)(ZP,{title:`Mac`,steps:JP,port:n,onCopied:a}),(0,G.jsx)(ZP,{title:`Windows`,steps:YP,port:n,onCopied:a})]})]}),r?(0,G.jsx)(gD,{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 $P(e){let t=(e.preferred||``).trim();return t&&e.lan.some(e=>e.address===t)?t:e.lan[0]?.address??``}function eF({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=rP(tP(t?.lastMobileAt),t?`${+!!t.enabled}|${+!!t.lan.enabled}|${t.lan.state}|${t.tunnel.state}|${+((t.lastMobileAt??0)>0)}`:``),k=sP(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 Bk(`/api/relay/addresses`);f(e),y($P(e))}catch{f(null),u(!0)}})()},[]),(0,g.useEffect)(()=>{(async()=>{try{let e=await Bk(`/api/relay/status`);n(e),e.enabled&&u(!0)}catch(e){i(Gk(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 Bk(`/api/relay/pairing`))}catch(e){_(Gk(e))}}(0,g.useEffect)(()=>{let e=Lk(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 Bk(`/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:Bj.map(e=>e.url),lanEnabled:!0,pairingPolicy:`code`};v&&(t.preferredLanAddress=v);try{n(await Vk(`/api/relay/config`,t)),e&&(n(await Vk(`/api/relay/toggle`,{enabled:!0})),await Vk(`/api/relay/onboarded`,{}).catch(()=>void 0)),await N(),e&&L().finally(()=>{j.current&&u(!0)})}catch(t){e&&j.current&&u(!0),o(Gk(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)(ZE,{className:`w-full max-w-4xl`,variant:`error`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:$(`panel.onboarding.statusFailed`)}),(0,G.jsx)(tD,{children:r})]}):null,a?(0,G.jsxs)(ZE,{className:`w-full max-w-4xl`,variant:`error`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:$(`panel.onboarding.stepFailed`)}),(0,G.jsx)(tD,{children:a})]}):null,(0,G.jsxs)(CD,{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)(UE,{}):$(`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)(Gj,{})]}),(0,G.jsxs)(`div`,{className:`w-full md:col-span-2 md:row-start-2 [&_dt]:text-foreground-strong`,children:[(0,G.jsxs)(kO,{children:[(0,G.jsx)(OO,{label:$(`panel.onboarding.direct`),children:(0,G.jsx)(AO,{tone:xg(t?.lan.state??`off`,!0),text:Sg(t?.lan.state??`off`,!0)})}),(0,G.jsx)(OO,{label:$(`panel.connection.tunnel`),children:(0,G.jsx)(AO,{tone:yg(t?.tunnel.state??`off`),text:bg(t?.tunnel.state??`off`)})}),(0,G.jsx)(OO,{label:$(`panel.tailcat.title`),children:(0,G.jsxs)(`span`,{className:`inline-flex items-center justify-end gap-1.5`,children:[(0,G.jsx)(AO,{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)(EO,{})}):null]})}),(0,G.jsx)(OO,{label:$(`panel.selfcheck.firewall`),children:(0,G.jsx)(AO,{tone:k.tone,text:k.text,detail:k.detail})})]}),I?(0,G.jsx)(`p`,{className:`mt-2 text-sm leading-relaxed break-words ${_g[iP(A)]}`,children:oP(A)}):null,t!==null&&(t.lan.state===`error`||t.tunnel.state===`error`)?(0,G.jsxs)(ZE,{className:`mt-2`,variant:`error`,children:[(0,G.jsx)($E,{}),(0,G.jsx)(eD,{children:t.lan.state===`error`?$(`panel.onboarding.lanFailed`):$(`panel.onboarding.relayFailed`)}),(0,G.jsx)(tD,{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)(QP,{open:b,onOpenChange:x,port:P}),(0,G.jsx)(uD,{open:S,onOpenChange:C,children:(0,G.jsxs)(dD,{className:`w-[min(680px,94vw)] max-w-none`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.pairing.qr`)})}),(0,G.jsx)(hD,{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)(uD,{open:w,onOpenChange:T,children:(0,G.jsxs)(dD,{className:`max-w-md`,closeLabel:$(`panel.common.close`),children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.tailcat.title`)})}),(0,G.jsxs)(hD,{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 tF(e){let t=typeof e==`string`?e:e instanceof Rk?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 nF=`/api/relay/remote-computers`,rF={list:()=>Bk(nF),invite:()=>Vk(`${nF}/invite`,{}),add:e=>Vk(`${nF}/add`,{invite:e}),open:e=>Vk(`${nF}/open`,{id:e}),openShell:e=>Vk(`${nF}/open-shell`,{id:e}),diagnose:e=>Vk(`${nF}/diagnose`,{id:e}),remove:e=>Vk(`${nF}/remove`,{id:e}),mode:(e,t)=>Vk(`${nF}/mode`,{id:e,mode:t}),revoke:e=>Vk(`${nF}/revoke`,{deviceId:e})};function iF(e){return[`auto`,...new Set(e.map(e=>e.channel).filter(e=>e&&e!==`auto`&&e!==`direct`))]}function aF(e){let t;try{t=new URL(e)}catch{throw new Rk($(`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 Rk($(`panel.remote.invalidOpenUrl`),`REMOTE_OPEN_URL`,0);return t.href}function oF(e){return e instanceof Rk?e.code===`SHELL_UNAVAILABLE`||e.status===404||e.status===405||e.status===0:e instanceof TypeError}async function sF(e){try{let t=await rF.openShell(e);return aF(t.url),t.shellOpened===!1?{...await cF(e),shellOpened:!1}:t}catch(t){if(!oF(t))throw t;return{...await cF(e),shellMissing:!0}}}async function cF(e){let t=window.location.protocol===`http:`||window.location.protocol===`https:`,n=t?window.open(`about:blank`,`_blank`):null;if(t&&!n)throw new Rk($(`panel.remote.popupBlocked`),`REMOTE_POPUP`,0);try{n&&(n.opener=null);let t=await rF.open(e),r=aF(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 Rk($(`panel.remote.externalOpenFailed`),`REMOTE_EXTERNAL_OPEN`,0)}return t}catch(e){throw n?.close(),e}}function lF(){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 uF(){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 dF(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 fF(e){try{return new URL(e).host}catch{return e}}function pF(){let e=aM(),[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 rF.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 Rk&&e.status===403;o(t),c(t?``:tF(e)),t&&n(null)}finally{j.current=!1,M.current&&i(!0)}}},[]);(0,g.useEffect)(()=>{M.current=!0;let e=()=>{d_()&&(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 Rk&&t.status===403&&(o(!0),n(null),f(null),x(null),m(null)),e(`error`,t instanceof Rk&&t.status===403?$(`panel.remote.localOnly`):tF(t))}finally{u(e=>e.filter(e=>e!==t))}}}async function L(t){if(!E){D(!0);try{T((await rF.diagnose(t.id)).routes)}catch(t){e(`error`,tF(t))}finally{D(!1)}}}function R(){m(null),y(!1),f(`invite`),I(`invite`,async()=>{m(await rF.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 sF(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}`,()=>rF.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)(CD,{frame:`solid`,className:`flex h-full min-h-0 flex-col`,children:[(0,G.jsx)(wD,{className:`flex-none px-4 py-3`,children:(0,G.jsxs)(TD,{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)(aD,{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)(UE,{}),$(`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)(aD,{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:[dF(e.mode),` · `,dF(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)(lF,{})}),(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)(uF,{})}),a?(0,G.jsx)(UE,{}):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:tF(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}`,()=>rF.revoke(e.deviceId),`panel.remote.revoked`)},children:(0,G.jsx)(uF,{})})]},e.deviceId))]}):null]}):null,(0,G.jsx)(uD,{open:d!==null,onOpenChange:e=>{!e&&!K&&(f(null),m(null))},children:(0,G.jsxs)(dD,{className:`max-w-md`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(d===`invite`?`panel.remote.createInvite`:`panel.remote.add`)})}),(0,G.jsxs)(hD,{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)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`remote-computer-invite`,children:$(`panel.remote.inviteLabel`)}),(0,G.jsx)(xN,{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)(UE,{}):null:(0,G.jsxs)(cN,{children:[(0,G.jsx)(lN,{htmlFor:`remote-computer-add`,children:$(`panel.remote.inviteLabel`)}),(0,G.jsx)(xN,{id:`remote-computer-add`,rows:4,value:h,onChange:e=>_(e.target.value),autoComplete:`off`,spellCheck:!1})]})]}),(0,G.jsxs)(gD,{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 rF.add(h.trim()),_(``),f(null)},`panel.remote.added`),children:$(`panel.remote.add`)})]})]})}),(0,G.jsx)(uD,{open:b!==null,onOpenChange:e=>{!e&&!te&&(x(null),T(null))},children:(0,G.jsxs)(dD,{className:`max-w-sm`,children:[(0,G.jsx)(fD,{children:(0,G.jsx)(pD,{children:$(`panel.remote.route`)})}),(0,G.jsxs)(hD,{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)(Nk,{className:`flex flex-col gap-2`,value:S,onValueChange:e=>{typeof e==`string`&&C(e)},children:iF(b?.routes??[]).map(e=>(0,G.jsxs)(`label`,{className:`flex cursor-pointer items-center gap-2`,children:[(0,G.jsx)(_k,{value:e}),(0,G.jsx)(`span`,{children:dF(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)(UE,{}):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:[dF(e.channel),` · `,fF(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?` · ${tF(e.errorCode)}`:``]})]},`${e.channel}:${e.url}`))}):null]})]}),(0,G.jsxs)(gD,{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||!iF(b?.routes??[]).includes(S),onClick:()=>{b&&I(`mode:${b.id}`,async()=>{await rF.mode(b.id,S),x(null)},`panel.remote.modeSaved`)},children:$(`panel.common.save`)})]})]})})]})}function mF(){try{let e=new URL(document.baseURI);return e.pathname=e.pathname.replace(/\/remote\/?$/,`/console`),e.search=``,e.hash=``,e.href}catch{return``}}function hF(){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=mF()},children:$(`panel.remote.backConsole`)}),(0,G.jsx)(HO,{})]})]}),(0,G.jsx)(pF,{})]})}function gF(){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?HP(`error`,s):(!i||a!==null)&&HP(`ready`)},[a,s,i]),(0,g.useEffect)(()=>{if(!i)return;let e=!0;return(async()=>{try{let t=await Bk(`/api/relay/status`);e&&o(t.onboarded===!0||t.enabled===!0)}catch(t){e&&c(Gk(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)(hF,{}):t?l?(0,G.jsx)(KP,{}):(0,G.jsx)(eF,{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)(UE,{}),$(`panel.shell.loading`)]}):!a&&!l?(0,G.jsx)(eF,{onDone:()=>u(!0)}):(0,G.jsx)(KP,{})}function _F(){let e=wg();(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 n_()},[n]),(0,g.useEffect)(()=>f_(),[]),(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(gF,{}),n?null:(0,G.jsx)(c_,{})]})}function vF(){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`)}vF();function yF(){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(_F,{}),(0,G.jsx)(td,{position:`top-right`})]})}(0,gd.createRoot)(document.getElementById(`root`),{onUncaughtError:e=>HP(`error`,Gk(e))}).render((0,G.jsx)(g.StrictMode,{children:(0,G.jsx)(ed,{children:(0,G.jsx)(yF,{})})}));</script>
|