just-git 1.5.6 → 1.5.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +342 -338
- package/dist/repo/index.d.ts +137 -2
- package/dist/repo/index.js +19 -18
- package/dist/server/index.d.ts +1 -1
- package/dist/{writing-IwfRRrts.d.ts → writing-CF-eYohc.d.ts} +1 -1
- package/package.json +1 -1
package/dist/repo/index.js
CHANGED
|
@@ -1,28 +1,29 @@
|
|
|
1
|
-
var Ne=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var At=(()=>{let t=new Array(256);for(let e=0;e<256;e++)t[e]=(e>>4).toString(16)+(e&15).toString(16);return t})();function Te(t){let e="";for(let n=0;n<20;n++)e+=At[t[n]];return e}function et(t,e){let n="";for(let r=0;r<20;r++)n+=At[t[e+r]];return n}function be(t){let e=new Uint8Array(20);for(let n=0;n<20;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}var ir=new TextEncoder;function tt(t){return typeof t=="string"?ir.encode(t):t}function or(){if(typeof globalThis.Bun<"u")return()=>{let t=new Bun.CryptoHasher("sha1"),e={update(n){return t.update(tt(n)),e},hex:()=>Promise.resolve(t.digest("hex"))};return e};try{let t=Ne(["node","crypto"].join(":"));if(typeof t.createHash=="function")return()=>{let e=t.createHash("sha1"),n={update(r){return e.update(tt(r)),n},hex:()=>Promise.resolve(e.digest("hex"))};return n}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let t=[],e={update(n){return t.push(tt(n)),e},async hex(){let n=0;for(let i of t)n+=i.byteLength;let r=new Uint8Array(n),s=0;for(let i of t)r.set(i,s),s+=i.byteLength;let o=await crypto.subtle.digest("SHA-1",r);return Te(new Uint8Array(o))}};return e};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}var $t=or(),nt=$t;async function Be(t){return $t().update(t).hex()}var ee=Uint8Array,we=Uint16Array,ar=Int32Array,Lt=new ee([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Mt=new ee([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),cr=new ee([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Ht=(t,e)=>{let n=new we(31);for(let s=0;s<31;++s)n[s]=e+=1<<t[s-1];let r=new ar(n[30]);for(let s=1;s<30;++s)for(let o=n[s];o<n[s+1];++o)r[o]=o-n[s]<<5|s;return{b:n,r}},{b:Dt}=Ht(Lt,2);Dt[28]=258;var{b:lr}=Ht(Mt,0),it=new we(32768);for(let t=0;t<32768;++t){let e=(t&43690)>>1|(t&21845)<<1;e=(e&52428)>>2|(e&13107)<<2,e=(e&61680)>>4|(e&3855)<<4,it[t]=((e&65280)>>8|(e&255)<<8)>>1}var Ce=(t,e,n)=>{let r=t.length,s=0,o=new we(e);for(;s<r;++s)t[s]&&++o[t[s]-1];let i=new we(e);for(s=1;s<e;++s)i[s]=i[s-1]+o[s-1]<<1;let a;if(n){a=new we(1<<e);let c=15-e;for(s=0;s<r;++s)if(t[s]){let l=s<<4|t[s],f=e-t[s],u=i[t[s]-1]++<<f;for(let d=u|(1<<f)-1;u<=d;++u)a[it[u]>>c]=l}}else for(a=new we(r),s=0;s<r;++s)t[s]&&(a[s]=it[i[t[s]-1]++]>>15-t[s]);return a},Se=new ee(288);for(let t=0;t<144;++t)Se[t]=8;for(let t=144;t<256;++t)Se[t]=9;for(let t=256;t<280;++t)Se[t]=7;for(let t=280;t<288;++t)Se[t]=8;var Ut=new ee(32);for(let t=0;t<32;++t)Ut[t]=5;var fr=Ce(Se,9,1),ur=Ce(Ut,5,1),rt=t=>{let e=t[0];for(let n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},Q=(t,e,n)=>{let r=e/8|0;return(t[r]|t[r+1]<<8)>>(e&7)&n},st=(t,e)=>{let n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(e&7)},Nt=t=>(t+7)/8|0,hr=(t,e,n)=>((e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new ee(t.subarray(e,n))),re=(t,e)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||n[t]||"unknown inflate error")},Bt=(t,e,n,r)=>{let s=t.length,o=r?r.length:0;if(!s||e.f&&!e.l)return n||new ee(0);let i=!n,a=i||e.i!=2,c=e.i;i&&(n=new ee(s*3));let l=k=>{let v=n.length;if(k>v){let j=new ee(Math.max(v*2,k));j.set(n),n=j}},f=e.f||0,u=e.p||0,d=e.b||0,h=e.l,m=e.d,g=e.m,p=e.n,b=s*8;do{if(!h){f=Q(t,u,1);let R=Q(t,u+1,3);if(u+=3,R)if(R==1)h=fr,m=ur,g=9,p=5;else if(R==2){let I=Q(t,u,31)+257,w=Q(t,u+10,15)+4,C=I+Q(t,u+5,31)+1;u+=14;let x=new ee(C),P=new ee(19);for(let y=0;y<w;++y)P[cr[y]]=Q(t,u+y*3,7);u+=w*3;let O=rt(P),$=(1<<O)-1,H=Ce(P,O,1);for(let y=0;y<C;){let T=H[Q(t,u,$)];u+=T&15;let L=T>>4;if(L<16)x[y++]=L;else{let M=0,S=0;for(L==16?(S=3+Q(t,u,3),u+=2,M=x[y-1]):L==17?(S=3+Q(t,u,7),u+=3):L==18&&(S=11+Q(t,u,127),u+=7);S--;)x[y++]=M}}let J=x.subarray(0,I),E=x.subarray(I);g=rt(J),p=rt(E),h=Ce(J,g,1),m=Ce(E,p,1)}else re(1);else{let I=Nt(u)+4,w=t[I-4]|t[I-3]<<8,C=I+w;if(C>s){c&&re(0);break}a&&l(d+w),n.set(t.subarray(I,C),d),e.b=d+=w,e.p=u=C*8,e.f=f;continue}if(u>b){c&&re(0);break}}a&&l(d+131072);let k=(1<<g)-1,v=(1<<p)-1,j=u;for(;;j=u){let R=h[st(t,u)&k],I=R>>4;if(u+=R&15,u>b){c&&re(0);break}if(R||re(2),I<256)n[d++]=I;else if(I==256){j=u,h=null;break}else{let w=I-254;if(I>264){let $=I-257,H=Lt[$];w=Q(t,u,(1<<H)-1)+Dt[$],u+=H}let C=m[st(t,u)&v],x=C>>4;C||re(3),u+=C&15;let P=lr[x];if(x>3){let $=Mt[x];P+=st(t,u)&(1<<$)-1,u+=$}if(u>b){c&&re(0);break}a&&l(d+131072);let O=d+w;if(d<P){let $=o-P,H=Math.min(P,O);for($+d<0&&re(3);d<H;++d)n[d]=r[$+d]}for(;d<O;++d)n[d]=n[d-P]}}e.l=h,e.p=j,e.b=d,e.f=f,h&&(f=1,e.m=g,e.d=m,e.n=p)}while(!f);return d!=n.length&&i?hr(n,0,d):n.subarray(0,d)},Gt=t=>(((t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31)&&re(0,"invalid zlib data"),t[1]&32&&re(0,"zlib dictionaries are not supported"),2);function Ft(t){let e=Gt(t);return Bt(t.subarray(e,-4),{i:2})}function ot(t){let e=Gt(t),n={i:2},r=Bt(t.subarray(e),n),s=Nt(n.p);return{result:r,bytesConsumed:e+s+4}}async function dr(){let t;if(!(typeof document<"u"))try{t=Ne(["node","zlib"].join(":"))}catch{try{t=await import(["node","zlib"].join(":"))}catch{}}if(t&&typeof t.deflateSync=="function"&&typeof t.inflateSync=="function"){let r=null;try{let s=t.inflateSync(t.deflateSync(Buffer.from("x")),{info:!0});s?.engine&&typeof s.engine.bytesWritten=="number"&&(r=o=>{let i=t.inflateSync(o,{info:!0});return{result:new Uint8Array(i.buffer),bytesConsumed:i.engine.bytesWritten}})}catch{}return{deflateSync:s=>new Uint8Array(t.deflateSync(s)),inflateSync:s=>new Uint8Array(t.inflateSync(s)),inflateWithConsumed:r??ot}}let n;return typeof globalThis.CompressionStream=="function"?n=async r=>{let s=new CompressionStream("deflate"),o=s.writable.getWriter();return o.write(r),o.close(),new Uint8Array(await new Response(s.readable).arrayBuffer())}:n=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:n,inflateSync:Ft,inflateWithConsumed:ot}}var mr=null;function pr(){return mr??=dr()}async function _t(t,e){let n=await pr(),{result:r,bytesConsumed:s}=n.inflateWithConsumed(t);if(r.byteLength!==e)throw new Error(`Inflate size mismatch: got ${r.byteLength}, expected ${e}`);return{result:r,bytesConsumed:s}}var Wt=1346454347,gr=2,yr=1,br=2,wr=3,Ir=4,Ge=6,ct=7,Er={[yr]:"commit",[br]:"tree",[wr]:"blob",[Ir]:"tag"};async function Yt(t,e){let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint32(0);if(r!==Wt)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${Wt.toString(16)})`);let s=n.getUint32(4);if(s!==gr)throw new Error(`Unsupported pack version: ${s}`);if(t.byteLength>=32){let l=et(t,t.byteLength-20),f=nt();f.update(t.subarray(0,t.byteLength-20));let u=await f.hex();if(u!==l)throw new Error(`pack checksum mismatch: expected ${l}, computed ${u}`)}let o=n.getUint32(8),i=[],a=12;for(let l=0;l<o;l++){let f=await xr(t,a);i.push(f),a=f.nextOffset}return(await Or(i,e)).map((l,f)=>({...l,offset:i[f].headerOffset,nextOffset:i[f].nextOffset}))}async function xr(t,e){let n=e,r=t[e++],s=r>>4&7,o=r&15,i=4;for(;r&128;)r=t[e++],o|=(r&127)<<i,i+=7;let a,c;if(s===Ge){let u=t[e++];for(a=u&127;u&128;)a+=1,u=t[e++],a=(a<<7)+(u&127);a=n-a}else s===ct&&(c=et(t,e),e+=20);let{result:l,bytesConsumed:f}=await _t(t.subarray(e),o);return{headerOffset:n,typeNum:s,inflated:l,baseOffset:a,baseHash:c,nextOffset:e+f}}var zt=50;async function Or(t,e){let n=new Map;for(let o=0;o<t.length;o++)n.set(t[o].headerOffset,o);let r=new Array(t.length).fill(null);async function s(o,i=0){if(i>zt)throw new Error(`delta chain depth ${i} exceeds limit of ${zt}`);let a=r[o];if(a)return a;let c=t[o];if(c.typeNum!==Ge&&c.typeNum!==ct){let h=Er[c.typeNum];if(!h)throw new Error(`Unknown object type: ${c.typeNum}`);let m={type:h,content:c.inflated,hash:await at(h,c.inflated)};return r[o]=m,m}if(c.typeNum===Ge){let h=n.get(c.baseOffset);if(h===void 0)throw new Error(`OFS_DELTA base not found at offset ${c.baseOffset}`);let m=await s(h,i+1),g=Vt(m.content,c.inflated),p={type:m.type,content:g,hash:await at(m.type,g)};return r[o]=p,p}let l=await Rr(t,r,c.baseHash,s),f;if(l!==void 0)f=await s(l,i+1);else if(e){let h=await e(c.baseHash);h&&(f=h)}if(!f)throw new Error(`REF_DELTA base not found for hash ${c.baseHash}`);let u=Vt(f.content,c.inflated),d={type:f.type,content:u,hash:await at(f.type,u)};return r[o]=d,d}for(let o=0;o<t.length;o++)await s(o);return r}async function Rr(t,e,n,r){for(let s=0;s<e.length;s++)if(e[s]?.hash===n)return s;for(let s=0;s<t.length;s++){let o=t[s];if(o.typeNum!==Ge&&o.typeNum!==ct&&(await r(s)).hash===n)return s}}function Vt(t,e){let n=0,{value:r,newPos:s}=Kt(e,n);if(n=s,r!==t.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${t.byteLength}`);let{value:o,newPos:i}=Kt(e,n);n=i;let a=new Uint8Array(o),c=0;for(;n<e.byteLength;){let l=e[n++];if(l&128){let f=0,u=0;l&1&&(f=e[n++]),l&2&&(f|=e[n++]<<8),l&4&&(f|=e[n++]<<16),l&8&&(f|=e[n++]<<24),l&16&&(u=e[n++]),l&32&&(u|=e[n++]<<8),l&64&&(u|=e[n++]<<16),u===0&&(u=65536),a.set(t.subarray(f,f+u),c),c+=u}else if(l>0)a.set(e.subarray(n,n+l),c),c+=l,n+=l;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(c!==o)throw new Error(`Delta produced ${c} bytes, expected ${o}`);return a}function Kt(t,e){let n=0,r=0,s;do s=t[e++],n|=(s&127)<<r,r+=7;while(s&128);return{value:n,newPos:e}}var Pr=new TextEncoder;async function at(t,e){let n=Pr.encode(`${t} ${e.byteLength}\0`),r=nt();return r.update(n),r.update(e),r.hex()}function kr(t){if(t==="")return".";if(t==="/")return"/";let e=t.charCodeAt(0)===47,n=t.charCodeAt(t.length-1)===47,r=t.split("/"),s=[];for(let i of r)i===""||i==="."||(i===".."?e||s.length>0&&s[s.length-1]!==".."?s.pop():s.push(".."):s.push(i));let o=s.join("/");return e&&(o=`/${o}`),n&&o.length>1&&!o.endsWith("/")&&(o+="/"),o||(e?"/":n?"./":".")}function Ie(...t){if(t.length===0)return".";let e=t.filter(n=>n!=="").join("/");return e===""?".":kr(e)}function qt(t){if(t==="")return".";if(t==="/")return"/";let e=t.length;for(;e>1&&t.charCodeAt(e-1)===47;)e--;let n=t.slice(0,e),r=n.lastIndexOf("/");return r===-1?".":r===0?"/":n.slice(0,r)}var Tr=new TextEncoder,Wi=new TextDecoder;function Xt(t,e){let n=Tr.encode(`${t} ${e.byteLength}\0`),r=new Uint8Array(n.byteLength+e.byteLength);return r.set(n),r.set(e,n.byteLength),r}function ve(t){let e=t.indexOf("<"),n=t.indexOf(">");if(e===-1||n===-1)throw new Error(`Malformed identity line: "${t}"`);let r=t.slice(0,e).trimEnd(),s=t.slice(e+1,n),o=t.slice(n+2),[i="0",a="+0000"]=o.split(" "),c=parseInt(i,10);return{name:r,email:s,timestamp:c,timezone:a}}function je(t){return`${t.name} <${t.email}> ${t.timestamp} ${t.timezone}`}var Cr=new TextEncoder,Sr=new TextDecoder;function Zt(t){let e=Sr.decode(t),n=e.indexOf(`
|
|
1
|
+
var _e=(t=>typeof require<"u"?require:typeof Proxy<"u"?new Proxy(t,{get:(e,n)=>(typeof require<"u"?require:e)[n]}):t)(function(t){if(typeof require<"u")return require.apply(this,arguments);throw Error('Dynamic require of "'+t+'" is not supported')});var Mt=(()=>{let t=new Array(256);for(let e=0;e<256;e++)t[e]=(e>>4).toString(16)+(e&15).toString(16);return t})();function Ce(t){let e="";for(let n=0;n<20;n++)e+=Mt[t[n]];return e}function nt(t,e){let n="";for(let r=0;r<20;r++)n+=Mt[t[e+r]];return n}function we(t){let e=new Uint8Array(20);for(let n=0;n<20;n++)e[n]=parseInt(t.slice(n*2,n*2+2),16);return e}var lr=new TextEncoder;function rt(t){return typeof t=="string"?lr.encode(t):t}function fr(){if(typeof globalThis.Bun<"u")return()=>{let t=new Bun.CryptoHasher("sha1"),e={update(n){return t.update(rt(n)),e},hex:()=>Promise.resolve(t.digest("hex"))};return e};try{let t=_e(["node","crypto"].join(":"));if(typeof t.createHash=="function")return()=>{let e=t.createHash("sha1"),n={update(r){return e.update(rt(r)),n},hex:()=>Promise.resolve(e.digest("hex"))};return n}}catch{}if(typeof globalThis.crypto?.subtle?.digest=="function")return()=>{let t=[],e={update(n){return t.push(rt(n)),e},async hex(){let n=0;for(let o of t)n+=o.byteLength;let r=new Uint8Array(n),s=0;for(let o of t)r.set(o,s),s+=o.byteLength;let i=await crypto.subtle.digest("SHA-1",r);return Ce(new Uint8Array(i))}};return e};throw new Error("No SHA-1 implementation available. Requires Bun, Node.js, Deno, or a browser with Web Crypto.")}var Lt=fr(),st=Lt;async function We(t){return Lt().update(t).hex()}var te=Uint8Array,Ee=Uint16Array,ur=Int32Array,Ht=new te([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0,0,0,0]),Bt=new te([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13,0,0]),hr=new te([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),Dt=(t,e)=>{let n=new Ee(31);for(let s=0;s<31;++s)n[s]=e+=1<<t[s-1];let r=new ur(n[30]);for(let s=1;s<30;++s)for(let i=n[s];i<n[s+1];++i)r[i]=i-n[s]<<5|s;return{b:n,r}},{b:Ut}=Dt(Ht,2);Ut[28]=258;var{b:dr}=Dt(Bt,0),at=new Ee(32768);for(let t=0;t<32768;++t){let e=(t&43690)>>1|(t&21845)<<1;e=(e&52428)>>2|(e&13107)<<2,e=(e&61680)>>4|(e&3855)<<4,at[t]=((e&65280)>>8|(e&255)<<8)>>1}var ve=(t,e,n)=>{let r=t.length,s=0,i=new Ee(e);for(;s<r;++s)t[s]&&++i[t[s]-1];let o=new Ee(e);for(s=1;s<e;++s)o[s]=o[s-1]+i[s-1]<<1;let a;if(n){a=new Ee(1<<e);let c=15-e;for(s=0;s<r;++s)if(t[s]){let l=s<<4|t[s],f=e-t[s],u=o[t[s]-1]++<<f;for(let d=u|(1<<f)-1;u<=d;++u)a[at[u]>>c]=l}}else for(a=new Ee(r),s=0;s<r;++s)t[s]&&(a[s]=at[o[t[s]-1]++]>>15-t[s]);return a},je=new te(288);for(let t=0;t<144;++t)je[t]=8;for(let t=144;t<256;++t)je[t]=9;for(let t=256;t<280;++t)je[t]=7;for(let t=280;t<288;++t)je[t]=8;var Nt=new te(32);for(let t=0;t<32;++t)Nt[t]=5;var mr=ve(je,9,1),pr=ve(Nt,5,1),it=t=>{let e=t[0];for(let n=1;n<t.length;++n)t[n]>e&&(e=t[n]);return e},ee=(t,e,n)=>{let r=e/8|0;return(t[r]|t[r+1]<<8)>>(e&7)&n},ot=(t,e)=>{let n=e/8|0;return(t[n]|t[n+1]<<8|t[n+2]<<16)>>(e&7)},Gt=t=>(t+7)/8|0,gr=(t,e,n)=>((e==null||e<0)&&(e=0),(n==null||n>t.length)&&(n=t.length),new te(t.subarray(e,n))),re=(t,e)=>{let n=["unexpected EOF","invalid block type","invalid length/literal","invalid distance"];throw new Error(e||n[t]||"unknown inflate error")},Ft=(t,e,n,r)=>{let s=t.length,i=r?r.length:0;if(!s||e.f&&!e.l)return n||new te(0);let o=!n,a=o||e.i!=2,c=e.i;o&&(n=new te(s*3));let l=P=>{let C=n.length;if(P>C){let v=new te(Math.max(C*2,P));v.set(n),n=v}},f=e.f||0,u=e.p||0,d=e.b||0,h=e.l,m=e.d,g=e.m,p=e.n,b=s*8;do{if(!h){f=ee(t,u,1);let R=ee(t,u+1,3);if(u+=3,R)if(R==1)h=mr,m=pr,g=9,p=5;else if(R==2){let w=ee(t,u,31)+257,E=ee(t,u+10,15)+4,S=w+ee(t,u+5,31)+1;u+=14;let x=new te(S),T=new te(19);for(let y=0;y<E;++y)T[hr[y]]=ee(t,u+y*3,7);u+=E*3;let O=it(T),$=(1<<O)-1,H=ve(T,O,1);for(let y=0;y<S;){let k=H[ee(t,u,$)];u+=k&15;let M=k>>4;if(M<16)x[y++]=M;else{let L=0,j=0;for(M==16?(j=3+ee(t,u,3),u+=2,L=x[y-1]):M==17?(j=3+ee(t,u,7),u+=3):M==18&&(j=11+ee(t,u,127),u+=7);j--;)x[y++]=L}}let Q=x.subarray(0,w),I=x.subarray(w);g=it(Q),p=it(I),h=ve(Q,g,1),m=ve(I,p,1)}else re(1);else{let w=Gt(u)+4,E=t[w-4]|t[w-3]<<8,S=w+E;if(S>s){c&&re(0);break}a&&l(d+E),n.set(t.subarray(w,S),d),e.b=d+=E,e.p=u=S*8,e.f=f;continue}if(u>b){c&&re(0);break}}a&&l(d+131072);let P=(1<<g)-1,C=(1<<p)-1,v=u;for(;;v=u){let R=h[ot(t,u)&P],w=R>>4;if(u+=R&15,u>b){c&&re(0);break}if(R||re(2),w<256)n[d++]=w;else if(w==256){v=u,h=null;break}else{let E=w-254;if(w>264){let $=w-257,H=Ht[$];E=ee(t,u,(1<<H)-1)+Ut[$],u+=H}let S=m[ot(t,u)&C],x=S>>4;S||re(3),u+=S&15;let T=dr[x];if(x>3){let $=Bt[x];T+=ot(t,u)&(1<<$)-1,u+=$}if(u>b){c&&re(0);break}a&&l(d+131072);let O=d+E;if(d<T){let $=i-T,H=Math.min(T,O);for($+d<0&&re(3);d<H;++d)n[d]=r[$+d]}for(;d<O;++d)n[d]=n[d-T]}}e.l=h,e.p=v,e.b=d,e.f=f,h&&(f=1,e.m=g,e.d=m,e.n=p)}while(!f);return d!=n.length&&o?gr(n,0,d):n.subarray(0,d)},_t=t=>(((t[0]&15)!=8||t[0]>>4>7||(t[0]<<8|t[1])%31)&&re(0,"invalid zlib data"),t[1]&32&&re(0,"zlib dictionaries are not supported"),2);function Wt(t){let e=_t(t);return Ft(t.subarray(e,-4),{i:2})}function ct(t){let e=_t(t),n={i:2},r=Ft(t.subarray(e),n),s=Gt(n.p);return{result:r,bytesConsumed:e+s+4}}async function yr(){let t;if(!(typeof document<"u"))try{t=_e(["node","zlib"].join(":"))}catch{try{t=await import(["node","zlib"].join(":"))}catch{}}if(t&&typeof t.deflateSync=="function"&&typeof t.inflateSync=="function"){let r=null;try{let s=t.inflateSync(t.deflateSync(Buffer.from("x")),{info:!0});s?.engine&&typeof s.engine.bytesWritten=="number"&&(r=i=>{let o=t.inflateSync(i,{info:!0});return{result:new Uint8Array(o.buffer),bytesConsumed:o.engine.bytesWritten}})}catch{}return{deflateSync:s=>new Uint8Array(t.deflateSync(s)),inflateSync:s=>new Uint8Array(t.inflateSync(s)),inflateWithConsumed:r??ct}}let n;return typeof globalThis.CompressionStream=="function"?n=async r=>{let s=new CompressionStream("deflate"),i=s.writable.getWriter();return i.write(r),i.close(),new Uint8Array(await new Response(s.readable).arrayBuffer())}:n=()=>{throw new Error("No deflate implementation available. Requires node:zlib or CompressionStream.")},{deflateSync:n,inflateSync:Wt,inflateWithConsumed:ct}}var br=null;function wr(){return br??=yr()}async function zt(t,e){let n=await wr(),{result:r,bytesConsumed:s}=n.inflateWithConsumed(t);if(r.byteLength!==e)throw new Error(`Inflate size mismatch: got ${r.byteLength}, expected ${e}`);return{result:r,bytesConsumed:s}}var Vt=1346454347,Er=2,Ir=1,xr=2,Rr=3,Or=4,ze=6,ft=7,Pr={[Ir]:"commit",[xr]:"tree",[Rr]:"blob",[Or]:"tag"};async function Xt(t,e){let n=new DataView(t.buffer,t.byteOffset,t.byteLength),r=n.getUint32(0);if(r!==Vt)throw new Error(`Invalid pack signature: 0x${r.toString(16)} (expected 0x${Vt.toString(16)})`);let s=n.getUint32(4);if(s!==Er)throw new Error(`Unsupported pack version: ${s}`);if(t.byteLength>=32){let l=nt(t,t.byteLength-20),f=st();f.update(t.subarray(0,t.byteLength-20));let u=await f.hex();if(u!==l)throw new Error(`pack checksum mismatch: expected ${l}, computed ${u}`)}let i=n.getUint32(8),o=[],a=12;for(let l=0;l<i;l++){let f=await Tr(t,a);o.push(f),a=f.nextOffset}return(await kr(o,e)).map((l,f)=>({...l,offset:o[f].headerOffset,nextOffset:o[f].nextOffset}))}async function Tr(t,e){let n=e,r=t[e++],s=r>>4&7,i=r&15,o=4;for(;r&128;)r=t[e++],i|=(r&127)<<o,o+=7;let a,c;if(s===ze){let u=t[e++];for(a=u&127;u&128;)a+=1,u=t[e++],a=(a<<7)+(u&127);a=n-a}else s===ft&&(c=nt(t,e),e+=20);let{result:l,bytesConsumed:f}=await zt(t.subarray(e),i);return{headerOffset:n,typeNum:s,inflated:l,baseOffset:a,baseHash:c,nextOffset:e+f}}var Kt=50;async function kr(t,e){let n=new Map;for(let i=0;i<t.length;i++)n.set(t[i].headerOffset,i);let r=new Array(t.length).fill(null);async function s(i,o=0){if(o>Kt)throw new Error(`delta chain depth ${o} exceeds limit of ${Kt}`);let a=r[i];if(a)return a;let c=t[i];if(c.typeNum!==ze&&c.typeNum!==ft){let h=Pr[c.typeNum];if(!h)throw new Error(`Unknown object type: ${c.typeNum}`);let m={type:h,content:c.inflated,hash:await lt(h,c.inflated)};return r[i]=m,m}if(c.typeNum===ze){let h=n.get(c.baseOffset);if(h===void 0)throw new Error(`OFS_DELTA base not found at offset ${c.baseOffset}`);let m=await s(h,o+1),g=Yt(m.content,c.inflated),p={type:m.type,content:g,hash:await lt(m.type,g)};return r[i]=p,p}let l=await Sr(t,r,c.baseHash,s),f;if(l!==void 0)f=await s(l,o+1);else if(e){let h=await e(c.baseHash);h&&(f=h)}if(!f)throw new Error(`REF_DELTA base not found for hash ${c.baseHash}`);let u=Yt(f.content,c.inflated),d={type:f.type,content:u,hash:await lt(f.type,u)};return r[i]=d,d}for(let i=0;i<t.length;i++)await s(i);return r}async function Sr(t,e,n,r){for(let s=0;s<e.length;s++)if(e[s]?.hash===n)return s;for(let s=0;s<t.length;s++){let i=t[s];if(i.typeNum!==ze&&i.typeNum!==ft&&(await r(s)).hash===n)return s}}function Yt(t,e){let n=0,{value:r,newPos:s}=qt(e,n);if(n=s,r!==t.byteLength)throw new Error(`Delta base size mismatch: expected ${r}, got ${t.byteLength}`);let{value:i,newPos:o}=qt(e,n);n=o;let a=new Uint8Array(i),c=0;for(;n<e.byteLength;){let l=e[n++];if(l&128){let f=0,u=0;l&1&&(f=e[n++]),l&2&&(f|=e[n++]<<8),l&4&&(f|=e[n++]<<16),l&8&&(f|=e[n++]<<24),l&16&&(u=e[n++]),l&32&&(u|=e[n++]<<8),l&64&&(u|=e[n++]<<16),u===0&&(u=65536),a.set(t.subarray(f,f+u),c),c+=u}else if(l>0)a.set(e.subarray(n,n+l),c),c+=l,n+=l;else throw new Error("Unexpected delta opcode 0x00 (reserved)")}if(c!==i)throw new Error(`Delta produced ${c} bytes, expected ${i}`);return a}function qt(t,e){let n=0,r=0,s;do s=t[e++],n|=(s&127)<<r,r+=7;while(s&128);return{value:n,newPos:e}}var Cr=new TextEncoder;async function lt(t,e){let n=Cr.encode(`${t} ${e.byteLength}\0`),r=st();return r.update(n),r.update(e),r.hex()}function vr(t){if(t==="")return".";if(t==="/")return"/";let e=t.charCodeAt(0)===47,n=t.charCodeAt(t.length-1)===47,r=t.split("/"),s=[];for(let o of r)o===""||o==="."||(o===".."?e||s.length>0&&s[s.length-1]!==".."?s.pop():s.push(".."):s.push(o));let i=s.join("/");return e&&(i=`/${i}`),n&&i.length>1&&!i.endsWith("/")&&(i+="/"),i||(e?"/":n?"./":".")}function pe(...t){if(t.length===0)return".";let e=t.filter(n=>n!=="").join("/");return e===""?".":vr(e)}function Zt(t){if(t==="")return".";if(t==="/")return"/";let e=t.length;for(;e>1&&t.charCodeAt(e-1)===47;)e--;let n=t.slice(0,e),r=n.lastIndexOf("/");return r===-1?".":r===0?"/":n.slice(0,r)}var jr=new TextEncoder,Zi=new TextDecoder;function Jt(t,e){let n=jr.encode(`${t} ${e.byteLength}\0`),r=new Uint8Array(n.byteLength+e.byteLength);return r.set(n),r.set(e,n.byteLength),r}function Ae(t){let e=t.indexOf("<"),n=t.indexOf(">");if(e===-1||n===-1)throw new Error(`Malformed identity line: "${t}"`);let r=t.slice(0,e).trimEnd(),s=t.slice(e+1,n),i=t.slice(n+2),[o="0",a="+0000"]=i.split(" "),c=parseInt(o,10);return{name:r,email:s,timestamp:c,timezone:a}}function $e(t){return`${t.name} <${t.email}> ${t.timestamp} ${t.timezone}`}var Ar=new TextEncoder,$r=new TextDecoder;function Qt(t){let e=$r.decode(t),n=e.indexOf(`
|
|
2
2
|
|
|
3
|
-
`),r=n===-1?e:e.slice(0,n),s=n===-1?"":e.slice(n+2),
|
|
4
|
-
`)){let f=l.indexOf(" ");if(f===-1)continue;let u=l.slice(0,f),d=l.slice(f+1);switch(u){case"tree":
|
|
5
|
-
`))}var
|
|
3
|
+
`),r=n===-1?e:e.slice(0,n),s=n===-1?"":e.slice(n+2),i="",o=[],a,c;for(let l of r.split(`
|
|
4
|
+
`)){let f=l.indexOf(" ");if(f===-1)continue;let u=l.slice(0,f),d=l.slice(f+1);switch(u){case"tree":i=d;break;case"parent":o.push(d);break;case"author":a=Ae(d);break;case"committer":c=Ae(d);break}}if(!i)throw new Error("Commit missing tree field");if(!a)throw new Error("Commit missing author field");if(!c)throw new Error("Commit missing committer field");return{type:"commit",tree:i,parents:o,author:a,committer:c,message:s}}function Me(t){let e=[];e.push(`tree ${t.tree}`);for(let n of t.parents)e.push(`parent ${n}`);return e.push(`author ${$e(t.author)}`),e.push(`committer ${$e(t.committer)}`),e.push(""),e.push(t.message),Ar.encode(e.join(`
|
|
5
|
+
`))}var Mr=new TextEncoder,Lr=new TextDecoder;function en(t){let e=Lr.decode(t),n=e.indexOf(`
|
|
6
6
|
|
|
7
|
-
`),r=n===-1?e:e.slice(0,n),s=n===-1?"":e.slice(n+2),
|
|
8
|
-
`)){let f=l.indexOf(" ");if(f===-1)continue;let u=l.slice(0,f),d=l.slice(f+1);switch(u){case"object":
|
|
9
|
-
`))}async function
|
|
10
|
-
`,exitCode:128}}var
|
|
11
|
-
`);
|
|
12
|
-
`);return e[e.length-1]===""&&e.pop(),e}var ls=4,yn=1024,We=100,Ke=0,ze=1,Ee=2;function mt(t){let e=1;for(;e*e<t;)e++;return e}function fs(t,e){let n=new Map,r=[],s=new Array(t.length),o=new Array(e.length);for(let i=0;i<t.length;i++){let a=t[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len1++,s[i]=c}for(let i=0;i<e.length;i++){let a=e[i],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len2++,o[i]=c}return{classes1:s,classes2:o,classInfo:r}}function us(t,e,n,r){let s=0,o=Math.min(e,r);for(;s<o&&t[s]===n[s];)s++;let i=s,a=0,c=o-i;for(;a<c&&t[e-1-a]===n[r-1-a];)a++;return{dstart:i,dend1:e-a-1,dend2:r-a-1}}function bn(t,e,n,r){e-n>We&&(n=e-We),r-e>We&&(r=e+We);let s=0,o=1;for(let c=1;e-c>=n;c++){let l=t[e-c];if(l===Ke)s++;else if(l===Ee)o++;else break}if(s===0)return!1;let i=0,a=1;for(let c=1;e+c<=r;c++){let l=t[e+c];if(l===Ke)i++;else if(l===Ee)a++;else break}return i===0?!1:(i+=s,a+=o,a*ls<a+i)}function hs(t,e,n,r,s,o,i,a,c,l){let f=new Uint8Array(e),u=new Uint8Array(r),d=Math.min(mt(e),yn);for(let p=o;p<=i;p++){let b=s[t[p]].len2;b===0?f[p]=Ke:b>=d?f[p]=Ee:f[p]=ze}let h=Math.min(mt(r),yn);for(let p=o;p<=a;p++){let b=s[n[p]].len1;b===0?u[p]=Ke:b>=h?u[p]=Ee:u[p]=ze}let m=[];for(let p=o;p<=i;p++)f[p]===ze||f[p]===Ee&&!bn(f,p,o,i)?m.push(p):c[p]=1;let g=[];for(let p=o;p<=a;p++)u[p]===ze||u[p]===Ee&&!bn(u,p,o,a)?g.push(p):l[p]=1;return{refIndex1:m,nreff1:m.length,refIndex2:g,nreff2:g.length}}var fe=20,wn=4,ds=256,ms=256,Ve=2147483647;function z(t,e){return t[e]??0}function ps(t,e,n,r,s,o,i,a,c,l){let f=e-o,u=n-s,d=e-s,h=n-o,m=d-h&1,g=d,p=d,b=h,k=h;i[d]=e,a[h]=n;for(let v=1;;v++){let j=!1;g>f?i[--g-1]=-1:++g,p<u?i[++p+1]=-1:--p;for(let R=p;R>=g;R-=2){let I;z(i,R-1)>=z(i,R+1)?I=z(i,R-1)+1:I=z(i,R+1);let w=I,C=I-R;for(;I<n&&C<o&&t[I]===r[C];)I++,C++;if(I-w>fe&&(j=!0),i[R]=I,m&&b<=R&&R<=k&&z(a,R)<=I)return{i1:I,i2:C,minLo:!0,minHi:!0}}b>f?a[--b-1]=Ve:++b,k<u?a[++k+1]=Ve:--k;for(let R=k;R>=b;R-=2){let I;z(a,R-1)<z(a,R+1)?I=z(a,R-1):I=z(a,R+1)-1;let w=I,C=I-R;for(;I>e&&C>s&&t[I-1]===r[C-1];)I--,C--;if(w-I>fe&&(j=!0),a[R]=I,!m&&g<=R&&R<=p&&I<=z(i,R))return{i1:I,i2:C,minLo:!0,minHi:!0}}if(!c){if(j&&v>ds){let R=0,I=null;for(let w=p;w>=g;w-=2){let C=w>d?w-d:d-w,x=z(i,w),P=x-w,O=x-e+(P-s)-C;if(O>wn*v&&O>R&&e+fe<=x&&x<n&&s+fe<=P&&P<o){let $=!0;for(let H=1;H<=fe;H++)if(t[x-H]!==r[P-H]){$=!1;break}$&&(R=O,I={i1:x,i2:P,minLo:!0,minHi:!1})}}if(I)return I;R=0,I=null;for(let w=k;w>=b;w-=2){let C=w>h?w-h:h-w,x=z(a,w),P=x-w,O=n-x+(o-P)-C;if(O>wn*v&&O>R&&e<x&&x<=n-fe&&s<P&&P<=o-fe){let $=!0;for(let H=0;H<fe;H++)if(t[x+H]!==r[P+H]){$=!1;break}$&&(R=O,I={i1:x,i2:P,minLo:!1,minHi:!0})}}if(I)return I}if(v>=l){let R=-1,I=-1;for(let x=p;x>=g;x-=2){let P=Math.min(z(i,x),n),O=P-x;o<O&&(P=o+x,O=o),R<P+O&&(R=P+O,I=P)}let w=Ve,C=Ve;for(let x=k;x>=b;x-=2){let P=Math.max(e,z(a,x)),O=P-x;O<s&&(P=s+x,O=s),P+O<w&&(w=P+O,C=P)}return n+o-w<R-(e+s)?{i1:I,i2:R-I,minLo:!0,minHi:!1}:{i1:C,i2:w-C,minLo:!1,minHi:!0}}}}}function pt(t,e,n,r,s,o,i,a,c,l,f,u,d,h){for(;e<n&&s<o&&t[e]===r[s];)e++,s++;for(;e<n&&s<o&&t[n-1]===r[o-1];)n--,o--;if(e===n)for(let m=s;m<o;m++)a[l[m]]=1;else if(s===o)for(let m=e;m<n;m++)i[c[m]]=1;else{let m=ps(t,e,n,r,s,o,f,u,d,h);pt(t,e,m.i1,r,s,m.i2,i,a,c,l,f,u,m.minLo,h),pt(t,m.i1,n,r,m.i2,o,i,a,c,l,f,u,m.minHi,h)}}function gs(t,e,n,r){let s=[],o=0,i=0,a=1,c=1;for(;o<t.length||i<e.length;){if(o<t.length&&i<e.length&&!n[o]&&!r[i]){s.push({type:"keep",line:t[o]??"",oldLineNo:a++,newLineNo:c++}),o++,i++;continue}for(;o<t.length&&n[o];)s.push({type:"delete",line:t[o]??"",oldLineNo:a++,newLineNo:0}),o++;for(;i<e.length&&r[i];)s.push({type:"insert",line:e[i]??"",oldLineNo:0,newLineNo:c++}),i++}return s}var In=200,En=20,xn=100,ys=1,bs=21,ws=-30,Is=6,Es=-4,xs=10,Os=24,Rs=17,Ps=23,ks=17,Ts=60;function dt(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);if(r===32)e+=1;else if(r===9)e+=8-e%8;else if(!(r===10||r===13||r===11||r===12))return e;if(e>=In)return In}return-1}function On(t,e,n){let r={endOfFile:!1,indent:-1,preBlank:0,preIndent:-1,postBlank:0,postIndent:-1};n>=e?(r.endOfFile=!0,r.indent=-1):(r.endOfFile=!1,r.indent=dt(t[n]));for(let s=n-1;s>=0&&(r.preIndent=dt(t[s]),r.preIndent===-1);s--)if(r.preBlank+=1,r.preBlank===En){r.preIndent=0;break}for(let s=n+1;s<e&&(r.postIndent=dt(t[s]),r.postIndent===-1);s++)if(r.postBlank+=1,r.postBlank===En){r.postIndent=0;break}return r}function Rn(t,e){t.preIndent===-1&&t.preBlank===0&&(e.penalty+=ys),t.endOfFile&&(e.penalty+=bs);let n=t.indent===-1?1+t.postBlank:0,r=t.preBlank+n;e.penalty+=ws*r,e.penalty+=Is*n;let s=t.indent!==-1?t.indent:t.postIndent,o=r!==0;e.effectiveIndent+=s,s===-1||t.preIndent===-1||(s>t.preIndent?e.penalty+=o?xs:Es:s===t.preIndent||(t.postIndent!==-1&&t.postIndent>s?e.penalty+=o?Rs:Os:e.penalty+=o?ks:Ps))}function Cs(t,e){let n=(t.effectiveIndent>e.effectiveIndent?1:0)-(t.effectiveIndent<e.effectiveIndent?1:0);return Ts*n+(t.penalty-e.penalty)}function Pn(t,e,n,r,s,o){let i=0,a=0;for(;t[a];)a++;let c=0,l=0;for(;s[l];)l++;let f=(u,d)=>e[u]===e[d];for(;;){if(a!==i){let u,d,h;do{for(u=a-i,d=-1;i>0&&f(i-1,a-1);){for(t[--i]=1,t[--a]=0;t[i-1];)i--;if(c===0)break;for(l=c-1,c=l;s[c-1];c--);}for(h=a,l>c&&(d=a);!(a>=r||!f(i,a));){for(t[i++]=0,t[a++]=1;t[a];)a++;if(l>=o)break;for(c=l+1,l=c;s[l];l++);l>c&&(d=a)}}while(u!==a-i);if(a!==h)if(d!==-1)for(;l===c;){for(t[--a]=0,t[--i]=1;t[i-1];)i--;for(l=c-1,c=l;s[c-1];c--);}else{let m=-1,g={effectiveIndent:0,penalty:0},p=h;for(a-u-1>p&&(p=a-u-1),a-xn>p&&(p=a-xn);p<=a;p++){let b={effectiveIndent:0,penalty:0},k=On(n,r,p);Rn(k,b);let v=On(n,r,p-u);Rn(v,b),(m===-1||Cs(b,g)<=0)&&(g={effectiveIndent:b.effectiveIndent,penalty:b.penalty},m=p)}for(;a>m;){for(t[--a]=0,t[--i]=1;t[i-1];)i--;for(l=c-1,c=l;s[c-1];c--);}}}if(a>=r)break;for(i=a+1,a=i;t[a];a++);if(l>=o)break;for(c=l+1,l=c;s[l];l++);}}function gt(t,e){let n=t.length,r=e.length,s=new Uint8Array(n),o=new Uint8Array(r);if(n>0&&r>0){let{classes1:i,classes2:a,classInfo:c}=fs(t,e),{dstart:l,dend1:f,dend2:u}=us(i,n,a,r);if(l>f)for(let d=l;d<r-(n-1-f);d++)o[d]=1;else if(l>u)for(let d=l;d<n-(r-1-u);d++)s[d]=1;else{let{refIndex1:d,nreff1:h,refIndex2:m,nreff2:g}=hs(i,n,a,r,c,l,f,u,s,o);if(h>0&&g>0){let p=new Array(h);for(let I=0;I<h;I++)p[I]=i[d[I]];let b=new Array(g);for(let I=0;I<g;I++)b[I]=a[m[I]];let k={},v={},j=h+g+3,R=Math.max(ms,mt(j));pt(p,0,h,b,0,g,s,o,d,m,k,v,!1,R)}else if(h===0)for(let p=0;p<g;p++)o[m[p]]=1;else for(let p=0;p<h;p++)s[d[p]]=1;Pn(s,i,t,n,o,r),Pn(o,a,e,r,s,n)}}else n===0?o.fill(1):s.fill(1);return{changedOld:s,changedNew:o}}function me(t,e){let n=t.length,r=e.length;if(n===0&&r===0)return[];if(n===0)return e.map((i,a)=>({type:"insert",line:i,oldLineNo:0,newLineNo:a+1}));if(r===0)return t.map((i,a)=>({type:"delete",line:i,oldLineNo:a+1,newLineNo:0}));let{changedOld:s,changedNew:o}=gt(t,e);return gs(t,e,s,o)}var Ss=3;function yt(t,e=Ss){if(e=Math.max(0,e),t.length===0)return[];let n=[];for(let a=0;a<t.length;a++){let c=t[a];c&&c.type!=="keep"&&n.push(a)}if(n.length===0)return[];let r=n[0]??0,s=[],o=Math.max(0,r-e),i=Math.min(t.length-1,r+e);for(let a=1;a<n.length;a++){let c=n[a]??0,l=Math.max(0,c-e),f=Math.min(t.length-1,c+e);l<=i+1||(s.push({start:o,end:i}),o=l),i=f}return s.push({start:o,end:i}),s.map(a=>vs(t,a.start,a.end))}function vs(t,e,n){let r=0,s=0,o=0,i=0,a=[],c=!1,l=!1;for(let f=e;f<=n;f++){let u=t[f];if(u)switch(u.type){case"keep":c||(r=u.oldLineNo,c=!0),l||(o=u.newLineNo,l=!0),s++,i++,a.push({type:"context",content:u.line});break;case"delete":c||(r=u.oldLineNo,c=!0),s++,a.push({type:"delete",content:u.line});break;case"insert":l||(o=u.newLineNo,l=!0),i++,a.push({type:"insert",content:u.line});break}}if(c||(r=o>0?o:1),l||(o=r>0?r:1),s===0)for(let f=e;f<=n;f++){let u=t[f];if(u&&u.type==="insert"){r=u.newLineNo>1?u.newLineNo-1:0;break}}if(i===0)for(let f=e;f<=n;f++){let u=t[f];if(u&&u.type==="delete"){o=u.oldLineNo>1?u.oldLineNo-1:0;break}}return{oldStart:r,oldCount:s,newStart:o,newCount:i,lines:a}}function Ye(t){return t?t.length<40?t:dn(t):"0000000"}function kn(t,e,n,r,s,o){let{path:i,oldMode:a,newMode:c}=e;t.push(`diff --git a/${i} b/${n}`),o?(t.push(`similarity index ${e.similarity??100}%`),t.push(`rename from ${i}`),t.push(`rename to ${n}`)):r?t.push(`new file mode ${c||"100644"}`):s?t.push(`deleted file mode ${a||"100644"}`):a&&c&&a!==c&&(t.push(`old mode ${a}`),t.push(`new mode ${c}`))}function js(t,e,n){let{path:r,oldContent:s,newContent:o,oldMode:i,oldHash:a,newHash:c}=t,l=t.renameTo!==void 0,f=t.renameTo??r,u=t.isNew??s==="",d=t.isDeleted??o==="";if(s===o&&!l)return"";let h=[];if(kn(h,t,f,u,d,l),s!==o){if(a||c){let m=Ye(a),g=Ye(c);u||d||l?h.push(`index ${m}..${g}`):h.push(`index ${m}..${g} ${i||"100644"}`)}e&&n?h.push(`Binary files a/${r} and b/${f} differ`):u?h.push(`Binary files /dev/null and b/${f} differ`):d?h.push(`Binary files a/${r} and /dev/null differ`):h.push(`Binary files a/${r} and b/${f} differ`)}return`${h.join(`
|
|
7
|
+
`),r=n===-1?e:e.slice(0,n),s=n===-1?"":e.slice(n+2),i="",o="commit",a="",c;for(let l of r.split(`
|
|
8
|
+
`)){let f=l.indexOf(" ");if(f===-1)continue;let u=l.slice(0,f),d=l.slice(f+1);switch(u){case"object":i=d;break;case"type":o=d;break;case"tag":a=d;break;case"tagger":c=Ae(d);break}}if(!i)throw new Error("Tag missing object field");if(!a)throw new Error("Tag missing tag name field");if(!c)throw new Error("Tag missing tagger field");return{type:"tag",object:i,objectType:o,name:a,tagger:c,message:s}}function tn(t){let e=[];return e.push(`object ${t.object}`),e.push(`type ${t.objectType}`),e.push(`tag ${t.name}`),e.push(`tagger ${$e(t.tagger)}`),e.push(""),e.push(t.message),Mr.encode(e.join(`
|
|
9
|
+
`))}async function N(t,e,n){let r=await t.objectStore.write(e,n);return t.hooks?.onObjectWrite?.({repo:t,type:e,hash:r}),r}async function F(t,e){return t.objectStore.read(e)}async function nn(t,e){return t.objectStore.exists(e)}async function rn(t,e){return t.objectStore.findByPrefix(e)}function Z(t){let e=Math.min(t.length,8e3);for(let n=0;n<e;n++)if(t.charCodeAt(n)===0)return!0;return!1}var Hr=new TextDecoder;async function B(t,e){let n=await F(t,e);if(n.type!=="blob")throw new Error(`Expected blob for ${e}, got ${n.type}`);return Hr.decode(n.content)}async function se(t,e){let n=await F(t,e);if(n.type!=="blob")throw new Error(`Expected blob for ${e}, got ${n.type}`);return n.content}async function A(t,e){let n=await F(t,e);if(n.type!=="commit")throw new Error(`Expected commit object for ${e}, got ${n.type}`);return Qt(n.content)}async function Le(t,e){let n=e;for(let r=0;r<100;r++){let s=await F(t,n);if(s.type==="commit")return n;if(s.type==="tag"){n=en(s.content).object;continue}throw new Error(`Cannot peel ${s.type} object ${e} to commit`)}throw new Error(`Tag chain too deep for ${e}`)}var Br=new TextEncoder,sn=new TextDecoder,Dr=new Set(["100644","100755","040000","120000","160000"]);function Ur(t){return t.length===4&&t.toLowerCase()===".git"}function Nr(t,e){if(t.length===0)throw new Error("invalid tree entry: empty name");if(t.includes("/"))throw new Error(`invalid tree entry: name contains slash: '${t}'`);if(t.includes("\0"))throw new Error("invalid tree entry: name contains null byte");if(t==="."||t==="..")throw new Error(`invalid tree entry: '${t}'`);if(Ur(t))throw new Error(`invalid tree entry: '${t}'`);if(!Dr.has(e))throw new Error(`invalid tree entry mode: '${e}' for '${t}'`)}function ie(t){let e=[],n=0;for(;n<t.byteLength;){let r=t.indexOf(32,n);if(r===-1)break;let s=sn.decode(t.subarray(n,r)),i=t.indexOf(0,r+1);if(i===-1)break;let o=sn.decode(t.subarray(r+1,i)),a=t.subarray(i+1,i+21),c=Ce(a),l=s.padStart(6,"0");Nr(o,l),e.push({mode:l,name:o,hash:c}),n=i+21}return{type:"tree",entries:e}}function He(t){let e=[];for(let i of t.entries){let o=i.mode.replace(/^0+/,""),a=Br.encode(`${o} ${i.name}\0`),c=we(i.hash);e.push(a),e.push(c)}let n=e.reduce((i,o)=>i+o.byteLength,0),r=new Uint8Array(n),s=0;for(let i of e)r.set(i,s),s+=i.byteLength;return r}var _={REGULAR:"100644",EXECUTABLE:"100755",SYMLINK:"120000",DIRECTORY:"040000",SUBMODULE:"160000"};function on(t){return typeof t=="string"?{type:"direct",hash:t}:t}var Gr=10;async function Fr(t,e){return t.refStore.readRef(e)}async function ne(t,e){let n=e;for(let r=0;r<Gr;r++){let s=await Fr(t,n);if(!s)return null;if(s.type==="direct")return s.hash;n=s.target}throw new Error(`Symbolic ref loop detected resolving "${e}"`)}async function ut(t,e="refs"){return t.refStore.listRefs(e)}function ht(t){return t.replace("refs/heads/","")}function an(t){return t.replace("refs/tags/","")}function cn(t){return t.length===4&&t.toLowerCase()===".git"}function ln(t){if(t.length===0||t.includes("\0")||t.charCodeAt(0)===47||t.charCodeAt(t.length-1)===47)return!1;let e=t.split("/");for(let n of e)if(n.length===0||n==="."||n===".."||cn(n))return!1;return!0}function fn(t,e){return e===t?!1:t==="/"?e.startsWith("/")&&e.length>1:e.startsWith(t+"/")}function un(t){if(t.length===0||t.charCodeAt(0)===47)return!1;let e=t.split("/");for(let n of e)if(n===".."||cn(n))return!1;return!0}var _r=1145655875,Wr=2;async function Ve(t,e){let n=pe(t.gitDir,"index"),r=await zr(e);await t.fs.writeFile(n,r)}function hn(t){let e=[...t].sort(dn);return{version:Wr,entries:e}}function le(){return{ctimeSeconds:0,ctimeNanoseconds:0,mtimeSeconds:0,mtimeNanoseconds:0,dev:0,ino:0,uid:0,gid:0,size:0}}async function zr(t){let e=new TextEncoder,n=[...t.entries].sort(dn),r=[],s=12;for(let d of n){let h=e.encode(d.path);r.push(h);let m=62+h.byteLength+1;s+=Math.ceil(m/8)*8}s+=20;let i=new ArrayBuffer(s),o=new Uint8Array(i),a=new DataView(i),c=0;a.setUint32(c,_r),c+=4,a.setUint32(c,t.version),c+=4,a.setUint32(c,n.length),c+=4;for(let d=0;d<n.length;d++){let h=n[d],m=r[d],g=c;a.setUint32(c,h.stat.ctimeSeconds),a.setUint32(c+4,h.stat.ctimeNanoseconds),a.setUint32(c+8,h.stat.mtimeSeconds),a.setUint32(c+12,h.stat.mtimeNanoseconds),a.setUint32(c+16,h.stat.dev),a.setUint32(c+20,h.stat.ino),a.setUint32(c+24,h.mode),a.setUint32(c+28,h.stat.uid),a.setUint32(c+32,h.stat.gid),a.setUint32(c+36,h.stat.size),c+=40;let p=we(h.hash);o.set(p,c),c+=20;let b=Math.min(m.byteLength,4095),P=(h.stage&3)<<12|b;a.setUint16(c,P),c+=2,o.set(m,c),c+=m.byteLength,o[c]=0,c+=1;let C=62+m.byteLength+1,v=Math.ceil(C/8)*8;c=g+v}let l=o.subarray(0,c),f=await We(l),u=we(f);return o.set(u,c),o}function dn(t,e){return t.path<e.path?-1:t.path>e.path?1:t.stage-e.stage}function Vr(t){let e=[],n=t.length;for(;n>0;){let i=t.slice(0,n).match(/^(.+?)~(\d*)$/);if(i&&i[1]!==void 0&&i[2]!==void 0){let c=i[2]===""?1:parseInt(i[2],10);e.unshift({type:"tilde",n:c}),n=i[1].length;continue}let o=t.slice(0,n).match(/^(.+?)\^{([^}]*)}$/);if(o&&o[1]!==void 0&&o[2]!==void 0){e.unshift({type:"peel",target:o[2]}),n=o[1].length;continue}let a=t.slice(0,n).match(/^(.+?)\^(\d*)$/);if(a&&a[1]!==void 0&&a[2]!==void 0){let c=a[2]===""?1:parseInt(a[2],10);e.unshift({type:"caret",n:c}),n=a[1].length;continue}break}let r=t.slice(0,n),s=r.match(/^(.+?)@\{(\d+)\}$/);return s&&s[1]!==void 0&&s[2]!==void 0?{base:s[1],reflogIndex:parseInt(s[2],10),suffixes:e}:{base:r,suffixes:e}}var Kr=["HEAD","FETCH_HEAD","ORIG_HEAD","MERGE_HEAD","CHERRY_PICK_HEAD","REBASE_HEAD"];async function Yr(t,e){let n=await rn(t,e);if(n.length===0)return null;if(n.length>1)throw new dt(e);return n[0]}var dt=class extends Error{constructor(n){super(`short object ID ${n} is ambiguous`);this.prefix=n}};async function qr(t,e){if(e==="HEAD"||e==="@")return ne(t,"HEAD");if(Kr.includes(e))return ne(t,e);if(/^[0-9a-f]{40}$/.test(e))return await nn(t,e)?e:null;if(/^[0-9a-f]{4,39}$/.test(e)){let i=await Yr(t,e);if(i)return i}if(e.startsWith("refs/")){let i=await ne(t,e);if(i)return i}let n=await ne(t,`refs/heads/${e}`);if(n)return n;let r=await ne(t,`refs/tags/${e}`);if(r)return r;let s=await ne(t,`refs/remotes/${e}`);return s||null}async function Xr(t,e,n){if(n===""||n==="commit")try{return await Le(t,e)}catch{return null}if(n==="tree"){let s;try{s=await Le(t,e)}catch{return null}return(await A(t,s)).tree}return(await F(t,e)).type!==n?null:e}async function Zr(t,e,n){let r=e;n.some(i=>i.type==="tilde"||i.type==="caret")&&(r=await Le(t,r));for(let i of n)if(i.type==="peel"){if(!r)return null;r=await Xr(t,r,i.target)}else if(i.type==="tilde")for(let o=0;o<i.n;o++){if(!r)return null;let a=await A(t,r);if(a.parents.length===0||(r=a.parents[0]??null,!r))return null}else{if(i.n===0)continue;if(!r)return null;let o=await A(t,r);if(i.n>o.parents.length||(r=o.parents[i.n-1]??null,!r))return null}return r}async function Ie(t,e){let{base:n,reflogIndex:r,suffixes:s}=Vr(e);if(r!==void 0)return null;let i=await qr(t,n);return i?Zr(t,i,s):null}var Eo=new TextEncoder;function oe(t){return typeof t=="string"?t==="120000":t===40960}function mn(t){return{stdout:"",stderr:`fatal: ${t}
|
|
10
|
+
`,exitCode:128}}var xo=mn("not a git repository (or any of the parent directories): .git"),Ro=mn("this operation must be run in a work tree");function Be(t,e){return t<e?-1:t>e?1:0}function pn(t){return t.slice(0,7)}function gn(t){let e=t.indexOf(`
|
|
11
|
+
`);return e===-1?t:t.slice(0,e)}async function mt(t,e){return yn(t,e,"")}async function yn(t,e,n){let r=[],s=new Map;for(let o of e){let a=n?o.path.slice(n.length+1):o.path,c=a.indexOf("/");if(c===-1)r.push({mode:Jr(o.mode),name:a,hash:o.hash});else{let l=a.slice(0,c),f=s.get(l);f||(f=[],s.set(l,f)),f.push(o)}}for(let[o,a]of s){let c=n?`${n}/${o}`:o,l=await yn(t,a,c);r.push({mode:_.DIRECTORY,name:o,hash:l})}r.sort((o,a)=>{let c=o.mode===_.DIRECTORY?`${o.name}/`:o.name,l=a.mode===_.DIRECTORY?`${a.name}/`:a.name;return c<l?-1:c>l?1:0});let i=He({type:"tree",entries:r});return N(t,"tree",i)}async function Y(t,e,n=""){let r=await F(t,e);if(r.type!=="tree")throw new Error(`Expected tree object, got ${r.type}`);let s=ie(r.content),i=[];for(let o of s.entries){let a=n?`${n}/${o.name}`:o.name;if(o.mode===_.DIRECTORY){let c=await Y(t,o.hash,a);i.push(...c)}else i.push({path:a,mode:o.mode,hash:o.hash})}return i}async function fe(t,e){if(!e)return new Map;let n=await Y(t,e);return new Map(n.map(r=>[r.path,r]))}async function ae(t,e,n){let r=await fe(t,e),s=await fe(t,n),i=[];for(let[o,a]of r){let c=s.get(o);c?(a.hash!==c.hash||a.mode!==c.mode)&&i.push({path:o,status:"modified",oldHash:a.hash,newHash:c.hash,oldMode:a.mode,newMode:c.mode}):i.push({path:o,status:"deleted",oldHash:a.hash,oldMode:a.mode})}for(let[o,a]of s)r.has(o)||i.push({path:o,status:"added",newHash:a.hash,newMode:a.mode});return i.sort((o,a)=>Be(o.path,a.path))}function Jr(t){return t.toString(8).padStart(6,"0")}function Qr(t){let e=Math.min(t.length,8e3),n=0;for(let r=0;r<e;r++)t.charCodeAt(r)===0&&n++;return n>e*.01}function bn(t,e,n,r){if(Qr(t)){let o=e.some(a=>a.test(t));return{matches:[],binary:o}}let s=t.split(`
|
|
12
|
+
`);if(s.length>0&&s[s.length-1]===""&&s.pop(),n&&e.length>1&&!e.every(a=>s.some(c=>a.test(c))))return{matches:[],binary:!1};let i=[];for(let o=0;o<s.length;o++){let a=s[o],c=e.some(l=>l.test(a));(r?!c:c)&&i.push({lineNo:o+1,line:a})}return{matches:i,binary:!1}}function es(t){return t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function wn(t,e){let n=e?.fixed?es(t):t;e?.wordRegexp&&(n=`\\b${n}\\b`);let r=e?.ignoreCase?"i":"";try{return new RegExp(n,r)}catch{return null}}var ts=new TextEncoder,En=new TextDecoder,xe=16877,Rn=33188,ns=33261,On=40960;function z(t){let e=[];for(let n of t.split("/"))n==="."||n===""||(n===".."?e.pop():e.push(n));return"/"+e.join("/")}function In(t){let e=t.lastIndexOf("/");return e<=0?"/":t.slice(0,e)}function xn(t){switch(t){case _.EXECUTABLE:return ns;case _.SYMLINK:return On;case _.DIRECTORY:return xe;default:return Rn}}var Re=class{constructor(e,n,r="/"){this.objectStore=e;this.rootTreeHash=n;this.rootPath=r;let s=z(r);this.overlay.set(s,{type:"directory",mode:xe,mtime:this.epoch})}treeCache=new Map;overlay=new Map;removals=new Set;epoch=new Date(0);toRelative(e){let n=z(e),r=z(this.rootPath);if(n===r)return"";let s=r==="/"?"/":`${r}/`;return n.startsWith(s)?n.slice(s.length):null}async loadTreeDir(e){let n=this.treeCache.get(e);if(n)return n;if(e===""){let o=await this.objectStore.read(this.rootTreeHash);if(o.type!=="tree")return null;let a=ie(o.content);return this.treeCache.set("",a.entries),a.entries}let r=e.split("/"),s=await this.loadTreeDir("");if(!s)return null;let i="";for(let o of r){let a=s.find(u=>u.name===o);if(!a||a.mode!==_.DIRECTORY)return null;i=i?`${i}/${o}`:o;let c=this.treeCache.get(i);if(c){s=c;continue}let l=await this.objectStore.read(a.hash);if(l.type!=="tree")return null;let f=ie(l.content);this.treeCache.set(i,f.entries),s=f.entries}return s}async lookupTreeEntry(e){if(e==="")return null;let n=e.lastIndexOf("/"),r=n===-1?"":e.slice(0,n),s=n===-1?e:e.slice(n+1),i=await this.loadTreeDir(r);if(!i)return null;let o=i.find(a=>a.name===s);return o?{entry:o,dirEntries:i}:null}async isTreeDirectory(e){return e===""?!0:(await this.lookupTreeEntry(e))?.entry.mode===_.DIRECTORY}ensureOverlayParents(e){let n=In(e);n===z(this.rootPath)||n==="/"||this.overlay.has(n)||(this.ensureOverlayParents(n),this.overlay.set(n,{type:"directory",mode:xe,mtime:new Date}))}async readFile(e){return En.decode(await this.readFileBuffer(e))}async readFileBuffer(e){let n=z(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, open '${e}'`);let r=this.overlay.get(n);if(r){if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content}let s=this.toRelative(n);if(s===null||s==="")throw new Error(`ENOENT: no such file or directory, open '${e}'`);let i=await this.lookupTreeEntry(s);if(!i)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(i.entry.mode===_.DIRECTORY)throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);let o=await this.objectStore.read(i.entry.hash);if(o.type!=="blob")throw new Error(`ENOENT: no such file or directory, open '${e}'`);return o.content}async writeFile(e,n){let r=z(e);this.removals.delete(r),this.ensureOverlayParents(r),this.overlay.set(r,{type:"file",content:typeof n=="string"?ts.encode(n):new Uint8Array(n),mode:Rn,mtime:new Date})}async exists(e){let n=z(e);if(this.removals.has(n))return!1;if(this.overlay.has(n))return!0;let r=this.toRelative(n);return r===null?!1:r===""||await this.isTreeDirectory(r)?!0:await this.lookupTreeEntry(r)!==null}async stat(e){let n=z(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let r=this.overlay.get(n);if(r)return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:r.type==="file"?r.content.byteLength:0,mtime:r.mtime};let s=this.toRelative(n);if(s===null)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(s==="")return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:xe,size:0,mtime:this.epoch};let i=await this.lookupTreeEntry(s);if(!i)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let{entry:o}=i,a=o.mode===_.DIRECTORY,c=o.mode===_.SYMLINK,l=0;return a||(l=(await this.objectStore.read(o.hash)).content.byteLength),{isFile:!a&&!c,isDirectory:a,isSymbolicLink:!1,mode:xn(o.mode),size:l,mtime:this.epoch}}async lstat(e){let n=z(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);let r=this.overlay.get(n);if(r)return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:r.type==="symlink",mode:r.mode,size:r.type==="file"?r.content.byteLength:r.type==="symlink"?r.target.length:0,mtime:r.mtime};let s=this.toRelative(n);if(s===null)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(s==="")return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:xe,size:0,mtime:this.epoch};let i=await this.lookupTreeEntry(s);if(!i)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);let{entry:o}=i,a=o.mode===_.DIRECTORY,c=o.mode===_.SYMLINK,l=0;return a||(l=(await this.objectStore.read(o.hash)).content.byteLength),{isFile:!a&&!c,isDirectory:a,isSymbolicLink:c,mode:xn(o.mode),size:l,mtime:this.epoch}}async mkdir(e,n){let r=z(e);if(this.overlay.has(r)){if(this.overlay.get(r).type!=="directory")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.toRelative(r);if(s!==null&&!this.removals.has(r)&&(s===""||await this.isTreeDirectory(s))){if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let i=In(r);if(!(this.overlay.has(i)||await this.exists(i)))if(n?.recursive)await this.mkdir(i,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.removals.delete(r),this.overlay.set(r,{type:"directory",mode:xe,mtime:new Date})}async readdir(e){let n=z(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let r=new Set,s=this.toRelative(n);if(s!==null){let o=await this.loadTreeDir(s);if(o)for(let a of o){let c=n==="/"?`/${a.name}`:`${n}/${a.name}`;this.removals.has(c)||r.add(a.name)}}let i=n==="/"?"/":`${n}/`;for(let o of this.overlay.keys())if(o!==n&&o.startsWith(i)){let c=o.slice(i.length).split("/")[0];c&&!this.removals.has(n==="/"?`/${c}`:`${n}/${c}`)&&r.add(c)}if(r.size===0){if(this.overlay.get(n)?.type==="directory")return[];if(s!==null&&(s===""||await this.isTreeDirectory(s)))return[];throw new Error(`ENOENT: no such file or directory, scandir '${e}'`)}return[...r].sort()}async rm(e,n){let r=z(e);if(!await this.exists(r)){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}let i=r==="/"?"/":`${r}/`;if(n?.recursive)for(let o of[...this.overlay.keys()])o.startsWith(i)&&(this.overlay.delete(o),this.removals.add(o));if(this.overlay.delete(r),this.removals.add(r),n?.recursive){let o=this.toRelative(r);o!==null&&await this.markTreeChildrenRemoved(o,r)}}async markTreeChildrenRemoved(e,n){let r=await this.loadTreeDir(e);if(r)for(let s of r){let i=n==="/"?`/${s.name}`:`${n}/${s.name}`;if(this.removals.add(i),s.mode===_.DIRECTORY){let o=e?`${e}/${s.name}`:s.name;await this.markTreeChildrenRemoved(o,i)}}}async readlink(e){let n=z(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);let r=this.overlay.get(n);if(r){if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}let s=this.toRelative(n);if(s===null||s==="")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);let i=await this.lookupTreeEntry(s);if(!i||i.entry.mode!==_.SYMLINK)throw new Error(`EINVAL: invalid argument, readlink '${e}'`);let o=await this.objectStore.read(i.entry.hash);return En.decode(o.content)}async symlink(e,n){let r=z(n);if(await this.exists(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureOverlayParents(r),this.removals.delete(r),this.overlay.set(r,{type:"symlink",target:e,mode:On,mtime:new Date})}};async function De(t,e,n,r){let s=new Set,i=0;for(let o of e){if(!ln(o.path))throw new Error(`refusing to check out unsafe path '${o.path}'`);let a=pe(r,o.path);if(!fn(r,a))throw new Error(`refusing to check out path outside target directory: '${o.path}'`);let c=Zt(a);if(c!==r&&!s.has(c)&&(await n.mkdir(c,{recursive:!0}),s.add(c)),oe(o.mode)){let l=await B(t,o.hash);if(!un(l))throw new Error(`refusing to create symlink with unsafe target '${l}'`);n.symlink?await n.symlink(l,a):await n.writeFile(a,l)}else{let l=await se(t,o.hash);await n.writeFile(a,l)}i++}return i}function Ue(t,e){let n=null,r;function s(i="/"){return n&&r===i||(n=new Re(t.objectStore,e,i),r=i),n}return{treeHash:e,async readFile(i){let o=s(),a=i.startsWith("/")?i:"/"+i;return await o.exists(a)?o.readFile(a):null},async readFileBytes(i){let o=s(),a=i.startsWith("/")?i:"/"+i;return await o.exists(a)?o.readFileBuffer(a):null},async files(){return(await Y(t,e)).map(o=>o.path)},fs(i="/"){return s(i)},async materialize(i,o="/"){let a=await Y(t,e);return De(t,a,i,o)}}}async function rs(t,e){return ne(t,e)}async function ss(t){return ut(t,"refs/heads")}async function is(t){return ut(t,"refs/tags")}async function os(t){let e=await t.refStore.readRef("HEAD");if(!e)return{branch:null,ref:null,hash:null};if(e.type==="symbolic"){let n=await t.refStore.readRef(e.target),r=n?.type==="direct"?n.hash:null;return{branch:e.target.startsWith("refs/heads/")?ht(e.target):null,ref:e.target,hash:r}}return{branch:null,ref:null,hash:e.hash}}async function as(t,e){return A(t,e)}async function cs(t,e){return se(t,e)}async function ls(t,e){return B(t,e)}async function fs(t,e){let n=await F(t,e);if(n.type!=="tree")throw new Error(`Expected tree object, got ${n.type}`);return ie(n.content).entries}async function us(t,e,n){let r=await A(t,e);return Ue(t,r.tree).readFile(n)}function hs(t){let e=0;for(let n=0;n<t.length;n++)t[n]==="/"&&e++;return e}function ds(t,e){let n=t.replace(/[.+^${}()|[\]\\]/g,"\\$&").replace(/\*\*/g,"\0").replace(/\*/g,"[^/]*").replace(/\?/g,"[^/]").replace(/\0/g,".*");return new RegExp(`^${n}$`).test(e)}async function ms(t,e,n,r){let s=[];for(let m of n)if(m instanceof RegExp)s.push(m);else{let g=wn(m,{fixed:r?.fixed,ignoreCase:r?.ignoreCase,wordRegexp:r?.wordRegexp});if(!g)throw new Error(`Invalid pattern: ${m}`);s.push(g)}let i=await A(t,e),a=(await Y(t,i.tree)).filter(m=>!m.mode.startsWith("120")).sort((m,g)=>m.path<g.path?-1:m.path>g.path?1:0),c=r?.allMatch??!1,l=r?.invert??!1,f=r?.maxCount,u=r?.maxDepth,d=r?.paths,h=[];for(let m of a){if(u!==void 0&&hs(m.path)>u||d&&!d.some(P=>ds(P,m.path)))continue;let g=await B(t,m.hash),p=bn(g,s,c,l);if(p.binary){h.push({path:m.path,matches:[],binary:!0});continue}if(p.matches.length===0)continue;let b=f!==void 0?p.matches.slice(0,f):p.matches;h.push({path:m.path,matches:b,binary:!1})}return h}function J(t){if(t.length===0)return[];let e=t.split(`
|
|
13
|
+
`);return e[e.length-1]===""&&e.pop(),e}var ps=4,Pn=1024,Ke=100,Xe=0,Ye=1,Oe=2;function gt(t){let e=1;for(;e*e<t;)e++;return e}function gs(t,e){let n=new Map,r=[],s=new Array(t.length),i=new Array(e.length);for(let o=0;o<t.length;o++){let a=t[o],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len1++,s[o]=c}for(let o=0;o<e.length;o++){let a=e[o],c=n.get(a);c===void 0&&(c=r.length,n.set(a,c),r.push({len1:0,len2:0})),r[c].len2++,i[o]=c}return{classes1:s,classes2:i,classInfo:r}}function ys(t,e,n,r){let s=0,i=Math.min(e,r);for(;s<i&&t[s]===n[s];)s++;let o=s,a=0,c=i-o;for(;a<c&&t[e-1-a]===n[r-1-a];)a++;return{dstart:o,dend1:e-a-1,dend2:r-a-1}}function Tn(t,e,n,r){e-n>Ke&&(n=e-Ke),r-e>Ke&&(r=e+Ke);let s=0,i=1;for(let c=1;e-c>=n;c++){let l=t[e-c];if(l===Xe)s++;else if(l===Oe)i++;else break}if(s===0)return!1;let o=0,a=1;for(let c=1;e+c<=r;c++){let l=t[e+c];if(l===Xe)o++;else if(l===Oe)a++;else break}return o===0?!1:(o+=s,a+=i,a*ps<a+o)}function bs(t,e,n,r,s,i,o,a,c,l){let f=new Uint8Array(e),u=new Uint8Array(r),d=Math.min(gt(e),Pn);for(let p=i;p<=o;p++){let b=s[t[p]].len2;b===0?f[p]=Xe:b>=d?f[p]=Oe:f[p]=Ye}let h=Math.min(gt(r),Pn);for(let p=i;p<=a;p++){let b=s[n[p]].len1;b===0?u[p]=Xe:b>=h?u[p]=Oe:u[p]=Ye}let m=[];for(let p=i;p<=o;p++)f[p]===Ye||f[p]===Oe&&!Tn(f,p,i,o)?m.push(p):c[p]=1;let g=[];for(let p=i;p<=a;p++)u[p]===Ye||u[p]===Oe&&!Tn(u,p,i,a)?g.push(p):l[p]=1;return{refIndex1:m,nreff1:m.length,refIndex2:g,nreff2:g.length}}var ue=20,kn=4,ws=256,Es=256,qe=2147483647;function V(t,e){return t[e]??0}function Is(t,e,n,r,s,i,o,a,c,l){let f=e-i,u=n-s,d=e-s,h=n-i,m=d-h&1,g=d,p=d,b=h,P=h;o[d]=e,a[h]=n;for(let C=1;;C++){let v=!1;g>f?o[--g-1]=-1:++g,p<u?o[++p+1]=-1:--p;for(let R=p;R>=g;R-=2){let w;V(o,R-1)>=V(o,R+1)?w=V(o,R-1)+1:w=V(o,R+1);let E=w,S=w-R;for(;w<n&&S<i&&t[w]===r[S];)w++,S++;if(w-E>ue&&(v=!0),o[R]=w,m&&b<=R&&R<=P&&V(a,R)<=w)return{i1:w,i2:S,minLo:!0,minHi:!0}}b>f?a[--b-1]=qe:++b,P<u?a[++P+1]=qe:--P;for(let R=P;R>=b;R-=2){let w;V(a,R-1)<V(a,R+1)?w=V(a,R-1):w=V(a,R+1)-1;let E=w,S=w-R;for(;w>e&&S>s&&t[w-1]===r[S-1];)w--,S--;if(E-w>ue&&(v=!0),a[R]=w,!m&&g<=R&&R<=p&&w<=V(o,R))return{i1:w,i2:S,minLo:!0,minHi:!0}}if(!c){if(v&&C>ws){let R=0,w=null;for(let E=p;E>=g;E-=2){let S=E>d?E-d:d-E,x=V(o,E),T=x-E,O=x-e+(T-s)-S;if(O>kn*C&&O>R&&e+ue<=x&&x<n&&s+ue<=T&&T<i){let $=!0;for(let H=1;H<=ue;H++)if(t[x-H]!==r[T-H]){$=!1;break}$&&(R=O,w={i1:x,i2:T,minLo:!0,minHi:!1})}}if(w)return w;R=0,w=null;for(let E=P;E>=b;E-=2){let S=E>h?E-h:h-E,x=V(a,E),T=x-E,O=n-x+(i-T)-S;if(O>kn*C&&O>R&&e<x&&x<=n-ue&&s<T&&T<=i-ue){let $=!0;for(let H=0;H<ue;H++)if(t[x+H]!==r[T+H]){$=!1;break}$&&(R=O,w={i1:x,i2:T,minLo:!1,minHi:!0})}}if(w)return w}if(C>=l){let R=-1,w=-1;for(let x=p;x>=g;x-=2){let T=Math.min(V(o,x),n),O=T-x;i<O&&(T=i+x,O=i),R<T+O&&(R=T+O,w=T)}let E=qe,S=qe;for(let x=P;x>=b;x-=2){let T=Math.max(e,V(a,x)),O=T-x;O<s&&(T=s+x,O=s),T+O<E&&(E=T+O,S=T)}return n+i-E<R-(e+s)?{i1:w,i2:R-w,minLo:!0,minHi:!1}:{i1:S,i2:E-S,minLo:!1,minHi:!0}}}}}function yt(t,e,n,r,s,i,o,a,c,l,f,u,d,h){for(;e<n&&s<i&&t[e]===r[s];)e++,s++;for(;e<n&&s<i&&t[n-1]===r[i-1];)n--,i--;if(e===n)for(let m=s;m<i;m++)a[l[m]]=1;else if(s===i)for(let m=e;m<n;m++)o[c[m]]=1;else{let m=Is(t,e,n,r,s,i,f,u,d,h);yt(t,e,m.i1,r,s,m.i2,o,a,c,l,f,u,m.minLo,h),yt(t,m.i1,n,r,m.i2,i,o,a,c,l,f,u,m.minHi,h)}}function xs(t,e,n,r){let s=[],i=0,o=0,a=1,c=1;for(;i<t.length||o<e.length;){if(i<t.length&&o<e.length&&!n[i]&&!r[o]){s.push({type:"keep",line:t[i]??"",oldLineNo:a++,newLineNo:c++}),i++,o++;continue}for(;i<t.length&&n[i];)s.push({type:"delete",line:t[i]??"",oldLineNo:a++,newLineNo:0}),i++;for(;o<e.length&&r[o];)s.push({type:"insert",line:e[o]??"",oldLineNo:0,newLineNo:c++}),o++}return s}var Sn=200,Cn=20,vn=100,Rs=1,Os=21,Ps=-30,Ts=6,ks=-4,Ss=10,Cs=24,vs=17,js=23,As=17,$s=60;function pt(t){let e=0;for(let n=0;n<t.length;n++){let r=t.charCodeAt(n);if(r===32)e+=1;else if(r===9)e+=8-e%8;else if(!(r===10||r===13||r===11||r===12))return e;if(e>=Sn)return Sn}return-1}function jn(t,e,n){let r={endOfFile:!1,indent:-1,preBlank:0,preIndent:-1,postBlank:0,postIndent:-1};n>=e?(r.endOfFile=!0,r.indent=-1):(r.endOfFile=!1,r.indent=pt(t[n]));for(let s=n-1;s>=0&&(r.preIndent=pt(t[s]),r.preIndent===-1);s--)if(r.preBlank+=1,r.preBlank===Cn){r.preIndent=0;break}for(let s=n+1;s<e&&(r.postIndent=pt(t[s]),r.postIndent===-1);s++)if(r.postBlank+=1,r.postBlank===Cn){r.postIndent=0;break}return r}function An(t,e){t.preIndent===-1&&t.preBlank===0&&(e.penalty+=Rs),t.endOfFile&&(e.penalty+=Os);let n=t.indent===-1?1+t.postBlank:0,r=t.preBlank+n;e.penalty+=Ps*r,e.penalty+=Ts*n;let s=t.indent!==-1?t.indent:t.postIndent,i=r!==0;e.effectiveIndent+=s,s===-1||t.preIndent===-1||(s>t.preIndent?e.penalty+=i?Ss:ks:s===t.preIndent||(t.postIndent!==-1&&t.postIndent>s?e.penalty+=i?vs:Cs:e.penalty+=i?As:js))}function Ms(t,e){let n=(t.effectiveIndent>e.effectiveIndent?1:0)-(t.effectiveIndent<e.effectiveIndent?1:0);return $s*n+(t.penalty-e.penalty)}function $n(t,e,n,r,s,i){let o=0,a=0;for(;t[a];)a++;let c=0,l=0;for(;s[l];)l++;let f=(u,d)=>e[u]===e[d];for(;;){if(a!==o){let u,d,h;do{for(u=a-o,d=-1;o>0&&f(o-1,a-1);){for(t[--o]=1,t[--a]=0;t[o-1];)o--;if(c===0)break;for(l=c-1,c=l;s[c-1];c--);}for(h=a,l>c&&(d=a);!(a>=r||!f(o,a));){for(t[o++]=0,t[a++]=1;t[a];)a++;if(l>=i)break;for(c=l+1,l=c;s[l];l++);l>c&&(d=a)}}while(u!==a-o);if(a!==h)if(d!==-1)for(;l===c;){for(t[--a]=0,t[--o]=1;t[o-1];)o--;for(l=c-1,c=l;s[c-1];c--);}else{let m=-1,g={effectiveIndent:0,penalty:0},p=h;for(a-u-1>p&&(p=a-u-1),a-vn>p&&(p=a-vn);p<=a;p++){let b={effectiveIndent:0,penalty:0},P=jn(n,r,p);An(P,b);let C=jn(n,r,p-u);An(C,b),(m===-1||Ms(b,g)<=0)&&(g={effectiveIndent:b.effectiveIndent,penalty:b.penalty},m=p)}for(;a>m;){for(t[--a]=0,t[--o]=1;t[o-1];)o--;for(l=c-1,c=l;s[c-1];c--);}}}if(a>=r)break;for(o=a+1,a=o;t[a];a++);if(l>=i)break;for(c=l+1,l=c;s[l];l++);}}function bt(t,e){let n=t.length,r=e.length,s=new Uint8Array(n),i=new Uint8Array(r);if(n>0&&r>0){let{classes1:o,classes2:a,classInfo:c}=gs(t,e),{dstart:l,dend1:f,dend2:u}=ys(o,n,a,r);if(l>f)for(let d=l;d<r-(n-1-f);d++)i[d]=1;else if(l>u)for(let d=l;d<n-(r-1-u);d++)s[d]=1;else{let{refIndex1:d,nreff1:h,refIndex2:m,nreff2:g}=bs(o,n,a,r,c,l,f,u,s,i);if(h>0&&g>0){let p=new Array(h);for(let w=0;w<h;w++)p[w]=o[d[w]];let b=new Array(g);for(let w=0;w<g;w++)b[w]=a[m[w]];let P={},C={},v=h+g+3,R=Math.max(Es,gt(v));yt(p,0,h,b,0,g,s,i,d,m,P,C,!1,R)}else if(h===0)for(let p=0;p<g;p++)i[m[p]]=1;else for(let p=0;p<h;p++)s[d[p]]=1;$n(s,o,t,n,i,r),$n(i,a,e,r,s,n)}}else n===0?i.fill(1):s.fill(1);return{changedOld:s,changedNew:i}}function ge(t,e){let n=t.length,r=e.length;if(n===0&&r===0)return[];if(n===0)return e.map((o,a)=>({type:"insert",line:o,oldLineNo:0,newLineNo:a+1}));if(r===0)return t.map((o,a)=>({type:"delete",line:o,oldLineNo:a+1,newLineNo:0}));let{changedOld:s,changedNew:i}=bt(t,e);return xs(t,e,s,i)}var Ls=3;function wt(t,e=Ls){if(e=Math.max(0,e),t.length===0)return[];let n=[];for(let a=0;a<t.length;a++){let c=t[a];c&&c.type!=="keep"&&n.push(a)}if(n.length===0)return[];let r=n[0]??0,s=[],i=Math.max(0,r-e),o=Math.min(t.length-1,r+e);for(let a=1;a<n.length;a++){let c=n[a]??0,l=Math.max(0,c-e),f=Math.min(t.length-1,c+e);l<=o+1||(s.push({start:i,end:o}),i=l),o=f}return s.push({start:i,end:o}),s.map(a=>Hs(t,a.start,a.end))}function Hs(t,e,n){let r=0,s=0,i=0,o=0,a=[],c=!1,l=!1;for(let f=e;f<=n;f++){let u=t[f];if(u)switch(u.type){case"keep":c||(r=u.oldLineNo,c=!0),l||(i=u.newLineNo,l=!0),s++,o++,a.push({type:"context",content:u.line});break;case"delete":c||(r=u.oldLineNo,c=!0),s++,a.push({type:"delete",content:u.line});break;case"insert":l||(i=u.newLineNo,l=!0),o++,a.push({type:"insert",content:u.line});break}}if(c||(r=i>0?i:1),l||(i=r>0?r:1),s===0)for(let f=e;f<=n;f++){let u=t[f];if(u&&u.type==="insert"){r=u.newLineNo>1?u.newLineNo-1:0;break}}if(o===0)for(let f=e;f<=n;f++){let u=t[f];if(u&&u.type==="delete"){i=u.oldLineNo>1?u.oldLineNo-1:0;break}}return{oldStart:r,oldCount:s,newStart:i,newCount:o,lines:a}}function Ze(t){return t?t.length<40?t:pn(t):"0000000"}function Mn(t,e,n,r,s,i){let{path:o,oldMode:a,newMode:c}=e;t.push(`diff --git a/${o} b/${n}`),i?(t.push(`similarity index ${e.similarity??100}%`),t.push(`rename from ${o}`),t.push(`rename to ${n}`)):r?t.push(`new file mode ${c||"100644"}`):s?t.push(`deleted file mode ${a||"100644"}`):a&&c&&a!==c&&(t.push(`old mode ${a}`),t.push(`new mode ${c}`))}function Bs(t,e,n){let{path:r,oldContent:s,newContent:i,oldMode:o,oldHash:a,newHash:c}=t,l=t.renameTo!==void 0,f=t.renameTo??r,u=t.isNew??s==="",d=t.isDeleted??i==="";if(s===i&&!l)return"";let h=[];if(Mn(h,t,f,u,d,l),s!==i){if(a||c){let m=Ze(a),g=Ze(c);u||d||l?h.push(`index ${m}..${g}`):h.push(`index ${m}..${g} ${o||"100644"}`)}e&&n?h.push(`Binary files a/${r} and b/${f} differ`):u?h.push(`Binary files /dev/null and b/${f} differ`):d?h.push(`Binary files a/${r} and /dev/null differ`):h.push(`Binary files a/${r} and b/${f} differ`)}return`${h.join(`
|
|
13
14
|
`)}
|
|
14
|
-
`}function
|
|
15
|
+
`}function Ln(t){let{path:e,oldContent:n,newContent:r,oldMode:s,newMode:i,oldHash:o,newHash:a}=t,c=t.renameTo!==void 0,l=t.renameTo??e,f=Z(n),u=Z(r);if(f||u)return Bs(t,f,u);let d=J(n),h=J(r),m=n.length>0&&n.endsWith(`
|
|
15
16
|
`),g=r.length>0&&r.endsWith(`
|
|
16
|
-
`),p="\0NOEOL",b=d;!m&&d.length>0&&(b=d.slice(),b[b.length-1]+=p);let
|
|
17
|
+
`),p="\0NOEOL",b=d;!m&&d.length>0&&(b=d.slice(),b[b.length-1]+=p);let P=h;!g&&h.length>0&&(P=h.slice(),P[P.length-1]+=p);let C=ge(b,P);if(!m||!g)for(let O of C)O.line.includes(p)&&(O.line=O.line.replace(p,""));let v=wt(C,t.contextLines);if(v.length===0&&!c)return"";let R=t.isNew??n==="",w=t.isDeleted??r==="",E=[];if(Mn(E,t,l,R,w,c),v.length===0)return`${E.join(`
|
|
17
18
|
`)}
|
|
18
|
-
`;if(
|
|
19
|
+
`;if(o||a){let O=Ze(o),$=Ze(a);R||w?E.push(`index ${O}..${$}`):c?E.push(`index ${O}..${$} ${s||"100644"}`):s&&i&&s!==i?E.push(`index ${O}..${$}`):E.push(`index ${O}..${$} ${s||"100644"}`)}let S=O=>O.includes(" ")?" ":"";R?(E.push("--- /dev/null"),E.push(`+++ b/${l}${S(l)}`)):w?(E.push(`--- a/${e}${S(e)}`),E.push("+++ /dev/null")):(E.push(`--- a/${e}${S(e)}`),E.push(`+++ b/${l}${S(l)}`));let x=d.length,T=h.length;for(let O of v){let $=O.oldCount===1?`${O.oldStart}`:`${O.oldStart},${O.oldCount}`,H=O.newCount===1?`${O.newStart}`:`${O.newStart},${O.newCount}`,Q="",I=O.oldCount===0?O.oldStart-1:O.oldStart-2;for(let M=I;M>=0;M--){let L=d[M];if(L&&/^[a-zA-Z$_]/.test(L)){Q=` ${L.trimEnd().slice(0,79)}`;break}}E.push(`@@ -${$} +${H} @@${Q}`);let y=O.oldStart,k=O.newStart;for(let M of O.lines)switch(M.type){case"context":E.push(` ${M.content}`),(!m&&y===x||!g&&k===T)&&E.push("\"),y++,k++;break;case"delete":E.push(`-${M.content}`),!m&&y===x&&E.push("\"),y++;break;case"insert":E.push(`+${M.content}`),!g&&k===T&&E.push("\"),k++;break}}return`${E.join(`
|
|
19
20
|
`)}
|
|
20
|
-
`}function
|
|
21
|
-
`)[0],boundary:i,previous:a}}var Oe=class{heap=[];nextEpoch=0;get size(){return this.heap.length}push(e){this.heap.push({entry:e,epoch:this.nextEpoch++}),this.siftUp(this.heap.length-1)}pop(){let{heap:e}=this;if(e.length===0)return;let n=e[0],r=e.pop();return e.length>0&&(e[0]=r,this.siftDown(0)),n.entry}higher(e,n){let r=e.entry.commit.committer.timestamp,s=n.entry.commit.committer.timestamp;return r>s||r===s&&e.epoch<n.epoch}siftUp(e){let{heap:n}=this;for(;e>0;){let r=e-1>>1;if(!this.higher(n[e],n[r]))break;[n[r],n[e]]=[n[e],n[r]],e=r}}siftDown(e){let{heap:n}=this,r=n.length;for(;;){let s=e,o=2*e+1,i=2*e+2;if(o<r&&this.higher(n[o],n[s])&&(s=o),i<r&&this.higher(n[i],n[s])&&(s=i),s===e)break;[n[e],n[s]]=[n[s],n[e]],e=s}}};async function*ge(t,e,n){if(n?.topoOrder){yield*Ns(t,e,n);return}let r=await $n(t,n?.exclude),s=new Set(r),o=new Oe,i=n?.shallowBoundary,a=n?.limit,c=0,l=Array.isArray(e)?e:[e];for(let f of l)s.has(f)||o.push(await Xe(t,f));for(;o.size>0;){let f=o.pop();if(s.has(f.hash))continue;if(s.add(f.hash),yield f,a!==void 0&&++c>=a)return;if(i?.has(f.hash))continue;let u=n?.firstParent?f.commit.parents.slice(0,1):f.commit.parents;for(let d of u)if(!s.has(d))try{o.push(await Xe(t,d))}catch{}}}async function*Ns(t,e,n){let r=await $n(t,n?.exclude),s=new Set(r),o=new Oe,i=n?.shallowBoundary,a=Array.isArray(e)?e:[e];for(let h of a)s.has(h)||o.push(await Xe(t,h));let c=[],l=new Map;for(;o.size>0;){let h=o.pop();if(s.has(h.hash)||(s.add(h.hash),l.set(h.hash,c.length),c.push(h),i?.has(h.hash)))continue;let m=n?.firstParent?h.commit.parents.slice(0,1):h.commit.parents;for(let g of m)if(!s.has(g))try{o.push(await Xe(t,g))}catch{}}let f=c.length;if(f===0)return;let u=new Int32Array(f);for(let h of c){let m=n?.firstParent?h.commit.parents.slice(0,1):h.commit.parents;for(let g of m){let p=l.get(g);p!==void 0&&(u[p]=(u[p]??0)+1)}}let d=[];for(let h=f-1;h>=0;h--)u[h]===0&&d.push(h);for(;d.length>0;){let h=d.pop();yield c[h];let m=n?.firstParent?c[h].commit.parents.slice(0,1):c[h].commit.parents;for(let g of m){let p=l.get(g);if(p!==void 0){let b=(u[p]??0)-1;u[p]=b,b===0&&d.push(p)}}}}async function An(t,e,n){if(e===n)return{ahead:0,behind:0};let r=new Set;for await(let a of ge(t,e))r.add(a.hash);let s=new Set;for await(let a of ge(t,n))s.add(a.hash);let o=0;for(let a of r)s.has(a)||o++;let i=0;for(let a of s)r.has(a)||i++;return{ahead:o,behind:i}}async function $n(t,e){if(!e||e.length===0)return new Set;let n=new Set;for await(let r of ge(t,e))n.add(r.hash);return n}async function Xe(t,e){return{hash:e,commit:await A(t,e)}}async function Bs(t,e){let n=new Set,r=[e],s=0;for(;s<r.length;){let o=r[s++];if(n.has(o))continue;n.add(o);let i;try{i=await A(t,o)}catch{continue}for(let a of i.parents)n.has(a)||r.push(a)}return n}async function bt(t,e,n){if(e===n)return!0;let r=new Set,s=[n],o=0;for(;o<s.length;){let i=s[o++];if(i===e)return!0;if(r.has(i))continue;r.add(i);let a;try{a=await A(t,i)}catch{continue}for(let c of a.parents)r.has(c)||s.push(c)}return!1}async function He(t,e,n){if(e===n)return[e];let r=await Bs(t,e),s=[],o=new Set,i=[n],a=0;for(;a<i.length;){let l=i[a++];if(o.has(l))continue;if(o.add(l),r.has(l)){s.push(l);continue}let f;try{f=await A(t,l)}catch{continue}for(let u of f.parents)o.has(u)||i.push(u)}if(s.length<=1)return s;let c=[];for(let l of s){let f=!1;for(let u of s)if(u!==l&&await bt(t,l,u)){f=!0;break}f||c.push(l)}return c.length<=1?c:Gs(t,e,n,c)}async function Gs(t,e,n,r){let s=new Set(r),o=new Set,i=[],a=new Map,c=new Map,l=0,f=[{hash:e,mask:1,seq:l++},{hash:n,mask:2,seq:l++}];async function u(d){let h=c.get(d);if(h!==void 0)return h;let m=(await A(t,d)).committer.timestamp;return c.set(d,m),m}for(;f.length>0;){let d=0,h=await u(f[0].hash);for(let k=1;k<f.length;k++){let v=f[k],j=await u(v.hash),R=f[d];(j>h||j===h&&v.seq<R.seq)&&(d=k,h=j)}let m=f.splice(d,1)[0],g=a.get(m.hash)??0,p=g|m.mask;if(p===g)continue;if(a.set(m.hash,p),p===3&&s.has(m.hash)&&!o.has(m.hash)&&(i.push(m.hash),o.add(m.hash),o.size===s.size))break;let b=await A(t,m.hash);for(let k of b.parents)f.push({hash:k,mask:p,seq:l++})}for(let d of r)o.has(d)||i.push(d);return i}async function Fs(t,e){return ne(t,e)}async function _s(t,e,n){return ae(t,e,n)}async function Ws(t,e,n){let r=await A(t,n),s=null;return e&&(s=(await A(t,e)).tree),ae(t,s,r.tree)}async function*zs(t,e,n){let r=e?[e]:[];for await(let s of ge(t,n,{exclude:r}))yield{hash:s.hash,message:s.commit.message,tree:s.commit.tree,parents:s.commit.parents,author:s.commit.author,committer:s.commit.committer}}async function Vs(t,e,n){return bt(t,e,n)}async function Ks(t,e,n){return He(t,e,n)}async function Ys(t,e,n){return An(t,e,n)}async function qs(t,e,n,r){return jn(t,e,n,r)}function Xs(t){return t==="insert"?"+":t==="delete"?"-":" "}function Zs(t){return{oldStart:t.oldStart,oldCount:t.oldCount,newStart:t.newStart,newCount:t.newCount,lines:t.lines.map(e=>Xs(e.type)+e.content)}}function Js(t,e,n){let r=Z(t),s=Z(e),o=me(r,s);return yt(o,n).map(Zs)}async function Ln(t,e){let n=await _e(t,e);if(n)return n;throw new Error(`ref or commit '${e}' not found`)}async function Mn(t,e,n,r){let s=await Ln(t,e),o=await Ln(t,n),i=await A(t,s),a=await A(t,o),c=await ae(t,i.tree,a.tree),l=r?.renames!==!1,f=r?.paths,u=[];if(l){let h=await pe(t,c);c=h.remaining,u=h.renames}let d=[];for(let h of c)f&&!f.some(m=>h.path.startsWith(m))||d.push({path:h.path,status:h.status,oldContent:h.oldHash?await D(t,h.oldHash):"",newContent:h.newHash?await D(t,h.newHash):"",oldHash:h.oldHash??void 0,newHash:h.newHash??void 0,oldMode:h.oldMode,newMode:h.newMode});for(let h of u)f&&!f.some(m=>h.newPath.startsWith(m)||h.oldPath.startsWith(m))||d.push({path:h.newPath,oldPath:h.oldPath,status:"renamed",oldContent:await D(t,h.oldHash),newContent:await D(t,h.newHash),oldHash:h.oldHash,newHash:h.newHash,oldMode:h.oldMode,newMode:h.newMode,similarity:h.similarity});return d.sort((h,m)=>h.path.localeCompare(m.path)),d}async function Qs(t,e,n,r){let s=await Mn(t,e,n,r),o=r?.contextLines;return s.map(i=>({path:i.path,status:i.status,oldPath:i.oldPath,similarity:i.similarity,hunks:Js(i.oldContent,i.newContent,o)}))}async function ei(t,e,n,r){let s=await Mn(t,e,n,r),o=r?.contextLines,i="";for(let a of s)i+=Tn({path:a.oldPath??a.path,oldContent:a.oldContent,newContent:a.newContent,oldHash:a.oldHash,newHash:a.newHash,oldMode:a.oldMode,newMode:a.newMode,isNew:a.status==="added",isDeleted:a.status==="deleted",renameTo:a.status==="renamed"?a.path:void 0,similarity:a.similarity,contextLines:o});return i}async function*ti(t,e,n){if(n?.paths&&n.paths.length>0){let r=n?.limit,s=0;for await(let o of ni(t,e,n.paths,n))if(yield o,r!==void 0&&++s>=r)return;return}for await(let r of ge(t,e,n))yield{hash:r.hash,message:r.commit.message,tree:r.commit.tree,parents:r.commit.parents,author:r.commit.author,committer:r.commit.committer}}function wt(t,e){return e.some(n=>t===n||t.startsWith(n.endsWith("/")?n:n+"/"))}async function*ni(t,e,n,r){let s=new Set;if(r?.exclude)for await(let l of ge(t,r.exclude))s.add(l.hash);let o=new Set(s),i=new Oe,a=async l=>{if(!o.has(l))try{let f=await A(t,l);i.push({hash:l,commit:f})}catch{}},c=Array.isArray(e)?e:[e];for(let l of c)await a(l);for(;i.size>0;){let l=i.pop();if(o.has(l.hash))continue;o.add(l.hash);let{commit:f}=l,u=r?.firstParent?f.parents.slice(0,1):f.parents,d=()=>({hash:l.hash,message:f.message,tree:f.tree,parents:f.parents,author:f.author,committer:f.committer});if(u.length===0){(await ae(t,null,f.tree)).some(g=>wt(g.path,n))&&(yield d());continue}if(u.length===1){let m=u[0];try{let g=await A(t,m);(await ae(t,g.tree,f.tree)).some(b=>wt(b.path,n))&&(yield d())}catch{yield d()}await a(m);continue}let h=[];for(let m of u)try{let g=await A(t,m);(await ae(t,g.tree,f.tree)).some(b=>wt(b.path,n))||h.push(m)}catch{}if(h.length>0)await a(h[0]);else{yield d();for(let m of u)await a(m)}}}function ri(t){let e=Math.abs(t),n=t<=0?"+":"-",r=String(Math.floor(e/60)).padStart(2,"0"),s=String(e%60).padStart(2,"0");return`${n}${r}${s}`}function De(t){if("timestamp"in t)return t;let e=t.date??new Date;return{name:t.name,email:t.email,timestamp:Math.floor(e.getTime()/1e3),timezone:ri(e.getTimezoneOffset())}}async function si(t,e){let n=De(e.author),r=e.committer?De(e.committer):n,s=Ae({type:"commit",tree:e.tree,parents:e.parents,author:n,committer:r,message:e.message}),o=await B(t,"commit",s);return e.branch&&await Un(t,e.branch,o),o}async function ii(t,e){let n=De(e.tagger),r=Qt({type:"tag",object:e.target,objectType:e.targetType??"commit",name:e.name,tagger:n,message:e.message}),s=await B(t,"tag",r);return await t.refStore.writeRef(`refs/tags/${e.name}`,{type:"direct",hash:s}),s}async function Dn(t,e){let n=e.branch?`refs/heads/${e.branch}`:null,r=n?await te(t,n):null,s=null;r&&(s=(await A(t,r)).tree);let o=[];for(let[d,h]of Object.entries(e.files))if(h===null)o.push({path:d,hash:null});else{let m=typeof h=="string"?new TextEncoder().encode(h):h,g=await B(t,"blob",m);o.push({path:d,hash:g})}let i;s?i=await Nn(t,s,o):i=await Et(t,null,It(o));let a=De(e.author),c=e.committer?De(e.committer):a,f=Ae({type:"commit",tree:i,parents:r?[r]:[],author:a,committer:c,message:e.message});return{hash:await B(t,"commit",f),parentHash:r}}async function oi(t,e){let{hash:n}=await Dn(t,e);return await Un(t,e.branch,n),n}async function Un(t,e,n){let r=`refs/heads/${e}`;await t.refStore.writeRef(r,{type:"direct",hash:n}),await t.refStore.readRef("HEAD")||await t.refStore.writeRef("HEAD",{type:"symbolic",target:r})}async function ai(t,e){let n=[...e].sort((o,i)=>o.name.localeCompare(i.name)),r=await Promise.all(n.map(async o=>{let i=o.mode;return i||(i=(await t.objectStore.read(o.hash)).type==="tree"?"040000":"100644"),{mode:i,name:o.name,hash:o.hash}})),s=Le({type:"tree",entries:r});return B(t,"tree",s)}async function ci(t,e){return B(t,"blob",new TextEncoder().encode(e))}async function Nn(t,e,n){return Et(t,e,It(n))}function It(t){let e=new Map,n=new Map;for(let r of t){let s=r.path.indexOf("/");if(s===-1)e.set(r.path,{hash:r.hash,mode:r.mode??"100644"});else{let o=r.path.slice(0,s),i=r.path.slice(s+1),a=n.get(o);a||(a=[],n.set(o,a)),a.push({...r,path:i})}}return{files:e,dirs:n}}async function Hn(t,e){let n=await F(t,e);if(n.type!=="tree")throw new Error(`Expected tree object, got ${n.type}`);return ie(n.content).entries}async function Et(t,e,n){let r=new Map;if(e)for(let i of await Hn(t,e))r.set(i.name,i);for(let[i,{hash:a,mode:c}]of n.files)a===null?r.delete(i):r.set(i,{name:i,hash:a,mode:c});for(let[i,a]of n.dirs){let c=r.get(i),l=c?.mode==="040000"?c.hash:null,f=It(a),u=await Et(t,l,f);(await Hn(t,u)).length===0?r.delete(i):r.set(i,{name:i,hash:u,mode:"040000"})}let s=[...r.values()].sort((i,a)=>{let c=i.mode==="040000"?`${i.name}/`:i.name,l=a.mode==="040000"?`${a.name}/`:a.name;return c<l?-1:c>l?1:0}),o=Le({type:"tree",entries:s});return B(t,"tree",o)}function xt(t,e){let n=t.length,r=e.length;if(n===0&&r===0)return[];if(n===0)return[{buffer1:[0,0],buffer2:[0,r]}];if(r===0)return[{buffer1:[0,n],buffer2:[0,0]}];let{changedOld:s,changedNew:o}=gt(t,e);return li(s,n,o,r)}function li(t,e,n,r){let s=[],o=0,i=0;for(;o<e||i<r;){for(;o<e&&i<r&&!t[o]&&!n[i];)o++,i++;if(o>=e&&i>=r)break;let a=o,c=i;for(;o<e&&t[o];)o++;for(;i<r&&n[i];)i++;(o>a||i>c)&&s.push({buffer1:[a,o-a],buffer2:[c,i-c]})}return s}function fi(t,e,n){let r=[];for(let c of xt(e,t))r.push({ab:"a",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});for(let c of xt(e,n))r.push({ab:"b",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});r.sort((c,l)=>c.oStart-l.oStart);let s=[],o=0;function i(c){c>o&&(s.push({stable:!0,buffer:"o",bufferStart:o,bufferLength:c-o,content:e.slice(o,c)}),o=c)}let a=0;for(;a<r.length;){let c=r[a++],l=c.oStart,f=c.oStart+c.oLength,u=[c];for(i(l);a<r.length;){let d=r[a];if(d.oStart>f)break;f=Math.max(f,d.oStart+d.oLength),u.push(d),a++}if(u.length===1){if(c.abLength>0){let d=c.ab==="a"?t:n;s.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:d.slice(c.abStart,c.abStart+c.abLength)})}}else{let d={a:{abMin:t.length,abMax:-1,oMin:e.length,oMax:-1},b:{abMin:n.length,abMax:-1,oMin:e.length,oMax:-1}};for(let b of u){let k=b.oStart,v=k+b.oLength,j=b.abStart,R=j+b.abLength,I=d[b.ab];I.abMin=Math.min(j,I.abMin),I.abMax=Math.max(R,I.abMax),I.oMin=Math.min(k,I.oMin),I.oMax=Math.max(v,I.oMax)}let h=d.a.abMin+(l-d.a.oMin),m=d.a.abMax+(f-d.a.oMax),g=d.b.abMin+(l-d.b.oMin),p=d.b.abMax+(f-d.b.oMax);s.push({stable:!1,a:t.slice(h,m),o:e.slice(l,f),b:n.slice(g,p)})}o=f}return i(e.length),s}function ui(t,e,n,r){let s=r?.excludeFalseConflicts??!0,o=fi(t,e,n),i=[],a=[];function c(){a.length&&(i.push({type:"ok",lines:a}),a=[])}for(let l of o)l.stable?a.push(...l.content):s&&Gn(l.a,l.b)?a.push(...l.a):(c(),i.push({type:"conflict",a:l.a,o:l.o,b:l.b}));return c(),r?.conflictStyle==="diff3"?Bn(i):Bn(hi(i))}function Ue(t,e,n,r){let s=r?.markerSize??7,o=r?.conflictStyle??"merge",i=`${"<".repeat(s)}${r?.a?` ${r.a}`:""}`,a=`${"|".repeat(s)}${r?.o?` ${r.o}`:""}`,c="=".repeat(s),l=`${">".repeat(s)}${r?.b?` ${r.b}`:""}`,f=ui(t,e,n,{conflictStyle:o}),u=!1,d=[];for(let h of f)h.type==="ok"?d.push(...h.lines):(u=!0,o==="diff3"?d.push(i,...h.a,a,...h.o,c,...h.b,l):d.push(i,...h.a,c,...h.b,l));return{conflict:u,result:d}}function hi(t){let e=[];for(let n of t)n.type==="ok"?e.push(n):e.push(...di(n));return e}function di(t){let{a:e,b:n}=t;if(e.length===0||n.length===0)return[t];if(Gn(e,n))return[t];let r=xt(e,n);if(r.length===0)return[{type:"ok",lines:e}];let s=[],o=0;for(let a of r){let c=a.buffer1[0];c-o>0&&s.push({type:"ok",lines:e.slice(o,c)});let f=c+a.buffer1[1],u=a.buffer2[0]+a.buffer2[1];s.push({type:"conflict",a:e.slice(c,f),o:[],b:n.slice(a.buffer2[0],u)}),o=f}return e.length-o>0&&s.push({type:"ok",lines:e.slice(o)}),s.length===1&&s[0].type==="conflict"?[t]:s}function Bn(t){if(t.length<3)return t;let e=[t[0]];for(let r=1;r<t.length;r++){let s=e[e.length-1],o=t[r];s.type==="ok"&&o.type==="ok"?s.lines=[...s.lines,...o.lines]:e.push(o)}if(e.length<3)return e;let n=[e[0]];for(let r=1;r<e.length;r++){let s=n[n.length-1],o=e[r];if(s.type==="conflict"&&o.type==="ok"&&o.lines.length<=3&&r+1<e.length&&e[r+1].type==="conflict"){let i=e[r+1],a=s;a.a=[...s.a,...o.lines,...i.a],a.b=[...s.b,...o.lines,...i.b],a.o=[...s.o,...o.lines,...i.o],r++}else n.push(o)}return n}function ye(t,e,n,r){let s=Ue(Y(t),Y(e),Y(n),{a:r.a,o:r.o,b:r.b,markerSize:r.markerSize,conflictStyle:r.conflictStyle}),i=(s.result[s.result.length-1]??"").endsWith("\0"),a=s.result.map(Ot);return(a[a.length-1]??"").startsWith(">>>>>>>")||!i?`${a.join(`
|
|
21
|
+
`}function Pe(t){let e=t.lastIndexOf("/");return e>=0?t.slice(e+1):t}function Ds(t,e){if(t.length===0)return;if(t.length===1)return t.shift();let n=Pe(e),r=0;for(let s=0;s<t.length;s++){let i=t[s];if(i&&Pe(i.path)===n){r=s;break}}return t.splice(r,1)[0]}var Us=50;async function ye(t,e,n=Us){let r=new Map,s=[],i=[],o=[];for(let f of e)if(f.status==="deleted"&&f.oldHash){let u=r.get(f.oldHash)??[];u.push(f),r.set(f.oldHash,u),s.push(f)}else f.status==="added"&&f.newHash?i.push(f):o.push(f);let a=[],c=[];for(let f of i){let u=f.newHash;if(!u){c.push(f);continue}let d=r.get(u);if(d&&d.length>0){let h=Ds(d,f.path);h&&a.push({oldPath:h.path,newPath:f.path,oldHash:h.oldHash??u,newHash:u,similarity:100,oldMode:h.oldMode,newMode:f.newMode})}else c.push(f)}let l=[...r.values()].flat();if(l.length>0&&c.length>0){let f=await Ns(t,l,c,n);if(f.length>0){let u=new Set(f.map(h=>h.oldPath)),d=new Set(f.map(h=>h.newPath));l=l.filter(h=>!u.has(h.path)),c=c.filter(h=>!d.has(h.path)),a.push(...f)}}if(l.length>0&&c.length>0){let f=await _s(t,l,c,n);if(f.length>0){let u=new Set(f.map(h=>h.oldPath)),d=new Set(f.map(h=>h.newPath));l=l.filter(h=>!u.has(h.path)),c=c.filter(h=>!d.has(h.path)),a.push(...f)}}return{remaining:[...o,...l,...c],renames:a}}async function Ns(t,e,n,r){let s=new Map;for(let a=0;a<e.length;a++){let c=e[a];if(!c)continue;let l=Pe(c.path);s.has(l)?s.set(l,-1):s.set(l,a)}let i=new Map;for(let a=0;a<n.length;a++){let c=n[a];if(!c)continue;let l=Pe(c.path);i.has(l)?i.set(l,-1):i.set(l,a)}let o=[];for(let[a,c]of s){if(c===-1)continue;let l=i.get(a);if(l===void 0||l===-1)continue;let f=e[c],u=n[l];if(!f?.oldHash||!u?.newHash||f.oldHash===u.newHash)continue;let d=await se(t,f.oldHash),h=await se(t,u.newHash),m=Fs(d,h);m<r||o.push({oldPath:f.path,newPath:u.path,oldHash:f.oldHash,newHash:u.newHash,similarity:m,oldMode:f.oldMode,newMode:u.newMode})}return o}var Hn=107927;function Je(t){let e=new Map,n=0,r=0,s=0;for(let o=0;o<t.length;o++){let a=t[o],c=r;if(r=(r<<7^s>>>25)>>>0,s=(s<<7^c>>>25)>>>0,r=r+a>>>0,n++,n<64&&a!==10)continue;let l=(r+Math.imul(s,97))%Hn;e.set(l,(e.get(l)??0)+n),n=0,r=0,s=0}if(n>0){let o=(r+Math.imul(s,97))%Hn;e.set(o,(e.get(o)??0)+n)}let i=[];for(let[o,a]of e)i.push({hash:o,count:a});return i.sort((o,a)=>o.hash-a.hash),i}function Gs(t,e){let n=0,r=0,s=0,i=0;for(;s<t.length;){let o=t[s];if(!o)break;for(;i<e.length;){let l=e[i];if(!l||l.hash>=o.hash)break;r+=l.count,i++}let a=o.count,c=0;if(i<e.length){let l=e[i];l&&l.hash===o.hash&&(c=l.count,i++)}a<c?(r+=c-a,n+=a):n+=c,s++}for(;i<e.length;){let o=e[i];o&&(r+=o.count),i++}return{srcCopied:n,literalAdded:r}}function Fs(t,e){return t.length===0&&e.length===0?100:t.length===0||e.length===0?0:Bn(t.length,Je(t),e.length,Je(e))}function Bn(t,e,n,r){let s=Math.max(t,n),i=Math.min(t,n);if(i<s-i)return 0;let{srcCopied:o}=Gs(e,r);return Math.floor(o*100/s)}async function _s(t,e,n,r){let s=[];for(let f of e)if(f.oldHash){let u=await se(t,f.oldHash);s.push({size:u.length,chunks:Je(u)})}else s.push(null);let i=[];for(let f of n)if(f.newHash){let u=await se(t,f.newHash);i.push({size:u.length,chunks:Je(u)})}else i.push(null);let o=[];for(let f=0;f<e.length;f++){let u=e[f],d=s[f];if(!(!u||!d))for(let h=0;h<n.length;h++){let m=n[h],g=i[h];if(!m||!g)continue;let p=Bn(d.size,d.chunks,g.size,g.chunks);if(p>=r){let b=Pe(u.path)===Pe(m.path)?1:0;o.push({similarity:p,nameScore:b,delIdx:f,addIdx:h})}}}o.sort((f,u)=>u.similarity-f.similarity||u.nameScore-f.nameScore);let a=new Set,c=new Set,l=[];for(let{similarity:f,delIdx:u,addIdx:d}of o){if(a.has(u)||c.has(d))continue;a.add(u),c.add(d);let h=e[u],m=n[d];!h||!m||l.push({oldPath:h.path,newPath:m.path,oldHash:h.oldHash??"",newHash:m.newHash??"",similarity:f,oldMode:h.oldMode,newMode:m.newMode})}return l}async function he(t,e,n){return(await fe(t,e)).get(n)?.hash??null}async function Dn(t,e,n,r){let s=await ae(t,e,n);if(!s.find(c=>c.status==="added"&&c.path===r))return null;let{renames:o}=await ye(t,s);return o.find(c=>c.newPath===r)?.oldPath??null}async function Ws(t,e,n,r,s,i){let o=await he(t,(await A(t,e)).tree,n);if(!o){let g=new Map,p=await A(t,e);for(let b of r)g.set(b.finalIdx,de(e,n,b.currentLine,i+b.finalIdx,s[b.finalIdx],p,!1,void 0));return g}let a=await B(t,o),c=J(a),l=new Array(s.length),f=[...r],u=e,d=n,h=c;for(;f.length>0;){let g=await A(t,u);if(g.parents.length===0){for(let x of f)l[x.finalIdx]=de(u,d,x.currentLine,i+x.finalIdx,s[x.finalIdx],g,!0,void 0);break}let p=await he(t,g.tree,d),b=null,P=[];for(let x of g.parents){let T=await A(t,x),O=d,$=await he(t,T.tree,O);if(!$){let H=await Dn(t,T.tree,g.tree,d);H&&(O=H,$=await he(t,T.tree,O))}if($&&(P.push({hash:x,path:O,blobHash:$}),$===p)){b={hash:x,path:O};break}}if(b){u=b.hash,d=b.path;continue}if(P.length===0){for(let x of f)l[x.finalIdx]=de(u,d,x.currentLine,i+x.finalIdx,s[x.finalIdx],g,!1,void 0);break}let C=P[0],v=await B(t,C.blobHash),R=J(v),w=ge(R,h),E=new Map;for(let x of w)x.type==="keep"&&E.set(x.newLineNo,x.oldLineNo);let S=[];for(let x of f){let T=E.get(x.currentLine);T!==void 0?S.push({finalIdx:x.finalIdx,currentLine:T}):l[x.finalIdx]=de(u,d,x.currentLine,i+x.finalIdx,s[x.finalIdx],g,!1,{hash:C.hash,path:C.path})}f=S,u=C.hash,d=C.path,h=R}let m=new Map;for(let g of r)l[g.finalIdx]&&m.set(g.finalIdx,l[g.finalIdx]);return m}async function Un(t,e,n,r){let s=await A(t,e),i=await he(t,s.tree,n);if(!i)throw new Error(`no such path '${n}' in ${e.slice(0,7)}`);let o=await B(t,i),a=J(o),c=r?.startLine??1,l=r?.endLine??a.length,f=a.slice(c-1,l),u=new Array(f.length),d=f.map((p,b)=>({finalIdx:b,currentLine:c+b})),h=e,m=n,g=a;for(;d.length>0;){let p=await A(t,h);if(p.parents.length===0){for(let E of d)u[E.finalIdx]=de(h,m,E.currentLine,c+E.finalIdx,f[E.finalIdx],p,!0,void 0);break}let b=await he(t,p.tree,m),P=[],C=null;for(let E of p.parents){let S=await A(t,E),x=m,T=await he(t,S.tree,x);if(!T){let O=await Dn(t,S.tree,p.tree,m);O&&(x=O,T=await he(t,S.tree,x))}if(T){let O={hash:E,path:x,blobHash:T};if(P.push(O),T===b){C=O;break}}}if(C){h=C.hash,m=C.path;continue}if(P.length===0){for(let E of d)u[E.finalIdx]=de(h,m,E.currentLine,c+E.finalIdx,f[E.finalIdx],p,!1,void 0);break}if(P.length===1){let E=P[0],S=await B(t,E.blobHash),x=J(S),T=ge(x,g),O=new Map;for(let H of T)H.type==="keep"&&O.set(H.newLineNo,H.oldLineNo);let $=[];for(let H of d){let Q=O.get(H.currentLine);Q!==void 0?$.push({finalIdx:H.finalIdx,currentLine:Q}):u[H.finalIdx]=de(h,m,H.currentLine,c+H.finalIdx,f[H.finalIdx],p,!1,{hash:E.hash,path:E.path})}d=$,h=E.hash,m=E.path,g=x;continue}let v=[];for(let E of P){let S=await B(t,E.blobHash),x=J(S),T=ge(x,g),O=new Map;for(let $ of T)$.type==="keep"&&O.set($.newLineNo,$.oldLineNo);v.push({info:E,newToOld:O})}let R=new Map;for(let E of d){let S=!1;for(let x=0;x<v.length;x++){let T=v[x],O=T.newToOld.get(E.currentLine);if(O!==void 0){let $=R.get(x);$||($={info:T.info,lines:[]},R.set(x,$)),$.lines.push({finalIdx:E.finalIdx,currentLine:O}),S=!0;break}}S||(u[E.finalIdx]=de(h,m,E.currentLine,c+E.finalIdx,f[E.finalIdx],p,!1,{hash:P[0].hash,path:P[0].path}))}let w=R.get(0);for(let[E,S]of R){if(E===0)continue;let x=await Ws(t,S.info.hash,S.info.path,S.lines,f,c);for(let[T,O]of x)u[T]=O}if(w&&w.lines.length>0){d=w.lines,h=w.info.hash,m=w.info.path;let E=await B(t,w.info.blobHash);g=J(E)}else break}return u}function de(t,e,n,r,s,i,o,a){return{hash:t,origPath:e,origLine:n,finalLine:r,content:s,author:i.author,committer:i.committer,summary:i.message.split(`
|
|
22
|
+
`)[0],boundary:o,previous:a}}var Te=class{heap=[];nextEpoch=0;get size(){return this.heap.length}push(e){this.heap.push({entry:e,epoch:this.nextEpoch++}),this.siftUp(this.heap.length-1)}pop(){let{heap:e}=this;if(e.length===0)return;let n=e[0],r=e.pop();return e.length>0&&(e[0]=r,this.siftDown(0)),n.entry}higher(e,n){let r=e.entry.commit.committer.timestamp,s=n.entry.commit.committer.timestamp;return r>s||r===s&&e.epoch<n.epoch}siftUp(e){let{heap:n}=this;for(;e>0;){let r=e-1>>1;if(!this.higher(n[e],n[r]))break;[n[r],n[e]]=[n[e],n[r]],e=r}}siftDown(e){let{heap:n}=this,r=n.length;for(;;){let s=e,i=2*e+1,o=2*e+2;if(i<r&&this.higher(n[i],n[s])&&(s=i),o<r&&this.higher(n[o],n[s])&&(s=o),s===e)break;[n[e],n[s]]=[n[s],n[e]],e=s}}};async function*ce(t,e,n){if(n?.topoOrder){yield*zs(t,e,n);return}let r=await Gn(t,n?.exclude),s=new Set(r),i=new Te,o=n?.shallowBoundary,a=n?.limit,c=0,l=Array.isArray(e)?e:[e];for(let f of l)s.has(f)||i.push(await Qe(t,f));for(;i.size>0;){let f=i.pop();if(s.has(f.hash))continue;if(s.add(f.hash),yield f,a!==void 0&&++c>=a)return;if(o?.has(f.hash))continue;let u=n?.firstParent?f.commit.parents.slice(0,1):f.commit.parents;for(let d of u)if(!s.has(d))try{i.push(await Qe(t,d))}catch{}}}async function*zs(t,e,n){let r=await Gn(t,n?.exclude),s=new Set(r),i=new Te,o=n?.shallowBoundary,a=Array.isArray(e)?e:[e];for(let h of a)s.has(h)||i.push(await Qe(t,h));let c=[],l=new Map;for(;i.size>0;){let h=i.pop();if(s.has(h.hash)||(s.add(h.hash),l.set(h.hash,c.length),c.push(h),o?.has(h.hash)))continue;let m=n?.firstParent?h.commit.parents.slice(0,1):h.commit.parents;for(let g of m)if(!s.has(g))try{i.push(await Qe(t,g))}catch{}}let f=c.length;if(f===0)return;let u=new Int32Array(f);for(let h of c){let m=n?.firstParent?h.commit.parents.slice(0,1):h.commit.parents;for(let g of m){let p=l.get(g);p!==void 0&&(u[p]=(u[p]??0)+1)}}let d=[];for(let h=f-1;h>=0;h--)u[h]===0&&d.push(h);for(;d.length>0;){let h=d.pop();yield c[h];let m=n?.firstParent?c[h].commit.parents.slice(0,1):c[h].commit.parents;for(let g of m){let p=l.get(g);if(p!==void 0){let b=(u[p]??0)-1;u[p]=b,b===0&&d.push(p)}}}}async function Nn(t,e,n){if(e===n)return{ahead:0,behind:0};let r=new Set;for await(let a of ce(t,e))r.add(a.hash);let s=new Set;for await(let a of ce(t,n))s.add(a.hash);let i=0;for(let a of r)s.has(a)||i++;let o=0;for(let a of s)r.has(a)||o++;return{ahead:i,behind:o}}async function Gn(t,e){if(!e||e.length===0)return new Set;let n=new Set;for await(let r of ce(t,e))n.add(r.hash);return n}async function Qe(t,e){return{hash:e,commit:await A(t,e)}}async function Vs(t,e){let n=new Set,r=[e],s=0;for(;s<r.length;){let i=r[s++];if(n.has(i))continue;n.add(i);let o;try{o=await A(t,i)}catch{continue}for(let a of o.parents)n.has(a)||r.push(a)}return n}async function Et(t,e,n){if(e===n)return!0;let r=new Set,s=[n],i=0;for(;i<s.length;){let o=s[i++];if(o===e)return!0;if(r.has(o))continue;r.add(o);let a;try{a=await A(t,o)}catch{continue}for(let c of a.parents)r.has(c)||s.push(c)}return!1}async function Ne(t,e,n){if(e===n)return[e];let r=await Vs(t,e),s=[],i=new Set,o=[n],a=0;for(;a<o.length;){let l=o[a++];if(i.has(l))continue;if(i.add(l),r.has(l)){s.push(l);continue}let f;try{f=await A(t,l)}catch{continue}for(let u of f.parents)i.has(u)||o.push(u)}if(s.length<=1)return s;let c=[];for(let l of s){let f=!1;for(let u of s)if(u!==l&&await Et(t,l,u)){f=!0;break}f||c.push(l)}return c.length<=1?c:Ks(t,e,n,c)}async function Ks(t,e,n,r){let s=new Set(r),i=new Set,o=[],a=new Map,c=new Map,l=0,f=[{hash:e,mask:1,seq:l++},{hash:n,mask:2,seq:l++}];async function u(d){let h=c.get(d);if(h!==void 0)return h;let m=(await A(t,d)).committer.timestamp;return c.set(d,m),m}for(;f.length>0;){let d=0,h=await u(f[0].hash);for(let P=1;P<f.length;P++){let C=f[P],v=await u(C.hash),R=f[d];(v>h||v===h&&C.seq<R.seq)&&(d=P,h=v)}let m=f.splice(d,1)[0],g=a.get(m.hash)??0,p=g|m.mask;if(p===g)continue;if(a.set(m.hash,p),p===3&&s.has(m.hash)&&!i.has(m.hash)&&(o.push(m.hash),i.add(m.hash),i.size===s.size))break;let b=await A(t,m.hash);for(let P of b.parents)f.push({hash:P,mask:p,seq:l++})}for(let d of r)i.has(d)||o.push(d);return o}async function Ys(t,e){return Y(t,e)}async function qs(t,e,n){return ae(t,e,n)}async function Xs(t,e,n){let r=await A(t,n),s=null;return e&&(s=(await A(t,e)).tree),ae(t,s,r.tree)}async function*Zs(t,e,n){let r=e?[e]:[];for await(let s of ce(t,n,{exclude:r}))yield{hash:s.hash,message:s.commit.message,tree:s.commit.tree,parents:s.commit.parents,author:s.commit.author,committer:s.commit.committer}}async function Js(t,e,n){return Et(t,e,n)}async function Qs(t,e,n){return Ne(t,e,n)}async function ei(t,e,n){return Nn(t,e,n)}async function ti(t,e,n,r){return Un(t,e,n,r)}function ni(t){return t==="insert"?"+":t==="delete"?"-":" "}function ri(t){return{oldStart:t.oldStart,oldCount:t.oldCount,newStart:t.newStart,newCount:t.newCount,lines:t.lines.map(e=>ni(e.type)+e.content)}}function si(t,e,n){let r=J(t),s=J(e),i=ge(r,s);return wt(i,n).map(ri)}async function Fn(t,e){let n=await Ie(t,e);if(n)return n;throw new Error(`ref or commit '${e}' not found`)}async function _n(t,e,n,r){let s=await Fn(t,e),i=await Fn(t,n),o=await A(t,s),a=await A(t,i),c=await ae(t,o.tree,a.tree),l=r?.renames!==!1,f=r?.paths,u=[];if(l){let h=await ye(t,c);c=h.remaining,u=h.renames}let d=[];for(let h of c)f&&!f.some(m=>h.path.startsWith(m))||d.push({path:h.path,status:h.status,oldContent:h.oldHash?await B(t,h.oldHash):"",newContent:h.newHash?await B(t,h.newHash):"",oldHash:h.oldHash??void 0,newHash:h.newHash??void 0,oldMode:h.oldMode,newMode:h.newMode});for(let h of u)f&&!f.some(m=>h.newPath.startsWith(m)||h.oldPath.startsWith(m))||d.push({path:h.newPath,oldPath:h.oldPath,status:"renamed",oldContent:await B(t,h.oldHash),newContent:await B(t,h.newHash),oldHash:h.oldHash,newHash:h.newHash,oldMode:h.oldMode,newMode:h.newMode,similarity:h.similarity});return d.sort((h,m)=>h.path.localeCompare(m.path)),d}async function ii(t,e,n,r){let s=await _n(t,e,n,r),i=r?.contextLines;return s.map(o=>({path:o.path,status:o.status,oldPath:o.oldPath,similarity:o.similarity,hunks:si(o.oldContent,o.newContent,i)}))}async function oi(t,e,n,r){let s=await _n(t,e,n,r),i=r?.contextLines,o="";for(let a of s)o+=Ln({path:a.oldPath??a.path,oldContent:a.oldContent,newContent:a.newContent,oldHash:a.oldHash,newHash:a.newHash,oldMode:a.oldMode,newMode:a.newMode,isNew:a.status==="added",isDeleted:a.status==="deleted",renameTo:a.status==="renamed"?a.path:void 0,similarity:a.similarity,contextLines:i});return o}async function*ai(t,e,n){if(n?.paths&&n.paths.length>0){let r=n?.limit,s=0;for await(let i of ci(t,e,n.paths,n))if(yield i,r!==void 0&&++s>=r)return;return}for await(let r of ce(t,e,n))yield{hash:r.hash,message:r.commit.message,tree:r.commit.tree,parents:r.commit.parents,author:r.commit.author,committer:r.commit.committer}}function It(t,e){return e.some(n=>t===n||t.startsWith(n.endsWith("/")?n:n+"/"))}async function*ci(t,e,n,r){let s=new Set;if(r?.exclude)for await(let l of ce(t,r.exclude))s.add(l.hash);let i=new Set(s),o=new Te,a=async l=>{if(!i.has(l))try{let f=await A(t,l);o.push({hash:l,commit:f})}catch{}},c=Array.isArray(e)?e:[e];for(let l of c)await a(l);for(;o.size>0;){let l=o.pop();if(i.has(l.hash))continue;i.add(l.hash);let{commit:f}=l,u=r?.firstParent?f.parents.slice(0,1):f.parents,d=()=>({hash:l.hash,message:f.message,tree:f.tree,parents:f.parents,author:f.author,committer:f.committer});if(u.length===0){(await ae(t,null,f.tree)).some(g=>It(g.path,n))&&(yield d());continue}if(u.length===1){let m=u[0];try{let g=await A(t,m);(await ae(t,g.tree,f.tree)).some(b=>It(b.path,n))&&(yield d())}catch{yield d()}await a(m);continue}let h=[];for(let m of u)try{let g=await A(t,m);(await ae(t,g.tree,f.tree)).some(b=>It(b.path,n))||h.push(m)}catch{}if(h.length>0)await a(h[0]);else{yield d();for(let m of u)await a(m)}}}function li(t){let e=Math.abs(t),n=t<=0?"+":"-",r=String(Math.floor(e/60)).padStart(2,"0"),s=String(e%60).padStart(2,"0");return`${n}${r}${s}`}function Ge(t){if("timestamp"in t)return t;let e=t.date??new Date;return{name:t.name,email:t.email,timestamp:Math.floor(e.getTime()/1e3),timezone:li(e.getTimezoneOffset())}}async function fi(t,e){let n=Ge(e.author),r=e.committer?Ge(e.committer):n,s=Me({type:"commit",tree:e.tree,parents:e.parents,author:n,committer:r,message:e.message}),i=await N(t,"commit",s);return e.branch&&await Vn(t,e.branch,i),i}async function ui(t,e){let n=Ge(e.tagger),r=tn({type:"tag",object:e.target,objectType:e.targetType??"commit",name:e.name,tagger:n,message:e.message}),s=await N(t,"tag",r);return await t.refStore.writeRef(`refs/tags/${e.name}`,{type:"direct",hash:s}),s}async function zn(t,e){let n=e.branch?`refs/heads/${e.branch}`:null,r=n?await ne(t,n):null,s=null;r&&(s=(await A(t,r)).tree);let i=[];for(let[d,h]of Object.entries(e.files))if(h===null)i.push({path:d,hash:null});else{let m=typeof h=="string"?new TextEncoder().encode(h):h,g=await N(t,"blob",m);i.push({path:d,hash:g})}let o;s?o=await Kn(t,s,i):o=await Rt(t,null,xt(i));let a=Ge(e.author),c=e.committer?Ge(e.committer):a,f=Me({type:"commit",tree:o,parents:r?[r]:[],author:a,committer:c,message:e.message});return{hash:await N(t,"commit",f),parentHash:r}}async function hi(t,e){let{hash:n}=await zn(t,e);return await Vn(t,e.branch,n),n}async function Vn(t,e,n){let r=`refs/heads/${e}`;await t.refStore.writeRef(r,{type:"direct",hash:n}),await t.refStore.readRef("HEAD")||await t.refStore.writeRef("HEAD",{type:"symbolic",target:r})}async function di(t,e){let n=[...e].sort((i,o)=>i.name.localeCompare(o.name)),r=await Promise.all(n.map(async i=>{let o=i.mode;return o||(o=(await t.objectStore.read(i.hash)).type==="tree"?"040000":"100644"),{mode:o,name:i.name,hash:i.hash}})),s=He({type:"tree",entries:r});return N(t,"tree",s)}async function mi(t,e){return N(t,"blob",new TextEncoder().encode(e))}async function Kn(t,e,n){return Rt(t,e,xt(n))}function xt(t){let e=new Map,n=new Map;for(let r of t){let s=r.path.indexOf("/");if(s===-1)e.set(r.path,{hash:r.hash,mode:r.mode??"100644"});else{let i=r.path.slice(0,s),o=r.path.slice(s+1),a=n.get(i);a||(a=[],n.set(i,a)),a.push({...r,path:o})}}return{files:e,dirs:n}}async function Wn(t,e){let n=await F(t,e);if(n.type!=="tree")throw new Error(`Expected tree object, got ${n.type}`);return ie(n.content).entries}async function Rt(t,e,n){let r=new Map;if(e)for(let o of await Wn(t,e))r.set(o.name,o);for(let[o,{hash:a,mode:c}]of n.files)a===null?r.delete(o):r.set(o,{name:o,hash:a,mode:c});for(let[o,a]of n.dirs){let c=r.get(o),l=c?.mode==="040000"?c.hash:null,f=xt(a),u=await Rt(t,l,f);(await Wn(t,u)).length===0?r.delete(o):r.set(o,{name:o,hash:u,mode:"040000"})}let s=[...r.values()].sort((o,a)=>{let c=o.mode==="040000"?`${o.name}/`:o.name,l=a.mode==="040000"?`${a.name}/`:a.name;return c<l?-1:c>l?1:0}),i=He({type:"tree",entries:s});return N(t,"tree",i)}function Ot(t,e){let n=t.length,r=e.length;if(n===0&&r===0)return[];if(n===0)return[{buffer1:[0,0],buffer2:[0,r]}];if(r===0)return[{buffer1:[0,n],buffer2:[0,0]}];let{changedOld:s,changedNew:i}=bt(t,e);return pi(s,n,i,r)}function pi(t,e,n,r){let s=[],i=0,o=0;for(;i<e||o<r;){for(;i<e&&o<r&&!t[i]&&!n[o];)i++,o++;if(i>=e&&o>=r)break;let a=i,c=o;for(;i<e&&t[i];)i++;for(;o<r&&n[o];)o++;(i>a||o>c)&&s.push({buffer1:[a,i-a],buffer2:[c,o-c]})}return s}function gi(t,e,n){let r=[];for(let c of Ot(e,t))r.push({ab:"a",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});for(let c of Ot(e,n))r.push({ab:"b",oStart:c.buffer1[0],oLength:c.buffer1[1],abStart:c.buffer2[0],abLength:c.buffer2[1]});r.sort((c,l)=>c.oStart-l.oStart);let s=[],i=0;function o(c){c>i&&(s.push({stable:!0,buffer:"o",bufferStart:i,bufferLength:c-i,content:e.slice(i,c)}),i=c)}let a=0;for(;a<r.length;){let c=r[a++],l=c.oStart,f=c.oStart+c.oLength,u=[c];for(o(l);a<r.length;){let d=r[a];if(d.oStart>f)break;f=Math.max(f,d.oStart+d.oLength),u.push(d),a++}if(u.length===1){if(c.abLength>0){let d=c.ab==="a"?t:n;s.push({stable:!0,buffer:c.ab,bufferStart:c.abStart,bufferLength:c.abLength,content:d.slice(c.abStart,c.abStart+c.abLength)})}}else{let d={a:{abMin:t.length,abMax:-1,oMin:e.length,oMax:-1},b:{abMin:n.length,abMax:-1,oMin:e.length,oMax:-1}};for(let b of u){let P=b.oStart,C=P+b.oLength,v=b.abStart,R=v+b.abLength,w=d[b.ab];w.abMin=Math.min(v,w.abMin),w.abMax=Math.max(R,w.abMax),w.oMin=Math.min(P,w.oMin),w.oMax=Math.max(C,w.oMax)}let h=d.a.abMin+(l-d.a.oMin),m=d.a.abMax+(f-d.a.oMax),g=d.b.abMin+(l-d.b.oMin),p=d.b.abMax+(f-d.b.oMax);s.push({stable:!1,a:t.slice(h,m),o:e.slice(l,f),b:n.slice(g,p)})}i=f}return o(e.length),s}function yi(t,e,n,r){let s=r?.excludeFalseConflicts??!0,i=gi(t,e,n),o=[],a=[];function c(){a.length&&(o.push({type:"ok",lines:a}),a=[])}for(let l of i)l.stable?a.push(...l.content):s&&qn(l.a,l.b)?a.push(...l.a):(c(),o.push({type:"conflict",a:l.a,o:l.o,b:l.b}));return c(),r?.conflictStyle==="diff3"?Yn(o):Yn(bi(o))}function Fe(t,e,n,r){let s=r?.markerSize??7,i=r?.conflictStyle??"merge",o=`${"<".repeat(s)}${r?.a?` ${r.a}`:""}`,a=`${"|".repeat(s)}${r?.o?` ${r.o}`:""}`,c="=".repeat(s),l=`${">".repeat(s)}${r?.b?` ${r.b}`:""}`,f=yi(t,e,n,{conflictStyle:i}),u=!1,d=[];for(let h of f)h.type==="ok"?d.push(...h.lines):(u=!0,i==="diff3"?d.push(o,...h.a,a,...h.o,c,...h.b,l):d.push(o,...h.a,c,...h.b,l));return{conflict:u,result:d}}function bi(t){let e=[];for(let n of t)n.type==="ok"?e.push(n):e.push(...wi(n));return e}function wi(t){let{a:e,b:n}=t;if(e.length===0||n.length===0)return[t];if(qn(e,n))return[t];let r=Ot(e,n);if(r.length===0)return[{type:"ok",lines:e}];let s=[],i=0;for(let a of r){let c=a.buffer1[0];c-i>0&&s.push({type:"ok",lines:e.slice(i,c)});let f=c+a.buffer1[1],u=a.buffer2[0]+a.buffer2[1];s.push({type:"conflict",a:e.slice(c,f),o:[],b:n.slice(a.buffer2[0],u)}),i=f}return e.length-i>0&&s.push({type:"ok",lines:e.slice(i)}),s.length===1&&s[0].type==="conflict"?[t]:s}function Yn(t){if(t.length<3)return t;let e=[t[0]];for(let r=1;r<t.length;r++){let s=e[e.length-1],i=t[r];s.type==="ok"&&i.type==="ok"?s.lines=[...s.lines,...i.lines]:e.push(i)}if(e.length<3)return e;let n=[e[0]];for(let r=1;r<e.length;r++){let s=n[n.length-1],i=e[r];if(s.type==="conflict"&&i.type==="ok"&&i.lines.length<=3&&r+1<e.length&&e[r+1].type==="conflict"){let o=e[r+1],a=s;a.a=[...s.a,...i.lines,...o.a],a.b=[...s.b,...i.lines,...o.b],a.o=[...s.o,...i.lines,...o.o],r++}else n.push(i)}return n}function be(t,e,n,r){let s=Fe(q(t),q(e),q(n),{a:r.a,o:r.o,b:r.b,markerSize:r.markerSize,conflictStyle:r.conflictStyle}),o=(s.result[s.result.length-1]??"").endsWith("\0"),a=s.result.map(Pt);return(a[a.length-1]??"").startsWith(">>>>>>>")||!o?`${a.join(`
|
|
22
23
|
`)}
|
|
23
24
|
`:a.join(`
|
|
24
|
-
`)}function
|
|
25
|
-
`);if(e[e.length-1]==="")e.pop();else{let n=e[e.length-1]??"";e[e.length-1]=`${n}\0`}return e}function Ot(t){return t.endsWith("\0")?t.slice(0,-1):t}function Gn(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}var Re=new TextDecoder,de=new TextEncoder,Fn={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Pe(t,e,n,r,s){let{paths:o,baseMap:i,oursMap:a,theirsMap:c}=await mi(t,e,n,r),l=await gi(t,o,i,a,c,s);return yi(t,o,s,l)}async function qn(t,e,n,r){let s=await He(t,e,n),o=await A(t,e),i=await A(t,n);if(s.length===0)return{...await Pe(t,null,o.tree,i.tree,r),baseTree:null};if(s.length===1){let l=await A(t,s[0]);return{...await Pe(t,l.tree,o.tree,i.tree,r),baseTree:l.tree}}let a=await Zn(t,e,n,s,1);return{...await Pe(t,a,o.tree,i.tree,r),baseTree:a}}async function mi(t,e,n,r){let s=await le(t,e),o=await le(t,n),i=await le(t,r),a=new Set;for(let l of s.keys())a.add(l);for(let l of o.keys())a.add(l);for(let l of i.keys())a.add(l);let c=new Map;for(let l of a){let f=s.get(l)??null,u=o.get(l)??null,d=i.get(l)??null,h=f?{hash:f.hash,mode:f.mode}:null,m=u?{hash:u.hash,mode:u.mode}:null,g=d?{hash:d.hash,mode:d.mode}:null,p=(f?1:0)|(u?2:0)|(d?4:0),b=f?.hash??null,k=u?.hash??null,v=d?.hash??null,j=0;b!==null&&b===k&&(j|=3),b!==null&&b===v&&(j|=5),k!==null&&k===v&&(j|=6);let R={path:l,stages:[h,m,g],pathnames:[l,l,l],filemask:p,matchMask:j,merged:{result:null,clean:!1},pathConflict:!1};if(pi(R)){c.set(l,R);continue}c.set(l,R)}return{paths:c,baseMap:s,oursMap:o,theirsMap:i}}function pi(t){let[e,n,r]=t.stages,s=e?.hash??null,o=n?.hash??null,i=r?.hash??null;return o===s&&i===s?(n?t.merged={result:{hash:o,mode:n.mode},clean:!0}:t.merged={result:null,clean:!0},!0):o===i&&o!==null?(t.merged={result:{hash:o,mode:n.mode},clean:!0},!0):o===null&&i===null?(t.merged={result:null,clean:!0},!0):i===s&&o!==s?(n?t.merged={result:{hash:o,mode:n.mode},clean:!0}:t.merged={result:null,clean:!0},!0):o===s&&i!==s?(r?t.merged={result:{hash:i,mode:r.mode},clean:!0}:t.merged={result:null,clean:!0},!0):!1}async function gi(t,e,n,r,s,o){let i={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[E,y]of n)r.has(E)||a.push({path:E,status:"deleted",oldHash:y.hash,oldMode:y.mode}),s.has(E)||c.push({path:E,status:"deleted",oldHash:y.hash,oldMode:y.mode});for(let[E,y]of r)n.has(E)||a.push({path:E,status:"added",newHash:y.hash,newMode:y.mode});for(let[E,y]of s)n.has(E)||c.push({path:E,status:"added",newHash:y.hash,newMode:y.mode});let l=await pe(t,a),f=await pe(t,c);if(l.renames.length===0&&f.renames.length===0)return i;let u=new Map,d=new Map;for(let E of l.renames)u.set(E.oldPath,E);for(let E of f.renames)d.set(E.oldPath,E);let h=new Set;for(let[E]of r)!n.has(E)&&s.has(E)&&h.add(E);let m=new Set,g=o?.a??"HEAD",p=o?.b??"theirs";function b(E,y,T=0){i.msgBuf.push({sortKey:E,subOrder:T,text:y})}for(let E of[...n.keys()].sort()){let y=u.get(E),T=d.get(E);if(!y&&!T)continue;let L=n.get(E);if(m.add(E),y&&T)if(m.add(y.newPath),m.add(T.newPath),y.newPath===T.newPath){let M=r.get(y.newPath),S=s.get(T.newPath);if(M.hash===S.hash)i.entries.push(V(y.newPath,M));else{let N=Rt(e,y.newPath);N.stages=[{hash:L.hash,mode:L.mode},{hash:M.hash,mode:M.mode},{hash:S.hash,mode:S.mode}],N.pathnames=[E,y.newPath,T.newPath],N.filemask=7,N.merged={result:null,clean:!1}}}else{let M=r.get(y.newPath),S=s.get(T.newPath),N=await Xn(t,L,M,S,o);N.conflict&&b(E,`Auto-merging ${E}`,-1),i.conflicts.push({path:E,reason:"rename-rename",oursPath:y.newPath,theirsPath:T.newPath}),b(E,`CONFLICT (rename/rename): ${E} renamed to ${y.newPath} in ${g} and to ${T.newPath} in ${p}.`),i.entries.push(V(E,L,1)),i.entries.push(W(y.newPath,M.mode,N.hash,2)),i.entries.push(W(T.newPath,S.mode,N.hash,3)),i.worktreeBlobs.set(y.newPath,{hash:N.hash,mode:M.mode}),i.worktreeBlobs.set(T.newPath,{hash:N.hash,mode:S.mode})}else if(y){m.add(y.newPath);let M=s.get(E),S=r.get(y.newPath),N=h.has(y.newPath);if(M)if(N)await Yn(t,i,y.newPath,E,L,S,M,r,s,!1,o);else if(M.hash===L.hash&&S.hash===L.hash)i.entries.push(V(y.newPath,S));else if(M.hash===L.hash)i.entries.push(V(y.newPath,S));else if(S.hash===L.hash)i.entries.push(W(y.newPath,S.mode,M.hash));else{let G=Rt(e,y.newPath);G.stages=[{hash:L.hash,mode:L.mode},{hash:S.hash,mode:S.mode},{hash:M.hash,mode:M.mode}],G.pathnames=[E,y.newPath,E],G.filemask=7,G.merged={result:null,clean:!1}}else{let G=s.get(y.newPath);if(i.conflicts.push({path:y.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:E}),b(y.newPath,`CONFLICT (rename/delete): ${E} renamed to ${y.newPath} in ${g}, but deleted in ${p}.`),G){i.conflicts.push({path:y.newPath,reason:"add-add"}),b(y.newPath,`Auto-merging ${y.newPath}`,0),b(y.newPath,`CONFLICT (add/add): Merge conflict in ${y.newPath}`,1),i.entries.push(V(y.newPath,S,2)),i.entries.push(V(y.newPath,G,3));let Qe=await Ze(t,S.hash,G.hash,S.mode,o);i.worktreeBlobs.set(y.newPath,{hash:Qe,mode:S.mode})}else i.entries.push(W(y.newPath,L.mode,L.hash,1)),i.entries.push(V(y.newPath,S,2)),i.worktreeBlobs.set(y.newPath,{hash:S.hash,mode:S.mode}),S.hash!==L.hash&&b(y.newPath,`CONFLICT (modify/delete): ${y.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${y.newPath} left in tree.`,1)}}else if(T){m.add(T.newPath);let M=r.get(E),S=s.get(T.newPath),N=h.has(T.newPath);if(M)if(N)await Yn(t,i,T.newPath,E,L,M,S,r,s,!0,o);else if(M.hash===L.hash&&S.hash===L.hash)i.entries.push(V(T.newPath,S));else if(M.hash===L.hash)i.entries.push(V(T.newPath,S));else if(S.hash===L.hash)i.entries.push(W(T.newPath,S.mode,M.hash));else{let G=Rt(e,T.newPath);G.stages=[{hash:L.hash,mode:L.mode},{hash:M.hash,mode:M.mode},{hash:S.hash,mode:S.mode}],G.pathnames=[E,E,T.newPath],G.filemask=7,G.merged={result:null,clean:!1}}else{let G=r.get(T.newPath);if(i.conflicts.push({path:T.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:E}),b(T.newPath,`CONFLICT (rename/delete): ${E} renamed to ${T.newPath} in ${p}, but deleted in ${g}.`),G){i.conflicts.push({path:T.newPath,reason:"add-add"}),b(T.newPath,`Auto-merging ${T.newPath}`,0),b(T.newPath,`CONFLICT (add/add): Merge conflict in ${T.newPath}`,1),i.entries.push(V(T.newPath,G,2)),i.entries.push(V(T.newPath,S,3));let Qe=await Ze(t,G.hash,S.hash,G.mode,o);i.worktreeBlobs.set(T.newPath,{hash:Qe,mode:G.mode})}else i.entries.push(W(T.newPath,L.mode,L.hash,1)),i.entries.push(V(T.newPath,S,3)),i.worktreeBlobs.set(T.newPath,{hash:S.hash,mode:S.mode}),S.hash!==L.hash&&b(T.newPath,`CONFLICT (modify/delete): ${T.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${T.newPath} left in tree.`,1)}}}let k=new Set(l.renames.map(E=>E.newPath)),v=new Set(f.renames.map(E=>E.newPath)),j=_n(n,r),R=_n(n,s),I=Wn(j,s,n),w=Wn(R,r,n),C=zn(l.renames,I),x=zn(f.renames,w),P=Vn(C),O=Vn(x);for(let E of[...P.keys()])O.has(E)&&(P.delete(E),O.delete(E));let $=new Set(P.keys()),H=new Set(O.keys());if(O.size>0)for(let E of a){if(E.status!=="added"||k.has(E.path))continue;let y=Kn(E.path,O,$);if(!y)continue;if(e.has(y)||n.has(y)||r.has(y)||s.has(y)){if(r.has(y)){b(y,`CONFLICT (implicit dir rename): Existing file/dir at ${y} in the way of implicit directory rename(s) putting the following path(s) there: ${E.path}.`,1);continue}let M=r.get(E.path),S=s.get(y)??n.get(y);i.entries.push(W(y,M.mode,M.hash,2)),S&&i.entries.push(W(y,S.mode,S.hash,3)),i.worktreeBlobs.set(y,{hash:M.hash,mode:M.mode}),i.conflicts.push({path:y,reason:"add-add"}),b(y,`CONFLICT (file location): ${E.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${y}.`,1);let N=e.get(E.path);N&&(N.merged={result:null,clean:!0}),m.add(E.path);continue}let T=r.get(E.path);i.entries.push(W(y,T.mode,T.hash,2)),i.worktreeBlobs.set(y,{hash:T.hash,mode:T.mode}),i.conflicts.push({path:y,reason:"directory-rename"}),b(y,`CONFLICT (file location): ${E.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${y}.`,1);let L=e.get(E.path);L&&(L.merged={result:null,clean:!0}),m.add(E.path)}if(P.size>0)for(let E of c){if(E.status!=="added"||v.has(E.path))continue;let y=Kn(E.path,P,H);if(!y)continue;if(e.has(y)||n.has(y)||r.has(y)||s.has(y)){if(s.has(y)){b(y,`CONFLICT (implicit dir rename): Existing file/dir at ${y} in the way of implicit directory rename(s) putting the following path(s) there: ${E.path}.`,1);continue}let M=s.get(E.path),S=r.get(y)??n.get(y);S&&i.entries.push(W(y,S.mode,S.hash,2)),i.entries.push(W(y,M.mode,M.hash,3)),i.worktreeBlobs.set(y,{hash:M.hash,mode:M.mode}),i.conflicts.push({path:y,reason:"add-add"}),b(y,`CONFLICT (file location): ${E.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${y}.`,1);let N=e.get(E.path);N&&(N.merged={result:null,clean:!0}),m.add(E.path);continue}let T=s.get(E.path);i.entries.push(W(y,T.mode,T.hash,3)),i.worktreeBlobs.set(y,{hash:T.hash,mode:T.mode}),i.conflicts.push({path:y,reason:"directory-rename"}),b(y,`CONFLICT (file location): ${E.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${y}.`,1);let L=e.get(E.path);L&&(L.merged={result:null,clean:!0}),m.add(E.path)}let J=new Set(i.entries.map(E=>E.path));for(let E of J){let y=e.get(E);y&&(y.merged={result:null,clean:!0})}for(let E of m){if(J.has(E))continue;let y=e.get(E);if(!y||y.merged.clean)continue;y.filemask===7&&!y.pathConflict||(y.merged={result:null,clean:!0})}return i}function _n(t,e){let n=new Set;for(let o of t.keys()){let i=q(o);for(;i;)n.add(i),i=q(i)}let r=new Set;for(let o of e.keys()){let i=q(o);for(;i;)r.add(i),i=q(i)}let s=new Set;for(let o of n)r.has(o)||s.add(o);return s}function Wn(t,e,n){if(t.size===0)return t;let r=new Set;for(let s of e.keys()){if(n.has(s))continue;let o=q(s)??"";t.has(o)&&r.add(o)}for(let s of[...r]){let o=q(s);for(;o;)t.has(o)&&!r.has(o)&&r.add(o),o=q(o)}return r}function zn(t,e){let n=new Map;for(let r of t){let s=q(r.oldPath),o=q(r.newPath),i=!0;for(;;){if(!i){let a=s.length+(s?1:0),c=o.length+(o?1:0),l=r.oldPath.slice(a,r.oldPath.indexOf("/",a)),f=r.newPath.slice(c,r.newPath.indexOf("/",c));if(l!==f)break}if(e.has(s)){let a=n.get(s);a||(a=new Map,n.set(s,a)),a.set(o,(a.get(o)??0)+1)}if(i=!1,!s||!o)break;s=q(s),o=q(o)}}return n}function Vn(t){let e=new Map;for(let[n,r]of t){let s=0,o=0,i=null;for(let[a,c]of r)c===s?o=s:c>s&&(s=c,i=a);s>0&&o!==s&&i!==null&&e.set(n,i)}return e}function Kn(t,e,n){let r=q(t);for(;r;){let o=e.get(r);if(o!==void 0){if(n.has(o))return null;let i=t.slice(r.length+1);return o?`${o}/${i}`:i}r=q(r)}let s=e.get("");return s!==void 0&&!n.has(s)?`${s}/${t}`:null}function q(t){let e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e)}async function Yn(t,e,n,r,s,o,i,a,c,l=!1,f){let u=l?a.get(n):c.get(n),d=l?i:o;if(u.hash===d.hash){e.entries.push(W(n,u.mode,u.hash)),e.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let m=await Xn(t,s,o,i,f,l?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(u.hash===m.hash)e.entries.push(W(n,u.mode,m.hash));else if(e.conflicts.push({path:n,reason:"add-add"}),e.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),e.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),l){e.entries.push(V(n,u,2)),e.entries.push(W(n,i.mode,m.hash,3));let g=await Ze(t,u.hash,m.hash,u.mode,f);e.worktreeBlobs.set(n,{hash:g,mode:u.mode})}else{e.entries.push(W(n,o.mode,m.hash,2)),e.entries.push(V(n,u,3));let g=await Ze(t,m.hash,u.hash,o.mode,f);e.worktreeBlobs.set(n,{hash:g,mode:o.mode})}}async function Xn(t,e,n,r,s,o,i){if(n.hash===e.hash)return{hash:r.hash,conflict:!1};if(r.hash===e.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(oe(e.mode)||oe(n.mode)||oe(r.mode))return{hash:n.hash,conflict:!0};let a=await D(t,e.hash),c=await D(t,n.hash),l=await D(t,r.hash);if(X(c)||X(l)||X(a))return{hash:n.hash,conflict:!0};let f=Y(a),u=Y(c),d=Y(l),h=s?.conflictStyle,m=Ue(u,f,d,{conflictStyle:h});if(!m.conflict)return{hash:await Pt(t,m.result),conflict:!1};let g=s?.a??"HEAD",p=s?.b??"theirs",b=o?.oursPath?`${g}:${o.oursPath}`:g,k=o?.theirsPath?`${p}:${o.theirsPath}`:p,v=ye(c,a,l,{a:b,b:k,markerSize:i??7,conflictStyle:h});return{hash:await B(t,"blob",de.encode(v)),conflict:!0}}async function Ze(t,e,n,r,s){let o=await D(t,e),i=await D(t,n),a=ye(o,"",i,{a:s?.a??"HEAD",b:s?.b??"theirs",conflictStyle:s?.conflictStyle});return B(t,"blob",de.encode(a))}function V(t,e,n=0){return W(t,e.mode,e.hash,n)}function W(t,e,n,r=0){return{path:t,mode:parseInt(e,8),hash:n,stage:r,stat:ce()}}async function yi(t,e,n,r){let s=[...r.entries],o=[...r.conflicts],i=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(h,m,g=0){i.push({sortKey:h,subOrder:g,text:m})}for(let h of[...e.keys()].sort()){let m=e.get(h);if(m.merged.clean){m.merged.result?.hash&&s.push(U(h,m.merged.result.hash,m.merged.result.mode));continue}await bi(t,m,n,s,o,c,a)}i.sort((h,m)=>(h.sortKey<m.sortKey?-1:h.sortKey>m.sortKey?1:0)||h.subOrder-m.subOrder);let l=i.map(h=>h.text),f=[],u=new Set;for(let h of s)h.stage===0&&(f.push(h),u.add(h.path));for(let[h,m]of a)u.has(h)||f.push(U(h,m.hash,m.mode));f.sort((h,m)=>Me(h.path,m.path));let d=await ht(t,f);return{entries:s,conflicts:o,messages:l,resultTree:d}}async function bi(t,e,n,r,s,o,i){let a=e.path,[c,l,f]=e.stages,u=c?.hash??null,d=l?.hash??null,h=f?.hash??null;if(d===null&&h!==null&&u!==null){s.push({path:a,reason:"delete-modify",deletedBy:"ours"});let m=n?.a??"HEAD",g=n?.b??"theirs";o(a,`CONFLICT (modify/delete): ${a} deleted in ${m} and modified in ${g}. Version ${g} of ${a} left in tree.`),c&&r.push(U(a,u,c.mode,1)),r.push(U(a,h,f.mode,3)),i.set(a,{hash:h,mode:f.mode});return}if(h===null&&d!==null&&u!==null){s.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let m=n?.b??"theirs",g=n?.a??"HEAD";o(a,`CONFLICT (modify/delete): ${a} deleted in ${m} and modified in ${g}. Version ${g} of ${a} left in tree.`),c&&r.push(U(a,u,c.mode,1)),r.push(U(a,d,l.mode,2)),i.set(a,{hash:d,mode:l.mode});return}if(u===null&&d!==null&&h!==null){if(d===h){r.push(U(a,d,l.mode));return}o(a,`Auto-merging ${a}`,0);let m=await D(t,d),g=await D(t,h);if(X(m)||X(g)){s.push({path:a,reason:"add-add"}),o(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),o(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(U(a,d,l.mode,2)),r.push(U(a,h,f.mode,3)),i.set(a,{hash:d,mode:l.mode});return}let p=Y(""),b=Y(m),k=Y(g),v=Ue(b,p,k,{conflictStyle:n?.conflictStyle});if(!v.conflict){let I=await Pt(t,v.result);r.push(U(a,I,l.mode));return}s.push({path:a,reason:"add-add"}),o(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(U(a,d,l.mode,2)),r.push(U(a,h,f.mode,3));let j=ye(m,"",g,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),R=await B(t,"blob",de.encode(j));i.set(a,{hash:R,mode:l.mode});return}if(u!==null&&d!==null&&h!==null){if(d===u){r.push(U(a,h,f.mode));return}if(h===u){r.push(U(a,d,l.mode));return}if(d===h){r.push(U(a,d,l.mode));return}if(o(a,`Auto-merging ${a}`,0),oe(c.mode)||oe(l.mode)||oe(f.mode)){s.push({path:a,reason:"content"}),o(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(U(a,u,c.mode,1)),r.push(U(a,d,l.mode,2)),r.push(U(a,h,f.mode,3)),i.set(a,{hash:d,mode:l.mode});return}let m=await D(t,u),g=await D(t,d),p=await D(t,h);if(X(g)||X(p)||X(m)){s.push({path:a,reason:"content"}),o(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),o(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(U(a,u,c.mode,1)),r.push(U(a,d,l.mode,2)),r.push(U(a,h,f.mode,3)),i.set(a,{hash:d,mode:l.mode});return}let b=Y(m),k=Y(g),v=Y(p),j=Ue(k,b,v,{conflictStyle:n?.conflictStyle});if(j.conflict){let R=e.pathnames[1],I=e.pathnames[2],w=R!==a||I!==a,C={path:a,reason:"content"};w&&(R!==a&&(C.oursOrigPath=R),I!==a&&(C.theirsOrigPath=I)),s.push(C),o(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(U(a,u,c.mode,1)),r.push(U(a,d,l.mode,2)),r.push(U(a,h,f.mode,3));let x=w?`${n?.a??"HEAD"}:${R}`:n?.a??"HEAD",P=w?`${n?.b??"theirs"}:${I}`:n?.b??"theirs",O=ye(g,m,p,{a:x,b:P,conflictStyle:n?.conflictStyle}),$=await B(t,"blob",de.encode(O));i.set(a,{hash:$,mode:l.mode})}else{let R=await Pt(t,j.result);r.push(U(a,R,l.mode))}return}}var wi=200;async function Zn(t,e,n,r,s){let o=await Promise.all(r.map(async f=>({hash:f,timestamp:(await A(t,f)).committer.timestamp})));o.sort((f,u)=>f.timestamp-u.timestamp);let i=o.map(f=>f.hash),a=i[0],c=a,l=(await A(t,a)).tree;for(let f=1;f<i.length;f++){let u=i[f],d=(await A(t,u)).tree,h=null;if(s>=wi)h=l;else{let p=await He(t,c,u);p.length===0?h=null:p.length===1?h=(await A(t,p[0])).tree:h=await Zn(t,c,u,p,s+1)}let m=await Pe(t,h,l,d);l=await Ii(t,m,s);let g=Ae({type:"commit",tree:l,parents:[c,u],author:Fn,committer:Fn,message:"merged common ancestors"});c=await B(t,"commit",g)}return l}async function Ii(t,e,n){let r=e.entries.filter(a=>a.stage===0),s=new Map;for(let a of e.entries)a.stage>0&&s.set(`${a.path}\0${a.stage}`,a);let o=(a,c)=>s.get(`${a}\0${c}`),i={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of e.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let f=o(a.path,1);if(f){r.push({...f,stage:0});continue}}if(a.reason==="rename-rename"){let f=a.oursPath??a.path,u=a.theirsPath??a.path,d=o(a.path,1),h=o(f,2),m=o(u,3);if(h&&m){let g=Re.decode((await F(t,h.hash)).content),p=Re.decode((await F(t,m.hash)).content),b=d?Re.decode((await F(t,d.hash)).content):"",k=8+n*2,v=i.a??"Temporary merge branch 1",j=i.b??"Temporary merge branch 2",R=ye(g,b,p,{a:`${v}:${f}`,o:i.o,b:`${j}:${u}`,markerSize:k}),I=await B(t,"blob",de.encode(R));r.push({path:f,mode:h.mode,hash:I,stage:0,stat:ce()}),r.push({path:u,mode:m.mode,hash:I,stage:0,stat:ce()});continue}else if(h){r.push({...h,stage:0});continue}}let c=o(a.path,2),l=o(a.path,3);if(c&&l&&(a.reason==="content"||a.reason==="add-add")){let f=Re.decode((await F(t,c.hash)).content),u=Re.decode((await F(t,l.hash)).content),d=a.reason==="content"?o(a.path,1):null,h=d?Re.decode((await F(t,d.hash)).content):"",m=a.oursOrigPath||a.theirsOrigPath,g=i.a??"Temporary merge branch 1",p=i.b??"Temporary merge branch 2",b=m?`${g}:${a.oursOrigPath??a.path}`:g,k=m?`${p}:${a.theirsOrigPath??a.path}`:p,v=ye(f,h,u,{a:b,o:i.o,b:k,markerSize:i.markerSize}),j=await B(t,"blob",de.encode(v));r.push({path:a.path,mode:c.mode,hash:j,stage:0,stat:ce()})}else c?r.push({...c,stage:0}):l&&r.push({...l,stage:0})}return r.sort((a,c)=>Me(a.path,c.path)),ht(t,r)}async function Pt(t,e){let n=e.map(Ot);if(n.length===0)return B(t,"blob",de.encode(""));let o=(e[e.length-1]??"").endsWith("\0")?n.join(`
|
|
25
|
+
`)}function q(t){if(t==="")return[];let e=t.split(`
|
|
26
|
+
`);if(e[e.length-1]==="")e.pop();else{let n=e[e.length-1]??"";e[e.length-1]=`${n}\0`}return e}function Pt(t){return t.endsWith("\0")?t.slice(0,-1):t}function qn(t,e){if(t.length!==e.length)return!1;for(let n=0;n<t.length;n++)if(t[n]!==e[n])return!1;return!0}var ke=new TextDecoder,me=new TextEncoder,Xn={name:"virtual",email:"virtual@merge",timestamp:0,timezone:"+0000"};async function Se(t,e,n,r,s){let{paths:i,baseMap:o,oursMap:a,theirsMap:c}=await Ei(t,e,n,r),l=await xi(t,i,o,a,c,s);return Ri(t,i,s,l)}async function rr(t,e,n,r){let s=await Ne(t,e,n),i=await A(t,e),o=await A(t,n);if(s.length===0)return{...await Se(t,null,i.tree,o.tree,r),baseTree:null};if(s.length===1){let l=await A(t,s[0]);return{...await Se(t,l.tree,i.tree,o.tree,r),baseTree:l.tree}}let a=await ir(t,e,n,s,1);return{...await Se(t,a,i.tree,o.tree,r),baseTree:a}}async function Ei(t,e,n,r){let s=await fe(t,e),i=await fe(t,n),o=await fe(t,r),a=new Set;for(let l of s.keys())a.add(l);for(let l of i.keys())a.add(l);for(let l of o.keys())a.add(l);let c=new Map;for(let l of a){let f=s.get(l)??null,u=i.get(l)??null,d=o.get(l)??null,h=f?{hash:f.hash,mode:f.mode}:null,m=u?{hash:u.hash,mode:u.mode}:null,g=d?{hash:d.hash,mode:d.mode}:null,p=(f?1:0)|(u?2:0)|(d?4:0),b=f?.hash??null,P=u?.hash??null,C=d?.hash??null,v=0;b!==null&&b===P&&(v|=3),b!==null&&b===C&&(v|=5),P!==null&&P===C&&(v|=6);let R={path:l,stages:[h,m,g],pathnames:[l,l,l],filemask:p,matchMask:v,merged:{result:null,clean:!1},pathConflict:!1};if(Ii(R)){c.set(l,R);continue}c.set(l,R)}return{paths:c,baseMap:s,oursMap:i,theirsMap:o}}function Ii(t){let[e,n,r]=t.stages,s=e?.hash??null,i=n?.hash??null,o=r?.hash??null;return i===s&&o===s?(n?t.merged={result:{hash:i,mode:n.mode},clean:!0}:t.merged={result:null,clean:!0},!0):i===o&&i!==null?(t.merged={result:{hash:i,mode:n.mode},clean:!0},!0):i===null&&o===null?(t.merged={result:null,clean:!0},!0):o===s&&i!==s?(n?t.merged={result:{hash:i,mode:n.mode},clean:!0}:t.merged={result:null,clean:!0},!0):i===s&&o!==s?(r?t.merged={result:{hash:o,mode:r.mode},clean:!0}:t.merged={result:null,clean:!0},!0):!1}async function xi(t,e,n,r,s,i){let o={entries:[],conflicts:[],msgBuf:[],worktreeBlobs:new Map},a=[],c=[];for(let[I,y]of n)r.has(I)||a.push({path:I,status:"deleted",oldHash:y.hash,oldMode:y.mode}),s.has(I)||c.push({path:I,status:"deleted",oldHash:y.hash,oldMode:y.mode});for(let[I,y]of r)n.has(I)||a.push({path:I,status:"added",newHash:y.hash,newMode:y.mode});for(let[I,y]of s)n.has(I)||c.push({path:I,status:"added",newHash:y.hash,newMode:y.mode});let l=await ye(t,a),f=await ye(t,c);if(l.renames.length===0&&f.renames.length===0)return o;let u=new Map,d=new Map;for(let I of l.renames)u.set(I.oldPath,I);for(let I of f.renames)d.set(I.oldPath,I);let h=new Set;for(let[I]of r)!n.has(I)&&s.has(I)&&h.add(I);let m=new Set,g=i?.a??"HEAD",p=i?.b??"theirs";function b(I,y,k=0){o.msgBuf.push({sortKey:I,subOrder:k,text:y})}for(let I of[...n.keys()].sort()){let y=u.get(I),k=d.get(I);if(!y&&!k)continue;let M=n.get(I);if(m.add(I),y&&k)if(m.add(y.newPath),m.add(k.newPath),y.newPath===k.newPath){let L=r.get(y.newPath),j=s.get(k.newPath);if(L.hash===j.hash)o.entries.push(K(y.newPath,L));else{let U=Tt(e,y.newPath);U.stages=[{hash:M.hash,mode:M.mode},{hash:L.hash,mode:L.mode},{hash:j.hash,mode:j.mode}],U.pathnames=[I,y.newPath,k.newPath],U.filemask=7,U.merged={result:null,clean:!1}}}else{let L=r.get(y.newPath),j=s.get(k.newPath),U=await sr(t,M,L,j,i);U.conflict&&b(I,`Auto-merging ${I}`,-1),o.conflicts.push({path:I,reason:"rename-rename",oursPath:y.newPath,theirsPath:k.newPath}),b(I,`CONFLICT (rename/rename): ${I} renamed to ${y.newPath} in ${g} and to ${k.newPath} in ${p}.`),o.entries.push(K(I,M,1)),o.entries.push(W(y.newPath,L.mode,U.hash,2)),o.entries.push(W(k.newPath,j.mode,U.hash,3)),o.worktreeBlobs.set(y.newPath,{hash:U.hash,mode:L.mode}),o.worktreeBlobs.set(k.newPath,{hash:U.hash,mode:j.mode})}else if(y){m.add(y.newPath);let L=s.get(I),j=r.get(y.newPath),U=h.has(y.newPath);if(L)if(U)await nr(t,o,y.newPath,I,M,j,L,r,s,!1,i);else if(L.hash===M.hash&&j.hash===M.hash)o.entries.push(K(y.newPath,j));else if(L.hash===M.hash)o.entries.push(K(y.newPath,j));else if(j.hash===M.hash)o.entries.push(W(y.newPath,j.mode,L.hash));else{let G=Tt(e,y.newPath);G.stages=[{hash:M.hash,mode:M.mode},{hash:j.hash,mode:j.mode},{hash:L.hash,mode:L.mode}],G.pathnames=[I,y.newPath,I],G.filemask=7,G.merged={result:null,clean:!1}}else{let G=s.get(y.newPath);if(o.conflicts.push({path:y.newPath,reason:"rename-delete",deletedBy:"theirs",oldPath:I}),b(y.newPath,`CONFLICT (rename/delete): ${I} renamed to ${y.newPath} in ${g}, but deleted in ${p}.`),G){o.conflicts.push({path:y.newPath,reason:"add-add"}),b(y.newPath,`Auto-merging ${y.newPath}`,0),b(y.newPath,`CONFLICT (add/add): Merge conflict in ${y.newPath}`,1),o.entries.push(K(y.newPath,j,2)),o.entries.push(K(y.newPath,G,3));let tt=await et(t,j.hash,G.hash,j.mode,i);o.worktreeBlobs.set(y.newPath,{hash:tt,mode:j.mode})}else o.entries.push(W(y.newPath,M.mode,M.hash,1)),o.entries.push(K(y.newPath,j,2)),o.worktreeBlobs.set(y.newPath,{hash:j.hash,mode:j.mode}),j.hash!==M.hash&&b(y.newPath,`CONFLICT (modify/delete): ${y.newPath} deleted in ${p} and modified in ${g}. Version ${g} of ${y.newPath} left in tree.`,1)}}else if(k){m.add(k.newPath);let L=r.get(I),j=s.get(k.newPath),U=h.has(k.newPath);if(L)if(U)await nr(t,o,k.newPath,I,M,L,j,r,s,!0,i);else if(L.hash===M.hash&&j.hash===M.hash)o.entries.push(K(k.newPath,j));else if(L.hash===M.hash)o.entries.push(K(k.newPath,j));else if(j.hash===M.hash)o.entries.push(W(k.newPath,j.mode,L.hash));else{let G=Tt(e,k.newPath);G.stages=[{hash:M.hash,mode:M.mode},{hash:L.hash,mode:L.mode},{hash:j.hash,mode:j.mode}],G.pathnames=[I,I,k.newPath],G.filemask=7,G.merged={result:null,clean:!1}}else{let G=r.get(k.newPath);if(o.conflicts.push({path:k.newPath,reason:"rename-delete",deletedBy:"ours",oldPath:I}),b(k.newPath,`CONFLICT (rename/delete): ${I} renamed to ${k.newPath} in ${p}, but deleted in ${g}.`),G){o.conflicts.push({path:k.newPath,reason:"add-add"}),b(k.newPath,`Auto-merging ${k.newPath}`,0),b(k.newPath,`CONFLICT (add/add): Merge conflict in ${k.newPath}`,1),o.entries.push(K(k.newPath,G,2)),o.entries.push(K(k.newPath,j,3));let tt=await et(t,G.hash,j.hash,G.mode,i);o.worktreeBlobs.set(k.newPath,{hash:tt,mode:G.mode})}else o.entries.push(W(k.newPath,M.mode,M.hash,1)),o.entries.push(K(k.newPath,j,3)),o.worktreeBlobs.set(k.newPath,{hash:j.hash,mode:j.mode}),j.hash!==M.hash&&b(k.newPath,`CONFLICT (modify/delete): ${k.newPath} deleted in ${g} and modified in ${p}. Version ${p} of ${k.newPath} left in tree.`,1)}}}let P=new Set(l.renames.map(I=>I.newPath)),C=new Set(f.renames.map(I=>I.newPath)),v=Zn(n,r),R=Zn(n,s),w=Jn(v,s,n),E=Jn(R,r,n),S=Qn(l.renames,w),x=Qn(f.renames,E),T=er(S),O=er(x);for(let I of[...T.keys()])O.has(I)&&(T.delete(I),O.delete(I));let $=new Set(T.keys()),H=new Set(O.keys());if(O.size>0)for(let I of a){if(I.status!=="added"||P.has(I.path))continue;let y=tr(I.path,O,$);if(!y)continue;if(e.has(y)||n.has(y)||r.has(y)||s.has(y)){if(r.has(y)){b(y,`CONFLICT (implicit dir rename): Existing file/dir at ${y} in the way of implicit directory rename(s) putting the following path(s) there: ${I.path}.`,1);continue}let L=r.get(I.path),j=s.get(y)??n.get(y);o.entries.push(W(y,L.mode,L.hash,2)),j&&o.entries.push(W(y,j.mode,j.hash,3)),o.worktreeBlobs.set(y,{hash:L.hash,mode:L.mode}),o.conflicts.push({path:y,reason:"add-add"}),b(y,`CONFLICT (file location): ${I.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${y}.`,1);let U=e.get(I.path);U&&(U.merged={result:null,clean:!0}),m.add(I.path);continue}let k=r.get(I.path);o.entries.push(W(y,k.mode,k.hash,2)),o.worktreeBlobs.set(y,{hash:k.hash,mode:k.mode}),o.conflicts.push({path:y,reason:"directory-rename"}),b(y,`CONFLICT (file location): ${I.path} added in ${g} inside a directory that was renamed in ${p}, suggesting it should perhaps be moved to ${y}.`,1);let M=e.get(I.path);M&&(M.merged={result:null,clean:!0}),m.add(I.path)}if(T.size>0)for(let I of c){if(I.status!=="added"||C.has(I.path))continue;let y=tr(I.path,T,H);if(!y)continue;if(e.has(y)||n.has(y)||r.has(y)||s.has(y)){if(s.has(y)){b(y,`CONFLICT (implicit dir rename): Existing file/dir at ${y} in the way of implicit directory rename(s) putting the following path(s) there: ${I.path}.`,1);continue}let L=s.get(I.path),j=r.get(y)??n.get(y);j&&o.entries.push(W(y,j.mode,j.hash,2)),o.entries.push(W(y,L.mode,L.hash,3)),o.worktreeBlobs.set(y,{hash:L.hash,mode:L.mode}),o.conflicts.push({path:y,reason:"add-add"}),b(y,`CONFLICT (file location): ${I.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${y}.`,1);let U=e.get(I.path);U&&(U.merged={result:null,clean:!0}),m.add(I.path);continue}let k=s.get(I.path);o.entries.push(W(y,k.mode,k.hash,3)),o.worktreeBlobs.set(y,{hash:k.hash,mode:k.mode}),o.conflicts.push({path:y,reason:"directory-rename"}),b(y,`CONFLICT (file location): ${I.path} added in ${p} inside a directory that was renamed in ${g}, suggesting it should perhaps be moved to ${y}.`,1);let M=e.get(I.path);M&&(M.merged={result:null,clean:!0}),m.add(I.path)}let Q=new Set(o.entries.map(I=>I.path));for(let I of Q){let y=e.get(I);y&&(y.merged={result:null,clean:!0})}for(let I of m){if(Q.has(I))continue;let y=e.get(I);if(!y||y.merged.clean)continue;y.filemask===7&&!y.pathConflict||(y.merged={result:null,clean:!0})}return o}function Zn(t,e){let n=new Set;for(let i of t.keys()){let o=X(i);for(;o;)n.add(o),o=X(o)}let r=new Set;for(let i of e.keys()){let o=X(i);for(;o;)r.add(o),o=X(o)}let s=new Set;for(let i of n)r.has(i)||s.add(i);return s}function Jn(t,e,n){if(t.size===0)return t;let r=new Set;for(let s of e.keys()){if(n.has(s))continue;let i=X(s)??"";t.has(i)&&r.add(i)}for(let s of[...r]){let i=X(s);for(;i;)t.has(i)&&!r.has(i)&&r.add(i),i=X(i)}return r}function Qn(t,e){let n=new Map;for(let r of t){let s=X(r.oldPath),i=X(r.newPath),o=!0;for(;;){if(!o){let a=s.length+(s?1:0),c=i.length+(i?1:0),l=r.oldPath.slice(a,r.oldPath.indexOf("/",a)),f=r.newPath.slice(c,r.newPath.indexOf("/",c));if(l!==f)break}if(e.has(s)){let a=n.get(s);a||(a=new Map,n.set(s,a)),a.set(i,(a.get(i)??0)+1)}if(o=!1,!s||!i)break;s=X(s),i=X(i)}}return n}function er(t){let e=new Map;for(let[n,r]of t){let s=0,i=0,o=null;for(let[a,c]of r)c===s?i=s:c>s&&(s=c,o=a);s>0&&i!==s&&o!==null&&e.set(n,o)}return e}function tr(t,e,n){let r=X(t);for(;r;){let i=e.get(r);if(i!==void 0){if(n.has(i))return null;let o=t.slice(r.length+1);return i?`${i}/${o}`:o}r=X(r)}let s=e.get("");return s!==void 0&&!n.has(s)?`${s}/${t}`:null}function X(t){let e=t.lastIndexOf("/");return e===-1?"":t.slice(0,e)}async function nr(t,e,n,r,s,i,o,a,c,l=!1,f){let u=l?a.get(n):c.get(n),d=l?o:i;if(u.hash===d.hash){e.entries.push(W(n,u.mode,u.hash)),e.msgBuf.push({sortKey:r,subOrder:0,text:`Auto-merging ${r}`});return}let m=await sr(t,s,i,o,f,l?{oursPath:r,theirsPath:n}:{oursPath:n,theirsPath:r},8);if(u.hash===m.hash)e.entries.push(W(n,u.mode,m.hash));else if(e.conflicts.push({path:n,reason:"add-add"}),e.msgBuf.push({sortKey:n,subOrder:0,text:`Auto-merging ${n}`}),e.msgBuf.push({sortKey:n,subOrder:1,text:`CONFLICT (add/add): Merge conflict in ${n}`}),l){e.entries.push(K(n,u,2)),e.entries.push(W(n,o.mode,m.hash,3));let g=await et(t,u.hash,m.hash,u.mode,f);e.worktreeBlobs.set(n,{hash:g,mode:u.mode})}else{e.entries.push(W(n,i.mode,m.hash,2)),e.entries.push(K(n,u,3));let g=await et(t,m.hash,u.hash,i.mode,f);e.worktreeBlobs.set(n,{hash:g,mode:i.mode})}}async function sr(t,e,n,r,s,i,o){if(n.hash===e.hash)return{hash:r.hash,conflict:!1};if(r.hash===e.hash)return{hash:n.hash,conflict:!1};if(n.hash===r.hash)return{hash:n.hash,conflict:!1};if(oe(e.mode)||oe(n.mode)||oe(r.mode))return{hash:n.hash,conflict:!0};let a=await B(t,e.hash),c=await B(t,n.hash),l=await B(t,r.hash);if(Z(c)||Z(l)||Z(a))return{hash:n.hash,conflict:!0};let f=q(a),u=q(c),d=q(l),h=s?.conflictStyle,m=Fe(u,f,d,{conflictStyle:h});if(!m.conflict)return{hash:await kt(t,m.result),conflict:!1};let g=s?.a??"HEAD",p=s?.b??"theirs",b=i?.oursPath?`${g}:${i.oursPath}`:g,P=i?.theirsPath?`${p}:${i.theirsPath}`:p,C=be(c,a,l,{a:b,b:P,markerSize:o??7,conflictStyle:h});return{hash:await N(t,"blob",me.encode(C)),conflict:!0}}async function et(t,e,n,r,s){let i=await B(t,e),o=await B(t,n),a=be(i,"",o,{a:s?.a??"HEAD",b:s?.b??"theirs",conflictStyle:s?.conflictStyle});return N(t,"blob",me.encode(a))}function K(t,e,n=0){return W(t,e.mode,e.hash,n)}function W(t,e,n,r=0){return{path:t,mode:parseInt(e,8),hash:n,stage:r,stat:le()}}async function Ri(t,e,n,r){let s=[...r.entries],i=[...r.conflicts],o=[...r.msgBuf],a=new Map(r.worktreeBlobs);function c(h,m,g=0){o.push({sortKey:h,subOrder:g,text:m})}for(let h of[...e.keys()].sort()){let m=e.get(h);if(m.merged.clean){m.merged.result?.hash&&s.push(D(h,m.merged.result.hash,m.merged.result.mode));continue}await Oi(t,m,n,s,i,c,a)}o.sort((h,m)=>(h.sortKey<m.sortKey?-1:h.sortKey>m.sortKey?1:0)||h.subOrder-m.subOrder);let l=o.map(h=>h.text),f=[],u=new Set;for(let h of s)h.stage===0&&(f.push(h),u.add(h.path));for(let[h,m]of a)u.has(h)||f.push(D(h,m.hash,m.mode));f.sort((h,m)=>Be(h.path,m.path));let d=await mt(t,f);return{entries:s,conflicts:i,messages:l,resultTree:d}}async function Oi(t,e,n,r,s,i,o){let a=e.path,[c,l,f]=e.stages,u=c?.hash??null,d=l?.hash??null,h=f?.hash??null;if(d===null&&h!==null&&u!==null){s.push({path:a,reason:"delete-modify",deletedBy:"ours"});let m=n?.a??"HEAD",g=n?.b??"theirs";i(a,`CONFLICT (modify/delete): ${a} deleted in ${m} and modified in ${g}. Version ${g} of ${a} left in tree.`),c&&r.push(D(a,u,c.mode,1)),r.push(D(a,h,f.mode,3)),o.set(a,{hash:h,mode:f.mode});return}if(h===null&&d!==null&&u!==null){s.push({path:a,reason:"delete-modify",deletedBy:"theirs"});let m=n?.b??"theirs",g=n?.a??"HEAD";i(a,`CONFLICT (modify/delete): ${a} deleted in ${m} and modified in ${g}. Version ${g} of ${a} left in tree.`),c&&r.push(D(a,u,c.mode,1)),r.push(D(a,d,l.mode,2)),o.set(a,{hash:d,mode:l.mode});return}if(u===null&&d!==null&&h!==null){if(d===h){r.push(D(a,d,l.mode));return}i(a,`Auto-merging ${a}`,0);let m=await B(t,d),g=await B(t,h);if(Z(m)||Z(g)){s.push({path:a,reason:"add-add"}),i(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),i(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(D(a,d,l.mode,2)),r.push(D(a,h,f.mode,3)),o.set(a,{hash:d,mode:l.mode});return}let p=q(""),b=q(m),P=q(g),C=Fe(b,p,P,{conflictStyle:n?.conflictStyle});if(!C.conflict){let w=await kt(t,C.result);r.push(D(a,w,l.mode));return}s.push({path:a,reason:"add-add"}),i(a,`CONFLICT (add/add): Merge conflict in ${a}`,1),r.push(D(a,d,l.mode,2)),r.push(D(a,h,f.mode,3));let v=be(m,"",g,{a:n?.a??"HEAD",b:n?.b??"theirs",conflictStyle:n?.conflictStyle}),R=await N(t,"blob",me.encode(v));o.set(a,{hash:R,mode:l.mode});return}if(u!==null&&d!==null&&h!==null){if(d===u){r.push(D(a,h,f.mode));return}if(h===u){r.push(D(a,d,l.mode));return}if(d===h){r.push(D(a,d,l.mode));return}if(i(a,`Auto-merging ${a}`,0),oe(c.mode)||oe(l.mode)||oe(f.mode)){s.push({path:a,reason:"content"}),i(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(D(a,u,c.mode,1)),r.push(D(a,d,l.mode,2)),r.push(D(a,h,f.mode,3)),o.set(a,{hash:d,mode:l.mode});return}let m=await B(t,u),g=await B(t,d),p=await B(t,h);if(Z(g)||Z(p)||Z(m)){s.push({path:a,reason:"content"}),i(a,`warning: Cannot merge binary files: ${a} (${n?.a??"HEAD"} vs. ${n?.b??"theirs"})`,-1),i(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(D(a,u,c.mode,1)),r.push(D(a,d,l.mode,2)),r.push(D(a,h,f.mode,3)),o.set(a,{hash:d,mode:l.mode});return}let b=q(m),P=q(g),C=q(p),v=Fe(P,b,C,{conflictStyle:n?.conflictStyle});if(v.conflict){let R=e.pathnames[1],w=e.pathnames[2],E=R!==a||w!==a,S={path:a,reason:"content"};E&&(R!==a&&(S.oursOrigPath=R),w!==a&&(S.theirsOrigPath=w)),s.push(S),i(a,`CONFLICT (content): Merge conflict in ${a}`,1),r.push(D(a,u,c.mode,1)),r.push(D(a,d,l.mode,2)),r.push(D(a,h,f.mode,3));let x=E?`${n?.a??"HEAD"}:${R}`:n?.a??"HEAD",T=E?`${n?.b??"theirs"}:${w}`:n?.b??"theirs",O=be(g,m,p,{a:x,b:T,conflictStyle:n?.conflictStyle}),$=await N(t,"blob",me.encode(O));o.set(a,{hash:$,mode:l.mode})}else{let R=await kt(t,v.result);r.push(D(a,R,l.mode))}return}}var Pi=200;async function ir(t,e,n,r,s){let i=await Promise.all(r.map(async f=>({hash:f,timestamp:(await A(t,f)).committer.timestamp})));i.sort((f,u)=>f.timestamp-u.timestamp);let o=i.map(f=>f.hash),a=o[0],c=a,l=(await A(t,a)).tree;for(let f=1;f<o.length;f++){let u=o[f],d=(await A(t,u)).tree,h=null;if(s>=Pi)h=l;else{let p=await Ne(t,c,u);p.length===0?h=null:p.length===1?h=(await A(t,p[0])).tree:h=await ir(t,c,u,p,s+1)}let m=await Se(t,h,l,d);l=await Ti(t,m,s);let g=Me({type:"commit",tree:l,parents:[c,u],author:Xn,committer:Xn,message:"merged common ancestors"});c=await N(t,"commit",g)}return l}async function Ti(t,e,n){let r=e.entries.filter(a=>a.stage===0),s=new Map;for(let a of e.entries)a.stage>0&&s.set(`${a.path}\0${a.stage}`,a);let i=(a,c)=>s.get(`${a}\0${c}`),o={a:"Temporary merge branch 1",b:"Temporary merge branch 2",markerSize:7+n*2};for(let a of e.conflicts){if(a.reason==="delete-modify"||a.reason==="rename-delete"){let f=i(a.path,1);if(f){r.push({...f,stage:0});continue}}if(a.reason==="rename-rename"){let f=a.oursPath??a.path,u=a.theirsPath??a.path,d=i(a.path,1),h=i(f,2),m=i(u,3);if(h&&m){let g=ke.decode((await F(t,h.hash)).content),p=ke.decode((await F(t,m.hash)).content),b=d?ke.decode((await F(t,d.hash)).content):"",P=8+n*2,C=o.a??"Temporary merge branch 1",v=o.b??"Temporary merge branch 2",R=be(g,b,p,{a:`${C}:${f}`,o:o.o,b:`${v}:${u}`,markerSize:P}),w=await N(t,"blob",me.encode(R));r.push({path:f,mode:h.mode,hash:w,stage:0,stat:le()}),r.push({path:u,mode:m.mode,hash:w,stage:0,stat:le()});continue}else if(h){r.push({...h,stage:0});continue}}let c=i(a.path,2),l=i(a.path,3);if(c&&l&&(a.reason==="content"||a.reason==="add-add")){let f=ke.decode((await F(t,c.hash)).content),u=ke.decode((await F(t,l.hash)).content),d=a.reason==="content"?i(a.path,1):null,h=d?ke.decode((await F(t,d.hash)).content):"",m=a.oursOrigPath||a.theirsOrigPath,g=o.a??"Temporary merge branch 1",p=o.b??"Temporary merge branch 2",b=m?`${g}:${a.oursOrigPath??a.path}`:g,P=m?`${p}:${a.theirsOrigPath??a.path}`:p,C=be(f,h,u,{a:b,o:o.o,b:P,markerSize:o.markerSize}),v=await N(t,"blob",me.encode(C));r.push({path:a.path,mode:c.mode,hash:v,stage:0,stat:le()})}else c?r.push({...c,stage:0}):l&&r.push({...l,stage:0})}return r.sort((a,c)=>Be(a.path,c.path)),mt(t,r)}async function kt(t,e){let n=e.map(Pt);if(n.length===0)return N(t,"blob",me.encode(""));let i=(e[e.length-1]??"").endsWith("\0")?n.join(`
|
|
26
27
|
`):`${n.join(`
|
|
27
28
|
`)}
|
|
28
|
-
`;return B(t,"blob",de.encode(o))}function U(t,e,n,r=0){let s=typeof n=="string"?parseInt(n,8):n;return{path:t,mode:s,hash:e,stage:r,stat:ce()}}function Rt(t,e){let n=t.get(e);return n||(n={path:e,stages:[null,null,null],pathnames:[e,e,e],filemask:0,matchMask:0,merged:{result:null,clean:!1},pathConflict:!1},t.set(e,n)),n}async function Ei(t,e,n,r){let s=r?{a:r.ours??"ours",b:r.theirs??"theirs"}:void 0,o=await qn(t,e,n,s);return{treeHash:o.resultTree,clean:o.conflicts.length===0,conflicts:o.conflicts,messages:o.messages}}async function xi(t,e,n,r,s){let o=s?{a:s.ours??"ours",b:s.theirs??"theirs"}:void 0,i=await Pe(t,e,n,r,o);return{treeHash:i.resultTree,clean:i.conflicts.length===0,conflicts:i.conflicts,messages:i.messages}}var Oi=new TextEncoder,Jn=new TextDecoder,ke=16877,tr=33188,Ri=33261,nr=40960;function K(t){let e=[];for(let n of t.split("/"))n==="."||n===""||(n===".."?e.pop():e.push(n));return"/"+e.join("/")}function Qn(t){let e=t.lastIndexOf("/");return e<=0?"/":t.slice(0,e)}function er(t){switch(t){case _.EXECUTABLE:return Ri;case _.SYMLINK:return nr;case _.DIRECTORY:return ke;default:return tr}}var Je=class{constructor(e,n,r="/"){this.objectStore=e;this.rootTreeHash=n;this.rootPath=r;let s=K(r);this.overlay.set(s,{type:"directory",mode:ke,mtime:this.epoch})}treeCache=new Map;overlay=new Map;removals=new Set;epoch=new Date(0);toRelative(e){let n=K(e),r=K(this.rootPath);if(n===r)return"";let s=r==="/"?"/":`${r}/`;return n.startsWith(s)?n.slice(s.length):null}async loadTreeDir(e){let n=this.treeCache.get(e);if(n)return n;if(e===""){let i=await this.objectStore.read(this.rootTreeHash);if(i.type!=="tree")return null;let a=ie(i.content);return this.treeCache.set("",a.entries),a.entries}let r=e.split("/"),s=await this.loadTreeDir("");if(!s)return null;let o="";for(let i of r){let a=s.find(u=>u.name===i);if(!a||a.mode!==_.DIRECTORY)return null;o=o?`${o}/${i}`:i;let c=this.treeCache.get(o);if(c){s=c;continue}let l=await this.objectStore.read(a.hash);if(l.type!=="tree")return null;let f=ie(l.content);this.treeCache.set(o,f.entries),s=f.entries}return s}async lookupTreeEntry(e){if(e==="")return null;let n=e.lastIndexOf("/"),r=n===-1?"":e.slice(0,n),s=n===-1?e:e.slice(n+1),o=await this.loadTreeDir(r);if(!o)return null;let i=o.find(a=>a.name===s);return i?{entry:i,dirEntries:o}:null}async isTreeDirectory(e){return e===""?!0:(await this.lookupTreeEntry(e))?.entry.mode===_.DIRECTORY}ensureOverlayParents(e){let n=Qn(e);n===K(this.rootPath)||n==="/"||this.overlay.has(n)||(this.ensureOverlayParents(n),this.overlay.set(n,{type:"directory",mode:ke,mtime:new Date}))}async readFile(e){return Jn.decode(await this.readFileBuffer(e))}async readFileBuffer(e){let n=K(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, open '${e}'`);let r=this.overlay.get(n);if(r){if(r.type!=="file")throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);return r.content}let s=this.toRelative(n);if(s===null||s==="")throw new Error(`ENOENT: no such file or directory, open '${e}'`);let o=await this.lookupTreeEntry(s);if(!o)throw new Error(`ENOENT: no such file or directory, open '${e}'`);if(o.entry.mode===_.DIRECTORY)throw new Error(`EISDIR: illegal operation on a directory, read '${e}'`);let i=await this.objectStore.read(o.entry.hash);if(i.type!=="blob")throw new Error(`ENOENT: no such file or directory, open '${e}'`);return i.content}async writeFile(e,n){let r=K(e);this.removals.delete(r),this.ensureOverlayParents(r),this.overlay.set(r,{type:"file",content:typeof n=="string"?Oi.encode(n):new Uint8Array(n),mode:tr,mtime:new Date})}async exists(e){let n=K(e);if(this.removals.has(n))return!1;if(this.overlay.has(n))return!0;let r=this.toRelative(n);return r===null?!1:r===""||await this.isTreeDirectory(r)?!0:await this.lookupTreeEntry(r)!==null}async stat(e){let n=K(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let r=this.overlay.get(n);if(r)return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:!1,mode:r.mode,size:r.type==="file"?r.content.byteLength:0,mtime:r.mtime};let s=this.toRelative(n);if(s===null)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);if(s==="")return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:ke,size:0,mtime:this.epoch};let o=await this.lookupTreeEntry(s);if(!o)throw new Error(`ENOENT: no such file or directory, stat '${e}'`);let{entry:i}=o,a=i.mode===_.DIRECTORY,c=i.mode===_.SYMLINK,l=0;return a||(l=(await this.objectStore.read(i.hash)).content.byteLength),{isFile:!a&&!c,isDirectory:a,isSymbolicLink:!1,mode:er(i.mode),size:l,mtime:this.epoch}}async lstat(e){let n=K(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);let r=this.overlay.get(n);if(r)return{isFile:r.type==="file",isDirectory:r.type==="directory",isSymbolicLink:r.type==="symlink",mode:r.mode,size:r.type==="file"?r.content.byteLength:r.type==="symlink"?r.target.length:0,mtime:r.mtime};let s=this.toRelative(n);if(s===null)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);if(s==="")return{isFile:!1,isDirectory:!0,isSymbolicLink:!1,mode:ke,size:0,mtime:this.epoch};let o=await this.lookupTreeEntry(s);if(!o)throw new Error(`ENOENT: no such file or directory, lstat '${e}'`);let{entry:i}=o,a=i.mode===_.DIRECTORY,c=i.mode===_.SYMLINK,l=0;return a||(l=(await this.objectStore.read(i.hash)).content.byteLength),{isFile:!a&&!c,isDirectory:a,isSymbolicLink:c,mode:er(i.mode),size:l,mtime:this.epoch}}async mkdir(e,n){let r=K(e);if(this.overlay.has(r)){if(this.overlay.get(r).type!=="directory")throw new Error(`EEXIST: file already exists, mkdir '${e}'`);if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let s=this.toRelative(r);if(s!==null&&!this.removals.has(r)&&(s===""||await this.isTreeDirectory(s))){if(!n?.recursive)throw new Error(`EEXIST: directory already exists, mkdir '${e}'`);return}let o=Qn(r);if(!(this.overlay.has(o)||await this.exists(o)))if(n?.recursive)await this.mkdir(o,{recursive:!0});else throw new Error(`ENOENT: no such file or directory, mkdir '${e}'`);this.removals.delete(r),this.overlay.set(r,{type:"directory",mode:ke,mtime:new Date})}async readdir(e){let n=K(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, scandir '${e}'`);let r=new Set,s=this.toRelative(n);if(s!==null){let i=await this.loadTreeDir(s);if(i)for(let a of i){let c=n==="/"?`/${a.name}`:`${n}/${a.name}`;this.removals.has(c)||r.add(a.name)}}let o=n==="/"?"/":`${n}/`;for(let i of this.overlay.keys())if(i!==n&&i.startsWith(o)){let c=i.slice(o.length).split("/")[0];c&&!this.removals.has(n==="/"?`/${c}`:`${n}/${c}`)&&r.add(c)}if(r.size===0){if(this.overlay.get(n)?.type==="directory")return[];if(s!==null&&(s===""||await this.isTreeDirectory(s)))return[];throw new Error(`ENOENT: no such file or directory, scandir '${e}'`)}return[...r].sort()}async rm(e,n){let r=K(e);if(!await this.exists(r)){if(n?.force)return;throw new Error(`ENOENT: no such file or directory, rm '${e}'`)}let o=r==="/"?"/":`${r}/`;if(n?.recursive)for(let i of[...this.overlay.keys()])i.startsWith(o)&&(this.overlay.delete(i),this.removals.add(i));if(this.overlay.delete(r),this.removals.add(r),n?.recursive){let i=this.toRelative(r);i!==null&&await this.markTreeChildrenRemoved(i,r)}}async markTreeChildrenRemoved(e,n){let r=await this.loadTreeDir(e);if(r)for(let s of r){let o=n==="/"?`/${s.name}`:`${n}/${s.name}`;if(this.removals.add(o),s.mode===_.DIRECTORY){let i=e?`${e}/${s.name}`:s.name;await this.markTreeChildrenRemoved(i,o)}}}async readlink(e){let n=K(e);if(this.removals.has(n))throw new Error(`ENOENT: no such file or directory, readlink '${e}'`);let r=this.overlay.get(n);if(r){if(r.type!=="symlink")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);return r.target}let s=this.toRelative(n);if(s===null||s==="")throw new Error(`EINVAL: invalid argument, readlink '${e}'`);let o=await this.lookupTreeEntry(s);if(!o||o.entry.mode!==_.SYMLINK)throw new Error(`EINVAL: invalid argument, readlink '${e}'`);let i=await this.objectStore.read(o.entry.hash);return Jn.decode(i.content)}async symlink(e,n){let r=K(n);if(await this.exists(r))throw new Error(`EEXIST: file already exists, symlink '${n}'`);this.ensureOverlayParents(r),this.removals.delete(r),this.overlay.set(r,{type:"symlink",target:e,mode:nr,mtime:new Date})}};var kt=class{constructor(e){this.inner=e}read(e){return this.inner.read(e)}write(e,n){throw new Error("cannot write: object store is read-only")}exists(e){return this.inner.exists(e)}ingestPack(e){throw new Error("cannot ingest pack: object store is read-only")}ingestPackStream(e){throw new Error("cannot ingest pack: object store is read-only")}findByPrefix(e){return this.inner.findByPrefix(e)}},Tt=class{constructor(e){this.inner=e}readRef(e){return this.inner.readRef(e)}writeRef(e,n){throw new Error("cannot write ref: ref store is read-only")}deleteRef(e){throw new Error("cannot delete ref: ref store is read-only")}listRefs(e){return this.inner.listRefs(e)}compareAndSwapRef(e,n,r){throw new Error("cannot update ref: ref store is read-only")}};function Pi(t){return{objectStore:new kt(t.objectStore),refStore:new Tt(t.refStore),hooks:t.hooks}}var Ct=class{constructor(e){this.inner=e}overlay=new Map;async read(e){let n=this.overlay.get(e);return n?{type:n.type,content:new Uint8Array(n.content)}:this.inner.read(e)}async write(e,n){let r=await Be(Xt(e,n));return this.overlay.has(r)||await this.inner.exists(r).catch(()=>!1)||this.overlay.set(r,{type:e,content:new Uint8Array(n)}),r}async exists(e){return this.overlay.has(e)?!0:this.inner.exists(e)}async ingestPack(e){if(e.byteLength<32)return 0;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==1346454347)throw new Error(`invalid pack signature: 0x${r.toString(16)} (expected 0x5041434b)`);let s=n.getUint32(4);if(s!==2)throw new Error(`unsupported pack version: ${s}`);if(n.getUint32(8)===0)return 0;let i=this.overlay,a=this.inner,c=await Yt(e,async l=>{let f=i.get(l);if(f)return{type:f.type,content:new Uint8Array(f.content)};try{return await a.read(l)}catch{return null}});for(let l of c)i.has(l.hash)||i.set(l.hash,{type:l.type,content:l.content});return c.length}async ingestPackStream(e){let n=this.overlay,r=0;for await(let s of e)n.has(s.hash)||n.set(s.hash,{type:s.type,content:s.content}),r++;return r}async findByPrefix(e){let n=await this.inner.findByPrefix(e),r=[];for(let o of this.overlay.keys())o.startsWith(e)&&r.push(o);return[...new Set([...n,...r])]}},St=class{constructor(e){this.inner=e}overlay=new Map;deleted=new Set;async readRef(e){if(this.deleted.has(e))return null;let n=this.overlay.get(e);return n||this.inner.readRef(e)}async writeRef(e,n){this.deleted.delete(e),this.overlay.set(e,rn(n))}async deleteRef(e){this.overlay.delete(e),this.deleted.add(e)}async listRefs(e){let n=await this.inner.listRefs(e),r=new Map;for(let s of n)this.deleted.has(s.name)||r.set(s.name,s);for(let[s,o]of this.overlay)if(!(e&&!s.startsWith(e))){if(o.type==="direct")r.set(s,{name:s,hash:o.hash});else if(o.type==="symbolic"){let i=await this.resolveSymbolic(o.target);i&&r.set(s,{name:s,hash:i})}}return[...r.values()]}async compareAndSwapRef(e,n,r){let s=await this.readRef(e),o=null;if(s&&(s.type==="direct"?o=s.hash:s.type==="symbolic"&&(o=await this.resolveSymbolic(s.target))),n===null){if(s!==null)return!1}else if(o!==n)return!1;return r===null?(this.overlay.delete(e),this.deleted.add(e)):(this.deleted.delete(e),this.overlay.set(e,r)),!0}async resolveSymbolic(e,n=0){if(n>10)return null;let r=await this.readRef(e);return r?r.type==="direct"?r.hash:r.type==="symbolic"?this.resolveSymbolic(r.target,n+1):null:null}};function vt(t){return{objectStore:new Ct(t.objectStore),refStore:new St(t.refStore),hooks:t.hooks}}async function jt(t,e){let n=await _e(t,e);if(n)return n;throw new Error(`ref or commit '${e}' not found`)}async function rr(t,e,n,r){let s=new Set,o=0;for(let i of e){if(!an(i.path))throw new Error(`refusing to check out unsafe path '${i.path}'`);let a=Ie(r,i.path);if(!cn(r,a))throw new Error(`refusing to check out path outside target directory: '${i.path}'`);let c=qt(a);if(c!==r&&!s.has(c)&&(await n.mkdir(c,{recursive:!0}),s.add(c)),oe(i.mode)){let l=await D(t,i.hash);if(!ln(l))throw new Error(`refusing to create symlink with unsafe target '${l}'`);n.symlink?await n.symlink(l,a):await n.writeFile(a,l)}else{let l=await se(t,i.hash);await n.writeFile(a,l)}o++}return o}function sr(t){return fn(t.map(e=>({path:e.path,mode:parseInt(e.mode,8),hash:e.hash,stage:0,stat:ce()})))}async function ki(t,e,n,r="/"){let s=await jt(t,e),o=await A(t,s),i=await ne(t,o.tree),a=await rr(t,i,n,r);return{commitHash:s,treeHash:o.tree,filesWritten:a}}async function Ti(t,e,n){let r=n?.workTree??"/",s=n?.gitDir??Ie(r,".git"),o=n?.ref??"HEAD";await e.mkdir(s,{recursive:!0});let i=await jt(t,o),a=await A(t,i),c=await ne(t,a.tree),l={...t,fs:e,gitDir:s,workTree:r},f=await rr(t,c,e,r);return await Fe(l,sr(c)),{ctx:l,commitHash:i,treeHash:a.tree,filesWritten:f}}async function Ci(t,e){let n=vt(t),r=e?.workTree??"/",s=e?.gitDir??Ie(r,".git"),o=e?.ref??"HEAD",i=await jt(n,o),a=await A(n,i),c=new Je(n.objectStore,a.tree,r),l="refs/heads/main";await n.refStore.writeRef("HEAD",{type:"symbolic",target:l}),await n.refStore.writeRef(l,{type:"direct",hash:i});let f={...n,fs:c,gitDir:s,workTree:r},u=await ne(n,a.tree);return await Fe(f,sr(u)),{ctx:f,commitHash:i,treeHash:a.tree,filesWritten:0}}export{qs as blame,ft as branchNameFromRef,Dn as buildCommit,oi as commit,Ys as countAheadBehind,ii as createAnnotatedTag,si as createCommit,Ci as createSandboxWorktree,Ti as createWorktree,Qs as diffCommits,_s as diffTrees,ki as extractTree,Ks as findMergeBases,Fs as flattenTree,ei as formatDiff,Ws as getChangedFiles,zs as getNewCommits,cs as grep,Vs as isAncestor,Jr as listBranches,Qr as listTags,Ei as mergeTrees,xi as mergeTreesFromTreeHashes,vt as overlayRepo,ns as readBlob,rs as readBlobText,ts as readCommit,is as readFileAtCommit,es as readHead,ss as readTree,Pi as readonlyRepo,Zr as resolveRef,sn as tagNameFromRef,Nn as updateTree,ti as walkCommitHistory,ci as writeBlob,ai as writeTree};
|
|
29
|
+
`;return N(t,"blob",me.encode(i))}function D(t,e,n,r=0){let s=typeof n=="string"?parseInt(n,8):n;return{path:t,mode:s,hash:e,stage:r,stat:le()}}function Tt(t,e){let n=t.get(e);return n||(n={path:e,stages:[null,null,null],pathnames:[e,e,e],filemask:0,matchMask:0,merged:{result:null,clean:!1},pathConflict:!1},t.set(e,n)),n}async function ki(t,e,n,r){let s=r?{a:r.ours??"ours",b:r.theirs??"theirs"}:void 0,i=await rr(t,e,n,s);return{treeHash:i.resultTree,clean:i.conflicts.length===0,conflicts:i.conflicts,messages:i.messages}}async function Si(t,e,n,r,s){let i=s?{a:s.ours??"ours",b:s.theirs??"theirs"}:void 0,o=await Se(t,e,n,r,i);return{treeHash:o.resultTree,clean:o.conflicts.length===0,conflicts:o.conflicts,messages:o.messages}}var St=class{constructor(e){this.inner=e}read(e){return this.inner.read(e)}write(e,n){throw new Error("cannot write: object store is read-only")}exists(e){return this.inner.exists(e)}ingestPack(e){throw new Error("cannot ingest pack: object store is read-only")}ingestPackStream(e){throw new Error("cannot ingest pack: object store is read-only")}findByPrefix(e){return this.inner.findByPrefix(e)}},Ct=class{constructor(e){this.inner=e}readRef(e){return this.inner.readRef(e)}writeRef(e,n){throw new Error("cannot write ref: ref store is read-only")}deleteRef(e){throw new Error("cannot delete ref: ref store is read-only")}listRefs(e){return this.inner.listRefs(e)}compareAndSwapRef(e,n,r){throw new Error("cannot update ref: ref store is read-only")}};function Ci(t){return{objectStore:new St(t.objectStore),refStore:new Ct(t.refStore),hooks:t.hooks}}var vt=class{constructor(e){this.inner=e}overlay=new Map;async read(e){let n=this.overlay.get(e);return n?{type:n.type,content:new Uint8Array(n.content)}:this.inner.read(e)}async write(e,n){let r=await We(Jt(e,n));return this.overlay.has(r)||await this.inner.exists(r).catch(()=>!1)||this.overlay.set(r,{type:e,content:new Uint8Array(n)}),r}async exists(e){return this.overlay.has(e)?!0:this.inner.exists(e)}async ingestPack(e){if(e.byteLength<32)return 0;let n=new DataView(e.buffer,e.byteOffset,e.byteLength),r=n.getUint32(0);if(r!==1346454347)throw new Error(`invalid pack signature: 0x${r.toString(16)} (expected 0x5041434b)`);let s=n.getUint32(4);if(s!==2)throw new Error(`unsupported pack version: ${s}`);if(n.getUint32(8)===0)return 0;let o=this.overlay,a=this.inner,c=await Xt(e,async l=>{let f=o.get(l);if(f)return{type:f.type,content:new Uint8Array(f.content)};try{return await a.read(l)}catch{return null}});for(let l of c)o.has(l.hash)||o.set(l.hash,{type:l.type,content:l.content});return c.length}async ingestPackStream(e){let n=this.overlay,r=0;for await(let s of e)n.has(s.hash)||n.set(s.hash,{type:s.type,content:s.content}),r++;return r}async findByPrefix(e){let n=await this.inner.findByPrefix(e),r=[];for(let i of this.overlay.keys())i.startsWith(e)&&r.push(i);return[...new Set([...n,...r])]}},jt=class{constructor(e){this.inner=e}overlay=new Map;deleted=new Set;async readRef(e){if(this.deleted.has(e))return null;let n=this.overlay.get(e);return n||this.inner.readRef(e)}async writeRef(e,n){this.deleted.delete(e),this.overlay.set(e,on(n))}async deleteRef(e){this.overlay.delete(e),this.deleted.add(e)}async listRefs(e){let n=await this.inner.listRefs(e),r=new Map;for(let s of n)this.deleted.has(s.name)||r.set(s.name,s);for(let[s,i]of this.overlay)if(!(e&&!s.startsWith(e))){if(i.type==="direct")r.set(s,{name:s,hash:i.hash});else if(i.type==="symbolic"){let o=await this.resolveSymbolic(i.target);o&&r.set(s,{name:s,hash:o})}}return[...r.values()]}async compareAndSwapRef(e,n,r){let s=await this.readRef(e),i=null;if(s&&(s.type==="direct"?i=s.hash:s.type==="symbolic"&&(i=await this.resolveSymbolic(s.target))),n===null){if(s!==null)return!1}else if(i!==n)return!1;return r===null?(this.overlay.delete(e),this.deleted.add(e)):(this.deleted.delete(e),this.overlay.set(e,r)),!0}async resolveSymbolic(e,n=0){if(n>10)return null;let r=await this.readRef(e);return r?r.type==="direct"?r.hash:r.type==="symbolic"?this.resolveSymbolic(r.target,n+1):null:null}};function At(t){return{objectStore:new vt(t.objectStore),refStore:new jt(t.refStore),hooks:t.hooks}}async function $t(t,e){let n=await Ie(t,e);if(n)return n;throw new Error(`ref or commit '${e}' not found`)}function or(t){return hn(t.map(e=>({path:e.path,mode:parseInt(e.mode,8),hash:e.hash,stage:0,stat:le()})))}async function vi(t,e,n,r="/"){let s=await $t(t,e),i=await A(t,s),o=await Y(t,i.tree),a=await De(t,o,n,r);return{commitHash:s,treeHash:i.tree,filesWritten:a}}async function ji(t,e,n){let r=n?.workTree??"/",s=n?.gitDir??pe(r,".git"),i=n?.ref??"HEAD";await e.mkdir(s,{recursive:!0});let o=await $t(t,i),a=await A(t,o),c=await Y(t,a.tree),l={...t,fs:e,gitDir:s,workTree:r},f=await De(t,c,e,r);return await Ve(l,or(c)),{ctx:l,commitHash:o,treeHash:a.tree,filesWritten:f}}async function Ai(t,e){let n=At(t),r=e?.workTree??"/",s=e?.gitDir??pe(r,".git"),i=e?.ref??"HEAD",o=await $t(n,i),a=await A(n,o),c=new Re(n.objectStore,a.tree,r),l="refs/heads/main";await n.refStore.writeRef("HEAD",{type:"symbolic",target:l}),await n.refStore.writeRef(l,{type:"direct",hash:o});let f={...n,fs:c,gitDir:s,workTree:r},u=await Y(n,a.tree);return await Ve(f,or(u)),{ctx:f,commitHash:o,treeHash:a.tree,filesWritten:0}}async function ar(t,e,n,r,s){let i=[],o=new Map;for await(let p of ce(t,e,{exclude:n})){let b=s?p.commit.parents.slice(0,1):p.commit.parents;i.push({hash:p.hash,subject:gn(p.commit.message)}),o.set(p.hash,b)}let a=i.length;if(a===0)return null;if(a===1)return{hash:i[0].hash,subject:i[0].subject,remaining:0,steps:0,found:!0,onlySkippedLeft:!1};let c=new Set(i.map(p=>p.hash)),l=new Map;for(let p of i){let b=new Set,P=[p.hash],C=0;for(;C<P.length;){let v=P[C++];if(b.has(v)||!c.has(v))continue;b.add(v);let R=o.get(v);if(R)for(let w of R)!b.has(w)&&c.has(w)&&P.push(w)}l.set(p.hash,b.size)}let f=i[0].hash,u=a;for(let p of i){if(r.has(p.hash))continue;let b=l.get(p.hash)??0,P=Math.abs(2*b-a);P<u&&(u=P,f=p.hash)}let d=!1;if(u===a){d=!0;for(let p of i){let b=l.get(p.hash)??0,P=Math.abs(2*b-a);P<u&&(u=P,f=p.hash)}}let h=i.find(p=>p.hash===f),m=$i(a),g=Mi(a);return{hash:h.hash,subject:h.subject,remaining:m,steps:g,found:!1,onlySkippedLeft:d}}function $i(t){return Math.floor((t-1)/2)}function Mi(t){return t<=1?0:Math.ceil(Math.log2(t))}async function cr(t,e){let n=await Ie(t,e);if(!n)throw new Error(`revision '${e}' not found`);return n}async function Li(t,e){let n=await cr(t,e.bad),r=Array.isArray(e.good)?e.good:[e.good],s=[];for(let c of r)s.push(await cr(t,c));let i=new Set,o=e.firstParent??!1,a=0;for(;;){let c=await ar(t,n,s,i,o);if(!c)return{found:!1,reason:"no-testable-commits"};if(c.found)return{found:!0,hash:c.hash,stepsTaken:a};if(c.onlySkippedLeft)return{found:!1,reason:"all-skipped",candidates:[...i,n]};let l=await A(t,c.hash),f=Ue(t,l.tree),u=await e.test(c.hash,f);a++;let d;u==="skip"?(d="skip",i.add(c.hash)):u===!0?(d="good",s.push(c.hash)):(d="bad",n=c.hash),e.onStep?.({hash:c.hash,subject:c.subject,verdict:d,remaining:c.remaining,estimatedSteps:c.steps,stepNumber:a})}}export{Li as bisect,ti as blame,ht as branchNameFromRef,zn as buildCommit,hi as commit,ei as countAheadBehind,ui as createAnnotatedTag,fi as createCommit,Ai as createSandboxWorktree,Ue as createTreeAccessor,ji as createWorktree,ii as diffCommits,qs as diffTrees,vi as extractTree,Qs as findMergeBases,Ys as flattenTree,oi as formatDiff,Xs as getChangedFiles,Zs as getNewCommits,ms as grep,Js as isAncestor,ss as listBranches,is as listTags,ki as mergeTrees,Si as mergeTreesFromTreeHashes,At as overlayRepo,cs as readBlob,ls as readBlobText,as as readCommit,us as readFileAtCommit,os as readHead,fs as readTree,Ci as readonlyRepo,rs as resolveRef,an as tagNameFromRef,Kn as updateTree,ai as walkCommitHistory,mi as writeBlob,di as writeTree};
|
package/dist/server/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as ObjectId, W as RawObject, X as Ref, g as GitRepo, $ as Rejection, N as NetworkPolicy } from '../hooks-CimfP56a.js';
|
|
2
|
-
import {
|
|
2
|
+
import { C as CommitOptions, a as CommitResult } from '../writing-CF-eYohc.js';
|
|
3
3
|
|
|
4
4
|
/** Shallow boundary delta: what to add/remove from `.git/shallow`. */
|
|
5
5
|
interface ShallowUpdate {
|
|
@@ -201,4 +201,4 @@ interface TreeUpdate {
|
|
|
201
201
|
*/
|
|
202
202
|
declare function updateTree(repo: GitRepo, treeHash: string, updates: TreeUpdate[]): Promise<string>;
|
|
203
203
|
|
|
204
|
-
export { type BuildCommitOptions as B, type
|
|
204
|
+
export { type BuildCommitOptions as B, type CommitOptions as C, type TreeEntryInput as T, type CommitResult as a, type CommitAuthor as b, type CommitIdentity as c, type CreateAnnotatedTagOptions as d, type CreateCommitOptions as e, type TreeUpdate as f, buildCommit as g, commit as h, createAnnotatedTag as i, createCommit as j, writeTree as k, updateTree as u, writeBlob as w };
|