const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./AppShell-CQvlT8mw.js","./rolldown-runtime-C0FnF6B9.js","./codemirror-CTwcbJL3.js","./file-preview-vendor-CwB0RzA5.js","./file-preview-vendor-DoXNJB2t.css","./theme-provider-DQgPGTNt.js","./i18n-DeUk-25j.js","./useTranslation-203uReis.js","./electron-6qqy_MBq.js","./dist-C3e0Op3d.js","./ui-vendor-Cxmm60yq.js","./main-axios-C9u_2VZF.js","./TabContext-D3vrdN81.js","./sheet-DTXfkMEX.js","./utils-DgxDy7ZJ.js","./use-mobile-DG8XVgKc.js","./use-ai-availability-Cq7eQkeb.js","./dropdown-menu-D1qdd0Yn.js","./rail-items-DjsS8mSD.js","./alerts-api-Be1rB0mm.js","./apply-ui-preset-pM0o_9ai.js","./dialog-DjGP9Pk1.js","./select-B1_G8Q9E.js","./kbd-CMVu8W5p.js","./tabUtils-CaK8shA7.js","./local-adaptive-engine-4n61WanU.js","./global-shortcut-handler-CZH5Ntqg.js","./workspaces-api-DQCVATAC.js","./ServerStatusContext-B3FpmkUf.js","./stats-widgets-C-2oAfGN.js","./transferProgressMonitor-C2NGTCYF.js","./HostManagerData-DXgap_XO.js","./host-connection-tabs-jWpQ9MXe.js","./quick-connect-host-m9ZIg2fL.js","./TerminalApp-CQG0_JuX.js","./Terminal-DJGvVEY0.js","./CommandHistoryContext-DjkpOcX6.js","./terminal-vendor-Dc02Ekzn.js","./terminal-vendor-BrP-ENHg.css","./WarpgateDialog-BD6ReVCg.js","./label-suu6ok-n.js","./clipboard-5EIl3z2t.js","./password-input-C6OTZdDF.js","./TOTPDialog-1Kx1i-9n.js","./terminal-themes-Re7orZjY.js","./terminal-theme-fMUF2uQ4.js","./tooltip-BGh94Nhj.js","./use-confirmation-e4Th94Qh.js","./ConnectionScreen-W-nM4gEW.js","./ShareSessionModal-Dw9UPGZ_.js","./session-sharing-api-BEhRd3Zy.js","./HostItem-DP52fjVp.js","./use-status-color-scheme-C2cWEXnf.js","./host-permissions-Bx4_iJy0.js","./local-adaptive-preferences-DD4uGSfL.js","./terminal-font-zoom-i-hjUJTS.js","./touch-input-settings-store-BCHI5T01.js","./snippet-variables-BvyHgYK6.js","./SnippetVariablesDialog-Cmzfa8Xo.js","./FullScreenAppWrapper-DqPibint.js","./skeleton-MluA_XaW.js","./FileManagerApp-B6W17Uk-.js","./FileManager-B3wbyAsc.js","./esm-Djqs40tV.js","./monaco-CZbP-9oW.js","./useConnectionRetry-CAUTw5LX.js","./TunnelApp-Cb912Ge1.js","./TunnelTab-DBUZpuv6.js","./card-BW2RjvL-.js","./tunnel-endpoints-BTiwMhPE.js","./HostMetricsApp-0PuFKL5t.js","./HostMetricsTab-WyDpnHFQ.js","./use-adaptive-polling-DQaG8M9_.js","./MetricCard-jXy0KSzE.js","./ProxmoxStatsApp-CPgaXYuW.js","./ProxmoxStatsTab-Cu4Qqf4J.js","./DockerApp-DCnfI2II.js","./DockerManager-ChAHUYhX.js","./alert-DWLe_kzz.js","./section-card-BcECN3Dt.js","./GuacamoleApp-n6Fg5qCe.js","./remote-desktop-vendor-D7-_CoWC.js","./GuacamoleDisplay-Bw4ks9ju.js","./TmuxMonitorApp-C52noJH7.js","./TmuxMonitor-DOB3PMgB.js","./popover-CwlPAg01.js","./badge-BjgH0Osd.js","./HomepageApp-GjXSOs0G.js","./HomepageCanvas-CyrmN7Xz.js","./switch-kxK0B462.js","./textarea-D6Kf0Czq.js","./use-page-visible-interval-DcWrxu6-.js","./ElectronVersionCheck-7i-K7yBB.js","./SharedSessionView-CdGdpWYi.js"])))=>i.map(i=>d[i]); import{o as e}from"./rolldown-runtime-C0FnF6B9.js";import{_ as t,v as n}from"./codemirror-CTwcbJL3.js";import{t as r}from"./react-vendor-DHaUBSmQ.js";import{p as i}from"./file-preview-vendor-CwB0RzA5.js";import{n as a,t as o}from"./theme-provider-DQgPGTNt.js";import{i as s,r as c,t as l}from"./i18n-DeUk-25j.js";import{t as u}from"./useTranslation-203uReis.js";import{t as d}from"./electron-6qqy_MBq.js";import{r as f,t as p}from"./dist-C3e0Op3d.js";import{$i as m,Ca as h,Da as g,Ea as _,Fn as v,G as ee,Gn as y,Kn as b,Or as te,Sa as ne,Tr as re,Yr as ie,_a as x,d as ae,hi as oe,kr as S,on as se,va as ce,vr as le,xa as ue,ya as C}from"./ui-vendor-Cxmm60yq.js";import{t as w}from"./utils-DgxDy7ZJ.js";import{$a as T,A as de,E,Er as fe,F as pe,H as me,I as he,L as ge,O as _e,T as D,Tr as ve,_ as ye,ai as be,b as xe,ci as Se,dt as O,g as Ce,h as k,i as A,ii as we,l as Te,li as Ee,r as De,ri as Oe,si as ke,st as Ae,tr as je,v as Me}from"./main-axios-C9u_2VZF.js";(function(){let e=document.createElement(`link`).relList;if(e&&e.supports&&e.supports(`modulepreload`))return;for(let e of document.querySelectorAll(`link[rel="modulepreload"]`))n(e);new MutationObserver(e=>{for(let t of e)if(t.type===`childList`)for(let e of t.addedNodes)e.tagName===`LINK`&&e.rel===`modulepreload`&&n(e)}).observe(document,{childList:!0,subtree:!0});function t(e){let t={};return e.integrity&&(t.integrity=e.integrity),e.referrerPolicy&&(t.referrerPolicy=e.referrerPolicy),t.credentials=e.crossOrigin===`use-credentials`?`include`:e.crossOrigin===`anonymous`?`omit`:`same-origin`,t}function n(e){if(e.ep)return;e.ep=!0;let n=t(e);fetch(e.href,n)}})();var Ne=`termix_client_cache_version`,Pe=`2.7.1`;async function Fe(){if(!(`caches`in window))return;let e=await caches.keys();await Promise.all(e.map(e=>caches.delete(e)))}async function j(){if(!(`serviceWorker`in navigator))return;let e=await navigator.serviceWorker.getRegistrations();await Promise.all(e.map(e=>e.unregister()))}function Ie(){try{localStorage.setItem(Ne,Pe)}catch{}}async function Le(){if(typeof window>`u`)return;let e=null;try{e=localStorage.getItem(Ne)}catch{e=null}e!==Pe&&(await Promise.allSettled([Fe(),j()]),Ie())}var M=e(n(),1),Re=r(),N=t(),P=({...e})=>{let{theme:t=`system`}=a();return(0,N.jsx)(p,{theme:t,className:`toaster group`,toastOptions:{classNames:{toast:`group toast group-[.toaster]:bg-card group-[.toaster]:text-card-foreground group-[.toaster]:border-border group-[.toaster]:rounded-none! group-[.toaster]:shadow-lg group-[.toaster]:font-mono`,description:`group-[.toast]:text-muted-foreground`,actionButton:`group-[.toast]:bg-accent-brand group-[.toast]:text-white group-[.toast]:font-semibold`,cancelButton:`group-[.toast]:bg-muted group-[.toast]:text-muted-foreground`,success:`group-[.toast]:!text-accent-brand group-[.toast]:!border-accent-brand/30`,info:`group-[.toast]:!text-accent-brand group-[.toast]:!border-accent-brand/30`,error:`group-[.toast]:!text-destructive group-[.toast]:!border-destructive/30`}},style:{"--radius":`0px`,"--normal-bg":`var(--card)`,"--normal-border":`var(--border)`,"--normal-text":`var(--card-foreground)`,"--success-bg":`var(--card)`,"--success-border":`var(--border)`,"--success-text":`var(--color-accent-brand)`,"--info-bg":`var(--card)`,"--info-border":`var(--border)`,"--info-text":`var(--color-accent-brand)`,"--error-bg":`var(--card)`,"--error-border":`var(--border)`,"--error-text":`var(--destructive)`},...e})},ze=Object.defineProperty,F=(e,t)=>ze(e,`name`,{value:t,configurable:!0}),Be=`Checkbox`,[Ve,He]=ue(Be),[I,L]=Ve(Be);function R(e){let{__scopeCheckbox:t,checked:n,children:r,defaultChecked:i,disabled:a,form:o,name:s,onCheckedChange:c,required:l,value:u=`on`,internal_do_not_use_render:d}=e,[f,p]=ce({prop:n,defaultProp:i??!1,onChange:c,caller:Be}),[m,h]=M.useState(null),[g,_]=M.useState(null),v=M.useRef(!1),[ee,y]=M.useReducer(e=>e+1,0),b=!m||!!o||!!m.closest(`form`),te={checked:f,disabled:a,setChecked:p,control:m,setControl:h,name:s,form:o,value:u,hasConsumerStoppedPropagationRef:v,userInteractionCount:ee,onUserInteraction:y,required:l,defaultChecked:!B(i)&&i,isFormControl:b,bubbleInput:g,setBubbleInput:_};return(0,N.jsx)(I,{scope:t,...te,children:z(d)?d(te):r})}F(R,`CheckboxProvider`);var Ue=`CheckboxTrigger`,We=M.forwardRef(F(function({__scopeCheckbox:e,onKeyDown:t,onClick:n,...r},i){let{control:a,value:o,disabled:s,checked:c,required:l,setControl:u,setChecked:d,hasConsumerStoppedPropagationRef:f,onUserInteraction:p,isFormControl:m,bubbleInput:h}=L(Ue,e),g=_(i,u),v=M.useRef(c);return M.useEffect(()=>{let e=a?.form;if(e){let t=F(()=>d(v.current),`reset`);return e.addEventListener(`reset`,t),()=>e.removeEventListener(`reset`,t)}},[a,d]),(0,N.jsx)(ne.button,{type:`button`,role:`checkbox`,"aria-checked":B(c)?`mixed`:c,"aria-required":l,"data-state":Xe(c),"data-disabled":s?``:void 0,disabled:s,value:o,...r,ref:g,onKeyDown:C(t,e=>{e.key===`Enter`&&e.preventDefault()}),onClick:C(n,e=>{p(),d(e=>B(e)?!0:!e),h&&m&&(f.current=e.isPropagationStopped(),f.current||e.stopPropagation())})})},`CheckboxTrigger`)),Ge=M.forwardRef(F(function(e,t){let{__scopeCheckbox:n,name:r,checked:i,defaultChecked:a,required:o,disabled:s,value:c,onCheckedChange:l,form:u,...d}=e;return(0,N.jsx)(R,{__scopeCheckbox:n,checked:i,defaultChecked:a,disabled:s,required:o,onCheckedChange:l,name:r,form:u,value:c,internal_do_not_use_render:({isFormControl:e})=>(0,N.jsxs)(N.Fragment,{children:[(0,N.jsx)(We,{...d,ref:t,__scopeCheckbox:n}),e&&(0,N.jsx)(Ye,{__scopeCheckbox:n})]})})},`Checkbox`)),Ke=`CheckboxIndicator`,qe=M.forwardRef(F(function(e,t){let{__scopeCheckbox:n,forceMount:r,...i}=e,a=L(Ke,n);return(0,N.jsx)(x,{present:r||B(a.checked)||a.checked===!0,children:(0,N.jsx)(ne.span,{"data-state":Xe(a.checked),"data-disabled":a.disabled?``:void 0,...i,ref:t,style:{pointerEvents:`none`,...e.style}})})},`CheckboxIndicator`)),Je=`CheckboxBubbleInput`,Ye=M.forwardRef(F(function({__scopeCheckbox:e,onClick:t,...n},r){let{control:i,hasConsumerStoppedPropagationRef:a,userInteractionCount:o,checked:s,defaultChecked:c,required:l,disabled:u,name:d,value:f,form:p,bubbleInput:h,setBubbleInput:g}=L(Je,e),v=_(r,g),ee=m(i),y=M.useRef(!1),b=M.useRef(s),te=M.useRef(o);M.useEffect(()=>{let e=h;if(!e)return;let t=window.HTMLInputElement.prototype,n=Object.getOwnPropertyDescriptor(t,`checked`).set,r=o!==te.current;te.current=o;let i=b.current!==s;b.current=s;let c=!(r&&a.current);if(i&&n){y.current=!r;let t=new Event(`click`,{bubbles:c});e.indeterminate=B(s),n.call(e,!B(s)&&s),e.dispatchEvent(t),y.current=!1}},[h,s,a,o]);let re=M.useRef(!B(s)&&s);return(0,N.jsx)(ne.input,{type:`checkbox`,"aria-hidden":!0,defaultChecked:c??re.current,required:l,disabled:u,name:d,value:f,form:p,...n,tabIndex:-1,ref:v,onClick:C(t,e=>{y.current&&e.stopPropagation()}),style:{...n.style,...ee,position:`absolute`,pointerEvents:`none`,opacity:0,margin:0,transform:`translateX(-100%)`}})},`CheckboxBubbleInput`));function z(e){return typeof e==`function`}F(z,`isFunction`);function B(e){return e===`indeterminate`}F(B,`isIndeterminate`);function Xe(e){return B(e)?`indeterminate`:e?`checked`:`unchecked`}F(Xe,`getState`);var Ze=g(`group/button inline-flex shrink-0 items-center justify-center rounded-none border border-transparent bg-clip-padding text-xs font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{default:`bg-primary text-primary-foreground [a]:hover:bg-primary/80`,outline:`border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50`,secondary:`bg-secondary text-secondary-foreground hover:bg-secondary/80 aria-expanded:bg-secondary aria-expanded:text-secondary-foreground`,ghost:`hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50`,destructive:`bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40`,link:`text-primary underline-offset-4 hover:underline`},size:{default:`h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,xs:`h-6 gap-1 rounded-none px-2 text-xs has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3`,sm:`h-7 gap-1 rounded-none px-2.5 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5`,lg:`h-9 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2`,icon:`size-8`,"icon-xs":`size-6 rounded-none [&_svg:not([class*='size-'])]:size-3`,"icon-sm":`size-7 rounded-none`,"icon-lg":`size-9`}},defaultVariants:{variant:`default`,size:`default`}});function V({className:e,variant:t=`default`,size:n=`default`,asChild:r=!1,...i}){let a=r?h:`button`;return(0,N.jsx)(a,{"data-slot":`button`,"data-variant":t,"data-size":n,className:w(Ze({variant:t,size:n,className:e})),...i})}function H({className:e,type:t,...n}){return(0,N.jsx)(`input`,{type:t,"data-slot":`input`,className:w(`h-8 w-full min-w-0 rounded-none border border-input bg-transparent px-2.5 py-1 text-xs transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-xs file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-1 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-1 aria-invalid:ring-destructive/20 md:text-xs dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40`,t===`number`&&`[appearance:textfield] [&::-webkit-outer-spin-button]:appearance-none [&::-webkit-inner-spin-button]:appearance-none`,e),...n})}function Qe({className:e,orientation:t=`horizontal`,decorative:n=!0,...r}){return(0,N.jsx)(oe,{"data-slot":`separator`,decorative:n,orientation:t,className:w(`shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch`,e),...r})}async function $e(){try{return(await A.get(`/users/sso-providers`)).data}catch(e){return console.warn(`Failed to fetch SSO providers:`,e),[]}}async function et(){try{let e=await A.get(`/users/sso-providers/admin`);return Array.isArray(e.data)?e.data:[]}catch(e){return E(e,`fetch admin SSO providers`),[]}}async function tt(e){try{return(await A.post(`/users/sso-providers`,e)).data}catch(e){E(e,`create SSO provider`)}}async function nt(e,t){try{return(await A.put(`/users/sso-providers/${e}`,t)).data}catch(e){E(e,`update SSO provider`)}}async function U(e){try{await A.delete(`/users/sso-providers/${e}`)}catch(e){E(e,`delete SSO provider`)}}async function rt(e,t,n,r){try{return(await A.post(`/users/ldap/login`,{providerId:e,username:t,password:n,rememberMe:r})).data}catch(e){E(e,`LDAP login`)}}function W(e){let t=new Uint8Array(e),n=``;for(let e of t)n+=String.fromCharCode(e);return btoa(n).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=/g,``)}function G(e){let t=e.replace(/-/g,`+`).replace(/_/g,`/`),n=(4-t.length%4)%4,r=t.padEnd(t.length+n,`=`),i=atob(r),a=new ArrayBuffer(i.length),o=new Uint8Array(a);for(let e=0;ee};function at(e){let{id:t}=e;return{...e,id:G(t),transports:e.transports}}function q(e){return e===`localhost`||/^((xn--[a-z0-9-]+|[a-z0-9]+(-[a-z0-9]+)*)\.)+([a-z]{2,}|xn--[a-z0-9-]+)$/i.test(e)}var J=class extends Error{constructor({message:e,code:t,cause:n,name:r}){super(e,{cause:n}),Object.defineProperty(this,"code",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=r??n.name,this.code=t}};function ot({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new J({message:`Registration ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`ConstraintError`){if(n.authenticatorSelection?.requireResidentKey===!0)return new J({message:`Discoverable credentials were required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_DISCOVERABLE_CREDENTIAL_SUPPORT`,cause:e});if(t.mediation===`conditional`&&n.authenticatorSelection?.userVerification===`required`)return new J({message:`User verification was required during automatic registration but it could not be performed`,code:`ERROR_AUTO_REGISTER_USER_VERIFICATION_FAILURE`,cause:e});if(n.authenticatorSelection?.userVerification===`required`)return new J({message:`User verification was required but no available authenticator supported it`,code:`ERROR_AUTHENTICATOR_MISSING_USER_VERIFICATION_SUPPORT`,cause:e})}else if(e.name===`InvalidStateError`)return new J({message:`The authenticator was previously registered`,code:`ERROR_AUTHENTICATOR_PREVIOUSLY_REGISTERED`,cause:e});else if(e.name===`NotAllowedError`)return new J({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`NotSupportedError`)return n.pubKeyCredParams.filter(e=>e.type===`public-key`).length===0?new J({message:`No entry in pubKeyCredParams was of type "public-key"`,code:`ERROR_MALFORMED_PUBKEYCREDPARAMS`,cause:e}):new J({message:`No available authenticator supported any of the specified pubKeyCredParams algorithms`,code:`ERROR_AUTHENTICATOR_NO_SUPPORTED_PUBKEYCREDPARAMS_ALG`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!q(t))return new J({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rp.id!==t)return new J({message:`The RP ID "${n.rp.id}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`TypeError`){if(n.user.id.byteLength<1||n.user.id.byteLength>64)return new J({message:`User ID was not between 1 and 64 characters`,code:`ERROR_INVALID_USER_ID_LENGTH`,cause:e})}else if(e.name===`UnknownError`)return new J({message:`The authenticator was unable to process the specified options, or could not create a new credential`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}var st=new class{constructor(){Object.defineProperty(this,"controller",{enumerable:!0,configurable:!0,writable:!0,value:void 0})}createNewAbortSignal(){if(this.controller){let e=Error(`Cancelling existing WebAuthn API call for new one`);e.name=`AbortError`,this.controller.abort(e)}let e=new AbortController;return this.controller=e,e.signal}cancelCeremony(){if(this.controller){let e=Error(`Manually cancelling existing WebAuthn API call`);e.name=`AbortError`,this.controller.abort(e),this.controller=void 0}}},ct=[`cross-platform`,`platform`];function lt(e){if(e&&!(ct.indexOf(e)<0))return e}async function ut(e){!e.optionsJSON&&e.challenge&&(console.warn(`startRegistration() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useAutoRegister:n=!1}=e;if(!K())throw Error(`WebAuthn is not supported in this browser`);let r={...t,challenge:G(t.challenge),user:{...t.user,id:G(t.user.id)},excludeCredentials:t.excludeCredentials?.map(at)},i={};n&&(i.mediation=`conditional`),i.publicKey=r,i.signal=st.createNewAbortSignal();let a;try{a=await navigator.credentials.create(i)}catch(e){throw ot({error:e,options:i})}if(!a)throw Error(`Registration was not completed`);let{id:o,rawId:s,response:c,type:l}=a,u;typeof c.getTransports==`function`&&(u=c.getTransports());let d;if(typeof c.getPublicKeyAlgorithm==`function`)try{d=c.getPublicKeyAlgorithm()}catch(e){dt(`getPublicKeyAlgorithm()`,e)}let f;if(typeof c.getPublicKey==`function`)try{let e=c.getPublicKey();e!==null&&(f=W(e))}catch(e){dt(`getPublicKey()`,e)}let p;if(typeof c.getAuthenticatorData==`function`)try{p=W(c.getAuthenticatorData())}catch(e){dt(`getAuthenticatorData()`,e)}return{id:o,rawId:W(s),response:{attestationObject:W(c.attestationObject),clientDataJSON:W(c.clientDataJSON),transports:u,publicKeyAlgorithm:d,publicKey:f,authenticatorData:p},type:l,clientExtensionResults:a.getClientExtensionResults(),authenticatorAttachment:lt(a.authenticatorAttachment)}}function dt(e,t){console.warn(`The browser extension that intercepted this WebAuthn API call incorrectly implemented ${e}. You should report this error to them.\n`,t)}function ft(){if(!K())return pt.stubThis(new Promise(e=>e(!1)));let e=globalThis.PublicKeyCredential;return e?.isConditionalMediationAvailable===void 0?pt.stubThis(new Promise(e=>e(!1))):pt.stubThis(e.isConditionalMediationAvailable())}var pt={stubThis:e=>e};function mt({error:e,options:t}){let{publicKey:n}=t;if(!n)throw Error(`options was missing required publicKey property`);if(e.name===`AbortError`){if(t.signal instanceof AbortSignal)return new J({message:`Authentication ceremony was sent an abort signal`,code:`ERROR_CEREMONY_ABORTED`,cause:e})}else if(e.name===`NotAllowedError`)return new J({message:e.message,code:`ERROR_PASSTHROUGH_SEE_CAUSE_PROPERTY`,cause:e});else if(e.name===`SecurityError`){let t=globalThis.location.hostname;if(!q(t))return new J({message:`${globalThis.location.hostname} is an invalid domain`,code:`ERROR_INVALID_DOMAIN`,cause:e});if(n.rpId!==t)return new J({message:`The RP ID "${n.rpId}" is invalid for this domain`,code:`ERROR_INVALID_RP_ID`,cause:e})}else if(e.name===`UnknownError`)return new J({message:`The authenticator was unable to process the specified options, or could not create a new assertion signature`,code:`ERROR_AUTHENTICATOR_GENERAL_ERROR`,cause:e});return e}async function ht(e){!e.optionsJSON&&e.challenge&&(console.warn(`startAuthentication() was not called correctly. It will try to continue with the provided options, but this call should be refactored to use the expected call structure instead. See https://simplewebauthn.dev/docs/packages/browser#typeerror-cannot-read-properties-of-undefined-reading-challenge for more information.`),e={optionsJSON:e});let{optionsJSON:t,useBrowserAutofill:n=!1,verifyBrowserAutofillInput:r=!0}=e;if(!K())throw Error(`WebAuthn is not supported in this browser`);let i;t.allowCredentials?.length!==0&&(i=t.allowCredentials?.map(at));let a={...t,challenge:G(t.challenge),allowCredentials:i},o={};if(n){if(!await ft())throw Error(`Browser does not support WebAuthn autofill`);if(document.querySelectorAll(`input[autocomplete$='webauthn']`).length<1&&r)throw Error('No with "webauthn" as the only or last value in its `autocomplete` attribute was detected');o.mediation=`conditional`,a.allowCredentials=[]}o.publicKey=a,o.signal=st.createNewAbortSignal();let s;try{s=await navigator.credentials.get(o)}catch(e){throw mt({error:e,options:o})}if(!s)throw Error(`Authentication was not completed`);let{id:c,rawId:l,response:u,type:d}=s,f;return u.userHandle&&(f=W(u.userHandle)),{id:c,rawId:W(l),response:{authenticatorData:W(u.authenticatorData),clientDataJSON:W(u.clientDataJSON),signature:W(u.signature),userHandle:f},type:d,clientExtensionResults:s.getClientExtensionResults(),authenticatorAttachment:lt(s.authenticatorAttachment)}}function gt(){return K()}async function _t(e,t=!1){try{let n=await A.post(`/users/webauthn/authenticate/options`,e?{username:e}:{}),r=await ht({optionsJSON:n.data.options});return(await A.post(`/users/webauthn/authenticate/verify`,{challengeId:n.data.challengeId,response:r,rememberMe:t})).data}catch(e){throw E(e,`sign in with passkey`)}}async function vt(){try{return(await A.get(`/users/webauthn/credentials`)).data}catch(e){throw E(e,`list passkeys`)}}async function yt(e,t){try{let n=await A.post(`/users/webauthn/register/options`,{userVerification:t}),r=await ut({optionsJSON:n.data.options});return(await A.post(`/users/webauthn/register/verify`,{challengeId:n.data.challengeId,name:e,response:r})).data}catch(e){throw E(e,`register passkey`)}}async function bt(e){try{return(await A.delete(`/users/webauthn/credentials/${e}`)).data}catch(e){throw E(e,`delete passkey`)}}function xt({className:e,...t}){return(0,N.jsx)(Ge,{"data-slot":`checkbox`,className:w(`peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-none border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50`,e),...t,children:(0,N.jsx)(qe,{"data-slot":`checkbox-indicator`,className:`flex items-center justify-center text-current transition-none`,children:(0,N.jsx)(S,{className:`size-3.5`})})})}function St(e){let t=new URLSearchParams(e);for(let[e,n]of t){if(e.toLowerCase()!==`silentsignin`)continue;let t=n;return t===``||t===`true`||t===`1`}return!1}function Ct(e){let t=new URLSearchParams(e);for(let e of Array.from(t.keys()))e.toLowerCase()===`silentsignin`&&t.delete(e);let n=t.toString();return n?`?${n}`:``}var wt=[{code:`en`,label:`English`},{code:`af`,label:`Afrikaans`},{code:`ar`,label:`العربية`},{code:`bn`,label:`বাংলা`},{code:`bg`,label:`Български`},{code:`ca`,label:`Català`},{code:`zh-CN`,label:`中文 (简体)`},{code:`zh-TW`,label:`中文 (繁體)`},{code:`cs`,label:`Čeština`},{code:`da`,label:`Dansk`},{code:`nl`,label:`Nederlands`},{code:`fi`,label:`Suomi`},{code:`fr`,label:`Français`},{code:`de`,label:`Deutsch`},{code:`el`,label:`Ελληνικά`},{code:`he`,label:`עברית`},{code:`hi`,label:`हिन्दी`},{code:`hu`,label:`Magyar`},{code:`id`,label:`Indonesia`},{code:`it`,label:`Italiano`},{code:`ja`,label:`日本語`},{code:`ko`,label:`한국어`},{code:`no`,label:`Norsk`},{code:`pl`,label:`Polski`},{code:`pt-PT`,label:`Português (PT)`},{code:`pt-BR`,label:`Português (BR)`},{code:`ro`,label:`Română`},{code:`ru`,label:`Русский`},{code:`sr`,label:`Српски`},{code:`es-ES`,label:`Español`},{code:`sv-SE`,label:`Svenska`},{code:`th`,label:`ไทย`},{code:`tr`,label:`Türkçe`},{code:`uk`,label:`Українська`},{code:`vi`,label:`Tiếng Việt`}],Tt=`termix_auth`;function Et(){try{let e=localStorage.getItem(Tt);return e?JSON.parse(e):null}catch{return null}}function Dt(){localStorage.removeItem(Tt)}function Y(e){localStorage.setItem(Tt,JSON.stringify({loggedIn:!0,username:e}))}var X=()=>/Termix-Mobile\/(Android|iOS)/.test(navigator.userAgent)||!!window.ReactNativeWebView,Z=()=>{if(X())return!1;if(window.IS_ELECTRON_WEBVIEW)return!0;try{if(window.self!==window.top)return!0}catch{return!0}return!1};function Q({value:e,onChange:t,placeholder:n,disabled:r,id:i}){let[a,o]=(0,M.useState)(!1);return(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(H,{id:i,type:a?`text`:`password`,value:e,onChange:e=>t(e.target.value),placeholder:n??`••••••••`,disabled:r,className:`pr-9 font-mono`}),(0,N.jsx)(`button`,{type:`button`,tabIndex:-1,onClick:()=>o(e=>!e),className:`absolute right-2.5 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors`,children:a?(0,N.jsx)(b,{className:`size-4`}):(0,N.jsx)(y,{className:`size-4`})})]})}function Ot({htmlFor:e,children:t}){return(0,N.jsx)(`label`,{htmlFor:e,className:`text-[10px] font-bold uppercase tracking-widest text-muted-foreground`,children:t})}function $({label:e,htmlFor:t,children:n}){return(0,N.jsxs)(`div`,{className:`flex flex-col gap-1.5`,children:[(0,N.jsx)(Ot,{htmlFor:t,children:e}),n]})}function kt({onLogin:e}){let{t}=u(),[n,r]=(0,M.useState)(`login`),[i,a]=(0,M.useState)(!1),[o,p]=(0,M.useState)({}),[m]=(0,M.useState)(()=>{try{return gt()}catch{return!1}}),[h,g]=(0,M.useState)(``),[_,y]=(0,M.useState)(``),[b,ne]=(0,M.useState)(``),[x,oe]=(0,M.useState)(()=>{try{return localStorage.getItem(`rememberMe`)===`true`}catch{return!1}}),[S,ce]=(0,M.useState)(``),[ue,C]=(0,M.useState)(``),w=(0,M.useRef)(null),[T,E]=(0,M.useState)(`email`),[be,Se]=(0,M.useState)(``),[O,A]=(0,M.useState)(``),[we,Ee]=(0,M.useState)(``),[De,Oe]=(0,M.useState)(``),[ke,Ae]=(0,M.useState)(()=>c(localStorage.getItem(`i18nextLng`)));function Ne(e){let t=s(e);l(t).then(e=>Ae(e)).catch(()=>{})}let[Pe,Fe]=(0,M.useState)(!0),[j,Ie]=(0,M.useState)(!0),[Le,Re]=(0,M.useState)(!0),[P,ze]=(0,M.useState)([]),[F,Be]=(0,M.useState)(!1),[Ve,He]=(0,M.useState)(null),[I,L]=(0,M.useState)(``),[R,Ue]=(0,M.useState)(``),We=(0,M.useRef)(!1),Ge=(0,M.useRef)(!1),[Ke,qe]=(0,M.useState)(!1),[Je,Ye]=(0,M.useState)(!1),[z,B]=(0,M.useState)(!1),[Xe,Ze]=(0,M.useState)(!1),[et,tt]=(0,M.useState)(!0),[nt,U]=(0,M.useState)(!1),[W,G]=(0,M.useState)(!d()||Z()?!0:null),[K,it]=(0,M.useState)(0);(0,M.useEffect)(()=>{Ge.current||d()||(Ge.current=!0,ge().then(t=>{!t.enabled||!t.success||(Y(t.username||``),e(t.username||``,t.userId||void 0,!!t.is_admin))}).catch(()=>{}))},[e]),(0,M.useEffect)(()=>{try{localStorage.setItem(`rememberMe`,x.toString())}catch{}},[x]),(0,M.useEffect)(()=>{if(!Z())return;let e=e=>{if(e.source!==window.parent||!e.data||typeof e.data!=`object`||e.data.type!==`OIDC_SYSTEM_BROWSER_AUTH_RESULT`)return;let n=typeof e.data.providerId==`number`?e.data.providerId:-1;e.data.success||(p(e=>({...e,[n]:!1})),f.error(e.data.error||t(`errors.failedOidcLogin`)))};return window.addEventListener(`message`,e),()=>window.removeEventListener(`message`,e)},[t]),(0,M.useEffect)(()=>{Me().then(e=>Fe(e.allowed)).catch(()=>{}),ye().then(e=>Ie(e.allowed)).catch(()=>{}),fe().then(e=>Re(e)).catch(()=>Re(!1)),$e().then(e=>ze(e||[])).catch(()=>ze([])).finally(()=>Be(!0)),ve().then(e=>qe(e.enabled)).catch(()=>{}).finally(()=>Ye(!0))},[]),(0,M.useEffect)(()=>{if(W!==!0)return;let e=!1,t=null,n=i=>{xe().then(t=>{e||(t.setup_required&&(B(!0),r(`register`)),Ze(!1),tt(!1))}).catch(()=>{if(e)return;if(i>=5){Ze(!0),tt(!1);return}let r=Math.min(500*2**i,5e3);t=setTimeout(()=>{e||n(i+1)},r)})};return tt(!0),n(0),()=>{e=!0,t&&clearTimeout(t)}},[W]),(0,M.useEffect)(()=>{if(W!==null)return;let t=!1,n=null;return he().then(r=>{if(!t){if(r.kind===`success`){Y(r.data.username||``),e(r.data.username||``,r.data.userId||void 0,!!r.data.is_admin);return}if(r.kind===`retry`){let e=Math.min(1e3*2**K,1e4);n=setTimeout(()=>{t||it(e=>e+1)},e);return}G(!0)}}).catch(()=>{if(t)return;let e=Math.min(1e3*2**K,1e4);n=setTimeout(()=>{t||it(e=>e+1)},e)}),()=>{t=!0,n&&clearTimeout(n)}},[W,K,e]),(0,M.useEffect)(()=>{n===`totp`&&w.current&&w.current.focus()},[n]),(0,M.useEffect)(()=>{L(``),Ue(``)},[Ve]),(0,M.useEffect)(()=>{F&&!j&&P.length>0&&n===`login`&&r(`external`)},[F,j,P.length,n]),(0,M.useEffect)(()=>{let n=new URLSearchParams(window.location.search),r=n.get(`success`),i=n.get(`error`);if(i){i===`registration_disabled`?f.error(t(`messages.registrationDisabled`)):i===`user_not_allowed`?f.error(t(`messages.userNotAllowed`)):f.error(`${t(`errors.oidcAuthFailed`)}: ${i}`),window.history.replaceState({},document.title,window.location.pathname);return}if(r){if(X()){let e=e=>{window.ReactNativeWebView?.postMessage(JSON.stringify({type:`AUTH_SUCCESS`,token:e})),U(!0),window.history.replaceState({},document.title,window.location.pathname)},t=n.get(`token`);t?e(t):k().then(t=>e(t??``)).catch(()=>e(``));return}if(Z()){window.parent.postMessage({type:`AUTH_SUCCESS`,source:`oidc_callback`,platform:`desktop`,timestamp:Date.now()},`*`),U(!0),window.history.replaceState({},document.title,window.location.pathname);return}D().then(t=>{Y(t.username||``),e(t.username||``,t.userId||void 0,!!t.is_admin),window.history.replaceState({},document.title,window.location.pathname)}).catch(()=>{f.error(t(`errors.failedUserInfo`))})}},[e,t]);function at(){g(``),y(``),ne(``),E(`email`),Se(``),A(``),Ee(``),Oe(``),ce(``),C(``)}function q(e){let t=h;at(),e===`reset`&&g(t),r(e)}async function J(n){if(n.preventDefault(),!h.trim()){f.error(t(`errors.requiredField`));return}a(!0);try{let n=await de(h.trim(),_,x);if(n.requires_totp){C(n.temp_token),r(`totp`);return}if(!n?.success)throw Error(t(`errors.loginFailed`));if(X()){let e=n?.token??``;window.ReactNativeWebView?.postMessage(JSON.stringify({type:`AUTH_SUCCESS`,token:e})),U(!0);return}if(Z()){let e=n?.token??await k();window.parent.postMessage({type:`AUTH_SUCCESS`,source:`auth_component`,platform:`desktop`,token:e??null,timestamp:Date.now()},`*`),U(!0);return}let i=await D();Y(i.username||h.trim()),f.success(t(`messages.loginSuccess`)),e(i.username||h.trim(),i.userId||void 0,!!i.is_admin)}catch(e){let n=e;f.error(n?.response?.data?.error||n?.message||t(`errors.unknownError`))}finally{a(!1)}}async function ot(){a(!0);try{let n=await _t(h.trim()||void 0,x);if(n.requires_totp){C(n.temp_token??``),r(`totp`);return}if(!n?.success)throw Error(t(`auth.passkeyLoginFailed`));if(X()){let e=n?.token??``;window.ReactNativeWebView?.postMessage(JSON.stringify({type:`AUTH_SUCCESS`,token:e})),U(!0);return}if(Z()){let e=n?.token??await k();window.parent.postMessage({type:`AUTH_SUCCESS`,source:`passkey_auth_component`,platform:`desktop`,token:e??null,timestamp:Date.now()},`*`),U(!0);return}let i=await D();Y(i.username||n.username||``),f.success(t(`messages.loginSuccess`)),e(i.username||n.username||``,i.userId||void 0,!!i.is_admin)}catch(e){let n=e;if(n?.name===`NotAllowedError`||n?.name===`AbortError`)return;f.error(n?.response?.data?.error||n?.message||t(`auth.passkeyLoginFailed`))}finally{a(!1)}}async function st(n){if(n.preventDefault(),!h.trim()){f.error(t(`errors.requiredField`));return}if(_.length<6){f.error(t(`errors.minLength`,{min:6}));return}if(_!==b){f.error(t(`errors.passwordMismatch`));return}a(!0);try{await pe(h.trim(),_);let n=await de(h.trim(),_,x);if(n.requires_totp){C(n.temp_token),r(`totp`);return}if(X()){let e=n?.token??``;window.ReactNativeWebView?.postMessage(JSON.stringify({type:`AUTH_SUCCESS`,token:e})),U(!0);return}if(Z()){let e=n?.token??await k();window.parent.postMessage({type:`AUTH_SUCCESS`,source:`auth_component`,platform:`desktop`,token:e??null,timestamp:Date.now()},`*`),U(!0);return}let i=await D();Y(i.username||h.trim()),f.success(t(`messages.registrationSuccess`)),e(i.username||h.trim(),i.userId||void 0,!!i.is_admin)}catch(e){let n=e;f.error(n?.response?.data?.error||n?.message||t(`errors.unknownError`))}finally{a(!1)}}async function ct(n){if(n.preventDefault(),S.length!==6){f.error(t(`auth.enterCode`));return}a(!0);try{let n=await je(ue,S,x);if(!n?.success)throw Error(t(`errors.loginFailed`));if(X()){let e=n?.token??``;window.ReactNativeWebView?.postMessage(JSON.stringify({type:`AUTH_SUCCESS`,token:e})),U(!0);return}if(Z()){let e=n?.token??await k();window.parent.postMessage({type:`AUTH_SUCCESS`,source:`totp_auth_component`,platform:`desktop`,token:e??null,timestamp:Date.now()},`*`),U(!0);return}Y(n.username||h),f.success(t(`messages.loginSuccess`)),e(n.username||h,n.userId||void 0,!!n.is_admin)}catch(e){let n=e;if(n?.response?.data?.code===`SESSION_EXPIRED`){r(`login`),f.error(t(`errors.sessionExpired`));return}f.error(n?.response?.data?.error||n?.message||t(`errors.invalidTotpCode`))}finally{a(!1)}}async function lt(e){if(e.preventDefault(),!h.trim()){f.error(t(`errors.requiredField`));return}a(!0);try{await _e(h.trim()),E(`code`),f.success(t(`messages.resetCodeSent`))}catch(e){let n=e;f.error(n?.response?.data?.error||n?.message||t(`errors.failedPasswordReset`))}finally{a(!1)}}async function ut(e){e.preventDefault(),a(!0);try{let e=await me(h.trim(),be);Oe(e.tempToken),E(`newpass`),f.success(t(`messages.codeVerified`))}catch(e){let n=e;f.error(n?.response?.data?.error||n?.message||t(`errors.failedVerifyCode`))}finally{a(!1)}}async function dt(e){if(e.preventDefault(),O.length<6){f.error(t(`errors.minLength`,{min:6}));return}if(O!==we){f.error(t(`errors.passwordMismatch`));return}a(!0);try{await Te(h.trim(),De,O),f.success(t(`messages.passwordResetSuccess`)),q(`login`)}catch(e){let n=e;f.error(n?.response?.data?.error||n?.message||t(`errors.failedCompleteReset`))}finally{a(!1)}}let ft=(0,M.useCallback)(async e=>{let n=e??-1;p(e=>({...e,[n]:!0}));try{if(Z()){let r=17832+Math.floor(Math.random()*100),{auth_url:i}=await Ce(x,r,e);if(!i)throw Error(t(`errors.invalidAuthUrl`));window.parent.postMessage({type:`OIDC_SYSTEM_BROWSER_AUTH`,source:`oidc_request`,authUrl:i,callbackPort:r,providerId:n},`*`);return}if(d()){let n=window.electronAPI;if(n?.oidcSystemBrowserAuth){let r=17832+Math.floor(Math.random()*100),{auth_url:i}=await Ce(x,r,e);if(!i)throw Error(t(`errors.invalidAuthUrl`));let a=await n.oidcSystemBrowserAuth(i,r);if(a.success&&a.token){localStorage.setItem(`jwt`,a.token),window.location.reload();return}throw Error(a.error||`Authentication failed`)}}let{auth_url:r}=await Ce(x,void 0,e);if(!r||r===`undefined`)throw Error(t(`errors.invalidAuthUrl`));window.location.replace(r)}catch(e){let r=e;f.error(r?.response?.data?.error||r?.message||t(`errors.failedOidcLogin`)),p(e=>({...e,[n]:!1}))}},[x,t]),pt=(0,M.useCallback)(async n=>{if(!I.trim()||!R){f.error(t(`errors.requiredField`));return}p(e=>({...e,[n]:!0}));try{await rt(n,I.trim(),R,x);let r=await D();Y(r.username||``),f.success(t(`messages.loginSuccess`)),e(r.username||``,r.userId||void 0,!!r.is_admin)}catch(e){let n=e;f.error(n?.response?.data?.error||n?.message||t(`auth.ldapLoginFailed`))}finally{p(e=>({...e,[n]:!1}))}},[I,R,x,e,t]);if((0,M.useEffect)(()=>{if(!F||We.current||!Je)return;let e=St(window.location.search);if(!e&&!Ke)return;if(e){let e=Ct(window.location.search);window.history.replaceState({},document.title,`${window.location.pathname}${e}${window.location.hash}`)}We.current=!0;let n=P.find(e=>e.type===`oidc`||e.type===`github`||e.type===`google`);if(n&&!d()){ft(n.id);return}e&&f.info(t(`errors.silentSigninOidcUnavailable`))},[ft,F,P,t,Ke,Je]),d()&&!Z()&&W===null)return(0,N.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-background`,children:(0,N.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary border-t-transparent rounded-full animate-spin`})});if(nt||Z()&&nt)return(0,N.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-background`,children:(0,N.jsxs)(`div`,{className:`text-center`,children:[(0,N.jsx)(le,{className:`size-12 text-accent-brand mx-auto mb-4`}),(0,N.jsx)(`p`,{className:`text-muted-foreground`,children:t(`auth.redirectingToApp`)})]})});if(Xe)return(0,N.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-background p-6`,children:(0,N.jsxs)(`div`,{className:`flex flex-col gap-5 p-6 border border-border bg-card max-w-sm w-full`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,N.jsx)(`p`,{className:`font-bold text-destructive`,children:t(`errors.databaseConnection`)}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t(`messages.databaseConnectionFailed`)})]}),(0,N.jsx)(V,{onClick:()=>window.location.reload(),children:t(`common.refresh`)}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between pt-2 border-t border-border`,children:[(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`common.language`)}),(0,N.jsx)(`select`,{value:ke,onChange:e=>Ne(e.target.value),className:`px-2.5 py-1.5 text-xs bg-background border border-border text-foreground outline-none focus:ring-1 focus:ring-ring`,children:wt.map(e=>(0,N.jsx)(`option`,{value:e.code,children:e.label},e.code))})]})]})});if(et)return(0,N.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-background`,children:(0,N.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary border-t-transparent rounded-full animate-spin`})});let mt=[{id:`login`,label:t(`common.login`),show:j&&!z},{id:`register`,label:t(`common.register`),show:(j||z)&&Pe},{id:`external`,label:t(`auth.external`),show:P.length>0}];return(0,N.jsx)(`div`,{className:`fixed inset-0 flex flex-col bg-background overflow-hidden`,children:(0,N.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[(0,N.jsxs)(`div`,{className:`hidden lg:flex flex-col w-[420px] shrink-0 bg-sidebar border-r border-border relative overflow-hidden select-none`,children:[(0,N.jsx)(`div`,{className:`absolute inset-0`,style:{backgroundImage:`radial-gradient(circle, color-mix(in oklch, var(--border) 80%, transparent) 1px, transparent 1px)`,backgroundSize:`24px 24px`}}),(0,N.jsxs)(`div`,{className:`absolute inset-0 flex flex-col items-center justify-center gap-3 z-10 px-12`,children:[(0,N.jsx)(`span`,{className:`text-4xl font-bold tracking-[0.3em] font-mono`,children:`TERMIX`}),(0,N.jsx)(`div`,{className:`w-8 h-px bg-accent-brand`}),(0,N.jsx)(`span`,{className:`text-[11px] font-mono text-muted-foreground uppercase tracking-[0.25em]`,children:t(`auth.tagline`)})]})]}),(0,N.jsx)(`div`,{className:`flex flex-1 items-center justify-center p-6 overflow-y-auto relative`,children:(0,N.jsxs)(`div`,{className:`w-full max-w-sm flex flex-col gap-6`,children:[n===`totp`&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,N.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold`,children:t(`auth.twoFactorAuth`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`auth.enterCode`)})]}),(0,N.jsxs)(`form`,{onSubmit:ct,className:`flex flex-col gap-4`,children:[(0,N.jsx)($,{label:t(`auth.verifyCode`),htmlFor:`totp-code`,children:(0,N.jsx)(H,{ref:w,id:`totp-code`,type:`text`,placeholder:`000000`,maxLength:6,value:S,onChange:e=>ce(e.target.value.replace(/\D/g,``)),disabled:i,className:`text-center text-2xl tracking-widest font-mono`,autoComplete:`one-time-code`})}),(0,N.jsx)(V,{type:`submit`,className:`w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold`,disabled:i||S.length!==6,children:t(i?`common.loading`:`auth.verifyCode`)}),(0,N.jsx)(V,{type:`button`,variant:`ghost`,className:`w-full`,onClick:()=>q(`login`),disabled:i,children:t(`common.cancel`)})]})]}),n===`reset`&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,N.jsxs)(`button`,{onClick:()=>q(`login`),className:`flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground transition-colors w-fit`,children:[(0,N.jsx)(ie,{className:`size-3.5`}),t(`common.back`)]}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold`,children:t(`auth.forgotPassword`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`auth.resetCodeDesc`)})]}),(0,N.jsx)(`div`,{className:`flex items-center gap-2`,children:[`email`,`code`,`newpass`].map((e,t)=>{let n=[`email`,`code`,`newpass`].indexOf(T),r=tg(e.target.value),placeholder:`your_username`,disabled:i})}),(0,N.jsx)(V,{type:`submit`,className:`w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold`,disabled:i,children:t(i?`common.loading`:`auth.sendResetCode`)})]}),T===`code`&&(0,N.jsxs)(`form`,{onSubmit:ut,className:`flex flex-col gap-4`,children:[(0,N.jsx)($,{label:t(`auth.resetCode`),htmlFor:`reset-code`,children:(0,N.jsx)(H,{id:`reset-code`,value:be,onChange:e=>Se(e.target.value.replace(/\D/g,``)),placeholder:`000000`,maxLength:6,className:`text-center font-mono text-lg tracking-widest`,disabled:i})}),(0,N.jsx)(V,{type:`submit`,className:`w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold`,disabled:i||be.length!==6,children:t(i?`common.loading`:`auth.verifyCodeButton`)}),(0,N.jsx)(V,{type:`button`,variant:`ghost`,className:`w-full`,onClick:()=>E(`email`),disabled:i,children:t(`common.back`)})]}),T===`newpass`&&(0,N.jsxs)(`form`,{onSubmit:dt,className:`flex flex-col gap-4`,children:[(0,N.jsx)($,{label:t(`auth.newPassword`),htmlFor:`new-pass`,children:(0,N.jsx)(Q,{id:`new-pass`,value:O,onChange:A,disabled:i})}),(0,N.jsx)($,{label:t(`auth.confirmNewPassword`),htmlFor:`confirm-new-pass`,children:(0,N.jsx)(Q,{id:`confirm-new-pass`,value:we,onChange:Ee,disabled:i})}),(0,N.jsx)(V,{type:`submit`,className:`w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold`,disabled:i,children:t(i?`common.loading`:`auth.resetPasswordButton`)})]})]}),(n===`login`||n===`register`||n===`external`)&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-5`,children:[(0,N.jsx)(`div`,{className:`flex border border-border overflow-hidden`,children:mt.filter(e=>e.show).map(e=>(0,N.jsx)(`button`,{onClick:()=>q(e.id),className:`flex-1 py-2.5 text-xs font-bold uppercase tracking-widest transition-colors ${n===e.id?`bg-accent-brand text-background`:`text-muted-foreground hover:text-foreground hover:bg-muted`}`,children:e.label},e.id))}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-1`,children:[(0,N.jsx)(`h1`,{className:`text-xl font-bold`,children:t(n===`login`?`auth.loginTitle`:n===`register`?`auth.registerTitle`:`auth.loginWithExternal`)}),(0,N.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n===`login`?t(`auth.loginSubtitle`,``):n===`register`?t(`auth.registerSubtitle`,``):t(`auth.loginWithExternalDesc`)})]}),n===`external`&&(0,N.jsxs)(`div`,{className:`flex flex-col gap-4`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(xt,{id:`rememberSSO`,checked:x,onCheckedChange:e=>oe(e===!0)}),(0,N.jsx)(`label`,{htmlFor:`rememberSSO`,className:`text-xs text-muted-foreground cursor-pointer`,children:t(`auth.rememberMe`)})]}),(0,N.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[P.map(e=>{let n=!!o[e.id];if(e.type===`ldap`){let r=Ve===e.id;return(0,N.jsxs)(`div`,{className:`flex flex-col gap-0 border border-border`,children:[(0,N.jsxs)(`button`,{type:`button`,onClick:()=>He(r?null:e.id),className:`flex items-center justify-between w-full px-3 py-2.5 text-xs font-bold uppercase tracking-widest text-muted-foreground hover:text-foreground hover:bg-muted transition-colors`,children:[(0,N.jsx)(`span`,{children:t(`auth.loginWithProvider`,{name:e.name})}),r?(0,N.jsx)(re,{className:`size-3.5`}):(0,N.jsx)(te,{className:`size-3.5`})]}),r&&(0,N.jsxs)(`form`,{onSubmit:t=>{t.preventDefault(),pt(e.id)},className:`flex flex-col gap-3 p-3 border-t border-border`,children:[(0,N.jsx)($,{label:t(`auth.ldapUsername`),htmlFor:`ldap-user-${e.id}`,children:(0,N.jsx)(H,{id:`ldap-user-${e.id}`,value:I,onChange:e=>L(e.target.value),disabled:n,autoFocus:!0})}),(0,N.jsx)($,{label:t(`auth.ldapPassword`),htmlFor:`ldap-pass-${e.id}`,children:(0,N.jsx)(Q,{id:`ldap-pass-${e.id}`,value:R,onChange:Ue,disabled:n})}),(0,N.jsx)(V,{type:`submit`,className:`w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold`,disabled:n,children:t(n?`common.loading`:`auth.ldapSignIn`)})]})]},e.id)}return(0,N.jsx)(V,{onClick:()=>ft(e.id),disabled:n,className:`w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold`,children:n?t(`common.loading`):t(`auth.loginWithProvider`,{name:e.name})},e.id)}),m&&(0,N.jsx)(V,{type:`button`,variant:`outline`,onClick:ot,disabled:i,className:`w-full h-10 font-bold`,children:(0,N.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(v,{className:`size-4`}),t(`auth.signInWithPasskey`)]})})]})]}),n===`login`&&(0,N.jsxs)(`form`,{onSubmit:J,className:`flex flex-col gap-4`,children:[(0,N.jsx)($,{label:t(`common.username`),htmlFor:`login-user`,children:(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(ae,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground pointer-events-none`}),(0,N.jsx)(H,{id:`login-user`,value:h,onChange:e=>g(e.target.value),placeholder:`username`,className:`pl-8`,disabled:i,autoFocus:!0})]})}),(0,N.jsx)($,{label:t(`common.password`),htmlFor:`login-pass`,children:(0,N.jsx)(Q,{id:`login-pass`,value:_,onChange:y,disabled:i})}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,N.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(xt,{id:`rememberMe`,checked:x,onCheckedChange:e=>oe(e===!0),disabled:i}),(0,N.jsx)(`label`,{htmlFor:`rememberMe`,className:`text-xs text-muted-foreground cursor-pointer`,children:t(`auth.rememberMe`)})]}),Le&&(0,N.jsx)(`button`,{type:`button`,onClick:()=>q(`reset`),className:`text-xs text-muted-foreground hover:text-accent-brand transition-colors`,children:t(`auth.forgotPassword`)})]}),(0,N.jsx)(V,{type:`submit`,className:`w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold h-10`,disabled:i,children:i?t(`common.loading`):(0,N.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(se,{className:`size-4`}),t(`common.login`)]})}),m&&(0,N.jsx)(V,{type:`button`,variant:`outline`,onClick:ot,disabled:i,className:`w-full h-10 font-bold`,children:(0,N.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(v,{className:`size-4`}),t(`auth.signInWithPasskey`)]})})]}),n===`register`&&(0,N.jsxs)(`form`,{onSubmit:st,className:`flex flex-col gap-4`,children:[(0,N.jsx)($,{label:t(`common.username`),htmlFor:`reg-user`,children:(0,N.jsxs)(`div`,{className:`relative`,children:[(0,N.jsx)(ae,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 size-4 text-muted-foreground pointer-events-none`}),(0,N.jsx)(H,{id:`reg-user`,value:h,onChange:e=>g(e.target.value),placeholder:`choose_a_username`,className:`pl-8`,disabled:i,autoFocus:!0})]})}),(0,N.jsx)($,{label:t(`common.password`),htmlFor:`reg-pass`,children:(0,N.jsx)(Q,{id:`reg-pass`,value:_,onChange:y,placeholder:t(`auth.minChars`,{min:6,defaultValue:`min. 6 characters`}),disabled:i})}),(0,N.jsx)($,{label:t(`common.confirmPassword`),htmlFor:`reg-confirm`,children:(0,N.jsx)(Q,{id:`reg-confirm`,value:b,onChange:ne,disabled:i})}),(0,N.jsx)(V,{type:`submit`,className:`w-full bg-accent-brand hover:bg-accent-brand/90 text-background font-bold h-10`,disabled:i,children:i?t(`common.loading`):(0,N.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,N.jsx)(ee,{className:`size-4`}),t(`auth.signUp`)]})})]}),(0,N.jsx)(Qe,{}),(0,N.jsx)(`p`,{className:`text-center text-xs text-muted-foreground`,children:n===`login`&&Pe?(0,N.jsxs)(N.Fragment,{children:[t(`auth.noAccount`,`Don't have an account?`),` `,(0,N.jsx)(`button`,{onClick:()=>q(`register`),className:`text-accent-brand hover:text-accent-brand/70 font-bold transition-colors`,children:t(`common.register`)})]}):n===`register`&&j&&!z?(0,N.jsxs)(N.Fragment,{children:[t(`auth.hasAccount`,`Already have an account?`),` `,(0,N.jsx)(`button`,{onClick:()=>q(`login`),className:`text-accent-brand hover:text-accent-brand/70 font-bold transition-colors`,children:t(`common.login`)})]}):null}),(0,N.jsxs)(`div`,{className:`flex items-center justify-between pt-1`,children:[(0,N.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:t(`common.language`)}),(0,N.jsx)(`select`,{value:ke,onChange:e=>Ne(e.target.value),className:`px-2.5 py-1.5 text-xs bg-background border border-border text-foreground outline-none focus:ring-1 focus:ring-ring`,children:wt.map(e=>(0,N.jsx)(`option`,{value:e.code,children:e.label},e.code))})]})]})]})})]})})}var At=[{id:`stats_bar`,label:`Status Bar`,description:`Version, uptime, database health, hosts online`,defaultEnabled:!0},{id:`counters_bar`,label:`Counters Bar`,description:`Total hosts, credentials, and tunnels count`,defaultEnabled:!0},{id:`quick_actions`,label:`Quick Actions`,description:`Shortcuts to add hosts, credentials, settings`,defaultEnabled:!0},{id:`host_status`,label:`Host Status`,description:`Live status list with CPU/RAM per host`,defaultEnabled:!0},{id:`recent_activity`,label:`Recent Activity`,description:`Feed of recent connection events`,defaultEnabled:!0},{id:`network_graph`,label:`Network Graph`,description:`Visual map of host network topology`,defaultEnabled:!1},{id:`service_links`,label:`Service Links`,description:`Clickable buttons linking to services on your servers`,defaultEnabled:!1},{id:`homepage_preview`,label:`Homepage`,description:`Scaled preview of your Homepage canvas`,defaultEnabled:!1}],jt=[{label:`Orange`,value:`#f59145`},{label:`Blue`,value:`#3b82f6`},{label:`Green`,value:`#22c55e`},{label:`Purple`,value:`#a855f7`},{label:`Pink`,value:`#ec4899`},{label:`Cyan`,value:`#06b6d4`},{label:`Red`,value:`#ef4444`},{label:`Yellow`,value:`#eab308`},{label:`Teal`,value:`#14b8a6`},{label:`Indigo`,value:`#6366f1`},{label:`Rose`,value:`#f43f5e`},{label:`Lime`,value:`#84cc16`}];function Mt(e){document.documentElement.style.setProperty(`--accent-brand`,e)}var Nt=[{id:`xs`,label:`XS`},{id:`sm`,label:`Small`},{id:`md`,label:`Normal`},{id:`lg`,label:`Large`},{id:`xl`,label:`XL`}];function Pt(e){let t=document.documentElement;t.classList.remove(`fs-xs`,`fs-sm`,`fs-md`,`fs-lg`,`fs-xl`),t.classList.add(`fs-${e}`),localStorage.setItem(`termix-font-size`,e)}var Ft=[`#ef4444`,`#f97316`,`#eab308`,`#22c55e`,`#3b82f6`,`#a855f7`,`#ec4899`,`#6b7280`],It=[{id:`none`,label:`None`},{id:`2-way`,label:`2-Way`},{id:`2-way-horizontal`,label:`2-Way (H)`},{id:`3-way`,label:`3-Way (V)`},{id:`3-way-horizontal`,label:`3-Way (H)`},{id:`4-way`,label:`4-Way`},{id:`5-way`,label:`5-Way`},{id:`6-way`,label:`6-Way`}],Lt={none:0,"2-way":2,"2-way-horizontal":2,"3-way":3,"3-way-horizontal":3,"4-way":4,"5-way":5,"6-way":6};function Rt(){if(!d())return()=>{};let e=e=>{!e.metaKey&&!e.ctrlKey||e.preventDefault()};return window.addEventListener(`wheel`,e,{capture:!0,passive:!1}),()=>window.removeEventListener(`wheel`,e,{capture:!0})}function zt(){let[e,t]=(0,M.useState)({isSupported:!1,isRegistered:!1,updateAvailable:!1}),n=(0,M.useCallback)(e=>{let n=e.installing;n&&n.addEventListener(`statechange`,()=>{n.state===`installed`&&navigator.serviceWorker.controller&&t(e=>({...e,updateAvailable:!0}))})},[]);return(0,M.useEffect)(()=>{let e=`serviceWorker`in navigator&&!d()&&!0;if(t(t=>({...t,isSupported:e})),!e)return;let r=!!navigator.serviceWorker.controller,i=!1,a=()=>{!r||i||(i=!0,window.location.reload())},o=async()=>{try{let e=await navigator.serviceWorker.register(`${T()}/sw.js`,{updateViaCache:`none`});t(e=>({...e,isRegistered:!0})),e.addEventListener(`updatefound`,()=>n(e)),await e.update()}catch(e){console.error(`[SW] Registration failed:`,e)}};return navigator.serviceWorker.addEventListener(`controllerchange`,a),document.readyState===`complete`?o():window.addEventListener(`load`,o),()=>{window.removeEventListener(`load`,o),navigator.serviceWorker.removeEventListener(`controllerchange`,a)}},[n]),e}var Bt=500,Vt=`uiPreferences`,Ht=`uiPreferencesChanged`;function Ut(){try{let e=localStorage.getItem(Vt);return e?Ee(JSON.parse(e)):null}catch{return null}}function Wt(e){try{localStorage.setItem(Vt,JSON.stringify(e))}catch{}}var Gt=(0,M.createContext)(null);function Kt({children:e}){let[t,n]=(0,M.useState)(()=>Ut()??ke()),[r,i]=(0,M.useState)(!1),a=(0,M.useRef)(null),o=(0,M.useRef)({});(0,M.useEffect)(()=>{let e=!1;return Oe().then(t=>{e||(n(t),Wt(t))}).catch(()=>{}).finally(()=>{e||i(!0)}),()=>{e=!0}},[]),(0,M.useEffect)(()=>{let e=()=>{let e=Ut();e&&n(e)};return window.addEventListener(Ht,e),()=>window.removeEventListener(Ht,e)},[]),(0,M.useEffect)(()=>()=>{a.current&&clearTimeout(a.current)},[]);let s=(0,M.useCallback)(e=>{let t={...o.current};for(let[n,r]of Object.entries(e))n===`overrides`&&r&&typeof r==`object`?t.overrides={...t.overrides??{},...r}:t[n]=r;o.current=t,a.current&&clearTimeout(a.current),a.current=setTimeout(()=>{let e=o.current;o.current={},Ae().then(t=>{if(t.storageMode===`cloud`)return we(e)}).catch(()=>{})},Bt)},[]),c=(0,M.useCallback)((e,t)=>{n(t=>{let n=Ee(e(t));return Wt(n),window.dispatchEvent(new Event(Ht)),n}),s(t)},[s]),l=(0,M.useCallback)(e=>{c(t=>({...t,preset:e}),{preset:e})},[c]),u=(0,M.useCallback)((e,t,n)=>{c(r=>{let i={...r.overrides[e]??{}};n===null?delete i[t]:i[t]=n;let a={...r.overrides};return Object.keys(i).length>0?a[e]=i:delete a[e],{...r,overrides:a}},{overrides:{[e]:{[t]:n}}})},[c]),d=(0,M.useCallback)(e=>{c(t=>{let n={...t.overrides};return delete n[e],{...t,overrides:n}},{overrides:{[e]:null}})},[c]),f=(0,M.useCallback)(()=>{c(e=>({...e,overrides:{}}),{overrides:null})},[c]),p=(0,M.useCallback)(e=>{let t={completedVersion:2,completedAt:new Date().toISOString(),skipped:e};c(e=>({...e,onboarding:t}),{onboarding:t})},[c]),m=(0,M.useMemo)(()=>({preferences:t,loaded:r,resolve:e=>Se(t,e),setPreset:l,setOverride:u,clearArea:d,clearAllOverrides:f,completeOnboarding:p}),[t,r,l,u,d,f,p]);return(0,N.jsx)(Gt.Provider,{value:m,children:e})}function qt(){return(0,M.useContext)(Gt)}function Jt(e){let t=(0,M.useContext)(Gt);return t?t.resolve(e):be.balanced[e]}function Yt(e,t){return Jt(e)[t]}function Xt(e){if(!e)return{};try{let t=JSON.parse(e);return t&&typeof t==`object`&&!Array.isArray(t)?t:{}}catch{return{}}}function Zt(e){return Xt(e)}function Qt(e){return Xt(e)}function $t(e){return e===void 0?`inherit`:e?`on`:`off`}function en(e){if(e!==`inherit`)return e===`on`}function tn(e,t){return{...e,...t}}var nn=(0,M.createContext)({ready:!0,terminal:{},rdp:{},saveDefaults:async()=>{}});function rn({children:e}){let[t,n]=(0,M.useState)(!1),[r,i]=(0,M.useState)({}),[a,o]=(0,M.useState)({});(0,M.useEffect)(()=>{let e=!1;return Ae().then(t=>{e||(i(Zt(t.terminalDefaults)),o(Qt(t.rdpDefaults)))}).catch(()=>{}).finally(()=>{e||n(!0)}),()=>{e=!0}},[]);let s=(0,M.useCallback)(async(e,t)=>{let n=JSON.stringify(t);await O({[`${e}Defaults`]:n}),e===`terminal`&&i(t),e===`rdp`&&o(t)},[]),c=(0,M.useMemo)(()=>({ready:t,terminal:r,rdp:a,saveDefaults:s}),[t,r,a,s]);return(0,N.jsx)(nn.Provider,{value:c,children:e})}function an(){return(0,M.useContext)(nn)}var on=(0,M.lazy)(()=>i(()=>import(`./AppShell-CQvlT8mw.js`).then(e=>({default:e.AppShell})),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33]),import.meta.url)),sn=(0,M.lazy)(()=>i(()=>import(`./TerminalApp-CQG0_JuX.js`).then(e=>({default:e.default})),__vite__mapDeps([34,1,2,7,35,3,4,5,8,9,10,14,11,12,15,22,26,36,37,38,39,40,41,42,43,44,45,46,47,48,49,17,21,50,51,24,25,28,29,31,52,53,54,55,56,57,58,59,13,60]),import.meta.url)),cn=(0,M.lazy)(()=>i(()=>import(`./FileManagerApp-B6W17Uk-.js`).then(e=>({default:e.default})),__vite__mapDeps([61,1,2,7,48,9,3,4,10,14,41,62,40,11,8,12,17,21,23,24,15,25,30,36,39,42,35,5,22,26,37,38,43,44,45,46,47,49,50,51,28,29,31,52,53,54,55,56,57,58,63,64,65,59,13,60]),import.meta.url)),ln=(0,M.lazy)(()=>i(()=>import(`./TunnelApp-Cb912Ge1.js`).then(e=>({default:e.default})),__vite__mapDeps([66,1,2,7,48,9,3,4,10,14,41,67,11,8,12,68,69,59,13,15,36,46,60]),import.meta.url)),un=(0,M.lazy)(()=>i(()=>import(`./HostMetricsApp-0PuFKL5t.js`).then(e=>({default:e.default})),__vite__mapDeps([70,1,2,7,48,9,3,4,10,14,41,59,8,11,12,13,15,36,46,60,71,17,29,43,47,57,58,21,65,72,73]),import.meta.url)),dn=(0,M.lazy)(()=>i(()=>import(`./ProxmoxStatsApp-CPgaXYuW.js`).then(e=>({default:e.default})),__vite__mapDeps([74,1,2,7,48,9,3,4,10,14,41,59,8,11,12,13,15,36,46,60,75,65,73]),import.meta.url)),fn=(0,M.lazy)(()=>i(()=>import(`./DockerApp-DCnfI2II.js`).then(e=>({default:e.default})),__vite__mapDeps([76,1,2,7,48,9,3,4,10,14,41,77,5,8,11,12,22,68,37,38,39,40,42,43,44,45,47,65,78,72,79,59,13,15,36,46,60]),import.meta.url)),pn=(0,M.lazy)(()=>i(()=>import(`./GuacamoleApp-n6Fg5qCe.js`).then(e=>({default:e.default})),__vite__mapDeps([80,1,2,7,8,9,3,4,10,14,11,12,21,42,46,48,41,49,17,50,65,81,82]),import.meta.url)),mn=(0,M.lazy)(()=>i(()=>import(`./TmuxMonitorApp-C52noJH7.js`).then(e=>({default:e.default})),__vite__mapDeps([83,1,2,84,7,8,9,3,4,10,85,14,11,12,17,21,86,36,35,5,15,22,26,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,24,25,28,29,31,52,53,54,55,56,57,58,72,60]),import.meta.url)),hn=(0,M.lazy)(()=>i(()=>import(`./HomepageApp-GjXSOs0G.js`).then(e=>({default:e.default})),__vite__mapDeps([87,1,2,88,7,10,3,4,11,8,9,12,19,21,14,89,90,91,36,35,5,15,22,26,37,38,39,40,41,42,43,44,45,46,47,48,49,17,50,51,24,25,28,29,31,52,53,54,55,56,57,58,62,23,30,63,64,65,77,68,78,72,79,67,69]),import.meta.url)),gn=(0,M.lazy)(()=>i(()=>import(`./ElectronVersionCheck-7i-K7yBB.js`).then(e=>({default:e.ElectronVersionCheck})),__vite__mapDeps([92,1,2,7,8,10,3,4,11,9,12,78,14]),import.meta.url)),_n=(0,M.lazy)(()=>i(()=>import(`./SharedSessionView-CdGdpWYi.js`),__vite__mapDeps([93,1,2,7,8,10,3,4,14,11,9,12,37,38,50,82,81]),import.meta.url));function vn(){let e=new URLSearchParams(window.location.search),t=e.get(`view`),n=e.get(`hostId`),r=e.get(`tmuxSession`),i=e.get(`path`);switch(t){case`terminal`:return(0,N.jsx)(sn,{hostId:n||void 0,tmuxSession:r||void 0});case`file-manager`:return(0,N.jsx)(cn,{hostId:n||void 0,initialPath:i||void 0});case`tunnel`:return(0,N.jsx)(ln,{hostId:n||void 0});case`host-metrics`:case`server-stats`:return(0,N.jsx)(un,{hostId:n||void 0});case`proxmox-stats`:return(0,N.jsx)(dn,{hostId:n||void 0});case`docker`:return(0,N.jsx)(fn,{hostId:n||void 0});case`rdp`:case`vnc`:case`telnet`:return(0,N.jsx)(pn,{hostId:n||void 0,protocol:t});case`tmux-monitor`:case`tmux_monitor`:return(0,N.jsx)(mn,{hostId:n||void 0});case`homepage`:return(0,N.jsx)(hn,{});default:return null}}function yn(){let{t:e}=u(),[t,n]=(0,M.useState)(!1),[r,i]=(0,M.useState)(!1);return(0,M.useEffect)(()=>{let e=!1;return De.then(()=>D()).then(async()=>{if(d())try{let e=await k();e&&localStorage.setItem(`jwt`,e)}catch{}e||n(!0)}).catch(()=>{e||i(!0)}),()=>{e=!0}},[]),r||t?(0,N.jsx)(vn,{}):(0,N.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-background`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,N.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary border-t-transparent rounded-full animate-spin`}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`common.loading`)})]})})}function bn(){let e=Et(),[t,n]=(0,M.useState)(e?.loggedIn?`verifying`:`idle-auth`),[r,i]=(0,M.useState)(e?.username??``),[a,o]=(0,M.useState)(0),s=(0,M.useRef)(null),c=(0,M.useRef)(!1),l=(0,M.useRef)(!1);(0,M.useEffect)(()=>{let e=localStorage.getItem(`termix-accent`);return e&&Mt(e),Pt(localStorage.getItem(`termix-font-size`)??`md`),()=>{s.current&&clearTimeout(s.current)}},[]),(0,M.useEffect)(()=>{t===`verifying`&&De.then(()=>D()).then(async()=>{if(d())try{let e=await k();e&&(localStorage.setItem(`jwt`,e),window.electronAPI?.invoke?.(`notify-local-login`,e).catch(()=>{}))}catch{}c.current=!1,n(`fading-in`),s.current=setTimeout(()=>n(`idle-app`),450)}).catch(e=>{let t=e?.status??e?.response?.status;if(t===401||t===403){Dt(),n(`idle-auth`);return}if(!d()&&a>=5){Dt(),n(`idle-auth`);return}let r=d()?Math.min(1e3*2**a,1e4):3e3;s.current=setTimeout(()=>{o(e=>e+1)},r)})},[t,a]);function f(e){if(l.current=!1,i(e),c.current=!0,n(`fading-in`),s.current=setTimeout(()=>n(`idle-app`),450),d()){window.electronAPI?.startC2SAutoStartTunnels?.().catch(()=>{});let e=localStorage.getItem(`jwt`);e&&window.electronAPI?.invoke?.(`notify-local-login`,e).catch(()=>{})}}function p(){l.current||(l.current=!0,Dt(),n(`fading-out`),s.current=setTimeout(()=>{i(``),n(`idle-auth`),l.current=!1},450))}let m=t===`idle-app`||t===`fading-in`||t===`fading-out`,h=t===`idle-auth`||t===`fading-in`&&c.current||t===`fading-out`,g=+(t===`idle-app`),_=+(t===`idle-auth`),{t:v}=u(),ee=t===`fading-in`||t===`fading-out`;return t===`verifying`?(0,N.jsx)(`div`,{className:`fixed inset-0 flex items-center justify-center bg-background`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,N.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary border-t-transparent rounded-full animate-spin`}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:v(`common.loading`)})]})}):(0,N.jsxs)(N.Fragment,{children:[ee&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-0 flex items-center justify-center bg-background`,children:(0,N.jsxs)(`div`,{className:`flex flex-col items-center gap-4`,children:[(0,N.jsx)(`div`,{className:`w-5 h-5 border-2 border-primary border-t-transparent rounded-full animate-spin`}),(0,N.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:v(`common.loading`)})]})}),m&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-10 transition-opacity duration-[450ms] ease-in-out`,style:{opacity:g,pointerEvents:t===`idle-app`?`auto`:`none`},children:(0,N.jsx)(M.Suspense,{fallback:null,children:(0,N.jsx)(Kt,{children:(0,N.jsx)(rn,{children:(0,N.jsx)(on,{username:r,onLogout:p})})})})}),h&&(0,N.jsx)(`div`,{className:`fixed inset-0 z-20 transition-opacity duration-[450ms] ease-in-out`,style:{opacity:_,pointerEvents:t===`idle-auth`?`auto`:`none`},children:(0,N.jsx)(kt,{onLogin:f})}),(0,N.jsx)(P,{position:`bottom-right`})]})}function xn(){let[e,t]=(0,M.useState)(!0);zt();let n=new URLSearchParams(window.location.search),r=n.has(`view`);return n.get(`view`)===`shared`?(0,N.jsx)(M.Suspense,{fallback:null,children:(0,N.jsx)(_n,{})}):r?(0,N.jsx)(M.Suspense,{fallback:null,children:(0,N.jsx)(Kt,{children:(0,N.jsx)(rn,{children:(0,N.jsx)(yn,{})})})}):d()&&e?(0,N.jsx)(M.Suspense,{fallback:null,children:(0,N.jsx)(gn,{onContinue:()=>t(!1)})}):(0,N.jsx)(bn,{})}Rt(),Le().finally(()=>{(0,Re.createRoot)(document.getElementById(`root`)).render((0,N.jsx)(M.StrictMode,{children:(0,N.jsx)(o,{defaultTheme:`dark`,storageKey:`vite-ui-theme`,children:(0,N.jsx)(xn,{})})}))});export{et as C,V as D,H as E,Ze as O,U as S,Qe as T,xt as _,Jt as a,yt as b,jt as c,Nt as d,Lt as f,kt as g,Pt as h,$t as i,P as k,At as l,Mt as m,en as n,Yt as o,It as p,tn as r,qt as s,an as t,Ft as u,bt as v,nt as w,tt as x,vt as y};