try{let e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`89d22650-e377-4980-9c20-f85a01865319`,e._sentryDebugIdIdentifier=`sentry-dbid-89d22650-e377-4980-9c20-f85a01865319`)}catch{}import{o as e}from"./rolldown-runtime-nx40z1zs.js";import{T as t,w as n}from"./vendor-misc-dys7qi6h.js";import{$m as r,Ag as i,Gu as a,Hm as o,Kh as s,Oi as c,Qh as l,Qm as u,Zm as d,_g as f,_r as p,jg as m,ng as h,pr as g,qh as _,rf as v,vr as y,yr as b}from"./entry.client-mpghtlrl.js";import{n as x}from"./auth-hooks-dkb6uyrd.js";var S=e(m(),1),C=i(),w={InvalidHost:`InvalidHost`,InvalidProtocol:`InvalidProtocol`,DisallowedKeyword:`DisallowedKeyword`,RedirectLoop:`RedirectLoop`},T=class e extends Error{static type=`InvalidReturnUrlError`;static buildMessage(e,t,n){switch(t){case w.InvalidHost:return`Invalid returnUrl '${e}': host '${n?.actual}' did not match expected '${n?.expected}'.`;case w.InvalidProtocol:return`Invalid returnUrl '${e}': protocol '${n?.actual}' did not match expected '${n?.expected}'.`;case w.DisallowedKeyword:return`Invalid returnUrl '${e}': disallowed keyword detected.`;case w.RedirectLoop:return`Invalid returnUrl '${e}': cannot redirect back to auth handler.`;default:return`Invalid returnUrl '${e}': ${t}.`}}type=e.type;constructor(t,n,r,i){let a=e.buildMessage(t,n,r);super(a,i),this.returnUrl=t,this.reason=n,this.actual=r?.actual,this.expected=r?.expected,this.name=e.name,Object.setPrototypeOf(this,e.prototype),Error.captureStackTrace&&Error.captureStackTrace(this,e)}};s(T.type);var E=e=>{try{return new URL(e)}catch{return new URL(e,window.location.origin)}},D=(e,t)=>{if(!globalThis.window)return t.info(`Skipping return URL validation on server`),e||`/`;if(t.info(`Validating return url: ${e}`),!e)return new URL(`/`,window.location.origin).pathname;try{let t=E(e);if(window.location.host!==t.host)throw new T(e,w.InvalidHost,{actual:t.host,expected:window.location.host});let n=`https:`;if(t.protocol!==n)throw new T(e,w.InvalidProtocol,{actual:t.protocol,expected:n});if(e.toLowerCase().includes(`javascript:`)||e.toLowerCase().includes(`vbscript:`))throw new T(e,w.DisallowedKeyword);if(t.pathname===`/auth/msa`||t.pathname.startsWith(`/auth/msa/`))throw new T(e,w.RedirectLoop);return t.pathname}catch(n){let r=new URL(`/`,window.location.origin);return t.warn(`Invalid returnUrl specified ${e} - Using default value: / (${n}).`),r.pathname}},O=h(),k=p(e=>{let t=(0,C.c)(36),{error:n,action:i,correlationVector:a,handleGoHome:s,signIn:c}=e,{t:l}=r(`AuthActionHandler`),{locGoHome:u,locTryAgain:d,locSomethingWentWrong:f}=o(),p;t[0]===n?p=t[1]:(p=v(n),t[0]=n,t[1]=p);let m=p,h;t[2]!==m||t[3]!==l||t[4]!==f?(h=m?l(`Taking longer than expected...`,{shortKey:`timeout_title`}):f(),t[2]=m,t[3]=l,t[4]=f,t[5]=h):h=t[5];let _=h,y;t[6]!==m||t[7]!==i||t[8]!==l?(y=m&&i===`login`?l(`We hit a snag while signing you in. Don't worry, these things happen!`,{shortKey:`timeout_subtitle`}):l(`We ran into an issue while processing your request. Please try again.`,{shortKey:`generic_error_subtitle`}),t[6]=m,t[7]=i,t[8]=l,t[9]=y):y=t[9];let x=y,S;if(i===`login`){let e;t[10]===d?e=t[11]:(e=d(),t[10]=d,t[11]=e);let n;t[12]!==e||t[13]!==c?(n={text:e,onPress:c},t[12]=e,t[13]=c,t[14]=n):n=t[14],S=n}else{let e;t[15]===u?e=t[16]:(e=u(),t[15]=u,t[16]=e);let n;t[17]!==e||t[18]!==s?(n={text:e,onPress:s},t[17]=e,t[18]=s,t[19]=n):n=t[19],S=n}let w=S,T;if(i===`login`){let e;t[20]===u?e=t[21]:(e=u(),t[20]=u,t[21]=e);let n;t[22]!==e||t[23]!==s?(n={text:e,onPress:s},t[22]=e,t[23]=s,t[24]=n):n=t[24],T=n}else T=void 0;let E=T,D=`auth-error-fallback-${i}`,k;t[25]!==_||t[26]!==x||t[27]!==w||t[28]!==E?(k=(0,O.jsx)(b,{title:_,subtitle:x,illustration:`error`,size:`large`,primaryButton:w,secondaryButton:E}),t[25]=_,t[26]=x,t[27]=w,t[28]=E,t[29]=k):k=t[29];let A;t[30]===a?A=t[31]:(A=a&&(0,O.jsx)(`p`,{className:`mt-layout-vertical-related-content-in-a-section-tight text-noninteractive-content-secondary-content type-caption`,children:a}),t[30]=a,t[31]=A);let j;return t[32]!==D||t[33]!==k||t[34]!==A?(j=(0,O.jsxs)(g,{className:`flex min-h-dvh w-full flex-col items-center justify-center flex-col-px`,"data-testid":D,children:[k,A]}),t[32]=D,t[33]=k,t[34]=A,t[35]=j):j=t[35],j},()=>{let[{action:e,returnUrl:r}]=t(a.auth.msa.error),{error:i}=n(a.auth.msa.error),{telemetry:o}=d(),{data:s}=l(o.queries.correlationVector.getOptions()),c=y(),{trackUserAction:p}=u(),m=(0,S.useCallback)(()=>{p(`NavigateInApp`,{destination:c},`Press`),window.location.href=c},[c,p]),h=x({returnUrl:D(r,f(`AuthErrorFallback`))});return{action:e,error:_(i),correlationVector:s?.getValue(),handleGoHome:m,signIn:h}}),A=c(e=>(0,O.jsx)(k.useComponent(),{...e}),`AuthErrorFallback`);export{D as n,A as t};