PageSourceSearch

https://www.milesmasterclass.com/chunk-5CCE3APX.js

js milesmasterclass.com collected 2026-09-24 13:01:40 UTC 9,762 bytes, 1 lines download raw bytes

1import{a as H}from"./chunk-TNDKBMBP.js";import{a as N,b as y}from"./chunk-DOYHICU5.js";import{a as k}from"./chunk-GAMBHOSW.js";import{c as v}from"./chunk-PWVZ3RMR.js";import{b as j}from"./chunk-BSTTMKBL.js";import{a as q}from"./chunk-IPKNN4YZ.js";import{a as i}from"./chunk-7XNWVJ7B.js";import{l as d,m as T}from"./chunk-GEHL6XGR.js";import{Ca as g,H as C,Ha as L,Z as A,ad as S,ba as f,ga as a,k as I,p as m,pd as M,qa as O,ra as w,sa as E,u as _,za as p}from"./chunk-ZHQDZIZV.js";var F=(()=>{class o{constructor(){this.document=a(w),this.platformId=a(g),this.documentIsAccessible=d(this.platformId)}static getCookieRegExp(t){let r=t.replace(/([[\]{}()|=;+?,.*^$\\])/gi,"\\$1");return new RegExp("(?:^"+r+"|;\\s*"+r+")=(.*?)(?:;|$)")}static safeDecodeURIComponent(t){try{return decodeURIComponent(t)}catch{return t}}check(t){return this.documentIsAccessible?(t=encodeURIComponent(t),o.getCookieRegExp(t).test(this.document.cookie)):!1}get(t){if(this.check(t)){t=encodeURIComponent(t);let s=o.getCookieRegExp(t).exec(this.document.cookie);return s?.[1]?o.safeDecodeURIComponent(s[1]):""}else return""}getAll(){if(!this.documentIsAccessible)return{};let t={},r=this.document;return r.cookie&&r.cookie!==""&&r.cookie.split(";").forEach(s=>{let[l,c]=s.split("=");t[o.safeDecodeURIComponent(l.replace(/^ /,""))]=o.safeDecodeURIComponent(c)}),t}set(t,r,s,l,c,h,D,J){if(!this.documentIsAccessible)return;if(typeof s=="number"||s instanceof Date||l||c||h||D){let b={expires:s,path:l,domain:c,secure:h,sameSite:D||"Lax",partitioned:J};this.set(t,r,b);return}let u=encodeURIComponent(t)+"="+encodeURIComponent(r)+";",n=s||{};if(n.expires)if(typeof n.expires=="number"){let b=new Date(new Date().getTime()+n.expires*1e3*60*60*24);u+="Expires="+b.toUTCString()+";"}else u+="Expires="+n.expires.toUTCString()+";";n.path&&(u+="Path="+n.path+";"),n.domain&&(u+="Domain="+n.domain+";"),n.secure===!1&&n.sameSite==="None"&&(n.secure=!0,console.warn(`[ngx-cookie-service] Cookie ${t} was forced with secure flag because sameSite=None.More details : https://github.com/stevermeister/ngx-cookie-service/issues/86#issuecomment-597720130`)),n.secure&&(u+="Secure;"),n.sameSite||(n.sameSite="Lax"),u+="SameSite="+n.sameSite+";",n.partitioned&&(u+="Partitioned;"),this.document.cookie=u}delete(t,r,s,l,c="Lax"){if(!this.documentIsAccessible)return;let h=new Date("Thu, 01 Jan 1970 00:00:01 GMT");this.set(t,"",{expires:h,path:r,domain:s,secure:l,sameSite:c})}deleteAll(t,r,s,l="Lax"){if(!this.documentIsAccessible)return;let c=this.getAll();for(let h in c)c.hasOwnProperty(h)&&this.delete(h,t,r,s,l)}static{this.\u0275fac=function(r){return new(r||o)}}static{this.\u0275prov=f({token:o,factory:o.\u0275fac,providedIn:"root"})}}return o})();var R=class o{cookieService=a(F);platformId=a(g);request=a(M,{optional:!0});get isBrowser(){return d(this.platformId)}get isServer(){return T(this.platformId)}getCookie(e){return this.isServer&&this.request?this.getServerCookie(e):this.cookieService.get(e)}getServerCookie(e){let t=this.request?.headers?.get("cookie")||"";return this.parseCookies(t)[e]||""}parseCookies(e){let t={};return e&&e.split(";").forEach(r=>{let[s,...l]=r.trim().split("=");s&&(t[s]=decodeURIComponent(l.join("=")))}),t}getAllCookies(){return this.cookieService.getAll()}hasCookie(e){return this.isServer&&this.request?!!this.getServerCookie(e):this.cookieService.check(e)}setCookie(e,t,r={}){this.cookieService.set(e,t,r.expires,r.path??"/",r.domain,r.secure,r.sameSite??"Lax")}deleteCookie(e,t="/",r){this.cookieService.delete(e,t,r)}deleteAllCookies(e="/",t){this.cookieService.deleteAll(e,t)}getLocal(e){if(!this.isServer){let t=localStorage.getItem(e);if(t)try{return JSON.parse(t)}catch{return t}}return null}setLocal(e,t){if(!this.isServer){let r=typeof t=="string"?t:JSON.stringify(t);localStorage.setItem(e,r)}}removeLocal(e){this.isServer||localStorage.removeItem(e)}hasLocal(e){return this.isServer?!1:localStorage.getItem(e)!==null}clearLocal(){this.isServer||localStorage.clear()}getSession(e){if(!this.isBrowser)return null;let t=sessionStorage.getItem(e);if(!t)return null;try{return JSON.parse(t)}catch{return t}}setSession(e,t){if(!this.isBrowser)return;let r=typeof t=="string"?t:JSON.stringify(t);sessionStorage.setItem(e,r)}getOrCreateBrowserSessionId(){let e=i.AUTH.browserSessionId,t=this.getSession(e);return t||(t=H(),this.setSession(e,t)),t}removeSession(e){this.isBrowser&&sessionStorage.removeItem(e)}hasSession(e){return this.isBrowser?sessionStorage.getItem(e)!==null:!1}clearSession(){this.isBrowser&&sessionStorage.clear()}clearAll(e="/",t){this.deleteAllCookies(e,t),this.clearLocal(),this.clearSession()}static \u0275fac=function(t){return new(t||o)};static \u0275prov=f({token:o,factory:o.\u0275fac,providedIn:"root"})};var U={myProfile:{path:"v2/user/myprofile/",method:"GET"},currentPlan:{path:"v2/user/active-plan/",method:"GET"}},V={ssoStart:{path:"sso/start/",method:"POST"},ssoSession:{path:"sso/session/",method:"POST"},sendOtp:{path:"v3/send-otp/",method:"POST"},verifyOtp:{path:"v3/verify-otp/",method:"POST"},refreshToken:{path:"v3/refresh-token/",method:"POST"}};var x=i.AUTH.transferUserData,P=i.AUTH.transferAuthStatus,K=class o{storage=a(R);logger=a(q);apiClient=a(N);transferState=a(L);platformId=a(g);destroyRef=a(E);injector=a(O);isBrowser=d(this.platformId);isServer=T(this.platformId);static REFRESH_TOKEN_DAYS=7;refreshTimer=null;authStateChanged=p(0);isLoadingProfile=p(!1);isAuthenticated=S(()=>(this.authStateChanged(),this.hasValidToken()));currentUser=p(null);currentPlan=p(null);isLoggedIn=S(()=>this.isAuthenticated());hasActivePlan=S(()=>this.isPlanActive(this.currentPlan()));
1accessTokenSubject=new I(null);isRefreshing=p(!1);constructor(){this.initializeUserData()}initializeUserData(){if(this.isServer){let e=this.loadUserFromStorage(),t=this.hasValidToken();this.transferState.set(x,e),this.transferState.set(P,t),e&&this.currentUser.set(e)}else if(this.isBrowser){let e=this.transferState.get(x,null),t=this.transferState.get(P,!1);if(e||t)e&&this.currentUser.set(e),this.transferState.remove(x),this.transferState.remove(P);else{let r=this.loadUserFromStorage();r&&this.currentUser.set(r)}}}loadUserFromStorage(){let e=this.storage.getLocal(i.AUTH.userData);return e&&this.hasValidToken()?e:null}hasValidToken(){let e=this.storage.getCookie(i.AUTH.accessToken);return!!e&&e.length>0}getAccessToken(){return this.storage.getCookie(i.AUTH.accessToken)||null}getRefreshToken(){return this.storage.getCookie(i.AUTH.refreshToken)||null}fetchMyProfile(){if(!this.isBrowser||!this.hasValidToken())return;this.isLoadingProfile.set(!0);let e=new v().set(y,!0);this.apiClient.get(U.myProfile.path,{context:e}).pipe(k(this.destroyRef)).subscribe({next:t=>{t.status_code&&t.data&&(this.setAuthenticated(t.data),this.fetchCurrentPlan().pipe(k(this.destroyRef)).subscribe()),this.isLoadingProfile.set(!1)},error:t=>{this.logger.error("Failed to fetch profile",t),this.isLoadingProfile.set(!1)}})}fetchCurrentPlan(){if(!this.hasValidToken())return this.setCurrentPlan(null),m(null);let e=new v().set(y,!0);return this.apiClient.get(U.currentPlan.path,{context:e}).pipe(_(t=>t?.data??null),A(t=>this.setCurrentPlan(t)),C(t=>(this.logger.error("Failed to fetch current plan",t),m(null))))}setCurrentPlan(e){this.currentPlan.set(e),this.storage.setCookie(i.AUTH.activePlan,this.isPlanActive(e)?"true":"false")}isPlanActive(e){return e?.subscription_status?.toLowerCase()==="active"}hasActivePlanFromCookie(){return this.storage.getCookie(i.AUTH.activePlan)==="true"}refreshToken(){let e=this.getRefreshToken();if(!e)return this.clearAuth(),m(null);let t={refresh_token:e},r=new v().set(y,!0);return this.apiClient.post(V.refreshToken.path,t,{context:r}).pipe(A(s=>{s.status&&s.data?this.handleRefreshSuccess(s.data):this.clearAuth()}),_(s=>s.data?.token||null),C(s=>(this.logger.error("Token refresh failed",s),this.clearAuth(),m(null))))}handleRefreshSuccess(e){this.storeTokens(e.token,e.refreshtoken,e.expires_in),e.user&&this.setAuthenticated(e.user),this.accessTokenSubject.next(e.token)}storeTokens(e,t,r){this.storage.setCookie(i.AUTH.accessToken,e,{expires:o.REFRESH_TOKEN_DAYS,path:"/",secure:i.production,sameSite:"Strict"}),this.storage.setCookie(i.AUTH.refreshToken,t,{expires:o.REFRESH_TOKEN_DAYS,path:"/",secure:i.production,sameSite:"Strict"}),r&&this.scheduleProactiveRefresh(r)}scheduleProactiveRefresh(e){if(!this.isBrowser||!e)return;this.refreshTimer!==null&&(clearTimeout(this.refreshTimer),this.refreshTimer=null);let t=Math.max(e-60,30)*1e3;this.refreshTimer=setTimeout(()=>{this.refreshTimer=null,!(!this.hasValidToken()||this.isRefreshing())&&(this.isRefreshing.set(!0),this.accessTokenSubject.next(null),this.refreshToken().pipe(k(this.destroyRef)).subscribe({next:()=>this.isRefreshing.set(!1),error:()=>this.isRefreshing.set(!1)}))},t)}setAuthenticated(e){this.currentUser.set(e),this.storage.setLocal(i.AUTH.userData,e),this.notifyAuthStateChange()}clearAuth(){this.refreshTimer!==null&&(clearTimeout(this.refreshTimer),this.refreshTimer=null),this.currentUser.set(null),this.currentPlan.set(null),this.storage.deleteCookie(i.AUTH.accessToken),this.storage.deleteCookie(i.AUTH.refreshToken),this.storage.deleteCookie(i.AUTH.activePlan),this.storage.removeLocal(i.AUTH.userData),this.isBrowser&&j(),this.notifyAuthStateChange(),this.accessTokenSubject.next(null)}async logout(){if(this.clearAuth(),!!this.isBrowser)try{let{AiLabsAuth:e}=await import("./chunk-XZ7XLS7G.js");await this.injector.get(e).signOutEverywhere()}catch(e){this.logger.error("Auth: AI Labs sign-out failed",e)}}notifyAuthStateChange(){this.authStateChanged.update(e=>e+1)}static \u0275fac=function(t){return new(t||o)};static \u0275prov=f({token:o,factory:o.\u0275fac,providedIn:"root"})};export{R as a,V as b,K as c};

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.