import{$s as e,ic as t,nc as n,rc as r,tc as i}from"./app-server-manager-signals-Yn0WSnoY.js";import{g as a}from"./vscode-api-DjORcpSo.js";import{s as o}from"./primary-runtime-install-state-B0daRQaC.js";var s=`3026692602`,c=`3502101112`;function l({bundleVersion:e,durationMs:t,release:n,status:r}){return{durationMs:t,release:p(n),status:m(r),...g(e)}}function u({diagnostics:t,durationMs:n}){return{durationMs:n,problemCount:t.problems.length,status:t.installed?e.CODEX_PRIMARY_RUNTIME_DEPENDENCIES_DIAGNOSE_STATUS_OK:e.CODEX_PRIMARY_RUNTIME_DEPENDENCIES_DIAGNOSE_STATUS_PROBLEM,...g(t.bundleVersion)}}function d({durationMs:t}){return{durationMs:t,status:e.CODEX_PRIMARY_RUNTIME_DEPENDENCIES_DIAGNOSE_STATUS_FAILED}}function f({bundleVersion:e,durationMs:t,status:n}){return{durationMs:t,status:h(n),...g(e)}}function p(e){switch(e){case`latest`:return t.CODEX_PRIMARY_RUNTIME_RELEASE_LATEST;case`latest-alpha`:return t.CODEX_PRIMARY_RUNTIME_RELEASE_LATEST_ALPHA}}function m(e){switch(e){case`already-current`:return r.CODEX_PRIMARY_RUNTIME_INSTALL_RESULT_STATUS_ALREADY_CURRENT;case`canceled`:return r.CODEX_PRIMARY_RUNTIME_INSTALL_RESULT_STATUS_CANCELED;case`failed`:return r.CODEX_PRIMARY_RUNTIME_INSTALL_RESULT_STATUS_FAILED;case`installed`:return r.CODEX_PRIMARY_RUNTIME_INSTALL_RESULT_STATUS_INSTALLED}}function h(e){switch(e){case`already-current`:return i.CODEX_PRIMARY_RUNTIME_DEPENDENCIES_RESET_STATUS_ALREADY_CURRENT;case`canceled`:return i.CODEX_PRIMARY_RUNTIME_DEPENDENCIES_RESET_STATUS_CANCELED;case`failed`:return i.CODEX_PRIMARY_RUNTIME_DEPENDENCIES_RESET_STATUS_FAILED;case`installed`:return i.CODEX_PRIMARY_RUNTIME_DEPENDENCIES_RESET_STATUS_INSTALLED}}function g(e){return e==null||e.length===0?{}:{bundleVersion:e}}async function _({formatMessage:e,hostId:t,productLogger:r,release:i,toast:s}){let c=Date.now(),u=s.info(e({id:`codex.command.installPrimaryRuntime.installing`,defaultMessage:`Installing Codex runtime…`,description:`Toast shown while the Codex runtime installer is running`}),{duration:120,hasCloseButton:!1,id:`install-primary-runtime`});try{let a=await o({hostId:t,release:i,request:`install`});if(r.logProductEvent(n,l({bundleVersion:a.bundleVersion,durationMs:Date.now()-c,release:i,status:a.status})),a.status===`already-current`){s.info(e({id:`codex.command.installPrimaryRuntime.alreadyDownloaded`,defaultMessage:`Latest Codex runtime is already downloaded`,description:`Toast shown when the Codex runtime installer exits because the latest runtime is already downloaded`}),{id:`install-primary-runtime`});return}s.success(e({id:`codex.command.installPrimaryRuntime.installed`,defaultMessage:`Codex runtime installed`,description:`Toast shown when the Codex runtime finishes installing`}),{id:`install-primary-runtime`})}catch(t){if(v(t)){r.logProductEvent(n,l({bundleVersion:null,durationMs:Date.now()-c,release:i,status:`canceled`})),s.info(e({id:`codex.command.installPrimaryRuntime.canceled`,defaultMessage:`Codex runtime install canceled`,description:`Toast shown when the Codex runtime installer is canceled`}),{id:`install-primary-runtime`});return}a.error(`Error installing primary runtime`,{safe:{release:i},sensitive:{error:t}}),r.logProductEvent(n,l({bundleVersion:null,durationMs:Date.now()-c,release:i,status:`failed`})),s.danger(e({id:`codex.command.installPrimaryRuntime.failed`,defaultMessage:`Couldn’t install Codex runtime`,description:`Toast shown when the Codex runtime installer fails`}),{id:`install-primary-runtime`})}finally{u.close()}}function v(e){return e instanceof Error||e instanceof DOMException?e.name===`AbortError`||e.message.toLowerCase().includes(`aborted`):!1}export{f as a,d as i,_ as n,c as o,u as r,s,v as t};
//# sourceMappingURL=primary-runtime-install-action-D2euWXfp.js.map