import e from"node:path";import t from"node:os";function n(e){return typeof e==`string`?e:void 0}function r(e){return typeof e==`string`&&e.trim()||null}function i(e){return r(e)??void 0}function a(e){if(typeof e==`string`)return i(e);if(typeof e==`number`||typeof e==`boolean`||typeof e==`bigint`)return i(String(e))}function o(e){return i(e)?.toLowerCase()}function s(e){return o(e)??``}function c(e){return typeof e==`number`?Number.isFinite(e)?Math.trunc(e):void 0:i(e)}function l(e){return i(e)!==void 0}function u(e){let t=i(e);if(t&&!(t===`undefined`||t===`null`))return t}function d(n=process.env,r=t.homedir){let i=f(n,r);return i?e.resolve(i):void 0}function f(e,t){let n=u(e.OPENCLAW_HOME);if(n){if(n===`~`||n.startsWith(`~/`)||n.startsWith(`~\\`)){let r=p(e,t);return r?n.replace(/^~(?=$|[\\/])/,r):void 0}return n}return p(e,t)}function p(e,t){return u(e.HOME)||u(e.USERPROFILE)||m(t)}function m(e){try{return u(e())}catch{return}}function h(n=process.env,r=t.homedir){return d(n,r)??e.resolve(process.cwd())}function g(e,n){if(!e.startsWith(`~`))return e;let r=u(n?.home)??d(n?.env??process.env,n?.homedir??t.homedir);return r?e.replace(/^~(?=$|[\\/])/,r):e}function _(n,r){let i=n.trim();if(!i)return i;if(i.startsWith(`~`)){let n=g(i,{home:h(r?.env??process.env,r?.homedir??t.homedir),env:r?.env,homedir:r?.homedir});return e.resolve(n)}return e.resolve(i)}export{l as a,i as c,n as d,h as i,c as l,d as n,s as o,_ as r,o as s,g as t,a as u};