/* Socket Lib - Built with esbuild */
var M=Object.create;var y=Object.defineProperty;var z=Object.getOwnPropertyDescriptor;var I=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,H=Object.prototype.hasOwnProperty;var L=(t,n)=>{for(var e in n)y(t,e,{get:n[e],enumerable:!0})},A=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let i of I(n))!H.call(t,i)&&i!==e&&y(t,i,{get:()=>n[i],enumerable:!(r=z(n,i))||r.enumerable});return t};var Q=(t,n,e)=>(e=t!=null?M(W(t)):{},A(n||!t||!t.__esModule?y(e,"default",{value:t,enumerable:!0}):e,t)),T=t=>A(y({},"__esModule",{value:!0}),t);var it={};L(it,{findGitRoot:()=>$,getChangedFiles:()=>R,getChangedFilesSync:()=>j,getStagedFiles:()=>E,getStagedFilesSync:()=>K,getUnstagedFiles:()=>N,getUnstagedFilesSync:()=>U,isChanged:()=>X,isChangedSync:()=>Y,isStaged:()=>nt,isStagedSync:()=>et,isUnstaged:()=>Z,isUnstagedSync:()=>tt});module.exports=T(it);var d=Q(require("node:path")),G=require("#constants/platform"),D=require("./debug"),F=require("./globs"),f=require("./path"),S=require("./spawn"),k=require("./strings");const m=new Map;let _;function a(){return _===void 0&&(_=require("node:fs")),_}let b;function V(){return b===void 0&&(b=require("node:path")),b}function P(){return"git"}function l(){return a().realpathSync(process.cwd())}function p(t){const n=t?a().realpathSync(t):l();return{all:[P(),["status","--porcelain"],{cwd:n,shell:G.WIN32}],unstaged:[P(),["diff","--name-only"],{cwd:n}],staged:[P(),["diff","--cached","--name-only"],{cwd:n,shell:G.WIN32}]}}async function O(t,n){const{cache:e=!0,...r}={__proto__:null,...n},i=e?JSON.stringify({args:t,parseOptions:r}):void 0;if(e&&i){const o=m.get(i);if(o)return o}let s;try{const o=await(0,S.spawn)(t[0],t[1],{...t[2],stdioString:!1}),g=Buffer.isBuffer(o.stdout)?o.stdout.toString("utf8"):String(o.stdout),u=typeof t[2].cwd=="string"?t[2].cwd:void 0;s=B(g,r,u)}catch(o){return(0,D.debugNs)("git",`Git command failed (${t[0]} ${t[1].join(" ")}): ${o.message}`),[]}return e&&i&&m.set(i,s),s}function v(t,n){const{cache:e=!0,...r}={__proto__:null,...n},i=e?JSON.stringify({args:t,parseOptions:r}):void 0;if(e&&i){const o=m.get(i);if(o)return o}let s;try{const o=(0,S.spawnSync)(t[0],t[1],{...t[2],stdioString:!1}),g=Buffer.isBuffer(o.stdout)?o.stdout.toString("utf8"):String(o.stdout),u=typeof t[2].cwd=="string"?t[2].cwd:void 0;s=B(g,r,u)}catch(o){return(0,D.debugNs)("git",`Git command failed (${t[0]} ${t[1].join(" ")}): ${o.message}`),[]}return e&&i&&m.set(i,s),s}function $(t){const n=a(),e=V();let r=t;for(;;){try{const s=e.join(r,".git");if(n.existsSync(s))return r}catch{}const i=e.dirname(r);if(i===r)return t;r=i}}function B(t,n,e){const r=e?$(e):l(),{absolute:i=!1,cwd:s=r,porcelain:o=!1,...g}={__proto__:null,...n},u=s===r?r:a().realpathSync(s),w=r;let h=t?(0,k.stripAnsi)(t).split(`
`).map(c=>c.trimEnd()).filter(c=>c):[];o&&(h=h.map(c=>c.length>3?c.substring(3):c));const x=i?h.map(c=>(0,f.normalizePath)(d.default.join(w,c))):h.map(c=>(0,f.normalizePath)(c));if(u===w)return x;const q=(0,f.normalizePath)(d.default.relative(w,u)),J=(0,F.getGlobMatcher)([`${q}/**`],{...g,absolute:i,cwd:w}),C=[];for(const c of x)J(c)&&C.push(c);return C}async function R(t){const n=p(t?.cwd).all;return await O(n,{__proto__:null,...t,porcelain:!0})}function j(t){const n=p(t?.cwd).all;return v(n,{__proto__:null,...t,porcelain:!0})}async function N(t){const n=p(t?.cwd).unstaged;return await O(n,t)}function U(t){const n=p(t?.cwd).unstaged;return v(n,t)}async function E(t){const n=p(t?.cwd).staged;return await O(n,t)}function K(t){const n=p(t?.cwd).staged;return v(n,t)}async function X(t,n){const e=await R({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}function Y(t,n){const e=j({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}async function Z(t,n){const e=await N({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}function tt(t,n){const e=U({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}async function nt(t,n){const e=await E({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}function et(t,n){const e=K({__proto__:null,...n,absolute:!1}),r=a().realpathSync(t),i=n?.cwd?a().realpathSync(n.cwd):l(),s=(0,f.normalizePath)(d.default.relative(i,r));return e.includes(s)}0&&(module.exports={findGitRoot,getChangedFiles,getChangedFilesSync,getStagedFiles,getStagedFilesSync,getUnstagedFiles,getUnstagedFilesSync,isChanged,isChangedSync,isStaged,isStagedSync,isUnstaged,isUnstagedSync});
//# sourceMappingURL=git.js.map
