1import{Ar as mf,Fi as y,Gt as Ue,Ji as r,Vi as ye,Yi as s,Zn as es,a as Ae,b as Do,fn as Xi,jn as _t,zn as bn}from"./chunk-CJI4O91X.js";import{h as ge,y as q}from"./chunk-CuJhA2Bf.js";import{i as s$1}from"./chunk-DB7mB_Ni.js";var k=`sessionEnd`;var x=1;var N=[`signed-out`,`session-ended`];var p=class s{router=y(q);document=y(Ae);navigationPending=!1;navigateToLogin(e,t){if(this.navigationPending)return;let i=e===`session-ended`?t??P(this.router,s$1(this.document)):void 0;i&&!A(i)||(this.navigationPending=!0,this.router.navigate([`/login`],R(e,i)).finally(()=>{this.navigationPending=!1}))}redirectToLogin(e,t){let i=R(e,t);return new ge(this.router.createUrlTree([`/login`],i),i)}static ɵfac=function(t){return new(t||s)};static ɵprov=_t({token:s,factory:s.ɵfac})};function w(s){return{version:x,reason:s}}function $(s){if(!E(s))return null;let e=s[k];return!T(e,[`version`,`reason`])||e.version!==x||!L(e.reason)?null:w(e.reason)}function P(s,e=`/`){let i=I(typeof window<`u`&&typeof window.location<`u`?`${window.location.pathname||``}${window.location.search||``}${window.location.hash||``}`:``,e),d=i&&i!==`/`?i:s.url||s.routerState.snapshot.url||`/dashboard`;return!d.startsWith(`/`)||d.startsWith(`//`)?`/dashboard`:d}function A(s){return!O(s)}function C(s){let e=s.trim();if(e.length===0||e.length>2048||!e.startsWith(`/`)||e.startsWith(`//`)||_(e))return`/dashboard`;try{let t=new URL(e,`https://hitkeep.invalid`),i=decodeURIComponent(t.pathname);if(t.origin!==`https://hitkeep.invalid`||!i.startsWith(`/`)||i.startsWith(`//`)||i.includes(`\\`)||_(i)||O(i))return`/dashboard`}catch{return`/dashboard`}return e}function L(s){return N.some(e=>e===s)}function E(s){return typeof s==`object`&&s!==null}function T(s,e){return E(s)&&Object.keys(s).length===e.length&&e.every(t=>Object.hasOwn(s,t))}function R(s$2,e){return s(r({},s$2===`session-ended`&&{queryParams:{returnUrl:C(e??`/dashboard`)}}),{replaceUrl:!0,state:{[k]:w(s$2)}})}function O(s){let e=s.split(/[?#]/,1)[0]??s;return e===`/login`||e.startsWith(`/login/`)||e===`/setup`||e.startsWith(`/setup/`)}function _(s){for(let e of s)if(e.charCodeAt(0)<32)return!0;return!1}function I(s,e){if(!s||e===`/`)return s;let t=e.endsWith(`/`)?e.slice(0,-1):e;return s===t?`/`:s.startsWith(`${t}/`)?s.slice(t.length)||`/`:s}var M=class s{http=y(mf);sessionEndNavigation=y(p);ticker=null;socialMfaHandoff=null;status=ye(`unknown`);session=ye(null);sessionLoading=ye(!1);sessionExtending=ye(!1);nowMs=ye(Date.now());isAuthenticated=Ue(()=>this.status()===`authenticated`);sessionRemainingMs=Ue(()=>{let e=this.session();return e?Math.max(new Date(e.expires_at).getTime()-this.nowMs(),0):0});sessionRemainingSeconds=Ue(()=>Math.ceil(this.sessionRemainingMs()/1e3));sessionDisplayRemainingMs=Ue(()=>{let e=this.session();if(!e)return 0;let t=e.remembered&&e.remember_expires_at?e.remember_expires_at:e.expires_at;return Math.max(new Date(t).getTime()-this.nowMs(),0)});sessionDisplayRemainingSeconds=Ue(()=>Math.ceil(this.sessionDisplayRemainingMs()/1e3));sessionWarningActive=Ue(()=>{let e=this.session();if(!e||this.status()!==`authenticated`)return!1;let t=this.sessionDisplayRemainingSeconds();return t>0&&t<=e.warning_seconds});sessionExpired=Ue(()=>!!this.session()&&this.sessionDisplayRemainingMs()<=0);login(e){return this.http.post(`/api/login`,e).pipe(es(t=>{t.status===`ok`&&this.status.set(`authenticated`)}))}getSSOAvailability(){return this.http.get(`/api/auth/sso`)}getInviteSSOAvailability(e){return this.http.post(`/api/auth/sso/invite`,{invite_token:e})}startSSOLogin(e){return this.http.post(`/api/auth/sso/start`,e)}getSocialProviders(){return this.http.get(`/api/auth/social/providers`)}startSocial(e,t){return this.http.post(`/api/auth/social/${e}/start`,t)}previewSocial(e){return this.http.post(`/api/auth/social/preview`,{completion_token:e})}completeSocial(e,t){return this.http.post(`/api/auth/social/complete`,{completion_token:e,email:t}).pipe(es(i=>{i.status===`ok`&&this.status.set(`authenticated`)}))}completeSocialSignup(e){return this.http.post(`/api/cloud/signup/social/complete`,e).pipe(es(t=>{t.status===`ok`&&this.status.set(`authenticated`)}))}setSocialMfaHandoff(e){this.socialMfaHandoff=e.status===`mfa_required`?e:null}consumeSocialMfaHandoff(){let e=this.socialMfaHandoff;return this.socialMfaHandoff=null,e}logout(){return this.http.post(`/api/logout`,{}).pipe(es({next:()=>this.endSession(`signed-out`),error:()=>this.endSession(`signed-out`)}))}loadSession(){return this.sessionLoading.set(!0),this.http.get(`/api/auth/session`).pipe(es(e=>this.applySession(e)),Do(()=>(this.clearSession(),bn(null))),Xi(()=>this.sessionLoading.set(!1)))}extendSession(){return this.sessionExtending.set(!0),this.http.post(`/api/auth/session/extend`,{}).pipe(es(e=>this.applySession(e)),Xi(()=>this.sessionExtending.set(!1)))}requestPasswordReset(e,t){return this.http.post(`/api/auth/forgot-password`,r({email:e},t?{plan:t.plan,billing:t.billing}:{}))}resetPassword(e,t){return this.http.post(`/api/auth/reset-password`,{token:e,password:t})}acceptInvite(e,t){return this.http.post(`/api/auth/accept-invite`,t?{token:e,password:t}:{token:e}).pipe(es(i=>{i.status===`ok`&&this.status.set(`authenticated`)}))}changePassword(e,t){return this.http.post(`/api/user/password`,{current_password:e,new_password:t})}startPasskeyLogin(){return this.http.post(`/api/auth/passkey/login/start`,{})}finishPasskeyLogin(e){return this.http.post(`/api/auth/passkey/login/finish`,e).pipe(es(()=>this.status.set(`authenticated`)))}verifyMfaTotp(e,t){return this.http.post(`/api/auth/mfa/totp/verify`,{challenge_token:e,code:t}).pipe(es(()=>this.status.set(`authenticated`)))}verifyMfaRecoveryCode(e,t){return this.http.post(`/api/auth/mfa/recovery-code/verify`,{challenge_token:e,code:t}).pipe(es(()=>this.status.set(`authenticated`)))}requestMfaEmailLink(e,t){return this.http.post(`/api/auth/mfa/email-link/request`,{challenge_token:e,return_url:t})}markAuthenticated(){this.status.set(`authenticated`)}markUnauthenticated(){this.status.set(`unauthenticated`),this.clearSession()}applySession(e){this.session.set(e),this.status.set(`authenticated`),this.startTicker()}clearSession(){this.session.set(null),this.stopTicker()}endSession(e){this.markUnauthenticated(),this.sessionEndNavigation.navigateToLogin(e)}startTicker(){if(this.nowMs.set(Date.now()),this.ticker)return;this.ticker=setInterval(()=>{this.nowMs.set(Date.now()),this.sessionExpired()&&this.endSession(`session-ended`)},1e3),this.ticker.unref?.()}stopTicker(){this.ticker&&(clearInterval(this.ticker),this.ticker=null)}static ɵfac=function(t){return new(t||s)};static ɵprov=_t({token:s,factory:s.ɵfac})};export{M as n,p as r,$ as t};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.