import{t as e}from"./command-format-CLxIPuLR.js";import{t}from"./openclaw-root-CnsBf6ZU.js";import{t as n}from"./version-q3SkUw2K.js";import{n as r,r as i}from"./channel-account-context-DuBGrKuL.js";async function a(e){return await r({root:await t({moduleUrl:import.meta.url,argv1:process.argv[1],cwd:process.cwd()}),timeoutMs:e.timeoutMs,fetchGit:e.fetchGit,includeRegistry:e.includeRegistry})}function o(e){let t=e.registry?.latestVersion??null,r=t?i(n,t):null,a=r!=null&&r<0,o=e.installKind===`git`&&typeof e.git?.behind==`number`?e.git.behind:null,s=o!=null&&o>0;return{available:s||a,hasGitUpdate:s,hasRegistryUpdate:a,latestVersion:a?t:null,gitBehind:o}}function s(t){let n=o(t);if(!n.available)return null;let r=[];return n.hasGitUpdate&&n.gitBehind!=null&&r.push(`git behind ${n.gitBehind}`),n.hasRegistryUpdate&&n.latestVersion&&r.push(`npm ${n.latestVersion}`),`Update available${r.length>0?` (${r.join(` · `)})`:``}. Run: ${e(`openclaw update`)}`}function c(e){let t=[],r=()=>{if(e.registry?.latestVersion){let r=i(n,e.registry.latestVersion);r===0?t.push(`npm latest ${e.registry.latestVersion}`):r!=null&&r<0?t.push(`npm update ${e.registry.latestVersion}`):t.push(`npm latest ${e.registry.latestVersion} (local newer)`);return}e.registry?.error&&t.push(`npm latest unknown`)};if(e.installKind===`git`&&e.git){let n=e.git.branch?`git ${e.git.branch}`:`git`;t.push(n),e.git.upstream&&t.push(`↔ ${e.git.upstream}`),e.git.dirty===!0&&t.push(`dirty`),e.git.behind!=null&&e.git.ahead!=null&&(e.git.behind===0&&e.git.ahead===0?t.push(`up to date`):e.git.behind>0&&e.git.ahead===0?t.push(`behind ${e.git.behind}`):e.git.behind===0&&e.git.ahead>0?t.push(`ahead ${e.git.ahead}`):e.git.behind>0&&e.git.ahead>0&&t.push(`diverged (ahead ${e.git.ahead}, behind ${e.git.behind})`)),e.git.fetchOk===!1&&t.push(`fetch failed`),r()}else t.push(e.packageManager===`unknown`?`pkg`:e.packageManager),r();return e.deps&&(e.deps.status===`ok`&&t.push(`deps ok`),e.deps.status===`missing`&&t.push(`deps missing`),e.deps.status===`stale`&&t.push(`deps stale`)),`Update: ${t.join(` · `)}`}export{o as i,c as n,a as r,s as t};
