var e=`https://chatgpt.com/backend-api/codex`,t=`codex_cli_rs/0.0.0 (CLEO)`;function n(e){if(typeof e!=`string`||!e.trim())return null;let t=e.split(`.`);if(t.length<2)return null;let n=t[1];if(!n)return null;try{let e=n.replace(/-/g,`+`).replace(/_/g,`/`),t=e+`=`.repeat((4-e.length%4)%4),r=Buffer.from(t,`base64`).toString(`utf8`),i=JSON.parse(r)[`https://api.openai.com/auth`];if(i&&typeof i==`object`&&!Array.isArray(i)){let e=i.chatgpt_account_id;if(typeof e==`string`&&e)return e}}catch{}return null}function r(e){let r={"User-Agent":t,originator:`codex_cli_rs`},i=n(e);return i&&(r[`ChatGPT-Account-ID`]=i),r}function i(t,n){return t===`anthropic`||t===`kimi-code`?{apiMode:`anthropic_messages`,baseUrl:null}:t===`bedrock`?{apiMode:`bedrock_converse`,baseUrl:null}:t===`gemini`?{apiMode:`chat_completions`,baseUrl:null}:t===`ollama`?{apiMode:`ollama_native`,baseUrl:null}:t===`openai`&&n===`oauth`?{apiMode:`codex_responses`,baseUrl:e}:{apiMode:`chat_completions`,baseUrl:null}}export{r as n,i as t};