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