/** No credentials, OAuth codes or PKCE verifiers are rendered into this page. */
export declare const ENROLLMENT_HTML = "
Codex \u8D26\u53F7\u4E0A\u4F20NUMA / CODEX
\u6B63\u5728\u51C6\u5907\u767B\u5F55
\u8BF7\u4FDD\u6301 CLI \u8FD0\u884C\u3002
";
export declare const ENROLLMENT_JS = "(() => {\nconst $=id=>document.getElementById(id),params=new URLSearchParams(location.hash.slice(1));\nlet token=params.get('token');\ntry{if(token)sessionStorage.setItem('numa-codex-enrollment-token',token);else token=sessionStorage.getItem('numa-codex-enrollment-token')}catch{}\nhistory.replaceState(null,'',location.pathname);\nlet attemptId='',busy=false,stopped=false,polling=false,revision=0,pollTimer;\nasync function request(path,method='GET'){\n const response=await fetch('/api/'+path,{method,headers:{Authorization:'Bearer '+token,...(method==='POST'?{'Content-Type':'application/json'}:{})},...(method==='POST'?{body:JSON.stringify({attemptId})}:{})});\n if(!response.ok)throw new Error(response.status===409?'\u5F53\u524D\u767B\u5F55\u4ECD\u5728\u5904\u7406\uFF0C\u8BF7\u7B49\u5F85\u7ED3\u679C\u3002':'\u65E0\u6CD5\u8FDE\u63A5\u767B\u5F55\u4F1A\u8BDD\uFF0C\u8BF7\u68C0\u67E5 CLI \u662F\u5426\u4ECD\u5728\u8FD0\u884C\u3002');\n return response.json();\n}\nfunction render(state){\n attemptId=state.attemptId;\n $('count').textContent='\u672C\u6B21\u5DF2\u5B8C\u6210 '+state.completed+' \u6B21\u8D26\u53F7\u4E0A\u4F20';\n $('again').hidden=state.phase!=='success';$('exit').hidden=!['success','failed'].includes(state.phase);\n $('account').textContent=state.accountId?'\u8D26\u53F7 ID\uFF1A'+state.accountId:'';\n const texts={preparing:['\u6B63\u5728\u51C6\u5907\u767B\u5F55','\u6B63\u5728\u68C0\u67E5\u4E0A\u4F20\u6743\u9650\u5E76\u751F\u6210\u767B\u5F55\u5730\u5740\u2026'],authenticating:['\u6B63\u5728\u8DF3\u8F6C\u767B\u5F55','\u8BF7\u5728\u767B\u5F55\u9875\u9762\u9009\u62E9\u4E0B\u4E00\u4E2A\u9700\u8981\u4E0A\u4F20\u7684\u8D26\u53F7\u3002'],uploading:['\u767B\u5F55\u6210\u529F\uFF0C\u6B63\u5728\u4E0A\u4F20','\u6B63\u5728\u7B49\u5F85\u670D\u52A1\u5668\u786E\u8BA4\u4E0A\u4F20\u7ED3\u679C\uFF0C\u8BF7\u52FF\u91CD\u590D\u64CD\u4F5C\u3002'],success:['\u767B\u5F55\u5E76\u4E0A\u4F20\u6210\u529F','\u53EF\u4EE5\u518D\u6B21\u767B\u5F55\u4E0A\u4F20\u53E6\u4E00\u4E2A\u8D26\u53F7\uFF0C\u6216\u9000\u51FA\u672C\u6B21\u4F1A\u8BDD\u3002'],failed:['\u672C\u6B21\u767B\u5F55\u6216\u4E0A\u4F20\u672A\u5B8C\u6210','\u8BF7\u5728\u7EC8\u7AEF\u67E5\u770B\u63D0\u793A\u3002\u82E5\u4E0A\u4F20\u7ED3\u679C\u672A\u786E\u8BA4\uFF0C\u91CD\u65B0\u8FD0\u884C\u540C\u4E00\u547D\u4EE4\u4F1A\u5148\u6062\u590D\u539F\u4E0A\u4F20\u3002']};\n const text=texts[state.phase]||['\u4F1A\u8BDD\u5DF2\u7ED3\u675F','\u53EF\u4EE5\u5173\u95ED\u6B64\u9875\u9762\u3002'];$('title').textContent=text[0];$('message').textContent=text[1];\n if(state.phase==='authenticating'&&state.authUrl){const url=new URL(state.authUrl);if(url.origin!=='https://auth.openai.com'||url.pathname!=='/oauth/authorize')throw new Error('\u767B\u5F55\u5730\u5740\u65E0\u6548\uFF0C\u8BF7\u91CD\u65B0\u8FD0\u884C CLI\u3002');stopped=true;location.replace(url.href)}\n}\nasync function poll(){if(stopped||busy||polling)return;polling=true;const current=revision;try{const state=await request('status');if(current===revision&&!stopped)render(state)}catch(error){if(current===revision&&!stopped){stopped=true;$('error').textContent=error.message}}finally{polling=false}}\nfunction closeAfterCountdown(){\n let remaining=3;\n const renderCountdown=()=>{$('message').textContent='\u5DF2\u4E0A\u4F20\u7684\u8D26\u53F7\u5DF2\u4FDD\u7559\uFF0C\u9875\u9762\u5C06\u5728 '+remaining+' \u79D2\u540E\u81EA\u52A8\u5173\u95ED\u3002'};\n renderCountdown();\n const timer=setInterval(()=>{\n remaining--;\n if(remaining>0){renderCountdown();return}\n clearInterval(timer);\n $('message').textContent='\u5DF2\u4E0A\u4F20\u7684\u8D26\u53F7\u5DF2\u4FDD\u7559\u3002\u82E5\u9875\u9762\u672A\u81EA\u52A8\u5173\u95ED\uFF0C\u8BF7\u624B\u52A8\u5173\u95ED\u6B64\u9875\u9762\u3002';\n try{window.close()}catch{}\n },1000);\n}\nasync function action(kind){if(busy||stopped)return;revision++;busy=true;$('again').disabled=$('exit').disabled=true;$('error').textContent='';try{const state=await request(kind,'POST');if(kind==='exit'){stopped=true;clearInterval(pollTimer);$('title').textContent='\u672C\u6B21\u767B\u5F55\u5DF2\u7ED3\u675F';$('again').hidden=$('exit').hidden=true;try{sessionStorage.removeItem('numa-codex-enrollment-token')}catch{}closeAfterCountdown()}else render(state)}catch(error){$('error').textContent=error.message}finally{busy=false;$('again').disabled=$('exit').disabled=false}}\n$('again').onclick=()=>action('again');$('exit').onclick=()=>action('exit');\nif(!token){stopped=true;$('error').textContent='\u8BF7\u4F7F\u7528 CLI \u63D0\u4F9B\u7684\u5B8C\u6574\u767B\u5F55\u9875\u9762\u5730\u5740\u3002'}else{poll();pollTimer=setInterval(poll,700)}\n})();";