import{o as e}from"./rolldown-runtime-iuO8RvI4.js";import{Dd as o,Tb as a,Vm as r,av as n,z_ as t}from"./shared-0-C4kdVF7Y.js";import{Mi as i}from"./vendor-frame-CwiylG4Y.js";import{Ru as s}from"./shared-1-3-6x7RKF.js";import{L as l}from"./shared-4-6CEyRAHb.js";var u=e(i());function m(){const e=l(),a=o(),r=n(),i=t("claudeai_login_sso_domain_param",!e&&a&&r);return(0,u.useMemo)(()=>{if(e)return{domain:e,source:"mdm"};if(!a||!r||!i)return{domain:null,source:null};const o=s();return o?{domain:o,source:"lastLogin"}:{domain:null,source:null}},[e,a,r,i])}function d(){const{domain:e,source:o}=m(),{data:n,isPending:t,error:i}=r(`/api/enterprise_auth/sso_url_for_domain?probe=true&client=desktop_app&email_domain=${encodeURIComponent(e??"")}`,{queryKey:["desktop-enterprise-sso-probe",e],enabled:!!e,timeoutMs:8e3,meta:{noToast:!0,silent:e=>e instanceof a&&404===e.statusCode||e instanceof DOMException&&"TimeoutError"===e.name},retry:(e,o)=>!(o instanceof a&&404===o.statusCode)&&((!(o instanceof DOMException)||"TimeoutError"!==o.name&&"AbortError"!==o.name)&&e<2),staleTime:6e4}),s=e?n?.available?"available":t?"loading":!1===n?.available||i instanceof a&&404===i.statusCode?"unavailable":"probe_error":"disabled";return(0,u.useEffect)(()=>{if("mdm"!==o||"unavailable"!==s&&"probe_error"!==s)return;const a="unavailable"===s?"SSO is not available for that domain; falling back to stock login.":`the SSO availability probe failed${i?` (${i})`:""}; the button is clickable and will retry on click.`;console.warn(`loginSsoOrgDomain is "${e}" (MDM key or Nest build default) but ${a}`)},[s,o,e,i]),{status:s,domain:e,source:o}}export{m as n,d as t};