import{n as e}from"./rolldown-runtime-BG2f4sTM.js";import{clt as t,ddt as n,gr as r,hr as i,o4 as a,s4 as o,udt as s,xot as c,yot as l}from"./app-initial-BHB6SClA.js";async function u({appBrand:e,hostId:t=c,signal:r,useHostedLoginSuccessPage:i,useStreamlinedLogin:a}){let o=f(r);return t===`local`?n(`login-with-chatgpt`,{abortController:o,...i&&e!=null?{appBrand:e}:{},useHostedLoginSuccessPage:i,useStreamlinedLogin:a}):n(`login-with-chatgpt-for-host`,{abortController:o,hostId:t,...i&&e!=null?{appBrand:e}:{},useHostedLoginSuccessPage:i,useStreamlinedLogin:a})}function d({signal:e}={}){return n(`login-with-chatgpt-device-code`,{abortController:f(e)})}function f(e){let t=new AbortController;return e==null?t:e.aborted?(t.abort(),t):(e.addEventListener(`abort`,()=>t.abort(),{once:!0}),t)}var p=e((()=>{s(),l()}));function m({allowedWorkspaceId:e,authUrl:t,codexAppVersion:n,currentWorkspaceId:r,loginHint:a,sourceSurfaceStableId:o=_.StableID.get(i),includeCodexOriginStableId:s=!1,useDesktopAuth:c,useStreamlinedLoginUx:l}){let u=!!(e||n||r||a||o);if(!u&&!c&&!l)return t;try{let i=new URL(t);if(i.pathname===v){let t=i.searchParams.get(`authorize_url`);if(u&&t){let c=new URL(t);g(c,e,n,r,a,o,s),i.searchParams.set(`authorize_url`,c.toString())}return l&&i.searchParams.set(S,`true`),i.toString()}if(u&&g(i,e,n,r,a,o,s),l&&i.searchParams.set(S,`true`),!c)return i.toString();let d=new URL(y);return d.searchParams.set(`authorize_url`,i.toString()),l&&d.searchParams.set(S,`true`),d.toString()}catch{return t}}function h(e){return e.get(a).data?.version}function g(e,t,n,r,i,a,o){t&&e.searchParams.set(C,t),n&&e.searchParams.set(b,n),r&&e.searchParams.set(w,r),i&&e.searchParams.set(T,i),a&&(e.searchParams.set(E,a),o&&e.searchParams.set(x,a))}var _,v,y,b,x,S,C,w,T,E,D=e((()=>{_=t(),o(),r(),v=`/codex/desktop-auth`,y=`https://chatgpt.com${v}`,b=`codex_app_version`,x=`codex_origin_stable_id`,S=`codex_streamlined_login`,C=`allowed_workspace_id`,w=`current_workspace_id`,T=`login_hint`,E=`source_surface_stable_id`}));export{d as a,p as i,h as n,u as o,D as r,m as t};
//# sourceMappingURL=chatgpt-desktop-auth-url-BRuffm-N.js.map