import{a as C}from"./chunk-ZSSEAP7S.js";import{$ as i,$a as k,E as d,I as f,R as b,S as v,aa as t,ba as _,ca as x,cb as y,fa as g,ga as c,hb as D,o as l,p as m,pa as n,q as u,qa as E,ra as p,x as h}from"./chunk-LH5Z5GGI.js";function L(r,o){if(r&1){let e=x();_(0,"div",5),i(1,"h1",6),n(2),t(),i(3,"p",7),n(4),t(),i(5,"button",8),g("click",function(){m(e);let a=c();return u(a.cancel())}),n(6," Cancelar "),t()}if(r&2){let e=c();d(2),p(" ",e.isDesktop?"Abriendo tu navegador\u2026":"Redirigiendo\u2026"," "),d(2),p(" ",e.isDesktop?"Completa el inicio de sesi\xF3n en tu navegador. Volver\xE1s a la app autom\xE1ticamente.":"Te llevamos al inicio de sesi\xF3n seguro."," ")}}function S(r,o){if(r&1){let e=x();i(0,"h1",6),n(1,"No se pudo iniciar sesi\xF3n"),t(),i(2,"p",9),n(3),t(),i(4,"button",10),g("click",function(){m(e);let a=c();return u(a.start())}),n(5," Reintentar "),t()}if(r&2){let e=c();d(3),E(e.error())}}function A(r,o){if(r&1){let e=x();i(0,"h1",6),n(1,"Inicia sesi\xF3n en Grid Forge"),t(),i(2,"p",7),n(3),t(),i(4,"button",10),g("click",function(){m(e);let a=c();return u(a.start())}),n(5," Iniciar sesi\xF3n "),t(),i(6,"p",11),n(7),t()}if(r&2){let e=c();d(3),p(" ",e.isDesktop?"Autoriza el acceso a tu espacio de trabajo. Se abrir\xE1 tu navegador para autenticarte de forma segura.":"Autoriza el acceso a tu espacio de trabajo."," "),d(4),p("Continuar\xE1s de forma segura en ",e.webHost())}}var T="aegis.postLoginRedirect",w=class r{auth=l(C);router=l(y);route=l(k);desktop=globalThis.aegisDesktop;isDesktop=!!this.desktop?.isDesktop;redirect=this.route.snapshot.queryParamMap.get("redirect")||"/app";phase=h("idle");error=h(null);dispose;constructor(){if(this.auth.isAuthenticated()){this.router.navigateByUrl(this.redirect);return}this.isDesktop&&this.desktop&&(this.dispose=this.desktop.onAuthSession((o,e)=>{this.onDesktopSession(o,e)}))}ngOnDestroy(){this.dispose?.()}webHost(){try{return new URL(D()).host}catch{return"el proveedor"}}cancel(){this.phase.set("idle")}async start(){if(this.error.set(null),this.auth.isAuthenticated()){this.router.navigateByUrl(this.redirect);return}if(this.phase.set("opening"),this.isDesktop&&this.desktop){this.desktop.signIn();return}sessionStorage.setItem(T,this.redirect),this.redirectTo(await this.auth.beginIdpLogin(`${location.origin}/auth/callback`))}redirectTo(o){location.href=o}onDesktopSession(o,e){if(!o){e?(this.phase.set("error"),this.error.set(e)):this.phase.set("idle");return}let s=this.auth.adoptIdpSession(o.accessToken,o.refreshToken);s.ok?this.router.navigateByUrl(this.redirect):(this.phase.set("error"),this.error.set(s.error??"No se pudo completar el inicio de sesi\xF3n."))}static \u0275fac=function(e){return new(e||r)};static \u0275cmp=f({type:r,selectors:[["page-login"]],decls:10,vars:1,consts:[[1,"flex","min-h-full","items-center","justify-center","bg-bg","px-6","py-10","[background-image:radial-gradient(var(--dot)_1px,transparent_1px)]","[background-size:22px_22px]"],[1,"flex","w-full","max-w-[380px]","flex-col","items-center","text-center","[animation:fadeUp_0.5s_cubic-bezier(0.2,0.7,0.2,1)_both]"],[1,"mb-[22px]","inline-flex","items-center","gap-2.5"],[1,"grid","h-[30px]","w-[30px]","place-items-center","rounded-[9px]","bg-brand","text-[13px]","text-white"],[1,"font-[family-name:var(--font-head)]","text-[20px]","font-bold","tracking-[-0.02em]"],[1,"mb-5","h-[42px]","w-[42px]","animate-spin","rounded-full","border-[3px]","border-solid","border-line-2","border-t-brand","[animation-duration:0.8s]"],[1,"m-0","mb-2","font-[family-name:var(--font-head)]","text-[26px]","tracking-[-0.02em]"],[1,"m-0","mb-[22px]","max-w-[320px]","text-[14.5px]","leading-[1.55]","text-muted"],["type","button",1,"cursor-pointer","border-0","bg-transparent","p-1.5","text-[13.5px]","text-muted","[font-family:inherit]",3,"click"],[1,"m-0","mb-[22px]","max-w-[320px]","text-[14.5px]","leading-[1.55]","text-danger"],["type","button",1,"w-full","cursor-pointer","rounded","border-0","bg-brand","px-4","py-[13px]","text-[15px]","font-semibold","text-white","[font-family:inherit]","transition-[transform,background-color]","duration-150","hover:-translate-y-px","hover:bg-brand-strong",3,"click"],[1,"mb-0","mt-3.5","font-[family-name:var(--mono)]","text-[11px]","text-faint"]],template:function(e,s){if(e&1&&(i(0,"div",0)(1,"div",1)(2,"div",2)(3,"span",3),n(4,"\u25C6"),t(),i(5,"span",4),n(6,"Grid Forge"),t()(),b(7,L,7,2)(8,S,6,1)(9,A,8,2),t()()),e&2){let a;d(7),v((a=s.phase())==="opening"?7:a==="error"?8:9)}},encapsulation:2,changeDetection:0})};export{T as a,w as b};
