(globalThis.TURBOPACK||(globalThis.TURBOPACK=[])).push(["object"==typeof document?document.currentScript:void 0,658729,e=>{"use strict";function t(e){let t="";for(let r of e)t+=String.fromCharCode(r);return btoa(t).replace(/\+/g,"-").replace(/\//g,"_").replace(/=+$/,"")}async function r(e){let r=new TextEncoder().encode(e);return t(new Uint8Array(await crypto.subtle.digest("SHA-256",r)))}let i={state:"oidc_state",nonce:"oidc_nonce",codeVerifier:"oidc_code_verifier",serverUrl:"oidc_server_url",redirectUri:"oidc_redirect_uri",issuer:"oidc_issuer"};e.s(["OIDC_SESSION_KEYS",0,i,"clearOidcSession",0,function(){for(let e of Object.values(i))sessionStorage.removeItem(e)},"generateCodeChallenge",0,r,"generateCodeVerifier",0,function(){return t(crypto.getRandomValues(new Uint8Array(32)))},"generateNonce",0,function(){return t(crypto.getRandomValues(new Uint8Array(16)))},"generateState",0,function(){return t(crypto.getRandomValues(new Uint8Array(16)))},"jsonToBase64url",0,function(e){let r=JSON.stringify(e);return t(new TextEncoder().encode(r))}])},56888,e=>{"use strict";var t=e.i(843476),r=e.i(271645),i=e.i(167881),n=e.i(433310),o=e.i(658729);e.s(["OidcSsoLoginSection",0,function({serverUrl:e,disabled:s,onError:a,onLoadingChange:c}){let[d,l]=(0,r.useState)(!1),[u,g]=(0,r.useState)(),[S,h]=(0,r.useState)(),[f,m]=(0,r.useState)([]),[p,_]=(0,r.useState)(!1),y=(0,r.useRef)("");async function b(){if(d&&S){if(!crypto?.subtle)return void a("Sign in with SSO requires a secure connection. Please access the app over HTTPS.");_(!0),c(!0);try{let t,r=await fetch(`/api/oidc-discovery?issuer=${encodeURIComponent(S)}`);if(r.ok){let e=await r.json();"string"==typeof e.authorization_endpoint&&(t=e.authorization_endpoint)}if(!t)throw Error("Could not determine the authorization endpoint from the OIDC discovery document. Please check that the issuer URL is correct in the OIDC plugin settings.");let i=(0,o.generateCodeVerifier)(),n=await (0,o.generateCodeChallenge)(i),s=(0,o.generateState)(),a=(0,o.generateNonce)(),c=`${window.location.origin}/auth/callback`;localStorage.setItem("bl_last_server",e.trim()),sessionStorage.setItem(o.OIDC_SESSION_KEYS.state,s),sessionStorage.setItem(o.OIDC_SESSION_KEYS.nonce,a),sessionStorage.setItem(o.OIDC_SESSION_KEYS.codeVerifier,i),sessionStorage.setItem(o.OIDC_SESSION_KEYS.serverUrl,e.trim()),sessionStorage.setItem(o.OIDC_SESSION_KEYS.redirectUri,c),sessionStorage.setItem(o.OIDC_SESSION_KEYS.issuer,S);let d=(f.length?f:["openid"]).join(" "),l=new URLSearchParams({response_type:"code",client_id:u??"",redirect_uri:c,scope:d,state:s,nonce:a,code_challenge:n,code_challenge_method:"S256"});window.location.href=`${t}?${l.toString()}`}catch(e){a(e instanceof Error?e.message:"SSO login failed"),_(!1),c(!1)}}}return(!e.trim()&&d&&l(!1),(0,r.useEffect)(()=>{let t=e.trim();if(!t)return;let r=setTimeout(async()=>{if(y.current!==t){y.current=t;try{let e=await (0,n.getOidcPublicConfig)(t);e.enabled?(l(!0),g(e.clientId??void 0),h(e.issuer??void 0),m(e.scopes??[])):l(!1)}catch{l(!1)}}},500);return()=>clearTimeout(r)},[e]),d)?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"relative flex items-center gap-3 py-1",children:[(0,t.jsx)("div",{className:"flex-1 border-t border-border"}),(0,t.jsx)("span",{className:"text-xs text-gray-400 dark:text-gray-500 shrink-0",children:"or"}),(0,t.jsx)("div",{className:"flex-1 border-t border-border"})]}),(0,t.jsx)(i.Button,{type:"button",onClick:b,disabled:s||p,className:"w-full bg-white dark:bg-gray-700 hover:bg-gray-50 dark:hover:bg-gray-600 text-gray-800 dark:text-gray-200 border border-border gap-2",children:p?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)("div",{className:"w-4 h-4 border-2 border-border border-t-transparent rounded-full animate-spin"}),"Redirecting…"]}):(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("svg",{className:"w-4 h-4 text-gray-500",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[(0,t.jsx)("circle",{cx:"7.5",cy:"15.5",r:"5.5"}),(0,t.jsx)("path",{d:"m21 2-9.6 9.6"}),(0,t.jsx)("path",{d:"m15.5 7.5 3 3L22 7l-3-3"})]}),"Sign in with SSO"]})})]}):null}])}]);