1import{t as R,r as a,E as T,j as e,F as B,C as z,P as O,S as f,g as W,T as G,H as L,B as b}from"./index-B1JCX_-d.js";import{S as D}from"./SEOHead-x5xN8jU_.js";import{A as y}from"./Alert-rB0v6-kr.js";import{D as H}from"./Divider-TnKyqnC7.js";import{T as J}from"./TextInput-D-E7ywd3.js";import"./InputBase-CWPbF_yb.js";const w="10.12.0";function $(n){return!n.startsWith("/")||n.startsWith("//")?"/":n}function K(){const n='{"apiKey":"AIzaSyBlBn7LoCJl851JJINJ-EE3IcdDOAjc8p4","authDomain":"auth.eu.formapprovals.com","projectId":"formapprovals-europe","storageBucket":"formapprovals-europe.appspot.com","messagingSenderId":"785099706722","appId":"1:785099706722:web:2ab4af1973c3facada5c3b"}';try{return JSON.parse(n)}catch{return{}}}const E={[`https://www.gstatic.com/firebasejs/${w}/firebase-app-compat.js`]:"sha384-sEVIly94UBRLKWdkYoPpSG7GD/e79YHMrxVyZaOk712Ga7+EAw6w1EFi+xBzBdd+",[`https://www.gstatic.com/firebasejs/${w}/firebase-auth-compat.js`]:"sha384-EkqK+ezBWJuvO3hfrSx2iVqr3YQbhmnzn8kPhOpBZ+0GMVU5oGSgptwIu8D84HjE"};function v(n){return new Promise((d,l)=>{if(document.querySelector(`script[src="${n}"]`)){d();return}const s=document.createElement("script");s.src=n,E[n]&&(s.integrity=E[n],s.crossOrigin="anonymous"),s.onload=()=>d(),s.onerror=()=>l(new Error(`Failed to load ${n}`)),document.head.appendChild(s)})}function Y(){const[n]=R(),d=$(n.get("return_to")||window.localStorage.getItem("signInReturnTo")||"/"),l=n.get("user")||"",[c,s]=a.useState(l),[m,g]=a.useState(!1),[I,r]=a.useState(null),[P,k]=a.useState(!1),[o,C]=a.useState(!1),[p,S]=a.useState(null),x=a.useRef(!1);a.useEffect(()=>{if(x.current)return;x.current=!0;const t=K();if(!t.apiKey){S("Firebase configuration not available. Please refresh the page.");return}(async()=>{try{await v(`https://www.gstatic.com/firebasejs/${w}/firebase-app-compat.js`),await v(`https://www.gstatic.com/firebasejs/${w}/firebase-auth-compat.js`),window.firebase&&!window.firebase.apps?.length&&window.firebase.initializeApp(t),window.firebase&&await window.firebase.auth().setPersistence(window.firebase.auth.Auth.Persistence.SESSION),C(!0)}catch{S("Failed to initialize authentication. Please refresh the page.")}})()},[]);const u=a.useCallback(async t=>{try{g(!0),r(null),await T(t),window.localStorage.removeItem("emailForSignIn"),window.localStorage.removeItem("signInReturnTo"),window.location.href=d}catch{r("Authentication failed. Please try again.")}finally{g(!1)}},[d]),F=()=>{if(!window.firebase?.auth)return;const t=new window.firebase.auth.GoogleAuthProvider;l&&t.setCustomParameters({login_hint:l}),window.firebase.auth().signInWithPopup(t).then(i=>i.user.getIdToken()).then(i=>u(i)).catch(()=>r("Google sign-in failed. Please try again."))},A=()=>{if(!window.firebase?.auth)return;const t=new window.firebase.auth.OAuthProvider("microsoft.com");l&&t.setCustomParameters({login_hint:l}),window.firebase.auth().signInWithPopup(t).then(i=>i.user.getIdToken()).then(i=>u(i)).catch(()=>r("Microsoft sign-in failed. Please try again."))},j=()=>
1{if(!c||!window.firebase?.auth)return;const t={url:window.location.href,handleCodeInApp:!0};window.firebase.auth().sendSignInLinkToEmail(c,t).then(()=>{window.localStorage.setItem("emailForSignIn",c),window.localStorage.setItem("signInReturnTo",d),k(!0)}).catch(()=>r("Failed to send sign-in email. Please try again."))};return a.useEffect(()=>{if(!o)return;const t=window.firebase?.auth();t&&t.getRedirectResult().then(i=>{if(i?.user)return i.user.getIdToken().then(h=>u(h))}).catch(i=>{i.code&&i.code!=="auth/invalid-action-code"&&r("Sign-in failed. Please try again.")})},[o,u]),a.useEffect(()=>{if(!o)return;const t=window.firebase?.auth();if(!t?.isSignInWithEmailLink(window.location.href))return;const i=window.localStorage.getItem("emailForSignIn");if(!i){r("Unable to verify your email. Please try signing in again from the same device.");return}g(!0),t.signInWithEmailLink(i,window.location.href).then(h=>(window.history.replaceState({},document.title,window.location.pathname),h.user.getIdToken())).then(h=>u(h)).catch(()=>{g(!1),r("Email sign-in failed. Please try again.")})},[o,u]),!o&&!p?e.jsx(B,{}):e.jsxs(e.Fragment,{children:[e.jsx(D,{title:"Sign In",noIndex:!0}),e.jsx(z,{size:"xs",py:80,children:e.jsx(O,{shadow:"md",p:"xl",radius:"md",children:e.jsxs(f,{gap:"lg",children:[e.jsxs(f,{align:"center",gap:"xs",children:[e.jsx(W,{order:2,ta:"center",c:"var(--mantine-primary-color-filled)",children:"Form Approvals"}),e.jsx(G,{c:"dimmed",ta:"center",size:"sm",children:"Sign in to respond to your approval request"})]}),(I||p)&&e.jsx(y,{icon:e.jsx(L,{size:16}),color:"red",variant:"light",onClose:()=>{r(null),S(null)},withCloseButton:!0,children:I||p}),P?e.jsxs(y,{color:"green",variant:"light",children:["A sign-in link has been sent to ",e.jsx("strong",{children:c}),". Check your inbox and click the link to continue."]}):e.jsxs(e.Fragment,{children:[e.jsxs(f,{gap:"sm",children:[e.jsx(b,{onClick:F,variant:"default",size:"md",fullWidth:!0,loading:m,disabled:!o,leftSection:e.jsx("img",{src:"https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/google.svg",alt:"",width:18,height:18}),children:"Sign in with Google"}),e.jsx(b,{onClick:A,variant:"default",size:"md",fullWidth:!0,loading:m,disabled:!o,leftSection:e.jsx("img",{src:"https://www.gstatic.com/firebasejs/ui/2.0.0/images/auth/microsoft.svg",alt:"",width:18,height:18}),children:"Sign in with Microsoft"})]}),e.jsx(H,{label:"Or sign in with email",labelPosition:"center"}),e.jsxs(f,{gap:"sm",children:[e.jsx(J,{type:"email",placeholder:"[email protected]",value:c,onChange:t=>s(t.currentTarget.value),onKeyDown:t=>t.key==="Enter"&&j()}),e.jsx(b,{onClick:j,variant:"light",fullWidth:!0,loading:m,disabled:!c||!o,children:"Send sign-in link"})]})]})]})})})]})}export{Y as default};
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.