1(function(){try{var e=typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:typeof self<`u`?self:{};e.SENTRY_RELEASE={id:`2a2642b6dfacef97687e3efcbfceddb15cf2ec44`};var t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]=`7accbca2-12ad-4ad3-b728-eb026e306e1c`,e._sentryDebugIdIdentifier=`sentry-dbid-7accbca2-12ad-4ad3-b728-eb026e306e1c`)}catch{}})();import{o as e,r as t}from"./rolldown-runtime-Dq-L5ofj.js";import{y as n}from"./vendor-highcharts-D9LiJ1jq.js";import{x as r}from"./vendor-mui-CwwA7Cvy.js";import{Gr as i,Nn as a,Vr as o,zn as s}from"./vendors-_iXptsBn.js";import{H as c,M as u,V as d,t as f}from"./apiSingleton-DoXPG3Va.js";import{G as p}from"./Popover-BFBsLyOX.js";import{t as m}from"./Button-kEJcF-Z7.js";import{t as h}from"./model-muK8IfVL.js";import{C as g,f as _}from"./model-D8C7UyMr.js";import{t as v}from"./VerticalSpacer-C7Is-MhU.js";import{t as y}from"./TextField-CCs-7-sS.js";import{t as b}from"./withRouter-BCDmnwO5.js";import{t as x}from"./H2-BYzh31mf.js";import{t as S}from"./Spinner-CgTX4SEN.js";import{t as C}from"./useApi-BK6l4M1T.js";import{t as w}from"./Head-DNkJXktr.js";import{t as T}from"./styles.module-C9Z7svUj.js";var E=e(n()),D=r(),O=e(o()),k=()=>({authentication_failed:l(`Authentication failed`,`authError`),invalid_identity_provider:l(`The company doesn't support SSO`,`authError`),invalid_user:l(`The user isn't onboarded to the account`,`authError`),server_error:l(`Something went wrong. Please try again later or contact support`,`authError`)}),A=e=>k()[e]||l(`Authentication failed`,`authError`),j=t({default:()=>N}),M=`ssoCompany`,N=i(b,a((e,{params:t})=>({loggedIn:g(e),logInError:_(e),logInCompany:t.name}),{logIn:h.action.logIn}))(({loggedIn:e,logInError:t,logInCompany:n,logIn:r})=>{let i=new URLSearchParams(window.location.search),[a,o]=(0,E.useState)(``),[h,g]=(0,E.useState)(``),{fetch:_,loading:b}=C(f.auth.validateIdp),k=`${window.location.origin}/sso/login`;(0,E.useEffect)(()=>{if(F(),!e){if(t){g(`authentication_failed`);return}if(n){P(n);return}R()}},[]);let j=async()=>{let e=a,t=await _({idp:e});t.valid?(c(M,e),P(e)):t.status==400?g(`invalid_identity_provider`):g(`server_error`)},N=e=>{e.keyCode===13&&j()},P=e=>{let t=new URL(`${u.apiPrefix}/authorize`);t.searchParams.set(`client_id`,`app`),t.searchParams.set(`redirect_uri`,k),t.searchParams.set(`response_type`,`code`),t.searchParams.set(`idp`,e),window.location.replace(t.toString())},F=()=>{a||(n?I(n):L(d(M)))},I=e=>{e&&(o(e),c(M,e))},L=e=>{e&&o(e)},R=()=>{i.has(`code`)&&z(i.get(`code`)),i.has(`error`)&&B(i.get(`error`))},z=e=>{r({code:e,clientId:`app`,redirectUrl:k})},B=e=>{g(e)};return i.has(`code`)||e?(0,D.jsx)(S,{}):(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(w,{title:l(`Log in with Single Sign-On`)}),(0,D.jsxs)(`div`,{className:(0,O.default)(T.formContainer),children:[(0,D.jsx)(x,{children:l(`Log in with Single Sign-On`)}),(0,D.jsx)(`div`,{className:T.subtitle,children:l(`If your organization uses Single Sign-on (SSO) with YouScan, enter your company name and sign in using your SSO credentials.`)}),(0,D.jsx)(v,{}),(0,D.jsx)(y,{fullWidth:!0,size:`large`,label:l(`Company name`),type:`text`,errorText:h?A(h):null,value:a,onChange:o,onKeyDown:N}),(0,D.jsx)(v,{double:!0}),(0,D.jsx)(m,{primary:!0,fullWidth:!0,size:`large`,label:l(`Log in`),loading:b,onClick:j}),(0,D.jsx)(v,{}),(0,D.jsxs)(s,{to:`/login`,className:T.loginLink,children:[(0,D.jsx)(p,{type:`arrow-right`}),` `,l(`Log in without Single Sign-On`)]})]})]})});export{j as n,N 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.